mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* marshal.c (r_object): better allocation type check for
TYPE_UCLASS. usage of allocation framework is disabled for now. * variable.c (rb_class_path): Module may have subclass. * string.c (rb_str_update): should maintain original negative offset. * string.c (rb_str_subpat_set): ditto * string.c (rb_str_aset): ditto. * re.c (rb_reg_nth_match): should check negative nth. * re.c (rb_reg_nth_defined): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1764 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d902111a57
commit
1fe40b7cc5
25 changed files with 349 additions and 342 deletions
29
struct.c
29
struct.c
|
@ -14,7 +14,7 @@
|
|||
|
||||
VALUE rb_cStruct;
|
||||
|
||||
static VALUE struct_alloc _((int, VALUE*, VALUE));
|
||||
static VALUE struct_alloc _((VALUE));
|
||||
|
||||
VALUE
|
||||
rb_struct_iv_get(c, name)
|
||||
|
@ -168,8 +168,9 @@ make_struct(name, member, klass)
|
|||
rb_iv_set(nstr, "__size__", INT2NUM(RARRAY(member)->len));
|
||||
rb_iv_set(nstr, "__member__", member);
|
||||
|
||||
rb_define_singleton_method(nstr, "new", struct_alloc, -1);
|
||||
rb_define_singleton_method(nstr, "[]", struct_alloc, -1);
|
||||
rb_define_singleton_method(nstr, "allocate", struct_alloc, 0);
|
||||
rb_define_singleton_method(nstr, "new", rb_class_new_instance, -1);
|
||||
rb_define_singleton_method(nstr, "[]", rb_class_new_instance, -1);
|
||||
rb_define_singleton_method(nstr, "members", rb_struct_s_members, 0);
|
||||
for (i=0; i< RARRAY(member)->len; i++) {
|
||||
ID id = SYM2ID(RARRAY(member)->ptr[i]);
|
||||
|
@ -269,14 +270,11 @@ rb_struct_initialize(self, values)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
struct_alloc(argc, argv, klass)
|
||||
int argc;
|
||||
VALUE *argv;
|
||||
struct_alloc(klass)
|
||||
VALUE klass;
|
||||
{
|
||||
VALUE size;
|
||||
long n;
|
||||
|
||||
NEWOBJ(st, struct RStruct);
|
||||
OBJSETUP(st, klass, T_STRUCT);
|
||||
|
||||
|
@ -286,7 +284,6 @@ struct_alloc(argc, argv, klass)
|
|||
st->ptr = ALLOC_N(VALUE, n);
|
||||
rb_mem_clear(st->ptr, n);
|
||||
st->len = n;
|
||||
rb_obj_call_init((VALUE)st, argc, argv);
|
||||
|
||||
return (VALUE)st;
|
||||
}
|
||||
|
@ -295,7 +292,7 @@ VALUE
|
|||
rb_struct_alloc(klass, values)
|
||||
VALUE klass, values;
|
||||
{
|
||||
return struct_alloc(RARRAY(values)->len, RARRAY(values)->ptr, klass);
|
||||
return rb_class_new_instance(RARRAY(values)->len, RARRAY(values)->ptr, klass);
|
||||
}
|
||||
|
||||
VALUE
|
||||
|
@ -320,7 +317,7 @@ rb_struct_new(klass, va_alist)
|
|||
}
|
||||
va_end(args);
|
||||
|
||||
return struct_alloc(size, mem, klass);
|
||||
return rb_class_new_instance(size, mem, klass);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
@ -409,13 +406,13 @@ static VALUE
|
|||
rb_struct_clone(s)
|
||||
VALUE s;
|
||||
{
|
||||
NEWOBJ(clone, struct RStruct);
|
||||
CLONESETUP(clone, s);
|
||||
clone->ptr = ALLOC_N(VALUE, RSTRUCT(s)->len);
|
||||
clone->len = RSTRUCT(s)->len;
|
||||
MEMCPY(clone->ptr, RSTRUCT(s)->ptr, VALUE, clone->len);
|
||||
VALUE clone = rb_obj_clone(s);
|
||||
|
||||
return (VALUE)clone;
|
||||
RSTRUCT(clone)->ptr = ALLOC_N(VALUE, RSTRUCT(s)->len);
|
||||
RSTRUCT(clone)->len = RSTRUCT(s)->len;
|
||||
MEMCPY(RSTRUCT(clone)->ptr, RSTRUCT(s)->ptr, VALUE, RSTRUCT(clone)->len);
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue