Documentation ¶
Overview ¶
Jscore is a Go wrapper around JavaScriptCore. Cgo is used a lot throughout the code. It uses reflection to expose Go objects in JS code.
Index ¶
- func CheckScriptSyntax(ctx Context, script string) bool
- type Context
- type GlobalContext
- type Object
- func (o Object) At(ctx Context, index int) Value
- func (o Object) Get(ctx Context, propertyName string) Value
- func (o Object) Has(ctx Context, propertyName string) bool
- func (o Object) Set(ctx Context, propertyName string, value Value)
- func (o Object) Slice(ctx Context) []interface{}
- func (o Object) Value() Value
- type Type
- type Value
- func EvaluateScript(ctx Context, script string) Value
- func NewBoolean(ctx Context, b bool) Value
- func NewNull(ctx Context) Value
- func NewNumber(ctx Context, x float64) Value
- func NewString(ctx Context, str string) Value
- func NewSymbol(ctx Context, str string) Value
- func NewValue(ctx Context, v interface{}) Value
- func (v Value) Boolean(ctx Context) bool
- func (v Value) Interface(ctx Context) interface{}
- func (v Value) Number(ctx Context) float64
- func (v Value) Object(ctx Context) Object
- func (v Value) Protect(ctx Context)
- func (v Value) String(ctx Context) string
- func (v Value) Type(ctx Context) Type
- func (v Value) Unprotect(ctx Context)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckScriptSyntax ¶
CheckScriptSyntax checks the syntax of the script.
Types ¶
type Context ¶
type Context interface { // GlobalObject returns the global object associated with the context. GlobalObject() Object // contains filtered or unexported methods }
Context is a JS context.
type GlobalContext ¶
type GlobalContext struct {
// contains filtered or unexported fields
}
GlobalContext is a global JS context.
func NewGlobalContext ¶
func NewGlobalContext() GlobalContext
NewGlobalContext creates a new global JS context.
func (GlobalContext) GlobalObject ¶
func (c GlobalContext) GlobalObject() Object
GlobalObject returns the global object associated with the context.
type Object ¶
type Object struct {
// contains filtered or unexported fields
}
Object is a JS object.
func NewGoObject ¶
NewGoObject creates a new JS object that wraps a Go object.
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
Value is a JS value.
func EvaluateScript ¶
EvaluateScript evaluates the provided script.
func (Value) Interface ¶
Interface returns the JS value as an interface{}. If the value is a wrapped Go object, then the wrapped object is returned. For other JS objects, a map of type map[string]interface{} is returned.