comparison src/settings.sml @ 765:a28982de5645

Successfully influenced effectful-ness status of FFI func
author Adam Chlipala <adamc@hcoop.net>
date Sat, 02 May 2009 11:27:26 -0400
parents 7f653298dd66
children df09c95085f8
comparison
equal deleted inserted replaced
764:7f653298dd66 765:a28982de5645
44 fun setTimeout n = timeout := n 44 fun setTimeout n = timeout := n
45 45
46 fun getHeaders () = !headers 46 fun getHeaders () = !headers
47 fun setHeaders ls = headers := ls 47 fun setHeaders ls = headers := ls
48 48
49 type ffi = string * string
50
51 structure K = struct
52 type ord_key = ffi
53 fun compare ((m1, x1), (m2, x2)) =
54 Order.join (String.compare (m1, m2),
55 fn () => String.compare (x1, x2))
49 end 56 end
57
58 structure S = BinarySetFn(K)
59 structure M = BinaryMapFn(K)
60
61 fun basis x = S.addList (S.empty, map (fn x : string => ("Basis", x)) x)
62
63 val clientToServerBase = basis ["int",
64 "float",
65 "string",
66 "time",
67 "file",
68 "unit",
69 "option",
70 "list",
71 "bool"]
72 val clientToServer = ref clientToServerBase
73 fun setClientToServer ls = clientToServer := S.addList (clientToServerBase, ls)
74 fun mayClientToServer x = S.member (!clientToServer, x)
75
76 val effectfulBase = basis ["set_cookie",
77 "new_client_source",
78 "get_client_source",
79 "set_client_source",
80 "alert",
81 "new_channel",
82 "send",
83 "onError",
84 "onFail",
85 "onConnectFail",
86 "onDisconnect",
87 "onServerError"]
88
89 val effectful = ref effectfulBase
90 fun setEffectful ls = effectful := S.addList (effectfulBase, ls)
91 fun isEffectful x = S.member (!effectful, x)
92
93 val clientBase = basis ["get",
94 "set",
95 "alert",
96 "recv",
97 "sleep",
98 "spawn",
99 "onError",
100 "onFail",
101 "onConnectFail",
102 "onDisconnect",
103 "onServerError"]
104 val client = ref clientBase
105 fun setClientOnly ls = client := S.addList (clientBase, ls)
106 fun isClientOnly x = S.member (!client, x)
107
108 val serverBase = basis ["requestHeader",
109 "query",
110 "dml",
111 "nextval",
112 "channel",
113 "send"]
114 val server = ref serverBase
115 fun setServerOnly ls = server := S.addList (serverBase, ls)
116 fun isServerOnly x = S.member (!server, x)
117
118 val basisM = foldl (fn ((k, v : string), m) => M.insert (m, ("Basis", k), v)) M.empty
119
120 val jsFuncsBase = basisM [("alert", "alert"),
121 ("get_client_source", "sg"),
122 ("htmlifyBool", "bs"),
123 ("htmlifyFloat", "ts"),
124 ("htmlifyInt", "ts"),
125 ("htmlifyString", "eh"),
126 ("new_client_source", "sc"),
127 ("set_client_source", "sv"),
128 ("stringToFloat_error", "pfl"),
129 ("stringToInt_error", "pi"),
130 ("urlifyInt", "ts"),
131 ("urlifyFloat", "ts"),
132 ("urlifyString", "uf"),
133 ("recv", "rv"),
134 ("strcat", "cat"),
135 ("intToString", "ts"),
136 ("floatToString", "ts"),
137 ("onError", "onError"),
138 ("onFail", "onFail"),
139 ("onConnectFail", "onConnectFail"),
140 ("onDisconnect", "onDisconnect"),
141 ("onServerError", "onServerError")]
142 val jsFuncs = ref jsFuncsBase
143 fun setJsFuncs ls = jsFuncs := foldl (fn ((k, v), m) => M.insert (m, k, v)) jsFuncsBase ls
144 fun jsFunc x = M.find (!jsFuncs, x)
145
146 end