mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* struct.c (rb_struct_alloc_noinit): new function.
(rb_struct_define_without_accessor): add allocator to the arguments. * range.c (range_alloc): re-introduced using rb_struct_alloc_noinit. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14003 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2109a52503
commit
0d89567252
4 changed files with 30 additions and 4 deletions
|
@ -1,3 +1,10 @@
|
|||
Fri Nov 23 15:59:04 2007 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* struct.c (rb_struct_alloc_noinit): new function.
|
||||
(rb_struct_define_without_accessor): add allocator to the arguments.
|
||||
|
||||
* range.c (range_alloc): re-introduced using rb_struct_alloc_noinit.
|
||||
|
||||
Fri Nov 23 15:27:43 2007 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* re.c (REG_CASESTATE): unused macro removed.
|
||||
|
|
|
@ -542,7 +542,8 @@ VALUE rb_struct_getmember(VALUE, ID);
|
|||
VALUE rb_struct_iv_get(VALUE, const char*);
|
||||
VALUE rb_struct_s_members(VALUE);
|
||||
VALUE rb_struct_members(VALUE);
|
||||
VALUE rb_struct_define_without_accessor(char *, VALUE, ...);
|
||||
VALUE rb_struct_alloc_noinit(VALUE);
|
||||
VALUE rb_struct_define_without_accessor(char *, VALUE, rb_alloc_func_t, ...);
|
||||
/* thread.c */
|
||||
typedef void rb_unblock_function_t(void *);
|
||||
typedef VALUE rb_blocking_function_t(void *);
|
||||
|
|
11
range.c
11
range.c
|
@ -816,6 +816,14 @@ range_loader(VALUE range, VALUE obj)
|
|||
return range;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
range_alloc(VALUE klass)
|
||||
{
|
||||
/* rb_struct_alloc_noinit itself should not be used because
|
||||
* rb_marshal_define_compat uses equality of allocaiton function */
|
||||
return rb_struct_alloc_noinit(klass);
|
||||
}
|
||||
|
||||
/* A <code>Range</code> represents an interval---a set of values with a
|
||||
* start and an end. Ranges may be constructed using the
|
||||
* <em>s</em><code>..</code><em>e</em> and
|
||||
|
@ -879,7 +887,8 @@ Init_Range(void)
|
|||
id_end = rb_intern("end");
|
||||
id_excl = rb_intern("excl");
|
||||
|
||||
rb_cRange = rb_struct_define_without_accessor("Range", rb_cObject,
|
||||
rb_cRange = rb_struct_define_without_accessor(
|
||||
"Range", rb_cObject, range_alloc,
|
||||
"begin", "end", "excl", NULL);
|
||||
|
||||
rb_include_module(rb_cRange, rb_mEnumerable);
|
||||
|
|
13
struct.c
13
struct.c
|
@ -218,7 +218,13 @@ make_struct(VALUE name, VALUE members, VALUE klass)
|
|||
}
|
||||
|
||||
VALUE
|
||||
rb_struct_define_without_accessor(char *class_name, VALUE super, ...)
|
||||
rb_struct_alloc_noinit(VALUE klass)
|
||||
{
|
||||
return struct_alloc(klass);
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_struct_define_without_accessor(char *class_name, VALUE super, rb_alloc_func_t alloc, ...)
|
||||
{
|
||||
VALUE klass;
|
||||
va_list ar;
|
||||
|
@ -247,7 +253,10 @@ rb_struct_define_without_accessor(char *class_name, VALUE super, ...)
|
|||
rb_iv_set(klass, "__size__", LONG2NUM(RARRAY_LEN(members)));
|
||||
rb_iv_set(klass, "__members__", members);
|
||||
|
||||
rb_define_alloc_func(klass, struct_alloc);
|
||||
if (alloc)
|
||||
rb_define_alloc_func(klass, alloc);
|
||||
else
|
||||
rb_define_alloc_func(klass, struct_alloc);
|
||||
|
||||
return klass;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue