javascriptcore.context
Module for [Context] class
Types 3
classContext : gobject.object.ObjectWrap
JSCContext represents a JavaScript execution context, where all operations take place and where the values will be associated.
When a new context is created, a global object is allocated and the built-in JavaScript objects (Object, Function, String, Array) are populated. You can execute JavaScript in the context by using [javascriptcore.context.Context.evaluate] or [javascriptcore.context.Context.evaluateWithSourceUri]. It's also possible to register custom objects in the context with [javascriptcore.context.Context.registerClass].
Methods
ContextGidBuilder builder()Get builder for [javascriptcore.context.Context] Returns: New builder objectjavascriptcore.virtual_machine.VirtualMachine virtualMachine() @propertyGet `virtualMachine` property. Returns: The #JSCVirtualMachine in which the context was created.javascriptcore.context.Context newWithVirtualMachine(javascriptcore.virtual_machine.VirtualMachine vm)Create a new #JSCContext in virtual_machine.javascriptcore.context.Context getCurrent()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. Returns: the #JSCContext that is curren...javascriptcore.types.CheckSyntaxResult checkSyntax(string code, javascriptcore.types.CheckSyntaxMode mode, string uri, uint lineNumber, out javascriptcore.exception.ExceptionWrap exception)Check the given code in context for syntax errors. The linenumber is the starting line number in uri; the value is one-based so the first line is 1. uri and linenumber are only used to fill the exc...void clearException()Clear the uncaught exception in context if any.javascriptcore.value.Value evaluate(string code)Evaluate code in context.javascriptcore.value.Value evaluateInObject(string code, void * objectInstance, javascriptcore.class_.Class objectClass, string uri, uint lineNumber, out javascriptcore.value.Value object)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. Si...javascriptcore.value.Value evaluateWithSourceUri(string code, string uri, uint lineNumber)Evaluate code in context using uri as the source URI. The linenumber is the starting line number in uri; the value is one-based so the first line is 1. uri and linenumber will be shown in exception...javascriptcore.exception.ExceptionWrap getException()Get the last unhandled exception thrown in context by API functions calls. Returns: a #JSCException or null if there isn't any unhandled exception in the #JSCContext.javascriptcore.value.Value getGlobalObject()Get a #JSCValue referencing the context global object Returns: a #JSCValuejavascriptcore.value.Value getValue(string name)Get a property of context global object with name.javascriptcore.virtual_machine.VirtualMachine getVirtualMachine()Get the #JSCVirtualMachine where context was created. Returns: the #JSCVirtualMachine where the #JSCContext was created.void popExceptionHandler()Remove the last #JSCExceptionHandler previously pushed to context with [javascriptcore.context.Context.pushExceptionHandler].void pushExceptionHandler(javascriptcore.types.ExceptionHandler 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 [javascriptcore.con...javascriptcore.class_.Class registerClass(string name, javascriptcore.class_.Class parentClass, javascriptcore.types.ClassVTable vtable, glib.types.DestroyNotify destroyNotify = null)Register a custom class in context using the given name. If the new class inherits from another #JSCClass, the parent should be passed as parentclass, otherwise null should be used. The optional vt...void setValue(string name, javascriptcore.value.Value value)Set a property of context global object with name and value.void throw_(string errorMessage)Throw an exception to context using the given error message. The created #JSCException can be retrieved with [javascriptcore.context.Context.getException].void throwException(javascriptcore.exception.ExceptionWrap exception)Throw exception to context.void throwWithName(string errorName, string errorMessage)Throw an exception to context using the given error name and message. The created #JSCException can be retrieved with [javascriptcore.context.Context.getException].Methods
T virtualMachine(javascriptcore.virtual_machine.VirtualMachine propval)Set `virtualMachine` property. Params: propval = The #JSCVirtualMachine in which the context was created. Returns: Builder instance for fluent chaining