javascriptcore.value
Module for [Value] class
Types 3
classValue : gobject.object.ObjectWrap
JSCValue represents a reference to a value in a #JSCContext. The JSCValue protects the referenced value from being garbage collected.
Methods
ValueGidBuilder builder() static nothrowGet builder for [javascriptcore.value.Value] Returns: New builder objectjavascriptcore.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 typeValue 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 Valuejavascriptcore.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 valuejavascriptcore.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.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 stringbool 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 objectGetPropertyAtIndex(uint index) nothrowGet property at index from value.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.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 #JSCValuevoid * 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.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.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 chainingFluent builder for javascriptcore.value.Value
Functions 3
fn
T 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 ...fn
JSCValue * 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: ...fn
bool 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