@@ -10,6 +10,12 @@ pub const LUA_MULTRET: c_int = -1;
10
10
// Max number of Lua stack slots
11
11
const LUAI_MAXCSTACK : c_int = 1000000 ;
12
12
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
+
13
19
//
14
20
// Pseudo-indices
15
21
//
@@ -144,9 +150,11 @@ extern "C-unwind" {
144
150
pub fn lua_objlen ( L : * mut lua_State , idx : c_int ) -> usize ;
145
151
pub fn lua_tocfunction ( L : * mut lua_State , idx : c_int ) -> Option < lua_CFunction > ;
146
152
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 ;
147
154
pub fn lua_touserdata ( L : * mut lua_State , idx : c_int ) -> * mut c_void ;
148
155
pub fn lua_touserdatatagged ( L : * mut lua_State , idx : c_int , tag : c_int ) -> * mut c_void ;
149
156
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 ;
150
158
pub fn lua_tothread ( L : * mut lua_State , idx : c_int ) -> * mut lua_State ;
151
159
pub fn lua_tobuffer ( L : * mut lua_State , idx : c_int , len : * mut usize ) -> * mut c_void ;
152
160
pub fn lua_topointer ( L : * mut lua_State , idx : c_int ) -> * const c_void ;
@@ -179,7 +187,7 @@ extern "C-unwind" {
179
187
pub fn lua_pushboolean ( L : * mut lua_State , b : c_int ) ;
180
188
pub fn lua_pushthread ( L : * mut lua_State ) -> c_int ;
181
189
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 ) ;
183
191
pub fn lua_newuserdatatagged ( L : * mut lua_State , sz : usize , tag : c_int ) -> * mut c_void ;
184
192
pub fn lua_newuserdatadtor ( L : * mut lua_State , sz : usize , dtor : lua_Udestructor ) -> * mut c_void ;
185
193
@@ -280,6 +288,8 @@ extern "C-unwind" {
280
288
pub fn lua_setuserdatatag ( L : * mut lua_State , idx : c_int , tag : c_int ) ;
281
289
pub fn lua_setuserdatadtor ( L : * mut lua_State , tag : c_int , dtor : Option < lua_Destructor > ) ;
282
290
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 ;
283
293
pub fn lua_clonefunction ( L : * mut lua_State , idx : c_int ) ;
284
294
pub fn lua_cleartable ( L : * mut lua_State , idx : c_int ) ;
285
295
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) {
398
408
lua_pushlstring_ ( L , c_str. as_ptr ( ) , c_str. as_bytes ( ) . len ( ) )
399
409
}
400
410
411
+ #[ inline( always) ]
401
412
pub unsafe fn lua_pushcfunction ( L : * mut lua_State , f : lua_CFunction ) {
402
413
lua_pushcclosurek ( L , f, ptr:: null ( ) , 0 , None )
403
414
}
404
415
416
+ #[ inline( always) ]
405
417
pub unsafe fn lua_pushcfunctiond ( L : * mut lua_State , f : lua_CFunction , debugname : * const c_char ) {
406
418
lua_pushcclosurek ( L , f, debugname, 0 , None )
407
419
}
408
420
421
+ #[ inline( always) ]
409
422
pub unsafe fn lua_pushcclosure ( L : * mut lua_State , f : lua_CFunction , nup : c_int ) {
410
423
lua_pushcclosurek ( L , f, ptr:: null ( ) , nup, None )
411
424
}
412
425
426
+ #[ inline( always) ]
413
427
pub unsafe fn lua_pushcclosured (
414
428
L : * mut lua_State ,
415
429
f : lua_CFunction ,
@@ -419,6 +433,11 @@ pub unsafe fn lua_pushcclosured(
419
433
lua_pushcclosurek ( L , f, debugname, nup, None )
420
434
}
421
435
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
+
422
441
#[ inline( always) ]
423
442
pub unsafe fn lua_setglobal ( L : * mut lua_State , var : * const c_char ) {
424
443
lua_setfield ( L , LUA_GLOBALSINDEX , var)
0 commit comments