@@ -442,13 +442,13 @@ pub const Lua = struct {
442442 /// Pushes onto the stack the value t[key] where t is the value at the given index
443443 /// See https://www.lua.org/manual/5.4/manual.html#lua_getfield
444444 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 );
446446 }
447447
448448 /// Pushes onto the stack the value of the global name
449449 /// See https://www.lua.org/manual/5.4/manual.html#lua_getglobal
450450 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 );
452452 }
453453
454454 /// Pushes onto the stack the Lua value associated with the full userdata at the given index.
@@ -562,7 +562,7 @@ pub const Lua = struct {
562562 /// If there are no errors, pushes the compiled chunk on the top of the stack as a function
563563 /// See https://www.lua.org/manual/5.4/manual.html#lua_load
564564 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 );
566566 switch (ret ) {
567567 StatusCode .ok = > return ,
568568 StatusCode .err_syntax = > return error .Syntax ,
@@ -657,7 +657,7 @@ pub const Lua = struct {
657657
658658 /// Push a formatted string onto the stack and return a pointer to the string
659659 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 );
661661 return @ptrCast ([* :0 ]const u8 , ptr );
662662 }
663663
@@ -782,12 +782,12 @@ pub const Lua = struct {
782782 /// Does the equivalent to t[`k`] = v where t is the value at the given `index`
783783 /// and v is the value on the top of the stack
784784 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 );
786786 }
787787
788788 /// Pops a value from the stack and sets it as the new value of global `name`
789789 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 );
791791 }
792792
793793 /// 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 {
10621062
10631063 /// Calls a metamethod
10641064 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 ;
10661066 }
10671067
10681068 /// Checks whether the function has an argument of any type at position `arg`
@@ -1080,7 +1080,7 @@ pub const Lua = struct {
10801080 var length : usize = 0 ;
10811081 const str = c .luaL_checklstring (lua .state , arg , @ptrCast ([* c ]usize , & length ));
10821082 // luaL_checklstring never returns null (throws lua error)
1083- return str .? [0.. length :0 ];
1083+ return str [0.. length :0 ];
10841084 }
10851085
10861086 /// Checks whether the function argument `arg` is a number and returns the number
@@ -1151,15 +1151,15 @@ pub const Lua = struct {
11511151
11521152 /// Raises an error
11531153 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 );
11551155 unreachable ;
11561156 }
11571157
11581158 /// Pushes onto the stack the field `e` from the metatable of the object at index `obj`
11591159 /// and returns the type of the pushed value
11601160 /// TODO: possibly return an error if nil
11611161 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 ));
11631163 if (val_type == .nil ) return error .Fail ;
11641164 return val_type ;
11651165 }
@@ -1174,12 +1174,12 @@ pub const Lua = struct {
11741174 /// Creates a copy of string `str`, replacing any occurrence of the string `pat` with the string `rep`
11751175 /// Pushes the resulting string on the stack and returns it.
11761176 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 ));
11781178 }
11791179
11801180 /// Loads a buffer as a Lua chunk
11811181 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 )) {
11831183 StatusCode .ok = > return ,
11841184 StatusCode .err_syntax = > return error .Syntax ,
11851185 StatusCode .err_memory = > return error .Memory ,
@@ -1189,7 +1189,7 @@ pub const Lua = struct {
11891189
11901190 /// Equivalent to `Lua.loadFileX()` with mode equal to binary+text
11911191 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 );
11931193 switch (ret ) {
11941194 StatusCode .ok = > return ,
11951195 StatusCode .err_syntax = > return error .Syntax ,
@@ -1202,7 +1202,7 @@ pub const Lua = struct {
12021202
12031203 /// Loads a string as a Lua chunk
12041204 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 );
12061206 switch (ret ) {
12071207 StatusCode .ok = > return ,
12081208 StatusCode .err_syntax = > return error .Syntax ,
@@ -1223,7 +1223,7 @@ pub const Lua = struct {
12231223 /// If the registry already has the key `key`, returns an error
12241224 /// Otherwise, creates a new table to be used as a metatable for userdata
12251225 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 ;
12271227 }
12281228
12291229 /// Creates a new Lua state with an allocator using the default libc allocator
@@ -1245,7 +1245,7 @@ pub const Lua = struct {
12451245 pub fn optBytes (lua : * Lua , arg : i32 , default : [:0 ]const u8 ) [:0 ]const u8 {
12461246 var length : usize = 0 ;
12471247 // 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 );
12491249 if (ret == default .ptr ) return default ;
12501250 return ret [0.. length :0 ];
12511251 }
@@ -1260,7 +1260,7 @@ pub const Lua = struct {
12601260 /// If the argment is absent or nil returns `default`
12611261 pub fn optString (lua : * Lua , arg : i32 , default : [:0 ]const u8 ) [* :0 ]const u8 {
12621262 // translate-c error
1263- return c .luaL_optlstring (lua .state , arg , default , null );
1263+ return c .luaL_optlstring (lua .state , arg , default . ptr , null );
12641264 }
12651265
12661266 /// 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 {
14091409
14101410 /// Adds the zero-terminated string pointed to by `str` to the buffer
14111411 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 );
14131413 }
14141414
14151415 /// Adds the value on the top of the stack to the buffer
0 commit comments