@@ -2,7 +2,7 @@
2module Generate.JavaScript.Ports (incoming, outgoing) where
2module Generate.JavaScript.Ports (incoming, outgoing) where
4import Generate.JavaScript.Helpers
4import Generate.JavaScript.Helpers
5−import Generate.JavaScript.Variable (nativePorts, nativeJson)
5+import qualified Generate.JavaScript.Variable as V
6import AST.Type as T
6import AST.Type as T
7import qualified AST.Variable as Var
7import qualified AST.Variable as Var
8import Language.ECMAScript3.Syntax
8import Language.ECMAScript3.Syntax
@@ -30,7 +30,7 @@ incoming tipe =
30 Aliased _ t -> incoming t
30 Aliased _ t -> incoming t
32 App (Type v) [t]
32 App (Type v) [t]
33− | Var.isSignal v -> nativePorts "incomingSignal" <| incoming t
33+ | Var.isSignal v -> V.value "Native.Ports" "incomingSignal" <| incoming t
35 _ -> ["v"] ==> inc tipe (ref "v")
35 _ -> ["v"] ==> inc tipe (ref "v")
@@ -51,15 +51,15 @@ inc tipe x =
51 from checks = check x checks x
51 from checks = check x checks x
54− | Var.isJson name -> nativeJson "fromJS" <| x
54+ | Var.isJson name -> V.value "Native.Json" "fromJS" <| x
55 | otherwise -> error "bad type got to incoming port generation code"
55 | otherwise -> error "bad type got to incoming port generation code"
57 App f args ->
57 App f args ->
58 case f : args of
58 case f : args of
59 Type name : [t]
59 Type name : [t]
60 | Var.isMaybe name -> CondExpr () (equal x (NullLit ()))
60 | Var.isMaybe name -> CondExpr () (equal x (NullLit ()))
61− (obj ["Maybe","Nothing"])
61+ (V.value "Maybe" "Nothing")
62− (obj ["Maybe","Just"] <| inc t x)
62+ (V.value "Maybe" "Just" <| inc t x)
64 | Var.isList name -> check x JSArray (obj ["_L","fromArray"] <| array)
64 | Var.isList name -> check x JSArray (obj ["_L","fromArray"] <| array)
@@ -97,7 +97,7 @@ outgoing tipe =
97 Aliased _ t -> outgoing t
97 Aliased _ t -> outgoing t
99 App (Type v) [t]
99 App (Type v) [t]
100− | Var.isSignal v -> nativePorts "outgoingSignal" <| outgoing t
100+ | Var.isSignal v -> V.value "Native.Ports" "outgoingSignal" <| outgoing t
102 _ -> ["v"] ==> out tipe (ref "v")
102 _ -> ["v"] ==> out tipe (ref "v")
@@ -126,7 +126,7 @@ out tipe x =
126 | name `elem` ["Int","Float","Bool","String"] -> x
126 | name `elem` ["Int","Float","Bool","String"] -> x
128 Type name
128 Type name
129− | Var.isJson name -> nativeJson "toJS" <| x
129+ | Var.isJson name -> V.value "Native.Json" "toJS" <| x
130 | otherwise -> error "bad type got to outgoing port generation code"
130 | otherwise -> error "bad type got to outgoing port generation code"
132 App f args ->
132 App f args ->