mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Add functions that take symbols as arguments.
- :
This commit is contained in:
+28
-3
@@ -1323,17 +1323,36 @@ mrb_define_singleton_method(mrb_state *mrb, struct RObject *o, const char *name,
|
||||
mrb_define_method_id(mrb, o->c, mrb_intern_cstr(mrb, name), func, aspec);
|
||||
}
|
||||
|
||||
MRB_API void
|
||||
mrb_define_singleton_method_id(mrb_state *mrb, struct RObject *o, mrb_sym name, mrb_func_t func, mrb_aspec aspec)
|
||||
{
|
||||
prepare_singleton_class(mrb, (struct RBasic*)o);
|
||||
mrb_define_method_id(mrb, o->c, name, func, aspec);
|
||||
}
|
||||
|
||||
MRB_API void
|
||||
mrb_define_class_method(mrb_state *mrb, struct RClass *c, const char *name, mrb_func_t func, mrb_aspec aspec)
|
||||
{
|
||||
mrb_define_singleton_method(mrb, (struct RObject*)c, name, func, aspec);
|
||||
}
|
||||
|
||||
MRB_API void
|
||||
mrb_define_class_method_id(mrb_state *mrb, struct RClass *c, mrb_sym name, mrb_func_t func, mrb_aspec aspec)
|
||||
{
|
||||
mrb_define_singleton_method_id(mrb, (struct RObject*)c, name, func, aspec);
|
||||
}
|
||||
|
||||
MRB_API void
|
||||
mrb_define_module_function_id(mrb_state *mrb, struct RClass *c, mrb_sym name, mrb_func_t func, mrb_aspec aspec)
|
||||
{
|
||||
mrb_define_class_method_id(mrb, c, name, func, aspec);
|
||||
mrb_define_method_id(mrb, c, name, func, aspec);
|
||||
}
|
||||
|
||||
MRB_API void
|
||||
mrb_define_module_function(mrb_state *mrb, struct RClass *c, const char *name, mrb_func_t func, mrb_aspec aspec)
|
||||
{
|
||||
mrb_define_class_method(mrb, c, name, func, aspec);
|
||||
mrb_define_method(mrb, c, name, func, aspec);
|
||||
mrb_define_module_function_id(mrb, c, mrb_intern_cstr(mrb, name), func, aspec);
|
||||
}
|
||||
|
||||
#ifdef MRB_METHOD_CACHE
|
||||
@@ -1927,7 +1946,7 @@ undef_method(mrb_state *mrb, struct RClass *c, mrb_sym a)
|
||||
mrb_define_method_raw(mrb, c, a, m);
|
||||
}
|
||||
|
||||
void
|
||||
MRB_API void
|
||||
mrb_undef_method_id(mrb_state *mrb, struct RClass *c, mrb_sym a)
|
||||
{
|
||||
if (!mrb_obj_respond_to(mrb, c, a)) {
|
||||
@@ -1942,6 +1961,12 @@ mrb_undef_method(mrb_state *mrb, struct RClass *c, const char *name)
|
||||
undef_method(mrb, c, mrb_intern_cstr(mrb, name));
|
||||
}
|
||||
|
||||
MRB_API void
|
||||
mrb_undef_class_method_id(mrb_state *mrb, struct RClass *c, mrb_sym name)
|
||||
{
|
||||
mrb_undef_method_id(mrb, mrb_class_ptr(mrb_singleton_class(mrb, mrb_obj_value(c))), name);
|
||||
}
|
||||
|
||||
MRB_API void
|
||||
mrb_undef_class_method(mrb_state *mrb, struct RClass *c, const char *name)
|
||||
{
|
||||
|
||||
@@ -872,6 +872,12 @@ mrb_const_remove(mrb_state *mrb, mrb_value mod, mrb_sym sym)
|
||||
mrb_iv_remove(mrb, mod, sym);
|
||||
}
|
||||
|
||||
MRB_API void
|
||||
mrb_define_const_id(mrb_state *mrb, struct RClass *mod, mrb_sym name, mrb_value v)
|
||||
{
|
||||
mrb_obj_iv_set(mrb, (struct RObject*)mod, name, v);
|
||||
}
|
||||
|
||||
MRB_API void
|
||||
mrb_define_const(mrb_state *mrb, struct RClass *mod, const char *name, mrb_value v)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user