typeregistry

package
v1.23.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2021 License: Apache-2.0 Imports: 3 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 TypeRegisterer

type TypeRegisterer interface {
	// RegisterClass maps the given FQN to the provided class interface, and proxy
	// maker function. This returns an error if the class type is not a go interface.
	RegisterClass(fqn api.FQN, class reflect.Type, maker func() 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.
	RegisterEnum(fqn api.FQN, enm reflect.Type, members map[string]interface{}) error

	// RegisterInterface maps the given FQN to the provided interface type, and
	// proxy maker function. Returns an error if the provided interface is not a go
	// interface.
	RegisterInterface(fqn api.FQN, iface reflect.Type, maker func() interface{}) 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.
	RegisterStruct(fqn api.FQN, strct reflect.Type) error
}

TypeRegisterer exposes the methods to register types with the jsii runtime for go.

type TypeRegistry

type TypeRegistry interface {
	TypeRegisterer

	// StructFields returns the list of fields that make a registered jsii struct.
	StructFields(typ reflect.Type) (fields []reflect.StructField, found bool)

	// 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).
	InitJsiiProxy(val reflect.Value) 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.
	EnumMemberForEnumRef(ref api.EnumRef) (interface{}, error)

	// 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: "").
	TryRenderEnumRef(value reflect.Value) (ref *api.EnumRef, isEnumRef bool)
}

TypeRegistry exposes the methods to register types with the jsii runtime for go as well as methods to work with registered types.

func NewTypeRegistry

func NewTypeRegistry() TypeRegistry

NewTypeRegistry creates a new type registry.

Jump to

Keyboard shortcuts

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