Skip to content

Instantly share code, notes, and snippets.

@donpdonp
Created August 21, 2019 00:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save donpdonp/d770da8dde3aaba0e6a25f5d35c78856 to your computer and use it in GitHub Desktop.
Save donpdonp/d770da8dde3aaba0e6a25f5d35c78856 to your computer and use it in GitHub Desktop.
diff --git a/src/main.zig b/src/main.zig
index d651eb9..93bb0ea 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -230,7 +230,7 @@ fn netback(command: *thread.Command) void {
for(tree.root.Array.toSlice()) |jsonValue| {
const item = jsonValue.Object;
var toot = allocator.create(toot_lib.Type) catch unreachable;
- toot.init(item, allocator);
+ toot = toot_lib.Type.init(item, allocator);
var id = toot.id();
warn("netback json create toot #{} {*}\n", toot.id(), toot);
if(column.toots.contains(toot)) {
diff --git a/src/toot.zig b/src/toot.zig
index 43e0f9b..d25263a 100644
--- a/src/toot.zig
+++ b/src/toot.zig
@@ -25,11 +25,14 @@ pub fn Toot() type {
const Toothashmap = std.hash_map.HashMap(K, V,
std.mem.hash_slice_u8,
std.mem.eql_slice_u8);
- pub fn init(self: *Self, hash: Toothashmap, allocator: *Allocator) void {
- self.hashmap = hash;
- self.tagList = TagList.init(allocator);
- self.imgList = ImgList.init(allocator);
- self.parseTags(allocator);
+ pub fn init(hash: Toothashmap, allocator: *Allocator) Self {
+ var newToot = Self{
+ .hashmap = hash,
+ .tagList = TagList.init(allocator),
+ .imgList = ImgList.init(allocator)
+ };
+ newToot.parseTags(allocator);
+ return newToot;
}
pub fn get(self: *const Self, key: K) ?*Toothashmap.KV {
donp@jewel zig $ zig build
Call parameter type does not match function signature!
%toot = alloca %"toot.Toot()"*, align 8
%"toot.Toot()"* call fastcc void @"toot.Toot().init"(%"toot.Toot()"** sret %toot, %"std.hash_map.HashMap([]const u8,std.json.Value,std.mem.hash_slice_u8,std.mem.eql_slice_u8)"* %item, %std.mem.Allocator* @c_allocator_state), !dbg !23580
LLVM ERROR: Broken module found, compilation aborted!
The following command exited with error code 1:
/opt/zig/2019-08-06/bin/zig build-exe /home/donp/code/zootdeck/zig/src/main.zig --library c --library glib-2.0 --library gdk-3 --library gdk_pixbuf-2.0 --library gtk-3 --library gobject-2.0 --library gmodule-2.0 --library gumbo --library glfw3 --library dl --library X11 --library pthread --library curl --library lmdb --cache-dir /home/donp/code/zootdeck/zig/zig-cache --name zootdeck -target x86_64-linux-gnu -isystem /usr/include -isystem /usr/include/x86_64-linux-gnu -isystem /usr/include/gtk-3.0 -isystem /usr/include/glib-2.0 -isystem /usr/include/atk-1.0 -isystem /usr/include/pango-1.0 -isystem /usr/include/gdk-pixbuf-2.0 -isystem /usr/include/cairo -isystem /usr/lib/x86_64-linux-gnu/glib-2.0/include -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /home/donp/code/zootdeck/glfw/include -isystem /home/donp/code/zootdeck/glfw/deps -isystem /home/donp/code/zootdeck/nanovg/src --library-path /usr/lib --library-path /usr/lib/x86_64-linux-gnu --library-path ../glfw/build/src --cache on
Build failed. The following command failed:
/home/donp/code/zootdeck/zig/zig-cache/o/Wg7yDXpx-h7BPfuDIXpfQpiDwDn_8h3v0-O7dLo5Ir9e8m-rXLyAHkv1MVT25O0t/build /opt/zig/2019-08-06/bin/zig /home/donp/code/zootdeck/zig /home/donp/code/zootdeck/zig/zig-cache
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment