ranger-compiler 3.0.4 → 3.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.md +1 -1
- package/dist/Lang.rgr +158 -9
- package/dist/lib/JSON.rgr +31 -4
- package/dist/lib/RangerProcess.rgr +273 -0
- package/dist/lib/stdlib.rgr +33 -3
- package/dist/package.json +1 -1
- package/dist/rgrc.js +1129 -37
- package/package.json +2 -2
- package/dist/lib/lib/ACEEditor.rgr +0 -5
- package/dist/lib/lib/Ajax.rgr +0 -196
- package/dist/lib/lib/CmdParams.rgr +0 -72
- package/dist/lib/lib/Crypto.rgr +0 -90
- package/dist/lib/lib/DOMLib.rgr +0 -307
- package/dist/lib/lib/Engine3D.rgr +0 -870
- package/dist/lib/lib/ImmutableVector.rgr +0 -364
- package/dist/lib/lib/IndexedDB.rgr +0 -32
- package/dist/lib/lib/JSON.rgr +0 -702
- package/dist/lib/lib/JinxProcess.rgr +0 -838
- package/dist/lib/lib/SQL.rgr +0 -44
- package/dist/lib/lib/ServiceLib.rgr +0 -9
- package/dist/lib/lib/Storage.rgr +0 -89
- package/dist/lib/lib/Time.rgr +0 -75
- package/dist/lib/lib/Timers.rgr +0 -176
- package/dist/lib/lib/TypedArrays.rgr +0 -14
- package/dist/lib/lib/ViewLib.rgr +0 -851
- package/dist/lib/lib/WebLib.rgr +0 -47
- package/dist/lib/lib/WebServerLib.rgr +0 -137
- package/dist/lib/lib/ranger-dir.rgr +0 -175
- package/dist/lib/lib/stdlib.rgr +0 -665
- package/dist/lib/lib/stdops.rgr +0 -168
package/dist/lib/lib/JSON.rgr
DELETED
|
@@ -1,702 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
; for scala maybe
|
|
3
|
-
; https://www.playframework.com/documentation/2.6.x/ScalaJson
|
|
4
|
-
; Scala testing of JSON parsing:
|
|
5
|
-
; https://scalafiddle.io/sf/S0EpdDK/1
|
|
6
|
-
; https://scalafiddle.io/sf/S0EpdDK/5
|
|
7
|
-
; https://msdn.microsoft.com/en-us/library/system.json.jsonobject(v=vs.95).aspx
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
systemclass JSONDataObject {
|
|
11
|
-
es6 Object
|
|
12
|
-
java7 JSONObject ( (imp "org.json.JSONObject") )
|
|
13
|
-
kotlin JSONObject
|
|
14
|
-
go "map[string]interface{}"
|
|
15
|
-
swift3 '[String:Any]'
|
|
16
|
-
swift6 '[String:Any]'
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
systemclass JSONArrayObject {
|
|
20
|
-
es6 JSONArrayObject2
|
|
21
|
-
java7 JSONArray ( (imp "org.json.JSONArray") )
|
|
22
|
-
kotlin JSONArray
|
|
23
|
-
go "[]interface{}"
|
|
24
|
-
swift3 '[Any]'
|
|
25
|
-
swift6 '[Any]'
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
systemclass JSONKeyValue {
|
|
29
|
-
es6 JSONKeyValue2
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
systemclass JSONValueUnion {
|
|
33
|
-
es6 Object
|
|
34
|
-
java7 Object
|
|
35
|
-
kotlin Any?
|
|
36
|
-
go "interface{}"
|
|
37
|
-
swift3 Any
|
|
38
|
-
swift6 Any
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
systemunion JSONValueUnion ( JSONDataObject JSONArrayObject string int double boolean )
|
|
42
|
-
systemunion JSONArrayUnion ( JSONDataObject string int double boolean )
|
|
43
|
-
systemunion JSONObjectUnion ( JSONKeyValue )
|
|
44
|
-
|
|
45
|
-
operator type:JSONArrayObject all {
|
|
46
|
-
fn forEach( cb:(_:void (item:JSONValueUnion index:int))) {
|
|
47
|
-
def cnt (array_length self)
|
|
48
|
-
def i 0
|
|
49
|
-
while( cnt > 0 ) {
|
|
50
|
-
def value (getValue self i)
|
|
51
|
-
cb(value i)
|
|
52
|
-
cnt = cnt - 1
|
|
53
|
-
i = i + 1
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
fn map:[S] (cb:(_:S (item:JSONValueUnion index:int)) to@(noeval):[S] ) {
|
|
57
|
-
def len (array_length self)
|
|
58
|
-
def res:[S]
|
|
59
|
-
def i 0
|
|
60
|
-
while ( i < len) {
|
|
61
|
-
def it (getValue self i)
|
|
62
|
-
push res (cb(it i))
|
|
63
|
-
i = i + 1
|
|
64
|
-
}
|
|
65
|
-
return res
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
operators {
|
|
70
|
-
|
|
71
|
-
print _:void (e:JSONDataObject) {
|
|
72
|
-
templates {
|
|
73
|
-
ranger ( "(print " (e 1 ) ")")
|
|
74
|
-
es6 (
|
|
75
|
-
"console.log(JSON.stringify(" (e 1) "));" nl
|
|
76
|
-
)
|
|
77
|
-
java7 @macro(true) ("print (to_string " (e 1) " )" (imp "org.json.JSONObject"))
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
getStr _@(optional):string (e:JSONDataObject key:string) {
|
|
82
|
-
templates {
|
|
83
|
-
php ( "isset(" (e 1) "[" (e 2) "]) ? " (e 1) "[" (e 2) "] : null" )
|
|
84
|
-
es6 (
|
|
85
|
-
"(typeof (" (e 1) " [" (e 2) "]) != \"string\" ) ? undefined : " (e 1) " [" (e 2) "] " nl
|
|
86
|
-
)
|
|
87
|
-
swift3 ( (e 1) '[' (e 2) '] as? String ')
|
|
88
|
-
swift6 ( (e 1) '[' (e 2) '] as? String ')
|
|
89
|
-
ranger ("(getStr " (e 1) " " (e 2) ")")
|
|
90
|
-
java7 ( (e 1) ".isNull( " (e 2) " ) ? null : " (e 1) ".optString(" (e 2) ") " )
|
|
91
|
-
kotlin ( "(if (" (e 1) ".isNull(" (e 2) ")) null else " (e 1) ".optString(" (e 2) "))"
|
|
92
|
-
(create_polyfill "
|
|
93
|
-
typealias JSONObject = org.json.JSONObject
|
|
94
|
-
typealias JSONArray = org.json.JSONArray
|
|
95
|
-
typealias JSONDataObject = org.json.JSONObject
|
|
96
|
-
typealias JSONArrayObject = org.json.JSONArray
|
|
97
|
-
")
|
|
98
|
-
)
|
|
99
|
-
go ( "r_get_opt_json_string(" (e 1) ", " (e 2) ")"
|
|
100
|
-
(create_polyfill "
|
|
101
|
-
func r_get_opt_json_string( data map[string]interface{}, key string ) *GoNullable {
|
|
102
|
-
res := new(GoNullable)
|
|
103
|
-
v, ok := data[key]
|
|
104
|
-
if ok {
|
|
105
|
-
if arr, ok := v.(string); ok {
|
|
106
|
-
res.has_value = true
|
|
107
|
-
res.value = arr
|
|
108
|
-
return res
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
res.has_value = false
|
|
112
|
-
return res
|
|
113
|
-
}
|
|
114
|
-
")
|
|
115
|
-
|
|
116
|
-
)
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
getInt _@(optional):int (e:JSONDataObject key:string) {
|
|
123
|
-
templates {
|
|
124
|
-
php ( "isset(" (e 1) "[" (e 2) "]) ? " (e 1) "[" (e 2) "] : null" )
|
|
125
|
-
es6 (
|
|
126
|
-
"isNaN( parseInt(" (e 1) " [" (e 2) "]) ) ? undefined : parseInt(" (e 1) " [" (e 2) "]) " nl
|
|
127
|
-
)
|
|
128
|
-
swift3 ( (e 1) '[' (e 2) '] as? Int ')
|
|
129
|
-
swift6 ( (e 1) '[' (e 2) '] as? Int ')
|
|
130
|
-
ranger( "(getInt " (e 1 )" " (e 2)")")
|
|
131
|
-
java7 ( (e 1) ".isNull( " (e 2) " ) ? null : " (e 1) ".optInt(" (e 2) ") " )
|
|
132
|
-
kotlin ( "(if (" (e 1) ".isNull(" (e 2) ")) null else " (e 1) ".optInt(" (e 2) "))" )
|
|
133
|
-
go ( "r_get_opt_json_int(" (e 1) ", " (e 2 ) ")"
|
|
134
|
-
(create_polyfill "
|
|
135
|
-
func r_get_opt_json_int( data map[string]interface{}, key string ) *GoNullable {
|
|
136
|
-
res := new(GoNullable)
|
|
137
|
-
v, ok := data[key]
|
|
138
|
-
if ok {
|
|
139
|
-
if arr, ok := v.(int); ok {
|
|
140
|
-
res.has_value = true
|
|
141
|
-
res.value = int64(arr)
|
|
142
|
-
return res
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
res.has_value = false
|
|
146
|
-
return res
|
|
147
|
-
}
|
|
148
|
-
")
|
|
149
|
-
|
|
150
|
-
)
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
getDouble _@(optional):double (e:JSONDataObject key:string) {
|
|
156
|
-
templates {
|
|
157
|
-
php ( "isset(" (e 1) "[" (e 2) "]) ? " (e 1) "[" (e 2) "] : null" )
|
|
158
|
-
es6 (
|
|
159
|
-
"isNaN( parseFloat(" (e 1) " [" (e 2) "]) ) ? undefined : parseFloat(" (e 1) " [" (e 2) "]) " nl
|
|
160
|
-
)
|
|
161
|
-
swift3 ( (e 1) '[' (e 2) '] as? Double ')
|
|
162
|
-
swift6 ( (e 1) '[' (e 2) '] as? Double ')
|
|
163
|
-
ranger( "(getDouble " (e 1 )" " (e 2)")")
|
|
164
|
-
java7 ( (e 1) ".isNull( " (e 2) " ) ? null : " (e 1) ".optDouble(" (e 2) ") " )
|
|
165
|
-
kotlin ( "(if (" (e 1) ".isNull(" (e 2) ")) null else " (e 1) ".optDouble(" (e 2) "))" )
|
|
166
|
-
go ( "r_get_opt_json_double(" (e 1) ", " (e 2) ")"
|
|
167
|
-
(create_polyfill "
|
|
168
|
-
func r_get_opt_json_double( data map[string]interface{}, key string ) *GoNullable {
|
|
169
|
-
res := new(GoNullable)
|
|
170
|
-
v, ok := data[key]
|
|
171
|
-
if ok {
|
|
172
|
-
if arr, ok := v.(float64); ok {
|
|
173
|
-
res.has_value = true
|
|
174
|
-
res.value = arr
|
|
175
|
-
return res
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
res.has_value = false
|
|
179
|
-
return res
|
|
180
|
-
}
|
|
181
|
-
")
|
|
182
|
-
|
|
183
|
-
)
|
|
184
|
-
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
getBoolean _@(optional):boolean (e:JSONDataObject key:string) {
|
|
189
|
-
templates {
|
|
190
|
-
php ( "isset(" (e 1) "[" (e 2) "]) ? " (e 1) "[" (e 2) "] : null" )
|
|
191
|
-
es6 (
|
|
192
|
-
"typeof(" (e 1) " [" (e 2) "]) === \"undefined\" ? undefined :(" (e 1) " [" (e 2) "]) "
|
|
193
|
-
)
|
|
194
|
-
swift3 ( (e 1) '[' (e 2) '] as? Bool ')
|
|
195
|
-
swift6 ( (e 1) '[' (e 2) '] as? Bool ')
|
|
196
|
-
ranger( "(getBoolean " (e 1 )" " (e 2)")")
|
|
197
|
-
java7 ( (e 1) ".isNull( " (e 2) " ) ? null : " (e 1) ".optBoolean(" (e 2) ") " )
|
|
198
|
-
kotlin ( "(if (" (e 1) ".isNull(" (e 2) ")) null else " (e 1) ".optBoolean(" (e 2) "))" )
|
|
199
|
-
go ( "r_get_opt_json_bool(" (e 1) ", " (e 2) ")"
|
|
200
|
-
(create_polyfill "
|
|
201
|
-
func r_get_opt_json_bool( data map[string]interface{}, key string ) *GoNullable {
|
|
202
|
-
res := new(GoNullable)
|
|
203
|
-
v, ok := data[key]
|
|
204
|
-
if ok {
|
|
205
|
-
if arr, ok := v.(bool); ok {
|
|
206
|
-
res.has_value = true
|
|
207
|
-
res.value = arr
|
|
208
|
-
return res
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
res.has_value = false
|
|
212
|
-
return res
|
|
213
|
-
}
|
|
214
|
-
")
|
|
215
|
-
|
|
216
|
-
)
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
getObject _@(optional):JSONDataObject (e:JSONDataObject key:string) {
|
|
221
|
-
templates {
|
|
222
|
-
php ( "isset(" (e 1) "[" (e 2) "]) ? " (e 1) "[" (e 2) "] : null" )
|
|
223
|
-
es6 (
|
|
224
|
-
"(" (e 1) "[" (e 2) "] instanceof Object ) ? " (e 1) " [" (e 2) "] : undefined "
|
|
225
|
-
)
|
|
226
|
-
swift3 ( (e 1) '[' (e 2) '] as? [String:Any] ')
|
|
227
|
-
swift6 ( (e 1) '[' (e 2) '] as? [String:Any] ')
|
|
228
|
-
ranger ( '(getObject ' (e 1) ' ' (e 2) ')')
|
|
229
|
-
java7 ( "__getJSONObj(" (e 1) ", " (e 2) " )" (imp 'org.json.JSONException')
|
|
230
|
-
|
|
231
|
-
(create_polyfill '
|
|
232
|
-
static JSONObject __getJSONObj(JSONObject o, String item)
|
|
233
|
-
{
|
|
234
|
-
try{
|
|
235
|
-
if(o.isNull(item)) {
|
|
236
|
-
return null;
|
|
237
|
-
}
|
|
238
|
-
return o.getJSONObject(item);
|
|
239
|
-
} catch(JSONException se) {
|
|
240
|
-
return null;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
')
|
|
244
|
-
|
|
245
|
-
)
|
|
246
|
-
kotlin ( "(if (" (e 1) ".isNull(" (e 2) ")) null else " (e 1) ".getJSONObject(" (e 2) "))" )
|
|
247
|
-
go ( "r_get_opt_json_obj(" (e 1) ", " (e 2) ")"
|
|
248
|
-
(create_polyfill "
|
|
249
|
-
func r_get_opt_json_obj( data map[string]interface{}, key string ) *GoNullable {
|
|
250
|
-
res := new(GoNullable)
|
|
251
|
-
v, ok := data[key]
|
|
252
|
-
if ok {
|
|
253
|
-
if arr, ok := v.(map[string]interface{}); ok {
|
|
254
|
-
res.has_value = true
|
|
255
|
-
res.value = arr
|
|
256
|
-
return res
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
res.has_value = false
|
|
260
|
-
return res
|
|
261
|
-
}
|
|
262
|
-
")
|
|
263
|
-
|
|
264
|
-
)
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
; todo: proper array detection for optionals
|
|
270
|
-
getArray _@(optional):JSONArrayObject (e:JSONDataObject key:string) {
|
|
271
|
-
templates {
|
|
272
|
-
php ( "isset(" (e 1) "[" (e 2) "]) ? " (e 1) "[" (e 2) "] : null" )
|
|
273
|
-
es6 (
|
|
274
|
-
"(" (e 1) "[" (e 2) "] instanceof Array ) ? " (e 1) " [" (e 2) "] : undefined "
|
|
275
|
-
)
|
|
276
|
-
swift3 ( (e 1) '[' (e 2) '] as? [Any] ')
|
|
277
|
-
swift6 ( (e 1) '[' (e 2) '] as? [Any] ')
|
|
278
|
-
ranger ("(getArray " (e 1) " " (e 2) ")")
|
|
279
|
-
java7 ( (e 1) ".isNull( " (e 2) " ) ? null : " (e 1) ".getJSONArray(" (e 2) ") " )
|
|
280
|
-
kotlin ( "(if (" (e 1) ".isNull(" (e 2) ")) null else " (e 1) ".getJSONArray(" (e 2) "))" )
|
|
281
|
-
go ( "r_get_opt_array(" (e 1) ", " (e 2) ")"
|
|
282
|
-
(create_polyfill '
|
|
283
|
-
func r_get_opt_array( data map[string]interface{}, key string ) *GoNullable {
|
|
284
|
-
res := new(GoNullable)
|
|
285
|
-
v, ok := data[key]
|
|
286
|
-
if ok {
|
|
287
|
-
if arr, ok := v.([]interface{}); ok {
|
|
288
|
-
res.has_value = true
|
|
289
|
-
res.value = arr
|
|
290
|
-
return res
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
res.has_value = false
|
|
294
|
-
return res
|
|
295
|
-
}
|
|
296
|
-
')
|
|
297
|
-
|
|
298
|
-
)
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
keys _:[string] (e:JSONDataObject) {
|
|
303
|
-
templates {
|
|
304
|
-
es6 ( "Object.keys(" (e 1) ")")
|
|
305
|
-
ranger( '(keys ' (e 1 )')')
|
|
306
|
-
swift3 ( 'Array('(e 1) '.keys)')
|
|
307
|
-
java7 ( "__getJSONKeys(" (e 1) ")"
|
|
308
|
-
; create template
|
|
309
|
-
(create_polyfill "
|
|
310
|
-
static ArrayList<String> __getJSONKeys(JSONObject obj)
|
|
311
|
-
{
|
|
312
|
-
ArrayList<String> list = new ArrayList<String>();
|
|
313
|
-
try {
|
|
314
|
-
JSONArray jsonArray = obj.names();
|
|
315
|
-
if (jsonArray != null) {
|
|
316
|
-
int len = jsonArray.length();
|
|
317
|
-
for (int i=0;i<len;i++){
|
|
318
|
-
list.add(jsonArray.get(i).toString());
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
} catch( Exception e) {
|
|
322
|
-
}
|
|
323
|
-
return list;
|
|
324
|
-
}
|
|
325
|
-
")
|
|
326
|
-
(imp "org.json.JSONObject")
|
|
327
|
-
(imp "org.json.JSONArray")
|
|
328
|
-
|
|
329
|
-
)
|
|
330
|
-
go ("(func() []string {" nl I
|
|
331
|
-
"keys := reflect.ValueOf(" (e 1) ").MapKeys()" nl
|
|
332
|
-
"strkeys := make([]string, len(keys))" nl
|
|
333
|
-
"for i := 0; i < len(keys); i++ {" nl I
|
|
334
|
-
"strkeys[i] = keys[i].String()" nl i "}" nl
|
|
335
|
-
"return strkeys" nl i "})()"
|
|
336
|
-
(imp "reflect"))
|
|
337
|
-
php ("array_keys(" (e 1) ")")
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
isArray _:boolean (e:JSONValueUnion) {
|
|
343
|
-
templates {
|
|
344
|
-
php ( "is_array(" (e 1) ")")
|
|
345
|
-
es6 ( (e 1) " instanceof Array")
|
|
346
|
-
ranger( "(isArray " (e 1 )")")
|
|
347
|
-
go ( "r_is_obj_array(" (e 1) ")"
|
|
348
|
-
(create_polyfill "
|
|
349
|
-
func r_is_obj_array( data inteface{} ) bool {
|
|
350
|
-
if _, ok := data.([]interface{}) ; ok {
|
|
351
|
-
return ok
|
|
352
|
-
}
|
|
353
|
-
return false
|
|
354
|
-
}
|
|
355
|
-
")
|
|
356
|
-
)
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
asArray _@(optional):JSONArrayObject (e:JSONValueUnion) {
|
|
361
|
-
templates {
|
|
362
|
-
es6 ( (e 1) " instanceof Array ? " (e 1 ) " : undefined")
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
getValue _:JSONValueUnion (e:JSONArrayObject index:int) {
|
|
367
|
-
templates {
|
|
368
|
-
es6 ( (e 1) "[" (e 2) "]")
|
|
369
|
-
ranger( "(getValue " (e 1) " " (e 2) " )")
|
|
370
|
-
java7( '__getJSONValue(' (e 1) ', ' (e 2) ')' (imp 'org.json.JSONObject') (imp 'org.json.JSONArray') (imp 'org.json.JSONException')
|
|
371
|
-
|
|
372
|
-
(create_polyfill '
|
|
373
|
-
static Object __getJSONValue(JSONArray o, Integer item)
|
|
374
|
-
{
|
|
375
|
-
try{
|
|
376
|
-
if(o.isNull(item)) {
|
|
377
|
-
return null;
|
|
378
|
-
}
|
|
379
|
-
return o.get(item);
|
|
380
|
-
} catch(JSONException se) {
|
|
381
|
-
return null;
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
')
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
)
|
|
388
|
-
swift3 ( (e 1) "[" (e 2) "]")
|
|
389
|
-
kotlin ( (e 1) ".get(" (e 2) ")")
|
|
390
|
-
go ( (e 1) "[" (e 2) "]")
|
|
391
|
-
php ( (e 1) "[" (e 2) "]")
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
array_length _:int (e:JSONArrayObject) {
|
|
396
|
-
templates {
|
|
397
|
-
ranger ("(array_length " (e 1) ")")
|
|
398
|
-
es6 ( (e 1) ".length")
|
|
399
|
-
java7 ( (e 1) ".length()" )
|
|
400
|
-
kotlin ( (e 1) ".length()" )
|
|
401
|
-
swift3 ( (e 1) ".count")
|
|
402
|
-
swift6 ( (e 1) ".count")
|
|
403
|
-
go( "int64(len(" (e 1) "))" )
|
|
404
|
-
php ( "count(" (e 1) ")" )
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
set _@(moves@( 3 1 ) ):void (e@(mutates):JSONDataObject key:string value:enum) {
|
|
409
|
-
templates {
|
|
410
|
-
ranger ( "(set " (e 1) " " (e 2) " " (e 3) " )")
|
|
411
|
-
es6 ( (e 1) "[" (e 2)"] = " (e 3) ";")
|
|
412
|
-
java7 ( (e 1) ".put(" (e 2)" , " (e 3) ");")
|
|
413
|
-
kotlin ( (e 1) ".put(" (e 2)" , " (e 3) ");")
|
|
414
|
-
go ( (e 1) "[" (e 2) "] = " (e 3) )
|
|
415
|
-
swift3 ( (e 1) "[" (e 2) "] = " (e 3) )
|
|
416
|
-
swift6 ( (e 1) "[" (e 2) "] = " (e 3) )
|
|
417
|
-
php ( (e 1) "[" (e 2) "] = " (e 3) ";" )
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
set _@(moves@( 3 1 ) ):void (e@(mutates):JSONDataObject key:string value:string) {
|
|
422
|
-
templates {
|
|
423
|
-
ranger ( "(set " (e 1) " " (e 2) " " (e 3) " )")
|
|
424
|
-
es6 ( (e 1) "[" (e 2)"] = " (e 3) ";")
|
|
425
|
-
java7 ( (e 1) ".put(" (e 2)" , " (e 3) ");")
|
|
426
|
-
kotlin ( (e 1) ".put(" (e 2)" , " (e 3) ");")
|
|
427
|
-
go ( (e 1) "[" (e 2) "] = " (e 3) )
|
|
428
|
-
swift3 ( (e 1) "[" (e 2) "] = " (e 3) )
|
|
429
|
-
swift6 ( (e 1) "[" (e 2) "] = " (e 3) )
|
|
430
|
-
php ( (e 1) "[" (e 2) "] = " (e 3) ";" )
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
set _@(moves@( 3 1 ) ):void (e@(mutates):JSONDataObject key:string value:int) {
|
|
435
|
-
templates {
|
|
436
|
-
ranger ( "(set " (e 1) " " (e 2) " " (e 3) " )")
|
|
437
|
-
es6 ( (e 1) "[" (e 2)"] = " (e 3) ";")
|
|
438
|
-
java7 ( (e 1) ".put(" (e 2)" , " (e 3) ");")
|
|
439
|
-
kotlin ( (e 1) ".put(" (e 2)" , " (e 3) ");")
|
|
440
|
-
go ( (e 1) "[" (e 2) "] = " (e 3) )
|
|
441
|
-
swift3 ( (e 1) "[" (e 2) "] = " (e 3) )
|
|
442
|
-
swift6 ( (e 1) "[" (e 2) "] = " (e 3) )
|
|
443
|
-
php ( (e 1) "[" (e 2) "] = " (e 3) ";" )
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
set _@(moves@( 3 1 ) ):void (e@(mutates):JSONDataObject key:string value:double) {
|
|
448
|
-
templates {
|
|
449
|
-
ranger ( "(set " (e 1) " " (e 2) " " (e 3) " )")
|
|
450
|
-
es6 ( (e 1) "[" (e 2)"] = " (e 3) ";")
|
|
451
|
-
java7 ( (e 1) ".put(" (e 2)" , " (e 3) ");")
|
|
452
|
-
kotlin ( (e 1) ".put(" (e 2)" , " (e 3) ");")
|
|
453
|
-
go ( (e 1) "[" (e 2) "] = " (e 3) )
|
|
454
|
-
swift3 ( (e 1) "[" (e 2) "] = " (e 3) )
|
|
455
|
-
swift6 ( (e 1) "[" (e 2) "] = " (e 3) )
|
|
456
|
-
php ( (e 1) "[" (e 2) "] = " (e 3) ";" )
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
set _@(moves@( 3 1 ) ):void (e@(mutates):JSONDataObject key:string value:boolean) {
|
|
461
|
-
templates {
|
|
462
|
-
ranger ( "(set " (e 1) " " (e 2) " " (e 3) " )")
|
|
463
|
-
es6 ( (e 1) "[" (e 2)"] = " (e 3) ";")
|
|
464
|
-
java7 ( (e 1) ".put(" (e 2)" , " (e 3) ");")
|
|
465
|
-
kotlin ( (e 1) ".put(" (e 2)" , " (e 3) ");")
|
|
466
|
-
go ( (e 1) "[" (e 2) "] = " (e 3) )
|
|
467
|
-
swift3 ( (e 1) "[" (e 2) "] = " (e 3) )
|
|
468
|
-
swift6 ( (e 1) "[" (e 2) "] = " (e 3) )
|
|
469
|
-
php ( (e 1) "[" (e 2) "] = " (e 3) ";" )
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
set _@(moves@( 3 1 ) ):void (e@(mutates):JSONDataObject key:string value:JSONValueUnion) {
|
|
474
|
-
templates {
|
|
475
|
-
ranger ( "(set " (e 1) " " (e 2) " " (e 3) " )")
|
|
476
|
-
es6 ( (e 1) "[" (e 2)"] = " (e 3) ";")
|
|
477
|
-
java7 ( (e 1) ".put(" (e 2)" , " (e 3) ");")
|
|
478
|
-
kotlin ( (e 1) ".put(" (e 2)" , " (e 3) ");")
|
|
479
|
-
go ( (e 1) "[" (e 2) "] = " (e 3) )
|
|
480
|
-
swift3 ( (e 1) "[" (e 2) "] = " (e 3) )
|
|
481
|
-
swift6 ( (e 1) "[" (e 2) "] = " (e 3) )
|
|
482
|
-
php ( (e 1) "[" (e 2) "] = " (e 3) ";" )
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
from_string _@(throws):JSONDataObject (txt:string) {
|
|
487
|
-
templates {
|
|
488
|
-
ranger ( "(from_string " (e 1 ) ")")
|
|
489
|
-
es6 (
|
|
490
|
-
"JSON.parse(" (e 1) ")"
|
|
491
|
-
)
|
|
492
|
-
swift3 ( 'try JSONSerialization.jsonObject(with: ' (e 1) ', options:[]) as! [String:Any]' (imp 'Foundation') )
|
|
493
|
-
swift6 ( 'try JSONSerialization.jsonObject(with: ' (e 1) ', options:[]) as! [String:Any]' (imp 'Foundation') )
|
|
494
|
-
java7 ("new JSONObject(" (e 1) ")" (imp "org.json.JSONObject") (plugin 'maven' ( (dep 'org.json' 'json' '20171018' ) ) ))
|
|
495
|
-
kotlin ("JSONObject(" (e 1) ")")
|
|
496
|
-
go ( "__r_json_to_interface(" (e 1) ")" (imp "encoding/json")
|
|
497
|
-
|
|
498
|
-
(create_polyfill "
|
|
499
|
-
func __r_json_to_interface ( s string ) map[string]interface{} {
|
|
500
|
-
b := []byte(s)
|
|
501
|
-
var f interface{}
|
|
502
|
-
_ = json.Unmarshal(b, &f)
|
|
503
|
-
return f.(map[string]interface{})
|
|
504
|
-
}
|
|
505
|
-
")
|
|
506
|
-
|
|
507
|
-
)
|
|
508
|
-
php ( "r_json_to_array(" (e 1) ")"
|
|
509
|
-
(create_polyfill
|
|
510
|
-
"
|
|
511
|
-
function r_json_to_array($str) {
|
|
512
|
-
$obj = json_decode($str, true);
|
|
513
|
-
if( $obj == NULL) {
|
|
514
|
-
throw new Exception('Invalid JSON');
|
|
515
|
-
}
|
|
516
|
-
return $obj;
|
|
517
|
-
}
|
|
518
|
-
"
|
|
519
|
-
|
|
520
|
-
)
|
|
521
|
-
)
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
to_string _:string (e:JSONDataObject) {
|
|
526
|
-
templates {
|
|
527
|
-
ranger ( "(to_string " (e 1 ) ")")
|
|
528
|
-
es6 (
|
|
529
|
-
"JSON.stringify(" (e 1) ")"
|
|
530
|
-
)
|
|
531
|
-
swift3 ( '{ () -> String in ' nl I
|
|
532
|
-
'do {' nl I
|
|
533
|
-
'return String(data:try JSONSerialization.data(withJSONObject: ' (e 1) ', options:[]), encoding:.utf8)!'
|
|
534
|
-
i nl '} catch {' nl I
|
|
535
|
-
'return ""'
|
|
536
|
-
i nl '}'
|
|
537
|
-
i nl '}()' (imp 'Foundation') )
|
|
538
|
-
swift6 ( '{ () -> String in ' nl I
|
|
539
|
-
'do {' nl I
|
|
540
|
-
'return String(data:try JSONSerialization.data(withJSONObject: ' (e 1) ', options:[]), encoding:.utf8)!'
|
|
541
|
-
i nl '} catch {' nl I
|
|
542
|
-
'return ""'
|
|
543
|
-
i nl '}'
|
|
544
|
-
i nl '}()' (imp 'Foundation') )
|
|
545
|
-
java7 ( (e 1) ".toString()" )
|
|
546
|
-
kotlin ( (e 1) ".toString()" )
|
|
547
|
-
go( "__toJSONData(" (e 1) ")" (imp "encoding/json")
|
|
548
|
-
(create_polyfill "
|
|
549
|
-
func __toJSONData ( data interface{} ) string {
|
|
550
|
-
b, _ := json.Marshal(data)
|
|
551
|
-
return string(b)
|
|
552
|
-
}
|
|
553
|
-
")
|
|
554
|
-
)
|
|
555
|
-
php ( "json_encode(" (e 1) ")")
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
to_string _:string (e:JSONArrayObject) {
|
|
560
|
-
templates {
|
|
561
|
-
ranger ( "(to_string " (e 1 ) ")")
|
|
562
|
-
es6 (
|
|
563
|
-
"JSON.stringify(" (e 1) ")"
|
|
564
|
-
)
|
|
565
|
-
swift3 ( 'String(data:try JSONSerialization.data(with: ' (e 1) ', options:[], encoding:.utf8)!)' (imp 'Foundation') )
|
|
566
|
-
swift6 ( 'String(data:try JSONSerialization.data(with: ' (e 1) ', options:[], encoding:.utf8)!)' (imp 'Foundation') )
|
|
567
|
-
java7 ( (e 1) ".toString()" )
|
|
568
|
-
kotlin ( (e 1) ".toString()" )
|
|
569
|
-
go( "__toJSONData(" (e 1) ")" (imp "encoding/json")
|
|
570
|
-
(create_polyfill "
|
|
571
|
-
func __toJSONData ( data interface{} ) string {
|
|
572
|
-
b, _ := json.Marshal(data)
|
|
573
|
-
return string(b)
|
|
574
|
-
}
|
|
575
|
-
")
|
|
576
|
-
)
|
|
577
|
-
php ( "json_encode(" (e 1) ")")
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
push _@(moves@( 2 1 ) ):void ( e@(mutates):JSONArrayObject el:JSONArrayUnion) {
|
|
582
|
-
templates {
|
|
583
|
-
ranger ( "(push " (e 1 ) " " (e 2) " )")
|
|
584
|
-
es6 ( (e 1) ".push(" (e 2) ")")
|
|
585
|
-
java7 ( (e 1) ".put(" (e 2) ");")
|
|
586
|
-
kotlin ( (e 1) ".put(" (e 2) ");")
|
|
587
|
-
swift3 ( (e 1) ".append(" (e 2) ");")
|
|
588
|
-
swift6 ( (e 1) ".append(" (e 2) ");")
|
|
589
|
-
go( (e 1) " = append(" (e 1) "," (e 2) ")")
|
|
590
|
-
php ( "array_push(" (e 1) ", " (e 2) ");")
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
json_array json@(expands):JSONArrayObject () {
|
|
594
|
-
templates {
|
|
595
|
-
es6 ("[]")
|
|
596
|
-
swift3 ( '[Any]()' )
|
|
597
|
-
swift6 ( '[Any]()' )
|
|
598
|
-
ranger ("(json_array )")
|
|
599
|
-
java7 ("new JSONArray()" (imp "org.json.JSONArray") (plugin 'maven' ( (dep 'org.json' 'json' '20171018' ) ) ))
|
|
600
|
-
kotlin ("JSONArray()")
|
|
601
|
-
go ( "make([]interface{},0)" )
|
|
602
|
-
php ( "array()" )
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
json_object json:JSONDataObject () {
|
|
606
|
-
templates {
|
|
607
|
-
es6 ("{}")
|
|
608
|
-
swift3 ( '[String:Any]()' )
|
|
609
|
-
swift6 ( '[String:Any]()' )
|
|
610
|
-
ranger ("(json_object )")
|
|
611
|
-
java7 ("new JSONObject()" (imp "org.json.JSONObject") (plugin 'maven' ( (dep 'org.json' 'json' '20171018' ) ) ))
|
|
612
|
-
kotlin ("JSONObject()")
|
|
613
|
-
go ( "make(map[string]interface{})" )
|
|
614
|
-
php ( "array()")
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
json_array json@(expands):JSONArrayObject ( e@(block):JSONArrayUnion ) {
|
|
618
|
-
templates {
|
|
619
|
-
es6 ("[" ( repeat_from 1 ( (block 1) ) ) "]")
|
|
620
|
-
swift3 ("[" ( repeat_from 1 ( (block 1) ) ) "]")
|
|
621
|
-
swift6 ("[" ( repeat_from 1 ( (block 1) ) ) "]")
|
|
622
|
-
ranger ("(json_array " ( repeat 1 ( (block 1) ) ) ")")
|
|
623
|
-
java7 ("new JSONArray" (imp "org.json.JSONArray") (plugin 'maven' ( (dep 'org.json' 'json' '20171018' ) ) ))
|
|
624
|
-
go ( "make([]interface{},0)" )
|
|
625
|
-
php ( "array()" )
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
json_obj json@(expands):JSONDataObject ( e@(block):JSONObjectUnion ) {
|
|
629
|
-
templates {
|
|
630
|
-
es6 ("{" nl I ( repeat_from 1 ( (block 1) ) ) i nl "}")
|
|
631
|
-
ranger ("( json_obj " nl I ( repeat 1 ( (block 1) ) ) i nl ")")
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
json_obj.attr _:JSONKeyValue (name:string value:string) {
|
|
636
|
-
templates {
|
|
637
|
-
es6 (
|
|
638
|
-
"\"" (str 1) "\": " (e 2) ""
|
|
639
|
-
)
|
|
640
|
-
ranger ("(json.attr " (e 1) " " (e 2) ")")
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
json.attr _:JSONKeyValue (name:string value:string) {
|
|
645
|
-
templates {
|
|
646
|
-
es6 (
|
|
647
|
-
"\"" (str 1) "\": " (e 2) ""
|
|
648
|
-
)
|
|
649
|
-
ranger ("(json.attr " (e 1) " " (e 2) ")")
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
json.attr _:JSONKeyValue (name:string value:int) {
|
|
653
|
-
templates {
|
|
654
|
-
es6 (
|
|
655
|
-
"\"" (str 1) "\": " (e 2) ""
|
|
656
|
-
)
|
|
657
|
-
ranger ("(json.attr " (e 1) " " (e 2) ")")
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
json.attr _:JSONKeyValue (name:string value:double) {
|
|
661
|
-
templates {
|
|
662
|
-
es6 (
|
|
663
|
-
"\"" (str 1) "\": " (e 2) ""
|
|
664
|
-
)
|
|
665
|
-
ranger ("(json.attr " (e 1) " " (e 2) ")")
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
json_obj.attr _:JSONKeyValue (name:string value:JSONDataObject) {
|
|
670
|
-
templates {
|
|
671
|
-
es6 (
|
|
672
|
-
"\"" (str 1) "\" : " (e 2) ""
|
|
673
|
-
)
|
|
674
|
-
ranger ("(json.attr " (e 1) " " (e 2) ")")
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
json.attr _:JSONKeyValue (name:string value:JSONDataObject) {
|
|
679
|
-
templates {
|
|
680
|
-
es6 (
|
|
681
|
-
"\"" (str 1) "\" : " (e 2) ""
|
|
682
|
-
)
|
|
683
|
-
ranger ("(json.attr " (e 1) " " (e 2) ")")
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
json_obj.attr _:JSONKeyValue (name:string value:JSONArrayObject) {
|
|
687
|
-
templates {
|
|
688
|
-
es6 (
|
|
689
|
-
"\"" (str 1) "\" : " (e 2) ""
|
|
690
|
-
)
|
|
691
|
-
ranger ("(json.attr " (e 1) " " (e 2) ")")
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
json.attr _:JSONKeyValue (name:string value:JSONArrayObject) {
|
|
695
|
-
templates {
|
|
696
|
-
es6 (
|
|
697
|
-
"\"" (str 1) "\" : " (e 2) ""
|
|
698
|
-
)
|
|
699
|
-
ranger ("(json.attr " (e 1) " " (e 2) ")")
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
}
|