Generates one module for a protobuf schema and its imports, or options.dir. Free the source or error.message with Basic.free. Parsing scratch uses temp; returned text and error messages use context.allocator.
#import "Extensions/Protobuf/Schema";
Compile-time protobuf schema graphs, or call protobuf_generate to obtain Jai source.
Api :: #import "Extensions/Protobuf/Schema"(TEXT = "syntax = 'proto3'; message Ping {}");
Module parameters#
- PATH := ""
- A single schema path, relative to the compiler working directory or absolute.
- TEXT := ""
- Inline schema text. Omit PATH when using TEXT.
- DIR := ""
- Recursively generate every .proto under one directory into a shared module.
- IMPORT_PATHS := ""
- Semicolon-separated import search paths, after the importing file directory.
- MAP := Map_Mode.HASH_MAP
- Map container, defaulting to Extensions/Hash_Map.
- MAP_MODULE := ""
- Module providing a custom map type and iteration.
- MAP_TYPE := ""
- Polymorphic custom map type name.
- MAP_INSERT := ""
- Custom insert procedure name.
- MAP_DEINIT := ""
- Custom deinitialization procedure name.
- STRIP_ENUM_PREFIX := false
- Strip ENUM_NAME_ from enum values where a valid identifier remains.
- GRPC := false
- Emit typed native gRPC services using this same message graph.
Procedures#
Types#
The generated map representation; ARRAY preserves duplicate entries.
Map_Mode :: enum {
HASH_MAP;
TABLE;
ARRAY;
CUSTOM;
}Configuration for the standalone source generator. path is used in diagnostics.
Generate_Options :: struct {
path: string = "<text.proto>";
import_paths: string;
dir: string;
map: Map_Mode = .HASH_MAP;
map_module: string;
map_type: string;
map_insert: string;
map_deinit: string;
strip_enum_prefix: bool;
grpc: bool;
}Schema failure at a one-based line and column. Free message with Basic.free; path shares its allocation and remains valid until message is freed.
Schema_Error :: struct {
message: string;
path: string;
line: s64;
column: s64;
}