javascriptcore.value

Module for [Value] class

Types 3

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

Methods
GType _getGType() static nothrow
GType _gType() @property nothrow
Value self() nothrowReturns `this`, for use in `with` statements.
ValueGidBuilder builder() static nothrowGet builder for [javascriptcore.value.Value] Returns: New builder object
javascriptcore.context.Context context() @property nothrowGet `context` property. Returns: The #JSCContext in which the value was created.
Value newFunction(T)(Context context, string name, T callback) static nothrowCreate a function in context which calls a D callback. Params: context = The context name = The name of the function or null for an anonymous function callback = The callback Returns: New function ...
T get(T)() nothrowGet the D value from a Value. Params: T = The D type Returns: The value as a native D type
Value from(T)(Context ctx, T val) static nothrowCreate a new Value from a native D value. Params: T = The type of the value ctx = The Context object val = The D value to create the Value from Returns: The new Value
javascriptcore.value.Value newArrayBuffer(javascriptcore.context.Context context, void * data, size_t size, glib.types.DestroyNotify destroyNotify = null) static nothrowCreates a new `ArrayBuffer` from existing data in memory.
javascriptcore.value.Value newArrayFromGarray(javascriptcore.context.Context context, javascriptcore.value.Value[] array = null) static nothrowCreate 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.
javascriptcore.value.Value newArrayFromStrv(javascriptcore.context.Context context, string[] strv) static nothrowCreate 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.
javascriptcore.value.Value newBoolean(javascriptcore.context.Context context, bool value) static nothrowCreate a new #JSCValue from value
javascriptcore.value.Value newFromJson(javascriptcore.context.Context context, string json) static nothrowCreate a new #JSCValue referencing a new value created by parsing json.
javascriptcore.value.Value newNull(javascriptcore.context.Context context) static nothrowCreate a new #JSCValue referencing <function>null</function> in context.
javascriptcore.value.Value newNumber(javascriptcore.context.Context context, double number) static nothrowCreate a new #JSCValue from number.
javascriptcore.value.Value newObject(javascriptcore.context.Context context, void * instance = null, javascriptcore.class_.Class jscClass = null) static nothrowCreate 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 b...
javascriptcore.value.Value newPromise(javascriptcore.context.Context context, javascriptcore.types.Executor executor) static nothrowCreates 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...
javascriptcore.value.Value newString(javascriptcore.context.Context context, string string_ = null) static nothrowCreate a new #JSCValue from string. If you need to create a #JSCValue from a string containing null characters, use [javascriptcore.value.Value.newStringFromBytes] instead.
javascriptcore.value.Value newStringFromBytes(javascriptcore.context.Context context, glib.bytes.Bytes bytes = null) static nothrowCreate a new #JSCValue from bytes.
javascriptcore.value.Value newTypedArray(javascriptcore.context.Context context, javascriptcore.types.TypedArrayType type, size_t length) static nothrowCreate a new typed array containing a given amount of elements.
javascriptcore.value.Value newUndefined(javascriptcore.context.Context context) static nothrowCreate a new #JSCValue referencing <function>undefined</function> in context.
size_t arrayBufferGetSize() nothrowGets the size in bytes of the array buffer.
javascriptcore.value.Value constructorCall(javascriptcore.value.Value[] parameters = null) nothrowInvoke <function>new</function> with constructor referenced by value. If n_parameters is 0 no parameters will be passed to the constructor.
javascriptcore.value.Value functionCall(javascriptcore.value.Value[] parameters = null) nothrowCall function referenced by value, passing the given parameters. If n_parameters is 0 no parameters will be passed to the function.
javascriptcore.context.Context getContext() nothrowGet the #JSCContext in which value was created. Returns: the #JSCValue context.
bool isArray() nothrowGet whether the value referenced by value is an array. Returns: whether the value is an array.
bool isArrayBuffer() nothrowCheck whether the value is an `ArrayBuffer`. Returns: whether the value is an `ArrayBuffer`
bool isBoolean() nothrowGet whether the value referenced by value is a boolean. Returns: whether the value is a boolean.
bool isConstructor() nothrowGet whether the value referenced by value is a constructor. Returns: whether the value is a constructor.
bool isFunction() nothrowGet whether the value referenced by value is a function Returns: whether the value is a function.
bool isNull() nothrowGet whether the value referenced by value is <function>null</function>. Returns: whether the value is null.
bool isNumber() nothrowGet whether the value referenced by value is a number. Returns: whether the value is a number.
bool isObject() nothrowGet whether the value referenced by value is an object. Returns: whether the value is an object.
bool isString() nothrowGet whether the value referenced by value is a string Returns: whether the value is a string
bool isTypedArray() nothrowDetermines whether a value is a typed array. Returns: Whether value is a typed array.
bool isUndefined() nothrowGet whether the value referenced by value is <function>undefined</function>. Returns: whether the value is undefined.
javascriptcore.value.Value newTypedArrayWithBuffer(javascriptcore.types.TypedArrayType type, size_t offset, ptrdiff_t length) nothrowCreate a new typed array value with elements from an array buffer.
void objectDefinePropertyData(string propertyName, javascriptcore.types.ValuePropertyFlags flags, javascriptcore.value.Value propertyValue = null) nothrowDefine 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.
bool objectDeleteProperty(string name) nothrowTry to delete property with name from value. This function will return false if the property was defined without `JSC_VALUE_PROPERTY_CONFIGURABLE` flag.
string[] objectEnumerateProperties() nothrowGet the list of property names of value. Only properties defined with `JSC_VALUE_PROPERTY_ENUMERABLE` flag will be collected. Returns: a null-terminated array of strings containing the property nam...
javascriptcore.value.Value objectGetProperty(string name) nothrowGet property with name from value.
javascriptcore.value.Value objectGetPropertyAtIndex(uint index) nothrowGet property at index from value.
bool objectHasProperty(string name) nothrowGet whether value has property with name.
javascriptcore.value.Value objectInvokeMethod(string name, javascriptcore.value.Value[] parameters = null) nothrowInvoke 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 automatical...
bool objectIsInstanceOf(string name) nothrowGet whether the value referenced by value is an instance of class name.
void objectSetProperty(string name, javascriptcore.value.Value property) nothrowSet property with name on value.
void objectSetPropertyAtIndex(uint index, javascriptcore.value.Value property) nothrowSet property at index on value.
bool toBoolean() nothrowConvert value to a boolean. Returns: a #gboolean result of the conversion.
double toDouble() nothrowConvert value to a double. Returns: a #gdouble result of the conversion.
int toInt32() nothrowConvert value to a #gint32. Returns: a #gint32 result of the conversion.
string toJson(uint indent) nothrowCreate 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.
string toString_() nothrowConvert value to a string. Use [javascriptcore.value.Value.toStringAsBytes] instead, if you need to handle strings containing null characters. Returns: a null-terminated string result of the conver...
glib.bytes.Bytes toStringAsBytes() nothrowConvert value to a string and return the results as #GBytes. This is needed to handle strings with null characters. Returns: a #GBytes with the result of the conversion.
javascriptcore.value.Value typedArrayGetBuffer() nothrowObtain the `ArrayBuffer` for the memory region of the typed array elements. Returns: A #JSCValue
void * typedArrayGetData(out size_t length) nothrowObtains 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 conta...
size_t typedArrayGetLength() nothrowGets the number of elements in a typed array. Returns: number of elements.
size_t typedArrayGetOffset() nothrowGets the offset over the underlying array buffer data. Returns: offset, in bytes.
size_t typedArrayGetSize() nothrowGets the size of a typed array. Returns: size, in bytes.
javascriptcore.types.TypedArrayType typedArrayGetType() nothrowGets the type of elements contained in a typed array. Returns: type of the elements, or `JSC_TYPED_ARRAY_NONE` if value is not a typed array.
Constructors
this(void * ptr, Flag!"Take" take)

Fluent builder implementation template for javascriptcore.value.Value

Methods
T context(javascriptcore.context.Context propval) nothrowSet `context` property. Params: propval = The #JSCContext in which the value was created. Returns: Builder instance for fluent chaining

Fluent builder for javascriptcore.value.Value

Methods
Value build() nothrowCreate object from builder. Returns: New object

Functions 3

fnT getJsVal(T)(JSCValue * jsval) static nothrowTemplate to get a value from a JSCValue of a given D type (must contain the correct type) Params: T = D type which the C GValue structure contains jsval = C JSCValue structure pointer Returns: The ...
fnJSCValue * createJsVal(T)(JSCContext * ctx, T val) static nothrowTemplate to create a JSCValue from a given D value Params: T = D type to create the C JSCValue from ctx = The JSCContext to create the value in val = The value to create the JSCValue from Returns: ...
fnbool isValidJsVal(T)() nothrowCheck if a D type is a valid JS Value type (a value of the type can be created with createJsVal) Params: T = The D type Returns: true if createJsVal is supported for the type, false otherwise