gi-javascriptcore-4.0.23: JavaScriptCore bindings
CopyrightWill Thompson Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellSafe-Inferred
LanguageHaskell2010

GI.JavaScriptCore.Objects.Context

Description

No description available in the introspection data.

Synopsis

Exported types

newtype Context Source #

Memory-managed wrapper type.

Constructors

Context (ManagedPtr Context) 

Instances

Instances details
Eq Context Source # 
Instance details

Defined in GI.JavaScriptCore.Objects.Context

Methods

(==) :: Context -> Context -> Bool #

(/=) :: Context -> Context -> Bool #

GObject Context Source # 
Instance details

Defined in GI.JavaScriptCore.Objects.Context

ManagedPtrNewtype Context Source # 
Instance details

Defined in GI.JavaScriptCore.Objects.Context

Methods

toManagedPtr :: Context -> ManagedPtr Context

TypedObject Context Source # 
Instance details

Defined in GI.JavaScriptCore.Objects.Context

Methods

glibType :: IO GType

HasParentTypes Context Source # 
Instance details

Defined in GI.JavaScriptCore.Objects.Context

IsGValue (Maybe Context) Source #

Convert Context to and from GValue. See toGValue and fromGValue.

Instance details

Defined in GI.JavaScriptCore.Objects.Context

Methods

gvalueGType_ :: IO GType

gvalueSet_ :: Ptr GValue -> Maybe Context -> IO ()

gvalueGet_ :: Ptr GValue -> IO (Maybe Context)

type ParentTypes Context Source # 
Instance details

Defined in GI.JavaScriptCore.Objects.Context

type ParentTypes Context = '[Object]

class (GObject o, IsDescendantOf Context o) => IsContext o Source #

Type class for types which can be safely cast to Context, for instance with toContext.

Instances

Instances details
(GObject o, IsDescendantOf Context o) => IsContext o Source # 
Instance details

Defined in GI.JavaScriptCore.Objects.Context

toContext :: (MonadIO m, IsContext o) => o -> m Context Source #

Cast to Context, for types for which this is known to be safe. For general casts, use castTo.

Methods

checkSyntax

contextCheckSyntax Source #

Arguments

:: (HasCallStack, MonadIO m, IsContext a) 
=> a

context: a Context

-> Text

code: a JavaScript script to check

-> Int64

length: length of code, or -1 if code is a nul-terminated string

-> CheckSyntaxMode

mode: a CheckSyntaxMode

-> Text

uri: the source URI

-> Word32

lineNumber: the starting line number

-> m (CheckSyntaxResult, Exception)

Returns: a CheckSyntaxResult

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 exception. In case of errors exception will be set to a new Exception with the details. You can pass Nothing to exception to ignore the error details.

clearException

contextClearException Source #

Arguments

:: (HasCallStack, MonadIO m, IsContext a) 
=> a

context: a Context

-> m () 

Clear the uncaught exception in context if any.

evaluate

contextEvaluate Source #

Arguments

:: (HasCallStack, MonadIO m, IsContext a) 
=> a

context: a Context

-> Text

code: a JavaScript script to evaluate

-> Int64

length: length of code, or -1 if code is a nul-terminated string

-> m Value

Returns: a Value representing the last value generated by the script.

Evaluate code in context.

evaluateInObject

contextEvaluateInObject Source #

Arguments

:: (HasCallStack, MonadIO m, IsContext a, IsClass b) 
=> a

context: a Context

-> Text

code: a JavaScript script to evaluate

-> Int64

length: length of code, or -1 if code is a nul-terminated string

-> Ptr ()

objectInstance: an object instance

-> Maybe b

objectClass: a Class or Nothing to use the default

-> Text

uri: the source URI

-> Word32

lineNumber: the starting line number

-> m (Value, Value)

Returns: a Value representing the last value generated by the script.

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 valueNewObject works, if objectInstance is not Nothing objectClass must be provided too. 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 exceptions and they don't affect the behavior of the script.

evaluateWithSourceUri

contextEvaluateWithSourceUri Source #

Arguments

:: (HasCallStack, MonadIO m, IsContext a) 
=> a

context: a Context

-> Text

code: a JavaScript script to evaluate

-> Int64

length: length of code, or -1 if code is a nul-terminated string

-> Text

uri: the source URI

-> Word32

lineNumber: the starting line number

-> m Value

Returns: a Value representing the last value generated by the script.

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 exceptions and they don't affect the behavior of the script.

getCurrent

contextGetCurrent Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> m (Maybe Context)

Returns: the Context that is currently executing.

Get the Context that is currently executing a function. This should only be called within a function or method callback, otherwise Nothing will be returned.

getException

contextGetException Source #

Arguments

:: (HasCallStack, MonadIO m, IsContext a) 
=> a

context: a Context

-> m (Maybe Exception)

Returns: a Exception or Nothing if there isn't any unhandled exception in the Context.

Get the last unhandled exception thrown in context by API functions calls.

getGlobalObject

contextGetGlobalObject Source #

Arguments

:: (HasCallStack, MonadIO m, IsContext a) 
=> a

context: a Context

-> m Value

Returns: a Value

Get a Value referencing the context global object

getValue

contextGetValue Source #

Arguments

:: (HasCallStack, MonadIO m, IsContext a) 
=> a

context: a Context

-> Text

name: the value name

-> m Value

Returns: a Value

Get a property of context global object with name.

getVirtualMachine

contextGetVirtualMachine Source #

Arguments

:: (HasCallStack, MonadIO m, IsContext a) 
=> a

context: a Context

-> m VirtualMachine

Returns: the VirtualMachine where the Context was created.

Get the VirtualMachine where context was created.

new

contextNew Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> m Context

Returns: the newly created Context.

Create a new Context. The context is created in a new VirtualMachine. Use contextNewWithVirtualMachine to create a new Context in an existing VirtualMachine.

newWithVirtualMachine

contextNewWithVirtualMachine Source #

Arguments

:: (HasCallStack, MonadIO m, IsVirtualMachine a) 
=> a

vm: a VirtualMachine

-> m Context

Returns: the newly created Context.

Create a new Context in virtualMachine.

popExceptionHandler

contextPopExceptionHandler Source #

Arguments

:: (HasCallStack, MonadIO m, IsContext a) 
=> a

context: a Context

-> m () 

Remove the last ExceptionHandler previously pushed to context with contextPushExceptionHandler.

pushExceptionHandler

contextPushExceptionHandler Source #

Arguments

:: (HasCallStack, MonadIO m, IsContext a) 
=> a

context: a Context

-> ExceptionHandler

handler: a ExceptionHandler

-> m () 

Push an exception handler in context. Whenever a JavaScript exception happens in the Context, the given handler will be called. The default ExceptionHandler simply calls contextThrowException to throw the exception to the Context. If you don't want to catch the exception, but only get notified about it, call contextThrowException in handler like the default one does. The last exception handler pushed is the only one used by the Context, use contextPopExceptionHandler to remove it and set the previous one. When handler is removed from the context, destroyNotify i called with userData as parameter.

registerClass

contextRegisterClass Source #

Arguments

:: (HasCallStack, MonadIO m, IsContext a, IsClass b) 
=> a

context: a Context

-> Text

name: the class name

-> Maybe b

parentClass: a Class or Nothing

-> Maybe ClassVTable

vtable: an optional ClassVTable or Nothing

-> Maybe DestroyNotify

destroyNotify: a destroy notifier for class instances

-> m Class

Returns: a Class

Register a custom class in context using the given name. If the new class inherits from another Class, the parent should be passed as parentClass, otherwise Nothing 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 Class is cleared in the context, destroyNotify is called with the instance as parameter.

setValue

contextSetValue Source #

Arguments

:: (HasCallStack, MonadIO m, IsContext a, IsValue b) 
=> a

context: a Context

-> Text

name: the value name

-> b

value: a Value

-> m () 

Set a property of context global object with name and value.

throw

contextThrow Source #

Arguments

:: (HasCallStack, MonadIO m, IsContext a) 
=> a

context: a Context

-> Text

errorMessage: an error message

-> m () 

Throw an exception to context using the given error message. The created Exception can be retrieved with contextGetException.

throwException

contextThrowException Source #

Arguments

:: (HasCallStack, MonadIO m, IsContext a, IsException b) 
=> a

context: a Context

-> b

exception: a Exception

-> m () 

Throw exception to context.

throwWithName

contextThrowWithName Source #

Arguments

:: (HasCallStack, MonadIO m, IsContext a) 
=> a

context: a Context

-> Text

errorName: the error name

-> Text

errorMessage: an error message

-> m () 

Throw an exception to context using the given error name and message. The created Exception can be retrieved with contextGetException.

Properties

virtualMachine

The VirtualMachine in which the context was created.

constructContextVirtualMachine :: (IsContext o, MonadIO m, IsVirtualMachine a) => a -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “virtual-machine” property. This is rarely needed directly, but it is used by new.

getContextVirtualMachine :: (MonadIO m, IsContext o) => o -> m VirtualMachine Source #

Get the value of the “virtual-machine” property. When overloading is enabled, this is equivalent to

get context #virtualMachine