plugin

package
Version: v1.10.6 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2019 License: GPL-3.0 Imports: 6 Imported by: 23

Documentation

Overview

Package plugin contains objects and functions to load and use javascript plugins in order to extend the functionalities of your projects.

Index

Constants

This section is empty.

Variables

View Source
var Defines = map[string]interface{}{}

Defines is a map containing the predefined objects and functions for each vm of each plugin.

Functions

This section is empty.

Types

type Plugin

type Plugin struct {
	sync.Mutex
	// The basename of the plugin.
	Name string
	// The actual javascript code.
	Code string
	// The full path of the plugin.
	Path string
	// contains filtered or unexported fields
}

Plugin is an object representing a javascript file exporting functions and variables that your project can use to extend its functionalities.

func Load

func Load(path string) (plug *Plugin, err error)

Load loads and compiles a plugin given its path.

func Parse

func Parse(code string) (*Plugin, error)

Parse parsesand compiles a plugin given its source code.

func (*Plugin) Call

func (p *Plugin) Call(name string, args ...interface{}) (interface{}, error)

Call executes one of the declared callbacks of the plugin by its name.

func (*Plugin) Clone

func (p *Plugin) Clone() (clone *Plugin)

Clone returns a new instance identical to the plugin.

func (*Plugin) GetObject

func (p *Plugin) GetObject(name string) (interface{}, error)

GetObject returns an interface containing the value of the object by its name

func (*Plugin) GetTypeObject

func (p *Plugin) GetTypeObject(name string) string

GetTypeObject returns the type of the object by its name

func (*Plugin) HasFunc

func (p *Plugin) HasFunc(name string) bool

HasFunc returns true if the function with `name` has been declared in the plugin code.

func (*Plugin) IsArrayObject

func (p *Plugin) IsArrayObject(name string) bool

IsArrayObject returns true if the object with a given name is a javascript array object, false otherwise

func (*Plugin) IsBooleanObject

func (p *Plugin) IsBooleanObject(name string) bool

IsBooleanObject returns true if the object with a given name is a javascript boolean object, false otherwise

func (*Plugin) IsBooleanPrimitive

func (p *Plugin) IsBooleanPrimitive(name string) bool

IsBooleanPrimitive returns true if the object with a given name is a javascript primitive boolean, false otherwise

func (*Plugin) IsDateObject

func (p *Plugin) IsDateObject(name string) bool

IsDateObject returns true if the object with a given name is a javascript Date object, false otherwise

func (*Plugin) IsErrorObject

func (p *Plugin) IsErrorObject(name string) bool

IsErrorObject returns true if the object with a given name is a javascript error object, false otherwise

func (*Plugin) IsNumberObject

func (p *Plugin) IsNumberObject(name string) bool

IsNumberObject returns true if the object with a given name is a javascript Number object, false otherwise

func (*Plugin) IsNumberPrimitive

func (p *Plugin) IsNumberPrimitive(name string) bool

IsNumberPrimitive returns true if the object with a given name is a javascript primitive number, false otherwise

func (*Plugin) IsRegExpObject

func (p *Plugin) IsRegExpObject(name string) bool

IsRegExpObject returns true if the object with a given name is a javascript RegExp object, false otherwise

func (*Plugin) IsStringObject

func (p *Plugin) IsStringObject(name string) bool

IsStringObject returns true if the object with a given name is a javascript string object, false otherwise

func (*Plugin) IsStringPrimitive

func (p *Plugin) IsStringPrimitive(name string) bool

IsStringPrimitive returns true if the object with a given name is a javascript primitive string

func (*Plugin) Methods

func (p *Plugin) Methods() []string

Methods returns a list of methods exported from the javascript

func (*Plugin) Objects

func (p *Plugin) Objects() []string

Objects returns a list of object exported by the javascript

func (*Plugin) Set

func (p *Plugin) Set(name string, v interface{}) error

Set sets a variable into the VM of this plugin instance.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to