plugin

package
v1.10.5 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: 0

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 added in v1.5.0

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 added in v1.3.0

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

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

func (*Plugin) GetTypeObject added in v1.3.0

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

GetTypeObject returns the type of the object by its name

func (*Plugin) HasFunc added in v1.3.0

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 added in v1.3.0

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 added in v1.3.0

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 added in v1.3.0

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 added in v1.3.0

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 added in v1.3.0

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 added in v1.3.0

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 added in v1.3.0

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 added in v1.3.0

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 added in v1.3.0

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 added in v1.3.0

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 added in v1.3.0

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

Methods returns a list of methods exported from the javascript

func (*Plugin) Objects added in v1.3.0

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

Objects returns a list of object exported by the javascript

func (*Plugin) Set added in v1.6.0

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
y or Y : Canonical URL