parcelspec

package
v0.0.6 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: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateGo

func GenerateGo(
	spec ParcelableSpec,
) ([]byte, error)

GenerateGo generates Go source code implementing MarshalParcel/UnmarshalParcel for the given ParcelableSpec. The returned bytes are gofmt-formatted.

Types

type FieldSpec

type FieldSpec struct {
	Name      string `yaml:"name"`
	Type      string `yaml:"type"`                // bool, int32, int64, float32, float64, string8, string16, opaque
	Condition string `yaml:"condition,omitempty"` // e.g. "FieldsMask & 1"
}

FieldSpec describes a single field in a Parcelable wire format.

type JavaExtractor

type JavaExtractor struct {
	// contains filtered or unexported fields
}

JavaExtractor reuses an ANTLR lexer/parser across multiple files. The DFA cache built by the ATN simulator persists across calls, dramatically reducing allocation and GC pressure.

func NewJavaExtractor

func NewJavaExtractor() *JavaExtractor

NewJavaExtractor creates a reusable extractor.

func (*JavaExtractor) ExtractSpecs

func (e *JavaExtractor) ExtractSpecs(
	javaSrc string,
	packageName string,
) []ParcelableSpec

ExtractSpecs parses a Java source file and returns ParcelableSpecs for each class that contains a writeToParcel method. Reuses the internal lexer/parser for DFA cache efficiency.

type ParcelableSpec

type ParcelableSpec struct {
	Package string      `yaml:"package"`
	Type    string      `yaml:"type"`
	Fields  []FieldSpec `yaml:"fields"`
}

ParcelableSpec describes the wire format of a single Java Parcelable type.

func ExtractSpecs

func ExtractSpecs(
	javaSrc string,
	packageName string,
) []ParcelableSpec

ExtractSpecs is a convenience function that creates a one-shot extractor. For batch processing, use NewJavaExtractor() and call its ExtractSpecs method.

Jump to

Keyboard shortcuts

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