summaryrefslogtreecommitdiff
path: root/namespace.c
diff options
context:
space:
mode:
authorYusuke Endoh <[email protected]>2025-05-01 18:36:24 +0900
committerSatoshi Tagomori <[email protected]>2025-05-11 23:32:50 +0900
commit4b33b468ac2f20d7b13e691ecc2c7e857b53d356 ()
tree794837dfc94a267c66fc261807ced0e1eaa38732 /namespace.c
parentcf3e2bbad27b8e37fcad7b804b44b907eca45a86 (diff)
Fix function pointer type mismatch with `rb_define_private_method`
`rb_define_private_method` performs strict type checking on the function pointer. As a result, we cannot pass the function a generic signature. ``` //workspace/src/namespace.c:1097:72: note: expected 'VALUE (*)(void)' {aka 'long unsigned int (*)(void)'} but argument is of type 'VALUE (*)(int, VALUE *, VALUE)' {aka 'long unsigned int (*)(int, long unsigned int *, long unsigned int)'} 1097 | namespace_define_loader_method(VALUE module, const char *name, VALUE (*func)(ANYARGS), int argc) | ~~~~~~~~^~~~~~~~~~~~~~ ``` This commit defines the method directly to avoid the mismatch error.
-rw-r--r--namespace.c12
1 files changed, 6 insertions, 6 deletions
@@ -1094,10 +1094,10 @@ setup_pushing_loading_namespace(rb_namespace_t *ns)
}
static void
-namespace_define_loader_method(VALUE module, const char *name, VALUE (*func)(ANYARGS), int argc)
{
- rb_define_private_method(module, name, func, argc);
- rb_define_singleton_method(module, name, func, argc);
}
void
@@ -1118,9 +1118,9 @@ Init_Namespace(void)
}
rb_mNamespaceLoader = rb_define_module_under(rb_cNamespace, "Loader");
- namespace_define_loader_method(rb_mNamespaceLoader, "require", rb_namespace_user_loading_func, -1);
- namespace_define_loader_method(rb_mNamespaceLoader, "require_relative", rb_namespace_user_loading_func, -1);
- namespace_define_loader_method(rb_mNamespaceLoader, "load", rb_namespace_user_loading_func, -1);
rb_define_singleton_method(rb_cNamespace, "enabled?", rb_namespace_s_getenabled, 0);
rb_define_singleton_method(rb_cNamespace, "current", rb_namespace_current, 0);