@@ -45,6 +45,7 @@ import Control.Monad.Trans.Reader (ask)
45import Language.Javascript.JSaddle.Value (JSVal)
45import Language.Javascript.JSaddle.Value (JSVal)
46import Language.Javascript.JSaddle.Arguments ()
46import Language.Javascript.JSaddle.Arguments ()
47import Language.Javascript.JSaddle.String ()
47import Language.Javascript.JSaddle.String ()
48+import Control.Monad.IO.Class (MonadIO(..))
49-- | Get a property value given the object and the name of the property.
50-- | Get a property value given the object and the name of the property.
50objGetPropertyByName :: ToJSString name
51objGetPropertyByName :: ToJSString name
@@ -52,14 +53,14 @@ objGetPropertyByName :: ToJSString name
52 -> name -- ^ name of the property.
53 -> name -- ^ name of the property.
53 -> JSM JSVal -- ^ returns the property value.
54 -> JSM JSVal -- ^ returns the property value.
54#ifdef ghcjs_HOST_OS
55#ifdef ghcjs_HOST_OS
55−objGetPropertyByName this name = liftIO . js_tryGetProp (toJSString name) this
56+objGetPropertyByName this name = liftIO $ js_tryGetProp (toJSString name) this
56−foreign import javascript unsafe "try { $r=$2[$1] } catch(e) { $3[0] = e }"
57+foreign import javascript unsafe "$r=$2[$1]"
57− js_tryGetProp :: JSString -> Object -> MutableJSArray -> IO JSVal
58+ js_tryGetProp :: JSString -> Object -> IO JSVal
59−objGetPropertyByName this name = do
60+objGetPropertyByName this name =
60− let name' = toJSString name
61 withObject this $ \rthis ->
61 withObject this $ \rthis ->
62+ withJSString (toJSString name) $
62− withJSString name' $ sendLazyCommand . GetPropertyByName rthis
63+ sendLazyCommand . GetPropertyByName rthis
65-- | Get a property value given the object and the index of the property.
66-- | 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.
67 -> Index -- ^ index of the property.
68 -> Index -- ^ index of the property.
68 -> JSM JSVal -- ^ returns the property value.
69 -> JSM JSVal -- ^ returns the property value.
69#ifdef ghcjs_HOST_OS
70#ifdef ghcjs_HOST_OS
70−objGetPropertyAtIndex this index = liftIO . js_tryIndex index this
71+objGetPropertyAtIndex this index = liftIO $ js_tryIndex index this
71−foreign import javascript unsafe "try { $r=$2[$1] } catch(e) { $3[0] = e }"
72+foreign import javascript unsafe "$r=$2[$1]"
72− js_tryIndex :: Index -> Object -> MutableJSArray -> IO JSVal
73+ js_tryIndex :: Index -> Object -> IO JSVal
74objGetPropertyAtIndex this index =
75objGetPropertyAtIndex this index =
75 withObject this $ \rthis -> sendLazyCommand $ GetPropertyAtIndex rthis index
76 withObject this $ \rthis -> sendLazyCommand $ GetPropertyAtIndex rthis index
@@ -85,8 +86,8 @@ objSetPropertyByName :: (ToJSString name, ToJSVal val)
85objSetPropertyByName this name val = do
86objSetPropertyByName this name val = do
86 vref <- toJSVal val
87 vref <- toJSVal val
87 liftIO $ js_trySetProp (toJSString name) this vref
88 liftIO $ js_trySetProp (toJSString name) this vref
88−foreign import javascript unsafe "try { $2[$1]=$3 } catch(e) { $4[0] = e }"
89+foreign import javascript unsafe "$2[$1]=$3"
89− js_trySetProp :: JSString -> Object -> JSVal -> MutableJSArray -> IO ()
90+ js_trySetProp :: JSString -> Object -> JSVal -> IO ()
91objSetPropertyByName this name val = do
92objSetPropertyByName this name val = do
92 let name' = toJSString name
93 let name' = toJSString name
@@ -106,8 +107,8 @@ objSetPropertyAtIndex :: (ToJSVal val)
106objSetPropertyAtIndex this index val = do
107objSetPropertyAtIndex this index val = do
107 vref <- toJSVal val
108 vref <- toJSVal val
108 liftIO $ js_trySetAtIndex index this vref
109 liftIO $ js_trySetAtIndex index this vref
109−foreign import javascript unsafe "try { $2[$1]=$3 } catch(e) { $4[0] = e }"
110+foreign import javascript unsafe "$2[$1]=$3"
110− js_trySetAtIndex :: Index -> Object -> JSVal -> MutableJSArray -> IO ()
111+ js_trySetAtIndex :: Index -> Object -> JSVal -> IO ()
112objSetPropertyAtIndex this index val = do
113objSetPropertyAtIndex this index val = do
113 gctxt <- ask
114 gctxt <- ask