idl

package
v0.0.0-...-720af6a Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidPackage

func ValidPackage(pkgName string) error

ValidPackage determines if a package name is valid.

Types

type Enum

type Enum struct {
	Name string
	Size int
	// contains filtered or unexported fields
}

Enum is a set of name values that translate to a number.

func NewEnum

func NewEnum() Enum

New creates a new Enum.

func (Enum) GoType

func (e Enum) GoType() string

func (Enum) Len

func (e Enum) Len() int

func (Enum) OrderByNames

func (e Enum) OrderByNames() []EnumVal

func (Enum) OrderByValues

func (e Enum) OrderByValues() []EnumVal

type EnumVal

type EnumVal struct {
	Name  string
	Value uint16
}

EnumVal is a value stored in an Enum.

type File

type File struct {
	// Package is the name of the package.
	Package string
	// FullPath is the full path to the package.
	FullPath string
	// Version is the version of the Claw language.
	Version int
	// Options defines options that were defined on the file.
	Options map[string]Option
	// Identifers hold types that are defined in this file.
	Identifers map[string]any
	// External holds externally defined types that are imported here.
	External map[string]*File
	// Imports are all the package imports.
	Imports Import

	// RepoVersion is the version of the file in the repo.
	RepoVersion string
	// SHA256 is the file's SHA256 hash value.
	SHA256 string
}

File represents the collected information from a .claw file.

func New

func New() *File

New is the constructor for File.

func (*File) Enums

func (f *File) Enums() chan Enum

Enums returns all Enums that were decoded.

func (*File) FindNext

func (f *File) FindNext(ctx context.Context, p *halfpike.Parser) halfpike.ParseFn

FindNext is used to scan lines until we find the next thing to parse and direct to the halfpike.ParseFn responsible.

func (*File) ParseOptions

func (f *File) ParseOptions(ctx context.Context, p *halfpike.Parser) halfpike.ParseFn

ParseOptions parses file options that follow the root "options" keyword.

func (*File) ParsePackage

func (f *File) ParsePackage(ctx context.Context, p *halfpike.Parser) halfpike.ParseFn

ParseVersion finds the version

func (*File) ParseVersion

func (f *File) ParseVersion(ctx context.Context, p *halfpike.Parser) halfpike.ParseFn

ParseVersion finds the version

func (*File) PkgImports

func (f *File) PkgImports() chan string

PkgImports returns a deduped list of all Claw packages that need importing. This DOES NOT include packages needed for Claw decoding.

func (*File) SkipLinesWithComments

func (f *File) SkipLinesWithComments(p *halfpike.Parser)

func (*File) Start

func (f *File) Start(ctx context.Context, p *halfpike.Parser) halfpike.ParseFn

Start is the start point for reading the IDL.

func (*File) Structs

func (f *File) Structs() []Struct

Structs returns all Structs that were decoded.

func (*File) Validate

func (f *File) Validate() error

Validate validates that the File has all the correct information required.

type Import

type Import struct {
	Imports map[string]ImportEntry
}

Import represents an import block.

func NewImport

func NewImport() Import

NewImport creates a new Import.

func (*Import) ByPkgName

func (i *Import) ByPkgName(name string) (ImportEntry, error)

type ImportEntry

type ImportEntry struct {
	Path string
	Name string
}

ImportEntry represents an individual import entry.

type Option

type Option struct {
	// Name is the name of the Option.
	Name string
	// Args are all the arguments to the Option.
	Args []string
}

Option is an option for the file.

type Options

type Options []Option

Options holds a set of options defined.

type Struct

type Struct struct {
	// Name is the name of the Struct type.
	Name string
	// Fields are the fields in the Struct.
	Fields []StructField

	// File has all the information in the File.
	File *File
}

Struct represents a Claw Struct type in the file.

func NewStruct

func NewStruct(file *File) Struct

NewStruct creates a new Struct type.

func (Struct) Render

func (s Struct) Render() (string, error)

Render renders the Struct in its Go form.

type StructField

type StructField struct {
	// Name is the name of the field.
	Name string
	// Index is the index of the field in the Struct.
	Index uint16
	// Type is the type of the field.
	Type field.Type
	// IsExternal indicates this field type was defined external to the file that has
	// the containing Struct.
	IsExternal bool
	// Package is the name of the package this field type is defined in, but only if
	// IsExternal is set. This is not the path to the package, see FullPath for that.
	Package string
	// FullPath is the path to this package. This is only set if IsExternal is set.
	FullPath string
	// IsEnum indicates if the field represents an enumerator.
	IsEnum bool
	// IsList indicates if the field represents a list of items. This can normally
	// be determined by the .Type, but if the field type is defined externally, we won't
	// have that information available yet and we need to note it is a list.
	IsList bool
	// IdentName is the name of the Struct or Enum that goes in this field. If not a Struct or Enum,
	// this is empty.
	IdentName string
	// SelfReferential indicates this type is the same Struct type as the containing Struct.
	SelfReferential bool
}

StructField represents a field in a Struct.

func (StructField) GoListType

func (s StructField) GoListType() string

GoListType will return the list type: "uint8", "int8", "<Enum Name>", ... for use in templates. If called on a non-list type, this will panic.

func (StructField) IdentInFile

func (s StructField) IdentInFile() string

IdentInFile returns the IdentName, removing a package identifier if it proceeds it in .IdentName.

func (StructField) TypeAsString

func (s StructField) TypeAsString() string

Jump to

Keyboard shortcuts

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