@@ -96,7 +96,7 @@ typedef struct loader_impl_rb_module_eval_protect_type
9696
9797static class_interface rb_class_interface_singleton (void );
9898static object_interface rb_object_interface_singleton (void );
99- static void rb_loader_impl_discover_methods (klass c , VALUE cls , const char * class_name_str , const char * method_type_str , VALUE methods , int (* register_method )(klass , method ));
99+ static void rb_loader_impl_discover_methods (klass c , VALUE cls , const char * class_name_str , enum class_visibility_id visibility , const char * method_type_str , VALUE methods , int (* register_method )(klass , method ));
100100
101101int function_rb_interface_create (function func , function_impl impl )
102102{
@@ -1348,7 +1348,7 @@ loader_impl_rb_function rb_function_create(loader_impl_rb_module rb_module, ID i
13481348 return NULL ;
13491349}
13501350
1351- void rb_loader_impl_discover_methods (klass c , VALUE cls , const char * class_name_str , const char * method_type_str , VALUE methods , int (* register_method )(klass , method ))
1351+ void rb_loader_impl_discover_methods (klass c , VALUE cls , const char * class_name_str , enum class_visibility_id visibility , const char * method_type_str , VALUE methods , int (* register_method )(klass , method ))
13521352{
13531353 VALUE methods_v_size = rb_funcall (methods , rb_intern ("size" ), 0 );
13541354 int method_index , methods_size = FIX2INT (methods_v_size );
@@ -1388,8 +1388,8 @@ void rb_loader_impl_discover_methods(klass c, VALUE cls, const char *class_name_
13881388 method_name_str ,
13891389 args_count ,
13901390 (method_impl )instance_method ,
1391- VISIBILITY_PUBLIC , /* TODO: Check previous TODO inside this function */
1392- SYNCHRONOUS , /* There is not async functions in Ruby */
1391+ visibility ,
1392+ SYNCHRONOUS , /* There is not async functions in Ruby */
13931393 NULL );
13941394
13951395 signature s = method_signature (m );
@@ -1408,7 +1408,7 @@ void rb_loader_impl_discover_methods(klass c, VALUE cls, const char *class_name_
14081408 }
14091409 }
14101410
1411- if (register_method (c , m ) = = 0 )
1411+ if (register_method (c , m ) ! = 0 )
14121412 {
14131413 log_write ("metacall" , LOG_LEVEL_ERROR , "Ruby failed to register method '%s'" , method_name_str );
14141414 }
@@ -1497,17 +1497,30 @@ int rb_loader_impl_discover_module(loader_impl impl, loader_impl_rb_module rb_mo
14971497 rb_cls -> impl = impl ;
14981498 rb_cls -> class = cls ;
14991499
1500- /*
1501- * TODO:
1502- * rb_obj_private_methods, rb_obj_protected_methods, rb_obj_public_methods and
1503- * rb_obj_singleton_methods, can be used instead of rb_class_instance_methods
1504- */
1505- VALUE argv [1 ] = { Qtrue }; /* include_superclasses ? Qtrue : Qfalse; */
1506- VALUE methods = rb_class_instance_methods (1 , argv , cls ); /* argc, argv, class */
1507- rb_loader_impl_discover_methods (c , cls , class_name_str , "instance_method" , methods , & class_register_method );
1500+ VALUE argv [1 ] = { Qtrue }; /* include_superclasses ? Qtrue : Qfalse; */
1501+ VALUE methods = rb_class_public_instance_methods (1 , argv , cls ); /* argc, argv, cls */
1502+ rb_loader_impl_discover_methods (c , cls , class_name_str , VISIBILITY_PUBLIC , "instance_method" , methods , & class_register_method );
1503+
1504+ methods = rb_class_protected_instance_methods (1 , argv , cls );
1505+ rb_loader_impl_discover_methods (c , cls , class_name_str , VISIBILITY_PROTECTED , "instance_method" , methods , & class_register_method );
1506+
1507+ methods = rb_class_private_instance_methods (1 , argv , cls );
1508+ rb_loader_impl_discover_methods (c , cls , class_name_str , VISIBILITY_PRIVATE , "instance_method" , methods , & class_register_method );
15081509
1509- methods = rb_obj_singleton_methods (1 , argv , cls ); /* argc, argv, class */
1510- rb_loader_impl_discover_methods (c , cls , class_name_str , "singleton_method" , methods , & class_register_static_method );
1510+ #if RUBY_VERSION_MAJOR == 3 && RUBY_VERSION_MINOR >= 0
1511+ methods = rb_obj_public_methods (1 , argv , cls );
1512+ rb_loader_impl_discover_methods (c , cls , class_name_str , VISIBILITY_PUBLIC , "singleton_method" , methods , & class_register_static_method );
1513+
1514+ methods = rb_obj_protected_methods (1 , argv , cls );
1515+ rb_loader_impl_discover_methods (c , cls , class_name_str , VISIBILITY_PROTECTED , "singleton_method" , methods , & class_register_static_method );
1516+
1517+ methods = rb_obj_private_methods (1 , argv , cls );
1518+ rb_loader_impl_discover_methods (c , cls , class_name_str , VISIBILITY_PRIVATE , "singleton_method" , methods , & class_register_static_method );
1519+ #else
1520+ methods = rb_obj_singleton_methods (1 , argv , cls );
1521+ rb_loader_impl_discover_methods (c , cls , class_name_str , VISIBILITY_PUBLIC , "singleton_method" , methods , & class_register_static_method );
1522+ #endif
1523+ /* TODO: Implement attributes */
15111524
15121525 /* Define default constructor. Ruby only supports one constructor, a
15131526 * method called 'initialize'. It can have arguments but when inspected via
0 commit comments