summaryrefslogtreecommitdiff
path: root/struct.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-12-14 06:50:43 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-12-14 06:50:43 +0000
commit9d228b13deccfdf23f44e2c465f723a2a7b3bcbd (patch)
tree9a4d769804c389b6b03bbfdf65e8e0a03288c8e8 /struct.c
parentc18d3740a925e8752c3b93acea6087fb0e03be53 (diff)
19991214
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@587 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'struct.c')
-rw-r--r--struct.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/struct.c b/struct.c
index b14b820..1114577 100644
--- a/struct.c
+++ b/struct.c
@@ -161,7 +161,7 @@ make_struct(name, member, klass)
else {
char *cname = STR2CSTR(name);
id = rb_intern(cname);
- if (!rb_is_shared_id(id)) {
+ if (!rb_is_const_id(id)) {
rb_raise(rb_eNameError, "identifier %s needs to be constant", cname);
}
nstr = rb_define_class_under(klass, cname, klass);
@@ -207,7 +207,8 @@ rb_struct_define(name, va_alist)
VALUE nm, ary;
char *mem;
- nm = rb_str_new2(name);
+ if (!name) nm = Qnil;
+ else nm = rb_str_new2(name);
ary = rb_ary_new();
va_init_list(ar, name);
@@ -224,16 +225,23 @@ static VALUE
rb_struct_s_def(argc, argv, klass)
int argc;
VALUE *argv;
+ VALUE klass;
{
VALUE name, rest;
long i;
VALUE st;
+ ID id;
rb_scan_args(argc, argv, "1*", &name, &rest);
for (i=0; i<RARRAY(rest)->len; i++) {
- ID id = rb_to_id(RARRAY(rest)->ptr[i]);
+ id = rb_to_id(RARRAY(rest)->ptr[i]);
RARRAY(rest)->ptr[i] = INT2FIX(id);
}
+ if (TYPE(name) != T_STRING) {
+ id = rb_to_id(name);
+ rb_ary_unshift(rest, INT2FIX(id));
+ name = Qnil;
+ }
st = make_struct(name, rest, klass);
return st;