diff options
Diffstat (limited to 'src/struct.c')
| -rw-r--r-- | src/struct.c | 35 |
1 files changed, 4 insertions, 31 deletions
diff --git a/src/struct.c b/src/struct.c index a133dc046..beb7c2f46 100644 --- a/src/struct.c +++ b/src/struct.c @@ -367,7 +367,7 @@ mrb_struct_s_def(mrb_state *mrb, mrb_value klass) name = mrb_nil_value(); rest = mrb_nil_value(); - mrb_get_args(mrb, "&*", &b, &argv, &argc); + mrb_get_args(mrb, "*&", &argv, &argc, &b); if (argc > 0) name = argv[0]; if (argc > 1) rest = argv[1]; if (mrb_type(rest) == MRB_TT_ARRAY) { @@ -400,7 +400,7 @@ mrb_struct_s_def(mrb_state *mrb, mrb_value klass) return st; } -static long +static int num_members(mrb_state *mrb, struct RClass *klass) { mrb_value members; @@ -418,7 +418,7 @@ static mrb_value mrb_struct_initialize_withArg(mrb_state *mrb, int argc, mrb_value *argv, mrb_value self) { struct RClass *klass = mrb_obj_class(mrb, self); - long n; + int n; struct RStruct *st; mrb_struct_modify(self); @@ -447,34 +447,7 @@ mrb_struct_initialize_m(mrb_state *mrb, /*int argc, mrb_value *argv,*/ mrb_value mrb_value mrb_struct_initialize(mrb_state *mrb, mrb_value self, mrb_value values) { - return mrb_struct_initialize_withArg(mrb, RARRAY_LEN/*INT*/(values), RARRAY_PTR(values), self); -} - -mrb_value -mrb_struct_alloc(mrb_state *mrb, mrb_value klass, mrb_value values) -{ - return mrb_class_new_instance(mrb, RARRAY_LEN(values), RARRAY_PTR(values), mrb_class(mrb, klass)); -} - -mrb_value -mrb_struct_new(mrb_state *mrb, struct RClass *klass, ...) -{ - mrb_value tmpargs[N_REF_FUNC], *mem = tmpargs; - int size, i; - va_list args; - - size = mrb_long2int(num_members(mrb, klass)); - if (size > numberof(tmpargs)) { - tmpargs[0] = mrb_ary_new_capa(mrb, size); - mem = RARRAY_PTR(tmpargs[0]); - } - va_start(args, klass); - for (i=0; i<size; i++) { - mem[i] = va_arg(args, mrb_value); - } - va_end(args); - - return mrb_class_new_instance(mrb, size, mem, klass); + return mrb_struct_initialize_withArg(mrb, RARRAY_LEN(values), RARRAY_PTR(values), self); } static mrb_value |
