@@ -10,6 +10,12 @@ pub const LUA_MULTRET: c_int = -1;
1010// Max number of Lua stack slots
1111const LUAI_MAXCSTACK : c_int = 1000000 ;
1212
13+ // Number of valid Lua userdata tags
14+ const LUA_UTAG_LIMIT : c_int = 128 ;
15+
16+ // Number of valid Lua lightuserdata tags
17+ const LUA_LUTAG_LIMIT : c_int = 128 ;
18+
1319//
1420// Pseudo-indices
1521//
@@ -144,9 +150,11 @@ extern "C-unwind" {
144150 pub fn lua_objlen ( L : * mut lua_State , idx : c_int ) -> usize ;
145151 pub fn lua_tocfunction ( L : * mut lua_State , idx : c_int ) -> Option < lua_CFunction > ;
146152 pub fn lua_tolightuserdata ( L : * mut lua_State , idx : c_int ) -> * mut c_void ;
153+ pub fn lua_tolightuserdatatagged ( L : * mut lua_State , idx : c_int , tag : c_int ) -> * mut c_void ;
147154 pub fn lua_touserdata ( L : * mut lua_State , idx : c_int ) -> * mut c_void ;
148155 pub fn lua_touserdatatagged ( L : * mut lua_State , idx : c_int , tag : c_int ) -> * mut c_void ;
149156 pub fn lua_userdatatag ( L : * mut lua_State , idx : c_int ) -> c_int ;
157+ pub fn lua_lightuserdatatag ( L : * mut lua_State , idx : c_int ) -> c_int ;
150158 pub fn lua_tothread ( L : * mut lua_State , idx : c_int ) -> * mut lua_State ;
151159 pub fn lua_tobuffer ( L : * mut lua_State , idx : c_int , len : * mut usize ) -> * mut c_void ;
152160 pub fn lua_topointer ( L : * mut lua_State , idx : c_int ) -> * const c_void ;
@@ -179,7 +187,7 @@ extern "C-unwind" {
179187 pub fn lua_pushboolean ( L : * mut lua_State , b : c_int ) ;
180188 pub fn lua_pushthread ( L : * mut lua_State ) -> c_int ;
181189
182- pub fn lua_pushlightuserdata ( L : * mut lua_State , p : * mut c_void ) ;
190+ pub fn lua_pushlightuserdatatagged ( L : * mut lua_State , p : * mut c_void , tag : c_int ) ;
183191 pub fn lua_newuserdatatagged ( L : * mut lua_State , sz : usize , tag : c_int ) -> * mut c_void ;
184192 pub fn lua_newuserdatadtor ( L : * mut lua_State , sz : usize , dtor : lua_Udestructor ) -> * mut c_void ;
185193
@@ -280,6 +288,8 @@ extern "C-unwind" {
280288 pub fn lua_setuserdatatag ( L : * mut lua_State , idx : c_int , tag : c_int ) ;
281289 pub fn lua_setuserdatadtor ( L : * mut lua_State , tag : c_int , dtor : Option < lua_Destructor > ) ;
282290 pub fn lua_getuserdatadtor ( L : * mut lua_State , tag : c_int ) -> Option < lua_Destructor > ;
291+ pub fn lua_setlightuserdataname ( L : * mut lua_State , tag : c_int , name : * const c_char ) ;
292+ pub fn lua_getlightuserdataname ( L : * mut lua_State , tag : c_int ) -> * const c_char ;
283293 pub fn lua_clonefunction ( L : * mut lua_State , idx : c_int ) ;
284294 pub fn lua_cleartable ( L : * mut lua_State , idx : c_int ) ;
285295 pub fn lua_getallocf ( L : * mut lua_State , ud : * mut * mut c_void ) -> lua_Alloc ;
@@ -398,18 +408,22 @@ pub unsafe fn lua_pushliteral(L: *mut lua_State, s: &'static str) {
398408 lua_pushlstring_ ( L , c_str. as_ptr ( ) , c_str. as_bytes ( ) . len ( ) )
399409}
400410
411+ #[ inline( always) ]
401412pub unsafe fn lua_pushcfunction ( L : * mut lua_State , f : lua_CFunction ) {
402413 lua_pushcclosurek ( L , f, ptr:: null ( ) , 0 , None )
403414}
404415
416+ #[ inline( always) ]
405417pub unsafe fn lua_pushcfunctiond ( L : * mut lua_State , f : lua_CFunction , debugname : * const c_char ) {
406418 lua_pushcclosurek ( L , f, debugname, 0 , None )
407419}
408420
421+ #[ inline( always) ]
409422pub unsafe fn lua_pushcclosure ( L : * mut lua_State , f : lua_CFunction , nup : c_int ) {
410423 lua_pushcclosurek ( L , f, ptr:: null ( ) , nup, None )
411424}
412425
426+ #[ inline( always) ]
413427pub unsafe fn lua_pushcclosured (
414428 L : * mut lua_State ,
415429 f : lua_CFunction ,
@@ -419,6 +433,11 @@ pub unsafe fn lua_pushcclosured(
419433 lua_pushcclosurek ( L , f, debugname, nup, None )
420434}
421435
436+ #[ inline( always) ]
437+ pub unsafe fn lua_pushlightuserdata ( L : * mut lua_State , p : * mut c_void ) {
438+ lua_pushlightuserdatatagged ( L , p, 0 )
439+ }
440+
422441#[ inline( always) ]
423442pub unsafe fn lua_setglobal ( L : * mut lua_State , var : * const c_char ) {
424443 lua_setfield ( L , LUA_GLOBALSINDEX , var)
0 commit comments