@@ -103,7 +103,7 @@ import Data.Coerce (coerce)
103#ifdef ghcjs_HOST_OS
103#ifdef ghcjs_HOST_OS
104import GHCJS.Types (nullRef)
104import GHCJS.Types (nullRef)
105import GHCJS.Foreign.Callback
105import GHCJS.Foreign.Callback
106− (releaseCallback, syncCallback2, OnBlocked(..), Callback)
106+ (releaseCallback, syncCallback2, asyncCallback2, OnBlocked(..), Callback)
107import GHCJS.Marshal (ToJSVal(..))
107import GHCJS.Marshal (ToJSVal(..))
108import JavaScript.Array (MutableJSArray)
108import JavaScript.Array (MutableJSArray)
109import qualified JavaScript.Array as Array (toListIO, fromListIO)
109import qualified JavaScript.Array as Array (toListIO, fromListIO)
@@ -436,6 +436,11 @@ newtype Function = Function {functionObject :: Object}
440+foreign import javascript unsafe "$r = function () { $1(this, arguments); }"
441+ makeFunctionWithCallback :: Callback (JSVal -> JSVal -> IO ()) -> IO Object
439-- ^ Make a JavaScript function object that wraps a Haskell function.
444-- ^ Make a JavaScript function object that wraps a Haskell function.
440-- Calls made to the function will be synchronous where possible
445-- Calls made to the function will be synchronous where possible
441-- (on GHCJS it uses on `syncCallback2` with `ContinueAsync`).
446-- (on GHCJS it uses on `syncCallback2` with `ContinueAsync`).
@@ -448,8 +453,6 @@ function f = do
448 rargs <- Array.toListIO (coerce args)
453 rargs <- Array.toListIO (coerce args)
449 f this this rargs -- TODO pass function object through
454 f this this rargs -- TODO pass function object through
450 Function callback <$> makeFunctionWithCallback callback
455 Function callback <$> makeFunctionWithCallback callback
451−foreign import javascript unsafe "$r = function () { $1(this, arguments); }"
452− makeFunctionWithCallback :: Callback (JSVal -> JSVal -> IO ()) -> IO Object
454function f = do
457function f = do
455 object <- newSyncCallback f
458 object <- newSyncCallback f
@@ -467,8 +470,6 @@ asyncFunction f = do
467 rargs <- Array.toListIO (coerce args)
470 rargs <- Array.toListIO (coerce args)
468 f this this rargs -- TODO pass function object through
471 f this this rargs -- TODO pass function object through
469 Function callback <$> makeFunctionWithCallback callback
472 Function callback <$> makeFunctionWithCallback callback
470−foreign import javascript unsafe "$r = function () { $1(this, arguments); }"
471− makeFunctionWithCallback :: Callback (JSVal -> JSVal -> IO ()) -> IO Object
473asyncFunction f = do
474asyncFunction f = do
474 object <- newAsyncCallback f
475 object <- newAsyncCallback f