Coder Social home page Coder Social logo

flatbuffers-zig's People

Contributors

clickingbuttons avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

flatbuffers-zig's Issues

Handle integer overflow

Use Zig error handling instead of runtime-dependent behavior everywhere there's an @intCast

Support cyclically referenced fields

According to a Flatbuffers maintainer (and the reference C++ impl) cyclical referencing tables are possible.

This means for the object API this:

const Foo = struct {
    foo: ?Foo,
};

should change to this:

const Foo = struct {
    foo: ?*Foo,
};

and the init allocations should change too.

ICE: Non-allocating tables with union fields

The flatc-zig compiler has issues when handling any table containing a union (possibly works with other types) and does not allocate memory. For instance, this snippet reproduces the error:

struct Foo {
  foo: ubyte;
}

union Bar { Foo }

table Baz {
  bar: Bar;
}

But this one does not:

struct Foo {
  foo: ubyte;
}

union Bar { Foo }

table Baz {
  bar: Bar;
  fix: string;
}

The error message is as follows (including the invocation and shell output stating that this is, in fact, a core dump):

[enderger] ( impure (nix-shell-env)) ✘!+?  master
…/kings-court/proto λ > ../client/flatc-zig -i tmp -o tmp
debug(flatbuffers): file_ident=//ice.fbs n_enums=1 n_objs=2
thread 3204581 panic: index out of bounds: index 1, len 1
/home/enderger/.cache/zig/p/122052b2f5bbffae771464571e74e9750d584aa0f15b4af411ad94fa7fc935967781/src/codegen/writer.zig:759:39: 0x255272 in writeObjectInitFn (flatc-zig)
                            args.items[1].name,
                                      ^
/home/enderger/.cache/zig/p/122052b2f5bbffae771464571e74e9750d584aa0f15b4af411ad94fa7fc935967781/src/codegen/writer.zig:981:43: 0x2599dd in writeObject__anon_9174 (flatc-zig)
                try self.writeObjectInitFn(object, has_allocations, packed_name);
                                          ^
/home/enderger/.cache/zig/p/122052b2f5bbffae771464571e74e9750d584aa0f15b4af411ad94fa7fc935967781/src/codegen/writer.zig:1203:55: 0x25c702 in write__anon_9113 (flatc-zig)
            const unpacked_name = try self.writeObject(obj_or_enum, false);
                                                      ^
/home/enderger/.cache/zig/p/122052b2f5bbffae771464571e74e9750d584aa0f15b4af411ad94fa7fc935967781/src/codegen/codegen.zig:91:30: 0x266e05 in writeFiles__anon_9880 (flatc-zig)
        try code_writer.write(obj);
                             ^
/home/enderger/.cache/zig/p/122052b2f5bbffae771464571e74e9750d584aa0f15b4af411ad94fa7fc935967781/src/codegen/codegen.zig:178:23: 0x268039 in codegen (flatc-zig)
        try writeFiles(allocator, opts, prelude, schema, .object);
                      ^
/home/enderger/.cache/zig/p/122052b2f5bbffae771464571e74e9750d584aa0f15b4af411ad94fa7fc935967781/src/main.zig:36:28: 0x269495 in walk (flatc-zig)
        try codegen.codegen(allocator, fbs_path, genned_bytes, opts);
                           ^
/home/enderger/.cache/zig/p/122052b2f5bbffae771464571e74e9750d584aa0f15b4af411ad94fa7fc935967781/src/main.zig:72:13: 0x269eb0 in main (flatc-zig)
    try walk(codegen.Options{
            ^
/nix/store/5j4g5igs5ral691mfrhnmpar5br1xxrs-zig-0.11.0-dev.4002+7dd1cf26f/lib/std/start.zig:608:37: 0x237814 in posixCallMainAndExit (flatc-zig)
            const result = root.main() catch |err| {
                                    ^
/nix/store/5j4g5igs5ral691mfrhnmpar5br1xxrs-zig-0.11.0-dev.4002+7dd1cf26f/lib/std/start.zig:367:5: 0x237301 in _start (flatc-zig)
    @call(.never_inline, posixCallMainAndExit, .{});
    ^
Aborted: oops, process '../client/flatc-zig' core dumped
Error: nu::shell::external_command

  × External command failed
   ╭─[entry #17:1:1]
 1 │ ../client/flatc-zig -i tmp -o tmp
   · ─────────┬─────────
   ·          ╰── core dumped
   ╰────
  help: Aborted: child process '../client/flatc-zig' core dumped

The error is caused by the unchecked access of the allocator argument in the code generator for the initializer of the union type.

Add option to add field setters to PackedTypes

Move Table to AdvancedTable(comptime mutable: bool) type with flatbuffer: if (mutable) []u8 else []const u8. Make pub const Table = AdvancedTable(false); and pub const MutableTable = AdvancedTable(true); (with mixed in setter methods).

Then codegen setters for the following types:

  • Scalars
  • Strings (with len checking against previous string?)
  • Vector + array elements
  • Is there a way to do unions?

Handle namespaces

Preferably ignore them as much as possible. Not sure if naming collisions are possible.

Module url 404

The URL provided in the README for instalation:

"https://github.com/clickingbuttons/flatbuffers-zig/archive/refs/tags/latest-release.tar.gz"

returns 404 code.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.