on master help sign in
Fix for ghcjs build
commit5c239aede5563a833c5f4ff5ae9005e422a28404 authorHamish Mackenzie <Hamish.K.Mackenzie@googlemail.com> dateFri 5 May 2017, 13:11 (9 years ago) parent675f74b
1 file changed+6−5
jsaddle/src/Language/Javascript/JSaddle/Object.hs+6−5
jsaddle/src/Language/Javascript/JSaddle/Object.hs+6−5
@@ -103,7 +103,7 @@ import Data.Coerce (coerce)
103103#ifdef ghcjs_HOST_OS
104104import GHCJS.Types (nullRef)
105105import GHCJS.Foreign.Callback
106− (releaseCallback, syncCallback2, OnBlocked(..), Callback)
106+ (releaseCallback, syncCallback2, asyncCallback2, OnBlocked(..), Callback)
107107import GHCJS.Marshal (ToJSVal(..))
108108import JavaScript.Array (MutableJSArray)
109109import qualified JavaScript.Array as Array (toListIO, fromListIO)
@@ -436,6 +436,11 @@ newtype Function = Function {functionObject :: Object}
436436#endif
437437
438438
439+#ifdef ghcjs_HOST_OS
440+foreign import javascript unsafe "$r = function () { $1(this, arguments); }"
441+ makeFunctionWithCallback :: Callback (JSVal -> JSVal -> IO ()) -> IO Object
442+#endif
443+
439444-- ^ Make a JavaScript function object that wraps a Haskell function.
440445-- Calls made to the function will be synchronous where possible
441446-- (on GHCJS it uses on `syncCallback2` with `ContinueAsync`).
@@ -448,8 +453,6 @@ function f = do
448453 rargs <- Array.toListIO (coerce args)
449454 f this this rargs -- TODO pass function object through
450455 Function callback <$> makeFunctionWithCallback callback
451−foreign import javascript unsafe "$r = function () { $1(this, arguments); }"
452− makeFunctionWithCallback :: Callback (JSVal -> JSVal -> IO ()) -> IO Object
453456#else
454457function f = do
455458 object <- newSyncCallback f
@@ -467,8 +470,6 @@ asyncFunction f = do
467470 rargs <- Array.toListIO (coerce args)
468471 f this this rargs -- TODO pass function object through
469472 Function callback <$> makeFunctionWithCallback callback
470−foreign import javascript unsafe "$r = function () { $1(this, arguments); }"
471− makeFunctionWithCallback :: Callback (JSVal -> JSVal -> IO ()) -> IO Object
472473#else
473474asyncFunction f = do
474475 object <- newAsyncCallback f