protogen

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: CC0-1.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(specPath, overlayPath, outputDir, goModule string) error

Generate loads a Java API spec and overlay, merges them, builds proto data structures, and writes a .proto file to the output directory.

Types

type ProtoData

type ProtoData struct {
	Package      string
	ProtoPackage string // Package with '/' replaced by '.' for proto syntax
	GoPackage    string
	Services     []ProtoService
	Messages     []ProtoMessage
	Enums        []ProtoEnum
}

ProtoData holds all information needed to render a .proto file.

func BuildProtoData

func BuildProtoData(merged *javagen.MergedSpec, goModule string) *ProtoData

BuildProtoData converts a MergedSpec into proto data structures.

type ProtoEnum

type ProtoEnum struct {
	Name   string
	Values []ProtoEnumValue
}

ProtoEnum describes a protobuf enum type.

type ProtoEnumValue

type ProtoEnumValue struct {
	Name   string
	Number int
}

ProtoEnumValue describes a single value in a protobuf enum.

type ProtoField

type ProtoField struct {
	Type     string
	Name     string
	Number   int
	Repeated bool
	Optional bool
	Comment  string
}

ProtoField describes a single field in a protobuf message.

type ProtoMessage

type ProtoMessage struct {
	Name   string
	Fields []ProtoField
}

ProtoMessage describes a protobuf message type.

type ProtoRPC

type ProtoRPC struct {
	Name            string
	OriginalName    string // Name before collision renaming (empty if unchanged).
	InputType       string
	OutputType      string
	ClientStreaming bool
	ServerStreaming bool
	Comment         string
}

ProtoRPC describes a single RPC method in a gRPC service.

type ProtoService

type ProtoService struct {
	Name string
	RPCs []ProtoRPC
}

ProtoService describes a gRPC service generated from a Java class.

type StreamingPattern

type StreamingPattern int

StreamingPattern classifies how a callback should be exposed as gRPC streaming.

const (
	// ServerStreaming means the server sends a stream of events to the client.
	ServerStreaming StreamingPattern = iota + 1
	// BidiStreaming means both client and server send streams.
	BidiStreaming
)

func DetectStreamingPattern

func DetectStreamingPattern(cb *javagen.MergedCallback) StreamingPattern

DetectStreamingPattern determines whether a callback should be exposed as server-streaming or bidirectional-streaming in the gRPC API.

Known bidi interfaces (e.g. BluetoothGattCallback) are always BidiStreaming. Any callback with 2+ methods containing "read"/"write" (case-insensitive) is also BidiStreaming. Everything else is ServerStreaming.

Jump to

Keyboard shortcuts

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