Function mrb_define_class_method

Source
pub unsafe extern "C" fn mrb_define_class_method(
    mrb: *mut mrb_state,
    cla: *mut RClass,
    name: *const c_char,
    fun: mrb_func_t,
    aspec: mrb_aspec,
)
Expand description

Defines a class method.

Example:

class Foo
  def Foo.bar
  end
end
// C style
mrb_value bar_method(mrb_state* mrb, mrb_value self){
  return mrb_nil_value();
}
void mrb_example_gem_init(mrb_state* mrb){
  struct RClass *foo;
  foo = mrb_define_class(mrb, "Foo", mrb->object_class);
  mrb_define_class_method(mrb, foo, "bar", bar_method, MRB_ARGS_NONE());
}

@param mrb The MRuby state reference. @param cla The class where the class method will be defined. @param name The name of the class method being defined. @param fun The function pointer to the class method definition. @param aspec The method parameters declaration.