Skip to content

Commit 73b596b

Browse files
axdanknatecraddock
authored andcommitted
make public some functions
1 parent b039a7f commit 73b596b

File tree

2 files changed

+5
-33
lines changed

2 files changed

+5
-33
lines changed

src/lib.zig

+4-32
Original file line numberDiff line numberDiff line change
@@ -585,34 +585,6 @@ pub fn Parsed(comptime T: type) type {
585585
};
586586
}
587587

588-
const internals = [_][]const u8{ "toStruct", "toSlice", "toTuple", "toAnyInternal" };
589-
590-
// wrap over some internal functions of the Lua struct
591-
pub const Internals = blk: {
592-
const StructField = std.builtin.Type.StructField;
593-
var fields: [internals.len]StructField = undefined;
594-
for (internals, 0..) |entry, i| {
595-
const F = @field(Lua, entry);
596-
const T = @TypeOf(F);
597-
fields[i] = .{
598-
.name = @ptrCast(entry),
599-
.type = T,
600-
.default_value = &F,
601-
.is_comptime = false,
602-
.alignment = @alignOf(T),
603-
};
604-
}
605-
606-
const TT = @Type(.{ .@"struct" = .{
607-
.layout = .auto,
608-
.fields = &fields,
609-
.decls = &.{},
610-
.is_tuple = false,
611-
} });
612-
613-
break :blk TT{};
614-
};
615-
616588
/// A Zig wrapper around the Lua C API
617589
/// Represents a Lua state or thread and contains the entire state of the Lua interpreter
618590
pub const Lua = opaque {
@@ -4570,7 +4542,7 @@ pub const Lua = opaque {
45704542
/// Converts the specified index of the lua stack to the specified
45714543
/// type if possible and returns it
45724544
/// optional allocator
4573-
fn toAnyInternal(lua: *Lua, comptime T: type, a: ?std.mem.Allocator, comptime allow_alloc: bool, index: i32) !T {
4545+
pub fn toAnyInternal(lua: *Lua, comptime T: type, a: ?std.mem.Allocator, comptime allow_alloc: bool, index: i32) !T {
45744546
const stack_size_on_entry = lua.getTop();
45754547
defer {
45764548
if (lua.getTop() != stack_size_on_entry) {
@@ -4771,7 +4743,7 @@ pub const Lua = opaque {
47714743
}
47724744

47734745
/// Converts a lua array to a zig slice, memory is owned by the caller
4774-
fn toSlice(lua: *Lua, comptime ChildType: type, a: std.mem.Allocator, raw_index: i32) ![]ChildType {
4746+
pub fn toSlice(lua: *Lua, comptime ChildType: type, a: std.mem.Allocator, raw_index: i32) ![]ChildType {
47754747
const index = lua.absIndex(raw_index);
47764748

47774749
if (!lua.isTable(index)) {
@@ -4792,7 +4764,7 @@ pub const Lua = opaque {
47924764
}
47934765

47944766
/// Converts value at given index to a zig struct tuple if possible
4795-
fn toTuple(lua: *Lua, comptime T: type, a: ?std.mem.Allocator, comptime allow_alloc: bool, raw_index: i32) !T {
4767+
pub fn toTuple(lua: *Lua, comptime T: type, a: ?std.mem.Allocator, comptime allow_alloc: bool, raw_index: i32) !T {
47964768
const stack_size_on_entry = lua.getTop();
47974769
defer std.debug.assert(lua.getTop() == stack_size_on_entry);
47984770

@@ -4835,7 +4807,7 @@ pub const Lua = opaque {
48354807
}
48364808

48374809
/// Converts value at given index to a zig struct if possible
4838-
fn toStruct(lua: *Lua, comptime T: type, a: ?std.mem.Allocator, comptime allow_alloc: bool, raw_index: i32) !T {
4810+
pub fn toStruct(lua: *Lua, comptime T: type, a: ?std.mem.Allocator, comptime allow_alloc: bool, raw_index: i32) !T {
48394811
const stack_size_on_entry = lua.getTop();
48404812
defer std.debug.assert(lua.getTop() == stack_size_on_entry);
48414813

src/tests.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -2443,7 +2443,7 @@ test "toAny from struct with fromLua" {
24432443
foo: i32,
24442444

24452445
pub fn fromLua(l: *Lua, a: ?std.mem.Allocator, i: i32) !Self {
2446-
return try ziglua.Internals.toStruct(l, Self, a, false, i);
2446+
return try l.toStruct(Self, a, false, i);
24472447
}
24482448
},
24492449
};

0 commit comments

Comments
 (0)