diff options
Diffstat (limited to 'ddl/out/LambdaCube.IR.cpp')
-rw-r--r-- | ddl/out/LambdaCube.IR.cpp | 2864 |
1 files changed, 2864 insertions, 0 deletions
diff --git a/ddl/out/LambdaCube.IR.cpp b/ddl/out/LambdaCube.IR.cpp new file mode 100644 index 0000000..bf5ab0b --- /dev/null +++ b/ddl/out/LambdaCube.IR.cpp | |||
@@ -0,0 +1,2864 @@ | |||
1 | // generated file, do not modify! | ||
2 | // 2016-01-28T13:15:30.803775Z | ||
3 | |||
4 | #include "LambdaCube.IR.hpp" | ||
5 | template<> json toJSON<std::shared_ptr<ArrayValue>>(std::shared_ptr<ArrayValue> &v) { | ||
6 | json obj({}); | ||
7 | switch (v->tag) { | ||
8 | case ::ArrayValue::tag::VBoolArray: | ||
9 | obj["tag"] = "VBoolArray"; | ||
10 | { | ||
11 | std::shared_ptr<data::VBoolArray> tv = std::static_pointer_cast<data::VBoolArray>(v); | ||
12 | obj["arg0"] = toJSON(tv->_0); | ||
13 | } | ||
14 | break; | ||
15 | case ::ArrayValue::tag::VIntArray: | ||
16 | obj["tag"] = "VIntArray"; | ||
17 | { | ||
18 | std::shared_ptr<data::VIntArray> tv = std::static_pointer_cast<data::VIntArray>(v); | ||
19 | obj["arg0"] = toJSON(tv->_0); | ||
20 | } | ||
21 | break; | ||
22 | case ::ArrayValue::tag::VWordArray: | ||
23 | obj["tag"] = "VWordArray"; | ||
24 | { | ||
25 | std::shared_ptr<data::VWordArray> tv = std::static_pointer_cast<data::VWordArray>(v); | ||
26 | obj["arg0"] = toJSON(tv->_0); | ||
27 | } | ||
28 | break; | ||
29 | case ::ArrayValue::tag::VFloatArray: | ||
30 | obj["tag"] = "VFloatArray"; | ||
31 | { | ||
32 | std::shared_ptr<data::VFloatArray> tv = std::static_pointer_cast<data::VFloatArray>(v); | ||
33 | obj["arg0"] = toJSON(tv->_0); | ||
34 | } | ||
35 | break; | ||
36 | } | ||
37 | return obj; | ||
38 | } | ||
39 | |||
40 | template<> std::shared_ptr<ArrayValue> fromJSON<std::shared_ptr<ArrayValue>>(W<std::shared_ptr<ArrayValue>> v, json &obj) { | ||
41 | enum ::ArrayValue::tag tagType; | ||
42 | std::string tag = obj["tag"]; | ||
43 | if (tag == "VBoolArray") { | ||
44 | tagType = ::ArrayValue::tag::VBoolArray; | ||
45 | std::shared_ptr<data::VBoolArray> tv(new data::VBoolArray()); | ||
46 | tv->_0 = fromJSON(W<std::vector<Bool>>(), obj["arg0"]); | ||
47 | return tv; | ||
48 | } | ||
49 | else if (tag == "VIntArray") { | ||
50 | tagType = ::ArrayValue::tag::VIntArray; | ||
51 | std::shared_ptr<data::VIntArray> tv(new data::VIntArray()); | ||
52 | tv->_0 = fromJSON(W<std::vector<Int32>>(), obj["arg0"]); | ||
53 | return tv; | ||
54 | } | ||
55 | else if (tag == "VWordArray") { | ||
56 | tagType = ::ArrayValue::tag::VWordArray; | ||
57 | std::shared_ptr<data::VWordArray> tv(new data::VWordArray()); | ||
58 | tv->_0 = fromJSON(W<std::vector<Word32>>(), obj["arg0"]); | ||
59 | return tv; | ||
60 | } | ||
61 | else if (tag == "VFloatArray") { | ||
62 | tagType = ::ArrayValue::tag::VFloatArray; | ||
63 | std::shared_ptr<data::VFloatArray> tv(new data::VFloatArray()); | ||
64 | tv->_0 = fromJSON(W<std::vector<Float>>(), obj["arg0"]); | ||
65 | return tv; | ||
66 | } | ||
67 | else throw "unknown constructor: " + tag; | ||
68 | std::shared_ptr<::ArrayValue> o(new ::ArrayValue()); | ||
69 | o->tag = tagType; | ||
70 | return o; | ||
71 | } | ||
72 | |||
73 | template<> json toJSON<std::shared_ptr<Value>>(std::shared_ptr<Value> &v) { | ||
74 | json obj({}); | ||
75 | switch (v->tag) { | ||
76 | case ::Value::tag::VBool: | ||
77 | obj["tag"] = "VBool"; | ||
78 | { | ||
79 | std::shared_ptr<data::VBool> tv = std::static_pointer_cast<data::VBool>(v); | ||
80 | obj["arg0"] = toJSON(tv->_0); | ||
81 | } | ||
82 | break; | ||
83 | case ::Value::tag::VV2B: | ||
84 | obj["tag"] = "VV2B"; | ||
85 | { | ||
86 | std::shared_ptr<data::VV2B> tv = std::static_pointer_cast<data::VV2B>(v); | ||
87 | obj["arg0"] = toJSON(tv->_0); | ||
88 | } | ||
89 | break; | ||
90 | case ::Value::tag::VV3B: | ||
91 | obj["tag"] = "VV3B"; | ||
92 | { | ||
93 | std::shared_ptr<data::VV3B> tv = std::static_pointer_cast<data::VV3B>(v); | ||
94 | obj["arg0"] = toJSON(tv->_0); | ||
95 | } | ||
96 | break; | ||
97 | case ::Value::tag::VV4B: | ||
98 | obj["tag"] = "VV4B"; | ||
99 | { | ||
100 | std::shared_ptr<data::VV4B> tv = std::static_pointer_cast<data::VV4B>(v); | ||
101 | obj["arg0"] = toJSON(tv->_0); | ||
102 | } | ||
103 | break; | ||
104 | case ::Value::tag::VWord: | ||
105 | obj["tag"] = "VWord"; | ||
106 | { | ||
107 | std::shared_ptr<data::VWord> tv = std::static_pointer_cast<data::VWord>(v); | ||
108 | obj["arg0"] = toJSON(tv->_0); | ||
109 | } | ||
110 | break; | ||
111 | case ::Value::tag::VV2U: | ||
112 | obj["tag"] = "VV2U"; | ||
113 | { | ||
114 | std::shared_ptr<data::VV2U> tv = std::static_pointer_cast<data::VV2U>(v); | ||
115 | obj["arg0"] = toJSON(tv->_0); | ||
116 | } | ||
117 | break; | ||
118 | case ::Value::tag::VV3U: | ||
119 | obj["tag"] = "VV3U"; | ||
120 | { | ||
121 | std::shared_ptr<data::VV3U> tv = std::static_pointer_cast<data::VV3U>(v); | ||
122 | obj["arg0"] = toJSON(tv->_0); | ||
123 | } | ||
124 | break; | ||
125 | case ::Value::tag::VV4U: | ||
126 | obj["tag"] = "VV4U"; | ||
127 | { | ||
128 | std::shared_ptr<data::VV4U> tv = std::static_pointer_cast<data::VV4U>(v); | ||
129 | obj["arg0"] = toJSON(tv->_0); | ||
130 | } | ||
131 | break; | ||
132 | case ::Value::tag::VInt: | ||
133 | obj["tag"] = "VInt"; | ||
134 | { | ||
135 | std::shared_ptr<data::VInt> tv = std::static_pointer_cast<data::VInt>(v); | ||
136 | obj["arg0"] = toJSON(tv->_0); | ||
137 | } | ||
138 | break; | ||
139 | case ::Value::tag::VV2I: | ||
140 | obj["tag"] = "VV2I"; | ||
141 | { | ||
142 | std::shared_ptr<data::VV2I> tv = std::static_pointer_cast<data::VV2I>(v); | ||
143 | obj["arg0"] = toJSON(tv->_0); | ||
144 | } | ||
145 | break; | ||
146 | case ::Value::tag::VV3I: | ||
147 | obj["tag"] = "VV3I"; | ||
148 | { | ||
149 | std::shared_ptr<data::VV3I> tv = std::static_pointer_cast<data::VV3I>(v); | ||
150 | obj["arg0"] = toJSON(tv->_0); | ||
151 | } | ||
152 | break; | ||
153 | case ::Value::tag::VV4I: | ||
154 | obj["tag"] = "VV4I"; | ||
155 | { | ||
156 | std::shared_ptr<data::VV4I> tv = std::static_pointer_cast<data::VV4I>(v); | ||
157 | obj["arg0"] = toJSON(tv->_0); | ||
158 | } | ||
159 | break; | ||
160 | case ::Value::tag::VFloat: | ||
161 | obj["tag"] = "VFloat"; | ||
162 | { | ||
163 | std::shared_ptr<data::VFloat> tv = std::static_pointer_cast<data::VFloat>(v); | ||
164 | obj["arg0"] = toJSON(tv->_0); | ||
165 | } | ||
166 | break; | ||
167 | case ::Value::tag::VV2F: | ||
168 | obj["tag"] = "VV2F"; | ||
169 | { | ||
170 | std::shared_ptr<data::VV2F> tv = std::static_pointer_cast<data::VV2F>(v); | ||
171 | obj["arg0"] = toJSON(tv->_0); | ||
172 | } | ||
173 | break; | ||
174 | case ::Value::tag::VV3F: | ||
175 | obj["tag"] = "VV3F"; | ||
176 | { | ||
177 | std::shared_ptr<data::VV3F> tv = std::static_pointer_cast<data::VV3F>(v); | ||
178 | obj["arg0"] = toJSON(tv->_0); | ||
179 | } | ||
180 | break; | ||
181 | case ::Value::tag::VV4F: | ||
182 | obj["tag"] = "VV4F"; | ||
183 | { | ||
184 | std::shared_ptr<data::VV4F> tv = std::static_pointer_cast<data::VV4F>(v); | ||
185 | obj["arg0"] = toJSON(tv->_0); | ||
186 | } | ||
187 | break; | ||
188 | case ::Value::tag::VM22F: | ||
189 | obj["tag"] = "VM22F"; | ||
190 | { | ||
191 | std::shared_ptr<data::VM22F> tv = std::static_pointer_cast<data::VM22F>(v); | ||
192 | obj["arg0"] = toJSON(tv->_0); | ||
193 | } | ||
194 | break; | ||
195 | case ::Value::tag::VM23F: | ||
196 | obj["tag"] = "VM23F"; | ||
197 | { | ||
198 | std::shared_ptr<data::VM23F> tv = std::static_pointer_cast<data::VM23F>(v); | ||
199 | obj["arg0"] = toJSON(tv->_0); | ||
200 | } | ||
201 | break; | ||
202 | case ::Value::tag::VM24F: | ||
203 | obj["tag"] = "VM24F"; | ||
204 | { | ||
205 | std::shared_ptr<data::VM24F> tv = std::static_pointer_cast<data::VM24F>(v); | ||
206 | obj["arg0"] = toJSON(tv->_0); | ||
207 | } | ||
208 | break; | ||
209 | case ::Value::tag::VM32F: | ||
210 | obj["tag"] = "VM32F"; | ||
211 | { | ||
212 | std::shared_ptr<data::VM32F> tv = std::static_pointer_cast<data::VM32F>(v); | ||
213 | obj["arg0"] = toJSON(tv->_0); | ||
214 | } | ||
215 | break; | ||
216 | case ::Value::tag::VM33F: | ||
217 | obj["tag"] = "VM33F"; | ||
218 | { | ||
219 | std::shared_ptr<data::VM33F> tv = std::static_pointer_cast<data::VM33F>(v); | ||
220 | obj["arg0"] = toJSON(tv->_0); | ||
221 | } | ||
222 | break; | ||
223 | case ::Value::tag::VM34F: | ||
224 | obj["tag"] = "VM34F"; | ||
225 | { | ||
226 | std::shared_ptr<data::VM34F> tv = std::static_pointer_cast<data::VM34F>(v); | ||
227 | obj["arg0"] = toJSON(tv->_0); | ||
228 | } | ||
229 | break; | ||
230 | case ::Value::tag::VM42F: | ||
231 | obj["tag"] = "VM42F"; | ||
232 | { | ||
233 | std::shared_ptr<data::VM42F> tv = std::static_pointer_cast<data::VM42F>(v); | ||
234 | obj["arg0"] = toJSON(tv->_0); | ||
235 | } | ||
236 | break; | ||
237 | case ::Value::tag::VM43F: | ||
238 | obj["tag"] = "VM43F"; | ||
239 | { | ||
240 | std::shared_ptr<data::VM43F> tv = std::static_pointer_cast<data::VM43F>(v); | ||
241 | obj["arg0"] = toJSON(tv->_0); | ||
242 | } | ||
243 | break; | ||
244 | case ::Value::tag::VM44F: | ||
245 | obj["tag"] = "VM44F"; | ||
246 | { | ||
247 | std::shared_ptr<data::VM44F> tv = std::static_pointer_cast<data::VM44F>(v); | ||
248 | obj["arg0"] = toJSON(tv->_0); | ||
249 | } | ||
250 | break; | ||
251 | } | ||
252 | return obj; | ||
253 | } | ||
254 | |||
255 | template<> std::shared_ptr<Value> fromJSON<std::shared_ptr<Value>>(W<std::shared_ptr<Value>> v, json &obj) { | ||
256 | enum ::Value::tag tagType; | ||
257 | std::string tag = obj["tag"]; | ||
258 | if (tag == "VBool") { | ||
259 | tagType = ::Value::tag::VBool; | ||
260 | std::shared_ptr<data::VBool> tv(new data::VBool()); | ||
261 | tv->_0 = fromJSON(W<Bool>(), obj["arg0"]); | ||
262 | return tv; | ||
263 | } | ||
264 | else if (tag == "VV2B") { | ||
265 | tagType = ::Value::tag::VV2B; | ||
266 | std::shared_ptr<data::VV2B> tv(new data::VV2B()); | ||
267 | tv->_0 = fromJSON(W<V2B>(), obj["arg0"]); | ||
268 | return tv; | ||
269 | } | ||
270 | else if (tag == "VV3B") { | ||
271 | tagType = ::Value::tag::VV3B; | ||
272 | std::shared_ptr<data::VV3B> tv(new data::VV3B()); | ||
273 | tv->_0 = fromJSON(W<V3B>(), obj["arg0"]); | ||
274 | return tv; | ||
275 | } | ||
276 | else if (tag == "VV4B") { | ||
277 | tagType = ::Value::tag::VV4B; | ||
278 | std::shared_ptr<data::VV4B> tv(new data::VV4B()); | ||
279 | tv->_0 = fromJSON(W<V4B>(), obj["arg0"]); | ||
280 | return tv; | ||
281 | } | ||
282 | else if (tag == "VWord") { | ||
283 | tagType = ::Value::tag::VWord; | ||
284 | std::shared_ptr<data::VWord> tv(new data::VWord()); | ||
285 | tv->_0 = fromJSON(W<Word32>(), obj["arg0"]); | ||
286 | return tv; | ||
287 | } | ||
288 | else if (tag == "VV2U") { | ||
289 | tagType = ::Value::tag::VV2U; | ||
290 | std::shared_ptr<data::VV2U> tv(new data::VV2U()); | ||
291 | tv->_0 = fromJSON(W<V2U>(), obj["arg0"]); | ||
292 | return tv; | ||
293 | } | ||
294 | else if (tag == "VV3U") { | ||
295 | tagType = ::Value::tag::VV3U; | ||
296 | std::shared_ptr<data::VV3U> tv(new data::VV3U()); | ||
297 | tv->_0 = fromJSON(W<V3U>(), obj["arg0"]); | ||
298 | return tv; | ||
299 | } | ||
300 | else if (tag == "VV4U") { | ||
301 | tagType = ::Value::tag::VV4U; | ||
302 | std::shared_ptr<data::VV4U> tv(new data::VV4U()); | ||
303 | tv->_0 = fromJSON(W<V4U>(), obj["arg0"]); | ||
304 | return tv; | ||
305 | } | ||
306 | else if (tag == "VInt") { | ||
307 | tagType = ::Value::tag::VInt; | ||
308 | std::shared_ptr<data::VInt> tv(new data::VInt()); | ||
309 | tv->_0 = fromJSON(W<Int32>(), obj["arg0"]); | ||
310 | return tv; | ||
311 | } | ||
312 | else if (tag == "VV2I") { | ||
313 | tagType = ::Value::tag::VV2I; | ||
314 | std::shared_ptr<data::VV2I> tv(new data::VV2I()); | ||
315 | tv->_0 = fromJSON(W<V2I>(), obj["arg0"]); | ||
316 | return tv; | ||
317 | } | ||
318 | else if (tag == "VV3I") { | ||
319 | tagType = ::Value::tag::VV3I; | ||
320 | std::shared_ptr<data::VV3I> tv(new data::VV3I()); | ||
321 | tv->_0 = fromJSON(W<V3I>(), obj["arg0"]); | ||
322 | return tv; | ||
323 | } | ||
324 | else if (tag == "VV4I") { | ||
325 | tagType = ::Value::tag::VV4I; | ||
326 | std::shared_ptr<data::VV4I> tv(new data::VV4I()); | ||
327 | tv->_0 = fromJSON(W<V4I>(), obj["arg0"]); | ||
328 | return tv; | ||
329 | } | ||
330 | else if (tag == "VFloat") { | ||
331 | tagType = ::Value::tag::VFloat; | ||
332 | std::shared_ptr<data::VFloat> tv(new data::VFloat()); | ||
333 | tv->_0 = fromJSON(W<Float>(), obj["arg0"]); | ||
334 | return tv; | ||
335 | } | ||
336 | else if (tag == "VV2F") { | ||
337 | tagType = ::Value::tag::VV2F; | ||
338 | std::shared_ptr<data::VV2F> tv(new data::VV2F()); | ||
339 | tv->_0 = fromJSON(W<V2F>(), obj["arg0"]); | ||
340 | return tv; | ||
341 | } | ||
342 | else if (tag == "VV3F") { | ||
343 | tagType = ::Value::tag::VV3F; | ||
344 | std::shared_ptr<data::VV3F> tv(new data::VV3F()); | ||
345 | tv->_0 = fromJSON(W<V3F>(), obj["arg0"]); | ||
346 | return tv; | ||
347 | } | ||
348 | else if (tag == "VV4F") { | ||
349 | tagType = ::Value::tag::VV4F; | ||
350 | std::shared_ptr<data::VV4F> tv(new data::VV4F()); | ||
351 | tv->_0 = fromJSON(W<V4F>(), obj["arg0"]); | ||
352 | return tv; | ||
353 | } | ||
354 | else if (tag == "VM22F") { | ||
355 | tagType = ::Value::tag::VM22F; | ||
356 | std::shared_ptr<data::VM22F> tv(new data::VM22F()); | ||
357 | tv->_0 = fromJSON(W<M22F>(), obj["arg0"]); | ||
358 | return tv; | ||
359 | } | ||
360 | else if (tag == "VM23F") { | ||
361 | tagType = ::Value::tag::VM23F; | ||
362 | std::shared_ptr<data::VM23F> tv(new data::VM23F()); | ||
363 | tv->_0 = fromJSON(W<M23F>(), obj["arg0"]); | ||
364 | return tv; | ||
365 | } | ||
366 | else if (tag == "VM24F") { | ||
367 | tagType = ::Value::tag::VM24F; | ||
368 | std::shared_ptr<data::VM24F> tv(new data::VM24F()); | ||
369 | tv->_0 = fromJSON(W<M24F>(), obj["arg0"]); | ||
370 | return tv; | ||
371 | } | ||
372 | else if (tag == "VM32F") { | ||
373 | tagType = ::Value::tag::VM32F; | ||
374 | std::shared_ptr<data::VM32F> tv(new data::VM32F()); | ||
375 | tv->_0 = fromJSON(W<M32F>(), obj["arg0"]); | ||
376 | return tv; | ||
377 | } | ||
378 | else if (tag == "VM33F") { | ||
379 | tagType = ::Value::tag::VM33F; | ||
380 | std::shared_ptr<data::VM33F> tv(new data::VM33F()); | ||
381 | tv->_0 = fromJSON(W<M33F>(), obj["arg0"]); | ||
382 | return tv; | ||
383 | } | ||
384 | else if (tag == "VM34F") { | ||
385 | tagType = ::Value::tag::VM34F; | ||
386 | std::shared_ptr<data::VM34F> tv(new data::VM34F()); | ||
387 | tv->_0 = fromJSON(W<M34F>(), obj["arg0"]); | ||
388 | return tv; | ||
389 | } | ||
390 | else if (tag == "VM42F") { | ||
391 | tagType = ::Value::tag::VM42F; | ||
392 | std::shared_ptr<data::VM42F> tv(new data::VM42F()); | ||
393 | tv->_0 = fromJSON(W<M42F>(), obj["arg0"]); | ||
394 | return tv; | ||
395 | } | ||
396 | else if (tag == "VM43F") { | ||
397 | tagType = ::Value::tag::VM43F; | ||
398 | std::shared_ptr<data::VM43F> tv(new data::VM43F()); | ||
399 | tv->_0 = fromJSON(W<M43F>(), obj["arg0"]); | ||
400 | return tv; | ||
401 | } | ||
402 | else if (tag == "VM44F") { | ||
403 | tagType = ::Value::tag::VM44F; | ||
404 | std::shared_ptr<data::VM44F> tv(new data::VM44F()); | ||
405 | tv->_0 = fromJSON(W<M44F>(), obj["arg0"]); | ||
406 | return tv; | ||
407 | } | ||
408 | else throw "unknown constructor: " + tag; | ||
409 | std::shared_ptr<::Value> o(new ::Value()); | ||
410 | o->tag = tagType; | ||
411 | return o; | ||
412 | } | ||
413 | |||
414 | template<> json toJSON<std::shared_ptr<InputType>>(std::shared_ptr<InputType> &v) { | ||
415 | json obj({}); | ||
416 | switch (v->tag) { | ||
417 | case ::InputType::tag::Bool: | ||
418 | obj["tag"] = "Bool"; | ||
419 | break; | ||
420 | case ::InputType::tag::V2B: | ||
421 | obj["tag"] = "V2B"; | ||
422 | break; | ||
423 | case ::InputType::tag::V3B: | ||
424 | obj["tag"] = "V3B"; | ||
425 | break; | ||
426 | case ::InputType::tag::V4B: | ||
427 | obj["tag"] = "V4B"; | ||
428 | break; | ||
429 | case ::InputType::tag::Word: | ||
430 | obj["tag"] = "Word"; | ||
431 | break; | ||
432 | case ::InputType::tag::V2U: | ||
433 | obj["tag"] = "V2U"; | ||
434 | break; | ||
435 | case ::InputType::tag::V3U: | ||
436 | obj["tag"] = "V3U"; | ||
437 | break; | ||
438 | case ::InputType::tag::V4U: | ||
439 | obj["tag"] = "V4U"; | ||
440 | break; | ||
441 | case ::InputType::tag::Int: | ||
442 | obj["tag"] = "Int"; | ||
443 | break; | ||
444 | case ::InputType::tag::V2I: | ||
445 | obj["tag"] = "V2I"; | ||
446 | break; | ||
447 | case ::InputType::tag::V3I: | ||
448 | obj["tag"] = "V3I"; | ||
449 | break; | ||
450 | case ::InputType::tag::V4I: | ||
451 | obj["tag"] = "V4I"; | ||
452 | break; | ||
453 | case ::InputType::tag::Float: | ||
454 | obj["tag"] = "Float"; | ||
455 | break; | ||
456 | case ::InputType::tag::V2F: | ||
457 | obj["tag"] = "V2F"; | ||
458 | break; | ||
459 | case ::InputType::tag::V3F: | ||
460 | obj["tag"] = "V3F"; | ||
461 | break; | ||
462 | case ::InputType::tag::V4F: | ||
463 | obj["tag"] = "V4F"; | ||
464 | break; | ||
465 | case ::InputType::tag::M22F: | ||
466 | obj["tag"] = "M22F"; | ||
467 | break; | ||
468 | case ::InputType::tag::M23F: | ||
469 | obj["tag"] = "M23F"; | ||
470 | break; | ||
471 | case ::InputType::tag::M24F: | ||
472 | obj["tag"] = "M24F"; | ||
473 | break; | ||
474 | case ::InputType::tag::M32F: | ||
475 | obj["tag"] = "M32F"; | ||
476 | break; | ||
477 | case ::InputType::tag::M33F: | ||
478 | obj["tag"] = "M33F"; | ||
479 | break; | ||
480 | case ::InputType::tag::M34F: | ||
481 | obj["tag"] = "M34F"; | ||
482 | break; | ||
483 | case ::InputType::tag::M42F: | ||
484 | obj["tag"] = "M42F"; | ||
485 | break; | ||
486 | case ::InputType::tag::M43F: | ||
487 | obj["tag"] = "M43F"; | ||
488 | break; | ||
489 | case ::InputType::tag::M44F: | ||
490 | obj["tag"] = "M44F"; | ||
491 | break; | ||
492 | case ::InputType::tag::STexture1D: | ||
493 | obj["tag"] = "STexture1D"; | ||
494 | break; | ||
495 | case ::InputType::tag::STexture2D: | ||
496 | obj["tag"] = "STexture2D"; | ||
497 | break; | ||
498 | case ::InputType::tag::STextureCube: | ||
499 | obj["tag"] = "STextureCube"; | ||
500 | break; | ||
501 | case ::InputType::tag::STexture1DArray: | ||
502 | obj["tag"] = "STexture1DArray"; | ||
503 | break; | ||
504 | case ::InputType::tag::STexture2DArray: | ||
505 | obj["tag"] = "STexture2DArray"; | ||
506 | break; | ||
507 | case ::InputType::tag::STexture2DRect: | ||
508 | obj["tag"] = "STexture2DRect"; | ||
509 | break; | ||
510 | case ::InputType::tag::FTexture1D: | ||
511 | obj["tag"] = "FTexture1D"; | ||
512 | break; | ||
513 | case ::InputType::tag::FTexture2D: | ||
514 | obj["tag"] = "FTexture2D"; | ||
515 | break; | ||
516 | case ::InputType::tag::FTexture3D: | ||
517 | obj["tag"] = "FTexture3D"; | ||
518 | break; | ||
519 | case ::InputType::tag::FTextureCube: | ||
520 | obj["tag"] = "FTextureCube"; | ||
521 | break; | ||
522 | case ::InputType::tag::FTexture1DArray: | ||
523 | obj["tag"] = "FTexture1DArray"; | ||
524 | break; | ||
525 | case ::InputType::tag::FTexture2DArray: | ||
526 | obj["tag"] = "FTexture2DArray"; | ||
527 | break; | ||
528 | case ::InputType::tag::FTexture2DMS: | ||
529 | obj["tag"] = "FTexture2DMS"; | ||
530 | break; | ||
531 | case ::InputType::tag::FTexture2DMSArray: | ||
532 | obj["tag"] = "FTexture2DMSArray"; | ||
533 | break; | ||
534 | case ::InputType::tag::FTextureBuffer: | ||
535 | obj["tag"] = "FTextureBuffer"; | ||
536 | break; | ||
537 | case ::InputType::tag::FTexture2DRect: | ||
538 | obj["tag"] = "FTexture2DRect"; | ||
539 | break; | ||
540 | case ::InputType::tag::ITexture1D: | ||
541 | obj["tag"] = "ITexture1D"; | ||
542 | break; | ||
543 | case ::InputType::tag::ITexture2D: | ||
544 | obj["tag"] = "ITexture2D"; | ||
545 | break; | ||
546 | case ::InputType::tag::ITexture3D: | ||
547 | obj["tag"] = "ITexture3D"; | ||
548 | break; | ||
549 | case ::InputType::tag::ITextureCube: | ||
550 | obj["tag"] = "ITextureCube"; | ||
551 | break; | ||
552 | case ::InputType::tag::ITexture1DArray: | ||
553 | obj["tag"] = "ITexture1DArray"; | ||
554 | break; | ||
555 | case ::InputType::tag::ITexture2DArray: | ||
556 | obj["tag"] = "ITexture2DArray"; | ||
557 | break; | ||
558 | case ::InputType::tag::ITexture2DMS: | ||
559 | obj["tag"] = "ITexture2DMS"; | ||
560 | break; | ||
561 | case ::InputType::tag::ITexture2DMSArray: | ||
562 | obj["tag"] = "ITexture2DMSArray"; | ||
563 | break; | ||
564 | case ::InputType::tag::ITextureBuffer: | ||
565 | obj["tag"] = "ITextureBuffer"; | ||
566 | break; | ||
567 | case ::InputType::tag::ITexture2DRect: | ||
568 | obj["tag"] = "ITexture2DRect"; | ||
569 | break; | ||
570 | case ::InputType::tag::UTexture1D: | ||
571 | obj["tag"] = "UTexture1D"; | ||
572 | break; | ||
573 | case ::InputType::tag::UTexture2D: | ||
574 | obj["tag"] = "UTexture2D"; | ||
575 | break; | ||
576 | case ::InputType::tag::UTexture3D: | ||
577 | obj["tag"] = "UTexture3D"; | ||
578 | break; | ||
579 | case ::InputType::tag::UTextureCube: | ||
580 | obj["tag"] = "UTextureCube"; | ||
581 | break; | ||
582 | case ::InputType::tag::UTexture1DArray: | ||
583 | obj["tag"] = "UTexture1DArray"; | ||
584 | break; | ||
585 | case ::InputType::tag::UTexture2DArray: | ||
586 | obj["tag"] = "UTexture2DArray"; | ||
587 | break; | ||
588 | case ::InputType::tag::UTexture2DMS: | ||
589 | obj["tag"] = "UTexture2DMS"; | ||
590 | break; | ||
591 | case ::InputType::tag::UTexture2DMSArray: | ||
592 | obj["tag"] = "UTexture2DMSArray"; | ||
593 | break; | ||
594 | case ::InputType::tag::UTextureBuffer: | ||
595 | obj["tag"] = "UTextureBuffer"; | ||
596 | break; | ||
597 | case ::InputType::tag::UTexture2DRect: | ||
598 | obj["tag"] = "UTexture2DRect"; | ||
599 | break; | ||
600 | } | ||
601 | return obj; | ||
602 | } | ||
603 | |||
604 | template<> std::shared_ptr<InputType> fromJSON<std::shared_ptr<InputType>>(W<std::shared_ptr<InputType>> v, json &obj) { | ||
605 | enum ::InputType::tag tagType; | ||
606 | std::string tag = obj["tag"]; | ||
607 | if (tag == "Bool") { | ||
608 | tagType = ::InputType::tag::Bool; | ||
609 | } | ||
610 | else if (tag == "V2B") { | ||
611 | tagType = ::InputType::tag::V2B; | ||
612 | } | ||
613 | else if (tag == "V3B") { | ||
614 | tagType = ::InputType::tag::V3B; | ||
615 | } | ||
616 | else if (tag == "V4B") { | ||
617 | tagType = ::InputType::tag::V4B; | ||
618 | } | ||
619 | else if (tag == "Word") { | ||
620 | tagType = ::InputType::tag::Word; | ||
621 | } | ||
622 | else if (tag == "V2U") { | ||
623 | tagType = ::InputType::tag::V2U; | ||
624 | } | ||
625 | else if (tag == "V3U") { | ||
626 | tagType = ::InputType::tag::V3U; | ||
627 | } | ||
628 | else if (tag == "V4U") { | ||
629 | tagType = ::InputType::tag::V4U; | ||
630 | } | ||
631 | else if (tag == "Int") { | ||
632 | tagType = ::InputType::tag::Int; | ||
633 | } | ||
634 | else if (tag == "V2I") { | ||
635 | tagType = ::InputType::tag::V2I; | ||
636 | } | ||
637 | else if (tag == "V3I") { | ||
638 | tagType = ::InputType::tag::V3I; | ||
639 | } | ||
640 | else if (tag == "V4I") { | ||
641 | tagType = ::InputType::tag::V4I; | ||
642 | } | ||
643 | else if (tag == "Float") { | ||
644 | tagType = ::InputType::tag::Float; | ||
645 | } | ||
646 | else if (tag == "V2F") { | ||
647 | tagType = ::InputType::tag::V2F; | ||
648 | } | ||
649 | else if (tag == "V3F") { | ||
650 | tagType = ::InputType::tag::V3F; | ||
651 | } | ||
652 | else if (tag == "V4F") { | ||
653 | tagType = ::InputType::tag::V4F; | ||
654 | } | ||
655 | else if (tag == "M22F") { | ||
656 | tagType = ::InputType::tag::M22F; | ||
657 | } | ||
658 | else if (tag == "M23F") { | ||
659 | tagType = ::InputType::tag::M23F; | ||
660 | } | ||
661 | else if (tag == "M24F") { | ||
662 | tagType = ::InputType::tag::M24F; | ||
663 | } | ||
664 | else if (tag == "M32F") { | ||
665 | tagType = ::InputType::tag::M32F; | ||
666 | } | ||
667 | else if (tag == "M33F") { | ||
668 | tagType = ::InputType::tag::M33F; | ||
669 | } | ||
670 | else if (tag == "M34F") { | ||
671 | tagType = ::InputType::tag::M34F; | ||
672 | } | ||
673 | else if (tag == "M42F") { | ||
674 | tagType = ::InputType::tag::M42F; | ||
675 | } | ||
676 | else if (tag == "M43F") { | ||
677 | tagType = ::InputType::tag::M43F; | ||
678 | } | ||
679 | else if (tag == "M44F") { | ||
680 | tagType = ::InputType::tag::M44F; | ||
681 | } | ||
682 | else if (tag == "STexture1D") { | ||
683 | tagType = ::InputType::tag::STexture1D; | ||
684 | } | ||
685 | else if (tag == "STexture2D") { | ||
686 | tagType = ::InputType::tag::STexture2D; | ||
687 | } | ||
688 | else if (tag == "STextureCube") { | ||
689 | tagType = ::InputType::tag::STextureCube; | ||
690 | } | ||
691 | else if (tag == "STexture1DArray") { | ||
692 | tagType = ::InputType::tag::STexture1DArray; | ||
693 | } | ||
694 | else if (tag == "STexture2DArray") { | ||
695 | tagType = ::InputType::tag::STexture2DArray; | ||
696 | } | ||
697 | else if (tag == "STexture2DRect") { | ||
698 | tagType = ::InputType::tag::STexture2DRect; | ||
699 | } | ||
700 | else if (tag == "FTexture1D") { | ||
701 | tagType = ::InputType::tag::FTexture1D; | ||
702 | } | ||
703 | else if (tag == "FTexture2D") { | ||
704 | tagType = ::InputType::tag::FTexture2D; | ||
705 | } | ||
706 | else if (tag == "FTexture3D") { | ||
707 | tagType = ::InputType::tag::FTexture3D; | ||
708 | } | ||
709 | else if (tag == "FTextureCube") { | ||
710 | tagType = ::InputType::tag::FTextureCube; | ||
711 | } | ||
712 | else if (tag == "FTexture1DArray") { | ||
713 | tagType = ::InputType::tag::FTexture1DArray; | ||
714 | } | ||
715 | else if (tag == "FTexture2DArray") { | ||
716 | tagType = ::InputType::tag::FTexture2DArray; | ||
717 | } | ||
718 | else if (tag == "FTexture2DMS") { | ||
719 | tagType = ::InputType::tag::FTexture2DMS; | ||
720 | } | ||
721 | else if (tag == "FTexture2DMSArray") { | ||
722 | tagType = ::InputType::tag::FTexture2DMSArray; | ||
723 | } | ||
724 | else if (tag == "FTextureBuffer") { | ||
725 | tagType = ::InputType::tag::FTextureBuffer; | ||
726 | } | ||
727 | else if (tag == "FTexture2DRect") { | ||
728 | tagType = ::InputType::tag::FTexture2DRect; | ||
729 | } | ||
730 | else if (tag == "ITexture1D") { | ||
731 | tagType = ::InputType::tag::ITexture1D; | ||
732 | } | ||
733 | else if (tag == "ITexture2D") { | ||
734 | tagType = ::InputType::tag::ITexture2D; | ||
735 | } | ||
736 | else if (tag == "ITexture3D") { | ||
737 | tagType = ::InputType::tag::ITexture3D; | ||
738 | } | ||
739 | else if (tag == "ITextureCube") { | ||
740 | tagType = ::InputType::tag::ITextureCube; | ||
741 | } | ||
742 | else if (tag == "ITexture1DArray") { | ||
743 | tagType = ::InputType::tag::ITexture1DArray; | ||
744 | } | ||
745 | else if (tag == "ITexture2DArray") { | ||
746 | tagType = ::InputType::tag::ITexture2DArray; | ||
747 | } | ||
748 | else if (tag == "ITexture2DMS") { | ||
749 | tagType = ::InputType::tag::ITexture2DMS; | ||
750 | } | ||
751 | else if (tag == "ITexture2DMSArray") { | ||
752 | tagType = ::InputType::tag::ITexture2DMSArray; | ||
753 | } | ||
754 | else if (tag == "ITextureBuffer") { | ||
755 | tagType = ::InputType::tag::ITextureBuffer; | ||
756 | } | ||
757 | else if (tag == "ITexture2DRect") { | ||
758 | tagType = ::InputType::tag::ITexture2DRect; | ||
759 | } | ||
760 | else if (tag == "UTexture1D") { | ||
761 | tagType = ::InputType::tag::UTexture1D; | ||
762 | } | ||
763 | else if (tag == "UTexture2D") { | ||
764 | tagType = ::InputType::tag::UTexture2D; | ||
765 | } | ||
766 | else if (tag == "UTexture3D") { | ||
767 | tagType = ::InputType::tag::UTexture3D; | ||
768 | } | ||
769 | else if (tag == "UTextureCube") { | ||
770 | tagType = ::InputType::tag::UTextureCube; | ||
771 | } | ||
772 | else if (tag == "UTexture1DArray") { | ||
773 | tagType = ::InputType::tag::UTexture1DArray; | ||
774 | } | ||
775 | else if (tag == "UTexture2DArray") { | ||
776 | tagType = ::InputType::tag::UTexture2DArray; | ||
777 | } | ||
778 | else if (tag == "UTexture2DMS") { | ||
779 | tagType = ::InputType::tag::UTexture2DMS; | ||
780 | } | ||
781 | else if (tag == "UTexture2DMSArray") { | ||
782 | tagType = ::InputType::tag::UTexture2DMSArray; | ||
783 | } | ||
784 | else if (tag == "UTextureBuffer") { | ||
785 | tagType = ::InputType::tag::UTextureBuffer; | ||
786 | } | ||
787 | else if (tag == "UTexture2DRect") { | ||
788 | tagType = ::InputType::tag::UTexture2DRect; | ||
789 | } | ||
790 | else throw "unknown constructor: " + tag; | ||
791 | std::shared_ptr<::InputType> o(new ::InputType()); | ||
792 | o->tag = tagType; | ||
793 | return o; | ||
794 | } | ||
795 | |||
796 | template<> json toJSON<std::shared_ptr<PointSpriteCoordOrigin>>(std::shared_ptr<PointSpriteCoordOrigin> &v) { | ||
797 | json obj({}); | ||
798 | switch (v->tag) { | ||
799 | case ::PointSpriteCoordOrigin::tag::LowerLeft: | ||
800 | obj["tag"] = "LowerLeft"; | ||
801 | break; | ||
802 | case ::PointSpriteCoordOrigin::tag::UpperLeft: | ||
803 | obj["tag"] = "UpperLeft"; | ||
804 | break; | ||
805 | } | ||
806 | return obj; | ||
807 | } | ||
808 | |||
809 | template<> std::shared_ptr<PointSpriteCoordOrigin> fromJSON<std::shared_ptr<PointSpriteCoordOrigin>>(W<std::shared_ptr<PointSpriteCoordOrigin>> v, json &obj) { | ||
810 | enum ::PointSpriteCoordOrigin::tag tagType; | ||
811 | std::string tag = obj["tag"]; | ||
812 | if (tag == "LowerLeft") { | ||
813 | tagType = ::PointSpriteCoordOrigin::tag::LowerLeft; | ||
814 | } | ||
815 | else if (tag == "UpperLeft") { | ||
816 | tagType = ::PointSpriteCoordOrigin::tag::UpperLeft; | ||
817 | } | ||
818 | else throw "unknown constructor: " + tag; | ||
819 | std::shared_ptr<::PointSpriteCoordOrigin> o(new ::PointSpriteCoordOrigin()); | ||
820 | o->tag = tagType; | ||
821 | return o; | ||
822 | } | ||
823 | |||
824 | template<> json toJSON<std::shared_ptr<PointSize>>(std::shared_ptr<PointSize> &v) { | ||
825 | json obj({}); | ||
826 | switch (v->tag) { | ||
827 | case ::PointSize::tag::PointSize: | ||
828 | obj["tag"] = "PointSize"; | ||
829 | { | ||
830 | std::shared_ptr<data::PointSize> tv = std::static_pointer_cast<data::PointSize>(v); | ||
831 | obj["arg0"] = toJSON(tv->_0); | ||
832 | } | ||
833 | break; | ||
834 | case ::PointSize::tag::ProgramPointSize: | ||
835 | obj["tag"] = "ProgramPointSize"; | ||
836 | break; | ||
837 | } | ||
838 | return obj; | ||
839 | } | ||
840 | |||
841 | template<> std::shared_ptr<PointSize> fromJSON<std::shared_ptr<PointSize>>(W<std::shared_ptr<PointSize>> v, json &obj) { | ||
842 | enum ::PointSize::tag tagType; | ||
843 | std::string tag = obj["tag"]; | ||
844 | if (tag == "PointSize") { | ||
845 | tagType = ::PointSize::tag::PointSize; | ||
846 | std::shared_ptr<data::PointSize> tv(new data::PointSize()); | ||
847 | tv->_0 = fromJSON(W<Float>(), obj["arg0"]); | ||
848 | return tv; | ||
849 | } | ||
850 | else if (tag == "ProgramPointSize") { | ||
851 | tagType = ::PointSize::tag::ProgramPointSize; | ||
852 | } | ||
853 | else throw "unknown constructor: " + tag; | ||
854 | std::shared_ptr<::PointSize> o(new ::PointSize()); | ||
855 | o->tag = tagType; | ||
856 | return o; | ||
857 | } | ||
858 | |||
859 | template<> json toJSON<std::shared_ptr<PolygonOffset>>(std::shared_ptr<PolygonOffset> &v) { | ||
860 | json obj({}); | ||
861 | switch (v->tag) { | ||
862 | case ::PolygonOffset::tag::NoOffset: | ||
863 | obj["tag"] = "NoOffset"; | ||
864 | break; | ||
865 | case ::PolygonOffset::tag::Offset: | ||
866 | obj["tag"] = "Offset"; | ||
867 | { | ||
868 | std::shared_ptr<data::Offset> tv = std::static_pointer_cast<data::Offset>(v); | ||
869 | obj["arg0"] = toJSON(tv->_0); | ||
870 | obj["arg1"] = toJSON(tv->_1); | ||
871 | } | ||
872 | break; | ||
873 | } | ||
874 | return obj; | ||
875 | } | ||
876 | |||
877 | template<> std::shared_ptr<PolygonOffset> fromJSON<std::shared_ptr<PolygonOffset>>(W<std::shared_ptr<PolygonOffset>> v, json &obj) { | ||
878 | enum ::PolygonOffset::tag tagType; | ||
879 | std::string tag = obj["tag"]; | ||
880 | if (tag == "NoOffset") { | ||
881 | tagType = ::PolygonOffset::tag::NoOffset; | ||
882 | } | ||
883 | else if (tag == "Offset") { | ||
884 | tagType = ::PolygonOffset::tag::Offset; | ||
885 | std::shared_ptr<data::Offset> tv(new data::Offset()); | ||
886 | tv->_0 = fromJSON(W<Float>(), obj["arg0"]); | ||
887 | tv->_1 = fromJSON(W<Float>(), obj["arg1"]); | ||
888 | return tv; | ||
889 | } | ||
890 | else throw "unknown constructor: " + tag; | ||
891 | std::shared_ptr<::PolygonOffset> o(new ::PolygonOffset()); | ||
892 | o->tag = tagType; | ||
893 | return o; | ||
894 | } | ||
895 | |||
896 | template<> json toJSON<std::shared_ptr<FrontFace>>(std::shared_ptr<FrontFace> &v) { | ||
897 | json obj({}); | ||
898 | switch (v->tag) { | ||
899 | case ::FrontFace::tag::CCW: | ||
900 | obj["tag"] = "CCW"; | ||
901 | break; | ||
902 | case ::FrontFace::tag::CW: | ||
903 | obj["tag"] = "CW"; | ||
904 | break; | ||
905 | } | ||
906 | return obj; | ||
907 | } | ||
908 | |||
909 | template<> std::shared_ptr<FrontFace> fromJSON<std::shared_ptr<FrontFace>>(W<std::shared_ptr<FrontFace>> v, json &obj) { | ||
910 | enum ::FrontFace::tag tagType; | ||
911 | std::string tag = obj["tag"]; | ||
912 | if (tag == "CCW") { | ||
913 | tagType = ::FrontFace::tag::CCW; | ||
914 | } | ||
915 | else if (tag == "CW") { | ||
916 | tagType = ::FrontFace::tag::CW; | ||
917 | } | ||
918 | else throw "unknown constructor: " + tag; | ||
919 | std::shared_ptr<::FrontFace> o(new ::FrontFace()); | ||
920 | o->tag = tagType; | ||
921 | return o; | ||
922 | } | ||
923 | |||
924 | template<> json toJSON<std::shared_ptr<PolygonMode>>(std::shared_ptr<PolygonMode> &v) { | ||
925 | json obj({}); | ||
926 | switch (v->tag) { | ||
927 | case ::PolygonMode::tag::PolygonPoint: | ||
928 | obj["tag"] = "PolygonPoint"; | ||
929 | { | ||
930 | std::shared_ptr<data::PolygonPoint> tv = std::static_pointer_cast<data::PolygonPoint>(v); | ||
931 | obj["arg0"] = toJSON(tv->_0); | ||
932 | } | ||
933 | break; | ||
934 | case ::PolygonMode::tag::PolygonLine: | ||
935 | obj["tag"] = "PolygonLine"; | ||
936 | { | ||
937 | std::shared_ptr<data::PolygonLine> tv = std::static_pointer_cast<data::PolygonLine>(v); | ||
938 | obj["arg0"] = toJSON(tv->_0); | ||
939 | } | ||
940 | break; | ||
941 | case ::PolygonMode::tag::PolygonFill: | ||
942 | obj["tag"] = "PolygonFill"; | ||
943 | break; | ||
944 | } | ||
945 | return obj; | ||
946 | } | ||
947 | |||
948 | template<> std::shared_ptr<PolygonMode> fromJSON<std::shared_ptr<PolygonMode>>(W<std::shared_ptr<PolygonMode>> v, json &obj) { | ||
949 | enum ::PolygonMode::tag tagType; | ||
950 | std::string tag = obj["tag"]; | ||
951 | if (tag == "PolygonPoint") { | ||
952 | tagType = ::PolygonMode::tag::PolygonPoint; | ||
953 | std::shared_ptr<data::PolygonPoint> tv(new data::PolygonPoint()); | ||
954 | tv->_0 = fromJSON(W<std::shared_ptr<::PointSize>>(), obj["arg0"]); | ||
955 | return tv; | ||
956 | } | ||
957 | else if (tag == "PolygonLine") { | ||
958 | tagType = ::PolygonMode::tag::PolygonLine; | ||
959 | std::shared_ptr<data::PolygonLine> tv(new data::PolygonLine()); | ||
960 | tv->_0 = fromJSON(W<Float>(), obj["arg0"]); | ||
961 | return tv; | ||
962 | } | ||
963 | else if (tag == "PolygonFill") { | ||
964 | tagType = ::PolygonMode::tag::PolygonFill; | ||
965 | } | ||
966 | else throw "unknown constructor: " + tag; | ||
967 | std::shared_ptr<::PolygonMode> o(new ::PolygonMode()); | ||
968 | o->tag = tagType; | ||
969 | return o; | ||
970 | } | ||
971 | |||
972 | template<> json toJSON<std::shared_ptr<ProvokingVertex>>(std::shared_ptr<ProvokingVertex> &v) { | ||
973 | json obj({}); | ||
974 | switch (v->tag) { | ||
975 | case ::ProvokingVertex::tag::FirstVertex: | ||
976 | obj["tag"] = "FirstVertex"; | ||
977 | break; | ||
978 | case ::ProvokingVertex::tag::LastVertex: | ||
979 | obj["tag"] = "LastVertex"; | ||
980 | break; | ||
981 | } | ||
982 | return obj; | ||
983 | } | ||
984 | |||
985 | template<> std::shared_ptr<ProvokingVertex> fromJSON<std::shared_ptr<ProvokingVertex>>(W<std::shared_ptr<ProvokingVertex>> v, json &obj) { | ||
986 | enum ::ProvokingVertex::tag tagType; | ||
987 | std::string tag = obj["tag"]; | ||
988 | if (tag == "FirstVertex") { | ||
989 | tagType = ::ProvokingVertex::tag::FirstVertex; | ||
990 | } | ||
991 | else if (tag == "LastVertex") { | ||
992 | tagType = ::ProvokingVertex::tag::LastVertex; | ||
993 | } | ||
994 | else throw "unknown constructor: " + tag; | ||
995 | std::shared_ptr<::ProvokingVertex> o(new ::ProvokingVertex()); | ||
996 | o->tag = tagType; | ||
997 | return o; | ||
998 | } | ||
999 | |||
1000 | template<> json toJSON<std::shared_ptr<CullMode>>(std::shared_ptr<CullMode> &v) { | ||
1001 | json obj({}); | ||
1002 | switch (v->tag) { | ||
1003 | case ::CullMode::tag::CullNone: | ||
1004 | obj["tag"] = "CullNone"; | ||
1005 | break; | ||
1006 | case ::CullMode::tag::CullFront: | ||
1007 | obj["tag"] = "CullFront"; | ||
1008 | { | ||
1009 | std::shared_ptr<data::CullFront> tv = std::static_pointer_cast<data::CullFront>(v); | ||
1010 | obj["arg0"] = toJSON(tv->_0); | ||
1011 | } | ||
1012 | break; | ||
1013 | case ::CullMode::tag::CullBack: | ||
1014 | obj["tag"] = "CullBack"; | ||
1015 | { | ||
1016 | std::shared_ptr<data::CullBack> tv = std::static_pointer_cast<data::CullBack>(v); | ||
1017 | obj["arg0"] = toJSON(tv->_0); | ||
1018 | } | ||
1019 | break; | ||
1020 | } | ||
1021 | return obj; | ||
1022 | } | ||
1023 | |||
1024 | template<> std::shared_ptr<CullMode> fromJSON<std::shared_ptr<CullMode>>(W<std::shared_ptr<CullMode>> v, json &obj) { | ||
1025 | enum ::CullMode::tag tagType; | ||
1026 | std::string tag = obj["tag"]; | ||
1027 | if (tag == "CullNone") { | ||
1028 | tagType = ::CullMode::tag::CullNone; | ||
1029 | } | ||
1030 | else if (tag == "CullFront") { | ||
1031 | tagType = ::CullMode::tag::CullFront; | ||
1032 | std::shared_ptr<data::CullFront> tv(new data::CullFront()); | ||
1033 | tv->_0 = fromJSON(W<std::shared_ptr<::FrontFace>>(), obj["arg0"]); | ||
1034 | return tv; | ||
1035 | } | ||
1036 | else if (tag == "CullBack") { | ||
1037 | tagType = ::CullMode::tag::CullBack; | ||
1038 | std::shared_ptr<data::CullBack> tv(new data::CullBack()); | ||
1039 | tv->_0 = fromJSON(W<std::shared_ptr<::FrontFace>>(), obj["arg0"]); | ||
1040 | return tv; | ||
1041 | } | ||
1042 | else throw "unknown constructor: " + tag; | ||
1043 | std::shared_ptr<::CullMode> o(new ::CullMode()); | ||
1044 | o->tag = tagType; | ||
1045 | return o; | ||
1046 | } | ||
1047 | |||
1048 | template<> json toJSON<std::shared_ptr<ComparisonFunction>>(std::shared_ptr<ComparisonFunction> &v) { | ||
1049 | json obj({}); | ||
1050 | switch (v->tag) { | ||
1051 | case ::ComparisonFunction::tag::Never: | ||
1052 | obj["tag"] = "Never"; | ||
1053 | break; | ||
1054 | case ::ComparisonFunction::tag::Less: | ||
1055 | obj["tag"] = "Less"; | ||
1056 | break; | ||
1057 | case ::ComparisonFunction::tag::Equal: | ||
1058 | obj["tag"] = "Equal"; | ||
1059 | break; | ||
1060 | case ::ComparisonFunction::tag::Lequal: | ||
1061 | obj["tag"] = "Lequal"; | ||
1062 | break; | ||
1063 | case ::ComparisonFunction::tag::Greater: | ||
1064 | obj["tag"] = "Greater"; | ||
1065 | break; | ||
1066 | case ::ComparisonFunction::tag::Notequal: | ||
1067 | obj["tag"] = "Notequal"; | ||
1068 | break; | ||
1069 | case ::ComparisonFunction::tag::Gequal: | ||
1070 | obj["tag"] = "Gequal"; | ||
1071 | break; | ||
1072 | case ::ComparisonFunction::tag::Always: | ||
1073 | obj["tag"] = "Always"; | ||
1074 | break; | ||
1075 | } | ||
1076 | return obj; | ||
1077 | } | ||
1078 | |||
1079 | template<> std::shared_ptr<ComparisonFunction> fromJSON<std::shared_ptr<ComparisonFunction>>(W<std::shared_ptr<ComparisonFunction>> v, json &obj) { | ||
1080 | enum ::ComparisonFunction::tag tagType; | ||
1081 | std::string tag = obj["tag"]; | ||
1082 | if (tag == "Never") { | ||
1083 | tagType = ::ComparisonFunction::tag::Never; | ||
1084 | } | ||
1085 | else if (tag == "Less") { | ||
1086 | tagType = ::ComparisonFunction::tag::Less; | ||
1087 | } | ||
1088 | else if (tag == "Equal") { | ||
1089 | tagType = ::ComparisonFunction::tag::Equal; | ||
1090 | } | ||
1091 | else if (tag == "Lequal") { | ||
1092 | tagType = ::ComparisonFunction::tag::Lequal; | ||
1093 | } | ||
1094 | else if (tag == "Greater") { | ||
1095 | tagType = ::ComparisonFunction::tag::Greater; | ||
1096 | } | ||
1097 | else if (tag == "Notequal") { | ||
1098 | tagType = ::ComparisonFunction::tag::Notequal; | ||
1099 | } | ||
1100 | else if (tag == "Gequal") { | ||
1101 | tagType = ::ComparisonFunction::tag::Gequal; | ||
1102 | } | ||
1103 | else if (tag == "Always") { | ||
1104 | tagType = ::ComparisonFunction::tag::Always; | ||
1105 | } | ||
1106 | else throw "unknown constructor: " + tag; | ||
1107 | std::shared_ptr<::ComparisonFunction> o(new ::ComparisonFunction()); | ||
1108 | o->tag = tagType; | ||
1109 | return o; | ||
1110 | } | ||
1111 | |||
1112 | template<> json toJSON<std::shared_ptr<StencilOperation>>(std::shared_ptr<StencilOperation> &v) { | ||
1113 | json obj({}); | ||
1114 | switch (v->tag) { | ||
1115 | case ::StencilOperation::tag::OpZero: | ||
1116 | obj["tag"] = "OpZero"; | ||
1117 | break; | ||
1118 | case ::StencilOperation::tag::OpKeep: | ||
1119 | obj["tag"] = "OpKeep"; | ||
1120 | break; | ||
1121 | case ::StencilOperation::tag::OpReplace: | ||
1122 | obj["tag"] = "OpReplace"; | ||
1123 | break; | ||
1124 | case ::StencilOperation::tag::OpIncr: | ||
1125 | obj["tag"] = "OpIncr"; | ||
1126 | break; | ||
1127 | case ::StencilOperation::tag::OpIncrWrap: | ||
1128 | obj["tag"] = "OpIncrWrap"; | ||
1129 | break; | ||
1130 | case ::StencilOperation::tag::OpDecr: | ||
1131 | obj["tag"] = "OpDecr"; | ||
1132 | break; | ||
1133 | case ::StencilOperation::tag::OpDecrWrap: | ||
1134 | obj["tag"] = "OpDecrWrap"; | ||
1135 | break; | ||
1136 | case ::StencilOperation::tag::OpInvert: | ||
1137 | obj["tag"] = "OpInvert"; | ||
1138 | break; | ||
1139 | } | ||
1140 | return obj; | ||
1141 | } | ||
1142 | |||
1143 | template<> std::shared_ptr<StencilOperation> fromJSON<std::shared_ptr<StencilOperation>>(W<std::shared_ptr<StencilOperation>> v, json &obj) { | ||
1144 | enum ::StencilOperation::tag tagType; | ||
1145 | std::string tag = obj["tag"]; | ||
1146 | if (tag == "OpZero") { | ||
1147 | tagType = ::StencilOperation::tag::OpZero; | ||
1148 | } | ||
1149 | else if (tag == "OpKeep") { | ||
1150 | tagType = ::StencilOperation::tag::OpKeep; | ||
1151 | } | ||
1152 | else if (tag == "OpReplace") { | ||
1153 | tagType = ::StencilOperation::tag::OpReplace; | ||
1154 | } | ||
1155 | else if (tag == "OpIncr") { | ||
1156 | tagType = ::StencilOperation::tag::OpIncr; | ||
1157 | } | ||
1158 | else if (tag == "OpIncrWrap") { | ||
1159 | tagType = ::StencilOperation::tag::OpIncrWrap; | ||
1160 | } | ||
1161 | else if (tag == "OpDecr") { | ||
1162 | tagType = ::StencilOperation::tag::OpDecr; | ||
1163 | } | ||
1164 | else if (tag == "OpDecrWrap") { | ||
1165 | tagType = ::StencilOperation::tag::OpDecrWrap; | ||
1166 | } | ||
1167 | else if (tag == "OpInvert") { | ||
1168 | tagType = ::StencilOperation::tag::OpInvert; | ||
1169 | } | ||
1170 | else throw "unknown constructor: " + tag; | ||
1171 | std::shared_ptr<::StencilOperation> o(new ::StencilOperation()); | ||
1172 | o->tag = tagType; | ||
1173 | return o; | ||
1174 | } | ||
1175 | |||
1176 | template<> json toJSON<std::shared_ptr<BlendEquation>>(std::shared_ptr<BlendEquation> &v) { | ||
1177 | json obj({}); | ||
1178 | switch (v->tag) { | ||
1179 | case ::BlendEquation::tag::FuncAdd: | ||
1180 | obj["tag"] = "FuncAdd"; | ||
1181 | break; | ||
1182 | case ::BlendEquation::tag::FuncSubtract: | ||
1183 | obj["tag"] = "FuncSubtract"; | ||
1184 | break; | ||
1185 | case ::BlendEquation::tag::FuncReverseSubtract: | ||
1186 | obj["tag"] = "FuncReverseSubtract"; | ||
1187 | break; | ||
1188 | case ::BlendEquation::tag::Min: | ||
1189 | obj["tag"] = "Min"; | ||
1190 | break; | ||
1191 | case ::BlendEquation::tag::Max: | ||
1192 | obj["tag"] = "Max"; | ||
1193 | break; | ||
1194 | } | ||
1195 | return obj; | ||
1196 | } | ||
1197 | |||
1198 | template<> std::shared_ptr<BlendEquation> fromJSON<std::shared_ptr<BlendEquation>>(W<std::shared_ptr<BlendEquation>> v, json &obj) { | ||
1199 | enum ::BlendEquation::tag tagType; | ||
1200 | std::string tag = obj["tag"]; | ||
1201 | if (tag == "FuncAdd") { | ||
1202 | tagType = ::BlendEquation::tag::FuncAdd; | ||
1203 | } | ||
1204 | else if (tag == "FuncSubtract") { | ||
1205 | tagType = ::BlendEquation::tag::FuncSubtract; | ||
1206 | } | ||
1207 | else if (tag == "FuncReverseSubtract") { | ||
1208 | tagType = ::BlendEquation::tag::FuncReverseSubtract; | ||
1209 | } | ||
1210 | else if (tag == "Min") { | ||
1211 | tagType = ::BlendEquation::tag::Min; | ||
1212 | } | ||
1213 | else if (tag == "Max") { | ||
1214 | tagType = ::BlendEquation::tag::Max; | ||
1215 | } | ||
1216 | else throw "unknown constructor: " + tag; | ||
1217 | std::shared_ptr<::BlendEquation> o(new ::BlendEquation()); | ||
1218 | o->tag = tagType; | ||
1219 | return o; | ||
1220 | } | ||
1221 | |||
1222 | template<> json toJSON<std::shared_ptr<BlendingFactor>>(std::shared_ptr<BlendingFactor> &v) { | ||
1223 | json obj({}); | ||
1224 | switch (v->tag) { | ||
1225 | case ::BlendingFactor::tag::Zero: | ||
1226 | obj["tag"] = "Zero"; | ||
1227 | break; | ||
1228 | case ::BlendingFactor::tag::One: | ||
1229 | obj["tag"] = "One"; | ||
1230 | break; | ||
1231 | case ::BlendingFactor::tag::SrcColor: | ||
1232 | obj["tag"] = "SrcColor"; | ||
1233 | break; | ||
1234 | case ::BlendingFactor::tag::OneMinusSrcColor: | ||
1235 | obj["tag"] = "OneMinusSrcColor"; | ||
1236 | break; | ||
1237 | case ::BlendingFactor::tag::DstColor: | ||
1238 | obj["tag"] = "DstColor"; | ||
1239 | break; | ||
1240 | case ::BlendingFactor::tag::OneMinusDstColor: | ||
1241 | obj["tag"] = "OneMinusDstColor"; | ||
1242 | break; | ||
1243 | case ::BlendingFactor::tag::SrcAlpha: | ||
1244 | obj["tag"] = "SrcAlpha"; | ||
1245 | break; | ||
1246 | case ::BlendingFactor::tag::OneMinusSrcAlpha: | ||
1247 | obj["tag"] = "OneMinusSrcAlpha"; | ||
1248 | break; | ||
1249 | case ::BlendingFactor::tag::DstAlpha: | ||
1250 | obj["tag"] = "DstAlpha"; | ||
1251 | break; | ||
1252 | case ::BlendingFactor::tag::OneMinusDstAlpha: | ||
1253 | obj["tag"] = "OneMinusDstAlpha"; | ||
1254 | break; | ||
1255 | case ::BlendingFactor::tag::ConstantColor: | ||
1256 | obj["tag"] = "ConstantColor"; | ||
1257 | break; | ||
1258 | case ::BlendingFactor::tag::OneMinusConstantColor: | ||
1259 | obj["tag"] = "OneMinusConstantColor"; | ||
1260 | break; | ||
1261 | case ::BlendingFactor::tag::ConstantAlpha: | ||
1262 | obj["tag"] = "ConstantAlpha"; | ||
1263 | break; | ||
1264 | case ::BlendingFactor::tag::OneMinusConstantAlpha: | ||
1265 | obj["tag"] = "OneMinusConstantAlpha"; | ||
1266 | break; | ||
1267 | case ::BlendingFactor::tag::SrcAlphaSaturate: | ||
1268 | obj["tag"] = "SrcAlphaSaturate"; | ||
1269 | break; | ||
1270 | } | ||
1271 | return obj; | ||
1272 | } | ||
1273 | |||
1274 | template<> std::shared_ptr<BlendingFactor> fromJSON<std::shared_ptr<BlendingFactor>>(W<std::shared_ptr<BlendingFactor>> v, json &obj) { | ||
1275 | enum ::BlendingFactor::tag tagType; | ||
1276 | std::string tag = obj["tag"]; | ||
1277 | if (tag == "Zero") { | ||
1278 | tagType = ::BlendingFactor::tag::Zero; | ||
1279 | } | ||
1280 | else if (tag == "One") { | ||
1281 | tagType = ::BlendingFactor::tag::One; | ||
1282 | } | ||
1283 | else if (tag == "SrcColor") { | ||
1284 | tagType = ::BlendingFactor::tag::SrcColor; | ||
1285 | } | ||
1286 | else if (tag == "OneMinusSrcColor") { | ||
1287 | tagType = ::BlendingFactor::tag::OneMinusSrcColor; | ||
1288 | } | ||
1289 | else if (tag == "DstColor") { | ||
1290 | tagType = ::BlendingFactor::tag::DstColor; | ||
1291 | } | ||
1292 | else if (tag == "OneMinusDstColor") { | ||
1293 | tagType = ::BlendingFactor::tag::OneMinusDstColor; | ||
1294 | } | ||
1295 | else if (tag == "SrcAlpha") { | ||
1296 | tagType = ::BlendingFactor::tag::SrcAlpha; | ||
1297 | } | ||
1298 | else if (tag == "OneMinusSrcAlpha") { | ||
1299 | tagType = ::BlendingFactor::tag::OneMinusSrcAlpha; | ||
1300 | } | ||
1301 | else if (tag == "DstAlpha") { | ||
1302 | tagType = ::BlendingFactor::tag::DstAlpha; | ||
1303 | } | ||
1304 | else if (tag == "OneMinusDstAlpha") { | ||
1305 | tagType = ::BlendingFactor::tag::OneMinusDstAlpha; | ||
1306 | } | ||
1307 | else if (tag == "ConstantColor") { | ||
1308 | tagType = ::BlendingFactor::tag::ConstantColor; | ||
1309 | } | ||
1310 | else if (tag == "OneMinusConstantColor") { | ||
1311 | tagType = ::BlendingFactor::tag::OneMinusConstantColor; | ||
1312 | } | ||
1313 | else if (tag == "ConstantAlpha") { | ||
1314 | tagType = ::BlendingFactor::tag::ConstantAlpha; | ||
1315 | } | ||
1316 | else if (tag == "OneMinusConstantAlpha") { | ||
1317 | tagType = ::BlendingFactor::tag::OneMinusConstantAlpha; | ||
1318 | } | ||
1319 | else if (tag == "SrcAlphaSaturate") { | ||
1320 | tagType = ::BlendingFactor::tag::SrcAlphaSaturate; | ||
1321 | } | ||
1322 | else throw "unknown constructor: " + tag; | ||
1323 | std::shared_ptr<::BlendingFactor> o(new ::BlendingFactor()); | ||
1324 | o->tag = tagType; | ||
1325 | return o; | ||
1326 | } | ||
1327 | |||
1328 | template<> json toJSON<std::shared_ptr<LogicOperation>>(std::shared_ptr<LogicOperation> &v) { | ||
1329 | json obj({}); | ||
1330 | switch (v->tag) { | ||
1331 | case ::LogicOperation::tag::Clear: | ||
1332 | obj["tag"] = "Clear"; | ||
1333 | break; | ||
1334 | case ::LogicOperation::tag::And: | ||
1335 | obj["tag"] = "And"; | ||
1336 | break; | ||
1337 | case ::LogicOperation::tag::AndReverse: | ||
1338 | obj["tag"] = "AndReverse"; | ||
1339 | break; | ||
1340 | case ::LogicOperation::tag::Copy: | ||
1341 | obj["tag"] = "Copy"; | ||
1342 | break; | ||
1343 | case ::LogicOperation::tag::AndInverted: | ||
1344 | obj["tag"] = "AndInverted"; | ||
1345 | break; | ||
1346 | case ::LogicOperation::tag::Noop: | ||
1347 | obj["tag"] = "Noop"; | ||
1348 | break; | ||
1349 | case ::LogicOperation::tag::Xor: | ||
1350 | obj["tag"] = "Xor"; | ||
1351 | break; | ||
1352 | case ::LogicOperation::tag::Or: | ||
1353 | obj["tag"] = "Or"; | ||
1354 | break; | ||
1355 | case ::LogicOperation::tag::Nor: | ||
1356 | obj["tag"] = "Nor"; | ||
1357 | break; | ||
1358 | case ::LogicOperation::tag::Equiv: | ||
1359 | obj["tag"] = "Equiv"; | ||
1360 | break; | ||
1361 | case ::LogicOperation::tag::Invert: | ||
1362 | obj["tag"] = "Invert"; | ||
1363 | break; | ||
1364 | case ::LogicOperation::tag::OrReverse: | ||
1365 | obj["tag"] = "OrReverse"; | ||
1366 | break; | ||
1367 | case ::LogicOperation::tag::CopyInverted: | ||
1368 | obj["tag"] = "CopyInverted"; | ||
1369 | break; | ||
1370 | case ::LogicOperation::tag::OrInverted: | ||
1371 | obj["tag"] = "OrInverted"; | ||
1372 | break; | ||
1373 | case ::LogicOperation::tag::Nand: | ||
1374 | obj["tag"] = "Nand"; | ||
1375 | break; | ||
1376 | case ::LogicOperation::tag::Set: | ||
1377 | obj["tag"] = "Set"; | ||
1378 | break; | ||
1379 | } | ||
1380 | return obj; | ||
1381 | } | ||
1382 | |||
1383 | template<> std::shared_ptr<LogicOperation> fromJSON<std::shared_ptr<LogicOperation>>(W<std::shared_ptr<LogicOperation>> v, json &obj) { | ||
1384 | enum ::LogicOperation::tag tagType; | ||
1385 | std::string tag = obj["tag"]; | ||
1386 | if (tag == "Clear") { | ||
1387 | tagType = ::LogicOperation::tag::Clear; | ||
1388 | } | ||
1389 | else if (tag == "And") { | ||
1390 | tagType = ::LogicOperation::tag::And; | ||
1391 | } | ||
1392 | else if (tag == "AndReverse") { | ||
1393 | tagType = ::LogicOperation::tag::AndReverse; | ||
1394 | } | ||
1395 | else if (tag == "Copy") { | ||
1396 | tagType = ::LogicOperation::tag::Copy; | ||
1397 | } | ||
1398 | else if (tag == "AndInverted") { | ||
1399 | tagType = ::LogicOperation::tag::AndInverted; | ||
1400 | } | ||
1401 | else if (tag == "Noop") { | ||
1402 | tagType = ::LogicOperation::tag::Noop; | ||
1403 | } | ||
1404 | else if (tag == "Xor") { | ||
1405 | tagType = ::LogicOperation::tag::Xor; | ||
1406 | } | ||
1407 | else if (tag == "Or") { | ||
1408 | tagType = ::LogicOperation::tag::Or; | ||
1409 | } | ||
1410 | else if (tag == "Nor") { | ||
1411 | tagType = ::LogicOperation::tag::Nor; | ||
1412 | } | ||
1413 | else if (tag == "Equiv") { | ||
1414 | tagType = ::LogicOperation::tag::Equiv; | ||
1415 | } | ||
1416 | else if (tag == "Invert") { | ||
1417 | tagType = ::LogicOperation::tag::Invert; | ||
1418 | } | ||
1419 | else if (tag == "OrReverse") { | ||
1420 | tagType = ::LogicOperation::tag::OrReverse; | ||
1421 | } | ||
1422 | else if (tag == "CopyInverted") { | ||
1423 | tagType = ::LogicOperation::tag::CopyInverted; | ||
1424 | } | ||
1425 | else if (tag == "OrInverted") { | ||
1426 | tagType = ::LogicOperation::tag::OrInverted; | ||
1427 | } | ||
1428 | else if (tag == "Nand") { | ||
1429 | tagType = ::LogicOperation::tag::Nand; | ||
1430 | } | ||
1431 | else if (tag == "Set") { | ||
1432 | tagType = ::LogicOperation::tag::Set; | ||
1433 | } | ||
1434 | else throw "unknown constructor: " + tag; | ||
1435 | std::shared_ptr<::LogicOperation> o(new ::LogicOperation()); | ||
1436 | o->tag = tagType; | ||
1437 | return o; | ||
1438 | } | ||
1439 | |||
1440 | template<> json toJSON<std::shared_ptr<StencilOps>>(std::shared_ptr<StencilOps> &v) { | ||
1441 | json obj({}); | ||
1442 | switch (v->tag) { | ||
1443 | case ::StencilOps::tag::StencilOps: | ||
1444 | obj["tag"] = "StencilOps"; | ||
1445 | { | ||
1446 | std::shared_ptr<data::StencilOps> tv = std::static_pointer_cast<data::StencilOps>(v); | ||
1447 | obj["frontStencilOp"] = toJSON(tv->frontStencilOp); | ||
1448 | obj["backStencilOp"] = toJSON(tv->backStencilOp); | ||
1449 | } | ||
1450 | break; | ||
1451 | } | ||
1452 | return obj; | ||
1453 | } | ||
1454 | |||
1455 | template<> std::shared_ptr<StencilOps> fromJSON<std::shared_ptr<StencilOps>>(W<std::shared_ptr<StencilOps>> v, json &obj) { | ||
1456 | enum ::StencilOps::tag tagType; | ||
1457 | std::string tag = obj["tag"]; | ||
1458 | if (tag == "StencilOps") { | ||
1459 | tagType = ::StencilOps::tag::StencilOps; | ||
1460 | std::shared_ptr<data::StencilOps> tv(new data::StencilOps()); | ||
1461 | tv->frontStencilOp = fromJSON(W<std::shared_ptr<::StencilOperation>>(), obj["frontStencilOp"]); | ||
1462 | tv->backStencilOp = fromJSON(W<std::shared_ptr<::StencilOperation>>(), obj["backStencilOp"]); | ||
1463 | return tv; | ||
1464 | } | ||
1465 | else throw "unknown constructor: " + tag; | ||
1466 | std::shared_ptr<::StencilOps> o(new ::StencilOps()); | ||
1467 | o->tag = tagType; | ||
1468 | return o; | ||
1469 | } | ||
1470 | |||
1471 | template<> json toJSON<std::shared_ptr<StencilTest>>(std::shared_ptr<StencilTest> &v) { | ||
1472 | json obj({}); | ||
1473 | switch (v->tag) { | ||
1474 | case ::StencilTest::tag::StencilTest: | ||
1475 | obj["tag"] = "StencilTest"; | ||
1476 | { | ||
1477 | std::shared_ptr<data::StencilTest> tv = std::static_pointer_cast<data::StencilTest>(v); | ||
1478 | obj["stencilComparision"] = toJSON(tv->stencilComparision); | ||
1479 | obj["stencilReference"] = toJSON(tv->stencilReference); | ||
1480 | obj["stencilMask"] = toJSON(tv->stencilMask); | ||
1481 | } | ||
1482 | break; | ||
1483 | } | ||
1484 | return obj; | ||
1485 | } | ||
1486 | |||
1487 | template<> std::shared_ptr<StencilTest> fromJSON<std::shared_ptr<StencilTest>>(W<std::shared_ptr<StencilTest>> v, json &obj) { | ||
1488 | enum ::StencilTest::tag tagType; | ||
1489 | std::string tag = obj["tag"]; | ||
1490 | if (tag == "StencilTest") { | ||
1491 | tagType = ::StencilTest::tag::StencilTest; | ||
1492 | std::shared_ptr<data::StencilTest> tv(new data::StencilTest()); | ||
1493 | tv->stencilComparision = fromJSON(W<std::shared_ptr<::ComparisonFunction>>(), obj["stencilComparision"]); | ||
1494 | tv->stencilReference = fromJSON(W<Int32>(), obj["stencilReference"]); | ||
1495 | tv->stencilMask = fromJSON(W<Word32>(), obj["stencilMask"]); | ||
1496 | return tv; | ||
1497 | } | ||
1498 | else throw "unknown constructor: " + tag; | ||
1499 | std::shared_ptr<::StencilTest> o(new ::StencilTest()); | ||
1500 | o->tag = tagType; | ||
1501 | return o; | ||
1502 | } | ||
1503 | |||
1504 | template<> json toJSON<std::shared_ptr<StencilTests>>(std::shared_ptr<StencilTests> &v) { | ||
1505 | json obj({}); | ||
1506 | switch (v->tag) { | ||
1507 | case ::StencilTests::tag::StencilTests: | ||
1508 | obj["tag"] = "StencilTests"; | ||
1509 | { | ||
1510 | std::shared_ptr<data::StencilTests> tv = std::static_pointer_cast<data::StencilTests>(v); | ||
1511 | obj["arg0"] = toJSON(tv->_0); | ||
1512 | obj["arg1"] = toJSON(tv->_1); | ||
1513 | } | ||
1514 | break; | ||
1515 | } | ||
1516 | return obj; | ||
1517 | } | ||
1518 | |||
1519 | template<> std::shared_ptr<StencilTests> fromJSON<std::shared_ptr<StencilTests>>(W<std::shared_ptr<StencilTests>> v, json &obj) { | ||
1520 | enum ::StencilTests::tag tagType; | ||
1521 | std::string tag = obj["tag"]; | ||
1522 | if (tag == "StencilTests") { | ||
1523 | tagType = ::StencilTests::tag::StencilTests; | ||
1524 | std::shared_ptr<data::StencilTests> tv(new data::StencilTests()); | ||
1525 | tv->_0 = fromJSON(W<std::shared_ptr<::StencilTest>>(), obj["arg0"]); | ||
1526 | tv->_1 = fromJSON(W<std::shared_ptr<::StencilTest>>(), obj["arg1"]); | ||
1527 | return tv; | ||
1528 | } | ||
1529 | else throw "unknown constructor: " + tag; | ||
1530 | std::shared_ptr<::StencilTests> o(new ::StencilTests()); | ||
1531 | o->tag = tagType; | ||
1532 | return o; | ||
1533 | } | ||
1534 | |||
1535 | template<> json toJSON<std::shared_ptr<FetchPrimitive>>(std::shared_ptr<FetchPrimitive> &v) { | ||
1536 | json obj({}); | ||
1537 | switch (v->tag) { | ||
1538 | case ::FetchPrimitive::tag::Points: | ||
1539 | obj["tag"] = "Points"; | ||
1540 | break; | ||
1541 | case ::FetchPrimitive::tag::Lines: | ||
1542 | obj["tag"] = "Lines"; | ||
1543 | break; | ||
1544 | case ::FetchPrimitive::tag::Triangles: | ||
1545 | obj["tag"] = "Triangles"; | ||
1546 | break; | ||
1547 | case ::FetchPrimitive::tag::LinesAdjacency: | ||
1548 | obj["tag"] = "LinesAdjacency"; | ||
1549 | break; | ||
1550 | case ::FetchPrimitive::tag::TrianglesAdjacency: | ||
1551 | obj["tag"] = "TrianglesAdjacency"; | ||
1552 | break; | ||
1553 | } | ||
1554 | return obj; | ||
1555 | } | ||
1556 | |||
1557 | template<> std::shared_ptr<FetchPrimitive> fromJSON<std::shared_ptr<FetchPrimitive>>(W<std::shared_ptr<FetchPrimitive>> v, json &obj) { | ||
1558 | enum ::FetchPrimitive::tag tagType; | ||
1559 | std::string tag = obj["tag"]; | ||
1560 | if (tag == "Points") { | ||
1561 | tagType = ::FetchPrimitive::tag::Points; | ||
1562 | } | ||
1563 | else if (tag == "Lines") { | ||
1564 | tagType = ::FetchPrimitive::tag::Lines; | ||
1565 | } | ||
1566 | else if (tag == "Triangles") { | ||
1567 | tagType = ::FetchPrimitive::tag::Triangles; | ||
1568 | } | ||
1569 | else if (tag == "LinesAdjacency") { | ||
1570 | tagType = ::FetchPrimitive::tag::LinesAdjacency; | ||
1571 | } | ||
1572 | else if (tag == "TrianglesAdjacency") { | ||
1573 | tagType = ::FetchPrimitive::tag::TrianglesAdjacency; | ||
1574 | } | ||
1575 | else throw "unknown constructor: " + tag; | ||
1576 | std::shared_ptr<::FetchPrimitive> o(new ::FetchPrimitive()); | ||
1577 | o->tag = tagType; | ||
1578 | return o; | ||
1579 | } | ||
1580 | |||
1581 | template<> json toJSON<std::shared_ptr<OutputPrimitive>>(std::shared_ptr<OutputPrimitive> &v) { | ||
1582 | json obj({}); | ||
1583 | switch (v->tag) { | ||
1584 | case ::OutputPrimitive::tag::TrianglesOutput: | ||
1585 | obj["tag"] = "TrianglesOutput"; | ||
1586 | break; | ||
1587 | case ::OutputPrimitive::tag::LinesOutput: | ||
1588 | obj["tag"] = "LinesOutput"; | ||
1589 | break; | ||
1590 | case ::OutputPrimitive::tag::PointsOutput: | ||
1591 | obj["tag"] = "PointsOutput"; | ||
1592 | break; | ||
1593 | } | ||
1594 | return obj; | ||
1595 | } | ||
1596 | |||
1597 | template<> std::shared_ptr<OutputPrimitive> fromJSON<std::shared_ptr<OutputPrimitive>>(W<std::shared_ptr<OutputPrimitive>> v, json &obj) { | ||
1598 | enum ::OutputPrimitive::tag tagType; | ||
1599 | std::string tag = obj["tag"]; | ||
1600 | if (tag == "TrianglesOutput") { | ||
1601 | tagType = ::OutputPrimitive::tag::TrianglesOutput; | ||
1602 | } | ||
1603 | else if (tag == "LinesOutput") { | ||
1604 | tagType = ::OutputPrimitive::tag::LinesOutput; | ||
1605 | } | ||
1606 | else if (tag == "PointsOutput") { | ||
1607 | tagType = ::OutputPrimitive::tag::PointsOutput; | ||
1608 | } | ||
1609 | else throw "unknown constructor: " + tag; | ||
1610 | std::shared_ptr<::OutputPrimitive> o(new ::OutputPrimitive()); | ||
1611 | o->tag = tagType; | ||
1612 | return o; | ||
1613 | } | ||
1614 | |||
1615 | template<> json toJSON<std::shared_ptr<ColorArity>>(std::shared_ptr<ColorArity> &v) { | ||
1616 | json obj({}); | ||
1617 | switch (v->tag) { | ||
1618 | case ::ColorArity::tag::Red: | ||
1619 | obj["tag"] = "Red"; | ||
1620 | break; | ||
1621 | case ::ColorArity::tag::RG: | ||
1622 | obj["tag"] = "RG"; | ||
1623 | break; | ||
1624 | case ::ColorArity::tag::RGB: | ||
1625 | obj["tag"] = "RGB"; | ||
1626 | break; | ||
1627 | case ::ColorArity::tag::RGBA: | ||
1628 | obj["tag"] = "RGBA"; | ||
1629 | break; | ||
1630 | } | ||
1631 | return obj; | ||
1632 | } | ||
1633 | |||
1634 | template<> std::shared_ptr<ColorArity> fromJSON<std::shared_ptr<ColorArity>>(W<std::shared_ptr<ColorArity>> v, json &obj) { | ||
1635 | enum ::ColorArity::tag tagType; | ||
1636 | std::string tag = obj["tag"]; | ||
1637 | if (tag == "Red") { | ||
1638 | tagType = ::ColorArity::tag::Red; | ||
1639 | } | ||
1640 | else if (tag == "RG") { | ||
1641 | tagType = ::ColorArity::tag::RG; | ||
1642 | } | ||
1643 | else if (tag == "RGB") { | ||
1644 | tagType = ::ColorArity::tag::RGB; | ||
1645 | } | ||
1646 | else if (tag == "RGBA") { | ||
1647 | tagType = ::ColorArity::tag::RGBA; | ||
1648 | } | ||
1649 | else throw "unknown constructor: " + tag; | ||
1650 | std::shared_ptr<::ColorArity> o(new ::ColorArity()); | ||
1651 | o->tag = tagType; | ||
1652 | return o; | ||
1653 | } | ||
1654 | |||
1655 | template<> json toJSON<std::shared_ptr<Blending>>(std::shared_ptr<Blending> &v) { | ||
1656 | json obj({}); | ||
1657 | switch (v->tag) { | ||
1658 | case ::Blending::tag::NoBlending: | ||
1659 | obj["tag"] = "NoBlending"; | ||
1660 | break; | ||
1661 | case ::Blending::tag::BlendLogicOp: | ||
1662 | obj["tag"] = "BlendLogicOp"; | ||
1663 | { | ||
1664 | std::shared_ptr<data::BlendLogicOp> tv = std::static_pointer_cast<data::BlendLogicOp>(v); | ||
1665 | obj["arg0"] = toJSON(tv->_0); | ||
1666 | } | ||
1667 | break; | ||
1668 | case ::Blending::tag::Blend: | ||
1669 | obj["tag"] = "Blend"; | ||
1670 | { | ||
1671 | std::shared_ptr<data::Blend> tv = std::static_pointer_cast<data::Blend>(v); | ||
1672 | obj["colorEqSrc"] = toJSON(tv->colorEqSrc); | ||
1673 | obj["alphaEqSrc"] = toJSON(tv->alphaEqSrc); | ||
1674 | obj["colorFSrc"] = toJSON(tv->colorFSrc); | ||
1675 | obj["colorFDst"] = toJSON(tv->colorFDst); | ||
1676 | obj["alphaFSrc"] = toJSON(tv->alphaFSrc); | ||
1677 | obj["alphaFDst"] = toJSON(tv->alphaFDst); | ||
1678 | obj["color"] = toJSON(tv->color); | ||
1679 | } | ||
1680 | break; | ||
1681 | } | ||
1682 | return obj; | ||
1683 | } | ||
1684 | |||
1685 | template<> std::shared_ptr<Blending> fromJSON<std::shared_ptr<Blending>>(W<std::shared_ptr<Blending>> v, json &obj) { | ||
1686 | enum ::Blending::tag tagType; | ||
1687 | std::string tag = obj["tag"]; | ||
1688 | if (tag == "NoBlending") { | ||
1689 | tagType = ::Blending::tag::NoBlending; | ||
1690 | } | ||
1691 | else if (tag == "BlendLogicOp") { | ||
1692 | tagType = ::Blending::tag::BlendLogicOp; | ||
1693 | std::shared_ptr<data::BlendLogicOp> tv(new data::BlendLogicOp()); | ||
1694 | tv->_0 = fromJSON(W<std::shared_ptr<::LogicOperation>>(), obj["arg0"]); | ||
1695 | return tv; | ||
1696 | } | ||
1697 | else if (tag == "Blend") { | ||
1698 | tagType = ::Blending::tag::Blend; | ||
1699 | std::shared_ptr<data::Blend> tv(new data::Blend()); | ||
1700 | tv->colorEqSrc = fromJSON(W<std::shared_ptr<::BlendEquation>>(), obj["colorEqSrc"]); | ||
1701 | tv->alphaEqSrc = fromJSON(W<std::shared_ptr<::BlendEquation>>(), obj["alphaEqSrc"]); | ||
1702 | tv->colorFSrc = fromJSON(W<std::shared_ptr<::BlendingFactor>>(), obj["colorFSrc"]); | ||
1703 | tv->colorFDst = fromJSON(W<std::shared_ptr<::BlendingFactor>>(), obj["colorFDst"]); | ||
1704 | tv->alphaFSrc = fromJSON(W<std::shared_ptr<::BlendingFactor>>(), obj["alphaFSrc"]); | ||
1705 | tv->alphaFDst = fromJSON(W<std::shared_ptr<::BlendingFactor>>(), obj["alphaFDst"]); | ||
1706 | tv->color = fromJSON(W<V4F>(), obj["color"]); | ||
1707 | return tv; | ||
1708 | } | ||
1709 | else throw "unknown constructor: " + tag; | ||
1710 | std::shared_ptr<::Blending> o(new ::Blending()); | ||
1711 | o->tag = tagType; | ||
1712 | return o; | ||
1713 | } | ||
1714 | |||
1715 | template<> json toJSON<std::shared_ptr<RasterContext>>(std::shared_ptr<RasterContext> &v) { | ||
1716 | json obj({}); | ||
1717 | switch (v->tag) { | ||
1718 | case ::RasterContext::tag::PointCtx: | ||
1719 | obj["tag"] = "PointCtx"; | ||
1720 | { | ||
1721 | std::shared_ptr<data::PointCtx> tv = std::static_pointer_cast<data::PointCtx>(v); | ||
1722 | obj["arg0"] = toJSON(tv->_0); | ||
1723 | obj["arg1"] = toJSON(tv->_1); | ||
1724 | obj["arg2"] = toJSON(tv->_2); | ||
1725 | } | ||
1726 | break; | ||
1727 | case ::RasterContext::tag::LineCtx: | ||
1728 | obj["tag"] = "LineCtx"; | ||
1729 | { | ||
1730 | std::shared_ptr<data::LineCtx> tv = std::static_pointer_cast<data::LineCtx>(v); | ||
1731 | obj["arg0"] = toJSON(tv->_0); | ||
1732 | obj["arg1"] = toJSON(tv->_1); | ||
1733 | } | ||
1734 | break; | ||
1735 | case ::RasterContext::tag::TriangleCtx: | ||
1736 | obj["tag"] = "TriangleCtx"; | ||
1737 | { | ||
1738 | std::shared_ptr<data::TriangleCtx> tv = std::static_pointer_cast<data::TriangleCtx>(v); | ||
1739 | obj["arg0"] = toJSON(tv->_0); | ||
1740 | obj["arg1"] = toJSON(tv->_1); | ||
1741 | obj["arg2"] = toJSON(tv->_2); | ||
1742 | obj["arg3"] = toJSON(tv->_3); | ||
1743 | } | ||
1744 | break; | ||
1745 | } | ||
1746 | return obj; | ||
1747 | } | ||
1748 | |||
1749 | template<> std::shared_ptr<RasterContext> fromJSON<std::shared_ptr<RasterContext>>(W<std::shared_ptr<RasterContext>> v, json &obj) { | ||
1750 | enum ::RasterContext::tag tagType; | ||
1751 | std::string tag = obj["tag"]; | ||
1752 | if (tag == "PointCtx") { | ||
1753 | tagType = ::RasterContext::tag::PointCtx; | ||
1754 | std::shared_ptr<data::PointCtx> tv(new data::PointCtx()); | ||
1755 | tv->_0 = fromJSON(W<std::shared_ptr<::PointSize>>(), obj["arg0"]); | ||
1756 | tv->_1 = fromJSON(W<Float>(), obj["arg1"]); | ||
1757 | tv->_2 = fromJSON(W<std::shared_ptr<::PointSpriteCoordOrigin>>(), obj["arg2"]); | ||
1758 | return tv; | ||
1759 | } | ||
1760 | else if (tag == "LineCtx") { | ||
1761 | tagType = ::RasterContext::tag::LineCtx; | ||
1762 | std::shared_ptr<data::LineCtx> tv(new data::LineCtx()); | ||
1763 | tv->_0 = fromJSON(W<Float>(), obj["arg0"]); | ||
1764 | tv->_1 = fromJSON(W<std::shared_ptr<::ProvokingVertex>>(), obj["arg1"]); | ||
1765 | return tv; | ||
1766 | } | ||
1767 | else if (tag == "TriangleCtx") { | ||
1768 | tagType = ::RasterContext::tag::TriangleCtx; | ||
1769 | std::shared_ptr<data::TriangleCtx> tv(new data::TriangleCtx()); | ||
1770 | tv->_0 = fromJSON(W<std::shared_ptr<::CullMode>>(), obj["arg0"]); | ||
1771 | tv->_1 = fromJSON(W<std::shared_ptr<::PolygonMode>>(), obj["arg1"]); | ||
1772 | tv->_2 = fromJSON(W<std::shared_ptr<::PolygonOffset>>(), obj["arg2"]); | ||
1773 | tv->_3 = fromJSON(W<std::shared_ptr<::ProvokingVertex>>(), obj["arg3"]); | ||
1774 | return tv; | ||
1775 | } | ||
1776 | else throw "unknown constructor: " + tag; | ||
1777 | std::shared_ptr<::RasterContext> o(new ::RasterContext()); | ||
1778 | o->tag = tagType; | ||
1779 | return o; | ||
1780 | } | ||
1781 | |||
1782 | template<> json toJSON<std::shared_ptr<FragmentOperation>>(std::shared_ptr<FragmentOperation> &v) { | ||
1783 | json obj({}); | ||
1784 | switch (v->tag) { | ||
1785 | case ::FragmentOperation::tag::DepthOp: | ||
1786 | obj["tag"] = "DepthOp"; | ||
1787 | { | ||
1788 | std::shared_ptr<data::DepthOp> tv = std::static_pointer_cast<data::DepthOp>(v); | ||
1789 | obj["arg0"] = toJSON(tv->_0); | ||
1790 | obj["arg1"] = toJSON(tv->_1); | ||
1791 | } | ||
1792 | break; | ||
1793 | case ::FragmentOperation::tag::StencilOp: | ||
1794 | obj["tag"] = "StencilOp"; | ||
1795 | { | ||
1796 | std::shared_ptr<data::StencilOp> tv = std::static_pointer_cast<data::StencilOp>(v); | ||
1797 | obj["arg0"] = toJSON(tv->_0); | ||
1798 | obj["arg1"] = toJSON(tv->_1); | ||
1799 | obj["arg2"] = toJSON(tv->_2); | ||
1800 | } | ||
1801 | break; | ||
1802 | case ::FragmentOperation::tag::ColorOp: | ||
1803 | obj["tag"] = "ColorOp"; | ||
1804 | { | ||
1805 | std::shared_ptr<data::ColorOp> tv = std::static_pointer_cast<data::ColorOp>(v); | ||
1806 | obj["arg0"] = toJSON(tv->_0); | ||
1807 | obj["arg1"] = toJSON(tv->_1); | ||
1808 | } | ||
1809 | break; | ||
1810 | } | ||
1811 | return obj; | ||
1812 | } | ||
1813 | |||
1814 | template<> std::shared_ptr<FragmentOperation> fromJSON<std::shared_ptr<FragmentOperation>>(W<std::shared_ptr<FragmentOperation>> v, json &obj) { | ||
1815 | enum ::FragmentOperation::tag tagType; | ||
1816 | std::string tag = obj["tag"]; | ||
1817 | if (tag == "DepthOp") { | ||
1818 | tagType = ::FragmentOperation::tag::DepthOp; | ||
1819 | std::shared_ptr<data::DepthOp> tv(new data::DepthOp()); | ||
1820 | tv->_0 = fromJSON(W<std::shared_ptr<::DepthFunction>>(), obj["arg0"]); | ||
1821 | tv->_1 = fromJSON(W<Bool>(), obj["arg1"]); | ||
1822 | return tv; | ||
1823 | } | ||
1824 | else if (tag == "StencilOp") { | ||
1825 | tagType = ::FragmentOperation::tag::StencilOp; | ||
1826 | std::shared_ptr<data::StencilOp> tv(new data::StencilOp()); | ||
1827 | tv->_0 = fromJSON(W<std::shared_ptr<::StencilTests>>(), obj["arg0"]); | ||
1828 | tv->_1 = fromJSON(W<std::shared_ptr<::StencilOps>>(), obj["arg1"]); | ||
1829 | tv->_2 = fromJSON(W<std::shared_ptr<::StencilOps>>(), obj["arg2"]); | ||
1830 | return tv; | ||
1831 | } | ||
1832 | else if (tag == "ColorOp") { | ||
1833 | tagType = ::FragmentOperation::tag::ColorOp; | ||
1834 | std::shared_ptr<data::ColorOp> tv(new data::ColorOp()); | ||
1835 | tv->_0 = fromJSON(W<std::shared_ptr<::Blending>>(), obj["arg0"]); | ||
1836 | tv->_1 = fromJSON(W<std::shared_ptr<::Value>>(), obj["arg1"]); | ||
1837 | return tv; | ||
1838 | } | ||
1839 | else throw "unknown constructor: " + tag; | ||
1840 | std::shared_ptr<::FragmentOperation> o(new ::FragmentOperation()); | ||
1841 | o->tag = tagType; | ||
1842 | return o; | ||
1843 | } | ||
1844 | |||
1845 | template<> json toJSON<std::shared_ptr<AccumulationContext>>(std::shared_ptr<AccumulationContext> &v) { | ||
1846 | json obj({}); | ||
1847 | switch (v->tag) { | ||
1848 | case ::AccumulationContext::tag::AccumulationContext: | ||
1849 | obj["tag"] = "AccumulationContext"; | ||
1850 | { | ||
1851 | std::shared_ptr<data::AccumulationContext> tv = std::static_pointer_cast<data::AccumulationContext>(v); | ||
1852 | obj["accViewportName"] = toJSON(tv->accViewportName); | ||
1853 | obj["accOperations"] = toJSON(tv->accOperations); | ||
1854 | } | ||
1855 | break; | ||
1856 | } | ||
1857 | return obj; | ||
1858 | } | ||
1859 | |||
1860 | template<> std::shared_ptr<AccumulationContext> fromJSON<std::shared_ptr<AccumulationContext>>(W<std::shared_ptr<AccumulationContext>> v, json &obj) { | ||
1861 | enum ::AccumulationContext::tag tagType; | ||
1862 | std::string tag = obj["tag"]; | ||
1863 | if (tag == "AccumulationContext") { | ||
1864 | tagType = ::AccumulationContext::tag::AccumulationContext; | ||
1865 | std::shared_ptr<data::AccumulationContext> tv(new data::AccumulationContext()); | ||
1866 | tv->accViewportName = fromJSON(W<Maybe<String>>(), obj["accViewportName"]); | ||
1867 | tv->accOperations = fromJSON(W<std::vector<std::shared_ptr<::FragmentOperation>>>(), obj["accOperations"]); | ||
1868 | return tv; | ||
1869 | } | ||
1870 | else throw "unknown constructor: " + tag; | ||
1871 | std::shared_ptr<::AccumulationContext> o(new ::AccumulationContext()); | ||
1872 | o->tag = tagType; | ||
1873 | return o; | ||
1874 | } | ||
1875 | |||
1876 | template<> json toJSON<std::shared_ptr<TextureDataType>>(std::shared_ptr<TextureDataType> &v) { | ||
1877 | json obj({}); | ||
1878 | switch (v->tag) { | ||
1879 | case ::TextureDataType::tag::FloatT: | ||
1880 | obj["tag"] = "FloatT"; | ||
1881 | { | ||
1882 | std::shared_ptr<data::FloatT> tv = std::static_pointer_cast<data::FloatT>(v); | ||
1883 | obj["arg0"] = toJSON(tv->_0); | ||
1884 | } | ||
1885 | break; | ||
1886 | case ::TextureDataType::tag::IntT: | ||
1887 | obj["tag"] = "IntT"; | ||
1888 | { | ||
1889 | std::shared_ptr<data::IntT> tv = std::static_pointer_cast<data::IntT>(v); | ||
1890 | obj["arg0"] = toJSON(tv->_0); | ||
1891 | } | ||
1892 | break; | ||
1893 | case ::TextureDataType::tag::WordT: | ||
1894 | obj["tag"] = "WordT"; | ||
1895 | { | ||
1896 | std::shared_ptr<data::WordT> tv = std::static_pointer_cast<data::WordT>(v); | ||
1897 | obj["arg0"] = toJSON(tv->_0); | ||
1898 | } | ||
1899 | break; | ||
1900 | case ::TextureDataType::tag::ShadowT: | ||
1901 | obj["tag"] = "ShadowT"; | ||
1902 | break; | ||
1903 | } | ||
1904 | return obj; | ||
1905 | } | ||
1906 | |||
1907 | template<> std::shared_ptr<TextureDataType> fromJSON<std::shared_ptr<TextureDataType>>(W<std::shared_ptr<TextureDataType>> v, json &obj) { | ||
1908 | enum ::TextureDataType::tag tagType; | ||
1909 | std::string tag = obj["tag"]; | ||
1910 | if (tag == "FloatT") { | ||
1911 | tagType = ::TextureDataType::tag::FloatT; | ||
1912 | std::shared_ptr<data::FloatT> tv(new data::FloatT()); | ||
1913 | tv->_0 = fromJSON(W<std::shared_ptr<::ColorArity>>(), obj["arg0"]); | ||
1914 | return tv; | ||
1915 | } | ||
1916 | else if (tag == "IntT") { | ||
1917 | tagType = ::TextureDataType::tag::IntT; | ||
1918 | std::shared_ptr<data::IntT> tv(new data::IntT()); | ||
1919 | tv->_0 = fromJSON(W<std::shared_ptr<::ColorArity>>(), obj["arg0"]); | ||
1920 | return tv; | ||
1921 | } | ||
1922 | else if (tag == "WordT") { | ||
1923 | tagType = ::TextureDataType::tag::WordT; | ||
1924 | std::shared_ptr<data::WordT> tv(new data::WordT()); | ||
1925 | tv->_0 = fromJSON(W<std::shared_ptr<::ColorArity>>(), obj["arg0"]); | ||
1926 | return tv; | ||
1927 | } | ||
1928 | else if (tag == "ShadowT") { | ||
1929 | tagType = ::TextureDataType::tag::ShadowT; | ||
1930 | } | ||
1931 | else throw "unknown constructor: " + tag; | ||
1932 | std::shared_ptr<::TextureDataType> o(new ::TextureDataType()); | ||
1933 | o->tag = tagType; | ||
1934 | return o; | ||
1935 | } | ||
1936 | |||
1937 | template<> json toJSON<std::shared_ptr<TextureType>>(std::shared_ptr<TextureType> &v) { | ||
1938 | json obj({}); | ||
1939 | switch (v->tag) { | ||
1940 | case ::TextureType::tag::Texture1D: | ||
1941 | obj["tag"] = "Texture1D"; | ||
1942 | { | ||
1943 | std::shared_ptr<data::Texture1D> tv = std::static_pointer_cast<data::Texture1D>(v); | ||
1944 | obj["arg0"] = toJSON(tv->_0); | ||
1945 | obj["arg1"] = toJSON(tv->_1); | ||
1946 | } | ||
1947 | break; | ||
1948 | case ::TextureType::tag::Texture2D: | ||
1949 | obj["tag"] = "Texture2D"; | ||
1950 | { | ||
1951 | std::shared_ptr<data::Texture2D> tv = std::static_pointer_cast<data::Texture2D>(v); | ||
1952 | obj["arg0"] = toJSON(tv->_0); | ||
1953 | obj["arg1"] = toJSON(tv->_1); | ||
1954 | } | ||
1955 | break; | ||
1956 | case ::TextureType::tag::Texture3D: | ||
1957 | obj["tag"] = "Texture3D"; | ||
1958 | { | ||
1959 | std::shared_ptr<data::Texture3D> tv = std::static_pointer_cast<data::Texture3D>(v); | ||
1960 | obj["arg0"] = toJSON(tv->_0); | ||
1961 | } | ||
1962 | break; | ||
1963 | case ::TextureType::tag::TextureCube: | ||
1964 | obj["tag"] = "TextureCube"; | ||
1965 | { | ||
1966 | std::shared_ptr<data::TextureCube> tv = std::static_pointer_cast<data::TextureCube>(v); | ||
1967 | obj["arg0"] = toJSON(tv->_0); | ||
1968 | } | ||
1969 | break; | ||
1970 | case ::TextureType::tag::TextureRect: | ||
1971 | obj["tag"] = "TextureRect"; | ||
1972 | { | ||
1973 | std::shared_ptr<data::TextureRect> tv = std::static_pointer_cast<data::TextureRect>(v); | ||
1974 | obj["arg0"] = toJSON(tv->_0); | ||
1975 | } | ||
1976 | break; | ||
1977 | case ::TextureType::tag::Texture2DMS: | ||
1978 | obj["tag"] = "Texture2DMS"; | ||
1979 | { | ||
1980 | std::shared_ptr<data::Texture2DMS> tv = std::static_pointer_cast<data::Texture2DMS>(v); | ||
1981 | obj["arg0"] = toJSON(tv->_0); | ||
1982 | obj["arg1"] = toJSON(tv->_1); | ||
1983 | obj["arg2"] = toJSON(tv->_2); | ||
1984 | obj["arg3"] = toJSON(tv->_3); | ||
1985 | } | ||
1986 | break; | ||
1987 | case ::TextureType::tag::TextureBuffer: | ||
1988 | obj["tag"] = "TextureBuffer"; | ||
1989 | { | ||
1990 | std::shared_ptr<data::TextureBuffer> tv = std::static_pointer_cast<data::TextureBuffer>(v); | ||
1991 | obj["arg0"] = toJSON(tv->_0); | ||
1992 | } | ||
1993 | break; | ||
1994 | } | ||
1995 | return obj; | ||
1996 | } | ||
1997 | |||
1998 | template<> std::shared_ptr<TextureType> fromJSON<std::shared_ptr<TextureType>>(W<std::shared_ptr<TextureType>> v, json &obj) { | ||
1999 | enum ::TextureType::tag tagType; | ||
2000 | std::string tag = obj["tag"]; | ||
2001 | if (tag == "Texture1D") { | ||
2002 | tagType = ::TextureType::tag::Texture1D; | ||
2003 | std::shared_ptr<data::Texture1D> tv(new data::Texture1D()); | ||
2004 | tv->_0 = fromJSON(W<std::shared_ptr<::TextureDataType>>(), obj["arg0"]); | ||
2005 | tv->_1 = fromJSON(W<Int>(), obj["arg1"]); | ||
2006 | return tv; | ||
2007 | } | ||
2008 | else if (tag == "Texture2D") { | ||
2009 | tagType = ::TextureType::tag::Texture2D; | ||
2010 | std::shared_ptr<data::Texture2D> tv(new data::Texture2D()); | ||
2011 | tv->_0 = fromJSON(W<std::shared_ptr<::TextureDataType>>(), obj["arg0"]); | ||
2012 | tv->_1 = fromJSON(W<Int>(), obj["arg1"]); | ||
2013 | return tv; | ||
2014 | } | ||
2015 | else if (tag == "Texture3D") { | ||
2016 | tagType = ::TextureType::tag::Texture3D; | ||
2017 | std::shared_ptr<data::Texture3D> tv(new data::Texture3D()); | ||
2018 | tv->_0 = fromJSON(W<std::shared_ptr<::TextureDataType>>(), obj["arg0"]); | ||
2019 | return tv; | ||
2020 | } | ||
2021 | else if (tag == "TextureCube") { | ||
2022 | tagType = ::TextureType::tag::TextureCube; | ||
2023 | std::shared_ptr<data::TextureCube> tv(new data::TextureCube()); | ||
2024 | tv->_0 = fromJSON(W<std::shared_ptr<::TextureDataType>>(), obj["arg0"]); | ||
2025 | return tv; | ||
2026 | } | ||
2027 | else if (tag == "TextureRect") { | ||
2028 | tagType = ::TextureType::tag::TextureRect; | ||
2029 | std::shared_ptr<data::TextureRect> tv(new data::TextureRect()); | ||
2030 | tv->_0 = fromJSON(W<std::shared_ptr<::TextureDataType>>(), obj["arg0"]); | ||
2031 | return tv; | ||
2032 | } | ||
2033 | else if (tag == "Texture2DMS") { | ||
2034 | tagType = ::TextureType::tag::Texture2DMS; | ||
2035 | std::shared_ptr<data::Texture2DMS> tv(new data::Texture2DMS()); | ||
2036 | tv->_0 = fromJSON(W<std::shared_ptr<::TextureDataType>>(), obj["arg0"]); | ||
2037 | tv->_1 = fromJSON(W<Int>(), obj["arg1"]); | ||
2038 | tv->_2 = fromJSON(W<Int>(), obj["arg2"]); | ||
2039 | tv->_3 = fromJSON(W<Bool>(), obj["arg3"]); | ||
2040 | return tv; | ||
2041 | } | ||
2042 | else if (tag == "TextureBuffer") { | ||
2043 | tagType = ::TextureType::tag::TextureBuffer; | ||
2044 | std::shared_ptr<data::TextureBuffer> tv(new data::TextureBuffer()); | ||
2045 | tv->_0 = fromJSON(W<std::shared_ptr<::TextureDataType>>(), obj["arg0"]); | ||
2046 | return tv; | ||
2047 | } | ||
2048 | else throw "unknown constructor: " + tag; | ||
2049 | std::shared_ptr<::TextureType> o(new ::TextureType()); | ||
2050 | o->tag = tagType; | ||
2051 | return o; | ||
2052 | } | ||
2053 | |||
2054 | template<> json toJSON<std::shared_ptr<MipMap>>(std::shared_ptr<MipMap> &v) { | ||
2055 | json obj({}); | ||
2056 | switch (v->tag) { | ||
2057 | case ::MipMap::tag::Mip: | ||
2058 | obj["tag"] = "Mip"; | ||
2059 | { | ||
2060 | std::shared_ptr<data::Mip> tv = std::static_pointer_cast<data::Mip>(v); | ||
2061 | obj["arg0"] = toJSON(tv->_0); | ||
2062 | obj["arg1"] = toJSON(tv->_1); | ||
2063 | } | ||
2064 | break; | ||
2065 | case ::MipMap::tag::NoMip: | ||
2066 | obj["tag"] = "NoMip"; | ||
2067 | break; | ||
2068 | case ::MipMap::tag::AutoMip: | ||
2069 | obj["tag"] = "AutoMip"; | ||
2070 | { | ||
2071 | std::shared_ptr<data::AutoMip> tv = std::static_pointer_cast<data::AutoMip>(v); | ||
2072 | obj["arg0"] = toJSON(tv->_0); | ||
2073 | obj["arg1"] = toJSON(tv->_1); | ||
2074 | } | ||
2075 | break; | ||
2076 | } | ||
2077 | return obj; | ||
2078 | } | ||
2079 | |||
2080 | template<> std::shared_ptr<MipMap> fromJSON<std::shared_ptr<MipMap>>(W<std::shared_ptr<MipMap>> v, json &obj) { | ||
2081 | enum ::MipMap::tag tagType; | ||
2082 | std::string tag = obj["tag"]; | ||
2083 | if (tag == "Mip") { | ||
2084 | tagType = ::MipMap::tag::Mip; | ||
2085 | std::shared_ptr<data::Mip> tv(new data::Mip()); | ||
2086 | tv->_0 = fromJSON(W<Int>(), obj["arg0"]); | ||
2087 | tv->_1 = fromJSON(W<Int>(), obj["arg1"]); | ||
2088 | return tv; | ||
2089 | } | ||
2090 | else if (tag == "NoMip") { | ||
2091 | tagType = ::MipMap::tag::NoMip; | ||
2092 | } | ||
2093 | else if (tag == "AutoMip") { | ||
2094 | tagType = ::MipMap::tag::AutoMip; | ||
2095 | std::shared_ptr<data::AutoMip> tv(new data::AutoMip()); | ||
2096 | tv->_0 = fromJSON(W<Int>(), obj["arg0"]); | ||
2097 | tv->_1 = fromJSON(W<Int>(), obj["arg1"]); | ||
2098 | return tv; | ||
2099 | } | ||
2100 | else throw "unknown constructor: " + tag; | ||
2101 | std::shared_ptr<::MipMap> o(new ::MipMap()); | ||
2102 | o->tag = tagType; | ||
2103 | return o; | ||
2104 | } | ||
2105 | |||
2106 | template<> json toJSON<std::shared_ptr<Filter>>(std::shared_ptr<Filter> &v) { | ||
2107 | json obj({}); | ||
2108 | switch (v->tag) { | ||
2109 | case ::Filter::tag::Nearest: | ||
2110 | obj["tag"] = "Nearest"; | ||
2111 | break; | ||
2112 | case ::Filter::tag::Linear: | ||
2113 | obj["tag"] = "Linear"; | ||
2114 | break; | ||
2115 | case ::Filter::tag::NearestMipmapNearest: | ||
2116 | obj["tag"] = "NearestMipmapNearest"; | ||
2117 | break; | ||
2118 | case ::Filter::tag::NearestMipmapLinear: | ||
2119 | obj["tag"] = "NearestMipmapLinear"; | ||
2120 | break; | ||
2121 | case ::Filter::tag::LinearMipmapNearest: | ||
2122 | obj["tag"] = "LinearMipmapNearest"; | ||
2123 | break; | ||
2124 | case ::Filter::tag::LinearMipmapLinear: | ||
2125 | obj["tag"] = "LinearMipmapLinear"; | ||
2126 | break; | ||
2127 | } | ||
2128 | return obj; | ||
2129 | } | ||
2130 | |||
2131 | template<> std::shared_ptr<Filter> fromJSON<std::shared_ptr<Filter>>(W<std::shared_ptr<Filter>> v, json &obj) { | ||
2132 | enum ::Filter::tag tagType; | ||
2133 | std::string tag = obj["tag"]; | ||
2134 | if (tag == "Nearest") { | ||
2135 | tagType = ::Filter::tag::Nearest; | ||
2136 | } | ||
2137 | else if (tag == "Linear") { | ||
2138 | tagType = ::Filter::tag::Linear; | ||
2139 | } | ||
2140 | else if (tag == "NearestMipmapNearest") { | ||
2141 | tagType = ::Filter::tag::NearestMipmapNearest; | ||
2142 | } | ||
2143 | else if (tag == "NearestMipmapLinear") { | ||
2144 | tagType = ::Filter::tag::NearestMipmapLinear; | ||
2145 | } | ||
2146 | else if (tag == "LinearMipmapNearest") { | ||
2147 | tagType = ::Filter::tag::LinearMipmapNearest; | ||
2148 | } | ||
2149 | else if (tag == "LinearMipmapLinear") { | ||
2150 | tagType = ::Filter::tag::LinearMipmapLinear; | ||
2151 | } | ||
2152 | else throw "unknown constructor: " + tag; | ||
2153 | std::shared_ptr<::Filter> o(new ::Filter()); | ||
2154 | o->tag = tagType; | ||
2155 | return o; | ||
2156 | } | ||
2157 | |||
2158 | template<> json toJSON<std::shared_ptr<EdgeMode>>(std::shared_ptr<EdgeMode> &v) { | ||
2159 | json obj({}); | ||
2160 | switch (v->tag) { | ||
2161 | case ::EdgeMode::tag::Repeat: | ||
2162 | obj["tag"] = "Repeat"; | ||
2163 | break; | ||
2164 | case ::EdgeMode::tag::MirroredRepeat: | ||
2165 | obj["tag"] = "MirroredRepeat"; | ||
2166 | break; | ||
2167 | case ::EdgeMode::tag::ClampToEdge: | ||
2168 | obj["tag"] = "ClampToEdge"; | ||
2169 | break; | ||
2170 | case ::EdgeMode::tag::ClampToBorder: | ||
2171 | obj["tag"] = "ClampToBorder"; | ||
2172 | break; | ||
2173 | } | ||
2174 | return obj; | ||
2175 | } | ||
2176 | |||
2177 | template<> std::shared_ptr<EdgeMode> fromJSON<std::shared_ptr<EdgeMode>>(W<std::shared_ptr<EdgeMode>> v, json &obj) { | ||
2178 | enum ::EdgeMode::tag tagType; | ||
2179 | std::string tag = obj["tag"]; | ||
2180 | if (tag == "Repeat") { | ||
2181 | tagType = ::EdgeMode::tag::Repeat; | ||
2182 | } | ||
2183 | else if (tag == "MirroredRepeat") { | ||
2184 | tagType = ::EdgeMode::tag::MirroredRepeat; | ||
2185 | } | ||
2186 | else if (tag == "ClampToEdge") { | ||
2187 | tagType = ::EdgeMode::tag::ClampToEdge; | ||
2188 | } | ||
2189 | else if (tag == "ClampToBorder") { | ||
2190 | tagType = ::EdgeMode::tag::ClampToBorder; | ||
2191 | } | ||
2192 | else throw "unknown constructor: " + tag; | ||
2193 | std::shared_ptr<::EdgeMode> o(new ::EdgeMode()); | ||
2194 | o->tag = tagType; | ||
2195 | return o; | ||
2196 | } | ||
2197 | |||
2198 | template<> json toJSON<std::shared_ptr<ImageSemantic>>(std::shared_ptr<ImageSemantic> &v) { | ||
2199 | json obj({}); | ||
2200 | switch (v->tag) { | ||
2201 | case ::ImageSemantic::tag::Depth: | ||
2202 | obj["tag"] = "Depth"; | ||
2203 | break; | ||
2204 | case ::ImageSemantic::tag::Stencil: | ||
2205 | obj["tag"] = "Stencil"; | ||
2206 | break; | ||
2207 | case ::ImageSemantic::tag::Color: | ||
2208 | obj["tag"] = "Color"; | ||
2209 | break; | ||
2210 | } | ||
2211 | return obj; | ||
2212 | } | ||
2213 | |||
2214 | template<> std::shared_ptr<ImageSemantic> fromJSON<std::shared_ptr<ImageSemantic>>(W<std::shared_ptr<ImageSemantic>> v, json &obj) { | ||
2215 | enum ::ImageSemantic::tag tagType; | ||
2216 | std::string tag = obj["tag"]; | ||
2217 | if (tag == "Depth") { | ||
2218 | tagType = ::ImageSemantic::tag::Depth; | ||
2219 | } | ||
2220 | else if (tag == "Stencil") { | ||
2221 | tagType = ::ImageSemantic::tag::Stencil; | ||
2222 | } | ||
2223 | else if (tag == "Color") { | ||
2224 | tagType = ::ImageSemantic::tag::Color; | ||
2225 | } | ||
2226 | else throw "unknown constructor: " + tag; | ||
2227 | std::shared_ptr<::ImageSemantic> o(new ::ImageSemantic()); | ||
2228 | o->tag = tagType; | ||
2229 | return o; | ||
2230 | } | ||
2231 | |||
2232 | template<> json toJSON<std::shared_ptr<ImageRef>>(std::shared_ptr<ImageRef> &v) { | ||
2233 | json obj({}); | ||
2234 | switch (v->tag) { | ||
2235 | case ::ImageRef::tag::TextureImage: | ||
2236 | obj["tag"] = "TextureImage"; | ||
2237 | { | ||
2238 | std::shared_ptr<data::TextureImage> tv = std::static_pointer_cast<data::TextureImage>(v); | ||
2239 | obj["arg0"] = toJSON(tv->_0); | ||
2240 | obj["arg1"] = toJSON(tv->_1); | ||
2241 | obj["arg2"] = toJSON(tv->_2); | ||
2242 | } | ||
2243 | break; | ||
2244 | case ::ImageRef::tag::Framebuffer: | ||
2245 | obj["tag"] = "Framebuffer"; | ||
2246 | { | ||
2247 | std::shared_ptr<data::Framebuffer> tv = std::static_pointer_cast<data::Framebuffer>(v); | ||
2248 | obj["arg0"] = toJSON(tv->_0); | ||
2249 | } | ||
2250 | break; | ||
2251 | } | ||
2252 | return obj; | ||
2253 | } | ||
2254 | |||
2255 | template<> std::shared_ptr<ImageRef> fromJSON<std::shared_ptr<ImageRef>>(W<std::shared_ptr<ImageRef>> v, json &obj) { | ||
2256 | enum ::ImageRef::tag tagType; | ||
2257 | std::string tag = obj["tag"]; | ||
2258 | if (tag == "TextureImage") { | ||
2259 | tagType = ::ImageRef::tag::TextureImage; | ||
2260 | std::shared_ptr<data::TextureImage> tv(new data::TextureImage()); | ||
2261 | tv->_0 = fromJSON(W<::TextureName>(), obj["arg0"]); | ||
2262 | tv->_1 = fromJSON(W<Int>(), obj["arg1"]); | ||
2263 | tv->_2 = fromJSON(W<Maybe<Int>>(), obj["arg2"]); | ||
2264 | return tv; | ||
2265 | } | ||
2266 | else if (tag == "Framebuffer") { | ||
2267 | tagType = ::ImageRef::tag::Framebuffer; | ||
2268 | std::shared_ptr<data::Framebuffer> tv(new data::Framebuffer()); | ||
2269 | tv->_0 = fromJSON(W<std::shared_ptr<::ImageSemantic>>(), obj["arg0"]); | ||
2270 | return tv; | ||
2271 | } | ||
2272 | else throw "unknown constructor: " + tag; | ||
2273 | std::shared_ptr<::ImageRef> o(new ::ImageRef()); | ||
2274 | o->tag = tagType; | ||
2275 | return o; | ||
2276 | } | ||
2277 | |||
2278 | template<> json toJSON<std::shared_ptr<ClearImage>>(std::shared_ptr<ClearImage> &v) { | ||
2279 | json obj({}); | ||
2280 | switch (v->tag) { | ||
2281 | case ::ClearImage::tag::ClearImage: | ||
2282 | obj["tag"] = "ClearImage"; | ||
2283 | { | ||
2284 | std::shared_ptr<data::ClearImage> tv = std::static_pointer_cast<data::ClearImage>(v); | ||
2285 | obj["imageSemantic"] = toJSON(tv->imageSemantic); | ||
2286 | obj["clearValue"] = toJSON(tv->clearValue); | ||
2287 | } | ||
2288 | break; | ||
2289 | } | ||
2290 | return obj; | ||
2291 | } | ||
2292 | |||
2293 | template<> std::shared_ptr<ClearImage> fromJSON<std::shared_ptr<ClearImage>>(W<std::shared_ptr<ClearImage>> v, json &obj) { | ||
2294 | enum ::ClearImage::tag tagType; | ||
2295 | std::string tag = obj["tag"]; | ||
2296 | if (tag == "ClearImage") { | ||
2297 | tagType = ::ClearImage::tag::ClearImage; | ||
2298 | std::shared_ptr<data::ClearImage> tv(new data::ClearImage()); | ||
2299 | tv->imageSemantic = fromJSON(W<std::shared_ptr<::ImageSemantic>>(), obj["imageSemantic"]); | ||
2300 | tv->clearValue = fromJSON(W<std::shared_ptr<::Value>>(), obj["clearValue"]); | ||
2301 | return tv; | ||
2302 | } | ||
2303 | else throw "unknown constructor: " + tag; | ||
2304 | std::shared_ptr<::ClearImage> o(new ::ClearImage()); | ||
2305 | o->tag = tagType; | ||
2306 | return o; | ||
2307 | } | ||
2308 | |||
2309 | template<> json toJSON<std::shared_ptr<Command>>(std::shared_ptr<Command> &v) { | ||
2310 | json obj({}); | ||
2311 | switch (v->tag) { | ||
2312 | case ::Command::tag::SetRasterContext: | ||
2313 | obj["tag"] = "SetRasterContext"; | ||
2314 | { | ||
2315 | std::shared_ptr<data::SetRasterContext> tv = std::static_pointer_cast<data::SetRasterContext>(v); | ||
2316 | obj["arg0"] = toJSON(tv->_0); | ||
2317 | } | ||
2318 | break; | ||
2319 | case ::Command::tag::SetAccumulationContext: | ||
2320 | obj["tag"] = "SetAccumulationContext"; | ||
2321 | { | ||
2322 | std::shared_ptr<data::SetAccumulationContext> tv = std::static_pointer_cast<data::SetAccumulationContext>(v); | ||
2323 | obj["arg0"] = toJSON(tv->_0); | ||
2324 | } | ||
2325 | break; | ||
2326 | case ::Command::tag::SetRenderTarget: | ||
2327 | obj["tag"] = "SetRenderTarget"; | ||
2328 | { | ||
2329 | std::shared_ptr<data::SetRenderTarget> tv = std::static_pointer_cast<data::SetRenderTarget>(v); | ||
2330 | obj["arg0"] = toJSON(tv->_0); | ||
2331 | } | ||
2332 | break; | ||
2333 | case ::Command::tag::SetProgram: | ||
2334 | obj["tag"] = "SetProgram"; | ||
2335 | { | ||
2336 | std::shared_ptr<data::SetProgram> tv = std::static_pointer_cast<data::SetProgram>(v); | ||
2337 | obj["arg0"] = toJSON(tv->_0); | ||
2338 | } | ||
2339 | break; | ||
2340 | case ::Command::tag::SetSamplerUniform: | ||
2341 | obj["tag"] = "SetSamplerUniform"; | ||
2342 | { | ||
2343 | std::shared_ptr<data::SetSamplerUniform> tv = std::static_pointer_cast<data::SetSamplerUniform>(v); | ||
2344 | obj["arg0"] = toJSON(tv->_0); | ||
2345 | obj["arg1"] = toJSON(tv->_1); | ||
2346 | } | ||
2347 | break; | ||
2348 | case ::Command::tag::SetTexture: | ||
2349 | obj["tag"] = "SetTexture"; | ||
2350 | { | ||
2351 | std::shared_ptr<data::SetTexture> tv = std::static_pointer_cast<data::SetTexture>(v); | ||
2352 | obj["arg0"] = toJSON(tv->_0); | ||
2353 | obj["arg1"] = toJSON(tv->_1); | ||
2354 | } | ||
2355 | break; | ||
2356 | case ::Command::tag::SetSampler: | ||
2357 | obj["tag"] = "SetSampler"; | ||
2358 | { | ||
2359 | std::shared_ptr<data::SetSampler> tv = std::static_pointer_cast<data::SetSampler>(v); | ||
2360 | obj["arg0"] = toJSON(tv->_0); | ||
2361 | obj["arg1"] = toJSON(tv->_1); | ||
2362 | } | ||
2363 | break; | ||
2364 | case ::Command::tag::RenderSlot: | ||
2365 | obj["tag"] = "RenderSlot"; | ||
2366 | { | ||
2367 | std::shared_ptr<data::RenderSlot> tv = std::static_pointer_cast<data::RenderSlot>(v); | ||
2368 | obj["arg0"] = toJSON(tv->_0); | ||
2369 | } | ||
2370 | break; | ||
2371 | case ::Command::tag::RenderStream: | ||
2372 | obj["tag"] = "RenderStream"; | ||
2373 | { | ||
2374 | std::shared_ptr<data::RenderStream> tv = std::static_pointer_cast<data::RenderStream>(v); | ||
2375 | obj["arg0"] = toJSON(tv->_0); | ||
2376 | } | ||
2377 | break; | ||
2378 | case ::Command::tag::ClearRenderTarget: | ||
2379 | obj["tag"] = "ClearRenderTarget"; | ||
2380 | { | ||
2381 | std::shared_ptr<data::ClearRenderTarget> tv = std::static_pointer_cast<data::ClearRenderTarget>(v); | ||
2382 | obj["arg0"] = toJSON(tv->_0); | ||
2383 | } | ||
2384 | break; | ||
2385 | case ::Command::tag::GenerateMipMap: | ||
2386 | obj["tag"] = "GenerateMipMap"; | ||
2387 | { | ||
2388 | std::shared_ptr<data::GenerateMipMap> tv = std::static_pointer_cast<data::GenerateMipMap>(v); | ||
2389 | obj["arg0"] = toJSON(tv->_0); | ||
2390 | } | ||
2391 | break; | ||
2392 | case ::Command::tag::SaveImage: | ||
2393 | obj["tag"] = "SaveImage"; | ||
2394 | { | ||
2395 | std::shared_ptr<data::SaveImage> tv = std::static_pointer_cast<data::SaveImage>(v); | ||
2396 | obj["arg0"] = toJSON(tv->_0); | ||
2397 | obj["arg1"] = toJSON(tv->_1); | ||
2398 | } | ||
2399 | break; | ||
2400 | case ::Command::tag::LoadImage: | ||
2401 | obj["tag"] = "LoadImage"; | ||
2402 | { | ||
2403 | std::shared_ptr<data::LoadImage> tv = std::static_pointer_cast<data::LoadImage>(v); | ||
2404 | obj["arg0"] = toJSON(tv->_0); | ||
2405 | obj["arg1"] = toJSON(tv->_1); | ||
2406 | } | ||
2407 | break; | ||
2408 | } | ||
2409 | return obj; | ||
2410 | } | ||
2411 | |||
2412 | template<> std::shared_ptr<Command> fromJSON<std::shared_ptr<Command>>(W<std::shared_ptr<Command>> v, json &obj) { | ||
2413 | enum ::Command::tag tagType; | ||
2414 | std::string tag = obj["tag"]; | ||
2415 | if (tag == "SetRasterContext") { | ||
2416 | tagType = ::Command::tag::SetRasterContext; | ||
2417 | std::shared_ptr<data::SetRasterContext> tv(new data::SetRasterContext()); | ||
2418 | tv->_0 = fromJSON(W<std::shared_ptr<::RasterContext>>(), obj["arg0"]); | ||
2419 | return tv; | ||
2420 | } | ||
2421 | else if (tag == "SetAccumulationContext") { | ||
2422 | tagType = ::Command::tag::SetAccumulationContext; | ||
2423 | std::shared_ptr<data::SetAccumulationContext> tv(new data::SetAccumulationContext()); | ||
2424 | tv->_0 = fromJSON(W<std::shared_ptr<::AccumulationContext>>(), obj["arg0"]); | ||
2425 | return tv; | ||
2426 | } | ||
2427 | else if (tag == "SetRenderTarget") { | ||
2428 | tagType = ::Command::tag::SetRenderTarget; | ||
2429 | std::shared_ptr<data::SetRenderTarget> tv(new data::SetRenderTarget()); | ||
2430 | tv->_0 = fromJSON(W<::RenderTargetName>(), obj["arg0"]); | ||
2431 | return tv; | ||
2432 | } | ||
2433 | else if (tag == "SetProgram") { | ||
2434 | tagType = ::Command::tag::SetProgram; | ||
2435 | std::shared_ptr<data::SetProgram> tv(new data::SetProgram()); | ||
2436 | tv->_0 = fromJSON(W<::ProgramName>(), obj["arg0"]); | ||
2437 | return tv; | ||
2438 | } | ||
2439 | else if (tag == "SetSamplerUniform") { | ||
2440 | tagType = ::Command::tag::SetSamplerUniform; | ||
2441 | std::shared_ptr<data::SetSamplerUniform> tv(new data::SetSamplerUniform()); | ||
2442 | tv->_0 = fromJSON(W<::UniformName>(), obj["arg0"]); | ||
2443 | tv->_1 = fromJSON(W<::TextureUnit>(), obj["arg1"]); | ||
2444 | return tv; | ||
2445 | } | ||
2446 | else if (tag == "SetTexture") { | ||
2447 | tagType = ::Command::tag::SetTexture; | ||
2448 | std::shared_ptr<data::SetTexture> tv(new data::SetTexture()); | ||
2449 | tv->_0 = fromJSON(W<::TextureUnit>(), obj["arg0"]); | ||
2450 | tv->_1 = fromJSON(W<::TextureName>(), obj["arg1"]); | ||
2451 | return tv; | ||
2452 | } | ||
2453 | else if (tag == "SetSampler") { | ||
2454 | tagType = ::Command::tag::SetSampler; | ||
2455 | std::shared_ptr<data::SetSampler> tv(new data::SetSampler()); | ||
2456 | tv->_0 = fromJSON(W<::TextureUnit>(), obj["arg0"]); | ||
2457 | tv->_1 = fromJSON(W<Maybe<::SamplerName>>(), obj["arg1"]); | ||
2458 | return tv; | ||
2459 | } | ||
2460 | else if (tag == "RenderSlot") { | ||
2461 | tagType = ::Command::tag::RenderSlot; | ||
2462 | std::shared_ptr<data::RenderSlot> tv(new data::RenderSlot()); | ||
2463 | tv->_0 = fromJSON(W<::SlotName>(), obj["arg0"]); | ||
2464 | return tv; | ||
2465 | } | ||
2466 | else if (tag == "RenderStream") { | ||
2467 | tagType = ::Command::tag::RenderStream; | ||
2468 | std::shared_ptr<data::RenderStream> tv(new data::RenderStream()); | ||
2469 | tv->_0 = fromJSON(W<::StreamName>(), obj["arg0"]); | ||
2470 | return tv; | ||
2471 | } | ||
2472 | else if (tag == "ClearRenderTarget") { | ||
2473 | tagType = ::Command::tag::ClearRenderTarget; | ||
2474 | std::shared_ptr<data::ClearRenderTarget> tv(new data::ClearRenderTarget()); | ||
2475 | tv->_0 = fromJSON(W<std::vector<std::shared_ptr<::ClearImage>>>(), obj["arg0"]); | ||
2476 | return tv; | ||
2477 | } | ||
2478 | else if (tag == "GenerateMipMap") { | ||
2479 | tagType = ::Command::tag::GenerateMipMap; | ||
2480 | std::shared_ptr<data::GenerateMipMap> tv(new data::GenerateMipMap()); | ||
2481 | tv->_0 = fromJSON(W<::TextureUnit>(), obj["arg0"]); | ||
2482 | return tv; | ||
2483 | } | ||
2484 | else if (tag == "SaveImage") { | ||
2485 | tagType = ::Command::tag::SaveImage; | ||
2486 | std::shared_ptr<data::SaveImage> tv(new data::SaveImage()); | ||
2487 | tv->_0 = fromJSON(W<::FrameBufferComponent>(), obj["arg0"]); | ||
2488 | tv->_1 = fromJSON(W<std::shared_ptr<::ImageRef>>(), obj["arg1"]); | ||
2489 | return tv; | ||
2490 | } | ||
2491 | else if (tag == "LoadImage") { | ||
2492 | tagType = ::Command::tag::LoadImage; | ||
2493 | std::shared_ptr<data::LoadImage> tv(new data::LoadImage()); | ||
2494 | tv->_0 = fromJSON(W<std::shared_ptr<::ImageRef>>(), obj["arg0"]); | ||
2495 | tv->_1 = fromJSON(W<::FrameBufferComponent>(), obj["arg1"]); | ||
2496 | return tv; | ||
2497 | } | ||
2498 | else throw "unknown constructor: " + tag; | ||
2499 | std::shared_ptr<::Command> o(new ::Command()); | ||
2500 | o->tag = tagType; | ||
2501 | return o; | ||
2502 | } | ||
2503 | |||
2504 | template<> json toJSON<std::shared_ptr<SamplerDescriptor>>(std::shared_ptr<SamplerDescriptor> &v) { | ||
2505 | json obj({}); | ||
2506 | switch (v->tag) { | ||
2507 | case ::SamplerDescriptor::tag::SamplerDescriptor: | ||
2508 | obj["tag"] = "SamplerDescriptor"; | ||
2509 | { | ||
2510 | std::shared_ptr<data::SamplerDescriptor> tv = std::static_pointer_cast<data::SamplerDescriptor>(v); | ||
2511 | obj["samplerWrapS"] = toJSON(tv->samplerWrapS); | ||
2512 | obj["samplerWrapT"] = toJSON(tv->samplerWrapT); | ||
2513 | obj["samplerWrapR"] = toJSON(tv->samplerWrapR); | ||
2514 | obj["samplerMinFilter"] = toJSON(tv->samplerMinFilter); | ||
2515 | obj["samplerMagFilter"] = toJSON(tv->samplerMagFilter); | ||
2516 | obj["samplerBorderColor"] = toJSON(tv->samplerBorderColor); | ||
2517 | obj["samplerMinLod"] = toJSON(tv->samplerMinLod); | ||
2518 | obj["samplerMaxLod"] = toJSON(tv->samplerMaxLod); | ||
2519 | obj["samplerLodBias"] = toJSON(tv->samplerLodBias); | ||
2520 | obj["samplerCompareFunc"] = toJSON(tv->samplerCompareFunc); | ||
2521 | } | ||
2522 | break; | ||
2523 | } | ||
2524 | return obj; | ||
2525 | } | ||
2526 | |||
2527 | template<> std::shared_ptr<SamplerDescriptor> fromJSON<std::shared_ptr<SamplerDescriptor>>(W<std::shared_ptr<SamplerDescriptor>> v, json &obj) { | ||
2528 | enum ::SamplerDescriptor::tag tagType; | ||
2529 | std::string tag = obj["tag"]; | ||
2530 | if (tag == "SamplerDescriptor") { | ||
2531 | tagType = ::SamplerDescriptor::tag::SamplerDescriptor; | ||
2532 | std::shared_ptr<data::SamplerDescriptor> tv(new data::SamplerDescriptor()); | ||
2533 | tv->samplerWrapS = fromJSON(W<std::shared_ptr<::EdgeMode>>(), obj["samplerWrapS"]); | ||
2534 | tv->samplerWrapT = fromJSON(W<Maybe<std::shared_ptr<::EdgeMode>>>(), obj["samplerWrapT"]); | ||
2535 | tv->samplerWrapR = fromJSON(W<Maybe<std::shared_ptr<::EdgeMode>>>(), obj["samplerWrapR"]); | ||
2536 | tv->samplerMinFilter = fromJSON(W<std::shared_ptr<::Filter>>(), obj["samplerMinFilter"]); | ||
2537 | tv->samplerMagFilter = fromJSON(W<std::shared_ptr<::Filter>>(), obj["samplerMagFilter"]); | ||
2538 | tv->samplerBorderColor = fromJSON(W<std::shared_ptr<::Value>>(), obj["samplerBorderColor"]); | ||
2539 | tv->samplerMinLod = fromJSON(W<Maybe<Float>>(), obj["samplerMinLod"]); | ||
2540 | tv->samplerMaxLod = fromJSON(W<Maybe<Float>>(), obj["samplerMaxLod"]); | ||
2541 | tv->samplerLodBias = fromJSON(W<Float>(), obj["samplerLodBias"]); | ||
2542 | tv->samplerCompareFunc = fromJSON(W<Maybe<std::shared_ptr<::ComparisonFunction>>>(), obj["samplerCompareFunc"]); | ||
2543 | return tv; | ||
2544 | } | ||
2545 | else throw "unknown constructor: " + tag; | ||
2546 | std::shared_ptr<::SamplerDescriptor> o(new ::SamplerDescriptor()); | ||
2547 | o->tag = tagType; | ||
2548 | return o; | ||
2549 | } | ||
2550 | |||
2551 | template<> json toJSON<std::shared_ptr<TextureDescriptor>>(std::shared_ptr<TextureDescriptor> &v) { | ||
2552 | json obj({}); | ||
2553 | switch (v->tag) { | ||
2554 | case ::TextureDescriptor::tag::TextureDescriptor: | ||
2555 | obj["tag"] = "TextureDescriptor"; | ||
2556 | { | ||
2557 | std::shared_ptr<data::TextureDescriptor> tv = std::static_pointer_cast<data::TextureDescriptor>(v); | ||
2558 | obj["textureType"] = toJSON(tv->textureType); | ||
2559 | obj["textureSize"] = toJSON(tv->textureSize); | ||
2560 | obj["textureSemantic"] = toJSON(tv->textureSemantic); | ||
2561 | obj["textureSampler"] = toJSON(tv->textureSampler); | ||
2562 | obj["textureBaseLevel"] = toJSON(tv->textureBaseLevel); | ||
2563 | obj["textureMaxLevel"] = toJSON(tv->textureMaxLevel); | ||
2564 | } | ||
2565 | break; | ||
2566 | } | ||
2567 | return obj; | ||
2568 | } | ||
2569 | |||
2570 | template<> std::shared_ptr<TextureDescriptor> fromJSON<std::shared_ptr<TextureDescriptor>>(W<std::shared_ptr<TextureDescriptor>> v, json &obj) { | ||
2571 | enum ::TextureDescriptor::tag tagType; | ||
2572 | std::string tag = obj["tag"]; | ||
2573 | if (tag == "TextureDescriptor") { | ||
2574 | tagType = ::TextureDescriptor::tag::TextureDescriptor; | ||
2575 | std::shared_ptr<data::TextureDescriptor> tv(new data::TextureDescriptor()); | ||
2576 | tv->textureType = fromJSON(W<std::shared_ptr<::TextureType>>(), obj["textureType"]); | ||
2577 | tv->textureSize = fromJSON(W<std::shared_ptr<::Value>>(), obj["textureSize"]); | ||
2578 | tv->textureSemantic = fromJSON(W<std::shared_ptr<::ImageSemantic>>(), obj["textureSemantic"]); | ||
2579 | tv->textureSampler = fromJSON(W<std::shared_ptr<::SamplerDescriptor>>(), obj["textureSampler"]); | ||
2580 | tv->textureBaseLevel = fromJSON(W<Int>(), obj["textureBaseLevel"]); | ||
2581 | tv->textureMaxLevel = fromJSON(W<Int>(), obj["textureMaxLevel"]); | ||
2582 | return tv; | ||
2583 | } | ||
2584 | else throw "unknown constructor: " + tag; | ||
2585 | std::shared_ptr<::TextureDescriptor> o(new ::TextureDescriptor()); | ||
2586 | o->tag = tagType; | ||
2587 | return o; | ||
2588 | } | ||
2589 | |||
2590 | template<> json toJSON<std::shared_ptr<Parameter>>(std::shared_ptr<Parameter> &v) { | ||
2591 | json obj({}); | ||
2592 | switch (v->tag) { | ||
2593 | case ::Parameter::tag::Parameter: | ||
2594 | obj["tag"] = "Parameter"; | ||
2595 | { | ||
2596 | std::shared_ptr<data::Parameter> tv = std::static_pointer_cast<data::Parameter>(v); | ||
2597 | obj["name"] = toJSON(tv->name); | ||
2598 | obj["ty"] = toJSON(tv->ty); | ||
2599 | } | ||
2600 | break; | ||
2601 | } | ||
2602 | return obj; | ||
2603 | } | ||
2604 | |||
2605 | template<> std::shared_ptr<Parameter> fromJSON<std::shared_ptr<Parameter>>(W<std::shared_ptr<Parameter>> v, json &obj) { | ||
2606 | enum ::Parameter::tag tagType; | ||
2607 | std::string tag = obj["tag"]; | ||
2608 | if (tag == "Parameter") { | ||
2609 | tagType = ::Parameter::tag::Parameter; | ||
2610 | std::shared_ptr<data::Parameter> tv(new data::Parameter()); | ||
2611 | tv->name = fromJSON(W<String>(), obj["name"]); | ||
2612 | tv->ty = fromJSON(W<std::shared_ptr<::InputType>>(), obj["ty"]); | ||
2613 | return tv; | ||
2614 | } | ||
2615 | else throw "unknown constructor: " + tag; | ||
2616 | std::shared_ptr<::Parameter> o(new ::Parameter()); | ||
2617 | o->tag = tagType; | ||
2618 | return o; | ||
2619 | } | ||
2620 | |||
2621 | template<> json toJSON<std::shared_ptr<Program>>(std::shared_ptr<Program> &v) { | ||
2622 | json obj({}); | ||
2623 | switch (v->tag) { | ||
2624 | case ::Program::tag::Program: | ||
2625 | obj["tag"] = "Program"; | ||
2626 | { | ||
2627 | std::shared_ptr<data::Program> tv = std::static_pointer_cast<data::Program>(v); | ||
2628 | obj["programUniforms"] = toJSON(tv->programUniforms); | ||
2629 | obj["programStreams"] = toJSON(tv->programStreams); | ||
2630 | obj["programInTextures"] = toJSON(tv->programInTextures); | ||
2631 | obj["programOutput"] = toJSON(tv->programOutput); | ||
2632 | obj["vertexShader"] = toJSON(tv->vertexShader); | ||
2633 | obj["geometryShader"] = toJSON(tv->geometryShader); | ||
2634 | obj["fragmentShader"] = toJSON(tv->fragmentShader); | ||
2635 | } | ||
2636 | break; | ||
2637 | } | ||
2638 | return obj; | ||
2639 | } | ||
2640 | |||
2641 | template<> std::shared_ptr<Program> fromJSON<std::shared_ptr<Program>>(W<std::shared_ptr<Program>> v, json &obj) { | ||
2642 | enum ::Program::tag tagType; | ||
2643 | std::string tag = obj["tag"]; | ||
2644 | if (tag == "Program") { | ||
2645 | tagType = ::Program::tag::Program; | ||
2646 | std::shared_ptr<data::Program> tv(new data::Program()); | ||
2647 | tv->programUniforms = fromJSON(W<std::map<::UniformName, std::shared_ptr<::InputType>>>(), obj["programUniforms"]); | ||
2648 | tv->programStreams = fromJSON(W<std::map<::UniformName, std::shared_ptr<::Parameter>>>(), obj["programStreams"]); | ||
2649 | tv->programInTextures = fromJSON(W<std::map<::UniformName, std::shared_ptr<::InputType>>>(), obj["programInTextures"]); | ||
2650 | tv->programOutput = fromJSON(W<std::vector<std::shared_ptr<::Parameter>>>(), obj["programOutput"]); | ||
2651 | tv->vertexShader = fromJSON(W<String>(), obj["vertexShader"]); | ||
2652 | tv->geometryShader = fromJSON(W<Maybe<String>>(), obj["geometryShader"]); | ||
2653 | tv->fragmentShader = fromJSON(W<String>(), obj["fragmentShader"]); | ||
2654 | return tv; | ||
2655 | } | ||
2656 | else throw "unknown constructor: " + tag; | ||
2657 | std::shared_ptr<::Program> o(new ::Program()); | ||
2658 | o->tag = tagType; | ||
2659 | return o; | ||
2660 | } | ||
2661 | |||
2662 | template<> json toJSON<std::shared_ptr<Slot>>(std::shared_ptr<Slot> &v) { | ||
2663 | json obj({}); | ||
2664 | switch (v->tag) { | ||
2665 | case ::Slot::tag::Slot: | ||
2666 | obj["tag"] = "Slot"; | ||
2667 | { | ||
2668 | std::shared_ptr<data::Slot> tv = std::static_pointer_cast<data::Slot>(v); | ||
2669 | obj["slotName"] = toJSON(tv->slotName); | ||
2670 | obj["slotStreams"] = toJSON(tv->slotStreams); | ||
2671 | obj["slotUniforms"] = toJSON(tv->slotUniforms); | ||
2672 | obj["slotPrimitive"] = toJSON(tv->slotPrimitive); | ||
2673 | obj["slotPrograms"] = toJSON(tv->slotPrograms); | ||
2674 | } | ||
2675 | break; | ||
2676 | } | ||
2677 | return obj; | ||
2678 | } | ||
2679 | |||
2680 | template<> std::shared_ptr<Slot> fromJSON<std::shared_ptr<Slot>>(W<std::shared_ptr<Slot>> v, json &obj) { | ||
2681 | enum ::Slot::tag tagType; | ||
2682 | std::string tag = obj["tag"]; | ||
2683 | if (tag == "Slot") { | ||
2684 | tagType = ::Slot::tag::Slot; | ||
2685 | std::shared_ptr<data::Slot> tv(new data::Slot()); | ||
2686 | tv->slotName = fromJSON(W<String>(), obj["slotName"]); | ||
2687 | tv->slotStreams = fromJSON(W<std::map<String, std::shared_ptr<::InputType>>>(), obj["slotStreams"]); | ||
2688 | tv->slotUniforms = fromJSON(W<std::map<::UniformName, std::shared_ptr<::InputType>>>(), obj["slotUniforms"]); | ||
2689 | tv->slotPrimitive = fromJSON(W<std::shared_ptr<::FetchPrimitive>>(), obj["slotPrimitive"]); | ||
2690 | tv->slotPrograms = fromJSON(W<std::vector<::ProgramName>>(), obj["slotPrograms"]); | ||
2691 | return tv; | ||
2692 | } | ||
2693 | else throw "unknown constructor: " + tag; | ||
2694 | std::shared_ptr<::Slot> o(new ::Slot()); | ||
2695 | o->tag = tagType; | ||
2696 | return o; | ||
2697 | } | ||
2698 | |||
2699 | template<> json toJSON<std::shared_ptr<StreamData>>(std::shared_ptr<StreamData> &v) { | ||
2700 | json obj({}); | ||
2701 | switch (v->tag) { | ||
2702 | case ::StreamData::tag::StreamData: | ||
2703 | obj["tag"] = "StreamData"; | ||
2704 | { | ||
2705 | std::shared_ptr<data::StreamData> tv = std::static_pointer_cast<data::StreamData>(v); | ||
2706 | obj["streamData"] = toJSON(tv->streamData); | ||
2707 | obj["streamType"] = toJSON(tv->streamType); | ||
2708 | obj["streamPrimitive"] = toJSON(tv->streamPrimitive); | ||
2709 | obj["streamPrograms"] = toJSON(tv->streamPrograms); | ||
2710 | } | ||
2711 | break; | ||
2712 | } | ||
2713 | return obj; | ||
2714 | } | ||
2715 | |||
2716 | template<> std::shared_ptr<StreamData> fromJSON<std::shared_ptr<StreamData>>(W<std::shared_ptr<StreamData>> v, json &obj) { | ||
2717 | enum ::StreamData::tag tagType; | ||
2718 | std::string tag = obj["tag"]; | ||
2719 | if (tag == "StreamData") { | ||
2720 | tagType = ::StreamData::tag::StreamData; | ||
2721 | std::shared_ptr<data::StreamData> tv(new data::StreamData()); | ||
2722 | tv->streamData = fromJSON(W<std::map<String, std::shared_ptr<::ArrayValue>>>(), obj["streamData"]); | ||
2723 | tv->streamType = fromJSON(W<std::map<String, std::shared_ptr<::InputType>>>(), obj["streamType"]); | ||
2724 | tv->streamPrimitive = fromJSON(W<std::shared_ptr<::FetchPrimitive>>(), obj["streamPrimitive"]); | ||
2725 | tv->streamPrograms = fromJSON(W<std::vector<::ProgramName>>(), obj["streamPrograms"]); | ||
2726 | return tv; | ||
2727 | } | ||
2728 | else throw "unknown constructor: " + tag; | ||
2729 | std::shared_ptr<::StreamData> o(new ::StreamData()); | ||
2730 | o->tag = tagType; | ||
2731 | return o; | ||
2732 | } | ||
2733 | |||
2734 | template<> json toJSON<std::shared_ptr<TargetItem>>(std::shared_ptr<TargetItem> &v) { | ||
2735 | json obj({}); | ||
2736 | switch (v->tag) { | ||
2737 | case ::TargetItem::tag::TargetItem: | ||
2738 | obj["tag"] = "TargetItem"; | ||
2739 | { | ||
2740 | std::shared_ptr<data::TargetItem> tv = std::static_pointer_cast<data::TargetItem>(v); | ||
2741 | obj["targetSemantic"] = toJSON(tv->targetSemantic); | ||
2742 | obj["targetRef"] = toJSON(tv->targetRef); | ||
2743 | } | ||
2744 | break; | ||
2745 | } | ||
2746 | return obj; | ||
2747 | } | ||
2748 | |||
2749 | template<> std::shared_ptr<TargetItem> fromJSON<std::shared_ptr<TargetItem>>(W<std::shared_ptr<TargetItem>> v, json &obj) { | ||
2750 | enum ::TargetItem::tag tagType; | ||
2751 | std::string tag = obj["tag"]; | ||
2752 | if (tag == "TargetItem") { | ||
2753 | tagType = ::TargetItem::tag::TargetItem; | ||
2754 | std::shared_ptr<data::TargetItem> tv(new data::TargetItem()); | ||
2755 | tv->targetSemantic = fromJSON(W<std::shared_ptr<::ImageSemantic>>(), obj["targetSemantic"]); | ||
2756 | tv->targetRef = fromJSON(W<Maybe<std::shared_ptr<::ImageRef>>>(), obj["targetRef"]); | ||
2757 | return tv; | ||
2758 | } | ||
2759 | else throw "unknown constructor: " + tag; | ||
2760 | std::shared_ptr<::TargetItem> o(new ::TargetItem()); | ||
2761 | o->tag = tagType; | ||
2762 | return o; | ||
2763 | } | ||
2764 | |||
2765 | template<> json toJSON<std::shared_ptr<RenderTarget>>(std::shared_ptr<RenderTarget> &v) { | ||
2766 | json obj({}); | ||
2767 | switch (v->tag) { | ||
2768 | case ::RenderTarget::tag::RenderTarget: | ||
2769 | obj["tag"] = "RenderTarget"; | ||
2770 | { | ||
2771 | std::shared_ptr<data::RenderTarget> tv = std::static_pointer_cast<data::RenderTarget>(v); | ||
2772 | obj["renderTargets"] = toJSON(tv->renderTargets); | ||
2773 | } | ||
2774 | break; | ||
2775 | } | ||
2776 | return obj; | ||
2777 | } | ||
2778 | |||
2779 | template<> std::shared_ptr<RenderTarget> fromJSON<std::shared_ptr<RenderTarget>>(W<std::shared_ptr<RenderTarget>> v, json &obj) { | ||
2780 | enum ::RenderTarget::tag tagType; | ||
2781 | std::string tag = obj["tag"]; | ||
2782 | if (tag == "RenderTarget") { | ||
2783 | tagType = ::RenderTarget::tag::RenderTarget; | ||
2784 | std::shared_ptr<data::RenderTarget> tv(new data::RenderTarget()); | ||
2785 | tv->renderTargets = fromJSON(W<std::vector<std::shared_ptr<::TargetItem>>>(), obj["renderTargets"]); | ||
2786 | return tv; | ||
2787 | } | ||
2788 | else throw "unknown constructor: " + tag; | ||
2789 | std::shared_ptr<::RenderTarget> o(new ::RenderTarget()); | ||
2790 | o->tag = tagType; | ||
2791 | return o; | ||
2792 | } | ||
2793 | |||
2794 | template<> json toJSON<std::shared_ptr<Backend>>(std::shared_ptr<Backend> &v) { | ||
2795 | json obj({}); | ||
2796 | switch (v->tag) { | ||
2797 | case ::Backend::tag::WebGL1: | ||
2798 | obj["tag"] = "WebGL1"; | ||
2799 | break; | ||
2800 | case ::Backend::tag::OpenGL33: | ||
2801 | obj["tag"] = "OpenGL33"; | ||
2802 | break; | ||
2803 | } | ||
2804 | return obj; | ||
2805 | } | ||
2806 | |||
2807 | template<> std::shared_ptr<Backend> fromJSON<std::shared_ptr<Backend>>(W<std::shared_ptr<Backend>> v, json &obj) { | ||
2808 | enum ::Backend::tag tagType; | ||
2809 | std::string tag = obj["tag"]; | ||
2810 | if (tag == "WebGL1") { | ||
2811 | tagType = ::Backend::tag::WebGL1; | ||
2812 | } | ||
2813 | else if (tag == "OpenGL33") { | ||
2814 | tagType = ::Backend::tag::OpenGL33; | ||
2815 | } | ||
2816 | else throw "unknown constructor: " + tag; | ||
2817 | std::shared_ptr<::Backend> o(new ::Backend()); | ||
2818 | o->tag = tagType; | ||
2819 | return o; | ||
2820 | } | ||
2821 | |||
2822 | template<> json toJSON<std::shared_ptr<Pipeline>>(std::shared_ptr<Pipeline> &v) { | ||
2823 | json obj({}); | ||
2824 | switch (v->tag) { | ||
2825 | case ::Pipeline::tag::Pipeline: | ||
2826 | obj["tag"] = "Pipeline"; | ||
2827 | { | ||
2828 | std::shared_ptr<data::Pipeline> tv = std::static_pointer_cast<data::Pipeline>(v); | ||
2829 | obj["backend"] = toJSON(tv->backend); | ||
2830 | obj["textures"] = toJSON(tv->textures); | ||
2831 | obj["samplers"] = toJSON(tv->samplers); | ||
2832 | obj["targets"] = toJSON(tv->targets); | ||
2833 | obj["programs"] = toJSON(tv->programs); | ||
2834 | obj["slots"] = toJSON(tv->slots); | ||
2835 | obj["streams"] = toJSON(tv->streams); | ||
2836 | obj["commands"] = toJSON(tv->commands); | ||
2837 | } | ||
2838 | break; | ||
2839 | } | ||
2840 | return obj; | ||
2841 | } | ||
2842 | |||
2843 | template<> std::shared_ptr<Pipeline> fromJSON<std::shared_ptr<Pipeline>>(W<std::shared_ptr<Pipeline>> v, json &obj) { | ||
2844 | enum ::Pipeline::tag tagType; | ||
2845 | std::string tag = obj["tag"]; | ||
2846 | if (tag == "Pipeline") { | ||
2847 | tagType = ::Pipeline::tag::Pipeline; | ||
2848 | std::shared_ptr<data::Pipeline> tv(new data::Pipeline()); | ||
2849 | tv->backend = fromJSON(W<std::shared_ptr<::Backend>>(), obj["backend"]); | ||
2850 | tv->textures = fromJSON(W<std::vector<std::shared_ptr<::TextureDescriptor>>>(), obj["textures"]); | ||
2851 | tv->samplers = fromJSON(W<std::vector<std::shared_ptr<::SamplerDescriptor>>>(), obj["samplers"]); | ||
2852 | tv->targets = fromJSON(W<std::vector<std::shared_ptr<::RenderTarget>>>(), obj["targets"]); | ||
2853 | tv->programs = fromJSON(W<std::vector<std::shared_ptr<::Program>>>(), obj["programs"]); | ||
2854 | tv->slots = fromJSON(W<std::vector<std::shared_ptr<::Slot>>>(), obj["slots"]); | ||
2855 | tv->streams = fromJSON(W<std::vector<std::shared_ptr<::StreamData>>>(), obj["streams"]); | ||
2856 | tv->commands = fromJSON(W<std::vector<std::shared_ptr<::Command>>>(), obj["commands"]); | ||
2857 | return tv; | ||
2858 | } | ||
2859 | else throw "unknown constructor: " + tag; | ||
2860 | std::shared_ptr<::Pipeline> o(new ::Pipeline()); | ||
2861 | o->tag = tagType; | ||
2862 | return o; | ||
2863 | } | ||
2864 | |||