Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' into iij

  • Loading branch information...
commit da24422ab8e85e125f4562a78d88ec697972dc93 2 parents 9471c3f + 92cf2a0
@tsahara-iij tsahara-iij authored
View
1  include/mruby/variable.h
@@ -37,6 +37,7 @@ void mrb_vm_const_set(mrb_state*, mrb_sym, mrb_value);
mrb_value mrb_const_get(mrb_state*, mrb_value, mrb_sym);
void mrb_const_set(mrb_state*, mrb_value, mrb_sym, mrb_value);
int mrb_const_defined(mrb_state*, mrb_value, mrb_sym);
+void mrb_const_remove(mrb_state*, mrb_value, mrb_sym);
mrb_value mrb_obj_iv_get(mrb_state *mrb, struct RObject *obj, mrb_sym sym);
void mrb_obj_iv_set(mrb_state *mrb, struct RObject *obj, mrb_sym sym, mrb_value v);
View
2  minirake
@@ -287,7 +287,7 @@ module MiniRake
end
Rake = MiniRake
-include MiniRake::DSL
+extend MiniRake::DSL
######################################################################
View
15 src/class.c
@@ -1748,6 +1748,20 @@ mrb_mod_const_set(mrb_state *mrb, mrb_value mod)
return value;
}
+mrb_value
+mrb_mod_remove_const(mrb_state *mrb, mrb_value mod)
+{
+ mrb_sym sym;
+ mrb_value val;
+
+ mrb_get_args(mrb, "n", &sym);
+ check_const_name(mrb, sym);
+ val = mrb_iv_remove(mrb, mod, sym);
+ if (mrb_undef_p(val)) {
+ mrb_name_error(mrb, sym, "instance variable %s not defined", mrb_sym2name(mrb, sym));
+ }
+ return val;
+}
static mrb_value
mrb_mod_eqq(mrb_state *mrb, mrb_value mod)
@@ -1828,6 +1842,7 @@ mrb_init_class(mrb_state *mrb)
mrb_define_method(mrb, mod, "const_defined?", mrb_mod_const_defined, ARGS_REQ(1)); /* 15.2.2.4.20 */
mrb_define_method(mrb, mod, "const_get", mrb_mod_const_get, ARGS_REQ(1)); /* 15.2.2.4.21 */
mrb_define_method(mrb, mod, "const_set", mrb_mod_const_set, ARGS_REQ(2)); /* 15.2.2.4.23 */
+ mrb_define_method(mrb, mod, "remove_const", mrb_mod_remove_const, ARGS_REQ(1)); /* 15.2.2.4.40 */
mrb_define_method(mrb, mod, "define_method", mod_define_method, ARGS_REQ(1));
mrb_define_method(mrb, mod, "class_variables", mrb_mod_class_variables, ARGS_NONE()); /* 15.2.2.4.19 */
View
9 src/variable.c
@@ -895,7 +895,7 @@ mrb_const_set(mrb_state *mrb, mrb_value mod, mrb_sym sym, mrb_value v)
mrb_iv_set(mrb, mod, sym, v);
}
-void
+ void
mrb_vm_const_set(mrb_state *mrb, mrb_sym sym, mrb_value v)
{
struct RClass *c = mrb->ci->proc->target_class;
@@ -905,6 +905,13 @@ mrb_vm_const_set(mrb_state *mrb, mrb_sym sym, mrb_value v)
}
void
+mrb_const_remove(mrb_state *mrb, mrb_value mod, mrb_sym sym)
+{
+ mod_const_check(mrb, mod);
+ mrb_iv_remove(mrb, mod, sym);
+}
+
+void
mrb_define_const(mrb_state *mrb, struct RClass *mod, const char *name, mrb_value v)
{
mrb_obj_iv_set(mrb, (struct RObject*)mod, mrb_intern(mrb, name), v);
Please sign in to comment.
Something went wrong with that request. Please try again.