gospec

package
v0.0.0-...-ca7aa0c Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasTag

func HasTag(field *Field, tagName, attribute string) bool

HasTag checks for a specific tag value presence

Types

type Context

type Context struct {
	FormatName string `json:"format"`
	Specs      []Spec `json:"specs"`
	Enums      []Enum `json:"enums"`
}

Context contains all processed specs

func ParseFile

func ParseFile(filePath string) (Context, error)

ParseFile processes the provided gspec file

func (*Context) ExportC

func (ctx *Context) ExportC()

ExportC exports data to the C language format

func (*Context) ExportGo

func (ctx *Context) ExportGo()

ExportGo exports data to the Go language format

func (*Context) ExportJSON

func (ctx *Context) ExportJSON()

ExportJSON marshals our current data into JSON format

func (*Context) ExportMD

func (ctx *Context) ExportMD()

ExportMD exports the data into a Markdown table format

type Enum

type Enum struct {
	Name   string      `json:"name"`
	Fields []EnumField `json:"fields"`
}

Enum describes enumeration

type EnumField

type EnumField struct {
	Value     string `json:"value"`
	DocString string `json:"_doc"`
}

EnumField describes enum value

type Field

type Field struct {
	Name       string `json:"name"`
	Type       string `json:"type"`
	IsArray    bool   `json:"is_array"`
	IsPointer  bool   `json:"is_ptr"`
	ArrayLen   uint   `json:"len"`
	InnerArray *Field `json:"inner"`
	Tags       []Tag  `json:"tags"`
	DocString  string `json:"_doc"`
}

Field describes the data inside of spec

type Spec

type Spec struct {
	Name      string  `json:"name"`
	Fields    []Field `json:"fields"`
	DocString string  `json:"_doc"`
	// contains filtered or unexported fields
}

Spec describes our structured data

type Tag

type Tag struct {
	Name   string   `json:"tag"`
	Values []string `json:"vals"`
}

Tag describes tags decorating the field

Jump to

Keyboard shortcuts

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