@@ -45,6 +45,7 @@ import Control.Monad.Trans.Reader (ask)
4545import Language.Javascript.JSaddle.Value (JSVal)
4646import Language.Javascript.JSaddle.Arguments ()
4747import Language.Javascript.JSaddle.String ()
48+import Control.Monad.IO.Class (MonadIO(..))
4849
4950-- | Get a property value given the object and the name of the property.
5051objGetPropertyByName :: ToJSString name
@@ -52,14 +53,14 @@ objGetPropertyByName :: ToJSString name
5253 -> name -- ^ name of the property.
5354 -> JSM JSVal -- ^ returns the property value.
5455#ifdef ghcjs_HOST_OS
55−objGetPropertyByName this name = liftIO . js_tryGetProp (toJSString name) this
56−foreign import javascript unsafe "try { $r=$2[$1] } catch(e) { $3[0] = e }"
57− js_tryGetProp :: JSString -> Object -> MutableJSArray -> IO JSVal
56+objGetPropertyByName this name = liftIO $ js_tryGetProp (toJSString name) this
57+foreign import javascript unsafe "$r=$2[$1]"
58+ js_tryGetProp :: JSString -> Object -> IO JSVal
5859#else
59−objGetPropertyByName this name = do
60− let name' = toJSString name
60+objGetPropertyByName this name =
6161 withObject this $ \rthis ->
62− withJSString name' $ sendLazyCommand . GetPropertyByName rthis
62+ withJSString (toJSString name) $
63+ sendLazyCommand . GetPropertyByName rthis
6364#endif
6465
6566-- | Get a property value given the object and the index of the property.
@@ -67,9 +68,9 @@ objGetPropertyAtIndex :: Object -- ^ object to find the property on.
6768 -> Index -- ^ index of the property.
6869 -> JSM JSVal -- ^ returns the property value.
6970#ifdef ghcjs_HOST_OS
70−objGetPropertyAtIndex this index = liftIO . js_tryIndex index this
71−foreign import javascript unsafe "try { $r=$2[$1] } catch(e) { $3[0] = e }"
72− js_tryIndex :: Index -> Object -> MutableJSArray -> IO JSVal
71+objGetPropertyAtIndex this index = liftIO $ js_tryIndex index this
72+foreign import javascript unsafe "$r=$2[$1]"
73+ js_tryIndex :: Index -> Object -> IO JSVal
7374#else
7475objGetPropertyAtIndex this index =
7576 withObject this $ \rthis -> sendLazyCommand $ GetPropertyAtIndex rthis index
@@ -85,8 +86,8 @@ objSetPropertyByName :: (ToJSString name, ToJSVal val)
8586objSetPropertyByName this name val = do
8687 vref <- toJSVal val
8788 liftIO $ js_trySetProp (toJSString name) this vref
88−foreign import javascript unsafe "try { $2[$1]=$3 } catch(e) { $4[0] = e }"
89− js_trySetProp :: JSString -> Object -> JSVal -> MutableJSArray -> IO ()
89+foreign import javascript unsafe "$2[$1]=$3"
90+ js_trySetProp :: JSString -> Object -> JSVal -> IO ()
9091#else
9192objSetPropertyByName this name val = do
9293 let name' = toJSString name
@@ -106,8 +107,8 @@ objSetPropertyAtIndex :: (ToJSVal val)
106107objSetPropertyAtIndex this index val = do
107108 vref <- toJSVal val
108109 liftIO $ js_trySetAtIndex index this vref
109−foreign import javascript unsafe "try { $2[$1]=$3 } catch(e) { $4[0] = e }"
110− js_trySetAtIndex :: Index -> Object -> JSVal -> MutableJSArray -> IO ()
110+foreign import javascript unsafe "$2[$1]=$3"
111+ js_trySetAtIndex :: Index -> Object -> JSVal -> IO ()
111112#else
112113objSetPropertyAtIndex this index val = do
113114 gctxt <- ask