@@ -320,7 +320,7 @@ test "type of and getting values" {
320
320
try expect (lua .isThread (-1 ));
321
321
try expectEqual (lua .state , (try lua .toThread (-1 )).state );
322
322
323
- _ = lua .pushString ("all your codebase are belong to us" );
323
+ _ = lua .pushStringZ ("all your codebase are belong to us" );
324
324
try expectEqual (.string , lua .typeOf (-1 ));
325
325
try expect (lua .isString (-1 ));
326
326
@@ -619,7 +619,7 @@ test "global table" {
619
619
lua .pushGlobalTable ();
620
620
621
621
// find the print function
622
- _ = lua .pushString ("print" );
622
+ _ = lua .pushStringZ ("print" );
623
623
try expectEqual (.function , lua .getTable (-2 ));
624
624
625
625
// index the global table in the global table
@@ -752,9 +752,9 @@ test "concat" {
752
752
var lua = try Lua .init (& testing .allocator );
753
753
defer lua .deinit ();
754
754
755
- _ = lua .pushString ("hello " );
755
+ _ = lua .pushStringZ ("hello " );
756
756
lua .pushNumber (10 );
757
- _ = lua .pushString (" wow!" );
757
+ _ = lua .pushStringZ (" wow!" );
758
758
lua .concat (3 );
759
759
760
760
if (ziglua .lang == .lua53 or ziglua .lang == .lua54 ) {
@@ -830,22 +830,22 @@ test "table access" {
830
830
});
831
831
try expectEqualStrings ("first" , try lua .toBytes (-1 ));
832
832
833
- _ = lua .pushString ("key" );
833
+ _ = lua .pushStringZ ("key" );
834
834
try expectEqual (.string , lua .getTable (1 ));
835
835
try expectEqualStrings ("value" , try lua .toBytes (-1 ));
836
836
837
- _ = lua .pushString ("other one" );
837
+ _ = lua .pushStringZ ("other one" );
838
838
try expectEqual (.number , lua .rawGetTable (1 ));
839
839
try expectEqual (1234 , try toInteger (& lua , -1 ));
840
840
841
841
// a.name = "ziglua"
842
- _ = lua .pushString ("name" );
843
- _ = lua .pushString ("ziglua" );
842
+ _ = lua .pushStringZ ("name" );
843
+ _ = lua .pushStringZ ("ziglua" );
844
844
lua .setTable (1 );
845
845
846
846
// a.lang = "zig"
847
- _ = lua .pushString ("lang" );
848
- _ = lua .pushString ("zig" );
847
+ _ = lua .pushStringZ ("lang" );
848
+ _ = lua .pushStringZ ("zig" );
849
849
lua .rawSetTable (1 );
850
850
851
851
try expectError (error .Fail , lua .getMetatable (1 ));
@@ -1031,7 +1031,7 @@ test "userdata and uservalues" {
1031
1031
lua .pushNumber (1234.56 );
1032
1032
try lua .setUserValue (1 , 1 );
1033
1033
1034
- _ = lua .pushString ("test string" );
1034
+ _ = lua .pushStringZ ("test string" );
1035
1035
try lua .setUserValue (1 , 2 );
1036
1036
1037
1037
try expectEqual (.number , try lua .getUserValue (1 , 1 ));
@@ -1113,7 +1113,7 @@ test "registry" {
1113
1113
const key = "mykey" ;
1114
1114
1115
1115
// store a string in the registry
1116
- _ = lua .pushString ("hello there" );
1116
+ _ = lua .pushStringZ ("hello there" );
1117
1117
lua .rawSetPtr (ziglua .registry_index , key );
1118
1118
1119
1119
// get key from the registry
@@ -1160,7 +1160,7 @@ test "raise error" {
1160
1160
1161
1161
const makeError = struct {
1162
1162
fn inner (l : * Lua ) i32 {
1163
- _ = l .pushString ("makeError made an error" );
1163
+ _ = l .pushStringZ ("makeError made an error" );
1164
1164
l .raiseError ();
1165
1165
return 0 ;
1166
1166
}
@@ -1175,7 +1175,7 @@ fn continuation(l: *Lua, status: ziglua.Status, ctx: isize) i32 {
1175
1175
_ = status ;
1176
1176
1177
1177
if (ctx == 5 ) {
1178
- _ = l .pushString ("done" );
1178
+ _ = l .pushStringZ ("done" );
1179
1179
return 1 ;
1180
1180
} else {
1181
1181
// yield the current context value
@@ -1233,7 +1233,7 @@ fn continuation52(l: *Lua) i32 {
1233
1233
const ctxOrNull = l .getContext () catch unreachable ;
1234
1234
const ctx = ctxOrNull orelse 0 ;
1235
1235
if (ctx == 5 ) {
1236
- _ = l .pushString ("done" );
1236
+ _ = l .pushStringZ ("done" );
1237
1237
return 1 ;
1238
1238
} else {
1239
1239
// yield the current context value
@@ -1386,7 +1386,7 @@ test "aux check functions" {
1386
1386
lua .pushInteger (3 );
1387
1387
_ = lua .pushBytes ("hello world" );
1388
1388
lua .pushNumber (4 );
1389
- _ = lua .pushString ("hello world" );
1389
+ _ = lua .pushStringZ ("hello world" );
1390
1390
lua .protectedCall (5 , 0 , 0 ) catch {
1391
1391
try expectStringContains ("boolean expected" , try lua .toBytes (-1 ));
1392
1392
lua .pop (-1 );
@@ -1398,7 +1398,7 @@ test "aux check functions" {
1398
1398
lua .pushInteger (3 );
1399
1399
_ = lua .pushBytes ("hello world" );
1400
1400
lua .pushNumber (4 );
1401
- _ = lua .pushString ("hello world" );
1401
+ _ = lua .pushStringZ ("hello world" );
1402
1402
lua .pushBoolean (true );
1403
1403
lua .protectedCall (6 , 0 , 0 ) catch {
1404
1404
try expectEqualStrings ("bad argument #7 to '?' (number expected, got no value)" , try lua .toBytes (-1 ));
@@ -1412,7 +1412,7 @@ test "aux check functions" {
1412
1412
lua .pushInteger (3 );
1413
1413
_ = lua .pushBytes ("hello world" );
1414
1414
lua .pushNumber (4 );
1415
- _ = lua .pushString ("hello world" );
1415
+ _ = lua .pushStringZ ("hello world" );
1416
1416
lua .pushBoolean (true );
1417
1417
if (ziglua .lang == .lua52 ) {
1418
1418
lua .pushUnsigned (1 );
@@ -1441,7 +1441,7 @@ test "aux opt functions" {
1441
1441
lua .pushInteger (10 );
1442
1442
_ = lua .pushBytes ("zig" );
1443
1443
lua .pushNumber (1.23 );
1444
- _ = lua .pushString ("lang" );
1444
+ _ = lua .pushStringZ ("lang" );
1445
1445
try lua .protectedCall (4 , 0 , 0 );
1446
1446
}
1447
1447
@@ -1468,19 +1468,19 @@ test "checkOption" {
1468
1468
}.inner );
1469
1469
1470
1470
lua .pushFunction (function );
1471
- _ = lua .pushString ("one" );
1471
+ _ = lua .pushStringZ ("one" );
1472
1472
try lua .protectedCall (1 , 1 , 0 );
1473
1473
try expectEqual (1 , try toInteger (& lua , -1 ));
1474
1474
lua .pop (1 );
1475
1475
1476
1476
lua .pushFunction (function );
1477
- _ = lua .pushString ("two" );
1477
+ _ = lua .pushStringZ ("two" );
1478
1478
try lua .protectedCall (1 , 1 , 0 );
1479
1479
try expectEqual (2 , try toInteger (& lua , -1 ));
1480
1480
lua .pop (1 );
1481
1481
1482
1482
lua .pushFunction (function );
1483
- _ = lua .pushString ("three" );
1483
+ _ = lua .pushStringZ ("three" );
1484
1484
try lua .protectedCall (1 , 1 , 0 );
1485
1485
try expectEqual (3 , try toInteger (& lua , -1 ));
1486
1486
lua .pop (1 );
@@ -1493,7 +1493,7 @@ test "checkOption" {
1493
1493
1494
1494
// check the raised error
1495
1495
lua .pushFunction (function );
1496
- _ = lua .pushString ("unknown" );
1496
+ _ = lua .pushStringZ ("unknown" );
1497
1497
try expectError (error .Runtime , lua .protectedCall (1 , 1 , 0 ));
1498
1498
try expectStringContains ("(invalid option 'unknown')" , try lua .toBytes (-1 ));
1499
1499
}
@@ -1860,7 +1860,7 @@ test "objectLen" {
1860
1860
var lua = try Lua .init (& testing .allocator );
1861
1861
defer lua .deinit ();
1862
1862
1863
- lua .pushString ("lua" );
1863
+ lua .pushStringZ ("lua" );
1864
1864
try testing .expectEqual (3 , lua .objectLen (-1 ));
1865
1865
}
1866
1866
@@ -2292,9 +2292,9 @@ test "useratom" {
2292
2292
defer lua .deinit ();
2293
2293
lua .setUserAtomCallbackFn (ziglua .wrap (useratomCb ));
2294
2294
2295
- _ = lua .pushString ("unknownatom" );
2296
- _ = lua .pushString ("method_one" );
2297
- _ = lua .pushString ("another_method" );
2295
+ _ = lua .pushStringZ ("unknownatom" );
2296
+ _ = lua .pushStringZ ("method_one" );
2297
+ _ = lua .pushStringZ ("another_method" );
2298
2298
2299
2299
const atom_idx0 , const str0 = try lua .toStringAtom (-2 );
2300
2300
const atom_idx1 , const str1 = try lua .toStringAtom (-1 );
@@ -2360,7 +2360,7 @@ test "namecall" {
2360
2360
lua .pushVector (0 , 0 , 0 );
2361
2361
2362
2362
try lua .newMetatable ("vector" );
2363
- lua .pushString ("__namecall" );
2363
+ lua .pushStringZ ("__namecall" );
2364
2364
lua .pushFunctionNamed (ziglua .wrap (funcs .vectorNamecall ), "vector_namecall" );
2365
2365
lua .setTable (-3 );
2366
2366
@@ -2406,17 +2406,17 @@ test "toAny" {
2406
2406
try testing .expect (my_float == 100.0 );
2407
2407
2408
2408
//[]const u8
2409
- _ = lua .pushString ("hello world" );
2409
+ _ = lua .pushStringZ ("hello world" );
2410
2410
const my_string_1 = try lua .toAny ([]const u8 , -1 );
2411
2411
try testing .expect (std .mem .eql (u8 , my_string_1 , "hello world" ));
2412
2412
2413
2413
//[:0]const u8
2414
- _ = lua .pushString ("hello world" );
2414
+ _ = lua .pushStringZ ("hello world" );
2415
2415
const my_string_2 = try lua .toAny ([:0 ]const u8 , -1 );
2416
2416
try testing .expect (std .mem .eql (u8 , my_string_2 , "hello world" ));
2417
2417
2418
2418
//[*:0]const u8
2419
- _ = lua .pushString ("hello world" );
2419
+ _ = lua .pushStringZ ("hello world" );
2420
2420
const my_string_3 = try lua .toAny ([* :0 ]const u8 , -1 );
2421
2421
const end = std .mem .indexOfSentinel (u8 , 0 , my_string_3 );
2422
2422
try testing .expect (std .mem .eql (u8 , my_string_3 [0.. end ], "hello world" ));
@@ -2434,7 +2434,7 @@ test "toAny" {
2434
2434
2435
2435
//enum
2436
2436
const MyEnumType = enum { hello , goodbye };
2437
- _ = lua .pushString ("hello" );
2437
+ _ = lua .pushStringZ ("hello" );
2438
2438
const my_enum = try lua .toAny (MyEnumType , -1 );
2439
2439
try testing .expect (my_enum == MyEnumType .hello );
2440
2440
0 commit comments