summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCsaba Hruska <csaba.hruska@gmail.com>2016-01-29 15:27:53 +0100
committerCsaba Hruska <csaba.hruska@gmail.com>2016-01-29 15:27:53 +0100
commitfe9a7c6d0af59227ff34b098f2a5ba1359790ae8 (patch)
tree3bb7170620c4b914d8bc39127af1e4fb4627fab3
parent0c885c5c6bfb69c543635fd08d697ce44f24642d (diff)
add Schema to IR module, also use namespace
-rw-r--r--ddl/Definitions.hs97
-rw-r--r--ddl/Generate.hs2
-rw-r--r--ddl/out/LambdaCube.IR.cpp (renamed from ddl/out/IR.cpp)4
-rw-r--r--ddl/out/LambdaCube.IR.hpp (renamed from ddl/out/IR.hpp)6
-rw-r--r--ddl/out/LambdaCube.IR.hs (renamed from ddl/out/IR.hs)6
-rw-r--r--ddl/out/LambdaCube.IR.purs (renamed from ddl/out/IR.purs)4
-rw-r--r--ddl/out/LambdaCube.IR.swift (renamed from ddl/out/IR.swift)2
-rw-r--r--ddl/out/LambdaCube.IR2.hpp (renamed from ddl/out/IR2.hpp)6
-rw-r--r--ddl/out/LambdaCube.Mesh.cpp (renamed from ddl/out/Mesh.cpp)4
-rw-r--r--ddl/out/LambdaCube.Mesh.hpp (renamed from ddl/out/Mesh.hpp)6
-rw-r--r--ddl/out/LambdaCube.Mesh.hs (renamed from ddl/out/Mesh.hs)6
-rw-r--r--ddl/out/LambdaCube.Mesh.purs (renamed from ddl/out/Mesh.purs)4
-rw-r--r--ddl/out/LambdaCube.Mesh.swift (renamed from ddl/out/Mesh.swift)2
-rw-r--r--ddl/out/LambdaCube.Mesh2.hpp (renamed from ddl/out/Mesh2.hpp)6
-rw-r--r--ddl/out/LambdaCube.PipelineSchema.cpp208
-rw-r--r--ddl/out/LambdaCube.PipelineSchema.hpp67
-rw-r--r--ddl/out/LambdaCube.PipelineSchema.hs153
-rw-r--r--ddl/out/LambdaCube.PipelineSchema.purs152
-rw-r--r--ddl/out/LambdaCube.PipelineSchema.swift205
-rw-r--r--ddl/out/LambdaCube.PipelineSchema2.hpp67
-rw-r--r--ddl/out/LambdaCube.TypeInfo.cpp (renamed from ddl/out/TypeInfo.cpp)4
-rw-r--r--ddl/out/LambdaCube.TypeInfo.hpp (renamed from ddl/out/TypeInfo.hpp)8
-rw-r--r--ddl/out/LambdaCube.TypeInfo.hs (renamed from ddl/out/TypeInfo.hs)8
-rw-r--r--ddl/out/LambdaCube.TypeInfo.purs (renamed from ddl/out/TypeInfo.purs)6
-rw-r--r--ddl/out/LambdaCube.TypeInfo.swift (renamed from ddl/out/TypeInfo.swift)2
-rw-r--r--ddl/out/LambdaCube.TypeInfo2.hpp (renamed from ddl/out/TypeInfo2.hpp)8
-rw-r--r--ddl/out/TestData.cpp215
-rw-r--r--ddl/out/TestData.hpp109
-rw-r--r--ddl/out/TestData.hs213
-rw-r--r--ddl/out/TestData.purs209
-rw-r--r--ddl/out/TestData.swift222
-rw-r--r--ddl/out/TestData2.hpp109
-rw-r--r--ddl/templates/data.hs.ede2
-rw-r--r--lambdacube-ir.haskell/lambdacube-ir.cabal10
l---------lambdacube-ir.haskell/src/IR.hs1
l---------lambdacube-ir.haskell/src/LambdaCube/IR.hs1
-rw-r--r--lambdacube-ir.haskell/src/LambdaCube/Linear.hs (renamed from lambdacube-ir.haskell/src/Linear.hs)2
l---------lambdacube-ir.haskell/src/LambdaCube/Mesh.hs1
l---------lambdacube-ir.haskell/src/LambdaCube/PipelineSchema.hs1
-rw-r--r--lambdacube-ir.haskell/src/LambdaCube/PipelineSchemaUtil.hs20
40 files changed, 2102 insertions, 56 deletions
diff --git a/ddl/Definitions.hs b/ddl/Definitions.hs
index 53930ef..6bac3d6 100644
--- a/ddl/Definitions.hs
+++ b/ddl/Definitions.hs
@@ -471,9 +471,98 @@ typeInfo = do
471 const_ "MyLeft" ["TypeInfo", Array "TypeInfo"] 471 const_ "MyLeft" ["TypeInfo", Array "TypeInfo"]
472 const_ "MyRight" [String, "Pipeline", Array "TypeInfo"] 472 const_ "MyRight" [String, "Pipeline", Array "TypeInfo"]
473 473
474pipelineSchema = do
475 data_ "StreamType" $ do
476 enum_ "Attribute_Word"
477 enum_ "Attribute_V2U"
478 enum_ "Attribute_V3U"
479 enum_ "Attribute_V4U"
480 enum_ "Attribute_Int"
481 enum_ "Attribute_V2I"
482 enum_ "Attribute_V3I"
483 enum_ "Attribute_V4I"
484 enum_ "Attribute_Float"
485 enum_ "Attribute_V2F"
486 enum_ "Attribute_V3F"
487 enum_ "Attribute_V4F"
488 enum_ "Attribute_M22F"
489 enum_ "Attribute_M23F"
490 enum_ "Attribute_M24F"
491 enum_ "Attribute_M32F"
492 enum_ "Attribute_M33F"
493 enum_ "Attribute_M34F"
494 enum_ "Attribute_M42F"
495 enum_ "Attribute_M43F"
496 enum_ "Attribute_M44F"
497
498 data_ "ObjectArraySchema" $ do
499 constR_ "ObjectArraySchema"
500 [ "primitive" #:: "FetchPrimitive"
501 , "attributes" #:: Map String "StreamType"
502 ]
503
504 data_ "PipelineSchema" $ do
505 constR_ "PipelineSchema"
506 [ "objectArrays" #:: Map String "ObjectArraySchema"
507 , "uniforms" #:: Map String "InputType"
508 ]
509
510testData = do
511 -- client info
512 data_ "ClientInfo" $ do
513 constR_ "ClientInfo"
514 [ "clientName" #:: String
515 , "clientBackend" #:: "Backend"
516 ]
517
518 -- test scene description
519 data_ "Frame" $ do
520 constR_ "Frame"
521 [ "renderCount" #:: Int
522 , "frameUniforms" #:: Map String "Value"
523 , "frameTextures" #:: Map String Int
524 ]
525
526 data_ "Scene" $ do
527 constR_ "Scene"
528 [ "objectArrays" #:: Map String (Array Int)
529 , "renderTargetWidth" #:: Int
530 , "renderTargetHeight" #:: Int
531 , "frames" #:: Array "Frame"
532 ]
533
534 data_ "RenderJob" $ do
535 constR_ "RenderJob"
536 [ "meshes" #:: Array "Mesh"
537 , "textures" #:: Array String -- png texture
538 , "schema" #:: "PipelineSchema"
539 , "scenes" #:: Array "Scene"
540 , "pipelines" #:: Array "Pipeline"
541 ]
542
543 -- test result
544 data_ "FrameResult" $ do
545 constR_ "FrameResult"
546 [ "frRenderTimes" #:: Array Float
547 , "frImageWidth" #:: Int
548 , "frImageHeight" #:: Int
549 ]
550
551 data_ "RenderJobResult" $ do
552 const_ "RenderJobResult" ["FrameResult"]
553 const_ "RenderJobError" [String]
554
474modules = do 555modules = do
475 module_ "IR" ir 556 module_ "LambdaCube.IR" ir
476 module_ "Mesh" mesh 557 module_ "LambdaCube.PipelineSchema" $ do
477 module_ "TypeInfo" $ do 558 import_ ["LambdaCube.IR"]
478 import_ ["IR"] 559 pipelineSchema
560 module_ "LambdaCube.Mesh" mesh
561 module_ "LambdaCube.TypeInfo" $ do
562 import_ ["LambdaCube.IR"]
479 typeInfo 563 typeInfo
564 module_ "TestData" $ do
565 import_ ["LambdaCube.IR"]
566 import_ ["LambdaCube.Mesh"]
567 import_ ["LambdaCube.PipelineSchema"]
568 testData
diff --git a/ddl/Generate.hs b/ddl/Generate.hs
index 5f5c0d0..532a012 100644
--- a/ddl/Generate.hs
+++ b/ddl/Generate.hs
@@ -8,6 +8,8 @@ import qualified Data.HashMap.Strict as HashMap
8import Data.Text (Text) 8import Data.Text (Text)
9import qualified Data.Map as Map 9import qualified Data.Map as Map
10 10
11import System.Directory
12
11import Data.Time.Clock 13import Data.Time.Clock
12import Control.Monad.Writer 14import Control.Monad.Writer
13 15
diff --git a/ddl/out/IR.cpp b/ddl/out/LambdaCube.IR.cpp
index cac97e7..bf5ab0b 100644
--- a/ddl/out/IR.cpp
+++ b/ddl/out/LambdaCube.IR.cpp
@@ -1,7 +1,7 @@
1// generated file, do not modify! 1// generated file, do not modify!
2// 2016-01-18T14:30:07.798481Z 2// 2016-01-28T13:15:30.803775Z
3 3
4#include "IR.hpp" 4#include "LambdaCube.IR.hpp"
5template<> json toJSON<std::shared_ptr<ArrayValue>>(std::shared_ptr<ArrayValue> &v) { 5template<> json toJSON<std::shared_ptr<ArrayValue>>(std::shared_ptr<ArrayValue> &v) {
6 json obj({}); 6 json obj({});
7 switch (v->tag) { 7 switch (v->tag) {
diff --git a/ddl/out/IR.hpp b/ddl/out/LambdaCube.IR.hpp
index 4c6e9f1..c45d1ce 100644
--- a/ddl/out/IR.hpp
+++ b/ddl/out/LambdaCube.IR.hpp
@@ -1,8 +1,8 @@
1// generated file, do not modify! 1// generated file, do not modify!
2// 2016-01-18T14:30:07.798481Z 2// 2016-01-28T13:15:30.803775Z
3 3
4#ifndef HEADER_IR_H 4#ifndef HEADER_LambdaCube.IR_H
5#define HEADER_IR_H 5#define HEADER_LambdaCube.IR_H
6 6
7#include "RT.hpp" 7#include "RT.hpp"
8 8
diff --git a/ddl/out/IR.hs b/ddl/out/LambdaCube.IR.hs
index d65d628..03675f7 100644
--- a/ddl/out/IR.hs
+++ b/ddl/out/LambdaCube.IR.hs
@@ -1,14 +1,14 @@
1-- generated file, do not modify! 1-- generated file, do not modify!
2-- 2016-01-18T14:30:07.798481Z 2-- 2016-01-28T13:15:30.803775Z
3 3
4{-# LANGUAGE OverloadedStrings, RecordWildCards #-} 4{-# LANGUAGE OverloadedStrings, RecordWildCards #-}
5module IR where 5module LambdaCube.IR where
6 6
7import Data.Int 7import Data.Int
8import Data.Word 8import Data.Word
9import Data.Map 9import Data.Map
10import Data.Vector (Vector(..)) 10import Data.Vector (Vector(..))
11import Linear 11import LambdaCube.Linear
12 12
13import Data.Text 13import Data.Text
14import Data.Aeson hiding (Value,Bool) 14import Data.Aeson hiding (Value,Bool)
diff --git a/ddl/out/IR.purs b/ddl/out/LambdaCube.IR.purs
index bfdeb62..459c1c8 100644
--- a/ddl/out/IR.purs
+++ b/ddl/out/LambdaCube.IR.purs
@@ -1,7 +1,7 @@
1-- generated file, do not modify! 1-- generated file, do not modify!
2-- 2016-01-18T14:30:07.798481Z 2-- 2016-01-28T13:15:30.803775Z
3 3
4module IR where 4module LambdaCube.IR where
5import Prelude 5import Prelude
6import Data.Generic 6import Data.Generic
7import Data.Maybe (Maybe(..)) 7import Data.Maybe (Maybe(..))
diff --git a/ddl/out/IR.swift b/ddl/out/LambdaCube.IR.swift
index 78358f4..eb4b35f 100644
--- a/ddl/out/IR.swift
+++ b/ddl/out/LambdaCube.IR.swift
@@ -1,5 +1,5 @@
1// generated file, do not modify! 1// generated file, do not modify!
2// 2016-01-18T14:30:07.798481Z 2// 2016-01-28T13:15:30.803775Z
3 3
4typealias StreamName = Int 4typealias StreamName = Int
5 5
diff --git a/ddl/out/IR2.hpp b/ddl/out/LambdaCube.IR2.hpp
index d286395..43de714 100644
--- a/ddl/out/IR2.hpp
+++ b/ddl/out/LambdaCube.IR2.hpp
@@ -1,8 +1,8 @@
1// generated file, do not modify! 1// generated file, do not modify!
2// 2016-01-18T14:30:07.798481Z 2// 2016-01-28T13:15:30.803775Z
3 3
4#ifndef HEADER_IR_H 4#ifndef HEADER_LambdaCube.IR_H
5#define HEADER_IR_H 5#define HEADER_LambdaCube.IR_H
6 6
7#include "RT.hpp" 7#include "RT.hpp"
8 8
diff --git a/ddl/out/Mesh.cpp b/ddl/out/LambdaCube.Mesh.cpp
index ce902bd..9f9599b 100644
--- a/ddl/out/Mesh.cpp
+++ b/ddl/out/LambdaCube.Mesh.cpp
@@ -1,7 +1,7 @@
1// generated file, do not modify! 1// generated file, do not modify!
2// 2016-01-18T14:30:08.223471Z 2// 2016-01-28T13:15:31.220124Z
3 3
4#include "Mesh.hpp" 4#include "LambdaCube.Mesh.hpp"
5template<> json toJSON<std::shared_ptr<MeshAttribute>>(std::shared_ptr<MeshAttribute> &v) { 5template<> json toJSON<std::shared_ptr<MeshAttribute>>(std::shared_ptr<MeshAttribute> &v) {
6 json obj({}); 6 json obj({});
7 switch (v->tag) { 7 switch (v->tag) {
diff --git a/ddl/out/Mesh.hpp b/ddl/out/LambdaCube.Mesh.hpp
index ab8c193..34583a2 100644
--- a/ddl/out/Mesh.hpp
+++ b/ddl/out/LambdaCube.Mesh.hpp
@@ -1,8 +1,8 @@
1// generated file, do not modify! 1// generated file, do not modify!
2// 2016-01-18T14:30:08.223471Z 2// 2016-01-28T13:15:31.220124Z
3 3
4#ifndef HEADER_Mesh_H 4#ifndef HEADER_LambdaCube.Mesh_H
5#define HEADER_Mesh_H 5#define HEADER_LambdaCube.Mesh_H
6 6
7#include "RT.hpp" 7#include "RT.hpp"
8 8
diff --git a/ddl/out/Mesh.hs b/ddl/out/LambdaCube.Mesh.hs
index 8a5b339..ad98c1b 100644
--- a/ddl/out/Mesh.hs
+++ b/ddl/out/LambdaCube.Mesh.hs
@@ -1,14 +1,14 @@
1-- generated file, do not modify! 1-- generated file, do not modify!
2-- 2016-01-18T14:30:08.223471Z 2-- 2016-01-28T13:15:31.220124Z
3 3
4{-# LANGUAGE OverloadedStrings, RecordWildCards #-} 4{-# LANGUAGE OverloadedStrings, RecordWildCards #-}
5module Mesh where 5module LambdaCube.Mesh where
6 6
7import Data.Int 7import Data.Int
8import Data.Word 8import Data.Word
9import Data.Map 9import Data.Map
10import Data.Vector (Vector(..)) 10import Data.Vector (Vector(..))
11import Linear 11import LambdaCube.Linear
12 12
13import Data.Text 13import Data.Text
14import Data.Aeson hiding (Value,Bool) 14import Data.Aeson hiding (Value,Bool)
diff --git a/ddl/out/Mesh.purs b/ddl/out/LambdaCube.Mesh.purs
index 725cced..230409f 100644
--- a/ddl/out/Mesh.purs
+++ b/ddl/out/LambdaCube.Mesh.purs
@@ -1,7 +1,7 @@
1-- generated file, do not modify! 1-- generated file, do not modify!
2-- 2016-01-18T14:30:08.223471Z 2-- 2016-01-28T13:15:31.220124Z
3 3
4module Mesh where 4module LambdaCube.Mesh where
5import Prelude 5import Prelude
6import Data.Generic 6import Data.Generic
7import Data.Maybe (Maybe(..)) 7import Data.Maybe (Maybe(..))
diff --git a/ddl/out/Mesh.swift b/ddl/out/LambdaCube.Mesh.swift
index 82b1d20..6be1e16 100644
--- a/ddl/out/Mesh.swift
+++ b/ddl/out/LambdaCube.Mesh.swift
@@ -1,5 +1,5 @@
1// generated file, do not modify! 1// generated file, do not modify!
2// 2016-01-18T14:30:08.223471Z 2// 2016-01-28T13:15:31.220124Z
3 3
4enum MeshAttribute { 4enum MeshAttribute {
5 case A_Float(Array<Float>) 5 case A_Float(Array<Float>)
diff --git a/ddl/out/Mesh2.hpp b/ddl/out/LambdaCube.Mesh2.hpp
index 041fa0f..4978258 100644
--- a/ddl/out/Mesh2.hpp
+++ b/ddl/out/LambdaCube.Mesh2.hpp
@@ -1,8 +1,8 @@
1// generated file, do not modify! 1// generated file, do not modify!
2// 2016-01-18T14:30:08.223471Z 2// 2016-01-28T13:15:31.220124Z
3 3
4#ifndef HEADER_Mesh_H 4#ifndef HEADER_LambdaCube.Mesh_H
5#define HEADER_Mesh_H 5#define HEADER_LambdaCube.Mesh_H
6 6
7#include "RT.hpp" 7#include "RT.hpp"
8 8
diff --git a/ddl/out/LambdaCube.PipelineSchema.cpp b/ddl/out/LambdaCube.PipelineSchema.cpp
new file mode 100644
index 0000000..6337f5b
--- /dev/null
+++ b/ddl/out/LambdaCube.PipelineSchema.cpp
@@ -0,0 +1,208 @@
1// generated file, do not modify!
2// 2016-01-28T13:15:31.196716Z
3
4#include "LambdaCube.PipelineSchema.hpp"
5template<> json toJSON<std::shared_ptr<StreamType>>(std::shared_ptr<StreamType> &v) {
6 json obj({});
7 switch (v->tag) {
8 case ::StreamType::tag::Attribute_Word:
9 obj["tag"] = "Attribute_Word";
10 break;
11 case ::StreamType::tag::Attribute_V2U:
12 obj["tag"] = "Attribute_V2U";
13 break;
14 case ::StreamType::tag::Attribute_V3U:
15 obj["tag"] = "Attribute_V3U";
16 break;
17 case ::StreamType::tag::Attribute_V4U:
18 obj["tag"] = "Attribute_V4U";
19 break;
20 case ::StreamType::tag::Attribute_Int:
21 obj["tag"] = "Attribute_Int";
22 break;
23 case ::StreamType::tag::Attribute_V2I:
24 obj["tag"] = "Attribute_V2I";
25 break;
26 case ::StreamType::tag::Attribute_V3I:
27 obj["tag"] = "Attribute_V3I";
28 break;
29 case ::StreamType::tag::Attribute_V4I:
30 obj["tag"] = "Attribute_V4I";
31 break;
32 case ::StreamType::tag::Attribute_Float:
33 obj["tag"] = "Attribute_Float";
34 break;
35 case ::StreamType::tag::Attribute_V2F:
36 obj["tag"] = "Attribute_V2F";
37 break;
38 case ::StreamType::tag::Attribute_V3F:
39 obj["tag"] = "Attribute_V3F";
40 break;
41 case ::StreamType::tag::Attribute_V4F:
42 obj["tag"] = "Attribute_V4F";
43 break;
44 case ::StreamType::tag::Attribute_M22F:
45 obj["tag"] = "Attribute_M22F";
46 break;
47 case ::StreamType::tag::Attribute_M23F:
48 obj["tag"] = "Attribute_M23F";
49 break;
50 case ::StreamType::tag::Attribute_M24F:
51 obj["tag"] = "Attribute_M24F";
52 break;
53 case ::StreamType::tag::Attribute_M32F:
54 obj["tag"] = "Attribute_M32F";
55 break;
56 case ::StreamType::tag::Attribute_M33F:
57 obj["tag"] = "Attribute_M33F";
58 break;
59 case ::StreamType::tag::Attribute_M34F:
60 obj["tag"] = "Attribute_M34F";
61 break;
62 case ::StreamType::tag::Attribute_M42F:
63 obj["tag"] = "Attribute_M42F";
64 break;
65 case ::StreamType::tag::Attribute_M43F:
66 obj["tag"] = "Attribute_M43F";
67 break;
68 case ::StreamType::tag::Attribute_M44F:
69 obj["tag"] = "Attribute_M44F";
70 break;
71 }
72 return obj;
73}
74
75template<> std::shared_ptr<StreamType> fromJSON<std::shared_ptr<StreamType>>(W<std::shared_ptr<StreamType>> v, json &obj) {
76 enum ::StreamType::tag tagType;
77 std::string tag = obj["tag"];
78 if (tag == "Attribute_Word") {
79 tagType = ::StreamType::tag::Attribute_Word;
80 }
81 else if (tag == "Attribute_V2U") {
82 tagType = ::StreamType::tag::Attribute_V2U;
83 }
84 else if (tag == "Attribute_V3U") {
85 tagType = ::StreamType::tag::Attribute_V3U;
86 }
87 else if (tag == "Attribute_V4U") {
88 tagType = ::StreamType::tag::Attribute_V4U;
89 }
90 else if (tag == "Attribute_Int") {
91 tagType = ::StreamType::tag::Attribute_Int;
92 }
93 else if (tag == "Attribute_V2I") {
94 tagType = ::StreamType::tag::Attribute_V2I;
95 }
96 else if (tag == "Attribute_V3I") {
97 tagType = ::StreamType::tag::Attribute_V3I;
98 }
99 else if (tag == "Attribute_V4I") {
100 tagType = ::StreamType::tag::Attribute_V4I;
101 }
102 else if (tag == "Attribute_Float") {
103 tagType = ::StreamType::tag::Attribute_Float;
104 }
105 else if (tag == "Attribute_V2F") {
106 tagType = ::StreamType::tag::Attribute_V2F;
107 }
108 else if (tag == "Attribute_V3F") {
109 tagType = ::StreamType::tag::Attribute_V3F;
110 }
111 else if (tag == "Attribute_V4F") {
112 tagType = ::StreamType::tag::Attribute_V4F;
113 }
114 else if (tag == "Attribute_M22F") {
115 tagType = ::StreamType::tag::Attribute_M22F;
116 }
117 else if (tag == "Attribute_M23F") {
118 tagType = ::StreamType::tag::Attribute_M23F;
119 }
120 else if (tag == "Attribute_M24F") {
121 tagType = ::StreamType::tag::Attribute_M24F;
122 }
123 else if (tag == "Attribute_M32F") {
124 tagType = ::StreamType::tag::Attribute_M32F;
125 }
126 else if (tag == "Attribute_M33F") {
127 tagType = ::StreamType::tag::Attribute_M33F;
128 }
129 else if (tag == "Attribute_M34F") {
130 tagType = ::StreamType::tag::Attribute_M34F;
131 }
132 else if (tag == "Attribute_M42F") {
133 tagType = ::StreamType::tag::Attribute_M42F;
134 }
135 else if (tag == "Attribute_M43F") {
136 tagType = ::StreamType::tag::Attribute_M43F;
137 }
138 else if (tag == "Attribute_M44F") {
139 tagType = ::StreamType::tag::Attribute_M44F;
140 }
141 else throw "unknown constructor: " + tag;
142 std::shared_ptr<::StreamType> o(new ::StreamType());
143 o->tag = tagType;
144 return o;
145}
146
147template<> json toJSON<std::shared_ptr<ObjectArraySchema>>(std::shared_ptr<ObjectArraySchema> &v) {
148 json obj({});
149 switch (v->tag) {
150 case ::ObjectArraySchema::tag::ObjectArraySchema:
151 obj["tag"] = "ObjectArraySchema";
152 {
153 std::shared_ptr<data::ObjectArraySchema> tv = std::static_pointer_cast<data::ObjectArraySchema>(v);
154 obj["primitive"] = toJSON(tv->primitive);
155 obj["attributes"] = toJSON(tv->attributes);
156 }
157 break;
158 }
159 return obj;
160}
161
162template<> std::shared_ptr<ObjectArraySchema> fromJSON<std::shared_ptr<ObjectArraySchema>>(W<std::shared_ptr<ObjectArraySchema>> v, json &obj) {
163 enum ::ObjectArraySchema::tag tagType;
164 std::string tag = obj["tag"];
165 if (tag == "ObjectArraySchema") {
166 tagType = ::ObjectArraySchema::tag::ObjectArraySchema;
167 std::shared_ptr<data::ObjectArraySchema> tv(new data::ObjectArraySchema());
168 tv->primitive = fromJSON(W<std::shared_ptr<::FetchPrimitive>>(), obj["primitive"]);
169 tv->attributes = fromJSON(W<std::map<String, std::shared_ptr<::StreamType>>>(), obj["attributes"]);
170 return tv;
171 }
172 else throw "unknown constructor: " + tag;
173 std::shared_ptr<::ObjectArraySchema> o(new ::ObjectArraySchema());
174 o->tag = tagType;
175 return o;
176}
177
178template<> json toJSON<std::shared_ptr<PipelineSchema>>(std::shared_ptr<PipelineSchema> &v) {
179 json obj({});
180 switch (v->tag) {
181 case ::PipelineSchema::tag::PipelineSchema:
182 obj["tag"] = "PipelineSchema";
183 {
184 std::shared_ptr<data::PipelineSchema> tv = std::static_pointer_cast<data::PipelineSchema>(v);
185 obj["objectArrays"] = toJSON(tv->objectArrays);
186 obj["uniforms"] = toJSON(tv->uniforms);
187 }
188 break;
189 }
190 return obj;
191}
192
193template<> std::shared_ptr<PipelineSchema> fromJSON<std::shared_ptr<PipelineSchema>>(W<std::shared_ptr<PipelineSchema>> v, json &obj) {
194 enum ::PipelineSchema::tag tagType;
195 std::string tag = obj["tag"];
196 if (tag == "PipelineSchema") {
197 tagType = ::PipelineSchema::tag::PipelineSchema;
198 std::shared_ptr<data::PipelineSchema> tv(new data::PipelineSchema());
199 tv->objectArrays = fromJSON(W<std::map<String, std::shared_ptr<::ObjectArraySchema>>>(), obj["objectArrays"]);
200 tv->uniforms = fromJSON(W<std::map<String, std::shared_ptr<::InputType>>>(), obj["uniforms"]);
201 return tv;
202 }
203 else throw "unknown constructor: " + tag;
204 std::shared_ptr<::PipelineSchema> o(new ::PipelineSchema());
205 o->tag = tagType;
206 return o;
207}
208
diff --git a/ddl/out/LambdaCube.PipelineSchema.hpp b/ddl/out/LambdaCube.PipelineSchema.hpp
new file mode 100644
index 0000000..86fef51
--- /dev/null
+++ b/ddl/out/LambdaCube.PipelineSchema.hpp
@@ -0,0 +1,67 @@
1// generated file, do not modify!
2// 2016-01-28T13:15:31.196716Z
3
4#ifndef HEADER_LambdaCube.PipelineSchema_H
5#define HEADER_LambdaCube.PipelineSchema_H
6
7#include "RT.hpp"
8
9#include "LambdaCube.IR.hpp"
10
11class StreamType {
12 public:
13 enum class tag {
14 Attribute_Word,
15 Attribute_V2U,
16 Attribute_V3U,
17 Attribute_V4U,
18 Attribute_Int,
19 Attribute_V2I,
20 Attribute_V3I,
21 Attribute_V4I,
22 Attribute_Float,
23 Attribute_V2F,
24 Attribute_V3F,
25 Attribute_V4F,
26 Attribute_M22F,
27 Attribute_M23F,
28 Attribute_M24F,
29 Attribute_M32F,
30 Attribute_M33F,
31 Attribute_M34F,
32 Attribute_M42F,
33 Attribute_M43F,
34 Attribute_M44F
35 } tag;
36};
37namespace data {
38}
39class ObjectArraySchema {
40 public:
41 enum class tag {
42 ObjectArraySchema
43 } tag;
44};
45namespace data {
46 class ObjectArraySchema : public ::ObjectArraySchema {
47 public:
48 std::shared_ptr<::FetchPrimitive> primitive;
49 std::map<String, std::shared_ptr<::StreamType>> attributes;
50 ObjectArraySchema() { tag = tag::ObjectArraySchema; }
51 };
52}
53class PipelineSchema {
54 public:
55 enum class tag {
56 PipelineSchema
57 } tag;
58};
59namespace data {
60 class PipelineSchema : public ::PipelineSchema {
61 public:
62 std::map<String, std::shared_ptr<::ObjectArraySchema>> objectArrays;
63 std::map<String, std::shared_ptr<::InputType>> uniforms;
64 PipelineSchema() { tag = tag::PipelineSchema; }
65 };
66}
67#endif
diff --git a/ddl/out/LambdaCube.PipelineSchema.hs b/ddl/out/LambdaCube.PipelineSchema.hs
new file mode 100644
index 0000000..c319967
--- /dev/null
+++ b/ddl/out/LambdaCube.PipelineSchema.hs
@@ -0,0 +1,153 @@
1-- generated file, do not modify!
2-- 2016-01-28T13:15:31.196716Z
3
4{-# LANGUAGE OverloadedStrings, RecordWildCards #-}
5module LambdaCube.PipelineSchema where
6
7import Data.Int
8import Data.Word
9import Data.Map
10import Data.Vector (Vector(..))
11import LambdaCube.Linear
12
13import Data.Text
14import Data.Aeson hiding (Value,Bool)
15import Data.Aeson.Types hiding (Value,Bool)
16import Control.Monad
17
18import LambdaCube.IR
19
20data StreamType
21 = Attribute_Word
22 | Attribute_V2U
23 | Attribute_V3U
24 | Attribute_V4U
25 | Attribute_Int
26 | Attribute_V2I
27 | Attribute_V3I
28 | Attribute_V4I
29 | Attribute_Float
30 | Attribute_V2F
31 | Attribute_V3F
32 | Attribute_V4F
33 | Attribute_M22F
34 | Attribute_M23F
35 | Attribute_M24F
36 | Attribute_M32F
37 | Attribute_M33F
38 | Attribute_M34F
39 | Attribute_M42F
40 | Attribute_M43F
41 | Attribute_M44F
42 deriving (Show, Eq, Ord)
43
44data ObjectArraySchema
45 = ObjectArraySchema
46 { primitive :: FetchPrimitive
47 , attributes :: Map String StreamType
48 }
49
50 deriving (Show, Eq, Ord)
51
52data PipelineSchema
53 = PipelineSchema
54 { objectArrays :: Map String ObjectArraySchema
55 , uniforms :: Map String InputType
56 }
57
58 deriving (Show, Eq, Ord)
59
60
61instance ToJSON StreamType where
62 toJSON v = case v of
63 Attribute_Word -> object [ "tag" .= ("Attribute_Word" :: Text)]
64 Attribute_V2U -> object [ "tag" .= ("Attribute_V2U" :: Text)]
65 Attribute_V3U -> object [ "tag" .= ("Attribute_V3U" :: Text)]
66 Attribute_V4U -> object [ "tag" .= ("Attribute_V4U" :: Text)]
67 Attribute_Int -> object [ "tag" .= ("Attribute_Int" :: Text)]
68 Attribute_V2I -> object [ "tag" .= ("Attribute_V2I" :: Text)]
69 Attribute_V3I -> object [ "tag" .= ("Attribute_V3I" :: Text)]
70 Attribute_V4I -> object [ "tag" .= ("Attribute_V4I" :: Text)]
71 Attribute_Float -> object [ "tag" .= ("Attribute_Float" :: Text)]
72 Attribute_V2F -> object [ "tag" .= ("Attribute_V2F" :: Text)]
73 Attribute_V3F -> object [ "tag" .= ("Attribute_V3F" :: Text)]
74 Attribute_V4F -> object [ "tag" .= ("Attribute_V4F" :: Text)]
75 Attribute_M22F -> object [ "tag" .= ("Attribute_M22F" :: Text)]
76 Attribute_M23F -> object [ "tag" .= ("Attribute_M23F" :: Text)]
77 Attribute_M24F -> object [ "tag" .= ("Attribute_M24F" :: Text)]
78 Attribute_M32F -> object [ "tag" .= ("Attribute_M32F" :: Text)]
79 Attribute_M33F -> object [ "tag" .= ("Attribute_M33F" :: Text)]
80 Attribute_M34F -> object [ "tag" .= ("Attribute_M34F" :: Text)]
81 Attribute_M42F -> object [ "tag" .= ("Attribute_M42F" :: Text)]
82 Attribute_M43F -> object [ "tag" .= ("Attribute_M43F" :: Text)]
83 Attribute_M44F -> object [ "tag" .= ("Attribute_M44F" :: Text)]
84
85instance FromJSON StreamType where
86 parseJSON (Object obj) = do
87 tag <- obj .: "tag"
88 case tag :: Text of
89 "Attribute_Word" -> pure Attribute_Word
90 "Attribute_V2U" -> pure Attribute_V2U
91 "Attribute_V3U" -> pure Attribute_V3U
92 "Attribute_V4U" -> pure Attribute_V4U
93 "Attribute_Int" -> pure Attribute_Int
94 "Attribute_V2I" -> pure Attribute_V2I
95 "Attribute_V3I" -> pure Attribute_V3I
96 "Attribute_V4I" -> pure Attribute_V4I
97 "Attribute_Float" -> pure Attribute_Float
98 "Attribute_V2F" -> pure Attribute_V2F
99 "Attribute_V3F" -> pure Attribute_V3F
100 "Attribute_V4F" -> pure Attribute_V4F
101 "Attribute_M22F" -> pure Attribute_M22F
102 "Attribute_M23F" -> pure Attribute_M23F
103 "Attribute_M24F" -> pure Attribute_M24F
104 "Attribute_M32F" -> pure Attribute_M32F
105 "Attribute_M33F" -> pure Attribute_M33F
106 "Attribute_M34F" -> pure Attribute_M34F
107 "Attribute_M42F" -> pure Attribute_M42F
108 "Attribute_M43F" -> pure Attribute_M43F
109 "Attribute_M44F" -> pure Attribute_M44F
110 parseJSON _ = mzero
111
112instance ToJSON ObjectArraySchema where
113 toJSON v = case v of
114 ObjectArraySchema{..} -> object
115 [ "tag" .= ("ObjectArraySchema" :: Text)
116 , "primitive" .= primitive
117 , "attributes" .= attributes
118 ]
119
120instance FromJSON ObjectArraySchema where
121 parseJSON (Object obj) = do
122 tag <- obj .: "tag"
123 case tag :: Text of
124 "ObjectArraySchema" -> do
125 primitive <- obj .: "primitive"
126 attributes <- obj .: "attributes"
127 pure $ ObjectArraySchema
128 { primitive = primitive
129 , attributes = attributes
130 }
131 parseJSON _ = mzero
132
133instance ToJSON PipelineSchema where
134 toJSON v = case v of
135 PipelineSchema{..} -> object
136 [ "tag" .= ("PipelineSchema" :: Text)
137 , "objectArrays" .= objectArrays
138 , "uniforms" .= uniforms
139 ]
140
141instance FromJSON PipelineSchema where
142 parseJSON (Object obj) = do
143 tag <- obj .: "tag"
144 case tag :: Text of
145 "PipelineSchema" -> do
146 objectArrays <- obj .: "objectArrays"
147 uniforms <- obj .: "uniforms"
148 pure $ PipelineSchema
149 { objectArrays = objectArrays
150 , uniforms = uniforms
151 }
152 parseJSON _ = mzero
153
diff --git a/ddl/out/LambdaCube.PipelineSchema.purs b/ddl/out/LambdaCube.PipelineSchema.purs
new file mode 100644
index 0000000..077d1e9
--- /dev/null
+++ b/ddl/out/LambdaCube.PipelineSchema.purs
@@ -0,0 +1,152 @@
1-- generated file, do not modify!
2-- 2016-01-28T13:15:31.196716Z
3
4module LambdaCube.PipelineSchema where
5import Prelude
6import Data.Generic
7import Data.Maybe (Maybe(..))
8import Data.StrMap (StrMap(..))
9import Data.Map (Map(..))
10import Data.List (List(..))
11import Linear
12
13import Data.Argonaut.Combinators ((~>), (:=), (.?))
14import Data.Argonaut.Core (jsonEmptyObject)
15import Data.Argonaut.Printer (printJson)
16import Data.Argonaut.Encode (EncodeJson, encodeJson)
17import Data.Argonaut.Decode (DecodeJson, decodeJson)
18
19import LambdaCube.IR
20
21data StreamType
22 = Attribute_Word
23 | Attribute_V2U
24 | Attribute_V3U
25 | Attribute_V4U
26 | Attribute_Int
27 | Attribute_V2I
28 | Attribute_V3I
29 | Attribute_V4I
30 | Attribute_Float
31 | Attribute_V2F
32 | Attribute_V3F
33 | Attribute_V4F
34 | Attribute_M22F
35 | Attribute_M23F
36 | Attribute_M24F
37 | Attribute_M32F
38 | Attribute_M33F
39 | Attribute_M34F
40 | Attribute_M42F
41 | Attribute_M43F
42 | Attribute_M44F
43
44data ObjectArraySchema
45 = ObjectArraySchema
46 { primitive :: FetchPrimitive
47 , attributes :: StrMap StreamType
48 }
49
50
51data PipelineSchema
52 = PipelineSchema
53 { objectArrays :: StrMap ObjectArraySchema
54 , uniforms :: StrMap InputType
55 }
56
57
58
59
60instance encodeJsonStreamType :: EncodeJson StreamType where
61 encodeJson v = case v of
62 Attribute_Word -> "tag" := "Attribute_Word" ~> jsonEmptyObject
63 Attribute_V2U -> "tag" := "Attribute_V2U" ~> jsonEmptyObject
64 Attribute_V3U -> "tag" := "Attribute_V3U" ~> jsonEmptyObject
65 Attribute_V4U -> "tag" := "Attribute_V4U" ~> jsonEmptyObject
66 Attribute_Int -> "tag" := "Attribute_Int" ~> jsonEmptyObject
67 Attribute_V2I -> "tag" := "Attribute_V2I" ~> jsonEmptyObject
68 Attribute_V3I -> "tag" := "Attribute_V3I" ~> jsonEmptyObject
69 Attribute_V4I -> "tag" := "Attribute_V4I" ~> jsonEmptyObject
70 Attribute_Float -> "tag" := "Attribute_Float" ~> jsonEmptyObject
71 Attribute_V2F -> "tag" := "Attribute_V2F" ~> jsonEmptyObject
72 Attribute_V3F -> "tag" := "Attribute_V3F" ~> jsonEmptyObject
73 Attribute_V4F -> "tag" := "Attribute_V4F" ~> jsonEmptyObject
74 Attribute_M22F -> "tag" := "Attribute_M22F" ~> jsonEmptyObject
75 Attribute_M23F -> "tag" := "Attribute_M23F" ~> jsonEmptyObject
76 Attribute_M24F -> "tag" := "Attribute_M24F" ~> jsonEmptyObject
77 Attribute_M32F -> "tag" := "Attribute_M32F" ~> jsonEmptyObject
78 Attribute_M33F -> "tag" := "Attribute_M33F" ~> jsonEmptyObject
79 Attribute_M34F -> "tag" := "Attribute_M34F" ~> jsonEmptyObject
80 Attribute_M42F -> "tag" := "Attribute_M42F" ~> jsonEmptyObject
81 Attribute_M43F -> "tag" := "Attribute_M43F" ~> jsonEmptyObject
82 Attribute_M44F -> "tag" := "Attribute_M44F" ~> jsonEmptyObject
83
84instance decodeJsonStreamType :: DecodeJson StreamType where
85 decodeJson json = do
86 obj <- decodeJson json
87 tag <- obj .? "tag"
88 case tag of
89 "Attribute_Word" -> pure Attribute_Word
90 "Attribute_V2U" -> pure Attribute_V2U
91 "Attribute_V3U" -> pure Attribute_V3U
92 "Attribute_V4U" -> pure Attribute_V4U
93 "Attribute_Int" -> pure Attribute_Int
94 "Attribute_V2I" -> pure Attribute_V2I
95 "Attribute_V3I" -> pure Attribute_V3I
96 "Attribute_V4I" -> pure Attribute_V4I
97 "Attribute_Float" -> pure Attribute_Float
98 "Attribute_V2F" -> pure Attribute_V2F
99 "Attribute_V3F" -> pure Attribute_V3F
100 "Attribute_V4F" -> pure Attribute_V4F
101 "Attribute_M22F" -> pure Attribute_M22F
102 "Attribute_M23F" -> pure Attribute_M23F
103 "Attribute_M24F" -> pure Attribute_M24F
104 "Attribute_M32F" -> pure Attribute_M32F
105 "Attribute_M33F" -> pure Attribute_M33F
106 "Attribute_M34F" -> pure Attribute_M34F
107 "Attribute_M42F" -> pure Attribute_M42F
108 "Attribute_M43F" -> pure Attribute_M43F
109 "Attribute_M44F" -> pure Attribute_M44F
110
111instance encodeJsonObjectArraySchema :: EncodeJson ObjectArraySchema where
112 encodeJson v = case v of
113 ObjectArraySchema r ->
114 "tag" := "ObjectArraySchema" ~>
115 "primitive" := r.primitive ~>
116 "attributes" := r.attributes ~>
117 jsonEmptyObject
118
119instance decodeJsonObjectArraySchema :: DecodeJson ObjectArraySchema where
120 decodeJson json = do
121 obj <- decodeJson json
122 tag <- obj .? "tag"
123 case tag of
124 "ObjectArraySchema" -> do
125 primitive <- obj .? "primitive"
126 attributes <- obj .? "attributes"
127 pure $ ObjectArraySchema
128 { primitive:primitive
129 , attributes:attributes
130 }
131
132instance encodeJsonPipelineSchema :: EncodeJson PipelineSchema where
133 encodeJson v = case v of
134 PipelineSchema r ->
135 "tag" := "PipelineSchema" ~>
136 "objectArrays" := r.objectArrays ~>
137 "uniforms" := r.uniforms ~>
138 jsonEmptyObject
139
140instance decodeJsonPipelineSchema :: DecodeJson PipelineSchema where
141 decodeJson json = do
142 obj <- decodeJson json
143 tag <- obj .? "tag"
144 case tag of
145 "PipelineSchema" -> do
146 objectArrays <- obj .? "objectArrays"
147 uniforms <- obj .? "uniforms"
148 pure $ PipelineSchema
149 { objectArrays:objectArrays
150 , uniforms:uniforms
151 }
152
diff --git a/ddl/out/LambdaCube.PipelineSchema.swift b/ddl/out/LambdaCube.PipelineSchema.swift
new file mode 100644
index 0000000..8afc9fc
--- /dev/null
+++ b/ddl/out/LambdaCube.PipelineSchema.swift
@@ -0,0 +1,205 @@
1// generated file, do not modify!
2// 2016-01-28T13:15:31.196716Z
3
4enum StreamType {
5 case Attribute_Word
6 case Attribute_V2U
7 case Attribute_V3U
8 case Attribute_V4U
9 case Attribute_Int
10 case Attribute_V2I
11 case Attribute_V3I
12 case Attribute_V4I
13 case Attribute_Float
14 case Attribute_V2F
15 case Attribute_V3F
16 case Attribute_V4F
17 case Attribute_M22F
18 case Attribute_M23F
19 case Attribute_M24F
20 case Attribute_M32F
21 case Attribute_M33F
22 case Attribute_M34F
23 case Attribute_M42F
24 case Attribute_M43F
25 case Attribute_M44F
26}
27
28enum ObjectArraySchema {
29 case ObjectArraySchema(ObjectArraySchema_Data)
30 struct ObjectArraySchema_Data {
31 var primitive : FetchPrimitive
32 var attributes : Dictionary<String, StreamType>
33 }
34}
35
36enum PipelineSchema {
37 case PipelineSchema(PipelineSchema_Data)
38 struct PipelineSchema_Data {
39 var objectArrays : Dictionary<String, ObjectArraySchema>
40 var uniforms : Dictionary<String, InputType>
41 }
42}
43
44
45extension Int {
46 var toJSON : [String: AnyObject] {
47 return ["":""]
48 }
49}
50extension Int32 {
51 var toJSON : [String: AnyObject] {
52 return ["":""]
53 }
54}
55extension UInt {
56 var toJSON : [String: AnyObject] {
57 return ["":""]
58 }
59}
60extension UInt32 {
61 var toJSON : [String: AnyObject] {
62 return ["":""]
63 }
64}
65extension Float {
66 var toJSON : [String: AnyObject] {
67 return ["":""]
68 }
69}
70extension Bool {
71 var toJSON : [String: AnyObject] {
72 return ["":""]
73 }
74}
75extension String {
76 var toJSON : [String: AnyObject] {
77 return ["":""]
78 }
79}
80extension Array {
81 var toJSON : [String: AnyObject] {
82 return ["":""]
83 }
84}
85extension Dictionary {
86 var toJSON : [String: AnyObject] {
87 return ["":""]
88 }
89}
90extension Maybe {
91 var toJSON : [String: AnyObject] {
92 return ["":""]
93 }
94}
95
96
97
98extension StreamType {
99 var toJSON : [String: AnyObject] {
100 switch self {
101 case .Attribute_Word:
102 return [ "tag" : "Attribute_Word"]
103 case .Attribute_V2U:
104 return [ "tag" : "Attribute_V2U"]
105 case .Attribute_V3U:
106 return [ "tag" : "Attribute_V3U"]
107 case .Attribute_V4U:
108 return [ "tag" : "Attribute_V4U"]
109 case .Attribute_Int:
110 return [ "tag" : "Attribute_Int"]
111 case .Attribute_V2I:
112 return [ "tag" : "Attribute_V2I"]
113 case .Attribute_V3I:
114 return [ "tag" : "Attribute_V3I"]
115 case .Attribute_V4I:
116 return [ "tag" : "Attribute_V4I"]
117 case .Attribute_Float:
118 return [ "tag" : "Attribute_Float"]
119 case .Attribute_V2F:
120 return [ "tag" : "Attribute_V2F"]
121 case .Attribute_V3F:
122 return [ "tag" : "Attribute_V3F"]
123 case .Attribute_V4F:
124 return [ "tag" : "Attribute_V4F"]
125 case .Attribute_M22F:
126 return [ "tag" : "Attribute_M22F"]
127 case .Attribute_M23F:
128 return [ "tag" : "Attribute_M23F"]
129 case .Attribute_M24F:
130 return [ "tag" : "Attribute_M24F"]
131 case .Attribute_M32F:
132 return [ "tag" : "Attribute_M32F"]
133 case .Attribute_M33F:
134 return [ "tag" : "Attribute_M33F"]
135 case .Attribute_M34F:
136 return [ "tag" : "Attribute_M34F"]
137 case .Attribute_M42F:
138 return [ "tag" : "Attribute_M42F"]
139 case .Attribute_M43F:
140 return [ "tag" : "Attribute_M43F"]
141 case .Attribute_M44F:
142 return [ "tag" : "Attribute_M44F"]
143 }
144 }
145}
146extension ObjectArraySchema {
147 var toJSON : [String: AnyObject] {
148 switch self {
149 case .ObjectArraySchema(let v):
150 return [ "tag" : "ObjectArraySchema"
151 , "primitive" : v.primitive.toJSON
152 , "attributes" : v.attributes.toJSON
153 ]
154 }
155 }
156}
157extension PipelineSchema {
158 var toJSON : [String: AnyObject] {
159 switch self {
160 case .PipelineSchema(let v):
161 return [ "tag" : "PipelineSchema"
162 , "objectArrays" : v.objectArrays.toJSON
163 , "uniforms" : v.uniforms.toJSON
164 ]
165 }
166 }
167}
168
169enum Maybe<T> {
170 case Nothing
171 case Just(T)
172}
173
174enum Type {
175 case Int
176 case Int32
177 case Word
178 case Word32
179 case Float
180 case Bool
181 case String
182 case Array(Type)
183 case List(Type)
184 case Maybe(Type)
185 case Map(Type,Type)
186 case StreamType
187 case ObjectArraySchema
188 case PipelineSchema
189}
190
191func fromJSON(type: Type, personName: String) -> Any {
192 switch type {
193 case .Int: return 0
194 case .Int32: return 0
195 case .Word: return 0
196 case .Word32: return 0
197 case .Float: return 0.0
198 case .Bool: return false
199 case .String: return ""
200 case .Array(let a): return fromJSON(a,personName)
201 case .List(let a): return fromJSON(a,personName)
202 case .Maybe(let a): return fromJSON(a,personName)
203 }
204 return 0;
205} \ No newline at end of file
diff --git a/ddl/out/LambdaCube.PipelineSchema2.hpp b/ddl/out/LambdaCube.PipelineSchema2.hpp
new file mode 100644
index 0000000..2812b18
--- /dev/null
+++ b/ddl/out/LambdaCube.PipelineSchema2.hpp
@@ -0,0 +1,67 @@
1// generated file, do not modify!
2// 2016-01-28T13:15:31.196716Z
3
4#ifndef HEADER_LambdaCube.PipelineSchema_H
5#define HEADER_LambdaCube.PipelineSchema_H
6
7#include "RT.hpp"
8
9#include "LambdaCube.IR.hpp"
10
11namespace data {
12}
13class StreamType {
14public:
15 enum class tag {
16 Attribute_Word,
17 Attribute_V2U,
18 Attribute_V3U,
19 Attribute_V4U,
20 Attribute_Int,
21 Attribute_V2I,
22 Attribute_V3I,
23 Attribute_V4I,
24 Attribute_Float,
25 Attribute_V2F,
26 Attribute_V3F,
27 Attribute_V4F,
28 Attribute_M22F,
29 Attribute_M23F,
30 Attribute_M24F,
31 Attribute_M32F,
32 Attribute_M33F,
33 Attribute_M34F,
34 Attribute_M42F,
35 Attribute_M43F,
36 Attribute_M44F
37 } tag;
38};
39namespace data {
40 class ObjectArraySchema {
41 public:
42 std::shared_ptr<::FetchPrimitive> primitive;
43 std::map<String, std::shared_ptr<::StreamType>> attributes;
44 };
45}
46class ObjectArraySchema {
47public:
48 enum class tag {
49 ObjectArraySchema
50 } tag;
51 std::shared_ptr<data::ObjectArraySchema> ObjectArraySchema;
52};
53namespace data {
54 class PipelineSchema {
55 public:
56 std::map<String, std::shared_ptr<::ObjectArraySchema>> objectArrays;
57 std::map<String, std::shared_ptr<::InputType>> uniforms;
58 };
59}
60class PipelineSchema {
61public:
62 enum class tag {
63 PipelineSchema
64 } tag;
65 std::shared_ptr<data::PipelineSchema> PipelineSchema;
66};
67#endif
diff --git a/ddl/out/TypeInfo.cpp b/ddl/out/LambdaCube.TypeInfo.cpp
index 6834bcc..7ad7fea 100644
--- a/ddl/out/TypeInfo.cpp
+++ b/ddl/out/LambdaCube.TypeInfo.cpp
@@ -1,7 +1,7 @@
1// generated file, do not modify! 1// generated file, do not modify!
2// 2016-01-18T14:30:08.262123Z 2// 2016-01-28T13:15:31.255126Z
3 3
4#include "TypeInfo.hpp" 4#include "LambdaCube.TypeInfo.hpp"
5template<> json toJSON<std::shared_ptr<TypeInfo>>(std::shared_ptr<TypeInfo> &v) { 5template<> json toJSON<std::shared_ptr<TypeInfo>>(std::shared_ptr<TypeInfo> &v) {
6 json obj({}); 6 json obj({});
7 switch (v->tag) { 7 switch (v->tag) {
diff --git a/ddl/out/TypeInfo.hpp b/ddl/out/LambdaCube.TypeInfo.hpp
index fdad33d..d2f239b 100644
--- a/ddl/out/TypeInfo.hpp
+++ b/ddl/out/LambdaCube.TypeInfo.hpp
@@ -1,12 +1,12 @@
1// generated file, do not modify! 1// generated file, do not modify!
2// 2016-01-18T14:30:08.262123Z 2// 2016-01-28T13:15:31.255126Z
3 3
4#ifndef HEADER_TypeInfo_H 4#ifndef HEADER_LambdaCube.TypeInfo_H
5#define HEADER_TypeInfo_H 5#define HEADER_LambdaCube.TypeInfo_H
6 6
7#include "RT.hpp" 7#include "RT.hpp"
8 8
9#include "IR.hpp" 9#include "LambdaCube.IR.hpp"
10 10
11class TypeInfo { 11class TypeInfo {
12 public: 12 public:
diff --git a/ddl/out/TypeInfo.hs b/ddl/out/LambdaCube.TypeInfo.hs
index 6891924..453057d 100644
--- a/ddl/out/TypeInfo.hs
+++ b/ddl/out/LambdaCube.TypeInfo.hs
@@ -1,21 +1,21 @@
1-- generated file, do not modify! 1-- generated file, do not modify!
2-- 2016-01-18T14:30:08.262123Z 2-- 2016-01-28T13:15:31.255126Z
3 3
4{-# LANGUAGE OverloadedStrings, RecordWildCards #-} 4{-# LANGUAGE OverloadedStrings, RecordWildCards #-}
5module TypeInfo where 5module LambdaCube.TypeInfo where
6 6
7import Data.Int 7import Data.Int
8import Data.Word 8import Data.Word
9import Data.Map 9import Data.Map
10import Data.Vector (Vector(..)) 10import Data.Vector (Vector(..))
11import Linear 11import LambdaCube.Linear
12 12
13import Data.Text 13import Data.Text
14import Data.Aeson hiding (Value,Bool) 14import Data.Aeson hiding (Value,Bool)
15import Data.Aeson.Types hiding (Value,Bool) 15import Data.Aeson.Types hiding (Value,Bool)
16import Control.Monad 16import Control.Monad
17 17
18import IR 18import LambdaCube.IR
19 19
20data TypeInfo 20data TypeInfo
21 = TypeInfo 21 = TypeInfo
diff --git a/ddl/out/TypeInfo.purs b/ddl/out/LambdaCube.TypeInfo.purs
index 667de39..3daca2f 100644
--- a/ddl/out/TypeInfo.purs
+++ b/ddl/out/LambdaCube.TypeInfo.purs
@@ -1,7 +1,7 @@
1-- generated file, do not modify! 1-- generated file, do not modify!
2-- 2016-01-18T14:30:08.262123Z 2-- 2016-01-28T13:15:31.255126Z
3 3
4module TypeInfo where 4module LambdaCube.TypeInfo where
5import Prelude 5import Prelude
6import Data.Generic 6import Data.Generic
7import Data.Maybe (Maybe(..)) 7import Data.Maybe (Maybe(..))
@@ -16,7 +16,7 @@ import Data.Argonaut.Printer (printJson)
16import Data.Argonaut.Encode (EncodeJson, encodeJson) 16import Data.Argonaut.Encode (EncodeJson, encodeJson)
17import Data.Argonaut.Decode (DecodeJson, decodeJson) 17import Data.Argonaut.Decode (DecodeJson, decodeJson)
18 18
19import IR 19import LambdaCube.IR
20 20
21data TypeInfo 21data TypeInfo
22 = TypeInfo 22 = TypeInfo
diff --git a/ddl/out/TypeInfo.swift b/ddl/out/LambdaCube.TypeInfo.swift
index c0c3a29..6b46124 100644
--- a/ddl/out/TypeInfo.swift
+++ b/ddl/out/LambdaCube.TypeInfo.swift
@@ -1,5 +1,5 @@
1// generated file, do not modify! 1// generated file, do not modify!
2// 2016-01-18T14:30:08.262123Z 2// 2016-01-28T13:15:31.255126Z
3 3
4enum TypeInfo { 4enum TypeInfo {
5 case TypeInfo(TypeInfo_Data) 5 case TypeInfo(TypeInfo_Data)
diff --git a/ddl/out/TypeInfo2.hpp b/ddl/out/LambdaCube.TypeInfo2.hpp
index 9ac29c9..b309a2b 100644
--- a/ddl/out/TypeInfo2.hpp
+++ b/ddl/out/LambdaCube.TypeInfo2.hpp
@@ -1,12 +1,12 @@
1// generated file, do not modify! 1// generated file, do not modify!
2// 2016-01-18T14:30:08.262123Z 2// 2016-01-28T13:15:31.255126Z
3 3
4#ifndef HEADER_TypeInfo_H 4#ifndef HEADER_LambdaCube.TypeInfo_H
5#define HEADER_TypeInfo_H 5#define HEADER_LambdaCube.TypeInfo_H
6 6
7#include "RT.hpp" 7#include "RT.hpp"
8 8
9#include "IR.hpp" 9#include "LambdaCube.IR.hpp"
10 10
11namespace data { 11namespace data {
12 class TypeInfo { 12 class TypeInfo {
diff --git a/ddl/out/TestData.cpp b/ddl/out/TestData.cpp
new file mode 100644
index 0000000..a2ff86c
--- /dev/null
+++ b/ddl/out/TestData.cpp
@@ -0,0 +1,215 @@
1// generated file, do not modify!
2// 2016-01-28T13:15:31.27456Z
3
4#include "TestData.hpp"
5template<> json toJSON<std::shared_ptr<ClientInfo>>(std::shared_ptr<ClientInfo> &v) {
6 json obj({});
7 switch (v->tag) {
8 case ::ClientInfo::tag::ClientInfo:
9 obj["tag"] = "ClientInfo";
10 {
11 std::shared_ptr<data::ClientInfo> tv = std::static_pointer_cast<data::ClientInfo>(v);
12 obj["clientName"] = toJSON(tv->clientName);
13 obj["clientBackend"] = toJSON(tv->clientBackend);
14 }
15 break;
16 }
17 return obj;
18}
19
20template<> std::shared_ptr<ClientInfo> fromJSON<std::shared_ptr<ClientInfo>>(W<std::shared_ptr<ClientInfo>> v, json &obj) {
21 enum ::ClientInfo::tag tagType;
22 std::string tag = obj["tag"];
23 if (tag == "ClientInfo") {
24 tagType = ::ClientInfo::tag::ClientInfo;
25 std::shared_ptr<data::ClientInfo> tv(new data::ClientInfo());
26 tv->clientName = fromJSON(W<String>(), obj["clientName"]);
27 tv->clientBackend = fromJSON(W<std::shared_ptr<::Backend>>(), obj["clientBackend"]);
28 return tv;
29 }
30 else throw "unknown constructor: " + tag;
31 std::shared_ptr<::ClientInfo> o(new ::ClientInfo());
32 o->tag = tagType;
33 return o;
34}
35
36template<> json toJSON<std::shared_ptr<Frame>>(std::shared_ptr<Frame> &v) {
37 json obj({});
38 switch (v->tag) {
39 case ::Frame::tag::Frame:
40 obj["tag"] = "Frame";
41 {
42 std::shared_ptr<data::Frame> tv = std::static_pointer_cast<data::Frame>(v);
43 obj["renderCount"] = toJSON(tv->renderCount);
44 obj["frameUniforms"] = toJSON(tv->frameUniforms);
45 obj["frameTextures"] = toJSON(tv->frameTextures);
46 }
47 break;
48 }
49 return obj;
50}
51
52template<> std::shared_ptr<Frame> fromJSON<std::shared_ptr<Frame>>(W<std::shared_ptr<Frame>> v, json &obj) {
53 enum ::Frame::tag tagType;
54 std::string tag = obj["tag"];
55 if (tag == "Frame") {
56 tagType = ::Frame::tag::Frame;
57 std::shared_ptr<data::Frame> tv(new data::Frame());
58 tv->renderCount = fromJSON(W<Int>(), obj["renderCount"]);
59 tv->frameUniforms = fromJSON(W<std::map<String, std::shared_ptr<::Value>>>(), obj["frameUniforms"]);
60 tv->frameTextures = fromJSON(W<std::map<String, Int>>(), obj["frameTextures"]);
61 return tv;
62 }
63 else throw "unknown constructor: " + tag;
64 std::shared_ptr<::Frame> o(new ::Frame());
65 o->tag = tagType;
66 return o;
67}
68
69template<> json toJSON<std::shared_ptr<Scene>>(std::shared_ptr<Scene> &v) {
70 json obj({});
71 switch (v->tag) {
72 case ::Scene::tag::Scene:
73 obj["tag"] = "Scene";
74 {
75 std::shared_ptr<data::Scene> tv = std::static_pointer_cast<data::Scene>(v);
76 obj["objectArrays"] = toJSON(tv->objectArrays);
77 obj["renderTargetWidth"] = toJSON(tv->renderTargetWidth);
78 obj["renderTargetHeight"] = toJSON(tv->renderTargetHeight);
79 obj["frames"] = toJSON(tv->frames);
80 }
81 break;
82 }
83 return obj;
84}
85
86template<> std::shared_ptr<Scene> fromJSON<std::shared_ptr<Scene>>(W<std::shared_ptr<Scene>> v, json &obj) {
87 enum ::Scene::tag tagType;
88 std::string tag = obj["tag"];
89 if (tag == "Scene") {
90 tagType = ::Scene::tag::Scene;
91 std::shared_ptr<data::Scene> tv(new data::Scene());
92 tv->objectArrays = fromJSON(W<std::map<String, std::vector<Int>>>(), obj["objectArrays"]);
93 tv->renderTargetWidth = fromJSON(W<Int>(), obj["renderTargetWidth"]);
94 tv->renderTargetHeight = fromJSON(W<Int>(), obj["renderTargetHeight"]);
95 tv->frames = fromJSON(W<std::vector<std::shared_ptr<::Frame>>>(), obj["frames"]);
96 return tv;
97 }
98 else throw "unknown constructor: " + tag;
99 std::shared_ptr<::Scene> o(new ::Scene());
100 o->tag = tagType;
101 return o;
102}
103
104template<> json toJSON<std::shared_ptr<RenderJob>>(std::shared_ptr<RenderJob> &v) {
105 json obj({});
106 switch (v->tag) {
107 case ::RenderJob::tag::RenderJob:
108 obj["tag"] = "RenderJob";
109 {
110 std::shared_ptr<data::RenderJob> tv = std::static_pointer_cast<data::RenderJob>(v);
111 obj["meshes"] = toJSON(tv->meshes);
112 obj["textures"] = toJSON(tv->textures);
113 obj["schema"] = toJSON(tv->schema);
114 obj["scenes"] = toJSON(tv->scenes);
115 obj["pipelines"] = toJSON(tv->pipelines);
116 }
117 break;
118 }
119 return obj;
120}
121
122template<> std::shared_ptr<RenderJob> fromJSON<std::shared_ptr<RenderJob>>(W<std::shared_ptr<RenderJob>> v, json &obj) {
123 enum ::RenderJob::tag tagType;
124 std::string tag = obj["tag"];
125 if (tag == "RenderJob") {
126 tagType = ::RenderJob::tag::RenderJob;
127 std::shared_ptr<data::RenderJob> tv(new data::RenderJob());
128 tv->meshes = fromJSON(W<std::vector<std::shared_ptr<::Mesh>>>(), obj["meshes"]);
129 tv->textures = fromJSON(W<std::vector<String>>(), obj["textures"]);
130 tv->schema = fromJSON(W<std::shared_ptr<::PipelineSchema>>(), obj["schema"]);
131 tv->scenes = fromJSON(W<std::vector<std::shared_ptr<::Scene>>>(), obj["scenes"]);
132 tv->pipelines = fromJSON(W<std::vector<std::shared_ptr<::Pipeline>>>(), obj["pipelines"]);
133 return tv;
134 }
135 else throw "unknown constructor: " + tag;
136 std::shared_ptr<::RenderJob> o(new ::RenderJob());
137 o->tag = tagType;
138 return o;
139}
140
141template<> json toJSON<std::shared_ptr<FrameResult>>(std::shared_ptr<FrameResult> &v) {
142 json obj({});
143 switch (v->tag) {
144 case ::FrameResult::tag::FrameResult:
145 obj["tag"] = "FrameResult";
146 {
147 std::shared_ptr<data::FrameResult> tv = std::static_pointer_cast<data::FrameResult>(v);
148 obj["frRenderTimes"] = toJSON(tv->frRenderTimes);
149 obj["frImageWidth"] = toJSON(tv->frImageWidth);
150 obj["frImageHeight"] = toJSON(tv->frImageHeight);
151 }
152 break;
153 }
154 return obj;
155}
156
157template<> std::shared_ptr<FrameResult> fromJSON<std::shared_ptr<FrameResult>>(W<std::shared_ptr<FrameResult>> v, json &obj) {
158 enum ::FrameResult::tag tagType;
159 std::string tag = obj["tag"];
160 if (tag == "FrameResult") {
161 tagType = ::FrameResult::tag::FrameResult;
162 std::shared_ptr<data::FrameResult> tv(new data::FrameResult());
163 tv->frRenderTimes = fromJSON(W<std::vector<Float>>(), obj["frRenderTimes"]);
164 tv->frImageWidth = fromJSON(W<Int>(), obj["frImageWidth"]);
165 tv->frImageHeight = fromJSON(W<Int>(), obj["frImageHeight"]);
166 return tv;
167 }
168 else throw "unknown constructor: " + tag;
169 std::shared_ptr<::FrameResult> o(new ::FrameResult());
170 o->tag = tagType;
171 return o;
172}
173
174template<> json toJSON<std::shared_ptr<RenderJobResult>>(std::shared_ptr<RenderJobResult> &v) {
175 json obj({});
176 switch (v->tag) {
177 case ::RenderJobResult::tag::RenderJobResult:
178 obj["tag"] = "RenderJobResult";
179 {
180 std::shared_ptr<data::RenderJobResult> tv = std::static_pointer_cast<data::RenderJobResult>(v);
181 obj["arg0"] = toJSON(tv->_0);
182 }
183 break;
184 case ::RenderJobResult::tag::RenderJobError:
185 obj["tag"] = "RenderJobError";
186 {
187 std::shared_ptr<data::RenderJobError> tv = std::static_pointer_cast<data::RenderJobError>(v);
188 obj["arg0"] = toJSON(tv->_0);
189 }
190 break;
191 }
192 return obj;
193}
194
195template<> std::shared_ptr<RenderJobResult> fromJSON<std::shared_ptr<RenderJobResult>>(W<std::shared_ptr<RenderJobResult>> v, json &obj) {
196 enum ::RenderJobResult::tag tagType;
197 std::string tag = obj["tag"];
198 if (tag == "RenderJobResult") {
199 tagType = ::RenderJobResult::tag::RenderJobResult;
200 std::shared_ptr<data::RenderJobResult> tv(new data::RenderJobResult());
201 tv->_0 = fromJSON(W<std::shared_ptr<::FrameResult>>(), obj["arg0"]);
202 return tv;
203 }
204 else if (tag == "RenderJobError") {
205 tagType = ::RenderJobResult::tag::RenderJobError;
206 std::shared_ptr<data::RenderJobError> tv(new data::RenderJobError());
207 tv->_0 = fromJSON(W<String>(), obj["arg0"]);
208 return tv;
209 }
210 else throw "unknown constructor: " + tag;
211 std::shared_ptr<::RenderJobResult> o(new ::RenderJobResult());
212 o->tag = tagType;
213 return o;
214}
215
diff --git a/ddl/out/TestData.hpp b/ddl/out/TestData.hpp
new file mode 100644
index 0000000..95f4436
--- /dev/null
+++ b/ddl/out/TestData.hpp
@@ -0,0 +1,109 @@
1// generated file, do not modify!
2// 2016-01-28T13:15:31.27456Z
3
4#ifndef HEADER_TestData_H
5#define HEADER_TestData_H
6
7#include "RT.hpp"
8
9#include "LambdaCube.IR.hpp"
10#include "LambdaCube.Mesh.hpp"
11#include "LambdaCube.PipelineSchema.hpp"
12
13class ClientInfo {
14 public:
15 enum class tag {
16 ClientInfo
17 } tag;
18};
19namespace data {
20 class ClientInfo : public ::ClientInfo {
21 public:
22 String clientName;
23 std::shared_ptr<::Backend> clientBackend;
24 ClientInfo() { tag = tag::ClientInfo; }
25 };
26}
27class Frame {
28 public:
29 enum class tag {
30 Frame
31 } tag;
32};
33namespace data {
34 class Frame : public ::Frame {
35 public:
36 Int renderCount;
37 std::map<String, std::shared_ptr<::Value>> frameUniforms;
38 std::map<String, Int> frameTextures;
39 Frame() { tag = tag::Frame; }
40 };
41}
42class Scene {
43 public:
44 enum class tag {
45 Scene
46 } tag;
47};
48namespace data {
49 class Scene : public ::Scene {
50 public:
51 std::map<String, std::vector<Int>> objectArrays;
52 Int renderTargetWidth;
53 Int renderTargetHeight;
54 std::vector<std::shared_ptr<::Frame>> frames;
55 Scene() { tag = tag::Scene; }
56 };
57}
58class RenderJob {
59 public:
60 enum class tag {
61 RenderJob
62 } tag;
63};
64namespace data {
65 class RenderJob : public ::RenderJob {
66 public:
67 std::vector<std::shared_ptr<::Mesh>> meshes;
68 std::vector<String> textures;
69 std::shared_ptr<::PipelineSchema> schema;
70 std::vector<std::shared_ptr<::Scene>> scenes;
71 std::vector<std::shared_ptr<::Pipeline>> pipelines;
72 RenderJob() { tag = tag::RenderJob; }
73 };
74}
75class FrameResult {
76 public:
77 enum class tag {
78 FrameResult
79 } tag;
80};
81namespace data {
82 class FrameResult : public ::FrameResult {
83 public:
84 std::vector<Float> frRenderTimes;
85 Int frImageWidth;
86 Int frImageHeight;
87 FrameResult() { tag = tag::FrameResult; }
88 };
89}
90class RenderJobResult {
91 public:
92 enum class tag {
93 RenderJobResult,
94 RenderJobError
95 } tag;
96};
97namespace data {
98 class RenderJobResult : public ::RenderJobResult {
99 public:
100 std::shared_ptr<::FrameResult> _0;
101 RenderJobResult() { tag = tag::RenderJobResult; }
102 };
103 class RenderJobError : public ::RenderJobResult {
104 public:
105 String _0;
106 RenderJobError() { tag = tag::RenderJobError; }
107 };
108}
109#endif
diff --git a/ddl/out/TestData.hs b/ddl/out/TestData.hs
new file mode 100644
index 0000000..a48dc42
--- /dev/null
+++ b/ddl/out/TestData.hs
@@ -0,0 +1,213 @@
1-- generated file, do not modify!
2-- 2016-01-28T13:15:31.27456Z
3
4{-# LANGUAGE OverloadedStrings, RecordWildCards #-}
5module TestData where
6
7import Data.Int
8import Data.Word
9import Data.Map
10import Data.Vector (Vector(..))
11import LambdaCube.Linear
12
13import Data.Text
14import Data.Aeson hiding (Value,Bool)
15import Data.Aeson.Types hiding (Value,Bool)
16import Control.Monad
17
18import LambdaCube.IR
19import LambdaCube.Mesh
20import LambdaCube.PipelineSchema
21
22data ClientInfo
23 = ClientInfo
24 { clientName :: String
25 , clientBackend :: Backend
26 }
27
28 deriving (Show, Eq, Ord)
29
30data Frame
31 = Frame
32 { renderCount :: Int
33 , frameUniforms :: Map String Value
34 , frameTextures :: Map String Int
35 }
36
37 deriving (Show, Eq, Ord)
38
39data Scene
40 = Scene
41 { objectArrays :: Map String (Vector Int)
42 , renderTargetWidth :: Int
43 , renderTargetHeight :: Int
44 , frames :: Vector Frame
45 }
46
47 deriving (Show, Eq, Ord)
48
49data RenderJob
50 = RenderJob
51 { meshes :: Vector Mesh
52 , textures :: Vector String
53 , schema :: PipelineSchema
54 , scenes :: Vector Scene
55 , pipelines :: Vector Pipeline
56 }
57
58 deriving (Show, Eq, Ord)
59
60data FrameResult
61 = FrameResult
62 { frRenderTimes :: Vector Float
63 , frImageWidth :: Int
64 , frImageHeight :: Int
65 }
66
67 deriving (Show, Eq, Ord)
68
69data RenderJobResult
70 = RenderJobResult FrameResult
71 | RenderJobError String
72 deriving (Show, Eq, Ord)
73
74
75instance ToJSON ClientInfo where
76 toJSON v = case v of
77 ClientInfo{..} -> object
78 [ "tag" .= ("ClientInfo" :: Text)
79 , "clientName" .= clientName
80 , "clientBackend" .= clientBackend
81 ]
82
83instance FromJSON ClientInfo where
84 parseJSON (Object obj) = do
85 tag <- obj .: "tag"
86 case tag :: Text of
87 "ClientInfo" -> do
88 clientName <- obj .: "clientName"
89 clientBackend <- obj .: "clientBackend"
90 pure $ ClientInfo
91 { clientName = clientName
92 , clientBackend = clientBackend
93 }
94 parseJSON _ = mzero
95
96instance ToJSON Frame where
97 toJSON v = case v of
98 Frame{..} -> object
99 [ "tag" .= ("Frame" :: Text)
100 , "renderCount" .= renderCount
101 , "frameUniforms" .= frameUniforms
102 , "frameTextures" .= frameTextures
103 ]
104
105instance FromJSON Frame where
106 parseJSON (Object obj) = do
107 tag <- obj .: "tag"
108 case tag :: Text of
109 "Frame" -> do
110 renderCount <- obj .: "renderCount"
111 frameUniforms <- obj .: "frameUniforms"
112 frameTextures <- obj .: "frameTextures"
113 pure $ Frame
114 { renderCount = renderCount
115 , frameUniforms = frameUniforms
116 , frameTextures = frameTextures
117 }
118 parseJSON _ = mzero
119
120instance ToJSON Scene where
121 toJSON v = case v of
122 Scene{..} -> object
123 [ "tag" .= ("Scene" :: Text)
124 , "objectArrays" .= objectArrays
125 , "renderTargetWidth" .= renderTargetWidth
126 , "renderTargetHeight" .= renderTargetHeight
127 , "frames" .= frames
128 ]
129
130instance FromJSON Scene where
131 parseJSON (Object obj) = do
132 tag <- obj .: "tag"
133 case tag :: Text of
134 "Scene" -> do
135 objectArrays <- obj .: "objectArrays"
136 renderTargetWidth <- obj .: "renderTargetWidth"
137 renderTargetHeight <- obj .: "renderTargetHeight"
138 frames <- obj .: "frames"
139 pure $ Scene
140 { objectArrays = objectArrays
141 , renderTargetWidth = renderTargetWidth
142 , renderTargetHeight = renderTargetHeight
143 , frames = frames
144 }
145 parseJSON _ = mzero
146
147instance ToJSON RenderJob where
148 toJSON v = case v of
149 RenderJob{..} -> object
150 [ "tag" .= ("RenderJob" :: Text)
151 , "meshes" .= meshes
152 , "textures" .= textures
153 , "schema" .= schema
154 , "scenes" .= scenes
155 , "pipelines" .= pipelines
156 ]
157
158instance FromJSON RenderJob where
159 parseJSON (Object obj) = do
160 tag <- obj .: "tag"
161 case tag :: Text of
162 "RenderJob" -> do
163 meshes <- obj .: "meshes"
164 textures <- obj .: "textures"
165 schema <- obj .: "schema"
166 scenes <- obj .: "scenes"
167 pipelines <- obj .: "pipelines"
168 pure $ RenderJob
169 { meshes = meshes
170 , textures = textures
171 , schema = schema
172 , scenes = scenes
173 , pipelines = pipelines
174 }
175 parseJSON _ = mzero
176
177instance ToJSON FrameResult where
178 toJSON v = case v of
179 FrameResult{..} -> object
180 [ "tag" .= ("FrameResult" :: Text)
181 , "frRenderTimes" .= frRenderTimes
182 , "frImageWidth" .= frImageWidth
183 , "frImageHeight" .= frImageHeight
184 ]
185
186instance FromJSON FrameResult where
187 parseJSON (Object obj) = do
188 tag <- obj .: "tag"
189 case tag :: Text of
190 "FrameResult" -> do
191 frRenderTimes <- obj .: "frRenderTimes"
192 frImageWidth <- obj .: "frImageWidth"
193 frImageHeight <- obj .: "frImageHeight"
194 pure $ FrameResult
195 { frRenderTimes = frRenderTimes
196 , frImageWidth = frImageWidth
197 , frImageHeight = frImageHeight
198 }
199 parseJSON _ = mzero
200
201instance ToJSON RenderJobResult where
202 toJSON v = case v of
203 RenderJobResult arg0 -> object [ "tag" .= ("RenderJobResult" :: Text), "arg0" .= arg0]
204 RenderJobError arg0 -> object [ "tag" .= ("RenderJobError" :: Text), "arg0" .= arg0]
205
206instance FromJSON RenderJobResult where
207 parseJSON (Object obj) = do
208 tag <- obj .: "tag"
209 case tag :: Text of
210 "RenderJobResult" -> RenderJobResult <$> obj .: "arg0"
211 "RenderJobError" -> RenderJobError <$> obj .: "arg0"
212 parseJSON _ = mzero
213
diff --git a/ddl/out/TestData.purs b/ddl/out/TestData.purs
new file mode 100644
index 0000000..4a0575b
--- /dev/null
+++ b/ddl/out/TestData.purs
@@ -0,0 +1,209 @@
1-- generated file, do not modify!
2-- 2016-01-28T13:15:31.27456Z
3
4module TestData where
5import Prelude
6import Data.Generic
7import Data.Maybe (Maybe(..))
8import Data.StrMap (StrMap(..))
9import Data.Map (Map(..))
10import Data.List (List(..))
11import Linear
12
13import Data.Argonaut.Combinators ((~>), (:=), (.?))
14import Data.Argonaut.Core (jsonEmptyObject)
15import Data.Argonaut.Printer (printJson)
16import Data.Argonaut.Encode (EncodeJson, encodeJson)
17import Data.Argonaut.Decode (DecodeJson, decodeJson)
18
19import LambdaCube.IR
20import LambdaCube.Mesh
21import LambdaCube.PipelineSchema
22
23data ClientInfo
24 = ClientInfo
25 { clientName :: String
26 , clientBackend :: Backend
27 }
28
29
30data Frame
31 = Frame
32 { renderCount :: Int
33 , frameUniforms :: StrMap Value
34 , frameTextures :: StrMap Int
35 }
36
37
38data Scene
39 = Scene
40 { objectArrays :: StrMap (Array Int)
41 , renderTargetWidth :: Int
42 , renderTargetHeight :: Int
43 , frames :: Array Frame
44 }
45
46
47data RenderJob
48 = RenderJob
49 { meshes :: Array Mesh
50 , textures :: Array String
51 , schema :: PipelineSchema
52 , scenes :: Array Scene
53 , pipelines :: Array Pipeline
54 }
55
56
57data FrameResult
58 = FrameResult
59 { frRenderTimes :: Array Float
60 , frImageWidth :: Int
61 , frImageHeight :: Int
62 }
63
64
65data RenderJobResult
66 = RenderJobResult FrameResult
67 | RenderJobError String
68
69
70
71instance encodeJsonClientInfo :: EncodeJson ClientInfo where
72 encodeJson v = case v of
73 ClientInfo r ->
74 "tag" := "ClientInfo" ~>
75 "clientName" := r.clientName ~>
76 "clientBackend" := r.clientBackend ~>
77 jsonEmptyObject
78
79instance decodeJsonClientInfo :: DecodeJson ClientInfo where
80 decodeJson json = do
81 obj <- decodeJson json
82 tag <- obj .? "tag"
83 case tag of
84 "ClientInfo" -> do
85 clientName <- obj .? "clientName"
86 clientBackend <- obj .? "clientBackend"
87 pure $ ClientInfo
88 { clientName:clientName
89 , clientBackend:clientBackend
90 }
91
92instance encodeJsonFrame :: EncodeJson Frame where
93 encodeJson v = case v of
94 Frame r ->
95 "tag" := "Frame" ~>
96 "renderCount" := r.renderCount ~>
97 "frameUniforms" := r.frameUniforms ~>
98 "frameTextures" := r.frameTextures ~>
99 jsonEmptyObject
100
101instance decodeJsonFrame :: DecodeJson Frame where
102 decodeJson json = do
103 obj <- decodeJson json
104 tag <- obj .? "tag"
105 case tag of
106 "Frame" -> do
107 renderCount <- obj .? "renderCount"
108 frameUniforms <- obj .? "frameUniforms"
109 frameTextures <- obj .? "frameTextures"
110 pure $ Frame
111 { renderCount:renderCount
112 , frameUniforms:frameUniforms
113 , frameTextures:frameTextures
114 }
115
116instance encodeJsonScene :: EncodeJson Scene where
117 encodeJson v = case v of
118 Scene r ->
119 "tag" := "Scene" ~>
120 "objectArrays" := r.objectArrays ~>
121 "renderTargetWidth" := r.renderTargetWidth ~>
122 "renderTargetHeight" := r.renderTargetHeight ~>
123 "frames" := r.frames ~>
124 jsonEmptyObject
125
126instance decodeJsonScene :: DecodeJson Scene where
127 decodeJson json = do
128 obj <- decodeJson json
129 tag <- obj .? "tag"
130 case tag of
131 "Scene" -> do
132 objectArrays <- obj .? "objectArrays"
133 renderTargetWidth <- obj .? "renderTargetWidth"
134 renderTargetHeight <- obj .? "renderTargetHeight"
135 frames <- obj .? "frames"
136 pure $ Scene
137 { objectArrays:objectArrays
138 , renderTargetWidth:renderTargetWidth
139 , renderTargetHeight:renderTargetHeight
140 , frames:frames
141 }
142
143instance encodeJsonRenderJob :: EncodeJson RenderJob where
144 encodeJson v = case v of
145 RenderJob r ->
146 "tag" := "RenderJob" ~>
147 "meshes" := r.meshes ~>
148 "textures" := r.textures ~>
149 "schema" := r.schema ~>
150 "scenes" := r.scenes ~>
151 "pipelines" := r.pipelines ~>
152 jsonEmptyObject
153
154instance decodeJsonRenderJob :: DecodeJson RenderJob where
155 decodeJson json = do
156 obj <- decodeJson json
157 tag <- obj .? "tag"
158 case tag of
159 "RenderJob" -> do
160 meshes <- obj .? "meshes"
161 textures <- obj .? "textures"
162 schema <- obj .? "schema"
163 scenes <- obj .? "scenes"
164 pipelines <- obj .? "pipelines"
165 pure $ RenderJob
166 { meshes:meshes
167 , textures:textures
168 , schema:schema
169 , scenes:scenes
170 , pipelines:pipelines
171 }
172
173instance encodeJsonFrameResult :: EncodeJson FrameResult where
174 encodeJson v = case v of
175 FrameResult r ->
176 "tag" := "FrameResult" ~>
177 "frRenderTimes" := r.frRenderTimes ~>
178 "frImageWidth" := r.frImageWidth ~>
179 "frImageHeight" := r.frImageHeight ~>
180 jsonEmptyObject
181
182instance decodeJsonFrameResult :: DecodeJson FrameResult where
183 decodeJson json = do
184 obj <- decodeJson json
185 tag <- obj .? "tag"
186 case tag of
187 "FrameResult" -> do
188 frRenderTimes <- obj .? "frRenderTimes"
189 frImageWidth <- obj .? "frImageWidth"
190 frImageHeight <- obj .? "frImageHeight"
191 pure $ FrameResult
192 { frRenderTimes:frRenderTimes
193 , frImageWidth:frImageWidth
194 , frImageHeight:frImageHeight
195 }
196
197instance encodeJsonRenderJobResult :: EncodeJson RenderJobResult where
198 encodeJson v = case v of
199 RenderJobResult arg0 -> "tag" := "RenderJobResult" ~> "arg0" := arg0 ~> jsonEmptyObject
200 RenderJobError arg0 -> "tag" := "RenderJobError" ~> "arg0" := arg0 ~> jsonEmptyObject
201
202instance decodeJsonRenderJobResult :: DecodeJson RenderJobResult where
203 decodeJson json = do
204 obj <- decodeJson json
205 tag <- obj .? "tag"
206 case tag of
207 "RenderJobResult" -> RenderJobResult <$> obj .? "arg0"
208 "RenderJobError" -> RenderJobError <$> obj .? "arg0"
209
diff --git a/ddl/out/TestData.swift b/ddl/out/TestData.swift
new file mode 100644
index 0000000..0b4be5a
--- /dev/null
+++ b/ddl/out/TestData.swift
@@ -0,0 +1,222 @@
1// generated file, do not modify!
2// 2016-01-28T13:15:31.27456Z
3
4enum ClientInfo {
5 case ClientInfo(ClientInfo_Data)
6 struct ClientInfo_Data {
7 var clientName : String
8 var clientBackend : Backend
9 }
10}
11
12enum Frame {
13 case Frame(Frame_Data)
14 struct Frame_Data {
15 var renderCount : Int
16 var frameUniforms : Dictionary<String, Value>
17 var frameTextures : Dictionary<String, Int>
18 }
19}
20
21enum Scene {
22 case Scene(Scene_Data)
23 struct Scene_Data {
24 var objectArrays : Dictionary<String, Array<Int>>
25 var renderTargetWidth : Int
26 var renderTargetHeight : Int
27 var frames : Array<Frame>
28 }
29}
30
31enum RenderJob {
32 case RenderJob(RenderJob_Data)
33 struct RenderJob_Data {
34 var meshes : Array<Mesh>
35 var textures : Array<String>
36 var schema : PipelineSchema
37 var scenes : Array<Scene>
38 var pipelines : Array<Pipeline>
39 }
40}
41
42enum FrameResult {
43 case FrameResult(FrameResult_Data)
44 struct FrameResult_Data {
45 var frRenderTimes : Array<Float>
46 var frImageWidth : Int
47 var frImageHeight : Int
48 }
49}
50
51enum RenderJobResult {
52 case RenderJobResult(FrameResult)
53 case RenderJobError(String)
54}
55
56
57extension Int {
58 var toJSON : [String: AnyObject] {
59 return ["":""]
60 }
61}
62extension Int32 {
63 var toJSON : [String: AnyObject] {
64 return ["":""]
65 }
66}
67extension UInt {
68 var toJSON : [String: AnyObject] {
69 return ["":""]
70 }
71}
72extension UInt32 {
73 var toJSON : [String: AnyObject] {
74 return ["":""]
75 }
76}
77extension Float {
78 var toJSON : [String: AnyObject] {
79 return ["":""]
80 }
81}
82extension Bool {
83 var toJSON : [String: AnyObject] {
84 return ["":""]
85 }
86}
87extension String {
88 var toJSON : [String: AnyObject] {
89 return ["":""]
90 }
91}
92extension Array {
93 var toJSON : [String: AnyObject] {
94 return ["":""]
95 }
96}
97extension Dictionary {
98 var toJSON : [String: AnyObject] {
99 return ["":""]
100 }
101}
102extension Maybe {
103 var toJSON : [String: AnyObject] {
104 return ["":""]
105 }
106}
107
108
109
110extension ClientInfo {
111 var toJSON : [String: AnyObject] {
112 switch self {
113 case .ClientInfo(let v):
114 return [ "tag" : "ClientInfo"
115 , "clientName" : v.clientName.toJSON
116 , "clientBackend" : v.clientBackend.toJSON
117 ]
118 }
119 }
120}
121extension Frame {
122 var toJSON : [String: AnyObject] {
123 switch self {
124 case .Frame(let v):
125 return [ "tag" : "Frame"
126 , "renderCount" : v.renderCount.toJSON
127 , "frameUniforms" : v.frameUniforms.toJSON
128 , "frameTextures" : v.frameTextures.toJSON
129 ]
130 }
131 }
132}
133extension Scene {
134 var toJSON : [String: AnyObject] {
135 switch self {
136 case .Scene(let v):
137 return [ "tag" : "Scene"
138 , "objectArrays" : v.objectArrays.toJSON
139 , "renderTargetWidth" : v.renderTargetWidth.toJSON
140 , "renderTargetHeight" : v.renderTargetHeight.toJSON
141 , "frames" : v.frames.toJSON
142 ]
143 }
144 }
145}
146extension RenderJob {
147 var toJSON : [String: AnyObject] {
148 switch self {
149 case .RenderJob(let v):
150 return [ "tag" : "RenderJob"
151 , "meshes" : v.meshes.toJSON
152 , "textures" : v.textures.toJSON
153 , "schema" : v.schema.toJSON
154 , "scenes" : v.scenes.toJSON
155 , "pipelines" : v.pipelines.toJSON
156 ]
157 }
158 }
159}
160extension FrameResult {
161 var toJSON : [String: AnyObject] {
162 switch self {
163 case .FrameResult(let v):
164 return [ "tag" : "FrameResult"
165 , "frRenderTimes" : v.frRenderTimes.toJSON
166 , "frImageWidth" : v.frImageWidth.toJSON
167 , "frImageHeight" : v.frImageHeight.toJSON
168 ]
169 }
170 }
171}
172extension RenderJobResult {
173 var toJSON : [String: AnyObject] {
174 switch self {
175 case .RenderJobResult(let arg0):
176 return [ "tag" : "RenderJobResult", "arg0" : arg0.toJSON]
177 case .RenderJobError(let arg0):
178 return [ "tag" : "RenderJobError", "arg0" : arg0.toJSON]
179 }
180 }
181}
182
183enum Maybe<T> {
184 case Nothing
185 case Just(T)
186}
187
188enum Type {
189 case Int
190 case Int32
191 case Word
192 case Word32
193 case Float
194 case Bool
195 case String
196 case Array(Type)
197 case List(Type)
198 case Maybe(Type)
199 case Map(Type,Type)
200 case ClientInfo
201 case Frame
202 case Scene
203 case RenderJob
204 case FrameResult
205 case RenderJobResult
206}
207
208func fromJSON(type: Type, personName: String) -> Any {
209 switch type {
210 case .Int: return 0
211 case .Int32: return 0
212 case .Word: return 0
213 case .Word32: return 0
214 case .Float: return 0.0
215 case .Bool: return false
216 case .String: return ""
217 case .Array(let a): return fromJSON(a,personName)
218 case .List(let a): return fromJSON(a,personName)
219 case .Maybe(let a): return fromJSON(a,personName)
220 }
221 return 0;
222} \ No newline at end of file
diff --git a/ddl/out/TestData2.hpp b/ddl/out/TestData2.hpp
new file mode 100644
index 0000000..7e44da4
--- /dev/null
+++ b/ddl/out/TestData2.hpp
@@ -0,0 +1,109 @@
1// generated file, do not modify!
2// 2016-01-28T13:15:31.27456Z
3
4#ifndef HEADER_TestData_H
5#define HEADER_TestData_H
6
7#include "RT.hpp"
8
9#include "LambdaCube.IR.hpp"
10#include "LambdaCube.Mesh.hpp"
11#include "LambdaCube.PipelineSchema.hpp"
12
13namespace data {
14 class ClientInfo {
15 public:
16 String clientName;
17 std::shared_ptr<::Backend> clientBackend;
18 };
19}
20class ClientInfo {
21public:
22 enum class tag {
23 ClientInfo
24 } tag;
25 std::shared_ptr<data::ClientInfo> ClientInfo;
26};
27namespace data {
28 class Frame {
29 public:
30 Int renderCount;
31 std::map<String, std::shared_ptr<::Value>> frameUniforms;
32 std::map<String, Int> frameTextures;
33 };
34}
35class Frame {
36public:
37 enum class tag {
38 Frame
39 } tag;
40 std::shared_ptr<data::Frame> Frame;
41};
42namespace data {
43 class Scene {
44 public:
45 std::map<String, std::vector<Int>> objectArrays;
46 Int renderTargetWidth;
47 Int renderTargetHeight;
48 std::vector<std::shared_ptr<::Frame>> frames;
49 };
50}
51class Scene {
52public:
53 enum class tag {
54 Scene
55 } tag;
56 std::shared_ptr<data::Scene> Scene;
57};
58namespace data {
59 class RenderJob {
60 public:
61 std::vector<std::shared_ptr<::Mesh>> meshes;
62 std::vector<String> textures;
63 std::shared_ptr<::PipelineSchema> schema;
64 std::vector<std::shared_ptr<::Scene>> scenes;
65 std::vector<std::shared_ptr<::Pipeline>> pipelines;
66 };
67}
68class RenderJob {
69public:
70 enum class tag {
71 RenderJob
72 } tag;
73 std::shared_ptr<data::RenderJob> RenderJob;
74};
75namespace data {
76 class FrameResult {
77 public:
78 std::vector<Float> frRenderTimes;
79 Int frImageWidth;
80 Int frImageHeight;
81 };
82}
83class FrameResult {
84public:
85 enum class tag {
86 FrameResult
87 } tag;
88 std::shared_ptr<data::FrameResult> FrameResult;
89};
90namespace data {
91 class RenderJobResult {
92 public:
93 std::shared_ptr<::FrameResult> _0;
94 };
95 class RenderJobError {
96 public:
97 String _0;
98 };
99}
100class RenderJobResult {
101public:
102 enum class tag {
103 RenderJobResult,
104 RenderJobError
105 } tag;
106 std::shared_ptr<data::RenderJobResult> RenderJobResult;
107 std::shared_ptr<data::RenderJobError> RenderJobError;
108};
109#endif
diff --git a/ddl/templates/data.hs.ede b/ddl/templates/data.hs.ede
index 54a148b..8e1115d 100644
--- a/ddl/templates/data.hs.ede
+++ b/ddl/templates/data.hs.ede
@@ -8,7 +8,7 @@ import Data.Int
8import Data.Word 8import Data.Word
9import Data.Map 9import Data.Map
10import Data.Vector (Vector(..)) 10import Data.Vector (Vector(..))
11import Linear 11import LambdaCube.Linear
12 12
13import Data.Text 13import Data.Text
14import Data.Aeson hiding (Value,Bool) 14import Data.Aeson hiding (Value,Bool)
diff --git a/lambdacube-ir.haskell/lambdacube-ir.cabal b/lambdacube-ir.haskell/lambdacube-ir.cabal
index 1389a9c..4ff27ed 100644
--- a/lambdacube-ir.haskell/lambdacube-ir.cabal
+++ b/lambdacube-ir.haskell/lambdacube-ir.cabal
@@ -2,7 +2,7 @@
2-- documentation, see http://haskell.org/cabal/users-guide/ 2-- documentation, see http://haskell.org/cabal/users-guide/
3 3
4name: lambdacube-ir 4name: lambdacube-ir
5version: 0.1.0.0 5version: 0.2.0.0
6-- synopsis: 6-- synopsis:
7-- description: 7-- description:
8license: BSD3 8license: BSD3
@@ -16,10 +16,14 @@ build-type: Simple
16cabal-version: >=1.10 16cabal-version: >=1.10
17 17
18library 18library
19 exposed-modules: IR, Linear 19 exposed-modules: LambdaCube.Linear
20 LambdaCube.IR
21 LambdaCube.Mesh
22 LambdaCube.PipelineSchema
23 LambdaCube.PipelineSchemaUtil
20 -- other-modules: 24 -- other-modules:
21 other-extensions: OverloadedStrings, RecordWildCards, DeriveFunctor 25 other-extensions: OverloadedStrings, RecordWildCards, DeriveFunctor
22 -- CAUTION: When the build-depends change, please bump the git submodule in lambdacube-docker repository 26 -- CAUTION: When the build-depends change, please bump the git submodule in lambdacube-docker repository
23 build-depends: base >=4.8 && <4.9, containers >=0.5 && <0.6, vector >=0.11 && <0.12, text >=1.2 && <1.3, aeson >=0.9 && <0.11 27 build-depends: base >=4.8 && <4.9, containers >=0.5 && <0.6, vector >=0.11 && <0.12, text >=1.2 && <1.3, aeson >=0.9 && <0.11, mtl >=2.2 && <2.3
24 hs-source-dirs: src 28 hs-source-dirs: src
25 default-language: Haskell2010 29 default-language: Haskell2010
diff --git a/lambdacube-ir.haskell/src/IR.hs b/lambdacube-ir.haskell/src/IR.hs
deleted file mode 120000
index e256d2b..0000000
--- a/lambdacube-ir.haskell/src/IR.hs
+++ /dev/null
@@ -1 +0,0 @@
1../../ddl/out/IR.hs \ No newline at end of file
diff --git a/lambdacube-ir.haskell/src/LambdaCube/IR.hs b/lambdacube-ir.haskell/src/LambdaCube/IR.hs
new file mode 120000
index 0000000..7b90d33
--- /dev/null
+++ b/lambdacube-ir.haskell/src/LambdaCube/IR.hs
@@ -0,0 +1 @@
../../../ddl/out/LambdaCube.IR.hs \ No newline at end of file
diff --git a/lambdacube-ir.haskell/src/Linear.hs b/lambdacube-ir.haskell/src/LambdaCube/Linear.hs
index 1329841..286cc93 100644
--- a/lambdacube-ir.haskell/src/Linear.hs
+++ b/lambdacube-ir.haskell/src/LambdaCube/Linear.hs
@@ -1,5 +1,5 @@
1{-# LANGUAGE DeriveFunctor, OverloadedStrings #-} 1{-# LANGUAGE DeriveFunctor, OverloadedStrings #-}
2module Linear where 2module LambdaCube.Linear where
3 3
4import Data.Int 4import Data.Int
5import Data.Word 5import Data.Word
diff --git a/lambdacube-ir.haskell/src/LambdaCube/Mesh.hs b/lambdacube-ir.haskell/src/LambdaCube/Mesh.hs
new file mode 120000
index 0000000..9dfc009
--- /dev/null
+++ b/lambdacube-ir.haskell/src/LambdaCube/Mesh.hs
@@ -0,0 +1 @@
../../../ddl/out/LambdaCube.Mesh.hs \ No newline at end of file
diff --git a/lambdacube-ir.haskell/src/LambdaCube/PipelineSchema.hs b/lambdacube-ir.haskell/src/LambdaCube/PipelineSchema.hs
new file mode 120000
index 0000000..afe52ef
--- /dev/null
+++ b/lambdacube-ir.haskell/src/LambdaCube/PipelineSchema.hs
@@ -0,0 +1 @@
../../../ddl/out/LambdaCube.PipelineSchema.hs \ No newline at end of file
diff --git a/lambdacube-ir.haskell/src/LambdaCube/PipelineSchemaUtil.hs b/lambdacube-ir.haskell/src/LambdaCube/PipelineSchemaUtil.hs
new file mode 100644
index 0000000..a5eac55
--- /dev/null
+++ b/lambdacube-ir.haskell/src/LambdaCube/PipelineSchemaUtil.hs
@@ -0,0 +1,20 @@
1{-# LANGUAGE FlexibleContexts, TypeSynonymInstances, FlexibleInstances #-}
2module LambdaCube.PipelineSchemaUtil where
3
4import Control.Monad.Writer
5import qualified Data.Map as Map
6import LambdaCube.PipelineSchema
7
8a @: b = tell [(a,b)]
9defObjectArray n p m = mapM_ tell [PipelineSchema (Map.singleton n $ ObjectArraySchema p $ Map.singleton a t) mempty | (a,t) <- execWriter m]
10defUniforms m = tell $ PipelineSchema mempty $ Map.fromList $ execWriter m
11makeSchema a = execWriter a :: PipelineSchema
12
13unionObjectArraySchema (ObjectArraySchema a1 b1) (ObjectArraySchema a2 b2) =
14 ObjectArraySchema (if a1 == a2 then a1 else error $ "object array schema primitive mismatch " ++ show (a1,a2))
15 (Map.unionWith (\a b -> if a == b then a else error $ "object array schema attribute type mismatch " ++ show (a,b)) b1 b2)
16
17instance Monoid PipelineSchema where
18 mempty = PipelineSchema mempty mempty
19 mappend (PipelineSchema a1 b1) (PipelineSchema a2 b2) =
20 PipelineSchema (Map.unionWith unionObjectArraySchema a1 a2) (Map.unionWith (\a b -> if a == b then a else error $ "schema type mismatch " ++ show (a,b)) b1 b2)