@@ -2,10 +2,10 @@
22module Generate.JavaScript.Ports (incoming, outgoing) where
33
44import Generate.JavaScript.Helpers
5+import Generate.JavaScript.Variable (nativePorts, nativeJson)
56import AST.Type as T
67import qualified AST.Variable as Var
78import Language.ECMAScript3.Syntax
8−import Generate.JavaScript.Variable (canonical)
99
1010data JSType = JSNumber | JSBoolean | JSString | JSArray | JSObject [String]
1111 deriving Show
@@ -30,7 +30,7 @@ incoming tipe =
3030 Aliased _ t -> incoming t
3131
3232 App (Type v) [t]
33− | Var.isSignal v -> obj ["_P","incomingSignal"] <| incoming t
33+ | Var.isSignal v -> nativePorts "incomingSignal" <| incoming t
3434
3535 _ -> ["v"] ==> inc tipe (ref "v")
3636
@@ -51,11 +51,8 @@ inc tipe x =
5151 from checks = check x checks x
5252
5353 Type name
54− | Var.isJson name -> canonical fromJS <| x
54+ | Var.isJson name -> nativeJson "fromJS" <| x
5555 | otherwise -> error "bad type got to incoming port generation code"
56− where
57− fromJS = Var.Canonical (Var.Module "Native.Json") "fromJS"
58−
5956
6057 App f args ->
6158 case f : args of
@@ -100,7 +97,7 @@ outgoing tipe =
10097 Aliased _ t -> outgoing t
10198
10299 App (Type v) [t]
103− | Var.isSignal v -> obj ["_P","outgoingSignal"] <| outgoing t
100+ | Var.isSignal v -> nativePorts "outgoingSignal" <| outgoing t
104101
105102 _ -> ["v"] ==> out tipe (ref "v")
106103
@@ -129,10 +126,8 @@ out tipe x =
129126 | name `elem` ["Int","Float","Bool","String"] -> x
130127
131128 Type name
132− | Var.isJson name -> canonical toJS <| x
129+ | Var.isJson name -> nativeJson "toJS" <| x
133130 | otherwise -> error "bad type got to outgoing port generation code"
134− where
135− toJS = Var.Canonical (Var.Module "Native.Json") "toJS"
136131
137132 App f args ->
138133 case f : args of