[前][次][番号順一覧][スレッド一覧]

ruby-changes:26135

From: nobu <ko1@a...>
Date: Wed, 5 Dec 2012 02:36:37 +0900 (JST)
Subject: [ruby-changes:26135] nobu:r38192 (trunk): id.c: generate

nobu	2012-12-05 02:36:19 +0900 (Wed, 05 Dec 2012)

  New Revision: 38192

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=38192

  Log:
    id.c: generate
    
    * common.mk, defs/id.def, template/id.c.tmpl: generate id.c as well as id.h.

  Added files:
    trunk/defs/id.def
    trunk/template/id.c.tmpl
  Removed files:
    trunk/id.c
  Modified directories:
    trunk/
  Modified files:
    trunk/.gitignore
    trunk/ChangeLog
    trunk/common.mk
    trunk/template/id.h.tmpl

Index: id.c
===================================================================
--- id.c	(revision 38191)
+++ id.c	(revision 38192)
@@ -1,56 +0,0 @@
-/**********************************************************************
-
-  id.c -
-
-  $Author$
-  created at: Thu Jul 12 04:37:51 2007
-
-  Copyright (C) 2004-2007 Koichi Sasada
-
-**********************************************************************/
-
-#include "ruby/ruby.h"
-
-#include "id.h"
-
-static void
-Init_id(void)
-{
-#undef rb_intern
-#define rb_intern(str) rb_intern_const(str)
-    rb_encoding *enc = rb_usascii_encoding();
-
-    REGISTER_SYMID(idNULL, "");
-    REGISTER_SYMID(idIFUNC, "<IFUNC>");
-    REGISTER_SYMID(idCFUNC, "<CFUNC>");
-    REGISTER_SYMID(idRespond_to, "respond_to?");
-    REGISTER_SYMID(idRespond_to_missing, "respond_to_missing?");
-
-    REGISTER_SYMID(id_core_set_method_alias,   	    "core#set_method_alias");
-    REGISTER_SYMID(id_core_set_variable_alias, 	    "core#set_variable_alias");
-    REGISTER_SYMID(id_core_undef_method,       	    "core#undef_method");
-    REGISTER_SYMID(id_core_define_method,      	    "core#define_method");
-    REGISTER_SYMID(id_core_define_singleton_method, "core#define_singleton_method");
-    REGISTER_SYMID(id_core_set_postexe,             "core#set_postexe");
-    REGISTER_SYMID(id_core_hash_from_ary,           "core#hash_from_ary");
-    REGISTER_SYMID(id_core_hash_merge_ary,          "core#hash_merge_ary");
-    REGISTER_SYMID(id_core_hash_merge_ptr,          "core#hash_merge_ptr");
-    REGISTER_SYMID(id_core_hash_merge_kwd,          "core#hash_merge_kwd");
-
-    REGISTER_SYMID(idEach, "each");
-    REGISTER_SYMID(idLength, "length");
-    REGISTER_SYMID(idSize, "size");
-    REGISTER_SYMID(idEmptyP, "empty?");
-    REGISTER_SYMID(idLambda, "lambda");
-    REGISTER_SYMID(idIntern, "intern");
-    REGISTER_SYMID(idGets, "gets");
-    REGISTER_SYMID(idSucc, "succ");
-    REGISTER_SYMID(idMethodMissing, "method_missing");
-    REGISTER_SYMID(idSend, "send");
-    REGISTER_SYMID(id__send__, "__send__");
-    REGISTER_SYMID(idInitialize, "initialize");
-    REGISTER_SYMID(idInitialize_copy, "initialize_copy");
-    REGISTER_SYMID(idInitialize_clone, "initialize_clone");
-    REGISTER_SYMID(idInitialize_dup, "initialize_dup");
-    REGISTER_SYMID(idUScore, "_");
-}
Index: defs/id.def
===================================================================
--- defs/id.def	(revision 0)
+++ defs/id.def	(revision 38192)
@@ -0,0 +1,50 @@
+# -*- ruby -*-
+predefined = %[\
+  intern
+  method_missing                                        MethodMissing
+  length
+  size
+  gets
+  succ
+  each
+  lambda
+  send
+  __send__
+  initialize
+  initialize_copy
+  initialize_clone
+  initialize_dup
+  _                                                     UScore
+  "/*NULL*/"                                            NULL
+  empty?
+  respond_to?                                           Respond_to
+  respond_to_missing?                                   Respond_to_missing
+  <IFUNC>
+  <CFUNC>
+  core#set_method_alias
+  core#set_variable_alias
+  core#undef_method
+  core#define_method
+  core#define_singleton_method
+  core#set_postexe
+  core#hash_from_ary
+  core#hash_merge_ary
+  core#hash_merge_ptr
+  core#hash_merge_kwd
+]
+
+predefined_ids = {}
+preserved_ids = []
+attr_ids = []
+predefined.each_line do |line|
+  next if /^#/ =~ line or (name, token = line.split; !name)
+  token ||= name
+  if /#/ =~ token
+    token = "_#{token.gsub(/\W+/, '_')}"
+  else
+    token = token.sub(/\?/, 'P').sub(/\A[a-z]/) {$&.upcase}
+    token.gsub!(/\W+/, "")
+  end
+  (/\A(?!\d)\w+\z/ =~ name ? attr_ids : preserved_ids) << token
+  predefined_ids[token] = name
+end

Property changes on: defs/id.def
___________________________________________________________________
Added: svn:eol-style
   + LF

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 38191)
+++ ChangeLog	(revision 38192)
@@ -1,3 +1,7 @@
+Wed Dec  5 02:36:10 2012  Nobuyoshi Nakada  <nobu@r...>
+
+	* common.mk, defs/id.def, template/id.c.tmpl: generate id.c as well as id.h.
+
 Wed Dec  5 00:56:21 2012  KOSAKI Motohiro  <kosaki.motohiro@g...>
 
 	* thread.c (rb_mutex_owned_p): new method that return current
Index: common.mk
===================================================================
--- common.mk	(revision 38191)
+++ common.mk	(revision 38192)
@@ -841,7 +841,7 @@
 
 {$(VPATH)}vm.inc: $(srcdir)/template/vm.inc.tmpl
 
-srcs: {$(VPATH)}parse.c {$(VPATH)}lex.c {$(VPATH)}newline.c srcs-ext srcs-enc
+srcs: {$(VPATH)}parse.c {$(VPATH)}lex.c {$(VPATH)}newline.c {$(VPATH)}id.c srcs-ext srcs-enc
 
 EXT_SRCS = $(srcdir)/ext/ripper/ripper.c $(srcdir)/ext/json/parser/parser.c
 
@@ -857,11 +857,16 @@
 
 insns: $(INSNS)
 
-id.h: $(srcdir)/tool/generic_erb.rb $(srcdir)/template/id.h.tmpl
+id.h: $(srcdir)/tool/generic_erb.rb $(srcdir)/template/id.h.tmpl $(srcdir)/defs/id.def
 	$(ECHO) generating $@
 	$(Q) $(BASERUBY) $(srcdir)/tool/generic_erb.rb --output=$@ \
 		$(srcdir)/template/$@.tmpl
 
+id.c: $(srcdir)/tool/generic_erb.rb $(srcdir)/template/id.c.tmpl $(srcdir)/defs/id.def
+	$(ECHO) generating $@
+	$(Q) $(BASERUBY) $(srcdir)/tool/generic_erb.rb --output=$@ \
+		$(srcdir)/template/$@.tmpl
+
 node_name.inc: {$(VPATH)}node.h
 	$(ECHO) generating $@
 	$(Q) $(BASERUBY) -n $(srcdir)/tool/node_name.rb < $? > $@
Index: .gitignore
===================================================================
--- .gitignore	(revision 38191)
+++ .gitignore	(revision 38192)
@@ -56,7 +56,7 @@
 /encdb.h
 /exts.mk
 /goruby
-/id.h
+/id.[ch]
 /largefile.h
 /lex.c
 /libruby*.*
Index: template/id.c.tmpl
===================================================================
--- template/id.c.tmpl	(revision 0)
+++ template/id.c.tmpl	(revision 38192)
@@ -0,0 +1,28 @@
+%#  -*- c -*-
+/* DO NOT EDIT THIS FILE DIRECTLY */
+/**********************************************************************
+
+  id.c -
+
+  $Author$
+  created at: Wed Dec  5 02:36:10 2012
+
+  Copyright (C) 2004-2007 Koichi Sasada
+
+**********************************************************************/
+<%
+predefined_ids = nil
+defs = File.join(File.dirname(erb.filename), "../defs/id.def")
+eval(File.read(defs), binding, defs)
+%>
+static void
+Init_id(void)
+{
+#undef rb_intern
+#define rb_intern(str) rb_intern_const(str)
+    rb_encoding *enc = rb_usascii_encoding();
+
+% predefined_ids.each_pair do |token, name|
+    REGISTER_SYMID(id<%=token%>, "<%=name%>");
+% end
+}

Property changes on: template/id.c.tmpl
___________________________________________________________________
Added: svn:eol-style
   + LF
Added: svn:keywords
   + Author

Index: template/id.h.tmpl
===================================================================
--- template/id.h.tmpl	(revision 38191)
+++ template/id.h.tmpl	(revision 38192)
@@ -15,48 +15,16 @@
 
 op_id_offset = 128
 
-attr_ids = %w[
-  Intern
-  MethodMissing
-  Length
-  Size
-  Gets
-  Succ
-  Each
-  Lambda
-  Send
-  __send__
-  Initialize
-  Initialize_copy
-  Initialize_clone
-  Initialize_dup
-  UScore
-]
-
 token_op_ids = %w[
   tDOT2 tDOT3 tUPLUS tUMINUS tPOW tDSTAR tCMP tLSHFT tRSHFT
   tLEQ tGEQ tEQ tEQQ tNEQ tMATCH tNMATCH tAREF tASET
   tCOLON2 tCOLON3
 ]
 
-preserved_ids = %w[
-  NULL
-  EmptyP
-  Respond_to
-  Respond_to_missing
-  IFUNC
-  CFUNC
-  _core_set_method_alias
-  _core_set_variable_alias
-  _core_undef_method
-  _core_define_method
-  _core_define_singleton_method
-  _core_set_postexe
-  _core_hash_from_ary
-  _core_hash_merge_ary
-  _core_hash_merge_ptr
-  _core_hash_merge_kwd
-]
+preserved_ids = nil
+attr_ids = nil
+defs = File.join(File.dirname(erb.filename), "../defs/id.def")
+eval(File.read(defs), binding, defs)
 %>
 #ifndef RUBY_ID_H
 #define RUBY_ID_H

Property changes on: .
___________________________________________________________________
Modified: svn:ignore
   - *.bak
*.dylib
*.inc
*.orig
*.pc
*.rej
*.sav
*.swp
*_prelude.c
*~
.*-*
.*.list
.*.time
.DS_Store
.ccmalloc
.ext
.git
.pc
.ppack
.svn
.time.id.h
COPYING.LIB
ChangeLog-1.8.0
ChangeLog.pre-alpha
ChangeLog.pre1_1
Doxyfile
GNUmakefile
Makefile
README.atheos
README.fat-patch
README.v6
TAGS
archive
autom4te*.cache
automake
beos
bmlog-*
breakpoints.gdb
change.log
config.cache
config.h
config.h.in
config.log
config.status
config.status.lineno
configure
enc.mk
enc/trans/*.c
encdb.h
ext/win32ole/.document
exts.mk
goruby
id.h
largefile.h
lex.c
libruby*.*
miniprelude.c
miniruby
newdate.rb
newline.c
newver.rb
parse.c
parse.h
patches
patches-master
pitest.rb
ppack
prelude.c
preview
probes.dmyh
probes.h
rbconfig.rb
rename2.h
repack
revision.h
riscos
rubicon
ruby
ruby-man.rd.gz
test.rb
tmp
transdb.h
uncommon.mk
verconf.h
web
y.output
y.tab.c
yasmdata.rb

   + *.bak
*.dylib
*.inc
*.orig
*.pc
*.rej
*.sav
*.swp
*_prelude.c
*~
.*-*
.*.list
.*.time
.DS_Store
.ccmalloc
.ext
.git
.pc
.ppack
.svn
.time.id.h
COPYING.LIB
ChangeLog-1.8.0
ChangeLog.pre-alpha
ChangeLog.pre1_1
Doxyfile
GNUmakefile
Makefile
README.atheos
README.fat-patch
README.v6
TAGS
archive
autom4te*.cache
automake
beos
bmlog-*
breakpoints.gdb
change.log
config.cache
config.h
config.h.in
config.log
config.status
config.status.lineno
configure
enc.mk
enc/trans/*.c
encdb.h
ext/win32ole/.document
exts.mk
goruby
id.[ch]
largefile.h
lex.c
libruby*.*
miniprelude.c
miniruby
newdate.rb
newline.c
newver.rb
parse.c
parse.h
patches
patches-master
pitest.rb
ppack
prelude.c
preview
probes.dmyh
probes.h
rbconfig.rb
rename2.h
repack
revision.h
riscos
rubicon
ruby
ruby-man.rd.gz
test.rb
tmp
transdb.h
uncommon.mk
verconf.h
web
y.output
y.tab.c
yasmdata.rb



--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]