class JavaScriptCore::Context
- JavaScriptCore::Context
- GObject::Object
- Reference
- Object
Defined in:
lib/gi-crystal/src/auto/java_script_core-5.0/context.crConstructors
-
.new : self
Create a new #JSCContext.
- .new(*, virtual_machine : JavaScriptCore::VirtualMachine? = nil)
-
.new_with_virtual_machine(vm : JavaScriptCore::VirtualMachine) : self
Create a new #JSCContext in @virtual_machine.
Class Method Summary
-
.current : JavaScriptCore::Context?
Get the #JSCContext that is currently executing a function.
-
.g_type : UInt64
Returns the type id (GType) registered in GLib type system.
Instance Method Summary
-
#check_syntax(code : String, length : Int64, mode : JavaScriptCore::CheckSyntaxMode, uri : String, line_number : UInt32) : JavaScriptCore::CheckSyntaxResult
Check the given @code in @context for syntax errors.
-
#clear_exception : Nil
Clear the uncaught exception in @context if any.
-
#evaluate(code : String, length : Int64) : JavaScriptCore::Value
Evaluate @code in @context.
-
#evaluate_in_object(code : String, length : Int64, object_instance : Pointer(Void)?, object_class : JavaScriptCore::Class?, uri : String, line_number : UInt32, object : JavaScriptCore::Value) : JavaScriptCore::Value
Evaluate @code and create an new object where symbols defined in @code will be added as properties, instead of being added to @context global object.
-
#evaluate_with_source_uri(code : String, length : Int64, uri : String, line_number : UInt32) : JavaScriptCore::Value
Evaluate @code in @context using @uri as the source URI.
-
#exception : JavaScriptCore::Exception?
Get the last unhandled exception thrown in @context by API functions calls.
-
#global_object : JavaScriptCore::Value
Get a #JSCValue referencing the @context global object
-
#pop_exception_handler : Nil
Remove the last #JSCExceptionHandler previously pushed to @context with jsc_context_push_exception_handler().
-
#push_exception_handler(handler : JavaScriptCore::ExceptionHandler) : Nil
Push an exception handler in @context.
-
#register_class(name : String, parent_class : JavaScriptCore::Class?, vtable : JavaScriptCore::ClassVTable?, destroy_notify : GLib::DestroyNotify?) : JavaScriptCore::Class
Register a custom class in @context using the given @name.
-
#set_value(name : String, value : JavaScriptCore::Value) : Nil
Set a property of @context global object with @name and @value.
-
#throw(error_message : String) : Nil
Throw an exception to @context using the given error message.
-
#throw_exception(exception : JavaScriptCore::Exception) : Nil
Throw @exception to @context.
-
#throw_with_name(error_name : String, error_message : String) : Nil
Throw an exception to @context using the given error name and message.
-
#value(name : String) : JavaScriptCore::Value
Get a property of @context global object with @name.
-
#virtual_machine : JavaScriptCore::VirtualMachine
Get the #JSCVirtualMachine where @context was created.
- #virtual_machine=(value : JavaScriptCore::VirtualMachine?) : JavaScriptCore::VirtualMachine?
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
Create a new #JSCContext. The context is created in a new #JSCVirtualMachine. Use jsc_context_new_with_virtual_machine() to create a new #JSCContext in an existing #JSCVirtualMachine.
Create a new #JSCContext in @virtual_machine.
Class Method Detail
Get the #JSCContext that is currently executing a function. This should only be called within a function or method callback, otherwise %NULL will be returned.
Instance Method Detail
Check the given @code in @context for syntax errors. The @line_number is the starting line number in @uri; the value is one-based so the first line is 1. @uri and @line_number are only used to fill the @exception. In case of errors @exception will be set to a new #JSCException with the details. You can pass %NULL to @exception to ignore the error details.
Evaluate @code and create an new object where symbols defined in @code will be added as properties, instead of being added to @context global object. The new object is returned as @object parameter. Similar to how jsc_value_new_object() works, if @object_instance is not %NULL @object_class must be provided too. The @line_number is the starting line number in @uri; the value is one-based so the first line is 1. @uri and @line_number will be shown in exceptions and they don't affect the behavior of the script.
Evaluate @code in @context using @uri as the source URI. The @line_number is the starting line number in @uri; the value is one-based so the first line is 1. @uri and @line_number will be shown in exceptions and they don't affect the behavior of the script.
Get the last unhandled exception thrown in @context by API functions calls.
Remove the last #JSCExceptionHandler previously pushed to @context with jsc_context_push_exception_handler().
Push an exception handler in @context. Whenever a JavaScript exception happens in the #JSCContext, the given @handler will be called. The default #JSCExceptionHandler simply calls jsc_context_throw_exception() to throw the exception to the #JSCContext. If you don't want to catch the exception, but only get notified about it, call jsc_context_throw_exception() in @handler like the default one does. The last exception handler pushed is the only one used by the #JSCContext, use jsc_context_pop_exception_handler() to remove it and set the previous one. When @handler is removed from the context, @destroy_notify i called with @user_data as parameter.
Register a custom class in @context using the given @name. If the new class inherits from another #JSCClass, the parent should be passed as @parent_class, otherwise %NULL should be used. The optional @vtable parameter allows to provide a custom implementation for handling the class, for example, to handle external properties not added to the prototype. When an instance of the #JSCClass is cleared in the context, @destroy_notify is called with the instance as parameter.
Set a property of @context global object with @name and @value.
Throw an exception to @context using the given error message. The created #JSCException can be retrieved with jsc_context_get_exception().
Throw an exception to @context using the given error name and message. The created #JSCException can be retrieved with jsc_context_get_exception().
Get a property of @context global object with @name.
Get the #JSCVirtualMachine where @context was created.