@@ -442,13 +442,13 @@ pub const Lua = struct {
442
442
/// Pushes onto the stack the value t[key] where t is the value at the given index
443
443
/// See https://www.lua.org/manual/5.4/manual.html#lua_getfield
444
444
pub fn getField (lua : * Lua , index : i32 , key : [:0 ]const u8 ) void {
445
- c .lua_getfield (lua .state , index , key );
445
+ c .lua_getfield (lua .state , index , key . ptr );
446
446
}
447
447
448
448
/// Pushes onto the stack the value of the global name
449
449
/// See https://www.lua.org/manual/5.4/manual.html#lua_getglobal
450
450
pub fn getGlobal (lua : * Lua , name : [:0 ]const u8 ) void {
451
- c .lua_getglobal (lua .state , name );
451
+ c .lua_getglobal (lua .state , name . ptr );
452
452
}
453
453
454
454
/// Pushes onto the stack the Lua value associated with the full userdata at the given index.
@@ -562,7 +562,7 @@ pub const Lua = struct {
562
562
/// If there are no errors, pushes the compiled chunk on the top of the stack as a function
563
563
/// See https://www.lua.org/manual/5.4/manual.html#lua_load
564
564
pub fn load (lua : * Lua , reader : CReaderFn , data : * anyopaque , chunk_name : [:0 ]const u8 ) ! void {
565
- const ret = c .lua_load (lua .state , reader , data , chunk_name );
565
+ const ret = c .lua_load (lua .state , reader , data , chunk_name . ptr );
566
566
switch (ret ) {
567
567
StatusCode .ok = > return ,
568
568
StatusCode .err_syntax = > return error .Syntax ,
@@ -657,7 +657,7 @@ pub const Lua = struct {
657
657
658
658
/// Push a formatted string onto the stack and return a pointer to the string
659
659
pub fn pushFStringEx (lua : * Lua , fmt : [:0 ]const u8 , args : anytype ) [* :0 ]const u8 {
660
- const ptr = @call (.{}, c .lua_pushfstring , .{ lua .state , fmt } ++ args );
660
+ const ptr = @call (.{}, c .lua_pushfstring , .{ lua .state , fmt . ptr } ++ args );
661
661
return @ptrCast ([* :0 ]const u8 , ptr );
662
662
}
663
663
@@ -782,12 +782,12 @@ pub const Lua = struct {
782
782
/// Does the equivalent to t[`k`] = v where t is the value at the given `index`
783
783
/// and v is the value on the top of the stack
784
784
pub fn setField (lua : * Lua , index : i32 , k : [:0 ]const u8 ) void {
785
- c .lua_setfield (lua .state , index , k );
785
+ c .lua_setfield (lua .state , index , k . ptr );
786
786
}
787
787
788
788
/// Pops a value from the stack and sets it as the new value of global `name`
789
789
pub fn setGlobal (lua : * Lua , name : [:0 ]const u8 ) void {
790
- c .lua_setglobal (lua .state , name );
790
+ c .lua_setglobal (lua .state , name . ptr );
791
791
}
792
792
793
793
/// Pops a table or nil from the stack and sets that value as the new metatable for the
@@ -1062,7 +1062,7 @@ pub const Lua = struct {
1062
1062
1063
1063
/// Calls a metamethod
1064
1064
pub fn callMeta (lua : * Lua , obj : i32 , field : [:0 ]const u8 ) ! void {
1065
- if (c .luaL_callmeta (lua .state , obj , field ) == 0 ) return error .Fail ;
1065
+ if (c .luaL_callmeta (lua .state , obj , field . ptr ) == 0 ) return error .Fail ;
1066
1066
}
1067
1067
1068
1068
/// Checks whether the function has an argument of any type at position `arg`
@@ -1080,7 +1080,7 @@ pub const Lua = struct {
1080
1080
var length : usize = 0 ;
1081
1081
const str = c .luaL_checklstring (lua .state , arg , @ptrCast ([* c ]usize , & length ));
1082
1082
// luaL_checklstring never returns null (throws lua error)
1083
- return str .? [0.. length :0 ];
1083
+ return str [0.. length :0 ];
1084
1084
}
1085
1085
1086
1086
/// Checks whether the function argument `arg` is a number and returns the number
@@ -1151,15 +1151,15 @@ pub const Lua = struct {
1151
1151
1152
1152
/// Raises an error
1153
1153
pub fn raiseErrorAux (lua : * Lua , fmt : [:0 ]const u8 , args : anytype ) noreturn {
1154
- _ = @call (.{}, c .luaL_error , .{ lua .state , fmt } ++ args );
1154
+ _ = @call (.{}, c .luaL_error , .{ lua .state , fmt . ptr } ++ args );
1155
1155
unreachable ;
1156
1156
}
1157
1157
1158
1158
/// Pushes onto the stack the field `e` from the metatable of the object at index `obj`
1159
1159
/// and returns the type of the pushed value
1160
1160
/// TODO: possibly return an error if nil
1161
1161
pub fn getMetaField (lua : * Lua , obj : i32 , field : [:0 ]const u8 ) ! LuaType {
1162
- const val_type = @intToEnum (LuaType , c .luaL_getmetafield (lua .state , obj , field ));
1162
+ const val_type = @intToEnum (LuaType , c .luaL_getmetafield (lua .state , obj , field . ptr ));
1163
1163
if (val_type == .nil ) return error .Fail ;
1164
1164
return val_type ;
1165
1165
}
@@ -1174,12 +1174,12 @@ pub const Lua = struct {
1174
1174
/// Creates a copy of string `str`, replacing any occurrence of the string `pat` with the string `rep`
1175
1175
/// Pushes the resulting string on the stack and returns it.
1176
1176
pub fn gSub (lua : * Lua , str : [:0 ]const u8 , pat : [:0 ]const u8 , rep : [:0 ]const u8 ) [:0 ]const u8 {
1177
- return std .mem .span (c .luaL_gsub (lua .state , str , pat , rep ));
1177
+ return std .mem .span (c .luaL_gsub (lua .state , str . ptr , pat . ptr , rep . ptr ));
1178
1178
}
1179
1179
1180
1180
/// Loads a buffer as a Lua chunk
1181
1181
pub fn loadBuffer (lua : * Lua , buf : []const u8 , name : [:0 ]const u8 ) ! void {
1182
- switch (c .luaL_loadbuffer (lua .state , buf .ptr , buf .len , name )) {
1182
+ switch (c .luaL_loadbuffer (lua .state , buf .ptr , buf .len , name . ptr )) {
1183
1183
StatusCode .ok = > return ,
1184
1184
StatusCode .err_syntax = > return error .Syntax ,
1185
1185
StatusCode .err_memory = > return error .Memory ,
@@ -1189,7 +1189,7 @@ pub const Lua = struct {
1189
1189
1190
1190
/// Equivalent to `Lua.loadFileX()` with mode equal to binary+text
1191
1191
pub fn loadFile (lua : * Lua , file_name : [:0 ]const u8 ) ! void {
1192
- const ret = c .luaL_loadfile (lua .state , file_name );
1192
+ const ret = c .luaL_loadfile (lua .state , file_name . ptr );
1193
1193
switch (ret ) {
1194
1194
StatusCode .ok = > return ,
1195
1195
StatusCode .err_syntax = > return error .Syntax ,
@@ -1202,7 +1202,7 @@ pub const Lua = struct {
1202
1202
1203
1203
/// Loads a string as a Lua chunk
1204
1204
pub fn loadString (lua : * Lua , str : [:0 ]const u8 ) ! void {
1205
- const ret = c .luaL_loadstring (lua .state , str );
1205
+ const ret = c .luaL_loadstring (lua .state , str . ptr );
1206
1206
switch (ret ) {
1207
1207
StatusCode .ok = > return ,
1208
1208
StatusCode .err_syntax = > return error .Syntax ,
@@ -1223,7 +1223,7 @@ pub const Lua = struct {
1223
1223
/// If the registry already has the key `key`, returns an error
1224
1224
/// Otherwise, creates a new table to be used as a metatable for userdata
1225
1225
pub fn newMetatable (lua : * Lua , key : [:0 ]const u8 ) ! void {
1226
- if (c .luaL_newmetatable (lua .state , key ) == 0 ) return error .Fail ;
1226
+ if (c .luaL_newmetatable (lua .state , key . ptr ) == 0 ) return error .Fail ;
1227
1227
}
1228
1228
1229
1229
/// Creates a new Lua state with an allocator using the default libc allocator
@@ -1245,7 +1245,7 @@ pub const Lua = struct {
1245
1245
pub fn optBytes (lua : * Lua , arg : i32 , default : [:0 ]const u8 ) [:0 ]const u8 {
1246
1246
var length : usize = 0 ;
1247
1247
// will never return null because default cannot be null
1248
- const ret : [* ]const u8 = c .luaL_optlstring (lua .state , arg , default , & length );
1248
+ const ret : [* ]const u8 = c .luaL_optlstring (lua .state , arg , default . ptr , & length );
1249
1249
if (ret == default .ptr ) return default ;
1250
1250
return ret [0.. length :0 ];
1251
1251
}
@@ -1260,7 +1260,7 @@ pub const Lua = struct {
1260
1260
/// If the argment is absent or nil returns `default`
1261
1261
pub fn optString (lua : * Lua , arg : i32 , default : [:0 ]const u8 ) [* :0 ]const u8 {
1262
1262
// translate-c error
1263
- return c .luaL_optlstring (lua .state , arg , default , null );
1263
+ return c .luaL_optlstring (lua .state , arg , default . ptr , null );
1264
1264
}
1265
1265
1266
1266
/// Creates and returns a reference in the table at index `index` for the object on the top of the stack
@@ -1409,7 +1409,7 @@ pub const Buffer = struct {
1409
1409
1410
1410
/// Adds the zero-terminated string pointed to by `str` to the buffer
1411
1411
pub fn addString (buf : * Buffer , str : [:0 ]const u8 ) void {
1412
- c .luaL_addstring (& buf .b , str );
1412
+ c .luaL_addstring (& buf .b , str . ptr );
1413
1413
}
1414
1414
1415
1415
/// Adds the value on the top of the stack to the buffer
0 commit comments