Skip to content

Commit d7d1e34

Browse files
committed
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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 5fd0076 commit d7d1e34

File tree

2 files changed

+6
-54
lines changed

2 files changed

+6
-54
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Fri Dec 26 15:28:27 2014 Nobuyoshi Nakada <[email protected]>
2+
3+
* ext/tk/tcltklib.c (ip_ruby_cmd_receiver_const_get): simply use
4+
rb_path2class() to get a class/module from its name.
5+
16
Fri Dec 26 15:20:54 2014 Nobuyoshi Nakada <[email protected]>
27

38
* marshal.c (w_long): append at once by w_nbyte() instead of

ext/tk/tcltklib.c

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -3489,77 +3489,24 @@ ip_ruby_cmd_core(arg)
34893489
return ret;
34903490
}
34913491

3492-
#define SUPPORT_NESTED_CONST_AS_IP_RUBY_CMD_RECEIVER 1
3493-
34943492
static VALUE
34953493
ip_ruby_cmd_receiver_const_get(name)
34963494
char *name;
34973495
{
3498-
volatile VALUE klass = rb_cObject;
3499-
#if 0
3500-
char *head, *tail;
3501-
#endif
3502-
int state;
3503-
3504-
#if SUPPORT_NESTED_CONST_AS_IP_RUBY_CMD_RECEIVER
3505-
klass = rb_eval_string_protect(name, &state);
3506-
if (state) {
3507-
return Qnil;
3508-
} else {
3509-
return klass;
3510-
}
3511-
#else
3512-
return rb_const_get(klass, rb_intern(name));
3513-
#endif
3514-
3515-
/* TODO!!!!!! */
3516-
/* support nest of classes/modules */
3517-
3518-
/* return rb_eval_string(name); */
3519-
/* return rb_eval_string_protect(name, &state); */
3520-
3521-
#if 0 /* doesn't work!! (fail to autoload?) */
3522-
/* duplicate */
3523-
head = name = strdup(name);
3524-
3525-
/* has '::' at head ? */
3526-
if (*head == ':') head += 2;
3527-
tail = head;
3528-
3529-
/* search */
3530-
while(*tail) {
3531-
if (*tail == ':') {
3532-
*tail = '\0';
3533-
klass = rb_const_get(klass, rb_intern(head));
3534-
tail += 2;
3535-
head = tail;
3536-
} else {
3537-
tail++;
3538-
}
3539-
}
3540-
3541-
free(name);
3542-
return rb_const_get(klass, rb_intern(head));
3543-
#endif
3496+
return rb_path2class(name);
35443497
}
35453498

35463499
static VALUE
35473500
ip_ruby_cmd_receiver_get(str)
35483501
char *str;
35493502
{
35503503
volatile VALUE receiver;
3551-
#if !SUPPORT_NESTED_CONST_AS_IP_RUBY_CMD_RECEIVER
35523504
int state;
3553-
#endif
35543505

35553506
if (str[0] == ':' || ('A' <= str[0] && str[0] <= 'Z')) {
35563507
/* class | module | constant */
3557-
#if SUPPORT_NESTED_CONST_AS_IP_RUBY_CMD_RECEIVER
3558-
receiver = ip_ruby_cmd_receiver_const_get(str);
3559-
#else
35603508
receiver = rb_protect(ip_ruby_cmd_receiver_const_get, (VALUE)str, &state);
35613509
if (state) return Qnil;
3562-
#endif
35633510
} else if (str[0] == '$') {
35643511
/* global variable */
35653512
receiver = rb_gv_get(str);

0 commit comments

Comments
 (0)