Documentation ¶
Overview ¶
*
- generate a key for any value.
- Rosbit Xu <me@rosbit.cn>
- Oct. 28, 2018
Index ¶
- type EcmaObject
- type GoModuleLoader
- type GoPluginModuleLoader
- type JSEnv
- func (ctx *JSEnv) CallEcmascriptFunc(ecmaFunc *EcmaObject, args ...interface{}) (interface{}, error)
- func (ctx *JSEnv) CallFileFunc(scriptFile string, args ...interface{}) (interface{}, error)
- func (ctx *JSEnv) CallFunc(funcName string, args ...interface{}) (interface{}, error)
- func (ctx *JSEnv) Destroy()
- func (ctx *JSEnv) DestroyEcmascriptFunc(ecmaFunc *EcmaObject)
- func (ctx *JSEnv) Eval(jsCode string) (interface{}, error)
- func (ctx *JSEnv) EvalBytes(jsCode []byte) (interface{}, error)
- func (ctx *JSEnv) EvalFile(scriptFile string) (interface{}, error)
- func (ctx *JSEnv) RegisterCodeFunc(jsCode []byte, funcName string) error
- func (ctx *JSEnv) RegisterFileFunc(scriptFile string, funcName string) error
- func (ctx *JSEnv) RegisterGoFunc(funcName string, fn interface{}) error
- func (ctx *JSEnv) RegisterVar(name string, val interface{}) error
- func (ctx *JSEnv) SyntaxCheck(jsCode string) error
- func (ctx *JSEnv) SyntaxCheckFile(scriptFile string) error
- func (ctx *JSEnv) UnregisterFunc(funcName string) error
- func (ctx *JSEnv) UnregisterGoFunc(funcName string) error
- type V2KPool
- type Val2KeyFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EcmaObject ¶
type EcmaObject struct {
// contains filtered or unexported fields
}
type GoModuleLoader ¶
type GoPluginModuleLoader ¶
type GoPluginModuleLoader struct{}
func (*GoPluginModuleLoader) FinalizeModule ¶
func (loader *GoPluginModuleLoader) FinalizeModule(modName string, modHandler interface{})
func (*GoPluginModuleLoader) GetExtName ¶
func (loader *GoPluginModuleLoader) GetExtName() string
func (*GoPluginModuleLoader) LoadModule ¶
func (loader *GoPluginModuleLoader) LoadModule(modHome string, modName string) interface{}
type JSEnv ¶
type JSEnv struct {
// contains filtered or unexported fields
}
*
- type of JS environment.
func NewEnv ¶
func NewEnv(loader GoModuleLoader) *JSEnv
*
- create a new JS environment.
- @param loader a implementation of go module loader, nil if none.
- @return a new JSEnv if ok, otherwise nil
func (*JSEnv) CallEcmascriptFunc ¶
func (ctx *JSEnv) CallEcmascriptFunc(ecmaFunc *EcmaObject, args ...interface{}) (interface{}, error)
func (*JSEnv) CallFileFunc ¶
*
- call a JS script file containing only one function
- @param scriptFile the JS file with only one function
- @param args any count of array of anything
- @return any type data
func (*JSEnv) CallFunc ¶
*
- call a JS function registered by JSEnv::RegisterFileFunc()/RegisterCodeFunc()
- @param funcName the registered function name when calling JSEnv::RegisterFileFunc()/RegisterCodeFunc()
- @param args any count of array of anything
- @return any type data
func (*JSEnv) DestroyEcmascriptFunc ¶
func (ctx *JSEnv) DestroyEcmascriptFunc(ecmaFunc *EcmaObject)
func (*JSEnv) Eval ¶
*
- evaluate any lines of JS codes.
- @param jsCode JS syntax satisfied codes.
- @return nil if ok
func (*JSEnv) EvalBytes ¶
*
- evaluate any lines of JS codes.
- @param jsCode JS syntax satisfied codes.
- @return nil if ok
func (*JSEnv) EvalFile ¶
*
- evaluate JS codes in a file.
- @param scriptFile the script file
- @return nil if ok.
func (*JSEnv) RegisterCodeFunc ¶
func (*JSEnv) RegisterFileFunc ¶
*
- register a function in a JS script file. the function could be called by JSEnv::CallFunc() later.
- @param scriptFile the script file containing a function
- @param funcName the function name to be registered, which can be different from the name in the scriptFile.
- @return nil if ok.
func (*JSEnv) RegisterGoFunc ¶
*
- register a global native function witten in golang. so JS code will call it later.
- @param funcName the function name to be registered
- @param fn the golang function to response the JS calling.
- @return nil if ok.
func (*JSEnv) RegisterVar ¶
func (*JSEnv) SyntaxCheck ¶
*
- check syntax of any lines of JS codes.
- @param jsCode JS codes to be syntax-checked.
- @return nil if ok
func (*JSEnv) SyntaxCheckFile ¶
*
- check syntax of JS codes in a file.
- @param scriptFile the script file
- @return nil if ok.
func (*JSEnv) UnregisterFunc ¶
*
- unregister a function which was registered by calling JSEnv::RegisterFileFunc()/RegisterCodeFunc()
- @param funcName the name of function to be unregistered.
- @return nil if ok.
func (*JSEnv) UnregisterGoFunc ¶
type V2KPool ¶
type V2KPool struct {
// contains filtered or unexported fields
}
func NewV2KPool ¶
func NewV2KPool(val2key Val2KeyFunc, valHashable bool) *V2KPool
type Val2KeyFunc ¶
type Val2KeyFunc func(val interface{}) (interface{}, error) // different val mapped to different key
Click to show internal directories.
Click to hide internal directories.