codegen

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: GPL-3.0 Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Generator

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

Generator generates Go source code from a protocol schema.

func NewGenerator

func NewGenerator(lib *protocol.Library) *Generator

NewGenerator creates a new code generator.

func (*Generator) GenerateC

func (g *Generator) GenerateC(name string) (string, error)

GenerateC generates C struct code for the given protocol.

func (*Generator) GenerateEmbeddedC

func (g *Generator) GenerateEmbeddedC(name string) (string, error)

GenerateEmbeddedC generates embedded-friendly C code (no malloc, fixed buffers).

func (*Generator) GenerateFromTemplate

func (g *Generator) GenerateFromTemplate(name, templateFile string) (string, error)

GenerateFromTemplate generates code using a custom Go text/template file.

func (*Generator) GenerateGo

func (g *Generator) GenerateGo(name, pkgName string) (string, error)

GenerateGo generates Go source code for the given protocol.

func (*Generator) GeneratePython

func (g *Generator) GeneratePython(name string) (string, error)

GeneratePython generates Python dataclass code for the given protocol.

func (*Generator) GenerateRust

func (g *Generator) GenerateRust(name string) (string, error)

GenerateRust generates Rust struct code for the given protocol.

func (*Generator) GenerateTypeScript

func (g *Generator) GenerateTypeScript(name string) (string, error)

GenerateTypeScript generates TypeScript type definitions for the given protocol.

func (*Generator) GenerateWireshark

func (g *Generator) GenerateWireshark(name string) (string, error)

GenerateWireshark generates a Lua dissector script for Wireshark.

type TemplateData

type TemplateData struct {
	Name      string
	Version   string
	ByteOrder string
	Fields    []TemplateField
}

TemplateData holds the data passed to custom templates.

type TemplateField

type TemplateField struct {
	Name      string
	Type      string
	BitWidth  int
	ByteWidth int
	Comment   string
}

TemplateField holds field data for templates.

Jump to

Keyboard shortcuts

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