Documentation
¶
Index ¶
- func Generate(specPath, overlayPath, outputDir, goModule string) error
- func IsServerEligible(cls javagen.MergedClass) bool
- func IsServiceEligible(cls javagen.MergedClass) bool
- func MergeProtoData(dst, src *ProtoData)
- func WriteProto(data *ProtoData, outputDir string) error
- type ProtoData
- type ProtoEnum
- type ProtoEnumValue
- type ProtoField
- type ProtoMessage
- type ProtoRPC
- type ProtoService
- type StreamingPattern
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Generate ¶
Generate loads a Java API spec and overlay, merges them, builds proto data structures, and writes a .proto file to the output directory.
func IsServerEligible ¶ added in v0.0.6
func IsServerEligible(cls javagen.MergedClass) bool
IsServerEligible reports whether a class should get a gRPC server implementation. system_service classes use NewXxx(ctx *app.Context) and constructor classes use NewXxx(vm *jni.VM, ...) with handle-based dispatch.
func IsServiceEligible ¶ added in v0.0.6
func IsServiceEligible(cls javagen.MergedClass) bool
IsServiceEligible reports whether a class should get a proto service definition and client wrappers. A class is eligible when it has methods and is not a data-only type (data_class, iterable_data, builder).
func MergeProtoData ¶ added in v0.0.6
func MergeProtoData(dst, src *ProtoData)
MergeProtoData combines two ProtoData for the same package. Identical messages (same name and field fingerprint) are deduplicated. Colliding messages (same name, different fields) are renamed with a class prefix from the service that owns them.
func WriteProto ¶ added in v0.0.6
WriteProto writes a ProtoData to the appropriate .proto file.
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 BuildFromSpec ¶ added in v0.0.6
BuildFromSpec loads a spec/overlay pair, merges them, and returns proto data.
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 ¶
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 ¶
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.