Documentation ¶
Overview ¶
Package gomonkey implements the go bindings to SpiderMonkey.
Index ¶
- Constants
- func Init()
- func JSONStringify(c *Context, v Valuer) (string, error)
- func ShutDown()
- func Version() string
- type ArrayObject
- type Context
- func (c *Context) CallFunctionName(name string, receiver Valuer, args ...*Value) (*Value, error)
- func (c *Context) CallFunctionValue(function Valuer, receiver Valuer, args ...*Value) (*Value, error)
- func (c *Context) CompileScript(name string, code []byte) (*Script, error)
- func (c *Context) DefineElement(object *Object, index uint, value *Value, attrs PropertyAttributes) error
- func (c *Context) DefineFunction(object *Object, name string, callback FunctionCallback, args uint, ...) error
- func (c *Context) DefineObject(object *Object, name string, attrs PropertyAttributes) (*Object, error)
- func (c *Context) DefineProperty(object *Object, name string, value *Value, attrs PropertyAttributes) error
- func (c *Context) Destroy()
- func (c *Context) Evaluate(code []byte) (*Value, error)
- func (c *Context) ExecuteScript(script *Script) (*Value, error)
- func (c *Context) ExecuteScriptFromStencil(stencil *Stencil) (*Value, error)
- func (c *Context) Global() (*Object, error)
- func (c *Context) RequestInterrupt()
- type ContextOptionFunc
- type FrontendContext
- type FrontendContextOptionFunc
- type Function
- type FunctionCallback
- type JSError
- type MapObject
- func (o *MapObject) AsValue() *Value
- func (o *MapObject) Clear() error
- func (o *MapObject) Delete(key *Value) error
- func (o *MapObject) Entries() (*Value, error)
- func (o *MapObject) Get(key *Value) (*Value, error)
- func (o *MapObject) Has(key *Value) bool
- func (o *MapObject) Keys() (*Value, error)
- func (o *MapObject) Release()
- func (o *MapObject) Set(key *Value, value *Value) error
- func (o *MapObject) Size() uint
- func (o *MapObject) Values() (*Value, error)
- type Object
- func (o *Object) AsValue() *Value
- func (o *Object) Call(name string, args ...*Value) (*Value, error)
- func (o *Object) Delete(key string) error
- func (o *Object) DeleteElement(index int) error
- func (o *Object) Get(key string) (*Value, error)
- func (o *Object) GetElement(index int) (*Value, error)
- func (o *Object) Has(key string) bool
- func (o *Object) HasElement(index int) bool
- func (o *Object) Release()
- func (o *Object) Set(key string, value *Value) error
- func (o *Object) SetElement(index int, value *Value) error
- type PropertyAttributes
- type Script
- type SetObject
- func (o *SetObject) Add(value *Value) error
- func (o *SetObject) AsValue() *Value
- func (o *SetObject) Clear() error
- func (o *SetObject) Delete(key *Value) error
- func (o *SetObject) Entries() (*Value, error)
- func (o *SetObject) Has(key *Value) bool
- func (o *SetObject) Keys() (*Value, error)
- func (o *SetObject) Release()
- func (o *SetObject) Size() uint
- func (o *SetObject) Values() (*Value, error)
- type Stencil
- type Value
- func NewValueBoolean(ctx *Context, b bool) (*Value, error)
- func NewValueInt32(ctx *Context, i int32) (*Value, error)
- func NewValueNull(ctx *Context) (*Value, error)
- func NewValueNumber(ctx *Context, f float64) (*Value, error)
- func NewValueString(ctx *Context, str string) (*Value, error)
- func NewValueUndefined(ctx *Context) (*Value, error)
- func (v *Value) AsFunction() (*Function, error)
- func (v *Value) AsObject() (*Object, error)
- func (v *Value) AsValue() *Value
- func (v *Value) Format(f fmt.State, verb rune)
- func (v *Value) Is(value *Value) bool
- func (v *Value) IsBoolean() bool
- func (v *Value) IsFalse() bool
- func (v *Value) IsFunction() bool
- func (v *Value) IsInt32() bool
- func (v *Value) IsNull() bool
- func (v *Value) IsNullOrUndefined() bool
- func (v *Value) IsNumber() bool
- func (v *Value) IsObject() bool
- func (v *Value) IsString() bool
- func (v *Value) IsSymbol() bool
- func (v *Value) IsTrue() bool
- func (v *Value) IsUndefined() bool
- func (v *Value) MarshalJSON() ([]byte, error)
- func (v *Value) Release()
- func (v *Value) String() string
- func (v *Value) ToBoolean() bool
- func (v *Value) ToInt32() int32
- func (v *Value) ToNumber() float64
- func (v *Value) ToString() string
- type Valuer
Constants ¶
const ( PropertyAttributeDefault PropertyAttributes = 0 PropertyAttributeEnumerate = 1 << iota PropertyAttributeReadOnly PropertyAttributePermanent )
Variables ¶
This section is empty.
Functions ¶
func JSONStringify ¶
JSONStringify encodes a JS value to a JSON-encoded string.
Types ¶
type ArrayObject ¶
type ArrayObject struct {
// contains filtered or unexported fields
}
ArrayObject implements a JS array object.
func NewArrayObject ¶
func NewArrayObject(ctx *Context, values ...*Value) (*ArrayObject, error)
NewArrayObject creates a new array.
func (*ArrayObject) AsObject ¶
func (o *ArrayObject) AsObject() (*Object, error)
AsObject casts as a JS object.
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context represents a JS context.
func NewContext ¶
func NewContext(options ...ContextOptionFunc) (*Context, error)
NewContext creates a new context.
func (*Context) CallFunctionName ¶
CallFunctionName executes a JS function by its name.
func (*Context) CallFunctionValue ¶
func (c *Context) CallFunctionValue(function Valuer, receiver Valuer, args ...*Value) (*Value, error)
CallFunctionName executes a JS function by its value.
func (*Context) CompileScript ¶
CompileScript compiles a JS code into a script.
func (*Context) DefineElement ¶
func (c *Context) DefineElement(object *Object, index uint, value *Value, attrs PropertyAttributes) error
DefineElement defines a new element on the given JS object.
func (*Context) DefineFunction ¶
func (c *Context) DefineFunction(object *Object, name string, callback FunctionCallback, args uint, attrs PropertyAttributes) error
DefineFunction defines a new JS function and sets it as a property of the given JS object.
func (*Context) DefineObject ¶
func (c *Context) DefineObject(object *Object, name string, attrs PropertyAttributes) (*Object, error)
DefineObject defines a new JS object and sets it as a property of the given JS object.
func (*Context) DefineProperty ¶
func (c *Context) DefineProperty(object *Object, name string, value *Value, attrs PropertyAttributes) error
DefineProperty defines a new property on the given JS object.
func (*Context) ExecuteScript ¶
Execute executes a script.
func (*Context) ExecuteScriptFromStencil ¶
Execute executes a script from a stencil.
func (*Context) RequestInterrupt ¶
func (c *Context) RequestInterrupt()
RequestInterrupt requests the context interruption.
type ContextOptionFunc ¶
ContextOptionFunc represents a context option function.
func WithGCIncrementalEnabled ¶
func WithGCIncrementalEnabled(state bool) ContextOptionFunc
WithGCIncrementalEnabled enables the incremental GC.
func WithGCMaxBytes ¶
func WithGCMaxBytes(max uint) ContextOptionFunc
WithGCMaxBytes sets the maximum heap size in bytes before GC.
func WithGCSliceTimeBudget ¶
func WithGCSliceTimeBudget(d time.Duration) ContextOptionFunc
WithGCSliceTimeBudget sets the maximal time to spend in an incremental GC slice.
func WithHeapMaxBytes ¶
func WithHeapMaxBytes(max uint) ContextOptionFunc
WithHeapMaxBytes sets the maximum heap size in bytes.
func WithNativeStackSize ¶
func WithNativeStackSize(size uint) ContextOptionFunc
WithNativeStackSize sets the native stack size in bytes.
type FrontendContext ¶
type FrontendContext struct {
// contains filtered or unexported fields
}
FrontendContext represents a JS frontend context.
func NewFrontendContext ¶
func NewFrontendContext(options ...FrontendContextOptionFunc) (*FrontendContext, error)
NewFrontendContext creates a new context.
func (*FrontendContext) CompileScriptToStencil ¶
func (c *FrontendContext) CompileScriptToStencil(name string, code []byte) (*Stencil, error)
CompileScriptToStencil compiles a script to a stencil.
type FrontendContextOptionFunc ¶
type FrontendContextOptionFunc func(c *FrontendContext) error
FrontendContextOptionFunc represents a frontend context option function.
func WithFrontendNativeStackSize ¶
func WithFrontendNativeStackSize(size uint) FrontendContextOptionFunc
WithNativeStackSize sets the native stack size in bytes.
type Function ¶
type Function struct {
// contains filtered or unexported fields
}
Function represents a JS function.
func NewFunction ¶
func NewFunction(ctx *Context, name string, callback FunctionCallback) (*Function, error)
NewFunction creates a new JS function.
type FunctionCallback ¶
FunctionCallback implements a JS function callback.
type MapObject ¶ added in v0.2.0
type MapObject struct {
// contains filtered or unexported fields
}
MapObject implements a JS map object.
func NewMapObject ¶ added in v0.2.0
NewMapObject creates a new map.
type Object ¶
type Object struct {
// contains filtered or unexported fields
}
Object implements a JS object.
func (*Object) DeleteElement ¶
DeleteElement deletes an object element.
func (*Object) GetElement ¶
GetElement returns an object element.
func (*Object) HasElement ¶
HasElement checks if the object has the given element.
type PropertyAttributes ¶
type PropertyAttributes uint8
PropertyAttributes represents the attributes of a property.
func (PropertyAttributes) Has ¶
func (a PropertyAttributes) Has(attr PropertyAttributes) bool
Has checks if an attribute is set.
type Script ¶
type Script struct {
// contains filtered or unexported fields
}
Script represents a JS script.
type SetObject ¶ added in v0.2.0
type SetObject struct {
// contains filtered or unexported fields
}
SetObject implements a JS set object.
func NewSetObject ¶ added in v0.2.0
NewSetObject creates a new set.
type Stencil ¶
type Stencil struct {
// contains filtered or unexported fields
}
Stencil implements a JS stencil.
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
Value implements a JS Value.
func NewValueBoolean ¶
NewValueBoolean creates a new JS boolean value.
func NewValueInt32 ¶
NewValueInt32 creates a new JS int32 value.
func NewValueNull ¶
NewValueNull creates a new JS null value.
func NewValueNumber ¶
NewValueNumber creates a new JS number value.
func NewValueString ¶
NewValueString creates a new JS string value.
func NewValueUndefined ¶
NewValueUndefined creates a new JS undefined value.
func (*Value) AsFunction ¶
AsFunction casts as a JS function.
func (*Value) IsFunction ¶
IsFunction checks if the JS value is a JS function.
func (*Value) IsNullOrUndefined ¶
IsNullOrUndefined checks if the JS value is null or undefined.
func (*Value) IsUndefined ¶
IsUndefined checks if the JS value is undefined.
func (*Value) MarshalJSON ¶
MarshalJSON implements json.Marshaler.