@@ -358,20 +358,15 @@ fn createUserDataFunc(comptime T: type, comptime method_name: []const u8, method
358358
359359/// Creates and registers a complete metatable for userdata type T.
360360///
361- /// This is the main public API for userdata registration. It counts methods,
362- /// creates the metatable, registers all methods (init, instance, static),
363- /// and registers metamethods. Returns the number of methods registered.
361+ /// This is the main public API for userdata registration. It creates the metatable,
362+ /// registers all methods (init, instance, static), and registers metamethods.
364363///
365364/// The type_name will be used for Lua userdata type checking and must be
366365/// a compile-time string literal ending with null terminator.
367- pub fn createMetaTable (comptime T : type , lua_state : * State , comptime type_name : [:0 ]const u8 ) u32 {
366+ pub fn createMetaTable (comptime T : type , lua_state : * State , comptime type_name : [:0 ]const u8 ) void {
368367 const struct_info = @typeInfo (T ).@"struct" ;
369368
370- // Detect what kind of methods we have in this struct
371- // We're interested in:
372- // - How many public methods (not deinit, not metamethods)
373- // - Whether __index metamethod is going to be defined by the user
374- var method_count : u32 = 0 ;
369+ // Check if user defines __index metamethod
375370 comptime var has_user_index = false ;
376371 inline for (struct_info .decls ) | decl | {
377372 if (@hasDecl (T , decl .name )) {
@@ -380,13 +375,7 @@ pub fn createMetaTable(comptime T: type, lua_state: *State, comptime type_name:
380375 // Check for __index metamethod
381376 if (comptime std .mem .eql (u8 , decl .name , "__index" )) {
382377 has_user_index = true ;
383- }
384-
385- // Count regular methods (not deinit, not metamethods)
386- if (! comptime std .mem .eql (u8 , decl .name , "deinit" ) and
387- MetaMethod .fromStr (decl .name ) == null )
388- {
389- method_count += 1 ;
378+ break ;
390379 }
391380 }
392381 }
@@ -441,6 +430,4 @@ pub fn createMetaTable(comptime T: type, lua_state: *State, comptime type_name:
441430
442431 // Store the metatable in the registry for later use
443432 lua_state .setField (State .REGISTRYINDEX , type_name );
444-
445- return method_count ;
446433}
0 commit comments