pkg

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const V_INTERNAL_F = "V_INTERNAL_F"
View Source
const V_PARAM = "V_PARAM"
View Source
const V_RETURN = "V_RETURN"
View Source
const V_SCRIPT_NAME = "V_SCRIPT_NAME"

Variables

This section is empty.

Functions

func Plugins

func Plugins() map[string]IPlugin

func RegisterPlugin

func RegisterPlugin(name string, m IPlugin)

func UnRegisterPlugin

func UnRegisterPlugin(name string)

Types

type Engine

type Engine interface {
	// 检查tengo脚本是否存在编译错误
	Compile(script string, opts ...RunOption) error

	// 执行tengo脚本,并从给定的返回变量名中获得返回值
	Eval(script string, opts ...RunOption) (string, string, error)

	// 执行tengo脚本,并从给定的返回变量名中获得返回值
	Run(script string, opts ...RunOption) (string, error)
}

tengo脚本执行引擎

func NewEngine

func NewEngine() Engine

type FormaterOption

type FormaterOption func(*FormaterOptions)

func FormaterEval

func FormaterEval(enabled bool) FormaterOption

func FormaterFuncParams

func FormaterFuncParams(params []string) FormaterOption

func FormaterImportModules

func FormaterImportModules(importModules map[string]struct{}) FormaterOption

func FormaterLogID

func FormaterLogID(logID string) FormaterOption

func FormaterModuleMap

func FormaterModuleMap(moduleMap *tengo.ModuleMap) FormaterOption

type FormaterOptions

type FormaterOptions struct {
	FuncParams    []string
	LogID         string
	Eval          bool
	ImportModules map[string]struct{}
	ModuleMap     *tengo.ModuleMap
}

func NewFormaterOptions

func NewFormaterOptions(opts ...FormaterOption) FormaterOptions

constructor

func (*FormaterOptions) OptionList

func (o *FormaterOptions) OptionList() []FormaterOption

type FullScriptInfo

type FullScriptInfo struct {
	ModuleMap     *tengo.ModuleMap
	ImportModules map[string]struct{}
	Params        []string
	FullCode      string
}

type IPlugin

type IPlugin interface {
	Doc() map[string]string
	Name() string
	Module() map[string]tengo.Object
	AliasMethod() bool
	IsInternal() bool
}

func GetPlugin

func GetPlugin(name string) IPlugin

type IPluginFactory

type IPluginFactory interface {
	Register(name string, m IPlugin)
	UnRegister(name string)
	Get(name string) IPlugin
	Plugins() map[string]IPlugin
}

type ISubPlugin

type ISubPlugin interface {
	Doc() map[string]string
	Module() map[string]tengo.Object
}

type RunOption

type RunOption func(*RunOptions)

func Eval

func Eval(enabled bool) RunOption

func FuncData

func FuncData(data map[string]interface{}) RunOption

func FuncParams

func FuncParams(params []string) RunOption

func OutputLog

func OutputLog(enabled bool) RunOption

func ShowSourceLine

func ShowSourceLine(enabled bool) RunOption

type RunOptions

type RunOptions struct {
	FuncParams     []string
	FuncData       map[string]interface{}
	OutputLog      bool
	ShowSourceLine bool
	Eval           bool
}

func NewRunOptions

func NewRunOptions(opts ...RunOption) RunOptions

constructor

func (*RunOptions) OptionList

func (o *RunOptions) OptionList() []RunOption

type ScriptEnhanceInputModel

type ScriptEnhanceInputModel struct {
	Script        string
	HasExport     bool
	ExportParams  []string
	ImportModules map[string]struct{}
	LogID         string
	IsEval        bool
}

type ScriptFormater

type ScriptFormater interface {
	ToSourceModel(script string, opts ...FormaterOption) (*FullScriptInfo, error)
	ToScript(script string, opts ...FormaterOption) (*FullScriptInfo, error)
}

func NewScriptFormater

func NewScriptFormater() ScriptFormater

Directories

Path Synopsis
log

Jump to

Keyboard shortcuts

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