flatbufferz
flatbufferz copied to clipboard
a flatbuffers codegen library in zig
For the following FBS: ```fbs enum AdvancedFeatures : ulong (bit_flags) { AdvancedArrayFeatures, AdvancedUnionFeatures, OptionalScalars, DefaultVectorsAndStrings, } ``` The following enum is generated: ```zig pub const AdvancedFeatures = enum(u64) { AdvancedArrayFeatures...
Make an identifier string pool per-file to handle naming clashes. Give user fields and enums their function, field, and type identifiers. Then: 1. Give modules their identifiers 2. Give inner...
Useful for when Zig breaks codegenned syntax and for codegen devs. Here's one way to do it: ```zig fn format(allocator: Allocator, fname: []const u8, code: [:0]const u8) ![]const u8 {...
The suffix `T` is a misnomer.
More convenient. Requires object API.
Arrays are only allowed inside of structs and are laid out like sequential struct fields. ```fbs struct Vec4 { v: [float:4]; } ``` Gives: ``` thread 280733 panic: TODO TypeFmt.init()...
Zig has a [style guide](https://ziglang.org/documentation/master/#Names), but it's [subject](https://github.com/ziglang/zig/issues/1097) to [change](https://github.com/ziglang/zig/issues/2101). Everyone has their own preferences coming from different languages.
Save a dereferencing `.?` and a memory allocation per-field. Change to `optional_field: ?T` instead of `optional_field: ?*T`.