kcl_plugin

package
v0.7.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const CgoEnabled = true

Variables

View Source
var DebugMode = false

Debug flag for kcl-plugin

Functions

func GetInvokeJsonProxyPtr

func GetInvokeJsonProxyPtr() uintptr

func Invoke

func Invoke(method string, args []interface{}, kwargs map[string]interface{}) (result_json string)

func InvokeJson

func InvokeJson(method, args_json, kwargs_json string) (result_json string)

func JSONError

func JSONError(err error) string

func RegisterPlugin

func RegisterPlugin(plugin Plugin)

Register register a new kcl plugin.

func ResetPlugin

func ResetPlugin()

ResetPlugin reset all kcl plugin state.

Types

type MethodArgs

type MethodArgs struct {
	Args   []interface{}
	KwArgs map[string]interface{}
}

plugin method args

func ParseMethodArgs

func ParseMethodArgs(args_json, kwargs_json string) (*MethodArgs, error)

func (*MethodArgs) Arg

func (p *MethodArgs) Arg(i int) interface{}

func (*MethodArgs) FloatArg

func (p *MethodArgs) FloatArg(i int) float64

func (*MethodArgs) FloatKwArg

func (p *MethodArgs) FloatKwArg(name string) float64

func (*MethodArgs) IntArg

func (p *MethodArgs) IntArg(i int) int64

func (*MethodArgs) IntKwArg

func (p *MethodArgs) IntKwArg(name string) int64

func (*MethodArgs) KwArg

func (p *MethodArgs) KwArg(name string) interface{}

func (*MethodArgs) StrArg

func (p *MethodArgs) StrArg(i int) string

func (*MethodArgs) StrKwArg

func (p *MethodArgs) StrKwArg(name string) string

type MethodResult

type MethodResult struct {
	V interface{}
}

plugin method result

type MethodSpec

type MethodSpec struct {
	Type *MethodType
	Body func(args *MethodArgs) (*MethodResult, error)
}

KCL Plugin method spec

func GetMethodSpec

func GetMethodSpec(methodName string) (method MethodSpec, ok bool)

GetMethodSpec get plugin method by name.

type MethodType

type MethodType struct {
	ArgsType   []string
	KwArgsType map[string]string
	ResultType string
}

KCL Plugin method type

type PanicInfo

type PanicInfo struct {
	X__kcl_PanicInfo__ bool `json:"__kcl_PanicInfo__"`

	RustFile string `json:"rust_file,omitempty"`
	RustLine int    `json:"rust_line,omitempty"`
	RustCol  int    `json:"rust_col,omitempty"`

	KclPkgPath string `json:"kcl_pkgpath,omitempty"`
	KclFile    string `json:"kcl_file,omitempty"`
	KclLine    int    `json:"kcl_line,omitempty"`
	KclCol     int    `json:"kcl_col,omitempty"`
	KclArgMsg  string `json:"kcl_arg_msg,omitempty"`

	// only for schema check
	KclConfigMetaFile   string `json:"kcl_config_meta_file,omitempty"`
	KclConfigMetaLine   int    `json:"kcl_config_meta_line,omitempty"`
	KclConfigMetaCol    int    `json:"kcl_config_meta_col,omitempty"`
	KclConfigMetaArgMsg string `json:"kcl_config_meta_arg_msg,omitempty"`

	Message     string `json:"message"`
	ErrTypeCode string `json:"err_type_code,omitempty"`
	IsWarning   string `json:"is_warning,omitempty"`
}

func (*PanicInfo) Error

func (p *PanicInfo) Error() string

func (*PanicInfo) JSONError

func (p *PanicInfo) JSONError() string

type Plugin

type Plugin struct {
	Name      string
	ResetFunc func()
	MethodMap map[string]MethodSpec
}

KCL Plugin object

func GetPlugin

func GetPlugin(name string) (plugin Plugin, ok bool)

GetPlugin get plugin object by name.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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