@@ -829,9 +829,14 @@ pub const Lua = struct {
829
829
return c .lua_pushstring (lua .state , str .ptr ).? [0.. str .len :0 ];
830
830
}
831
831
832
+ /// Pushes this thread onto the stack
833
+ pub fn pushThread (lua : * Lua ) void {
834
+ _ = lua .pushThreadEx ();
835
+ }
836
+
832
837
/// Pushes this thread onto the stack
833
838
/// Returns true if this thread is the main thread of its state
834
- pub fn pushThread (lua : * Lua ) bool {
839
+ pub fn pushThreadEx (lua : * Lua ) bool {
835
840
return c .lua_pushthread (lua .state ) != 0 ;
836
841
}
837
842
@@ -1203,7 +1208,13 @@ pub const Lua = struct {
1203
1208
}
1204
1209
1205
1210
/// Gets information about a local variable
1206
- pub fn getLocal (lua : * Lua , info : * DebugInfo , n : i32 ) ! [:0 ]const u8 {
1211
+ pub fn getLocal (lua : * Lua , info : * DebugInfo , n : i32 ) ! void {
1212
+ _ = try lua .getLocalEx (info , n );
1213
+ }
1214
+
1215
+ /// Gets information about a local variable
1216
+ /// Returns the name of the local variable
1217
+ pub fn getLocalEx (lua : * Lua , info : * DebugInfo , n : i32 ) ! [:0 ]const u8 {
1207
1218
var ar : Debug = undefined ;
1208
1219
ar .i_ci = @ptrCast (* c .struct_CallInfo , info .private );
1209
1220
if (c .lua_getlocal (lua .state , & ar , n )) | name | {
@@ -1233,9 +1244,15 @@ pub const Lua = struct {
1233
1244
c .lua_sethook (lua .state , hook_fn , hook_mask , count );
1234
1245
}
1235
1246
1247
+ /// Sets the value of a local variable
1248
+ pub fn setLocal (lua : * Lua , info : * DebugInfo , n : i32 ) ! void {
1249
+ _ = try lua .setLocalEx (info , n );
1250
+ }
1251
+
1236
1252
/// Sets the value of a local variable
1237
1253
/// Returns an error when the index is greater than the number of active locals
1238
- pub fn setLocal (lua : * Lua , info : * DebugInfo , n : i32 ) ! [:0 ]const u8 {
1254
+ /// Returns the name of the local variable
1255
+ pub fn setLocalEx (lua : * Lua , info : * DebugInfo , n : i32 ) ! [:0 ]const u8 {
1239
1256
var ar : Debug = undefined ;
1240
1257
ar .i_ci = @ptrCast (* c .struct_CallInfo , info .private );
1241
1258
if (c .lua_setlocal (lua .state , & ar , n )) | name | {
@@ -1245,7 +1262,14 @@ pub const Lua = struct {
1245
1262
}
1246
1263
1247
1264
/// Sets the value of a closure's upvalue
1248
- pub fn setUpvalue (lua : * Lua , func_index : i32 , n : i32 ) ! [:0 ]const u8 {
1265
+ /// Returns an error if the upvalu does not exist
1266
+ pub fn setUpvalue (lua : * Lua , func_index : i32 , n : i32 ) ! void {
1267
+ _ = try lua .setUpvalueEx (func_index , n );
1268
+ }
1269
+
1270
+ /// Sets the value of a closure's upvalue
1271
+ /// Returns the name of the upvalue or an error if the upvalue does not exist
1272
+ pub fn setUpvalueEx (lua : * Lua , func_index : i32 , n : i32 ) ! [:0 ]const u8 {
1249
1273
if (c .lua_setupvalue (lua .state , func_index , n )) | name | {
1250
1274
return std .mem .span (name );
1251
1275
}
0 commit comments