duk_bridge

package
v0.0.0-...-ac57bad Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

*

  • generate a key for any value.
  • Rosbit Xu <me@rosbit.cn>
  • Oct. 28, 2018

Index

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 GoModuleLoader interface {
	GetExtName() string
	LoadModule(modHome string, modName string) interface{}
	FinalizeModule(modName string, modHandler interface{})
}

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

func (ctx *JSEnv) CallFileFunc(scriptFile string, args ...interface{}) (interface{}, error)

*

  • 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

func (ctx *JSEnv) CallFunc(funcName string, args ...interface{}) (interface{}, error)

*

  • 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) Destroy

func (ctx *JSEnv) Destroy()

*

  • destory a JS environment.

func (*JSEnv) DestroyEcmascriptFunc

func (ctx *JSEnv) DestroyEcmascriptFunc(ecmaFunc *EcmaObject)

func (*JSEnv) Eval

func (ctx *JSEnv) Eval(jsCode string) (interface{}, error)

*

  • evaluate any lines of JS codes.
  • @param jsCode JS syntax satisfied codes.
  • @return nil if ok

func (*JSEnv) EvalBytes

func (ctx *JSEnv) EvalBytes(jsCode []byte) (interface{}, error)

*

  • evaluate any lines of JS codes.
  • @param jsCode JS syntax satisfied codes.
  • @return nil if ok

func (*JSEnv) EvalFile

func (ctx *JSEnv) EvalFile(scriptFile string) (interface{}, error)

*

  • evaluate JS codes in a file.
  • @param scriptFile the script file
  • @return nil if ok.

func (*JSEnv) RegisterCodeFunc

func (ctx *JSEnv) RegisterCodeFunc(jsCode []byte, funcName string) error

func (*JSEnv) RegisterFileFunc

func (ctx *JSEnv) RegisterFileFunc(scriptFile string, funcName string) error

*

  • 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

func (ctx *JSEnv) RegisterGoFunc(funcName string, fn interface{}) error

*

  • 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 (ctx *JSEnv) RegisterVar(name string, val interface{}) error

func (*JSEnv) SyntaxCheck

func (ctx *JSEnv) SyntaxCheck(jsCode string) error

*

  • check syntax of any lines of JS codes.
  • @param jsCode JS codes to be syntax-checked.
  • @return nil if ok

func (*JSEnv) SyntaxCheckFile

func (ctx *JSEnv) SyntaxCheckFile(scriptFile string) error

*

  • check syntax of JS codes in a file.
  • @param scriptFile the script file
  • @return nil if ok.

func (*JSEnv) UnregisterFunc

func (ctx *JSEnv) UnregisterFunc(funcName string) error

*

  • 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

func (ctx *JSEnv) UnregisterGoFunc(funcName string) error

type V2KPool

type V2KPool struct {
	// contains filtered or unexported fields
}

func NewV2KPool

func NewV2KPool(val2key Val2KeyFunc, valHashable bool) *V2KPool

func (*V2KPool) GetVal

func (p *V2KPool) GetVal(key interface{}) interface{}

func (*V2KPool) Quit

func (p *V2KPool) Quit()

func (*V2KPool) RemoveKey

func (p *V2KPool) RemoveKey(key interface{})

func (*V2KPool) RemoveVal

func (p *V2KPool) RemoveVal(val interface{})

func (*V2KPool) V2K

func (p *V2KPool) V2K(val interface{}) (interface{}, error)

type Val2KeyFunc

type Val2KeyFunc func(val interface{}) (interface{}, error) // different val mapped to different key

Jump to

Keyboard shortcuts

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