layerutil

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package layerutil provides shared layer discovery and parsing logic for codegen backends (Go, Java, etc.).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LayerDef

type LayerDef struct {
	EnumName string                // fully qualified enum name
	Values   []LayerValue          // all enum values
	ByName   map[string]LayerValue // keyed by lowercase layer name (prefix-stripped)
}

LayerDef holds the discovered layer enum and its parsed values.

func DiscoverLayers

func DiscoverLayers(plugin *protogen.Plugin) (*LayerDef, error)

DiscoverLayers scans all files in the plugin request for an enum annotated with option (pbflags.layers) = true. Returns the layer definition, or an error if none is found or multiple are found.

func (*LayerDef) ResolveLayer

func (ld *LayerDef) ResolveLayer(name string) (LayerValue, bool)

ResolveLayer looks up a layer name string (e.g., "entity") against the discovered layer values. Returns the matching LayerValue and true, or false if the name doesn't match any value.

type LayerValue

type LayerValue struct {
	Name         string // original enum value name, e.g., "LAYER_ENTITY"
	Number       int32  // enum ordinal
	StrippedName string // prefix-stripped name, e.g., "ENTITY"
	LayerName    string // lowercase layer name for matching, e.g., "entity"
	IsGlobal     bool   // true for ordinal 0, 1, or name containing "GLOBAL"
}

LayerValue represents a single value from the (pbflags.layers) enum.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL