Value

JSCValue represents a reference to a value in a #JSCContext. The JSCValue protects the referenced value from being garbage collected.

class Value : ObjectWrap {}

Constructors

this
this(void* ptr, Flag!"Take" take)

Members

Functions

arrayBufferGetSize
size_t arrayBufferGetSize()

Gets the size in bytes of the array buffer.

constructorCall
javascriptcore.value.Value constructorCall(javascriptcore.value.Value[] parameters)

Invoke <function>new</function> with constructor referenced by value. If n_parameters is 0 no parameters will be passed to the constructor.

functionCall
javascriptcore.value.Value functionCall(javascriptcore.value.Value[] parameters)

Call function referenced by value, passing the given parameters. If n_parameters is 0 no parameters will be passed to the function.

getContext
javascriptcore.context.Context getContext()

Get the #JSCContext in which value was created.

isArray
bool isArray()

Get whether the value referenced by value is an array.

isArrayBuffer
bool isArrayBuffer()

Check whether the value is an ArrayBuffer.

isBoolean
bool isBoolean()

Get whether the value referenced by value is a boolean.

isConstructor
bool isConstructor()

Get whether the value referenced by value is a constructor.

isFunction
bool isFunction()

Get whether the value referenced by value is a function

isNull
bool isNull()

Get whether the value referenced by value is <function>null</function>.

isNumber
bool isNumber()

Get whether the value referenced by value is a number.

isObject
bool isObject()

Get whether the value referenced by value is an object.

isString
bool isString()

Get whether the value referenced by value is a string

isTypedArray
bool isTypedArray()

Determines whether a value is a typed array.

isUndefined
bool isUndefined()

Get whether the value referenced by value is <function>undefined</function>.

newTypedArrayWithBuffer
javascriptcore.value.Value newTypedArrayWithBuffer(javascriptcore.types.TypedArrayType type, size_t offset, ptrdiff_t length)

Create a new typed array value with elements from an array buffer.

objectDefinePropertyData
void objectDefinePropertyData(string propertyName, javascriptcore.types.ValuePropertyFlags flags, javascriptcore.value.Value propertyValue)

Define or modify a property with property_name in object referenced by value. This is equivalent to JavaScript <function>Object.defineProperty()</function> when used with a data descriptor.

objectDeleteProperty
bool objectDeleteProperty(string name)

Try to delete property with name from value. This function will return false if the property was defined without JSC_VALUE_PROPERTY_CONFIGURABLE flag.

objectEnumerateProperties
string[] objectEnumerateProperties()

Get the list of property names of value. Only properties defined with JSC_VALUE_PROPERTY_ENUMERABLE flag will be collected.

objectGetProperty
javascriptcore.value.Value objectGetProperty(string name)

Get property with name from value.

objectGetPropertyAtIndex
javascriptcore.value.Value objectGetPropertyAtIndex(uint index)

Get property at index from value.

objectHasProperty
bool objectHasProperty(string name)

Get whether value has property with name.

objectInvokeMethod
javascriptcore.value.Value objectInvokeMethod(string name, javascriptcore.value.Value[] parameters)

Invoke method with name on object referenced by value, passing the given parameters. If n_parameters is 0 no parameters will be passed to the method. The object instance will be handled automatically even when the method is a custom one registered with javascriptcore.class_.Class.addMethod, so it should never be passed explicitly as parameter of this function.

objectIsInstanceOf
bool objectIsInstanceOf(string name)

Get whether the value referenced by value is an instance of class name.

objectSetProperty
void objectSetProperty(string name, javascriptcore.value.Value property)

Set property with name on value.

objectSetPropertyAtIndex
void objectSetPropertyAtIndex(uint index, javascriptcore.value.Value property)

Set property at index on value.

self
Value self()

Returns this, for use in with statements.

toBoolean
bool toBoolean()

Convert value to a boolean.

toDouble
double toDouble()

Convert value to a double.

toInt32
int toInt32()

Convert value to a #gint32.

toJson
string toJson(uint indent)

Create a JSON string of value serialization. If indent is 0, the resulting JSON will not contain newlines. The size of the indent is clamped to 10 spaces.

toStringAsBytes
glib.bytes.Bytes toStringAsBytes()

Convert value to a string and return the results as #GBytes. This is needed to handle strings with null characters.

toString_
string toString_()

Convert value to a string. Use javascriptcore.value.Value.toStringAsBytes instead, if you need to handle strings containing null characters.

typedArrayGetBuffer
javascriptcore.value.Value typedArrayGetBuffer()

Obtain the ArrayBuffer for the memory region of the typed array elements.

typedArrayGetData
void* typedArrayGetData(size_t length)

Obtains a pointer to the memory region that holds the elements of the typed array; modifications done to them will be visible to JavaScript code. If length is not null, the number of elements contained in the typed array are also stored in the pointed location.

typedArrayGetLength
size_t typedArrayGetLength()

Gets the number of elements in a typed array.

typedArrayGetOffset
size_t typedArrayGetOffset()

Gets the offset over the underlying array buffer data.

typedArrayGetSize
size_t typedArrayGetSize()

Gets the size of a typed array.

typedArrayGetType
javascriptcore.types.TypedArrayType typedArrayGetType()

Gets the type of elements contained in a typed array.

Properties

gType
GType gType [@property getter]

Static functions

getGType
GType getGType()
newArrayBuffer
javascriptcore.value.Value newArrayBuffer(javascriptcore.context.Context context, void* data, size_t size, glib.types.DestroyNotify destroyNotify)

Creates a new ArrayBuffer from existing data in memory.

newArrayFromGarray
javascriptcore.value.Value newArrayFromGarray(javascriptcore.context.Context context, javascriptcore.value.Value[] array)

Create a new #JSCValue referencing an array with the items from array. If array is null or empty a new empty array will be created. Elements of array should be pointers to a #JSCValue.

newArrayFromStrv
javascriptcore.value.Value newArrayFromStrv(javascriptcore.context.Context context, string[] strv)

Create a new #JSCValue referencing an array of strings with the items from strv. If array is null or empty a new empty array will be created.

newBoolean
javascriptcore.value.Value newBoolean(javascriptcore.context.Context context, bool value)

Create a new #JSCValue from value

newFromJson
javascriptcore.value.Value newFromJson(javascriptcore.context.Context context, string json)

Create a new #JSCValue referencing a new value created by parsing json.

newNull
javascriptcore.value.Value newNull(javascriptcore.context.Context context)

Create a new #JSCValue referencing <function>null</function> in context.

newNumber
javascriptcore.value.Value newNumber(javascriptcore.context.Context context, double number)

Create a new #JSCValue from number.

newObject
javascriptcore.value.Value newObject(javascriptcore.context.Context context, void* instance, javascriptcore.class_.Class jscClass)

Create a new #JSCValue from instance. If instance is null a new empty object is created. When instance is provided, jsc_class must be provided too. jsc_class takes ownership of instance that will be freed by the #GDestroyNotify passed to javascriptcore.context.Context.registerClass.

newPromise
javascriptcore.value.Value newPromise(javascriptcore.context.Context context, javascriptcore.types.Executor executor)

Creates a new Promise. executor will be invoked during promise initialization and it receives the resolve and reject objects than can be called to resolve or reject the promise. It is called like a JavaScript function, so exceptions raised during the executor invocation will not be propagated to the context, but handled by the promise causing a rejection.

newString
javascriptcore.value.Value newString(javascriptcore.context.Context context, string string_)

Create a new #JSCValue from string. If you need to create a #JSCValue from a string containing null characters, use javascriptcore.value.Value.newStringFromBytes instead.

newStringFromBytes
javascriptcore.value.Value newStringFromBytes(javascriptcore.context.Context context, glib.bytes.Bytes bytes)

Create a new #JSCValue from bytes.

newTypedArray
javascriptcore.value.Value newTypedArray(javascriptcore.context.Context context, javascriptcore.types.TypedArrayType type, size_t length)

Create a new typed array containing a given amount of elements.

newUndefined
javascriptcore.value.Value newUndefined(javascriptcore.context.Context context)

Create a new #JSCValue referencing <function>undefined</function> in context.

Inherited Members

From ObjectWrap

setGObject
void setGObject(void* cObj, Flag!"Take" take)

Set the GObject of a D ObjectWrap wrapper.

cPtr
void* cPtr(Flag!"Dup" dup)

Get a pointer to the underlying C object.

ref_
void* ref_(void* gObj)

Calls g_object_ref() on a GObject.

unref
unref(void* gObj)

Calls g_object_unref() on a GObject.

getType
GType getType()

Get the GType of an object.

gType
GType gType [@property getter]

GObject GType property.

self
ObjectWrap self()

Convenience method to return this cast to a type. For use in D with statements.

getDObject
T getDObject(void* cptr, Flag!"Take" take)

Template to get the D object from a C GObject and cast it to the given D object type.

connectSignalClosure
ulong connectSignalClosure(string signalDetail, DClosure closure, Flag!"After" after)

Connect a D closure to an object signal.

setProperty
void setProperty(string propertyName, T val)

Template for setting a GObject property.

getProperty
T getProperty(string propertyName)

Template for getting a GObject property.

compatControl
size_t compatControl(size_t what, void* data)
bindProperty
gobject.binding.Binding bindProperty(string sourceProperty, gobject.object.ObjectWrap target, string targetProperty, gobject.types.BindingFlags flags)

Creates a binding between source_property on source and target_property on target.

bindPropertyFull
gobject.binding.Binding bindPropertyFull(string sourceProperty, gobject.object.ObjectWrap target, string targetProperty, gobject.types.BindingFlags flags, gobject.closure.Closure transformTo, gobject.closure.Closure transformFrom)

Creates a binding between source_property on source and target_property on target, allowing you to set the transformation functions to be used by the binding.

forceFloating
void forceFloating()

This function is intended for #GObject implementations to re-enforce a floating[floating-ref] object reference. Doing this is seldom required: all #GInitiallyUnowneds are created with a floating reference which usually just needs to be sunken by calling gobject.object.ObjectWrap.refSink.

freezeNotify
void freezeNotify()

Increases the freeze count on object. If the freeze count is non-zero, the emission of "notify" signals on object is stopped. The signals are queued until the freeze count is decreased to zero. Duplicate notifications are squashed so that at most one #GObject::notify signal is emitted for each property modified while the object is frozen.

getData
void* getData(string key)

Gets a named field from the objects table of associations (see gobject.object.ObjectWrap.setData).

getProperty
void getProperty(string propertyName, gobject.value.Value value)

Gets a property of an object.

getQdata
void* getQdata(glib.types.Quark quark)

This function gets back user data pointers stored via gobject.object.ObjectWrap.setQdata.

getv
void getv(string[] names, gobject.value.Value[] values)

Gets n_properties properties for an object. Obtained properties will be set to values. All properties must be valid. Warnings will be emitted and undefined behaviour may result if invalid properties are passed in.

isFloating
bool isFloating()

Checks whether object has a floating[floating-ref] reference.

notify
void notify(string propertyName)

Emits a "notify" signal for the property property_name on object.

notifyByPspec
void notifyByPspec(gobject.param_spec.ParamSpec pspec)

Emits a "notify" signal for the property specified by pspec on object.

refSink
gobject.object.ObjectWrap refSink()

Increase the reference count of object, and possibly remove the floating[floating-ref] reference, if object has a floating reference.

runDispose
void runDispose()

Releases all references to other objects. This can be used to break reference cycles.

setData
void setData(string key, void* data)

Each object carries around a table of associations from strings to pointers. This function lets you set an association.

setProperty
void setProperty(string propertyName, gobject.value.Value value)

Sets a property on an object.

stealData
void* stealData(string key)

Remove a specified datum from the object's data associations, without invoking the association's destroy handler.

stealQdata
void* stealQdata(glib.types.Quark quark)

This function gets back user data pointers stored via gobject.object.ObjectWrap.setQdata and removes the data from object without invoking its destroy() function (if any was set). Usually, calling this function is only required to update user data pointers with a destroy notifier, for example:

thawNotify
void thawNotify()

Reverts the effect of a previous call to gobject.object.ObjectWrap.freezeNotify. The freeze count is decreased on object and when it reaches zero, queued "notify" signals are emitted.

watchClosure
void watchClosure(gobject.closure.Closure closure)

This function essentially limits the life time of the closure to the life time of the object. That is, when the object is finalized, the closure is invalidated by calling gobject.closure.Closure.invalidate on it, in order to prevent invocations of the closure with a finalized (nonexisting) object. Also, gobject.object.ObjectWrap.ref_ and gobject.object.ObjectWrap.unref are added as marshal guards to the closure, to ensure that an extra reference count is held on object during invocation of the closure. Usually, this function will be called on closures that use this object as closure data.

connectNotify
ulong connectNotify(string detail, T callback, Flag!"After" after)

Connect to Notify signal.