Skip to content

Commit 220b10a

Browse files
committed
Rename pushBytes to pushString
1 parent ec16700 commit 220b10a

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

src/lib.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1533,7 +1533,7 @@ pub const Lua = struct {
15331533

15341534
/// Pushes the bytes onto the stack. Returns a slice pointing to Lua's internal copy of the string
15351535
/// See https://www.lua.org/manual/5.4/manual.html#lua_pushlstring
1536-
pub fn pushBytes(lua: *Lua, bytes: []const u8) BytesResult {
1536+
pub fn pushString(lua: *Lua, bytes: []const u8) BytesResult {
15371537
switch (lang) {
15381538
.lua51, .luajit, .luau => {
15391539
c.lua_pushlstring(lua.state, bytes.ptr, bytes.len);

src/tests.zig

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ test "type of and getting values" {
330330
try expect(lua.isFunction(-1));
331331
try expectEqual(ziglua.wrap(add), try lua.toCFunction(-1));
332332

333-
_ = lua.pushBytes("hello world");
333+
_ = lua.pushString("hello world");
334334
try expectEqual(.string, lua.typeOf(-1));
335335
try expect(lua.isString(-1));
336336

@@ -373,7 +373,7 @@ test "unsigned" {
373373
lua.pushUnsigned(123456);
374374
try expectEqual(123456, try lua.toUnsigned(-1));
375375

376-
_ = lua.pushBytes("hello");
376+
_ = lua.pushString("hello");
377377
try expectError(error.Fail, lua.toUnsigned(-1));
378378
}
379379

@@ -1365,7 +1365,7 @@ test "aux check functions" {
13651365
lua.pushFunction(function);
13661366
lua.pushNil();
13671367
lua.pushInteger(3);
1368-
_ = lua.pushBytes("hello world");
1368+
_ = lua.pushString("hello world");
13691369
lua.protectedCall(3, 0, 0) catch {
13701370
try expectStringContains("number expected", try lua.toBytes(-1));
13711371
lua.pop(-1);
@@ -1374,7 +1374,7 @@ test "aux check functions" {
13741374
lua.pushFunction(function);
13751375
lua.pushNil();
13761376
lua.pushInteger(3);
1377-
_ = lua.pushBytes("hello world");
1377+
_ = lua.pushString("hello world");
13781378
lua.pushNumber(4);
13791379
lua.protectedCall(4, 0, 0) catch {
13801380
try expectStringContains("string expected", try lua.toBytes(-1));
@@ -1384,7 +1384,7 @@ test "aux check functions" {
13841384
lua.pushFunction(function);
13851385
lua.pushNil();
13861386
lua.pushInteger(3);
1387-
_ = lua.pushBytes("hello world");
1387+
_ = lua.pushString("hello world");
13881388
lua.pushNumber(4);
13891389
_ = lua.pushStringZ("hello world");
13901390
lua.protectedCall(5, 0, 0) catch {
@@ -1396,7 +1396,7 @@ test "aux check functions" {
13961396
lua.pushFunction(function);
13971397
lua.pushNil();
13981398
lua.pushInteger(3);
1399-
_ = lua.pushBytes("hello world");
1399+
_ = lua.pushString("hello world");
14001400
lua.pushNumber(4);
14011401
_ = lua.pushStringZ("hello world");
14021402
lua.pushBoolean(true);
@@ -1410,7 +1410,7 @@ test "aux check functions" {
14101410
// test pushFail here (currently acts the same as pushNil)
14111411
if (ziglua.lang == .lua54) lua.pushFail() else lua.pushNil();
14121412
lua.pushInteger(3);
1413-
_ = lua.pushBytes("hello world");
1413+
_ = lua.pushString("hello world");
14141414
lua.pushNumber(4);
14151415
_ = lua.pushStringZ("hello world");
14161416
lua.pushBoolean(true);
@@ -1439,7 +1439,7 @@ test "aux opt functions" {
14391439

14401440
lua.pushFunction(function);
14411441
lua.pushInteger(10);
1442-
_ = lua.pushBytes("zig");
1442+
_ = lua.pushString("zig");
14431443
lua.pushNumber(1.23);
14441444
_ = lua.pushStringZ("lang");
14451445
try lua.protectedCall(4, 0, 0);
@@ -1565,7 +1565,7 @@ test "ref" {
15651565
try expectError(error.Fail, lua.ref(ziglua.registry_index));
15661566
try expectEqual(0, lua.getTop());
15671567

1568-
_ = lua.pushBytes("Hello there");
1568+
_ = lua.pushString("Hello there");
15691569
const ref = try lua.ref(ziglua.registry_index);
15701570

15711571
_ = lua.rawGetIndex(ziglua.registry_index, ref);
@@ -1586,7 +1586,7 @@ test "ref luau" {
15861586

15871587
// In luau lua.ref does not pop the item from the stack
15881588
// and the data is stored in the registry_index by default
1589-
lua.pushBytes("Hello there");
1589+
lua.pushString("Hello there");
15901590
const ref = try lua.ref(2);
15911591

15921592
_ = lua.rawGetIndex(ziglua.registry_index, ref);
@@ -1718,11 +1718,11 @@ test "userdata" {
17181718
fn inner(l: *Lua) i32 {
17191719
const ptr = l.checkUserdata(Type, 1, "Type");
17201720
if (ptr.a != 1234) {
1721-
_ = l.pushBytes("error!");
1721+
_ = l.pushString("error!");
17221722
l.raiseError();
17231723
}
17241724
if (ptr.b != 3.14) {
1725-
_ = l.pushBytes("error!");
1725+
_ = l.pushString("error!");
17261726
l.raiseError();
17271727
}
17281728
return 1;
@@ -1751,15 +1751,15 @@ test "userdata" {
17511751
const testUdata = ziglua.wrap(struct {
17521752
fn inner(l: *Lua) i32 {
17531753
const ptr = l.testUserdata(Type, 1, "Type") catch {
1754-
_ = l.pushBytes("error!");
1754+
_ = l.pushString("error!");
17551755
l.raiseError();
17561756
};
17571757
if (ptr.a != 1234) {
1758-
_ = l.pushBytes("error!");
1758+
_ = l.pushString("error!");
17591759
l.raiseError();
17601760
}
17611761
if (ptr.b != 3.14) {
1762-
_ = l.pushBytes("error!");
1762+
_ = l.pushString("error!");
17631763
l.raiseError();
17641764
}
17651765
return 0;

0 commit comments

Comments
 (0)