fix method bind

This commit is contained in:
2025-10-21 19:29:36 +08:00
parent f5e0474c1f
commit a172949a3d
5 changed files with 192 additions and 117 deletions

View File

@@ -29,6 +29,15 @@ template <> struct mrubypp_converter<int> {
}
};
template <> struct mrubypp_converter<unsigned int> {
static mrb_value to_mrb(mrb_state *mrb, unsigned int var) {
return mrb_fixnum_value(var);
}
static int from_mrb(mrb_state *mrb, mrb_value value) {
return mrb_fixnum(value);
}
};
template <> struct mrubypp_converter<float> {
static mrb_value to_mrb(mrb_state *mrb, float var) {
return mrb_float_value(mrb, var);
@@ -60,6 +69,12 @@ template <> struct mrubypp_converter<std::string> {
}
};
template <> struct mrubypp_converter<const char *> {
static mrb_value to_mrb(mrb_state *mrb, const char *var) {
return mrb_str_new(mrb, var, (mrb_int)strlen(var));
}
};
template <typename T> struct mrubypp_converter<std::vector<T>> {
static mrb_value to_mrb(mrb_state *mrb, const std::vector<T> &var) {
mrb_value ary = mrb_ary_new_capa(mrb, static_cast<mrb_int>(var.size()));