| Copyright | Will Thompson and Iñaki García Etxebarria |
|---|---|
| License | LGPL-2.1 |
| Maintainer | Iñaki García Etxebarria |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
GI.JavaScriptCore.Objects.Value
Contents
- Exported types
- Methods
- arrayBufferGetData
- arrayBufferGetSize
- constructorCall
- functionCall
- getContext
- isArray
- isArrayBuffer
- isBoolean
- isConstructor
- isFunction
- isNull
- isNumber
- isObject
- isString
- isTypedArray
- isUndefined
- newArrayBuffer
- newArrayFromGarray
- newArrayFromStrv
- newBoolean
- newFromJson
- newFunction
- newFunctionVariadic
- newNull
- newNumber
- newObject
- newString
- newStringFromBytes
- newTypedArray
- newTypedArrayWithBuffer
- newUndefined
- objectDefinePropertyData
- objectDeleteProperty
- objectEnumerateProperties
- objectGetProperty
- objectGetPropertyAtIndex
- objectHasProperty
- objectInvokeMethod
- objectIsInstanceOf
- objectSetProperty
- objectSetPropertyAtIndex
- toBoolean
- toDouble
- toInt32
- toJson
- toString
- toStringAsBytes
- typedArrayGetBuffer
- typedArrayGetData
- typedArrayGetLength
- typedArrayGetOffset
- typedArrayGetSize
- typedArrayGetType
- Properties
Description
JSCValue represents a reference to a value in a Context. The JSCValue
protects the referenced value from being garbage collected.
Synopsis
- newtype Value = Value (ManagedPtr Value)
- class (GObject o, IsDescendantOf Value o) => IsValue o
- toValue :: (MonadIO m, IsValue o) => o -> m Value
- valueArrayBufferGetData :: (HasCallStack, MonadIO m, IsValue a) => a -> CSize -> m (Ptr ())
- valueArrayBufferGetSize :: (HasCallStack, MonadIO m, IsValue a) => a -> m CSize
- valueConstructorCall :: (HasCallStack, MonadIO m, IsValue a) => a -> Maybe [Value] -> m Value
- valueFunctionCall :: (HasCallStack, MonadIO m, IsValue a) => a -> Maybe [Value] -> m Value
- valueGetContext :: (HasCallStack, MonadIO m, IsValue a) => a -> m Context
- valueIsArray :: (HasCallStack, MonadIO m, IsValue a) => a -> m Bool
- valueIsArrayBuffer :: (HasCallStack, MonadIO m, IsValue a) => a -> m Bool
- valueIsBoolean :: (HasCallStack, MonadIO m, IsValue a) => a -> m Bool
- valueIsConstructor :: (HasCallStack, MonadIO m, IsValue a) => a -> m Bool
- valueIsFunction :: (HasCallStack, MonadIO m, IsValue a) => a -> m Bool
- valueIsNull :: (HasCallStack, MonadIO m, IsValue a) => a -> m Bool
- valueIsNumber :: (HasCallStack, MonadIO m, IsValue a) => a -> m Bool
- valueIsObject :: (HasCallStack, MonadIO m, IsValue a) => a -> m Bool
- valueIsString :: (HasCallStack, MonadIO m, IsValue a) => a -> m Bool
- valueIsTypedArray :: (HasCallStack, MonadIO m, IsValue a) => a -> m Bool
- valueIsUndefined :: (HasCallStack, MonadIO m, IsValue a) => a -> m Bool
- valueNewArrayBuffer :: (HasCallStack, MonadIO m, IsContext a) => a -> Ptr () -> CSize -> Maybe DestroyNotify -> m (Maybe Value)
- valueNewArrayFromGarray :: (HasCallStack, MonadIO m, IsContext a) => a -> Maybe [Value] -> m Value
- valueNewArrayFromStrv :: (HasCallStack, MonadIO m, IsContext a) => a -> [Text] -> m Value
- valueNewBoolean :: (HasCallStack, MonadIO m, IsContext a) => a -> Bool -> m Value
- valueNewFromJson :: (HasCallStack, MonadIO m, IsContext a) => a -> Text -> m Value
- valueNewFunction :: (HasCallStack, MonadIO m, IsContext a) => a -> Maybe Text -> Callback -> GType -> Maybe [GType] -> m Value
- valueNewFunctionVariadic :: (HasCallStack, MonadIO m, IsContext a) => a -> Maybe Text -> Callback -> GType -> m Value
- valueNewNull :: (HasCallStack, MonadIO m, IsContext a) => a -> m Value
- valueNewNumber :: (HasCallStack, MonadIO m, IsContext a) => a -> Double -> m Value
- valueNewObject :: (HasCallStack, MonadIO m, IsContext a, IsClass b) => a -> Ptr () -> Maybe b -> m Value
- valueNewString :: (HasCallStack, MonadIO m, IsContext a) => a -> Maybe Text -> m Value
- valueNewStringFromBytes :: (HasCallStack, MonadIO m, IsContext a) => a -> Maybe Bytes -> m Value
- valueNewTypedArray :: (HasCallStack, MonadIO m, IsContext a) => a -> TypedArrayType -> CSize -> m Value
- valueNewTypedArrayWithBuffer :: (HasCallStack, MonadIO m, IsValue a) => a -> TypedArrayType -> CSize -> Int64 -> m Value
- valueNewUndefined :: (HasCallStack, MonadIO m, IsContext a) => a -> m Value
- valueObjectDefinePropertyData :: (HasCallStack, MonadIO m, IsValue a, IsValue b) => a -> Text -> [ValuePropertyFlags] -> Maybe b -> m ()
- valueObjectDeleteProperty :: (HasCallStack, MonadIO m, IsValue a) => a -> Text -> m Bool
- valueObjectEnumerateProperties :: (HasCallStack, MonadIO m, IsValue a) => a -> m (Maybe [Text])
- valueObjectGetProperty :: (HasCallStack, MonadIO m, IsValue a) => a -> Text -> m Value
- valueObjectGetPropertyAtIndex :: (HasCallStack, MonadIO m, IsValue a) => a -> Word32 -> m Value
- valueObjectHasProperty :: (HasCallStack, MonadIO m, IsValue a) => a -> Text -> m Bool
- valueObjectInvokeMethod :: (HasCallStack, MonadIO m, IsValue a) => a -> Text -> Maybe [Value] -> m Value
- valueObjectIsInstanceOf :: (HasCallStack, MonadIO m, IsValue a) => a -> Text -> m Bool
- valueObjectSetProperty :: (HasCallStack, MonadIO m, IsValue a, IsValue b) => a -> Text -> b -> m ()
- valueObjectSetPropertyAtIndex :: (HasCallStack, MonadIO m, IsValue a, IsValue b) => a -> Word32 -> b -> m ()
- valueToBoolean :: (HasCallStack, MonadIO m, IsValue a) => a -> m Bool
- valueToDouble :: (HasCallStack, MonadIO m, IsValue a) => a -> m Double
- valueToInt32 :: (HasCallStack, MonadIO m, IsValue a) => a -> m Int32
- valueToJson :: (HasCallStack, MonadIO m, IsValue a) => a -> Word32 -> m Text
- valueToString :: (HasCallStack, MonadIO m, IsValue a) => a -> m Text
- valueToStringAsBytes :: (HasCallStack, MonadIO m, IsValue a) => a -> m Bytes
- valueTypedArrayGetBuffer :: (HasCallStack, MonadIO m, IsValue a) => a -> m Value
- valueTypedArrayGetData :: (HasCallStack, MonadIO m, IsValue a) => a -> m (Ptr (), CSize)
- valueTypedArrayGetLength :: (HasCallStack, MonadIO m, IsValue a) => a -> m CSize
- valueTypedArrayGetOffset :: (HasCallStack, MonadIO m, IsValue a) => a -> m CSize
- valueTypedArrayGetSize :: (HasCallStack, MonadIO m, IsValue a) => a -> m CSize
- valueTypedArrayGetType :: (HasCallStack, MonadIO m, IsValue a) => a -> m TypedArrayType
- constructValueContext :: (IsValue o, MonadIO m, IsContext a) => a -> m (GValueConstruct o)
- getValueContext :: (MonadIO m, IsValue o) => o -> m Context
Exported types
Memory-managed wrapper type.
Instances
| Eq Value Source # | |
| GObject Value Source # | |
Defined in GI.JavaScriptCore.Objects.Value | |
| ManagedPtrNewtype Value Source # | |
Defined in GI.JavaScriptCore.Objects.Value Methods toManagedPtr :: Value -> ManagedPtr Value | |
| TypedObject Value Source # | |
Defined in GI.JavaScriptCore.Objects.Value | |
| HasParentTypes Value Source # | |
Defined in GI.JavaScriptCore.Objects.Value | |
| IsGValue (Maybe Value) Source # | Convert |
Defined in GI.JavaScriptCore.Objects.Value Methods gvalueGType_ :: IO GType gvalueSet_ :: Ptr GValue -> Maybe Value -> IO () gvalueGet_ :: Ptr GValue -> IO (Maybe Value) | |
| type ParentTypes Value Source # | |
Defined in GI.JavaScriptCore.Objects.Value type ParentTypes Value = '[Object] | |
class (GObject o, IsDescendantOf Value o) => IsValue o Source #
Instances
| (GObject o, IsDescendantOf Value o) => IsValue o Source # | |
Defined in GI.JavaScriptCore.Objects.Value | |
Methods
Click to display all available methods, including inherited ones
Methods
arrayBufferGetData, arrayBufferGetSize, bindProperty, bindPropertyFull, constructorCall, forceFloating, freezeNotify, functionCall, getv, isArray, isArrayBuffer, isBoolean, isConstructor, isFloating, isFunction, isNull, isNumber, isObject, isString, isTypedArray, isUndefined, newTypedArrayWithBuffer, notify, notifyByPspec, objectDefinePropertyAccessor, objectDefinePropertyData, objectDeleteProperty, objectEnumerateProperties, objectGetProperty, objectGetPropertyAtIndex, objectHasProperty, objectInvokeMethod, objectIsInstanceOf, objectSetProperty, objectSetPropertyAtIndex, ref, refSink, runDispose, stealData, stealQdata, thawNotify, toBoolean, toDouble, toInt32, toJson, toString, toStringAsBytes, typedArrayGetBuffer, typedArrayGetData, typedArrayGetLength, typedArrayGetOffset, typedArrayGetSize, typedArrayGetType, unref, watchClosure.
Getters
getContext, getData, getProperty, getQdata.
Setters
arrayBufferGetData
valueArrayBufferGetData Source #
Arguments
| :: (HasCallStack, MonadIO m, IsValue a) | |
| => a |
|
| -> CSize |
|
| -> m (Ptr ()) | Returns: pointer to memory. |
Gets a pointer to memory that contains the array buffer data.
Obtains a pointer to the memory region that holds the contents of the
ArrayBuffer; modifications done to the data will be visible to JavaScript
code. If size is not Nothing, the size in bytes of the memory region
will also be stored in the pointed location.
Note that the pointer returned by this function is not guaranteed to remain
the same after calls to other JSC API functions. If you plan to access the
data of the ArrayBuffer later, you can keep a reference to the value and
obtain the data pointer at a later point. Keep in mind that if JavaScript
code has a chance to run, for example due to main loop events that result
in JSC being called, the contents of the memory region might be modified in
the meantime. Consider taking a copy of the data and using the copy instead
in asynchronous code.
Since: 2.38
arrayBufferGetSize
valueArrayBufferGetSize Source #
Arguments
| :: (HasCallStack, MonadIO m, IsValue a) | |
| => a |
|
| -> m CSize | Returns: size, in bytes. |
Gets the size in bytes of the array buffer.
Obtains the size in bytes of the memory region that holds the contents of
an ArrayBuffer.
Since: 2.38
constructorCall
Arguments
| :: (HasCallStack, MonadIO m, IsValue a) | |
| => a |
|
| -> Maybe [Value] |
|
| -> m Value | Returns: a |
Invoke <function>new</function> with constructor referenced by value. If nParameters
is 0 no parameters will be passed to the constructor.
functionCall
getContext
Arguments
| :: (HasCallStack, MonadIO m, IsValue a) | |
| => a |
|
| -> m Context | Returns: the |
Get the Context in which value was created.
isArray
Arguments
| :: (HasCallStack, MonadIO m, IsValue a) | |
| => a |
|
| -> m Bool | Returns: whether the value is an array. |
Get whether the value referenced by value is an array.
isArrayBuffer
Arguments
| :: (HasCallStack, MonadIO m, IsValue a) | |
| => a |
|
| -> m Bool | Returns: whether the value is an |
Check whether the value is an ArrayBuffer.
Since: 2.38
isBoolean
Arguments
| :: (HasCallStack, MonadIO m, IsValue a) | |
| => a |
|
| -> m Bool | Returns: whether the value is a boolean. |
Get whether the value referenced by value is a boolean.
isConstructor
Arguments
| :: (HasCallStack, MonadIO m, IsValue a) | |
| => a |
|
| -> m Bool | Returns: whether the value is a constructor. |
Get whether the value referenced by value is a constructor.
isFunction
Arguments
| :: (HasCallStack, MonadIO m, IsValue a) | |
| => a |
|
| -> m Bool | Returns: whether the value is a function. |
Get whether the value referenced by value is a function
isNull
Arguments
| :: (HasCallStack, MonadIO m, IsValue a) | |
| => a |
|
| -> m Bool | Returns: whether the value is null. |
Get whether the value referenced by value is <function>null</function>.
isNumber
Arguments
| :: (HasCallStack, MonadIO m, IsValue a) | |
| => a |
|
| -> m Bool | Returns: whether the value is a number. |
Get whether the value referenced by value is a number.
isObject
Arguments
| :: (HasCallStack, MonadIO m, IsValue a) | |
| => a |
|
| -> m Bool | Returns: whether the value is an object. |
Get whether the value referenced by value is an object.
isString
Arguments
| :: (HasCallStack, MonadIO m, IsValue a) | |
| => a |
|
| -> m Bool | Returns: whether the value is a string |
Get whether the value referenced by value is a string
isTypedArray
Arguments
| :: (HasCallStack, MonadIO m, IsValue a) | |
| => a |
|
| -> m Bool | Returns: Whether |
Determines whether a value is a typed array.
Since: 2.38
isUndefined
Arguments
| :: (HasCallStack, MonadIO m, IsValue a) | |
| => a |
|
| -> m Bool | Returns: whether the value is undefined. |
Get whether the value referenced by value is <function>undefined</function>.
newArrayBuffer
Arguments
| :: (HasCallStack, MonadIO m, IsContext a) | |
| => a |
|
| -> Ptr () |
|
| -> CSize |
|
| -> Maybe DestroyNotify |
|
| -> m (Maybe Value) |
Creates a new ArrayBuffer from existing data in memory.
The data is not copied: while this allows sharing data with JavaScript
efficiently, the caller must ensure that the memory region remains valid
until the newly created object is released by JSC.
Optionally, a destroyNotify callback can be provided, which will be
invoked with userData as parameter when the ArrayBuffer object is
released. This is intended to be used for freeing resources related to
the memory region which contains the data:
!<-- language="C" -->
GMappedFile *f = g_mapped_file_new (file_path, TRUE, NULL);
JSCValue *value = jsc_value_new_array_buffer (context,
g_mapped_file_get_contents (f), g_mapped_file_get_length (f),
(GDestroyNotify) g_mapped_file_unref, f);Note that the userData can be the same value as data:
!<-- language="C" --> void *bytes = g_malloc0 (100); JSCValue *value = jsc_value_new_array_buffer (context, bytes, 100, g_free, bytes);
Since: 2.38
newArrayFromGarray
newArrayFromStrv
newBoolean
Arguments
| :: (HasCallStack, MonadIO m, IsContext a) | |
| => a |
|
| -> Bool |
|
| -> m Value | Returns: a |
Create a new Value from value
newFromJson
Arguments
| :: (HasCallStack, MonadIO m, IsContext a) | |
| => a |
|
| -> Text |
|
| -> m Value | Returns: a |
Create a new Value referencing a new value created by parsing json.
Since: 2.28
newFunction
Arguments
| :: (HasCallStack, MonadIO m, IsContext a) | |
| => a |
|
| -> Maybe Text |
|
| -> Callback |
|
| -> GType |
|
| -> Maybe [GType] |
|
| -> m Value | Returns: a |
Create a function in context. If name is Nothing an anonymous function will be created.
When the function is called by JavaScript or jsc_value_function_call(), callback is called
receiving the function parameters and then userData as last parameter. When the function is
cleared in context, destroyNotify is called with userData as parameter.
Note that the value returned by callback must be fully transferred. In case of boxed types, you could use
G_TYPE_POINTER instead of the actual boxed GType to ensure that the instance owned by Class is used.
If you really want to return a new copy of the boxed type, use JSC_TYPE_VALUE and return a Value created
with valueNewObject that receives the copy as instance parameter.
newFunctionVariadic
valueNewFunctionVariadic Source #
Arguments
| :: (HasCallStack, MonadIO m, IsContext a) | |
| => a |
|
| -> Maybe Text |
|
| -> Callback |
|
| -> GType |
|
| -> m Value | Returns: a |
Create a function in context. If name is Nothing an anonymous function will be created.
When the function is called by JavaScript or jsc_value_function_call(), callback is called
receiving an PtrArray of Values with the arguments and then userData as last parameter.
When the function is cleared in context, destroyNotify is called with userData as parameter.
Note that the value returned by callback must be fully transferred. In case of boxed types, you could use
G_TYPE_POINTER instead of the actual boxed GType to ensure that the instance owned by Class is used.
If you really want to return a new copy of the boxed type, use JSC_TYPE_VALUE and return a Value created
with valueNewObject that receives the copy as instance parameter.
newNull
Arguments
| :: (HasCallStack, MonadIO m, IsContext a) | |
| => a |
|
| -> m Value | Returns: a |
Create a new Value referencing <function>null</function> in context.
newNumber
Arguments
| :: (HasCallStack, MonadIO m, IsContext a) | |
| => a |
|
| -> Double |
|
| -> m Value | Returns: a |
Create a new Value from number.
newObject
Arguments
| :: (HasCallStack, MonadIO m, IsContext a, IsClass b) | |
| => a |
|
| -> Ptr () |
|
| -> Maybe b |
|
| -> m Value | Returns: a |
Create a new Value from instance. If instance is Nothing a new empty object is created.
When instance is provided, jscClass must be provided too. jscClass takes ownership of
instance that will be freed by the DestroyNotify passed to contextRegisterClass.
newString
Arguments
| :: (HasCallStack, MonadIO m, IsContext a) | |
| => a |
|
| -> Maybe Text |
|
| -> m Value | Returns: a |
Create a new Value from string. If you need to create a Value from a
string containing null characters, use valueNewStringFromBytes instead.
newStringFromBytes
valueNewStringFromBytes Source #
Arguments
| :: (HasCallStack, MonadIO m, IsContext a) | |
| => a |
|
| -> Maybe Bytes |
|
| -> m Value | Returns: a |
Create a new Value from bytes.
newTypedArray
Arguments
| :: (HasCallStack, MonadIO m, IsContext a) | |
| => a |
|
| -> TypedArrayType |
|
| -> CSize |
|
| -> m Value | Returns: a |
Create a new typed array containing a given amount of elements.
Create a Value referencing a new typed array with space for length
elements of a given type. As all typed arrays must have an associated
ArrayBuffer, a new one of suitable size will be allocated to store
the elements, which will be initialized to zero.
The type must *not* be TypedArrayTypeNone.
Since: 2.38
newTypedArrayWithBuffer
valueNewTypedArrayWithBuffer Source #
Arguments
| :: (HasCallStack, MonadIO m, IsValue a) | |
| => a |
|
| -> TypedArrayType |
|
| -> CSize |
|
| -> Int64 |
|
| -> m Value | Returns: a |
Create a new typed array value with elements from an array buffer.
Create a Value referencing a new typed array value containing
elements of the given type, where the elements are stored at the memory
region represented by the arrayBuffer.
The type must *not* be TypedArrayTypeNone.
The offset and length parameters can be used to indicate which part of
the array buffer can be accessed through the typed array. If both are
omitted (passing zero as offset, and -1 as length), the whole
arrayBuffer is exposed through the typed array. Omitting the length
with a non-zero offset will expose the remainder of the arrayBuffer
starting at the indicated offset.
Since: 2.38
newUndefined
Arguments
| :: (HasCallStack, MonadIO m, IsContext a) | |
| => a |
|
| -> m Value | Returns: a |
Create a new Value referencing <function>undefined</function> in context.
objectDefinePropertyData
valueObjectDefinePropertyData Source #
Arguments
| :: (HasCallStack, MonadIO m, IsValue a, IsValue b) | |
| => a |
|
| -> Text |
|
| -> [ValuePropertyFlags] |
|
| -> Maybe b |
|
| -> m () |
Define or modify a property with propertyName in object referenced by value. This is equivalent to
JavaScript <function>Object.defineProperty()</function> when used with a data descriptor.
objectDeleteProperty
valueObjectDeleteProperty Source #
Arguments
| :: (HasCallStack, MonadIO m, IsValue a) | |
| => a |
|
| -> Text |
|
| -> m Bool | Returns: |
Try to delete property with name from value. This function will return False if
the property was defined without ValuePropertyFlagsConfigurable flag.
objectEnumerateProperties
valueObjectEnumerateProperties Source #
Arguments
| :: (HasCallStack, MonadIO m, IsValue a) | |
| => a |
|
| -> m (Maybe [Text]) | Returns: a |
Get the list of property names of value. Only properties defined with ValuePropertyFlagsEnumerable
flag will be collected.
objectGetProperty
valueObjectGetProperty Source #
Arguments
| :: (HasCallStack, MonadIO m, IsValue a) | |
| => a |
|
| -> Text |
|
| -> m Value | Returns: the property |
Get property with name from value.
objectGetPropertyAtIndex
valueObjectGetPropertyAtIndex Source #
Arguments
| :: (HasCallStack, MonadIO m, IsValue a) | |
| => a |
|
| -> Word32 |
|
| -> m Value | Returns: the property |
Get property at index from value.
objectHasProperty
valueObjectHasProperty Source #
Arguments
| :: (HasCallStack, MonadIO m, IsValue a) | |
| => a |
|
| -> Text |
|
| -> m Bool | Returns: |
Get whether value has property with name.
objectInvokeMethod
valueObjectInvokeMethod Source #
Arguments
| :: (HasCallStack, MonadIO m, IsValue a) | |
| => a |
|
| -> Text |
|
| -> Maybe [Value] |
|
| -> m Value | Returns: a |
Invoke method with name on object referenced by value, passing the given parameters. If
nParameters 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 jsc_class_add_method(), so it should never be passed explicitly as parameter
of this function.
This function always returns a Value, in case of void methods a Value referencing
<function>undefined</function> is returned.
objectIsInstanceOf
valueObjectIsInstanceOf Source #
Arguments
| :: (HasCallStack, MonadIO m, IsValue a) | |
| => a |
|
| -> Text |
|
| -> m Bool | Returns: whether the value is an object instance of class |
Get whether the value referenced by value is an instance of class name.
objectSetProperty
valueObjectSetProperty Source #
Arguments
| :: (HasCallStack, MonadIO m, IsValue a, IsValue b) | |
| => a |
|
| -> Text |
|
| -> b |
|
| -> m () |
Set property with name on value.
objectSetPropertyAtIndex
valueObjectSetPropertyAtIndex Source #
Arguments
| :: (HasCallStack, MonadIO m, IsValue a, IsValue b) | |
| => a |
|
| -> Word32 |
|
| -> b |
|
| -> m () |
Set property at index on value.
toBoolean
Arguments
| :: (HasCallStack, MonadIO m, IsValue a) | |
| => a |
|
| -> m Bool | Returns: a |
Convert value to a boolean.
toDouble
Arguments
| :: (HasCallStack, MonadIO m, IsValue a) | |
| => a |
|
| -> m Double | Returns: a |
Convert value to a double.
toInt32
Arguments
| :: (HasCallStack, MonadIO m, IsValue a) | |
| => a |
|
| -> m Int32 | Returns: a |
Convert value to a gint32.
toJson
Arguments
| :: (HasCallStack, MonadIO m, IsValue a) | |
| => a |
|
| -> Word32 |
|
| -> m Text | Returns: a null-terminated JSON string with serialization of |
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.
Since: 2.28
toString
Arguments
| :: (HasCallStack, MonadIO m, IsValue a) | |
| => a |
|
| -> m Text | Returns: a null-terminated string result of the conversion. |
Convert value to a string. Use valueToStringAsBytes instead, if you need to
handle strings containing null characters.
toStringAsBytes
Arguments
| :: (HasCallStack, MonadIO m, IsValue a) | |
| => a |
|
| -> m Bytes | Returns: a |
Convert value to a string and return the results as Bytes. This is needed
to handle strings with null characters.
typedArrayGetBuffer
valueTypedArrayGetBuffer Source #
Obtain the ArrayBuffer for the memory region of the typed array elements.
Since: 2.38
typedArrayGetData
valueTypedArrayGetData Source #
Arguments
| :: (HasCallStack, MonadIO m, IsValue a) | |
| => a |
|
| -> m (Ptr (), CSize) | Returns: pointer to memory. |
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 Nothing, the number of elements contained in the typed array
are also stored in the pointed location.
The returned pointer needs to be casted to the appropriate type (see
TypedArrayType), and has the offset over the underlying array
buffer data applied—that is, points to the first element of the typed
array:
C code
if (jsc_value_typed_array_get_type(value) != JSC_TYPED_ARRAY_UINT32)
g_error ("Only arrays of uint32_t are supported");
gsize count = 0;
uint32_t *elements = jsc_value_typed_array_get_contents (value, &count);
for (gsize i = 0; i < count; i++)
g_print ("index %zu, value %" PRIu32 "\n", i, elements[i]);Note that the pointer returned by this function is not guaranteed to remain
the same after calls to other JSC API functions. See
valueArrayBufferGetData for details.
Since: 2.38
typedArrayGetLength
valueTypedArrayGetLength Source #
Arguments
| :: (HasCallStack, MonadIO m, IsValue a) | |
| => a |
|
| -> m CSize | Returns: number of elements. |
Gets the number of elements in a typed array.
Since: 2.38
typedArrayGetOffset
valueTypedArrayGetOffset Source #
Arguments
| :: (HasCallStack, MonadIO m, IsValue a) | |
| => a |
|
| -> m CSize | Returns: offset, in bytes. |
Gets the offset over the underlying array buffer data.
Since: 2.38
typedArrayGetSize
valueTypedArrayGetSize Source #
Arguments
| :: (HasCallStack, MonadIO m, IsValue a) | |
| => a |
|
| -> m CSize | Returns: size, in bytes. |
Gets the size of a typed array.
Since: 2.38
typedArrayGetType
valueTypedArrayGetType Source #
Arguments
| :: (HasCallStack, MonadIO m, IsValue a) | |
| => a |
|
| -> m TypedArrayType | Returns: type of the elements, or |
Gets the type of elements contained in a typed array.
Since: 2.38
Properties
context
The Context in which the value was created.
constructValueContext :: (IsValue o, MonadIO m, IsContext a) => a -> m (GValueConstruct o) Source #
Construct a GValueConstruct with valid value for the “context” property. This is rarely needed directly, but it is used by new.
getValueContext :: (MonadIO m, IsValue o) => o -> m Context Source #
Get the value of the “context” property.
When overloading is enabled, this is equivalent to
get value #context