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 ¶
- type TypeRegistry
- func (t *TypeRegistry) DiscoverImplementation(vt reflect.Type) (interfaces []api.FQN, overrides []api.Override)
- func (t *TypeRegistry) EnsureLoaded(typ reflect.Type)
- func (t *TypeRegistry) EnumMemberForEnumRef(ref api.EnumRef) (interface{}, error)
- func (t *TypeRegistry) FindType(fqn api.FQN) (typ reflect.Type, ok bool)
- func (t *TypeRegistry) GetOverride(fqn api.FQN, n string) (api.Override, bool)
- func (t *TypeRegistry) InitJsiiProxy(val reflect.Value) error
- func (t *TypeRegistry) RegisterClass(fqn api.FQN, class reflect.Type, overrides []api.Override, ...) error
- func (t *TypeRegistry) RegisterEnum(fqn api.FQN, enm reflect.Type, loader func(), members map[string]interface{}) error
- func (t *TypeRegistry) RegisterInterface(fqn api.FQN, iface reflect.Type, loader func(), overrides []api.Override, ...) error
- func (t *TypeRegistry) RegisterStruct(fqn api.FQN, strct reflect.Type, loader func()) error
- func (t *TypeRegistry) StructFields(typ reflect.Type) (fields []reflect.StructField, fqn api.FQN, ok bool)
- func (t *TypeRegistry) TryRenderEnumRef(value reflect.Value) (ref *api.EnumRef, isEnumRef bool)
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 (*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 ¶
FindType returns the registered type corresponding to the provided jsii FQN.
func (*TypeRegistry) GetOverride ¶
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 ¶
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 ¶
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: "").