ruby-changes:36948
From: nobu <ko1@a...>
Date: Fri, 26 Dec 2014 15:28:36 +0900 (JST)
Subject: [ruby-changes:36948] nobu:r49029 (trunk): tcltklib.c: rb_path2class
nobu 2014-12-26 15:28:29 +0900 (Fri, 26 Dec 2014) New Revision: 49029 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49029 Log: tcltklib.c: rb_path2class * ext/tk/tcltklib.c (ip_ruby_cmd_receiver_const_get): simply use rb_path2class() to get a class/module from its name. Modified files: trunk/ChangeLog trunk/ext/tk/tcltklib.c Index: ChangeLog =================================================================== --- ChangeLog (revision 49028) +++ ChangeLog (revision 49029) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri Dec 26 15:28:27 2014 Nobuyoshi Nakada <nobu@r...> + + * ext/tk/tcltklib.c (ip_ruby_cmd_receiver_const_get): simply use + rb_path2class() to get a class/module from its name. + Fri Dec 26 15:20:54 2014 Nobuyoshi Nakada <nobu@r...> * marshal.c (w_long): append at once by w_nbyte() instead of Index: ext/tk/tcltklib.c =================================================================== --- ext/tk/tcltklib.c (revision 49028) +++ ext/tk/tcltklib.c (revision 49029) @@ -3489,58 +3489,11 @@ ip_ruby_cmd_core(arg) https://github.com/ruby/ruby/blob/trunk/ext/tk/tcltklib.c#L3489 return ret; } -#define SUPPORT_NESTED_CONST_AS_IP_RUBY_CMD_RECEIVER 1 - static VALUE ip_ruby_cmd_receiver_const_get(name) char *name; { - volatile VALUE klass = rb_cObject; -#if 0 - char *head, *tail; -#endif - int state; - -#if SUPPORT_NESTED_CONST_AS_IP_RUBY_CMD_RECEIVER - klass = rb_eval_string_protect(name, &state); - if (state) { - return Qnil; - } else { - return klass; - } -#else - return rb_const_get(klass, rb_intern(name)); -#endif - - /* TODO!!!!!! */ - /* support nest of classes/modules */ - - /* return rb_eval_string(name); */ - /* return rb_eval_string_protect(name, &state); */ - -#if 0 /* doesn't work!! (fail to autoload?) */ - /* duplicate */ - head = name = strdup(name); - - /* has '::' at head ? */ - if (*head == ':') head += 2; - tail = head; - - /* search */ - while(*tail) { - if (*tail == ':') { - *tail = '\0'; - klass = rb_const_get(klass, rb_intern(head)); - tail += 2; - head = tail; - } else { - tail++; - } - } - - free(name); - return rb_const_get(klass, rb_intern(head)); -#endif + return rb_path2class(name); } static VALUE @@ -3548,18 +3501,12 @@ ip_ruby_cmd_receiver_get(str) https://github.com/ruby/ruby/blob/trunk/ext/tk/tcltklib.c#L3501 char *str; { volatile VALUE receiver; -#if !SUPPORT_NESTED_CONST_AS_IP_RUBY_CMD_RECEIVER int state; -#endif if (str[0] == ':' || ('A' <= str[0] && str[0] <= 'Z')) { /* class | module | constant */ -#if SUPPORT_NESTED_CONST_AS_IP_RUBY_CMD_RECEIVER - receiver = ip_ruby_cmd_receiver_const_get(str); -#else receiver = rb_protect(ip_ruby_cmd_receiver_const_get, (VALUE)str, &state); if (state) return Qnil; -#endif } else if (str[0] == '$') { /* global variable */ receiver = rb_gv_get(str); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/