@@ -32,6 +32,7 @@ pub struct Function(pub(crate) ValueRef);
3232///
3333/// [`Lua Debug Interface`]: https://www.lua.org/manual/5.4/manual.html#4.7
3434#[ derive( Clone , Debug ) ]
35+ #[ non_exhaustive]
3536pub struct FunctionInfo {
3637 /// A (reasonable) name of the function (`None` if the name cannot be found).
3738 pub name : Option < String > ,
@@ -50,15 +51,16 @@ pub struct FunctionInfo {
5051 pub line_defined : Option < usize > ,
5152 /// The line number where the definition of the function ends (not set by Luau).
5253 pub last_line_defined : Option < usize > ,
53- /// Number of function parameters
54+ /// The number of upvalues of the function.
55+ pub num_upvalues : u8 ,
56+ /// The number of parameters of the function (always 0 for C).
5457 #[ cfg( any( not( any( feature = "lua51" , feature = "luajit" ) ) , doc) ) ]
55- pub num_params : usize ,
56- /// True if function accepts variable args
58+ #[ cfg_attr( docsrs, doc( cfg( not( any( feature = "lua51" , feature = "luajit" ) ) ) ) ) ]
59+ pub num_params : u8 ,
60+ /// Whether the function is a variadic function (always true for C).
5761 #[ cfg( any( not( any( feature = "lua51" , feature = "luajit" ) ) , doc) ) ]
62+ #[ cfg_attr( docsrs, doc( cfg( not( any( feature = "lua51" , feature = "luajit" ) ) ) ) ) ]
5863 pub is_vararg : bool ,
59- /// Number of upvalues
60- #[ cfg( any( not( feature = "luau" ) , doc) ) ]
61- pub nups : usize ,
6264}
6365
6466/// Luau function coverage snapshot.
@@ -365,11 +367,16 @@ impl Function {
365367
366368 let mut ar: ffi:: lua_Debug = mem:: zeroed ( ) ;
367369 lua. push_ref ( & self . 0 ) ;
370+
368371 #[ cfg( not( feature = "luau" ) ) ]
369372 let res = ffi:: lua_getinfo ( state, cstr ! ( ">Snu" ) , & mut ar) ;
373+ #[ cfg( not( feature = "luau" ) ) ]
374+ mlua_assert ! ( res != 0 , "lua_getinfo failed with `>Snu`" ) ;
375+
376+ #[ cfg( feature = "luau" ) ]
377+ let res = ffi:: lua_getinfo ( state, -1 , cstr ! ( "snau" ) , & mut ar) ;
370378 #[ cfg( feature = "luau" ) ]
371- let res = ffi:: lua_getinfo ( state, -1 , cstr ! ( "sn" ) , & mut ar) ;
372- mlua_assert ! ( res != 0 , "lua_getinfo failed with `>Sn`" ) ;
379+ mlua_assert ! ( res != 0 , "lua_getinfo failed with `snau`" ) ;
373380
374381 FunctionInfo {
375382 name : ptr_to_lossy_str ( ar. name ) . map ( |s| s. into_owned ( ) ) ,
@@ -391,12 +398,14 @@ impl Function {
391398 last_line_defined : linenumber_to_usize ( ar. lastlinedefined ) ,
392399 #[ cfg( feature = "luau" ) ]
393400 last_line_defined : None ,
401+ #[ cfg( not( feature = "luau" ) ) ]
402+ num_upvalues : ar. nups as _ ,
403+ #[ cfg( feature = "luau" ) ]
404+ num_upvalues : ar. nupvals ,
394405 #[ cfg( not( any( feature = "lua51" , feature = "luajit" ) ) ) ]
395- num_params : ar. nparams as usize ,
406+ num_params : ar. nparams ,
396407 #[ cfg( not( any( feature = "lua51" , feature = "luajit" ) ) ) ]
397408 is_vararg : ar. isvararg != 0 ,
398- #[ cfg( not( feature = "luau" ) ) ]
399- nups : ar. nups as usize ,
400409 }
401410 }
402411 }
0 commit comments