class JavaScriptCore::Value

Defined in:

lib/gi-crystal/src/auto/java_script_core-5.0/value.cr
bindings/alias.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from class GObject::Object

bind_property(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags) : GObject::Binding bind_property, bind_property_full(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags, transform_to : GObject::Closure, transform_from : GObject::Closure) : GObject::Binding bind_property_full, data(key : String) : Pointer(Void)? data, finalize finalize, freeze_notify : Nil freeze_notify, getv(names : Enumerable(String), values : Enumerable(_)) : Nil getv, notify(property_name : String) : Nil notify, notify_by_pspec(pspec : GObject::ParamSpec) : Nil notify_by_pspec, notify_signal notify_signal, property(property_name : String, value : _) : Nil property, qdata(quark : UInt32) : Pointer(Void)? qdata, ref_count : UInt32 ref_count, run_dispose : Nil run_dispose, set_data(key : String, data : Pointer(Void)?) : Nil set_data, set_property(property_name : String, value : _) : Nil set_property, steal_data(key : String) : Pointer(Void)? steal_data, steal_qdata(quark : UInt32) : Pointer(Void)? steal_qdata, thaw_notify : Nil thaw_notify, to_unsafe : Pointer(Void) to_unsafe, watch_closure(closure : GObject::Closure) : Nil watch_closure

Constructor methods inherited from class GObject::Object

cast(obj : GObject::Object) : self cast, cast?(obj : GObject::Object) : self? cast?, new(pointer : Pointer(Void), transfer : GICrystal::Transfer)
new
new
, newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter)) : self newv

Class methods inherited from class GObject::Object

compat_control(what : UInt64, data : Pointer(Void)?) : UInt64 compat_control, g_type : UInt64 g_type, interface_find_property(g_iface : GObject::TypeInterface, property_name : String) : GObject::ParamSpec interface_find_property, interface_list_properties(g_iface : GObject::TypeInterface) : Enumerable(GObject::ParamSpec) interface_list_properties

Constructor Detail

def self.new #

Initialize a new Value.


def self.new(*, context : JavaScriptCore::Context? = nil) #

def self.new_array_from_garray(context : JavaScriptCore::Context, array : Enumerable(JavaScriptCore::Value)?) : self #

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.


def self.new_array_from_strv(context : JavaScriptCore::Context, strv : Enumerable(String)) : self #

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.


def self.new_boolean(context : JavaScriptCore::Context, value : Bool) : self #

Create a new #JSCValue from @value


def self.new_from_json(context : JavaScriptCore::Context, json : String) : self #

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


def self.new_function(context : JavaScriptCore::Context, name : String?, callback : GObject::Callback, user_data : Pointer(Void)?, destroy_notify : GLib::DestroyNotify?, return_type : UInt64, parameter_types : Enumerable(UInt64)?) : self #

Create a function in @context. If @name is %NULL 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 @user_data as last parameter. When the function is cleared in @context, @destroy_notify is called with @user_data 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 #JSCClass is used. If you really want to return a new copy of the boxed type, use #JSC_TYPE_VALUE and return a #JSCValue created with jsc_value_new_object() that receives the copy as instance parameter.


def self.new_function_variadic(context : JavaScriptCore::Context, name : String?, callback : GObject::Callback, user_data : Pointer(Void)?, destroy_notify : GLib::DestroyNotify?, return_type : UInt64) : self #

Create a function in @context. If @name is %NULL an anonymous function will be created. When the function is called by JavaScript or jsc_value_function_call(), @callback is called receiving an #GPtrArray of #JSCValues with the arguments and then @user_data as last parameter. When the function is cleared in @context, @destroy_notify is called with @user_data 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 #JSCClass is used. If you really want to return a new copy of the boxed type, use #JSC_TYPE_VALUE and return a #JSCValue created with jsc_value_new_object() that receives the copy as instance parameter.


def self.new_null(context : JavaScriptCore::Context) : self #

Create a new #JSCValue referencing null in @context.


def self.new_number(context : JavaScriptCore::Context, number : Float64) : self #

Create a new #JSCValue from @number.


def self.new_object(context : JavaScriptCore::Context, instance : Pointer(Void)?, jsc_class : JavaScriptCore::Class?) : self #

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 jsc_context_register_class().


def self.new_string(context : JavaScriptCore::Context, string : String?) : self #

Create a new #JSCValue from @string. If you need to create a #JSCValue from a string containing null characters, use jsc_value_new_string_from_bytes() instead.


def self.new_string_from_bytes(context : JavaScriptCore::Context, bytes : GLib::Bytes?) : self #

Create a new #JSCValue from @bytes.


def self.new_undefined(context : JavaScriptCore::Context) : self #

Create a new #JSCValue referencing undefined in @context.


Class Method Detail

def self.g_type : UInt64 #

Returns the type id (GType) registered in GLib type system.


Instance Method Detail

def constructor_call(parameters : Enumerable(JavaScriptCore::Value)?) : JavaScriptCore::Value #

Invoke new with constructor referenced by @value. If @first_parameter_type is %G_TYPE_NONE no parameters will be passed to the constructor.


def constructor_call(*parameters : JavaScriptCore::Value) #

def context : JavaScriptCore::Context #

Get the #JSCContext in which @value was created.



def function_call(parameters : Enumerable(JavaScriptCore::Value)?) : JavaScriptCore::Value #

Call function referenced by @value, passing the given parameters. If @first_parameter_type is %G_TYPE_NONE no parameters will be passed to the function.

This function always returns a #JSCValue, in case of void functions a #JSCValue referencing undefined is returned


def function_call(*parameters : JavaScriptCore::Value) #

def is_array : Bool #

Get whether the value referenced by @value is an array.


def is_boolean : Bool #

Get whether the value referenced by @value is a boolean.


def is_constructor : Bool #

Get whether the value referenced by @value is a constructor.


def is_function : Bool #

Get whether the value referenced by @value is a function


def is_null : Bool #

Get whether the value referenced by @value is null.


def is_number : Bool #

Get whether the value referenced by @value is a number.


def is_object : Bool #

Get whether the value referenced by @value is an object.


def is_string : Bool #

Get whether the value referenced by @value is a string


def is_undefined : Bool #

Get whether the value referenced by @value is undefined.


def object_define_property_accessor(property_name : String, flags : JavaScriptCore::ValuePropertyFlags, property_type : UInt64, getter : GObject::Callback?, setter : GObject::Callback?) : Nil #

Define or modify a property with @property_name in object referenced by @value. When the property value needs to be getted or set, @getter and @setter callbacks will be called. When the property is cleared in the #JSCClass context, @destroy_notify is called with @user_data as parameter. This is equivalent to JavaScript Object.defineProperty() when used with an accessor descriptor.

Note that the value returned by @getter 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 #JSCClass is used. If you really want to return a new copy of the boxed type, use #JSC_TYPE_VALUE and return a #JSCValue created with jsc_value_new_object() that receives the copy as instance parameter.

Note that @getter and @setter are called as functions and not methods, so they don't receive an instance as first parameter. Use jsc_class_add_property() if you want to add property accessor invoked as a method.


def object_define_property_data(property_name : String, flags : JavaScriptCore::ValuePropertyFlags, property_value : JavaScriptCore::Value?) : Nil #

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


def object_delete_property(name : String) : Bool #

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


def object_enumerate_properties : Enumerable(String)? #

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


def object_get_property(name : String) : JavaScriptCore::Value #

Get property with @name from @value.


def object_get_property_at_index(index : UInt32) : JavaScriptCore::Value #

Get property at @index from @value.


def object_has_property(name : String) : Bool #

Get whether @value has property with @name.


def object_invoke_method(name : String, parameters : Enumerable(JavaScriptCore::Value)?) : JavaScriptCore::Value #

Invoke method with @name on object referenced by @value, passing the given parameters. If @first_parameter_type is %G_TYPE_NONE 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 #JSCValue, in case of void methods a #JSCValue referencing undefined is returned.


def object_is_instance_of(name : String) : Bool #

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


def object_set_property(name : String, property : JavaScriptCore::Value) : Nil #

Set @property with @name on @value.


def object_set_property_at_index(index : UInt32, property : JavaScriptCore::Value) : Nil #

Set @property at @index on @value.


def to_bool : Bool #

Same as .to_boolean.


def to_boolean : Bool #

Convert @value to a boolean.


def to_double : Float64 #

Convert @value to a double.


def to_f : Float64 #

Same as .to_double.


def to_i : Int32 #

Same as .to_int32.


def to_int32 : Int32 #

Convert @value to a #gint32.


def to_json(indent : UInt32) : String #

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.


def to_s : String #

Same as .to_string.


def to_string : String #

Convert @value to a string. Use jsc_value_to_string_as_bytes() instead, if you need to handle strings containing null characters.


def to_string_as_bytes : GLib::Bytes #

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