idl

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var InterfaceTypeForStub = false

InterfaceTypeForStub is a global flags which informs the InterfaceType instances if they are used in the context of the generation of a stub.

Functions

func GenerateIDL

func GenerateIDL(writer io.Writer, packageName string, objs map[string]object.MetaObject) error

GenerateIDL writes the IDL definition for the meta object in objs. a MetaObject into a writer. This IDL definition can be used to re-create the MetaObject with the method ParseIDL.

func NewRefType

func NewRefType(name string, scope Scope) signature.Type

NewRefType is a contructor for the representation of a type reference to be resolved with a TypeSet.

func ParseIDL

func ParseIDL(reader io.Reader) ([]object.MetaObject, error)

ParseIDL read an IDL definition from a reader and returns the MetaObject associated with the IDL.

Types

type Context

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

Context catures the current state of the parser.

func NewContext

func NewContext() *Context

NewContext creates a new context.

type InterfaceType

type InterfaceType struct {
	Name        string
	PackageName string
	Methods     map[uint32]Method
	Signals     map[uint32]Signal
	Properties  map[uint32]Property
	Scope       Scope
	Namespace   Namespace
	ForStub     bool
}

InterfaceType represents a parsed IDL interface. It implements signature.Type.

func (*InterfaceType) Marshal

func (s *InterfaceType) Marshal(id string, writer string) *jen.Statement

Marshal returns a statement which represent the code needed to put the variable "id" into the io.Writer "writer" while returning an error.

func (*InterfaceType) MetaObject

func (s *InterfaceType) MetaObject() object.MetaObject

MetaObject returs the MetaObject describing the interface.

func (*InterfaceType) Reader

func (s *InterfaceType) Reader() signature.TypeReader

Reader returns a TypeReader for object references

func (*InterfaceType) RegisterTo

func (s *InterfaceType) RegisterTo(set *signature.TypeSet)

RegisterTo adds the type to the type set.

func (*InterfaceType) Signature

func (s *InterfaceType) Signature() string

Signature returns "o".

func (*InterfaceType) SignatureIDL

func (s *InterfaceType) SignatureIDL() string

SignatureIDL returns "obj".

func (*InterfaceType) Type

func (s *InterfaceType) Type() reflect.Type

func (*InterfaceType) TypeDeclaration

func (s *InterfaceType) TypeDeclaration(f *jen.File)

TypeDeclaration writes the type declaration into file. It generates the proxy for the interface.

func (*InterfaceType) TypeName

func (s *InterfaceType) TypeName() *jen.Statement

TypeName returns a statement to be inserted when the type is to be declared.

func (*InterfaceType) Unmarshal

func (s *InterfaceType) Unmarshal(reader string) *jen.Statement

Unmarshal returns a statement which represent the code needed to read from a reader "reader" of type io.Reader and returns both the value read and an error.

type Method

type Method struct {
	Name   string
	ID     uint32
	Return signature.Type
	Params []Parameter
}

Method represents the signature of a method describe in an IDL file.

func (Method) Meta

func (m Method) Meta(id uint32) object.MetaMethod

Meta translate the method signature into a MetaMethod use in a MetaObject. There is not a one-to-one mapping between the two structures: Method capture the reference to other interface (object) while MetaMethod treats all object with a generic reference.

func (Method) Tuple

func (m Method) Tuple() *signature.TupleType

Tuple returns a TupleType used to generate marshall/unmarshall operations.

func (Method) Type

func (m Method) Type() signature.Type

type Namespace

type Namespace map[string]Scope

Namespace represents a set of packages extracted from IDL files. Each package is given a name and a set of types.

type PackageDeclaration

type PackageDeclaration struct {
	Name  string
	Types []signature.Type
}

PackageDeclaration is the result of the parsing of an IDL file. It represents a package declaration containing a package name and a list of declared types.

func ParsePackage

func ParsePackage(input []byte) (*PackageDeclaration, error)

ParsePackage takes an IDL file as input, parse it and returns a PackageDeclaration.

type Parameter

type Parameter struct {
	Name string
	Type signature.Type
}

Parameter represents a method parameter. It is used to describe a method.

type Property

type Property struct {
	Name   string
	ID     uint32
	Params []Parameter
}

Property represents a property

func (Property) Meta

func (p Property) Meta(id uint32) object.MetaProperty

Meta converts a property to a MetaProperty.

func (Property) Tuple

func (s Property) Tuple() *signature.TupleType

Tuple returns a TupleType used to generate marshall/unmarshall operations.

func (Property) Type

func (p Property) Type() signature.Type

Type returns a StructType used to generate marshall/unmarshall operations.

type RefType

type RefType struct {
	Scope Scope
	Name  string
}

RefType represents a reference to an IDL interface. It implements signature.Type.

func (*RefType) Marshal

func (r *RefType) Marshal(id string, writer string) *signature.Statement

Marshal returns a statement which represent the code needed to put the variable "id" into the io.Writer "writer" while returning an error.

func (*RefType) Reader

func (r *RefType) Reader() signature.TypeReader

Reader returns a TypeReader of the referenced type.

func (*RefType) RegisterTo

func (r *RefType) RegisterTo(set *signature.TypeSet)

RegisterTo adds the type to the type set. Does nothing on RefType.

func (*RefType) Signature

func (r *RefType) Signature() string

Signature returns the signature of the referenced type. If the reference can not be resolved, it returns an invalid struct type with a name describing the error.

func (*RefType) SignatureIDL

func (r *RefType) SignatureIDL() string

SignatureIDL returns the IDL signature of the referenced type. If the reference can not be resolved, it returns an invalid name describing the error.

func (*RefType) Type

func (r *RefType) Type() reflect.Type

func (*RefType) TypeDeclaration

func (r *RefType) TypeDeclaration(file *jen.File)

TypeDeclaration writes the type declaration into file.

func (*RefType) TypeName

func (r *RefType) TypeName() *signature.Statement

TypeName returns a statement to be inserted when the type is to be declared.

func (*RefType) Unmarshal

func (r *RefType) Unmarshal(reader string) *signature.Statement

Unmarshal returns a statement which represent the code needed to read from a reader "reader" of type io.Reader and returns both the value read and an error.

type Scope

type Scope interface {
	Add(name string, typ signature.Type) error
	Search(name string) (signature.Type, error)
	Extend(namespace string, other Scope) error
}

Scope represents the scope of a type in which type declarations are resolved.

func NewScope

func NewScope() Scope

NewScope returns a new scope.

type Signal

type Signal struct {
	Name   string
	ID     uint32
	Params []Parameter
}

Signal represent an interface signal

func (Signal) Meta

func (s Signal) Meta(id uint32) object.MetaSignal

Meta returns a MetaSignal.

func (Signal) Tuple

func (s Signal) Tuple() *signature.TupleType

Tuple returns a TupleType used to generate marshall/unmarshall operations.

func (Signal) Type

func (s Signal) Type() signature.Type

Type returns a StructType used to generate marshall/unmarshall operations.

type Statement

type Statement = jen.Statement

Statement is imported from jennifer code generator.

Jump to

Keyboard shortcuts

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