javascriptcore

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Rendered for darwin/amd64

Overview

Package javascriptcore provides a fluent Go API over the macOS JavaScriptCore framework.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CurrentArguments

func CurrentArguments() obj.Object

CurrentArguments returns the arguments to the current native callback from JavaScript code.

func JSClassRelease

func JSClassRelease(jsClass obj.Object)

JSClassRelease calls the JavaScriptCore framework function JSClassRelease.

func JSClassRetain

func JSClassRetain(jsClass obj.Object) obj.Object

JSClassRetain calls the JavaScriptCore framework function JSClassRetain.

func JSContextGetGlobalContext

func JSContextGetGlobalContext(ctx obj.Object) obj.Object

JSContextGetGlobalContext calls the JavaScriptCore framework function JSContextGetGlobalContext.

func JSContextGetGlobalObject

func JSContextGetGlobalObject(ctx obj.Object) obj.Object

JSContextGetGlobalObject calls the JavaScriptCore framework function JSContextGetGlobalObject.

func JSContextGetGroup

func JSContextGetGroup(ctx obj.Object) obj.Object

JSContextGetGroup calls the JavaScriptCore framework function JSContextGetGroup.

func JSContextGroupCreate

func JSContextGroupCreate() obj.Object

JSContextGroupCreate calls the JavaScriptCore framework function JSContextGroupCreate.

func JSContextGroupRelease

func JSContextGroupRelease(group obj.Object)

JSContextGroupRelease calls the JavaScriptCore framework function JSContextGroupRelease.

func JSContextGroupRetain

func JSContextGroupRetain(group obj.Object) obj.Object

JSContextGroupRetain calls the JavaScriptCore framework function JSContextGroupRetain.

func JSGarbageCollect

func JSGarbageCollect(ctx obj.Object)

JSGarbageCollect calls the JavaScriptCore framework function JSGarbageCollect.

func JSGlobalContextCopyName

func JSGlobalContextCopyName(ctx obj.Object) obj.Object

JSGlobalContextCopyName calls the JavaScriptCore framework function JSGlobalContextCopyName.

func JSGlobalContextCreate

func JSGlobalContextCreate(globalObjectClass obj.Object) obj.Object

JSGlobalContextCreate calls the JavaScriptCore framework function JSGlobalContextCreate.

func JSGlobalContextCreateInGroup

func JSGlobalContextCreateInGroup(group obj.Object, globalObjectClass obj.Object) obj.Object

JSGlobalContextCreateInGroup calls the JavaScriptCore framework function JSGlobalContextCreateInGroup.

func JSGlobalContextIsInspectable

func JSGlobalContextIsInspectable(ctx obj.Object) bool

JSGlobalContextIsInspectable calls the JavaScriptCore framework function JSGlobalContextIsInspectable.

func JSGlobalContextRelease

func JSGlobalContextRelease(ctx obj.Object)

JSGlobalContextRelease calls the JavaScriptCore framework function JSGlobalContextRelease.

func JSGlobalContextRetain

func JSGlobalContextRetain(ctx obj.Object) obj.Object

JSGlobalContextRetain calls the JavaScriptCore framework function JSGlobalContextRetain.

func JSGlobalContextSetInspectable

func JSGlobalContextSetInspectable(ctx obj.Object, inspectable bool)

JSGlobalContextSetInspectable calls the JavaScriptCore framework function JSGlobalContextSetInspectable.

func JSGlobalContextSetName

func JSGlobalContextSetName(ctx obj.Object, name obj.Object)

JSGlobalContextSetName calls the JavaScriptCore framework function JSGlobalContextSetName.

func JSObjectCopyPropertyNames

func JSObjectCopyPropertyNames(ctx obj.Object, object obj.Object) obj.Object

JSObjectCopyPropertyNames calls the JavaScriptCore framework function JSObjectCopyPropertyNames.

func JSObjectGetPrototype

func JSObjectGetPrototype(ctx obj.Object, object obj.Object) obj.Object

JSObjectGetPrototype calls the JavaScriptCore framework function JSObjectGetPrototype.

func JSObjectHasProperty

func JSObjectHasProperty(ctx obj.Object, object obj.Object, propertyName obj.Object) bool

JSObjectHasProperty calls the JavaScriptCore framework function JSObjectHasProperty.

func JSObjectIsConstructor

func JSObjectIsConstructor(ctx obj.Object, object obj.Object) bool

JSObjectIsConstructor calls the JavaScriptCore framework function JSObjectIsConstructor.

func JSObjectIsFunction

func JSObjectIsFunction(ctx obj.Object, object obj.Object) bool

JSObjectIsFunction calls the JavaScriptCore framework function JSObjectIsFunction.

func JSObjectSetPrototype

func JSObjectSetPrototype(ctx obj.Object, object obj.Object, value obj.Object)

JSObjectSetPrototype calls the JavaScriptCore framework function JSObjectSetPrototype.

func JSPropertyDescriptorConfigurableKey added in v0.8.0

func JSPropertyDescriptorConfigurableKey() obj.Object

JSPropertyDescriptorConfigurableKey returns the string constant JSPropertyDescriptorConfigurableKey, for use as a dictionary key or argument.

func JSPropertyDescriptorEnumerableKey added in v0.8.0

func JSPropertyDescriptorEnumerableKey() obj.Object

JSPropertyDescriptorEnumerableKey returns the string constant JSPropertyDescriptorEnumerableKey, for use as a dictionary key or argument.

func JSPropertyDescriptorGetKey added in v0.8.0

func JSPropertyDescriptorGetKey() obj.Object

JSPropertyDescriptorGetKey returns the string constant JSPropertyDescriptorGetKey, for use as a dictionary key or argument.

func JSPropertyDescriptorSetKey added in v0.8.0

func JSPropertyDescriptorSetKey() obj.Object

JSPropertyDescriptorSetKey returns the string constant JSPropertyDescriptorSetKey, for use as a dictionary key or argument.

func JSPropertyDescriptorValueKey added in v0.8.0

func JSPropertyDescriptorValueKey() obj.Object

JSPropertyDescriptorValueKey returns the string constant JSPropertyDescriptorValueKey, for use as a dictionary key or argument.

func JSPropertyDescriptorWritableKey added in v0.8.0

func JSPropertyDescriptorWritableKey() obj.Object

JSPropertyDescriptorWritableKey returns the string constant JSPropertyDescriptorWritableKey, for use as a dictionary key or argument.

func JSPropertyNameAccumulatorAddName

func JSPropertyNameAccumulatorAddName(accumulator obj.Object, propertyName obj.Object)

JSPropertyNameAccumulatorAddName calls the JavaScriptCore framework function JSPropertyNameAccumulatorAddName.

func JSPropertyNameArrayGetCount

func JSPropertyNameArrayGetCount(array obj.Object) int

JSPropertyNameArrayGetCount calls the JavaScriptCore framework function JSPropertyNameArrayGetCount.

func JSPropertyNameArrayGetNameAtIndex

func JSPropertyNameArrayGetNameAtIndex(array obj.Object, index int) obj.Object

JSPropertyNameArrayGetNameAtIndex calls the JavaScriptCore framework function JSPropertyNameArrayGetNameAtIndex.

func JSPropertyNameArrayRelease

func JSPropertyNameArrayRelease(array obj.Object)

JSPropertyNameArrayRelease calls the JavaScriptCore framework function JSPropertyNameArrayRelease.

func JSPropertyNameArrayRetain

func JSPropertyNameArrayRetain(array obj.Object) obj.Object

JSPropertyNameArrayRetain calls the JavaScriptCore framework function JSPropertyNameArrayRetain.

func JSStringCopyCFString

func JSStringCopyCFString(alloc obj.Object, string_ obj.Object) obj.Object

JSStringCopyCFString calls the JavaScriptCore framework function JSStringCopyCFString.

func JSStringCreateWithCFString

func JSStringCreateWithCFString(string_ obj.Object) obj.Object

JSStringCreateWithCFString calls the JavaScriptCore framework function JSStringCreateWithCFString.

func JSStringCreateWithUTF8CString

func JSStringCreateWithUTF8CString(string_ string) obj.Object

JSStringCreateWithUTF8CString calls the JavaScriptCore framework function JSStringCreateWithUTF8CString.

func JSStringGetLength

func JSStringGetLength(string_ obj.Object) int

JSStringGetLength calls the JavaScriptCore framework function JSStringGetLength.

func JSStringGetMaximumUTF8CStringSize

func JSStringGetMaximumUTF8CStringSize(string_ obj.Object) int

JSStringGetMaximumUTF8CStringSize calls the JavaScriptCore framework function JSStringGetMaximumUTF8CStringSize.

func JSStringGetUTF8CString

func JSStringGetUTF8CString(string_ obj.Object, buffer string, bufferSize int) int

JSStringGetUTF8CString calls the JavaScriptCore framework function JSStringGetUTF8CString.

func JSStringIsEqual

func JSStringIsEqual(a obj.Object, b obj.Object) bool

JSStringIsEqual calls the JavaScriptCore framework function JSStringIsEqual.

func JSStringIsEqualToUTF8CString

func JSStringIsEqualToUTF8CString(a obj.Object, b string) bool

JSStringIsEqualToUTF8CString calls the JavaScriptCore framework function JSStringIsEqualToUTF8CString.

func JSStringRelease

func JSStringRelease(string_ obj.Object)

JSStringRelease calls the JavaScriptCore framework function JSStringRelease.

func JSStringRetain

func JSStringRetain(string_ obj.Object) obj.Object

JSStringRetain calls the JavaScriptCore framework function JSStringRetain.

func JSValueIsArray

func JSValueIsArray(ctx obj.Object, value obj.Object) bool

JSValueIsArray calls the JavaScriptCore framework function JSValueIsArray.

func JSValueIsBigInt

func JSValueIsBigInt(ctx obj.Object, value obj.Object) bool

JSValueIsBigInt calls the JavaScriptCore framework function JSValueIsBigInt.

func JSValueIsBoolean

func JSValueIsBoolean(ctx obj.Object, value obj.Object) bool

JSValueIsBoolean calls the JavaScriptCore framework function JSValueIsBoolean.

func JSValueIsDate

func JSValueIsDate(ctx obj.Object, value obj.Object) bool

JSValueIsDate calls the JavaScriptCore framework function JSValueIsDate.

func JSValueIsNull

func JSValueIsNull(ctx obj.Object, value obj.Object) bool

JSValueIsNull calls the JavaScriptCore framework function JSValueIsNull.

func JSValueIsNumber

func JSValueIsNumber(ctx obj.Object, value obj.Object) bool

JSValueIsNumber calls the JavaScriptCore framework function JSValueIsNumber.

func JSValueIsObject

func JSValueIsObject(ctx obj.Object, value obj.Object) bool

JSValueIsObject calls the JavaScriptCore framework function JSValueIsObject.

func JSValueIsObjectOfClass

func JSValueIsObjectOfClass(ctx obj.Object, value obj.Object, jsClass obj.Object) bool

JSValueIsObjectOfClass calls the JavaScriptCore framework function JSValueIsObjectOfClass.

func JSValueIsStrictEqual

func JSValueIsStrictEqual(ctx obj.Object, a obj.Object, b obj.Object) bool

JSValueIsStrictEqual calls the JavaScriptCore framework function JSValueIsStrictEqual.

func JSValueIsString

func JSValueIsString(ctx obj.Object, value obj.Object) bool

JSValueIsString calls the JavaScriptCore framework function JSValueIsString.

func JSValueIsSymbol

func JSValueIsSymbol(ctx obj.Object, value obj.Object) bool

JSValueIsSymbol calls the JavaScriptCore framework function JSValueIsSymbol.

func JSValueIsUndefined

func JSValueIsUndefined(ctx obj.Object, value obj.Object) bool

JSValueIsUndefined calls the JavaScriptCore framework function JSValueIsUndefined.

func JSValueMakeBoolean

func JSValueMakeBoolean(ctx obj.Object, boolean bool) obj.Object

JSValueMakeBoolean calls the JavaScriptCore framework function JSValueMakeBoolean.

func JSValueMakeFromJSONString

func JSValueMakeFromJSONString(ctx obj.Object, string_ obj.Object) obj.Object

JSValueMakeFromJSONString calls the JavaScriptCore framework function JSValueMakeFromJSONString.

func JSValueMakeNull

func JSValueMakeNull(ctx obj.Object) obj.Object

JSValueMakeNull calls the JavaScriptCore framework function JSValueMakeNull.

func JSValueMakeNumber

func JSValueMakeNumber(ctx obj.Object, number float64) obj.Object

JSValueMakeNumber calls the JavaScriptCore framework function JSValueMakeNumber.

func JSValueMakeString

func JSValueMakeString(ctx obj.Object, string_ obj.Object) obj.Object

JSValueMakeString calls the JavaScriptCore framework function JSValueMakeString.

func JSValueMakeSymbol

func JSValueMakeSymbol(ctx obj.Object, description obj.Object) obj.Object

JSValueMakeSymbol calls the JavaScriptCore framework function JSValueMakeSymbol.

func JSValueMakeUndefined

func JSValueMakeUndefined(ctx obj.Object) obj.Object

JSValueMakeUndefined calls the JavaScriptCore framework function JSValueMakeUndefined.

func JSValueProtect

func JSValueProtect(ctx obj.Object, value obj.Object)

JSValueProtect calls the JavaScriptCore framework function JSValueProtect.

func JSValueToBoolean

func JSValueToBoolean(ctx obj.Object, value obj.Object) bool

JSValueToBoolean calls the JavaScriptCore framework function JSValueToBoolean.

func JSValueUnprotect

func JSValueUnprotect(ctx obj.Object, value obj.Object)

JSValueUnprotect calls the JavaScriptCore framework function JSValueUnprotect.

Types

type Context

type Context struct {
	objref.Handle
}

Context is an idiomatic wrapper over the Objective-C class JSContext.

A JavaScript execution environment.

func ContextFromID

func ContextFromID(id objc.ID) *Context

ContextFromID adopts an existing Objective-C object as a Context (nil for 0), retaining it and registering a release finalizer.

func ContextWithJSGlobalContextRef

func ContextWithJSGlobalContextRef(jsGlobalContextRef obj.Object) *Context

ContextWithJSGlobalContextRef create a JSContext, wrapping its C API counterpart.

func CurrentContext

func CurrentContext() *Context

CurrentContext returns the context currently executing JavaScript code.

func NewContext

func NewContext() *Context

NewContext creates a new Context.

func NewContextWithVirtualMachine

func NewContextWithVirtualMachine(virtualMachine *VirtualMachine) *Context

NewContextWithVirtualMachine creates a new JavaScript context associated with a specific virtual machine.

func (*Context) Description added in v0.10.0

func (x *Context) Description() string

Description returns the object's -description text.

func (*Context) EvaluateScript

func (x *Context) EvaluateScript(script string) *Value

EvaluateScript executes the specified JavaScript code.

func (*Context) EvaluateScriptWithSourceURL

func (x *Context) EvaluateScriptWithSourceURL(script string, sourceURL string) *Value

EvaluateScriptWithSourceURL executes the specified JavaScript code, treating the specified URL as its source location.

func (*Context) Exception

func (x *Context) Exception() *Value

Exception the <code>exception</code> property may be used to throw an exception to JavaScript. Before a callback is made from JavaScript to an Objective-C block or method, the prior value of the exception property will be preserved and the property will be set to nil. After the callback has completed the new value of the exception property will be read, and prior value restored. If the new value of exception is not nil, the callback will result in that value being thrown. This property may also be used to check for uncaught exceptions arising from API function calls (since the default behaviour of <code>exceptionHandler</code> is to assign an uncaught exception to this property).

func (*Context) GlobalObject

func (x *Context) GlobalObject() *Value

GlobalObject get the global object of the context. This method retrieves the global object of the JavaScript execution context. Instances of JSContext originating from WebKit will return a reference to the WindowProxy object.

func (*Context) IsEqual added in v0.10.0

func (x *Context) IsEqual(other obj.Object) bool

IsEqual reports Objective-C equality (isEqual:) with another object.

func (*Context) IsInspectable

func (x *Context) IsInspectable() bool

IsInspectable controls whether this

func (*Context) IsKind added in v0.10.0

func (x *Context) IsKind(className string) bool

IsKind reports whether the object is an instance of the named class or a subclass.

func (*Context) JSGlobalContextRef

func (x *Context) JSGlobalContextRef() obj.Object

JSGlobalContextRef wraps the corresponding Objective-C method.

func (*Context) Name

func (x *Context) Name() string

Name name of the JSContext. Exposed when inspecting the context.

func (*Context) ObjectForKeyedSubscript

func (x *Context) ObjectForKeyedSubscript(key obj.Object) *Value

ObjectForKeyedSubscript returns the value of the specified JavaScript property in the context’s global object, allowing subscript getter syntax.

func (*Context) SetException

func (x *Context) SetException(exception *Value)

SetException wraps the corresponding Objective-C method.

func (*Context) SetExceptionHandler

func (x *Context) SetExceptionHandler(exceptionHandler func(obj.Object, obj.Object))

SetExceptionHandler wraps the corresponding Objective-C method.

func (*Context) SetInspectable

func (x *Context) SetInspectable(inspectable bool)

SetInspectable wraps the corresponding Objective-C method.

func (*Context) SetName

func (x *Context) SetName(name string)

SetName wraps the corresponding Objective-C method.

func (*Context) SetObjectForKeyedSubscript

func (x *Context) SetObjectForKeyedSubscript(object obj.Object, key obj.Object)

SetObjectForKeyedSubscript sets the specified JavaScript property of the context’s global object, allowing subscript setter syntax.

func (*Context) String added in v0.10.0

func (x *Context) String() string

String returns the object's -description text, so a wrapper prints usefully under fmt.

func (*Context) VirtualMachine

func (x *Context) VirtualMachine() *VirtualMachine

VirtualMachine all instances of JSContext are associated with a JSVirtualMachine.

func (*Context) WithException

func (x *Context) WithException(exception *Value) *Context

WithException a JavaScript exception to be thrown in evaluation of the script.

func (*Context) WithExceptionHandler

func (x *Context) WithExceptionHandler(exceptionHandler func(obj.Object, obj.Object)) *Context

WithExceptionHandler a block to be invoked should evaluating a script result in a JavaScript exception being thrown.

func (*Context) WithInspectable

func (x *Context) WithInspectable(inspectable bool) *Context

WithInspectable a Boolean value that indicates whether you can inspect the JavaScript context with Safari Web Inspector.

func (*Context) WithName

func (x *Context) WithName(name string) *Context

WithName a descriptive name for the context.

type Contextable

type Contextable interface {
	obj.Object
	WithException(exception *Value) *Context
	WithExceptionHandler(exceptionHandler func(obj.Object, obj.Object)) *Context
	WithName(name string) *Context
	WithInspectable(inspectable bool) *Context
	EvaluateScript(script string) *Value
	EvaluateScriptWithSourceURL(script string, sourceURL string) *Value
	GlobalObject() *Value
	Exception() *Value
	SetException(exception *Value)
	SetExceptionHandler(exceptionHandler func(obj.Object, obj.Object))
	VirtualMachine() *VirtualMachine
	Name() string
	SetName(name string)
	IsInspectable() bool
	SetInspectable(inspectable bool)
	ObjectForKeyedSubscript(key obj.Object) *Value
	SetObjectForKeyedSubscript(object obj.Object, key obj.Object)
	JSGlobalContextRef() obj.Object
}

Contextable is the interface implemented by Context, for mocking and DI.

type ManagedValue

type ManagedValue struct {
	objref.Handle
}

ManagedValue is an idiomatic wrapper over the Objective-C class JSManagedValue.

A JavaScript value with conditional retain behavior to provide automatic memory management.

func ManagedValueFromID

func ManagedValueFromID(id objc.ID) *ManagedValue

ManagedValueFromID adopts an existing Objective-C object as a ManagedValue (nil for 0), retaining it and registering a release finalizer.

func ManagedValueWithValue

func ManagedValueWithValue(value *Value) *ManagedValue

ManagedValueWithValue creates a managed value with the specified JavaScript value.

func ManagedValueWithValueAndOwner

func ManagedValueWithValueAndOwner(value *Value, owner obj.Object) *ManagedValue

ManagedValueWithValueAndOwner creates a managed value and associates it with an owner.

func NewManagedValueWithValue

func NewManagedValueWithValue(value *Value) *ManagedValue

NewManagedValueWithValue initializes a managed value with the specified JavaScript value.

func (*ManagedValue) Description added in v0.10.0

func (x *ManagedValue) Description() string

Description returns the object's -description text.

func (*ManagedValue) IsEqual added in v0.10.0

func (x *ManagedValue) IsEqual(other obj.Object) bool

IsEqual reports Objective-C equality (isEqual:) with another object.

func (*ManagedValue) IsKind added in v0.10.0

func (x *ManagedValue) IsKind(className string) bool

IsKind reports whether the object is an instance of the named class or a subclass.

func (*ManagedValue) String added in v0.10.0

func (x *ManagedValue) String() string

String returns the object's -description text, so a wrapper prints usefully under fmt.

func (*ManagedValue) Value

func (x *ManagedValue) Value() *Value

Value wraps the corresponding Objective-C method.

type ManagedValueable

type ManagedValueable interface {
	obj.Object
	Value() *Value
}

ManagedValueable is the interface implemented by ManagedValue, for mocking and DI.

type RelationCondition added in v0.10.0

type RelationCondition int64
const (
	KJSRelationConditionUndefined   RelationCondition = 0
	KJSRelationConditionEqual       RelationCondition = 1
	KJSRelationConditionGreaterThan RelationCondition = 2
	KJSRelationConditionLessThan    RelationCondition = 3
)

func (RelationCondition) String added in v0.10.0

func (e RelationCondition) String() string

String returns the RelationCondition constant's name, or its numeric form when the value is not a known constant.

type Type added in v0.10.0

type Type int64

Constants that identify the type of a JavaScript value.

const (
	KJSTypeUndefined Type = 0
	KJSTypeNull      Type = 1
	KJSTypeBoolean   Type = 2
	KJSTypeNumber    Type = 3
	KJSTypeString    Type = 4
	KJSTypeObject    Type = 5
	KJSTypeSymbol    Type = 6
	KJSTypeBigInt    Type = 7
)

func JSValueGetType

func JSValueGetType(ctx obj.Object, value obj.Object) Type

JSValueGetType calls the JavaScriptCore framework function JSValueGetType.

func (Type) String added in v0.10.0

func (e Type) String() string

String returns the Type constant's name, or its numeric form when the value is not a known constant.

type TypedArrayType added in v0.10.0

type TypedArrayType int64

The type of a JavaScript typed array object.

const (
	KJSTypedArrayTypeInt8Array         TypedArrayType = 0
	KJSTypedArrayTypeInt16Array        TypedArrayType = 1
	KJSTypedArrayTypeInt32Array        TypedArrayType = 2
	KJSTypedArrayTypeUint8Array        TypedArrayType = 3
	KJSTypedArrayTypeUint8ClampedArray TypedArrayType = 4
	KJSTypedArrayTypeUint16Array       TypedArrayType = 5
	KJSTypedArrayTypeUint32Array       TypedArrayType = 6
	KJSTypedArrayTypeFloat32Array      TypedArrayType = 7
	KJSTypedArrayTypeFloat64Array      TypedArrayType = 8
	KJSTypedArrayTypeArrayBuffer       TypedArrayType = 9
	KJSTypedArrayTypeNone              TypedArrayType = 10
	KJSTypedArrayTypeBigInt64Array     TypedArrayType = 11
	KJSTypedArrayTypeBigUint64Array    TypedArrayType = 12
)

func (TypedArrayType) String added in v0.10.0

func (e TypedArrayType) String() string

String returns the TypedArrayType constant's name, or its numeric form when the value is not a known constant.

type Value

type Value struct {
	objref.Handle
}

Value is an idiomatic wrapper over the Objective-C class JSValue.

A JavaScript value.

func CurrentCallee

func CurrentCallee() *Value

CurrentCallee returns the currently executing JavaScript function.

func CurrentThis

func CurrentThis() *Value

CurrentThis returns the value of the this keyword in currently executing JavaScript code.

func NewValue

func NewValue() *Value

NewValue creates a new Value.

func ValueFromID

func ValueFromID(id objc.ID) *Value

ValueFromID adopts an existing Objective-C object as a Value (nil for 0), retaining it and registering a release finalizer.

func ValueWithBoolInContext

func ValueWithBoolInContext(value bool, context_ *Context) *Value

ValueWithBoolInContext creates a JavaScript representation of the specified Boolean value.

func ValueWithDoubleInContext

func ValueWithDoubleInContext(value float64, context_ *Context) *Value

ValueWithDoubleInContext creates a JavaScript representation of the specified floating-point value.

func ValueWithInt32InContext

func ValueWithInt32InContext(value int32, context_ *Context) *Value

ValueWithInt32InContext creates a JavaScript representation of the specified signed integer value.

func ValueWithJSValueRefInContext

func ValueWithJSValueRefInContext(value obj.Object, context_ *Context) *Value

ValueWithJSValueRefInContext creates a JSValue, wrapping its C API counterpart.

func ValueWithNewArrayInContext

func ValueWithNewArrayInContext(context_ *Context) *Value

ValueWithNewArrayInContext creates a new, empty JavaScript array value.

func ValueWithNewBigIntFromDoubleInContext

func ValueWithNewBigIntFromDoubleInContext(value float64, context_ *Context) *Value

ValueWithNewBigIntFromDoubleInContext create a new BigInt value from a double. If the value is not an integer, an exception is thrown.

func ValueWithNewBigIntFromInt64InContext

func ValueWithNewBigIntFromInt64InContext(int64 int64, context_ *Context) *Value

ValueWithNewBigIntFromInt64InContext create a new BigInt value from a <code>int64_t</code>.

func ValueWithNewBigIntFromStringInContext

func ValueWithNewBigIntFromStringInContext(string_ string, context_ *Context) *Value

ValueWithNewBigIntFromStringInContext create a new BigInt value from a numeric string. This is equivalent to calling the <code>BigInt</code> constructor from JavaScript with a string argument.

func ValueWithNewBigIntFromUInt64InContext

func ValueWithNewBigIntFromUInt64InContext(uint64 uint64, context_ *Context) *Value

ValueWithNewBigIntFromUInt64InContext create a new BigInt value from a <code>uint64_t</code>.

func ValueWithNewErrorFromMessageInContext

func ValueWithNewErrorFromMessageInContext(message string, context_ *Context) *Value

ValueWithNewErrorFromMessageInContext creates a JavaScript error value with the specified error message.

func ValueWithNewObjectInContext

func ValueWithNewObjectInContext(context_ *Context) *Value

ValueWithNewObjectInContext creates a new, empty JavaScript object value.

func ValueWithNewPromiseInContextFromExecutor

func ValueWithNewPromiseInContextFromExecutor(context_ *Context, callback func(obj.Object, obj.Object)) *Value

ValueWithNewPromiseInContextFromExecutor creates a promise object using the specified executor callback.

func ValueWithNewPromiseRejectedWithReasonInContext

func ValueWithNewPromiseRejectedWithReasonInContext(reason obj.Object, context_ *Context) *Value

ValueWithNewPromiseRejectedWithReasonInContext creates a rejected promise object with the specified value.

func ValueWithNewPromiseResolvedWithResultInContext

func ValueWithNewPromiseResolvedWithResultInContext(result obj.Object, context_ *Context) *Value

ValueWithNewPromiseResolvedWithResultInContext creates a resolved promise object with the specified value.

func ValueWithNewRegularExpressionFromPatternFlagsInContext

func ValueWithNewRegularExpressionFromPatternFlagsInContext(pattern string, flags string, context_ *Context) *Value

ValueWithNewRegularExpressionFromPatternFlagsInContext creates a JavaScript regular expression value from the specified pattern.

func ValueWithNewSymbolFromDescriptionInContext

func ValueWithNewSymbolFromDescriptionInContext(description string, context_ *Context) *Value

ValueWithNewSymbolFromDescriptionInContext creates a unique symbol object.

func ValueWithNullInContext

func ValueWithNullInContext(context_ *Context) *Value

ValueWithNullInContext creates a JavaScript null value.

func ValueWithObjectInContext

func ValueWithObjectInContext(value obj.Object, context_ *Context) *Value

ValueWithObjectInContext creates a JavaScript value by converting the specified native object.

func ValueWithPointInContext

func ValueWithPointInContext(point corefoundation.CGPoint, context_ *Context) *Value

ValueWithPointInContext create a JSValue from a CGPoint.

func ValueWithRangeInContext

func ValueWithRangeInContext(range_ foundation.NSRange, context_ *Context) *Value

ValueWithRangeInContext create a JSValue from a NSRange.

func ValueWithRectInContext

func ValueWithRectInContext(rect corefoundation.CGRect, context_ *Context) *Value

ValueWithRectInContext create a JSValue from a CGRect.

func ValueWithSizeInContext

func ValueWithSizeInContext(size corefoundation.CGSize, context_ *Context) *Value

ValueWithSizeInContext create a JSValue from a CGSize.

func ValueWithUInt32InContext

func ValueWithUInt32InContext(value uint32, context_ *Context) *Value

ValueWithUInt32InContext creates a JavaScript representation of the specified unsigned integer value.

func ValueWithUndefinedInContext

func ValueWithUndefinedInContext(context_ *Context) *Value

ValueWithUndefinedInContext creates a JavaScript undefined value.

func (*Value) CallWithArguments

func (x *Value) CallWithArguments(arguments obj.Object) *Value

CallWithArguments invokes the value as a JavaScript function.

func (*Value) CompareDouble

func (x *Value) CompareDouble(other float64) RelationCondition

CompareDouble compare a JSValue with a double. The JSValue is converted to a double according to the rules specified by the JavaScript language then compared with <code>other</code>.

func (*Value) CompareInt64

func (x *Value) CompareInt64(other int64) RelationCondition

CompareInt64 compare a JSValue with a <code>int64_t</code>. The JSValue is converted to an integer according to the rules specified by the JavaScript language then compared with <code>other</code>.

func (*Value) CompareJSValue

func (x *Value) CompareJSValue(other *Value) RelationCondition

CompareJSValue compare two JSValues. The result is computed by comparing the results of JavaScript's <code>==</code>, <code><</code>, and <code>></code> operators. If either <code>self</code> or <code>other</code> is (or would coerce to) <code>NaN</code> in JavaScript, then the result is kJSRelationConditionUndefined.

func (*Value) CompareUInt64

func (x *Value) CompareUInt64(other uint64) RelationCondition

CompareUInt64 compare a JSValue with a <code>uint64_t</code>. The JSValue is converted to an integer according to the rules specified by the JavaScript language then compared with <code>other</code>.

func (*Value) ConstructWithArguments

func (x *Value) ConstructWithArguments(arguments obj.Object) *Value

ConstructWithArguments invokes the value as a JavaScript constructor.

func (*Value) Context

func (x *Value) Context() *Context

Context the JSContext that this value originates from.

func (*Value) DefinePropertyDescriptor

func (x *Value) DefinePropertyDescriptor(property obj.Object, descriptor obj.Object)

DefinePropertyDescriptor defines a property on the JavaScript object value or modifies a property’s definition.

func (*Value) DeleteProperty

func (x *Value) DeleteProperty(property obj.Object) bool

DeleteProperty deletes the named property from the JavaScript object value.

func (*Value) Description added in v0.10.0

func (x *Value) Description() string

Description returns the object's -description text.

func (*Value) HasProperty

func (x *Value) HasProperty(property obj.Object) bool

HasProperty returns a Boolean value indicating whether the JavaScript value has a defined property with the specified name.

func (*Value) InvokeMethodWithArguments

func (x *Value) InvokeMethodWithArguments(method string, arguments obj.Object) *Value

InvokeMethodWithArguments calls the named JavaScript method on the value.

func (*Value) IsArray

func (x *Value) IsArray() bool

IsArray check if a JSValue is an array.

func (*Value) IsBigInt

func (x *Value) IsBigInt() bool

IsBigInt check if a JSValue is a BigInt.

func (*Value) IsBoolean

func (x *Value) IsBoolean() bool

IsBoolean check if a JSValue is a boolean.

func (*Value) IsDate

func (x *Value) IsDate() bool

IsDate check if a JSValue is a date.

func (*Value) IsEqual added in v0.10.0

func (x *Value) IsEqual(other obj.Object) bool

IsEqual reports Objective-C equality (isEqual:) with another object.

func (*Value) IsEqualToObject

func (x *Value) IsEqualToObject(value obj.Object) bool

IsEqualToObject compares the value to another for strict equality.

func (*Value) IsEqualWithTypeCoercionToObject

func (x *Value) IsEqualWithTypeCoercionToObject(value obj.Object) bool

IsEqualWithTypeCoercionToObject compares the value to another for equivalence, allowing type conversion.

func (*Value) IsInstanceOf

func (x *Value) IsInstanceOf(value obj.Object) bool

IsInstanceOf returns a Boolean value indicating whether the value is an instance of another JavaScript object value.

func (*Value) IsKind added in v0.10.0

func (x *Value) IsKind(className string) bool

IsKind reports whether the object is an instance of the named class or a subclass.

func (*Value) IsNull

func (x *Value) IsNull() bool

IsNull check if a JSValue corresponds to the JavaScript value <code>null</code>.

func (*Value) IsNumber

func (x *Value) IsNumber() bool

IsNumber check if a JSValue is a number. In JavaScript, there is no differentiation between types of numbers. Semantically all numbers behave like doubles except in special cases like bit operations.

func (*Value) IsObject

func (x *Value) IsObject() bool

IsObject check if a JSValue is an object.

func (*Value) IsString

func (x *Value) IsString() bool

IsString check if a JSValue is a string.

func (*Value) IsSymbol

func (x *Value) IsSymbol() bool

IsSymbol check if a JSValue is a symbol.

func (*Value) IsUndefined

func (x *Value) IsUndefined() bool

IsUndefined check if a JSValue corresponds to the JavaScript value <code>undefined</code>.

func (*Value) JSValueRef

func (x *Value) JSValueRef() obj.Object

JSValueRef wraps the corresponding Objective-C method.

func (*Value) ObjectAtIndexedSubscript

func (x *Value) ObjectAtIndexedSubscript(index int) *Value

ObjectAtIndexedSubscript returns the value’s JavaScript property at the specified index, allowing subscript syntax.

func (*Value) ObjectForKeyedSubscript

func (x *Value) ObjectForKeyedSubscript(key obj.Object) *Value

ObjectForKeyedSubscript returns the value’s JavaScript property named with the specified key, allowing subscript syntax.

func (*Value) SetObjectAtIndexedSubscript

func (x *Value) SetObjectAtIndexedSubscript(object obj.Object, index int)

SetObjectAtIndexedSubscript sets the value’s JavaScript property at the specified index, allowing subscript syntax.

func (*Value) SetObjectForKeyedSubscript

func (x *Value) SetObjectForKeyedSubscript(object obj.Object, key obj.Object)

SetObjectForKeyedSubscript sets the value’s JavaScript property named with the specified key, allowing subscript syntax.

func (*Value) SetValueAtIndex

func (x *Value) SetValueAtIndex(value obj.Object, index int)

SetValueAtIndex sets the value at the specified numeric index in the JavaScript object value.

func (*Value) SetValueForProperty

func (x *Value) SetValueForProperty(value obj.Object, property obj.Object)

SetValueForProperty sets the value of the named property in the JavaScript object value.

func (*Value) String added in v0.10.0

func (x *Value) String() string

String returns the object's -description text, so a wrapper prints usefully under fmt.

func (*Value) ToArray

func (x *Value) ToArray() obj.Object

ToArray converts the JavaScript value to an array.

func (*Value) ToBool

func (x *Value) ToBool() bool

ToBool converts the JavaScript value to a native Boolean value.

func (*Value) ToDate

func (x *Value) ToDate() obj.Object

ToDate converts the JavaScript value to a date object.

func (*Value) ToDictionary

func (x *Value) ToDictionary() obj.Object

ToDictionary converts the JavaScript value to a dictionary.

func (*Value) ToDouble

func (x *Value) ToDouble() float64

ToDouble converts the JavaScript value to a native floating-point value.

func (*Value) ToInt32

func (x *Value) ToInt32() int32

ToInt32 converts the JavaScript value to a native signed integer value.

func (*Value) ToInt64

func (x *Value) ToInt64() int64

ToInt64 convert a JSValue to a <code>int64_t</code>. The JSValue is converted to an integer according to the rules specified by the JavaScript language. If the value is a BigInt, then the value is truncated to an <code>int64_t</code>.

func (*Value) ToNumber

func (x *Value) ToNumber() obj.Object

ToNumber converts the JavaScript value to a NSNumber object.

func (*Value) ToObject

func (x *Value) ToObject() obj.Object

ToObject converts the JavaScript value to a native object.

func (*Value) ToPoint

func (x *Value) ToPoint() corefoundation.CGPoint

ToPoint converts the value to a point structure.

func (*Value) ToRange

func (x *Value) ToRange() foundation.NSRange

ToRange converts the value to a range.

func (*Value) ToRect

func (x *Value) ToRect() corefoundation.CGRect

ToRect converts the value to a rectangle structure.

func (*Value) ToSize

func (x *Value) ToSize() corefoundation.CGSize

ToSize converts the value to a size.

func (*Value) ToString

func (x *Value) ToString() string

ToString converts the JavaScript value to a native string.

func (*Value) ToUInt32

func (x *Value) ToUInt32() uint32

ToUInt32 converts the JavaScript value to a native unsigned integer value.

func (*Value) ToUInt64

func (x *Value) ToUInt64() uint64

ToUInt64 convert a JSValue to a <code>uint64_t</code>. The JSValue is converted to an integer according to the rules specified by the JavaScript language. If the value is a BigInt, then the value is truncated to a <code>uint64_t</code>.

func (*Value) ValueAtIndex

func (x *Value) ValueAtIndex(index int) *Value

ValueAtIndex returns the value at the specified numeric index in the JavaScript object value.

func (*Value) ValueForProperty

func (x *Value) ValueForProperty(property obj.Object) *Value

ValueForProperty returns the value of the named property in the JavaScript object value.

type Valueable

type Valueable interface {
	obj.Object
	ToObject() obj.Object
	ToBool() bool
	ToDouble() float64
	ToInt32() int32
	ToUInt32() uint32
	ToInt64() int64
	ToUInt64() uint64
	ToNumber() obj.Object
	ToString() string
	ToDate() obj.Object
	ToArray() obj.Object
	ToDictionary() obj.Object
	IsInstanceOf(value obj.Object) bool
	IsEqualToObject(value obj.Object) bool
	IsEqualWithTypeCoercionToObject(value obj.Object) bool
	CompareJSValue(other *Value) RelationCondition
	CompareInt64(other int64) RelationCondition
	CompareUInt64(other uint64) RelationCondition
	CompareDouble(other float64) RelationCondition
	CallWithArguments(arguments obj.Object) *Value
	ConstructWithArguments(arguments obj.Object) *Value
	InvokeMethodWithArguments(method string, arguments obj.Object) *Value
	Context() *Context
	IsUndefined() bool
	IsNull() bool
	IsBoolean() bool
	IsNumber() bool
	IsString() bool
	IsObject() bool
	IsArray() bool
	IsDate() bool
	IsSymbol() bool
	IsBigInt() bool
	ToPoint() corefoundation.CGPoint
	ToRange() foundation.NSRange
	ToRect() corefoundation.CGRect
	ToSize() corefoundation.CGSize
	ValueForProperty(property obj.Object) *Value
	SetValueForProperty(value obj.Object, property obj.Object)
	DeleteProperty(property obj.Object) bool
	HasProperty(property obj.Object) bool
	DefinePropertyDescriptor(property obj.Object, descriptor obj.Object)
	ValueAtIndex(index int) *Value
	SetValueAtIndex(value obj.Object, index int)
	ObjectForKeyedSubscript(key obj.Object) *Value
	ObjectAtIndexedSubscript(index int) *Value
	SetObjectForKeyedSubscript(object obj.Object, key obj.Object)
	SetObjectAtIndexedSubscript(object obj.Object, index int)
	JSValueRef() obj.Object
}

Valueable is the interface implemented by Value, for mocking and DI.

type VirtualMachine

type VirtualMachine struct {
	objref.Handle
}

VirtualMachine is an idiomatic wrapper over the Objective-C class JSVirtualMachine.

A self-contained environment for JavaScript execution.

func NewVirtualMachine

func NewVirtualMachine() *VirtualMachine

NewVirtualMachine creates a new VirtualMachine.

func VirtualMachineFromID

func VirtualMachineFromID(id objc.ID) *VirtualMachine

VirtualMachineFromID adopts an existing Objective-C object as a VirtualMachine (nil for 0), retaining it and registering a release finalizer.

func (*VirtualMachine) AddManagedReferenceWithOwner

func (x *VirtualMachine) AddManagedReferenceWithOwner(object obj.Object, owner obj.Object)

AddManagedReferenceWithOwner notifies the JavaScriptCore virtual machine of an external object relationship.

func (*VirtualMachine) Description added in v0.10.0

func (x *VirtualMachine) Description() string

Description returns the object's -description text.

func (*VirtualMachine) IsEqual added in v0.10.0

func (x *VirtualMachine) IsEqual(other obj.Object) bool

IsEqual reports Objective-C equality (isEqual:) with another object.

func (*VirtualMachine) IsKind added in v0.10.0

func (x *VirtualMachine) IsKind(className string) bool

IsKind reports whether the object is an instance of the named class or a subclass.

func (*VirtualMachine) RemoveManagedReferenceWithOwner

func (x *VirtualMachine) RemoveManagedReferenceWithOwner(object obj.Object, owner obj.Object)

RemoveManagedReferenceWithOwner notifies the JavaScriptCore virtual machine that a previously registered object relationship no longer exists.

func (*VirtualMachine) String added in v0.10.0

func (x *VirtualMachine) String() string

String returns the object's -description text, so a wrapper prints usefully under fmt.

type VirtualMachineable

type VirtualMachineable interface {
	obj.Object
	AddManagedReferenceWithOwner(object obj.Object, owner obj.Object)
	RemoveManagedReferenceWithOwner(object obj.Object, owner obj.Object)
}

VirtualMachineable is the interface implemented by VirtualMachine, for mocking and DI.

Jump to

Keyboard shortcuts

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