idl

package
v0.0.0-...-5bd6a24 Latest Latest
Warning

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

Go to latest
Published: May 17, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package idl provides support for CORBA IDL (Interface Definition Language) including parsing and code generation functionality

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateRepositoryID

func GenerateRepositoryID(modulePath []string, typeName string, version string) string

GenerateRepositoryID 根据模块前缀和类型名生成标准的 Repository ID

func MarshalValue

func MarshalValue(value interface{}) (interface{}, error)

MarshalValue marshals a Go value to a CORBA value

func Register

func Register(orb *corba.ORB, objectName string, servant interface{}) error

Register registers a servant with the ORB

func UnmarshalValue

func UnmarshalValue(corbaValue interface{}, goType reflect.Type) (interface{}, error)

UnmarshalValue unmarshals a CORBA value to a Go value

Types

type Any

type Any struct {
	TypeCode TypeCode
	Value    interface{}
}

Any represents a CORBA any type that can hold values of any type

func NewAny

func NewAny(value interface{}) (*Any, error)

NewAny creates a new Any value

type Attribute

type Attribute struct {
	Name     string
	Type     Type
	Readonly bool
}

Attribute represents an attribute in an IDL interface

type BaseType

type BaseType struct {
	RepositoryID string
}

BaseType 提供基本的类型功能,可以被其他类型嵌入

func (*BaseType) GetRepositoryID

func (t *BaseType) GetRepositoryID() string

GetRepositoryID returns the repository ID

func (*BaseType) SetRepositoryID

func (t *BaseType) SetRepositoryID(repoID string)

SetRepositoryID sets the repository ID

type BasicType

type BasicType string

BasicType represents a primitive IDL type

const (
	TypeShort     BasicType = "short"
	TypeLong      BasicType = "long"
	TypeLongLong  BasicType = "long long"
	TypeUShort    BasicType = "unsigned short"
	TypeULong     BasicType = "unsigned long"
	TypeULongLong BasicType = "unsigned long long"
	TypeFloat     BasicType = "float"
	TypeDouble    BasicType = "double"
	TypeBoolean   BasicType = "boolean"
	TypeChar      BasicType = "char"
	TypeWChar     BasicType = "wchar"
	TypeOctet     BasicType = "octet"
	TypeAny       BasicType = "any"
	TypeString    BasicType = "string"
	TypeWString   BasicType = "wstring"
	TypeVoid      BasicType = "void"
)

IDL Basic Types

type Direction

type Direction string

Direction represents the parameter direction in IDL operations

const (
	In    Direction = "in"
	Out   Direction = "out"
	InOut Direction = "inout"
)

Parameter direction constants

type EnumType

type EnumType struct {
	BaseType
	Name     string
	Module   string
	Elements []string
}

EnumType represents an IDL enum type

func (*EnumType) GoTypeName

func (t *EnumType) GoTypeName() string

GoTypeName returns the corresponding Go type name

func (*EnumType) TypeName

func (t *EnumType) TypeName() string

TypeName returns the IDL type name

type Generator

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

Generator generates Go code from IDL definitions

func NewGenerator

func NewGenerator(module *Module, outputDir string) *Generator

NewGenerator creates a new Go code generator for IDL

func (*Generator) AddInclude

func (g *Generator) AddInclude(include string)

AddInclude adds an import to include in generated files

func (*Generator) Generate

func (g *Generator) Generate() error

Generate generates Go code for all types in the module and its submodules

func (*Generator) SetPackageName

func (g *Generator) SetPackageName(name string)

SetPackageName sets the Go package name to use for generated code

type Helper

type Helper interface {
	// ID returns the repository ID for the type
	ID() string
}

Helper is a base interface for all CORBA helper classes

type InterfaceType

type InterfaceType struct {
	BaseType
	Name       string
	Module     string
	Parents    []string
	Operations []Operation
	Attributes []Attribute
	Types      map[string]Type // Support for nested enums/types
}

InterfaceType represents an IDL interface type

func (*InterfaceType) GoTypeName

func (t *InterfaceType) GoTypeName() string

GoTypeName returns the corresponding Go type name

func (*InterfaceType) TypeName

func (t *InterfaceType) TypeName() string

TypeName returns the IDL type name

type Module

type Module struct {
	Name       string
	Parent     *Module
	Types      map[string]Type
	Submodules map[string]*Module
	Prefix     string // Repository ID prefix for this module
}

Module represents an IDL module that contains types

func NewModule

func NewModule(name string) *Module

NewModule creates a new IDL module

func (*Module) AddSubmodule

func (m *Module) AddSubmodule(name string) *Module

AddSubmodule adds a submodule with the given name

func (*Module) AddType

func (m *Module) AddType(name string, typ Type)

AddType adds a type to the module

func (*Module) AllTypes

func (m *Module) AllTypes() map[string]Type

AllTypes returns all types in the module and its submodules

func (*Module) BuildRepositoryID

func (m *Module) BuildRepositoryID(typeName string, version string) string

BuildRepositoryID 根据模块层次结构构建 Repository ID

func (*Module) FullName

func (m *Module) FullName() string

FullName returns the fully qualified module name

func (*Module) GetSubmodule

func (m *Module) GetSubmodule(name string) (*Module, bool)

GetSubmodule gets a submodule by name

func (*Module) GetType

func (m *Module) GetType(name string) (Type, bool)

GetType gets a type by name

func (*Module) GoPackageName

func (m *Module) GoPackageName() string

GoPackageName returns the Go package name for this module

func (*Module) Path

func (m *Module) Path() []string

Path returns the module path as a slice of names

type Operation

type Operation struct {
	Name       string
	ReturnType Type
	Parameters []Parameter
	Raises     []string
	Oneway     bool
}

Operation represents an operation in an IDL interface

type Parameter

type Parameter struct {
	Name      string
	Type      Type
	Direction Direction
}

Parameter represents a parameter in an IDL operation

type Parser

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

Parser represents an IDL parser that reads and parses IDL files

func NewParser

func NewParser() *Parser

NewParser creates a new IDL parser

func (*Parser) AddIncludeDir

func (p *Parser) AddIncludeDir(dir string)

AddIncludeDir adds a directory to search for included files

func (*Parser) GetRootModule

func (p *Parser) GetRootModule() *Module

GetRootModule returns the root module containing all parsed types

func (*Parser) Parse

func (p *Parser) Parse(reader io.Reader) error

Parse parses an IDL file

func (*Parser) SetCurrentFile

func (p *Parser) SetCurrentFile(filename string)

SetCurrentFile sets the name of the file currently being processed

func (*Parser) SetIncludeDirs

func (p *Parser) SetIncludeDirs(dirs []string)

SetIncludeDirs sets the directories to search for included files

func (*Parser) SetIncludeHandler

func (p *Parser) SetIncludeHandler(handler func(string) (io.Reader, error))

SetIncludeHandler sets a handler for #include directives

type Repository

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

Repository represents an Interface Repository that stores IDL type information

func NewRepository

func NewRepository() *Repository

NewRepository creates a new interface repository

func (*Repository) Get

func (r *Repository) Get(id string) (Type, bool)

Get retrieves a type from the repository

func (*Repository) Register

func (r *Repository) Register(id string, t Type)

Register adds a type to the repository

type ScopedType

type ScopedType struct {
	BaseType
	Name string // 包含完整作用域的类型名称,例如 "module::submodule::type"
}

ScopedType 表示带有作用域的类型,例如 A::B::C

func (*ScopedType) GoTypeName

func (t *ScopedType) GoTypeName() string

GoTypeName 返回对应的Go类型名

func (*ScopedType) TypeName

func (t *ScopedType) TypeName() string

TypeName 返回类型全名(包括作用域)

type SequenceType

type SequenceType struct {
	BaseType
	ElementType Type
	MaxSize     int // -1 for unbounded
}

SequenceType represents an IDL sequence type

func (*SequenceType) GoTypeName

func (t *SequenceType) GoTypeName() string

GoTypeName returns the corresponding Go type name

func (*SequenceType) TypeName

func (t *SequenceType) TypeName() string

TypeName returns the IDL type name

type ServantBase

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

ServantBase is a base for all CORBA servants

func (*ServantBase) Dispatch

func (s *ServantBase) Dispatch(methodName string, args []interface{}) (interface{}, error)

Dispatch dispatches a method call to the servant implementation

func (*ServantBase) SetDispatcher

func (s *ServantBase) SetDispatcher(dispatcher func(methodName string, args []interface{}) (interface{}, error))

SetDispatcher sets the function that will handle method dispatching

type SimpleType

type SimpleType struct {
	BaseType
	Name BasicType
}

SimpleType represents a basic IDL type

func (*SimpleType) GoTypeName

func (t *SimpleType) GoTypeName() string

GoTypeName returns the corresponding Go type name

func (*SimpleType) TypeName

func (t *SimpleType) TypeName() string

TypeName returns the IDL type name

type StructField

type StructField struct {
	Name string
	Type Type
}

StructField represents a field in an IDL struct

type StructType

type StructType struct {
	BaseType
	Name   string
	Module string
	Fields []StructField
}

StructType represents an IDL struct type

func (*StructType) GoTypeName

func (t *StructType) GoTypeName() string

GoTypeName returns the corresponding Go type name

func (*StructType) TypeName

func (t *StructType) TypeName() string

TypeName returns the IDL type name

type StubFactory

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

StubFactory creates client stubs for interfaces

func NewStubFactory

func NewStubFactory(orb *corba.ORB, repo *Repository) *StubFactory

NewStubFactory creates a new factory for client stubs

func (*StubFactory) CreateStub

func (f *StubFactory) CreateStub(objRef *corba.ObjectRef, interfaceName string) (interface{}, error)

CreateStub creates a new stub for a given interface

type TCKind

type TCKind int

TCKind represents the kind of a TypeCode

const (
	TCVoid TCKind = iota
	TCShort
	TCLong
	TCLongLong
	TCUShort
	TCULong
	TCULongLong
	TCFloat
	TCDouble
	TCBoolean
	TCChar
	TCWChar
	TCOctet
	TCAny
	TCString
	TCWString
	TCSequence
	TCArray
	TCStruct
	TCUnion
	TCEnum
	TCAlias
	TCException
	TCValue
	TCValueBox
	TCNative
	TCAbstractInterface
)

TypeCode kinds

type Type

type Type interface {
	TypeName() string
	GoTypeName() string
	GetRepositoryID() string
	SetRepositoryID(string)
}

Type is the interface for all IDL types

type TypeCode

type TypeCode struct {
	Kind    TCKind
	ID      string
	Name    string
	Length  int
	Content *TypeCode
	Members []TypeCodeMember
}

TypeCode represents the metadata for a type

func TypeCodeFromValue

func TypeCodeFromValue(value interface{}) (TypeCode, error)

TypeCodeFromValue creates a TypeCode from a Go value

type TypeCodeMember

type TypeCodeMember struct {
	Name string
	Type *TypeCode
	ID   string
}

TypeCodeMember represents a member in a complex type

type TypeDef

type TypeDef struct {
	BaseType
	Name     string
	Module   string
	OrigType Type
}

TypeDef represents an IDL typedef

func (*TypeDef) GoTypeName

func (t *TypeDef) GoTypeName() string

GoTypeName returns the corresponding Go type name

func (*TypeDef) TypeName

func (t *TypeDef) TypeName() string

TypeName returns the IDL type name

type UnionCase

type UnionCase struct {
	Labels []string
	Name   string
	Type   Type
}

UnionCase represents a case in an IDL union

type UnionType

type UnionType struct {
	BaseType
	Name         string
	Module       string
	Discriminant Type
	Cases        []UnionCase
}

UnionType represents an IDL union type

func (*UnionType) GoTypeName

func (t *UnionType) GoTypeName() string

GoTypeName returns the corresponding Go type name

func (*UnionType) TypeName

func (t *UnionType) TypeName() string

TypeName returns the IDL type name

Jump to

Keyboard shortcuts

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