d2script

package
v0.0.0-...-7f92c57 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2021 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package d2script provides a virtual machine for interpretting scripts

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ScriptEngine

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

ScriptEngine allows running JavaScript scripts

func CreateScriptEngine

func CreateScriptEngine() *ScriptEngine

CreateScriptEngine creates the script engine and returns a pointer to it.

func (*ScriptEngine) AddFunction

func (s *ScriptEngine) AddFunction(name string, value interface{})

AddFunction adds the given function to the script engine with the given name.

func (*ScriptEngine) AllowEval

func (s *ScriptEngine) AllowEval()

AllowEval allows the evaluation of JS code.

func (*ScriptEngine) DisallowEval

func (s *ScriptEngine) DisallowEval()

DisallowEval disallows the evaluation of JS code.

func (*ScriptEngine) Eval

func (s *ScriptEngine) Eval(code string) (string, error)

Eval JS code.

func (*ScriptEngine) RunScript

func (s *ScriptEngine) RunScript(fileName string) (*otto.Value, error)

RunScript runs the script file within the given path.

func (*ScriptEngine) ToValue

func (s *ScriptEngine) ToValue(source interface{}) (otto.Value, error)

ToValue converts the given interface{} value to a otto.Value

Jump to

Keyboard shortcuts

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