Esc

Schema

moduleextensionSource
  • macOS: Everything works on macOS
  • Linux: Everything works on Linux
  • Windows: Everything works on Windows
  • Wasm: Everything works on Wasm
ยทsince 0.36.1

#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#

(text: string, options := Generate_Options.{}) -> (string, Schema_Error)

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.

Types#

Map_Modeenumsince 0.36.1Source

The generated map representation; ARRAY preserves duplicate entries.

Map_Mode :: enum {
    HASH_MAP;
    TABLE;
    ARRAY;
    CUSTOM;
}
Generate_Optionsstructsince 0.36.1Source

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_Errorstructsince 0.36.1Source

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;
}