Skip to content

Commit

Permalink
* trunk/common.mk, goruby.c, golf_prelude.rb: for golfers.
Browse files Browse the repository at this point in the history
* trunk/main.c (main): hook for embedding applications.

* trunk/tool/compile_prelude.rb: can change initialize function name.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14676 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu committed Dec 25, 2007
1 parent 319bcad commit 4496da1
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 3 deletions.
8 changes: 8 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Tue Dec 25 16:04:28 2007 Nobuyoshi Nakada <[email protected]>

* trunk/common.mk, goruby.c, golf_prelude.rb: for golfers.

* trunk/main.c (main): hook for embedding applications.

* trunk/tool/compile_prelude.rb: can change initialize function name.

Tue Dec 25 15:59:51 2007 Nobuyoshi Nakada <[email protected]>

* encoding.c (rb_enc_register): do not use based_encoding to check if
Expand Down
19 changes: 17 additions & 2 deletions common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ LIBRUBY_EXTS = ./.libruby-with-ext.time
RDOCOUT = $(EXTOUT)/rdoc

DMYEXT = dmyext.$(OBJEXT)
MAINOBJ = main.$(OBJEXT)
NORMALMAINOBJ = main.$(OBJEXT) revision.$(OBJEXT)
MAINOBJ = $(NORMALMAINOBJ)
EXTOBJS =
DLDOBJS = $(DMYEXT)

Expand Down Expand Up @@ -79,6 +80,8 @@ OBJS = dln.$(OBJEXT) \
prelude.$(OBJEXT) \
$(COMMONOBJS)

GOLFOBJS = goruby.$(OBJEXT) golf_prelude.$(OBJEXT)

SCRIPT_ARGS = --dest-dir="$(DESTDIR)" \
--extout="$(EXTOUT)" \
--make="$(MAKE)" \
Expand All @@ -99,7 +102,13 @@ all: $(MKFILES) $(PREP) $(RBCONFIG) $(LIBRUBY) encs
@$(MINIRUBY) $(srcdir)/ext/extmk.rb $(EXTMK_ARGS)
prog: $(PROGRAM) $(WPROGRAM)

miniruby$(EXEEXT): config.status $(MAINOBJ) $(MINIOBJS) $(COMMONOBJS) $(DMYEXT) $(ARCHFILE)
miniruby$(EXEEXT): config.status $(NORMALMAINOBJ) $(MINIOBJS) $(COMMONOBJS) $(DMYEXT) $(ARCHFILE)

GORUBY = go$(RUBY_INSTALL_NAME)
golf: $(LIBRUBY) $(GOLFOBJS)
$(MAKE) $(MFLAGS) MAINOBJ="$(GOLFOBJS)" PROGRAM=$(GORUBY)$(EXEEXT) program

program: $(PROGRAM)

$(PROGRAM): $(LIBRUBY) $(MAINOBJ) $(OBJS) $(EXTOBJS) $(SETUP) $(PREP)

Expand Down Expand Up @@ -600,6 +609,9 @@ blockinlining.$(OBJEXT): {$(VPATH)}blockinlining.c \
id.$(OBJEXT): {$(VPATH)}id.c {$(VPATH)}ruby.h
miniprelude.$(OBJEXT): {$(VPATH)}miniprelude.c {$(VPATH)}ruby.h {$(VPATH)}vm_core.h
prelude.$(OBJEXT): {$(VPATH)}prelude.c {$(VPATH)}ruby.h {$(VPATH)}vm_core.h
golf_prelude.$(OBJEXT): {$(VPATH)}golf_prelude.c {$(VPATH)}ruby.h {$(VPATH)}vm_core.h
goruby.$(OBJEXT): {$(VPATH)}goruby.c {$(VPATH)}main.c {$(VPATH)}ruby.h {$(VPATH)}config.h \
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h

ascii.$(OBJEXT): {$(VPATH)}ascii.c {$(VPATH)}regenc.h \
{$(VPATH)}oniguruma.h {$(VPATH)}config.h {$(VPATH)}defines.h
Expand Down Expand Up @@ -650,10 +662,13 @@ miniprelude.c: $(srcdir)/tool/compile_prelude.rb $(srcdir)/prelude.rb
prelude.c: $(srcdir)/tool/compile_prelude.rb $(srcdir)/prelude.rb $(srcdir)/gem_prelude.rb $(RBCONFIG)
$(MINIRUBY) -I$(srcdir) -I$(srcdir)/lib -rrbconfig $(srcdir)/tool/compile_prelude.rb $(srcdir)/prelude.rb $(srcdir)/gem_prelude.rb $@

golf_prelude.c: $(srcdir)/tool/compile_prelude.rb $(srcdir)/prelude.rb $(srcdir)/golf_prelude.rb
$(BASERUBY) -I$(srcdir) -I$(srcdir)/lib -rrbconfig $(srcdir)/tool/compile_prelude.rb $(srcdir)/golf_prelude.rb $@

prereq: incs srcs preludes

preludes: {$(VPATH)}miniprelude.c
preludes: {$(srcdir)}golf_prelude.c

docs:
$(BASERUBY) -I$(srcdir) $(srcdir)/tool/makedocs.rb $(INSNS2VMOPT)
Expand Down
7 changes: 7 additions & 0 deletions golf_prelude.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Object
def method_missing m, *a, &b
r = /^#{m}/
t = (methods + private_methods).sort.find{|e|r=~e}
t ? __send__(t, *a, &b) : super
end
end
3 changes: 3 additions & 0 deletions goruby.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
void Init_golf(void);
#define RUBY_MAIN_INIT() Init_golf()
#include "main.c"
3 changes: 3 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ main(int argc, char **argv, char **envp)
{
RUBY_INIT_STACK;
ruby_init();
#ifdef RUBY_MAIN_INIT
RUBY_MAIN_INIT();
#endif
return ruby_run_node(ruby_options(argc, argv));
}
}
3 changes: 2 additions & 1 deletion tool/compile_prelude.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

preludes = ARGV.dup
outfile = preludes.pop
init_name = outfile[/\w+(?=_prelude.c\z)/] || 'prelude'

C_ESC = {
"\\" => "\\\\",
Expand Down Expand Up @@ -72,7 +73,7 @@ def c_esc(str)
% }
void
Init_prelude(void)
Init_<%=init_name%>(void)
{
% lines_list.each_with_index {|(setup_lines, lines), i|
rb_iseq_eval(rb_iseq_compile(
Expand Down

0 comments on commit 4496da1

Please sign in to comment.