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

ruby-changes:28504

From: nobu <ko1@a...>
Date: Thu, 2 May 2013 16:56:28 +0900 (JST)
Subject: [ruby-changes:28504] nobu:r40556 (trunk): id.def: predefined IDs

nobu	2013-05-02 16:54:17 +0900 (Thu, 02 May 2013)

  New Revision: 40556

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

  Log:
    id.def: predefined IDs
    
    * defs/id.def: add more predefined IDs used in core.

  Modified files:
    trunk/ChangeLog
    trunk/class.c
    trunk/common.mk
    trunk/defs/id.def
    trunk/object.c
    trunk/proc.c
    trunk/variable.c
    trunk/vm_method.c
    trunk/vm_trace.c

Index: defs/id.def
===================================================================
--- defs/id.def	(revision 40555)
+++ defs/id.def	(revision 40556)
@@ -1,7 +1,16 @@ https://github.com/ruby/ruby/blob/trunk/defs/id.def#L1
 # -*- mode: ruby; coding: us-ascii -*-
 firstline, predefined = __LINE__+1, %[\
+  inspect
   intern
+  object_id
+  const_missing
   method_missing                                        MethodMissing
+  method_added
+  singleton_method_added
+  method_removed
+  singleton_method_removed
+  method_undefined
+  singleton_method_undefined
   length
   size
   gets
@@ -11,6 +20,7 @@ firstline, predefined = __LINE__+1, %[\ https://github.com/ruby/ruby/blob/trunk/defs/id.def#L20
   lambda
   send
   __send__
+  __attached__
   initialize
   initialize_copy
   initialize_clone
@@ -18,6 +28,7 @@ firstline, predefined = __LINE__+1, %[\ https://github.com/ruby/ruby/blob/trunk/defs/id.def#L28
   _                                                     UScore
   "/*NULL*/"                                            NULL
   empty?
+  eql?
   respond_to?                                           Respond_to
   respond_to_missing?                                   Respond_to_missing
   <IFUNC>
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 40555)
+++ ChangeLog	(revision 40556)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu May  2 16:54:07 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* defs/id.def: add more predefined IDs used in core.
+
 Thu May  2 13:42:42 2013  Ryan Davis  <ryand-ruby@z...>
 
 	* lib/minitest/*: Imported minitest 4.7.4 (r8483)
Index: variable.c
===================================================================
--- variable.c	(revision 40555)
+++ variable.c	(revision 40556)
@@ -18,6 +18,7 @@ https://github.com/ruby/ruby/blob/trunk/variable.c#L18
 #include "node.h"
 #include "constant.h"
 #include "internal.h"
+#include "id.h"
 
 st_table *rb_global_tbl;
 st_table *rb_class_tbl;
@@ -2300,7 +2301,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/variable.c#L2301
 cvar_front_klass(VALUE klass)
 {
     if (FL_TEST(klass, FL_SINGLETON)) {
-	VALUE obj = rb_iv_get(klass, "__attached__");
+	VALUE obj = rb_ivar_get(klass, id__attached__);
 	if (RB_TYPE_P(obj, T_MODULE) || RB_TYPE_P(obj, T_CLASS)) {
 	    return obj;
 	}
Index: object.c
===================================================================
--- object.c	(revision 40555)
+++ object.c	(revision 40556)
@@ -22,6 +22,7 @@ https://github.com/ruby/ruby/blob/trunk/object.c#L22
 #include <float.h>
 #include "constant.h"
 #include "internal.h"
+#include "id.h"
 #include "probes.h"
 
 VALUE rb_cBasicObject;
@@ -35,9 +36,14 @@ VALUE rb_cNilClass; https://github.com/ruby/ruby/blob/trunk/object.c#L36
 VALUE rb_cTrueClass;
 VALUE rb_cFalseClass;
 
-static ID id_eq, id_eql, id_match, id_inspect;
-static ID id_init_copy, id_init_clone, id_init_dup;
-static ID id_const_missing;
+#define id_eq               idEq
+#define id_eql              idEqlP
+#define id_match            idEqTilde
+#define id_inspect          idInspect
+#define id_init_copy        idInitialize_copy
+#define id_init_clone       idInitialize_clone
+#define id_init_dup         idInitialize_dup
+#define id_const_missing    idConst_missing
 
 #define CLASS_OR_MODULE_P(obj) \
     (!SPECIAL_CONST_P(obj) && \
@@ -1425,7 +1431,7 @@ rb_mod_to_s(VALUE klass) https://github.com/ruby/ruby/blob/trunk/object.c#L1431
 
     if (FL_TEST(klass, FL_SINGLETON)) {
 	VALUE s = rb_usascii_str_new2("#<Class:");
-	VALUE v = rb_iv_get(klass, "__attached__");
+	VALUE v = rb_ivar_get(klass, id__attached__);
 
 	if (CLASS_OR_MODULE_P(v)) {
 	    rb_str_append(s, rb_inspect(v));
@@ -3251,15 +3257,6 @@ Init_Object(void) https://github.com/ruby/ruby/blob/trunk/object.c#L3257
      */
     rb_define_global_const("FALSE", Qfalse);
 
-    id_eq = rb_intern("==");
-    id_eql = rb_intern("eql?");
-    id_match = rb_intern("=~");
-    id_inspect = rb_intern("inspect");
-    id_init_copy = rb_intern("initialize_copy");
-    id_init_clone = rb_intern("initialize_clone");
-    id_init_dup = rb_intern("initialize_dup");
-    id_const_missing = rb_intern("const_missing");
-
     for (i=0; conv_method_names[i].method; i++) {
 	conv_method_names[i].id = rb_intern(conv_method_names[i].method);
     }
Index: proc.c
===================================================================
--- proc.c	(revision 40555)
+++ proc.c	(revision 40556)
@@ -31,7 +31,7 @@ VALUE rb_cProc; https://github.com/ruby/ruby/blob/trunk/proc.c#L31
 static VALUE bmcall(VALUE, VALUE);
 static int method_arity(VALUE);
 static int method_min_max_arity(VALUE, int *max);
-static ID attached;
+#define attached id__attached__
 
 /* Proc */
 
@@ -2448,6 +2448,5 @@ Init_Binding(void) https://github.com/ruby/ruby/blob/trunk/proc.c#L2448
     rb_define_method(rb_cBinding, "dup", binding_dup, 0);
     rb_define_method(rb_cBinding, "eval", bind_eval, -1);
     rb_define_global_function("binding", rb_f_binding, 0);
-    attached = rb_intern("__attached__");
 }
 
Index: common.mk
===================================================================
--- common.mk	(revision 40555)
+++ common.mk	(revision 40556)
@@ -696,7 +696,8 @@ node.$(OBJEXT): {$(VPATH)}node.c $(RUBY_ https://github.com/ruby/ruby/blob/trunk/common.mk#L696
 numeric.$(OBJEXT): {$(VPATH)}numeric.c $(RUBY_H_INCLUDES) \
   {$(VPATH)}util.h $(ENCODING_H_INCLUDES) {$(VPATH)}internal.h {$(VPATH)}id.h
 object.$(OBJEXT): {$(VPATH)}object.c $(RUBY_H_INCLUDES) {$(VPATH)}util.h \
-  {$(VPATH)}internal.h {$(VPATH)}constant.h $(ENCODING_H_INCLUDES) $(PROBES_H_INCLUDES) {$(VPATH)}vm_opts.h
+  {$(VPATH)}internal.h {$(VPATH)}constant.h $(ENCODING_H_INCLUDES) $(PROBES_H_INCLUDES) \
+  {$(VPATH)}vm_opts.h {$(VPATH)}id.h
 pack.$(OBJEXT): {$(VPATH)}pack.c $(RUBY_H_INCLUDES) {$(VPATH)}encoding.h \
   {$(VPATH)}oniguruma.h {$(VPATH)}internal.h
 parse.$(OBJEXT): {$(VPATH)}parse.c $(RUBY_H_INCLUDES) {$(VPATH)}node.h \
@@ -761,7 +762,7 @@ time.$(OBJEXT): {$(VPATH)}time.c $(RUBY_ https://github.com/ruby/ruby/blob/trunk/common.mk#L762
 util.$(OBJEXT): {$(VPATH)}util.c $(RUBY_H_INCLUDES) {$(VPATH)}util.h \
   {$(VPATH)}internal.h
 variable.$(OBJEXT): {$(VPATH)}variable.c $(RUBY_H_INCLUDES) \
-  {$(VPATH)}node.h {$(VPATH)}util.h {$(VPATH)}encoding.h \
+  {$(VPATH)}node.h {$(VPATH)}util.h {$(VPATH)}encoding.h {$(VPATH)}id.h \
   {$(VPATH)}oniguruma.h {$(VPATH)}internal.h {$(VPATH)}constant.h
 version.$(OBJEXT): {$(VPATH)}version.c $(RUBY_H_INCLUDES) \
   $(srcdir)/include/ruby/version.h $(srcdir)/version.h $(srcdir)/revision.h {$(VPATH)}config.h \
Index: vm_method.c
===================================================================
--- vm_method.c	(revision 40555)
+++ vm_method.c	(revision 40556)
@@ -13,9 +13,14 @@ https://github.com/ruby/ruby/blob/trunk/vm_method.c#L13
 
 static void rb_vm_check_redefinition_opt_method(const rb_method_entry_t *me, VALUE klass);
 
-static ID object_id;
-static ID removed, singleton_removed, undefined, singleton_undefined;
-static ID added, singleton_added, attached;
+#define object_id           idObject_id
+#define added               idMethod_added
+#define singleton_added     idSingleton_method_added
+#define removed             idMethod_removed
+#define singleton_removed   idSingleton_method_removed
+#define undefined           idMethod_undefined
+#define singleton_undefined idSingleton_method_undefined
+#define attached            id__attached__
 
 struct cache_entry {		/* method hash table. */
     VALUE filled_version;        /* filled state version */
@@ -1674,15 +1679,6 @@ Init_eval_method(void) https://github.com/ruby/ruby/blob/trunk/vm_method.c#L1679
     rb_define_private_method(rb_singleton_class(rb_vm_top_self()),
 			     "private", top_private, -1);
 
-    object_id = rb_intern("object_id");
-    added = rb_intern("method_added");
-    singleton_added = rb_intern("singleton_method_added");
-    removed = rb_intern("method_removed");
-    singleton_removed = rb_intern("singleton_method_removed");
-    undefined = rb_intern("method_undefined");
-    singleton_undefined = rb_intern("singleton_method_undefined");
-    attached = rb_intern("__attached__");
-
     {
 #define REPLICATE_METHOD(klass, id, noex) \
 	rb_method_entry_set((klass), (id), \
Index: class.c
===================================================================
--- class.c	(revision 40555)
+++ class.c	(revision 40556)
@@ -32,7 +32,7 @@ https://github.com/ruby/ruby/blob/trunk/class.c#L32
 #include <ctype.h>
 
 extern st_table *rb_class_tbl;
-static ID id_attached;
+#define id_attached id__attached__
 
 /**
  * Allocates a struct RClass for a new class.
@@ -400,8 +400,6 @@ boot_defclass(const char *name, VALUE su https://github.com/ruby/ruby/blob/trunk/class.c#L400
 void
 Init_class_hierarchy(void)
 {
-    id_attached = rb_intern("__attached__");
-
     rb_cBasicObject = boot_defclass("BasicObject", 0);
     rb_cObject = boot_defclass("Object", rb_cBasicObject);
     rb_cModule = boot_defclass("Module", rb_cObject);
Index: vm_trace.c
===================================================================
--- vm_trace.c	(revision 40555)
+++ vm_trace.c	(revision 40556)
@@ -582,7 +582,7 @@ call_trace_func(rb_event_flag_t event, V https://github.com/ruby/ruby/blob/trunk/vm_trace.c#L582
 	    klass = RBASIC(klass)->klass;
 	}
 	else if (FL_TEST(klass, FL_SINGLETON)) {
-	    klass = rb_iv_get(klass, "__attached__");
+	    klass = rb_ivar_get(klass, id__attached__);
 	}
     }
 

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

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