typeregistry

package
v1.49.0-go-generics.1 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package typeregistry offers features useful to manage the registration and operation of types in the context of the jsii runtime. These are used to support type conversion for values exchanged between the child node process and the go application.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TypeRegistry

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

TypeRegistry is used to record runtime type information about the loaded modules, which is later used to correctly convert objects received from the JavaScript process into native go values.

func New

func New() *TypeRegistry

New creates a new type registry.

func (*TypeRegistry) DiscoverImplementation

func (t *TypeRegistry) DiscoverImplementation(vt reflect.Type) (interfaces []api.FQN, overrides []api.Override)

DiscoverImplementation determines the list of registered interfaces that are implemented by the provided type, and returns the list of their FQNs and overrides for all their combined methods and properties.

func (*TypeRegistry) EnsureLoaded

func (t *TypeRegistry) EnsureLoaded(typ reflect.Type)

Ensures the JavaScript module for the provided type has been loaded.

func (*TypeRegistry) EnumMemberForEnumRef

func (t *TypeRegistry) EnumMemberForEnumRef(ref api.EnumRef) (interface{}, error)

EnumMemberForEnumRef returns the go enum member corresponding to a jsii fully qualified enum member name (e.g: "jsii-calc.StringEnum/A"). If no enum member was registered (via registerEnum) for the provided enumref, an error is returned.

func (*TypeRegistry) FindType

func (t *TypeRegistry) FindType(fqn api.FQN) (typ reflect.Type, ok bool)

FindType returns the registered type corresponding to the provided jsii FQN.

func (*TypeRegistry) GetOverride

func (t *TypeRegistry) GetOverride(fqn api.FQN, n string) (api.Override, bool)

func (*TypeRegistry) InitJsiiProxy

func (t *TypeRegistry) InitJsiiProxy(val reflect.Value) error

InitJsiiProxy initializes a jsii proxy value at the provided pointer. It returns an error if the pointer does not have a value of a registered proxyable type (that is, a class or interface type).

func (*TypeRegistry) RegisterClass

func (t *TypeRegistry) RegisterClass(fqn api.FQN, class reflect.Type, overrides []api.Override, maker func() interface{}) error

RegisterClass maps the given FQN to the provided class interface, list of overrides, and proxy maker function. This returns an error if the class type is not a go interface.

func (*TypeRegistry) RegisterEnum

func (t *TypeRegistry) RegisterEnum(fqn api.FQN, enm reflect.Type, loader func(), members map[string]interface{}) error

RegisterEnum maps the given FQN to the provided enum type, and records the provided members map (jsii member name => go value). This returns an error if the provided enum is not a string derivative, or of any of the provided member values has a type other than enm.

func (*TypeRegistry) RegisterInterface

func (t *TypeRegistry) RegisterInterface(fqn api.FQN, iface reflect.Type, loader func(), overrides []api.Override, maker func() interface{}) error

RegisterInterface maps the given FQN to the provided interface type, list of overrides, and proxy maker function. Returns an error if the provided interface is not a go interface.

func (*TypeRegistry) RegisterStruct

func (t *TypeRegistry) RegisterStruct(fqn api.FQN, strct reflect.Type, loader func()) error

RegisterStruct maps the given FQN to the provided struct type, and struct interface. Returns an error if the provided struct type is not a go struct, or the provided iface not a go interface.

func (*TypeRegistry) StructFields

func (t *TypeRegistry) StructFields(typ reflect.Type) (fields []reflect.StructField, fqn api.FQN, ok bool)

StructFields returns the list of fields associated with a jsii struct type, the jsii fully qualified type name, and a boolean telling whether the provided type was a registered jsii struct type.

func (*TypeRegistry) TryRenderEnumRef

func (t *TypeRegistry) TryRenderEnumRef(value reflect.Value) (ref *api.EnumRef, isEnumRef bool)

TryRenderEnumRef returns an enumref if the provided value corresponds to a registered enum type. The returned enumref is nil if the provided enum value is a zero-value (i.e: "").

Jump to

Keyboard shortcuts

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