Safe Haskell | None |
---|---|
Language | Haskell2010 |
Haskell bindings for duktape, a very compact embedded ECMAScript (JavaScript) engine.
Concurrency note: you can't execute code with the same context from multiple threads in parallel. If you use the same context from multiple threads, only one will run at a time, others will block.
Synopsis
- type DuktapeCtx = MVar (ForeignPtr DuktapeHeap)
- createDuktapeCtx :: MonadIO μ => μ (Maybe DuktapeCtx)
- evalDuktape :: MonadIO μ => DuktapeCtx -> ByteString -> μ (Either String (Maybe Value))
- callDuktape :: MonadIO μ => DuktapeCtx -> Maybe ByteString -> ByteString -> [Value] -> μ (Either String (Maybe Value))
- exposeFnDuktape :: (MonadIO μ, Duktapeable ξ) => DuktapeCtx -> Maybe ByteString -> ByteString -> ξ -> μ (Either String ())
- class Duktapeable ξ
Documentation
type DuktapeCtx = MVar (ForeignPtr DuktapeHeap) Source #
createDuktapeCtx :: MonadIO μ => μ (Maybe DuktapeCtx) Source #
Creates a Duktape context.
evalDuktape :: MonadIO μ => DuktapeCtx -> ByteString -> μ (Either String (Maybe Value)) Source #
Evaluates a string of ECMAScript on a given Duktape context.
Note: a top level object, like {some: thing
}, is not a valid string to evaluate.
You'd need to at least wrap it in parens, like ({some: thing
}).
:: MonadIO μ | |
=> DuktapeCtx | |
-> Maybe ByteString | The name of the object that contains the function (Nothing is the global object) |
-> ByteString | The function name |
-> [Value] | The arguments |
-> μ (Either String (Maybe Value)) |
Calls an ECMAScript function on a given Duktape context, passing in arguments from the Haskell world.
:: (MonadIO μ, Duktapeable ξ) | |
=> DuktapeCtx | |
-> Maybe ByteString | The name of the object that will contain the function (Nothing is the global object) |
-> ByteString | The function name |
-> ξ | The function itself |
-> μ (Either String ()) |
Makes a Haskell function available in ECMAScript.
class Duktapeable ξ Source #
runInDuktape, argCount
Instances
Duktapeable (IO ()) Source # | |
Defined in Scripting.Duktape runInDuktape :: Int -> IO () -> Ptr DuktapeHeap -> IO CInt | |
ToJSON v => Duktapeable (IO v) Source # | |
Defined in Scripting.Duktape runInDuktape :: Int -> IO v -> Ptr DuktapeHeap -> IO CInt | |
(Duktapeable ξ, FromJSON v) => Duktapeable (v -> ξ) Source # | |
Defined in Scripting.Duktape runInDuktape :: Int -> (v -> ξ) -> Ptr DuktapeHeap -> IO CInt |