def

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBitmaskTypeFromXML

func NewBitmaskTypeFromXML(node *xmlquery.Node) *bitmaskType

func NewBitmaskValueFromXML

func NewBitmaskValueFromXML(forBitmask TypeDefiner, elt *xmlquery.Node) *bitmaskValue

func NewCommandFromJSON

func NewCommandFromJSON(key, json gjson.Result) *commandType

func NewCommandFromXML

func NewCommandFromXML(elt *xmlquery.Node) *commandType

func NewCommandParamFromXML

func NewCommandParamFromXML(elt *xmlquery.Node, forCommand *commandType) *commandParam

func NewDefineTypeFromXML

func NewDefineTypeFromXML(node *xmlquery.Node) *defineType

NewDefineTypeFromXML has a few processing paths. First, the name is typically a child node, but is an XML attribute for a few entries. Next, some defines such as VK_API_VERSION_1_0 are actually macro calls, which is named in a child node for type. Defines may also have a requires attr, which also indicates the name of the macro call, except when it doesn't (e.g., VK_HEADER_VERSION_COMPLETE). Then, parameters of the macro may be present in plain text between parenthesis. Or the define might be a singular value, in the case of VK_HEADER_VERSION.

func NewEnumValueFromXML

func NewEnumValueFromXML(td TypeDefiner, elt *xmlquery.Node) *enumValue

func NewExternalTypeFromXML

func NewExternalTypeFromXML(node *xmlquery.Node) *externalType

func NewIncludeTypeFromXML

func NewIncludeTypeFromXML(node *xmlquery.Node) *includeType

func NewOrUpdateExternalValueFromJSON

func NewOrUpdateExternalValueFromJSON(key, value string, td TypeDefiner, tr TypeRegistry, vr ValueRegistry)

func NewUntypedEnumValueFromXML

func NewUntypedEnumValueFromXML(elt *xmlquery.Node) *extenValue

func ReadAllExtensionsFromXML

func ReadAllExtensionsFromXML(doc *xmlquery.Node, tr TypeRegistry, vr ValueRegistry) []*extensionSet

func ReadApiConstantsFromXML

func ReadApiConstantsFromXML(doc *xmlquery.Node, externalType TypeDefiner, tr TypeRegistry, vr ValueRegistry)

func ReadBaseTypeExceptionsFromJSON

func ReadBaseTypeExceptionsFromJSON(exceptions gjson.Result, tr TypeRegistry, vr ValueRegistry)

func ReadBaseTypesFromXML

func ReadBaseTypesFromXML(doc *xmlquery.Node, tr TypeRegistry, _ ValueRegistry)

func ReadBitmaskTypesFromXML

func ReadBitmaskTypesFromXML(doc *xmlquery.Node, tr TypeRegistry, vr ValueRegistry)

func ReadCommandExceptionsFromJSON

func ReadCommandExceptionsFromJSON(exceptions gjson.Result, tr TypeRegistry, vr ValueRegistry)

func ReadCommandTypesFromXML

func ReadCommandTypesFromXML(doc *xmlquery.Node, tr TypeRegistry, vr ValueRegistry)

func ReadDefineExceptionsFromJSON

func ReadDefineExceptionsFromJSON(exceptions gjson.Result, tr TypeRegistry, vr ValueRegistry)

func ReadDefineTypesFromXML

func ReadDefineTypesFromXML(doc *xmlquery.Node, tr TypeRegistry, _ ValueRegistry)

func ReadEnumTypesFromXML

func ReadEnumTypesFromXML(doc *xmlquery.Node, tr TypeRegistry, vr ValueRegistry)

func ReadEnumValuesFromXML

func ReadEnumValuesFromXML(doc *xmlquery.Node, td TypeDefiner, tr TypeRegistry, vr ValueRegistry)

func ReadExternalExceptionsFromJSON

func ReadExternalExceptionsFromJSON(exceptions gjson.Result, tr TypeRegistry, vr ValueRegistry)

func ReadExternalTypesFromXML

func ReadExternalTypesFromXML(doc *xmlquery.Node, tr TypeRegistry, vr ValueRegistry)

func ReadFeatureFromXML

func ReadFeatureFromXML(featureNode *xmlquery.Node, tr TypeRegistry, vr ValueRegistry) *featureSet

func ReadHandleExceptionsFromJSON

func ReadHandleExceptionsFromJSON(exceptions gjson.Result, tr TypeRegistry, vr ValueRegistry)

func ReadHandleTypesFromXML

func ReadHandleTypesFromXML(doc *xmlquery.Node, tr TypeRegistry, _ ValueRegistry)

func ReadIncludeExceptionsFromJSON

func ReadIncludeExceptionsFromJSON(exceptions gjson.Result, tr TypeRegistry, vr ValueRegistry)

func ReadIncludeTypesFromXML

func ReadIncludeTypesFromXML(doc *xmlquery.Node, tr TypeRegistry, _ ValueRegistry)

func ReadPlatformExceptionsFromJSON

func ReadPlatformExceptionsFromJSON(exceptions gjson.Result, fm FeatureMap)

func ReadStructExceptionsFromJSON

func ReadStructExceptionsFromJSON(exceptions gjson.Result, tr TypeRegistry, vr ValueRegistry)

func ReadStructTypesFromXML

func ReadStructTypesFromXML(doc *xmlquery.Node, tr TypeRegistry, vr ValueRegistry)

func ReadUnionExceptionsFromJSON

func ReadUnionExceptionsFromJSON(exceptions gjson.Result, tr TypeRegistry, vr ValueRegistry)

func ReadUnionTypesFromXML

func ReadUnionTypesFromXML(doc *xmlquery.Node, tr TypeRegistry, vr ValueRegistry)

func RenameIdentifier

func RenameIdentifier(s string) string

RenameIdentifier trims the leading Vk (or variants) and then renames any keywords or typenames reserved in Go. Every type and value definer needs to call this on every registry name.

func SegmentExtensionsByPlatform

func SegmentExtensionsByPlatform(allExts []*extensionSet) map[string][]*extensionSet

func UpdateUnionTypeFromJSON

func UpdateUnionTypeFromJSON(key, json gjson.Result, td *unionType)

func WriteStringerCommands

func WriteStringerCommands(w io.Writer, defs []TypeDefiner, cat TypeCategory, filenameBase string)

Types

type Aliaser

type Aliaser interface {
	SetAliasType(TypeDefiner)
	IsAlias() bool
}

type ByName

type ByName []TypeDefiner

func (ByName) Len

func (a ByName) Len() int

func (ByName) Less

func (a ByName) Less(i, j int) bool

func (ByName) Swap

func (a ByName) Swap(i, j int)

type ByValue

type ByValue []ValueDefiner

func (ByValue) Len

func (a ByValue) Len() int

TODO: also sort by bitmask values and aliases

func (ByValue) Less

func (a ByValue) Less(i, j int) bool

func (ByValue) Swap

func (a ByValue) Swap(i, j int)

type ByValuePublicName

type ByValuePublicName []ValueDefiner // add for cleanup/issue-3

func (ByValuePublicName) Len

func (a ByValuePublicName) Len() int

func (ByValuePublicName) Less

func (a ByValuePublicName) Less(i, j int) bool

func (ByValuePublicName) Swap

func (a ByValuePublicName) Swap(i, j int)

type FeatureCollection

type FeatureCollection interface {
	Resolver
	ResolvedTypes() TypeRegistry

	FilterTypesByCategory() map[TypeCategory]FeatureCollection

	Platform() string
	FilenameFragment() string
	WriteBuildTags(io.Writer)

	MergeWith(FeatureCollection)
	// contains filtered or unexported methods
}

type FeatureMap

type FeatureMap map[string]FeatureCollection

func ReadPlatformsFromXML

func ReadPlatformsFromXML(doc *xmlquery.Node) FeatureMap

type ImportMap

type ImportMap map[string]bool

func (ImportMap) SortedKeys

func (m ImportMap) SortedKeys() []string

type IncludeSet

type IncludeSet struct {
	IncludeTypes, IncludeValues map[string]bool
	ResolvedTypes               TypeRegistry
	ResolvedValues              ValueRegistry
}

func NewIncludeSet

func NewIncludeSet() *IncludeSet

func (*IncludeSet) MergeWith

func (is *IncludeSet) MergeWith(js *IncludeSet)

type Namer

type Namer interface {
	RegistryName() string
	PublicName() string
	InternalName() string

	Aliaser
	Resolver
}

type Printer

type Printer interface {
	RegisterImports(reg map[string]bool)
	PrintGlobalDeclarations(io.Writer, int, bool)
	PrintFileInitContent(io.Writer)
	PrintPublicDeclaration(io.Writer)
	PrintInternalDeclaration(io.Writer)
	PrintPublicToInternalTranslation(w io.Writer, inputVar, outputVar, lenSpec string)

	// PrintTranslateToPublic(w io.Writer, inputVar, outputVar string)
	PrintTranslateToInternal(w io.Writer, inputVar, outputVar string)
	TranslateToPublic(inputVar string) string
	TranslateToInternal(inputVar string) string
}

type Resolver

type Resolver interface {
	Resolve(TypeRegistry, ValueRegistry) *IncludeSet
	IsIdenticalPublicAndInternal() bool
}

type TypeCategory

type TypeCategory int
const (
	CatNone TypeCategory = iota

	CatExten // meta-category for printing extension names/version constants

	CatDefine
	CatInclude
	CatExternal

	CatHandle
	CatBasetype
	CatEnum
	CatBitmask

	CatStruct
	CatUnion

	CatPointer
	CatArray

	CatCommand

	CatMaximum
)

func (TypeCategory) ReadFns

func (c TypeCategory) ReadFns() (fnReadFromXML, fnReadFromJSON)

func (TypeCategory) String

func (i TypeCategory) String() string

type TypeDefiner

type TypeDefiner interface {
	Category() TypeCategory
	Namer
	Resolver
	Printer

	AllValues() []ValueDefiner
	PushValue(ValueDefiner)
	AppendValues(vals ValueRegistry)
}

func NewBaseTypeFromXML

func NewBaseTypeFromXML(node *xmlquery.Node) TypeDefiner

func NewDefineTypeFromJSON

func NewDefineTypeFromJSON(key, json gjson.Result) TypeDefiner

func NewEnumTypeFromXML

func NewEnumTypeFromXML(node *xmlquery.Node) TypeDefiner

func NewHandleTypeFromJSON

func NewHandleTypeFromJSON(key, json gjson.Result) TypeDefiner

func NewHandleTypeFromXML

func NewHandleTypeFromXML(node *xmlquery.Node) TypeDefiner

func NewOrUpdateBaseTypeFromJSON

func NewOrUpdateBaseTypeFromJSON(key string, exception gjson.Result, tr TypeRegistry, vr ValueRegistry) TypeDefiner

func NewOrUpdateExternalTypeFromJSON

func NewOrUpdateExternalTypeFromJSON(key string, exception gjson.Result, tr TypeRegistry, vr ValueRegistry) TypeDefiner

func NewOrUpdateIncludeTypeFromJSON

func NewOrUpdateIncludeTypeFromJSON(key string, exception gjson.Result, tr TypeRegistry, vr ValueRegistry) TypeDefiner

func NewOrUpdateStructTypeFromJSON

func NewOrUpdateStructTypeFromJSON(key, json gjson.Result, existing *structType) TypeDefiner

type TypeRegistry

type TypeRegistry map[string]TypeDefiner

func (TypeRegistry) SelectCategory

func (tr TypeRegistry) SelectCategory(cat TypeCategory) *IncludeSet

type ValueDefiner

type ValueDefiner interface {
	RegistryName() string
	PublicName() string

	ValueString() string
	UnderlyingTypeName() string
	ResolvedType() TypeDefiner

	Resolve(TypeRegistry, ValueRegistry) *IncludeSet

	PrintPublicDeclaration(w io.Writer)
	SetExtensionNumber(int)

	IsAlias() bool
	IsCore() bool
}

type ValueRegistry

type ValueRegistry map[string]ValueDefiner

Jump to

Keyboard shortcuts

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