Documentation ¶
Index ¶
- Constants
- func GetInvokeJsonProxyPtr() uint64
- func Invoke(method string, args []interface{}, kwargs map[string]interface{}) (result_json string)
- func InvokeJson(method, args_json, kwargs_json string) (result_json string)
- func JSONError(err error) string
- func RegisterPlugin(plugin Plugin)
- func ResetPlugin()
- type BacktraceFrame
- type MethodArgs
- func (p *MethodArgs) Arg(i int) interface{}
- func (p *MethodArgs) BoolArg(i int) bool
- func (p *MethodArgs) BoolKwArg(name string) bool
- func (p *MethodArgs) FloatArg(i int) float64
- func (p *MethodArgs) FloatKwArg(name string) float64
- func (p *MethodArgs) GetCallArg(index int, key string) any
- func (p *MethodArgs) IntArg(i int) int64
- func (p *MethodArgs) IntKwArg(name string) int64
- func (p *MethodArgs) KwArg(name string) interface{}
- func (p *MethodArgs) ListArg(i int) []any
- func (p *MethodArgs) ListKwArg(name string) []any
- func (p *MethodArgs) MapArg(i int) map[string]any
- func (p *MethodArgs) MapKwArg(name string) map[string]any
- func (p *MethodArgs) StrArg(i int) string
- func (p *MethodArgs) StrKwArg(name string) string
- type MethodResult
- type MethodSpec
- type MethodType
- type PanicInfo
- type Plugin
Constants ¶
const CgoEnabled = true
Variables ¶
This section is empty.
Functions ¶
func GetInvokeJsonProxyPtr ¶
func GetInvokeJsonProxyPtr() uint64
func InvokeJson ¶
Types ¶
type BacktraceFrame ¶
type MethodArgs ¶
type MethodArgs struct { Args []interface{} // List of positional arguments KwArgs map[string]interface{} // Map of keyword arguments }
MethodArgs represents the arguments passed to a KCL Plugin method. It includes a list of positional arguments and a map of keyword arguments.
func ParseMethodArgs ¶
func ParseMethodArgs(args_json, kwargs_json string) (*MethodArgs, error)
ParseMethodArgs parses JSON strings for positional and keyword arguments and returns a MethodArgs object. args_json: JSON string of positional arguments kwargs_json: JSON string of keyword arguments
func (*MethodArgs) Arg ¶
func (p *MethodArgs) Arg(i int) interface{}
Arg returns the positional argument at the specified index.
func (*MethodArgs) BoolArg ¶ added in v0.9.0
func (p *MethodArgs) BoolArg(i int) bool
BoolArg returns the positional argument at the specified index as a bool. It panics if the conversion fails.
func (*MethodArgs) BoolKwArg ¶ added in v0.9.0
func (p *MethodArgs) BoolKwArg(name string) bool
BoolKwArg returns the keyword argument with the given name as a bool. It panics if the conversion fails.
func (*MethodArgs) FloatArg ¶
func (p *MethodArgs) FloatArg(i int) float64
FloatArg returns the positional argument at the specified index as a float64. It panics if the conversion fails.
func (*MethodArgs) FloatKwArg ¶
func (p *MethodArgs) FloatKwArg(name string) float64
FloatKwArg returns the keyword argument with the given name as a float64. It panics if the conversion fails.
func (*MethodArgs) GetCallArg ¶ added in v0.9.2
func (p *MethodArgs) GetCallArg(index int, key string) any
GetCallArg retrieves an argument by index or key. If the key exists in KwArgs, it returns the corresponding value. Otherwise, it returns the positional argument at the given index.
func (*MethodArgs) IntArg ¶
func (p *MethodArgs) IntArg(i int) int64
IntArg returns the positional argument at the specified index as an int64. It panics if the conversion fails.
func (*MethodArgs) IntKwArg ¶
func (p *MethodArgs) IntKwArg(name string) int64
IntKwArg returns the keyword argument with the given name as an int64. It panics if the conversion fails.
func (*MethodArgs) KwArg ¶
func (p *MethodArgs) KwArg(name string) interface{}
KwArg returns the keyword argument with the given name.
func (*MethodArgs) ListArg ¶ added in v0.9.0
func (p *MethodArgs) ListArg(i int) []any
ListArg returns the positional argument at the specified index as a list of any type.
func (*MethodArgs) ListKwArg ¶ added in v0.9.0
func (p *MethodArgs) ListKwArg(name string) []any
ListKwArg returns the keyword argument with the given name as a list of any type.
func (*MethodArgs) MapArg ¶ added in v0.9.0
func (p *MethodArgs) MapArg(i int) map[string]any
MapArg returns the positional argument at the specified index as a map with string keys and any type values.
func (*MethodArgs) MapKwArg ¶ added in v0.9.0
func (p *MethodArgs) MapKwArg(name string) map[string]any
MapKwArg returns the keyword argument with the given name as a map with string keys and any type values.
func (*MethodArgs) StrArg ¶
func (p *MethodArgs) StrArg(i int) string
StrArg returns the positional argument at the specified index as a string.
func (*MethodArgs) StrKwArg ¶
func (p *MethodArgs) StrKwArg(name string) string
StrKwArg returns the keyword argument with the given name as a string.
type MethodResult ¶
type MethodResult struct {
V interface{} // Result value
}
MethodResult represents the result returned from a KCL Plugin method. It holds the value of the result.
type MethodSpec ¶
type MethodSpec struct { Type *MethodType // Specification of the method's type Body func(args *MethodArgs) (*MethodResult, error) // Function to execute the method's logic }
MethodSpec defines the specification for a KCL Plugin method. It includes the method type and the body function which executes the method logic.
func GetMethodSpec ¶
func GetMethodSpec(methodName string) (method MethodSpec, ok bool)
GetMethodSpec get plugin method by name.
type MethodType ¶
type MethodType struct { ArgsType []string // List of types for positional arguments KwArgsType map[string]string // Map of keyword argument names to their types ResultType string // Type of the result }
MethodType describes the type of a KCL Plugin method's arguments, keyword arguments, and result. It specifies the types of positional arguments, keyword arguments, and the result type.
type Plugin ¶
type Plugin struct { Name string // Name of the plugin Version string // Version of the plugin ResetFunc func() // Reset function for the plugin MethodMap map[string]MethodSpec // Map of method names to their specifications }
Plugin represents a KCL Plugin with metadata and methods. It contains the plugin name, version, a reset function, and a map of methods.