From fe9a7c6d0af59227ff34b098f2a5ba1359790ae8 Mon Sep 17 00:00:00 2001 From: Csaba Hruska Date: Fri, 29 Jan 2016 15:27:53 +0100 Subject: add Schema to IR module, also use namespace --- ddl/Definitions.hs | 97 +- ddl/Generate.hs | 2 + ddl/out/IR.cpp | 2864 -------------------- ddl/out/IR.hpp | 1070 -------- ddl/out/IR.hs | 1608 ----------- ddl/out/IR.purs | 1590 ----------- ddl/out/IR.swift | 1429 ---------- ddl/out/IR2.hpp | 1070 -------- ddl/out/LambdaCube.IR.cpp | 2864 ++++++++++++++++++++ ddl/out/LambdaCube.IR.hpp | 1070 ++++++++ ddl/out/LambdaCube.IR.hs | 1608 +++++++++++ ddl/out/LambdaCube.IR.purs | 1590 +++++++++++ ddl/out/LambdaCube.IR.swift | 1429 ++++++++++ ddl/out/LambdaCube.IR2.hpp | 1070 ++++++++ ddl/out/LambdaCube.Mesh.cpp | 228 ++ ddl/out/LambdaCube.Mesh.hpp | 107 + ddl/out/LambdaCube.Mesh.hs | 114 + ddl/out/LambdaCube.Mesh.purs | 113 + ddl/out/LambdaCube.Mesh.swift | 174 ++ ddl/out/LambdaCube.Mesh2.hpp | 107 + ddl/out/LambdaCube.PipelineSchema.cpp | 208 ++ ddl/out/LambdaCube.PipelineSchema.hpp | 67 + ddl/out/LambdaCube.PipelineSchema.hs | 153 ++ ddl/out/LambdaCube.PipelineSchema.purs | 152 ++ ddl/out/LambdaCube.PipelineSchema.swift | 205 ++ ddl/out/LambdaCube.PipelineSchema2.hpp | 67 + ddl/out/LambdaCube.TypeInfo.cpp | 89 + ddl/out/LambdaCube.TypeInfo.hpp | 50 + ddl/out/LambdaCube.TypeInfo.hs | 79 + ddl/out/LambdaCube.TypeInfo.purs | 79 + ddl/out/LambdaCube.TypeInfo.swift | 134 + ddl/out/LambdaCube.TypeInfo2.hpp | 50 + ddl/out/Mesh.cpp | 228 -- ddl/out/Mesh.hpp | 107 - ddl/out/Mesh.hs | 114 - ddl/out/Mesh.purs | 113 - ddl/out/Mesh.swift | 174 -- ddl/out/Mesh2.hpp | 107 - ddl/out/TestData.cpp | 215 ++ ddl/out/TestData.hpp | 109 + ddl/out/TestData.hs | 213 ++ ddl/out/TestData.purs | 209 ++ ddl/out/TestData.swift | 222 ++ ddl/out/TestData2.hpp | 109 + ddl/out/TypeInfo.cpp | 89 - ddl/out/TypeInfo.hpp | 50 - ddl/out/TypeInfo.hs | 79 - ddl/out/TypeInfo.purs | 79 - ddl/out/TypeInfo.swift | 134 - ddl/out/TypeInfo2.hpp | 50 - ddl/templates/data.hs.ede | 2 +- lambdacube-ir.haskell/lambdacube-ir.cabal | 10 +- lambdacube-ir.haskell/src/IR.hs | 1 - lambdacube-ir.haskell/src/LambdaCube/IR.hs | 1 + lambdacube-ir.haskell/src/LambdaCube/Linear.hs | 60 + lambdacube-ir.haskell/src/LambdaCube/Mesh.hs | 1 + .../src/LambdaCube/PipelineSchema.hs | 1 + .../src/LambdaCube/PipelineSchemaUtil.hs | 20 + lambdacube-ir.haskell/src/Linear.hs | 60 - 59 files changed, 13070 insertions(+), 11024 deletions(-) delete mode 100644 ddl/out/IR.cpp delete mode 100644 ddl/out/IR.hpp delete mode 100644 ddl/out/IR.hs delete mode 100644 ddl/out/IR.purs delete mode 100644 ddl/out/IR.swift delete mode 100644 ddl/out/IR2.hpp create mode 100644 ddl/out/LambdaCube.IR.cpp create mode 100644 ddl/out/LambdaCube.IR.hpp create mode 100644 ddl/out/LambdaCube.IR.hs create mode 100644 ddl/out/LambdaCube.IR.purs create mode 100644 ddl/out/LambdaCube.IR.swift create mode 100644 ddl/out/LambdaCube.IR2.hpp create mode 100644 ddl/out/LambdaCube.Mesh.cpp create mode 100644 ddl/out/LambdaCube.Mesh.hpp create mode 100644 ddl/out/LambdaCube.Mesh.hs create mode 100644 ddl/out/LambdaCube.Mesh.purs create mode 100644 ddl/out/LambdaCube.Mesh.swift create mode 100644 ddl/out/LambdaCube.Mesh2.hpp create mode 100644 ddl/out/LambdaCube.PipelineSchema.cpp create mode 100644 ddl/out/LambdaCube.PipelineSchema.hpp create mode 100644 ddl/out/LambdaCube.PipelineSchema.hs create mode 100644 ddl/out/LambdaCube.PipelineSchema.purs create mode 100644 ddl/out/LambdaCube.PipelineSchema.swift create mode 100644 ddl/out/LambdaCube.PipelineSchema2.hpp create mode 100644 ddl/out/LambdaCube.TypeInfo.cpp create mode 100644 ddl/out/LambdaCube.TypeInfo.hpp create mode 100644 ddl/out/LambdaCube.TypeInfo.hs create mode 100644 ddl/out/LambdaCube.TypeInfo.purs create mode 100644 ddl/out/LambdaCube.TypeInfo.swift create mode 100644 ddl/out/LambdaCube.TypeInfo2.hpp delete mode 100644 ddl/out/Mesh.cpp delete mode 100644 ddl/out/Mesh.hpp delete mode 100644 ddl/out/Mesh.hs delete mode 100644 ddl/out/Mesh.purs delete mode 100644 ddl/out/Mesh.swift delete mode 100644 ddl/out/Mesh2.hpp create mode 100644 ddl/out/TestData.cpp create mode 100644 ddl/out/TestData.hpp create mode 100644 ddl/out/TestData.hs create mode 100644 ddl/out/TestData.purs create mode 100644 ddl/out/TestData.swift create mode 100644 ddl/out/TestData2.hpp delete mode 100644 ddl/out/TypeInfo.cpp delete mode 100644 ddl/out/TypeInfo.hpp delete mode 100644 ddl/out/TypeInfo.hs delete mode 100644 ddl/out/TypeInfo.purs delete mode 100644 ddl/out/TypeInfo.swift delete mode 100644 ddl/out/TypeInfo2.hpp delete mode 120000 lambdacube-ir.haskell/src/IR.hs create mode 120000 lambdacube-ir.haskell/src/LambdaCube/IR.hs create mode 100644 lambdacube-ir.haskell/src/LambdaCube/Linear.hs create mode 120000 lambdacube-ir.haskell/src/LambdaCube/Mesh.hs create mode 120000 lambdacube-ir.haskell/src/LambdaCube/PipelineSchema.hs create mode 100644 lambdacube-ir.haskell/src/LambdaCube/PipelineSchemaUtil.hs delete mode 100644 lambdacube-ir.haskell/src/Linear.hs 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 const_ "MyLeft" ["TypeInfo", Array "TypeInfo"] const_ "MyRight" [String, "Pipeline", Array "TypeInfo"] +pipelineSchema = do + data_ "StreamType" $ do + enum_ "Attribute_Word" + enum_ "Attribute_V2U" + enum_ "Attribute_V3U" + enum_ "Attribute_V4U" + enum_ "Attribute_Int" + enum_ "Attribute_V2I" + enum_ "Attribute_V3I" + enum_ "Attribute_V4I" + enum_ "Attribute_Float" + enum_ "Attribute_V2F" + enum_ "Attribute_V3F" + enum_ "Attribute_V4F" + enum_ "Attribute_M22F" + enum_ "Attribute_M23F" + enum_ "Attribute_M24F" + enum_ "Attribute_M32F" + enum_ "Attribute_M33F" + enum_ "Attribute_M34F" + enum_ "Attribute_M42F" + enum_ "Attribute_M43F" + enum_ "Attribute_M44F" + + data_ "ObjectArraySchema" $ do + constR_ "ObjectArraySchema" + [ "primitive" #:: "FetchPrimitive" + , "attributes" #:: Map String "StreamType" + ] + + data_ "PipelineSchema" $ do + constR_ "PipelineSchema" + [ "objectArrays" #:: Map String "ObjectArraySchema" + , "uniforms" #:: Map String "InputType" + ] + +testData = do + -- client info + data_ "ClientInfo" $ do + constR_ "ClientInfo" + [ "clientName" #:: String + , "clientBackend" #:: "Backend" + ] + + -- test scene description + data_ "Frame" $ do + constR_ "Frame" + [ "renderCount" #:: Int + , "frameUniforms" #:: Map String "Value" + , "frameTextures" #:: Map String Int + ] + + data_ "Scene" $ do + constR_ "Scene" + [ "objectArrays" #:: Map String (Array Int) + , "renderTargetWidth" #:: Int + , "renderTargetHeight" #:: Int + , "frames" #:: Array "Frame" + ] + + data_ "RenderJob" $ do + constR_ "RenderJob" + [ "meshes" #:: Array "Mesh" + , "textures" #:: Array String -- png texture + , "schema" #:: "PipelineSchema" + , "scenes" #:: Array "Scene" + , "pipelines" #:: Array "Pipeline" + ] + + -- test result + data_ "FrameResult" $ do + constR_ "FrameResult" + [ "frRenderTimes" #:: Array Float + , "frImageWidth" #:: Int + , "frImageHeight" #:: Int + ] + + data_ "RenderJobResult" $ do + const_ "RenderJobResult" ["FrameResult"] + const_ "RenderJobError" [String] + modules = do - module_ "IR" ir - module_ "Mesh" mesh - module_ "TypeInfo" $ do - import_ ["IR"] + module_ "LambdaCube.IR" ir + module_ "LambdaCube.PipelineSchema" $ do + import_ ["LambdaCube.IR"] + pipelineSchema + module_ "LambdaCube.Mesh" mesh + module_ "LambdaCube.TypeInfo" $ do + import_ ["LambdaCube.IR"] typeInfo + module_ "TestData" $ do + import_ ["LambdaCube.IR"] + import_ ["LambdaCube.Mesh"] + import_ ["LambdaCube.PipelineSchema"] + 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 import Data.Text (Text) import qualified Data.Map as Map +import System.Directory + import Data.Time.Clock import Control.Monad.Writer diff --git a/ddl/out/IR.cpp b/ddl/out/IR.cpp deleted file mode 100644 index cac97e7..0000000 --- a/ddl/out/IR.cpp +++ /dev/null @@ -1,2864 +0,0 @@ -// generated file, do not modify! -// 2016-01-18T14:30:07.798481Z - -#include "IR.hpp" -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::ArrayValue::tag::VBoolArray: - obj["tag"] = "VBoolArray"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::ArrayValue::tag::VIntArray: - obj["tag"] = "VIntArray"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::ArrayValue::tag::VWordArray: - obj["tag"] = "VWordArray"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::ArrayValue::tag::VFloatArray: - obj["tag"] = "VFloatArray"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::ArrayValue::tag tagType; - std::string tag = obj["tag"]; - if (tag == "VBoolArray") { - tagType = ::ArrayValue::tag::VBoolArray; - std::shared_ptr tv(new data::VBoolArray()); - tv->_0 = fromJSON(W>(), obj["arg0"]); - return tv; - } - else if (tag == "VIntArray") { - tagType = ::ArrayValue::tag::VIntArray; - std::shared_ptr tv(new data::VIntArray()); - tv->_0 = fromJSON(W>(), obj["arg0"]); - return tv; - } - else if (tag == "VWordArray") { - tagType = ::ArrayValue::tag::VWordArray; - std::shared_ptr tv(new data::VWordArray()); - tv->_0 = fromJSON(W>(), obj["arg0"]); - return tv; - } - else if (tag == "VFloatArray") { - tagType = ::ArrayValue::tag::VFloatArray; - std::shared_ptr tv(new data::VFloatArray()); - tv->_0 = fromJSON(W>(), obj["arg0"]); - return tv; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::ArrayValue> o(new ::ArrayValue()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::Value::tag::VBool: - obj["tag"] = "VBool"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::Value::tag::VV2B: - obj["tag"] = "VV2B"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::Value::tag::VV3B: - obj["tag"] = "VV3B"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::Value::tag::VV4B: - obj["tag"] = "VV4B"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::Value::tag::VWord: - obj["tag"] = "VWord"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::Value::tag::VV2U: - obj["tag"] = "VV2U"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::Value::tag::VV3U: - obj["tag"] = "VV3U"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::Value::tag::VV4U: - obj["tag"] = "VV4U"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::Value::tag::VInt: - obj["tag"] = "VInt"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::Value::tag::VV2I: - obj["tag"] = "VV2I"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::Value::tag::VV3I: - obj["tag"] = "VV3I"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::Value::tag::VV4I: - obj["tag"] = "VV4I"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::Value::tag::VFloat: - obj["tag"] = "VFloat"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::Value::tag::VV2F: - obj["tag"] = "VV2F"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::Value::tag::VV3F: - obj["tag"] = "VV3F"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::Value::tag::VV4F: - obj["tag"] = "VV4F"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::Value::tag::VM22F: - obj["tag"] = "VM22F"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::Value::tag::VM23F: - obj["tag"] = "VM23F"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::Value::tag::VM24F: - obj["tag"] = "VM24F"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::Value::tag::VM32F: - obj["tag"] = "VM32F"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::Value::tag::VM33F: - obj["tag"] = "VM33F"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::Value::tag::VM34F: - obj["tag"] = "VM34F"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::Value::tag::VM42F: - obj["tag"] = "VM42F"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::Value::tag::VM43F: - obj["tag"] = "VM43F"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::Value::tag::VM44F: - obj["tag"] = "VM44F"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::Value::tag tagType; - std::string tag = obj["tag"]; - if (tag == "VBool") { - tagType = ::Value::tag::VBool; - std::shared_ptr tv(new data::VBool()); - tv->_0 = fromJSON(W(), obj["arg0"]); - return tv; - } - else if (tag == "VV2B") { - tagType = ::Value::tag::VV2B; - std::shared_ptr tv(new data::VV2B()); - tv->_0 = fromJSON(W(), obj["arg0"]); - return tv; - } - else if (tag == "VV3B") { - tagType = ::Value::tag::VV3B; - std::shared_ptr tv(new data::VV3B()); - tv->_0 = fromJSON(W(), obj["arg0"]); - return tv; - } - else if (tag == "VV4B") { - tagType = ::Value::tag::VV4B; - std::shared_ptr tv(new data::VV4B()); - tv->_0 = fromJSON(W(), obj["arg0"]); - return tv; - } - else if (tag == "VWord") { - tagType = ::Value::tag::VWord; - std::shared_ptr tv(new data::VWord()); - tv->_0 = fromJSON(W(), obj["arg0"]); - return tv; - } - else if (tag == "VV2U") { - tagType = ::Value::tag::VV2U; - std::shared_ptr tv(new data::VV2U()); - tv->_0 = fromJSON(W(), obj["arg0"]); - return tv; - } - else if (tag == "VV3U") { - tagType = ::Value::tag::VV3U; - std::shared_ptr tv(new data::VV3U()); - tv->_0 = fromJSON(W(), obj["arg0"]); - return tv; - } - else if (tag == "VV4U") { - tagType = ::Value::tag::VV4U; - std::shared_ptr tv(new data::VV4U()); - tv->_0 = fromJSON(W(), obj["arg0"]); - return tv; - } - else if (tag == "VInt") { - tagType = ::Value::tag::VInt; - std::shared_ptr tv(new data::VInt()); - tv->_0 = fromJSON(W(), obj["arg0"]); - return tv; - } - else if (tag == "VV2I") { - tagType = ::Value::tag::VV2I; - std::shared_ptr tv(new data::VV2I()); - tv->_0 = fromJSON(W(), obj["arg0"]); - return tv; - } - else if (tag == "VV3I") { - tagType = ::Value::tag::VV3I; - std::shared_ptr tv(new data::VV3I()); - tv->_0 = fromJSON(W(), obj["arg0"]); - return tv; - } - else if (tag == "VV4I") { - tagType = ::Value::tag::VV4I; - std::shared_ptr tv(new data::VV4I()); - tv->_0 = fromJSON(W(), obj["arg0"]); - return tv; - } - else if (tag == "VFloat") { - tagType = ::Value::tag::VFloat; - std::shared_ptr tv(new data::VFloat()); - tv->_0 = fromJSON(W(), obj["arg0"]); - return tv; - } - else if (tag == "VV2F") { - tagType = ::Value::tag::VV2F; - std::shared_ptr tv(new data::VV2F()); - tv->_0 = fromJSON(W(), obj["arg0"]); - return tv; - } - else if (tag == "VV3F") { - tagType = ::Value::tag::VV3F; - std::shared_ptr tv(new data::VV3F()); - tv->_0 = fromJSON(W(), obj["arg0"]); - return tv; - } - else if (tag == "VV4F") { - tagType = ::Value::tag::VV4F; - std::shared_ptr tv(new data::VV4F()); - tv->_0 = fromJSON(W(), obj["arg0"]); - return tv; - } - else if (tag == "VM22F") { - tagType = ::Value::tag::VM22F; - std::shared_ptr tv(new data::VM22F()); - tv->_0 = fromJSON(W(), obj["arg0"]); - return tv; - } - else if (tag == "VM23F") { - tagType = ::Value::tag::VM23F; - std::shared_ptr tv(new data::VM23F()); - tv->_0 = fromJSON(W(), obj["arg0"]); - return tv; - } - else if (tag == "VM24F") { - tagType = ::Value::tag::VM24F; - std::shared_ptr tv(new data::VM24F()); - tv->_0 = fromJSON(W(), obj["arg0"]); - return tv; - } - else if (tag == "VM32F") { - tagType = ::Value::tag::VM32F; - std::shared_ptr tv(new data::VM32F()); - tv->_0 = fromJSON(W(), obj["arg0"]); - return tv; - } - else if (tag == "VM33F") { - tagType = ::Value::tag::VM33F; - std::shared_ptr tv(new data::VM33F()); - tv->_0 = fromJSON(W(), obj["arg0"]); - return tv; - } - else if (tag == "VM34F") { - tagType = ::Value::tag::VM34F; - std::shared_ptr tv(new data::VM34F()); - tv->_0 = fromJSON(W(), obj["arg0"]); - return tv; - } - else if (tag == "VM42F") { - tagType = ::Value::tag::VM42F; - std::shared_ptr tv(new data::VM42F()); - tv->_0 = fromJSON(W(), obj["arg0"]); - return tv; - } - else if (tag == "VM43F") { - tagType = ::Value::tag::VM43F; - std::shared_ptr tv(new data::VM43F()); - tv->_0 = fromJSON(W(), obj["arg0"]); - return tv; - } - else if (tag == "VM44F") { - tagType = ::Value::tag::VM44F; - std::shared_ptr tv(new data::VM44F()); - tv->_0 = fromJSON(W(), obj["arg0"]); - return tv; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::Value> o(new ::Value()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::InputType::tag::Bool: - obj["tag"] = "Bool"; - break; - case ::InputType::tag::V2B: - obj["tag"] = "V2B"; - break; - case ::InputType::tag::V3B: - obj["tag"] = "V3B"; - break; - case ::InputType::tag::V4B: - obj["tag"] = "V4B"; - break; - case ::InputType::tag::Word: - obj["tag"] = "Word"; - break; - case ::InputType::tag::V2U: - obj["tag"] = "V2U"; - break; - case ::InputType::tag::V3U: - obj["tag"] = "V3U"; - break; - case ::InputType::tag::V4U: - obj["tag"] = "V4U"; - break; - case ::InputType::tag::Int: - obj["tag"] = "Int"; - break; - case ::InputType::tag::V2I: - obj["tag"] = "V2I"; - break; - case ::InputType::tag::V3I: - obj["tag"] = "V3I"; - break; - case ::InputType::tag::V4I: - obj["tag"] = "V4I"; - break; - case ::InputType::tag::Float: - obj["tag"] = "Float"; - break; - case ::InputType::tag::V2F: - obj["tag"] = "V2F"; - break; - case ::InputType::tag::V3F: - obj["tag"] = "V3F"; - break; - case ::InputType::tag::V4F: - obj["tag"] = "V4F"; - break; - case ::InputType::tag::M22F: - obj["tag"] = "M22F"; - break; - case ::InputType::tag::M23F: - obj["tag"] = "M23F"; - break; - case ::InputType::tag::M24F: - obj["tag"] = "M24F"; - break; - case ::InputType::tag::M32F: - obj["tag"] = "M32F"; - break; - case ::InputType::tag::M33F: - obj["tag"] = "M33F"; - break; - case ::InputType::tag::M34F: - obj["tag"] = "M34F"; - break; - case ::InputType::tag::M42F: - obj["tag"] = "M42F"; - break; - case ::InputType::tag::M43F: - obj["tag"] = "M43F"; - break; - case ::InputType::tag::M44F: - obj["tag"] = "M44F"; - break; - case ::InputType::tag::STexture1D: - obj["tag"] = "STexture1D"; - break; - case ::InputType::tag::STexture2D: - obj["tag"] = "STexture2D"; - break; - case ::InputType::tag::STextureCube: - obj["tag"] = "STextureCube"; - break; - case ::InputType::tag::STexture1DArray: - obj["tag"] = "STexture1DArray"; - break; - case ::InputType::tag::STexture2DArray: - obj["tag"] = "STexture2DArray"; - break; - case ::InputType::tag::STexture2DRect: - obj["tag"] = "STexture2DRect"; - break; - case ::InputType::tag::FTexture1D: - obj["tag"] = "FTexture1D"; - break; - case ::InputType::tag::FTexture2D: - obj["tag"] = "FTexture2D"; - break; - case ::InputType::tag::FTexture3D: - obj["tag"] = "FTexture3D"; - break; - case ::InputType::tag::FTextureCube: - obj["tag"] = "FTextureCube"; - break; - case ::InputType::tag::FTexture1DArray: - obj["tag"] = "FTexture1DArray"; - break; - case ::InputType::tag::FTexture2DArray: - obj["tag"] = "FTexture2DArray"; - break; - case ::InputType::tag::FTexture2DMS: - obj["tag"] = "FTexture2DMS"; - break; - case ::InputType::tag::FTexture2DMSArray: - obj["tag"] = "FTexture2DMSArray"; - break; - case ::InputType::tag::FTextureBuffer: - obj["tag"] = "FTextureBuffer"; - break; - case ::InputType::tag::FTexture2DRect: - obj["tag"] = "FTexture2DRect"; - break; - case ::InputType::tag::ITexture1D: - obj["tag"] = "ITexture1D"; - break; - case ::InputType::tag::ITexture2D: - obj["tag"] = "ITexture2D"; - break; - case ::InputType::tag::ITexture3D: - obj["tag"] = "ITexture3D"; - break; - case ::InputType::tag::ITextureCube: - obj["tag"] = "ITextureCube"; - break; - case ::InputType::tag::ITexture1DArray: - obj["tag"] = "ITexture1DArray"; - break; - case ::InputType::tag::ITexture2DArray: - obj["tag"] = "ITexture2DArray"; - break; - case ::InputType::tag::ITexture2DMS: - obj["tag"] = "ITexture2DMS"; - break; - case ::InputType::tag::ITexture2DMSArray: - obj["tag"] = "ITexture2DMSArray"; - break; - case ::InputType::tag::ITextureBuffer: - obj["tag"] = "ITextureBuffer"; - break; - case ::InputType::tag::ITexture2DRect: - obj["tag"] = "ITexture2DRect"; - break; - case ::InputType::tag::UTexture1D: - obj["tag"] = "UTexture1D"; - break; - case ::InputType::tag::UTexture2D: - obj["tag"] = "UTexture2D"; - break; - case ::InputType::tag::UTexture3D: - obj["tag"] = "UTexture3D"; - break; - case ::InputType::tag::UTextureCube: - obj["tag"] = "UTextureCube"; - break; - case ::InputType::tag::UTexture1DArray: - obj["tag"] = "UTexture1DArray"; - break; - case ::InputType::tag::UTexture2DArray: - obj["tag"] = "UTexture2DArray"; - break; - case ::InputType::tag::UTexture2DMS: - obj["tag"] = "UTexture2DMS"; - break; - case ::InputType::tag::UTexture2DMSArray: - obj["tag"] = "UTexture2DMSArray"; - break; - case ::InputType::tag::UTextureBuffer: - obj["tag"] = "UTextureBuffer"; - break; - case ::InputType::tag::UTexture2DRect: - obj["tag"] = "UTexture2DRect"; - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::InputType::tag tagType; - std::string tag = obj["tag"]; - if (tag == "Bool") { - tagType = ::InputType::tag::Bool; - } - else if (tag == "V2B") { - tagType = ::InputType::tag::V2B; - } - else if (tag == "V3B") { - tagType = ::InputType::tag::V3B; - } - else if (tag == "V4B") { - tagType = ::InputType::tag::V4B; - } - else if (tag == "Word") { - tagType = ::InputType::tag::Word; - } - else if (tag == "V2U") { - tagType = ::InputType::tag::V2U; - } - else if (tag == "V3U") { - tagType = ::InputType::tag::V3U; - } - else if (tag == "V4U") { - tagType = ::InputType::tag::V4U; - } - else if (tag == "Int") { - tagType = ::InputType::tag::Int; - } - else if (tag == "V2I") { - tagType = ::InputType::tag::V2I; - } - else if (tag == "V3I") { - tagType = ::InputType::tag::V3I; - } - else if (tag == "V4I") { - tagType = ::InputType::tag::V4I; - } - else if (tag == "Float") { - tagType = ::InputType::tag::Float; - } - else if (tag == "V2F") { - tagType = ::InputType::tag::V2F; - } - else if (tag == "V3F") { - tagType = ::InputType::tag::V3F; - } - else if (tag == "V4F") { - tagType = ::InputType::tag::V4F; - } - else if (tag == "M22F") { - tagType = ::InputType::tag::M22F; - } - else if (tag == "M23F") { - tagType = ::InputType::tag::M23F; - } - else if (tag == "M24F") { - tagType = ::InputType::tag::M24F; - } - else if (tag == "M32F") { - tagType = ::InputType::tag::M32F; - } - else if (tag == "M33F") { - tagType = ::InputType::tag::M33F; - } - else if (tag == "M34F") { - tagType = ::InputType::tag::M34F; - } - else if (tag == "M42F") { - tagType = ::InputType::tag::M42F; - } - else if (tag == "M43F") { - tagType = ::InputType::tag::M43F; - } - else if (tag == "M44F") { - tagType = ::InputType::tag::M44F; - } - else if (tag == "STexture1D") { - tagType = ::InputType::tag::STexture1D; - } - else if (tag == "STexture2D") { - tagType = ::InputType::tag::STexture2D; - } - else if (tag == "STextureCube") { - tagType = ::InputType::tag::STextureCube; - } - else if (tag == "STexture1DArray") { - tagType = ::InputType::tag::STexture1DArray; - } - else if (tag == "STexture2DArray") { - tagType = ::InputType::tag::STexture2DArray; - } - else if (tag == "STexture2DRect") { - tagType = ::InputType::tag::STexture2DRect; - } - else if (tag == "FTexture1D") { - tagType = ::InputType::tag::FTexture1D; - } - else if (tag == "FTexture2D") { - tagType = ::InputType::tag::FTexture2D; - } - else if (tag == "FTexture3D") { - tagType = ::InputType::tag::FTexture3D; - } - else if (tag == "FTextureCube") { - tagType = ::InputType::tag::FTextureCube; - } - else if (tag == "FTexture1DArray") { - tagType = ::InputType::tag::FTexture1DArray; - } - else if (tag == "FTexture2DArray") { - tagType = ::InputType::tag::FTexture2DArray; - } - else if (tag == "FTexture2DMS") { - tagType = ::InputType::tag::FTexture2DMS; - } - else if (tag == "FTexture2DMSArray") { - tagType = ::InputType::tag::FTexture2DMSArray; - } - else if (tag == "FTextureBuffer") { - tagType = ::InputType::tag::FTextureBuffer; - } - else if (tag == "FTexture2DRect") { - tagType = ::InputType::tag::FTexture2DRect; - } - else if (tag == "ITexture1D") { - tagType = ::InputType::tag::ITexture1D; - } - else if (tag == "ITexture2D") { - tagType = ::InputType::tag::ITexture2D; - } - else if (tag == "ITexture3D") { - tagType = ::InputType::tag::ITexture3D; - } - else if (tag == "ITextureCube") { - tagType = ::InputType::tag::ITextureCube; - } - else if (tag == "ITexture1DArray") { - tagType = ::InputType::tag::ITexture1DArray; - } - else if (tag == "ITexture2DArray") { - tagType = ::InputType::tag::ITexture2DArray; - } - else if (tag == "ITexture2DMS") { - tagType = ::InputType::tag::ITexture2DMS; - } - else if (tag == "ITexture2DMSArray") { - tagType = ::InputType::tag::ITexture2DMSArray; - } - else if (tag == "ITextureBuffer") { - tagType = ::InputType::tag::ITextureBuffer; - } - else if (tag == "ITexture2DRect") { - tagType = ::InputType::tag::ITexture2DRect; - } - else if (tag == "UTexture1D") { - tagType = ::InputType::tag::UTexture1D; - } - else if (tag == "UTexture2D") { - tagType = ::InputType::tag::UTexture2D; - } - else if (tag == "UTexture3D") { - tagType = ::InputType::tag::UTexture3D; - } - else if (tag == "UTextureCube") { - tagType = ::InputType::tag::UTextureCube; - } - else if (tag == "UTexture1DArray") { - tagType = ::InputType::tag::UTexture1DArray; - } - else if (tag == "UTexture2DArray") { - tagType = ::InputType::tag::UTexture2DArray; - } - else if (tag == "UTexture2DMS") { - tagType = ::InputType::tag::UTexture2DMS; - } - else if (tag == "UTexture2DMSArray") { - tagType = ::InputType::tag::UTexture2DMSArray; - } - else if (tag == "UTextureBuffer") { - tagType = ::InputType::tag::UTextureBuffer; - } - else if (tag == "UTexture2DRect") { - tagType = ::InputType::tag::UTexture2DRect; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::InputType> o(new ::InputType()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::PointSpriteCoordOrigin::tag::LowerLeft: - obj["tag"] = "LowerLeft"; - break; - case ::PointSpriteCoordOrigin::tag::UpperLeft: - obj["tag"] = "UpperLeft"; - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::PointSpriteCoordOrigin::tag tagType; - std::string tag = obj["tag"]; - if (tag == "LowerLeft") { - tagType = ::PointSpriteCoordOrigin::tag::LowerLeft; - } - else if (tag == "UpperLeft") { - tagType = ::PointSpriteCoordOrigin::tag::UpperLeft; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::PointSpriteCoordOrigin> o(new ::PointSpriteCoordOrigin()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::PointSize::tag::PointSize: - obj["tag"] = "PointSize"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::PointSize::tag::ProgramPointSize: - obj["tag"] = "ProgramPointSize"; - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::PointSize::tag tagType; - std::string tag = obj["tag"]; - if (tag == "PointSize") { - tagType = ::PointSize::tag::PointSize; - std::shared_ptr tv(new data::PointSize()); - tv->_0 = fromJSON(W(), obj["arg0"]); - return tv; - } - else if (tag == "ProgramPointSize") { - tagType = ::PointSize::tag::ProgramPointSize; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::PointSize> o(new ::PointSize()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::PolygonOffset::tag::NoOffset: - obj["tag"] = "NoOffset"; - break; - case ::PolygonOffset::tag::Offset: - obj["tag"] = "Offset"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - obj["arg1"] = toJSON(tv->_1); - } - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::PolygonOffset::tag tagType; - std::string tag = obj["tag"]; - if (tag == "NoOffset") { - tagType = ::PolygonOffset::tag::NoOffset; - } - else if (tag == "Offset") { - tagType = ::PolygonOffset::tag::Offset; - std::shared_ptr tv(new data::Offset()); - tv->_0 = fromJSON(W(), obj["arg0"]); - tv->_1 = fromJSON(W(), obj["arg1"]); - return tv; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::PolygonOffset> o(new ::PolygonOffset()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::FrontFace::tag::CCW: - obj["tag"] = "CCW"; - break; - case ::FrontFace::tag::CW: - obj["tag"] = "CW"; - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::FrontFace::tag tagType; - std::string tag = obj["tag"]; - if (tag == "CCW") { - tagType = ::FrontFace::tag::CCW; - } - else if (tag == "CW") { - tagType = ::FrontFace::tag::CW; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::FrontFace> o(new ::FrontFace()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::PolygonMode::tag::PolygonPoint: - obj["tag"] = "PolygonPoint"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::PolygonMode::tag::PolygonLine: - obj["tag"] = "PolygonLine"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::PolygonMode::tag::PolygonFill: - obj["tag"] = "PolygonFill"; - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::PolygonMode::tag tagType; - std::string tag = obj["tag"]; - if (tag == "PolygonPoint") { - tagType = ::PolygonMode::tag::PolygonPoint; - std::shared_ptr tv(new data::PolygonPoint()); - tv->_0 = fromJSON(W>(), obj["arg0"]); - return tv; - } - else if (tag == "PolygonLine") { - tagType = ::PolygonMode::tag::PolygonLine; - std::shared_ptr tv(new data::PolygonLine()); - tv->_0 = fromJSON(W(), obj["arg0"]); - return tv; - } - else if (tag == "PolygonFill") { - tagType = ::PolygonMode::tag::PolygonFill; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::PolygonMode> o(new ::PolygonMode()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::ProvokingVertex::tag::FirstVertex: - obj["tag"] = "FirstVertex"; - break; - case ::ProvokingVertex::tag::LastVertex: - obj["tag"] = "LastVertex"; - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::ProvokingVertex::tag tagType; - std::string tag = obj["tag"]; - if (tag == "FirstVertex") { - tagType = ::ProvokingVertex::tag::FirstVertex; - } - else if (tag == "LastVertex") { - tagType = ::ProvokingVertex::tag::LastVertex; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::ProvokingVertex> o(new ::ProvokingVertex()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::CullMode::tag::CullNone: - obj["tag"] = "CullNone"; - break; - case ::CullMode::tag::CullFront: - obj["tag"] = "CullFront"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::CullMode::tag::CullBack: - obj["tag"] = "CullBack"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::CullMode::tag tagType; - std::string tag = obj["tag"]; - if (tag == "CullNone") { - tagType = ::CullMode::tag::CullNone; - } - else if (tag == "CullFront") { - tagType = ::CullMode::tag::CullFront; - std::shared_ptr tv(new data::CullFront()); - tv->_0 = fromJSON(W>(), obj["arg0"]); - return tv; - } - else if (tag == "CullBack") { - tagType = ::CullMode::tag::CullBack; - std::shared_ptr tv(new data::CullBack()); - tv->_0 = fromJSON(W>(), obj["arg0"]); - return tv; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::CullMode> o(new ::CullMode()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::ComparisonFunction::tag::Never: - obj["tag"] = "Never"; - break; - case ::ComparisonFunction::tag::Less: - obj["tag"] = "Less"; - break; - case ::ComparisonFunction::tag::Equal: - obj["tag"] = "Equal"; - break; - case ::ComparisonFunction::tag::Lequal: - obj["tag"] = "Lequal"; - break; - case ::ComparisonFunction::tag::Greater: - obj["tag"] = "Greater"; - break; - case ::ComparisonFunction::tag::Notequal: - obj["tag"] = "Notequal"; - break; - case ::ComparisonFunction::tag::Gequal: - obj["tag"] = "Gequal"; - break; - case ::ComparisonFunction::tag::Always: - obj["tag"] = "Always"; - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::ComparisonFunction::tag tagType; - std::string tag = obj["tag"]; - if (tag == "Never") { - tagType = ::ComparisonFunction::tag::Never; - } - else if (tag == "Less") { - tagType = ::ComparisonFunction::tag::Less; - } - else if (tag == "Equal") { - tagType = ::ComparisonFunction::tag::Equal; - } - else if (tag == "Lequal") { - tagType = ::ComparisonFunction::tag::Lequal; - } - else if (tag == "Greater") { - tagType = ::ComparisonFunction::tag::Greater; - } - else if (tag == "Notequal") { - tagType = ::ComparisonFunction::tag::Notequal; - } - else if (tag == "Gequal") { - tagType = ::ComparisonFunction::tag::Gequal; - } - else if (tag == "Always") { - tagType = ::ComparisonFunction::tag::Always; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::ComparisonFunction> o(new ::ComparisonFunction()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::StencilOperation::tag::OpZero: - obj["tag"] = "OpZero"; - break; - case ::StencilOperation::tag::OpKeep: - obj["tag"] = "OpKeep"; - break; - case ::StencilOperation::tag::OpReplace: - obj["tag"] = "OpReplace"; - break; - case ::StencilOperation::tag::OpIncr: - obj["tag"] = "OpIncr"; - break; - case ::StencilOperation::tag::OpIncrWrap: - obj["tag"] = "OpIncrWrap"; - break; - case ::StencilOperation::tag::OpDecr: - obj["tag"] = "OpDecr"; - break; - case ::StencilOperation::tag::OpDecrWrap: - obj["tag"] = "OpDecrWrap"; - break; - case ::StencilOperation::tag::OpInvert: - obj["tag"] = "OpInvert"; - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::StencilOperation::tag tagType; - std::string tag = obj["tag"]; - if (tag == "OpZero") { - tagType = ::StencilOperation::tag::OpZero; - } - else if (tag == "OpKeep") { - tagType = ::StencilOperation::tag::OpKeep; - } - else if (tag == "OpReplace") { - tagType = ::StencilOperation::tag::OpReplace; - } - else if (tag == "OpIncr") { - tagType = ::StencilOperation::tag::OpIncr; - } - else if (tag == "OpIncrWrap") { - tagType = ::StencilOperation::tag::OpIncrWrap; - } - else if (tag == "OpDecr") { - tagType = ::StencilOperation::tag::OpDecr; - } - else if (tag == "OpDecrWrap") { - tagType = ::StencilOperation::tag::OpDecrWrap; - } - else if (tag == "OpInvert") { - tagType = ::StencilOperation::tag::OpInvert; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::StencilOperation> o(new ::StencilOperation()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::BlendEquation::tag::FuncAdd: - obj["tag"] = "FuncAdd"; - break; - case ::BlendEquation::tag::FuncSubtract: - obj["tag"] = "FuncSubtract"; - break; - case ::BlendEquation::tag::FuncReverseSubtract: - obj["tag"] = "FuncReverseSubtract"; - break; - case ::BlendEquation::tag::Min: - obj["tag"] = "Min"; - break; - case ::BlendEquation::tag::Max: - obj["tag"] = "Max"; - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::BlendEquation::tag tagType; - std::string tag = obj["tag"]; - if (tag == "FuncAdd") { - tagType = ::BlendEquation::tag::FuncAdd; - } - else if (tag == "FuncSubtract") { - tagType = ::BlendEquation::tag::FuncSubtract; - } - else if (tag == "FuncReverseSubtract") { - tagType = ::BlendEquation::tag::FuncReverseSubtract; - } - else if (tag == "Min") { - tagType = ::BlendEquation::tag::Min; - } - else if (tag == "Max") { - tagType = ::BlendEquation::tag::Max; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::BlendEquation> o(new ::BlendEquation()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::BlendingFactor::tag::Zero: - obj["tag"] = "Zero"; - break; - case ::BlendingFactor::tag::One: - obj["tag"] = "One"; - break; - case ::BlendingFactor::tag::SrcColor: - obj["tag"] = "SrcColor"; - break; - case ::BlendingFactor::tag::OneMinusSrcColor: - obj["tag"] = "OneMinusSrcColor"; - break; - case ::BlendingFactor::tag::DstColor: - obj["tag"] = "DstColor"; - break; - case ::BlendingFactor::tag::OneMinusDstColor: - obj["tag"] = "OneMinusDstColor"; - break; - case ::BlendingFactor::tag::SrcAlpha: - obj["tag"] = "SrcAlpha"; - break; - case ::BlendingFactor::tag::OneMinusSrcAlpha: - obj["tag"] = "OneMinusSrcAlpha"; - break; - case ::BlendingFactor::tag::DstAlpha: - obj["tag"] = "DstAlpha"; - break; - case ::BlendingFactor::tag::OneMinusDstAlpha: - obj["tag"] = "OneMinusDstAlpha"; - break; - case ::BlendingFactor::tag::ConstantColor: - obj["tag"] = "ConstantColor"; - break; - case ::BlendingFactor::tag::OneMinusConstantColor: - obj["tag"] = "OneMinusConstantColor"; - break; - case ::BlendingFactor::tag::ConstantAlpha: - obj["tag"] = "ConstantAlpha"; - break; - case ::BlendingFactor::tag::OneMinusConstantAlpha: - obj["tag"] = "OneMinusConstantAlpha"; - break; - case ::BlendingFactor::tag::SrcAlphaSaturate: - obj["tag"] = "SrcAlphaSaturate"; - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::BlendingFactor::tag tagType; - std::string tag = obj["tag"]; - if (tag == "Zero") { - tagType = ::BlendingFactor::tag::Zero; - } - else if (tag == "One") { - tagType = ::BlendingFactor::tag::One; - } - else if (tag == "SrcColor") { - tagType = ::BlendingFactor::tag::SrcColor; - } - else if (tag == "OneMinusSrcColor") { - tagType = ::BlendingFactor::tag::OneMinusSrcColor; - } - else if (tag == "DstColor") { - tagType = ::BlendingFactor::tag::DstColor; - } - else if (tag == "OneMinusDstColor") { - tagType = ::BlendingFactor::tag::OneMinusDstColor; - } - else if (tag == "SrcAlpha") { - tagType = ::BlendingFactor::tag::SrcAlpha; - } - else if (tag == "OneMinusSrcAlpha") { - tagType = ::BlendingFactor::tag::OneMinusSrcAlpha; - } - else if (tag == "DstAlpha") { - tagType = ::BlendingFactor::tag::DstAlpha; - } - else if (tag == "OneMinusDstAlpha") { - tagType = ::BlendingFactor::tag::OneMinusDstAlpha; - } - else if (tag == "ConstantColor") { - tagType = ::BlendingFactor::tag::ConstantColor; - } - else if (tag == "OneMinusConstantColor") { - tagType = ::BlendingFactor::tag::OneMinusConstantColor; - } - else if (tag == "ConstantAlpha") { - tagType = ::BlendingFactor::tag::ConstantAlpha; - } - else if (tag == "OneMinusConstantAlpha") { - tagType = ::BlendingFactor::tag::OneMinusConstantAlpha; - } - else if (tag == "SrcAlphaSaturate") { - tagType = ::BlendingFactor::tag::SrcAlphaSaturate; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::BlendingFactor> o(new ::BlendingFactor()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::LogicOperation::tag::Clear: - obj["tag"] = "Clear"; - break; - case ::LogicOperation::tag::And: - obj["tag"] = "And"; - break; - case ::LogicOperation::tag::AndReverse: - obj["tag"] = "AndReverse"; - break; - case ::LogicOperation::tag::Copy: - obj["tag"] = "Copy"; - break; - case ::LogicOperation::tag::AndInverted: - obj["tag"] = "AndInverted"; - break; - case ::LogicOperation::tag::Noop: - obj["tag"] = "Noop"; - break; - case ::LogicOperation::tag::Xor: - obj["tag"] = "Xor"; - break; - case ::LogicOperation::tag::Or: - obj["tag"] = "Or"; - break; - case ::LogicOperation::tag::Nor: - obj["tag"] = "Nor"; - break; - case ::LogicOperation::tag::Equiv: - obj["tag"] = "Equiv"; - break; - case ::LogicOperation::tag::Invert: - obj["tag"] = "Invert"; - break; - case ::LogicOperation::tag::OrReverse: - obj["tag"] = "OrReverse"; - break; - case ::LogicOperation::tag::CopyInverted: - obj["tag"] = "CopyInverted"; - break; - case ::LogicOperation::tag::OrInverted: - obj["tag"] = "OrInverted"; - break; - case ::LogicOperation::tag::Nand: - obj["tag"] = "Nand"; - break; - case ::LogicOperation::tag::Set: - obj["tag"] = "Set"; - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::LogicOperation::tag tagType; - std::string tag = obj["tag"]; - if (tag == "Clear") { - tagType = ::LogicOperation::tag::Clear; - } - else if (tag == "And") { - tagType = ::LogicOperation::tag::And; - } - else if (tag == "AndReverse") { - tagType = ::LogicOperation::tag::AndReverse; - } - else if (tag == "Copy") { - tagType = ::LogicOperation::tag::Copy; - } - else if (tag == "AndInverted") { - tagType = ::LogicOperation::tag::AndInverted; - } - else if (tag == "Noop") { - tagType = ::LogicOperation::tag::Noop; - } - else if (tag == "Xor") { - tagType = ::LogicOperation::tag::Xor; - } - else if (tag == "Or") { - tagType = ::LogicOperation::tag::Or; - } - else if (tag == "Nor") { - tagType = ::LogicOperation::tag::Nor; - } - else if (tag == "Equiv") { - tagType = ::LogicOperation::tag::Equiv; - } - else if (tag == "Invert") { - tagType = ::LogicOperation::tag::Invert; - } - else if (tag == "OrReverse") { - tagType = ::LogicOperation::tag::OrReverse; - } - else if (tag == "CopyInverted") { - tagType = ::LogicOperation::tag::CopyInverted; - } - else if (tag == "OrInverted") { - tagType = ::LogicOperation::tag::OrInverted; - } - else if (tag == "Nand") { - tagType = ::LogicOperation::tag::Nand; - } - else if (tag == "Set") { - tagType = ::LogicOperation::tag::Set; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::LogicOperation> o(new ::LogicOperation()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::StencilOps::tag::StencilOps: - obj["tag"] = "StencilOps"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["frontStencilOp"] = toJSON(tv->frontStencilOp); - obj["backStencilOp"] = toJSON(tv->backStencilOp); - } - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::StencilOps::tag tagType; - std::string tag = obj["tag"]; - if (tag == "StencilOps") { - tagType = ::StencilOps::tag::StencilOps; - std::shared_ptr tv(new data::StencilOps()); - tv->frontStencilOp = fromJSON(W>(), obj["frontStencilOp"]); - tv->backStencilOp = fromJSON(W>(), obj["backStencilOp"]); - return tv; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::StencilOps> o(new ::StencilOps()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::StencilTest::tag::StencilTest: - obj["tag"] = "StencilTest"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["stencilComparision"] = toJSON(tv->stencilComparision); - obj["stencilReference"] = toJSON(tv->stencilReference); - obj["stencilMask"] = toJSON(tv->stencilMask); - } - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::StencilTest::tag tagType; - std::string tag = obj["tag"]; - if (tag == "StencilTest") { - tagType = ::StencilTest::tag::StencilTest; - std::shared_ptr tv(new data::StencilTest()); - tv->stencilComparision = fromJSON(W>(), obj["stencilComparision"]); - tv->stencilReference = fromJSON(W(), obj["stencilReference"]); - tv->stencilMask = fromJSON(W(), obj["stencilMask"]); - return tv; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::StencilTest> o(new ::StencilTest()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::StencilTests::tag::StencilTests: - obj["tag"] = "StencilTests"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - obj["arg1"] = toJSON(tv->_1); - } - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::StencilTests::tag tagType; - std::string tag = obj["tag"]; - if (tag == "StencilTests") { - tagType = ::StencilTests::tag::StencilTests; - std::shared_ptr tv(new data::StencilTests()); - tv->_0 = fromJSON(W>(), obj["arg0"]); - tv->_1 = fromJSON(W>(), obj["arg1"]); - return tv; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::StencilTests> o(new ::StencilTests()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::FetchPrimitive::tag::Points: - obj["tag"] = "Points"; - break; - case ::FetchPrimitive::tag::Lines: - obj["tag"] = "Lines"; - break; - case ::FetchPrimitive::tag::Triangles: - obj["tag"] = "Triangles"; - break; - case ::FetchPrimitive::tag::LinesAdjacency: - obj["tag"] = "LinesAdjacency"; - break; - case ::FetchPrimitive::tag::TrianglesAdjacency: - obj["tag"] = "TrianglesAdjacency"; - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::FetchPrimitive::tag tagType; - std::string tag = obj["tag"]; - if (tag == "Points") { - tagType = ::FetchPrimitive::tag::Points; - } - else if (tag == "Lines") { - tagType = ::FetchPrimitive::tag::Lines; - } - else if (tag == "Triangles") { - tagType = ::FetchPrimitive::tag::Triangles; - } - else if (tag == "LinesAdjacency") { - tagType = ::FetchPrimitive::tag::LinesAdjacency; - } - else if (tag == "TrianglesAdjacency") { - tagType = ::FetchPrimitive::tag::TrianglesAdjacency; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::FetchPrimitive> o(new ::FetchPrimitive()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::OutputPrimitive::tag::TrianglesOutput: - obj["tag"] = "TrianglesOutput"; - break; - case ::OutputPrimitive::tag::LinesOutput: - obj["tag"] = "LinesOutput"; - break; - case ::OutputPrimitive::tag::PointsOutput: - obj["tag"] = "PointsOutput"; - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::OutputPrimitive::tag tagType; - std::string tag = obj["tag"]; - if (tag == "TrianglesOutput") { - tagType = ::OutputPrimitive::tag::TrianglesOutput; - } - else if (tag == "LinesOutput") { - tagType = ::OutputPrimitive::tag::LinesOutput; - } - else if (tag == "PointsOutput") { - tagType = ::OutputPrimitive::tag::PointsOutput; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::OutputPrimitive> o(new ::OutputPrimitive()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::ColorArity::tag::Red: - obj["tag"] = "Red"; - break; - case ::ColorArity::tag::RG: - obj["tag"] = "RG"; - break; - case ::ColorArity::tag::RGB: - obj["tag"] = "RGB"; - break; - case ::ColorArity::tag::RGBA: - obj["tag"] = "RGBA"; - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::ColorArity::tag tagType; - std::string tag = obj["tag"]; - if (tag == "Red") { - tagType = ::ColorArity::tag::Red; - } - else if (tag == "RG") { - tagType = ::ColorArity::tag::RG; - } - else if (tag == "RGB") { - tagType = ::ColorArity::tag::RGB; - } - else if (tag == "RGBA") { - tagType = ::ColorArity::tag::RGBA; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::ColorArity> o(new ::ColorArity()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::Blending::tag::NoBlending: - obj["tag"] = "NoBlending"; - break; - case ::Blending::tag::BlendLogicOp: - obj["tag"] = "BlendLogicOp"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::Blending::tag::Blend: - obj["tag"] = "Blend"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["colorEqSrc"] = toJSON(tv->colorEqSrc); - obj["alphaEqSrc"] = toJSON(tv->alphaEqSrc); - obj["colorFSrc"] = toJSON(tv->colorFSrc); - obj["colorFDst"] = toJSON(tv->colorFDst); - obj["alphaFSrc"] = toJSON(tv->alphaFSrc); - obj["alphaFDst"] = toJSON(tv->alphaFDst); - obj["color"] = toJSON(tv->color); - } - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::Blending::tag tagType; - std::string tag = obj["tag"]; - if (tag == "NoBlending") { - tagType = ::Blending::tag::NoBlending; - } - else if (tag == "BlendLogicOp") { - tagType = ::Blending::tag::BlendLogicOp; - std::shared_ptr tv(new data::BlendLogicOp()); - tv->_0 = fromJSON(W>(), obj["arg0"]); - return tv; - } - else if (tag == "Blend") { - tagType = ::Blending::tag::Blend; - std::shared_ptr tv(new data::Blend()); - tv->colorEqSrc = fromJSON(W>(), obj["colorEqSrc"]); - tv->alphaEqSrc = fromJSON(W>(), obj["alphaEqSrc"]); - tv->colorFSrc = fromJSON(W>(), obj["colorFSrc"]); - tv->colorFDst = fromJSON(W>(), obj["colorFDst"]); - tv->alphaFSrc = fromJSON(W>(), obj["alphaFSrc"]); - tv->alphaFDst = fromJSON(W>(), obj["alphaFDst"]); - tv->color = fromJSON(W(), obj["color"]); - return tv; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::Blending> o(new ::Blending()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::RasterContext::tag::PointCtx: - obj["tag"] = "PointCtx"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - obj["arg1"] = toJSON(tv->_1); - obj["arg2"] = toJSON(tv->_2); - } - break; - case ::RasterContext::tag::LineCtx: - obj["tag"] = "LineCtx"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - obj["arg1"] = toJSON(tv->_1); - } - break; - case ::RasterContext::tag::TriangleCtx: - obj["tag"] = "TriangleCtx"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - obj["arg1"] = toJSON(tv->_1); - obj["arg2"] = toJSON(tv->_2); - obj["arg3"] = toJSON(tv->_3); - } - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::RasterContext::tag tagType; - std::string tag = obj["tag"]; - if (tag == "PointCtx") { - tagType = ::RasterContext::tag::PointCtx; - std::shared_ptr tv(new data::PointCtx()); - tv->_0 = fromJSON(W>(), obj["arg0"]); - tv->_1 = fromJSON(W(), obj["arg1"]); - tv->_2 = fromJSON(W>(), obj["arg2"]); - return tv; - } - else if (tag == "LineCtx") { - tagType = ::RasterContext::tag::LineCtx; - std::shared_ptr tv(new data::LineCtx()); - tv->_0 = fromJSON(W(), obj["arg0"]); - tv->_1 = fromJSON(W>(), obj["arg1"]); - return tv; - } - else if (tag == "TriangleCtx") { - tagType = ::RasterContext::tag::TriangleCtx; - std::shared_ptr tv(new data::TriangleCtx()); - tv->_0 = fromJSON(W>(), obj["arg0"]); - tv->_1 = fromJSON(W>(), obj["arg1"]); - tv->_2 = fromJSON(W>(), obj["arg2"]); - tv->_3 = fromJSON(W>(), obj["arg3"]); - return tv; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::RasterContext> o(new ::RasterContext()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::FragmentOperation::tag::DepthOp: - obj["tag"] = "DepthOp"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - obj["arg1"] = toJSON(tv->_1); - } - break; - case ::FragmentOperation::tag::StencilOp: - obj["tag"] = "StencilOp"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - obj["arg1"] = toJSON(tv->_1); - obj["arg2"] = toJSON(tv->_2); - } - break; - case ::FragmentOperation::tag::ColorOp: - obj["tag"] = "ColorOp"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - obj["arg1"] = toJSON(tv->_1); - } - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::FragmentOperation::tag tagType; - std::string tag = obj["tag"]; - if (tag == "DepthOp") { - tagType = ::FragmentOperation::tag::DepthOp; - std::shared_ptr tv(new data::DepthOp()); - tv->_0 = fromJSON(W>(), obj["arg0"]); - tv->_1 = fromJSON(W(), obj["arg1"]); - return tv; - } - else if (tag == "StencilOp") { - tagType = ::FragmentOperation::tag::StencilOp; - std::shared_ptr tv(new data::StencilOp()); - tv->_0 = fromJSON(W>(), obj["arg0"]); - tv->_1 = fromJSON(W>(), obj["arg1"]); - tv->_2 = fromJSON(W>(), obj["arg2"]); - return tv; - } - else if (tag == "ColorOp") { - tagType = ::FragmentOperation::tag::ColorOp; - std::shared_ptr tv(new data::ColorOp()); - tv->_0 = fromJSON(W>(), obj["arg0"]); - tv->_1 = fromJSON(W>(), obj["arg1"]); - return tv; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::FragmentOperation> o(new ::FragmentOperation()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::AccumulationContext::tag::AccumulationContext: - obj["tag"] = "AccumulationContext"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["accViewportName"] = toJSON(tv->accViewportName); - obj["accOperations"] = toJSON(tv->accOperations); - } - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::AccumulationContext::tag tagType; - std::string tag = obj["tag"]; - if (tag == "AccumulationContext") { - tagType = ::AccumulationContext::tag::AccumulationContext; - std::shared_ptr tv(new data::AccumulationContext()); - tv->accViewportName = fromJSON(W>(), obj["accViewportName"]); - tv->accOperations = fromJSON(W>>(), obj["accOperations"]); - return tv; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::AccumulationContext> o(new ::AccumulationContext()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::TextureDataType::tag::FloatT: - obj["tag"] = "FloatT"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::TextureDataType::tag::IntT: - obj["tag"] = "IntT"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::TextureDataType::tag::WordT: - obj["tag"] = "WordT"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::TextureDataType::tag::ShadowT: - obj["tag"] = "ShadowT"; - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::TextureDataType::tag tagType; - std::string tag = obj["tag"]; - if (tag == "FloatT") { - tagType = ::TextureDataType::tag::FloatT; - std::shared_ptr tv(new data::FloatT()); - tv->_0 = fromJSON(W>(), obj["arg0"]); - return tv; - } - else if (tag == "IntT") { - tagType = ::TextureDataType::tag::IntT; - std::shared_ptr tv(new data::IntT()); - tv->_0 = fromJSON(W>(), obj["arg0"]); - return tv; - } - else if (tag == "WordT") { - tagType = ::TextureDataType::tag::WordT; - std::shared_ptr tv(new data::WordT()); - tv->_0 = fromJSON(W>(), obj["arg0"]); - return tv; - } - else if (tag == "ShadowT") { - tagType = ::TextureDataType::tag::ShadowT; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::TextureDataType> o(new ::TextureDataType()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::TextureType::tag::Texture1D: - obj["tag"] = "Texture1D"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - obj["arg1"] = toJSON(tv->_1); - } - break; - case ::TextureType::tag::Texture2D: - obj["tag"] = "Texture2D"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - obj["arg1"] = toJSON(tv->_1); - } - break; - case ::TextureType::tag::Texture3D: - obj["tag"] = "Texture3D"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::TextureType::tag::TextureCube: - obj["tag"] = "TextureCube"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::TextureType::tag::TextureRect: - obj["tag"] = "TextureRect"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::TextureType::tag::Texture2DMS: - obj["tag"] = "Texture2DMS"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - obj["arg1"] = toJSON(tv->_1); - obj["arg2"] = toJSON(tv->_2); - obj["arg3"] = toJSON(tv->_3); - } - break; - case ::TextureType::tag::TextureBuffer: - obj["tag"] = "TextureBuffer"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::TextureType::tag tagType; - std::string tag = obj["tag"]; - if (tag == "Texture1D") { - tagType = ::TextureType::tag::Texture1D; - std::shared_ptr tv(new data::Texture1D()); - tv->_0 = fromJSON(W>(), obj["arg0"]); - tv->_1 = fromJSON(W(), obj["arg1"]); - return tv; - } - else if (tag == "Texture2D") { - tagType = ::TextureType::tag::Texture2D; - std::shared_ptr tv(new data::Texture2D()); - tv->_0 = fromJSON(W>(), obj["arg0"]); - tv->_1 = fromJSON(W(), obj["arg1"]); - return tv; - } - else if (tag == "Texture3D") { - tagType = ::TextureType::tag::Texture3D; - std::shared_ptr tv(new data::Texture3D()); - tv->_0 = fromJSON(W>(), obj["arg0"]); - return tv; - } - else if (tag == "TextureCube") { - tagType = ::TextureType::tag::TextureCube; - std::shared_ptr tv(new data::TextureCube()); - tv->_0 = fromJSON(W>(), obj["arg0"]); - return tv; - } - else if (tag == "TextureRect") { - tagType = ::TextureType::tag::TextureRect; - std::shared_ptr tv(new data::TextureRect()); - tv->_0 = fromJSON(W>(), obj["arg0"]); - return tv; - } - else if (tag == "Texture2DMS") { - tagType = ::TextureType::tag::Texture2DMS; - std::shared_ptr tv(new data::Texture2DMS()); - tv->_0 = fromJSON(W>(), obj["arg0"]); - tv->_1 = fromJSON(W(), obj["arg1"]); - tv->_2 = fromJSON(W(), obj["arg2"]); - tv->_3 = fromJSON(W(), obj["arg3"]); - return tv; - } - else if (tag == "TextureBuffer") { - tagType = ::TextureType::tag::TextureBuffer; - std::shared_ptr tv(new data::TextureBuffer()); - tv->_0 = fromJSON(W>(), obj["arg0"]); - return tv; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::TextureType> o(new ::TextureType()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::MipMap::tag::Mip: - obj["tag"] = "Mip"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - obj["arg1"] = toJSON(tv->_1); - } - break; - case ::MipMap::tag::NoMip: - obj["tag"] = "NoMip"; - break; - case ::MipMap::tag::AutoMip: - obj["tag"] = "AutoMip"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - obj["arg1"] = toJSON(tv->_1); - } - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::MipMap::tag tagType; - std::string tag = obj["tag"]; - if (tag == "Mip") { - tagType = ::MipMap::tag::Mip; - std::shared_ptr tv(new data::Mip()); - tv->_0 = fromJSON(W(), obj["arg0"]); - tv->_1 = fromJSON(W(), obj["arg1"]); - return tv; - } - else if (tag == "NoMip") { - tagType = ::MipMap::tag::NoMip; - } - else if (tag == "AutoMip") { - tagType = ::MipMap::tag::AutoMip; - std::shared_ptr tv(new data::AutoMip()); - tv->_0 = fromJSON(W(), obj["arg0"]); - tv->_1 = fromJSON(W(), obj["arg1"]); - return tv; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::MipMap> o(new ::MipMap()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::Filter::tag::Nearest: - obj["tag"] = "Nearest"; - break; - case ::Filter::tag::Linear: - obj["tag"] = "Linear"; - break; - case ::Filter::tag::NearestMipmapNearest: - obj["tag"] = "NearestMipmapNearest"; - break; - case ::Filter::tag::NearestMipmapLinear: - obj["tag"] = "NearestMipmapLinear"; - break; - case ::Filter::tag::LinearMipmapNearest: - obj["tag"] = "LinearMipmapNearest"; - break; - case ::Filter::tag::LinearMipmapLinear: - obj["tag"] = "LinearMipmapLinear"; - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::Filter::tag tagType; - std::string tag = obj["tag"]; - if (tag == "Nearest") { - tagType = ::Filter::tag::Nearest; - } - else if (tag == "Linear") { - tagType = ::Filter::tag::Linear; - } - else if (tag == "NearestMipmapNearest") { - tagType = ::Filter::tag::NearestMipmapNearest; - } - else if (tag == "NearestMipmapLinear") { - tagType = ::Filter::tag::NearestMipmapLinear; - } - else if (tag == "LinearMipmapNearest") { - tagType = ::Filter::tag::LinearMipmapNearest; - } - else if (tag == "LinearMipmapLinear") { - tagType = ::Filter::tag::LinearMipmapLinear; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::Filter> o(new ::Filter()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::EdgeMode::tag::Repeat: - obj["tag"] = "Repeat"; - break; - case ::EdgeMode::tag::MirroredRepeat: - obj["tag"] = "MirroredRepeat"; - break; - case ::EdgeMode::tag::ClampToEdge: - obj["tag"] = "ClampToEdge"; - break; - case ::EdgeMode::tag::ClampToBorder: - obj["tag"] = "ClampToBorder"; - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::EdgeMode::tag tagType; - std::string tag = obj["tag"]; - if (tag == "Repeat") { - tagType = ::EdgeMode::tag::Repeat; - } - else if (tag == "MirroredRepeat") { - tagType = ::EdgeMode::tag::MirroredRepeat; - } - else if (tag == "ClampToEdge") { - tagType = ::EdgeMode::tag::ClampToEdge; - } - else if (tag == "ClampToBorder") { - tagType = ::EdgeMode::tag::ClampToBorder; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::EdgeMode> o(new ::EdgeMode()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::ImageSemantic::tag::Depth: - obj["tag"] = "Depth"; - break; - case ::ImageSemantic::tag::Stencil: - obj["tag"] = "Stencil"; - break; - case ::ImageSemantic::tag::Color: - obj["tag"] = "Color"; - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::ImageSemantic::tag tagType; - std::string tag = obj["tag"]; - if (tag == "Depth") { - tagType = ::ImageSemantic::tag::Depth; - } - else if (tag == "Stencil") { - tagType = ::ImageSemantic::tag::Stencil; - } - else if (tag == "Color") { - tagType = ::ImageSemantic::tag::Color; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::ImageSemantic> o(new ::ImageSemantic()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::ImageRef::tag::TextureImage: - obj["tag"] = "TextureImage"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - obj["arg1"] = toJSON(tv->_1); - obj["arg2"] = toJSON(tv->_2); - } - break; - case ::ImageRef::tag::Framebuffer: - obj["tag"] = "Framebuffer"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::ImageRef::tag tagType; - std::string tag = obj["tag"]; - if (tag == "TextureImage") { - tagType = ::ImageRef::tag::TextureImage; - std::shared_ptr tv(new data::TextureImage()); - tv->_0 = fromJSON(W<::TextureName>(), obj["arg0"]); - tv->_1 = fromJSON(W(), obj["arg1"]); - tv->_2 = fromJSON(W>(), obj["arg2"]); - return tv; - } - else if (tag == "Framebuffer") { - tagType = ::ImageRef::tag::Framebuffer; - std::shared_ptr tv(new data::Framebuffer()); - tv->_0 = fromJSON(W>(), obj["arg0"]); - return tv; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::ImageRef> o(new ::ImageRef()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::ClearImage::tag::ClearImage: - obj["tag"] = "ClearImage"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["imageSemantic"] = toJSON(tv->imageSemantic); - obj["clearValue"] = toJSON(tv->clearValue); - } - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::ClearImage::tag tagType; - std::string tag = obj["tag"]; - if (tag == "ClearImage") { - tagType = ::ClearImage::tag::ClearImage; - std::shared_ptr tv(new data::ClearImage()); - tv->imageSemantic = fromJSON(W>(), obj["imageSemantic"]); - tv->clearValue = fromJSON(W>(), obj["clearValue"]); - return tv; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::ClearImage> o(new ::ClearImage()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::Command::tag::SetRasterContext: - obj["tag"] = "SetRasterContext"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::Command::tag::SetAccumulationContext: - obj["tag"] = "SetAccumulationContext"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::Command::tag::SetRenderTarget: - obj["tag"] = "SetRenderTarget"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::Command::tag::SetProgram: - obj["tag"] = "SetProgram"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::Command::tag::SetSamplerUniform: - obj["tag"] = "SetSamplerUniform"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - obj["arg1"] = toJSON(tv->_1); - } - break; - case ::Command::tag::SetTexture: - obj["tag"] = "SetTexture"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - obj["arg1"] = toJSON(tv->_1); - } - break; - case ::Command::tag::SetSampler: - obj["tag"] = "SetSampler"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - obj["arg1"] = toJSON(tv->_1); - } - break; - case ::Command::tag::RenderSlot: - obj["tag"] = "RenderSlot"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::Command::tag::RenderStream: - obj["tag"] = "RenderStream"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::Command::tag::ClearRenderTarget: - obj["tag"] = "ClearRenderTarget"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::Command::tag::GenerateMipMap: - obj["tag"] = "GenerateMipMap"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::Command::tag::SaveImage: - obj["tag"] = "SaveImage"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - obj["arg1"] = toJSON(tv->_1); - } - break; - case ::Command::tag::LoadImage: - obj["tag"] = "LoadImage"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - obj["arg1"] = toJSON(tv->_1); - } - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::Command::tag tagType; - std::string tag = obj["tag"]; - if (tag == "SetRasterContext") { - tagType = ::Command::tag::SetRasterContext; - std::shared_ptr tv(new data::SetRasterContext()); - tv->_0 = fromJSON(W>(), obj["arg0"]); - return tv; - } - else if (tag == "SetAccumulationContext") { - tagType = ::Command::tag::SetAccumulationContext; - std::shared_ptr tv(new data::SetAccumulationContext()); - tv->_0 = fromJSON(W>(), obj["arg0"]); - return tv; - } - else if (tag == "SetRenderTarget") { - tagType = ::Command::tag::SetRenderTarget; - std::shared_ptr tv(new data::SetRenderTarget()); - tv->_0 = fromJSON(W<::RenderTargetName>(), obj["arg0"]); - return tv; - } - else if (tag == "SetProgram") { - tagType = ::Command::tag::SetProgram; - std::shared_ptr tv(new data::SetProgram()); - tv->_0 = fromJSON(W<::ProgramName>(), obj["arg0"]); - return tv; - } - else if (tag == "SetSamplerUniform") { - tagType = ::Command::tag::SetSamplerUniform; - std::shared_ptr tv(new data::SetSamplerUniform()); - tv->_0 = fromJSON(W<::UniformName>(), obj["arg0"]); - tv->_1 = fromJSON(W<::TextureUnit>(), obj["arg1"]); - return tv; - } - else if (tag == "SetTexture") { - tagType = ::Command::tag::SetTexture; - std::shared_ptr tv(new data::SetTexture()); - tv->_0 = fromJSON(W<::TextureUnit>(), obj["arg0"]); - tv->_1 = fromJSON(W<::TextureName>(), obj["arg1"]); - return tv; - } - else if (tag == "SetSampler") { - tagType = ::Command::tag::SetSampler; - std::shared_ptr tv(new data::SetSampler()); - tv->_0 = fromJSON(W<::TextureUnit>(), obj["arg0"]); - tv->_1 = fromJSON(W>(), obj["arg1"]); - return tv; - } - else if (tag == "RenderSlot") { - tagType = ::Command::tag::RenderSlot; - std::shared_ptr tv(new data::RenderSlot()); - tv->_0 = fromJSON(W<::SlotName>(), obj["arg0"]); - return tv; - } - else if (tag == "RenderStream") { - tagType = ::Command::tag::RenderStream; - std::shared_ptr tv(new data::RenderStream()); - tv->_0 = fromJSON(W<::StreamName>(), obj["arg0"]); - return tv; - } - else if (tag == "ClearRenderTarget") { - tagType = ::Command::tag::ClearRenderTarget; - std::shared_ptr tv(new data::ClearRenderTarget()); - tv->_0 = fromJSON(W>>(), obj["arg0"]); - return tv; - } - else if (tag == "GenerateMipMap") { - tagType = ::Command::tag::GenerateMipMap; - std::shared_ptr tv(new data::GenerateMipMap()); - tv->_0 = fromJSON(W<::TextureUnit>(), obj["arg0"]); - return tv; - } - else if (tag == "SaveImage") { - tagType = ::Command::tag::SaveImage; - std::shared_ptr tv(new data::SaveImage()); - tv->_0 = fromJSON(W<::FrameBufferComponent>(), obj["arg0"]); - tv->_1 = fromJSON(W>(), obj["arg1"]); - return tv; - } - else if (tag == "LoadImage") { - tagType = ::Command::tag::LoadImage; - std::shared_ptr tv(new data::LoadImage()); - tv->_0 = fromJSON(W>(), obj["arg0"]); - tv->_1 = fromJSON(W<::FrameBufferComponent>(), obj["arg1"]); - return tv; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::Command> o(new ::Command()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::SamplerDescriptor::tag::SamplerDescriptor: - obj["tag"] = "SamplerDescriptor"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["samplerWrapS"] = toJSON(tv->samplerWrapS); - obj["samplerWrapT"] = toJSON(tv->samplerWrapT); - obj["samplerWrapR"] = toJSON(tv->samplerWrapR); - obj["samplerMinFilter"] = toJSON(tv->samplerMinFilter); - obj["samplerMagFilter"] = toJSON(tv->samplerMagFilter); - obj["samplerBorderColor"] = toJSON(tv->samplerBorderColor); - obj["samplerMinLod"] = toJSON(tv->samplerMinLod); - obj["samplerMaxLod"] = toJSON(tv->samplerMaxLod); - obj["samplerLodBias"] = toJSON(tv->samplerLodBias); - obj["samplerCompareFunc"] = toJSON(tv->samplerCompareFunc); - } - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::SamplerDescriptor::tag tagType; - std::string tag = obj["tag"]; - if (tag == "SamplerDescriptor") { - tagType = ::SamplerDescriptor::tag::SamplerDescriptor; - std::shared_ptr tv(new data::SamplerDescriptor()); - tv->samplerWrapS = fromJSON(W>(), obj["samplerWrapS"]); - tv->samplerWrapT = fromJSON(W>>(), obj["samplerWrapT"]); - tv->samplerWrapR = fromJSON(W>>(), obj["samplerWrapR"]); - tv->samplerMinFilter = fromJSON(W>(), obj["samplerMinFilter"]); - tv->samplerMagFilter = fromJSON(W>(), obj["samplerMagFilter"]); - tv->samplerBorderColor = fromJSON(W>(), obj["samplerBorderColor"]); - tv->samplerMinLod = fromJSON(W>(), obj["samplerMinLod"]); - tv->samplerMaxLod = fromJSON(W>(), obj["samplerMaxLod"]); - tv->samplerLodBias = fromJSON(W(), obj["samplerLodBias"]); - tv->samplerCompareFunc = fromJSON(W>>(), obj["samplerCompareFunc"]); - return tv; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::SamplerDescriptor> o(new ::SamplerDescriptor()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::TextureDescriptor::tag::TextureDescriptor: - obj["tag"] = "TextureDescriptor"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["textureType"] = toJSON(tv->textureType); - obj["textureSize"] = toJSON(tv->textureSize); - obj["textureSemantic"] = toJSON(tv->textureSemantic); - obj["textureSampler"] = toJSON(tv->textureSampler); - obj["textureBaseLevel"] = toJSON(tv->textureBaseLevel); - obj["textureMaxLevel"] = toJSON(tv->textureMaxLevel); - } - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::TextureDescriptor::tag tagType; - std::string tag = obj["tag"]; - if (tag == "TextureDescriptor") { - tagType = ::TextureDescriptor::tag::TextureDescriptor; - std::shared_ptr tv(new data::TextureDescriptor()); - tv->textureType = fromJSON(W>(), obj["textureType"]); - tv->textureSize = fromJSON(W>(), obj["textureSize"]); - tv->textureSemantic = fromJSON(W>(), obj["textureSemantic"]); - tv->textureSampler = fromJSON(W>(), obj["textureSampler"]); - tv->textureBaseLevel = fromJSON(W(), obj["textureBaseLevel"]); - tv->textureMaxLevel = fromJSON(W(), obj["textureMaxLevel"]); - return tv; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::TextureDescriptor> o(new ::TextureDescriptor()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::Parameter::tag::Parameter: - obj["tag"] = "Parameter"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["name"] = toJSON(tv->name); - obj["ty"] = toJSON(tv->ty); - } - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::Parameter::tag tagType; - std::string tag = obj["tag"]; - if (tag == "Parameter") { - tagType = ::Parameter::tag::Parameter; - std::shared_ptr tv(new data::Parameter()); - tv->name = fromJSON(W(), obj["name"]); - tv->ty = fromJSON(W>(), obj["ty"]); - return tv; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::Parameter> o(new ::Parameter()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::Program::tag::Program: - obj["tag"] = "Program"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["programUniforms"] = toJSON(tv->programUniforms); - obj["programStreams"] = toJSON(tv->programStreams); - obj["programInTextures"] = toJSON(tv->programInTextures); - obj["programOutput"] = toJSON(tv->programOutput); - obj["vertexShader"] = toJSON(tv->vertexShader); - obj["geometryShader"] = toJSON(tv->geometryShader); - obj["fragmentShader"] = toJSON(tv->fragmentShader); - } - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::Program::tag tagType; - std::string tag = obj["tag"]; - if (tag == "Program") { - tagType = ::Program::tag::Program; - std::shared_ptr tv(new data::Program()); - tv->programUniforms = fromJSON(W>>(), obj["programUniforms"]); - tv->programStreams = fromJSON(W>>(), obj["programStreams"]); - tv->programInTextures = fromJSON(W>>(), obj["programInTextures"]); - tv->programOutput = fromJSON(W>>(), obj["programOutput"]); - tv->vertexShader = fromJSON(W(), obj["vertexShader"]); - tv->geometryShader = fromJSON(W>(), obj["geometryShader"]); - tv->fragmentShader = fromJSON(W(), obj["fragmentShader"]); - return tv; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::Program> o(new ::Program()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::Slot::tag::Slot: - obj["tag"] = "Slot"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["slotName"] = toJSON(tv->slotName); - obj["slotStreams"] = toJSON(tv->slotStreams); - obj["slotUniforms"] = toJSON(tv->slotUniforms); - obj["slotPrimitive"] = toJSON(tv->slotPrimitive); - obj["slotPrograms"] = toJSON(tv->slotPrograms); - } - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::Slot::tag tagType; - std::string tag = obj["tag"]; - if (tag == "Slot") { - tagType = ::Slot::tag::Slot; - std::shared_ptr tv(new data::Slot()); - tv->slotName = fromJSON(W(), obj["slotName"]); - tv->slotStreams = fromJSON(W>>(), obj["slotStreams"]); - tv->slotUniforms = fromJSON(W>>(), obj["slotUniforms"]); - tv->slotPrimitive = fromJSON(W>(), obj["slotPrimitive"]); - tv->slotPrograms = fromJSON(W>(), obj["slotPrograms"]); - return tv; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::Slot> o(new ::Slot()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::StreamData::tag::StreamData: - obj["tag"] = "StreamData"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["streamData"] = toJSON(tv->streamData); - obj["streamType"] = toJSON(tv->streamType); - obj["streamPrimitive"] = toJSON(tv->streamPrimitive); - obj["streamPrograms"] = toJSON(tv->streamPrograms); - } - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::StreamData::tag tagType; - std::string tag = obj["tag"]; - if (tag == "StreamData") { - tagType = ::StreamData::tag::StreamData; - std::shared_ptr tv(new data::StreamData()); - tv->streamData = fromJSON(W>>(), obj["streamData"]); - tv->streamType = fromJSON(W>>(), obj["streamType"]); - tv->streamPrimitive = fromJSON(W>(), obj["streamPrimitive"]); - tv->streamPrograms = fromJSON(W>(), obj["streamPrograms"]); - return tv; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::StreamData> o(new ::StreamData()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::TargetItem::tag::TargetItem: - obj["tag"] = "TargetItem"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["targetSemantic"] = toJSON(tv->targetSemantic); - obj["targetRef"] = toJSON(tv->targetRef); - } - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::TargetItem::tag tagType; - std::string tag = obj["tag"]; - if (tag == "TargetItem") { - tagType = ::TargetItem::tag::TargetItem; - std::shared_ptr tv(new data::TargetItem()); - tv->targetSemantic = fromJSON(W>(), obj["targetSemantic"]); - tv->targetRef = fromJSON(W>>(), obj["targetRef"]); - return tv; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::TargetItem> o(new ::TargetItem()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::RenderTarget::tag::RenderTarget: - obj["tag"] = "RenderTarget"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["renderTargets"] = toJSON(tv->renderTargets); - } - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::RenderTarget::tag tagType; - std::string tag = obj["tag"]; - if (tag == "RenderTarget") { - tagType = ::RenderTarget::tag::RenderTarget; - std::shared_ptr tv(new data::RenderTarget()); - tv->renderTargets = fromJSON(W>>(), obj["renderTargets"]); - return tv; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::RenderTarget> o(new ::RenderTarget()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::Backend::tag::WebGL1: - obj["tag"] = "WebGL1"; - break; - case ::Backend::tag::OpenGL33: - obj["tag"] = "OpenGL33"; - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::Backend::tag tagType; - std::string tag = obj["tag"]; - if (tag == "WebGL1") { - tagType = ::Backend::tag::WebGL1; - } - else if (tag == "OpenGL33") { - tagType = ::Backend::tag::OpenGL33; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::Backend> o(new ::Backend()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::Pipeline::tag::Pipeline: - obj["tag"] = "Pipeline"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["backend"] = toJSON(tv->backend); - obj["textures"] = toJSON(tv->textures); - obj["samplers"] = toJSON(tv->samplers); - obj["targets"] = toJSON(tv->targets); - obj["programs"] = toJSON(tv->programs); - obj["slots"] = toJSON(tv->slots); - obj["streams"] = toJSON(tv->streams); - obj["commands"] = toJSON(tv->commands); - } - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::Pipeline::tag tagType; - std::string tag = obj["tag"]; - if (tag == "Pipeline") { - tagType = ::Pipeline::tag::Pipeline; - std::shared_ptr tv(new data::Pipeline()); - tv->backend = fromJSON(W>(), obj["backend"]); - tv->textures = fromJSON(W>>(), obj["textures"]); - tv->samplers = fromJSON(W>>(), obj["samplers"]); - tv->targets = fromJSON(W>>(), obj["targets"]); - tv->programs = fromJSON(W>>(), obj["programs"]); - tv->slots = fromJSON(W>>(), obj["slots"]); - tv->streams = fromJSON(W>>(), obj["streams"]); - tv->commands = fromJSON(W>>(), obj["commands"]); - return tv; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::Pipeline> o(new ::Pipeline()); - o->tag = tagType; - return o; -} - diff --git a/ddl/out/IR.hpp b/ddl/out/IR.hpp deleted file mode 100644 index 4c6e9f1..0000000 --- a/ddl/out/IR.hpp +++ /dev/null @@ -1,1070 +0,0 @@ -// generated file, do not modify! -// 2016-01-18T14:30:07.798481Z - -#ifndef HEADER_IR_H -#define HEADER_IR_H - -#include "RT.hpp" - - -typedef Int StreamName; - -typedef Int ProgramName; - -typedef Int TextureName; - -typedef Int SamplerName; - -typedef String UniformName; - -typedef Int SlotName; - -typedef Int FrameBufferComponent; - -typedef Int TextureUnit; - -typedef Int RenderTargetName; - -typedef std::map<::UniformName, ::TextureUnit> TextureUnitMapping; - -class ArrayValue { - public: - enum class tag { - VBoolArray, - VIntArray, - VWordArray, - VFloatArray - } tag; -}; -namespace data { - class VBoolArray : public ::ArrayValue { - public: - std::vector _0; - VBoolArray() { tag = tag::VBoolArray; } - }; - class VIntArray : public ::ArrayValue { - public: - std::vector _0; - VIntArray() { tag = tag::VIntArray; } - }; - class VWordArray : public ::ArrayValue { - public: - std::vector _0; - VWordArray() { tag = tag::VWordArray; } - }; - class VFloatArray : public ::ArrayValue { - public: - std::vector _0; - VFloatArray() { tag = tag::VFloatArray; } - }; -} -class Value { - public: - enum class tag { - VBool, - VV2B, - VV3B, - VV4B, - VWord, - VV2U, - VV3U, - VV4U, - VInt, - VV2I, - VV3I, - VV4I, - VFloat, - VV2F, - VV3F, - VV4F, - VM22F, - VM23F, - VM24F, - VM32F, - VM33F, - VM34F, - VM42F, - VM43F, - VM44F - } tag; -}; -namespace data { - class VBool : public ::Value { - public: - Bool _0; - VBool() { tag = tag::VBool; } - }; - class VV2B : public ::Value { - public: - V2B _0; - VV2B() { tag = tag::VV2B; } - }; - class VV3B : public ::Value { - public: - V3B _0; - VV3B() { tag = tag::VV3B; } - }; - class VV4B : public ::Value { - public: - V4B _0; - VV4B() { tag = tag::VV4B; } - }; - class VWord : public ::Value { - public: - Word32 _0; - VWord() { tag = tag::VWord; } - }; - class VV2U : public ::Value { - public: - V2U _0; - VV2U() { tag = tag::VV2U; } - }; - class VV3U : public ::Value { - public: - V3U _0; - VV3U() { tag = tag::VV3U; } - }; - class VV4U : public ::Value { - public: - V4U _0; - VV4U() { tag = tag::VV4U; } - }; - class VInt : public ::Value { - public: - Int32 _0; - VInt() { tag = tag::VInt; } - }; - class VV2I : public ::Value { - public: - V2I _0; - VV2I() { tag = tag::VV2I; } - }; - class VV3I : public ::Value { - public: - V3I _0; - VV3I() { tag = tag::VV3I; } - }; - class VV4I : public ::Value { - public: - V4I _0; - VV4I() { tag = tag::VV4I; } - }; - class VFloat : public ::Value { - public: - Float _0; - VFloat() { tag = tag::VFloat; } - }; - class VV2F : public ::Value { - public: - V2F _0; - VV2F() { tag = tag::VV2F; } - }; - class VV3F : public ::Value { - public: - V3F _0; - VV3F() { tag = tag::VV3F; } - }; - class VV4F : public ::Value { - public: - V4F _0; - VV4F() { tag = tag::VV4F; } - }; - class VM22F : public ::Value { - public: - M22F _0; - VM22F() { tag = tag::VM22F; } - }; - class VM23F : public ::Value { - public: - M23F _0; - VM23F() { tag = tag::VM23F; } - }; - class VM24F : public ::Value { - public: - M24F _0; - VM24F() { tag = tag::VM24F; } - }; - class VM32F : public ::Value { - public: - M32F _0; - VM32F() { tag = tag::VM32F; } - }; - class VM33F : public ::Value { - public: - M33F _0; - VM33F() { tag = tag::VM33F; } - }; - class VM34F : public ::Value { - public: - M34F _0; - VM34F() { tag = tag::VM34F; } - }; - class VM42F : public ::Value { - public: - M42F _0; - VM42F() { tag = tag::VM42F; } - }; - class VM43F : public ::Value { - public: - M43F _0; - VM43F() { tag = tag::VM43F; } - }; - class VM44F : public ::Value { - public: - M44F _0; - VM44F() { tag = tag::VM44F; } - }; -} -class InputType { - public: - enum class tag { - Bool, - V2B, - V3B, - V4B, - Word, - V2U, - V3U, - V4U, - Int, - V2I, - V3I, - V4I, - Float, - V2F, - V3F, - V4F, - M22F, - M23F, - M24F, - M32F, - M33F, - M34F, - M42F, - M43F, - M44F, - STexture1D, - STexture2D, - STextureCube, - STexture1DArray, - STexture2DArray, - STexture2DRect, - FTexture1D, - FTexture2D, - FTexture3D, - FTextureCube, - FTexture1DArray, - FTexture2DArray, - FTexture2DMS, - FTexture2DMSArray, - FTextureBuffer, - FTexture2DRect, - ITexture1D, - ITexture2D, - ITexture3D, - ITextureCube, - ITexture1DArray, - ITexture2DArray, - ITexture2DMS, - ITexture2DMSArray, - ITextureBuffer, - ITexture2DRect, - UTexture1D, - UTexture2D, - UTexture3D, - UTextureCube, - UTexture1DArray, - UTexture2DArray, - UTexture2DMS, - UTexture2DMSArray, - UTextureBuffer, - UTexture2DRect - } tag; -}; -namespace data { -} -class PointSpriteCoordOrigin { - public: - enum class tag { - LowerLeft, - UpperLeft - } tag; -}; -namespace data { -} -class PointSize { - public: - enum class tag { - PointSize, - ProgramPointSize - } tag; -}; -namespace data { - class PointSize : public ::PointSize { - public: - Float _0; - PointSize() { tag = tag::PointSize; } - }; -} -class PolygonOffset { - public: - enum class tag { - NoOffset, - Offset - } tag; -}; -namespace data { - class Offset : public ::PolygonOffset { - public: - Float _0; - Float _1; - Offset() { tag = tag::Offset; } - }; -} -class FrontFace { - public: - enum class tag { - CCW, - CW - } tag; -}; -namespace data { -} -class PolygonMode { - public: - enum class tag { - PolygonPoint, - PolygonLine, - PolygonFill - } tag; -}; -namespace data { - class PolygonPoint : public ::PolygonMode { - public: - std::shared_ptr<::PointSize> _0; - PolygonPoint() { tag = tag::PolygonPoint; } - }; - class PolygonLine : public ::PolygonMode { - public: - Float _0; - PolygonLine() { tag = tag::PolygonLine; } - }; -} -class ProvokingVertex { - public: - enum class tag { - FirstVertex, - LastVertex - } tag; -}; -namespace data { -} -class CullMode { - public: - enum class tag { - CullNone, - CullFront, - CullBack - } tag; -}; -namespace data { - class CullFront : public ::CullMode { - public: - std::shared_ptr<::FrontFace> _0; - CullFront() { tag = tag::CullFront; } - }; - class CullBack : public ::CullMode { - public: - std::shared_ptr<::FrontFace> _0; - CullBack() { tag = tag::CullBack; } - }; -} -class ComparisonFunction { - public: - enum class tag { - Never, - Less, - Equal, - Lequal, - Greater, - Notequal, - Gequal, - Always - } tag; -}; -namespace data { -} -typedef ComparisonFunction DepthFunction; - -class StencilOperation { - public: - enum class tag { - OpZero, - OpKeep, - OpReplace, - OpIncr, - OpIncrWrap, - OpDecr, - OpDecrWrap, - OpInvert - } tag; -}; -namespace data { -} -class BlendEquation { - public: - enum class tag { - FuncAdd, - FuncSubtract, - FuncReverseSubtract, - Min, - Max - } tag; -}; -namespace data { -} -class BlendingFactor { - public: - enum class tag { - Zero, - One, - SrcColor, - OneMinusSrcColor, - DstColor, - OneMinusDstColor, - SrcAlpha, - OneMinusSrcAlpha, - DstAlpha, - OneMinusDstAlpha, - ConstantColor, - OneMinusConstantColor, - ConstantAlpha, - OneMinusConstantAlpha, - SrcAlphaSaturate - } tag; -}; -namespace data { -} -class LogicOperation { - public: - enum class tag { - Clear, - And, - AndReverse, - Copy, - AndInverted, - Noop, - Xor, - Or, - Nor, - Equiv, - Invert, - OrReverse, - CopyInverted, - OrInverted, - Nand, - Set - } tag; -}; -namespace data { -} -class StencilOps { - public: - enum class tag { - StencilOps - } tag; -}; -namespace data { - class StencilOps : public ::StencilOps { - public: - std::shared_ptr<::StencilOperation> frontStencilOp; - std::shared_ptr<::StencilOperation> backStencilOp; - StencilOps() { tag = tag::StencilOps; } - }; -} -class StencilTest { - public: - enum class tag { - StencilTest - } tag; -}; -namespace data { - class StencilTest : public ::StencilTest { - public: - std::shared_ptr<::ComparisonFunction> stencilComparision; - Int32 stencilReference; - Word32 stencilMask; - StencilTest() { tag = tag::StencilTest; } - }; -} -class StencilTests { - public: - enum class tag { - StencilTests - } tag; -}; -namespace data { - class StencilTests : public ::StencilTests { - public: - std::shared_ptr<::StencilTest> _0; - std::shared_ptr<::StencilTest> _1; - StencilTests() { tag = tag::StencilTests; } - }; -} -class FetchPrimitive { - public: - enum class tag { - Points, - Lines, - Triangles, - LinesAdjacency, - TrianglesAdjacency - } tag; -}; -namespace data { -} -class OutputPrimitive { - public: - enum class tag { - TrianglesOutput, - LinesOutput, - PointsOutput - } tag; -}; -namespace data { -} -class ColorArity { - public: - enum class tag { - Red, - RG, - RGB, - RGBA - } tag; -}; -namespace data { -} -class Blending { - public: - enum class tag { - NoBlending, - BlendLogicOp, - Blend - } tag; -}; -namespace data { - class BlendLogicOp : public ::Blending { - public: - std::shared_ptr<::LogicOperation> _0; - BlendLogicOp() { tag = tag::BlendLogicOp; } - }; - class Blend : public ::Blending { - public: - std::shared_ptr<::BlendEquation> colorEqSrc; - std::shared_ptr<::BlendEquation> alphaEqSrc; - std::shared_ptr<::BlendingFactor> colorFSrc; - std::shared_ptr<::BlendingFactor> colorFDst; - std::shared_ptr<::BlendingFactor> alphaFSrc; - std::shared_ptr<::BlendingFactor> alphaFDst; - V4F color; - Blend() { tag = tag::Blend; } - }; -} -class RasterContext { - public: - enum class tag { - PointCtx, - LineCtx, - TriangleCtx - } tag; -}; -namespace data { - class PointCtx : public ::RasterContext { - public: - std::shared_ptr<::PointSize> _0; - Float _1; - std::shared_ptr<::PointSpriteCoordOrigin> _2; - PointCtx() { tag = tag::PointCtx; } - }; - class LineCtx : public ::RasterContext { - public: - Float _0; - std::shared_ptr<::ProvokingVertex> _1; - LineCtx() { tag = tag::LineCtx; } - }; - class TriangleCtx : public ::RasterContext { - public: - std::shared_ptr<::CullMode> _0; - std::shared_ptr<::PolygonMode> _1; - std::shared_ptr<::PolygonOffset> _2; - std::shared_ptr<::ProvokingVertex> _3; - TriangleCtx() { tag = tag::TriangleCtx; } - }; -} -class FragmentOperation { - public: - enum class tag { - DepthOp, - StencilOp, - ColorOp - } tag; -}; -namespace data { - class DepthOp : public ::FragmentOperation { - public: - std::shared_ptr<::DepthFunction> _0; - Bool _1; - DepthOp() { tag = tag::DepthOp; } - }; - class StencilOp : public ::FragmentOperation { - public: - std::shared_ptr<::StencilTests> _0; - std::shared_ptr<::StencilOps> _1; - std::shared_ptr<::StencilOps> _2; - StencilOp() { tag = tag::StencilOp; } - }; - class ColorOp : public ::FragmentOperation { - public: - std::shared_ptr<::Blending> _0; - std::shared_ptr<::Value> _1; - ColorOp() { tag = tag::ColorOp; } - }; -} -class AccumulationContext { - public: - enum class tag { - AccumulationContext - } tag; -}; -namespace data { - class AccumulationContext : public ::AccumulationContext { - public: - Maybe accViewportName; - std::vector> accOperations; - AccumulationContext() { tag = tag::AccumulationContext; } - }; -} -class TextureDataType { - public: - enum class tag { - FloatT, - IntT, - WordT, - ShadowT - } tag; -}; -namespace data { - class FloatT : public ::TextureDataType { - public: - std::shared_ptr<::ColorArity> _0; - FloatT() { tag = tag::FloatT; } - }; - class IntT : public ::TextureDataType { - public: - std::shared_ptr<::ColorArity> _0; - IntT() { tag = tag::IntT; } - }; - class WordT : public ::TextureDataType { - public: - std::shared_ptr<::ColorArity> _0; - WordT() { tag = tag::WordT; } - }; -} -class TextureType { - public: - enum class tag { - Texture1D, - Texture2D, - Texture3D, - TextureCube, - TextureRect, - Texture2DMS, - TextureBuffer - } tag; -}; -namespace data { - class Texture1D : public ::TextureType { - public: - std::shared_ptr<::TextureDataType> _0; - Int _1; - Texture1D() { tag = tag::Texture1D; } - }; - class Texture2D : public ::TextureType { - public: - std::shared_ptr<::TextureDataType> _0; - Int _1; - Texture2D() { tag = tag::Texture2D; } - }; - class Texture3D : public ::TextureType { - public: - std::shared_ptr<::TextureDataType> _0; - Texture3D() { tag = tag::Texture3D; } - }; - class TextureCube : public ::TextureType { - public: - std::shared_ptr<::TextureDataType> _0; - TextureCube() { tag = tag::TextureCube; } - }; - class TextureRect : public ::TextureType { - public: - std::shared_ptr<::TextureDataType> _0; - TextureRect() { tag = tag::TextureRect; } - }; - class Texture2DMS : public ::TextureType { - public: - std::shared_ptr<::TextureDataType> _0; - Int _1; - Int _2; - Bool _3; - Texture2DMS() { tag = tag::Texture2DMS; } - }; - class TextureBuffer : public ::TextureType { - public: - std::shared_ptr<::TextureDataType> _0; - TextureBuffer() { tag = tag::TextureBuffer; } - }; -} -class MipMap { - public: - enum class tag { - Mip, - NoMip, - AutoMip - } tag; -}; -namespace data { - class Mip : public ::MipMap { - public: - Int _0; - Int _1; - Mip() { tag = tag::Mip; } - }; - class AutoMip : public ::MipMap { - public: - Int _0; - Int _1; - AutoMip() { tag = tag::AutoMip; } - }; -} -class Filter { - public: - enum class tag { - Nearest, - Linear, - NearestMipmapNearest, - NearestMipmapLinear, - LinearMipmapNearest, - LinearMipmapLinear - } tag; -}; -namespace data { -} -class EdgeMode { - public: - enum class tag { - Repeat, - MirroredRepeat, - ClampToEdge, - ClampToBorder - } tag; -}; -namespace data { -} -class ImageSemantic { - public: - enum class tag { - Depth, - Stencil, - Color - } tag; -}; -namespace data { -} -class ImageRef { - public: - enum class tag { - TextureImage, - Framebuffer - } tag; -}; -namespace data { - class TextureImage : public ::ImageRef { - public: - ::TextureName _0; - Int _1; - Maybe _2; - TextureImage() { tag = tag::TextureImage; } - }; - class Framebuffer : public ::ImageRef { - public: - std::shared_ptr<::ImageSemantic> _0; - Framebuffer() { tag = tag::Framebuffer; } - }; -} -class ClearImage { - public: - enum class tag { - ClearImage - } tag; -}; -namespace data { - class ClearImage : public ::ClearImage { - public: - std::shared_ptr<::ImageSemantic> imageSemantic; - std::shared_ptr<::Value> clearValue; - ClearImage() { tag = tag::ClearImage; } - }; -} -class Command { - public: - enum class tag { - SetRasterContext, - SetAccumulationContext, - SetRenderTarget, - SetProgram, - SetSamplerUniform, - SetTexture, - SetSampler, - RenderSlot, - RenderStream, - ClearRenderTarget, - GenerateMipMap, - SaveImage, - LoadImage - } tag; -}; -namespace data { - class SetRasterContext : public ::Command { - public: - std::shared_ptr<::RasterContext> _0; - SetRasterContext() { tag = tag::SetRasterContext; } - }; - class SetAccumulationContext : public ::Command { - public: - std::shared_ptr<::AccumulationContext> _0; - SetAccumulationContext() { tag = tag::SetAccumulationContext; } - }; - class SetRenderTarget : public ::Command { - public: - ::RenderTargetName _0; - SetRenderTarget() { tag = tag::SetRenderTarget; } - }; - class SetProgram : public ::Command { - public: - ::ProgramName _0; - SetProgram() { tag = tag::SetProgram; } - }; - class SetSamplerUniform : public ::Command { - public: - ::UniformName _0; - ::TextureUnit _1; - SetSamplerUniform() { tag = tag::SetSamplerUniform; } - }; - class SetTexture : public ::Command { - public: - ::TextureUnit _0; - ::TextureName _1; - SetTexture() { tag = tag::SetTexture; } - }; - class SetSampler : public ::Command { - public: - ::TextureUnit _0; - Maybe<::SamplerName> _1; - SetSampler() { tag = tag::SetSampler; } - }; - class RenderSlot : public ::Command { - public: - ::SlotName _0; - RenderSlot() { tag = tag::RenderSlot; } - }; - class RenderStream : public ::Command { - public: - ::StreamName _0; - RenderStream() { tag = tag::RenderStream; } - }; - class ClearRenderTarget : public ::Command { - public: - std::vector> _0; - ClearRenderTarget() { tag = tag::ClearRenderTarget; } - }; - class GenerateMipMap : public ::Command { - public: - ::TextureUnit _0; - GenerateMipMap() { tag = tag::GenerateMipMap; } - }; - class SaveImage : public ::Command { - public: - ::FrameBufferComponent _0; - std::shared_ptr<::ImageRef> _1; - SaveImage() { tag = tag::SaveImage; } - }; - class LoadImage : public ::Command { - public: - std::shared_ptr<::ImageRef> _0; - ::FrameBufferComponent _1; - LoadImage() { tag = tag::LoadImage; } - }; -} -class SamplerDescriptor { - public: - enum class tag { - SamplerDescriptor - } tag; -}; -namespace data { - class SamplerDescriptor : public ::SamplerDescriptor { - public: - std::shared_ptr<::EdgeMode> samplerWrapS; - Maybe> samplerWrapT; - Maybe> samplerWrapR; - std::shared_ptr<::Filter> samplerMinFilter; - std::shared_ptr<::Filter> samplerMagFilter; - std::shared_ptr<::Value> samplerBorderColor; - Maybe samplerMinLod; - Maybe samplerMaxLod; - Float samplerLodBias; - Maybe> samplerCompareFunc; - SamplerDescriptor() { tag = tag::SamplerDescriptor; } - }; -} -class TextureDescriptor { - public: - enum class tag { - TextureDescriptor - } tag; -}; -namespace data { - class TextureDescriptor : public ::TextureDescriptor { - public: - std::shared_ptr<::TextureType> textureType; - std::shared_ptr<::Value> textureSize; - std::shared_ptr<::ImageSemantic> textureSemantic; - std::shared_ptr<::SamplerDescriptor> textureSampler; - Int textureBaseLevel; - Int textureMaxLevel; - TextureDescriptor() { tag = tag::TextureDescriptor; } - }; -} -class Parameter { - public: - enum class tag { - Parameter - } tag; -}; -namespace data { - class Parameter : public ::Parameter { - public: - String name; - std::shared_ptr<::InputType> ty; - Parameter() { tag = tag::Parameter; } - }; -} -class Program { - public: - enum class tag { - Program - } tag; -}; -namespace data { - class Program : public ::Program { - public: - std::map<::UniformName, std::shared_ptr<::InputType>> programUniforms; - std::map<::UniformName, std::shared_ptr<::Parameter>> programStreams; - std::map<::UniformName, std::shared_ptr<::InputType>> programInTextures; - std::vector> programOutput; - String vertexShader; - Maybe geometryShader; - String fragmentShader; - Program() { tag = tag::Program; } - }; -} -class Slot { - public: - enum class tag { - Slot - } tag; -}; -namespace data { - class Slot : public ::Slot { - public: - String slotName; - std::map> slotStreams; - std::map<::UniformName, std::shared_ptr<::InputType>> slotUniforms; - std::shared_ptr<::FetchPrimitive> slotPrimitive; - std::vector<::ProgramName> slotPrograms; - Slot() { tag = tag::Slot; } - }; -} -class StreamData { - public: - enum class tag { - StreamData - } tag; -}; -namespace data { - class StreamData : public ::StreamData { - public: - std::map> streamData; - std::map> streamType; - std::shared_ptr<::FetchPrimitive> streamPrimitive; - std::vector<::ProgramName> streamPrograms; - StreamData() { tag = tag::StreamData; } - }; -} -class TargetItem { - public: - enum class tag { - TargetItem - } tag; -}; -namespace data { - class TargetItem : public ::TargetItem { - public: - std::shared_ptr<::ImageSemantic> targetSemantic; - Maybe> targetRef; - TargetItem() { tag = tag::TargetItem; } - }; -} -class RenderTarget { - public: - enum class tag { - RenderTarget - } tag; -}; -namespace data { - class RenderTarget : public ::RenderTarget { - public: - std::vector> renderTargets; - RenderTarget() { tag = tag::RenderTarget; } - }; -} -class Backend { - public: - enum class tag { - WebGL1, - OpenGL33 - } tag; -}; -namespace data { -} -class Pipeline { - public: - enum class tag { - Pipeline - } tag; -}; -namespace data { - class Pipeline : public ::Pipeline { - public: - std::shared_ptr<::Backend> backend; - std::vector> textures; - std::vector> samplers; - std::vector> targets; - std::vector> programs; - std::vector> slots; - std::vector> streams; - std::vector> commands; - Pipeline() { tag = tag::Pipeline; } - }; -} -#endif diff --git a/ddl/out/IR.hs b/ddl/out/IR.hs deleted file mode 100644 index d65d628..0000000 --- a/ddl/out/IR.hs +++ /dev/null @@ -1,1608 +0,0 @@ --- generated file, do not modify! --- 2016-01-18T14:30:07.798481Z - -{-# LANGUAGE OverloadedStrings, RecordWildCards #-} -module IR where - -import Data.Int -import Data.Word -import Data.Map -import Data.Vector (Vector(..)) -import Linear - -import Data.Text -import Data.Aeson hiding (Value,Bool) -import Data.Aeson.Types hiding (Value,Bool) -import Control.Monad - - -type StreamName = Int - -type ProgramName = Int - -type TextureName = Int - -type SamplerName = Int - -type UniformName = String - -type SlotName = Int - -type FrameBufferComponent = Int - -type TextureUnit = Int - -type RenderTargetName = Int - -type TextureUnitMapping = Map UniformName TextureUnit - -data ArrayValue - = VBoolArray (Vector Bool) - | VIntArray (Vector Int32) - | VWordArray (Vector Word32) - | VFloatArray (Vector Float) - deriving (Show, Eq, Ord) - -data Value - = VBool Bool - | VV2B V2B - | VV3B V3B - | VV4B V4B - | VWord Word32 - | VV2U V2U - | VV3U V3U - | VV4U V4U - | VInt Int32 - | VV2I V2I - | VV3I V3I - | VV4I V4I - | VFloat Float - | VV2F V2F - | VV3F V3F - | VV4F V4F - | VM22F M22F - | VM23F M23F - | VM24F M24F - | VM32F M32F - | VM33F M33F - | VM34F M34F - | VM42F M42F - | VM43F M43F - | VM44F M44F - deriving (Show, Eq, Ord) - -data InputType - = Bool - | V2B - | V3B - | V4B - | Word - | V2U - | V3U - | V4U - | Int - | V2I - | V3I - | V4I - | Float - | V2F - | V3F - | V4F - | M22F - | M23F - | M24F - | M32F - | M33F - | M34F - | M42F - | M43F - | M44F - | STexture1D - | STexture2D - | STextureCube - | STexture1DArray - | STexture2DArray - | STexture2DRect - | FTexture1D - | FTexture2D - | FTexture3D - | FTextureCube - | FTexture1DArray - | FTexture2DArray - | FTexture2DMS - | FTexture2DMSArray - | FTextureBuffer - | FTexture2DRect - | ITexture1D - | ITexture2D - | ITexture3D - | ITextureCube - | ITexture1DArray - | ITexture2DArray - | ITexture2DMS - | ITexture2DMSArray - | ITextureBuffer - | ITexture2DRect - | UTexture1D - | UTexture2D - | UTexture3D - | UTextureCube - | UTexture1DArray - | UTexture2DArray - | UTexture2DMS - | UTexture2DMSArray - | UTextureBuffer - | UTexture2DRect - deriving (Show, Eq, Ord) - -data PointSpriteCoordOrigin - = LowerLeft - | UpperLeft - deriving (Show, Eq, Ord) - -data PointSize - = PointSize Float - | ProgramPointSize - deriving (Show, Eq, Ord) - -data PolygonOffset - = NoOffset - | Offset Float Float - deriving (Show, Eq, Ord) - -data FrontFace - = CCW - | CW - deriving (Show, Eq, Ord) - -data PolygonMode - = PolygonPoint PointSize - | PolygonLine Float - | PolygonFill - deriving (Show, Eq, Ord) - -data ProvokingVertex - = FirstVertex - | LastVertex - deriving (Show, Eq, Ord) - -data CullMode - = CullNone - | CullFront FrontFace - | CullBack FrontFace - deriving (Show, Eq, Ord) - -data ComparisonFunction - = Never - | Less - | Equal - | Lequal - | Greater - | Notequal - | Gequal - | Always - deriving (Show, Eq, Ord) - -type DepthFunction = ComparisonFunction - -data StencilOperation - = OpZero - | OpKeep - | OpReplace - | OpIncr - | OpIncrWrap - | OpDecr - | OpDecrWrap - | OpInvert - deriving (Show, Eq, Ord) - -data BlendEquation - = FuncAdd - | FuncSubtract - | FuncReverseSubtract - | Min - | Max - deriving (Show, Eq, Ord) - -data BlendingFactor - = Zero - | One - | SrcColor - | OneMinusSrcColor - | DstColor - | OneMinusDstColor - | SrcAlpha - | OneMinusSrcAlpha - | DstAlpha - | OneMinusDstAlpha - | ConstantColor - | OneMinusConstantColor - | ConstantAlpha - | OneMinusConstantAlpha - | SrcAlphaSaturate - deriving (Show, Eq, Ord) - -data LogicOperation - = Clear - | And - | AndReverse - | Copy - | AndInverted - | Noop - | Xor - | Or - | Nor - | Equiv - | Invert - | OrReverse - | CopyInverted - | OrInverted - | Nand - | Set - deriving (Show, Eq, Ord) - -data StencilOps - = StencilOps - { frontStencilOp :: StencilOperation - , backStencilOp :: StencilOperation - } - - deriving (Show, Eq, Ord) - -data StencilTest - = StencilTest - { stencilComparision :: ComparisonFunction - , stencilReference :: Int32 - , stencilMask :: Word32 - } - - deriving (Show, Eq, Ord) - -data StencilTests - = StencilTests StencilTest StencilTest - deriving (Show, Eq, Ord) - -data FetchPrimitive - = Points - | Lines - | Triangles - | LinesAdjacency - | TrianglesAdjacency - deriving (Show, Eq, Ord) - -data OutputPrimitive - = TrianglesOutput - | LinesOutput - | PointsOutput - deriving (Show, Eq, Ord) - -data ColorArity - = Red - | RG - | RGB - | RGBA - deriving (Show, Eq, Ord) - -data Blending - = NoBlending - | BlendLogicOp LogicOperation - | Blend - { colorEqSrc :: BlendEquation - , alphaEqSrc :: BlendEquation - , colorFSrc :: BlendingFactor - , colorFDst :: BlendingFactor - , alphaFSrc :: BlendingFactor - , alphaFDst :: BlendingFactor - , color :: V4F - } - - deriving (Show, Eq, Ord) - -data RasterContext - = PointCtx PointSize Float PointSpriteCoordOrigin - | LineCtx Float ProvokingVertex - | TriangleCtx CullMode PolygonMode PolygonOffset ProvokingVertex - deriving (Show, Eq, Ord) - -data FragmentOperation - = DepthOp DepthFunction Bool - | StencilOp StencilTests StencilOps StencilOps - | ColorOp Blending Value - deriving (Show, Eq, Ord) - -data AccumulationContext - = AccumulationContext - { accViewportName :: Maybe String - , accOperations :: [FragmentOperation] - } - - deriving (Show, Eq, Ord) - -data TextureDataType - = FloatT ColorArity - | IntT ColorArity - | WordT ColorArity - | ShadowT - deriving (Show, Eq, Ord) - -data TextureType - = Texture1D TextureDataType Int - | Texture2D TextureDataType Int - | Texture3D TextureDataType - | TextureCube TextureDataType - | TextureRect TextureDataType - | Texture2DMS TextureDataType Int Int Bool - | TextureBuffer TextureDataType - deriving (Show, Eq, Ord) - -data MipMap - = Mip Int Int - | NoMip - | AutoMip Int Int - deriving (Show, Eq, Ord) - -data Filter - = Nearest - | Linear - | NearestMipmapNearest - | NearestMipmapLinear - | LinearMipmapNearest - | LinearMipmapLinear - deriving (Show, Eq, Ord) - -data EdgeMode - = Repeat - | MirroredRepeat - | ClampToEdge - | ClampToBorder - deriving (Show, Eq, Ord) - -data ImageSemantic - = Depth - | Stencil - | Color - deriving (Show, Eq, Ord) - -data ImageRef - = TextureImage TextureName Int (Maybe Int) - | Framebuffer ImageSemantic - deriving (Show, Eq, Ord) - -data ClearImage - = ClearImage - { imageSemantic :: ImageSemantic - , clearValue :: Value - } - - deriving (Show, Eq, Ord) - -data Command - = SetRasterContext RasterContext - | SetAccumulationContext AccumulationContext - | SetRenderTarget RenderTargetName - | SetProgram ProgramName - | SetSamplerUniform UniformName TextureUnit - | SetTexture TextureUnit TextureName - | SetSampler TextureUnit (Maybe SamplerName) - | RenderSlot SlotName - | RenderStream StreamName - | ClearRenderTarget (Vector ClearImage) - | GenerateMipMap TextureUnit - | SaveImage FrameBufferComponent ImageRef - | LoadImage ImageRef FrameBufferComponent - deriving (Show, Eq, Ord) - -data SamplerDescriptor - = SamplerDescriptor - { samplerWrapS :: EdgeMode - , samplerWrapT :: Maybe EdgeMode - , samplerWrapR :: Maybe EdgeMode - , samplerMinFilter :: Filter - , samplerMagFilter :: Filter - , samplerBorderColor :: Value - , samplerMinLod :: Maybe Float - , samplerMaxLod :: Maybe Float - , samplerLodBias :: Float - , samplerCompareFunc :: Maybe ComparisonFunction - } - - deriving (Show, Eq, Ord) - -data TextureDescriptor - = TextureDescriptor - { textureType :: TextureType - , textureSize :: Value - , textureSemantic :: ImageSemantic - , textureSampler :: SamplerDescriptor - , textureBaseLevel :: Int - , textureMaxLevel :: Int - } - - deriving (Show, Eq, Ord) - -data Parameter - = Parameter - { name :: String - , ty :: InputType - } - - deriving (Show, Eq, Ord) - -data Program - = Program - { programUniforms :: Map UniformName InputType - , programStreams :: Map UniformName Parameter - , programInTextures :: Map UniformName InputType - , programOutput :: Vector Parameter - , vertexShader :: String - , geometryShader :: Maybe String - , fragmentShader :: String - } - - deriving (Show, Eq, Ord) - -data Slot - = Slot - { slotName :: String - , slotStreams :: Map String InputType - , slotUniforms :: Map UniformName InputType - , slotPrimitive :: FetchPrimitive - , slotPrograms :: Vector ProgramName - } - - deriving (Show, Eq, Ord) - -data StreamData - = StreamData - { streamData :: Map String ArrayValue - , streamType :: Map String InputType - , streamPrimitive :: FetchPrimitive - , streamPrograms :: Vector ProgramName - } - - deriving (Show, Eq, Ord) - -data TargetItem - = TargetItem - { targetSemantic :: ImageSemantic - , targetRef :: Maybe ImageRef - } - - deriving (Show, Eq, Ord) - -data RenderTarget - = RenderTarget - { renderTargets :: Vector TargetItem - } - - deriving (Show, Eq, Ord) - -data Backend - = WebGL1 - | OpenGL33 - deriving (Show, Eq, Ord) - -data Pipeline - = Pipeline - { backend :: Backend - , textures :: Vector TextureDescriptor - , samplers :: Vector SamplerDescriptor - , targets :: Vector RenderTarget - , programs :: Vector Program - , slots :: Vector Slot - , streams :: Vector StreamData - , commands :: Vector Command - } - - deriving (Show, Eq, Ord) - - -instance ToJSON ArrayValue where - toJSON v = case v of - VBoolArray arg0 -> object [ "tag" .= ("VBoolArray" :: Text), "arg0" .= arg0] - VIntArray arg0 -> object [ "tag" .= ("VIntArray" :: Text), "arg0" .= arg0] - VWordArray arg0 -> object [ "tag" .= ("VWordArray" :: Text), "arg0" .= arg0] - VFloatArray arg0 -> object [ "tag" .= ("VFloatArray" :: Text), "arg0" .= arg0] - -instance FromJSON ArrayValue where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "VBoolArray" -> VBoolArray <$> obj .: "arg0" - "VIntArray" -> VIntArray <$> obj .: "arg0" - "VWordArray" -> VWordArray <$> obj .: "arg0" - "VFloatArray" -> VFloatArray <$> obj .: "arg0" - parseJSON _ = mzero - -instance ToJSON Value where - toJSON v = case v of - VBool arg0 -> object [ "tag" .= ("VBool" :: Text), "arg0" .= arg0] - VV2B arg0 -> object [ "tag" .= ("VV2B" :: Text), "arg0" .= arg0] - VV3B arg0 -> object [ "tag" .= ("VV3B" :: Text), "arg0" .= arg0] - VV4B arg0 -> object [ "tag" .= ("VV4B" :: Text), "arg0" .= arg0] - VWord arg0 -> object [ "tag" .= ("VWord" :: Text), "arg0" .= arg0] - VV2U arg0 -> object [ "tag" .= ("VV2U" :: Text), "arg0" .= arg0] - VV3U arg0 -> object [ "tag" .= ("VV3U" :: Text), "arg0" .= arg0] - VV4U arg0 -> object [ "tag" .= ("VV4U" :: Text), "arg0" .= arg0] - VInt arg0 -> object [ "tag" .= ("VInt" :: Text), "arg0" .= arg0] - VV2I arg0 -> object [ "tag" .= ("VV2I" :: Text), "arg0" .= arg0] - VV3I arg0 -> object [ "tag" .= ("VV3I" :: Text), "arg0" .= arg0] - VV4I arg0 -> object [ "tag" .= ("VV4I" :: Text), "arg0" .= arg0] - VFloat arg0 -> object [ "tag" .= ("VFloat" :: Text), "arg0" .= arg0] - VV2F arg0 -> object [ "tag" .= ("VV2F" :: Text), "arg0" .= arg0] - VV3F arg0 -> object [ "tag" .= ("VV3F" :: Text), "arg0" .= arg0] - VV4F arg0 -> object [ "tag" .= ("VV4F" :: Text), "arg0" .= arg0] - VM22F arg0 -> object [ "tag" .= ("VM22F" :: Text), "arg0" .= arg0] - VM23F arg0 -> object [ "tag" .= ("VM23F" :: Text), "arg0" .= arg0] - VM24F arg0 -> object [ "tag" .= ("VM24F" :: Text), "arg0" .= arg0] - VM32F arg0 -> object [ "tag" .= ("VM32F" :: Text), "arg0" .= arg0] - VM33F arg0 -> object [ "tag" .= ("VM33F" :: Text), "arg0" .= arg0] - VM34F arg0 -> object [ "tag" .= ("VM34F" :: Text), "arg0" .= arg0] - VM42F arg0 -> object [ "tag" .= ("VM42F" :: Text), "arg0" .= arg0] - VM43F arg0 -> object [ "tag" .= ("VM43F" :: Text), "arg0" .= arg0] - VM44F arg0 -> object [ "tag" .= ("VM44F" :: Text), "arg0" .= arg0] - -instance FromJSON Value where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "VBool" -> VBool <$> obj .: "arg0" - "VV2B" -> VV2B <$> obj .: "arg0" - "VV3B" -> VV3B <$> obj .: "arg0" - "VV4B" -> VV4B <$> obj .: "arg0" - "VWord" -> VWord <$> obj .: "arg0" - "VV2U" -> VV2U <$> obj .: "arg0" - "VV3U" -> VV3U <$> obj .: "arg0" - "VV4U" -> VV4U <$> obj .: "arg0" - "VInt" -> VInt <$> obj .: "arg0" - "VV2I" -> VV2I <$> obj .: "arg0" - "VV3I" -> VV3I <$> obj .: "arg0" - "VV4I" -> VV4I <$> obj .: "arg0" - "VFloat" -> VFloat <$> obj .: "arg0" - "VV2F" -> VV2F <$> obj .: "arg0" - "VV3F" -> VV3F <$> obj .: "arg0" - "VV4F" -> VV4F <$> obj .: "arg0" - "VM22F" -> VM22F <$> obj .: "arg0" - "VM23F" -> VM23F <$> obj .: "arg0" - "VM24F" -> VM24F <$> obj .: "arg0" - "VM32F" -> VM32F <$> obj .: "arg0" - "VM33F" -> VM33F <$> obj .: "arg0" - "VM34F" -> VM34F <$> obj .: "arg0" - "VM42F" -> VM42F <$> obj .: "arg0" - "VM43F" -> VM43F <$> obj .: "arg0" - "VM44F" -> VM44F <$> obj .: "arg0" - parseJSON _ = mzero - -instance ToJSON InputType where - toJSON v = case v of - Bool -> object [ "tag" .= ("Bool" :: Text)] - V2B -> object [ "tag" .= ("V2B" :: Text)] - V3B -> object [ "tag" .= ("V3B" :: Text)] - V4B -> object [ "tag" .= ("V4B" :: Text)] - Word -> object [ "tag" .= ("Word" :: Text)] - V2U -> object [ "tag" .= ("V2U" :: Text)] - V3U -> object [ "tag" .= ("V3U" :: Text)] - V4U -> object [ "tag" .= ("V4U" :: Text)] - Int -> object [ "tag" .= ("Int" :: Text)] - V2I -> object [ "tag" .= ("V2I" :: Text)] - V3I -> object [ "tag" .= ("V3I" :: Text)] - V4I -> object [ "tag" .= ("V4I" :: Text)] - Float -> object [ "tag" .= ("Float" :: Text)] - V2F -> object [ "tag" .= ("V2F" :: Text)] - V3F -> object [ "tag" .= ("V3F" :: Text)] - V4F -> object [ "tag" .= ("V4F" :: Text)] - M22F -> object [ "tag" .= ("M22F" :: Text)] - M23F -> object [ "tag" .= ("M23F" :: Text)] - M24F -> object [ "tag" .= ("M24F" :: Text)] - M32F -> object [ "tag" .= ("M32F" :: Text)] - M33F -> object [ "tag" .= ("M33F" :: Text)] - M34F -> object [ "tag" .= ("M34F" :: Text)] - M42F -> object [ "tag" .= ("M42F" :: Text)] - M43F -> object [ "tag" .= ("M43F" :: Text)] - M44F -> object [ "tag" .= ("M44F" :: Text)] - STexture1D -> object [ "tag" .= ("STexture1D" :: Text)] - STexture2D -> object [ "tag" .= ("STexture2D" :: Text)] - STextureCube -> object [ "tag" .= ("STextureCube" :: Text)] - STexture1DArray -> object [ "tag" .= ("STexture1DArray" :: Text)] - STexture2DArray -> object [ "tag" .= ("STexture2DArray" :: Text)] - STexture2DRect -> object [ "tag" .= ("STexture2DRect" :: Text)] - FTexture1D -> object [ "tag" .= ("FTexture1D" :: Text)] - FTexture2D -> object [ "tag" .= ("FTexture2D" :: Text)] - FTexture3D -> object [ "tag" .= ("FTexture3D" :: Text)] - FTextureCube -> object [ "tag" .= ("FTextureCube" :: Text)] - FTexture1DArray -> object [ "tag" .= ("FTexture1DArray" :: Text)] - FTexture2DArray -> object [ "tag" .= ("FTexture2DArray" :: Text)] - FTexture2DMS -> object [ "tag" .= ("FTexture2DMS" :: Text)] - FTexture2DMSArray -> object [ "tag" .= ("FTexture2DMSArray" :: Text)] - FTextureBuffer -> object [ "tag" .= ("FTextureBuffer" :: Text)] - FTexture2DRect -> object [ "tag" .= ("FTexture2DRect" :: Text)] - ITexture1D -> object [ "tag" .= ("ITexture1D" :: Text)] - ITexture2D -> object [ "tag" .= ("ITexture2D" :: Text)] - ITexture3D -> object [ "tag" .= ("ITexture3D" :: Text)] - ITextureCube -> object [ "tag" .= ("ITextureCube" :: Text)] - ITexture1DArray -> object [ "tag" .= ("ITexture1DArray" :: Text)] - ITexture2DArray -> object [ "tag" .= ("ITexture2DArray" :: Text)] - ITexture2DMS -> object [ "tag" .= ("ITexture2DMS" :: Text)] - ITexture2DMSArray -> object [ "tag" .= ("ITexture2DMSArray" :: Text)] - ITextureBuffer -> object [ "tag" .= ("ITextureBuffer" :: Text)] - ITexture2DRect -> object [ "tag" .= ("ITexture2DRect" :: Text)] - UTexture1D -> object [ "tag" .= ("UTexture1D" :: Text)] - UTexture2D -> object [ "tag" .= ("UTexture2D" :: Text)] - UTexture3D -> object [ "tag" .= ("UTexture3D" :: Text)] - UTextureCube -> object [ "tag" .= ("UTextureCube" :: Text)] - UTexture1DArray -> object [ "tag" .= ("UTexture1DArray" :: Text)] - UTexture2DArray -> object [ "tag" .= ("UTexture2DArray" :: Text)] - UTexture2DMS -> object [ "tag" .= ("UTexture2DMS" :: Text)] - UTexture2DMSArray -> object [ "tag" .= ("UTexture2DMSArray" :: Text)] - UTextureBuffer -> object [ "tag" .= ("UTextureBuffer" :: Text)] - UTexture2DRect -> object [ "tag" .= ("UTexture2DRect" :: Text)] - -instance FromJSON InputType where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "Bool" -> pure Bool - "V2B" -> pure V2B - "V3B" -> pure V3B - "V4B" -> pure V4B - "Word" -> pure Word - "V2U" -> pure V2U - "V3U" -> pure V3U - "V4U" -> pure V4U - "Int" -> pure Int - "V2I" -> pure V2I - "V3I" -> pure V3I - "V4I" -> pure V4I - "Float" -> pure Float - "V2F" -> pure V2F - "V3F" -> pure V3F - "V4F" -> pure V4F - "M22F" -> pure M22F - "M23F" -> pure M23F - "M24F" -> pure M24F - "M32F" -> pure M32F - "M33F" -> pure M33F - "M34F" -> pure M34F - "M42F" -> pure M42F - "M43F" -> pure M43F - "M44F" -> pure M44F - "STexture1D" -> pure STexture1D - "STexture2D" -> pure STexture2D - "STextureCube" -> pure STextureCube - "STexture1DArray" -> pure STexture1DArray - "STexture2DArray" -> pure STexture2DArray - "STexture2DRect" -> pure STexture2DRect - "FTexture1D" -> pure FTexture1D - "FTexture2D" -> pure FTexture2D - "FTexture3D" -> pure FTexture3D - "FTextureCube" -> pure FTextureCube - "FTexture1DArray" -> pure FTexture1DArray - "FTexture2DArray" -> pure FTexture2DArray - "FTexture2DMS" -> pure FTexture2DMS - "FTexture2DMSArray" -> pure FTexture2DMSArray - "FTextureBuffer" -> pure FTextureBuffer - "FTexture2DRect" -> pure FTexture2DRect - "ITexture1D" -> pure ITexture1D - "ITexture2D" -> pure ITexture2D - "ITexture3D" -> pure ITexture3D - "ITextureCube" -> pure ITextureCube - "ITexture1DArray" -> pure ITexture1DArray - "ITexture2DArray" -> pure ITexture2DArray - "ITexture2DMS" -> pure ITexture2DMS - "ITexture2DMSArray" -> pure ITexture2DMSArray - "ITextureBuffer" -> pure ITextureBuffer - "ITexture2DRect" -> pure ITexture2DRect - "UTexture1D" -> pure UTexture1D - "UTexture2D" -> pure UTexture2D - "UTexture3D" -> pure UTexture3D - "UTextureCube" -> pure UTextureCube - "UTexture1DArray" -> pure UTexture1DArray - "UTexture2DArray" -> pure UTexture2DArray - "UTexture2DMS" -> pure UTexture2DMS - "UTexture2DMSArray" -> pure UTexture2DMSArray - "UTextureBuffer" -> pure UTextureBuffer - "UTexture2DRect" -> pure UTexture2DRect - parseJSON _ = mzero - -instance ToJSON PointSpriteCoordOrigin where - toJSON v = case v of - LowerLeft -> object [ "tag" .= ("LowerLeft" :: Text)] - UpperLeft -> object [ "tag" .= ("UpperLeft" :: Text)] - -instance FromJSON PointSpriteCoordOrigin where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "LowerLeft" -> pure LowerLeft - "UpperLeft" -> pure UpperLeft - parseJSON _ = mzero - -instance ToJSON PointSize where - toJSON v = case v of - PointSize arg0 -> object [ "tag" .= ("PointSize" :: Text), "arg0" .= arg0] - ProgramPointSize -> object [ "tag" .= ("ProgramPointSize" :: Text)] - -instance FromJSON PointSize where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "PointSize" -> PointSize <$> obj .: "arg0" - "ProgramPointSize" -> pure ProgramPointSize - parseJSON _ = mzero - -instance ToJSON PolygonOffset where - toJSON v = case v of - NoOffset -> object [ "tag" .= ("NoOffset" :: Text)] - Offset arg0 arg1 -> object [ "tag" .= ("Offset" :: Text), "arg0" .= arg0, "arg1" .= arg1] - -instance FromJSON PolygonOffset where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "NoOffset" -> pure NoOffset - "Offset" -> Offset <$> obj .: "arg0" <*> obj .: "arg1" - parseJSON _ = mzero - -instance ToJSON FrontFace where - toJSON v = case v of - CCW -> object [ "tag" .= ("CCW" :: Text)] - CW -> object [ "tag" .= ("CW" :: Text)] - -instance FromJSON FrontFace where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "CCW" -> pure CCW - "CW" -> pure CW - parseJSON _ = mzero - -instance ToJSON PolygonMode where - toJSON v = case v of - PolygonPoint arg0 -> object [ "tag" .= ("PolygonPoint" :: Text), "arg0" .= arg0] - PolygonLine arg0 -> object [ "tag" .= ("PolygonLine" :: Text), "arg0" .= arg0] - PolygonFill -> object [ "tag" .= ("PolygonFill" :: Text)] - -instance FromJSON PolygonMode where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "PolygonPoint" -> PolygonPoint <$> obj .: "arg0" - "PolygonLine" -> PolygonLine <$> obj .: "arg0" - "PolygonFill" -> pure PolygonFill - parseJSON _ = mzero - -instance ToJSON ProvokingVertex where - toJSON v = case v of - FirstVertex -> object [ "tag" .= ("FirstVertex" :: Text)] - LastVertex -> object [ "tag" .= ("LastVertex" :: Text)] - -instance FromJSON ProvokingVertex where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "FirstVertex" -> pure FirstVertex - "LastVertex" -> pure LastVertex - parseJSON _ = mzero - -instance ToJSON CullMode where - toJSON v = case v of - CullNone -> object [ "tag" .= ("CullNone" :: Text)] - CullFront arg0 -> object [ "tag" .= ("CullFront" :: Text), "arg0" .= arg0] - CullBack arg0 -> object [ "tag" .= ("CullBack" :: Text), "arg0" .= arg0] - -instance FromJSON CullMode where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "CullNone" -> pure CullNone - "CullFront" -> CullFront <$> obj .: "arg0" - "CullBack" -> CullBack <$> obj .: "arg0" - parseJSON _ = mzero - -instance ToJSON ComparisonFunction where - toJSON v = case v of - Never -> object [ "tag" .= ("Never" :: Text)] - Less -> object [ "tag" .= ("Less" :: Text)] - Equal -> object [ "tag" .= ("Equal" :: Text)] - Lequal -> object [ "tag" .= ("Lequal" :: Text)] - Greater -> object [ "tag" .= ("Greater" :: Text)] - Notequal -> object [ "tag" .= ("Notequal" :: Text)] - Gequal -> object [ "tag" .= ("Gequal" :: Text)] - Always -> object [ "tag" .= ("Always" :: Text)] - -instance FromJSON ComparisonFunction where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "Never" -> pure Never - "Less" -> pure Less - "Equal" -> pure Equal - "Lequal" -> pure Lequal - "Greater" -> pure Greater - "Notequal" -> pure Notequal - "Gequal" -> pure Gequal - "Always" -> pure Always - parseJSON _ = mzero - -instance ToJSON StencilOperation where - toJSON v = case v of - OpZero -> object [ "tag" .= ("OpZero" :: Text)] - OpKeep -> object [ "tag" .= ("OpKeep" :: Text)] - OpReplace -> object [ "tag" .= ("OpReplace" :: Text)] - OpIncr -> object [ "tag" .= ("OpIncr" :: Text)] - OpIncrWrap -> object [ "tag" .= ("OpIncrWrap" :: Text)] - OpDecr -> object [ "tag" .= ("OpDecr" :: Text)] - OpDecrWrap -> object [ "tag" .= ("OpDecrWrap" :: Text)] - OpInvert -> object [ "tag" .= ("OpInvert" :: Text)] - -instance FromJSON StencilOperation where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "OpZero" -> pure OpZero - "OpKeep" -> pure OpKeep - "OpReplace" -> pure OpReplace - "OpIncr" -> pure OpIncr - "OpIncrWrap" -> pure OpIncrWrap - "OpDecr" -> pure OpDecr - "OpDecrWrap" -> pure OpDecrWrap - "OpInvert" -> pure OpInvert - parseJSON _ = mzero - -instance ToJSON BlendEquation where - toJSON v = case v of - FuncAdd -> object [ "tag" .= ("FuncAdd" :: Text)] - FuncSubtract -> object [ "tag" .= ("FuncSubtract" :: Text)] - FuncReverseSubtract -> object [ "tag" .= ("FuncReverseSubtract" :: Text)] - Min -> object [ "tag" .= ("Min" :: Text)] - Max -> object [ "tag" .= ("Max" :: Text)] - -instance FromJSON BlendEquation where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "FuncAdd" -> pure FuncAdd - "FuncSubtract" -> pure FuncSubtract - "FuncReverseSubtract" -> pure FuncReverseSubtract - "Min" -> pure Min - "Max" -> pure Max - parseJSON _ = mzero - -instance ToJSON BlendingFactor where - toJSON v = case v of - Zero -> object [ "tag" .= ("Zero" :: Text)] - One -> object [ "tag" .= ("One" :: Text)] - SrcColor -> object [ "tag" .= ("SrcColor" :: Text)] - OneMinusSrcColor -> object [ "tag" .= ("OneMinusSrcColor" :: Text)] - DstColor -> object [ "tag" .= ("DstColor" :: Text)] - OneMinusDstColor -> object [ "tag" .= ("OneMinusDstColor" :: Text)] - SrcAlpha -> object [ "tag" .= ("SrcAlpha" :: Text)] - OneMinusSrcAlpha -> object [ "tag" .= ("OneMinusSrcAlpha" :: Text)] - DstAlpha -> object [ "tag" .= ("DstAlpha" :: Text)] - OneMinusDstAlpha -> object [ "tag" .= ("OneMinusDstAlpha" :: Text)] - ConstantColor -> object [ "tag" .= ("ConstantColor" :: Text)] - OneMinusConstantColor -> object [ "tag" .= ("OneMinusConstantColor" :: Text)] - ConstantAlpha -> object [ "tag" .= ("ConstantAlpha" :: Text)] - OneMinusConstantAlpha -> object [ "tag" .= ("OneMinusConstantAlpha" :: Text)] - SrcAlphaSaturate -> object [ "tag" .= ("SrcAlphaSaturate" :: Text)] - -instance FromJSON BlendingFactor where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "Zero" -> pure Zero - "One" -> pure One - "SrcColor" -> pure SrcColor - "OneMinusSrcColor" -> pure OneMinusSrcColor - "DstColor" -> pure DstColor - "OneMinusDstColor" -> pure OneMinusDstColor - "SrcAlpha" -> pure SrcAlpha - "OneMinusSrcAlpha" -> pure OneMinusSrcAlpha - "DstAlpha" -> pure DstAlpha - "OneMinusDstAlpha" -> pure OneMinusDstAlpha - "ConstantColor" -> pure ConstantColor - "OneMinusConstantColor" -> pure OneMinusConstantColor - "ConstantAlpha" -> pure ConstantAlpha - "OneMinusConstantAlpha" -> pure OneMinusConstantAlpha - "SrcAlphaSaturate" -> pure SrcAlphaSaturate - parseJSON _ = mzero - -instance ToJSON LogicOperation where - toJSON v = case v of - Clear -> object [ "tag" .= ("Clear" :: Text)] - And -> object [ "tag" .= ("And" :: Text)] - AndReverse -> object [ "tag" .= ("AndReverse" :: Text)] - Copy -> object [ "tag" .= ("Copy" :: Text)] - AndInverted -> object [ "tag" .= ("AndInverted" :: Text)] - Noop -> object [ "tag" .= ("Noop" :: Text)] - Xor -> object [ "tag" .= ("Xor" :: Text)] - Or -> object [ "tag" .= ("Or" :: Text)] - Nor -> object [ "tag" .= ("Nor" :: Text)] - Equiv -> object [ "tag" .= ("Equiv" :: Text)] - Invert -> object [ "tag" .= ("Invert" :: Text)] - OrReverse -> object [ "tag" .= ("OrReverse" :: Text)] - CopyInverted -> object [ "tag" .= ("CopyInverted" :: Text)] - OrInverted -> object [ "tag" .= ("OrInverted" :: Text)] - Nand -> object [ "tag" .= ("Nand" :: Text)] - Set -> object [ "tag" .= ("Set" :: Text)] - -instance FromJSON LogicOperation where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "Clear" -> pure Clear - "And" -> pure And - "AndReverse" -> pure AndReverse - "Copy" -> pure Copy - "AndInverted" -> pure AndInverted - "Noop" -> pure Noop - "Xor" -> pure Xor - "Or" -> pure Or - "Nor" -> pure Nor - "Equiv" -> pure Equiv - "Invert" -> pure Invert - "OrReverse" -> pure OrReverse - "CopyInverted" -> pure CopyInverted - "OrInverted" -> pure OrInverted - "Nand" -> pure Nand - "Set" -> pure Set - parseJSON _ = mzero - -instance ToJSON StencilOps where - toJSON v = case v of - StencilOps{..} -> object - [ "tag" .= ("StencilOps" :: Text) - , "frontStencilOp" .= frontStencilOp - , "backStencilOp" .= backStencilOp - ] - -instance FromJSON StencilOps where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "StencilOps" -> do - frontStencilOp <- obj .: "frontStencilOp" - backStencilOp <- obj .: "backStencilOp" - pure $ StencilOps - { frontStencilOp = frontStencilOp - , backStencilOp = backStencilOp - } - parseJSON _ = mzero - -instance ToJSON StencilTest where - toJSON v = case v of - StencilTest{..} -> object - [ "tag" .= ("StencilTest" :: Text) - , "stencilComparision" .= stencilComparision - , "stencilReference" .= stencilReference - , "stencilMask" .= stencilMask - ] - -instance FromJSON StencilTest where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "StencilTest" -> do - stencilComparision <- obj .: "stencilComparision" - stencilReference <- obj .: "stencilReference" - stencilMask <- obj .: "stencilMask" - pure $ StencilTest - { stencilComparision = stencilComparision - , stencilReference = stencilReference - , stencilMask = stencilMask - } - parseJSON _ = mzero - -instance ToJSON StencilTests where - toJSON v = case v of - StencilTests arg0 arg1 -> object [ "tag" .= ("StencilTests" :: Text), "arg0" .= arg0, "arg1" .= arg1] - -instance FromJSON StencilTests where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "StencilTests" -> StencilTests <$> obj .: "arg0" <*> obj .: "arg1" - parseJSON _ = mzero - -instance ToJSON FetchPrimitive where - toJSON v = case v of - Points -> object [ "tag" .= ("Points" :: Text)] - Lines -> object [ "tag" .= ("Lines" :: Text)] - Triangles -> object [ "tag" .= ("Triangles" :: Text)] - LinesAdjacency -> object [ "tag" .= ("LinesAdjacency" :: Text)] - TrianglesAdjacency -> object [ "tag" .= ("TrianglesAdjacency" :: Text)] - -instance FromJSON FetchPrimitive where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "Points" -> pure Points - "Lines" -> pure Lines - "Triangles" -> pure Triangles - "LinesAdjacency" -> pure LinesAdjacency - "TrianglesAdjacency" -> pure TrianglesAdjacency - parseJSON _ = mzero - -instance ToJSON OutputPrimitive where - toJSON v = case v of - TrianglesOutput -> object [ "tag" .= ("TrianglesOutput" :: Text)] - LinesOutput -> object [ "tag" .= ("LinesOutput" :: Text)] - PointsOutput -> object [ "tag" .= ("PointsOutput" :: Text)] - -instance FromJSON OutputPrimitive where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "TrianglesOutput" -> pure TrianglesOutput - "LinesOutput" -> pure LinesOutput - "PointsOutput" -> pure PointsOutput - parseJSON _ = mzero - -instance ToJSON ColorArity where - toJSON v = case v of - Red -> object [ "tag" .= ("Red" :: Text)] - RG -> object [ "tag" .= ("RG" :: Text)] - RGB -> object [ "tag" .= ("RGB" :: Text)] - RGBA -> object [ "tag" .= ("RGBA" :: Text)] - -instance FromJSON ColorArity where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "Red" -> pure Red - "RG" -> pure RG - "RGB" -> pure RGB - "RGBA" -> pure RGBA - parseJSON _ = mzero - -instance ToJSON Blending where - toJSON v = case v of - NoBlending -> object [ "tag" .= ("NoBlending" :: Text)] - BlendLogicOp arg0 -> object [ "tag" .= ("BlendLogicOp" :: Text), "arg0" .= arg0] - Blend{..} -> object - [ "tag" .= ("Blend" :: Text) - , "colorEqSrc" .= colorEqSrc - , "alphaEqSrc" .= alphaEqSrc - , "colorFSrc" .= colorFSrc - , "colorFDst" .= colorFDst - , "alphaFSrc" .= alphaFSrc - , "alphaFDst" .= alphaFDst - , "color" .= color - ] - -instance FromJSON Blending where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "NoBlending" -> pure NoBlending - "BlendLogicOp" -> BlendLogicOp <$> obj .: "arg0" - "Blend" -> do - colorEqSrc <- obj .: "colorEqSrc" - alphaEqSrc <- obj .: "alphaEqSrc" - colorFSrc <- obj .: "colorFSrc" - colorFDst <- obj .: "colorFDst" - alphaFSrc <- obj .: "alphaFSrc" - alphaFDst <- obj .: "alphaFDst" - color <- obj .: "color" - pure $ Blend - { colorEqSrc = colorEqSrc - , alphaEqSrc = alphaEqSrc - , colorFSrc = colorFSrc - , colorFDst = colorFDst - , alphaFSrc = alphaFSrc - , alphaFDst = alphaFDst - , color = color - } - parseJSON _ = mzero - -instance ToJSON RasterContext where - toJSON v = case v of - PointCtx arg0 arg1 arg2 -> object [ "tag" .= ("PointCtx" :: Text), "arg0" .= arg0, "arg1" .= arg1, "arg2" .= arg2] - LineCtx arg0 arg1 -> object [ "tag" .= ("LineCtx" :: Text), "arg0" .= arg0, "arg1" .= arg1] - TriangleCtx arg0 arg1 arg2 arg3 -> object [ "tag" .= ("TriangleCtx" :: Text), "arg0" .= arg0, "arg1" .= arg1, "arg2" .= arg2, "arg3" .= arg3] - -instance FromJSON RasterContext where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "PointCtx" -> PointCtx <$> obj .: "arg0" <*> obj .: "arg1" <*> obj .: "arg2" - "LineCtx" -> LineCtx <$> obj .: "arg0" <*> obj .: "arg1" - "TriangleCtx" -> TriangleCtx <$> obj .: "arg0" <*> obj .: "arg1" <*> obj .: "arg2" <*> obj .: "arg3" - parseJSON _ = mzero - -instance ToJSON FragmentOperation where - toJSON v = case v of - DepthOp arg0 arg1 -> object [ "tag" .= ("DepthOp" :: Text), "arg0" .= arg0, "arg1" .= arg1] - StencilOp arg0 arg1 arg2 -> object [ "tag" .= ("StencilOp" :: Text), "arg0" .= arg0, "arg1" .= arg1, "arg2" .= arg2] - ColorOp arg0 arg1 -> object [ "tag" .= ("ColorOp" :: Text), "arg0" .= arg0, "arg1" .= arg1] - -instance FromJSON FragmentOperation where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "DepthOp" -> DepthOp <$> obj .: "arg0" <*> obj .: "arg1" - "StencilOp" -> StencilOp <$> obj .: "arg0" <*> obj .: "arg1" <*> obj .: "arg2" - "ColorOp" -> ColorOp <$> obj .: "arg0" <*> obj .: "arg1" - parseJSON _ = mzero - -instance ToJSON AccumulationContext where - toJSON v = case v of - AccumulationContext{..} -> object - [ "tag" .= ("AccumulationContext" :: Text) - , "accViewportName" .= accViewportName - , "accOperations" .= accOperations - ] - -instance FromJSON AccumulationContext where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "AccumulationContext" -> do - accViewportName <- obj .: "accViewportName" - accOperations <- obj .: "accOperations" - pure $ AccumulationContext - { accViewportName = accViewportName - , accOperations = accOperations - } - parseJSON _ = mzero - -instance ToJSON TextureDataType where - toJSON v = case v of - FloatT arg0 -> object [ "tag" .= ("FloatT" :: Text), "arg0" .= arg0] - IntT arg0 -> object [ "tag" .= ("IntT" :: Text), "arg0" .= arg0] - WordT arg0 -> object [ "tag" .= ("WordT" :: Text), "arg0" .= arg0] - ShadowT -> object [ "tag" .= ("ShadowT" :: Text)] - -instance FromJSON TextureDataType where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "FloatT" -> FloatT <$> obj .: "arg0" - "IntT" -> IntT <$> obj .: "arg0" - "WordT" -> WordT <$> obj .: "arg0" - "ShadowT" -> pure ShadowT - parseJSON _ = mzero - -instance ToJSON TextureType where - toJSON v = case v of - Texture1D arg0 arg1 -> object [ "tag" .= ("Texture1D" :: Text), "arg0" .= arg0, "arg1" .= arg1] - Texture2D arg0 arg1 -> object [ "tag" .= ("Texture2D" :: Text), "arg0" .= arg0, "arg1" .= arg1] - Texture3D arg0 -> object [ "tag" .= ("Texture3D" :: Text), "arg0" .= arg0] - TextureCube arg0 -> object [ "tag" .= ("TextureCube" :: Text), "arg0" .= arg0] - TextureRect arg0 -> object [ "tag" .= ("TextureRect" :: Text), "arg0" .= arg0] - Texture2DMS arg0 arg1 arg2 arg3 -> object [ "tag" .= ("Texture2DMS" :: Text), "arg0" .= arg0, "arg1" .= arg1, "arg2" .= arg2, "arg3" .= arg3] - TextureBuffer arg0 -> object [ "tag" .= ("TextureBuffer" :: Text), "arg0" .= arg0] - -instance FromJSON TextureType where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "Texture1D" -> Texture1D <$> obj .: "arg0" <*> obj .: "arg1" - "Texture2D" -> Texture2D <$> obj .: "arg0" <*> obj .: "arg1" - "Texture3D" -> Texture3D <$> obj .: "arg0" - "TextureCube" -> TextureCube <$> obj .: "arg0" - "TextureRect" -> TextureRect <$> obj .: "arg0" - "Texture2DMS" -> Texture2DMS <$> obj .: "arg0" <*> obj .: "arg1" <*> obj .: "arg2" <*> obj .: "arg3" - "TextureBuffer" -> TextureBuffer <$> obj .: "arg0" - parseJSON _ = mzero - -instance ToJSON MipMap where - toJSON v = case v of - Mip arg0 arg1 -> object [ "tag" .= ("Mip" :: Text), "arg0" .= arg0, "arg1" .= arg1] - NoMip -> object [ "tag" .= ("NoMip" :: Text)] - AutoMip arg0 arg1 -> object [ "tag" .= ("AutoMip" :: Text), "arg0" .= arg0, "arg1" .= arg1] - -instance FromJSON MipMap where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "Mip" -> Mip <$> obj .: "arg0" <*> obj .: "arg1" - "NoMip" -> pure NoMip - "AutoMip" -> AutoMip <$> obj .: "arg0" <*> obj .: "arg1" - parseJSON _ = mzero - -instance ToJSON Filter where - toJSON v = case v of - Nearest -> object [ "tag" .= ("Nearest" :: Text)] - Linear -> object [ "tag" .= ("Linear" :: Text)] - NearestMipmapNearest -> object [ "tag" .= ("NearestMipmapNearest" :: Text)] - NearestMipmapLinear -> object [ "tag" .= ("NearestMipmapLinear" :: Text)] - LinearMipmapNearest -> object [ "tag" .= ("LinearMipmapNearest" :: Text)] - LinearMipmapLinear -> object [ "tag" .= ("LinearMipmapLinear" :: Text)] - -instance FromJSON Filter where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "Nearest" -> pure Nearest - "Linear" -> pure Linear - "NearestMipmapNearest" -> pure NearestMipmapNearest - "NearestMipmapLinear" -> pure NearestMipmapLinear - "LinearMipmapNearest" -> pure LinearMipmapNearest - "LinearMipmapLinear" -> pure LinearMipmapLinear - parseJSON _ = mzero - -instance ToJSON EdgeMode where - toJSON v = case v of - Repeat -> object [ "tag" .= ("Repeat" :: Text)] - MirroredRepeat -> object [ "tag" .= ("MirroredRepeat" :: Text)] - ClampToEdge -> object [ "tag" .= ("ClampToEdge" :: Text)] - ClampToBorder -> object [ "tag" .= ("ClampToBorder" :: Text)] - -instance FromJSON EdgeMode where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "Repeat" -> pure Repeat - "MirroredRepeat" -> pure MirroredRepeat - "ClampToEdge" -> pure ClampToEdge - "ClampToBorder" -> pure ClampToBorder - parseJSON _ = mzero - -instance ToJSON ImageSemantic where - toJSON v = case v of - Depth -> object [ "tag" .= ("Depth" :: Text)] - Stencil -> object [ "tag" .= ("Stencil" :: Text)] - Color -> object [ "tag" .= ("Color" :: Text)] - -instance FromJSON ImageSemantic where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "Depth" -> pure Depth - "Stencil" -> pure Stencil - "Color" -> pure Color - parseJSON _ = mzero - -instance ToJSON ImageRef where - toJSON v = case v of - TextureImage arg0 arg1 arg2 -> object [ "tag" .= ("TextureImage" :: Text), "arg0" .= arg0, "arg1" .= arg1, "arg2" .= arg2] - Framebuffer arg0 -> object [ "tag" .= ("Framebuffer" :: Text), "arg0" .= arg0] - -instance FromJSON ImageRef where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "TextureImage" -> TextureImage <$> obj .: "arg0" <*> obj .: "arg1" <*> obj .: "arg2" - "Framebuffer" -> Framebuffer <$> obj .: "arg0" - parseJSON _ = mzero - -instance ToJSON ClearImage where - toJSON v = case v of - ClearImage{..} -> object - [ "tag" .= ("ClearImage" :: Text) - , "imageSemantic" .= imageSemantic - , "clearValue" .= clearValue - ] - -instance FromJSON ClearImage where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "ClearImage" -> do - imageSemantic <- obj .: "imageSemantic" - clearValue <- obj .: "clearValue" - pure $ ClearImage - { imageSemantic = imageSemantic - , clearValue = clearValue - } - parseJSON _ = mzero - -instance ToJSON Command where - toJSON v = case v of - SetRasterContext arg0 -> object [ "tag" .= ("SetRasterContext" :: Text), "arg0" .= arg0] - SetAccumulationContext arg0 -> object [ "tag" .= ("SetAccumulationContext" :: Text), "arg0" .= arg0] - SetRenderTarget arg0 -> object [ "tag" .= ("SetRenderTarget" :: Text), "arg0" .= arg0] - SetProgram arg0 -> object [ "tag" .= ("SetProgram" :: Text), "arg0" .= arg0] - SetSamplerUniform arg0 arg1 -> object [ "tag" .= ("SetSamplerUniform" :: Text), "arg0" .= arg0, "arg1" .= arg1] - SetTexture arg0 arg1 -> object [ "tag" .= ("SetTexture" :: Text), "arg0" .= arg0, "arg1" .= arg1] - SetSampler arg0 arg1 -> object [ "tag" .= ("SetSampler" :: Text), "arg0" .= arg0, "arg1" .= arg1] - RenderSlot arg0 -> object [ "tag" .= ("RenderSlot" :: Text), "arg0" .= arg0] - RenderStream arg0 -> object [ "tag" .= ("RenderStream" :: Text), "arg0" .= arg0] - ClearRenderTarget arg0 -> object [ "tag" .= ("ClearRenderTarget" :: Text), "arg0" .= arg0] - GenerateMipMap arg0 -> object [ "tag" .= ("GenerateMipMap" :: Text), "arg0" .= arg0] - SaveImage arg0 arg1 -> object [ "tag" .= ("SaveImage" :: Text), "arg0" .= arg0, "arg1" .= arg1] - LoadImage arg0 arg1 -> object [ "tag" .= ("LoadImage" :: Text), "arg0" .= arg0, "arg1" .= arg1] - -instance FromJSON Command where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "SetRasterContext" -> SetRasterContext <$> obj .: "arg0" - "SetAccumulationContext" -> SetAccumulationContext <$> obj .: "arg0" - "SetRenderTarget" -> SetRenderTarget <$> obj .: "arg0" - "SetProgram" -> SetProgram <$> obj .: "arg0" - "SetSamplerUniform" -> SetSamplerUniform <$> obj .: "arg0" <*> obj .: "arg1" - "SetTexture" -> SetTexture <$> obj .: "arg0" <*> obj .: "arg1" - "SetSampler" -> SetSampler <$> obj .: "arg0" <*> obj .: "arg1" - "RenderSlot" -> RenderSlot <$> obj .: "arg0" - "RenderStream" -> RenderStream <$> obj .: "arg0" - "ClearRenderTarget" -> ClearRenderTarget <$> obj .: "arg0" - "GenerateMipMap" -> GenerateMipMap <$> obj .: "arg0" - "SaveImage" -> SaveImage <$> obj .: "arg0" <*> obj .: "arg1" - "LoadImage" -> LoadImage <$> obj .: "arg0" <*> obj .: "arg1" - parseJSON _ = mzero - -instance ToJSON SamplerDescriptor where - toJSON v = case v of - SamplerDescriptor{..} -> object - [ "tag" .= ("SamplerDescriptor" :: Text) - , "samplerWrapS" .= samplerWrapS - , "samplerWrapT" .= samplerWrapT - , "samplerWrapR" .= samplerWrapR - , "samplerMinFilter" .= samplerMinFilter - , "samplerMagFilter" .= samplerMagFilter - , "samplerBorderColor" .= samplerBorderColor - , "samplerMinLod" .= samplerMinLod - , "samplerMaxLod" .= samplerMaxLod - , "samplerLodBias" .= samplerLodBias - , "samplerCompareFunc" .= samplerCompareFunc - ] - -instance FromJSON SamplerDescriptor where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "SamplerDescriptor" -> do - samplerWrapS <- obj .: "samplerWrapS" - samplerWrapT <- obj .: "samplerWrapT" - samplerWrapR <- obj .: "samplerWrapR" - samplerMinFilter <- obj .: "samplerMinFilter" - samplerMagFilter <- obj .: "samplerMagFilter" - samplerBorderColor <- obj .: "samplerBorderColor" - samplerMinLod <- obj .: "samplerMinLod" - samplerMaxLod <- obj .: "samplerMaxLod" - samplerLodBias <- obj .: "samplerLodBias" - samplerCompareFunc <- obj .: "samplerCompareFunc" - pure $ SamplerDescriptor - { samplerWrapS = samplerWrapS - , samplerWrapT = samplerWrapT - , samplerWrapR = samplerWrapR - , samplerMinFilter = samplerMinFilter - , samplerMagFilter = samplerMagFilter - , samplerBorderColor = samplerBorderColor - , samplerMinLod = samplerMinLod - , samplerMaxLod = samplerMaxLod - , samplerLodBias = samplerLodBias - , samplerCompareFunc = samplerCompareFunc - } - parseJSON _ = mzero - -instance ToJSON TextureDescriptor where - toJSON v = case v of - TextureDescriptor{..} -> object - [ "tag" .= ("TextureDescriptor" :: Text) - , "textureType" .= textureType - , "textureSize" .= textureSize - , "textureSemantic" .= textureSemantic - , "textureSampler" .= textureSampler - , "textureBaseLevel" .= textureBaseLevel - , "textureMaxLevel" .= textureMaxLevel - ] - -instance FromJSON TextureDescriptor where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "TextureDescriptor" -> do - textureType <- obj .: "textureType" - textureSize <- obj .: "textureSize" - textureSemantic <- obj .: "textureSemantic" - textureSampler <- obj .: "textureSampler" - textureBaseLevel <- obj .: "textureBaseLevel" - textureMaxLevel <- obj .: "textureMaxLevel" - pure $ TextureDescriptor - { textureType = textureType - , textureSize = textureSize - , textureSemantic = textureSemantic - , textureSampler = textureSampler - , textureBaseLevel = textureBaseLevel - , textureMaxLevel = textureMaxLevel - } - parseJSON _ = mzero - -instance ToJSON Parameter where - toJSON v = case v of - Parameter{..} -> object - [ "tag" .= ("Parameter" :: Text) - , "name" .= name - , "ty" .= ty - ] - -instance FromJSON Parameter where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "Parameter" -> do - name <- obj .: "name" - ty <- obj .: "ty" - pure $ Parameter - { name = name - , ty = ty - } - parseJSON _ = mzero - -instance ToJSON Program where - toJSON v = case v of - Program{..} -> object - [ "tag" .= ("Program" :: Text) - , "programUniforms" .= programUniforms - , "programStreams" .= programStreams - , "programInTextures" .= programInTextures - , "programOutput" .= programOutput - , "vertexShader" .= vertexShader - , "geometryShader" .= geometryShader - , "fragmentShader" .= fragmentShader - ] - -instance FromJSON Program where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "Program" -> do - programUniforms <- obj .: "programUniforms" - programStreams <- obj .: "programStreams" - programInTextures <- obj .: "programInTextures" - programOutput <- obj .: "programOutput" - vertexShader <- obj .: "vertexShader" - geometryShader <- obj .: "geometryShader" - fragmentShader <- obj .: "fragmentShader" - pure $ Program - { programUniforms = programUniforms - , programStreams = programStreams - , programInTextures = programInTextures - , programOutput = programOutput - , vertexShader = vertexShader - , geometryShader = geometryShader - , fragmentShader = fragmentShader - } - parseJSON _ = mzero - -instance ToJSON Slot where - toJSON v = case v of - Slot{..} -> object - [ "tag" .= ("Slot" :: Text) - , "slotName" .= slotName - , "slotStreams" .= slotStreams - , "slotUniforms" .= slotUniforms - , "slotPrimitive" .= slotPrimitive - , "slotPrograms" .= slotPrograms - ] - -instance FromJSON Slot where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "Slot" -> do - slotName <- obj .: "slotName" - slotStreams <- obj .: "slotStreams" - slotUniforms <- obj .: "slotUniforms" - slotPrimitive <- obj .: "slotPrimitive" - slotPrograms <- obj .: "slotPrograms" - pure $ Slot - { slotName = slotName - , slotStreams = slotStreams - , slotUniforms = slotUniforms - , slotPrimitive = slotPrimitive - , slotPrograms = slotPrograms - } - parseJSON _ = mzero - -instance ToJSON StreamData where - toJSON v = case v of - StreamData{..} -> object - [ "tag" .= ("StreamData" :: Text) - , "streamData" .= streamData - , "streamType" .= streamType - , "streamPrimitive" .= streamPrimitive - , "streamPrograms" .= streamPrograms - ] - -instance FromJSON StreamData where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "StreamData" -> do - streamData <- obj .: "streamData" - streamType <- obj .: "streamType" - streamPrimitive <- obj .: "streamPrimitive" - streamPrograms <- obj .: "streamPrograms" - pure $ StreamData - { streamData = streamData - , streamType = streamType - , streamPrimitive = streamPrimitive - , streamPrograms = streamPrograms - } - parseJSON _ = mzero - -instance ToJSON TargetItem where - toJSON v = case v of - TargetItem{..} -> object - [ "tag" .= ("TargetItem" :: Text) - , "targetSemantic" .= targetSemantic - , "targetRef" .= targetRef - ] - -instance FromJSON TargetItem where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "TargetItem" -> do - targetSemantic <- obj .: "targetSemantic" - targetRef <- obj .: "targetRef" - pure $ TargetItem - { targetSemantic = targetSemantic - , targetRef = targetRef - } - parseJSON _ = mzero - -instance ToJSON RenderTarget where - toJSON v = case v of - RenderTarget{..} -> object - [ "tag" .= ("RenderTarget" :: Text) - , "renderTargets" .= renderTargets - ] - -instance FromJSON RenderTarget where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "RenderTarget" -> do - renderTargets <- obj .: "renderTargets" - pure $ RenderTarget - { renderTargets = renderTargets - } - parseJSON _ = mzero - -instance ToJSON Backend where - toJSON v = case v of - WebGL1 -> object [ "tag" .= ("WebGL1" :: Text)] - OpenGL33 -> object [ "tag" .= ("OpenGL33" :: Text)] - -instance FromJSON Backend where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "WebGL1" -> pure WebGL1 - "OpenGL33" -> pure OpenGL33 - parseJSON _ = mzero - -instance ToJSON Pipeline where - toJSON v = case v of - Pipeline{..} -> object - [ "tag" .= ("Pipeline" :: Text) - , "backend" .= backend - , "textures" .= textures - , "samplers" .= samplers - , "targets" .= targets - , "programs" .= programs - , "slots" .= slots - , "streams" .= streams - , "commands" .= commands - ] - -instance FromJSON Pipeline where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "Pipeline" -> do - backend <- obj .: "backend" - textures <- obj .: "textures" - samplers <- obj .: "samplers" - targets <- obj .: "targets" - programs <- obj .: "programs" - slots <- obj .: "slots" - streams <- obj .: "streams" - commands <- obj .: "commands" - pure $ Pipeline - { backend = backend - , textures = textures - , samplers = samplers - , targets = targets - , programs = programs - , slots = slots - , streams = streams - , commands = commands - } - parseJSON _ = mzero - diff --git a/ddl/out/IR.purs b/ddl/out/IR.purs deleted file mode 100644 index bfdeb62..0000000 --- a/ddl/out/IR.purs +++ /dev/null @@ -1,1590 +0,0 @@ --- generated file, do not modify! --- 2016-01-18T14:30:07.798481Z - -module IR where -import Prelude -import Data.Generic -import Data.Maybe (Maybe(..)) -import Data.StrMap (StrMap(..)) -import Data.Map (Map(..)) -import Data.List (List(..)) -import Linear - -import Data.Argonaut.Combinators ((~>), (:=), (.?)) -import Data.Argonaut.Core (jsonEmptyObject) -import Data.Argonaut.Printer (printJson) -import Data.Argonaut.Encode (EncodeJson, encodeJson) -import Data.Argonaut.Decode (DecodeJson, decodeJson) - - -type StreamName = Int - -type ProgramName = Int - -type TextureName = Int - -type SamplerName = Int - -type UniformName = String - -type SlotName = Int - -type FrameBufferComponent = Int - -type TextureUnit = Int - -type RenderTargetName = Int - -type TextureUnitMapping = StrMap TextureUnit - -data ArrayValue - = VBoolArray (Array Bool) - | VIntArray (Array Int32) - | VWordArray (Array Word32) - | VFloatArray (Array Float) - -data Value - = VBool Bool - | VV2B V2B - | VV3B V3B - | VV4B V4B - | VWord Word32 - | VV2U V2U - | VV3U V3U - | VV4U V4U - | VInt Int32 - | VV2I V2I - | VV3I V3I - | VV4I V4I - | VFloat Float - | VV2F V2F - | VV3F V3F - | VV4F V4F - | VM22F M22F - | VM23F M23F - | VM24F M24F - | VM32F M32F - | VM33F M33F - | VM34F M34F - | VM42F M42F - | VM43F M43F - | VM44F M44F - -data InputType - = Bool - | V2B - | V3B - | V4B - | Word - | V2U - | V3U - | V4U - | Int - | V2I - | V3I - | V4I - | Float - | V2F - | V3F - | V4F - | M22F - | M23F - | M24F - | M32F - | M33F - | M34F - | M42F - | M43F - | M44F - | STexture1D - | STexture2D - | STextureCube - | STexture1DArray - | STexture2DArray - | STexture2DRect - | FTexture1D - | FTexture2D - | FTexture3D - | FTextureCube - | FTexture1DArray - | FTexture2DArray - | FTexture2DMS - | FTexture2DMSArray - | FTextureBuffer - | FTexture2DRect - | ITexture1D - | ITexture2D - | ITexture3D - | ITextureCube - | ITexture1DArray - | ITexture2DArray - | ITexture2DMS - | ITexture2DMSArray - | ITextureBuffer - | ITexture2DRect - | UTexture1D - | UTexture2D - | UTexture3D - | UTextureCube - | UTexture1DArray - | UTexture2DArray - | UTexture2DMS - | UTexture2DMSArray - | UTextureBuffer - | UTexture2DRect - -data PointSpriteCoordOrigin - = LowerLeft - | UpperLeft - -data PointSize - = PointSize Float - | ProgramPointSize - -data PolygonOffset - = NoOffset - | Offset Float Float - -data FrontFace - = CCW - | CW - -data PolygonMode - = PolygonPoint PointSize - | PolygonLine Float - | PolygonFill - -data ProvokingVertex - = FirstVertex - | LastVertex - -data CullMode - = CullNone - | CullFront FrontFace - | CullBack FrontFace - -data ComparisonFunction - = Never - | Less - | Equal - | Lequal - | Greater - | Notequal - | Gequal - | Always - -type DepthFunction = ComparisonFunction - -data StencilOperation - = OpZero - | OpKeep - | OpReplace - | OpIncr - | OpIncrWrap - | OpDecr - | OpDecrWrap - | OpInvert - -data BlendEquation - = FuncAdd - | FuncSubtract - | FuncReverseSubtract - | Min - | Max - -data BlendingFactor - = Zero - | One - | SrcColor - | OneMinusSrcColor - | DstColor - | OneMinusDstColor - | SrcAlpha - | OneMinusSrcAlpha - | DstAlpha - | OneMinusDstAlpha - | ConstantColor - | OneMinusConstantColor - | ConstantAlpha - | OneMinusConstantAlpha - | SrcAlphaSaturate - -data LogicOperation - = Clear - | And - | AndReverse - | Copy - | AndInverted - | Noop - | Xor - | Or - | Nor - | Equiv - | Invert - | OrReverse - | CopyInverted - | OrInverted - | Nand - | Set - -data StencilOps - = StencilOps - { frontStencilOp :: StencilOperation - , backStencilOp :: StencilOperation - } - - -data StencilTest - = StencilTest - { stencilComparision :: ComparisonFunction - , stencilReference :: Int32 - , stencilMask :: Word32 - } - - -data StencilTests - = StencilTests StencilTest StencilTest - -data FetchPrimitive - = Points - | Lines - | Triangles - | LinesAdjacency - | TrianglesAdjacency - -data OutputPrimitive - = TrianglesOutput - | LinesOutput - | PointsOutput - -data ColorArity - = Red - | RG - | RGB - | RGBA - -data Blending - = NoBlending - | BlendLogicOp LogicOperation - | Blend - { colorEqSrc :: BlendEquation - , alphaEqSrc :: BlendEquation - , colorFSrc :: BlendingFactor - , colorFDst :: BlendingFactor - , alphaFSrc :: BlendingFactor - , alphaFDst :: BlendingFactor - , color :: V4F - } - - -data RasterContext - = PointCtx PointSize Float PointSpriteCoordOrigin - | LineCtx Float ProvokingVertex - | TriangleCtx CullMode PolygonMode PolygonOffset ProvokingVertex - -data FragmentOperation - = DepthOp DepthFunction Bool - | StencilOp StencilTests StencilOps StencilOps - | ColorOp Blending Value - -data AccumulationContext - = AccumulationContext - { accViewportName :: Maybe String - , accOperations :: List FragmentOperation - } - - -data TextureDataType - = FloatT ColorArity - | IntT ColorArity - | WordT ColorArity - | ShadowT - -data TextureType - = Texture1D TextureDataType Int - | Texture2D TextureDataType Int - | Texture3D TextureDataType - | TextureCube TextureDataType - | TextureRect TextureDataType - | Texture2DMS TextureDataType Int Int Bool - | TextureBuffer TextureDataType - -data MipMap - = Mip Int Int - | NoMip - | AutoMip Int Int - -data Filter - = Nearest - | Linear - | NearestMipmapNearest - | NearestMipmapLinear - | LinearMipmapNearest - | LinearMipmapLinear - -data EdgeMode - = Repeat - | MirroredRepeat - | ClampToEdge - | ClampToBorder - -data ImageSemantic - = Depth - | Stencil - | Color - -data ImageRef - = TextureImage TextureName Int (Maybe Int) - | Framebuffer ImageSemantic - -data ClearImage - = ClearImage - { imageSemantic :: ImageSemantic - , clearValue :: Value - } - - -data Command - = SetRasterContext RasterContext - | SetAccumulationContext AccumulationContext - | SetRenderTarget RenderTargetName - | SetProgram ProgramName - | SetSamplerUniform UniformName TextureUnit - | SetTexture TextureUnit TextureName - | SetSampler TextureUnit (Maybe SamplerName) - | RenderSlot SlotName - | RenderStream StreamName - | ClearRenderTarget (Array ClearImage) - | GenerateMipMap TextureUnit - | SaveImage FrameBufferComponent ImageRef - | LoadImage ImageRef FrameBufferComponent - -data SamplerDescriptor - = SamplerDescriptor - { samplerWrapS :: EdgeMode - , samplerWrapT :: Maybe EdgeMode - , samplerWrapR :: Maybe EdgeMode - , samplerMinFilter :: Filter - , samplerMagFilter :: Filter - , samplerBorderColor :: Value - , samplerMinLod :: Maybe Float - , samplerMaxLod :: Maybe Float - , samplerLodBias :: Float - , samplerCompareFunc :: Maybe ComparisonFunction - } - - -data TextureDescriptor - = TextureDescriptor - { textureType :: TextureType - , textureSize :: Value - , textureSemantic :: ImageSemantic - , textureSampler :: SamplerDescriptor - , textureBaseLevel :: Int - , textureMaxLevel :: Int - } - - -data Parameter - = Parameter - { name :: String - , ty :: InputType - } - - -data Program - = Program - { programUniforms :: StrMap InputType - , programStreams :: StrMap Parameter - , programInTextures :: StrMap InputType - , programOutput :: Array Parameter - , vertexShader :: String - , geometryShader :: Maybe String - , fragmentShader :: String - } - - -data Slot - = Slot - { slotName :: String - , slotStreams :: StrMap InputType - , slotUniforms :: StrMap InputType - , slotPrimitive :: FetchPrimitive - , slotPrograms :: Array ProgramName - } - - -data StreamData - = StreamData - { streamData :: StrMap ArrayValue - , streamType :: StrMap InputType - , streamPrimitive :: FetchPrimitive - , streamPrograms :: Array ProgramName - } - - -data TargetItem - = TargetItem - { targetSemantic :: ImageSemantic - , targetRef :: Maybe ImageRef - } - - -data RenderTarget - = RenderTarget - { renderTargets :: Array TargetItem - } - - -data Backend - = WebGL1 - | OpenGL33 - -data Pipeline - = Pipeline - { backend :: Backend - , textures :: Array TextureDescriptor - , samplers :: Array SamplerDescriptor - , targets :: Array RenderTarget - , programs :: Array Program - , slots :: Array Slot - , streams :: Array StreamData - , commands :: Array Command - } - - - -derive instance genericInputType :: Generic InputType -instance showInputType :: Show InputType where show = gShow -instance eqInputType :: Eq InputType where eq = gEq - -derive instance genericFetchPrimitive :: Generic FetchPrimitive -instance showFetchPrimitive :: Show FetchPrimitive where show = gShow -instance eqFetchPrimitive :: Eq FetchPrimitive where eq = gEq - -derive instance genericColorArity :: Generic ColorArity -instance showColorArity :: Show ColorArity where show = gShow -instance eqColorArity :: Eq ColorArity where eq = gEq - -derive instance genericTextureDataType :: Generic TextureDataType -instance showTextureDataType :: Show TextureDataType where show = gShow -instance eqTextureDataType :: Eq TextureDataType where eq = gEq - -derive instance genericImageSemantic :: Generic ImageSemantic -instance showImageSemantic :: Show ImageSemantic where show = gShow -instance eqImageSemantic :: Eq ImageSemantic where eq = gEq - -derive instance genericPipeline :: Generic Pipeline -instance showPipeline :: Show Pipeline where show = gShow -instance eqPipeline :: Eq Pipeline where eq = gEq - - -instance encodeJsonArrayValue :: EncodeJson ArrayValue where - encodeJson v = case v of - VBoolArray arg0 -> "tag" := "VBoolArray" ~> "arg0" := arg0 ~> jsonEmptyObject - VIntArray arg0 -> "tag" := "VIntArray" ~> "arg0" := arg0 ~> jsonEmptyObject - VWordArray arg0 -> "tag" := "VWordArray" ~> "arg0" := arg0 ~> jsonEmptyObject - VFloatArray arg0 -> "tag" := "VFloatArray" ~> "arg0" := arg0 ~> jsonEmptyObject - -instance decodeJsonArrayValue :: DecodeJson ArrayValue where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "VBoolArray" -> VBoolArray <$> obj .? "arg0" - "VIntArray" -> VIntArray <$> obj .? "arg0" - "VWordArray" -> VWordArray <$> obj .? "arg0" - "VFloatArray" -> VFloatArray <$> obj .? "arg0" - -instance encodeJsonValue :: EncodeJson Value where - encodeJson v = case v of - VBool arg0 -> "tag" := "VBool" ~> "arg0" := arg0 ~> jsonEmptyObject - VV2B arg0 -> "tag" := "VV2B" ~> "arg0" := arg0 ~> jsonEmptyObject - VV3B arg0 -> "tag" := "VV3B" ~> "arg0" := arg0 ~> jsonEmptyObject - VV4B arg0 -> "tag" := "VV4B" ~> "arg0" := arg0 ~> jsonEmptyObject - VWord arg0 -> "tag" := "VWord" ~> "arg0" := arg0 ~> jsonEmptyObject - VV2U arg0 -> "tag" := "VV2U" ~> "arg0" := arg0 ~> jsonEmptyObject - VV3U arg0 -> "tag" := "VV3U" ~> "arg0" := arg0 ~> jsonEmptyObject - VV4U arg0 -> "tag" := "VV4U" ~> "arg0" := arg0 ~> jsonEmptyObject - VInt arg0 -> "tag" := "VInt" ~> "arg0" := arg0 ~> jsonEmptyObject - VV2I arg0 -> "tag" := "VV2I" ~> "arg0" := arg0 ~> jsonEmptyObject - VV3I arg0 -> "tag" := "VV3I" ~> "arg0" := arg0 ~> jsonEmptyObject - VV4I arg0 -> "tag" := "VV4I" ~> "arg0" := arg0 ~> jsonEmptyObject - VFloat arg0 -> "tag" := "VFloat" ~> "arg0" := arg0 ~> jsonEmptyObject - VV2F arg0 -> "tag" := "VV2F" ~> "arg0" := arg0 ~> jsonEmptyObject - VV3F arg0 -> "tag" := "VV3F" ~> "arg0" := arg0 ~> jsonEmptyObject - VV4F arg0 -> "tag" := "VV4F" ~> "arg0" := arg0 ~> jsonEmptyObject - VM22F arg0 -> "tag" := "VM22F" ~> "arg0" := arg0 ~> jsonEmptyObject - VM23F arg0 -> "tag" := "VM23F" ~> "arg0" := arg0 ~> jsonEmptyObject - VM24F arg0 -> "tag" := "VM24F" ~> "arg0" := arg0 ~> jsonEmptyObject - VM32F arg0 -> "tag" := "VM32F" ~> "arg0" := arg0 ~> jsonEmptyObject - VM33F arg0 -> "tag" := "VM33F" ~> "arg0" := arg0 ~> jsonEmptyObject - VM34F arg0 -> "tag" := "VM34F" ~> "arg0" := arg0 ~> jsonEmptyObject - VM42F arg0 -> "tag" := "VM42F" ~> "arg0" := arg0 ~> jsonEmptyObject - VM43F arg0 -> "tag" := "VM43F" ~> "arg0" := arg0 ~> jsonEmptyObject - VM44F arg0 -> "tag" := "VM44F" ~> "arg0" := arg0 ~> jsonEmptyObject - -instance decodeJsonValue :: DecodeJson Value where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "VBool" -> VBool <$> obj .? "arg0" - "VV2B" -> VV2B <$> obj .? "arg0" - "VV3B" -> VV3B <$> obj .? "arg0" - "VV4B" -> VV4B <$> obj .? "arg0" - "VWord" -> VWord <$> obj .? "arg0" - "VV2U" -> VV2U <$> obj .? "arg0" - "VV3U" -> VV3U <$> obj .? "arg0" - "VV4U" -> VV4U <$> obj .? "arg0" - "VInt" -> VInt <$> obj .? "arg0" - "VV2I" -> VV2I <$> obj .? "arg0" - "VV3I" -> VV3I <$> obj .? "arg0" - "VV4I" -> VV4I <$> obj .? "arg0" - "VFloat" -> VFloat <$> obj .? "arg0" - "VV2F" -> VV2F <$> obj .? "arg0" - "VV3F" -> VV3F <$> obj .? "arg0" - "VV4F" -> VV4F <$> obj .? "arg0" - "VM22F" -> VM22F <$> obj .? "arg0" - "VM23F" -> VM23F <$> obj .? "arg0" - "VM24F" -> VM24F <$> obj .? "arg0" - "VM32F" -> VM32F <$> obj .? "arg0" - "VM33F" -> VM33F <$> obj .? "arg0" - "VM34F" -> VM34F <$> obj .? "arg0" - "VM42F" -> VM42F <$> obj .? "arg0" - "VM43F" -> VM43F <$> obj .? "arg0" - "VM44F" -> VM44F <$> obj .? "arg0" - -instance encodeJsonInputType :: EncodeJson InputType where - encodeJson v = case v of - Bool -> "tag" := "Bool" ~> jsonEmptyObject - V2B -> "tag" := "V2B" ~> jsonEmptyObject - V3B -> "tag" := "V3B" ~> jsonEmptyObject - V4B -> "tag" := "V4B" ~> jsonEmptyObject - Word -> "tag" := "Word" ~> jsonEmptyObject - V2U -> "tag" := "V2U" ~> jsonEmptyObject - V3U -> "tag" := "V3U" ~> jsonEmptyObject - V4U -> "tag" := "V4U" ~> jsonEmptyObject - Int -> "tag" := "Int" ~> jsonEmptyObject - V2I -> "tag" := "V2I" ~> jsonEmptyObject - V3I -> "tag" := "V3I" ~> jsonEmptyObject - V4I -> "tag" := "V4I" ~> jsonEmptyObject - Float -> "tag" := "Float" ~> jsonEmptyObject - V2F -> "tag" := "V2F" ~> jsonEmptyObject - V3F -> "tag" := "V3F" ~> jsonEmptyObject - V4F -> "tag" := "V4F" ~> jsonEmptyObject - M22F -> "tag" := "M22F" ~> jsonEmptyObject - M23F -> "tag" := "M23F" ~> jsonEmptyObject - M24F -> "tag" := "M24F" ~> jsonEmptyObject - M32F -> "tag" := "M32F" ~> jsonEmptyObject - M33F -> "tag" := "M33F" ~> jsonEmptyObject - M34F -> "tag" := "M34F" ~> jsonEmptyObject - M42F -> "tag" := "M42F" ~> jsonEmptyObject - M43F -> "tag" := "M43F" ~> jsonEmptyObject - M44F -> "tag" := "M44F" ~> jsonEmptyObject - STexture1D -> "tag" := "STexture1D" ~> jsonEmptyObject - STexture2D -> "tag" := "STexture2D" ~> jsonEmptyObject - STextureCube -> "tag" := "STextureCube" ~> jsonEmptyObject - STexture1DArray -> "tag" := "STexture1DArray" ~> jsonEmptyObject - STexture2DArray -> "tag" := "STexture2DArray" ~> jsonEmptyObject - STexture2DRect -> "tag" := "STexture2DRect" ~> jsonEmptyObject - FTexture1D -> "tag" := "FTexture1D" ~> jsonEmptyObject - FTexture2D -> "tag" := "FTexture2D" ~> jsonEmptyObject - FTexture3D -> "tag" := "FTexture3D" ~> jsonEmptyObject - FTextureCube -> "tag" := "FTextureCube" ~> jsonEmptyObject - FTexture1DArray -> "tag" := "FTexture1DArray" ~> jsonEmptyObject - FTexture2DArray -> "tag" := "FTexture2DArray" ~> jsonEmptyObject - FTexture2DMS -> "tag" := "FTexture2DMS" ~> jsonEmptyObject - FTexture2DMSArray -> "tag" := "FTexture2DMSArray" ~> jsonEmptyObject - FTextureBuffer -> "tag" := "FTextureBuffer" ~> jsonEmptyObject - FTexture2DRect -> "tag" := "FTexture2DRect" ~> jsonEmptyObject - ITexture1D -> "tag" := "ITexture1D" ~> jsonEmptyObject - ITexture2D -> "tag" := "ITexture2D" ~> jsonEmptyObject - ITexture3D -> "tag" := "ITexture3D" ~> jsonEmptyObject - ITextureCube -> "tag" := "ITextureCube" ~> jsonEmptyObject - ITexture1DArray -> "tag" := "ITexture1DArray" ~> jsonEmptyObject - ITexture2DArray -> "tag" := "ITexture2DArray" ~> jsonEmptyObject - ITexture2DMS -> "tag" := "ITexture2DMS" ~> jsonEmptyObject - ITexture2DMSArray -> "tag" := "ITexture2DMSArray" ~> jsonEmptyObject - ITextureBuffer -> "tag" := "ITextureBuffer" ~> jsonEmptyObject - ITexture2DRect -> "tag" := "ITexture2DRect" ~> jsonEmptyObject - UTexture1D -> "tag" := "UTexture1D" ~> jsonEmptyObject - UTexture2D -> "tag" := "UTexture2D" ~> jsonEmptyObject - UTexture3D -> "tag" := "UTexture3D" ~> jsonEmptyObject - UTextureCube -> "tag" := "UTextureCube" ~> jsonEmptyObject - UTexture1DArray -> "tag" := "UTexture1DArray" ~> jsonEmptyObject - UTexture2DArray -> "tag" := "UTexture2DArray" ~> jsonEmptyObject - UTexture2DMS -> "tag" := "UTexture2DMS" ~> jsonEmptyObject - UTexture2DMSArray -> "tag" := "UTexture2DMSArray" ~> jsonEmptyObject - UTextureBuffer -> "tag" := "UTextureBuffer" ~> jsonEmptyObject - UTexture2DRect -> "tag" := "UTexture2DRect" ~> jsonEmptyObject - -instance decodeJsonInputType :: DecodeJson InputType where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "Bool" -> pure Bool - "V2B" -> pure V2B - "V3B" -> pure V3B - "V4B" -> pure V4B - "Word" -> pure Word - "V2U" -> pure V2U - "V3U" -> pure V3U - "V4U" -> pure V4U - "Int" -> pure Int - "V2I" -> pure V2I - "V3I" -> pure V3I - "V4I" -> pure V4I - "Float" -> pure Float - "V2F" -> pure V2F - "V3F" -> pure V3F - "V4F" -> pure V4F - "M22F" -> pure M22F - "M23F" -> pure M23F - "M24F" -> pure M24F - "M32F" -> pure M32F - "M33F" -> pure M33F - "M34F" -> pure M34F - "M42F" -> pure M42F - "M43F" -> pure M43F - "M44F" -> pure M44F - "STexture1D" -> pure STexture1D - "STexture2D" -> pure STexture2D - "STextureCube" -> pure STextureCube - "STexture1DArray" -> pure STexture1DArray - "STexture2DArray" -> pure STexture2DArray - "STexture2DRect" -> pure STexture2DRect - "FTexture1D" -> pure FTexture1D - "FTexture2D" -> pure FTexture2D - "FTexture3D" -> pure FTexture3D - "FTextureCube" -> pure FTextureCube - "FTexture1DArray" -> pure FTexture1DArray - "FTexture2DArray" -> pure FTexture2DArray - "FTexture2DMS" -> pure FTexture2DMS - "FTexture2DMSArray" -> pure FTexture2DMSArray - "FTextureBuffer" -> pure FTextureBuffer - "FTexture2DRect" -> pure FTexture2DRect - "ITexture1D" -> pure ITexture1D - "ITexture2D" -> pure ITexture2D - "ITexture3D" -> pure ITexture3D - "ITextureCube" -> pure ITextureCube - "ITexture1DArray" -> pure ITexture1DArray - "ITexture2DArray" -> pure ITexture2DArray - "ITexture2DMS" -> pure ITexture2DMS - "ITexture2DMSArray" -> pure ITexture2DMSArray - "ITextureBuffer" -> pure ITextureBuffer - "ITexture2DRect" -> pure ITexture2DRect - "UTexture1D" -> pure UTexture1D - "UTexture2D" -> pure UTexture2D - "UTexture3D" -> pure UTexture3D - "UTextureCube" -> pure UTextureCube - "UTexture1DArray" -> pure UTexture1DArray - "UTexture2DArray" -> pure UTexture2DArray - "UTexture2DMS" -> pure UTexture2DMS - "UTexture2DMSArray" -> pure UTexture2DMSArray - "UTextureBuffer" -> pure UTextureBuffer - "UTexture2DRect" -> pure UTexture2DRect - -instance encodeJsonPointSpriteCoordOrigin :: EncodeJson PointSpriteCoordOrigin where - encodeJson v = case v of - LowerLeft -> "tag" := "LowerLeft" ~> jsonEmptyObject - UpperLeft -> "tag" := "UpperLeft" ~> jsonEmptyObject - -instance decodeJsonPointSpriteCoordOrigin :: DecodeJson PointSpriteCoordOrigin where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "LowerLeft" -> pure LowerLeft - "UpperLeft" -> pure UpperLeft - -instance encodeJsonPointSize :: EncodeJson PointSize where - encodeJson v = case v of - PointSize arg0 -> "tag" := "PointSize" ~> "arg0" := arg0 ~> jsonEmptyObject - ProgramPointSize -> "tag" := "ProgramPointSize" ~> jsonEmptyObject - -instance decodeJsonPointSize :: DecodeJson PointSize where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "PointSize" -> PointSize <$> obj .? "arg0" - "ProgramPointSize" -> pure ProgramPointSize - -instance encodeJsonPolygonOffset :: EncodeJson PolygonOffset where - encodeJson v = case v of - NoOffset -> "tag" := "NoOffset" ~> jsonEmptyObject - Offset arg0 arg1 -> "tag" := "Offset" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject - -instance decodeJsonPolygonOffset :: DecodeJson PolygonOffset where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "NoOffset" -> pure NoOffset - "Offset" -> Offset <$> obj .? "arg0" <*> obj .? "arg1" - -instance encodeJsonFrontFace :: EncodeJson FrontFace where - encodeJson v = case v of - CCW -> "tag" := "CCW" ~> jsonEmptyObject - CW -> "tag" := "CW" ~> jsonEmptyObject - -instance decodeJsonFrontFace :: DecodeJson FrontFace where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "CCW" -> pure CCW - "CW" -> pure CW - -instance encodeJsonPolygonMode :: EncodeJson PolygonMode where - encodeJson v = case v of - PolygonPoint arg0 -> "tag" := "PolygonPoint" ~> "arg0" := arg0 ~> jsonEmptyObject - PolygonLine arg0 -> "tag" := "PolygonLine" ~> "arg0" := arg0 ~> jsonEmptyObject - PolygonFill -> "tag" := "PolygonFill" ~> jsonEmptyObject - -instance decodeJsonPolygonMode :: DecodeJson PolygonMode where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "PolygonPoint" -> PolygonPoint <$> obj .? "arg0" - "PolygonLine" -> PolygonLine <$> obj .? "arg0" - "PolygonFill" -> pure PolygonFill - -instance encodeJsonProvokingVertex :: EncodeJson ProvokingVertex where - encodeJson v = case v of - FirstVertex -> "tag" := "FirstVertex" ~> jsonEmptyObject - LastVertex -> "tag" := "LastVertex" ~> jsonEmptyObject - -instance decodeJsonProvokingVertex :: DecodeJson ProvokingVertex where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "FirstVertex" -> pure FirstVertex - "LastVertex" -> pure LastVertex - -instance encodeJsonCullMode :: EncodeJson CullMode where - encodeJson v = case v of - CullNone -> "tag" := "CullNone" ~> jsonEmptyObject - CullFront arg0 -> "tag" := "CullFront" ~> "arg0" := arg0 ~> jsonEmptyObject - CullBack arg0 -> "tag" := "CullBack" ~> "arg0" := arg0 ~> jsonEmptyObject - -instance decodeJsonCullMode :: DecodeJson CullMode where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "CullNone" -> pure CullNone - "CullFront" -> CullFront <$> obj .? "arg0" - "CullBack" -> CullBack <$> obj .? "arg0" - -instance encodeJsonComparisonFunction :: EncodeJson ComparisonFunction where - encodeJson v = case v of - Never -> "tag" := "Never" ~> jsonEmptyObject - Less -> "tag" := "Less" ~> jsonEmptyObject - Equal -> "tag" := "Equal" ~> jsonEmptyObject - Lequal -> "tag" := "Lequal" ~> jsonEmptyObject - Greater -> "tag" := "Greater" ~> jsonEmptyObject - Notequal -> "tag" := "Notequal" ~> jsonEmptyObject - Gequal -> "tag" := "Gequal" ~> jsonEmptyObject - Always -> "tag" := "Always" ~> jsonEmptyObject - -instance decodeJsonComparisonFunction :: DecodeJson ComparisonFunction where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "Never" -> pure Never - "Less" -> pure Less - "Equal" -> pure Equal - "Lequal" -> pure Lequal - "Greater" -> pure Greater - "Notequal" -> pure Notequal - "Gequal" -> pure Gequal - "Always" -> pure Always - -instance encodeJsonStencilOperation :: EncodeJson StencilOperation where - encodeJson v = case v of - OpZero -> "tag" := "OpZero" ~> jsonEmptyObject - OpKeep -> "tag" := "OpKeep" ~> jsonEmptyObject - OpReplace -> "tag" := "OpReplace" ~> jsonEmptyObject - OpIncr -> "tag" := "OpIncr" ~> jsonEmptyObject - OpIncrWrap -> "tag" := "OpIncrWrap" ~> jsonEmptyObject - OpDecr -> "tag" := "OpDecr" ~> jsonEmptyObject - OpDecrWrap -> "tag" := "OpDecrWrap" ~> jsonEmptyObject - OpInvert -> "tag" := "OpInvert" ~> jsonEmptyObject - -instance decodeJsonStencilOperation :: DecodeJson StencilOperation where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "OpZero" -> pure OpZero - "OpKeep" -> pure OpKeep - "OpReplace" -> pure OpReplace - "OpIncr" -> pure OpIncr - "OpIncrWrap" -> pure OpIncrWrap - "OpDecr" -> pure OpDecr - "OpDecrWrap" -> pure OpDecrWrap - "OpInvert" -> pure OpInvert - -instance encodeJsonBlendEquation :: EncodeJson BlendEquation where - encodeJson v = case v of - FuncAdd -> "tag" := "FuncAdd" ~> jsonEmptyObject - FuncSubtract -> "tag" := "FuncSubtract" ~> jsonEmptyObject - FuncReverseSubtract -> "tag" := "FuncReverseSubtract" ~> jsonEmptyObject - Min -> "tag" := "Min" ~> jsonEmptyObject - Max -> "tag" := "Max" ~> jsonEmptyObject - -instance decodeJsonBlendEquation :: DecodeJson BlendEquation where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "FuncAdd" -> pure FuncAdd - "FuncSubtract" -> pure FuncSubtract - "FuncReverseSubtract" -> pure FuncReverseSubtract - "Min" -> pure Min - "Max" -> pure Max - -instance encodeJsonBlendingFactor :: EncodeJson BlendingFactor where - encodeJson v = case v of - Zero -> "tag" := "Zero" ~> jsonEmptyObject - One -> "tag" := "One" ~> jsonEmptyObject - SrcColor -> "tag" := "SrcColor" ~> jsonEmptyObject - OneMinusSrcColor -> "tag" := "OneMinusSrcColor" ~> jsonEmptyObject - DstColor -> "tag" := "DstColor" ~> jsonEmptyObject - OneMinusDstColor -> "tag" := "OneMinusDstColor" ~> jsonEmptyObject - SrcAlpha -> "tag" := "SrcAlpha" ~> jsonEmptyObject - OneMinusSrcAlpha -> "tag" := "OneMinusSrcAlpha" ~> jsonEmptyObject - DstAlpha -> "tag" := "DstAlpha" ~> jsonEmptyObject - OneMinusDstAlpha -> "tag" := "OneMinusDstAlpha" ~> jsonEmptyObject - ConstantColor -> "tag" := "ConstantColor" ~> jsonEmptyObject - OneMinusConstantColor -> "tag" := "OneMinusConstantColor" ~> jsonEmptyObject - ConstantAlpha -> "tag" := "ConstantAlpha" ~> jsonEmptyObject - OneMinusConstantAlpha -> "tag" := "OneMinusConstantAlpha" ~> jsonEmptyObject - SrcAlphaSaturate -> "tag" := "SrcAlphaSaturate" ~> jsonEmptyObject - -instance decodeJsonBlendingFactor :: DecodeJson BlendingFactor where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "Zero" -> pure Zero - "One" -> pure One - "SrcColor" -> pure SrcColor - "OneMinusSrcColor" -> pure OneMinusSrcColor - "DstColor" -> pure DstColor - "OneMinusDstColor" -> pure OneMinusDstColor - "SrcAlpha" -> pure SrcAlpha - "OneMinusSrcAlpha" -> pure OneMinusSrcAlpha - "DstAlpha" -> pure DstAlpha - "OneMinusDstAlpha" -> pure OneMinusDstAlpha - "ConstantColor" -> pure ConstantColor - "OneMinusConstantColor" -> pure OneMinusConstantColor - "ConstantAlpha" -> pure ConstantAlpha - "OneMinusConstantAlpha" -> pure OneMinusConstantAlpha - "SrcAlphaSaturate" -> pure SrcAlphaSaturate - -instance encodeJsonLogicOperation :: EncodeJson LogicOperation where - encodeJson v = case v of - Clear -> "tag" := "Clear" ~> jsonEmptyObject - And -> "tag" := "And" ~> jsonEmptyObject - AndReverse -> "tag" := "AndReverse" ~> jsonEmptyObject - Copy -> "tag" := "Copy" ~> jsonEmptyObject - AndInverted -> "tag" := "AndInverted" ~> jsonEmptyObject - Noop -> "tag" := "Noop" ~> jsonEmptyObject - Xor -> "tag" := "Xor" ~> jsonEmptyObject - Or -> "tag" := "Or" ~> jsonEmptyObject - Nor -> "tag" := "Nor" ~> jsonEmptyObject - Equiv -> "tag" := "Equiv" ~> jsonEmptyObject - Invert -> "tag" := "Invert" ~> jsonEmptyObject - OrReverse -> "tag" := "OrReverse" ~> jsonEmptyObject - CopyInverted -> "tag" := "CopyInverted" ~> jsonEmptyObject - OrInverted -> "tag" := "OrInverted" ~> jsonEmptyObject - Nand -> "tag" := "Nand" ~> jsonEmptyObject - Set -> "tag" := "Set" ~> jsonEmptyObject - -instance decodeJsonLogicOperation :: DecodeJson LogicOperation where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "Clear" -> pure Clear - "And" -> pure And - "AndReverse" -> pure AndReverse - "Copy" -> pure Copy - "AndInverted" -> pure AndInverted - "Noop" -> pure Noop - "Xor" -> pure Xor - "Or" -> pure Or - "Nor" -> pure Nor - "Equiv" -> pure Equiv - "Invert" -> pure Invert - "OrReverse" -> pure OrReverse - "CopyInverted" -> pure CopyInverted - "OrInverted" -> pure OrInverted - "Nand" -> pure Nand - "Set" -> pure Set - -instance encodeJsonStencilOps :: EncodeJson StencilOps where - encodeJson v = case v of - StencilOps r -> - "tag" := "StencilOps" ~> - "frontStencilOp" := r.frontStencilOp ~> - "backStencilOp" := r.backStencilOp ~> - jsonEmptyObject - -instance decodeJsonStencilOps :: DecodeJson StencilOps where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "StencilOps" -> do - frontStencilOp <- obj .? "frontStencilOp" - backStencilOp <- obj .? "backStencilOp" - pure $ StencilOps - { frontStencilOp:frontStencilOp - , backStencilOp:backStencilOp - } - -instance encodeJsonStencilTest :: EncodeJson StencilTest where - encodeJson v = case v of - StencilTest r -> - "tag" := "StencilTest" ~> - "stencilComparision" := r.stencilComparision ~> - "stencilReference" := r.stencilReference ~> - "stencilMask" := r.stencilMask ~> - jsonEmptyObject - -instance decodeJsonStencilTest :: DecodeJson StencilTest where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "StencilTest" -> do - stencilComparision <- obj .? "stencilComparision" - stencilReference <- obj .? "stencilReference" - stencilMask <- obj .? "stencilMask" - pure $ StencilTest - { stencilComparision:stencilComparision - , stencilReference:stencilReference - , stencilMask:stencilMask - } - -instance encodeJsonStencilTests :: EncodeJson StencilTests where - encodeJson v = case v of - StencilTests arg0 arg1 -> "tag" := "StencilTests" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject - -instance decodeJsonStencilTests :: DecodeJson StencilTests where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "StencilTests" -> StencilTests <$> obj .? "arg0" <*> obj .? "arg1" - -instance encodeJsonFetchPrimitive :: EncodeJson FetchPrimitive where - encodeJson v = case v of - Points -> "tag" := "Points" ~> jsonEmptyObject - Lines -> "tag" := "Lines" ~> jsonEmptyObject - Triangles -> "tag" := "Triangles" ~> jsonEmptyObject - LinesAdjacency -> "tag" := "LinesAdjacency" ~> jsonEmptyObject - TrianglesAdjacency -> "tag" := "TrianglesAdjacency" ~> jsonEmptyObject - -instance decodeJsonFetchPrimitive :: DecodeJson FetchPrimitive where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "Points" -> pure Points - "Lines" -> pure Lines - "Triangles" -> pure Triangles - "LinesAdjacency" -> pure LinesAdjacency - "TrianglesAdjacency" -> pure TrianglesAdjacency - -instance encodeJsonOutputPrimitive :: EncodeJson OutputPrimitive where - encodeJson v = case v of - TrianglesOutput -> "tag" := "TrianglesOutput" ~> jsonEmptyObject - LinesOutput -> "tag" := "LinesOutput" ~> jsonEmptyObject - PointsOutput -> "tag" := "PointsOutput" ~> jsonEmptyObject - -instance decodeJsonOutputPrimitive :: DecodeJson OutputPrimitive where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "TrianglesOutput" -> pure TrianglesOutput - "LinesOutput" -> pure LinesOutput - "PointsOutput" -> pure PointsOutput - -instance encodeJsonColorArity :: EncodeJson ColorArity where - encodeJson v = case v of - Red -> "tag" := "Red" ~> jsonEmptyObject - RG -> "tag" := "RG" ~> jsonEmptyObject - RGB -> "tag" := "RGB" ~> jsonEmptyObject - RGBA -> "tag" := "RGBA" ~> jsonEmptyObject - -instance decodeJsonColorArity :: DecodeJson ColorArity where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "Red" -> pure Red - "RG" -> pure RG - "RGB" -> pure RGB - "RGBA" -> pure RGBA - -instance encodeJsonBlending :: EncodeJson Blending where - encodeJson v = case v of - NoBlending -> "tag" := "NoBlending" ~> jsonEmptyObject - BlendLogicOp arg0 -> "tag" := "BlendLogicOp" ~> "arg0" := arg0 ~> jsonEmptyObject - Blend r -> - "tag" := "Blend" ~> - "colorEqSrc" := r.colorEqSrc ~> - "alphaEqSrc" := r.alphaEqSrc ~> - "colorFSrc" := r.colorFSrc ~> - "colorFDst" := r.colorFDst ~> - "alphaFSrc" := r.alphaFSrc ~> - "alphaFDst" := r.alphaFDst ~> - "color" := r.color ~> - jsonEmptyObject - -instance decodeJsonBlending :: DecodeJson Blending where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "NoBlending" -> pure NoBlending - "BlendLogicOp" -> BlendLogicOp <$> obj .? "arg0" - "Blend" -> do - colorEqSrc <- obj .? "colorEqSrc" - alphaEqSrc <- obj .? "alphaEqSrc" - colorFSrc <- obj .? "colorFSrc" - colorFDst <- obj .? "colorFDst" - alphaFSrc <- obj .? "alphaFSrc" - alphaFDst <- obj .? "alphaFDst" - color <- obj .? "color" - pure $ Blend - { colorEqSrc:colorEqSrc - , alphaEqSrc:alphaEqSrc - , colorFSrc:colorFSrc - , colorFDst:colorFDst - , alphaFSrc:alphaFSrc - , alphaFDst:alphaFDst - , color:color - } - -instance encodeJsonRasterContext :: EncodeJson RasterContext where - encodeJson v = case v of - PointCtx arg0 arg1 arg2 -> "tag" := "PointCtx" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> "arg2" := arg2 ~> jsonEmptyObject - LineCtx arg0 arg1 -> "tag" := "LineCtx" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject - TriangleCtx arg0 arg1 arg2 arg3 -> "tag" := "TriangleCtx" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> "arg2" := arg2 ~> "arg3" := arg3 ~> jsonEmptyObject - -instance decodeJsonRasterContext :: DecodeJson RasterContext where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "PointCtx" -> PointCtx <$> obj .? "arg0" <*> obj .? "arg1" <*> obj .? "arg2" - "LineCtx" -> LineCtx <$> obj .? "arg0" <*> obj .? "arg1" - "TriangleCtx" -> TriangleCtx <$> obj .? "arg0" <*> obj .? "arg1" <*> obj .? "arg2" <*> obj .? "arg3" - -instance encodeJsonFragmentOperation :: EncodeJson FragmentOperation where - encodeJson v = case v of - DepthOp arg0 arg1 -> "tag" := "DepthOp" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject - StencilOp arg0 arg1 arg2 -> "tag" := "StencilOp" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> "arg2" := arg2 ~> jsonEmptyObject - ColorOp arg0 arg1 -> "tag" := "ColorOp" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject - -instance decodeJsonFragmentOperation :: DecodeJson FragmentOperation where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "DepthOp" -> DepthOp <$> obj .? "arg0" <*> obj .? "arg1" - "StencilOp" -> StencilOp <$> obj .? "arg0" <*> obj .? "arg1" <*> obj .? "arg2" - "ColorOp" -> ColorOp <$> obj .? "arg0" <*> obj .? "arg1" - -instance encodeJsonAccumulationContext :: EncodeJson AccumulationContext where - encodeJson v = case v of - AccumulationContext r -> - "tag" := "AccumulationContext" ~> - "accViewportName" := r.accViewportName ~> - "accOperations" := r.accOperations ~> - jsonEmptyObject - -instance decodeJsonAccumulationContext :: DecodeJson AccumulationContext where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "AccumulationContext" -> do - accViewportName <- obj .? "accViewportName" - accOperations <- obj .? "accOperations" - pure $ AccumulationContext - { accViewportName:accViewportName - , accOperations:accOperations - } - -instance encodeJsonTextureDataType :: EncodeJson TextureDataType where - encodeJson v = case v of - FloatT arg0 -> "tag" := "FloatT" ~> "arg0" := arg0 ~> jsonEmptyObject - IntT arg0 -> "tag" := "IntT" ~> "arg0" := arg0 ~> jsonEmptyObject - WordT arg0 -> "tag" := "WordT" ~> "arg0" := arg0 ~> jsonEmptyObject - ShadowT -> "tag" := "ShadowT" ~> jsonEmptyObject - -instance decodeJsonTextureDataType :: DecodeJson TextureDataType where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "FloatT" -> FloatT <$> obj .? "arg0" - "IntT" -> IntT <$> obj .? "arg0" - "WordT" -> WordT <$> obj .? "arg0" - "ShadowT" -> pure ShadowT - -instance encodeJsonTextureType :: EncodeJson TextureType where - encodeJson v = case v of - Texture1D arg0 arg1 -> "tag" := "Texture1D" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject - Texture2D arg0 arg1 -> "tag" := "Texture2D" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject - Texture3D arg0 -> "tag" := "Texture3D" ~> "arg0" := arg0 ~> jsonEmptyObject - TextureCube arg0 -> "tag" := "TextureCube" ~> "arg0" := arg0 ~> jsonEmptyObject - TextureRect arg0 -> "tag" := "TextureRect" ~> "arg0" := arg0 ~> jsonEmptyObject - Texture2DMS arg0 arg1 arg2 arg3 -> "tag" := "Texture2DMS" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> "arg2" := arg2 ~> "arg3" := arg3 ~> jsonEmptyObject - TextureBuffer arg0 -> "tag" := "TextureBuffer" ~> "arg0" := arg0 ~> jsonEmptyObject - -instance decodeJsonTextureType :: DecodeJson TextureType where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "Texture1D" -> Texture1D <$> obj .? "arg0" <*> obj .? "arg1" - "Texture2D" -> Texture2D <$> obj .? "arg0" <*> obj .? "arg1" - "Texture3D" -> Texture3D <$> obj .? "arg0" - "TextureCube" -> TextureCube <$> obj .? "arg0" - "TextureRect" -> TextureRect <$> obj .? "arg0" - "Texture2DMS" -> Texture2DMS <$> obj .? "arg0" <*> obj .? "arg1" <*> obj .? "arg2" <*> obj .? "arg3" - "TextureBuffer" -> TextureBuffer <$> obj .? "arg0" - -instance encodeJsonMipMap :: EncodeJson MipMap where - encodeJson v = case v of - Mip arg0 arg1 -> "tag" := "Mip" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject - NoMip -> "tag" := "NoMip" ~> jsonEmptyObject - AutoMip arg0 arg1 -> "tag" := "AutoMip" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject - -instance decodeJsonMipMap :: DecodeJson MipMap where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "Mip" -> Mip <$> obj .? "arg0" <*> obj .? "arg1" - "NoMip" -> pure NoMip - "AutoMip" -> AutoMip <$> obj .? "arg0" <*> obj .? "arg1" - -instance encodeJsonFilter :: EncodeJson Filter where - encodeJson v = case v of - Nearest -> "tag" := "Nearest" ~> jsonEmptyObject - Linear -> "tag" := "Linear" ~> jsonEmptyObject - NearestMipmapNearest -> "tag" := "NearestMipmapNearest" ~> jsonEmptyObject - NearestMipmapLinear -> "tag" := "NearestMipmapLinear" ~> jsonEmptyObject - LinearMipmapNearest -> "tag" := "LinearMipmapNearest" ~> jsonEmptyObject - LinearMipmapLinear -> "tag" := "LinearMipmapLinear" ~> jsonEmptyObject - -instance decodeJsonFilter :: DecodeJson Filter where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "Nearest" -> pure Nearest - "Linear" -> pure Linear - "NearestMipmapNearest" -> pure NearestMipmapNearest - "NearestMipmapLinear" -> pure NearestMipmapLinear - "LinearMipmapNearest" -> pure LinearMipmapNearest - "LinearMipmapLinear" -> pure LinearMipmapLinear - -instance encodeJsonEdgeMode :: EncodeJson EdgeMode where - encodeJson v = case v of - Repeat -> "tag" := "Repeat" ~> jsonEmptyObject - MirroredRepeat -> "tag" := "MirroredRepeat" ~> jsonEmptyObject - ClampToEdge -> "tag" := "ClampToEdge" ~> jsonEmptyObject - ClampToBorder -> "tag" := "ClampToBorder" ~> jsonEmptyObject - -instance decodeJsonEdgeMode :: DecodeJson EdgeMode where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "Repeat" -> pure Repeat - "MirroredRepeat" -> pure MirroredRepeat - "ClampToEdge" -> pure ClampToEdge - "ClampToBorder" -> pure ClampToBorder - -instance encodeJsonImageSemantic :: EncodeJson ImageSemantic where - encodeJson v = case v of - Depth -> "tag" := "Depth" ~> jsonEmptyObject - Stencil -> "tag" := "Stencil" ~> jsonEmptyObject - Color -> "tag" := "Color" ~> jsonEmptyObject - -instance decodeJsonImageSemantic :: DecodeJson ImageSemantic where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "Depth" -> pure Depth - "Stencil" -> pure Stencil - "Color" -> pure Color - -instance encodeJsonImageRef :: EncodeJson ImageRef where - encodeJson v = case v of - TextureImage arg0 arg1 arg2 -> "tag" := "TextureImage" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> "arg2" := arg2 ~> jsonEmptyObject - Framebuffer arg0 -> "tag" := "Framebuffer" ~> "arg0" := arg0 ~> jsonEmptyObject - -instance decodeJsonImageRef :: DecodeJson ImageRef where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "TextureImage" -> TextureImage <$> obj .? "arg0" <*> obj .? "arg1" <*> obj .? "arg2" - "Framebuffer" -> Framebuffer <$> obj .? "arg0" - -instance encodeJsonClearImage :: EncodeJson ClearImage where - encodeJson v = case v of - ClearImage r -> - "tag" := "ClearImage" ~> - "imageSemantic" := r.imageSemantic ~> - "clearValue" := r.clearValue ~> - jsonEmptyObject - -instance decodeJsonClearImage :: DecodeJson ClearImage where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "ClearImage" -> do - imageSemantic <- obj .? "imageSemantic" - clearValue <- obj .? "clearValue" - pure $ ClearImage - { imageSemantic:imageSemantic - , clearValue:clearValue - } - -instance encodeJsonCommand :: EncodeJson Command where - encodeJson v = case v of - SetRasterContext arg0 -> "tag" := "SetRasterContext" ~> "arg0" := arg0 ~> jsonEmptyObject - SetAccumulationContext arg0 -> "tag" := "SetAccumulationContext" ~> "arg0" := arg0 ~> jsonEmptyObject - SetRenderTarget arg0 -> "tag" := "SetRenderTarget" ~> "arg0" := arg0 ~> jsonEmptyObject - SetProgram arg0 -> "tag" := "SetProgram" ~> "arg0" := arg0 ~> jsonEmptyObject - SetSamplerUniform arg0 arg1 -> "tag" := "SetSamplerUniform" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject - SetTexture arg0 arg1 -> "tag" := "SetTexture" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject - SetSampler arg0 arg1 -> "tag" := "SetSampler" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject - RenderSlot arg0 -> "tag" := "RenderSlot" ~> "arg0" := arg0 ~> jsonEmptyObject - RenderStream arg0 -> "tag" := "RenderStream" ~> "arg0" := arg0 ~> jsonEmptyObject - ClearRenderTarget arg0 -> "tag" := "ClearRenderTarget" ~> "arg0" := arg0 ~> jsonEmptyObject - GenerateMipMap arg0 -> "tag" := "GenerateMipMap" ~> "arg0" := arg0 ~> jsonEmptyObject - SaveImage arg0 arg1 -> "tag" := "SaveImage" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject - LoadImage arg0 arg1 -> "tag" := "LoadImage" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject - -instance decodeJsonCommand :: DecodeJson Command where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "SetRasterContext" -> SetRasterContext <$> obj .? "arg0" - "SetAccumulationContext" -> SetAccumulationContext <$> obj .? "arg0" - "SetRenderTarget" -> SetRenderTarget <$> obj .? "arg0" - "SetProgram" -> SetProgram <$> obj .? "arg0" - "SetSamplerUniform" -> SetSamplerUniform <$> obj .? "arg0" <*> obj .? "arg1" - "SetTexture" -> SetTexture <$> obj .? "arg0" <*> obj .? "arg1" - "SetSampler" -> SetSampler <$> obj .? "arg0" <*> obj .? "arg1" - "RenderSlot" -> RenderSlot <$> obj .? "arg0" - "RenderStream" -> RenderStream <$> obj .? "arg0" - "ClearRenderTarget" -> ClearRenderTarget <$> obj .? "arg0" - "GenerateMipMap" -> GenerateMipMap <$> obj .? "arg0" - "SaveImage" -> SaveImage <$> obj .? "arg0" <*> obj .? "arg1" - "LoadImage" -> LoadImage <$> obj .? "arg0" <*> obj .? "arg1" - -instance encodeJsonSamplerDescriptor :: EncodeJson SamplerDescriptor where - encodeJson v = case v of - SamplerDescriptor r -> - "tag" := "SamplerDescriptor" ~> - "samplerWrapS" := r.samplerWrapS ~> - "samplerWrapT" := r.samplerWrapT ~> - "samplerWrapR" := r.samplerWrapR ~> - "samplerMinFilter" := r.samplerMinFilter ~> - "samplerMagFilter" := r.samplerMagFilter ~> - "samplerBorderColor" := r.samplerBorderColor ~> - "samplerMinLod" := r.samplerMinLod ~> - "samplerMaxLod" := r.samplerMaxLod ~> - "samplerLodBias" := r.samplerLodBias ~> - "samplerCompareFunc" := r.samplerCompareFunc ~> - jsonEmptyObject - -instance decodeJsonSamplerDescriptor :: DecodeJson SamplerDescriptor where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "SamplerDescriptor" -> do - samplerWrapS <- obj .? "samplerWrapS" - samplerWrapT <- obj .? "samplerWrapT" - samplerWrapR <- obj .? "samplerWrapR" - samplerMinFilter <- obj .? "samplerMinFilter" - samplerMagFilter <- obj .? "samplerMagFilter" - samplerBorderColor <- obj .? "samplerBorderColor" - samplerMinLod <- obj .? "samplerMinLod" - samplerMaxLod <- obj .? "samplerMaxLod" - samplerLodBias <- obj .? "samplerLodBias" - samplerCompareFunc <- obj .? "samplerCompareFunc" - pure $ SamplerDescriptor - { samplerWrapS:samplerWrapS - , samplerWrapT:samplerWrapT - , samplerWrapR:samplerWrapR - , samplerMinFilter:samplerMinFilter - , samplerMagFilter:samplerMagFilter - , samplerBorderColor:samplerBorderColor - , samplerMinLod:samplerMinLod - , samplerMaxLod:samplerMaxLod - , samplerLodBias:samplerLodBias - , samplerCompareFunc:samplerCompareFunc - } - -instance encodeJsonTextureDescriptor :: EncodeJson TextureDescriptor where - encodeJson v = case v of - TextureDescriptor r -> - "tag" := "TextureDescriptor" ~> - "textureType" := r.textureType ~> - "textureSize" := r.textureSize ~> - "textureSemantic" := r.textureSemantic ~> - "textureSampler" := r.textureSampler ~> - "textureBaseLevel" := r.textureBaseLevel ~> - "textureMaxLevel" := r.textureMaxLevel ~> - jsonEmptyObject - -instance decodeJsonTextureDescriptor :: DecodeJson TextureDescriptor where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "TextureDescriptor" -> do - textureType <- obj .? "textureType" - textureSize <- obj .? "textureSize" - textureSemantic <- obj .? "textureSemantic" - textureSampler <- obj .? "textureSampler" - textureBaseLevel <- obj .? "textureBaseLevel" - textureMaxLevel <- obj .? "textureMaxLevel" - pure $ TextureDescriptor - { textureType:textureType - , textureSize:textureSize - , textureSemantic:textureSemantic - , textureSampler:textureSampler - , textureBaseLevel:textureBaseLevel - , textureMaxLevel:textureMaxLevel - } - -instance encodeJsonParameter :: EncodeJson Parameter where - encodeJson v = case v of - Parameter r -> - "tag" := "Parameter" ~> - "name" := r.name ~> - "ty" := r.ty ~> - jsonEmptyObject - -instance decodeJsonParameter :: DecodeJson Parameter where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "Parameter" -> do - name <- obj .? "name" - ty <- obj .? "ty" - pure $ Parameter - { name:name - , ty:ty - } - -instance encodeJsonProgram :: EncodeJson Program where - encodeJson v = case v of - Program r -> - "tag" := "Program" ~> - "programUniforms" := r.programUniforms ~> - "programStreams" := r.programStreams ~> - "programInTextures" := r.programInTextures ~> - "programOutput" := r.programOutput ~> - "vertexShader" := r.vertexShader ~> - "geometryShader" := r.geometryShader ~> - "fragmentShader" := r.fragmentShader ~> - jsonEmptyObject - -instance decodeJsonProgram :: DecodeJson Program where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "Program" -> do - programUniforms <- obj .? "programUniforms" - programStreams <- obj .? "programStreams" - programInTextures <- obj .? "programInTextures" - programOutput <- obj .? "programOutput" - vertexShader <- obj .? "vertexShader" - geometryShader <- obj .? "geometryShader" - fragmentShader <- obj .? "fragmentShader" - pure $ Program - { programUniforms:programUniforms - , programStreams:programStreams - , programInTextures:programInTextures - , programOutput:programOutput - , vertexShader:vertexShader - , geometryShader:geometryShader - , fragmentShader:fragmentShader - } - -instance encodeJsonSlot :: EncodeJson Slot where - encodeJson v = case v of - Slot r -> - "tag" := "Slot" ~> - "slotName" := r.slotName ~> - "slotStreams" := r.slotStreams ~> - "slotUniforms" := r.slotUniforms ~> - "slotPrimitive" := r.slotPrimitive ~> - "slotPrograms" := r.slotPrograms ~> - jsonEmptyObject - -instance decodeJsonSlot :: DecodeJson Slot where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "Slot" -> do - slotName <- obj .? "slotName" - slotStreams <- obj .? "slotStreams" - slotUniforms <- obj .? "slotUniforms" - slotPrimitive <- obj .? "slotPrimitive" - slotPrograms <- obj .? "slotPrograms" - pure $ Slot - { slotName:slotName - , slotStreams:slotStreams - , slotUniforms:slotUniforms - , slotPrimitive:slotPrimitive - , slotPrograms:slotPrograms - } - -instance encodeJsonStreamData :: EncodeJson StreamData where - encodeJson v = case v of - StreamData r -> - "tag" := "StreamData" ~> - "streamData" := r.streamData ~> - "streamType" := r.streamType ~> - "streamPrimitive" := r.streamPrimitive ~> - "streamPrograms" := r.streamPrograms ~> - jsonEmptyObject - -instance decodeJsonStreamData :: DecodeJson StreamData where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "StreamData" -> do - streamData <- obj .? "streamData" - streamType <- obj .? "streamType" - streamPrimitive <- obj .? "streamPrimitive" - streamPrograms <- obj .? "streamPrograms" - pure $ StreamData - { streamData:streamData - , streamType:streamType - , streamPrimitive:streamPrimitive - , streamPrograms:streamPrograms - } - -instance encodeJsonTargetItem :: EncodeJson TargetItem where - encodeJson v = case v of - TargetItem r -> - "tag" := "TargetItem" ~> - "targetSemantic" := r.targetSemantic ~> - "targetRef" := r.targetRef ~> - jsonEmptyObject - -instance decodeJsonTargetItem :: DecodeJson TargetItem where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "TargetItem" -> do - targetSemantic <- obj .? "targetSemantic" - targetRef <- obj .? "targetRef" - pure $ TargetItem - { targetSemantic:targetSemantic - , targetRef:targetRef - } - -instance encodeJsonRenderTarget :: EncodeJson RenderTarget where - encodeJson v = case v of - RenderTarget r -> - "tag" := "RenderTarget" ~> - "renderTargets" := r.renderTargets ~> - jsonEmptyObject - -instance decodeJsonRenderTarget :: DecodeJson RenderTarget where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "RenderTarget" -> do - renderTargets <- obj .? "renderTargets" - pure $ RenderTarget - { renderTargets:renderTargets - } - -instance encodeJsonBackend :: EncodeJson Backend where - encodeJson v = case v of - WebGL1 -> "tag" := "WebGL1" ~> jsonEmptyObject - OpenGL33 -> "tag" := "OpenGL33" ~> jsonEmptyObject - -instance decodeJsonBackend :: DecodeJson Backend where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "WebGL1" -> pure WebGL1 - "OpenGL33" -> pure OpenGL33 - -instance encodeJsonPipeline :: EncodeJson Pipeline where - encodeJson v = case v of - Pipeline r -> - "tag" := "Pipeline" ~> - "backend" := r.backend ~> - "textures" := r.textures ~> - "samplers" := r.samplers ~> - "targets" := r.targets ~> - "programs" := r.programs ~> - "slots" := r.slots ~> - "streams" := r.streams ~> - "commands" := r.commands ~> - jsonEmptyObject - -instance decodeJsonPipeline :: DecodeJson Pipeline where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "Pipeline" -> do - backend <- obj .? "backend" - textures <- obj .? "textures" - samplers <- obj .? "samplers" - targets <- obj .? "targets" - programs <- obj .? "programs" - slots <- obj .? "slots" - streams <- obj .? "streams" - commands <- obj .? "commands" - pure $ Pipeline - { backend:backend - , textures:textures - , samplers:samplers - , targets:targets - , programs:programs - , slots:slots - , streams:streams - , commands:commands - } - diff --git a/ddl/out/IR.swift b/ddl/out/IR.swift deleted file mode 100644 index 78358f4..0000000 --- a/ddl/out/IR.swift +++ /dev/null @@ -1,1429 +0,0 @@ -// generated file, do not modify! -// 2016-01-18T14:30:07.798481Z - -typealias StreamName = Int - -typealias ProgramName = Int - -typealias TextureName = Int - -typealias SamplerName = Int - -typealias UniformName = String - -typealias SlotName = Int - -typealias FrameBufferComponent = Int - -typealias TextureUnit = Int - -typealias RenderTargetName = Int - -typealias TextureUnitMapping = Dictionary - -enum ArrayValue { - case VBoolArray(Array) - case VIntArray(Array) - case VWordArray(Array) - case VFloatArray(Array) -} - -enum Value { - case VBool(Bool) - case VV2B(Int) - case VV3B(Int) - case VV4B(Int) - case VWord(UInt32) - case VV2U(Int) - case VV3U(Int) - case VV4U(Int) - case VInt(Int32) - case VV2I(Int) - case VV3I(Int) - case VV4I(Int) - case VFloat(Float) - case VV2F(Int) - case VV3F(Int) - case VV4F(Int) - case VM22F(Int) - case VM23F(Int) - case VM24F(Int) - case VM32F(Int) - case VM33F(Int) - case VM34F(Int) - case VM42F(Int) - case VM43F(Int) - case VM44F(Int) -} - -enum InputType { - case Bool - case V2B - case V3B - case V4B - case Word - case V2U - case V3U - case V4U - case Int - case V2I - case V3I - case V4I - case Float - case V2F - case V3F - case V4F - case M22F - case M23F - case M24F - case M32F - case M33F - case M34F - case M42F - case M43F - case M44F - case STexture1D - case STexture2D - case STextureCube - case STexture1DArray - case STexture2DArray - case STexture2DRect - case FTexture1D - case FTexture2D - case FTexture3D - case FTextureCube - case FTexture1DArray - case FTexture2DArray - case FTexture2DMS - case FTexture2DMSArray - case FTextureBuffer - case FTexture2DRect - case ITexture1D - case ITexture2D - case ITexture3D - case ITextureCube - case ITexture1DArray - case ITexture2DArray - case ITexture2DMS - case ITexture2DMSArray - case ITextureBuffer - case ITexture2DRect - case UTexture1D - case UTexture2D - case UTexture3D - case UTextureCube - case UTexture1DArray - case UTexture2DArray - case UTexture2DMS - case UTexture2DMSArray - case UTextureBuffer - case UTexture2DRect -} - -enum PointSpriteCoordOrigin { - case LowerLeft - case UpperLeft -} - -enum PointSize { - case PointSize(Float) - case ProgramPointSize -} - -enum PolygonOffset { - case NoOffset - case Offset(Float,Float) -} - -enum FrontFace { - case CCW - case CW -} - -enum PolygonMode { - case PolygonPoint(PointSize) - case PolygonLine(Float) - case PolygonFill -} - -enum ProvokingVertex { - case FirstVertex - case LastVertex -} - -enum CullMode { - case CullNone - case CullFront(FrontFace) - case CullBack(FrontFace) -} - -enum ComparisonFunction { - case Never - case Less - case Equal - case Lequal - case Greater - case Notequal - case Gequal - case Always -} - -typealias DepthFunction = ComparisonFunction - -enum StencilOperation { - case OpZero - case OpKeep - case OpReplace - case OpIncr - case OpIncrWrap - case OpDecr - case OpDecrWrap - case OpInvert -} - -enum BlendEquation { - case FuncAdd - case FuncSubtract - case FuncReverseSubtract - case Min - case Max -} - -enum BlendingFactor { - case Zero - case One - case SrcColor - case OneMinusSrcColor - case DstColor - case OneMinusDstColor - case SrcAlpha - case OneMinusSrcAlpha - case DstAlpha - case OneMinusDstAlpha - case ConstantColor - case OneMinusConstantColor - case ConstantAlpha - case OneMinusConstantAlpha - case SrcAlphaSaturate -} - -enum LogicOperation { - case Clear - case And - case AndReverse - case Copy - case AndInverted - case Noop - case Xor - case Or - case Nor - case Equiv - case Invert - case OrReverse - case CopyInverted - case OrInverted - case Nand - case Set -} - -enum StencilOps { - case StencilOps(StencilOps_Data) - struct StencilOps_Data { - var frontStencilOp : StencilOperation - var backStencilOp : StencilOperation - } -} - -enum StencilTest { - case StencilTest(StencilTest_Data) - struct StencilTest_Data { - var stencilComparision : ComparisonFunction - var stencilReference : Int32 - var stencilMask : UInt32 - } -} - -enum StencilTests { - case StencilTests(StencilTest,StencilTest) -} - -enum FetchPrimitive { - case Points - case Lines - case Triangles - case LinesAdjacency - case TrianglesAdjacency -} - -enum OutputPrimitive { - case TrianglesOutput - case LinesOutput - case PointsOutput -} - -enum ColorArity { - case Red - case RG - case RGB - case RGBA -} - -enum Blending { - case NoBlending - case BlendLogicOp(LogicOperation) - case Blend(Blend_Data) - struct Blend_Data { - var colorEqSrc : BlendEquation - var alphaEqSrc : BlendEquation - var colorFSrc : BlendingFactor - var colorFDst : BlendingFactor - var alphaFSrc : BlendingFactor - var alphaFDst : BlendingFactor - var color : Int - } -} - -enum RasterContext { - case PointCtx(PointSize,Float,PointSpriteCoordOrigin) - case LineCtx(Float,ProvokingVertex) - case TriangleCtx(CullMode,PolygonMode,PolygonOffset,ProvokingVertex) -} - -enum FragmentOperation { - case DepthOp(DepthFunction,Bool) - case StencilOp(StencilTests,StencilOps,StencilOps) - case ColorOp(Blending,Value) -} - -enum AccumulationContext { - case AccumulationContext(AccumulationContext_Data) - struct AccumulationContext_Data { - var accViewportName : Maybe - var accOperations : Array - } -} - -enum TextureDataType { - case FloatT(ColorArity) - case IntT(ColorArity) - case WordT(ColorArity) - case ShadowT -} - -enum TextureType { - case Texture1D(TextureDataType,Int) - case Texture2D(TextureDataType,Int) - case Texture3D(TextureDataType) - case TextureCube(TextureDataType) - case TextureRect(TextureDataType) - case Texture2DMS(TextureDataType,Int,Int,Bool) - case TextureBuffer(TextureDataType) -} - -enum MipMap { - case Mip(Int,Int) - case NoMip - case AutoMip(Int,Int) -} - -enum Filter { - case Nearest - case Linear - case NearestMipmapNearest - case NearestMipmapLinear - case LinearMipmapNearest - case LinearMipmapLinear -} - -enum EdgeMode { - case Repeat - case MirroredRepeat - case ClampToEdge - case ClampToBorder -} - -enum ImageSemantic { - case Depth - case Stencil - case Color -} - -enum ImageRef { - case TextureImage(TextureName,Int,Maybe) - case Framebuffer(ImageSemantic) -} - -enum ClearImage { - case ClearImage(ClearImage_Data) - struct ClearImage_Data { - var imageSemantic : ImageSemantic - var clearValue : Value - } -} - -enum Command { - case SetRasterContext(RasterContext) - case SetAccumulationContext(AccumulationContext) - case SetRenderTarget(RenderTargetName) - case SetProgram(ProgramName) - case SetSamplerUniform(UniformName,TextureUnit) - case SetTexture(TextureUnit,TextureName) - case SetSampler(TextureUnit,Maybe) - case RenderSlot(SlotName) - case RenderStream(StreamName) - case ClearRenderTarget(Array) - case GenerateMipMap(TextureUnit) - case SaveImage(FrameBufferComponent,ImageRef) - case LoadImage(ImageRef,FrameBufferComponent) -} - -enum SamplerDescriptor { - case SamplerDescriptor(SamplerDescriptor_Data) - struct SamplerDescriptor_Data { - var samplerWrapS : EdgeMode - var samplerWrapT : Maybe - var samplerWrapR : Maybe - var samplerMinFilter : Filter - var samplerMagFilter : Filter - var samplerBorderColor : Value - var samplerMinLod : Maybe - var samplerMaxLod : Maybe - var samplerLodBias : Float - var samplerCompareFunc : Maybe - } -} - -enum TextureDescriptor { - case TextureDescriptor(TextureDescriptor_Data) - struct TextureDescriptor_Data { - var textureType : TextureType - var textureSize : Value - var textureSemantic : ImageSemantic - var textureSampler : SamplerDescriptor - var textureBaseLevel : Int - var textureMaxLevel : Int - } -} - -enum Parameter { - case Parameter(Parameter_Data) - struct Parameter_Data { - var name : String - var ty : InputType - } -} - -enum Program { - case Program(Program_Data) - struct Program_Data { - var programUniforms : Dictionary - var programStreams : Dictionary - var programInTextures : Dictionary - var programOutput : Array - var vertexShader : String - var geometryShader : Maybe - var fragmentShader : String - } -} - -enum Slot { - case Slot(Slot_Data) - struct Slot_Data { - var slotName : String - var slotStreams : Dictionary - var slotUniforms : Dictionary - var slotPrimitive : FetchPrimitive - var slotPrograms : Array - } -} - -enum StreamData { - case StreamData(StreamData_Data) - struct StreamData_Data { - var streamData : Dictionary - var streamType : Dictionary - var streamPrimitive : FetchPrimitive - var streamPrograms : Array - } -} - -enum TargetItem { - case TargetItem(TargetItem_Data) - struct TargetItem_Data { - var targetSemantic : ImageSemantic - var targetRef : Maybe - } -} - -enum RenderTarget { - case RenderTarget(RenderTarget_Data) - struct RenderTarget_Data { - var renderTargets : Array - } -} - -enum Backend { - case WebGL1 - case OpenGL33 -} - -enum Pipeline { - case Pipeline(Pipeline_Data) - struct Pipeline_Data { - var backend : Backend - var textures : Array - var samplers : Array - var targets : Array - var programs : Array - var slots : Array - var streams : Array - var commands : Array - } -} - - -extension Int { - var toJSON : [String: AnyObject] { - return ["":""] - } -} -extension Int32 { - var toJSON : [String: AnyObject] { - return ["":""] - } -} -extension UInt { - var toJSON : [String: AnyObject] { - return ["":""] - } -} -extension UInt32 { - var toJSON : [String: AnyObject] { - return ["":""] - } -} -extension Float { - var toJSON : [String: AnyObject] { - return ["":""] - } -} -extension Bool { - var toJSON : [String: AnyObject] { - return ["":""] - } -} -extension String { - var toJSON : [String: AnyObject] { - return ["":""] - } -} -extension Array { - var toJSON : [String: AnyObject] { - return ["":""] - } -} -extension Dictionary { - var toJSON : [String: AnyObject] { - return ["":""] - } -} -extension Maybe { - var toJSON : [String: AnyObject] { - return ["":""] - } -} - - - -extension ArrayValue { - var toJSON : [String: AnyObject] { - switch self { - case .VBoolArray(let arg0): - return [ "tag" : "VBoolArray", "arg0" : arg0.toJSON] - case .VIntArray(let arg0): - return [ "tag" : "VIntArray", "arg0" : arg0.toJSON] - case .VWordArray(let arg0): - return [ "tag" : "VWordArray", "arg0" : arg0.toJSON] - case .VFloatArray(let arg0): - return [ "tag" : "VFloatArray", "arg0" : arg0.toJSON] - } - } -} -extension Value { - var toJSON : [String: AnyObject] { - switch self { - case .VBool(let arg0): - return [ "tag" : "VBool", "arg0" : arg0.toJSON] - case .VV2B(let arg0): - return [ "tag" : "VV2B", "arg0" : arg0.toJSON] - case .VV3B(let arg0): - return [ "tag" : "VV3B", "arg0" : arg0.toJSON] - case .VV4B(let arg0): - return [ "tag" : "VV4B", "arg0" : arg0.toJSON] - case .VWord(let arg0): - return [ "tag" : "VWord", "arg0" : arg0.toJSON] - case .VV2U(let arg0): - return [ "tag" : "VV2U", "arg0" : arg0.toJSON] - case .VV3U(let arg0): - return [ "tag" : "VV3U", "arg0" : arg0.toJSON] - case .VV4U(let arg0): - return [ "tag" : "VV4U", "arg0" : arg0.toJSON] - case .VInt(let arg0): - return [ "tag" : "VInt", "arg0" : arg0.toJSON] - case .VV2I(let arg0): - return [ "tag" : "VV2I", "arg0" : arg0.toJSON] - case .VV3I(let arg0): - return [ "tag" : "VV3I", "arg0" : arg0.toJSON] - case .VV4I(let arg0): - return [ "tag" : "VV4I", "arg0" : arg0.toJSON] - case .VFloat(let arg0): - return [ "tag" : "VFloat", "arg0" : arg0.toJSON] - case .VV2F(let arg0): - return [ "tag" : "VV2F", "arg0" : arg0.toJSON] - case .VV3F(let arg0): - return [ "tag" : "VV3F", "arg0" : arg0.toJSON] - case .VV4F(let arg0): - return [ "tag" : "VV4F", "arg0" : arg0.toJSON] - case .VM22F(let arg0): - return [ "tag" : "VM22F", "arg0" : arg0.toJSON] - case .VM23F(let arg0): - return [ "tag" : "VM23F", "arg0" : arg0.toJSON] - case .VM24F(let arg0): - return [ "tag" : "VM24F", "arg0" : arg0.toJSON] - case .VM32F(let arg0): - return [ "tag" : "VM32F", "arg0" : arg0.toJSON] - case .VM33F(let arg0): - return [ "tag" : "VM33F", "arg0" : arg0.toJSON] - case .VM34F(let arg0): - return [ "tag" : "VM34F", "arg0" : arg0.toJSON] - case .VM42F(let arg0): - return [ "tag" : "VM42F", "arg0" : arg0.toJSON] - case .VM43F(let arg0): - return [ "tag" : "VM43F", "arg0" : arg0.toJSON] - case .VM44F(let arg0): - return [ "tag" : "VM44F", "arg0" : arg0.toJSON] - } - } -} -extension InputType { - var toJSON : [String: AnyObject] { - switch self { - case .Bool: - return [ "tag" : "Bool"] - case .V2B: - return [ "tag" : "V2B"] - case .V3B: - return [ "tag" : "V3B"] - case .V4B: - return [ "tag" : "V4B"] - case .Word: - return [ "tag" : "Word"] - case .V2U: - return [ "tag" : "V2U"] - case .V3U: - return [ "tag" : "V3U"] - case .V4U: - return [ "tag" : "V4U"] - case .Int: - return [ "tag" : "Int"] - case .V2I: - return [ "tag" : "V2I"] - case .V3I: - return [ "tag" : "V3I"] - case .V4I: - return [ "tag" : "V4I"] - case .Float: - return [ "tag" : "Float"] - case .V2F: - return [ "tag" : "V2F"] - case .V3F: - return [ "tag" : "V3F"] - case .V4F: - return [ "tag" : "V4F"] - case .M22F: - return [ "tag" : "M22F"] - case .M23F: - return [ "tag" : "M23F"] - case .M24F: - return [ "tag" : "M24F"] - case .M32F: - return [ "tag" : "M32F"] - case .M33F: - return [ "tag" : "M33F"] - case .M34F: - return [ "tag" : "M34F"] - case .M42F: - return [ "tag" : "M42F"] - case .M43F: - return [ "tag" : "M43F"] - case .M44F: - return [ "tag" : "M44F"] - case .STexture1D: - return [ "tag" : "STexture1D"] - case .STexture2D: - return [ "tag" : "STexture2D"] - case .STextureCube: - return [ "tag" : "STextureCube"] - case .STexture1DArray: - return [ "tag" : "STexture1DArray"] - case .STexture2DArray: - return [ "tag" : "STexture2DArray"] - case .STexture2DRect: - return [ "tag" : "STexture2DRect"] - case .FTexture1D: - return [ "tag" : "FTexture1D"] - case .FTexture2D: - return [ "tag" : "FTexture2D"] - case .FTexture3D: - return [ "tag" : "FTexture3D"] - case .FTextureCube: - return [ "tag" : "FTextureCube"] - case .FTexture1DArray: - return [ "tag" : "FTexture1DArray"] - case .FTexture2DArray: - return [ "tag" : "FTexture2DArray"] - case .FTexture2DMS: - return [ "tag" : "FTexture2DMS"] - case .FTexture2DMSArray: - return [ "tag" : "FTexture2DMSArray"] - case .FTextureBuffer: - return [ "tag" : "FTextureBuffer"] - case .FTexture2DRect: - return [ "tag" : "FTexture2DRect"] - case .ITexture1D: - return [ "tag" : "ITexture1D"] - case .ITexture2D: - return [ "tag" : "ITexture2D"] - case .ITexture3D: - return [ "tag" : "ITexture3D"] - case .ITextureCube: - return [ "tag" : "ITextureCube"] - case .ITexture1DArray: - return [ "tag" : "ITexture1DArray"] - case .ITexture2DArray: - return [ "tag" : "ITexture2DArray"] - case .ITexture2DMS: - return [ "tag" : "ITexture2DMS"] - case .ITexture2DMSArray: - return [ "tag" : "ITexture2DMSArray"] - case .ITextureBuffer: - return [ "tag" : "ITextureBuffer"] - case .ITexture2DRect: - return [ "tag" : "ITexture2DRect"] - case .UTexture1D: - return [ "tag" : "UTexture1D"] - case .UTexture2D: - return [ "tag" : "UTexture2D"] - case .UTexture3D: - return [ "tag" : "UTexture3D"] - case .UTextureCube: - return [ "tag" : "UTextureCube"] - case .UTexture1DArray: - return [ "tag" : "UTexture1DArray"] - case .UTexture2DArray: - return [ "tag" : "UTexture2DArray"] - case .UTexture2DMS: - return [ "tag" : "UTexture2DMS"] - case .UTexture2DMSArray: - return [ "tag" : "UTexture2DMSArray"] - case .UTextureBuffer: - return [ "tag" : "UTextureBuffer"] - case .UTexture2DRect: - return [ "tag" : "UTexture2DRect"] - } - } -} -extension PointSpriteCoordOrigin { - var toJSON : [String: AnyObject] { - switch self { - case .LowerLeft: - return [ "tag" : "LowerLeft"] - case .UpperLeft: - return [ "tag" : "UpperLeft"] - } - } -} -extension PointSize { - var toJSON : [String: AnyObject] { - switch self { - case .PointSize(let arg0): - return [ "tag" : "PointSize", "arg0" : arg0.toJSON] - case .ProgramPointSize: - return [ "tag" : "ProgramPointSize"] - } - } -} -extension PolygonOffset { - var toJSON : [String: AnyObject] { - switch self { - case .NoOffset: - return [ "tag" : "NoOffset"] - case .Offset(let arg0, let arg1): - return [ "tag" : "Offset", "arg0" : arg0.toJSON, "arg1" : arg1.toJSON] - } - } -} -extension FrontFace { - var toJSON : [String: AnyObject] { - switch self { - case .CCW: - return [ "tag" : "CCW"] - case .CW: - return [ "tag" : "CW"] - } - } -} -extension PolygonMode { - var toJSON : [String: AnyObject] { - switch self { - case .PolygonPoint(let arg0): - return [ "tag" : "PolygonPoint", "arg0" : arg0.toJSON] - case .PolygonLine(let arg0): - return [ "tag" : "PolygonLine", "arg0" : arg0.toJSON] - case .PolygonFill: - return [ "tag" : "PolygonFill"] - } - } -} -extension ProvokingVertex { - var toJSON : [String: AnyObject] { - switch self { - case .FirstVertex: - return [ "tag" : "FirstVertex"] - case .LastVertex: - return [ "tag" : "LastVertex"] - } - } -} -extension CullMode { - var toJSON : [String: AnyObject] { - switch self { - case .CullNone: - return [ "tag" : "CullNone"] - case .CullFront(let arg0): - return [ "tag" : "CullFront", "arg0" : arg0.toJSON] - case .CullBack(let arg0): - return [ "tag" : "CullBack", "arg0" : arg0.toJSON] - } - } -} -extension ComparisonFunction { - var toJSON : [String: AnyObject] { - switch self { - case .Never: - return [ "tag" : "Never"] - case .Less: - return [ "tag" : "Less"] - case .Equal: - return [ "tag" : "Equal"] - case .Lequal: - return [ "tag" : "Lequal"] - case .Greater: - return [ "tag" : "Greater"] - case .Notequal: - return [ "tag" : "Notequal"] - case .Gequal: - return [ "tag" : "Gequal"] - case .Always: - return [ "tag" : "Always"] - } - } -} -extension StencilOperation { - var toJSON : [String: AnyObject] { - switch self { - case .OpZero: - return [ "tag" : "OpZero"] - case .OpKeep: - return [ "tag" : "OpKeep"] - case .OpReplace: - return [ "tag" : "OpReplace"] - case .OpIncr: - return [ "tag" : "OpIncr"] - case .OpIncrWrap: - return [ "tag" : "OpIncrWrap"] - case .OpDecr: - return [ "tag" : "OpDecr"] - case .OpDecrWrap: - return [ "tag" : "OpDecrWrap"] - case .OpInvert: - return [ "tag" : "OpInvert"] - } - } -} -extension BlendEquation { - var toJSON : [String: AnyObject] { - switch self { - case .FuncAdd: - return [ "tag" : "FuncAdd"] - case .FuncSubtract: - return [ "tag" : "FuncSubtract"] - case .FuncReverseSubtract: - return [ "tag" : "FuncReverseSubtract"] - case .Min: - return [ "tag" : "Min"] - case .Max: - return [ "tag" : "Max"] - } - } -} -extension BlendingFactor { - var toJSON : [String: AnyObject] { - switch self { - case .Zero: - return [ "tag" : "Zero"] - case .One: - return [ "tag" : "One"] - case .SrcColor: - return [ "tag" : "SrcColor"] - case .OneMinusSrcColor: - return [ "tag" : "OneMinusSrcColor"] - case .DstColor: - return [ "tag" : "DstColor"] - case .OneMinusDstColor: - return [ "tag" : "OneMinusDstColor"] - case .SrcAlpha: - return [ "tag" : "SrcAlpha"] - case .OneMinusSrcAlpha: - return [ "tag" : "OneMinusSrcAlpha"] - case .DstAlpha: - return [ "tag" : "DstAlpha"] - case .OneMinusDstAlpha: - return [ "tag" : "OneMinusDstAlpha"] - case .ConstantColor: - return [ "tag" : "ConstantColor"] - case .OneMinusConstantColor: - return [ "tag" : "OneMinusConstantColor"] - case .ConstantAlpha: - return [ "tag" : "ConstantAlpha"] - case .OneMinusConstantAlpha: - return [ "tag" : "OneMinusConstantAlpha"] - case .SrcAlphaSaturate: - return [ "tag" : "SrcAlphaSaturate"] - } - } -} -extension LogicOperation { - var toJSON : [String: AnyObject] { - switch self { - case .Clear: - return [ "tag" : "Clear"] - case .And: - return [ "tag" : "And"] - case .AndReverse: - return [ "tag" : "AndReverse"] - case .Copy: - return [ "tag" : "Copy"] - case .AndInverted: - return [ "tag" : "AndInverted"] - case .Noop: - return [ "tag" : "Noop"] - case .Xor: - return [ "tag" : "Xor"] - case .Or: - return [ "tag" : "Or"] - case .Nor: - return [ "tag" : "Nor"] - case .Equiv: - return [ "tag" : "Equiv"] - case .Invert: - return [ "tag" : "Invert"] - case .OrReverse: - return [ "tag" : "OrReverse"] - case .CopyInverted: - return [ "tag" : "CopyInverted"] - case .OrInverted: - return [ "tag" : "OrInverted"] - case .Nand: - return [ "tag" : "Nand"] - case .Set: - return [ "tag" : "Set"] - } - } -} -extension StencilOps { - var toJSON : [String: AnyObject] { - switch self { - case .StencilOps(let v): - return [ "tag" : "StencilOps" - , "frontStencilOp" : v.frontStencilOp.toJSON - , "backStencilOp" : v.backStencilOp.toJSON - ] - } - } -} -extension StencilTest { - var toJSON : [String: AnyObject] { - switch self { - case .StencilTest(let v): - return [ "tag" : "StencilTest" - , "stencilComparision" : v.stencilComparision.toJSON - , "stencilReference" : v.stencilReference.toJSON - , "stencilMask" : v.stencilMask.toJSON - ] - } - } -} -extension StencilTests { - var toJSON : [String: AnyObject] { - switch self { - case .StencilTests(let arg0, let arg1): - return [ "tag" : "StencilTests", "arg0" : arg0.toJSON, "arg1" : arg1.toJSON] - } - } -} -extension FetchPrimitive { - var toJSON : [String: AnyObject] { - switch self { - case .Points: - return [ "tag" : "Points"] - case .Lines: - return [ "tag" : "Lines"] - case .Triangles: - return [ "tag" : "Triangles"] - case .LinesAdjacency: - return [ "tag" : "LinesAdjacency"] - case .TrianglesAdjacency: - return [ "tag" : "TrianglesAdjacency"] - } - } -} -extension OutputPrimitive { - var toJSON : [String: AnyObject] { - switch self { - case .TrianglesOutput: - return [ "tag" : "TrianglesOutput"] - case .LinesOutput: - return [ "tag" : "LinesOutput"] - case .PointsOutput: - return [ "tag" : "PointsOutput"] - } - } -} -extension ColorArity { - var toJSON : [String: AnyObject] { - switch self { - case .Red: - return [ "tag" : "Red"] - case .RG: - return [ "tag" : "RG"] - case .RGB: - return [ "tag" : "RGB"] - case .RGBA: - return [ "tag" : "RGBA"] - } - } -} -extension Blending { - var toJSON : [String: AnyObject] { - switch self { - case .NoBlending: - return [ "tag" : "NoBlending"] - case .BlendLogicOp(let arg0): - return [ "tag" : "BlendLogicOp", "arg0" : arg0.toJSON] - case .Blend(let v): - return [ "tag" : "Blend" - , "colorEqSrc" : v.colorEqSrc.toJSON - , "alphaEqSrc" : v.alphaEqSrc.toJSON - , "colorFSrc" : v.colorFSrc.toJSON - , "colorFDst" : v.colorFDst.toJSON - , "alphaFSrc" : v.alphaFSrc.toJSON - , "alphaFDst" : v.alphaFDst.toJSON - , "color" : v.color.toJSON - ] - } - } -} -extension RasterContext { - var toJSON : [String: AnyObject] { - switch self { - case .PointCtx(let arg0, let arg1, let arg2): - return [ "tag" : "PointCtx", "arg0" : arg0.toJSON, "arg1" : arg1.toJSON, "arg2" : arg2.toJSON] - case .LineCtx(let arg0, let arg1): - return [ "tag" : "LineCtx", "arg0" : arg0.toJSON, "arg1" : arg1.toJSON] - case .TriangleCtx(let arg0, let arg1, let arg2, let arg3): - return [ "tag" : "TriangleCtx", "arg0" : arg0.toJSON, "arg1" : arg1.toJSON, "arg2" : arg2.toJSON, "arg3" : arg3.toJSON] - } - } -} -extension FragmentOperation { - var toJSON : [String: AnyObject] { - switch self { - case .DepthOp(let arg0, let arg1): - return [ "tag" : "DepthOp", "arg0" : arg0.toJSON, "arg1" : arg1.toJSON] - case .StencilOp(let arg0, let arg1, let arg2): - return [ "tag" : "StencilOp", "arg0" : arg0.toJSON, "arg1" : arg1.toJSON, "arg2" : arg2.toJSON] - case .ColorOp(let arg0, let arg1): - return [ "tag" : "ColorOp", "arg0" : arg0.toJSON, "arg1" : arg1.toJSON] - } - } -} -extension AccumulationContext { - var toJSON : [String: AnyObject] { - switch self { - case .AccumulationContext(let v): - return [ "tag" : "AccumulationContext" - , "accViewportName" : v.accViewportName.toJSON - , "accOperations" : v.accOperations.toJSON - ] - } - } -} -extension TextureDataType { - var toJSON : [String: AnyObject] { - switch self { - case .FloatT(let arg0): - return [ "tag" : "FloatT", "arg0" : arg0.toJSON] - case .IntT(let arg0): - return [ "tag" : "IntT", "arg0" : arg0.toJSON] - case .WordT(let arg0): - return [ "tag" : "WordT", "arg0" : arg0.toJSON] - case .ShadowT: - return [ "tag" : "ShadowT"] - } - } -} -extension TextureType { - var toJSON : [String: AnyObject] { - switch self { - case .Texture1D(let arg0, let arg1): - return [ "tag" : "Texture1D", "arg0" : arg0.toJSON, "arg1" : arg1.toJSON] - case .Texture2D(let arg0, let arg1): - return [ "tag" : "Texture2D", "arg0" : arg0.toJSON, "arg1" : arg1.toJSON] - case .Texture3D(let arg0): - return [ "tag" : "Texture3D", "arg0" : arg0.toJSON] - case .TextureCube(let arg0): - return [ "tag" : "TextureCube", "arg0" : arg0.toJSON] - case .TextureRect(let arg0): - return [ "tag" : "TextureRect", "arg0" : arg0.toJSON] - case .Texture2DMS(let arg0, let arg1, let arg2, let arg3): - return [ "tag" : "Texture2DMS", "arg0" : arg0.toJSON, "arg1" : arg1.toJSON, "arg2" : arg2.toJSON, "arg3" : arg3.toJSON] - case .TextureBuffer(let arg0): - return [ "tag" : "TextureBuffer", "arg0" : arg0.toJSON] - } - } -} -extension MipMap { - var toJSON : [String: AnyObject] { - switch self { - case .Mip(let arg0, let arg1): - return [ "tag" : "Mip", "arg0" : arg0.toJSON, "arg1" : arg1.toJSON] - case .NoMip: - return [ "tag" : "NoMip"] - case .AutoMip(let arg0, let arg1): - return [ "tag" : "AutoMip", "arg0" : arg0.toJSON, "arg1" : arg1.toJSON] - } - } -} -extension Filter { - var toJSON : [String: AnyObject] { - switch self { - case .Nearest: - return [ "tag" : "Nearest"] - case .Linear: - return [ "tag" : "Linear"] - case .NearestMipmapNearest: - return [ "tag" : "NearestMipmapNearest"] - case .NearestMipmapLinear: - return [ "tag" : "NearestMipmapLinear"] - case .LinearMipmapNearest: - return [ "tag" : "LinearMipmapNearest"] - case .LinearMipmapLinear: - return [ "tag" : "LinearMipmapLinear"] - } - } -} -extension EdgeMode { - var toJSON : [String: AnyObject] { - switch self { - case .Repeat: - return [ "tag" : "Repeat"] - case .MirroredRepeat: - return [ "tag" : "MirroredRepeat"] - case .ClampToEdge: - return [ "tag" : "ClampToEdge"] - case .ClampToBorder: - return [ "tag" : "ClampToBorder"] - } - } -} -extension ImageSemantic { - var toJSON : [String: AnyObject] { - switch self { - case .Depth: - return [ "tag" : "Depth"] - case .Stencil: - return [ "tag" : "Stencil"] - case .Color: - return [ "tag" : "Color"] - } - } -} -extension ImageRef { - var toJSON : [String: AnyObject] { - switch self { - case .TextureImage(let arg0, let arg1, let arg2): - return [ "tag" : "TextureImage", "arg0" : arg0.toJSON, "arg1" : arg1.toJSON, "arg2" : arg2.toJSON] - case .Framebuffer(let arg0): - return [ "tag" : "Framebuffer", "arg0" : arg0.toJSON] - } - } -} -extension ClearImage { - var toJSON : [String: AnyObject] { - switch self { - case .ClearImage(let v): - return [ "tag" : "ClearImage" - , "imageSemantic" : v.imageSemantic.toJSON - , "clearValue" : v.clearValue.toJSON - ] - } - } -} -extension Command { - var toJSON : [String: AnyObject] { - switch self { - case .SetRasterContext(let arg0): - return [ "tag" : "SetRasterContext", "arg0" : arg0.toJSON] - case .SetAccumulationContext(let arg0): - return [ "tag" : "SetAccumulationContext", "arg0" : arg0.toJSON] - case .SetRenderTarget(let arg0): - return [ "tag" : "SetRenderTarget", "arg0" : arg0.toJSON] - case .SetProgram(let arg0): - return [ "tag" : "SetProgram", "arg0" : arg0.toJSON] - case .SetSamplerUniform(let arg0, let arg1): - return [ "tag" : "SetSamplerUniform", "arg0" : arg0.toJSON, "arg1" : arg1.toJSON] - case .SetTexture(let arg0, let arg1): - return [ "tag" : "SetTexture", "arg0" : arg0.toJSON, "arg1" : arg1.toJSON] - case .SetSampler(let arg0, let arg1): - return [ "tag" : "SetSampler", "arg0" : arg0.toJSON, "arg1" : arg1.toJSON] - case .RenderSlot(let arg0): - return [ "tag" : "RenderSlot", "arg0" : arg0.toJSON] - case .RenderStream(let arg0): - return [ "tag" : "RenderStream", "arg0" : arg0.toJSON] - case .ClearRenderTarget(let arg0): - return [ "tag" : "ClearRenderTarget", "arg0" : arg0.toJSON] - case .GenerateMipMap(let arg0): - return [ "tag" : "GenerateMipMap", "arg0" : arg0.toJSON] - case .SaveImage(let arg0, let arg1): - return [ "tag" : "SaveImage", "arg0" : arg0.toJSON, "arg1" : arg1.toJSON] - case .LoadImage(let arg0, let arg1): - return [ "tag" : "LoadImage", "arg0" : arg0.toJSON, "arg1" : arg1.toJSON] - } - } -} -extension SamplerDescriptor { - var toJSON : [String: AnyObject] { - switch self { - case .SamplerDescriptor(let v): - return [ "tag" : "SamplerDescriptor" - , "samplerWrapS" : v.samplerWrapS.toJSON - , "samplerWrapT" : v.samplerWrapT.toJSON - , "samplerWrapR" : v.samplerWrapR.toJSON - , "samplerMinFilter" : v.samplerMinFilter.toJSON - , "samplerMagFilter" : v.samplerMagFilter.toJSON - , "samplerBorderColor" : v.samplerBorderColor.toJSON - , "samplerMinLod" : v.samplerMinLod.toJSON - , "samplerMaxLod" : v.samplerMaxLod.toJSON - , "samplerLodBias" : v.samplerLodBias.toJSON - , "samplerCompareFunc" : v.samplerCompareFunc.toJSON - ] - } - } -} -extension TextureDescriptor { - var toJSON : [String: AnyObject] { - switch self { - case .TextureDescriptor(let v): - return [ "tag" : "TextureDescriptor" - , "textureType" : v.textureType.toJSON - , "textureSize" : v.textureSize.toJSON - , "textureSemantic" : v.textureSemantic.toJSON - , "textureSampler" : v.textureSampler.toJSON - , "textureBaseLevel" : v.textureBaseLevel.toJSON - , "textureMaxLevel" : v.textureMaxLevel.toJSON - ] - } - } -} -extension Parameter { - var toJSON : [String: AnyObject] { - switch self { - case .Parameter(let v): - return [ "tag" : "Parameter" - , "name" : v.name.toJSON - , "ty" : v.ty.toJSON - ] - } - } -} -extension Program { - var toJSON : [String: AnyObject] { - switch self { - case .Program(let v): - return [ "tag" : "Program" - , "programUniforms" : v.programUniforms.toJSON - , "programStreams" : v.programStreams.toJSON - , "programInTextures" : v.programInTextures.toJSON - , "programOutput" : v.programOutput.toJSON - , "vertexShader" : v.vertexShader.toJSON - , "geometryShader" : v.geometryShader.toJSON - , "fragmentShader" : v.fragmentShader.toJSON - ] - } - } -} -extension Slot { - var toJSON : [String: AnyObject] { - switch self { - case .Slot(let v): - return [ "tag" : "Slot" - , "slotName" : v.slotName.toJSON - , "slotStreams" : v.slotStreams.toJSON - , "slotUniforms" : v.slotUniforms.toJSON - , "slotPrimitive" : v.slotPrimitive.toJSON - , "slotPrograms" : v.slotPrograms.toJSON - ] - } - } -} -extension StreamData { - var toJSON : [String: AnyObject] { - switch self { - case .StreamData(let v): - return [ "tag" : "StreamData" - , "streamData" : v.streamData.toJSON - , "streamType" : v.streamType.toJSON - , "streamPrimitive" : v.streamPrimitive.toJSON - , "streamPrograms" : v.streamPrograms.toJSON - ] - } - } -} -extension TargetItem { - var toJSON : [String: AnyObject] { - switch self { - case .TargetItem(let v): - return [ "tag" : "TargetItem" - , "targetSemantic" : v.targetSemantic.toJSON - , "targetRef" : v.targetRef.toJSON - ] - } - } -} -extension RenderTarget { - var toJSON : [String: AnyObject] { - switch self { - case .RenderTarget(let v): - return [ "tag" : "RenderTarget" - , "renderTargets" : v.renderTargets.toJSON - ] - } - } -} -extension Backend { - var toJSON : [String: AnyObject] { - switch self { - case .WebGL1: - return [ "tag" : "WebGL1"] - case .OpenGL33: - return [ "tag" : "OpenGL33"] - } - } -} -extension Pipeline { - var toJSON : [String: AnyObject] { - switch self { - case .Pipeline(let v): - return [ "tag" : "Pipeline" - , "backend" : v.backend.toJSON - , "textures" : v.textures.toJSON - , "samplers" : v.samplers.toJSON - , "targets" : v.targets.toJSON - , "programs" : v.programs.toJSON - , "slots" : v.slots.toJSON - , "streams" : v.streams.toJSON - , "commands" : v.commands.toJSON - ] - } - } -} - -enum Maybe { - case Nothing - case Just(T) -} - -enum Type { - case Int - case Int32 - case Word - case Word32 - case Float - case Bool - case String - case Array(Type) - case List(Type) - case Maybe(Type) - case Map(Type,Type) - case ArrayValue - case Value - case InputType - case PointSpriteCoordOrigin - case PointSize - case PolygonOffset - case FrontFace - case PolygonMode - case ProvokingVertex - case CullMode - case ComparisonFunction - case StencilOperation - case BlendEquation - case BlendingFactor - case LogicOperation - case StencilOps - case StencilTest - case StencilTests - case FetchPrimitive - case OutputPrimitive - case ColorArity - case Blending - case RasterContext - case FragmentOperation - case AccumulationContext - case TextureDataType - case TextureType - case MipMap - case Filter - case EdgeMode - case ImageSemantic - case ImageRef - case ClearImage - case Command - case SamplerDescriptor - case TextureDescriptor - case Parameter - case Program - case Slot - case StreamData - case TargetItem - case RenderTarget - case Backend - case Pipeline -} - -func fromJSON(type: Type, personName: String) -> Any { - switch type { - case .Int: return 0 - case .Int32: return 0 - case .Word: return 0 - case .Word32: return 0 - case .Float: return 0.0 - case .Bool: return false - case .String: return "" - case .Array(let a): return fromJSON(a,personName) - case .List(let a): return fromJSON(a,personName) - case .Maybe(let a): return fromJSON(a,personName) - } - return 0; -} \ No newline at end of file diff --git a/ddl/out/IR2.hpp b/ddl/out/IR2.hpp deleted file mode 100644 index d286395..0000000 --- a/ddl/out/IR2.hpp +++ /dev/null @@ -1,1070 +0,0 @@ -// generated file, do not modify! -// 2016-01-18T14:30:07.798481Z - -#ifndef HEADER_IR_H -#define HEADER_IR_H - -#include "RT.hpp" - - -typedef Int StreamName; - -typedef Int ProgramName; - -typedef Int TextureName; - -typedef Int SamplerName; - -typedef String UniformName; - -typedef Int SlotName; - -typedef Int FrameBufferComponent; - -typedef Int TextureUnit; - -typedef Int RenderTargetName; - -typedef std::map<::UniformName, ::TextureUnit> TextureUnitMapping; - -namespace data { - class VBoolArray { - public: - std::vector _0; - }; - class VIntArray { - public: - std::vector _0; - }; - class VWordArray { - public: - std::vector _0; - }; - class VFloatArray { - public: - std::vector _0; - }; -} -class ArrayValue { -public: - enum class tag { - VBoolArray, - VIntArray, - VWordArray, - VFloatArray - } tag; - std::shared_ptr VBoolArray; - std::shared_ptr VIntArray; - std::shared_ptr VWordArray; - std::shared_ptr VFloatArray; -}; -namespace data { - class VBool { - public: - Bool _0; - }; - class VV2B { - public: - V2B _0; - }; - class VV3B { - public: - V3B _0; - }; - class VV4B { - public: - V4B _0; - }; - class VWord { - public: - Word32 _0; - }; - class VV2U { - public: - V2U _0; - }; - class VV3U { - public: - V3U _0; - }; - class VV4U { - public: - V4U _0; - }; - class VInt { - public: - Int32 _0; - }; - class VV2I { - public: - V2I _0; - }; - class VV3I { - public: - V3I _0; - }; - class VV4I { - public: - V4I _0; - }; - class VFloat { - public: - Float _0; - }; - class VV2F { - public: - V2F _0; - }; - class VV3F { - public: - V3F _0; - }; - class VV4F { - public: - V4F _0; - }; - class VM22F { - public: - M22F _0; - }; - class VM23F { - public: - M23F _0; - }; - class VM24F { - public: - M24F _0; - }; - class VM32F { - public: - M32F _0; - }; - class VM33F { - public: - M33F _0; - }; - class VM34F { - public: - M34F _0; - }; - class VM42F { - public: - M42F _0; - }; - class VM43F { - public: - M43F _0; - }; - class VM44F { - public: - M44F _0; - }; -} -class Value { -public: - enum class tag { - VBool, - VV2B, - VV3B, - VV4B, - VWord, - VV2U, - VV3U, - VV4U, - VInt, - VV2I, - VV3I, - VV4I, - VFloat, - VV2F, - VV3F, - VV4F, - VM22F, - VM23F, - VM24F, - VM32F, - VM33F, - VM34F, - VM42F, - VM43F, - VM44F - } tag; - std::shared_ptr VBool; - std::shared_ptr VV2B; - std::shared_ptr VV3B; - std::shared_ptr VV4B; - std::shared_ptr VWord; - std::shared_ptr VV2U; - std::shared_ptr VV3U; - std::shared_ptr VV4U; - std::shared_ptr VInt; - std::shared_ptr VV2I; - std::shared_ptr VV3I; - std::shared_ptr VV4I; - std::shared_ptr VFloat; - std::shared_ptr VV2F; - std::shared_ptr VV3F; - std::shared_ptr VV4F; - std::shared_ptr VM22F; - std::shared_ptr VM23F; - std::shared_ptr VM24F; - std::shared_ptr VM32F; - std::shared_ptr VM33F; - std::shared_ptr VM34F; - std::shared_ptr VM42F; - std::shared_ptr VM43F; - std::shared_ptr VM44F; -}; -namespace data { -} -class InputType { -public: - enum class tag { - Bool, - V2B, - V3B, - V4B, - Word, - V2U, - V3U, - V4U, - Int, - V2I, - V3I, - V4I, - Float, - V2F, - V3F, - V4F, - M22F, - M23F, - M24F, - M32F, - M33F, - M34F, - M42F, - M43F, - M44F, - STexture1D, - STexture2D, - STextureCube, - STexture1DArray, - STexture2DArray, - STexture2DRect, - FTexture1D, - FTexture2D, - FTexture3D, - FTextureCube, - FTexture1DArray, - FTexture2DArray, - FTexture2DMS, - FTexture2DMSArray, - FTextureBuffer, - FTexture2DRect, - ITexture1D, - ITexture2D, - ITexture3D, - ITextureCube, - ITexture1DArray, - ITexture2DArray, - ITexture2DMS, - ITexture2DMSArray, - ITextureBuffer, - ITexture2DRect, - UTexture1D, - UTexture2D, - UTexture3D, - UTextureCube, - UTexture1DArray, - UTexture2DArray, - UTexture2DMS, - UTexture2DMSArray, - UTextureBuffer, - UTexture2DRect - } tag; -}; -namespace data { -} -class PointSpriteCoordOrigin { -public: - enum class tag { - LowerLeft, - UpperLeft - } tag; -}; -namespace data { - class PointSize { - public: - Float _0; - }; -} -class PointSize { -public: - enum class tag { - PointSize, - ProgramPointSize - } tag; - std::shared_ptr PointSize; -}; -namespace data { - class Offset { - public: - Float _0; - Float _1; - }; -} -class PolygonOffset { -public: - enum class tag { - NoOffset, - Offset - } tag; - std::shared_ptr Offset; -}; -namespace data { -} -class FrontFace { -public: - enum class tag { - CCW, - CW - } tag; -}; -namespace data { - class PolygonPoint { - public: - std::shared_ptr<::PointSize> _0; - }; - class PolygonLine { - public: - Float _0; - }; -} -class PolygonMode { -public: - enum class tag { - PolygonPoint, - PolygonLine, - PolygonFill - } tag; - std::shared_ptr PolygonPoint; - std::shared_ptr PolygonLine; -}; -namespace data { -} -class ProvokingVertex { -public: - enum class tag { - FirstVertex, - LastVertex - } tag; -}; -namespace data { - class CullFront { - public: - std::shared_ptr<::FrontFace> _0; - }; - class CullBack { - public: - std::shared_ptr<::FrontFace> _0; - }; -} -class CullMode { -public: - enum class tag { - CullNone, - CullFront, - CullBack - } tag; - std::shared_ptr CullFront; - std::shared_ptr CullBack; -}; -namespace data { -} -class ComparisonFunction { -public: - enum class tag { - Never, - Less, - Equal, - Lequal, - Greater, - Notequal, - Gequal, - Always - } tag; -}; -typedef ComparisonFunction DepthFunction; - -namespace data { -} -class StencilOperation { -public: - enum class tag { - OpZero, - OpKeep, - OpReplace, - OpIncr, - OpIncrWrap, - OpDecr, - OpDecrWrap, - OpInvert - } tag; -}; -namespace data { -} -class BlendEquation { -public: - enum class tag { - FuncAdd, - FuncSubtract, - FuncReverseSubtract, - Min, - Max - } tag; -}; -namespace data { -} -class BlendingFactor { -public: - enum class tag { - Zero, - One, - SrcColor, - OneMinusSrcColor, - DstColor, - OneMinusDstColor, - SrcAlpha, - OneMinusSrcAlpha, - DstAlpha, - OneMinusDstAlpha, - ConstantColor, - OneMinusConstantColor, - ConstantAlpha, - OneMinusConstantAlpha, - SrcAlphaSaturate - } tag; -}; -namespace data { -} -class LogicOperation { -public: - enum class tag { - Clear, - And, - AndReverse, - Copy, - AndInverted, - Noop, - Xor, - Or, - Nor, - Equiv, - Invert, - OrReverse, - CopyInverted, - OrInverted, - Nand, - Set - } tag; -}; -namespace data { - class StencilOps { - public: - std::shared_ptr<::StencilOperation> frontStencilOp; - std::shared_ptr<::StencilOperation> backStencilOp; - }; -} -class StencilOps { -public: - enum class tag { - StencilOps - } tag; - std::shared_ptr StencilOps; -}; -namespace data { - class StencilTest { - public: - std::shared_ptr<::ComparisonFunction> stencilComparision; - Int32 stencilReference; - Word32 stencilMask; - }; -} -class StencilTest { -public: - enum class tag { - StencilTest - } tag; - std::shared_ptr StencilTest; -}; -namespace data { - class StencilTests { - public: - std::shared_ptr<::StencilTest> _0; - std::shared_ptr<::StencilTest> _1; - }; -} -class StencilTests { -public: - enum class tag { - StencilTests - } tag; - std::shared_ptr StencilTests; -}; -namespace data { -} -class FetchPrimitive { -public: - enum class tag { - Points, - Lines, - Triangles, - LinesAdjacency, - TrianglesAdjacency - } tag; -}; -namespace data { -} -class OutputPrimitive { -public: - enum class tag { - TrianglesOutput, - LinesOutput, - PointsOutput - } tag; -}; -namespace data { -} -class ColorArity { -public: - enum class tag { - Red, - RG, - RGB, - RGBA - } tag; -}; -namespace data { - class BlendLogicOp { - public: - std::shared_ptr<::LogicOperation> _0; - }; - class Blend { - public: - std::shared_ptr<::BlendEquation> colorEqSrc; - std::shared_ptr<::BlendEquation> alphaEqSrc; - std::shared_ptr<::BlendingFactor> colorFSrc; - std::shared_ptr<::BlendingFactor> colorFDst; - std::shared_ptr<::BlendingFactor> alphaFSrc; - std::shared_ptr<::BlendingFactor> alphaFDst; - V4F color; - }; -} -class Blending { -public: - enum class tag { - NoBlending, - BlendLogicOp, - Blend - } tag; - std::shared_ptr BlendLogicOp; - std::shared_ptr Blend; -}; -namespace data { - class PointCtx { - public: - std::shared_ptr<::PointSize> _0; - Float _1; - std::shared_ptr<::PointSpriteCoordOrigin> _2; - }; - class LineCtx { - public: - Float _0; - std::shared_ptr<::ProvokingVertex> _1; - }; - class TriangleCtx { - public: - std::shared_ptr<::CullMode> _0; - std::shared_ptr<::PolygonMode> _1; - std::shared_ptr<::PolygonOffset> _2; - std::shared_ptr<::ProvokingVertex> _3; - }; -} -class RasterContext { -public: - enum class tag { - PointCtx, - LineCtx, - TriangleCtx - } tag; - std::shared_ptr PointCtx; - std::shared_ptr LineCtx; - std::shared_ptr TriangleCtx; -}; -namespace data { - class DepthOp { - public: - std::shared_ptr<::DepthFunction> _0; - Bool _1; - }; - class StencilOp { - public: - std::shared_ptr<::StencilTests> _0; - std::shared_ptr<::StencilOps> _1; - std::shared_ptr<::StencilOps> _2; - }; - class ColorOp { - public: - std::shared_ptr<::Blending> _0; - std::shared_ptr<::Value> _1; - }; -} -class FragmentOperation { -public: - enum class tag { - DepthOp, - StencilOp, - ColorOp - } tag; - std::shared_ptr DepthOp; - std::shared_ptr StencilOp; - std::shared_ptr ColorOp; -}; -namespace data { - class AccumulationContext { - public: - Maybe accViewportName; - std::vector> accOperations; - }; -} -class AccumulationContext { -public: - enum class tag { - AccumulationContext - } tag; - std::shared_ptr AccumulationContext; -}; -namespace data { - class FloatT { - public: - std::shared_ptr<::ColorArity> _0; - }; - class IntT { - public: - std::shared_ptr<::ColorArity> _0; - }; - class WordT { - public: - std::shared_ptr<::ColorArity> _0; - }; -} -class TextureDataType { -public: - enum class tag { - FloatT, - IntT, - WordT, - ShadowT - } tag; - std::shared_ptr FloatT; - std::shared_ptr IntT; - std::shared_ptr WordT; -}; -namespace data { - class Texture1D { - public: - std::shared_ptr<::TextureDataType> _0; - Int _1; - }; - class Texture2D { - public: - std::shared_ptr<::TextureDataType> _0; - Int _1; - }; - class Texture3D { - public: - std::shared_ptr<::TextureDataType> _0; - }; - class TextureCube { - public: - std::shared_ptr<::TextureDataType> _0; - }; - class TextureRect { - public: - std::shared_ptr<::TextureDataType> _0; - }; - class Texture2DMS { - public: - std::shared_ptr<::TextureDataType> _0; - Int _1; - Int _2; - Bool _3; - }; - class TextureBuffer { - public: - std::shared_ptr<::TextureDataType> _0; - }; -} -class TextureType { -public: - enum class tag { - Texture1D, - Texture2D, - Texture3D, - TextureCube, - TextureRect, - Texture2DMS, - TextureBuffer - } tag; - std::shared_ptr Texture1D; - std::shared_ptr Texture2D; - std::shared_ptr Texture3D; - std::shared_ptr TextureCube; - std::shared_ptr TextureRect; - std::shared_ptr Texture2DMS; - std::shared_ptr TextureBuffer; -}; -namespace data { - class Mip { - public: - Int _0; - Int _1; - }; - class AutoMip { - public: - Int _0; - Int _1; - }; -} -class MipMap { -public: - enum class tag { - Mip, - NoMip, - AutoMip - } tag; - std::shared_ptr Mip; - std::shared_ptr AutoMip; -}; -namespace data { -} -class Filter { -public: - enum class tag { - Nearest, - Linear, - NearestMipmapNearest, - NearestMipmapLinear, - LinearMipmapNearest, - LinearMipmapLinear - } tag; -}; -namespace data { -} -class EdgeMode { -public: - enum class tag { - Repeat, - MirroredRepeat, - ClampToEdge, - ClampToBorder - } tag; -}; -namespace data { -} -class ImageSemantic { -public: - enum class tag { - Depth, - Stencil, - Color - } tag; -}; -namespace data { - class TextureImage { - public: - ::TextureName _0; - Int _1; - Maybe _2; - }; - class Framebuffer { - public: - std::shared_ptr<::ImageSemantic> _0; - }; -} -class ImageRef { -public: - enum class tag { - TextureImage, - Framebuffer - } tag; - std::shared_ptr TextureImage; - std::shared_ptr Framebuffer; -}; -namespace data { - class ClearImage { - public: - std::shared_ptr<::ImageSemantic> imageSemantic; - std::shared_ptr<::Value> clearValue; - }; -} -class ClearImage { -public: - enum class tag { - ClearImage - } tag; - std::shared_ptr ClearImage; -}; -namespace data { - class SetRasterContext { - public: - std::shared_ptr<::RasterContext> _0; - }; - class SetAccumulationContext { - public: - std::shared_ptr<::AccumulationContext> _0; - }; - class SetRenderTarget { - public: - ::RenderTargetName _0; - }; - class SetProgram { - public: - ::ProgramName _0; - }; - class SetSamplerUniform { - public: - ::UniformName _0; - ::TextureUnit _1; - }; - class SetTexture { - public: - ::TextureUnit _0; - ::TextureName _1; - }; - class SetSampler { - public: - ::TextureUnit _0; - Maybe<::SamplerName> _1; - }; - class RenderSlot { - public: - ::SlotName _0; - }; - class RenderStream { - public: - ::StreamName _0; - }; - class ClearRenderTarget { - public: - std::vector> _0; - }; - class GenerateMipMap { - public: - ::TextureUnit _0; - }; - class SaveImage { - public: - ::FrameBufferComponent _0; - std::shared_ptr<::ImageRef> _1; - }; - class LoadImage { - public: - std::shared_ptr<::ImageRef> _0; - ::FrameBufferComponent _1; - }; -} -class Command { -public: - enum class tag { - SetRasterContext, - SetAccumulationContext, - SetRenderTarget, - SetProgram, - SetSamplerUniform, - SetTexture, - SetSampler, - RenderSlot, - RenderStream, - ClearRenderTarget, - GenerateMipMap, - SaveImage, - LoadImage - } tag; - std::shared_ptr SetRasterContext; - std::shared_ptr SetAccumulationContext; - std::shared_ptr SetRenderTarget; - std::shared_ptr SetProgram; - std::shared_ptr SetSamplerUniform; - std::shared_ptr SetTexture; - std::shared_ptr SetSampler; - std::shared_ptr RenderSlot; - std::shared_ptr RenderStream; - std::shared_ptr ClearRenderTarget; - std::shared_ptr GenerateMipMap; - std::shared_ptr SaveImage; - std::shared_ptr LoadImage; -}; -namespace data { - class SamplerDescriptor { - public: - std::shared_ptr<::EdgeMode> samplerWrapS; - Maybe> samplerWrapT; - Maybe> samplerWrapR; - std::shared_ptr<::Filter> samplerMinFilter; - std::shared_ptr<::Filter> samplerMagFilter; - std::shared_ptr<::Value> samplerBorderColor; - Maybe samplerMinLod; - Maybe samplerMaxLod; - Float samplerLodBias; - Maybe> samplerCompareFunc; - }; -} -class SamplerDescriptor { -public: - enum class tag { - SamplerDescriptor - } tag; - std::shared_ptr SamplerDescriptor; -}; -namespace data { - class TextureDescriptor { - public: - std::shared_ptr<::TextureType> textureType; - std::shared_ptr<::Value> textureSize; - std::shared_ptr<::ImageSemantic> textureSemantic; - std::shared_ptr<::SamplerDescriptor> textureSampler; - Int textureBaseLevel; - Int textureMaxLevel; - }; -} -class TextureDescriptor { -public: - enum class tag { - TextureDescriptor - } tag; - std::shared_ptr TextureDescriptor; -}; -namespace data { - class Parameter { - public: - String name; - std::shared_ptr<::InputType> ty; - }; -} -class Parameter { -public: - enum class tag { - Parameter - } tag; - std::shared_ptr Parameter; -}; -namespace data { - class Program { - public: - std::map<::UniformName, std::shared_ptr<::InputType>> programUniforms; - std::map<::UniformName, std::shared_ptr<::Parameter>> programStreams; - std::map<::UniformName, std::shared_ptr<::InputType>> programInTextures; - std::vector> programOutput; - String vertexShader; - Maybe geometryShader; - String fragmentShader; - }; -} -class Program { -public: - enum class tag { - Program - } tag; - std::shared_ptr Program; -}; -namespace data { - class Slot { - public: - String slotName; - std::map> slotStreams; - std::map<::UniformName, std::shared_ptr<::InputType>> slotUniforms; - std::shared_ptr<::FetchPrimitive> slotPrimitive; - std::vector<::ProgramName> slotPrograms; - }; -} -class Slot { -public: - enum class tag { - Slot - } tag; - std::shared_ptr Slot; -}; -namespace data { - class StreamData { - public: - std::map> streamData; - std::map> streamType; - std::shared_ptr<::FetchPrimitive> streamPrimitive; - std::vector<::ProgramName> streamPrograms; - }; -} -class StreamData { -public: - enum class tag { - StreamData - } tag; - std::shared_ptr StreamData; -}; -namespace data { - class TargetItem { - public: - std::shared_ptr<::ImageSemantic> targetSemantic; - Maybe> targetRef; - }; -} -class TargetItem { -public: - enum class tag { - TargetItem - } tag; - std::shared_ptr TargetItem; -}; -namespace data { - class RenderTarget { - public: - std::vector> renderTargets; - }; -} -class RenderTarget { -public: - enum class tag { - RenderTarget - } tag; - std::shared_ptr RenderTarget; -}; -namespace data { -} -class Backend { -public: - enum class tag { - WebGL1, - OpenGL33 - } tag; -}; -namespace data { - class Pipeline { - public: - std::shared_ptr<::Backend> backend; - std::vector> textures; - std::vector> samplers; - std::vector> targets; - std::vector> programs; - std::vector> slots; - std::vector> streams; - std::vector> commands; - }; -} -class Pipeline { -public: - enum class tag { - Pipeline - } tag; - std::shared_ptr Pipeline; -}; -#endif 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 @@ +// generated file, do not modify! +// 2016-01-28T13:15:30.803775Z + +#include "LambdaCube.IR.hpp" +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::ArrayValue::tag::VBoolArray: + obj["tag"] = "VBoolArray"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::ArrayValue::tag::VIntArray: + obj["tag"] = "VIntArray"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::ArrayValue::tag::VWordArray: + obj["tag"] = "VWordArray"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::ArrayValue::tag::VFloatArray: + obj["tag"] = "VFloatArray"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::ArrayValue::tag tagType; + std::string tag = obj["tag"]; + if (tag == "VBoolArray") { + tagType = ::ArrayValue::tag::VBoolArray; + std::shared_ptr tv(new data::VBoolArray()); + tv->_0 = fromJSON(W>(), obj["arg0"]); + return tv; + } + else if (tag == "VIntArray") { + tagType = ::ArrayValue::tag::VIntArray; + std::shared_ptr tv(new data::VIntArray()); + tv->_0 = fromJSON(W>(), obj["arg0"]); + return tv; + } + else if (tag == "VWordArray") { + tagType = ::ArrayValue::tag::VWordArray; + std::shared_ptr tv(new data::VWordArray()); + tv->_0 = fromJSON(W>(), obj["arg0"]); + return tv; + } + else if (tag == "VFloatArray") { + tagType = ::ArrayValue::tag::VFloatArray; + std::shared_ptr tv(new data::VFloatArray()); + tv->_0 = fromJSON(W>(), obj["arg0"]); + return tv; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::ArrayValue> o(new ::ArrayValue()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::Value::tag::VBool: + obj["tag"] = "VBool"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::Value::tag::VV2B: + obj["tag"] = "VV2B"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::Value::tag::VV3B: + obj["tag"] = "VV3B"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::Value::tag::VV4B: + obj["tag"] = "VV4B"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::Value::tag::VWord: + obj["tag"] = "VWord"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::Value::tag::VV2U: + obj["tag"] = "VV2U"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::Value::tag::VV3U: + obj["tag"] = "VV3U"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::Value::tag::VV4U: + obj["tag"] = "VV4U"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::Value::tag::VInt: + obj["tag"] = "VInt"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::Value::tag::VV2I: + obj["tag"] = "VV2I"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::Value::tag::VV3I: + obj["tag"] = "VV3I"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::Value::tag::VV4I: + obj["tag"] = "VV4I"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::Value::tag::VFloat: + obj["tag"] = "VFloat"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::Value::tag::VV2F: + obj["tag"] = "VV2F"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::Value::tag::VV3F: + obj["tag"] = "VV3F"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::Value::tag::VV4F: + obj["tag"] = "VV4F"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::Value::tag::VM22F: + obj["tag"] = "VM22F"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::Value::tag::VM23F: + obj["tag"] = "VM23F"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::Value::tag::VM24F: + obj["tag"] = "VM24F"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::Value::tag::VM32F: + obj["tag"] = "VM32F"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::Value::tag::VM33F: + obj["tag"] = "VM33F"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::Value::tag::VM34F: + obj["tag"] = "VM34F"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::Value::tag::VM42F: + obj["tag"] = "VM42F"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::Value::tag::VM43F: + obj["tag"] = "VM43F"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::Value::tag::VM44F: + obj["tag"] = "VM44F"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::Value::tag tagType; + std::string tag = obj["tag"]; + if (tag == "VBool") { + tagType = ::Value::tag::VBool; + std::shared_ptr tv(new data::VBool()); + tv->_0 = fromJSON(W(), obj["arg0"]); + return tv; + } + else if (tag == "VV2B") { + tagType = ::Value::tag::VV2B; + std::shared_ptr tv(new data::VV2B()); + tv->_0 = fromJSON(W(), obj["arg0"]); + return tv; + } + else if (tag == "VV3B") { + tagType = ::Value::tag::VV3B; + std::shared_ptr tv(new data::VV3B()); + tv->_0 = fromJSON(W(), obj["arg0"]); + return tv; + } + else if (tag == "VV4B") { + tagType = ::Value::tag::VV4B; + std::shared_ptr tv(new data::VV4B()); + tv->_0 = fromJSON(W(), obj["arg0"]); + return tv; + } + else if (tag == "VWord") { + tagType = ::Value::tag::VWord; + std::shared_ptr tv(new data::VWord()); + tv->_0 = fromJSON(W(), obj["arg0"]); + return tv; + } + else if (tag == "VV2U") { + tagType = ::Value::tag::VV2U; + std::shared_ptr tv(new data::VV2U()); + tv->_0 = fromJSON(W(), obj["arg0"]); + return tv; + } + else if (tag == "VV3U") { + tagType = ::Value::tag::VV3U; + std::shared_ptr tv(new data::VV3U()); + tv->_0 = fromJSON(W(), obj["arg0"]); + return tv; + } + else if (tag == "VV4U") { + tagType = ::Value::tag::VV4U; + std::shared_ptr tv(new data::VV4U()); + tv->_0 = fromJSON(W(), obj["arg0"]); + return tv; + } + else if (tag == "VInt") { + tagType = ::Value::tag::VInt; + std::shared_ptr tv(new data::VInt()); + tv->_0 = fromJSON(W(), obj["arg0"]); + return tv; + } + else if (tag == "VV2I") { + tagType = ::Value::tag::VV2I; + std::shared_ptr tv(new data::VV2I()); + tv->_0 = fromJSON(W(), obj["arg0"]); + return tv; + } + else if (tag == "VV3I") { + tagType = ::Value::tag::VV3I; + std::shared_ptr tv(new data::VV3I()); + tv->_0 = fromJSON(W(), obj["arg0"]); + return tv; + } + else if (tag == "VV4I") { + tagType = ::Value::tag::VV4I; + std::shared_ptr tv(new data::VV4I()); + tv->_0 = fromJSON(W(), obj["arg0"]); + return tv; + } + else if (tag == "VFloat") { + tagType = ::Value::tag::VFloat; + std::shared_ptr tv(new data::VFloat()); + tv->_0 = fromJSON(W(), obj["arg0"]); + return tv; + } + else if (tag == "VV2F") { + tagType = ::Value::tag::VV2F; + std::shared_ptr tv(new data::VV2F()); + tv->_0 = fromJSON(W(), obj["arg0"]); + return tv; + } + else if (tag == "VV3F") { + tagType = ::Value::tag::VV3F; + std::shared_ptr tv(new data::VV3F()); + tv->_0 = fromJSON(W(), obj["arg0"]); + return tv; + } + else if (tag == "VV4F") { + tagType = ::Value::tag::VV4F; + std::shared_ptr tv(new data::VV4F()); + tv->_0 = fromJSON(W(), obj["arg0"]); + return tv; + } + else if (tag == "VM22F") { + tagType = ::Value::tag::VM22F; + std::shared_ptr tv(new data::VM22F()); + tv->_0 = fromJSON(W(), obj["arg0"]); + return tv; + } + else if (tag == "VM23F") { + tagType = ::Value::tag::VM23F; + std::shared_ptr tv(new data::VM23F()); + tv->_0 = fromJSON(W(), obj["arg0"]); + return tv; + } + else if (tag == "VM24F") { + tagType = ::Value::tag::VM24F; + std::shared_ptr tv(new data::VM24F()); + tv->_0 = fromJSON(W(), obj["arg0"]); + return tv; + } + else if (tag == "VM32F") { + tagType = ::Value::tag::VM32F; + std::shared_ptr tv(new data::VM32F()); + tv->_0 = fromJSON(W(), obj["arg0"]); + return tv; + } + else if (tag == "VM33F") { + tagType = ::Value::tag::VM33F; + std::shared_ptr tv(new data::VM33F()); + tv->_0 = fromJSON(W(), obj["arg0"]); + return tv; + } + else if (tag == "VM34F") { + tagType = ::Value::tag::VM34F; + std::shared_ptr tv(new data::VM34F()); + tv->_0 = fromJSON(W(), obj["arg0"]); + return tv; + } + else if (tag == "VM42F") { + tagType = ::Value::tag::VM42F; + std::shared_ptr tv(new data::VM42F()); + tv->_0 = fromJSON(W(), obj["arg0"]); + return tv; + } + else if (tag == "VM43F") { + tagType = ::Value::tag::VM43F; + std::shared_ptr tv(new data::VM43F()); + tv->_0 = fromJSON(W(), obj["arg0"]); + return tv; + } + else if (tag == "VM44F") { + tagType = ::Value::tag::VM44F; + std::shared_ptr tv(new data::VM44F()); + tv->_0 = fromJSON(W(), obj["arg0"]); + return tv; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::Value> o(new ::Value()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::InputType::tag::Bool: + obj["tag"] = "Bool"; + break; + case ::InputType::tag::V2B: + obj["tag"] = "V2B"; + break; + case ::InputType::tag::V3B: + obj["tag"] = "V3B"; + break; + case ::InputType::tag::V4B: + obj["tag"] = "V4B"; + break; + case ::InputType::tag::Word: + obj["tag"] = "Word"; + break; + case ::InputType::tag::V2U: + obj["tag"] = "V2U"; + break; + case ::InputType::tag::V3U: + obj["tag"] = "V3U"; + break; + case ::InputType::tag::V4U: + obj["tag"] = "V4U"; + break; + case ::InputType::tag::Int: + obj["tag"] = "Int"; + break; + case ::InputType::tag::V2I: + obj["tag"] = "V2I"; + break; + case ::InputType::tag::V3I: + obj["tag"] = "V3I"; + break; + case ::InputType::tag::V4I: + obj["tag"] = "V4I"; + break; + case ::InputType::tag::Float: + obj["tag"] = "Float"; + break; + case ::InputType::tag::V2F: + obj["tag"] = "V2F"; + break; + case ::InputType::tag::V3F: + obj["tag"] = "V3F"; + break; + case ::InputType::tag::V4F: + obj["tag"] = "V4F"; + break; + case ::InputType::tag::M22F: + obj["tag"] = "M22F"; + break; + case ::InputType::tag::M23F: + obj["tag"] = "M23F"; + break; + case ::InputType::tag::M24F: + obj["tag"] = "M24F"; + break; + case ::InputType::tag::M32F: + obj["tag"] = "M32F"; + break; + case ::InputType::tag::M33F: + obj["tag"] = "M33F"; + break; + case ::InputType::tag::M34F: + obj["tag"] = "M34F"; + break; + case ::InputType::tag::M42F: + obj["tag"] = "M42F"; + break; + case ::InputType::tag::M43F: + obj["tag"] = "M43F"; + break; + case ::InputType::tag::M44F: + obj["tag"] = "M44F"; + break; + case ::InputType::tag::STexture1D: + obj["tag"] = "STexture1D"; + break; + case ::InputType::tag::STexture2D: + obj["tag"] = "STexture2D"; + break; + case ::InputType::tag::STextureCube: + obj["tag"] = "STextureCube"; + break; + case ::InputType::tag::STexture1DArray: + obj["tag"] = "STexture1DArray"; + break; + case ::InputType::tag::STexture2DArray: + obj["tag"] = "STexture2DArray"; + break; + case ::InputType::tag::STexture2DRect: + obj["tag"] = "STexture2DRect"; + break; + case ::InputType::tag::FTexture1D: + obj["tag"] = "FTexture1D"; + break; + case ::InputType::tag::FTexture2D: + obj["tag"] = "FTexture2D"; + break; + case ::InputType::tag::FTexture3D: + obj["tag"] = "FTexture3D"; + break; + case ::InputType::tag::FTextureCube: + obj["tag"] = "FTextureCube"; + break; + case ::InputType::tag::FTexture1DArray: + obj["tag"] = "FTexture1DArray"; + break; + case ::InputType::tag::FTexture2DArray: + obj["tag"] = "FTexture2DArray"; + break; + case ::InputType::tag::FTexture2DMS: + obj["tag"] = "FTexture2DMS"; + break; + case ::InputType::tag::FTexture2DMSArray: + obj["tag"] = "FTexture2DMSArray"; + break; + case ::InputType::tag::FTextureBuffer: + obj["tag"] = "FTextureBuffer"; + break; + case ::InputType::tag::FTexture2DRect: + obj["tag"] = "FTexture2DRect"; + break; + case ::InputType::tag::ITexture1D: + obj["tag"] = "ITexture1D"; + break; + case ::InputType::tag::ITexture2D: + obj["tag"] = "ITexture2D"; + break; + case ::InputType::tag::ITexture3D: + obj["tag"] = "ITexture3D"; + break; + case ::InputType::tag::ITextureCube: + obj["tag"] = "ITextureCube"; + break; + case ::InputType::tag::ITexture1DArray: + obj["tag"] = "ITexture1DArray"; + break; + case ::InputType::tag::ITexture2DArray: + obj["tag"] = "ITexture2DArray"; + break; + case ::InputType::tag::ITexture2DMS: + obj["tag"] = "ITexture2DMS"; + break; + case ::InputType::tag::ITexture2DMSArray: + obj["tag"] = "ITexture2DMSArray"; + break; + case ::InputType::tag::ITextureBuffer: + obj["tag"] = "ITextureBuffer"; + break; + case ::InputType::tag::ITexture2DRect: + obj["tag"] = "ITexture2DRect"; + break; + case ::InputType::tag::UTexture1D: + obj["tag"] = "UTexture1D"; + break; + case ::InputType::tag::UTexture2D: + obj["tag"] = "UTexture2D"; + break; + case ::InputType::tag::UTexture3D: + obj["tag"] = "UTexture3D"; + break; + case ::InputType::tag::UTextureCube: + obj["tag"] = "UTextureCube"; + break; + case ::InputType::tag::UTexture1DArray: + obj["tag"] = "UTexture1DArray"; + break; + case ::InputType::tag::UTexture2DArray: + obj["tag"] = "UTexture2DArray"; + break; + case ::InputType::tag::UTexture2DMS: + obj["tag"] = "UTexture2DMS"; + break; + case ::InputType::tag::UTexture2DMSArray: + obj["tag"] = "UTexture2DMSArray"; + break; + case ::InputType::tag::UTextureBuffer: + obj["tag"] = "UTextureBuffer"; + break; + case ::InputType::tag::UTexture2DRect: + obj["tag"] = "UTexture2DRect"; + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::InputType::tag tagType; + std::string tag = obj["tag"]; + if (tag == "Bool") { + tagType = ::InputType::tag::Bool; + } + else if (tag == "V2B") { + tagType = ::InputType::tag::V2B; + } + else if (tag == "V3B") { + tagType = ::InputType::tag::V3B; + } + else if (tag == "V4B") { + tagType = ::InputType::tag::V4B; + } + else if (tag == "Word") { + tagType = ::InputType::tag::Word; + } + else if (tag == "V2U") { + tagType = ::InputType::tag::V2U; + } + else if (tag == "V3U") { + tagType = ::InputType::tag::V3U; + } + else if (tag == "V4U") { + tagType = ::InputType::tag::V4U; + } + else if (tag == "Int") { + tagType = ::InputType::tag::Int; + } + else if (tag == "V2I") { + tagType = ::InputType::tag::V2I; + } + else if (tag == "V3I") { + tagType = ::InputType::tag::V3I; + } + else if (tag == "V4I") { + tagType = ::InputType::tag::V4I; + } + else if (tag == "Float") { + tagType = ::InputType::tag::Float; + } + else if (tag == "V2F") { + tagType = ::InputType::tag::V2F; + } + else if (tag == "V3F") { + tagType = ::InputType::tag::V3F; + } + else if (tag == "V4F") { + tagType = ::InputType::tag::V4F; + } + else if (tag == "M22F") { + tagType = ::InputType::tag::M22F; + } + else if (tag == "M23F") { + tagType = ::InputType::tag::M23F; + } + else if (tag == "M24F") { + tagType = ::InputType::tag::M24F; + } + else if (tag == "M32F") { + tagType = ::InputType::tag::M32F; + } + else if (tag == "M33F") { + tagType = ::InputType::tag::M33F; + } + else if (tag == "M34F") { + tagType = ::InputType::tag::M34F; + } + else if (tag == "M42F") { + tagType = ::InputType::tag::M42F; + } + else if (tag == "M43F") { + tagType = ::InputType::tag::M43F; + } + else if (tag == "M44F") { + tagType = ::InputType::tag::M44F; + } + else if (tag == "STexture1D") { + tagType = ::InputType::tag::STexture1D; + } + else if (tag == "STexture2D") { + tagType = ::InputType::tag::STexture2D; + } + else if (tag == "STextureCube") { + tagType = ::InputType::tag::STextureCube; + } + else if (tag == "STexture1DArray") { + tagType = ::InputType::tag::STexture1DArray; + } + else if (tag == "STexture2DArray") { + tagType = ::InputType::tag::STexture2DArray; + } + else if (tag == "STexture2DRect") { + tagType = ::InputType::tag::STexture2DRect; + } + else if (tag == "FTexture1D") { + tagType = ::InputType::tag::FTexture1D; + } + else if (tag == "FTexture2D") { + tagType = ::InputType::tag::FTexture2D; + } + else if (tag == "FTexture3D") { + tagType = ::InputType::tag::FTexture3D; + } + else if (tag == "FTextureCube") { + tagType = ::InputType::tag::FTextureCube; + } + else if (tag == "FTexture1DArray") { + tagType = ::InputType::tag::FTexture1DArray; + } + else if (tag == "FTexture2DArray") { + tagType = ::InputType::tag::FTexture2DArray; + } + else if (tag == "FTexture2DMS") { + tagType = ::InputType::tag::FTexture2DMS; + } + else if (tag == "FTexture2DMSArray") { + tagType = ::InputType::tag::FTexture2DMSArray; + } + else if (tag == "FTextureBuffer") { + tagType = ::InputType::tag::FTextureBuffer; + } + else if (tag == "FTexture2DRect") { + tagType = ::InputType::tag::FTexture2DRect; + } + else if (tag == "ITexture1D") { + tagType = ::InputType::tag::ITexture1D; + } + else if (tag == "ITexture2D") { + tagType = ::InputType::tag::ITexture2D; + } + else if (tag == "ITexture3D") { + tagType = ::InputType::tag::ITexture3D; + } + else if (tag == "ITextureCube") { + tagType = ::InputType::tag::ITextureCube; + } + else if (tag == "ITexture1DArray") { + tagType = ::InputType::tag::ITexture1DArray; + } + else if (tag == "ITexture2DArray") { + tagType = ::InputType::tag::ITexture2DArray; + } + else if (tag == "ITexture2DMS") { + tagType = ::InputType::tag::ITexture2DMS; + } + else if (tag == "ITexture2DMSArray") { + tagType = ::InputType::tag::ITexture2DMSArray; + } + else if (tag == "ITextureBuffer") { + tagType = ::InputType::tag::ITextureBuffer; + } + else if (tag == "ITexture2DRect") { + tagType = ::InputType::tag::ITexture2DRect; + } + else if (tag == "UTexture1D") { + tagType = ::InputType::tag::UTexture1D; + } + else if (tag == "UTexture2D") { + tagType = ::InputType::tag::UTexture2D; + } + else if (tag == "UTexture3D") { + tagType = ::InputType::tag::UTexture3D; + } + else if (tag == "UTextureCube") { + tagType = ::InputType::tag::UTextureCube; + } + else if (tag == "UTexture1DArray") { + tagType = ::InputType::tag::UTexture1DArray; + } + else if (tag == "UTexture2DArray") { + tagType = ::InputType::tag::UTexture2DArray; + } + else if (tag == "UTexture2DMS") { + tagType = ::InputType::tag::UTexture2DMS; + } + else if (tag == "UTexture2DMSArray") { + tagType = ::InputType::tag::UTexture2DMSArray; + } + else if (tag == "UTextureBuffer") { + tagType = ::InputType::tag::UTextureBuffer; + } + else if (tag == "UTexture2DRect") { + tagType = ::InputType::tag::UTexture2DRect; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::InputType> o(new ::InputType()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::PointSpriteCoordOrigin::tag::LowerLeft: + obj["tag"] = "LowerLeft"; + break; + case ::PointSpriteCoordOrigin::tag::UpperLeft: + obj["tag"] = "UpperLeft"; + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::PointSpriteCoordOrigin::tag tagType; + std::string tag = obj["tag"]; + if (tag == "LowerLeft") { + tagType = ::PointSpriteCoordOrigin::tag::LowerLeft; + } + else if (tag == "UpperLeft") { + tagType = ::PointSpriteCoordOrigin::tag::UpperLeft; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::PointSpriteCoordOrigin> o(new ::PointSpriteCoordOrigin()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::PointSize::tag::PointSize: + obj["tag"] = "PointSize"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::PointSize::tag::ProgramPointSize: + obj["tag"] = "ProgramPointSize"; + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::PointSize::tag tagType; + std::string tag = obj["tag"]; + if (tag == "PointSize") { + tagType = ::PointSize::tag::PointSize; + std::shared_ptr tv(new data::PointSize()); + tv->_0 = fromJSON(W(), obj["arg0"]); + return tv; + } + else if (tag == "ProgramPointSize") { + tagType = ::PointSize::tag::ProgramPointSize; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::PointSize> o(new ::PointSize()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::PolygonOffset::tag::NoOffset: + obj["tag"] = "NoOffset"; + break; + case ::PolygonOffset::tag::Offset: + obj["tag"] = "Offset"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + obj["arg1"] = toJSON(tv->_1); + } + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::PolygonOffset::tag tagType; + std::string tag = obj["tag"]; + if (tag == "NoOffset") { + tagType = ::PolygonOffset::tag::NoOffset; + } + else if (tag == "Offset") { + tagType = ::PolygonOffset::tag::Offset; + std::shared_ptr tv(new data::Offset()); + tv->_0 = fromJSON(W(), obj["arg0"]); + tv->_1 = fromJSON(W(), obj["arg1"]); + return tv; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::PolygonOffset> o(new ::PolygonOffset()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::FrontFace::tag::CCW: + obj["tag"] = "CCW"; + break; + case ::FrontFace::tag::CW: + obj["tag"] = "CW"; + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::FrontFace::tag tagType; + std::string tag = obj["tag"]; + if (tag == "CCW") { + tagType = ::FrontFace::tag::CCW; + } + else if (tag == "CW") { + tagType = ::FrontFace::tag::CW; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::FrontFace> o(new ::FrontFace()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::PolygonMode::tag::PolygonPoint: + obj["tag"] = "PolygonPoint"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::PolygonMode::tag::PolygonLine: + obj["tag"] = "PolygonLine"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::PolygonMode::tag::PolygonFill: + obj["tag"] = "PolygonFill"; + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::PolygonMode::tag tagType; + std::string tag = obj["tag"]; + if (tag == "PolygonPoint") { + tagType = ::PolygonMode::tag::PolygonPoint; + std::shared_ptr tv(new data::PolygonPoint()); + tv->_0 = fromJSON(W>(), obj["arg0"]); + return tv; + } + else if (tag == "PolygonLine") { + tagType = ::PolygonMode::tag::PolygonLine; + std::shared_ptr tv(new data::PolygonLine()); + tv->_0 = fromJSON(W(), obj["arg0"]); + return tv; + } + else if (tag == "PolygonFill") { + tagType = ::PolygonMode::tag::PolygonFill; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::PolygonMode> o(new ::PolygonMode()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::ProvokingVertex::tag::FirstVertex: + obj["tag"] = "FirstVertex"; + break; + case ::ProvokingVertex::tag::LastVertex: + obj["tag"] = "LastVertex"; + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::ProvokingVertex::tag tagType; + std::string tag = obj["tag"]; + if (tag == "FirstVertex") { + tagType = ::ProvokingVertex::tag::FirstVertex; + } + else if (tag == "LastVertex") { + tagType = ::ProvokingVertex::tag::LastVertex; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::ProvokingVertex> o(new ::ProvokingVertex()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::CullMode::tag::CullNone: + obj["tag"] = "CullNone"; + break; + case ::CullMode::tag::CullFront: + obj["tag"] = "CullFront"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::CullMode::tag::CullBack: + obj["tag"] = "CullBack"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::CullMode::tag tagType; + std::string tag = obj["tag"]; + if (tag == "CullNone") { + tagType = ::CullMode::tag::CullNone; + } + else if (tag == "CullFront") { + tagType = ::CullMode::tag::CullFront; + std::shared_ptr tv(new data::CullFront()); + tv->_0 = fromJSON(W>(), obj["arg0"]); + return tv; + } + else if (tag == "CullBack") { + tagType = ::CullMode::tag::CullBack; + std::shared_ptr tv(new data::CullBack()); + tv->_0 = fromJSON(W>(), obj["arg0"]); + return tv; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::CullMode> o(new ::CullMode()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::ComparisonFunction::tag::Never: + obj["tag"] = "Never"; + break; + case ::ComparisonFunction::tag::Less: + obj["tag"] = "Less"; + break; + case ::ComparisonFunction::tag::Equal: + obj["tag"] = "Equal"; + break; + case ::ComparisonFunction::tag::Lequal: + obj["tag"] = "Lequal"; + break; + case ::ComparisonFunction::tag::Greater: + obj["tag"] = "Greater"; + break; + case ::ComparisonFunction::tag::Notequal: + obj["tag"] = "Notequal"; + break; + case ::ComparisonFunction::tag::Gequal: + obj["tag"] = "Gequal"; + break; + case ::ComparisonFunction::tag::Always: + obj["tag"] = "Always"; + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::ComparisonFunction::tag tagType; + std::string tag = obj["tag"]; + if (tag == "Never") { + tagType = ::ComparisonFunction::tag::Never; + } + else if (tag == "Less") { + tagType = ::ComparisonFunction::tag::Less; + } + else if (tag == "Equal") { + tagType = ::ComparisonFunction::tag::Equal; + } + else if (tag == "Lequal") { + tagType = ::ComparisonFunction::tag::Lequal; + } + else if (tag == "Greater") { + tagType = ::ComparisonFunction::tag::Greater; + } + else if (tag == "Notequal") { + tagType = ::ComparisonFunction::tag::Notequal; + } + else if (tag == "Gequal") { + tagType = ::ComparisonFunction::tag::Gequal; + } + else if (tag == "Always") { + tagType = ::ComparisonFunction::tag::Always; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::ComparisonFunction> o(new ::ComparisonFunction()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::StencilOperation::tag::OpZero: + obj["tag"] = "OpZero"; + break; + case ::StencilOperation::tag::OpKeep: + obj["tag"] = "OpKeep"; + break; + case ::StencilOperation::tag::OpReplace: + obj["tag"] = "OpReplace"; + break; + case ::StencilOperation::tag::OpIncr: + obj["tag"] = "OpIncr"; + break; + case ::StencilOperation::tag::OpIncrWrap: + obj["tag"] = "OpIncrWrap"; + break; + case ::StencilOperation::tag::OpDecr: + obj["tag"] = "OpDecr"; + break; + case ::StencilOperation::tag::OpDecrWrap: + obj["tag"] = "OpDecrWrap"; + break; + case ::StencilOperation::tag::OpInvert: + obj["tag"] = "OpInvert"; + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::StencilOperation::tag tagType; + std::string tag = obj["tag"]; + if (tag == "OpZero") { + tagType = ::StencilOperation::tag::OpZero; + } + else if (tag == "OpKeep") { + tagType = ::StencilOperation::tag::OpKeep; + } + else if (tag == "OpReplace") { + tagType = ::StencilOperation::tag::OpReplace; + } + else if (tag == "OpIncr") { + tagType = ::StencilOperation::tag::OpIncr; + } + else if (tag == "OpIncrWrap") { + tagType = ::StencilOperation::tag::OpIncrWrap; + } + else if (tag == "OpDecr") { + tagType = ::StencilOperation::tag::OpDecr; + } + else if (tag == "OpDecrWrap") { + tagType = ::StencilOperation::tag::OpDecrWrap; + } + else if (tag == "OpInvert") { + tagType = ::StencilOperation::tag::OpInvert; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::StencilOperation> o(new ::StencilOperation()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::BlendEquation::tag::FuncAdd: + obj["tag"] = "FuncAdd"; + break; + case ::BlendEquation::tag::FuncSubtract: + obj["tag"] = "FuncSubtract"; + break; + case ::BlendEquation::tag::FuncReverseSubtract: + obj["tag"] = "FuncReverseSubtract"; + break; + case ::BlendEquation::tag::Min: + obj["tag"] = "Min"; + break; + case ::BlendEquation::tag::Max: + obj["tag"] = "Max"; + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::BlendEquation::tag tagType; + std::string tag = obj["tag"]; + if (tag == "FuncAdd") { + tagType = ::BlendEquation::tag::FuncAdd; + } + else if (tag == "FuncSubtract") { + tagType = ::BlendEquation::tag::FuncSubtract; + } + else if (tag == "FuncReverseSubtract") { + tagType = ::BlendEquation::tag::FuncReverseSubtract; + } + else if (tag == "Min") { + tagType = ::BlendEquation::tag::Min; + } + else if (tag == "Max") { + tagType = ::BlendEquation::tag::Max; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::BlendEquation> o(new ::BlendEquation()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::BlendingFactor::tag::Zero: + obj["tag"] = "Zero"; + break; + case ::BlendingFactor::tag::One: + obj["tag"] = "One"; + break; + case ::BlendingFactor::tag::SrcColor: + obj["tag"] = "SrcColor"; + break; + case ::BlendingFactor::tag::OneMinusSrcColor: + obj["tag"] = "OneMinusSrcColor"; + break; + case ::BlendingFactor::tag::DstColor: + obj["tag"] = "DstColor"; + break; + case ::BlendingFactor::tag::OneMinusDstColor: + obj["tag"] = "OneMinusDstColor"; + break; + case ::BlendingFactor::tag::SrcAlpha: + obj["tag"] = "SrcAlpha"; + break; + case ::BlendingFactor::tag::OneMinusSrcAlpha: + obj["tag"] = "OneMinusSrcAlpha"; + break; + case ::BlendingFactor::tag::DstAlpha: + obj["tag"] = "DstAlpha"; + break; + case ::BlendingFactor::tag::OneMinusDstAlpha: + obj["tag"] = "OneMinusDstAlpha"; + break; + case ::BlendingFactor::tag::ConstantColor: + obj["tag"] = "ConstantColor"; + break; + case ::BlendingFactor::tag::OneMinusConstantColor: + obj["tag"] = "OneMinusConstantColor"; + break; + case ::BlendingFactor::tag::ConstantAlpha: + obj["tag"] = "ConstantAlpha"; + break; + case ::BlendingFactor::tag::OneMinusConstantAlpha: + obj["tag"] = "OneMinusConstantAlpha"; + break; + case ::BlendingFactor::tag::SrcAlphaSaturate: + obj["tag"] = "SrcAlphaSaturate"; + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::BlendingFactor::tag tagType; + std::string tag = obj["tag"]; + if (tag == "Zero") { + tagType = ::BlendingFactor::tag::Zero; + } + else if (tag == "One") { + tagType = ::BlendingFactor::tag::One; + } + else if (tag == "SrcColor") { + tagType = ::BlendingFactor::tag::SrcColor; + } + else if (tag == "OneMinusSrcColor") { + tagType = ::BlendingFactor::tag::OneMinusSrcColor; + } + else if (tag == "DstColor") { + tagType = ::BlendingFactor::tag::DstColor; + } + else if (tag == "OneMinusDstColor") { + tagType = ::BlendingFactor::tag::OneMinusDstColor; + } + else if (tag == "SrcAlpha") { + tagType = ::BlendingFactor::tag::SrcAlpha; + } + else if (tag == "OneMinusSrcAlpha") { + tagType = ::BlendingFactor::tag::OneMinusSrcAlpha; + } + else if (tag == "DstAlpha") { + tagType = ::BlendingFactor::tag::DstAlpha; + } + else if (tag == "OneMinusDstAlpha") { + tagType = ::BlendingFactor::tag::OneMinusDstAlpha; + } + else if (tag == "ConstantColor") { + tagType = ::BlendingFactor::tag::ConstantColor; + } + else if (tag == "OneMinusConstantColor") { + tagType = ::BlendingFactor::tag::OneMinusConstantColor; + } + else if (tag == "ConstantAlpha") { + tagType = ::BlendingFactor::tag::ConstantAlpha; + } + else if (tag == "OneMinusConstantAlpha") { + tagType = ::BlendingFactor::tag::OneMinusConstantAlpha; + } + else if (tag == "SrcAlphaSaturate") { + tagType = ::BlendingFactor::tag::SrcAlphaSaturate; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::BlendingFactor> o(new ::BlendingFactor()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::LogicOperation::tag::Clear: + obj["tag"] = "Clear"; + break; + case ::LogicOperation::tag::And: + obj["tag"] = "And"; + break; + case ::LogicOperation::tag::AndReverse: + obj["tag"] = "AndReverse"; + break; + case ::LogicOperation::tag::Copy: + obj["tag"] = "Copy"; + break; + case ::LogicOperation::tag::AndInverted: + obj["tag"] = "AndInverted"; + break; + case ::LogicOperation::tag::Noop: + obj["tag"] = "Noop"; + break; + case ::LogicOperation::tag::Xor: + obj["tag"] = "Xor"; + break; + case ::LogicOperation::tag::Or: + obj["tag"] = "Or"; + break; + case ::LogicOperation::tag::Nor: + obj["tag"] = "Nor"; + break; + case ::LogicOperation::tag::Equiv: + obj["tag"] = "Equiv"; + break; + case ::LogicOperation::tag::Invert: + obj["tag"] = "Invert"; + break; + case ::LogicOperation::tag::OrReverse: + obj["tag"] = "OrReverse"; + break; + case ::LogicOperation::tag::CopyInverted: + obj["tag"] = "CopyInverted"; + break; + case ::LogicOperation::tag::OrInverted: + obj["tag"] = "OrInverted"; + break; + case ::LogicOperation::tag::Nand: + obj["tag"] = "Nand"; + break; + case ::LogicOperation::tag::Set: + obj["tag"] = "Set"; + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::LogicOperation::tag tagType; + std::string tag = obj["tag"]; + if (tag == "Clear") { + tagType = ::LogicOperation::tag::Clear; + } + else if (tag == "And") { + tagType = ::LogicOperation::tag::And; + } + else if (tag == "AndReverse") { + tagType = ::LogicOperation::tag::AndReverse; + } + else if (tag == "Copy") { + tagType = ::LogicOperation::tag::Copy; + } + else if (tag == "AndInverted") { + tagType = ::LogicOperation::tag::AndInverted; + } + else if (tag == "Noop") { + tagType = ::LogicOperation::tag::Noop; + } + else if (tag == "Xor") { + tagType = ::LogicOperation::tag::Xor; + } + else if (tag == "Or") { + tagType = ::LogicOperation::tag::Or; + } + else if (tag == "Nor") { + tagType = ::LogicOperation::tag::Nor; + } + else if (tag == "Equiv") { + tagType = ::LogicOperation::tag::Equiv; + } + else if (tag == "Invert") { + tagType = ::LogicOperation::tag::Invert; + } + else if (tag == "OrReverse") { + tagType = ::LogicOperation::tag::OrReverse; + } + else if (tag == "CopyInverted") { + tagType = ::LogicOperation::tag::CopyInverted; + } + else if (tag == "OrInverted") { + tagType = ::LogicOperation::tag::OrInverted; + } + else if (tag == "Nand") { + tagType = ::LogicOperation::tag::Nand; + } + else if (tag == "Set") { + tagType = ::LogicOperation::tag::Set; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::LogicOperation> o(new ::LogicOperation()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::StencilOps::tag::StencilOps: + obj["tag"] = "StencilOps"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["frontStencilOp"] = toJSON(tv->frontStencilOp); + obj["backStencilOp"] = toJSON(tv->backStencilOp); + } + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::StencilOps::tag tagType; + std::string tag = obj["tag"]; + if (tag == "StencilOps") { + tagType = ::StencilOps::tag::StencilOps; + std::shared_ptr tv(new data::StencilOps()); + tv->frontStencilOp = fromJSON(W>(), obj["frontStencilOp"]); + tv->backStencilOp = fromJSON(W>(), obj["backStencilOp"]); + return tv; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::StencilOps> o(new ::StencilOps()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::StencilTest::tag::StencilTest: + obj["tag"] = "StencilTest"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["stencilComparision"] = toJSON(tv->stencilComparision); + obj["stencilReference"] = toJSON(tv->stencilReference); + obj["stencilMask"] = toJSON(tv->stencilMask); + } + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::StencilTest::tag tagType; + std::string tag = obj["tag"]; + if (tag == "StencilTest") { + tagType = ::StencilTest::tag::StencilTest; + std::shared_ptr tv(new data::StencilTest()); + tv->stencilComparision = fromJSON(W>(), obj["stencilComparision"]); + tv->stencilReference = fromJSON(W(), obj["stencilReference"]); + tv->stencilMask = fromJSON(W(), obj["stencilMask"]); + return tv; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::StencilTest> o(new ::StencilTest()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::StencilTests::tag::StencilTests: + obj["tag"] = "StencilTests"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + obj["arg1"] = toJSON(tv->_1); + } + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::StencilTests::tag tagType; + std::string tag = obj["tag"]; + if (tag == "StencilTests") { + tagType = ::StencilTests::tag::StencilTests; + std::shared_ptr tv(new data::StencilTests()); + tv->_0 = fromJSON(W>(), obj["arg0"]); + tv->_1 = fromJSON(W>(), obj["arg1"]); + return tv; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::StencilTests> o(new ::StencilTests()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::FetchPrimitive::tag::Points: + obj["tag"] = "Points"; + break; + case ::FetchPrimitive::tag::Lines: + obj["tag"] = "Lines"; + break; + case ::FetchPrimitive::tag::Triangles: + obj["tag"] = "Triangles"; + break; + case ::FetchPrimitive::tag::LinesAdjacency: + obj["tag"] = "LinesAdjacency"; + break; + case ::FetchPrimitive::tag::TrianglesAdjacency: + obj["tag"] = "TrianglesAdjacency"; + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::FetchPrimitive::tag tagType; + std::string tag = obj["tag"]; + if (tag == "Points") { + tagType = ::FetchPrimitive::tag::Points; + } + else if (tag == "Lines") { + tagType = ::FetchPrimitive::tag::Lines; + } + else if (tag == "Triangles") { + tagType = ::FetchPrimitive::tag::Triangles; + } + else if (tag == "LinesAdjacency") { + tagType = ::FetchPrimitive::tag::LinesAdjacency; + } + else if (tag == "TrianglesAdjacency") { + tagType = ::FetchPrimitive::tag::TrianglesAdjacency; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::FetchPrimitive> o(new ::FetchPrimitive()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::OutputPrimitive::tag::TrianglesOutput: + obj["tag"] = "TrianglesOutput"; + break; + case ::OutputPrimitive::tag::LinesOutput: + obj["tag"] = "LinesOutput"; + break; + case ::OutputPrimitive::tag::PointsOutput: + obj["tag"] = "PointsOutput"; + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::OutputPrimitive::tag tagType; + std::string tag = obj["tag"]; + if (tag == "TrianglesOutput") { + tagType = ::OutputPrimitive::tag::TrianglesOutput; + } + else if (tag == "LinesOutput") { + tagType = ::OutputPrimitive::tag::LinesOutput; + } + else if (tag == "PointsOutput") { + tagType = ::OutputPrimitive::tag::PointsOutput; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::OutputPrimitive> o(new ::OutputPrimitive()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::ColorArity::tag::Red: + obj["tag"] = "Red"; + break; + case ::ColorArity::tag::RG: + obj["tag"] = "RG"; + break; + case ::ColorArity::tag::RGB: + obj["tag"] = "RGB"; + break; + case ::ColorArity::tag::RGBA: + obj["tag"] = "RGBA"; + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::ColorArity::tag tagType; + std::string tag = obj["tag"]; + if (tag == "Red") { + tagType = ::ColorArity::tag::Red; + } + else if (tag == "RG") { + tagType = ::ColorArity::tag::RG; + } + else if (tag == "RGB") { + tagType = ::ColorArity::tag::RGB; + } + else if (tag == "RGBA") { + tagType = ::ColorArity::tag::RGBA; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::ColorArity> o(new ::ColorArity()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::Blending::tag::NoBlending: + obj["tag"] = "NoBlending"; + break; + case ::Blending::tag::BlendLogicOp: + obj["tag"] = "BlendLogicOp"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::Blending::tag::Blend: + obj["tag"] = "Blend"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["colorEqSrc"] = toJSON(tv->colorEqSrc); + obj["alphaEqSrc"] = toJSON(tv->alphaEqSrc); + obj["colorFSrc"] = toJSON(tv->colorFSrc); + obj["colorFDst"] = toJSON(tv->colorFDst); + obj["alphaFSrc"] = toJSON(tv->alphaFSrc); + obj["alphaFDst"] = toJSON(tv->alphaFDst); + obj["color"] = toJSON(tv->color); + } + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::Blending::tag tagType; + std::string tag = obj["tag"]; + if (tag == "NoBlending") { + tagType = ::Blending::tag::NoBlending; + } + else if (tag == "BlendLogicOp") { + tagType = ::Blending::tag::BlendLogicOp; + std::shared_ptr tv(new data::BlendLogicOp()); + tv->_0 = fromJSON(W>(), obj["arg0"]); + return tv; + } + else if (tag == "Blend") { + tagType = ::Blending::tag::Blend; + std::shared_ptr tv(new data::Blend()); + tv->colorEqSrc = fromJSON(W>(), obj["colorEqSrc"]); + tv->alphaEqSrc = fromJSON(W>(), obj["alphaEqSrc"]); + tv->colorFSrc = fromJSON(W>(), obj["colorFSrc"]); + tv->colorFDst = fromJSON(W>(), obj["colorFDst"]); + tv->alphaFSrc = fromJSON(W>(), obj["alphaFSrc"]); + tv->alphaFDst = fromJSON(W>(), obj["alphaFDst"]); + tv->color = fromJSON(W(), obj["color"]); + return tv; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::Blending> o(new ::Blending()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::RasterContext::tag::PointCtx: + obj["tag"] = "PointCtx"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + obj["arg1"] = toJSON(tv->_1); + obj["arg2"] = toJSON(tv->_2); + } + break; + case ::RasterContext::tag::LineCtx: + obj["tag"] = "LineCtx"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + obj["arg1"] = toJSON(tv->_1); + } + break; + case ::RasterContext::tag::TriangleCtx: + obj["tag"] = "TriangleCtx"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + obj["arg1"] = toJSON(tv->_1); + obj["arg2"] = toJSON(tv->_2); + obj["arg3"] = toJSON(tv->_3); + } + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::RasterContext::tag tagType; + std::string tag = obj["tag"]; + if (tag == "PointCtx") { + tagType = ::RasterContext::tag::PointCtx; + std::shared_ptr tv(new data::PointCtx()); + tv->_0 = fromJSON(W>(), obj["arg0"]); + tv->_1 = fromJSON(W(), obj["arg1"]); + tv->_2 = fromJSON(W>(), obj["arg2"]); + return tv; + } + else if (tag == "LineCtx") { + tagType = ::RasterContext::tag::LineCtx; + std::shared_ptr tv(new data::LineCtx()); + tv->_0 = fromJSON(W(), obj["arg0"]); + tv->_1 = fromJSON(W>(), obj["arg1"]); + return tv; + } + else if (tag == "TriangleCtx") { + tagType = ::RasterContext::tag::TriangleCtx; + std::shared_ptr tv(new data::TriangleCtx()); + tv->_0 = fromJSON(W>(), obj["arg0"]); + tv->_1 = fromJSON(W>(), obj["arg1"]); + tv->_2 = fromJSON(W>(), obj["arg2"]); + tv->_3 = fromJSON(W>(), obj["arg3"]); + return tv; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::RasterContext> o(new ::RasterContext()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::FragmentOperation::tag::DepthOp: + obj["tag"] = "DepthOp"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + obj["arg1"] = toJSON(tv->_1); + } + break; + case ::FragmentOperation::tag::StencilOp: + obj["tag"] = "StencilOp"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + obj["arg1"] = toJSON(tv->_1); + obj["arg2"] = toJSON(tv->_2); + } + break; + case ::FragmentOperation::tag::ColorOp: + obj["tag"] = "ColorOp"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + obj["arg1"] = toJSON(tv->_1); + } + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::FragmentOperation::tag tagType; + std::string tag = obj["tag"]; + if (tag == "DepthOp") { + tagType = ::FragmentOperation::tag::DepthOp; + std::shared_ptr tv(new data::DepthOp()); + tv->_0 = fromJSON(W>(), obj["arg0"]); + tv->_1 = fromJSON(W(), obj["arg1"]); + return tv; + } + else if (tag == "StencilOp") { + tagType = ::FragmentOperation::tag::StencilOp; + std::shared_ptr tv(new data::StencilOp()); + tv->_0 = fromJSON(W>(), obj["arg0"]); + tv->_1 = fromJSON(W>(), obj["arg1"]); + tv->_2 = fromJSON(W>(), obj["arg2"]); + return tv; + } + else if (tag == "ColorOp") { + tagType = ::FragmentOperation::tag::ColorOp; + std::shared_ptr tv(new data::ColorOp()); + tv->_0 = fromJSON(W>(), obj["arg0"]); + tv->_1 = fromJSON(W>(), obj["arg1"]); + return tv; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::FragmentOperation> o(new ::FragmentOperation()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::AccumulationContext::tag::AccumulationContext: + obj["tag"] = "AccumulationContext"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["accViewportName"] = toJSON(tv->accViewportName); + obj["accOperations"] = toJSON(tv->accOperations); + } + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::AccumulationContext::tag tagType; + std::string tag = obj["tag"]; + if (tag == "AccumulationContext") { + tagType = ::AccumulationContext::tag::AccumulationContext; + std::shared_ptr tv(new data::AccumulationContext()); + tv->accViewportName = fromJSON(W>(), obj["accViewportName"]); + tv->accOperations = fromJSON(W>>(), obj["accOperations"]); + return tv; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::AccumulationContext> o(new ::AccumulationContext()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::TextureDataType::tag::FloatT: + obj["tag"] = "FloatT"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::TextureDataType::tag::IntT: + obj["tag"] = "IntT"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::TextureDataType::tag::WordT: + obj["tag"] = "WordT"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::TextureDataType::tag::ShadowT: + obj["tag"] = "ShadowT"; + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::TextureDataType::tag tagType; + std::string tag = obj["tag"]; + if (tag == "FloatT") { + tagType = ::TextureDataType::tag::FloatT; + std::shared_ptr tv(new data::FloatT()); + tv->_0 = fromJSON(W>(), obj["arg0"]); + return tv; + } + else if (tag == "IntT") { + tagType = ::TextureDataType::tag::IntT; + std::shared_ptr tv(new data::IntT()); + tv->_0 = fromJSON(W>(), obj["arg0"]); + return tv; + } + else if (tag == "WordT") { + tagType = ::TextureDataType::tag::WordT; + std::shared_ptr tv(new data::WordT()); + tv->_0 = fromJSON(W>(), obj["arg0"]); + return tv; + } + else if (tag == "ShadowT") { + tagType = ::TextureDataType::tag::ShadowT; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::TextureDataType> o(new ::TextureDataType()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::TextureType::tag::Texture1D: + obj["tag"] = "Texture1D"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + obj["arg1"] = toJSON(tv->_1); + } + break; + case ::TextureType::tag::Texture2D: + obj["tag"] = "Texture2D"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + obj["arg1"] = toJSON(tv->_1); + } + break; + case ::TextureType::tag::Texture3D: + obj["tag"] = "Texture3D"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::TextureType::tag::TextureCube: + obj["tag"] = "TextureCube"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::TextureType::tag::TextureRect: + obj["tag"] = "TextureRect"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::TextureType::tag::Texture2DMS: + obj["tag"] = "Texture2DMS"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + obj["arg1"] = toJSON(tv->_1); + obj["arg2"] = toJSON(tv->_2); + obj["arg3"] = toJSON(tv->_3); + } + break; + case ::TextureType::tag::TextureBuffer: + obj["tag"] = "TextureBuffer"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::TextureType::tag tagType; + std::string tag = obj["tag"]; + if (tag == "Texture1D") { + tagType = ::TextureType::tag::Texture1D; + std::shared_ptr tv(new data::Texture1D()); + tv->_0 = fromJSON(W>(), obj["arg0"]); + tv->_1 = fromJSON(W(), obj["arg1"]); + return tv; + } + else if (tag == "Texture2D") { + tagType = ::TextureType::tag::Texture2D; + std::shared_ptr tv(new data::Texture2D()); + tv->_0 = fromJSON(W>(), obj["arg0"]); + tv->_1 = fromJSON(W(), obj["arg1"]); + return tv; + } + else if (tag == "Texture3D") { + tagType = ::TextureType::tag::Texture3D; + std::shared_ptr tv(new data::Texture3D()); + tv->_0 = fromJSON(W>(), obj["arg0"]); + return tv; + } + else if (tag == "TextureCube") { + tagType = ::TextureType::tag::TextureCube; + std::shared_ptr tv(new data::TextureCube()); + tv->_0 = fromJSON(W>(), obj["arg0"]); + return tv; + } + else if (tag == "TextureRect") { + tagType = ::TextureType::tag::TextureRect; + std::shared_ptr tv(new data::TextureRect()); + tv->_0 = fromJSON(W>(), obj["arg0"]); + return tv; + } + else if (tag == "Texture2DMS") { + tagType = ::TextureType::tag::Texture2DMS; + std::shared_ptr tv(new data::Texture2DMS()); + tv->_0 = fromJSON(W>(), obj["arg0"]); + tv->_1 = fromJSON(W(), obj["arg1"]); + tv->_2 = fromJSON(W(), obj["arg2"]); + tv->_3 = fromJSON(W(), obj["arg3"]); + return tv; + } + else if (tag == "TextureBuffer") { + tagType = ::TextureType::tag::TextureBuffer; + std::shared_ptr tv(new data::TextureBuffer()); + tv->_0 = fromJSON(W>(), obj["arg0"]); + return tv; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::TextureType> o(new ::TextureType()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::MipMap::tag::Mip: + obj["tag"] = "Mip"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + obj["arg1"] = toJSON(tv->_1); + } + break; + case ::MipMap::tag::NoMip: + obj["tag"] = "NoMip"; + break; + case ::MipMap::tag::AutoMip: + obj["tag"] = "AutoMip"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + obj["arg1"] = toJSON(tv->_1); + } + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::MipMap::tag tagType; + std::string tag = obj["tag"]; + if (tag == "Mip") { + tagType = ::MipMap::tag::Mip; + std::shared_ptr tv(new data::Mip()); + tv->_0 = fromJSON(W(), obj["arg0"]); + tv->_1 = fromJSON(W(), obj["arg1"]); + return tv; + } + else if (tag == "NoMip") { + tagType = ::MipMap::tag::NoMip; + } + else if (tag == "AutoMip") { + tagType = ::MipMap::tag::AutoMip; + std::shared_ptr tv(new data::AutoMip()); + tv->_0 = fromJSON(W(), obj["arg0"]); + tv->_1 = fromJSON(W(), obj["arg1"]); + return tv; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::MipMap> o(new ::MipMap()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::Filter::tag::Nearest: + obj["tag"] = "Nearest"; + break; + case ::Filter::tag::Linear: + obj["tag"] = "Linear"; + break; + case ::Filter::tag::NearestMipmapNearest: + obj["tag"] = "NearestMipmapNearest"; + break; + case ::Filter::tag::NearestMipmapLinear: + obj["tag"] = "NearestMipmapLinear"; + break; + case ::Filter::tag::LinearMipmapNearest: + obj["tag"] = "LinearMipmapNearest"; + break; + case ::Filter::tag::LinearMipmapLinear: + obj["tag"] = "LinearMipmapLinear"; + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::Filter::tag tagType; + std::string tag = obj["tag"]; + if (tag == "Nearest") { + tagType = ::Filter::tag::Nearest; + } + else if (tag == "Linear") { + tagType = ::Filter::tag::Linear; + } + else if (tag == "NearestMipmapNearest") { + tagType = ::Filter::tag::NearestMipmapNearest; + } + else if (tag == "NearestMipmapLinear") { + tagType = ::Filter::tag::NearestMipmapLinear; + } + else if (tag == "LinearMipmapNearest") { + tagType = ::Filter::tag::LinearMipmapNearest; + } + else if (tag == "LinearMipmapLinear") { + tagType = ::Filter::tag::LinearMipmapLinear; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::Filter> o(new ::Filter()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::EdgeMode::tag::Repeat: + obj["tag"] = "Repeat"; + break; + case ::EdgeMode::tag::MirroredRepeat: + obj["tag"] = "MirroredRepeat"; + break; + case ::EdgeMode::tag::ClampToEdge: + obj["tag"] = "ClampToEdge"; + break; + case ::EdgeMode::tag::ClampToBorder: + obj["tag"] = "ClampToBorder"; + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::EdgeMode::tag tagType; + std::string tag = obj["tag"]; + if (tag == "Repeat") { + tagType = ::EdgeMode::tag::Repeat; + } + else if (tag == "MirroredRepeat") { + tagType = ::EdgeMode::tag::MirroredRepeat; + } + else if (tag == "ClampToEdge") { + tagType = ::EdgeMode::tag::ClampToEdge; + } + else if (tag == "ClampToBorder") { + tagType = ::EdgeMode::tag::ClampToBorder; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::EdgeMode> o(new ::EdgeMode()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::ImageSemantic::tag::Depth: + obj["tag"] = "Depth"; + break; + case ::ImageSemantic::tag::Stencil: + obj["tag"] = "Stencil"; + break; + case ::ImageSemantic::tag::Color: + obj["tag"] = "Color"; + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::ImageSemantic::tag tagType; + std::string tag = obj["tag"]; + if (tag == "Depth") { + tagType = ::ImageSemantic::tag::Depth; + } + else if (tag == "Stencil") { + tagType = ::ImageSemantic::tag::Stencil; + } + else if (tag == "Color") { + tagType = ::ImageSemantic::tag::Color; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::ImageSemantic> o(new ::ImageSemantic()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::ImageRef::tag::TextureImage: + obj["tag"] = "TextureImage"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + obj["arg1"] = toJSON(tv->_1); + obj["arg2"] = toJSON(tv->_2); + } + break; + case ::ImageRef::tag::Framebuffer: + obj["tag"] = "Framebuffer"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::ImageRef::tag tagType; + std::string tag = obj["tag"]; + if (tag == "TextureImage") { + tagType = ::ImageRef::tag::TextureImage; + std::shared_ptr tv(new data::TextureImage()); + tv->_0 = fromJSON(W<::TextureName>(), obj["arg0"]); + tv->_1 = fromJSON(W(), obj["arg1"]); + tv->_2 = fromJSON(W>(), obj["arg2"]); + return tv; + } + else if (tag == "Framebuffer") { + tagType = ::ImageRef::tag::Framebuffer; + std::shared_ptr tv(new data::Framebuffer()); + tv->_0 = fromJSON(W>(), obj["arg0"]); + return tv; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::ImageRef> o(new ::ImageRef()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::ClearImage::tag::ClearImage: + obj["tag"] = "ClearImage"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["imageSemantic"] = toJSON(tv->imageSemantic); + obj["clearValue"] = toJSON(tv->clearValue); + } + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::ClearImage::tag tagType; + std::string tag = obj["tag"]; + if (tag == "ClearImage") { + tagType = ::ClearImage::tag::ClearImage; + std::shared_ptr tv(new data::ClearImage()); + tv->imageSemantic = fromJSON(W>(), obj["imageSemantic"]); + tv->clearValue = fromJSON(W>(), obj["clearValue"]); + return tv; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::ClearImage> o(new ::ClearImage()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::Command::tag::SetRasterContext: + obj["tag"] = "SetRasterContext"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::Command::tag::SetAccumulationContext: + obj["tag"] = "SetAccumulationContext"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::Command::tag::SetRenderTarget: + obj["tag"] = "SetRenderTarget"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::Command::tag::SetProgram: + obj["tag"] = "SetProgram"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::Command::tag::SetSamplerUniform: + obj["tag"] = "SetSamplerUniform"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + obj["arg1"] = toJSON(tv->_1); + } + break; + case ::Command::tag::SetTexture: + obj["tag"] = "SetTexture"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + obj["arg1"] = toJSON(tv->_1); + } + break; + case ::Command::tag::SetSampler: + obj["tag"] = "SetSampler"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + obj["arg1"] = toJSON(tv->_1); + } + break; + case ::Command::tag::RenderSlot: + obj["tag"] = "RenderSlot"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::Command::tag::RenderStream: + obj["tag"] = "RenderStream"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::Command::tag::ClearRenderTarget: + obj["tag"] = "ClearRenderTarget"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::Command::tag::GenerateMipMap: + obj["tag"] = "GenerateMipMap"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::Command::tag::SaveImage: + obj["tag"] = "SaveImage"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + obj["arg1"] = toJSON(tv->_1); + } + break; + case ::Command::tag::LoadImage: + obj["tag"] = "LoadImage"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + obj["arg1"] = toJSON(tv->_1); + } + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::Command::tag tagType; + std::string tag = obj["tag"]; + if (tag == "SetRasterContext") { + tagType = ::Command::tag::SetRasterContext; + std::shared_ptr tv(new data::SetRasterContext()); + tv->_0 = fromJSON(W>(), obj["arg0"]); + return tv; + } + else if (tag == "SetAccumulationContext") { + tagType = ::Command::tag::SetAccumulationContext; + std::shared_ptr tv(new data::SetAccumulationContext()); + tv->_0 = fromJSON(W>(), obj["arg0"]); + return tv; + } + else if (tag == "SetRenderTarget") { + tagType = ::Command::tag::SetRenderTarget; + std::shared_ptr tv(new data::SetRenderTarget()); + tv->_0 = fromJSON(W<::RenderTargetName>(), obj["arg0"]); + return tv; + } + else if (tag == "SetProgram") { + tagType = ::Command::tag::SetProgram; + std::shared_ptr tv(new data::SetProgram()); + tv->_0 = fromJSON(W<::ProgramName>(), obj["arg0"]); + return tv; + } + else if (tag == "SetSamplerUniform") { + tagType = ::Command::tag::SetSamplerUniform; + std::shared_ptr tv(new data::SetSamplerUniform()); + tv->_0 = fromJSON(W<::UniformName>(), obj["arg0"]); + tv->_1 = fromJSON(W<::TextureUnit>(), obj["arg1"]); + return tv; + } + else if (tag == "SetTexture") { + tagType = ::Command::tag::SetTexture; + std::shared_ptr tv(new data::SetTexture()); + tv->_0 = fromJSON(W<::TextureUnit>(), obj["arg0"]); + tv->_1 = fromJSON(W<::TextureName>(), obj["arg1"]); + return tv; + } + else if (tag == "SetSampler") { + tagType = ::Command::tag::SetSampler; + std::shared_ptr tv(new data::SetSampler()); + tv->_0 = fromJSON(W<::TextureUnit>(), obj["arg0"]); + tv->_1 = fromJSON(W>(), obj["arg1"]); + return tv; + } + else if (tag == "RenderSlot") { + tagType = ::Command::tag::RenderSlot; + std::shared_ptr tv(new data::RenderSlot()); + tv->_0 = fromJSON(W<::SlotName>(), obj["arg0"]); + return tv; + } + else if (tag == "RenderStream") { + tagType = ::Command::tag::RenderStream; + std::shared_ptr tv(new data::RenderStream()); + tv->_0 = fromJSON(W<::StreamName>(), obj["arg0"]); + return tv; + } + else if (tag == "ClearRenderTarget") { + tagType = ::Command::tag::ClearRenderTarget; + std::shared_ptr tv(new data::ClearRenderTarget()); + tv->_0 = fromJSON(W>>(), obj["arg0"]); + return tv; + } + else if (tag == "GenerateMipMap") { + tagType = ::Command::tag::GenerateMipMap; + std::shared_ptr tv(new data::GenerateMipMap()); + tv->_0 = fromJSON(W<::TextureUnit>(), obj["arg0"]); + return tv; + } + else if (tag == "SaveImage") { + tagType = ::Command::tag::SaveImage; + std::shared_ptr tv(new data::SaveImage()); + tv->_0 = fromJSON(W<::FrameBufferComponent>(), obj["arg0"]); + tv->_1 = fromJSON(W>(), obj["arg1"]); + return tv; + } + else if (tag == "LoadImage") { + tagType = ::Command::tag::LoadImage; + std::shared_ptr tv(new data::LoadImage()); + tv->_0 = fromJSON(W>(), obj["arg0"]); + tv->_1 = fromJSON(W<::FrameBufferComponent>(), obj["arg1"]); + return tv; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::Command> o(new ::Command()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::SamplerDescriptor::tag::SamplerDescriptor: + obj["tag"] = "SamplerDescriptor"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["samplerWrapS"] = toJSON(tv->samplerWrapS); + obj["samplerWrapT"] = toJSON(tv->samplerWrapT); + obj["samplerWrapR"] = toJSON(tv->samplerWrapR); + obj["samplerMinFilter"] = toJSON(tv->samplerMinFilter); + obj["samplerMagFilter"] = toJSON(tv->samplerMagFilter); + obj["samplerBorderColor"] = toJSON(tv->samplerBorderColor); + obj["samplerMinLod"] = toJSON(tv->samplerMinLod); + obj["samplerMaxLod"] = toJSON(tv->samplerMaxLod); + obj["samplerLodBias"] = toJSON(tv->samplerLodBias); + obj["samplerCompareFunc"] = toJSON(tv->samplerCompareFunc); + } + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::SamplerDescriptor::tag tagType; + std::string tag = obj["tag"]; + if (tag == "SamplerDescriptor") { + tagType = ::SamplerDescriptor::tag::SamplerDescriptor; + std::shared_ptr tv(new data::SamplerDescriptor()); + tv->samplerWrapS = fromJSON(W>(), obj["samplerWrapS"]); + tv->samplerWrapT = fromJSON(W>>(), obj["samplerWrapT"]); + tv->samplerWrapR = fromJSON(W>>(), obj["samplerWrapR"]); + tv->samplerMinFilter = fromJSON(W>(), obj["samplerMinFilter"]); + tv->samplerMagFilter = fromJSON(W>(), obj["samplerMagFilter"]); + tv->samplerBorderColor = fromJSON(W>(), obj["samplerBorderColor"]); + tv->samplerMinLod = fromJSON(W>(), obj["samplerMinLod"]); + tv->samplerMaxLod = fromJSON(W>(), obj["samplerMaxLod"]); + tv->samplerLodBias = fromJSON(W(), obj["samplerLodBias"]); + tv->samplerCompareFunc = fromJSON(W>>(), obj["samplerCompareFunc"]); + return tv; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::SamplerDescriptor> o(new ::SamplerDescriptor()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::TextureDescriptor::tag::TextureDescriptor: + obj["tag"] = "TextureDescriptor"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["textureType"] = toJSON(tv->textureType); + obj["textureSize"] = toJSON(tv->textureSize); + obj["textureSemantic"] = toJSON(tv->textureSemantic); + obj["textureSampler"] = toJSON(tv->textureSampler); + obj["textureBaseLevel"] = toJSON(tv->textureBaseLevel); + obj["textureMaxLevel"] = toJSON(tv->textureMaxLevel); + } + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::TextureDescriptor::tag tagType; + std::string tag = obj["tag"]; + if (tag == "TextureDescriptor") { + tagType = ::TextureDescriptor::tag::TextureDescriptor; + std::shared_ptr tv(new data::TextureDescriptor()); + tv->textureType = fromJSON(W>(), obj["textureType"]); + tv->textureSize = fromJSON(W>(), obj["textureSize"]); + tv->textureSemantic = fromJSON(W>(), obj["textureSemantic"]); + tv->textureSampler = fromJSON(W>(), obj["textureSampler"]); + tv->textureBaseLevel = fromJSON(W(), obj["textureBaseLevel"]); + tv->textureMaxLevel = fromJSON(W(), obj["textureMaxLevel"]); + return tv; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::TextureDescriptor> o(new ::TextureDescriptor()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::Parameter::tag::Parameter: + obj["tag"] = "Parameter"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["name"] = toJSON(tv->name); + obj["ty"] = toJSON(tv->ty); + } + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::Parameter::tag tagType; + std::string tag = obj["tag"]; + if (tag == "Parameter") { + tagType = ::Parameter::tag::Parameter; + std::shared_ptr tv(new data::Parameter()); + tv->name = fromJSON(W(), obj["name"]); + tv->ty = fromJSON(W>(), obj["ty"]); + return tv; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::Parameter> o(new ::Parameter()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::Program::tag::Program: + obj["tag"] = "Program"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["programUniforms"] = toJSON(tv->programUniforms); + obj["programStreams"] = toJSON(tv->programStreams); + obj["programInTextures"] = toJSON(tv->programInTextures); + obj["programOutput"] = toJSON(tv->programOutput); + obj["vertexShader"] = toJSON(tv->vertexShader); + obj["geometryShader"] = toJSON(tv->geometryShader); + obj["fragmentShader"] = toJSON(tv->fragmentShader); + } + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::Program::tag tagType; + std::string tag = obj["tag"]; + if (tag == "Program") { + tagType = ::Program::tag::Program; + std::shared_ptr tv(new data::Program()); + tv->programUniforms = fromJSON(W>>(), obj["programUniforms"]); + tv->programStreams = fromJSON(W>>(), obj["programStreams"]); + tv->programInTextures = fromJSON(W>>(), obj["programInTextures"]); + tv->programOutput = fromJSON(W>>(), obj["programOutput"]); + tv->vertexShader = fromJSON(W(), obj["vertexShader"]); + tv->geometryShader = fromJSON(W>(), obj["geometryShader"]); + tv->fragmentShader = fromJSON(W(), obj["fragmentShader"]); + return tv; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::Program> o(new ::Program()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::Slot::tag::Slot: + obj["tag"] = "Slot"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["slotName"] = toJSON(tv->slotName); + obj["slotStreams"] = toJSON(tv->slotStreams); + obj["slotUniforms"] = toJSON(tv->slotUniforms); + obj["slotPrimitive"] = toJSON(tv->slotPrimitive); + obj["slotPrograms"] = toJSON(tv->slotPrograms); + } + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::Slot::tag tagType; + std::string tag = obj["tag"]; + if (tag == "Slot") { + tagType = ::Slot::tag::Slot; + std::shared_ptr tv(new data::Slot()); + tv->slotName = fromJSON(W(), obj["slotName"]); + tv->slotStreams = fromJSON(W>>(), obj["slotStreams"]); + tv->slotUniforms = fromJSON(W>>(), obj["slotUniforms"]); + tv->slotPrimitive = fromJSON(W>(), obj["slotPrimitive"]); + tv->slotPrograms = fromJSON(W>(), obj["slotPrograms"]); + return tv; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::Slot> o(new ::Slot()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::StreamData::tag::StreamData: + obj["tag"] = "StreamData"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["streamData"] = toJSON(tv->streamData); + obj["streamType"] = toJSON(tv->streamType); + obj["streamPrimitive"] = toJSON(tv->streamPrimitive); + obj["streamPrograms"] = toJSON(tv->streamPrograms); + } + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::StreamData::tag tagType; + std::string tag = obj["tag"]; + if (tag == "StreamData") { + tagType = ::StreamData::tag::StreamData; + std::shared_ptr tv(new data::StreamData()); + tv->streamData = fromJSON(W>>(), obj["streamData"]); + tv->streamType = fromJSON(W>>(), obj["streamType"]); + tv->streamPrimitive = fromJSON(W>(), obj["streamPrimitive"]); + tv->streamPrograms = fromJSON(W>(), obj["streamPrograms"]); + return tv; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::StreamData> o(new ::StreamData()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::TargetItem::tag::TargetItem: + obj["tag"] = "TargetItem"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["targetSemantic"] = toJSON(tv->targetSemantic); + obj["targetRef"] = toJSON(tv->targetRef); + } + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::TargetItem::tag tagType; + std::string tag = obj["tag"]; + if (tag == "TargetItem") { + tagType = ::TargetItem::tag::TargetItem; + std::shared_ptr tv(new data::TargetItem()); + tv->targetSemantic = fromJSON(W>(), obj["targetSemantic"]); + tv->targetRef = fromJSON(W>>(), obj["targetRef"]); + return tv; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::TargetItem> o(new ::TargetItem()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::RenderTarget::tag::RenderTarget: + obj["tag"] = "RenderTarget"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["renderTargets"] = toJSON(tv->renderTargets); + } + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::RenderTarget::tag tagType; + std::string tag = obj["tag"]; + if (tag == "RenderTarget") { + tagType = ::RenderTarget::tag::RenderTarget; + std::shared_ptr tv(new data::RenderTarget()); + tv->renderTargets = fromJSON(W>>(), obj["renderTargets"]); + return tv; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::RenderTarget> o(new ::RenderTarget()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::Backend::tag::WebGL1: + obj["tag"] = "WebGL1"; + break; + case ::Backend::tag::OpenGL33: + obj["tag"] = "OpenGL33"; + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::Backend::tag tagType; + std::string tag = obj["tag"]; + if (tag == "WebGL1") { + tagType = ::Backend::tag::WebGL1; + } + else if (tag == "OpenGL33") { + tagType = ::Backend::tag::OpenGL33; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::Backend> o(new ::Backend()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::Pipeline::tag::Pipeline: + obj["tag"] = "Pipeline"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["backend"] = toJSON(tv->backend); + obj["textures"] = toJSON(tv->textures); + obj["samplers"] = toJSON(tv->samplers); + obj["targets"] = toJSON(tv->targets); + obj["programs"] = toJSON(tv->programs); + obj["slots"] = toJSON(tv->slots); + obj["streams"] = toJSON(tv->streams); + obj["commands"] = toJSON(tv->commands); + } + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::Pipeline::tag tagType; + std::string tag = obj["tag"]; + if (tag == "Pipeline") { + tagType = ::Pipeline::tag::Pipeline; + std::shared_ptr tv(new data::Pipeline()); + tv->backend = fromJSON(W>(), obj["backend"]); + tv->textures = fromJSON(W>>(), obj["textures"]); + tv->samplers = fromJSON(W>>(), obj["samplers"]); + tv->targets = fromJSON(W>>(), obj["targets"]); + tv->programs = fromJSON(W>>(), obj["programs"]); + tv->slots = fromJSON(W>>(), obj["slots"]); + tv->streams = fromJSON(W>>(), obj["streams"]); + tv->commands = fromJSON(W>>(), obj["commands"]); + return tv; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::Pipeline> o(new ::Pipeline()); + o->tag = tagType; + return o; +} + diff --git a/ddl/out/LambdaCube.IR.hpp b/ddl/out/LambdaCube.IR.hpp new file mode 100644 index 0000000..c45d1ce --- /dev/null +++ b/ddl/out/LambdaCube.IR.hpp @@ -0,0 +1,1070 @@ +// generated file, do not modify! +// 2016-01-28T13:15:30.803775Z + +#ifndef HEADER_LambdaCube.IR_H +#define HEADER_LambdaCube.IR_H + +#include "RT.hpp" + + +typedef Int StreamName; + +typedef Int ProgramName; + +typedef Int TextureName; + +typedef Int SamplerName; + +typedef String UniformName; + +typedef Int SlotName; + +typedef Int FrameBufferComponent; + +typedef Int TextureUnit; + +typedef Int RenderTargetName; + +typedef std::map<::UniformName, ::TextureUnit> TextureUnitMapping; + +class ArrayValue { + public: + enum class tag { + VBoolArray, + VIntArray, + VWordArray, + VFloatArray + } tag; +}; +namespace data { + class VBoolArray : public ::ArrayValue { + public: + std::vector _0; + VBoolArray() { tag = tag::VBoolArray; } + }; + class VIntArray : public ::ArrayValue { + public: + std::vector _0; + VIntArray() { tag = tag::VIntArray; } + }; + class VWordArray : public ::ArrayValue { + public: + std::vector _0; + VWordArray() { tag = tag::VWordArray; } + }; + class VFloatArray : public ::ArrayValue { + public: + std::vector _0; + VFloatArray() { tag = tag::VFloatArray; } + }; +} +class Value { + public: + enum class tag { + VBool, + VV2B, + VV3B, + VV4B, + VWord, + VV2U, + VV3U, + VV4U, + VInt, + VV2I, + VV3I, + VV4I, + VFloat, + VV2F, + VV3F, + VV4F, + VM22F, + VM23F, + VM24F, + VM32F, + VM33F, + VM34F, + VM42F, + VM43F, + VM44F + } tag; +}; +namespace data { + class VBool : public ::Value { + public: + Bool _0; + VBool() { tag = tag::VBool; } + }; + class VV2B : public ::Value { + public: + V2B _0; + VV2B() { tag = tag::VV2B; } + }; + class VV3B : public ::Value { + public: + V3B _0; + VV3B() { tag = tag::VV3B; } + }; + class VV4B : public ::Value { + public: + V4B _0; + VV4B() { tag = tag::VV4B; } + }; + class VWord : public ::Value { + public: + Word32 _0; + VWord() { tag = tag::VWord; } + }; + class VV2U : public ::Value { + public: + V2U _0; + VV2U() { tag = tag::VV2U; } + }; + class VV3U : public ::Value { + public: + V3U _0; + VV3U() { tag = tag::VV3U; } + }; + class VV4U : public ::Value { + public: + V4U _0; + VV4U() { tag = tag::VV4U; } + }; + class VInt : public ::Value { + public: + Int32 _0; + VInt() { tag = tag::VInt; } + }; + class VV2I : public ::Value { + public: + V2I _0; + VV2I() { tag = tag::VV2I; } + }; + class VV3I : public ::Value { + public: + V3I _0; + VV3I() { tag = tag::VV3I; } + }; + class VV4I : public ::Value { + public: + V4I _0; + VV4I() { tag = tag::VV4I; } + }; + class VFloat : public ::Value { + public: + Float _0; + VFloat() { tag = tag::VFloat; } + }; + class VV2F : public ::Value { + public: + V2F _0; + VV2F() { tag = tag::VV2F; } + }; + class VV3F : public ::Value { + public: + V3F _0; + VV3F() { tag = tag::VV3F; } + }; + class VV4F : public ::Value { + public: + V4F _0; + VV4F() { tag = tag::VV4F; } + }; + class VM22F : public ::Value { + public: + M22F _0; + VM22F() { tag = tag::VM22F; } + }; + class VM23F : public ::Value { + public: + M23F _0; + VM23F() { tag = tag::VM23F; } + }; + class VM24F : public ::Value { + public: + M24F _0; + VM24F() { tag = tag::VM24F; } + }; + class VM32F : public ::Value { + public: + M32F _0; + VM32F() { tag = tag::VM32F; } + }; + class VM33F : public ::Value { + public: + M33F _0; + VM33F() { tag = tag::VM33F; } + }; + class VM34F : public ::Value { + public: + M34F _0; + VM34F() { tag = tag::VM34F; } + }; + class VM42F : public ::Value { + public: + M42F _0; + VM42F() { tag = tag::VM42F; } + }; + class VM43F : public ::Value { + public: + M43F _0; + VM43F() { tag = tag::VM43F; } + }; + class VM44F : public ::Value { + public: + M44F _0; + VM44F() { tag = tag::VM44F; } + }; +} +class InputType { + public: + enum class tag { + Bool, + V2B, + V3B, + V4B, + Word, + V2U, + V3U, + V4U, + Int, + V2I, + V3I, + V4I, + Float, + V2F, + V3F, + V4F, + M22F, + M23F, + M24F, + M32F, + M33F, + M34F, + M42F, + M43F, + M44F, + STexture1D, + STexture2D, + STextureCube, + STexture1DArray, + STexture2DArray, + STexture2DRect, + FTexture1D, + FTexture2D, + FTexture3D, + FTextureCube, + FTexture1DArray, + FTexture2DArray, + FTexture2DMS, + FTexture2DMSArray, + FTextureBuffer, + FTexture2DRect, + ITexture1D, + ITexture2D, + ITexture3D, + ITextureCube, + ITexture1DArray, + ITexture2DArray, + ITexture2DMS, + ITexture2DMSArray, + ITextureBuffer, + ITexture2DRect, + UTexture1D, + UTexture2D, + UTexture3D, + UTextureCube, + UTexture1DArray, + UTexture2DArray, + UTexture2DMS, + UTexture2DMSArray, + UTextureBuffer, + UTexture2DRect + } tag; +}; +namespace data { +} +class PointSpriteCoordOrigin { + public: + enum class tag { + LowerLeft, + UpperLeft + } tag; +}; +namespace data { +} +class PointSize { + public: + enum class tag { + PointSize, + ProgramPointSize + } tag; +}; +namespace data { + class PointSize : public ::PointSize { + public: + Float _0; + PointSize() { tag = tag::PointSize; } + }; +} +class PolygonOffset { + public: + enum class tag { + NoOffset, + Offset + } tag; +}; +namespace data { + class Offset : public ::PolygonOffset { + public: + Float _0; + Float _1; + Offset() { tag = tag::Offset; } + }; +} +class FrontFace { + public: + enum class tag { + CCW, + CW + } tag; +}; +namespace data { +} +class PolygonMode { + public: + enum class tag { + PolygonPoint, + PolygonLine, + PolygonFill + } tag; +}; +namespace data { + class PolygonPoint : public ::PolygonMode { + public: + std::shared_ptr<::PointSize> _0; + PolygonPoint() { tag = tag::PolygonPoint; } + }; + class PolygonLine : public ::PolygonMode { + public: + Float _0; + PolygonLine() { tag = tag::PolygonLine; } + }; +} +class ProvokingVertex { + public: + enum class tag { + FirstVertex, + LastVertex + } tag; +}; +namespace data { +} +class CullMode { + public: + enum class tag { + CullNone, + CullFront, + CullBack + } tag; +}; +namespace data { + class CullFront : public ::CullMode { + public: + std::shared_ptr<::FrontFace> _0; + CullFront() { tag = tag::CullFront; } + }; + class CullBack : public ::CullMode { + public: + std::shared_ptr<::FrontFace> _0; + CullBack() { tag = tag::CullBack; } + }; +} +class ComparisonFunction { + public: + enum class tag { + Never, + Less, + Equal, + Lequal, + Greater, + Notequal, + Gequal, + Always + } tag; +}; +namespace data { +} +typedef ComparisonFunction DepthFunction; + +class StencilOperation { + public: + enum class tag { + OpZero, + OpKeep, + OpReplace, + OpIncr, + OpIncrWrap, + OpDecr, + OpDecrWrap, + OpInvert + } tag; +}; +namespace data { +} +class BlendEquation { + public: + enum class tag { + FuncAdd, + FuncSubtract, + FuncReverseSubtract, + Min, + Max + } tag; +}; +namespace data { +} +class BlendingFactor { + public: + enum class tag { + Zero, + One, + SrcColor, + OneMinusSrcColor, + DstColor, + OneMinusDstColor, + SrcAlpha, + OneMinusSrcAlpha, + DstAlpha, + OneMinusDstAlpha, + ConstantColor, + OneMinusConstantColor, + ConstantAlpha, + OneMinusConstantAlpha, + SrcAlphaSaturate + } tag; +}; +namespace data { +} +class LogicOperation { + public: + enum class tag { + Clear, + And, + AndReverse, + Copy, + AndInverted, + Noop, + Xor, + Or, + Nor, + Equiv, + Invert, + OrReverse, + CopyInverted, + OrInverted, + Nand, + Set + } tag; +}; +namespace data { +} +class StencilOps { + public: + enum class tag { + StencilOps + } tag; +}; +namespace data { + class StencilOps : public ::StencilOps { + public: + std::shared_ptr<::StencilOperation> frontStencilOp; + std::shared_ptr<::StencilOperation> backStencilOp; + StencilOps() { tag = tag::StencilOps; } + }; +} +class StencilTest { + public: + enum class tag { + StencilTest + } tag; +}; +namespace data { + class StencilTest : public ::StencilTest { + public: + std::shared_ptr<::ComparisonFunction> stencilComparision; + Int32 stencilReference; + Word32 stencilMask; + StencilTest() { tag = tag::StencilTest; } + }; +} +class StencilTests { + public: + enum class tag { + StencilTests + } tag; +}; +namespace data { + class StencilTests : public ::StencilTests { + public: + std::shared_ptr<::StencilTest> _0; + std::shared_ptr<::StencilTest> _1; + StencilTests() { tag = tag::StencilTests; } + }; +} +class FetchPrimitive { + public: + enum class tag { + Points, + Lines, + Triangles, + LinesAdjacency, + TrianglesAdjacency + } tag; +}; +namespace data { +} +class OutputPrimitive { + public: + enum class tag { + TrianglesOutput, + LinesOutput, + PointsOutput + } tag; +}; +namespace data { +} +class ColorArity { + public: + enum class tag { + Red, + RG, + RGB, + RGBA + } tag; +}; +namespace data { +} +class Blending { + public: + enum class tag { + NoBlending, + BlendLogicOp, + Blend + } tag; +}; +namespace data { + class BlendLogicOp : public ::Blending { + public: + std::shared_ptr<::LogicOperation> _0; + BlendLogicOp() { tag = tag::BlendLogicOp; } + }; + class Blend : public ::Blending { + public: + std::shared_ptr<::BlendEquation> colorEqSrc; + std::shared_ptr<::BlendEquation> alphaEqSrc; + std::shared_ptr<::BlendingFactor> colorFSrc; + std::shared_ptr<::BlendingFactor> colorFDst; + std::shared_ptr<::BlendingFactor> alphaFSrc; + std::shared_ptr<::BlendingFactor> alphaFDst; + V4F color; + Blend() { tag = tag::Blend; } + }; +} +class RasterContext { + public: + enum class tag { + PointCtx, + LineCtx, + TriangleCtx + } tag; +}; +namespace data { + class PointCtx : public ::RasterContext { + public: + std::shared_ptr<::PointSize> _0; + Float _1; + std::shared_ptr<::PointSpriteCoordOrigin> _2; + PointCtx() { tag = tag::PointCtx; } + }; + class LineCtx : public ::RasterContext { + public: + Float _0; + std::shared_ptr<::ProvokingVertex> _1; + LineCtx() { tag = tag::LineCtx; } + }; + class TriangleCtx : public ::RasterContext { + public: + std::shared_ptr<::CullMode> _0; + std::shared_ptr<::PolygonMode> _1; + std::shared_ptr<::PolygonOffset> _2; + std::shared_ptr<::ProvokingVertex> _3; + TriangleCtx() { tag = tag::TriangleCtx; } + }; +} +class FragmentOperation { + public: + enum class tag { + DepthOp, + StencilOp, + ColorOp + } tag; +}; +namespace data { + class DepthOp : public ::FragmentOperation { + public: + std::shared_ptr<::DepthFunction> _0; + Bool _1; + DepthOp() { tag = tag::DepthOp; } + }; + class StencilOp : public ::FragmentOperation { + public: + std::shared_ptr<::StencilTests> _0; + std::shared_ptr<::StencilOps> _1; + std::shared_ptr<::StencilOps> _2; + StencilOp() { tag = tag::StencilOp; } + }; + class ColorOp : public ::FragmentOperation { + public: + std::shared_ptr<::Blending> _0; + std::shared_ptr<::Value> _1; + ColorOp() { tag = tag::ColorOp; } + }; +} +class AccumulationContext { + public: + enum class tag { + AccumulationContext + } tag; +}; +namespace data { + class AccumulationContext : public ::AccumulationContext { + public: + Maybe accViewportName; + std::vector> accOperations; + AccumulationContext() { tag = tag::AccumulationContext; } + }; +} +class TextureDataType { + public: + enum class tag { + FloatT, + IntT, + WordT, + ShadowT + } tag; +}; +namespace data { + class FloatT : public ::TextureDataType { + public: + std::shared_ptr<::ColorArity> _0; + FloatT() { tag = tag::FloatT; } + }; + class IntT : public ::TextureDataType { + public: + std::shared_ptr<::ColorArity> _0; + IntT() { tag = tag::IntT; } + }; + class WordT : public ::TextureDataType { + public: + std::shared_ptr<::ColorArity> _0; + WordT() { tag = tag::WordT; } + }; +} +class TextureType { + public: + enum class tag { + Texture1D, + Texture2D, + Texture3D, + TextureCube, + TextureRect, + Texture2DMS, + TextureBuffer + } tag; +}; +namespace data { + class Texture1D : public ::TextureType { + public: + std::shared_ptr<::TextureDataType> _0; + Int _1; + Texture1D() { tag = tag::Texture1D; } + }; + class Texture2D : public ::TextureType { + public: + std::shared_ptr<::TextureDataType> _0; + Int _1; + Texture2D() { tag = tag::Texture2D; } + }; + class Texture3D : public ::TextureType { + public: + std::shared_ptr<::TextureDataType> _0; + Texture3D() { tag = tag::Texture3D; } + }; + class TextureCube : public ::TextureType { + public: + std::shared_ptr<::TextureDataType> _0; + TextureCube() { tag = tag::TextureCube; } + }; + class TextureRect : public ::TextureType { + public: + std::shared_ptr<::TextureDataType> _0; + TextureRect() { tag = tag::TextureRect; } + }; + class Texture2DMS : public ::TextureType { + public: + std::shared_ptr<::TextureDataType> _0; + Int _1; + Int _2; + Bool _3; + Texture2DMS() { tag = tag::Texture2DMS; } + }; + class TextureBuffer : public ::TextureType { + public: + std::shared_ptr<::TextureDataType> _0; + TextureBuffer() { tag = tag::TextureBuffer; } + }; +} +class MipMap { + public: + enum class tag { + Mip, + NoMip, + AutoMip + } tag; +}; +namespace data { + class Mip : public ::MipMap { + public: + Int _0; + Int _1; + Mip() { tag = tag::Mip; } + }; + class AutoMip : public ::MipMap { + public: + Int _0; + Int _1; + AutoMip() { tag = tag::AutoMip; } + }; +} +class Filter { + public: + enum class tag { + Nearest, + Linear, + NearestMipmapNearest, + NearestMipmapLinear, + LinearMipmapNearest, + LinearMipmapLinear + } tag; +}; +namespace data { +} +class EdgeMode { + public: + enum class tag { + Repeat, + MirroredRepeat, + ClampToEdge, + ClampToBorder + } tag; +}; +namespace data { +} +class ImageSemantic { + public: + enum class tag { + Depth, + Stencil, + Color + } tag; +}; +namespace data { +} +class ImageRef { + public: + enum class tag { + TextureImage, + Framebuffer + } tag; +}; +namespace data { + class TextureImage : public ::ImageRef { + public: + ::TextureName _0; + Int _1; + Maybe _2; + TextureImage() { tag = tag::TextureImage; } + }; + class Framebuffer : public ::ImageRef { + public: + std::shared_ptr<::ImageSemantic> _0; + Framebuffer() { tag = tag::Framebuffer; } + }; +} +class ClearImage { + public: + enum class tag { + ClearImage + } tag; +}; +namespace data { + class ClearImage : public ::ClearImage { + public: + std::shared_ptr<::ImageSemantic> imageSemantic; + std::shared_ptr<::Value> clearValue; + ClearImage() { tag = tag::ClearImage; } + }; +} +class Command { + public: + enum class tag { + SetRasterContext, + SetAccumulationContext, + SetRenderTarget, + SetProgram, + SetSamplerUniform, + SetTexture, + SetSampler, + RenderSlot, + RenderStream, + ClearRenderTarget, + GenerateMipMap, + SaveImage, + LoadImage + } tag; +}; +namespace data { + class SetRasterContext : public ::Command { + public: + std::shared_ptr<::RasterContext> _0; + SetRasterContext() { tag = tag::SetRasterContext; } + }; + class SetAccumulationContext : public ::Command { + public: + std::shared_ptr<::AccumulationContext> _0; + SetAccumulationContext() { tag = tag::SetAccumulationContext; } + }; + class SetRenderTarget : public ::Command { + public: + ::RenderTargetName _0; + SetRenderTarget() { tag = tag::SetRenderTarget; } + }; + class SetProgram : public ::Command { + public: + ::ProgramName _0; + SetProgram() { tag = tag::SetProgram; } + }; + class SetSamplerUniform : public ::Command { + public: + ::UniformName _0; + ::TextureUnit _1; + SetSamplerUniform() { tag = tag::SetSamplerUniform; } + }; + class SetTexture : public ::Command { + public: + ::TextureUnit _0; + ::TextureName _1; + SetTexture() { tag = tag::SetTexture; } + }; + class SetSampler : public ::Command { + public: + ::TextureUnit _0; + Maybe<::SamplerName> _1; + SetSampler() { tag = tag::SetSampler; } + }; + class RenderSlot : public ::Command { + public: + ::SlotName _0; + RenderSlot() { tag = tag::RenderSlot; } + }; + class RenderStream : public ::Command { + public: + ::StreamName _0; + RenderStream() { tag = tag::RenderStream; } + }; + class ClearRenderTarget : public ::Command { + public: + std::vector> _0; + ClearRenderTarget() { tag = tag::ClearRenderTarget; } + }; + class GenerateMipMap : public ::Command { + public: + ::TextureUnit _0; + GenerateMipMap() { tag = tag::GenerateMipMap; } + }; + class SaveImage : public ::Command { + public: + ::FrameBufferComponent _0; + std::shared_ptr<::ImageRef> _1; + SaveImage() { tag = tag::SaveImage; } + }; + class LoadImage : public ::Command { + public: + std::shared_ptr<::ImageRef> _0; + ::FrameBufferComponent _1; + LoadImage() { tag = tag::LoadImage; } + }; +} +class SamplerDescriptor { + public: + enum class tag { + SamplerDescriptor + } tag; +}; +namespace data { + class SamplerDescriptor : public ::SamplerDescriptor { + public: + std::shared_ptr<::EdgeMode> samplerWrapS; + Maybe> samplerWrapT; + Maybe> samplerWrapR; + std::shared_ptr<::Filter> samplerMinFilter; + std::shared_ptr<::Filter> samplerMagFilter; + std::shared_ptr<::Value> samplerBorderColor; + Maybe samplerMinLod; + Maybe samplerMaxLod; + Float samplerLodBias; + Maybe> samplerCompareFunc; + SamplerDescriptor() { tag = tag::SamplerDescriptor; } + }; +} +class TextureDescriptor { + public: + enum class tag { + TextureDescriptor + } tag; +}; +namespace data { + class TextureDescriptor : public ::TextureDescriptor { + public: + std::shared_ptr<::TextureType> textureType; + std::shared_ptr<::Value> textureSize; + std::shared_ptr<::ImageSemantic> textureSemantic; + std::shared_ptr<::SamplerDescriptor> textureSampler; + Int textureBaseLevel; + Int textureMaxLevel; + TextureDescriptor() { tag = tag::TextureDescriptor; } + }; +} +class Parameter { + public: + enum class tag { + Parameter + } tag; +}; +namespace data { + class Parameter : public ::Parameter { + public: + String name; + std::shared_ptr<::InputType> ty; + Parameter() { tag = tag::Parameter; } + }; +} +class Program { + public: + enum class tag { + Program + } tag; +}; +namespace data { + class Program : public ::Program { + public: + std::map<::UniformName, std::shared_ptr<::InputType>> programUniforms; + std::map<::UniformName, std::shared_ptr<::Parameter>> programStreams; + std::map<::UniformName, std::shared_ptr<::InputType>> programInTextures; + std::vector> programOutput; + String vertexShader; + Maybe geometryShader; + String fragmentShader; + Program() { tag = tag::Program; } + }; +} +class Slot { + public: + enum class tag { + Slot + } tag; +}; +namespace data { + class Slot : public ::Slot { + public: + String slotName; + std::map> slotStreams; + std::map<::UniformName, std::shared_ptr<::InputType>> slotUniforms; + std::shared_ptr<::FetchPrimitive> slotPrimitive; + std::vector<::ProgramName> slotPrograms; + Slot() { tag = tag::Slot; } + }; +} +class StreamData { + public: + enum class tag { + StreamData + } tag; +}; +namespace data { + class StreamData : public ::StreamData { + public: + std::map> streamData; + std::map> streamType; + std::shared_ptr<::FetchPrimitive> streamPrimitive; + std::vector<::ProgramName> streamPrograms; + StreamData() { tag = tag::StreamData; } + }; +} +class TargetItem { + public: + enum class tag { + TargetItem + } tag; +}; +namespace data { + class TargetItem : public ::TargetItem { + public: + std::shared_ptr<::ImageSemantic> targetSemantic; + Maybe> targetRef; + TargetItem() { tag = tag::TargetItem; } + }; +} +class RenderTarget { + public: + enum class tag { + RenderTarget + } tag; +}; +namespace data { + class RenderTarget : public ::RenderTarget { + public: + std::vector> renderTargets; + RenderTarget() { tag = tag::RenderTarget; } + }; +} +class Backend { + public: + enum class tag { + WebGL1, + OpenGL33 + } tag; +}; +namespace data { +} +class Pipeline { + public: + enum class tag { + Pipeline + } tag; +}; +namespace data { + class Pipeline : public ::Pipeline { + public: + std::shared_ptr<::Backend> backend; + std::vector> textures; + std::vector> samplers; + std::vector> targets; + std::vector> programs; + std::vector> slots; + std::vector> streams; + std::vector> commands; + Pipeline() { tag = tag::Pipeline; } + }; +} +#endif diff --git a/ddl/out/LambdaCube.IR.hs b/ddl/out/LambdaCube.IR.hs new file mode 100644 index 0000000..03675f7 --- /dev/null +++ b/ddl/out/LambdaCube.IR.hs @@ -0,0 +1,1608 @@ +-- generated file, do not modify! +-- 2016-01-28T13:15:30.803775Z + +{-# LANGUAGE OverloadedStrings, RecordWildCards #-} +module LambdaCube.IR where + +import Data.Int +import Data.Word +import Data.Map +import Data.Vector (Vector(..)) +import LambdaCube.Linear + +import Data.Text +import Data.Aeson hiding (Value,Bool) +import Data.Aeson.Types hiding (Value,Bool) +import Control.Monad + + +type StreamName = Int + +type ProgramName = Int + +type TextureName = Int + +type SamplerName = Int + +type UniformName = String + +type SlotName = Int + +type FrameBufferComponent = Int + +type TextureUnit = Int + +type RenderTargetName = Int + +type TextureUnitMapping = Map UniformName TextureUnit + +data ArrayValue + = VBoolArray (Vector Bool) + | VIntArray (Vector Int32) + | VWordArray (Vector Word32) + | VFloatArray (Vector Float) + deriving (Show, Eq, Ord) + +data Value + = VBool Bool + | VV2B V2B + | VV3B V3B + | VV4B V4B + | VWord Word32 + | VV2U V2U + | VV3U V3U + | VV4U V4U + | VInt Int32 + | VV2I V2I + | VV3I V3I + | VV4I V4I + | VFloat Float + | VV2F V2F + | VV3F V3F + | VV4F V4F + | VM22F M22F + | VM23F M23F + | VM24F M24F + | VM32F M32F + | VM33F M33F + | VM34F M34F + | VM42F M42F + | VM43F M43F + | VM44F M44F + deriving (Show, Eq, Ord) + +data InputType + = Bool + | V2B + | V3B + | V4B + | Word + | V2U + | V3U + | V4U + | Int + | V2I + | V3I + | V4I + | Float + | V2F + | V3F + | V4F + | M22F + | M23F + | M24F + | M32F + | M33F + | M34F + | M42F + | M43F + | M44F + | STexture1D + | STexture2D + | STextureCube + | STexture1DArray + | STexture2DArray + | STexture2DRect + | FTexture1D + | FTexture2D + | FTexture3D + | FTextureCube + | FTexture1DArray + | FTexture2DArray + | FTexture2DMS + | FTexture2DMSArray + | FTextureBuffer + | FTexture2DRect + | ITexture1D + | ITexture2D + | ITexture3D + | ITextureCube + | ITexture1DArray + | ITexture2DArray + | ITexture2DMS + | ITexture2DMSArray + | ITextureBuffer + | ITexture2DRect + | UTexture1D + | UTexture2D + | UTexture3D + | UTextureCube + | UTexture1DArray + | UTexture2DArray + | UTexture2DMS + | UTexture2DMSArray + | UTextureBuffer + | UTexture2DRect + deriving (Show, Eq, Ord) + +data PointSpriteCoordOrigin + = LowerLeft + | UpperLeft + deriving (Show, Eq, Ord) + +data PointSize + = PointSize Float + | ProgramPointSize + deriving (Show, Eq, Ord) + +data PolygonOffset + = NoOffset + | Offset Float Float + deriving (Show, Eq, Ord) + +data FrontFace + = CCW + | CW + deriving (Show, Eq, Ord) + +data PolygonMode + = PolygonPoint PointSize + | PolygonLine Float + | PolygonFill + deriving (Show, Eq, Ord) + +data ProvokingVertex + = FirstVertex + | LastVertex + deriving (Show, Eq, Ord) + +data CullMode + = CullNone + | CullFront FrontFace + | CullBack FrontFace + deriving (Show, Eq, Ord) + +data ComparisonFunction + = Never + | Less + | Equal + | Lequal + | Greater + | Notequal + | Gequal + | Always + deriving (Show, Eq, Ord) + +type DepthFunction = ComparisonFunction + +data StencilOperation + = OpZero + | OpKeep + | OpReplace + | OpIncr + | OpIncrWrap + | OpDecr + | OpDecrWrap + | OpInvert + deriving (Show, Eq, Ord) + +data BlendEquation + = FuncAdd + | FuncSubtract + | FuncReverseSubtract + | Min + | Max + deriving (Show, Eq, Ord) + +data BlendingFactor + = Zero + | One + | SrcColor + | OneMinusSrcColor + | DstColor + | OneMinusDstColor + | SrcAlpha + | OneMinusSrcAlpha + | DstAlpha + | OneMinusDstAlpha + | ConstantColor + | OneMinusConstantColor + | ConstantAlpha + | OneMinusConstantAlpha + | SrcAlphaSaturate + deriving (Show, Eq, Ord) + +data LogicOperation + = Clear + | And + | AndReverse + | Copy + | AndInverted + | Noop + | Xor + | Or + | Nor + | Equiv + | Invert + | OrReverse + | CopyInverted + | OrInverted + | Nand + | Set + deriving (Show, Eq, Ord) + +data StencilOps + = StencilOps + { frontStencilOp :: StencilOperation + , backStencilOp :: StencilOperation + } + + deriving (Show, Eq, Ord) + +data StencilTest + = StencilTest + { stencilComparision :: ComparisonFunction + , stencilReference :: Int32 + , stencilMask :: Word32 + } + + deriving (Show, Eq, Ord) + +data StencilTests + = StencilTests StencilTest StencilTest + deriving (Show, Eq, Ord) + +data FetchPrimitive + = Points + | Lines + | Triangles + | LinesAdjacency + | TrianglesAdjacency + deriving (Show, Eq, Ord) + +data OutputPrimitive + = TrianglesOutput + | LinesOutput + | PointsOutput + deriving (Show, Eq, Ord) + +data ColorArity + = Red + | RG + | RGB + | RGBA + deriving (Show, Eq, Ord) + +data Blending + = NoBlending + | BlendLogicOp LogicOperation + | Blend + { colorEqSrc :: BlendEquation + , alphaEqSrc :: BlendEquation + , colorFSrc :: BlendingFactor + , colorFDst :: BlendingFactor + , alphaFSrc :: BlendingFactor + , alphaFDst :: BlendingFactor + , color :: V4F + } + + deriving (Show, Eq, Ord) + +data RasterContext + = PointCtx PointSize Float PointSpriteCoordOrigin + | LineCtx Float ProvokingVertex + | TriangleCtx CullMode PolygonMode PolygonOffset ProvokingVertex + deriving (Show, Eq, Ord) + +data FragmentOperation + = DepthOp DepthFunction Bool + | StencilOp StencilTests StencilOps StencilOps + | ColorOp Blending Value + deriving (Show, Eq, Ord) + +data AccumulationContext + = AccumulationContext + { accViewportName :: Maybe String + , accOperations :: [FragmentOperation] + } + + deriving (Show, Eq, Ord) + +data TextureDataType + = FloatT ColorArity + | IntT ColorArity + | WordT ColorArity + | ShadowT + deriving (Show, Eq, Ord) + +data TextureType + = Texture1D TextureDataType Int + | Texture2D TextureDataType Int + | Texture3D TextureDataType + | TextureCube TextureDataType + | TextureRect TextureDataType + | Texture2DMS TextureDataType Int Int Bool + | TextureBuffer TextureDataType + deriving (Show, Eq, Ord) + +data MipMap + = Mip Int Int + | NoMip + | AutoMip Int Int + deriving (Show, Eq, Ord) + +data Filter + = Nearest + | Linear + | NearestMipmapNearest + | NearestMipmapLinear + | LinearMipmapNearest + | LinearMipmapLinear + deriving (Show, Eq, Ord) + +data EdgeMode + = Repeat + | MirroredRepeat + | ClampToEdge + | ClampToBorder + deriving (Show, Eq, Ord) + +data ImageSemantic + = Depth + | Stencil + | Color + deriving (Show, Eq, Ord) + +data ImageRef + = TextureImage TextureName Int (Maybe Int) + | Framebuffer ImageSemantic + deriving (Show, Eq, Ord) + +data ClearImage + = ClearImage + { imageSemantic :: ImageSemantic + , clearValue :: Value + } + + deriving (Show, Eq, Ord) + +data Command + = SetRasterContext RasterContext + | SetAccumulationContext AccumulationContext + | SetRenderTarget RenderTargetName + | SetProgram ProgramName + | SetSamplerUniform UniformName TextureUnit + | SetTexture TextureUnit TextureName + | SetSampler TextureUnit (Maybe SamplerName) + | RenderSlot SlotName + | RenderStream StreamName + | ClearRenderTarget (Vector ClearImage) + | GenerateMipMap TextureUnit + | SaveImage FrameBufferComponent ImageRef + | LoadImage ImageRef FrameBufferComponent + deriving (Show, Eq, Ord) + +data SamplerDescriptor + = SamplerDescriptor + { samplerWrapS :: EdgeMode + , samplerWrapT :: Maybe EdgeMode + , samplerWrapR :: Maybe EdgeMode + , samplerMinFilter :: Filter + , samplerMagFilter :: Filter + , samplerBorderColor :: Value + , samplerMinLod :: Maybe Float + , samplerMaxLod :: Maybe Float + , samplerLodBias :: Float + , samplerCompareFunc :: Maybe ComparisonFunction + } + + deriving (Show, Eq, Ord) + +data TextureDescriptor + = TextureDescriptor + { textureType :: TextureType + , textureSize :: Value + , textureSemantic :: ImageSemantic + , textureSampler :: SamplerDescriptor + , textureBaseLevel :: Int + , textureMaxLevel :: Int + } + + deriving (Show, Eq, Ord) + +data Parameter + = Parameter + { name :: String + , ty :: InputType + } + + deriving (Show, Eq, Ord) + +data Program + = Program + { programUniforms :: Map UniformName InputType + , programStreams :: Map UniformName Parameter + , programInTextures :: Map UniformName InputType + , programOutput :: Vector Parameter + , vertexShader :: String + , geometryShader :: Maybe String + , fragmentShader :: String + } + + deriving (Show, Eq, Ord) + +data Slot + = Slot + { slotName :: String + , slotStreams :: Map String InputType + , slotUniforms :: Map UniformName InputType + , slotPrimitive :: FetchPrimitive + , slotPrograms :: Vector ProgramName + } + + deriving (Show, Eq, Ord) + +data StreamData + = StreamData + { streamData :: Map String ArrayValue + , streamType :: Map String InputType + , streamPrimitive :: FetchPrimitive + , streamPrograms :: Vector ProgramName + } + + deriving (Show, Eq, Ord) + +data TargetItem + = TargetItem + { targetSemantic :: ImageSemantic + , targetRef :: Maybe ImageRef + } + + deriving (Show, Eq, Ord) + +data RenderTarget + = RenderTarget + { renderTargets :: Vector TargetItem + } + + deriving (Show, Eq, Ord) + +data Backend + = WebGL1 + | OpenGL33 + deriving (Show, Eq, Ord) + +data Pipeline + = Pipeline + { backend :: Backend + , textures :: Vector TextureDescriptor + , samplers :: Vector SamplerDescriptor + , targets :: Vector RenderTarget + , programs :: Vector Program + , slots :: Vector Slot + , streams :: Vector StreamData + , commands :: Vector Command + } + + deriving (Show, Eq, Ord) + + +instance ToJSON ArrayValue where + toJSON v = case v of + VBoolArray arg0 -> object [ "tag" .= ("VBoolArray" :: Text), "arg0" .= arg0] + VIntArray arg0 -> object [ "tag" .= ("VIntArray" :: Text), "arg0" .= arg0] + VWordArray arg0 -> object [ "tag" .= ("VWordArray" :: Text), "arg0" .= arg0] + VFloatArray arg0 -> object [ "tag" .= ("VFloatArray" :: Text), "arg0" .= arg0] + +instance FromJSON ArrayValue where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "VBoolArray" -> VBoolArray <$> obj .: "arg0" + "VIntArray" -> VIntArray <$> obj .: "arg0" + "VWordArray" -> VWordArray <$> obj .: "arg0" + "VFloatArray" -> VFloatArray <$> obj .: "arg0" + parseJSON _ = mzero + +instance ToJSON Value where + toJSON v = case v of + VBool arg0 -> object [ "tag" .= ("VBool" :: Text), "arg0" .= arg0] + VV2B arg0 -> object [ "tag" .= ("VV2B" :: Text), "arg0" .= arg0] + VV3B arg0 -> object [ "tag" .= ("VV3B" :: Text), "arg0" .= arg0] + VV4B arg0 -> object [ "tag" .= ("VV4B" :: Text), "arg0" .= arg0] + VWord arg0 -> object [ "tag" .= ("VWord" :: Text), "arg0" .= arg0] + VV2U arg0 -> object [ "tag" .= ("VV2U" :: Text), "arg0" .= arg0] + VV3U arg0 -> object [ "tag" .= ("VV3U" :: Text), "arg0" .= arg0] + VV4U arg0 -> object [ "tag" .= ("VV4U" :: Text), "arg0" .= arg0] + VInt arg0 -> object [ "tag" .= ("VInt" :: Text), "arg0" .= arg0] + VV2I arg0 -> object [ "tag" .= ("VV2I" :: Text), "arg0" .= arg0] + VV3I arg0 -> object [ "tag" .= ("VV3I" :: Text), "arg0" .= arg0] + VV4I arg0 -> object [ "tag" .= ("VV4I" :: Text), "arg0" .= arg0] + VFloat arg0 -> object [ "tag" .= ("VFloat" :: Text), "arg0" .= arg0] + VV2F arg0 -> object [ "tag" .= ("VV2F" :: Text), "arg0" .= arg0] + VV3F arg0 -> object [ "tag" .= ("VV3F" :: Text), "arg0" .= arg0] + VV4F arg0 -> object [ "tag" .= ("VV4F" :: Text), "arg0" .= arg0] + VM22F arg0 -> object [ "tag" .= ("VM22F" :: Text), "arg0" .= arg0] + VM23F arg0 -> object [ "tag" .= ("VM23F" :: Text), "arg0" .= arg0] + VM24F arg0 -> object [ "tag" .= ("VM24F" :: Text), "arg0" .= arg0] + VM32F arg0 -> object [ "tag" .= ("VM32F" :: Text), "arg0" .= arg0] + VM33F arg0 -> object [ "tag" .= ("VM33F" :: Text), "arg0" .= arg0] + VM34F arg0 -> object [ "tag" .= ("VM34F" :: Text), "arg0" .= arg0] + VM42F arg0 -> object [ "tag" .= ("VM42F" :: Text), "arg0" .= arg0] + VM43F arg0 -> object [ "tag" .= ("VM43F" :: Text), "arg0" .= arg0] + VM44F arg0 -> object [ "tag" .= ("VM44F" :: Text), "arg0" .= arg0] + +instance FromJSON Value where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "VBool" -> VBool <$> obj .: "arg0" + "VV2B" -> VV2B <$> obj .: "arg0" + "VV3B" -> VV3B <$> obj .: "arg0" + "VV4B" -> VV4B <$> obj .: "arg0" + "VWord" -> VWord <$> obj .: "arg0" + "VV2U" -> VV2U <$> obj .: "arg0" + "VV3U" -> VV3U <$> obj .: "arg0" + "VV4U" -> VV4U <$> obj .: "arg0" + "VInt" -> VInt <$> obj .: "arg0" + "VV2I" -> VV2I <$> obj .: "arg0" + "VV3I" -> VV3I <$> obj .: "arg0" + "VV4I" -> VV4I <$> obj .: "arg0" + "VFloat" -> VFloat <$> obj .: "arg0" + "VV2F" -> VV2F <$> obj .: "arg0" + "VV3F" -> VV3F <$> obj .: "arg0" + "VV4F" -> VV4F <$> obj .: "arg0" + "VM22F" -> VM22F <$> obj .: "arg0" + "VM23F" -> VM23F <$> obj .: "arg0" + "VM24F" -> VM24F <$> obj .: "arg0" + "VM32F" -> VM32F <$> obj .: "arg0" + "VM33F" -> VM33F <$> obj .: "arg0" + "VM34F" -> VM34F <$> obj .: "arg0" + "VM42F" -> VM42F <$> obj .: "arg0" + "VM43F" -> VM43F <$> obj .: "arg0" + "VM44F" -> VM44F <$> obj .: "arg0" + parseJSON _ = mzero + +instance ToJSON InputType where + toJSON v = case v of + Bool -> object [ "tag" .= ("Bool" :: Text)] + V2B -> object [ "tag" .= ("V2B" :: Text)] + V3B -> object [ "tag" .= ("V3B" :: Text)] + V4B -> object [ "tag" .= ("V4B" :: Text)] + Word -> object [ "tag" .= ("Word" :: Text)] + V2U -> object [ "tag" .= ("V2U" :: Text)] + V3U -> object [ "tag" .= ("V3U" :: Text)] + V4U -> object [ "tag" .= ("V4U" :: Text)] + Int -> object [ "tag" .= ("Int" :: Text)] + V2I -> object [ "tag" .= ("V2I" :: Text)] + V3I -> object [ "tag" .= ("V3I" :: Text)] + V4I -> object [ "tag" .= ("V4I" :: Text)] + Float -> object [ "tag" .= ("Float" :: Text)] + V2F -> object [ "tag" .= ("V2F" :: Text)] + V3F -> object [ "tag" .= ("V3F" :: Text)] + V4F -> object [ "tag" .= ("V4F" :: Text)] + M22F -> object [ "tag" .= ("M22F" :: Text)] + M23F -> object [ "tag" .= ("M23F" :: Text)] + M24F -> object [ "tag" .= ("M24F" :: Text)] + M32F -> object [ "tag" .= ("M32F" :: Text)] + M33F -> object [ "tag" .= ("M33F" :: Text)] + M34F -> object [ "tag" .= ("M34F" :: Text)] + M42F -> object [ "tag" .= ("M42F" :: Text)] + M43F -> object [ "tag" .= ("M43F" :: Text)] + M44F -> object [ "tag" .= ("M44F" :: Text)] + STexture1D -> object [ "tag" .= ("STexture1D" :: Text)] + STexture2D -> object [ "tag" .= ("STexture2D" :: Text)] + STextureCube -> object [ "tag" .= ("STextureCube" :: Text)] + STexture1DArray -> object [ "tag" .= ("STexture1DArray" :: Text)] + STexture2DArray -> object [ "tag" .= ("STexture2DArray" :: Text)] + STexture2DRect -> object [ "tag" .= ("STexture2DRect" :: Text)] + FTexture1D -> object [ "tag" .= ("FTexture1D" :: Text)] + FTexture2D -> object [ "tag" .= ("FTexture2D" :: Text)] + FTexture3D -> object [ "tag" .= ("FTexture3D" :: Text)] + FTextureCube -> object [ "tag" .= ("FTextureCube" :: Text)] + FTexture1DArray -> object [ "tag" .= ("FTexture1DArray" :: Text)] + FTexture2DArray -> object [ "tag" .= ("FTexture2DArray" :: Text)] + FTexture2DMS -> object [ "tag" .= ("FTexture2DMS" :: Text)] + FTexture2DMSArray -> object [ "tag" .= ("FTexture2DMSArray" :: Text)] + FTextureBuffer -> object [ "tag" .= ("FTextureBuffer" :: Text)] + FTexture2DRect -> object [ "tag" .= ("FTexture2DRect" :: Text)] + ITexture1D -> object [ "tag" .= ("ITexture1D" :: Text)] + ITexture2D -> object [ "tag" .= ("ITexture2D" :: Text)] + ITexture3D -> object [ "tag" .= ("ITexture3D" :: Text)] + ITextureCube -> object [ "tag" .= ("ITextureCube" :: Text)] + ITexture1DArray -> object [ "tag" .= ("ITexture1DArray" :: Text)] + ITexture2DArray -> object [ "tag" .= ("ITexture2DArray" :: Text)] + ITexture2DMS -> object [ "tag" .= ("ITexture2DMS" :: Text)] + ITexture2DMSArray -> object [ "tag" .= ("ITexture2DMSArray" :: Text)] + ITextureBuffer -> object [ "tag" .= ("ITextureBuffer" :: Text)] + ITexture2DRect -> object [ "tag" .= ("ITexture2DRect" :: Text)] + UTexture1D -> object [ "tag" .= ("UTexture1D" :: Text)] + UTexture2D -> object [ "tag" .= ("UTexture2D" :: Text)] + UTexture3D -> object [ "tag" .= ("UTexture3D" :: Text)] + UTextureCube -> object [ "tag" .= ("UTextureCube" :: Text)] + UTexture1DArray -> object [ "tag" .= ("UTexture1DArray" :: Text)] + UTexture2DArray -> object [ "tag" .= ("UTexture2DArray" :: Text)] + UTexture2DMS -> object [ "tag" .= ("UTexture2DMS" :: Text)] + UTexture2DMSArray -> object [ "tag" .= ("UTexture2DMSArray" :: Text)] + UTextureBuffer -> object [ "tag" .= ("UTextureBuffer" :: Text)] + UTexture2DRect -> object [ "tag" .= ("UTexture2DRect" :: Text)] + +instance FromJSON InputType where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "Bool" -> pure Bool + "V2B" -> pure V2B + "V3B" -> pure V3B + "V4B" -> pure V4B + "Word" -> pure Word + "V2U" -> pure V2U + "V3U" -> pure V3U + "V4U" -> pure V4U + "Int" -> pure Int + "V2I" -> pure V2I + "V3I" -> pure V3I + "V4I" -> pure V4I + "Float" -> pure Float + "V2F" -> pure V2F + "V3F" -> pure V3F + "V4F" -> pure V4F + "M22F" -> pure M22F + "M23F" -> pure M23F + "M24F" -> pure M24F + "M32F" -> pure M32F + "M33F" -> pure M33F + "M34F" -> pure M34F + "M42F" -> pure M42F + "M43F" -> pure M43F + "M44F" -> pure M44F + "STexture1D" -> pure STexture1D + "STexture2D" -> pure STexture2D + "STextureCube" -> pure STextureCube + "STexture1DArray" -> pure STexture1DArray + "STexture2DArray" -> pure STexture2DArray + "STexture2DRect" -> pure STexture2DRect + "FTexture1D" -> pure FTexture1D + "FTexture2D" -> pure FTexture2D + "FTexture3D" -> pure FTexture3D + "FTextureCube" -> pure FTextureCube + "FTexture1DArray" -> pure FTexture1DArray + "FTexture2DArray" -> pure FTexture2DArray + "FTexture2DMS" -> pure FTexture2DMS + "FTexture2DMSArray" -> pure FTexture2DMSArray + "FTextureBuffer" -> pure FTextureBuffer + "FTexture2DRect" -> pure FTexture2DRect + "ITexture1D" -> pure ITexture1D + "ITexture2D" -> pure ITexture2D + "ITexture3D" -> pure ITexture3D + "ITextureCube" -> pure ITextureCube + "ITexture1DArray" -> pure ITexture1DArray + "ITexture2DArray" -> pure ITexture2DArray + "ITexture2DMS" -> pure ITexture2DMS + "ITexture2DMSArray" -> pure ITexture2DMSArray + "ITextureBuffer" -> pure ITextureBuffer + "ITexture2DRect" -> pure ITexture2DRect + "UTexture1D" -> pure UTexture1D + "UTexture2D" -> pure UTexture2D + "UTexture3D" -> pure UTexture3D + "UTextureCube" -> pure UTextureCube + "UTexture1DArray" -> pure UTexture1DArray + "UTexture2DArray" -> pure UTexture2DArray + "UTexture2DMS" -> pure UTexture2DMS + "UTexture2DMSArray" -> pure UTexture2DMSArray + "UTextureBuffer" -> pure UTextureBuffer + "UTexture2DRect" -> pure UTexture2DRect + parseJSON _ = mzero + +instance ToJSON PointSpriteCoordOrigin where + toJSON v = case v of + LowerLeft -> object [ "tag" .= ("LowerLeft" :: Text)] + UpperLeft -> object [ "tag" .= ("UpperLeft" :: Text)] + +instance FromJSON PointSpriteCoordOrigin where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "LowerLeft" -> pure LowerLeft + "UpperLeft" -> pure UpperLeft + parseJSON _ = mzero + +instance ToJSON PointSize where + toJSON v = case v of + PointSize arg0 -> object [ "tag" .= ("PointSize" :: Text), "arg0" .= arg0] + ProgramPointSize -> object [ "tag" .= ("ProgramPointSize" :: Text)] + +instance FromJSON PointSize where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "PointSize" -> PointSize <$> obj .: "arg0" + "ProgramPointSize" -> pure ProgramPointSize + parseJSON _ = mzero + +instance ToJSON PolygonOffset where + toJSON v = case v of + NoOffset -> object [ "tag" .= ("NoOffset" :: Text)] + Offset arg0 arg1 -> object [ "tag" .= ("Offset" :: Text), "arg0" .= arg0, "arg1" .= arg1] + +instance FromJSON PolygonOffset where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "NoOffset" -> pure NoOffset + "Offset" -> Offset <$> obj .: "arg0" <*> obj .: "arg1" + parseJSON _ = mzero + +instance ToJSON FrontFace where + toJSON v = case v of + CCW -> object [ "tag" .= ("CCW" :: Text)] + CW -> object [ "tag" .= ("CW" :: Text)] + +instance FromJSON FrontFace where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "CCW" -> pure CCW + "CW" -> pure CW + parseJSON _ = mzero + +instance ToJSON PolygonMode where + toJSON v = case v of + PolygonPoint arg0 -> object [ "tag" .= ("PolygonPoint" :: Text), "arg0" .= arg0] + PolygonLine arg0 -> object [ "tag" .= ("PolygonLine" :: Text), "arg0" .= arg0] + PolygonFill -> object [ "tag" .= ("PolygonFill" :: Text)] + +instance FromJSON PolygonMode where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "PolygonPoint" -> PolygonPoint <$> obj .: "arg0" + "PolygonLine" -> PolygonLine <$> obj .: "arg0" + "PolygonFill" -> pure PolygonFill + parseJSON _ = mzero + +instance ToJSON ProvokingVertex where + toJSON v = case v of + FirstVertex -> object [ "tag" .= ("FirstVertex" :: Text)] + LastVertex -> object [ "tag" .= ("LastVertex" :: Text)] + +instance FromJSON ProvokingVertex where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "FirstVertex" -> pure FirstVertex + "LastVertex" -> pure LastVertex + parseJSON _ = mzero + +instance ToJSON CullMode where + toJSON v = case v of + CullNone -> object [ "tag" .= ("CullNone" :: Text)] + CullFront arg0 -> object [ "tag" .= ("CullFront" :: Text), "arg0" .= arg0] + CullBack arg0 -> object [ "tag" .= ("CullBack" :: Text), "arg0" .= arg0] + +instance FromJSON CullMode where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "CullNone" -> pure CullNone + "CullFront" -> CullFront <$> obj .: "arg0" + "CullBack" -> CullBack <$> obj .: "arg0" + parseJSON _ = mzero + +instance ToJSON ComparisonFunction where + toJSON v = case v of + Never -> object [ "tag" .= ("Never" :: Text)] + Less -> object [ "tag" .= ("Less" :: Text)] + Equal -> object [ "tag" .= ("Equal" :: Text)] + Lequal -> object [ "tag" .= ("Lequal" :: Text)] + Greater -> object [ "tag" .= ("Greater" :: Text)] + Notequal -> object [ "tag" .= ("Notequal" :: Text)] + Gequal -> object [ "tag" .= ("Gequal" :: Text)] + Always -> object [ "tag" .= ("Always" :: Text)] + +instance FromJSON ComparisonFunction where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "Never" -> pure Never + "Less" -> pure Less + "Equal" -> pure Equal + "Lequal" -> pure Lequal + "Greater" -> pure Greater + "Notequal" -> pure Notequal + "Gequal" -> pure Gequal + "Always" -> pure Always + parseJSON _ = mzero + +instance ToJSON StencilOperation where + toJSON v = case v of + OpZero -> object [ "tag" .= ("OpZero" :: Text)] + OpKeep -> object [ "tag" .= ("OpKeep" :: Text)] + OpReplace -> object [ "tag" .= ("OpReplace" :: Text)] + OpIncr -> object [ "tag" .= ("OpIncr" :: Text)] + OpIncrWrap -> object [ "tag" .= ("OpIncrWrap" :: Text)] + OpDecr -> object [ "tag" .= ("OpDecr" :: Text)] + OpDecrWrap -> object [ "tag" .= ("OpDecrWrap" :: Text)] + OpInvert -> object [ "tag" .= ("OpInvert" :: Text)] + +instance FromJSON StencilOperation where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "OpZero" -> pure OpZero + "OpKeep" -> pure OpKeep + "OpReplace" -> pure OpReplace + "OpIncr" -> pure OpIncr + "OpIncrWrap" -> pure OpIncrWrap + "OpDecr" -> pure OpDecr + "OpDecrWrap" -> pure OpDecrWrap + "OpInvert" -> pure OpInvert + parseJSON _ = mzero + +instance ToJSON BlendEquation where + toJSON v = case v of + FuncAdd -> object [ "tag" .= ("FuncAdd" :: Text)] + FuncSubtract -> object [ "tag" .= ("FuncSubtract" :: Text)] + FuncReverseSubtract -> object [ "tag" .= ("FuncReverseSubtract" :: Text)] + Min -> object [ "tag" .= ("Min" :: Text)] + Max -> object [ "tag" .= ("Max" :: Text)] + +instance FromJSON BlendEquation where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "FuncAdd" -> pure FuncAdd + "FuncSubtract" -> pure FuncSubtract + "FuncReverseSubtract" -> pure FuncReverseSubtract + "Min" -> pure Min + "Max" -> pure Max + parseJSON _ = mzero + +instance ToJSON BlendingFactor where + toJSON v = case v of + Zero -> object [ "tag" .= ("Zero" :: Text)] + One -> object [ "tag" .= ("One" :: Text)] + SrcColor -> object [ "tag" .= ("SrcColor" :: Text)] + OneMinusSrcColor -> object [ "tag" .= ("OneMinusSrcColor" :: Text)] + DstColor -> object [ "tag" .= ("DstColor" :: Text)] + OneMinusDstColor -> object [ "tag" .= ("OneMinusDstColor" :: Text)] + SrcAlpha -> object [ "tag" .= ("SrcAlpha" :: Text)] + OneMinusSrcAlpha -> object [ "tag" .= ("OneMinusSrcAlpha" :: Text)] + DstAlpha -> object [ "tag" .= ("DstAlpha" :: Text)] + OneMinusDstAlpha -> object [ "tag" .= ("OneMinusDstAlpha" :: Text)] + ConstantColor -> object [ "tag" .= ("ConstantColor" :: Text)] + OneMinusConstantColor -> object [ "tag" .= ("OneMinusConstantColor" :: Text)] + ConstantAlpha -> object [ "tag" .= ("ConstantAlpha" :: Text)] + OneMinusConstantAlpha -> object [ "tag" .= ("OneMinusConstantAlpha" :: Text)] + SrcAlphaSaturate -> object [ "tag" .= ("SrcAlphaSaturate" :: Text)] + +instance FromJSON BlendingFactor where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "Zero" -> pure Zero + "One" -> pure One + "SrcColor" -> pure SrcColor + "OneMinusSrcColor" -> pure OneMinusSrcColor + "DstColor" -> pure DstColor + "OneMinusDstColor" -> pure OneMinusDstColor + "SrcAlpha" -> pure SrcAlpha + "OneMinusSrcAlpha" -> pure OneMinusSrcAlpha + "DstAlpha" -> pure DstAlpha + "OneMinusDstAlpha" -> pure OneMinusDstAlpha + "ConstantColor" -> pure ConstantColor + "OneMinusConstantColor" -> pure OneMinusConstantColor + "ConstantAlpha" -> pure ConstantAlpha + "OneMinusConstantAlpha" -> pure OneMinusConstantAlpha + "SrcAlphaSaturate" -> pure SrcAlphaSaturate + parseJSON _ = mzero + +instance ToJSON LogicOperation where + toJSON v = case v of + Clear -> object [ "tag" .= ("Clear" :: Text)] + And -> object [ "tag" .= ("And" :: Text)] + AndReverse -> object [ "tag" .= ("AndReverse" :: Text)] + Copy -> object [ "tag" .= ("Copy" :: Text)] + AndInverted -> object [ "tag" .= ("AndInverted" :: Text)] + Noop -> object [ "tag" .= ("Noop" :: Text)] + Xor -> object [ "tag" .= ("Xor" :: Text)] + Or -> object [ "tag" .= ("Or" :: Text)] + Nor -> object [ "tag" .= ("Nor" :: Text)] + Equiv -> object [ "tag" .= ("Equiv" :: Text)] + Invert -> object [ "tag" .= ("Invert" :: Text)] + OrReverse -> object [ "tag" .= ("OrReverse" :: Text)] + CopyInverted -> object [ "tag" .= ("CopyInverted" :: Text)] + OrInverted -> object [ "tag" .= ("OrInverted" :: Text)] + Nand -> object [ "tag" .= ("Nand" :: Text)] + Set -> object [ "tag" .= ("Set" :: Text)] + +instance FromJSON LogicOperation where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "Clear" -> pure Clear + "And" -> pure And + "AndReverse" -> pure AndReverse + "Copy" -> pure Copy + "AndInverted" -> pure AndInverted + "Noop" -> pure Noop + "Xor" -> pure Xor + "Or" -> pure Or + "Nor" -> pure Nor + "Equiv" -> pure Equiv + "Invert" -> pure Invert + "OrReverse" -> pure OrReverse + "CopyInverted" -> pure CopyInverted + "OrInverted" -> pure OrInverted + "Nand" -> pure Nand + "Set" -> pure Set + parseJSON _ = mzero + +instance ToJSON StencilOps where + toJSON v = case v of + StencilOps{..} -> object + [ "tag" .= ("StencilOps" :: Text) + , "frontStencilOp" .= frontStencilOp + , "backStencilOp" .= backStencilOp + ] + +instance FromJSON StencilOps where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "StencilOps" -> do + frontStencilOp <- obj .: "frontStencilOp" + backStencilOp <- obj .: "backStencilOp" + pure $ StencilOps + { frontStencilOp = frontStencilOp + , backStencilOp = backStencilOp + } + parseJSON _ = mzero + +instance ToJSON StencilTest where + toJSON v = case v of + StencilTest{..} -> object + [ "tag" .= ("StencilTest" :: Text) + , "stencilComparision" .= stencilComparision + , "stencilReference" .= stencilReference + , "stencilMask" .= stencilMask + ] + +instance FromJSON StencilTest where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "StencilTest" -> do + stencilComparision <- obj .: "stencilComparision" + stencilReference <- obj .: "stencilReference" + stencilMask <- obj .: "stencilMask" + pure $ StencilTest + { stencilComparision = stencilComparision + , stencilReference = stencilReference + , stencilMask = stencilMask + } + parseJSON _ = mzero + +instance ToJSON StencilTests where + toJSON v = case v of + StencilTests arg0 arg1 -> object [ "tag" .= ("StencilTests" :: Text), "arg0" .= arg0, "arg1" .= arg1] + +instance FromJSON StencilTests where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "StencilTests" -> StencilTests <$> obj .: "arg0" <*> obj .: "arg1" + parseJSON _ = mzero + +instance ToJSON FetchPrimitive where + toJSON v = case v of + Points -> object [ "tag" .= ("Points" :: Text)] + Lines -> object [ "tag" .= ("Lines" :: Text)] + Triangles -> object [ "tag" .= ("Triangles" :: Text)] + LinesAdjacency -> object [ "tag" .= ("LinesAdjacency" :: Text)] + TrianglesAdjacency -> object [ "tag" .= ("TrianglesAdjacency" :: Text)] + +instance FromJSON FetchPrimitive where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "Points" -> pure Points + "Lines" -> pure Lines + "Triangles" -> pure Triangles + "LinesAdjacency" -> pure LinesAdjacency + "TrianglesAdjacency" -> pure TrianglesAdjacency + parseJSON _ = mzero + +instance ToJSON OutputPrimitive where + toJSON v = case v of + TrianglesOutput -> object [ "tag" .= ("TrianglesOutput" :: Text)] + LinesOutput -> object [ "tag" .= ("LinesOutput" :: Text)] + PointsOutput -> object [ "tag" .= ("PointsOutput" :: Text)] + +instance FromJSON OutputPrimitive where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "TrianglesOutput" -> pure TrianglesOutput + "LinesOutput" -> pure LinesOutput + "PointsOutput" -> pure PointsOutput + parseJSON _ = mzero + +instance ToJSON ColorArity where + toJSON v = case v of + Red -> object [ "tag" .= ("Red" :: Text)] + RG -> object [ "tag" .= ("RG" :: Text)] + RGB -> object [ "tag" .= ("RGB" :: Text)] + RGBA -> object [ "tag" .= ("RGBA" :: Text)] + +instance FromJSON ColorArity where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "Red" -> pure Red + "RG" -> pure RG + "RGB" -> pure RGB + "RGBA" -> pure RGBA + parseJSON _ = mzero + +instance ToJSON Blending where + toJSON v = case v of + NoBlending -> object [ "tag" .= ("NoBlending" :: Text)] + BlendLogicOp arg0 -> object [ "tag" .= ("BlendLogicOp" :: Text), "arg0" .= arg0] + Blend{..} -> object + [ "tag" .= ("Blend" :: Text) + , "colorEqSrc" .= colorEqSrc + , "alphaEqSrc" .= alphaEqSrc + , "colorFSrc" .= colorFSrc + , "colorFDst" .= colorFDst + , "alphaFSrc" .= alphaFSrc + , "alphaFDst" .= alphaFDst + , "color" .= color + ] + +instance FromJSON Blending where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "NoBlending" -> pure NoBlending + "BlendLogicOp" -> BlendLogicOp <$> obj .: "arg0" + "Blend" -> do + colorEqSrc <- obj .: "colorEqSrc" + alphaEqSrc <- obj .: "alphaEqSrc" + colorFSrc <- obj .: "colorFSrc" + colorFDst <- obj .: "colorFDst" + alphaFSrc <- obj .: "alphaFSrc" + alphaFDst <- obj .: "alphaFDst" + color <- obj .: "color" + pure $ Blend + { colorEqSrc = colorEqSrc + , alphaEqSrc = alphaEqSrc + , colorFSrc = colorFSrc + , colorFDst = colorFDst + , alphaFSrc = alphaFSrc + , alphaFDst = alphaFDst + , color = color + } + parseJSON _ = mzero + +instance ToJSON RasterContext where + toJSON v = case v of + PointCtx arg0 arg1 arg2 -> object [ "tag" .= ("PointCtx" :: Text), "arg0" .= arg0, "arg1" .= arg1, "arg2" .= arg2] + LineCtx arg0 arg1 -> object [ "tag" .= ("LineCtx" :: Text), "arg0" .= arg0, "arg1" .= arg1] + TriangleCtx arg0 arg1 arg2 arg3 -> object [ "tag" .= ("TriangleCtx" :: Text), "arg0" .= arg0, "arg1" .= arg1, "arg2" .= arg2, "arg3" .= arg3] + +instance FromJSON RasterContext where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "PointCtx" -> PointCtx <$> obj .: "arg0" <*> obj .: "arg1" <*> obj .: "arg2" + "LineCtx" -> LineCtx <$> obj .: "arg0" <*> obj .: "arg1" + "TriangleCtx" -> TriangleCtx <$> obj .: "arg0" <*> obj .: "arg1" <*> obj .: "arg2" <*> obj .: "arg3" + parseJSON _ = mzero + +instance ToJSON FragmentOperation where + toJSON v = case v of + DepthOp arg0 arg1 -> object [ "tag" .= ("DepthOp" :: Text), "arg0" .= arg0, "arg1" .= arg1] + StencilOp arg0 arg1 arg2 -> object [ "tag" .= ("StencilOp" :: Text), "arg0" .= arg0, "arg1" .= arg1, "arg2" .= arg2] + ColorOp arg0 arg1 -> object [ "tag" .= ("ColorOp" :: Text), "arg0" .= arg0, "arg1" .= arg1] + +instance FromJSON FragmentOperation where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "DepthOp" -> DepthOp <$> obj .: "arg0" <*> obj .: "arg1" + "StencilOp" -> StencilOp <$> obj .: "arg0" <*> obj .: "arg1" <*> obj .: "arg2" + "ColorOp" -> ColorOp <$> obj .: "arg0" <*> obj .: "arg1" + parseJSON _ = mzero + +instance ToJSON AccumulationContext where + toJSON v = case v of + AccumulationContext{..} -> object + [ "tag" .= ("AccumulationContext" :: Text) + , "accViewportName" .= accViewportName + , "accOperations" .= accOperations + ] + +instance FromJSON AccumulationContext where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "AccumulationContext" -> do + accViewportName <- obj .: "accViewportName" + accOperations <- obj .: "accOperations" + pure $ AccumulationContext + { accViewportName = accViewportName + , accOperations = accOperations + } + parseJSON _ = mzero + +instance ToJSON TextureDataType where + toJSON v = case v of + FloatT arg0 -> object [ "tag" .= ("FloatT" :: Text), "arg0" .= arg0] + IntT arg0 -> object [ "tag" .= ("IntT" :: Text), "arg0" .= arg0] + WordT arg0 -> object [ "tag" .= ("WordT" :: Text), "arg0" .= arg0] + ShadowT -> object [ "tag" .= ("ShadowT" :: Text)] + +instance FromJSON TextureDataType where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "FloatT" -> FloatT <$> obj .: "arg0" + "IntT" -> IntT <$> obj .: "arg0" + "WordT" -> WordT <$> obj .: "arg0" + "ShadowT" -> pure ShadowT + parseJSON _ = mzero + +instance ToJSON TextureType where + toJSON v = case v of + Texture1D arg0 arg1 -> object [ "tag" .= ("Texture1D" :: Text), "arg0" .= arg0, "arg1" .= arg1] + Texture2D arg0 arg1 -> object [ "tag" .= ("Texture2D" :: Text), "arg0" .= arg0, "arg1" .= arg1] + Texture3D arg0 -> object [ "tag" .= ("Texture3D" :: Text), "arg0" .= arg0] + TextureCube arg0 -> object [ "tag" .= ("TextureCube" :: Text), "arg0" .= arg0] + TextureRect arg0 -> object [ "tag" .= ("TextureRect" :: Text), "arg0" .= arg0] + Texture2DMS arg0 arg1 arg2 arg3 -> object [ "tag" .= ("Texture2DMS" :: Text), "arg0" .= arg0, "arg1" .= arg1, "arg2" .= arg2, "arg3" .= arg3] + TextureBuffer arg0 -> object [ "tag" .= ("TextureBuffer" :: Text), "arg0" .= arg0] + +instance FromJSON TextureType where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "Texture1D" -> Texture1D <$> obj .: "arg0" <*> obj .: "arg1" + "Texture2D" -> Texture2D <$> obj .: "arg0" <*> obj .: "arg1" + "Texture3D" -> Texture3D <$> obj .: "arg0" + "TextureCube" -> TextureCube <$> obj .: "arg0" + "TextureRect" -> TextureRect <$> obj .: "arg0" + "Texture2DMS" -> Texture2DMS <$> obj .: "arg0" <*> obj .: "arg1" <*> obj .: "arg2" <*> obj .: "arg3" + "TextureBuffer" -> TextureBuffer <$> obj .: "arg0" + parseJSON _ = mzero + +instance ToJSON MipMap where + toJSON v = case v of + Mip arg0 arg1 -> object [ "tag" .= ("Mip" :: Text), "arg0" .= arg0, "arg1" .= arg1] + NoMip -> object [ "tag" .= ("NoMip" :: Text)] + AutoMip arg0 arg1 -> object [ "tag" .= ("AutoMip" :: Text), "arg0" .= arg0, "arg1" .= arg1] + +instance FromJSON MipMap where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "Mip" -> Mip <$> obj .: "arg0" <*> obj .: "arg1" + "NoMip" -> pure NoMip + "AutoMip" -> AutoMip <$> obj .: "arg0" <*> obj .: "arg1" + parseJSON _ = mzero + +instance ToJSON Filter where + toJSON v = case v of + Nearest -> object [ "tag" .= ("Nearest" :: Text)] + Linear -> object [ "tag" .= ("Linear" :: Text)] + NearestMipmapNearest -> object [ "tag" .= ("NearestMipmapNearest" :: Text)] + NearestMipmapLinear -> object [ "tag" .= ("NearestMipmapLinear" :: Text)] + LinearMipmapNearest -> object [ "tag" .= ("LinearMipmapNearest" :: Text)] + LinearMipmapLinear -> object [ "tag" .= ("LinearMipmapLinear" :: Text)] + +instance FromJSON Filter where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "Nearest" -> pure Nearest + "Linear" -> pure Linear + "NearestMipmapNearest" -> pure NearestMipmapNearest + "NearestMipmapLinear" -> pure NearestMipmapLinear + "LinearMipmapNearest" -> pure LinearMipmapNearest + "LinearMipmapLinear" -> pure LinearMipmapLinear + parseJSON _ = mzero + +instance ToJSON EdgeMode where + toJSON v = case v of + Repeat -> object [ "tag" .= ("Repeat" :: Text)] + MirroredRepeat -> object [ "tag" .= ("MirroredRepeat" :: Text)] + ClampToEdge -> object [ "tag" .= ("ClampToEdge" :: Text)] + ClampToBorder -> object [ "tag" .= ("ClampToBorder" :: Text)] + +instance FromJSON EdgeMode where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "Repeat" -> pure Repeat + "MirroredRepeat" -> pure MirroredRepeat + "ClampToEdge" -> pure ClampToEdge + "ClampToBorder" -> pure ClampToBorder + parseJSON _ = mzero + +instance ToJSON ImageSemantic where + toJSON v = case v of + Depth -> object [ "tag" .= ("Depth" :: Text)] + Stencil -> object [ "tag" .= ("Stencil" :: Text)] + Color -> object [ "tag" .= ("Color" :: Text)] + +instance FromJSON ImageSemantic where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "Depth" -> pure Depth + "Stencil" -> pure Stencil + "Color" -> pure Color + parseJSON _ = mzero + +instance ToJSON ImageRef where + toJSON v = case v of + TextureImage arg0 arg1 arg2 -> object [ "tag" .= ("TextureImage" :: Text), "arg0" .= arg0, "arg1" .= arg1, "arg2" .= arg2] + Framebuffer arg0 -> object [ "tag" .= ("Framebuffer" :: Text), "arg0" .= arg0] + +instance FromJSON ImageRef where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "TextureImage" -> TextureImage <$> obj .: "arg0" <*> obj .: "arg1" <*> obj .: "arg2" + "Framebuffer" -> Framebuffer <$> obj .: "arg0" + parseJSON _ = mzero + +instance ToJSON ClearImage where + toJSON v = case v of + ClearImage{..} -> object + [ "tag" .= ("ClearImage" :: Text) + , "imageSemantic" .= imageSemantic + , "clearValue" .= clearValue + ] + +instance FromJSON ClearImage where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "ClearImage" -> do + imageSemantic <- obj .: "imageSemantic" + clearValue <- obj .: "clearValue" + pure $ ClearImage + { imageSemantic = imageSemantic + , clearValue = clearValue + } + parseJSON _ = mzero + +instance ToJSON Command where + toJSON v = case v of + SetRasterContext arg0 -> object [ "tag" .= ("SetRasterContext" :: Text), "arg0" .= arg0] + SetAccumulationContext arg0 -> object [ "tag" .= ("SetAccumulationContext" :: Text), "arg0" .= arg0] + SetRenderTarget arg0 -> object [ "tag" .= ("SetRenderTarget" :: Text), "arg0" .= arg0] + SetProgram arg0 -> object [ "tag" .= ("SetProgram" :: Text), "arg0" .= arg0] + SetSamplerUniform arg0 arg1 -> object [ "tag" .= ("SetSamplerUniform" :: Text), "arg0" .= arg0, "arg1" .= arg1] + SetTexture arg0 arg1 -> object [ "tag" .= ("SetTexture" :: Text), "arg0" .= arg0, "arg1" .= arg1] + SetSampler arg0 arg1 -> object [ "tag" .= ("SetSampler" :: Text), "arg0" .= arg0, "arg1" .= arg1] + RenderSlot arg0 -> object [ "tag" .= ("RenderSlot" :: Text), "arg0" .= arg0] + RenderStream arg0 -> object [ "tag" .= ("RenderStream" :: Text), "arg0" .= arg0] + ClearRenderTarget arg0 -> object [ "tag" .= ("ClearRenderTarget" :: Text), "arg0" .= arg0] + GenerateMipMap arg0 -> object [ "tag" .= ("GenerateMipMap" :: Text), "arg0" .= arg0] + SaveImage arg0 arg1 -> object [ "tag" .= ("SaveImage" :: Text), "arg0" .= arg0, "arg1" .= arg1] + LoadImage arg0 arg1 -> object [ "tag" .= ("LoadImage" :: Text), "arg0" .= arg0, "arg1" .= arg1] + +instance FromJSON Command where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "SetRasterContext" -> SetRasterContext <$> obj .: "arg0" + "SetAccumulationContext" -> SetAccumulationContext <$> obj .: "arg0" + "SetRenderTarget" -> SetRenderTarget <$> obj .: "arg0" + "SetProgram" -> SetProgram <$> obj .: "arg0" + "SetSamplerUniform" -> SetSamplerUniform <$> obj .: "arg0" <*> obj .: "arg1" + "SetTexture" -> SetTexture <$> obj .: "arg0" <*> obj .: "arg1" + "SetSampler" -> SetSampler <$> obj .: "arg0" <*> obj .: "arg1" + "RenderSlot" -> RenderSlot <$> obj .: "arg0" + "RenderStream" -> RenderStream <$> obj .: "arg0" + "ClearRenderTarget" -> ClearRenderTarget <$> obj .: "arg0" + "GenerateMipMap" -> GenerateMipMap <$> obj .: "arg0" + "SaveImage" -> SaveImage <$> obj .: "arg0" <*> obj .: "arg1" + "LoadImage" -> LoadImage <$> obj .: "arg0" <*> obj .: "arg1" + parseJSON _ = mzero + +instance ToJSON SamplerDescriptor where + toJSON v = case v of + SamplerDescriptor{..} -> object + [ "tag" .= ("SamplerDescriptor" :: Text) + , "samplerWrapS" .= samplerWrapS + , "samplerWrapT" .= samplerWrapT + , "samplerWrapR" .= samplerWrapR + , "samplerMinFilter" .= samplerMinFilter + , "samplerMagFilter" .= samplerMagFilter + , "samplerBorderColor" .= samplerBorderColor + , "samplerMinLod" .= samplerMinLod + , "samplerMaxLod" .= samplerMaxLod + , "samplerLodBias" .= samplerLodBias + , "samplerCompareFunc" .= samplerCompareFunc + ] + +instance FromJSON SamplerDescriptor where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "SamplerDescriptor" -> do + samplerWrapS <- obj .: "samplerWrapS" + samplerWrapT <- obj .: "samplerWrapT" + samplerWrapR <- obj .: "samplerWrapR" + samplerMinFilter <- obj .: "samplerMinFilter" + samplerMagFilter <- obj .: "samplerMagFilter" + samplerBorderColor <- obj .: "samplerBorderColor" + samplerMinLod <- obj .: "samplerMinLod" + samplerMaxLod <- obj .: "samplerMaxLod" + samplerLodBias <- obj .: "samplerLodBias" + samplerCompareFunc <- obj .: "samplerCompareFunc" + pure $ SamplerDescriptor + { samplerWrapS = samplerWrapS + , samplerWrapT = samplerWrapT + , samplerWrapR = samplerWrapR + , samplerMinFilter = samplerMinFilter + , samplerMagFilter = samplerMagFilter + , samplerBorderColor = samplerBorderColor + , samplerMinLod = samplerMinLod + , samplerMaxLod = samplerMaxLod + , samplerLodBias = samplerLodBias + , samplerCompareFunc = samplerCompareFunc + } + parseJSON _ = mzero + +instance ToJSON TextureDescriptor where + toJSON v = case v of + TextureDescriptor{..} -> object + [ "tag" .= ("TextureDescriptor" :: Text) + , "textureType" .= textureType + , "textureSize" .= textureSize + , "textureSemantic" .= textureSemantic + , "textureSampler" .= textureSampler + , "textureBaseLevel" .= textureBaseLevel + , "textureMaxLevel" .= textureMaxLevel + ] + +instance FromJSON TextureDescriptor where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "TextureDescriptor" -> do + textureType <- obj .: "textureType" + textureSize <- obj .: "textureSize" + textureSemantic <- obj .: "textureSemantic" + textureSampler <- obj .: "textureSampler" + textureBaseLevel <- obj .: "textureBaseLevel" + textureMaxLevel <- obj .: "textureMaxLevel" + pure $ TextureDescriptor + { textureType = textureType + , textureSize = textureSize + , textureSemantic = textureSemantic + , textureSampler = textureSampler + , textureBaseLevel = textureBaseLevel + , textureMaxLevel = textureMaxLevel + } + parseJSON _ = mzero + +instance ToJSON Parameter where + toJSON v = case v of + Parameter{..} -> object + [ "tag" .= ("Parameter" :: Text) + , "name" .= name + , "ty" .= ty + ] + +instance FromJSON Parameter where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "Parameter" -> do + name <- obj .: "name" + ty <- obj .: "ty" + pure $ Parameter + { name = name + , ty = ty + } + parseJSON _ = mzero + +instance ToJSON Program where + toJSON v = case v of + Program{..} -> object + [ "tag" .= ("Program" :: Text) + , "programUniforms" .= programUniforms + , "programStreams" .= programStreams + , "programInTextures" .= programInTextures + , "programOutput" .= programOutput + , "vertexShader" .= vertexShader + , "geometryShader" .= geometryShader + , "fragmentShader" .= fragmentShader + ] + +instance FromJSON Program where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "Program" -> do + programUniforms <- obj .: "programUniforms" + programStreams <- obj .: "programStreams" + programInTextures <- obj .: "programInTextures" + programOutput <- obj .: "programOutput" + vertexShader <- obj .: "vertexShader" + geometryShader <- obj .: "geometryShader" + fragmentShader <- obj .: "fragmentShader" + pure $ Program + { programUniforms = programUniforms + , programStreams = programStreams + , programInTextures = programInTextures + , programOutput = programOutput + , vertexShader = vertexShader + , geometryShader = geometryShader + , fragmentShader = fragmentShader + } + parseJSON _ = mzero + +instance ToJSON Slot where + toJSON v = case v of + Slot{..} -> object + [ "tag" .= ("Slot" :: Text) + , "slotName" .= slotName + , "slotStreams" .= slotStreams + , "slotUniforms" .= slotUniforms + , "slotPrimitive" .= slotPrimitive + , "slotPrograms" .= slotPrograms + ] + +instance FromJSON Slot where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "Slot" -> do + slotName <- obj .: "slotName" + slotStreams <- obj .: "slotStreams" + slotUniforms <- obj .: "slotUniforms" + slotPrimitive <- obj .: "slotPrimitive" + slotPrograms <- obj .: "slotPrograms" + pure $ Slot + { slotName = slotName + , slotStreams = slotStreams + , slotUniforms = slotUniforms + , slotPrimitive = slotPrimitive + , slotPrograms = slotPrograms + } + parseJSON _ = mzero + +instance ToJSON StreamData where + toJSON v = case v of + StreamData{..} -> object + [ "tag" .= ("StreamData" :: Text) + , "streamData" .= streamData + , "streamType" .= streamType + , "streamPrimitive" .= streamPrimitive + , "streamPrograms" .= streamPrograms + ] + +instance FromJSON StreamData where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "StreamData" -> do + streamData <- obj .: "streamData" + streamType <- obj .: "streamType" + streamPrimitive <- obj .: "streamPrimitive" + streamPrograms <- obj .: "streamPrograms" + pure $ StreamData + { streamData = streamData + , streamType = streamType + , streamPrimitive = streamPrimitive + , streamPrograms = streamPrograms + } + parseJSON _ = mzero + +instance ToJSON TargetItem where + toJSON v = case v of + TargetItem{..} -> object + [ "tag" .= ("TargetItem" :: Text) + , "targetSemantic" .= targetSemantic + , "targetRef" .= targetRef + ] + +instance FromJSON TargetItem where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "TargetItem" -> do + targetSemantic <- obj .: "targetSemantic" + targetRef <- obj .: "targetRef" + pure $ TargetItem + { targetSemantic = targetSemantic + , targetRef = targetRef + } + parseJSON _ = mzero + +instance ToJSON RenderTarget where + toJSON v = case v of + RenderTarget{..} -> object + [ "tag" .= ("RenderTarget" :: Text) + , "renderTargets" .= renderTargets + ] + +instance FromJSON RenderTarget where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "RenderTarget" -> do + renderTargets <- obj .: "renderTargets" + pure $ RenderTarget + { renderTargets = renderTargets + } + parseJSON _ = mzero + +instance ToJSON Backend where + toJSON v = case v of + WebGL1 -> object [ "tag" .= ("WebGL1" :: Text)] + OpenGL33 -> object [ "tag" .= ("OpenGL33" :: Text)] + +instance FromJSON Backend where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "WebGL1" -> pure WebGL1 + "OpenGL33" -> pure OpenGL33 + parseJSON _ = mzero + +instance ToJSON Pipeline where + toJSON v = case v of + Pipeline{..} -> object + [ "tag" .= ("Pipeline" :: Text) + , "backend" .= backend + , "textures" .= textures + , "samplers" .= samplers + , "targets" .= targets + , "programs" .= programs + , "slots" .= slots + , "streams" .= streams + , "commands" .= commands + ] + +instance FromJSON Pipeline where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "Pipeline" -> do + backend <- obj .: "backend" + textures <- obj .: "textures" + samplers <- obj .: "samplers" + targets <- obj .: "targets" + programs <- obj .: "programs" + slots <- obj .: "slots" + streams <- obj .: "streams" + commands <- obj .: "commands" + pure $ Pipeline + { backend = backend + , textures = textures + , samplers = samplers + , targets = targets + , programs = programs + , slots = slots + , streams = streams + , commands = commands + } + parseJSON _ = mzero + diff --git a/ddl/out/LambdaCube.IR.purs b/ddl/out/LambdaCube.IR.purs new file mode 100644 index 0000000..459c1c8 --- /dev/null +++ b/ddl/out/LambdaCube.IR.purs @@ -0,0 +1,1590 @@ +-- generated file, do not modify! +-- 2016-01-28T13:15:30.803775Z + +module LambdaCube.IR where +import Prelude +import Data.Generic +import Data.Maybe (Maybe(..)) +import Data.StrMap (StrMap(..)) +import Data.Map (Map(..)) +import Data.List (List(..)) +import Linear + +import Data.Argonaut.Combinators ((~>), (:=), (.?)) +import Data.Argonaut.Core (jsonEmptyObject) +import Data.Argonaut.Printer (printJson) +import Data.Argonaut.Encode (EncodeJson, encodeJson) +import Data.Argonaut.Decode (DecodeJson, decodeJson) + + +type StreamName = Int + +type ProgramName = Int + +type TextureName = Int + +type SamplerName = Int + +type UniformName = String + +type SlotName = Int + +type FrameBufferComponent = Int + +type TextureUnit = Int + +type RenderTargetName = Int + +type TextureUnitMapping = StrMap TextureUnit + +data ArrayValue + = VBoolArray (Array Bool) + | VIntArray (Array Int32) + | VWordArray (Array Word32) + | VFloatArray (Array Float) + +data Value + = VBool Bool + | VV2B V2B + | VV3B V3B + | VV4B V4B + | VWord Word32 + | VV2U V2U + | VV3U V3U + | VV4U V4U + | VInt Int32 + | VV2I V2I + | VV3I V3I + | VV4I V4I + | VFloat Float + | VV2F V2F + | VV3F V3F + | VV4F V4F + | VM22F M22F + | VM23F M23F + | VM24F M24F + | VM32F M32F + | VM33F M33F + | VM34F M34F + | VM42F M42F + | VM43F M43F + | VM44F M44F + +data InputType + = Bool + | V2B + | V3B + | V4B + | Word + | V2U + | V3U + | V4U + | Int + | V2I + | V3I + | V4I + | Float + | V2F + | V3F + | V4F + | M22F + | M23F + | M24F + | M32F + | M33F + | M34F + | M42F + | M43F + | M44F + | STexture1D + | STexture2D + | STextureCube + | STexture1DArray + | STexture2DArray + | STexture2DRect + | FTexture1D + | FTexture2D + | FTexture3D + | FTextureCube + | FTexture1DArray + | FTexture2DArray + | FTexture2DMS + | FTexture2DMSArray + | FTextureBuffer + | FTexture2DRect + | ITexture1D + | ITexture2D + | ITexture3D + | ITextureCube + | ITexture1DArray + | ITexture2DArray + | ITexture2DMS + | ITexture2DMSArray + | ITextureBuffer + | ITexture2DRect + | UTexture1D + | UTexture2D + | UTexture3D + | UTextureCube + | UTexture1DArray + | UTexture2DArray + | UTexture2DMS + | UTexture2DMSArray + | UTextureBuffer + | UTexture2DRect + +data PointSpriteCoordOrigin + = LowerLeft + | UpperLeft + +data PointSize + = PointSize Float + | ProgramPointSize + +data PolygonOffset + = NoOffset + | Offset Float Float + +data FrontFace + = CCW + | CW + +data PolygonMode + = PolygonPoint PointSize + | PolygonLine Float + | PolygonFill + +data ProvokingVertex + = FirstVertex + | LastVertex + +data CullMode + = CullNone + | CullFront FrontFace + | CullBack FrontFace + +data ComparisonFunction + = Never + | Less + | Equal + | Lequal + | Greater + | Notequal + | Gequal + | Always + +type DepthFunction = ComparisonFunction + +data StencilOperation + = OpZero + | OpKeep + | OpReplace + | OpIncr + | OpIncrWrap + | OpDecr + | OpDecrWrap + | OpInvert + +data BlendEquation + = FuncAdd + | FuncSubtract + | FuncReverseSubtract + | Min + | Max + +data BlendingFactor + = Zero + | One + | SrcColor + | OneMinusSrcColor + | DstColor + | OneMinusDstColor + | SrcAlpha + | OneMinusSrcAlpha + | DstAlpha + | OneMinusDstAlpha + | ConstantColor + | OneMinusConstantColor + | ConstantAlpha + | OneMinusConstantAlpha + | SrcAlphaSaturate + +data LogicOperation + = Clear + | And + | AndReverse + | Copy + | AndInverted + | Noop + | Xor + | Or + | Nor + | Equiv + | Invert + | OrReverse + | CopyInverted + | OrInverted + | Nand + | Set + +data StencilOps + = StencilOps + { frontStencilOp :: StencilOperation + , backStencilOp :: StencilOperation + } + + +data StencilTest + = StencilTest + { stencilComparision :: ComparisonFunction + , stencilReference :: Int32 + , stencilMask :: Word32 + } + + +data StencilTests + = StencilTests StencilTest StencilTest + +data FetchPrimitive + = Points + | Lines + | Triangles + | LinesAdjacency + | TrianglesAdjacency + +data OutputPrimitive + = TrianglesOutput + | LinesOutput + | PointsOutput + +data ColorArity + = Red + | RG + | RGB + | RGBA + +data Blending + = NoBlending + | BlendLogicOp LogicOperation + | Blend + { colorEqSrc :: BlendEquation + , alphaEqSrc :: BlendEquation + , colorFSrc :: BlendingFactor + , colorFDst :: BlendingFactor + , alphaFSrc :: BlendingFactor + , alphaFDst :: BlendingFactor + , color :: V4F + } + + +data RasterContext + = PointCtx PointSize Float PointSpriteCoordOrigin + | LineCtx Float ProvokingVertex + | TriangleCtx CullMode PolygonMode PolygonOffset ProvokingVertex + +data FragmentOperation + = DepthOp DepthFunction Bool + | StencilOp StencilTests StencilOps StencilOps + | ColorOp Blending Value + +data AccumulationContext + = AccumulationContext + { accViewportName :: Maybe String + , accOperations :: List FragmentOperation + } + + +data TextureDataType + = FloatT ColorArity + | IntT ColorArity + | WordT ColorArity + | ShadowT + +data TextureType + = Texture1D TextureDataType Int + | Texture2D TextureDataType Int + | Texture3D TextureDataType + | TextureCube TextureDataType + | TextureRect TextureDataType + | Texture2DMS TextureDataType Int Int Bool + | TextureBuffer TextureDataType + +data MipMap + = Mip Int Int + | NoMip + | AutoMip Int Int + +data Filter + = Nearest + | Linear + | NearestMipmapNearest + | NearestMipmapLinear + | LinearMipmapNearest + | LinearMipmapLinear + +data EdgeMode + = Repeat + | MirroredRepeat + | ClampToEdge + | ClampToBorder + +data ImageSemantic + = Depth + | Stencil + | Color + +data ImageRef + = TextureImage TextureName Int (Maybe Int) + | Framebuffer ImageSemantic + +data ClearImage + = ClearImage + { imageSemantic :: ImageSemantic + , clearValue :: Value + } + + +data Command + = SetRasterContext RasterContext + | SetAccumulationContext AccumulationContext + | SetRenderTarget RenderTargetName + | SetProgram ProgramName + | SetSamplerUniform UniformName TextureUnit + | SetTexture TextureUnit TextureName + | SetSampler TextureUnit (Maybe SamplerName) + | RenderSlot SlotName + | RenderStream StreamName + | ClearRenderTarget (Array ClearImage) + | GenerateMipMap TextureUnit + | SaveImage FrameBufferComponent ImageRef + | LoadImage ImageRef FrameBufferComponent + +data SamplerDescriptor + = SamplerDescriptor + { samplerWrapS :: EdgeMode + , samplerWrapT :: Maybe EdgeMode + , samplerWrapR :: Maybe EdgeMode + , samplerMinFilter :: Filter + , samplerMagFilter :: Filter + , samplerBorderColor :: Value + , samplerMinLod :: Maybe Float + , samplerMaxLod :: Maybe Float + , samplerLodBias :: Float + , samplerCompareFunc :: Maybe ComparisonFunction + } + + +data TextureDescriptor + = TextureDescriptor + { textureType :: TextureType + , textureSize :: Value + , textureSemantic :: ImageSemantic + , textureSampler :: SamplerDescriptor + , textureBaseLevel :: Int + , textureMaxLevel :: Int + } + + +data Parameter + = Parameter + { name :: String + , ty :: InputType + } + + +data Program + = Program + { programUniforms :: StrMap InputType + , programStreams :: StrMap Parameter + , programInTextures :: StrMap InputType + , programOutput :: Array Parameter + , vertexShader :: String + , geometryShader :: Maybe String + , fragmentShader :: String + } + + +data Slot + = Slot + { slotName :: String + , slotStreams :: StrMap InputType + , slotUniforms :: StrMap InputType + , slotPrimitive :: FetchPrimitive + , slotPrograms :: Array ProgramName + } + + +data StreamData + = StreamData + { streamData :: StrMap ArrayValue + , streamType :: StrMap InputType + , streamPrimitive :: FetchPrimitive + , streamPrograms :: Array ProgramName + } + + +data TargetItem + = TargetItem + { targetSemantic :: ImageSemantic + , targetRef :: Maybe ImageRef + } + + +data RenderTarget + = RenderTarget + { renderTargets :: Array TargetItem + } + + +data Backend + = WebGL1 + | OpenGL33 + +data Pipeline + = Pipeline + { backend :: Backend + , textures :: Array TextureDescriptor + , samplers :: Array SamplerDescriptor + , targets :: Array RenderTarget + , programs :: Array Program + , slots :: Array Slot + , streams :: Array StreamData + , commands :: Array Command + } + + + +derive instance genericInputType :: Generic InputType +instance showInputType :: Show InputType where show = gShow +instance eqInputType :: Eq InputType where eq = gEq + +derive instance genericFetchPrimitive :: Generic FetchPrimitive +instance showFetchPrimitive :: Show FetchPrimitive where show = gShow +instance eqFetchPrimitive :: Eq FetchPrimitive where eq = gEq + +derive instance genericColorArity :: Generic ColorArity +instance showColorArity :: Show ColorArity where show = gShow +instance eqColorArity :: Eq ColorArity where eq = gEq + +derive instance genericTextureDataType :: Generic TextureDataType +instance showTextureDataType :: Show TextureDataType where show = gShow +instance eqTextureDataType :: Eq TextureDataType where eq = gEq + +derive instance genericImageSemantic :: Generic ImageSemantic +instance showImageSemantic :: Show ImageSemantic where show = gShow +instance eqImageSemantic :: Eq ImageSemantic where eq = gEq + +derive instance genericPipeline :: Generic Pipeline +instance showPipeline :: Show Pipeline where show = gShow +instance eqPipeline :: Eq Pipeline where eq = gEq + + +instance encodeJsonArrayValue :: EncodeJson ArrayValue where + encodeJson v = case v of + VBoolArray arg0 -> "tag" := "VBoolArray" ~> "arg0" := arg0 ~> jsonEmptyObject + VIntArray arg0 -> "tag" := "VIntArray" ~> "arg0" := arg0 ~> jsonEmptyObject + VWordArray arg0 -> "tag" := "VWordArray" ~> "arg0" := arg0 ~> jsonEmptyObject + VFloatArray arg0 -> "tag" := "VFloatArray" ~> "arg0" := arg0 ~> jsonEmptyObject + +instance decodeJsonArrayValue :: DecodeJson ArrayValue where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "VBoolArray" -> VBoolArray <$> obj .? "arg0" + "VIntArray" -> VIntArray <$> obj .? "arg0" + "VWordArray" -> VWordArray <$> obj .? "arg0" + "VFloatArray" -> VFloatArray <$> obj .? "arg0" + +instance encodeJsonValue :: EncodeJson Value where + encodeJson v = case v of + VBool arg0 -> "tag" := "VBool" ~> "arg0" := arg0 ~> jsonEmptyObject + VV2B arg0 -> "tag" := "VV2B" ~> "arg0" := arg0 ~> jsonEmptyObject + VV3B arg0 -> "tag" := "VV3B" ~> "arg0" := arg0 ~> jsonEmptyObject + VV4B arg0 -> "tag" := "VV4B" ~> "arg0" := arg0 ~> jsonEmptyObject + VWord arg0 -> "tag" := "VWord" ~> "arg0" := arg0 ~> jsonEmptyObject + VV2U arg0 -> "tag" := "VV2U" ~> "arg0" := arg0 ~> jsonEmptyObject + VV3U arg0 -> "tag" := "VV3U" ~> "arg0" := arg0 ~> jsonEmptyObject + VV4U arg0 -> "tag" := "VV4U" ~> "arg0" := arg0 ~> jsonEmptyObject + VInt arg0 -> "tag" := "VInt" ~> "arg0" := arg0 ~> jsonEmptyObject + VV2I arg0 -> "tag" := "VV2I" ~> "arg0" := arg0 ~> jsonEmptyObject + VV3I arg0 -> "tag" := "VV3I" ~> "arg0" := arg0 ~> jsonEmptyObject + VV4I arg0 -> "tag" := "VV4I" ~> "arg0" := arg0 ~> jsonEmptyObject + VFloat arg0 -> "tag" := "VFloat" ~> "arg0" := arg0 ~> jsonEmptyObject + VV2F arg0 -> "tag" := "VV2F" ~> "arg0" := arg0 ~> jsonEmptyObject + VV3F arg0 -> "tag" := "VV3F" ~> "arg0" := arg0 ~> jsonEmptyObject + VV4F arg0 -> "tag" := "VV4F" ~> "arg0" := arg0 ~> jsonEmptyObject + VM22F arg0 -> "tag" := "VM22F" ~> "arg0" := arg0 ~> jsonEmptyObject + VM23F arg0 -> "tag" := "VM23F" ~> "arg0" := arg0 ~> jsonEmptyObject + VM24F arg0 -> "tag" := "VM24F" ~> "arg0" := arg0 ~> jsonEmptyObject + VM32F arg0 -> "tag" := "VM32F" ~> "arg0" := arg0 ~> jsonEmptyObject + VM33F arg0 -> "tag" := "VM33F" ~> "arg0" := arg0 ~> jsonEmptyObject + VM34F arg0 -> "tag" := "VM34F" ~> "arg0" := arg0 ~> jsonEmptyObject + VM42F arg0 -> "tag" := "VM42F" ~> "arg0" := arg0 ~> jsonEmptyObject + VM43F arg0 -> "tag" := "VM43F" ~> "arg0" := arg0 ~> jsonEmptyObject + VM44F arg0 -> "tag" := "VM44F" ~> "arg0" := arg0 ~> jsonEmptyObject + +instance decodeJsonValue :: DecodeJson Value where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "VBool" -> VBool <$> obj .? "arg0" + "VV2B" -> VV2B <$> obj .? "arg0" + "VV3B" -> VV3B <$> obj .? "arg0" + "VV4B" -> VV4B <$> obj .? "arg0" + "VWord" -> VWord <$> obj .? "arg0" + "VV2U" -> VV2U <$> obj .? "arg0" + "VV3U" -> VV3U <$> obj .? "arg0" + "VV4U" -> VV4U <$> obj .? "arg0" + "VInt" -> VInt <$> obj .? "arg0" + "VV2I" -> VV2I <$> obj .? "arg0" + "VV3I" -> VV3I <$> obj .? "arg0" + "VV4I" -> VV4I <$> obj .? "arg0" + "VFloat" -> VFloat <$> obj .? "arg0" + "VV2F" -> VV2F <$> obj .? "arg0" + "VV3F" -> VV3F <$> obj .? "arg0" + "VV4F" -> VV4F <$> obj .? "arg0" + "VM22F" -> VM22F <$> obj .? "arg0" + "VM23F" -> VM23F <$> obj .? "arg0" + "VM24F" -> VM24F <$> obj .? "arg0" + "VM32F" -> VM32F <$> obj .? "arg0" + "VM33F" -> VM33F <$> obj .? "arg0" + "VM34F" -> VM34F <$> obj .? "arg0" + "VM42F" -> VM42F <$> obj .? "arg0" + "VM43F" -> VM43F <$> obj .? "arg0" + "VM44F" -> VM44F <$> obj .? "arg0" + +instance encodeJsonInputType :: EncodeJson InputType where + encodeJson v = case v of + Bool -> "tag" := "Bool" ~> jsonEmptyObject + V2B -> "tag" := "V2B" ~> jsonEmptyObject + V3B -> "tag" := "V3B" ~> jsonEmptyObject + V4B -> "tag" := "V4B" ~> jsonEmptyObject + Word -> "tag" := "Word" ~> jsonEmptyObject + V2U -> "tag" := "V2U" ~> jsonEmptyObject + V3U -> "tag" := "V3U" ~> jsonEmptyObject + V4U -> "tag" := "V4U" ~> jsonEmptyObject + Int -> "tag" := "Int" ~> jsonEmptyObject + V2I -> "tag" := "V2I" ~> jsonEmptyObject + V3I -> "tag" := "V3I" ~> jsonEmptyObject + V4I -> "tag" := "V4I" ~> jsonEmptyObject + Float -> "tag" := "Float" ~> jsonEmptyObject + V2F -> "tag" := "V2F" ~> jsonEmptyObject + V3F -> "tag" := "V3F" ~> jsonEmptyObject + V4F -> "tag" := "V4F" ~> jsonEmptyObject + M22F -> "tag" := "M22F" ~> jsonEmptyObject + M23F -> "tag" := "M23F" ~> jsonEmptyObject + M24F -> "tag" := "M24F" ~> jsonEmptyObject + M32F -> "tag" := "M32F" ~> jsonEmptyObject + M33F -> "tag" := "M33F" ~> jsonEmptyObject + M34F -> "tag" := "M34F" ~> jsonEmptyObject + M42F -> "tag" := "M42F" ~> jsonEmptyObject + M43F -> "tag" := "M43F" ~> jsonEmptyObject + M44F -> "tag" := "M44F" ~> jsonEmptyObject + STexture1D -> "tag" := "STexture1D" ~> jsonEmptyObject + STexture2D -> "tag" := "STexture2D" ~> jsonEmptyObject + STextureCube -> "tag" := "STextureCube" ~> jsonEmptyObject + STexture1DArray -> "tag" := "STexture1DArray" ~> jsonEmptyObject + STexture2DArray -> "tag" := "STexture2DArray" ~> jsonEmptyObject + STexture2DRect -> "tag" := "STexture2DRect" ~> jsonEmptyObject + FTexture1D -> "tag" := "FTexture1D" ~> jsonEmptyObject + FTexture2D -> "tag" := "FTexture2D" ~> jsonEmptyObject + FTexture3D -> "tag" := "FTexture3D" ~> jsonEmptyObject + FTextureCube -> "tag" := "FTextureCube" ~> jsonEmptyObject + FTexture1DArray -> "tag" := "FTexture1DArray" ~> jsonEmptyObject + FTexture2DArray -> "tag" := "FTexture2DArray" ~> jsonEmptyObject + FTexture2DMS -> "tag" := "FTexture2DMS" ~> jsonEmptyObject + FTexture2DMSArray -> "tag" := "FTexture2DMSArray" ~> jsonEmptyObject + FTextureBuffer -> "tag" := "FTextureBuffer" ~> jsonEmptyObject + FTexture2DRect -> "tag" := "FTexture2DRect" ~> jsonEmptyObject + ITexture1D -> "tag" := "ITexture1D" ~> jsonEmptyObject + ITexture2D -> "tag" := "ITexture2D" ~> jsonEmptyObject + ITexture3D -> "tag" := "ITexture3D" ~> jsonEmptyObject + ITextureCube -> "tag" := "ITextureCube" ~> jsonEmptyObject + ITexture1DArray -> "tag" := "ITexture1DArray" ~> jsonEmptyObject + ITexture2DArray -> "tag" := "ITexture2DArray" ~> jsonEmptyObject + ITexture2DMS -> "tag" := "ITexture2DMS" ~> jsonEmptyObject + ITexture2DMSArray -> "tag" := "ITexture2DMSArray" ~> jsonEmptyObject + ITextureBuffer -> "tag" := "ITextureBuffer" ~> jsonEmptyObject + ITexture2DRect -> "tag" := "ITexture2DRect" ~> jsonEmptyObject + UTexture1D -> "tag" := "UTexture1D" ~> jsonEmptyObject + UTexture2D -> "tag" := "UTexture2D" ~> jsonEmptyObject + UTexture3D -> "tag" := "UTexture3D" ~> jsonEmptyObject + UTextureCube -> "tag" := "UTextureCube" ~> jsonEmptyObject + UTexture1DArray -> "tag" := "UTexture1DArray" ~> jsonEmptyObject + UTexture2DArray -> "tag" := "UTexture2DArray" ~> jsonEmptyObject + UTexture2DMS -> "tag" := "UTexture2DMS" ~> jsonEmptyObject + UTexture2DMSArray -> "tag" := "UTexture2DMSArray" ~> jsonEmptyObject + UTextureBuffer -> "tag" := "UTextureBuffer" ~> jsonEmptyObject + UTexture2DRect -> "tag" := "UTexture2DRect" ~> jsonEmptyObject + +instance decodeJsonInputType :: DecodeJson InputType where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "Bool" -> pure Bool + "V2B" -> pure V2B + "V3B" -> pure V3B + "V4B" -> pure V4B + "Word" -> pure Word + "V2U" -> pure V2U + "V3U" -> pure V3U + "V4U" -> pure V4U + "Int" -> pure Int + "V2I" -> pure V2I + "V3I" -> pure V3I + "V4I" -> pure V4I + "Float" -> pure Float + "V2F" -> pure V2F + "V3F" -> pure V3F + "V4F" -> pure V4F + "M22F" -> pure M22F + "M23F" -> pure M23F + "M24F" -> pure M24F + "M32F" -> pure M32F + "M33F" -> pure M33F + "M34F" -> pure M34F + "M42F" -> pure M42F + "M43F" -> pure M43F + "M44F" -> pure M44F + "STexture1D" -> pure STexture1D + "STexture2D" -> pure STexture2D + "STextureCube" -> pure STextureCube + "STexture1DArray" -> pure STexture1DArray + "STexture2DArray" -> pure STexture2DArray + "STexture2DRect" -> pure STexture2DRect + "FTexture1D" -> pure FTexture1D + "FTexture2D" -> pure FTexture2D + "FTexture3D" -> pure FTexture3D + "FTextureCube" -> pure FTextureCube + "FTexture1DArray" -> pure FTexture1DArray + "FTexture2DArray" -> pure FTexture2DArray + "FTexture2DMS" -> pure FTexture2DMS + "FTexture2DMSArray" -> pure FTexture2DMSArray + "FTextureBuffer" -> pure FTextureBuffer + "FTexture2DRect" -> pure FTexture2DRect + "ITexture1D" -> pure ITexture1D + "ITexture2D" -> pure ITexture2D + "ITexture3D" -> pure ITexture3D + "ITextureCube" -> pure ITextureCube + "ITexture1DArray" -> pure ITexture1DArray + "ITexture2DArray" -> pure ITexture2DArray + "ITexture2DMS" -> pure ITexture2DMS + "ITexture2DMSArray" -> pure ITexture2DMSArray + "ITextureBuffer" -> pure ITextureBuffer + "ITexture2DRect" -> pure ITexture2DRect + "UTexture1D" -> pure UTexture1D + "UTexture2D" -> pure UTexture2D + "UTexture3D" -> pure UTexture3D + "UTextureCube" -> pure UTextureCube + "UTexture1DArray" -> pure UTexture1DArray + "UTexture2DArray" -> pure UTexture2DArray + "UTexture2DMS" -> pure UTexture2DMS + "UTexture2DMSArray" -> pure UTexture2DMSArray + "UTextureBuffer" -> pure UTextureBuffer + "UTexture2DRect" -> pure UTexture2DRect + +instance encodeJsonPointSpriteCoordOrigin :: EncodeJson PointSpriteCoordOrigin where + encodeJson v = case v of + LowerLeft -> "tag" := "LowerLeft" ~> jsonEmptyObject + UpperLeft -> "tag" := "UpperLeft" ~> jsonEmptyObject + +instance decodeJsonPointSpriteCoordOrigin :: DecodeJson PointSpriteCoordOrigin where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "LowerLeft" -> pure LowerLeft + "UpperLeft" -> pure UpperLeft + +instance encodeJsonPointSize :: EncodeJson PointSize where + encodeJson v = case v of + PointSize arg0 -> "tag" := "PointSize" ~> "arg0" := arg0 ~> jsonEmptyObject + ProgramPointSize -> "tag" := "ProgramPointSize" ~> jsonEmptyObject + +instance decodeJsonPointSize :: DecodeJson PointSize where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "PointSize" -> PointSize <$> obj .? "arg0" + "ProgramPointSize" -> pure ProgramPointSize + +instance encodeJsonPolygonOffset :: EncodeJson PolygonOffset where + encodeJson v = case v of + NoOffset -> "tag" := "NoOffset" ~> jsonEmptyObject + Offset arg0 arg1 -> "tag" := "Offset" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject + +instance decodeJsonPolygonOffset :: DecodeJson PolygonOffset where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "NoOffset" -> pure NoOffset + "Offset" -> Offset <$> obj .? "arg0" <*> obj .? "arg1" + +instance encodeJsonFrontFace :: EncodeJson FrontFace where + encodeJson v = case v of + CCW -> "tag" := "CCW" ~> jsonEmptyObject + CW -> "tag" := "CW" ~> jsonEmptyObject + +instance decodeJsonFrontFace :: DecodeJson FrontFace where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "CCW" -> pure CCW + "CW" -> pure CW + +instance encodeJsonPolygonMode :: EncodeJson PolygonMode where + encodeJson v = case v of + PolygonPoint arg0 -> "tag" := "PolygonPoint" ~> "arg0" := arg0 ~> jsonEmptyObject + PolygonLine arg0 -> "tag" := "PolygonLine" ~> "arg0" := arg0 ~> jsonEmptyObject + PolygonFill -> "tag" := "PolygonFill" ~> jsonEmptyObject + +instance decodeJsonPolygonMode :: DecodeJson PolygonMode where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "PolygonPoint" -> PolygonPoint <$> obj .? "arg0" + "PolygonLine" -> PolygonLine <$> obj .? "arg0" + "PolygonFill" -> pure PolygonFill + +instance encodeJsonProvokingVertex :: EncodeJson ProvokingVertex where + encodeJson v = case v of + FirstVertex -> "tag" := "FirstVertex" ~> jsonEmptyObject + LastVertex -> "tag" := "LastVertex" ~> jsonEmptyObject + +instance decodeJsonProvokingVertex :: DecodeJson ProvokingVertex where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "FirstVertex" -> pure FirstVertex + "LastVertex" -> pure LastVertex + +instance encodeJsonCullMode :: EncodeJson CullMode where + encodeJson v = case v of + CullNone -> "tag" := "CullNone" ~> jsonEmptyObject + CullFront arg0 -> "tag" := "CullFront" ~> "arg0" := arg0 ~> jsonEmptyObject + CullBack arg0 -> "tag" := "CullBack" ~> "arg0" := arg0 ~> jsonEmptyObject + +instance decodeJsonCullMode :: DecodeJson CullMode where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "CullNone" -> pure CullNone + "CullFront" -> CullFront <$> obj .? "arg0" + "CullBack" -> CullBack <$> obj .? "arg0" + +instance encodeJsonComparisonFunction :: EncodeJson ComparisonFunction where + encodeJson v = case v of + Never -> "tag" := "Never" ~> jsonEmptyObject + Less -> "tag" := "Less" ~> jsonEmptyObject + Equal -> "tag" := "Equal" ~> jsonEmptyObject + Lequal -> "tag" := "Lequal" ~> jsonEmptyObject + Greater -> "tag" := "Greater" ~> jsonEmptyObject + Notequal -> "tag" := "Notequal" ~> jsonEmptyObject + Gequal -> "tag" := "Gequal" ~> jsonEmptyObject + Always -> "tag" := "Always" ~> jsonEmptyObject + +instance decodeJsonComparisonFunction :: DecodeJson ComparisonFunction where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "Never" -> pure Never + "Less" -> pure Less + "Equal" -> pure Equal + "Lequal" -> pure Lequal + "Greater" -> pure Greater + "Notequal" -> pure Notequal + "Gequal" -> pure Gequal + "Always" -> pure Always + +instance encodeJsonStencilOperation :: EncodeJson StencilOperation where + encodeJson v = case v of + OpZero -> "tag" := "OpZero" ~> jsonEmptyObject + OpKeep -> "tag" := "OpKeep" ~> jsonEmptyObject + OpReplace -> "tag" := "OpReplace" ~> jsonEmptyObject + OpIncr -> "tag" := "OpIncr" ~> jsonEmptyObject + OpIncrWrap -> "tag" := "OpIncrWrap" ~> jsonEmptyObject + OpDecr -> "tag" := "OpDecr" ~> jsonEmptyObject + OpDecrWrap -> "tag" := "OpDecrWrap" ~> jsonEmptyObject + OpInvert -> "tag" := "OpInvert" ~> jsonEmptyObject + +instance decodeJsonStencilOperation :: DecodeJson StencilOperation where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "OpZero" -> pure OpZero + "OpKeep" -> pure OpKeep + "OpReplace" -> pure OpReplace + "OpIncr" -> pure OpIncr + "OpIncrWrap" -> pure OpIncrWrap + "OpDecr" -> pure OpDecr + "OpDecrWrap" -> pure OpDecrWrap + "OpInvert" -> pure OpInvert + +instance encodeJsonBlendEquation :: EncodeJson BlendEquation where + encodeJson v = case v of + FuncAdd -> "tag" := "FuncAdd" ~> jsonEmptyObject + FuncSubtract -> "tag" := "FuncSubtract" ~> jsonEmptyObject + FuncReverseSubtract -> "tag" := "FuncReverseSubtract" ~> jsonEmptyObject + Min -> "tag" := "Min" ~> jsonEmptyObject + Max -> "tag" := "Max" ~> jsonEmptyObject + +instance decodeJsonBlendEquation :: DecodeJson BlendEquation where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "FuncAdd" -> pure FuncAdd + "FuncSubtract" -> pure FuncSubtract + "FuncReverseSubtract" -> pure FuncReverseSubtract + "Min" -> pure Min + "Max" -> pure Max + +instance encodeJsonBlendingFactor :: EncodeJson BlendingFactor where + encodeJson v = case v of + Zero -> "tag" := "Zero" ~> jsonEmptyObject + One -> "tag" := "One" ~> jsonEmptyObject + SrcColor -> "tag" := "SrcColor" ~> jsonEmptyObject + OneMinusSrcColor -> "tag" := "OneMinusSrcColor" ~> jsonEmptyObject + DstColor -> "tag" := "DstColor" ~> jsonEmptyObject + OneMinusDstColor -> "tag" := "OneMinusDstColor" ~> jsonEmptyObject + SrcAlpha -> "tag" := "SrcAlpha" ~> jsonEmptyObject + OneMinusSrcAlpha -> "tag" := "OneMinusSrcAlpha" ~> jsonEmptyObject + DstAlpha -> "tag" := "DstAlpha" ~> jsonEmptyObject + OneMinusDstAlpha -> "tag" := "OneMinusDstAlpha" ~> jsonEmptyObject + ConstantColor -> "tag" := "ConstantColor" ~> jsonEmptyObject + OneMinusConstantColor -> "tag" := "OneMinusConstantColor" ~> jsonEmptyObject + ConstantAlpha -> "tag" := "ConstantAlpha" ~> jsonEmptyObject + OneMinusConstantAlpha -> "tag" := "OneMinusConstantAlpha" ~> jsonEmptyObject + SrcAlphaSaturate -> "tag" := "SrcAlphaSaturate" ~> jsonEmptyObject + +instance decodeJsonBlendingFactor :: DecodeJson BlendingFactor where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "Zero" -> pure Zero + "One" -> pure One + "SrcColor" -> pure SrcColor + "OneMinusSrcColor" -> pure OneMinusSrcColor + "DstColor" -> pure DstColor + "OneMinusDstColor" -> pure OneMinusDstColor + "SrcAlpha" -> pure SrcAlpha + "OneMinusSrcAlpha" -> pure OneMinusSrcAlpha + "DstAlpha" -> pure DstAlpha + "OneMinusDstAlpha" -> pure OneMinusDstAlpha + "ConstantColor" -> pure ConstantColor + "OneMinusConstantColor" -> pure OneMinusConstantColor + "ConstantAlpha" -> pure ConstantAlpha + "OneMinusConstantAlpha" -> pure OneMinusConstantAlpha + "SrcAlphaSaturate" -> pure SrcAlphaSaturate + +instance encodeJsonLogicOperation :: EncodeJson LogicOperation where + encodeJson v = case v of + Clear -> "tag" := "Clear" ~> jsonEmptyObject + And -> "tag" := "And" ~> jsonEmptyObject + AndReverse -> "tag" := "AndReverse" ~> jsonEmptyObject + Copy -> "tag" := "Copy" ~> jsonEmptyObject + AndInverted -> "tag" := "AndInverted" ~> jsonEmptyObject + Noop -> "tag" := "Noop" ~> jsonEmptyObject + Xor -> "tag" := "Xor" ~> jsonEmptyObject + Or -> "tag" := "Or" ~> jsonEmptyObject + Nor -> "tag" := "Nor" ~> jsonEmptyObject + Equiv -> "tag" := "Equiv" ~> jsonEmptyObject + Invert -> "tag" := "Invert" ~> jsonEmptyObject + OrReverse -> "tag" := "OrReverse" ~> jsonEmptyObject + CopyInverted -> "tag" := "CopyInverted" ~> jsonEmptyObject + OrInverted -> "tag" := "OrInverted" ~> jsonEmptyObject + Nand -> "tag" := "Nand" ~> jsonEmptyObject + Set -> "tag" := "Set" ~> jsonEmptyObject + +instance decodeJsonLogicOperation :: DecodeJson LogicOperation where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "Clear" -> pure Clear + "And" -> pure And + "AndReverse" -> pure AndReverse + "Copy" -> pure Copy + "AndInverted" -> pure AndInverted + "Noop" -> pure Noop + "Xor" -> pure Xor + "Or" -> pure Or + "Nor" -> pure Nor + "Equiv" -> pure Equiv + "Invert" -> pure Invert + "OrReverse" -> pure OrReverse + "CopyInverted" -> pure CopyInverted + "OrInverted" -> pure OrInverted + "Nand" -> pure Nand + "Set" -> pure Set + +instance encodeJsonStencilOps :: EncodeJson StencilOps where + encodeJson v = case v of + StencilOps r -> + "tag" := "StencilOps" ~> + "frontStencilOp" := r.frontStencilOp ~> + "backStencilOp" := r.backStencilOp ~> + jsonEmptyObject + +instance decodeJsonStencilOps :: DecodeJson StencilOps where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "StencilOps" -> do + frontStencilOp <- obj .? "frontStencilOp" + backStencilOp <- obj .? "backStencilOp" + pure $ StencilOps + { frontStencilOp:frontStencilOp + , backStencilOp:backStencilOp + } + +instance encodeJsonStencilTest :: EncodeJson StencilTest where + encodeJson v = case v of + StencilTest r -> + "tag" := "StencilTest" ~> + "stencilComparision" := r.stencilComparision ~> + "stencilReference" := r.stencilReference ~> + "stencilMask" := r.stencilMask ~> + jsonEmptyObject + +instance decodeJsonStencilTest :: DecodeJson StencilTest where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "StencilTest" -> do + stencilComparision <- obj .? "stencilComparision" + stencilReference <- obj .? "stencilReference" + stencilMask <- obj .? "stencilMask" + pure $ StencilTest + { stencilComparision:stencilComparision + , stencilReference:stencilReference + , stencilMask:stencilMask + } + +instance encodeJsonStencilTests :: EncodeJson StencilTests where + encodeJson v = case v of + StencilTests arg0 arg1 -> "tag" := "StencilTests" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject + +instance decodeJsonStencilTests :: DecodeJson StencilTests where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "StencilTests" -> StencilTests <$> obj .? "arg0" <*> obj .? "arg1" + +instance encodeJsonFetchPrimitive :: EncodeJson FetchPrimitive where + encodeJson v = case v of + Points -> "tag" := "Points" ~> jsonEmptyObject + Lines -> "tag" := "Lines" ~> jsonEmptyObject + Triangles -> "tag" := "Triangles" ~> jsonEmptyObject + LinesAdjacency -> "tag" := "LinesAdjacency" ~> jsonEmptyObject + TrianglesAdjacency -> "tag" := "TrianglesAdjacency" ~> jsonEmptyObject + +instance decodeJsonFetchPrimitive :: DecodeJson FetchPrimitive where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "Points" -> pure Points + "Lines" -> pure Lines + "Triangles" -> pure Triangles + "LinesAdjacency" -> pure LinesAdjacency + "TrianglesAdjacency" -> pure TrianglesAdjacency + +instance encodeJsonOutputPrimitive :: EncodeJson OutputPrimitive where + encodeJson v = case v of + TrianglesOutput -> "tag" := "TrianglesOutput" ~> jsonEmptyObject + LinesOutput -> "tag" := "LinesOutput" ~> jsonEmptyObject + PointsOutput -> "tag" := "PointsOutput" ~> jsonEmptyObject + +instance decodeJsonOutputPrimitive :: DecodeJson OutputPrimitive where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "TrianglesOutput" -> pure TrianglesOutput + "LinesOutput" -> pure LinesOutput + "PointsOutput" -> pure PointsOutput + +instance encodeJsonColorArity :: EncodeJson ColorArity where + encodeJson v = case v of + Red -> "tag" := "Red" ~> jsonEmptyObject + RG -> "tag" := "RG" ~> jsonEmptyObject + RGB -> "tag" := "RGB" ~> jsonEmptyObject + RGBA -> "tag" := "RGBA" ~> jsonEmptyObject + +instance decodeJsonColorArity :: DecodeJson ColorArity where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "Red" -> pure Red + "RG" -> pure RG + "RGB" -> pure RGB + "RGBA" -> pure RGBA + +instance encodeJsonBlending :: EncodeJson Blending where + encodeJson v = case v of + NoBlending -> "tag" := "NoBlending" ~> jsonEmptyObject + BlendLogicOp arg0 -> "tag" := "BlendLogicOp" ~> "arg0" := arg0 ~> jsonEmptyObject + Blend r -> + "tag" := "Blend" ~> + "colorEqSrc" := r.colorEqSrc ~> + "alphaEqSrc" := r.alphaEqSrc ~> + "colorFSrc" := r.colorFSrc ~> + "colorFDst" := r.colorFDst ~> + "alphaFSrc" := r.alphaFSrc ~> + "alphaFDst" := r.alphaFDst ~> + "color" := r.color ~> + jsonEmptyObject + +instance decodeJsonBlending :: DecodeJson Blending where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "NoBlending" -> pure NoBlending + "BlendLogicOp" -> BlendLogicOp <$> obj .? "arg0" + "Blend" -> do + colorEqSrc <- obj .? "colorEqSrc" + alphaEqSrc <- obj .? "alphaEqSrc" + colorFSrc <- obj .? "colorFSrc" + colorFDst <- obj .? "colorFDst" + alphaFSrc <- obj .? "alphaFSrc" + alphaFDst <- obj .? "alphaFDst" + color <- obj .? "color" + pure $ Blend + { colorEqSrc:colorEqSrc + , alphaEqSrc:alphaEqSrc + , colorFSrc:colorFSrc + , colorFDst:colorFDst + , alphaFSrc:alphaFSrc + , alphaFDst:alphaFDst + , color:color + } + +instance encodeJsonRasterContext :: EncodeJson RasterContext where + encodeJson v = case v of + PointCtx arg0 arg1 arg2 -> "tag" := "PointCtx" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> "arg2" := arg2 ~> jsonEmptyObject + LineCtx arg0 arg1 -> "tag" := "LineCtx" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject + TriangleCtx arg0 arg1 arg2 arg3 -> "tag" := "TriangleCtx" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> "arg2" := arg2 ~> "arg3" := arg3 ~> jsonEmptyObject + +instance decodeJsonRasterContext :: DecodeJson RasterContext where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "PointCtx" -> PointCtx <$> obj .? "arg0" <*> obj .? "arg1" <*> obj .? "arg2" + "LineCtx" -> LineCtx <$> obj .? "arg0" <*> obj .? "arg1" + "TriangleCtx" -> TriangleCtx <$> obj .? "arg0" <*> obj .? "arg1" <*> obj .? "arg2" <*> obj .? "arg3" + +instance encodeJsonFragmentOperation :: EncodeJson FragmentOperation where + encodeJson v = case v of + DepthOp arg0 arg1 -> "tag" := "DepthOp" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject + StencilOp arg0 arg1 arg2 -> "tag" := "StencilOp" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> "arg2" := arg2 ~> jsonEmptyObject + ColorOp arg0 arg1 -> "tag" := "ColorOp" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject + +instance decodeJsonFragmentOperation :: DecodeJson FragmentOperation where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "DepthOp" -> DepthOp <$> obj .? "arg0" <*> obj .? "arg1" + "StencilOp" -> StencilOp <$> obj .? "arg0" <*> obj .? "arg1" <*> obj .? "arg2" + "ColorOp" -> ColorOp <$> obj .? "arg0" <*> obj .? "arg1" + +instance encodeJsonAccumulationContext :: EncodeJson AccumulationContext where + encodeJson v = case v of + AccumulationContext r -> + "tag" := "AccumulationContext" ~> + "accViewportName" := r.accViewportName ~> + "accOperations" := r.accOperations ~> + jsonEmptyObject + +instance decodeJsonAccumulationContext :: DecodeJson AccumulationContext where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "AccumulationContext" -> do + accViewportName <- obj .? "accViewportName" + accOperations <- obj .? "accOperations" + pure $ AccumulationContext + { accViewportName:accViewportName + , accOperations:accOperations + } + +instance encodeJsonTextureDataType :: EncodeJson TextureDataType where + encodeJson v = case v of + FloatT arg0 -> "tag" := "FloatT" ~> "arg0" := arg0 ~> jsonEmptyObject + IntT arg0 -> "tag" := "IntT" ~> "arg0" := arg0 ~> jsonEmptyObject + WordT arg0 -> "tag" := "WordT" ~> "arg0" := arg0 ~> jsonEmptyObject + ShadowT -> "tag" := "ShadowT" ~> jsonEmptyObject + +instance decodeJsonTextureDataType :: DecodeJson TextureDataType where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "FloatT" -> FloatT <$> obj .? "arg0" + "IntT" -> IntT <$> obj .? "arg0" + "WordT" -> WordT <$> obj .? "arg0" + "ShadowT" -> pure ShadowT + +instance encodeJsonTextureType :: EncodeJson TextureType where + encodeJson v = case v of + Texture1D arg0 arg1 -> "tag" := "Texture1D" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject + Texture2D arg0 arg1 -> "tag" := "Texture2D" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject + Texture3D arg0 -> "tag" := "Texture3D" ~> "arg0" := arg0 ~> jsonEmptyObject + TextureCube arg0 -> "tag" := "TextureCube" ~> "arg0" := arg0 ~> jsonEmptyObject + TextureRect arg0 -> "tag" := "TextureRect" ~> "arg0" := arg0 ~> jsonEmptyObject + Texture2DMS arg0 arg1 arg2 arg3 -> "tag" := "Texture2DMS" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> "arg2" := arg2 ~> "arg3" := arg3 ~> jsonEmptyObject + TextureBuffer arg0 -> "tag" := "TextureBuffer" ~> "arg0" := arg0 ~> jsonEmptyObject + +instance decodeJsonTextureType :: DecodeJson TextureType where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "Texture1D" -> Texture1D <$> obj .? "arg0" <*> obj .? "arg1" + "Texture2D" -> Texture2D <$> obj .? "arg0" <*> obj .? "arg1" + "Texture3D" -> Texture3D <$> obj .? "arg0" + "TextureCube" -> TextureCube <$> obj .? "arg0" + "TextureRect" -> TextureRect <$> obj .? "arg0" + "Texture2DMS" -> Texture2DMS <$> obj .? "arg0" <*> obj .? "arg1" <*> obj .? "arg2" <*> obj .? "arg3" + "TextureBuffer" -> TextureBuffer <$> obj .? "arg0" + +instance encodeJsonMipMap :: EncodeJson MipMap where + encodeJson v = case v of + Mip arg0 arg1 -> "tag" := "Mip" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject + NoMip -> "tag" := "NoMip" ~> jsonEmptyObject + AutoMip arg0 arg1 -> "tag" := "AutoMip" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject + +instance decodeJsonMipMap :: DecodeJson MipMap where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "Mip" -> Mip <$> obj .? "arg0" <*> obj .? "arg1" + "NoMip" -> pure NoMip + "AutoMip" -> AutoMip <$> obj .? "arg0" <*> obj .? "arg1" + +instance encodeJsonFilter :: EncodeJson Filter where + encodeJson v = case v of + Nearest -> "tag" := "Nearest" ~> jsonEmptyObject + Linear -> "tag" := "Linear" ~> jsonEmptyObject + NearestMipmapNearest -> "tag" := "NearestMipmapNearest" ~> jsonEmptyObject + NearestMipmapLinear -> "tag" := "NearestMipmapLinear" ~> jsonEmptyObject + LinearMipmapNearest -> "tag" := "LinearMipmapNearest" ~> jsonEmptyObject + LinearMipmapLinear -> "tag" := "LinearMipmapLinear" ~> jsonEmptyObject + +instance decodeJsonFilter :: DecodeJson Filter where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "Nearest" -> pure Nearest + "Linear" -> pure Linear + "NearestMipmapNearest" -> pure NearestMipmapNearest + "NearestMipmapLinear" -> pure NearestMipmapLinear + "LinearMipmapNearest" -> pure LinearMipmapNearest + "LinearMipmapLinear" -> pure LinearMipmapLinear + +instance encodeJsonEdgeMode :: EncodeJson EdgeMode where + encodeJson v = case v of + Repeat -> "tag" := "Repeat" ~> jsonEmptyObject + MirroredRepeat -> "tag" := "MirroredRepeat" ~> jsonEmptyObject + ClampToEdge -> "tag" := "ClampToEdge" ~> jsonEmptyObject + ClampToBorder -> "tag" := "ClampToBorder" ~> jsonEmptyObject + +instance decodeJsonEdgeMode :: DecodeJson EdgeMode where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "Repeat" -> pure Repeat + "MirroredRepeat" -> pure MirroredRepeat + "ClampToEdge" -> pure ClampToEdge + "ClampToBorder" -> pure ClampToBorder + +instance encodeJsonImageSemantic :: EncodeJson ImageSemantic where + encodeJson v = case v of + Depth -> "tag" := "Depth" ~> jsonEmptyObject + Stencil -> "tag" := "Stencil" ~> jsonEmptyObject + Color -> "tag" := "Color" ~> jsonEmptyObject + +instance decodeJsonImageSemantic :: DecodeJson ImageSemantic where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "Depth" -> pure Depth + "Stencil" -> pure Stencil + "Color" -> pure Color + +instance encodeJsonImageRef :: EncodeJson ImageRef where + encodeJson v = case v of + TextureImage arg0 arg1 arg2 -> "tag" := "TextureImage" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> "arg2" := arg2 ~> jsonEmptyObject + Framebuffer arg0 -> "tag" := "Framebuffer" ~> "arg0" := arg0 ~> jsonEmptyObject + +instance decodeJsonImageRef :: DecodeJson ImageRef where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "TextureImage" -> TextureImage <$> obj .? "arg0" <*> obj .? "arg1" <*> obj .? "arg2" + "Framebuffer" -> Framebuffer <$> obj .? "arg0" + +instance encodeJsonClearImage :: EncodeJson ClearImage where + encodeJson v = case v of + ClearImage r -> + "tag" := "ClearImage" ~> + "imageSemantic" := r.imageSemantic ~> + "clearValue" := r.clearValue ~> + jsonEmptyObject + +instance decodeJsonClearImage :: DecodeJson ClearImage where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "ClearImage" -> do + imageSemantic <- obj .? "imageSemantic" + clearValue <- obj .? "clearValue" + pure $ ClearImage + { imageSemantic:imageSemantic + , clearValue:clearValue + } + +instance encodeJsonCommand :: EncodeJson Command where + encodeJson v = case v of + SetRasterContext arg0 -> "tag" := "SetRasterContext" ~> "arg0" := arg0 ~> jsonEmptyObject + SetAccumulationContext arg0 -> "tag" := "SetAccumulationContext" ~> "arg0" := arg0 ~> jsonEmptyObject + SetRenderTarget arg0 -> "tag" := "SetRenderTarget" ~> "arg0" := arg0 ~> jsonEmptyObject + SetProgram arg0 -> "tag" := "SetProgram" ~> "arg0" := arg0 ~> jsonEmptyObject + SetSamplerUniform arg0 arg1 -> "tag" := "SetSamplerUniform" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject + SetTexture arg0 arg1 -> "tag" := "SetTexture" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject + SetSampler arg0 arg1 -> "tag" := "SetSampler" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject + RenderSlot arg0 -> "tag" := "RenderSlot" ~> "arg0" := arg0 ~> jsonEmptyObject + RenderStream arg0 -> "tag" := "RenderStream" ~> "arg0" := arg0 ~> jsonEmptyObject + ClearRenderTarget arg0 -> "tag" := "ClearRenderTarget" ~> "arg0" := arg0 ~> jsonEmptyObject + GenerateMipMap arg0 -> "tag" := "GenerateMipMap" ~> "arg0" := arg0 ~> jsonEmptyObject + SaveImage arg0 arg1 -> "tag" := "SaveImage" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject + LoadImage arg0 arg1 -> "tag" := "LoadImage" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject + +instance decodeJsonCommand :: DecodeJson Command where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "SetRasterContext" -> SetRasterContext <$> obj .? "arg0" + "SetAccumulationContext" -> SetAccumulationContext <$> obj .? "arg0" + "SetRenderTarget" -> SetRenderTarget <$> obj .? "arg0" + "SetProgram" -> SetProgram <$> obj .? "arg0" + "SetSamplerUniform" -> SetSamplerUniform <$> obj .? "arg0" <*> obj .? "arg1" + "SetTexture" -> SetTexture <$> obj .? "arg0" <*> obj .? "arg1" + "SetSampler" -> SetSampler <$> obj .? "arg0" <*> obj .? "arg1" + "RenderSlot" -> RenderSlot <$> obj .? "arg0" + "RenderStream" -> RenderStream <$> obj .? "arg0" + "ClearRenderTarget" -> ClearRenderTarget <$> obj .? "arg0" + "GenerateMipMap" -> GenerateMipMap <$> obj .? "arg0" + "SaveImage" -> SaveImage <$> obj .? "arg0" <*> obj .? "arg1" + "LoadImage" -> LoadImage <$> obj .? "arg0" <*> obj .? "arg1" + +instance encodeJsonSamplerDescriptor :: EncodeJson SamplerDescriptor where + encodeJson v = case v of + SamplerDescriptor r -> + "tag" := "SamplerDescriptor" ~> + "samplerWrapS" := r.samplerWrapS ~> + "samplerWrapT" := r.samplerWrapT ~> + "samplerWrapR" := r.samplerWrapR ~> + "samplerMinFilter" := r.samplerMinFilter ~> + "samplerMagFilter" := r.samplerMagFilter ~> + "samplerBorderColor" := r.samplerBorderColor ~> + "samplerMinLod" := r.samplerMinLod ~> + "samplerMaxLod" := r.samplerMaxLod ~> + "samplerLodBias" := r.samplerLodBias ~> + "samplerCompareFunc" := r.samplerCompareFunc ~> + jsonEmptyObject + +instance decodeJsonSamplerDescriptor :: DecodeJson SamplerDescriptor where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "SamplerDescriptor" -> do + samplerWrapS <- obj .? "samplerWrapS" + samplerWrapT <- obj .? "samplerWrapT" + samplerWrapR <- obj .? "samplerWrapR" + samplerMinFilter <- obj .? "samplerMinFilter" + samplerMagFilter <- obj .? "samplerMagFilter" + samplerBorderColor <- obj .? "samplerBorderColor" + samplerMinLod <- obj .? "samplerMinLod" + samplerMaxLod <- obj .? "samplerMaxLod" + samplerLodBias <- obj .? "samplerLodBias" + samplerCompareFunc <- obj .? "samplerCompareFunc" + pure $ SamplerDescriptor + { samplerWrapS:samplerWrapS + , samplerWrapT:samplerWrapT + , samplerWrapR:samplerWrapR + , samplerMinFilter:samplerMinFilter + , samplerMagFilter:samplerMagFilter + , samplerBorderColor:samplerBorderColor + , samplerMinLod:samplerMinLod + , samplerMaxLod:samplerMaxLod + , samplerLodBias:samplerLodBias + , samplerCompareFunc:samplerCompareFunc + } + +instance encodeJsonTextureDescriptor :: EncodeJson TextureDescriptor where + encodeJson v = case v of + TextureDescriptor r -> + "tag" := "TextureDescriptor" ~> + "textureType" := r.textureType ~> + "textureSize" := r.textureSize ~> + "textureSemantic" := r.textureSemantic ~> + "textureSampler" := r.textureSampler ~> + "textureBaseLevel" := r.textureBaseLevel ~> + "textureMaxLevel" := r.textureMaxLevel ~> + jsonEmptyObject + +instance decodeJsonTextureDescriptor :: DecodeJson TextureDescriptor where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "TextureDescriptor" -> do + textureType <- obj .? "textureType" + textureSize <- obj .? "textureSize" + textureSemantic <- obj .? "textureSemantic" + textureSampler <- obj .? "textureSampler" + textureBaseLevel <- obj .? "textureBaseLevel" + textureMaxLevel <- obj .? "textureMaxLevel" + pure $ TextureDescriptor + { textureType:textureType + , textureSize:textureSize + , textureSemantic:textureSemantic + , textureSampler:textureSampler + , textureBaseLevel:textureBaseLevel + , textureMaxLevel:textureMaxLevel + } + +instance encodeJsonParameter :: EncodeJson Parameter where + encodeJson v = case v of + Parameter r -> + "tag" := "Parameter" ~> + "name" := r.name ~> + "ty" := r.ty ~> + jsonEmptyObject + +instance decodeJsonParameter :: DecodeJson Parameter where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "Parameter" -> do + name <- obj .? "name" + ty <- obj .? "ty" + pure $ Parameter + { name:name + , ty:ty + } + +instance encodeJsonProgram :: EncodeJson Program where + encodeJson v = case v of + Program r -> + "tag" := "Program" ~> + "programUniforms" := r.programUniforms ~> + "programStreams" := r.programStreams ~> + "programInTextures" := r.programInTextures ~> + "programOutput" := r.programOutput ~> + "vertexShader" := r.vertexShader ~> + "geometryShader" := r.geometryShader ~> + "fragmentShader" := r.fragmentShader ~> + jsonEmptyObject + +instance decodeJsonProgram :: DecodeJson Program where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "Program" -> do + programUniforms <- obj .? "programUniforms" + programStreams <- obj .? "programStreams" + programInTextures <- obj .? "programInTextures" + programOutput <- obj .? "programOutput" + vertexShader <- obj .? "vertexShader" + geometryShader <- obj .? "geometryShader" + fragmentShader <- obj .? "fragmentShader" + pure $ Program + { programUniforms:programUniforms + , programStreams:programStreams + , programInTextures:programInTextures + , programOutput:programOutput + , vertexShader:vertexShader + , geometryShader:geometryShader + , fragmentShader:fragmentShader + } + +instance encodeJsonSlot :: EncodeJson Slot where + encodeJson v = case v of + Slot r -> + "tag" := "Slot" ~> + "slotName" := r.slotName ~> + "slotStreams" := r.slotStreams ~> + "slotUniforms" := r.slotUniforms ~> + "slotPrimitive" := r.slotPrimitive ~> + "slotPrograms" := r.slotPrograms ~> + jsonEmptyObject + +instance decodeJsonSlot :: DecodeJson Slot where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "Slot" -> do + slotName <- obj .? "slotName" + slotStreams <- obj .? "slotStreams" + slotUniforms <- obj .? "slotUniforms" + slotPrimitive <- obj .? "slotPrimitive" + slotPrograms <- obj .? "slotPrograms" + pure $ Slot + { slotName:slotName + , slotStreams:slotStreams + , slotUniforms:slotUniforms + , slotPrimitive:slotPrimitive + , slotPrograms:slotPrograms + } + +instance encodeJsonStreamData :: EncodeJson StreamData where + encodeJson v = case v of + StreamData r -> + "tag" := "StreamData" ~> + "streamData" := r.streamData ~> + "streamType" := r.streamType ~> + "streamPrimitive" := r.streamPrimitive ~> + "streamPrograms" := r.streamPrograms ~> + jsonEmptyObject + +instance decodeJsonStreamData :: DecodeJson StreamData where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "StreamData" -> do + streamData <- obj .? "streamData" + streamType <- obj .? "streamType" + streamPrimitive <- obj .? "streamPrimitive" + streamPrograms <- obj .? "streamPrograms" + pure $ StreamData + { streamData:streamData + , streamType:streamType + , streamPrimitive:streamPrimitive + , streamPrograms:streamPrograms + } + +instance encodeJsonTargetItem :: EncodeJson TargetItem where + encodeJson v = case v of + TargetItem r -> + "tag" := "TargetItem" ~> + "targetSemantic" := r.targetSemantic ~> + "targetRef" := r.targetRef ~> + jsonEmptyObject + +instance decodeJsonTargetItem :: DecodeJson TargetItem where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "TargetItem" -> do + targetSemantic <- obj .? "targetSemantic" + targetRef <- obj .? "targetRef" + pure $ TargetItem + { targetSemantic:targetSemantic + , targetRef:targetRef + } + +instance encodeJsonRenderTarget :: EncodeJson RenderTarget where + encodeJson v = case v of + RenderTarget r -> + "tag" := "RenderTarget" ~> + "renderTargets" := r.renderTargets ~> + jsonEmptyObject + +instance decodeJsonRenderTarget :: DecodeJson RenderTarget where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "RenderTarget" -> do + renderTargets <- obj .? "renderTargets" + pure $ RenderTarget + { renderTargets:renderTargets + } + +instance encodeJsonBackend :: EncodeJson Backend where + encodeJson v = case v of + WebGL1 -> "tag" := "WebGL1" ~> jsonEmptyObject + OpenGL33 -> "tag" := "OpenGL33" ~> jsonEmptyObject + +instance decodeJsonBackend :: DecodeJson Backend where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "WebGL1" -> pure WebGL1 + "OpenGL33" -> pure OpenGL33 + +instance encodeJsonPipeline :: EncodeJson Pipeline where + encodeJson v = case v of + Pipeline r -> + "tag" := "Pipeline" ~> + "backend" := r.backend ~> + "textures" := r.textures ~> + "samplers" := r.samplers ~> + "targets" := r.targets ~> + "programs" := r.programs ~> + "slots" := r.slots ~> + "streams" := r.streams ~> + "commands" := r.commands ~> + jsonEmptyObject + +instance decodeJsonPipeline :: DecodeJson Pipeline where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "Pipeline" -> do + backend <- obj .? "backend" + textures <- obj .? "textures" + samplers <- obj .? "samplers" + targets <- obj .? "targets" + programs <- obj .? "programs" + slots <- obj .? "slots" + streams <- obj .? "streams" + commands <- obj .? "commands" + pure $ Pipeline + { backend:backend + , textures:textures + , samplers:samplers + , targets:targets + , programs:programs + , slots:slots + , streams:streams + , commands:commands + } + diff --git a/ddl/out/LambdaCube.IR.swift b/ddl/out/LambdaCube.IR.swift new file mode 100644 index 0000000..eb4b35f --- /dev/null +++ b/ddl/out/LambdaCube.IR.swift @@ -0,0 +1,1429 @@ +// generated file, do not modify! +// 2016-01-28T13:15:30.803775Z + +typealias StreamName = Int + +typealias ProgramName = Int + +typealias TextureName = Int + +typealias SamplerName = Int + +typealias UniformName = String + +typealias SlotName = Int + +typealias FrameBufferComponent = Int + +typealias TextureUnit = Int + +typealias RenderTargetName = Int + +typealias TextureUnitMapping = Dictionary + +enum ArrayValue { + case VBoolArray(Array) + case VIntArray(Array) + case VWordArray(Array) + case VFloatArray(Array) +} + +enum Value { + case VBool(Bool) + case VV2B(Int) + case VV3B(Int) + case VV4B(Int) + case VWord(UInt32) + case VV2U(Int) + case VV3U(Int) + case VV4U(Int) + case VInt(Int32) + case VV2I(Int) + case VV3I(Int) + case VV4I(Int) + case VFloat(Float) + case VV2F(Int) + case VV3F(Int) + case VV4F(Int) + case VM22F(Int) + case VM23F(Int) + case VM24F(Int) + case VM32F(Int) + case VM33F(Int) + case VM34F(Int) + case VM42F(Int) + case VM43F(Int) + case VM44F(Int) +} + +enum InputType { + case Bool + case V2B + case V3B + case V4B + case Word + case V2U + case V3U + case V4U + case Int + case V2I + case V3I + case V4I + case Float + case V2F + case V3F + case V4F + case M22F + case M23F + case M24F + case M32F + case M33F + case M34F + case M42F + case M43F + case M44F + case STexture1D + case STexture2D + case STextureCube + case STexture1DArray + case STexture2DArray + case STexture2DRect + case FTexture1D + case FTexture2D + case FTexture3D + case FTextureCube + case FTexture1DArray + case FTexture2DArray + case FTexture2DMS + case FTexture2DMSArray + case FTextureBuffer + case FTexture2DRect + case ITexture1D + case ITexture2D + case ITexture3D + case ITextureCube + case ITexture1DArray + case ITexture2DArray + case ITexture2DMS + case ITexture2DMSArray + case ITextureBuffer + case ITexture2DRect + case UTexture1D + case UTexture2D + case UTexture3D + case UTextureCube + case UTexture1DArray + case UTexture2DArray + case UTexture2DMS + case UTexture2DMSArray + case UTextureBuffer + case UTexture2DRect +} + +enum PointSpriteCoordOrigin { + case LowerLeft + case UpperLeft +} + +enum PointSize { + case PointSize(Float) + case ProgramPointSize +} + +enum PolygonOffset { + case NoOffset + case Offset(Float,Float) +} + +enum FrontFace { + case CCW + case CW +} + +enum PolygonMode { + case PolygonPoint(PointSize) + case PolygonLine(Float) + case PolygonFill +} + +enum ProvokingVertex { + case FirstVertex + case LastVertex +} + +enum CullMode { + case CullNone + case CullFront(FrontFace) + case CullBack(FrontFace) +} + +enum ComparisonFunction { + case Never + case Less + case Equal + case Lequal + case Greater + case Notequal + case Gequal + case Always +} + +typealias DepthFunction = ComparisonFunction + +enum StencilOperation { + case OpZero + case OpKeep + case OpReplace + case OpIncr + case OpIncrWrap + case OpDecr + case OpDecrWrap + case OpInvert +} + +enum BlendEquation { + case FuncAdd + case FuncSubtract + case FuncReverseSubtract + case Min + case Max +} + +enum BlendingFactor { + case Zero + case One + case SrcColor + case OneMinusSrcColor + case DstColor + case OneMinusDstColor + case SrcAlpha + case OneMinusSrcAlpha + case DstAlpha + case OneMinusDstAlpha + case ConstantColor + case OneMinusConstantColor + case ConstantAlpha + case OneMinusConstantAlpha + case SrcAlphaSaturate +} + +enum LogicOperation { + case Clear + case And + case AndReverse + case Copy + case AndInverted + case Noop + case Xor + case Or + case Nor + case Equiv + case Invert + case OrReverse + case CopyInverted + case OrInverted + case Nand + case Set +} + +enum StencilOps { + case StencilOps(StencilOps_Data) + struct StencilOps_Data { + var frontStencilOp : StencilOperation + var backStencilOp : StencilOperation + } +} + +enum StencilTest { + case StencilTest(StencilTest_Data) + struct StencilTest_Data { + var stencilComparision : ComparisonFunction + var stencilReference : Int32 + var stencilMask : UInt32 + } +} + +enum StencilTests { + case StencilTests(StencilTest,StencilTest) +} + +enum FetchPrimitive { + case Points + case Lines + case Triangles + case LinesAdjacency + case TrianglesAdjacency +} + +enum OutputPrimitive { + case TrianglesOutput + case LinesOutput + case PointsOutput +} + +enum ColorArity { + case Red + case RG + case RGB + case RGBA +} + +enum Blending { + case NoBlending + case BlendLogicOp(LogicOperation) + case Blend(Blend_Data) + struct Blend_Data { + var colorEqSrc : BlendEquation + var alphaEqSrc : BlendEquation + var colorFSrc : BlendingFactor + var colorFDst : BlendingFactor + var alphaFSrc : BlendingFactor + var alphaFDst : BlendingFactor + var color : Int + } +} + +enum RasterContext { + case PointCtx(PointSize,Float,PointSpriteCoordOrigin) + case LineCtx(Float,ProvokingVertex) + case TriangleCtx(CullMode,PolygonMode,PolygonOffset,ProvokingVertex) +} + +enum FragmentOperation { + case DepthOp(DepthFunction,Bool) + case StencilOp(StencilTests,StencilOps,StencilOps) + case ColorOp(Blending,Value) +} + +enum AccumulationContext { + case AccumulationContext(AccumulationContext_Data) + struct AccumulationContext_Data { + var accViewportName : Maybe + var accOperations : Array + } +} + +enum TextureDataType { + case FloatT(ColorArity) + case IntT(ColorArity) + case WordT(ColorArity) + case ShadowT +} + +enum TextureType { + case Texture1D(TextureDataType,Int) + case Texture2D(TextureDataType,Int) + case Texture3D(TextureDataType) + case TextureCube(TextureDataType) + case TextureRect(TextureDataType) + case Texture2DMS(TextureDataType,Int,Int,Bool) + case TextureBuffer(TextureDataType) +} + +enum MipMap { + case Mip(Int,Int) + case NoMip + case AutoMip(Int,Int) +} + +enum Filter { + case Nearest + case Linear + case NearestMipmapNearest + case NearestMipmapLinear + case LinearMipmapNearest + case LinearMipmapLinear +} + +enum EdgeMode { + case Repeat + case MirroredRepeat + case ClampToEdge + case ClampToBorder +} + +enum ImageSemantic { + case Depth + case Stencil + case Color +} + +enum ImageRef { + case TextureImage(TextureName,Int,Maybe) + case Framebuffer(ImageSemantic) +} + +enum ClearImage { + case ClearImage(ClearImage_Data) + struct ClearImage_Data { + var imageSemantic : ImageSemantic + var clearValue : Value + } +} + +enum Command { + case SetRasterContext(RasterContext) + case SetAccumulationContext(AccumulationContext) + case SetRenderTarget(RenderTargetName) + case SetProgram(ProgramName) + case SetSamplerUniform(UniformName,TextureUnit) + case SetTexture(TextureUnit,TextureName) + case SetSampler(TextureUnit,Maybe) + case RenderSlot(SlotName) + case RenderStream(StreamName) + case ClearRenderTarget(Array) + case GenerateMipMap(TextureUnit) + case SaveImage(FrameBufferComponent,ImageRef) + case LoadImage(ImageRef,FrameBufferComponent) +} + +enum SamplerDescriptor { + case SamplerDescriptor(SamplerDescriptor_Data) + struct SamplerDescriptor_Data { + var samplerWrapS : EdgeMode + var samplerWrapT : Maybe + var samplerWrapR : Maybe + var samplerMinFilter : Filter + var samplerMagFilter : Filter + var samplerBorderColor : Value + var samplerMinLod : Maybe + var samplerMaxLod : Maybe + var samplerLodBias : Float + var samplerCompareFunc : Maybe + } +} + +enum TextureDescriptor { + case TextureDescriptor(TextureDescriptor_Data) + struct TextureDescriptor_Data { + var textureType : TextureType + var textureSize : Value + var textureSemantic : ImageSemantic + var textureSampler : SamplerDescriptor + var textureBaseLevel : Int + var textureMaxLevel : Int + } +} + +enum Parameter { + case Parameter(Parameter_Data) + struct Parameter_Data { + var name : String + var ty : InputType + } +} + +enum Program { + case Program(Program_Data) + struct Program_Data { + var programUniforms : Dictionary + var programStreams : Dictionary + var programInTextures : Dictionary + var programOutput : Array + var vertexShader : String + var geometryShader : Maybe + var fragmentShader : String + } +} + +enum Slot { + case Slot(Slot_Data) + struct Slot_Data { + var slotName : String + var slotStreams : Dictionary + var slotUniforms : Dictionary + var slotPrimitive : FetchPrimitive + var slotPrograms : Array + } +} + +enum StreamData { + case StreamData(StreamData_Data) + struct StreamData_Data { + var streamData : Dictionary + var streamType : Dictionary + var streamPrimitive : FetchPrimitive + var streamPrograms : Array + } +} + +enum TargetItem { + case TargetItem(TargetItem_Data) + struct TargetItem_Data { + var targetSemantic : ImageSemantic + var targetRef : Maybe + } +} + +enum RenderTarget { + case RenderTarget(RenderTarget_Data) + struct RenderTarget_Data { + var renderTargets : Array + } +} + +enum Backend { + case WebGL1 + case OpenGL33 +} + +enum Pipeline { + case Pipeline(Pipeline_Data) + struct Pipeline_Data { + var backend : Backend + var textures : Array + var samplers : Array + var targets : Array + var programs : Array + var slots : Array + var streams : Array + var commands : Array + } +} + + +extension Int { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension Int32 { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension UInt { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension UInt32 { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension Float { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension Bool { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension String { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension Array { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension Dictionary { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension Maybe { + var toJSON : [String: AnyObject] { + return ["":""] + } +} + + + +extension ArrayValue { + var toJSON : [String: AnyObject] { + switch self { + case .VBoolArray(let arg0): + return [ "tag" : "VBoolArray", "arg0" : arg0.toJSON] + case .VIntArray(let arg0): + return [ "tag" : "VIntArray", "arg0" : arg0.toJSON] + case .VWordArray(let arg0): + return [ "tag" : "VWordArray", "arg0" : arg0.toJSON] + case .VFloatArray(let arg0): + return [ "tag" : "VFloatArray", "arg0" : arg0.toJSON] + } + } +} +extension Value { + var toJSON : [String: AnyObject] { + switch self { + case .VBool(let arg0): + return [ "tag" : "VBool", "arg0" : arg0.toJSON] + case .VV2B(let arg0): + return [ "tag" : "VV2B", "arg0" : arg0.toJSON] + case .VV3B(let arg0): + return [ "tag" : "VV3B", "arg0" : arg0.toJSON] + case .VV4B(let arg0): + return [ "tag" : "VV4B", "arg0" : arg0.toJSON] + case .VWord(let arg0): + return [ "tag" : "VWord", "arg0" : arg0.toJSON] + case .VV2U(let arg0): + return [ "tag" : "VV2U", "arg0" : arg0.toJSON] + case .VV3U(let arg0): + return [ "tag" : "VV3U", "arg0" : arg0.toJSON] + case .VV4U(let arg0): + return [ "tag" : "VV4U", "arg0" : arg0.toJSON] + case .VInt(let arg0): + return [ "tag" : "VInt", "arg0" : arg0.toJSON] + case .VV2I(let arg0): + return [ "tag" : "VV2I", "arg0" : arg0.toJSON] + case .VV3I(let arg0): + return [ "tag" : "VV3I", "arg0" : arg0.toJSON] + case .VV4I(let arg0): + return [ "tag" : "VV4I", "arg0" : arg0.toJSON] + case .VFloat(let arg0): + return [ "tag" : "VFloat", "arg0" : arg0.toJSON] + case .VV2F(let arg0): + return [ "tag" : "VV2F", "arg0" : arg0.toJSON] + case .VV3F(let arg0): + return [ "tag" : "VV3F", "arg0" : arg0.toJSON] + case .VV4F(let arg0): + return [ "tag" : "VV4F", "arg0" : arg0.toJSON] + case .VM22F(let arg0): + return [ "tag" : "VM22F", "arg0" : arg0.toJSON] + case .VM23F(let arg0): + return [ "tag" : "VM23F", "arg0" : arg0.toJSON] + case .VM24F(let arg0): + return [ "tag" : "VM24F", "arg0" : arg0.toJSON] + case .VM32F(let arg0): + return [ "tag" : "VM32F", "arg0" : arg0.toJSON] + case .VM33F(let arg0): + return [ "tag" : "VM33F", "arg0" : arg0.toJSON] + case .VM34F(let arg0): + return [ "tag" : "VM34F", "arg0" : arg0.toJSON] + case .VM42F(let arg0): + return [ "tag" : "VM42F", "arg0" : arg0.toJSON] + case .VM43F(let arg0): + return [ "tag" : "VM43F", "arg0" : arg0.toJSON] + case .VM44F(let arg0): + return [ "tag" : "VM44F", "arg0" : arg0.toJSON] + } + } +} +extension InputType { + var toJSON : [String: AnyObject] { + switch self { + case .Bool: + return [ "tag" : "Bool"] + case .V2B: + return [ "tag" : "V2B"] + case .V3B: + return [ "tag" : "V3B"] + case .V4B: + return [ "tag" : "V4B"] + case .Word: + return [ "tag" : "Word"] + case .V2U: + return [ "tag" : "V2U"] + case .V3U: + return [ "tag" : "V3U"] + case .V4U: + return [ "tag" : "V4U"] + case .Int: + return [ "tag" : "Int"] + case .V2I: + return [ "tag" : "V2I"] + case .V3I: + return [ "tag" : "V3I"] + case .V4I: + return [ "tag" : "V4I"] + case .Float: + return [ "tag" : "Float"] + case .V2F: + return [ "tag" : "V2F"] + case .V3F: + return [ "tag" : "V3F"] + case .V4F: + return [ "tag" : "V4F"] + case .M22F: + return [ "tag" : "M22F"] + case .M23F: + return [ "tag" : "M23F"] + case .M24F: + return [ "tag" : "M24F"] + case .M32F: + return [ "tag" : "M32F"] + case .M33F: + return [ "tag" : "M33F"] + case .M34F: + return [ "tag" : "M34F"] + case .M42F: + return [ "tag" : "M42F"] + case .M43F: + return [ "tag" : "M43F"] + case .M44F: + return [ "tag" : "M44F"] + case .STexture1D: + return [ "tag" : "STexture1D"] + case .STexture2D: + return [ "tag" : "STexture2D"] + case .STextureCube: + return [ "tag" : "STextureCube"] + case .STexture1DArray: + return [ "tag" : "STexture1DArray"] + case .STexture2DArray: + return [ "tag" : "STexture2DArray"] + case .STexture2DRect: + return [ "tag" : "STexture2DRect"] + case .FTexture1D: + return [ "tag" : "FTexture1D"] + case .FTexture2D: + return [ "tag" : "FTexture2D"] + case .FTexture3D: + return [ "tag" : "FTexture3D"] + case .FTextureCube: + return [ "tag" : "FTextureCube"] + case .FTexture1DArray: + return [ "tag" : "FTexture1DArray"] + case .FTexture2DArray: + return [ "tag" : "FTexture2DArray"] + case .FTexture2DMS: + return [ "tag" : "FTexture2DMS"] + case .FTexture2DMSArray: + return [ "tag" : "FTexture2DMSArray"] + case .FTextureBuffer: + return [ "tag" : "FTextureBuffer"] + case .FTexture2DRect: + return [ "tag" : "FTexture2DRect"] + case .ITexture1D: + return [ "tag" : "ITexture1D"] + case .ITexture2D: + return [ "tag" : "ITexture2D"] + case .ITexture3D: + return [ "tag" : "ITexture3D"] + case .ITextureCube: + return [ "tag" : "ITextureCube"] + case .ITexture1DArray: + return [ "tag" : "ITexture1DArray"] + case .ITexture2DArray: + return [ "tag" : "ITexture2DArray"] + case .ITexture2DMS: + return [ "tag" : "ITexture2DMS"] + case .ITexture2DMSArray: + return [ "tag" : "ITexture2DMSArray"] + case .ITextureBuffer: + return [ "tag" : "ITextureBuffer"] + case .ITexture2DRect: + return [ "tag" : "ITexture2DRect"] + case .UTexture1D: + return [ "tag" : "UTexture1D"] + case .UTexture2D: + return [ "tag" : "UTexture2D"] + case .UTexture3D: + return [ "tag" : "UTexture3D"] + case .UTextureCube: + return [ "tag" : "UTextureCube"] + case .UTexture1DArray: + return [ "tag" : "UTexture1DArray"] + case .UTexture2DArray: + return [ "tag" : "UTexture2DArray"] + case .UTexture2DMS: + return [ "tag" : "UTexture2DMS"] + case .UTexture2DMSArray: + return [ "tag" : "UTexture2DMSArray"] + case .UTextureBuffer: + return [ "tag" : "UTextureBuffer"] + case .UTexture2DRect: + return [ "tag" : "UTexture2DRect"] + } + } +} +extension PointSpriteCoordOrigin { + var toJSON : [String: AnyObject] { + switch self { + case .LowerLeft: + return [ "tag" : "LowerLeft"] + case .UpperLeft: + return [ "tag" : "UpperLeft"] + } + } +} +extension PointSize { + var toJSON : [String: AnyObject] { + switch self { + case .PointSize(let arg0): + return [ "tag" : "PointSize", "arg0" : arg0.toJSON] + case .ProgramPointSize: + return [ "tag" : "ProgramPointSize"] + } + } +} +extension PolygonOffset { + var toJSON : [String: AnyObject] { + switch self { + case .NoOffset: + return [ "tag" : "NoOffset"] + case .Offset(let arg0, let arg1): + return [ "tag" : "Offset", "arg0" : arg0.toJSON, "arg1" : arg1.toJSON] + } + } +} +extension FrontFace { + var toJSON : [String: AnyObject] { + switch self { + case .CCW: + return [ "tag" : "CCW"] + case .CW: + return [ "tag" : "CW"] + } + } +} +extension PolygonMode { + var toJSON : [String: AnyObject] { + switch self { + case .PolygonPoint(let arg0): + return [ "tag" : "PolygonPoint", "arg0" : arg0.toJSON] + case .PolygonLine(let arg0): + return [ "tag" : "PolygonLine", "arg0" : arg0.toJSON] + case .PolygonFill: + return [ "tag" : "PolygonFill"] + } + } +} +extension ProvokingVertex { + var toJSON : [String: AnyObject] { + switch self { + case .FirstVertex: + return [ "tag" : "FirstVertex"] + case .LastVertex: + return [ "tag" : "LastVertex"] + } + } +} +extension CullMode { + var toJSON : [String: AnyObject] { + switch self { + case .CullNone: + return [ "tag" : "CullNone"] + case .CullFront(let arg0): + return [ "tag" : "CullFront", "arg0" : arg0.toJSON] + case .CullBack(let arg0): + return [ "tag" : "CullBack", "arg0" : arg0.toJSON] + } + } +} +extension ComparisonFunction { + var toJSON : [String: AnyObject] { + switch self { + case .Never: + return [ "tag" : "Never"] + case .Less: + return [ "tag" : "Less"] + case .Equal: + return [ "tag" : "Equal"] + case .Lequal: + return [ "tag" : "Lequal"] + case .Greater: + return [ "tag" : "Greater"] + case .Notequal: + return [ "tag" : "Notequal"] + case .Gequal: + return [ "tag" : "Gequal"] + case .Always: + return [ "tag" : "Always"] + } + } +} +extension StencilOperation { + var toJSON : [String: AnyObject] { + switch self { + case .OpZero: + return [ "tag" : "OpZero"] + case .OpKeep: + return [ "tag" : "OpKeep"] + case .OpReplace: + return [ "tag" : "OpReplace"] + case .OpIncr: + return [ "tag" : "OpIncr"] + case .OpIncrWrap: + return [ "tag" : "OpIncrWrap"] + case .OpDecr: + return [ "tag" : "OpDecr"] + case .OpDecrWrap: + return [ "tag" : "OpDecrWrap"] + case .OpInvert: + return [ "tag" : "OpInvert"] + } + } +} +extension BlendEquation { + var toJSON : [String: AnyObject] { + switch self { + case .FuncAdd: + return [ "tag" : "FuncAdd"] + case .FuncSubtract: + return [ "tag" : "FuncSubtract"] + case .FuncReverseSubtract: + return [ "tag" : "FuncReverseSubtract"] + case .Min: + return [ "tag" : "Min"] + case .Max: + return [ "tag" : "Max"] + } + } +} +extension BlendingFactor { + var toJSON : [String: AnyObject] { + switch self { + case .Zero: + return [ "tag" : "Zero"] + case .One: + return [ "tag" : "One"] + case .SrcColor: + return [ "tag" : "SrcColor"] + case .OneMinusSrcColor: + return [ "tag" : "OneMinusSrcColor"] + case .DstColor: + return [ "tag" : "DstColor"] + case .OneMinusDstColor: + return [ "tag" : "OneMinusDstColor"] + case .SrcAlpha: + return [ "tag" : "SrcAlpha"] + case .OneMinusSrcAlpha: + return [ "tag" : "OneMinusSrcAlpha"] + case .DstAlpha: + return [ "tag" : "DstAlpha"] + case .OneMinusDstAlpha: + return [ "tag" : "OneMinusDstAlpha"] + case .ConstantColor: + return [ "tag" : "ConstantColor"] + case .OneMinusConstantColor: + return [ "tag" : "OneMinusConstantColor"] + case .ConstantAlpha: + return [ "tag" : "ConstantAlpha"] + case .OneMinusConstantAlpha: + return [ "tag" : "OneMinusConstantAlpha"] + case .SrcAlphaSaturate: + return [ "tag" : "SrcAlphaSaturate"] + } + } +} +extension LogicOperation { + var toJSON : [String: AnyObject] { + switch self { + case .Clear: + return [ "tag" : "Clear"] + case .And: + return [ "tag" : "And"] + case .AndReverse: + return [ "tag" : "AndReverse"] + case .Copy: + return [ "tag" : "Copy"] + case .AndInverted: + return [ "tag" : "AndInverted"] + case .Noop: + return [ "tag" : "Noop"] + case .Xor: + return [ "tag" : "Xor"] + case .Or: + return [ "tag" : "Or"] + case .Nor: + return [ "tag" : "Nor"] + case .Equiv: + return [ "tag" : "Equiv"] + case .Invert: + return [ "tag" : "Invert"] + case .OrReverse: + return [ "tag" : "OrReverse"] + case .CopyInverted: + return [ "tag" : "CopyInverted"] + case .OrInverted: + return [ "tag" : "OrInverted"] + case .Nand: + return [ "tag" : "Nand"] + case .Set: + return [ "tag" : "Set"] + } + } +} +extension StencilOps { + var toJSON : [String: AnyObject] { + switch self { + case .StencilOps(let v): + return [ "tag" : "StencilOps" + , "frontStencilOp" : v.frontStencilOp.toJSON + , "backStencilOp" : v.backStencilOp.toJSON + ] + } + } +} +extension StencilTest { + var toJSON : [String: AnyObject] { + switch self { + case .StencilTest(let v): + return [ "tag" : "StencilTest" + , "stencilComparision" : v.stencilComparision.toJSON + , "stencilReference" : v.stencilReference.toJSON + , "stencilMask" : v.stencilMask.toJSON + ] + } + } +} +extension StencilTests { + var toJSON : [String: AnyObject] { + switch self { + case .StencilTests(let arg0, let arg1): + return [ "tag" : "StencilTests", "arg0" : arg0.toJSON, "arg1" : arg1.toJSON] + } + } +} +extension FetchPrimitive { + var toJSON : [String: AnyObject] { + switch self { + case .Points: + return [ "tag" : "Points"] + case .Lines: + return [ "tag" : "Lines"] + case .Triangles: + return [ "tag" : "Triangles"] + case .LinesAdjacency: + return [ "tag" : "LinesAdjacency"] + case .TrianglesAdjacency: + return [ "tag" : "TrianglesAdjacency"] + } + } +} +extension OutputPrimitive { + var toJSON : [String: AnyObject] { + switch self { + case .TrianglesOutput: + return [ "tag" : "TrianglesOutput"] + case .LinesOutput: + return [ "tag" : "LinesOutput"] + case .PointsOutput: + return [ "tag" : "PointsOutput"] + } + } +} +extension ColorArity { + var toJSON : [String: AnyObject] { + switch self { + case .Red: + return [ "tag" : "Red"] + case .RG: + return [ "tag" : "RG"] + case .RGB: + return [ "tag" : "RGB"] + case .RGBA: + return [ "tag" : "RGBA"] + } + } +} +extension Blending { + var toJSON : [String: AnyObject] { + switch self { + case .NoBlending: + return [ "tag" : "NoBlending"] + case .BlendLogicOp(let arg0): + return [ "tag" : "BlendLogicOp", "arg0" : arg0.toJSON] + case .Blend(let v): + return [ "tag" : "Blend" + , "colorEqSrc" : v.colorEqSrc.toJSON + , "alphaEqSrc" : v.alphaEqSrc.toJSON + , "colorFSrc" : v.colorFSrc.toJSON + , "colorFDst" : v.colorFDst.toJSON + , "alphaFSrc" : v.alphaFSrc.toJSON + , "alphaFDst" : v.alphaFDst.toJSON + , "color" : v.color.toJSON + ] + } + } +} +extension RasterContext { + var toJSON : [String: AnyObject] { + switch self { + case .PointCtx(let arg0, let arg1, let arg2): + return [ "tag" : "PointCtx", "arg0" : arg0.toJSON, "arg1" : arg1.toJSON, "arg2" : arg2.toJSON] + case .LineCtx(let arg0, let arg1): + return [ "tag" : "LineCtx", "arg0" : arg0.toJSON, "arg1" : arg1.toJSON] + case .TriangleCtx(let arg0, let arg1, let arg2, let arg3): + return [ "tag" : "TriangleCtx", "arg0" : arg0.toJSON, "arg1" : arg1.toJSON, "arg2" : arg2.toJSON, "arg3" : arg3.toJSON] + } + } +} +extension FragmentOperation { + var toJSON : [String: AnyObject] { + switch self { + case .DepthOp(let arg0, let arg1): + return [ "tag" : "DepthOp", "arg0" : arg0.toJSON, "arg1" : arg1.toJSON] + case .StencilOp(let arg0, let arg1, let arg2): + return [ "tag" : "StencilOp", "arg0" : arg0.toJSON, "arg1" : arg1.toJSON, "arg2" : arg2.toJSON] + case .ColorOp(let arg0, let arg1): + return [ "tag" : "ColorOp", "arg0" : arg0.toJSON, "arg1" : arg1.toJSON] + } + } +} +extension AccumulationContext { + var toJSON : [String: AnyObject] { + switch self { + case .AccumulationContext(let v): + return [ "tag" : "AccumulationContext" + , "accViewportName" : v.accViewportName.toJSON + , "accOperations" : v.accOperations.toJSON + ] + } + } +} +extension TextureDataType { + var toJSON : [String: AnyObject] { + switch self { + case .FloatT(let arg0): + return [ "tag" : "FloatT", "arg0" : arg0.toJSON] + case .IntT(let arg0): + return [ "tag" : "IntT", "arg0" : arg0.toJSON] + case .WordT(let arg0): + return [ "tag" : "WordT", "arg0" : arg0.toJSON] + case .ShadowT: + return [ "tag" : "ShadowT"] + } + } +} +extension TextureType { + var toJSON : [String: AnyObject] { + switch self { + case .Texture1D(let arg0, let arg1): + return [ "tag" : "Texture1D", "arg0" : arg0.toJSON, "arg1" : arg1.toJSON] + case .Texture2D(let arg0, let arg1): + return [ "tag" : "Texture2D", "arg0" : arg0.toJSON, "arg1" : arg1.toJSON] + case .Texture3D(let arg0): + return [ "tag" : "Texture3D", "arg0" : arg0.toJSON] + case .TextureCube(let arg0): + return [ "tag" : "TextureCube", "arg0" : arg0.toJSON] + case .TextureRect(let arg0): + return [ "tag" : "TextureRect", "arg0" : arg0.toJSON] + case .Texture2DMS(let arg0, let arg1, let arg2, let arg3): + return [ "tag" : "Texture2DMS", "arg0" : arg0.toJSON, "arg1" : arg1.toJSON, "arg2" : arg2.toJSON, "arg3" : arg3.toJSON] + case .TextureBuffer(let arg0): + return [ "tag" : "TextureBuffer", "arg0" : arg0.toJSON] + } + } +} +extension MipMap { + var toJSON : [String: AnyObject] { + switch self { + case .Mip(let arg0, let arg1): + return [ "tag" : "Mip", "arg0" : arg0.toJSON, "arg1" : arg1.toJSON] + case .NoMip: + return [ "tag" : "NoMip"] + case .AutoMip(let arg0, let arg1): + return [ "tag" : "AutoMip", "arg0" : arg0.toJSON, "arg1" : arg1.toJSON] + } + } +} +extension Filter { + var toJSON : [String: AnyObject] { + switch self { + case .Nearest: + return [ "tag" : "Nearest"] + case .Linear: + return [ "tag" : "Linear"] + case .NearestMipmapNearest: + return [ "tag" : "NearestMipmapNearest"] + case .NearestMipmapLinear: + return [ "tag" : "NearestMipmapLinear"] + case .LinearMipmapNearest: + return [ "tag" : "LinearMipmapNearest"] + case .LinearMipmapLinear: + return [ "tag" : "LinearMipmapLinear"] + } + } +} +extension EdgeMode { + var toJSON : [String: AnyObject] { + switch self { + case .Repeat: + return [ "tag" : "Repeat"] + case .MirroredRepeat: + return [ "tag" : "MirroredRepeat"] + case .ClampToEdge: + return [ "tag" : "ClampToEdge"] + case .ClampToBorder: + return [ "tag" : "ClampToBorder"] + } + } +} +extension ImageSemantic { + var toJSON : [String: AnyObject] { + switch self { + case .Depth: + return [ "tag" : "Depth"] + case .Stencil: + return [ "tag" : "Stencil"] + case .Color: + return [ "tag" : "Color"] + } + } +} +extension ImageRef { + var toJSON : [String: AnyObject] { + switch self { + case .TextureImage(let arg0, let arg1, let arg2): + return [ "tag" : "TextureImage", "arg0" : arg0.toJSON, "arg1" : arg1.toJSON, "arg2" : arg2.toJSON] + case .Framebuffer(let arg0): + return [ "tag" : "Framebuffer", "arg0" : arg0.toJSON] + } + } +} +extension ClearImage { + var toJSON : [String: AnyObject] { + switch self { + case .ClearImage(let v): + return [ "tag" : "ClearImage" + , "imageSemantic" : v.imageSemantic.toJSON + , "clearValue" : v.clearValue.toJSON + ] + } + } +} +extension Command { + var toJSON : [String: AnyObject] { + switch self { + case .SetRasterContext(let arg0): + return [ "tag" : "SetRasterContext", "arg0" : arg0.toJSON] + case .SetAccumulationContext(let arg0): + return [ "tag" : "SetAccumulationContext", "arg0" : arg0.toJSON] + case .SetRenderTarget(let arg0): + return [ "tag" : "SetRenderTarget", "arg0" : arg0.toJSON] + case .SetProgram(let arg0): + return [ "tag" : "SetProgram", "arg0" : arg0.toJSON] + case .SetSamplerUniform(let arg0, let arg1): + return [ "tag" : "SetSamplerUniform", "arg0" : arg0.toJSON, "arg1" : arg1.toJSON] + case .SetTexture(let arg0, let arg1): + return [ "tag" : "SetTexture", "arg0" : arg0.toJSON, "arg1" : arg1.toJSON] + case .SetSampler(let arg0, let arg1): + return [ "tag" : "SetSampler", "arg0" : arg0.toJSON, "arg1" : arg1.toJSON] + case .RenderSlot(let arg0): + return [ "tag" : "RenderSlot", "arg0" : arg0.toJSON] + case .RenderStream(let arg0): + return [ "tag" : "RenderStream", "arg0" : arg0.toJSON] + case .ClearRenderTarget(let arg0): + return [ "tag" : "ClearRenderTarget", "arg0" : arg0.toJSON] + case .GenerateMipMap(let arg0): + return [ "tag" : "GenerateMipMap", "arg0" : arg0.toJSON] + case .SaveImage(let arg0, let arg1): + return [ "tag" : "SaveImage", "arg0" : arg0.toJSON, "arg1" : arg1.toJSON] + case .LoadImage(let arg0, let arg1): + return [ "tag" : "LoadImage", "arg0" : arg0.toJSON, "arg1" : arg1.toJSON] + } + } +} +extension SamplerDescriptor { + var toJSON : [String: AnyObject] { + switch self { + case .SamplerDescriptor(let v): + return [ "tag" : "SamplerDescriptor" + , "samplerWrapS" : v.samplerWrapS.toJSON + , "samplerWrapT" : v.samplerWrapT.toJSON + , "samplerWrapR" : v.samplerWrapR.toJSON + , "samplerMinFilter" : v.samplerMinFilter.toJSON + , "samplerMagFilter" : v.samplerMagFilter.toJSON + , "samplerBorderColor" : v.samplerBorderColor.toJSON + , "samplerMinLod" : v.samplerMinLod.toJSON + , "samplerMaxLod" : v.samplerMaxLod.toJSON + , "samplerLodBias" : v.samplerLodBias.toJSON + , "samplerCompareFunc" : v.samplerCompareFunc.toJSON + ] + } + } +} +extension TextureDescriptor { + var toJSON : [String: AnyObject] { + switch self { + case .TextureDescriptor(let v): + return [ "tag" : "TextureDescriptor" + , "textureType" : v.textureType.toJSON + , "textureSize" : v.textureSize.toJSON + , "textureSemantic" : v.textureSemantic.toJSON + , "textureSampler" : v.textureSampler.toJSON + , "textureBaseLevel" : v.textureBaseLevel.toJSON + , "textureMaxLevel" : v.textureMaxLevel.toJSON + ] + } + } +} +extension Parameter { + var toJSON : [String: AnyObject] { + switch self { + case .Parameter(let v): + return [ "tag" : "Parameter" + , "name" : v.name.toJSON + , "ty" : v.ty.toJSON + ] + } + } +} +extension Program { + var toJSON : [String: AnyObject] { + switch self { + case .Program(let v): + return [ "tag" : "Program" + , "programUniforms" : v.programUniforms.toJSON + , "programStreams" : v.programStreams.toJSON + , "programInTextures" : v.programInTextures.toJSON + , "programOutput" : v.programOutput.toJSON + , "vertexShader" : v.vertexShader.toJSON + , "geometryShader" : v.geometryShader.toJSON + , "fragmentShader" : v.fragmentShader.toJSON + ] + } + } +} +extension Slot { + var toJSON : [String: AnyObject] { + switch self { + case .Slot(let v): + return [ "tag" : "Slot" + , "slotName" : v.slotName.toJSON + , "slotStreams" : v.slotStreams.toJSON + , "slotUniforms" : v.slotUniforms.toJSON + , "slotPrimitive" : v.slotPrimitive.toJSON + , "slotPrograms" : v.slotPrograms.toJSON + ] + } + } +} +extension StreamData { + var toJSON : [String: AnyObject] { + switch self { + case .StreamData(let v): + return [ "tag" : "StreamData" + , "streamData" : v.streamData.toJSON + , "streamType" : v.streamType.toJSON + , "streamPrimitive" : v.streamPrimitive.toJSON + , "streamPrograms" : v.streamPrograms.toJSON + ] + } + } +} +extension TargetItem { + var toJSON : [String: AnyObject] { + switch self { + case .TargetItem(let v): + return [ "tag" : "TargetItem" + , "targetSemantic" : v.targetSemantic.toJSON + , "targetRef" : v.targetRef.toJSON + ] + } + } +} +extension RenderTarget { + var toJSON : [String: AnyObject] { + switch self { + case .RenderTarget(let v): + return [ "tag" : "RenderTarget" + , "renderTargets" : v.renderTargets.toJSON + ] + } + } +} +extension Backend { + var toJSON : [String: AnyObject] { + switch self { + case .WebGL1: + return [ "tag" : "WebGL1"] + case .OpenGL33: + return [ "tag" : "OpenGL33"] + } + } +} +extension Pipeline { + var toJSON : [String: AnyObject] { + switch self { + case .Pipeline(let v): + return [ "tag" : "Pipeline" + , "backend" : v.backend.toJSON + , "textures" : v.textures.toJSON + , "samplers" : v.samplers.toJSON + , "targets" : v.targets.toJSON + , "programs" : v.programs.toJSON + , "slots" : v.slots.toJSON + , "streams" : v.streams.toJSON + , "commands" : v.commands.toJSON + ] + } + } +} + +enum Maybe { + case Nothing + case Just(T) +} + +enum Type { + case Int + case Int32 + case Word + case Word32 + case Float + case Bool + case String + case Array(Type) + case List(Type) + case Maybe(Type) + case Map(Type,Type) + case ArrayValue + case Value + case InputType + case PointSpriteCoordOrigin + case PointSize + case PolygonOffset + case FrontFace + case PolygonMode + case ProvokingVertex + case CullMode + case ComparisonFunction + case StencilOperation + case BlendEquation + case BlendingFactor + case LogicOperation + case StencilOps + case StencilTest + case StencilTests + case FetchPrimitive + case OutputPrimitive + case ColorArity + case Blending + case RasterContext + case FragmentOperation + case AccumulationContext + case TextureDataType + case TextureType + case MipMap + case Filter + case EdgeMode + case ImageSemantic + case ImageRef + case ClearImage + case Command + case SamplerDescriptor + case TextureDescriptor + case Parameter + case Program + case Slot + case StreamData + case TargetItem + case RenderTarget + case Backend + case Pipeline +} + +func fromJSON(type: Type, personName: String) -> Any { + switch type { + case .Int: return 0 + case .Int32: return 0 + case .Word: return 0 + case .Word32: return 0 + case .Float: return 0.0 + case .Bool: return false + case .String: return "" + case .Array(let a): return fromJSON(a,personName) + case .List(let a): return fromJSON(a,personName) + case .Maybe(let a): return fromJSON(a,personName) + } + return 0; +} \ No newline at end of file diff --git a/ddl/out/LambdaCube.IR2.hpp b/ddl/out/LambdaCube.IR2.hpp new file mode 100644 index 0000000..43de714 --- /dev/null +++ b/ddl/out/LambdaCube.IR2.hpp @@ -0,0 +1,1070 @@ +// generated file, do not modify! +// 2016-01-28T13:15:30.803775Z + +#ifndef HEADER_LambdaCube.IR_H +#define HEADER_LambdaCube.IR_H + +#include "RT.hpp" + + +typedef Int StreamName; + +typedef Int ProgramName; + +typedef Int TextureName; + +typedef Int SamplerName; + +typedef String UniformName; + +typedef Int SlotName; + +typedef Int FrameBufferComponent; + +typedef Int TextureUnit; + +typedef Int RenderTargetName; + +typedef std::map<::UniformName, ::TextureUnit> TextureUnitMapping; + +namespace data { + class VBoolArray { + public: + std::vector _0; + }; + class VIntArray { + public: + std::vector _0; + }; + class VWordArray { + public: + std::vector _0; + }; + class VFloatArray { + public: + std::vector _0; + }; +} +class ArrayValue { +public: + enum class tag { + VBoolArray, + VIntArray, + VWordArray, + VFloatArray + } tag; + std::shared_ptr VBoolArray; + std::shared_ptr VIntArray; + std::shared_ptr VWordArray; + std::shared_ptr VFloatArray; +}; +namespace data { + class VBool { + public: + Bool _0; + }; + class VV2B { + public: + V2B _0; + }; + class VV3B { + public: + V3B _0; + }; + class VV4B { + public: + V4B _0; + }; + class VWord { + public: + Word32 _0; + }; + class VV2U { + public: + V2U _0; + }; + class VV3U { + public: + V3U _0; + }; + class VV4U { + public: + V4U _0; + }; + class VInt { + public: + Int32 _0; + }; + class VV2I { + public: + V2I _0; + }; + class VV3I { + public: + V3I _0; + }; + class VV4I { + public: + V4I _0; + }; + class VFloat { + public: + Float _0; + }; + class VV2F { + public: + V2F _0; + }; + class VV3F { + public: + V3F _0; + }; + class VV4F { + public: + V4F _0; + }; + class VM22F { + public: + M22F _0; + }; + class VM23F { + public: + M23F _0; + }; + class VM24F { + public: + M24F _0; + }; + class VM32F { + public: + M32F _0; + }; + class VM33F { + public: + M33F _0; + }; + class VM34F { + public: + M34F _0; + }; + class VM42F { + public: + M42F _0; + }; + class VM43F { + public: + M43F _0; + }; + class VM44F { + public: + M44F _0; + }; +} +class Value { +public: + enum class tag { + VBool, + VV2B, + VV3B, + VV4B, + VWord, + VV2U, + VV3U, + VV4U, + VInt, + VV2I, + VV3I, + VV4I, + VFloat, + VV2F, + VV3F, + VV4F, + VM22F, + VM23F, + VM24F, + VM32F, + VM33F, + VM34F, + VM42F, + VM43F, + VM44F + } tag; + std::shared_ptr VBool; + std::shared_ptr VV2B; + std::shared_ptr VV3B; + std::shared_ptr VV4B; + std::shared_ptr VWord; + std::shared_ptr VV2U; + std::shared_ptr VV3U; + std::shared_ptr VV4U; + std::shared_ptr VInt; + std::shared_ptr VV2I; + std::shared_ptr VV3I; + std::shared_ptr VV4I; + std::shared_ptr VFloat; + std::shared_ptr VV2F; + std::shared_ptr VV3F; + std::shared_ptr VV4F; + std::shared_ptr VM22F; + std::shared_ptr VM23F; + std::shared_ptr VM24F; + std::shared_ptr VM32F; + std::shared_ptr VM33F; + std::shared_ptr VM34F; + std::shared_ptr VM42F; + std::shared_ptr VM43F; + std::shared_ptr VM44F; +}; +namespace data { +} +class InputType { +public: + enum class tag { + Bool, + V2B, + V3B, + V4B, + Word, + V2U, + V3U, + V4U, + Int, + V2I, + V3I, + V4I, + Float, + V2F, + V3F, + V4F, + M22F, + M23F, + M24F, + M32F, + M33F, + M34F, + M42F, + M43F, + M44F, + STexture1D, + STexture2D, + STextureCube, + STexture1DArray, + STexture2DArray, + STexture2DRect, + FTexture1D, + FTexture2D, + FTexture3D, + FTextureCube, + FTexture1DArray, + FTexture2DArray, + FTexture2DMS, + FTexture2DMSArray, + FTextureBuffer, + FTexture2DRect, + ITexture1D, + ITexture2D, + ITexture3D, + ITextureCube, + ITexture1DArray, + ITexture2DArray, + ITexture2DMS, + ITexture2DMSArray, + ITextureBuffer, + ITexture2DRect, + UTexture1D, + UTexture2D, + UTexture3D, + UTextureCube, + UTexture1DArray, + UTexture2DArray, + UTexture2DMS, + UTexture2DMSArray, + UTextureBuffer, + UTexture2DRect + } tag; +}; +namespace data { +} +class PointSpriteCoordOrigin { +public: + enum class tag { + LowerLeft, + UpperLeft + } tag; +}; +namespace data { + class PointSize { + public: + Float _0; + }; +} +class PointSize { +public: + enum class tag { + PointSize, + ProgramPointSize + } tag; + std::shared_ptr PointSize; +}; +namespace data { + class Offset { + public: + Float _0; + Float _1; + }; +} +class PolygonOffset { +public: + enum class tag { + NoOffset, + Offset + } tag; + std::shared_ptr Offset; +}; +namespace data { +} +class FrontFace { +public: + enum class tag { + CCW, + CW + } tag; +}; +namespace data { + class PolygonPoint { + public: + std::shared_ptr<::PointSize> _0; + }; + class PolygonLine { + public: + Float _0; + }; +} +class PolygonMode { +public: + enum class tag { + PolygonPoint, + PolygonLine, + PolygonFill + } tag; + std::shared_ptr PolygonPoint; + std::shared_ptr PolygonLine; +}; +namespace data { +} +class ProvokingVertex { +public: + enum class tag { + FirstVertex, + LastVertex + } tag; +}; +namespace data { + class CullFront { + public: + std::shared_ptr<::FrontFace> _0; + }; + class CullBack { + public: + std::shared_ptr<::FrontFace> _0; + }; +} +class CullMode { +public: + enum class tag { + CullNone, + CullFront, + CullBack + } tag; + std::shared_ptr CullFront; + std::shared_ptr CullBack; +}; +namespace data { +} +class ComparisonFunction { +public: + enum class tag { + Never, + Less, + Equal, + Lequal, + Greater, + Notequal, + Gequal, + Always + } tag; +}; +typedef ComparisonFunction DepthFunction; + +namespace data { +} +class StencilOperation { +public: + enum class tag { + OpZero, + OpKeep, + OpReplace, + OpIncr, + OpIncrWrap, + OpDecr, + OpDecrWrap, + OpInvert + } tag; +}; +namespace data { +} +class BlendEquation { +public: + enum class tag { + FuncAdd, + FuncSubtract, + FuncReverseSubtract, + Min, + Max + } tag; +}; +namespace data { +} +class BlendingFactor { +public: + enum class tag { + Zero, + One, + SrcColor, + OneMinusSrcColor, + DstColor, + OneMinusDstColor, + SrcAlpha, + OneMinusSrcAlpha, + DstAlpha, + OneMinusDstAlpha, + ConstantColor, + OneMinusConstantColor, + ConstantAlpha, + OneMinusConstantAlpha, + SrcAlphaSaturate + } tag; +}; +namespace data { +} +class LogicOperation { +public: + enum class tag { + Clear, + And, + AndReverse, + Copy, + AndInverted, + Noop, + Xor, + Or, + Nor, + Equiv, + Invert, + OrReverse, + CopyInverted, + OrInverted, + Nand, + Set + } tag; +}; +namespace data { + class StencilOps { + public: + std::shared_ptr<::StencilOperation> frontStencilOp; + std::shared_ptr<::StencilOperation> backStencilOp; + }; +} +class StencilOps { +public: + enum class tag { + StencilOps + } tag; + std::shared_ptr StencilOps; +}; +namespace data { + class StencilTest { + public: + std::shared_ptr<::ComparisonFunction> stencilComparision; + Int32 stencilReference; + Word32 stencilMask; + }; +} +class StencilTest { +public: + enum class tag { + StencilTest + } tag; + std::shared_ptr StencilTest; +}; +namespace data { + class StencilTests { + public: + std::shared_ptr<::StencilTest> _0; + std::shared_ptr<::StencilTest> _1; + }; +} +class StencilTests { +public: + enum class tag { + StencilTests + } tag; + std::shared_ptr StencilTests; +}; +namespace data { +} +class FetchPrimitive { +public: + enum class tag { + Points, + Lines, + Triangles, + LinesAdjacency, + TrianglesAdjacency + } tag; +}; +namespace data { +} +class OutputPrimitive { +public: + enum class tag { + TrianglesOutput, + LinesOutput, + PointsOutput + } tag; +}; +namespace data { +} +class ColorArity { +public: + enum class tag { + Red, + RG, + RGB, + RGBA + } tag; +}; +namespace data { + class BlendLogicOp { + public: + std::shared_ptr<::LogicOperation> _0; + }; + class Blend { + public: + std::shared_ptr<::BlendEquation> colorEqSrc; + std::shared_ptr<::BlendEquation> alphaEqSrc; + std::shared_ptr<::BlendingFactor> colorFSrc; + std::shared_ptr<::BlendingFactor> colorFDst; + std::shared_ptr<::BlendingFactor> alphaFSrc; + std::shared_ptr<::BlendingFactor> alphaFDst; + V4F color; + }; +} +class Blending { +public: + enum class tag { + NoBlending, + BlendLogicOp, + Blend + } tag; + std::shared_ptr BlendLogicOp; + std::shared_ptr Blend; +}; +namespace data { + class PointCtx { + public: + std::shared_ptr<::PointSize> _0; + Float _1; + std::shared_ptr<::PointSpriteCoordOrigin> _2; + }; + class LineCtx { + public: + Float _0; + std::shared_ptr<::ProvokingVertex> _1; + }; + class TriangleCtx { + public: + std::shared_ptr<::CullMode> _0; + std::shared_ptr<::PolygonMode> _1; + std::shared_ptr<::PolygonOffset> _2; + std::shared_ptr<::ProvokingVertex> _3; + }; +} +class RasterContext { +public: + enum class tag { + PointCtx, + LineCtx, + TriangleCtx + } tag; + std::shared_ptr PointCtx; + std::shared_ptr LineCtx; + std::shared_ptr TriangleCtx; +}; +namespace data { + class DepthOp { + public: + std::shared_ptr<::DepthFunction> _0; + Bool _1; + }; + class StencilOp { + public: + std::shared_ptr<::StencilTests> _0; + std::shared_ptr<::StencilOps> _1; + std::shared_ptr<::StencilOps> _2; + }; + class ColorOp { + public: + std::shared_ptr<::Blending> _0; + std::shared_ptr<::Value> _1; + }; +} +class FragmentOperation { +public: + enum class tag { + DepthOp, + StencilOp, + ColorOp + } tag; + std::shared_ptr DepthOp; + std::shared_ptr StencilOp; + std::shared_ptr ColorOp; +}; +namespace data { + class AccumulationContext { + public: + Maybe accViewportName; + std::vector> accOperations; + }; +} +class AccumulationContext { +public: + enum class tag { + AccumulationContext + } tag; + std::shared_ptr AccumulationContext; +}; +namespace data { + class FloatT { + public: + std::shared_ptr<::ColorArity> _0; + }; + class IntT { + public: + std::shared_ptr<::ColorArity> _0; + }; + class WordT { + public: + std::shared_ptr<::ColorArity> _0; + }; +} +class TextureDataType { +public: + enum class tag { + FloatT, + IntT, + WordT, + ShadowT + } tag; + std::shared_ptr FloatT; + std::shared_ptr IntT; + std::shared_ptr WordT; +}; +namespace data { + class Texture1D { + public: + std::shared_ptr<::TextureDataType> _0; + Int _1; + }; + class Texture2D { + public: + std::shared_ptr<::TextureDataType> _0; + Int _1; + }; + class Texture3D { + public: + std::shared_ptr<::TextureDataType> _0; + }; + class TextureCube { + public: + std::shared_ptr<::TextureDataType> _0; + }; + class TextureRect { + public: + std::shared_ptr<::TextureDataType> _0; + }; + class Texture2DMS { + public: + std::shared_ptr<::TextureDataType> _0; + Int _1; + Int _2; + Bool _3; + }; + class TextureBuffer { + public: + std::shared_ptr<::TextureDataType> _0; + }; +} +class TextureType { +public: + enum class tag { + Texture1D, + Texture2D, + Texture3D, + TextureCube, + TextureRect, + Texture2DMS, + TextureBuffer + } tag; + std::shared_ptr Texture1D; + std::shared_ptr Texture2D; + std::shared_ptr Texture3D; + std::shared_ptr TextureCube; + std::shared_ptr TextureRect; + std::shared_ptr Texture2DMS; + std::shared_ptr TextureBuffer; +}; +namespace data { + class Mip { + public: + Int _0; + Int _1; + }; + class AutoMip { + public: + Int _0; + Int _1; + }; +} +class MipMap { +public: + enum class tag { + Mip, + NoMip, + AutoMip + } tag; + std::shared_ptr Mip; + std::shared_ptr AutoMip; +}; +namespace data { +} +class Filter { +public: + enum class tag { + Nearest, + Linear, + NearestMipmapNearest, + NearestMipmapLinear, + LinearMipmapNearest, + LinearMipmapLinear + } tag; +}; +namespace data { +} +class EdgeMode { +public: + enum class tag { + Repeat, + MirroredRepeat, + ClampToEdge, + ClampToBorder + } tag; +}; +namespace data { +} +class ImageSemantic { +public: + enum class tag { + Depth, + Stencil, + Color + } tag; +}; +namespace data { + class TextureImage { + public: + ::TextureName _0; + Int _1; + Maybe _2; + }; + class Framebuffer { + public: + std::shared_ptr<::ImageSemantic> _0; + }; +} +class ImageRef { +public: + enum class tag { + TextureImage, + Framebuffer + } tag; + std::shared_ptr TextureImage; + std::shared_ptr Framebuffer; +}; +namespace data { + class ClearImage { + public: + std::shared_ptr<::ImageSemantic> imageSemantic; + std::shared_ptr<::Value> clearValue; + }; +} +class ClearImage { +public: + enum class tag { + ClearImage + } tag; + std::shared_ptr ClearImage; +}; +namespace data { + class SetRasterContext { + public: + std::shared_ptr<::RasterContext> _0; + }; + class SetAccumulationContext { + public: + std::shared_ptr<::AccumulationContext> _0; + }; + class SetRenderTarget { + public: + ::RenderTargetName _0; + }; + class SetProgram { + public: + ::ProgramName _0; + }; + class SetSamplerUniform { + public: + ::UniformName _0; + ::TextureUnit _1; + }; + class SetTexture { + public: + ::TextureUnit _0; + ::TextureName _1; + }; + class SetSampler { + public: + ::TextureUnit _0; + Maybe<::SamplerName> _1; + }; + class RenderSlot { + public: + ::SlotName _0; + }; + class RenderStream { + public: + ::StreamName _0; + }; + class ClearRenderTarget { + public: + std::vector> _0; + }; + class GenerateMipMap { + public: + ::TextureUnit _0; + }; + class SaveImage { + public: + ::FrameBufferComponent _0; + std::shared_ptr<::ImageRef> _1; + }; + class LoadImage { + public: + std::shared_ptr<::ImageRef> _0; + ::FrameBufferComponent _1; + }; +} +class Command { +public: + enum class tag { + SetRasterContext, + SetAccumulationContext, + SetRenderTarget, + SetProgram, + SetSamplerUniform, + SetTexture, + SetSampler, + RenderSlot, + RenderStream, + ClearRenderTarget, + GenerateMipMap, + SaveImage, + LoadImage + } tag; + std::shared_ptr SetRasterContext; + std::shared_ptr SetAccumulationContext; + std::shared_ptr SetRenderTarget; + std::shared_ptr SetProgram; + std::shared_ptr SetSamplerUniform; + std::shared_ptr SetTexture; + std::shared_ptr SetSampler; + std::shared_ptr RenderSlot; + std::shared_ptr RenderStream; + std::shared_ptr ClearRenderTarget; + std::shared_ptr GenerateMipMap; + std::shared_ptr SaveImage; + std::shared_ptr LoadImage; +}; +namespace data { + class SamplerDescriptor { + public: + std::shared_ptr<::EdgeMode> samplerWrapS; + Maybe> samplerWrapT; + Maybe> samplerWrapR; + std::shared_ptr<::Filter> samplerMinFilter; + std::shared_ptr<::Filter> samplerMagFilter; + std::shared_ptr<::Value> samplerBorderColor; + Maybe samplerMinLod; + Maybe samplerMaxLod; + Float samplerLodBias; + Maybe> samplerCompareFunc; + }; +} +class SamplerDescriptor { +public: + enum class tag { + SamplerDescriptor + } tag; + std::shared_ptr SamplerDescriptor; +}; +namespace data { + class TextureDescriptor { + public: + std::shared_ptr<::TextureType> textureType; + std::shared_ptr<::Value> textureSize; + std::shared_ptr<::ImageSemantic> textureSemantic; + std::shared_ptr<::SamplerDescriptor> textureSampler; + Int textureBaseLevel; + Int textureMaxLevel; + }; +} +class TextureDescriptor { +public: + enum class tag { + TextureDescriptor + } tag; + std::shared_ptr TextureDescriptor; +}; +namespace data { + class Parameter { + public: + String name; + std::shared_ptr<::InputType> ty; + }; +} +class Parameter { +public: + enum class tag { + Parameter + } tag; + std::shared_ptr Parameter; +}; +namespace data { + class Program { + public: + std::map<::UniformName, std::shared_ptr<::InputType>> programUniforms; + std::map<::UniformName, std::shared_ptr<::Parameter>> programStreams; + std::map<::UniformName, std::shared_ptr<::InputType>> programInTextures; + std::vector> programOutput; + String vertexShader; + Maybe geometryShader; + String fragmentShader; + }; +} +class Program { +public: + enum class tag { + Program + } tag; + std::shared_ptr Program; +}; +namespace data { + class Slot { + public: + String slotName; + std::map> slotStreams; + std::map<::UniformName, std::shared_ptr<::InputType>> slotUniforms; + std::shared_ptr<::FetchPrimitive> slotPrimitive; + std::vector<::ProgramName> slotPrograms; + }; +} +class Slot { +public: + enum class tag { + Slot + } tag; + std::shared_ptr Slot; +}; +namespace data { + class StreamData { + public: + std::map> streamData; + std::map> streamType; + std::shared_ptr<::FetchPrimitive> streamPrimitive; + std::vector<::ProgramName> streamPrograms; + }; +} +class StreamData { +public: + enum class tag { + StreamData + } tag; + std::shared_ptr StreamData; +}; +namespace data { + class TargetItem { + public: + std::shared_ptr<::ImageSemantic> targetSemantic; + Maybe> targetRef; + }; +} +class TargetItem { +public: + enum class tag { + TargetItem + } tag; + std::shared_ptr TargetItem; +}; +namespace data { + class RenderTarget { + public: + std::vector> renderTargets; + }; +} +class RenderTarget { +public: + enum class tag { + RenderTarget + } tag; + std::shared_ptr RenderTarget; +}; +namespace data { +} +class Backend { +public: + enum class tag { + WebGL1, + OpenGL33 + } tag; +}; +namespace data { + class Pipeline { + public: + std::shared_ptr<::Backend> backend; + std::vector> textures; + std::vector> samplers; + std::vector> targets; + std::vector> programs; + std::vector> slots; + std::vector> streams; + std::vector> commands; + }; +} +class Pipeline { +public: + enum class tag { + Pipeline + } tag; + std::shared_ptr Pipeline; +}; +#endif diff --git a/ddl/out/LambdaCube.Mesh.cpp b/ddl/out/LambdaCube.Mesh.cpp new file mode 100644 index 0000000..9f9599b --- /dev/null +++ b/ddl/out/LambdaCube.Mesh.cpp @@ -0,0 +1,228 @@ +// generated file, do not modify! +// 2016-01-28T13:15:31.220124Z + +#include "LambdaCube.Mesh.hpp" +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::MeshAttribute::tag::A_Float: + obj["tag"] = "A_Float"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::MeshAttribute::tag::A_V2F: + obj["tag"] = "A_V2F"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::MeshAttribute::tag::A_V3F: + obj["tag"] = "A_V3F"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::MeshAttribute::tag::A_V4F: + obj["tag"] = "A_V4F"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::MeshAttribute::tag::A_M22F: + obj["tag"] = "A_M22F"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::MeshAttribute::tag::A_M33F: + obj["tag"] = "A_M33F"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::MeshAttribute::tag::A_M44F: + obj["tag"] = "A_M44F"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::MeshAttribute::tag::A_Int: + obj["tag"] = "A_Int"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::MeshAttribute::tag::A_Word: + obj["tag"] = "A_Word"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::MeshAttribute::tag tagType; + std::string tag = obj["tag"]; + if (tag == "A_Float") { + tagType = ::MeshAttribute::tag::A_Float; + std::shared_ptr tv(new data::A_Float()); + tv->_0 = fromJSON(W>(), obj["arg0"]); + return tv; + } + else if (tag == "A_V2F") { + tagType = ::MeshAttribute::tag::A_V2F; + std::shared_ptr tv(new data::A_V2F()); + tv->_0 = fromJSON(W>(), obj["arg0"]); + return tv; + } + else if (tag == "A_V3F") { + tagType = ::MeshAttribute::tag::A_V3F; + std::shared_ptr tv(new data::A_V3F()); + tv->_0 = fromJSON(W>(), obj["arg0"]); + return tv; + } + else if (tag == "A_V4F") { + tagType = ::MeshAttribute::tag::A_V4F; + std::shared_ptr tv(new data::A_V4F()); + tv->_0 = fromJSON(W>(), obj["arg0"]); + return tv; + } + else if (tag == "A_M22F") { + tagType = ::MeshAttribute::tag::A_M22F; + std::shared_ptr tv(new data::A_M22F()); + tv->_0 = fromJSON(W>(), obj["arg0"]); + return tv; + } + else if (tag == "A_M33F") { + tagType = ::MeshAttribute::tag::A_M33F; + std::shared_ptr tv(new data::A_M33F()); + tv->_0 = fromJSON(W>(), obj["arg0"]); + return tv; + } + else if (tag == "A_M44F") { + tagType = ::MeshAttribute::tag::A_M44F; + std::shared_ptr tv(new data::A_M44F()); + tv->_0 = fromJSON(W>(), obj["arg0"]); + return tv; + } + else if (tag == "A_Int") { + tagType = ::MeshAttribute::tag::A_Int; + std::shared_ptr tv(new data::A_Int()); + tv->_0 = fromJSON(W>(), obj["arg0"]); + return tv; + } + else if (tag == "A_Word") { + tagType = ::MeshAttribute::tag::A_Word; + std::shared_ptr tv(new data::A_Word()); + tv->_0 = fromJSON(W>(), obj["arg0"]); + return tv; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::MeshAttribute> o(new ::MeshAttribute()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::MeshPrimitive::tag::P_Points: + obj["tag"] = "P_Points"; + break; + case ::MeshPrimitive::tag::P_TriangleStrip: + obj["tag"] = "P_TriangleStrip"; + break; + case ::MeshPrimitive::tag::P_Triangles: + obj["tag"] = "P_Triangles"; + break; + case ::MeshPrimitive::tag::P_TriangleStripI: + obj["tag"] = "P_TriangleStripI"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::MeshPrimitive::tag::P_TrianglesI: + obj["tag"] = "P_TrianglesI"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::MeshPrimitive::tag tagType; + std::string tag = obj["tag"]; + if (tag == "P_Points") { + tagType = ::MeshPrimitive::tag::P_Points; + } + else if (tag == "P_TriangleStrip") { + tagType = ::MeshPrimitive::tag::P_TriangleStrip; + } + else if (tag == "P_Triangles") { + tagType = ::MeshPrimitive::tag::P_Triangles; + } + else if (tag == "P_TriangleStripI") { + tagType = ::MeshPrimitive::tag::P_TriangleStripI; + std::shared_ptr tv(new data::P_TriangleStripI()); + tv->_0 = fromJSON(W>(), obj["arg0"]); + return tv; + } + else if (tag == "P_TrianglesI") { + tagType = ::MeshPrimitive::tag::P_TrianglesI; + std::shared_ptr tv(new data::P_TrianglesI()); + tv->_0 = fromJSON(W>(), obj["arg0"]); + return tv; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::MeshPrimitive> o(new ::MeshPrimitive()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::Mesh::tag::Mesh: + obj["tag"] = "Mesh"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["mAttributes"] = toJSON(tv->mAttributes); + obj["mPrimitive"] = toJSON(tv->mPrimitive); + } + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::Mesh::tag tagType; + std::string tag = obj["tag"]; + if (tag == "Mesh") { + tagType = ::Mesh::tag::Mesh; + std::shared_ptr tv(new data::Mesh()); + tv->mAttributes = fromJSON(W>>(), obj["mAttributes"]); + tv->mPrimitive = fromJSON(W>(), obj["mPrimitive"]); + return tv; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::Mesh> o(new ::Mesh()); + o->tag = tagType; + return o; +} + diff --git a/ddl/out/LambdaCube.Mesh.hpp b/ddl/out/LambdaCube.Mesh.hpp new file mode 100644 index 0000000..34583a2 --- /dev/null +++ b/ddl/out/LambdaCube.Mesh.hpp @@ -0,0 +1,107 @@ +// generated file, do not modify! +// 2016-01-28T13:15:31.220124Z + +#ifndef HEADER_LambdaCube.Mesh_H +#define HEADER_LambdaCube.Mesh_H + +#include "RT.hpp" + + +class MeshAttribute { + public: + enum class tag { + A_Float, + A_V2F, + A_V3F, + A_V4F, + A_M22F, + A_M33F, + A_M44F, + A_Int, + A_Word + } tag; +}; +namespace data { + class A_Float : public ::MeshAttribute { + public: + std::vector _0; + A_Float() { tag = tag::A_Float; } + }; + class A_V2F : public ::MeshAttribute { + public: + std::vector _0; + A_V2F() { tag = tag::A_V2F; } + }; + class A_V3F : public ::MeshAttribute { + public: + std::vector _0; + A_V3F() { tag = tag::A_V3F; } + }; + class A_V4F : public ::MeshAttribute { + public: + std::vector _0; + A_V4F() { tag = tag::A_V4F; } + }; + class A_M22F : public ::MeshAttribute { + public: + std::vector _0; + A_M22F() { tag = tag::A_M22F; } + }; + class A_M33F : public ::MeshAttribute { + public: + std::vector _0; + A_M33F() { tag = tag::A_M33F; } + }; + class A_M44F : public ::MeshAttribute { + public: + std::vector _0; + A_M44F() { tag = tag::A_M44F; } + }; + class A_Int : public ::MeshAttribute { + public: + std::vector _0; + A_Int() { tag = tag::A_Int; } + }; + class A_Word : public ::MeshAttribute { + public: + std::vector _0; + A_Word() { tag = tag::A_Word; } + }; +} +class MeshPrimitive { + public: + enum class tag { + P_Points, + P_TriangleStrip, + P_Triangles, + P_TriangleStripI, + P_TrianglesI + } tag; +}; +namespace data { + class P_TriangleStripI : public ::MeshPrimitive { + public: + std::vector _0; + P_TriangleStripI() { tag = tag::P_TriangleStripI; } + }; + class P_TrianglesI : public ::MeshPrimitive { + public: + std::vector _0; + P_TrianglesI() { tag = tag::P_TrianglesI; } + }; +} +class Mesh { + public: + enum class tag { + Mesh + } tag; +}; +namespace data { + class Mesh : public ::Mesh { + public: + std::map> mAttributes; + std::shared_ptr<::MeshPrimitive> mPrimitive; + Mesh() { tag = tag::Mesh; } + }; +} +#endif diff --git a/ddl/out/LambdaCube.Mesh.hs b/ddl/out/LambdaCube.Mesh.hs new file mode 100644 index 0000000..ad98c1b --- /dev/null +++ b/ddl/out/LambdaCube.Mesh.hs @@ -0,0 +1,114 @@ +-- generated file, do not modify! +-- 2016-01-28T13:15:31.220124Z + +{-# LANGUAGE OverloadedStrings, RecordWildCards #-} +module LambdaCube.Mesh where + +import Data.Int +import Data.Word +import Data.Map +import Data.Vector (Vector(..)) +import LambdaCube.Linear + +import Data.Text +import Data.Aeson hiding (Value,Bool) +import Data.Aeson.Types hiding (Value,Bool) +import Control.Monad + + +data MeshAttribute + = A_Float (Vector Float) + | A_V2F (Vector V2F) + | A_V3F (Vector V3F) + | A_V4F (Vector V4F) + | A_M22F (Vector M22F) + | A_M33F (Vector M33F) + | A_M44F (Vector M44F) + | A_Int (Vector Int32) + | A_Word (Vector Word32) + deriving (Show, Eq, Ord) + +data MeshPrimitive + = P_Points + | P_TriangleStrip + | P_Triangles + | P_TriangleStripI (Vector Int32) + | P_TrianglesI (Vector Int32) + deriving (Show, Eq, Ord) + +data Mesh + = Mesh + { mAttributes :: Map String MeshAttribute + , mPrimitive :: MeshPrimitive + } + + deriving (Show, Eq, Ord) + + +instance ToJSON MeshAttribute where + toJSON v = case v of + A_Float arg0 -> object [ "tag" .= ("A_Float" :: Text), "arg0" .= arg0] + A_V2F arg0 -> object [ "tag" .= ("A_V2F" :: Text), "arg0" .= arg0] + A_V3F arg0 -> object [ "tag" .= ("A_V3F" :: Text), "arg0" .= arg0] + A_V4F arg0 -> object [ "tag" .= ("A_V4F" :: Text), "arg0" .= arg0] + A_M22F arg0 -> object [ "tag" .= ("A_M22F" :: Text), "arg0" .= arg0] + A_M33F arg0 -> object [ "tag" .= ("A_M33F" :: Text), "arg0" .= arg0] + A_M44F arg0 -> object [ "tag" .= ("A_M44F" :: Text), "arg0" .= arg0] + A_Int arg0 -> object [ "tag" .= ("A_Int" :: Text), "arg0" .= arg0] + A_Word arg0 -> object [ "tag" .= ("A_Word" :: Text), "arg0" .= arg0] + +instance FromJSON MeshAttribute where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "A_Float" -> A_Float <$> obj .: "arg0" + "A_V2F" -> A_V2F <$> obj .: "arg0" + "A_V3F" -> A_V3F <$> obj .: "arg0" + "A_V4F" -> A_V4F <$> obj .: "arg0" + "A_M22F" -> A_M22F <$> obj .: "arg0" + "A_M33F" -> A_M33F <$> obj .: "arg0" + "A_M44F" -> A_M44F <$> obj .: "arg0" + "A_Int" -> A_Int <$> obj .: "arg0" + "A_Word" -> A_Word <$> obj .: "arg0" + parseJSON _ = mzero + +instance ToJSON MeshPrimitive where + toJSON v = case v of + P_Points -> object [ "tag" .= ("P_Points" :: Text)] + P_TriangleStrip -> object [ "tag" .= ("P_TriangleStrip" :: Text)] + P_Triangles -> object [ "tag" .= ("P_Triangles" :: Text)] + P_TriangleStripI arg0 -> object [ "tag" .= ("P_TriangleStripI" :: Text), "arg0" .= arg0] + P_TrianglesI arg0 -> object [ "tag" .= ("P_TrianglesI" :: Text), "arg0" .= arg0] + +instance FromJSON MeshPrimitive where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "P_Points" -> pure P_Points + "P_TriangleStrip" -> pure P_TriangleStrip + "P_Triangles" -> pure P_Triangles + "P_TriangleStripI" -> P_TriangleStripI <$> obj .: "arg0" + "P_TrianglesI" -> P_TrianglesI <$> obj .: "arg0" + parseJSON _ = mzero + +instance ToJSON Mesh where + toJSON v = case v of + Mesh{..} -> object + [ "tag" .= ("Mesh" :: Text) + , "mAttributes" .= mAttributes + , "mPrimitive" .= mPrimitive + ] + +instance FromJSON Mesh where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "Mesh" -> do + mAttributes <- obj .: "mAttributes" + mPrimitive <- obj .: "mPrimitive" + pure $ Mesh + { mAttributes = mAttributes + , mPrimitive = mPrimitive + } + parseJSON _ = mzero + diff --git a/ddl/out/LambdaCube.Mesh.purs b/ddl/out/LambdaCube.Mesh.purs new file mode 100644 index 0000000..230409f --- /dev/null +++ b/ddl/out/LambdaCube.Mesh.purs @@ -0,0 +1,113 @@ +-- generated file, do not modify! +-- 2016-01-28T13:15:31.220124Z + +module LambdaCube.Mesh where +import Prelude +import Data.Generic +import Data.Maybe (Maybe(..)) +import Data.StrMap (StrMap(..)) +import Data.Map (Map(..)) +import Data.List (List(..)) +import Linear + +import Data.Argonaut.Combinators ((~>), (:=), (.?)) +import Data.Argonaut.Core (jsonEmptyObject) +import Data.Argonaut.Printer (printJson) +import Data.Argonaut.Encode (EncodeJson, encodeJson) +import Data.Argonaut.Decode (DecodeJson, decodeJson) + + +data MeshAttribute + = A_Float (Array Float) + | A_V2F (Array V2F) + | A_V3F (Array V3F) + | A_V4F (Array V4F) + | A_M22F (Array M22F) + | A_M33F (Array M33F) + | A_M44F (Array M44F) + | A_Int (Array Int32) + | A_Word (Array Word32) + +data MeshPrimitive + = P_Points + | P_TriangleStrip + | P_Triangles + | P_TriangleStripI (Array Int32) + | P_TrianglesI (Array Int32) + +data Mesh + = Mesh + { mAttributes :: StrMap MeshAttribute + , mPrimitive :: MeshPrimitive + } + + + + +instance encodeJsonMeshAttribute :: EncodeJson MeshAttribute where + encodeJson v = case v of + A_Float arg0 -> "tag" := "A_Float" ~> "arg0" := arg0 ~> jsonEmptyObject + A_V2F arg0 -> "tag" := "A_V2F" ~> "arg0" := arg0 ~> jsonEmptyObject + A_V3F arg0 -> "tag" := "A_V3F" ~> "arg0" := arg0 ~> jsonEmptyObject + A_V4F arg0 -> "tag" := "A_V4F" ~> "arg0" := arg0 ~> jsonEmptyObject + A_M22F arg0 -> "tag" := "A_M22F" ~> "arg0" := arg0 ~> jsonEmptyObject + A_M33F arg0 -> "tag" := "A_M33F" ~> "arg0" := arg0 ~> jsonEmptyObject + A_M44F arg0 -> "tag" := "A_M44F" ~> "arg0" := arg0 ~> jsonEmptyObject + A_Int arg0 -> "tag" := "A_Int" ~> "arg0" := arg0 ~> jsonEmptyObject + A_Word arg0 -> "tag" := "A_Word" ~> "arg0" := arg0 ~> jsonEmptyObject + +instance decodeJsonMeshAttribute :: DecodeJson MeshAttribute where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "A_Float" -> A_Float <$> obj .? "arg0" + "A_V2F" -> A_V2F <$> obj .? "arg0" + "A_V3F" -> A_V3F <$> obj .? "arg0" + "A_V4F" -> A_V4F <$> obj .? "arg0" + "A_M22F" -> A_M22F <$> obj .? "arg0" + "A_M33F" -> A_M33F <$> obj .? "arg0" + "A_M44F" -> A_M44F <$> obj .? "arg0" + "A_Int" -> A_Int <$> obj .? "arg0" + "A_Word" -> A_Word <$> obj .? "arg0" + +instance encodeJsonMeshPrimitive :: EncodeJson MeshPrimitive where + encodeJson v = case v of + P_Points -> "tag" := "P_Points" ~> jsonEmptyObject + P_TriangleStrip -> "tag" := "P_TriangleStrip" ~> jsonEmptyObject + P_Triangles -> "tag" := "P_Triangles" ~> jsonEmptyObject + P_TriangleStripI arg0 -> "tag" := "P_TriangleStripI" ~> "arg0" := arg0 ~> jsonEmptyObject + P_TrianglesI arg0 -> "tag" := "P_TrianglesI" ~> "arg0" := arg0 ~> jsonEmptyObject + +instance decodeJsonMeshPrimitive :: DecodeJson MeshPrimitive where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "P_Points" -> pure P_Points + "P_TriangleStrip" -> pure P_TriangleStrip + "P_Triangles" -> pure P_Triangles + "P_TriangleStripI" -> P_TriangleStripI <$> obj .? "arg0" + "P_TrianglesI" -> P_TrianglesI <$> obj .? "arg0" + +instance encodeJsonMesh :: EncodeJson Mesh where + encodeJson v = case v of + Mesh r -> + "tag" := "Mesh" ~> + "mAttributes" := r.mAttributes ~> + "mPrimitive" := r.mPrimitive ~> + jsonEmptyObject + +instance decodeJsonMesh :: DecodeJson Mesh where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "Mesh" -> do + mAttributes <- obj .? "mAttributes" + mPrimitive <- obj .? "mPrimitive" + pure $ Mesh + { mAttributes:mAttributes + , mPrimitive:mPrimitive + } + diff --git a/ddl/out/LambdaCube.Mesh.swift b/ddl/out/LambdaCube.Mesh.swift new file mode 100644 index 0000000..6be1e16 --- /dev/null +++ b/ddl/out/LambdaCube.Mesh.swift @@ -0,0 +1,174 @@ +// generated file, do not modify! +// 2016-01-28T13:15:31.220124Z + +enum MeshAttribute { + case A_Float(Array) + case A_V2F(Array) + case A_V3F(Array) + case A_V4F(Array) + case A_M22F(Array) + case A_M33F(Array) + case A_M44F(Array) + case A_Int(Array) + case A_Word(Array) +} + +enum MeshPrimitive { + case P_Points + case P_TriangleStrip + case P_Triangles + case P_TriangleStripI(Array) + case P_TrianglesI(Array) +} + +enum Mesh { + case Mesh(Mesh_Data) + struct Mesh_Data { + var mAttributes : Dictionary + var mPrimitive : MeshPrimitive + } +} + + +extension Int { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension Int32 { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension UInt { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension UInt32 { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension Float { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension Bool { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension String { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension Array { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension Dictionary { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension Maybe { + var toJSON : [String: AnyObject] { + return ["":""] + } +} + + + +extension MeshAttribute { + var toJSON : [String: AnyObject] { + switch self { + case .A_Float(let arg0): + return [ "tag" : "A_Float", "arg0" : arg0.toJSON] + case .A_V2F(let arg0): + return [ "tag" : "A_V2F", "arg0" : arg0.toJSON] + case .A_V3F(let arg0): + return [ "tag" : "A_V3F", "arg0" : arg0.toJSON] + case .A_V4F(let arg0): + return [ "tag" : "A_V4F", "arg0" : arg0.toJSON] + case .A_M22F(let arg0): + return [ "tag" : "A_M22F", "arg0" : arg0.toJSON] + case .A_M33F(let arg0): + return [ "tag" : "A_M33F", "arg0" : arg0.toJSON] + case .A_M44F(let arg0): + return [ "tag" : "A_M44F", "arg0" : arg0.toJSON] + case .A_Int(let arg0): + return [ "tag" : "A_Int", "arg0" : arg0.toJSON] + case .A_Word(let arg0): + return [ "tag" : "A_Word", "arg0" : arg0.toJSON] + } + } +} +extension MeshPrimitive { + var toJSON : [String: AnyObject] { + switch self { + case .P_Points: + return [ "tag" : "P_Points"] + case .P_TriangleStrip: + return [ "tag" : "P_TriangleStrip"] + case .P_Triangles: + return [ "tag" : "P_Triangles"] + case .P_TriangleStripI(let arg0): + return [ "tag" : "P_TriangleStripI", "arg0" : arg0.toJSON] + case .P_TrianglesI(let arg0): + return [ "tag" : "P_TrianglesI", "arg0" : arg0.toJSON] + } + } +} +extension Mesh { + var toJSON : [String: AnyObject] { + switch self { + case .Mesh(let v): + return [ "tag" : "Mesh" + , "mAttributes" : v.mAttributes.toJSON + , "mPrimitive" : v.mPrimitive.toJSON + ] + } + } +} + +enum Maybe { + case Nothing + case Just(T) +} + +enum Type { + case Int + case Int32 + case Word + case Word32 + case Float + case Bool + case String + case Array(Type) + case List(Type) + case Maybe(Type) + case Map(Type,Type) + case MeshAttribute + case MeshPrimitive + case Mesh +} + +func fromJSON(type: Type, personName: String) -> Any { + switch type { + case .Int: return 0 + case .Int32: return 0 + case .Word: return 0 + case .Word32: return 0 + case .Float: return 0.0 + case .Bool: return false + case .String: return "" + case .Array(let a): return fromJSON(a,personName) + case .List(let a): return fromJSON(a,personName) + case .Maybe(let a): return fromJSON(a,personName) + } + return 0; +} \ No newline at end of file diff --git a/ddl/out/LambdaCube.Mesh2.hpp b/ddl/out/LambdaCube.Mesh2.hpp new file mode 100644 index 0000000..4978258 --- /dev/null +++ b/ddl/out/LambdaCube.Mesh2.hpp @@ -0,0 +1,107 @@ +// generated file, do not modify! +// 2016-01-28T13:15:31.220124Z + +#ifndef HEADER_LambdaCube.Mesh_H +#define HEADER_LambdaCube.Mesh_H + +#include "RT.hpp" + + +namespace data { + class A_Float { + public: + std::vector _0; + }; + class A_V2F { + public: + std::vector _0; + }; + class A_V3F { + public: + std::vector _0; + }; + class A_V4F { + public: + std::vector _0; + }; + class A_M22F { + public: + std::vector _0; + }; + class A_M33F { + public: + std::vector _0; + }; + class A_M44F { + public: + std::vector _0; + }; + class A_Int { + public: + std::vector _0; + }; + class A_Word { + public: + std::vector _0; + }; +} +class MeshAttribute { +public: + enum class tag { + A_Float, + A_V2F, + A_V3F, + A_V4F, + A_M22F, + A_M33F, + A_M44F, + A_Int, + A_Word + } tag; + std::shared_ptr A_Float; + std::shared_ptr A_V2F; + std::shared_ptr A_V3F; + std::shared_ptr A_V4F; + std::shared_ptr A_M22F; + std::shared_ptr A_M33F; + std::shared_ptr A_M44F; + std::shared_ptr A_Int; + std::shared_ptr A_Word; +}; +namespace data { + class P_TriangleStripI { + public: + std::vector _0; + }; + class P_TrianglesI { + public: + std::vector _0; + }; +} +class MeshPrimitive { +public: + enum class tag { + P_Points, + P_TriangleStrip, + P_Triangles, + P_TriangleStripI, + P_TrianglesI + } tag; + std::shared_ptr P_TriangleStripI; + std::shared_ptr P_TrianglesI; +}; +namespace data { + class Mesh { + public: + std::map> mAttributes; + std::shared_ptr<::MeshPrimitive> mPrimitive; + }; +} +class Mesh { +public: + enum class tag { + Mesh + } tag; + std::shared_ptr Mesh; +}; +#endif 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 @@ +// generated file, do not modify! +// 2016-01-28T13:15:31.196716Z + +#include "LambdaCube.PipelineSchema.hpp" +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::StreamType::tag::Attribute_Word: + obj["tag"] = "Attribute_Word"; + break; + case ::StreamType::tag::Attribute_V2U: + obj["tag"] = "Attribute_V2U"; + break; + case ::StreamType::tag::Attribute_V3U: + obj["tag"] = "Attribute_V3U"; + break; + case ::StreamType::tag::Attribute_V4U: + obj["tag"] = "Attribute_V4U"; + break; + case ::StreamType::tag::Attribute_Int: + obj["tag"] = "Attribute_Int"; + break; + case ::StreamType::tag::Attribute_V2I: + obj["tag"] = "Attribute_V2I"; + break; + case ::StreamType::tag::Attribute_V3I: + obj["tag"] = "Attribute_V3I"; + break; + case ::StreamType::tag::Attribute_V4I: + obj["tag"] = "Attribute_V4I"; + break; + case ::StreamType::tag::Attribute_Float: + obj["tag"] = "Attribute_Float"; + break; + case ::StreamType::tag::Attribute_V2F: + obj["tag"] = "Attribute_V2F"; + break; + case ::StreamType::tag::Attribute_V3F: + obj["tag"] = "Attribute_V3F"; + break; + case ::StreamType::tag::Attribute_V4F: + obj["tag"] = "Attribute_V4F"; + break; + case ::StreamType::tag::Attribute_M22F: + obj["tag"] = "Attribute_M22F"; + break; + case ::StreamType::tag::Attribute_M23F: + obj["tag"] = "Attribute_M23F"; + break; + case ::StreamType::tag::Attribute_M24F: + obj["tag"] = "Attribute_M24F"; + break; + case ::StreamType::tag::Attribute_M32F: + obj["tag"] = "Attribute_M32F"; + break; + case ::StreamType::tag::Attribute_M33F: + obj["tag"] = "Attribute_M33F"; + break; + case ::StreamType::tag::Attribute_M34F: + obj["tag"] = "Attribute_M34F"; + break; + case ::StreamType::tag::Attribute_M42F: + obj["tag"] = "Attribute_M42F"; + break; + case ::StreamType::tag::Attribute_M43F: + obj["tag"] = "Attribute_M43F"; + break; + case ::StreamType::tag::Attribute_M44F: + obj["tag"] = "Attribute_M44F"; + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::StreamType::tag tagType; + std::string tag = obj["tag"]; + if (tag == "Attribute_Word") { + tagType = ::StreamType::tag::Attribute_Word; + } + else if (tag == "Attribute_V2U") { + tagType = ::StreamType::tag::Attribute_V2U; + } + else if (tag == "Attribute_V3U") { + tagType = ::StreamType::tag::Attribute_V3U; + } + else if (tag == "Attribute_V4U") { + tagType = ::StreamType::tag::Attribute_V4U; + } + else if (tag == "Attribute_Int") { + tagType = ::StreamType::tag::Attribute_Int; + } + else if (tag == "Attribute_V2I") { + tagType = ::StreamType::tag::Attribute_V2I; + } + else if (tag == "Attribute_V3I") { + tagType = ::StreamType::tag::Attribute_V3I; + } + else if (tag == "Attribute_V4I") { + tagType = ::StreamType::tag::Attribute_V4I; + } + else if (tag == "Attribute_Float") { + tagType = ::StreamType::tag::Attribute_Float; + } + else if (tag == "Attribute_V2F") { + tagType = ::StreamType::tag::Attribute_V2F; + } + else if (tag == "Attribute_V3F") { + tagType = ::StreamType::tag::Attribute_V3F; + } + else if (tag == "Attribute_V4F") { + tagType = ::StreamType::tag::Attribute_V4F; + } + else if (tag == "Attribute_M22F") { + tagType = ::StreamType::tag::Attribute_M22F; + } + else if (tag == "Attribute_M23F") { + tagType = ::StreamType::tag::Attribute_M23F; + } + else if (tag == "Attribute_M24F") { + tagType = ::StreamType::tag::Attribute_M24F; + } + else if (tag == "Attribute_M32F") { + tagType = ::StreamType::tag::Attribute_M32F; + } + else if (tag == "Attribute_M33F") { + tagType = ::StreamType::tag::Attribute_M33F; + } + else if (tag == "Attribute_M34F") { + tagType = ::StreamType::tag::Attribute_M34F; + } + else if (tag == "Attribute_M42F") { + tagType = ::StreamType::tag::Attribute_M42F; + } + else if (tag == "Attribute_M43F") { + tagType = ::StreamType::tag::Attribute_M43F; + } + else if (tag == "Attribute_M44F") { + tagType = ::StreamType::tag::Attribute_M44F; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::StreamType> o(new ::StreamType()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::ObjectArraySchema::tag::ObjectArraySchema: + obj["tag"] = "ObjectArraySchema"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["primitive"] = toJSON(tv->primitive); + obj["attributes"] = toJSON(tv->attributes); + } + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::ObjectArraySchema::tag tagType; + std::string tag = obj["tag"]; + if (tag == "ObjectArraySchema") { + tagType = ::ObjectArraySchema::tag::ObjectArraySchema; + std::shared_ptr tv(new data::ObjectArraySchema()); + tv->primitive = fromJSON(W>(), obj["primitive"]); + tv->attributes = fromJSON(W>>(), obj["attributes"]); + return tv; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::ObjectArraySchema> o(new ::ObjectArraySchema()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::PipelineSchema::tag::PipelineSchema: + obj["tag"] = "PipelineSchema"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["objectArrays"] = toJSON(tv->objectArrays); + obj["uniforms"] = toJSON(tv->uniforms); + } + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::PipelineSchema::tag tagType; + std::string tag = obj["tag"]; + if (tag == "PipelineSchema") { + tagType = ::PipelineSchema::tag::PipelineSchema; + std::shared_ptr tv(new data::PipelineSchema()); + tv->objectArrays = fromJSON(W>>(), obj["objectArrays"]); + tv->uniforms = fromJSON(W>>(), obj["uniforms"]); + return tv; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::PipelineSchema> o(new ::PipelineSchema()); + o->tag = tagType; + return o; +} + 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 @@ +// generated file, do not modify! +// 2016-01-28T13:15:31.196716Z + +#ifndef HEADER_LambdaCube.PipelineSchema_H +#define HEADER_LambdaCube.PipelineSchema_H + +#include "RT.hpp" + +#include "LambdaCube.IR.hpp" + +class StreamType { + public: + enum class tag { + Attribute_Word, + Attribute_V2U, + Attribute_V3U, + Attribute_V4U, + Attribute_Int, + Attribute_V2I, + Attribute_V3I, + Attribute_V4I, + Attribute_Float, + Attribute_V2F, + Attribute_V3F, + Attribute_V4F, + Attribute_M22F, + Attribute_M23F, + Attribute_M24F, + Attribute_M32F, + Attribute_M33F, + Attribute_M34F, + Attribute_M42F, + Attribute_M43F, + Attribute_M44F + } tag; +}; +namespace data { +} +class ObjectArraySchema { + public: + enum class tag { + ObjectArraySchema + } tag; +}; +namespace data { + class ObjectArraySchema : public ::ObjectArraySchema { + public: + std::shared_ptr<::FetchPrimitive> primitive; + std::map> attributes; + ObjectArraySchema() { tag = tag::ObjectArraySchema; } + }; +} +class PipelineSchema { + public: + enum class tag { + PipelineSchema + } tag; +}; +namespace data { + class PipelineSchema : public ::PipelineSchema { + public: + std::map> objectArrays; + std::map> uniforms; + PipelineSchema() { tag = tag::PipelineSchema; } + }; +} +#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 @@ +-- generated file, do not modify! +-- 2016-01-28T13:15:31.196716Z + +{-# LANGUAGE OverloadedStrings, RecordWildCards #-} +module LambdaCube.PipelineSchema where + +import Data.Int +import Data.Word +import Data.Map +import Data.Vector (Vector(..)) +import LambdaCube.Linear + +import Data.Text +import Data.Aeson hiding (Value,Bool) +import Data.Aeson.Types hiding (Value,Bool) +import Control.Monad + +import LambdaCube.IR + +data StreamType + = Attribute_Word + | Attribute_V2U + | Attribute_V3U + | Attribute_V4U + | Attribute_Int + | Attribute_V2I + | Attribute_V3I + | Attribute_V4I + | Attribute_Float + | Attribute_V2F + | Attribute_V3F + | Attribute_V4F + | Attribute_M22F + | Attribute_M23F + | Attribute_M24F + | Attribute_M32F + | Attribute_M33F + | Attribute_M34F + | Attribute_M42F + | Attribute_M43F + | Attribute_M44F + deriving (Show, Eq, Ord) + +data ObjectArraySchema + = ObjectArraySchema + { primitive :: FetchPrimitive + , attributes :: Map String StreamType + } + + deriving (Show, Eq, Ord) + +data PipelineSchema + = PipelineSchema + { objectArrays :: Map String ObjectArraySchema + , uniforms :: Map String InputType + } + + deriving (Show, Eq, Ord) + + +instance ToJSON StreamType where + toJSON v = case v of + Attribute_Word -> object [ "tag" .= ("Attribute_Word" :: Text)] + Attribute_V2U -> object [ "tag" .= ("Attribute_V2U" :: Text)] + Attribute_V3U -> object [ "tag" .= ("Attribute_V3U" :: Text)] + Attribute_V4U -> object [ "tag" .= ("Attribute_V4U" :: Text)] + Attribute_Int -> object [ "tag" .= ("Attribute_Int" :: Text)] + Attribute_V2I -> object [ "tag" .= ("Attribute_V2I" :: Text)] + Attribute_V3I -> object [ "tag" .= ("Attribute_V3I" :: Text)] + Attribute_V4I -> object [ "tag" .= ("Attribute_V4I" :: Text)] + Attribute_Float -> object [ "tag" .= ("Attribute_Float" :: Text)] + Attribute_V2F -> object [ "tag" .= ("Attribute_V2F" :: Text)] + Attribute_V3F -> object [ "tag" .= ("Attribute_V3F" :: Text)] + Attribute_V4F -> object [ "tag" .= ("Attribute_V4F" :: Text)] + Attribute_M22F -> object [ "tag" .= ("Attribute_M22F" :: Text)] + Attribute_M23F -> object [ "tag" .= ("Attribute_M23F" :: Text)] + Attribute_M24F -> object [ "tag" .= ("Attribute_M24F" :: Text)] + Attribute_M32F -> object [ "tag" .= ("Attribute_M32F" :: Text)] + Attribute_M33F -> object [ "tag" .= ("Attribute_M33F" :: Text)] + Attribute_M34F -> object [ "tag" .= ("Attribute_M34F" :: Text)] + Attribute_M42F -> object [ "tag" .= ("Attribute_M42F" :: Text)] + Attribute_M43F -> object [ "tag" .= ("Attribute_M43F" :: Text)] + Attribute_M44F -> object [ "tag" .= ("Attribute_M44F" :: Text)] + +instance FromJSON StreamType where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "Attribute_Word" -> pure Attribute_Word + "Attribute_V2U" -> pure Attribute_V2U + "Attribute_V3U" -> pure Attribute_V3U + "Attribute_V4U" -> pure Attribute_V4U + "Attribute_Int" -> pure Attribute_Int + "Attribute_V2I" -> pure Attribute_V2I + "Attribute_V3I" -> pure Attribute_V3I + "Attribute_V4I" -> pure Attribute_V4I + "Attribute_Float" -> pure Attribute_Float + "Attribute_V2F" -> pure Attribute_V2F + "Attribute_V3F" -> pure Attribute_V3F + "Attribute_V4F" -> pure Attribute_V4F + "Attribute_M22F" -> pure Attribute_M22F + "Attribute_M23F" -> pure Attribute_M23F + "Attribute_M24F" -> pure Attribute_M24F + "Attribute_M32F" -> pure Attribute_M32F + "Attribute_M33F" -> pure Attribute_M33F + "Attribute_M34F" -> pure Attribute_M34F + "Attribute_M42F" -> pure Attribute_M42F + "Attribute_M43F" -> pure Attribute_M43F + "Attribute_M44F" -> pure Attribute_M44F + parseJSON _ = mzero + +instance ToJSON ObjectArraySchema where + toJSON v = case v of + ObjectArraySchema{..} -> object + [ "tag" .= ("ObjectArraySchema" :: Text) + , "primitive" .= primitive + , "attributes" .= attributes + ] + +instance FromJSON ObjectArraySchema where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "ObjectArraySchema" -> do + primitive <- obj .: "primitive" + attributes <- obj .: "attributes" + pure $ ObjectArraySchema + { primitive = primitive + , attributes = attributes + } + parseJSON _ = mzero + +instance ToJSON PipelineSchema where + toJSON v = case v of + PipelineSchema{..} -> object + [ "tag" .= ("PipelineSchema" :: Text) + , "objectArrays" .= objectArrays + , "uniforms" .= uniforms + ] + +instance FromJSON PipelineSchema where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "PipelineSchema" -> do + objectArrays <- obj .: "objectArrays" + uniforms <- obj .: "uniforms" + pure $ PipelineSchema + { objectArrays = objectArrays + , uniforms = uniforms + } + parseJSON _ = mzero + 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 @@ +-- generated file, do not modify! +-- 2016-01-28T13:15:31.196716Z + +module LambdaCube.PipelineSchema where +import Prelude +import Data.Generic +import Data.Maybe (Maybe(..)) +import Data.StrMap (StrMap(..)) +import Data.Map (Map(..)) +import Data.List (List(..)) +import Linear + +import Data.Argonaut.Combinators ((~>), (:=), (.?)) +import Data.Argonaut.Core (jsonEmptyObject) +import Data.Argonaut.Printer (printJson) +import Data.Argonaut.Encode (EncodeJson, encodeJson) +import Data.Argonaut.Decode (DecodeJson, decodeJson) + +import LambdaCube.IR + +data StreamType + = Attribute_Word + | Attribute_V2U + | Attribute_V3U + | Attribute_V4U + | Attribute_Int + | Attribute_V2I + | Attribute_V3I + | Attribute_V4I + | Attribute_Float + | Attribute_V2F + | Attribute_V3F + | Attribute_V4F + | Attribute_M22F + | Attribute_M23F + | Attribute_M24F + | Attribute_M32F + | Attribute_M33F + | Attribute_M34F + | Attribute_M42F + | Attribute_M43F + | Attribute_M44F + +data ObjectArraySchema + = ObjectArraySchema + { primitive :: FetchPrimitive + , attributes :: StrMap StreamType + } + + +data PipelineSchema + = PipelineSchema + { objectArrays :: StrMap ObjectArraySchema + , uniforms :: StrMap InputType + } + + + + +instance encodeJsonStreamType :: EncodeJson StreamType where + encodeJson v = case v of + Attribute_Word -> "tag" := "Attribute_Word" ~> jsonEmptyObject + Attribute_V2U -> "tag" := "Attribute_V2U" ~> jsonEmptyObject + Attribute_V3U -> "tag" := "Attribute_V3U" ~> jsonEmptyObject + Attribute_V4U -> "tag" := "Attribute_V4U" ~> jsonEmptyObject + Attribute_Int -> "tag" := "Attribute_Int" ~> jsonEmptyObject + Attribute_V2I -> "tag" := "Attribute_V2I" ~> jsonEmptyObject + Attribute_V3I -> "tag" := "Attribute_V3I" ~> jsonEmptyObject + Attribute_V4I -> "tag" := "Attribute_V4I" ~> jsonEmptyObject + Attribute_Float -> "tag" := "Attribute_Float" ~> jsonEmptyObject + Attribute_V2F -> "tag" := "Attribute_V2F" ~> jsonEmptyObject + Attribute_V3F -> "tag" := "Attribute_V3F" ~> jsonEmptyObject + Attribute_V4F -> "tag" := "Attribute_V4F" ~> jsonEmptyObject + Attribute_M22F -> "tag" := "Attribute_M22F" ~> jsonEmptyObject + Attribute_M23F -> "tag" := "Attribute_M23F" ~> jsonEmptyObject + Attribute_M24F -> "tag" := "Attribute_M24F" ~> jsonEmptyObject + Attribute_M32F -> "tag" := "Attribute_M32F" ~> jsonEmptyObject + Attribute_M33F -> "tag" := "Attribute_M33F" ~> jsonEmptyObject + Attribute_M34F -> "tag" := "Attribute_M34F" ~> jsonEmptyObject + Attribute_M42F -> "tag" := "Attribute_M42F" ~> jsonEmptyObject + Attribute_M43F -> "tag" := "Attribute_M43F" ~> jsonEmptyObject + Attribute_M44F -> "tag" := "Attribute_M44F" ~> jsonEmptyObject + +instance decodeJsonStreamType :: DecodeJson StreamType where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "Attribute_Word" -> pure Attribute_Word + "Attribute_V2U" -> pure Attribute_V2U + "Attribute_V3U" -> pure Attribute_V3U + "Attribute_V4U" -> pure Attribute_V4U + "Attribute_Int" -> pure Attribute_Int + "Attribute_V2I" -> pure Attribute_V2I + "Attribute_V3I" -> pure Attribute_V3I + "Attribute_V4I" -> pure Attribute_V4I + "Attribute_Float" -> pure Attribute_Float + "Attribute_V2F" -> pure Attribute_V2F + "Attribute_V3F" -> pure Attribute_V3F + "Attribute_V4F" -> pure Attribute_V4F + "Attribute_M22F" -> pure Attribute_M22F + "Attribute_M23F" -> pure Attribute_M23F + "Attribute_M24F" -> pure Attribute_M24F + "Attribute_M32F" -> pure Attribute_M32F + "Attribute_M33F" -> pure Attribute_M33F + "Attribute_M34F" -> pure Attribute_M34F + "Attribute_M42F" -> pure Attribute_M42F + "Attribute_M43F" -> pure Attribute_M43F + "Attribute_M44F" -> pure Attribute_M44F + +instance encodeJsonObjectArraySchema :: EncodeJson ObjectArraySchema where + encodeJson v = case v of + ObjectArraySchema r -> + "tag" := "ObjectArraySchema" ~> + "primitive" := r.primitive ~> + "attributes" := r.attributes ~> + jsonEmptyObject + +instance decodeJsonObjectArraySchema :: DecodeJson ObjectArraySchema where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "ObjectArraySchema" -> do + primitive <- obj .? "primitive" + attributes <- obj .? "attributes" + pure $ ObjectArraySchema + { primitive:primitive + , attributes:attributes + } + +instance encodeJsonPipelineSchema :: EncodeJson PipelineSchema where + encodeJson v = case v of + PipelineSchema r -> + "tag" := "PipelineSchema" ~> + "objectArrays" := r.objectArrays ~> + "uniforms" := r.uniforms ~> + jsonEmptyObject + +instance decodeJsonPipelineSchema :: DecodeJson PipelineSchema where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "PipelineSchema" -> do + objectArrays <- obj .? "objectArrays" + uniforms <- obj .? "uniforms" + pure $ PipelineSchema + { objectArrays:objectArrays + , uniforms:uniforms + } + 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 @@ +// generated file, do not modify! +// 2016-01-28T13:15:31.196716Z + +enum StreamType { + case Attribute_Word + case Attribute_V2U + case Attribute_V3U + case Attribute_V4U + case Attribute_Int + case Attribute_V2I + case Attribute_V3I + case Attribute_V4I + case Attribute_Float + case Attribute_V2F + case Attribute_V3F + case Attribute_V4F + case Attribute_M22F + case Attribute_M23F + case Attribute_M24F + case Attribute_M32F + case Attribute_M33F + case Attribute_M34F + case Attribute_M42F + case Attribute_M43F + case Attribute_M44F +} + +enum ObjectArraySchema { + case ObjectArraySchema(ObjectArraySchema_Data) + struct ObjectArraySchema_Data { + var primitive : FetchPrimitive + var attributes : Dictionary + } +} + +enum PipelineSchema { + case PipelineSchema(PipelineSchema_Data) + struct PipelineSchema_Data { + var objectArrays : Dictionary + var uniforms : Dictionary + } +} + + +extension Int { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension Int32 { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension UInt { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension UInt32 { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension Float { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension Bool { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension String { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension Array { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension Dictionary { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension Maybe { + var toJSON : [String: AnyObject] { + return ["":""] + } +} + + + +extension StreamType { + var toJSON : [String: AnyObject] { + switch self { + case .Attribute_Word: + return [ "tag" : "Attribute_Word"] + case .Attribute_V2U: + return [ "tag" : "Attribute_V2U"] + case .Attribute_V3U: + return [ "tag" : "Attribute_V3U"] + case .Attribute_V4U: + return [ "tag" : "Attribute_V4U"] + case .Attribute_Int: + return [ "tag" : "Attribute_Int"] + case .Attribute_V2I: + return [ "tag" : "Attribute_V2I"] + case .Attribute_V3I: + return [ "tag" : "Attribute_V3I"] + case .Attribute_V4I: + return [ "tag" : "Attribute_V4I"] + case .Attribute_Float: + return [ "tag" : "Attribute_Float"] + case .Attribute_V2F: + return [ "tag" : "Attribute_V2F"] + case .Attribute_V3F: + return [ "tag" : "Attribute_V3F"] + case .Attribute_V4F: + return [ "tag" : "Attribute_V4F"] + case .Attribute_M22F: + return [ "tag" : "Attribute_M22F"] + case .Attribute_M23F: + return [ "tag" : "Attribute_M23F"] + case .Attribute_M24F: + return [ "tag" : "Attribute_M24F"] + case .Attribute_M32F: + return [ "tag" : "Attribute_M32F"] + case .Attribute_M33F: + return [ "tag" : "Attribute_M33F"] + case .Attribute_M34F: + return [ "tag" : "Attribute_M34F"] + case .Attribute_M42F: + return [ "tag" : "Attribute_M42F"] + case .Attribute_M43F: + return [ "tag" : "Attribute_M43F"] + case .Attribute_M44F: + return [ "tag" : "Attribute_M44F"] + } + } +} +extension ObjectArraySchema { + var toJSON : [String: AnyObject] { + switch self { + case .ObjectArraySchema(let v): + return [ "tag" : "ObjectArraySchema" + , "primitive" : v.primitive.toJSON + , "attributes" : v.attributes.toJSON + ] + } + } +} +extension PipelineSchema { + var toJSON : [String: AnyObject] { + switch self { + case .PipelineSchema(let v): + return [ "tag" : "PipelineSchema" + , "objectArrays" : v.objectArrays.toJSON + , "uniforms" : v.uniforms.toJSON + ] + } + } +} + +enum Maybe { + case Nothing + case Just(T) +} + +enum Type { + case Int + case Int32 + case Word + case Word32 + case Float + case Bool + case String + case Array(Type) + case List(Type) + case Maybe(Type) + case Map(Type,Type) + case StreamType + case ObjectArraySchema + case PipelineSchema +} + +func fromJSON(type: Type, personName: String) -> Any { + switch type { + case .Int: return 0 + case .Int32: return 0 + case .Word: return 0 + case .Word32: return 0 + case .Float: return 0.0 + case .Bool: return false + case .String: return "" + case .Array(let a): return fromJSON(a,personName) + case .List(let a): return fromJSON(a,personName) + case .Maybe(let a): return fromJSON(a,personName) + } + return 0; +} \ 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 @@ +// generated file, do not modify! +// 2016-01-28T13:15:31.196716Z + +#ifndef HEADER_LambdaCube.PipelineSchema_H +#define HEADER_LambdaCube.PipelineSchema_H + +#include "RT.hpp" + +#include "LambdaCube.IR.hpp" + +namespace data { +} +class StreamType { +public: + enum class tag { + Attribute_Word, + Attribute_V2U, + Attribute_V3U, + Attribute_V4U, + Attribute_Int, + Attribute_V2I, + Attribute_V3I, + Attribute_V4I, + Attribute_Float, + Attribute_V2F, + Attribute_V3F, + Attribute_V4F, + Attribute_M22F, + Attribute_M23F, + Attribute_M24F, + Attribute_M32F, + Attribute_M33F, + Attribute_M34F, + Attribute_M42F, + Attribute_M43F, + Attribute_M44F + } tag; +}; +namespace data { + class ObjectArraySchema { + public: + std::shared_ptr<::FetchPrimitive> primitive; + std::map> attributes; + }; +} +class ObjectArraySchema { +public: + enum class tag { + ObjectArraySchema + } tag; + std::shared_ptr ObjectArraySchema; +}; +namespace data { + class PipelineSchema { + public: + std::map> objectArrays; + std::map> uniforms; + }; +} +class PipelineSchema { +public: + enum class tag { + PipelineSchema + } tag; + std::shared_ptr PipelineSchema; +}; +#endif diff --git a/ddl/out/LambdaCube.TypeInfo.cpp b/ddl/out/LambdaCube.TypeInfo.cpp new file mode 100644 index 0000000..7ad7fea --- /dev/null +++ b/ddl/out/LambdaCube.TypeInfo.cpp @@ -0,0 +1,89 @@ +// generated file, do not modify! +// 2016-01-28T13:15:31.255126Z + +#include "LambdaCube.TypeInfo.hpp" +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::TypeInfo::tag::TypeInfo: + obj["tag"] = "TypeInfo"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["startLine"] = toJSON(tv->startLine); + obj["startColumn"] = toJSON(tv->startColumn); + obj["endLine"] = toJSON(tv->endLine); + obj["endColumn"] = toJSON(tv->endColumn); + obj["text"] = toJSON(tv->text); + } + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::TypeInfo::tag tagType; + std::string tag = obj["tag"]; + if (tag == "TypeInfo") { + tagType = ::TypeInfo::tag::TypeInfo; + std::shared_ptr tv(new data::TypeInfo()); + tv->startLine = fromJSON(W(), obj["startLine"]); + tv->startColumn = fromJSON(W(), obj["startColumn"]); + tv->endLine = fromJSON(W(), obj["endLine"]); + tv->endColumn = fromJSON(W(), obj["endColumn"]); + tv->text = fromJSON(W(), obj["text"]); + return tv; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::TypeInfo> o(new ::TypeInfo()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::MyEither::tag::MyLeft: + obj["tag"] = "MyLeft"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + obj["arg1"] = toJSON(tv->_1); + } + break; + case ::MyEither::tag::MyRight: + obj["tag"] = "MyRight"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + obj["arg1"] = toJSON(tv->_1); + obj["arg2"] = toJSON(tv->_2); + } + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::MyEither::tag tagType; + std::string tag = obj["tag"]; + if (tag == "MyLeft") { + tagType = ::MyEither::tag::MyLeft; + std::shared_ptr tv(new data::MyLeft()); + tv->_0 = fromJSON(W>(), obj["arg0"]); + tv->_1 = fromJSON(W>>(), obj["arg1"]); + return tv; + } + else if (tag == "MyRight") { + tagType = ::MyEither::tag::MyRight; + std::shared_ptr tv(new data::MyRight()); + tv->_0 = fromJSON(W(), obj["arg0"]); + tv->_1 = fromJSON(W>(), obj["arg1"]); + tv->_2 = fromJSON(W>>(), obj["arg2"]); + return tv; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::MyEither> o(new ::MyEither()); + o->tag = tagType; + return o; +} + diff --git a/ddl/out/LambdaCube.TypeInfo.hpp b/ddl/out/LambdaCube.TypeInfo.hpp new file mode 100644 index 0000000..d2f239b --- /dev/null +++ b/ddl/out/LambdaCube.TypeInfo.hpp @@ -0,0 +1,50 @@ +// generated file, do not modify! +// 2016-01-28T13:15:31.255126Z + +#ifndef HEADER_LambdaCube.TypeInfo_H +#define HEADER_LambdaCube.TypeInfo_H + +#include "RT.hpp" + +#include "LambdaCube.IR.hpp" + +class TypeInfo { + public: + enum class tag { + TypeInfo + } tag; +}; +namespace data { + class TypeInfo : public ::TypeInfo { + public: + Int startLine; + Int startColumn; + Int endLine; + Int endColumn; + String text; + TypeInfo() { tag = tag::TypeInfo; } + }; +} +class MyEither { + public: + enum class tag { + MyLeft, + MyRight + } tag; +}; +namespace data { + class MyLeft : public ::MyEither { + public: + std::shared_ptr<::TypeInfo> _0; + std::vector> _1; + MyLeft() { tag = tag::MyLeft; } + }; + class MyRight : public ::MyEither { + public: + String _0; + std::shared_ptr<::Pipeline> _1; + std::vector> _2; + MyRight() { tag = tag::MyRight; } + }; +} +#endif diff --git a/ddl/out/LambdaCube.TypeInfo.hs b/ddl/out/LambdaCube.TypeInfo.hs new file mode 100644 index 0000000..453057d --- /dev/null +++ b/ddl/out/LambdaCube.TypeInfo.hs @@ -0,0 +1,79 @@ +-- generated file, do not modify! +-- 2016-01-28T13:15:31.255126Z + +{-# LANGUAGE OverloadedStrings, RecordWildCards #-} +module LambdaCube.TypeInfo where + +import Data.Int +import Data.Word +import Data.Map +import Data.Vector (Vector(..)) +import LambdaCube.Linear + +import Data.Text +import Data.Aeson hiding (Value,Bool) +import Data.Aeson.Types hiding (Value,Bool) +import Control.Monad + +import LambdaCube.IR + +data TypeInfo + = TypeInfo + { startLine :: Int + , startColumn :: Int + , endLine :: Int + , endColumn :: Int + , text :: String + } + + deriving (Show, Eq, Ord) + +data MyEither + = MyLeft TypeInfo (Vector TypeInfo) + | MyRight String Pipeline (Vector TypeInfo) + deriving (Show, Eq, Ord) + + +instance ToJSON TypeInfo where + toJSON v = case v of + TypeInfo{..} -> object + [ "tag" .= ("TypeInfo" :: Text) + , "startLine" .= startLine + , "startColumn" .= startColumn + , "endLine" .= endLine + , "endColumn" .= endColumn + , "text" .= text + ] + +instance FromJSON TypeInfo where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "TypeInfo" -> do + startLine <- obj .: "startLine" + startColumn <- obj .: "startColumn" + endLine <- obj .: "endLine" + endColumn <- obj .: "endColumn" + text <- obj .: "text" + pure $ TypeInfo + { startLine = startLine + , startColumn = startColumn + , endLine = endLine + , endColumn = endColumn + , text = text + } + parseJSON _ = mzero + +instance ToJSON MyEither where + toJSON v = case v of + MyLeft arg0 arg1 -> object [ "tag" .= ("MyLeft" :: Text), "arg0" .= arg0, "arg1" .= arg1] + MyRight arg0 arg1 arg2 -> object [ "tag" .= ("MyRight" :: Text), "arg0" .= arg0, "arg1" .= arg1, "arg2" .= arg2] + +instance FromJSON MyEither where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "MyLeft" -> MyLeft <$> obj .: "arg0" <*> obj .: "arg1" + "MyRight" -> MyRight <$> obj .: "arg0" <*> obj .: "arg1" <*> obj .: "arg2" + parseJSON _ = mzero + diff --git a/ddl/out/LambdaCube.TypeInfo.purs b/ddl/out/LambdaCube.TypeInfo.purs new file mode 100644 index 0000000..3daca2f --- /dev/null +++ b/ddl/out/LambdaCube.TypeInfo.purs @@ -0,0 +1,79 @@ +-- generated file, do not modify! +-- 2016-01-28T13:15:31.255126Z + +module LambdaCube.TypeInfo where +import Prelude +import Data.Generic +import Data.Maybe (Maybe(..)) +import Data.StrMap (StrMap(..)) +import Data.Map (Map(..)) +import Data.List (List(..)) +import Linear + +import Data.Argonaut.Combinators ((~>), (:=), (.?)) +import Data.Argonaut.Core (jsonEmptyObject) +import Data.Argonaut.Printer (printJson) +import Data.Argonaut.Encode (EncodeJson, encodeJson) +import Data.Argonaut.Decode (DecodeJson, decodeJson) + +import LambdaCube.IR + +data TypeInfo + = TypeInfo + { startLine :: Int + , startColumn :: Int + , endLine :: Int + , endColumn :: Int + , text :: String + } + + +data MyEither + = MyLeft TypeInfo (Array TypeInfo) + | MyRight String Pipeline (Array TypeInfo) + + + +instance encodeJsonTypeInfo :: EncodeJson TypeInfo where + encodeJson v = case v of + TypeInfo r -> + "tag" := "TypeInfo" ~> + "startLine" := r.startLine ~> + "startColumn" := r.startColumn ~> + "endLine" := r.endLine ~> + "endColumn" := r.endColumn ~> + "text" := r.text ~> + jsonEmptyObject + +instance decodeJsonTypeInfo :: DecodeJson TypeInfo where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "TypeInfo" -> do + startLine <- obj .? "startLine" + startColumn <- obj .? "startColumn" + endLine <- obj .? "endLine" + endColumn <- obj .? "endColumn" + text <- obj .? "text" + pure $ TypeInfo + { startLine:startLine + , startColumn:startColumn + , endLine:endLine + , endColumn:endColumn + , text:text + } + +instance encodeJsonMyEither :: EncodeJson MyEither where + encodeJson v = case v of + MyLeft arg0 arg1 -> "tag" := "MyLeft" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject + MyRight arg0 arg1 arg2 -> "tag" := "MyRight" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> "arg2" := arg2 ~> jsonEmptyObject + +instance decodeJsonMyEither :: DecodeJson MyEither where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "MyLeft" -> MyLeft <$> obj .? "arg0" <*> obj .? "arg1" + "MyRight" -> MyRight <$> obj .? "arg0" <*> obj .? "arg1" <*> obj .? "arg2" + diff --git a/ddl/out/LambdaCube.TypeInfo.swift b/ddl/out/LambdaCube.TypeInfo.swift new file mode 100644 index 0000000..6b46124 --- /dev/null +++ b/ddl/out/LambdaCube.TypeInfo.swift @@ -0,0 +1,134 @@ +// generated file, do not modify! +// 2016-01-28T13:15:31.255126Z + +enum TypeInfo { + case TypeInfo(TypeInfo_Data) + struct TypeInfo_Data { + var startLine : Int + var startColumn : Int + var endLine : Int + var endColumn : Int + var text : String + } +} + +enum MyEither { + case MyLeft(TypeInfo,Array) + case MyRight(String,Pipeline,Array) +} + + +extension Int { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension Int32 { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension UInt { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension UInt32 { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension Float { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension Bool { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension String { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension Array { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension Dictionary { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension Maybe { + var toJSON : [String: AnyObject] { + return ["":""] + } +} + + + +extension TypeInfo { + var toJSON : [String: AnyObject] { + switch self { + case .TypeInfo(let v): + return [ "tag" : "TypeInfo" + , "startLine" : v.startLine.toJSON + , "startColumn" : v.startColumn.toJSON + , "endLine" : v.endLine.toJSON + , "endColumn" : v.endColumn.toJSON + , "text" : v.text.toJSON + ] + } + } +} +extension MyEither { + var toJSON : [String: AnyObject] { + switch self { + case .MyLeft(let arg0, let arg1): + return [ "tag" : "MyLeft", "arg0" : arg0.toJSON, "arg1" : arg1.toJSON] + case .MyRight(let arg0, let arg1, let arg2): + return [ "tag" : "MyRight", "arg0" : arg0.toJSON, "arg1" : arg1.toJSON, "arg2" : arg2.toJSON] + } + } +} + +enum Maybe { + case Nothing + case Just(T) +} + +enum Type { + case Int + case Int32 + case Word + case Word32 + case Float + case Bool + case String + case Array(Type) + case List(Type) + case Maybe(Type) + case Map(Type,Type) + case TypeInfo + case MyEither +} + +func fromJSON(type: Type, personName: String) -> Any { + switch type { + case .Int: return 0 + case .Int32: return 0 + case .Word: return 0 + case .Word32: return 0 + case .Float: return 0.0 + case .Bool: return false + case .String: return "" + case .Array(let a): return fromJSON(a,personName) + case .List(let a): return fromJSON(a,personName) + case .Maybe(let a): return fromJSON(a,personName) + } + return 0; +} \ No newline at end of file diff --git a/ddl/out/LambdaCube.TypeInfo2.hpp b/ddl/out/LambdaCube.TypeInfo2.hpp new file mode 100644 index 0000000..b309a2b --- /dev/null +++ b/ddl/out/LambdaCube.TypeInfo2.hpp @@ -0,0 +1,50 @@ +// generated file, do not modify! +// 2016-01-28T13:15:31.255126Z + +#ifndef HEADER_LambdaCube.TypeInfo_H +#define HEADER_LambdaCube.TypeInfo_H + +#include "RT.hpp" + +#include "LambdaCube.IR.hpp" + +namespace data { + class TypeInfo { + public: + Int startLine; + Int startColumn; + Int endLine; + Int endColumn; + String text; + }; +} +class TypeInfo { +public: + enum class tag { + TypeInfo + } tag; + std::shared_ptr TypeInfo; +}; +namespace data { + class MyLeft { + public: + std::shared_ptr<::TypeInfo> _0; + std::vector> _1; + }; + class MyRight { + public: + String _0; + std::shared_ptr<::Pipeline> _1; + std::vector> _2; + }; +} +class MyEither { +public: + enum class tag { + MyLeft, + MyRight + } tag; + std::shared_ptr MyLeft; + std::shared_ptr MyRight; +}; +#endif diff --git a/ddl/out/Mesh.cpp b/ddl/out/Mesh.cpp deleted file mode 100644 index ce902bd..0000000 --- a/ddl/out/Mesh.cpp +++ /dev/null @@ -1,228 +0,0 @@ -// generated file, do not modify! -// 2016-01-18T14:30:08.223471Z - -#include "Mesh.hpp" -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::MeshAttribute::tag::A_Float: - obj["tag"] = "A_Float"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::MeshAttribute::tag::A_V2F: - obj["tag"] = "A_V2F"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::MeshAttribute::tag::A_V3F: - obj["tag"] = "A_V3F"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::MeshAttribute::tag::A_V4F: - obj["tag"] = "A_V4F"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::MeshAttribute::tag::A_M22F: - obj["tag"] = "A_M22F"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::MeshAttribute::tag::A_M33F: - obj["tag"] = "A_M33F"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::MeshAttribute::tag::A_M44F: - obj["tag"] = "A_M44F"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::MeshAttribute::tag::A_Int: - obj["tag"] = "A_Int"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::MeshAttribute::tag::A_Word: - obj["tag"] = "A_Word"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::MeshAttribute::tag tagType; - std::string tag = obj["tag"]; - if (tag == "A_Float") { - tagType = ::MeshAttribute::tag::A_Float; - std::shared_ptr tv(new data::A_Float()); - tv->_0 = fromJSON(W>(), obj["arg0"]); - return tv; - } - else if (tag == "A_V2F") { - tagType = ::MeshAttribute::tag::A_V2F; - std::shared_ptr tv(new data::A_V2F()); - tv->_0 = fromJSON(W>(), obj["arg0"]); - return tv; - } - else if (tag == "A_V3F") { - tagType = ::MeshAttribute::tag::A_V3F; - std::shared_ptr tv(new data::A_V3F()); - tv->_0 = fromJSON(W>(), obj["arg0"]); - return tv; - } - else if (tag == "A_V4F") { - tagType = ::MeshAttribute::tag::A_V4F; - std::shared_ptr tv(new data::A_V4F()); - tv->_0 = fromJSON(W>(), obj["arg0"]); - return tv; - } - else if (tag == "A_M22F") { - tagType = ::MeshAttribute::tag::A_M22F; - std::shared_ptr tv(new data::A_M22F()); - tv->_0 = fromJSON(W>(), obj["arg0"]); - return tv; - } - else if (tag == "A_M33F") { - tagType = ::MeshAttribute::tag::A_M33F; - std::shared_ptr tv(new data::A_M33F()); - tv->_0 = fromJSON(W>(), obj["arg0"]); - return tv; - } - else if (tag == "A_M44F") { - tagType = ::MeshAttribute::tag::A_M44F; - std::shared_ptr tv(new data::A_M44F()); - tv->_0 = fromJSON(W>(), obj["arg0"]); - return tv; - } - else if (tag == "A_Int") { - tagType = ::MeshAttribute::tag::A_Int; - std::shared_ptr tv(new data::A_Int()); - tv->_0 = fromJSON(W>(), obj["arg0"]); - return tv; - } - else if (tag == "A_Word") { - tagType = ::MeshAttribute::tag::A_Word; - std::shared_ptr tv(new data::A_Word()); - tv->_0 = fromJSON(W>(), obj["arg0"]); - return tv; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::MeshAttribute> o(new ::MeshAttribute()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::MeshPrimitive::tag::P_Points: - obj["tag"] = "P_Points"; - break; - case ::MeshPrimitive::tag::P_TriangleStrip: - obj["tag"] = "P_TriangleStrip"; - break; - case ::MeshPrimitive::tag::P_Triangles: - obj["tag"] = "P_Triangles"; - break; - case ::MeshPrimitive::tag::P_TriangleStripI: - obj["tag"] = "P_TriangleStripI"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - case ::MeshPrimitive::tag::P_TrianglesI: - obj["tag"] = "P_TrianglesI"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - } - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::MeshPrimitive::tag tagType; - std::string tag = obj["tag"]; - if (tag == "P_Points") { - tagType = ::MeshPrimitive::tag::P_Points; - } - else if (tag == "P_TriangleStrip") { - tagType = ::MeshPrimitive::tag::P_TriangleStrip; - } - else if (tag == "P_Triangles") { - tagType = ::MeshPrimitive::tag::P_Triangles; - } - else if (tag == "P_TriangleStripI") { - tagType = ::MeshPrimitive::tag::P_TriangleStripI; - std::shared_ptr tv(new data::P_TriangleStripI()); - tv->_0 = fromJSON(W>(), obj["arg0"]); - return tv; - } - else if (tag == "P_TrianglesI") { - tagType = ::MeshPrimitive::tag::P_TrianglesI; - std::shared_ptr tv(new data::P_TrianglesI()); - tv->_0 = fromJSON(W>(), obj["arg0"]); - return tv; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::MeshPrimitive> o(new ::MeshPrimitive()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::Mesh::tag::Mesh: - obj["tag"] = "Mesh"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["mAttributes"] = toJSON(tv->mAttributes); - obj["mPrimitive"] = toJSON(tv->mPrimitive); - } - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::Mesh::tag tagType; - std::string tag = obj["tag"]; - if (tag == "Mesh") { - tagType = ::Mesh::tag::Mesh; - std::shared_ptr tv(new data::Mesh()); - tv->mAttributes = fromJSON(W>>(), obj["mAttributes"]); - tv->mPrimitive = fromJSON(W>(), obj["mPrimitive"]); - return tv; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::Mesh> o(new ::Mesh()); - o->tag = tagType; - return o; -} - diff --git a/ddl/out/Mesh.hpp b/ddl/out/Mesh.hpp deleted file mode 100644 index ab8c193..0000000 --- a/ddl/out/Mesh.hpp +++ /dev/null @@ -1,107 +0,0 @@ -// generated file, do not modify! -// 2016-01-18T14:30:08.223471Z - -#ifndef HEADER_Mesh_H -#define HEADER_Mesh_H - -#include "RT.hpp" - - -class MeshAttribute { - public: - enum class tag { - A_Float, - A_V2F, - A_V3F, - A_V4F, - A_M22F, - A_M33F, - A_M44F, - A_Int, - A_Word - } tag; -}; -namespace data { - class A_Float : public ::MeshAttribute { - public: - std::vector _0; - A_Float() { tag = tag::A_Float; } - }; - class A_V2F : public ::MeshAttribute { - public: - std::vector _0; - A_V2F() { tag = tag::A_V2F; } - }; - class A_V3F : public ::MeshAttribute { - public: - std::vector _0; - A_V3F() { tag = tag::A_V3F; } - }; - class A_V4F : public ::MeshAttribute { - public: - std::vector _0; - A_V4F() { tag = tag::A_V4F; } - }; - class A_M22F : public ::MeshAttribute { - public: - std::vector _0; - A_M22F() { tag = tag::A_M22F; } - }; - class A_M33F : public ::MeshAttribute { - public: - std::vector _0; - A_M33F() { tag = tag::A_M33F; } - }; - class A_M44F : public ::MeshAttribute { - public: - std::vector _0; - A_M44F() { tag = tag::A_M44F; } - }; - class A_Int : public ::MeshAttribute { - public: - std::vector _0; - A_Int() { tag = tag::A_Int; } - }; - class A_Word : public ::MeshAttribute { - public: - std::vector _0; - A_Word() { tag = tag::A_Word; } - }; -} -class MeshPrimitive { - public: - enum class tag { - P_Points, - P_TriangleStrip, - P_Triangles, - P_TriangleStripI, - P_TrianglesI - } tag; -}; -namespace data { - class P_TriangleStripI : public ::MeshPrimitive { - public: - std::vector _0; - P_TriangleStripI() { tag = tag::P_TriangleStripI; } - }; - class P_TrianglesI : public ::MeshPrimitive { - public: - std::vector _0; - P_TrianglesI() { tag = tag::P_TrianglesI; } - }; -} -class Mesh { - public: - enum class tag { - Mesh - } tag; -}; -namespace data { - class Mesh : public ::Mesh { - public: - std::map> mAttributes; - std::shared_ptr<::MeshPrimitive> mPrimitive; - Mesh() { tag = tag::Mesh; } - }; -} -#endif diff --git a/ddl/out/Mesh.hs b/ddl/out/Mesh.hs deleted file mode 100644 index 8a5b339..0000000 --- a/ddl/out/Mesh.hs +++ /dev/null @@ -1,114 +0,0 @@ --- generated file, do not modify! --- 2016-01-18T14:30:08.223471Z - -{-# LANGUAGE OverloadedStrings, RecordWildCards #-} -module Mesh where - -import Data.Int -import Data.Word -import Data.Map -import Data.Vector (Vector(..)) -import Linear - -import Data.Text -import Data.Aeson hiding (Value,Bool) -import Data.Aeson.Types hiding (Value,Bool) -import Control.Monad - - -data MeshAttribute - = A_Float (Vector Float) - | A_V2F (Vector V2F) - | A_V3F (Vector V3F) - | A_V4F (Vector V4F) - | A_M22F (Vector M22F) - | A_M33F (Vector M33F) - | A_M44F (Vector M44F) - | A_Int (Vector Int32) - | A_Word (Vector Word32) - deriving (Show, Eq, Ord) - -data MeshPrimitive - = P_Points - | P_TriangleStrip - | P_Triangles - | P_TriangleStripI (Vector Int32) - | P_TrianglesI (Vector Int32) - deriving (Show, Eq, Ord) - -data Mesh - = Mesh - { mAttributes :: Map String MeshAttribute - , mPrimitive :: MeshPrimitive - } - - deriving (Show, Eq, Ord) - - -instance ToJSON MeshAttribute where - toJSON v = case v of - A_Float arg0 -> object [ "tag" .= ("A_Float" :: Text), "arg0" .= arg0] - A_V2F arg0 -> object [ "tag" .= ("A_V2F" :: Text), "arg0" .= arg0] - A_V3F arg0 -> object [ "tag" .= ("A_V3F" :: Text), "arg0" .= arg0] - A_V4F arg0 -> object [ "tag" .= ("A_V4F" :: Text), "arg0" .= arg0] - A_M22F arg0 -> object [ "tag" .= ("A_M22F" :: Text), "arg0" .= arg0] - A_M33F arg0 -> object [ "tag" .= ("A_M33F" :: Text), "arg0" .= arg0] - A_M44F arg0 -> object [ "tag" .= ("A_M44F" :: Text), "arg0" .= arg0] - A_Int arg0 -> object [ "tag" .= ("A_Int" :: Text), "arg0" .= arg0] - A_Word arg0 -> object [ "tag" .= ("A_Word" :: Text), "arg0" .= arg0] - -instance FromJSON MeshAttribute where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "A_Float" -> A_Float <$> obj .: "arg0" - "A_V2F" -> A_V2F <$> obj .: "arg0" - "A_V3F" -> A_V3F <$> obj .: "arg0" - "A_V4F" -> A_V4F <$> obj .: "arg0" - "A_M22F" -> A_M22F <$> obj .: "arg0" - "A_M33F" -> A_M33F <$> obj .: "arg0" - "A_M44F" -> A_M44F <$> obj .: "arg0" - "A_Int" -> A_Int <$> obj .: "arg0" - "A_Word" -> A_Word <$> obj .: "arg0" - parseJSON _ = mzero - -instance ToJSON MeshPrimitive where - toJSON v = case v of - P_Points -> object [ "tag" .= ("P_Points" :: Text)] - P_TriangleStrip -> object [ "tag" .= ("P_TriangleStrip" :: Text)] - P_Triangles -> object [ "tag" .= ("P_Triangles" :: Text)] - P_TriangleStripI arg0 -> object [ "tag" .= ("P_TriangleStripI" :: Text), "arg0" .= arg0] - P_TrianglesI arg0 -> object [ "tag" .= ("P_TrianglesI" :: Text), "arg0" .= arg0] - -instance FromJSON MeshPrimitive where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "P_Points" -> pure P_Points - "P_TriangleStrip" -> pure P_TriangleStrip - "P_Triangles" -> pure P_Triangles - "P_TriangleStripI" -> P_TriangleStripI <$> obj .: "arg0" - "P_TrianglesI" -> P_TrianglesI <$> obj .: "arg0" - parseJSON _ = mzero - -instance ToJSON Mesh where - toJSON v = case v of - Mesh{..} -> object - [ "tag" .= ("Mesh" :: Text) - , "mAttributes" .= mAttributes - , "mPrimitive" .= mPrimitive - ] - -instance FromJSON Mesh where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "Mesh" -> do - mAttributes <- obj .: "mAttributes" - mPrimitive <- obj .: "mPrimitive" - pure $ Mesh - { mAttributes = mAttributes - , mPrimitive = mPrimitive - } - parseJSON _ = mzero - diff --git a/ddl/out/Mesh.purs b/ddl/out/Mesh.purs deleted file mode 100644 index 725cced..0000000 --- a/ddl/out/Mesh.purs +++ /dev/null @@ -1,113 +0,0 @@ --- generated file, do not modify! --- 2016-01-18T14:30:08.223471Z - -module Mesh where -import Prelude -import Data.Generic -import Data.Maybe (Maybe(..)) -import Data.StrMap (StrMap(..)) -import Data.Map (Map(..)) -import Data.List (List(..)) -import Linear - -import Data.Argonaut.Combinators ((~>), (:=), (.?)) -import Data.Argonaut.Core (jsonEmptyObject) -import Data.Argonaut.Printer (printJson) -import Data.Argonaut.Encode (EncodeJson, encodeJson) -import Data.Argonaut.Decode (DecodeJson, decodeJson) - - -data MeshAttribute - = A_Float (Array Float) - | A_V2F (Array V2F) - | A_V3F (Array V3F) - | A_V4F (Array V4F) - | A_M22F (Array M22F) - | A_M33F (Array M33F) - | A_M44F (Array M44F) - | A_Int (Array Int32) - | A_Word (Array Word32) - -data MeshPrimitive - = P_Points - | P_TriangleStrip - | P_Triangles - | P_TriangleStripI (Array Int32) - | P_TrianglesI (Array Int32) - -data Mesh - = Mesh - { mAttributes :: StrMap MeshAttribute - , mPrimitive :: MeshPrimitive - } - - - - -instance encodeJsonMeshAttribute :: EncodeJson MeshAttribute where - encodeJson v = case v of - A_Float arg0 -> "tag" := "A_Float" ~> "arg0" := arg0 ~> jsonEmptyObject - A_V2F arg0 -> "tag" := "A_V2F" ~> "arg0" := arg0 ~> jsonEmptyObject - A_V3F arg0 -> "tag" := "A_V3F" ~> "arg0" := arg0 ~> jsonEmptyObject - A_V4F arg0 -> "tag" := "A_V4F" ~> "arg0" := arg0 ~> jsonEmptyObject - A_M22F arg0 -> "tag" := "A_M22F" ~> "arg0" := arg0 ~> jsonEmptyObject - A_M33F arg0 -> "tag" := "A_M33F" ~> "arg0" := arg0 ~> jsonEmptyObject - A_M44F arg0 -> "tag" := "A_M44F" ~> "arg0" := arg0 ~> jsonEmptyObject - A_Int arg0 -> "tag" := "A_Int" ~> "arg0" := arg0 ~> jsonEmptyObject - A_Word arg0 -> "tag" := "A_Word" ~> "arg0" := arg0 ~> jsonEmptyObject - -instance decodeJsonMeshAttribute :: DecodeJson MeshAttribute where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "A_Float" -> A_Float <$> obj .? "arg0" - "A_V2F" -> A_V2F <$> obj .? "arg0" - "A_V3F" -> A_V3F <$> obj .? "arg0" - "A_V4F" -> A_V4F <$> obj .? "arg0" - "A_M22F" -> A_M22F <$> obj .? "arg0" - "A_M33F" -> A_M33F <$> obj .? "arg0" - "A_M44F" -> A_M44F <$> obj .? "arg0" - "A_Int" -> A_Int <$> obj .? "arg0" - "A_Word" -> A_Word <$> obj .? "arg0" - -instance encodeJsonMeshPrimitive :: EncodeJson MeshPrimitive where - encodeJson v = case v of - P_Points -> "tag" := "P_Points" ~> jsonEmptyObject - P_TriangleStrip -> "tag" := "P_TriangleStrip" ~> jsonEmptyObject - P_Triangles -> "tag" := "P_Triangles" ~> jsonEmptyObject - P_TriangleStripI arg0 -> "tag" := "P_TriangleStripI" ~> "arg0" := arg0 ~> jsonEmptyObject - P_TrianglesI arg0 -> "tag" := "P_TrianglesI" ~> "arg0" := arg0 ~> jsonEmptyObject - -instance decodeJsonMeshPrimitive :: DecodeJson MeshPrimitive where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "P_Points" -> pure P_Points - "P_TriangleStrip" -> pure P_TriangleStrip - "P_Triangles" -> pure P_Triangles - "P_TriangleStripI" -> P_TriangleStripI <$> obj .? "arg0" - "P_TrianglesI" -> P_TrianglesI <$> obj .? "arg0" - -instance encodeJsonMesh :: EncodeJson Mesh where - encodeJson v = case v of - Mesh r -> - "tag" := "Mesh" ~> - "mAttributes" := r.mAttributes ~> - "mPrimitive" := r.mPrimitive ~> - jsonEmptyObject - -instance decodeJsonMesh :: DecodeJson Mesh where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "Mesh" -> do - mAttributes <- obj .? "mAttributes" - mPrimitive <- obj .? "mPrimitive" - pure $ Mesh - { mAttributes:mAttributes - , mPrimitive:mPrimitive - } - diff --git a/ddl/out/Mesh.swift b/ddl/out/Mesh.swift deleted file mode 100644 index 82b1d20..0000000 --- a/ddl/out/Mesh.swift +++ /dev/null @@ -1,174 +0,0 @@ -// generated file, do not modify! -// 2016-01-18T14:30:08.223471Z - -enum MeshAttribute { - case A_Float(Array) - case A_V2F(Array) - case A_V3F(Array) - case A_V4F(Array) - case A_M22F(Array) - case A_M33F(Array) - case A_M44F(Array) - case A_Int(Array) - case A_Word(Array) -} - -enum MeshPrimitive { - case P_Points - case P_TriangleStrip - case P_Triangles - case P_TriangleStripI(Array) - case P_TrianglesI(Array) -} - -enum Mesh { - case Mesh(Mesh_Data) - struct Mesh_Data { - var mAttributes : Dictionary - var mPrimitive : MeshPrimitive - } -} - - -extension Int { - var toJSON : [String: AnyObject] { - return ["":""] - } -} -extension Int32 { - var toJSON : [String: AnyObject] { - return ["":""] - } -} -extension UInt { - var toJSON : [String: AnyObject] { - return ["":""] - } -} -extension UInt32 { - var toJSON : [String: AnyObject] { - return ["":""] - } -} -extension Float { - var toJSON : [String: AnyObject] { - return ["":""] - } -} -extension Bool { - var toJSON : [String: AnyObject] { - return ["":""] - } -} -extension String { - var toJSON : [String: AnyObject] { - return ["":""] - } -} -extension Array { - var toJSON : [String: AnyObject] { - return ["":""] - } -} -extension Dictionary { - var toJSON : [String: AnyObject] { - return ["":""] - } -} -extension Maybe { - var toJSON : [String: AnyObject] { - return ["":""] - } -} - - - -extension MeshAttribute { - var toJSON : [String: AnyObject] { - switch self { - case .A_Float(let arg0): - return [ "tag" : "A_Float", "arg0" : arg0.toJSON] - case .A_V2F(let arg0): - return [ "tag" : "A_V2F", "arg0" : arg0.toJSON] - case .A_V3F(let arg0): - return [ "tag" : "A_V3F", "arg0" : arg0.toJSON] - case .A_V4F(let arg0): - return [ "tag" : "A_V4F", "arg0" : arg0.toJSON] - case .A_M22F(let arg0): - return [ "tag" : "A_M22F", "arg0" : arg0.toJSON] - case .A_M33F(let arg0): - return [ "tag" : "A_M33F", "arg0" : arg0.toJSON] - case .A_M44F(let arg0): - return [ "tag" : "A_M44F", "arg0" : arg0.toJSON] - case .A_Int(let arg0): - return [ "tag" : "A_Int", "arg0" : arg0.toJSON] - case .A_Word(let arg0): - return [ "tag" : "A_Word", "arg0" : arg0.toJSON] - } - } -} -extension MeshPrimitive { - var toJSON : [String: AnyObject] { - switch self { - case .P_Points: - return [ "tag" : "P_Points"] - case .P_TriangleStrip: - return [ "tag" : "P_TriangleStrip"] - case .P_Triangles: - return [ "tag" : "P_Triangles"] - case .P_TriangleStripI(let arg0): - return [ "tag" : "P_TriangleStripI", "arg0" : arg0.toJSON] - case .P_TrianglesI(let arg0): - return [ "tag" : "P_TrianglesI", "arg0" : arg0.toJSON] - } - } -} -extension Mesh { - var toJSON : [String: AnyObject] { - switch self { - case .Mesh(let v): - return [ "tag" : "Mesh" - , "mAttributes" : v.mAttributes.toJSON - , "mPrimitive" : v.mPrimitive.toJSON - ] - } - } -} - -enum Maybe { - case Nothing - case Just(T) -} - -enum Type { - case Int - case Int32 - case Word - case Word32 - case Float - case Bool - case String - case Array(Type) - case List(Type) - case Maybe(Type) - case Map(Type,Type) - case MeshAttribute - case MeshPrimitive - case Mesh -} - -func fromJSON(type: Type, personName: String) -> Any { - switch type { - case .Int: return 0 - case .Int32: return 0 - case .Word: return 0 - case .Word32: return 0 - case .Float: return 0.0 - case .Bool: return false - case .String: return "" - case .Array(let a): return fromJSON(a,personName) - case .List(let a): return fromJSON(a,personName) - case .Maybe(let a): return fromJSON(a,personName) - } - return 0; -} \ No newline at end of file diff --git a/ddl/out/Mesh2.hpp b/ddl/out/Mesh2.hpp deleted file mode 100644 index 041fa0f..0000000 --- a/ddl/out/Mesh2.hpp +++ /dev/null @@ -1,107 +0,0 @@ -// generated file, do not modify! -// 2016-01-18T14:30:08.223471Z - -#ifndef HEADER_Mesh_H -#define HEADER_Mesh_H - -#include "RT.hpp" - - -namespace data { - class A_Float { - public: - std::vector _0; - }; - class A_V2F { - public: - std::vector _0; - }; - class A_V3F { - public: - std::vector _0; - }; - class A_V4F { - public: - std::vector _0; - }; - class A_M22F { - public: - std::vector _0; - }; - class A_M33F { - public: - std::vector _0; - }; - class A_M44F { - public: - std::vector _0; - }; - class A_Int { - public: - std::vector _0; - }; - class A_Word { - public: - std::vector _0; - }; -} -class MeshAttribute { -public: - enum class tag { - A_Float, - A_V2F, - A_V3F, - A_V4F, - A_M22F, - A_M33F, - A_M44F, - A_Int, - A_Word - } tag; - std::shared_ptr A_Float; - std::shared_ptr A_V2F; - std::shared_ptr A_V3F; - std::shared_ptr A_V4F; - std::shared_ptr A_M22F; - std::shared_ptr A_M33F; - std::shared_ptr A_M44F; - std::shared_ptr A_Int; - std::shared_ptr A_Word; -}; -namespace data { - class P_TriangleStripI { - public: - std::vector _0; - }; - class P_TrianglesI { - public: - std::vector _0; - }; -} -class MeshPrimitive { -public: - enum class tag { - P_Points, - P_TriangleStrip, - P_Triangles, - P_TriangleStripI, - P_TrianglesI - } tag; - std::shared_ptr P_TriangleStripI; - std::shared_ptr P_TrianglesI; -}; -namespace data { - class Mesh { - public: - std::map> mAttributes; - std::shared_ptr<::MeshPrimitive> mPrimitive; - }; -} -class Mesh { -public: - enum class tag { - Mesh - } tag; - std::shared_ptr Mesh; -}; -#endif 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 @@ +// generated file, do not modify! +// 2016-01-28T13:15:31.27456Z + +#include "TestData.hpp" +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::ClientInfo::tag::ClientInfo: + obj["tag"] = "ClientInfo"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["clientName"] = toJSON(tv->clientName); + obj["clientBackend"] = toJSON(tv->clientBackend); + } + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::ClientInfo::tag tagType; + std::string tag = obj["tag"]; + if (tag == "ClientInfo") { + tagType = ::ClientInfo::tag::ClientInfo; + std::shared_ptr tv(new data::ClientInfo()); + tv->clientName = fromJSON(W(), obj["clientName"]); + tv->clientBackend = fromJSON(W>(), obj["clientBackend"]); + return tv; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::ClientInfo> o(new ::ClientInfo()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::Frame::tag::Frame: + obj["tag"] = "Frame"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["renderCount"] = toJSON(tv->renderCount); + obj["frameUniforms"] = toJSON(tv->frameUniforms); + obj["frameTextures"] = toJSON(tv->frameTextures); + } + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::Frame::tag tagType; + std::string tag = obj["tag"]; + if (tag == "Frame") { + tagType = ::Frame::tag::Frame; + std::shared_ptr tv(new data::Frame()); + tv->renderCount = fromJSON(W(), obj["renderCount"]); + tv->frameUniforms = fromJSON(W>>(), obj["frameUniforms"]); + tv->frameTextures = fromJSON(W>(), obj["frameTextures"]); + return tv; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::Frame> o(new ::Frame()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::Scene::tag::Scene: + obj["tag"] = "Scene"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["objectArrays"] = toJSON(tv->objectArrays); + obj["renderTargetWidth"] = toJSON(tv->renderTargetWidth); + obj["renderTargetHeight"] = toJSON(tv->renderTargetHeight); + obj["frames"] = toJSON(tv->frames); + } + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::Scene::tag tagType; + std::string tag = obj["tag"]; + if (tag == "Scene") { + tagType = ::Scene::tag::Scene; + std::shared_ptr tv(new data::Scene()); + tv->objectArrays = fromJSON(W>>(), obj["objectArrays"]); + tv->renderTargetWidth = fromJSON(W(), obj["renderTargetWidth"]); + tv->renderTargetHeight = fromJSON(W(), obj["renderTargetHeight"]); + tv->frames = fromJSON(W>>(), obj["frames"]); + return tv; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::Scene> o(new ::Scene()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::RenderJob::tag::RenderJob: + obj["tag"] = "RenderJob"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["meshes"] = toJSON(tv->meshes); + obj["textures"] = toJSON(tv->textures); + obj["schema"] = toJSON(tv->schema); + obj["scenes"] = toJSON(tv->scenes); + obj["pipelines"] = toJSON(tv->pipelines); + } + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::RenderJob::tag tagType; + std::string tag = obj["tag"]; + if (tag == "RenderJob") { + tagType = ::RenderJob::tag::RenderJob; + std::shared_ptr tv(new data::RenderJob()); + tv->meshes = fromJSON(W>>(), obj["meshes"]); + tv->textures = fromJSON(W>(), obj["textures"]); + tv->schema = fromJSON(W>(), obj["schema"]); + tv->scenes = fromJSON(W>>(), obj["scenes"]); + tv->pipelines = fromJSON(W>>(), obj["pipelines"]); + return tv; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::RenderJob> o(new ::RenderJob()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::FrameResult::tag::FrameResult: + obj["tag"] = "FrameResult"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["frRenderTimes"] = toJSON(tv->frRenderTimes); + obj["frImageWidth"] = toJSON(tv->frImageWidth); + obj["frImageHeight"] = toJSON(tv->frImageHeight); + } + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::FrameResult::tag tagType; + std::string tag = obj["tag"]; + if (tag == "FrameResult") { + tagType = ::FrameResult::tag::FrameResult; + std::shared_ptr tv(new data::FrameResult()); + tv->frRenderTimes = fromJSON(W>(), obj["frRenderTimes"]); + tv->frImageWidth = fromJSON(W(), obj["frImageWidth"]); + tv->frImageHeight = fromJSON(W(), obj["frImageHeight"]); + return tv; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::FrameResult> o(new ::FrameResult()); + o->tag = tagType; + return o; +} + +template<> json toJSON>(std::shared_ptr &v) { + json obj({}); + switch (v->tag) { + case ::RenderJobResult::tag::RenderJobResult: + obj["tag"] = "RenderJobResult"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + case ::RenderJobResult::tag::RenderJobError: + obj["tag"] = "RenderJobError"; + { + std::shared_ptr tv = std::static_pointer_cast(v); + obj["arg0"] = toJSON(tv->_0); + } + break; + } + return obj; +} + +template<> std::shared_ptr fromJSON>(W> v, json &obj) { + enum ::RenderJobResult::tag tagType; + std::string tag = obj["tag"]; + if (tag == "RenderJobResult") { + tagType = ::RenderJobResult::tag::RenderJobResult; + std::shared_ptr tv(new data::RenderJobResult()); + tv->_0 = fromJSON(W>(), obj["arg0"]); + return tv; + } + else if (tag == "RenderJobError") { + tagType = ::RenderJobResult::tag::RenderJobError; + std::shared_ptr tv(new data::RenderJobError()); + tv->_0 = fromJSON(W(), obj["arg0"]); + return tv; + } + else throw "unknown constructor: " + tag; + std::shared_ptr<::RenderJobResult> o(new ::RenderJobResult()); + o->tag = tagType; + return o; +} + 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 @@ +// generated file, do not modify! +// 2016-01-28T13:15:31.27456Z + +#ifndef HEADER_TestData_H +#define HEADER_TestData_H + +#include "RT.hpp" + +#include "LambdaCube.IR.hpp" +#include "LambdaCube.Mesh.hpp" +#include "LambdaCube.PipelineSchema.hpp" + +class ClientInfo { + public: + enum class tag { + ClientInfo + } tag; +}; +namespace data { + class ClientInfo : public ::ClientInfo { + public: + String clientName; + std::shared_ptr<::Backend> clientBackend; + ClientInfo() { tag = tag::ClientInfo; } + }; +} +class Frame { + public: + enum class tag { + Frame + } tag; +}; +namespace data { + class Frame : public ::Frame { + public: + Int renderCount; + std::map> frameUniforms; + std::map frameTextures; + Frame() { tag = tag::Frame; } + }; +} +class Scene { + public: + enum class tag { + Scene + } tag; +}; +namespace data { + class Scene : public ::Scene { + public: + std::map> objectArrays; + Int renderTargetWidth; + Int renderTargetHeight; + std::vector> frames; + Scene() { tag = tag::Scene; } + }; +} +class RenderJob { + public: + enum class tag { + RenderJob + } tag; +}; +namespace data { + class RenderJob : public ::RenderJob { + public: + std::vector> meshes; + std::vector textures; + std::shared_ptr<::PipelineSchema> schema; + std::vector> scenes; + std::vector> pipelines; + RenderJob() { tag = tag::RenderJob; } + }; +} +class FrameResult { + public: + enum class tag { + FrameResult + } tag; +}; +namespace data { + class FrameResult : public ::FrameResult { + public: + std::vector frRenderTimes; + Int frImageWidth; + Int frImageHeight; + FrameResult() { tag = tag::FrameResult; } + }; +} +class RenderJobResult { + public: + enum class tag { + RenderJobResult, + RenderJobError + } tag; +}; +namespace data { + class RenderJobResult : public ::RenderJobResult { + public: + std::shared_ptr<::FrameResult> _0; + RenderJobResult() { tag = tag::RenderJobResult; } + }; + class RenderJobError : public ::RenderJobResult { + public: + String _0; + RenderJobError() { tag = tag::RenderJobError; } + }; +} +#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 @@ +-- generated file, do not modify! +-- 2016-01-28T13:15:31.27456Z + +{-# LANGUAGE OverloadedStrings, RecordWildCards #-} +module TestData where + +import Data.Int +import Data.Word +import Data.Map +import Data.Vector (Vector(..)) +import LambdaCube.Linear + +import Data.Text +import Data.Aeson hiding (Value,Bool) +import Data.Aeson.Types hiding (Value,Bool) +import Control.Monad + +import LambdaCube.IR +import LambdaCube.Mesh +import LambdaCube.PipelineSchema + +data ClientInfo + = ClientInfo + { clientName :: String + , clientBackend :: Backend + } + + deriving (Show, Eq, Ord) + +data Frame + = Frame + { renderCount :: Int + , frameUniforms :: Map String Value + , frameTextures :: Map String Int + } + + deriving (Show, Eq, Ord) + +data Scene + = Scene + { objectArrays :: Map String (Vector Int) + , renderTargetWidth :: Int + , renderTargetHeight :: Int + , frames :: Vector Frame + } + + deriving (Show, Eq, Ord) + +data RenderJob + = RenderJob + { meshes :: Vector Mesh + , textures :: Vector String + , schema :: PipelineSchema + , scenes :: Vector Scene + , pipelines :: Vector Pipeline + } + + deriving (Show, Eq, Ord) + +data FrameResult + = FrameResult + { frRenderTimes :: Vector Float + , frImageWidth :: Int + , frImageHeight :: Int + } + + deriving (Show, Eq, Ord) + +data RenderJobResult + = RenderJobResult FrameResult + | RenderJobError String + deriving (Show, Eq, Ord) + + +instance ToJSON ClientInfo where + toJSON v = case v of + ClientInfo{..} -> object + [ "tag" .= ("ClientInfo" :: Text) + , "clientName" .= clientName + , "clientBackend" .= clientBackend + ] + +instance FromJSON ClientInfo where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "ClientInfo" -> do + clientName <- obj .: "clientName" + clientBackend <- obj .: "clientBackend" + pure $ ClientInfo + { clientName = clientName + , clientBackend = clientBackend + } + parseJSON _ = mzero + +instance ToJSON Frame where + toJSON v = case v of + Frame{..} -> object + [ "tag" .= ("Frame" :: Text) + , "renderCount" .= renderCount + , "frameUniforms" .= frameUniforms + , "frameTextures" .= frameTextures + ] + +instance FromJSON Frame where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "Frame" -> do + renderCount <- obj .: "renderCount" + frameUniforms <- obj .: "frameUniforms" + frameTextures <- obj .: "frameTextures" + pure $ Frame + { renderCount = renderCount + , frameUniforms = frameUniforms + , frameTextures = frameTextures + } + parseJSON _ = mzero + +instance ToJSON Scene where + toJSON v = case v of + Scene{..} -> object + [ "tag" .= ("Scene" :: Text) + , "objectArrays" .= objectArrays + , "renderTargetWidth" .= renderTargetWidth + , "renderTargetHeight" .= renderTargetHeight + , "frames" .= frames + ] + +instance FromJSON Scene where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "Scene" -> do + objectArrays <- obj .: "objectArrays" + renderTargetWidth <- obj .: "renderTargetWidth" + renderTargetHeight <- obj .: "renderTargetHeight" + frames <- obj .: "frames" + pure $ Scene + { objectArrays = objectArrays + , renderTargetWidth = renderTargetWidth + , renderTargetHeight = renderTargetHeight + , frames = frames + } + parseJSON _ = mzero + +instance ToJSON RenderJob where + toJSON v = case v of + RenderJob{..} -> object + [ "tag" .= ("RenderJob" :: Text) + , "meshes" .= meshes + , "textures" .= textures + , "schema" .= schema + , "scenes" .= scenes + , "pipelines" .= pipelines + ] + +instance FromJSON RenderJob where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "RenderJob" -> do + meshes <- obj .: "meshes" + textures <- obj .: "textures" + schema <- obj .: "schema" + scenes <- obj .: "scenes" + pipelines <- obj .: "pipelines" + pure $ RenderJob + { meshes = meshes + , textures = textures + , schema = schema + , scenes = scenes + , pipelines = pipelines + } + parseJSON _ = mzero + +instance ToJSON FrameResult where + toJSON v = case v of + FrameResult{..} -> object + [ "tag" .= ("FrameResult" :: Text) + , "frRenderTimes" .= frRenderTimes + , "frImageWidth" .= frImageWidth + , "frImageHeight" .= frImageHeight + ] + +instance FromJSON FrameResult where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "FrameResult" -> do + frRenderTimes <- obj .: "frRenderTimes" + frImageWidth <- obj .: "frImageWidth" + frImageHeight <- obj .: "frImageHeight" + pure $ FrameResult + { frRenderTimes = frRenderTimes + , frImageWidth = frImageWidth + , frImageHeight = frImageHeight + } + parseJSON _ = mzero + +instance ToJSON RenderJobResult where + toJSON v = case v of + RenderJobResult arg0 -> object [ "tag" .= ("RenderJobResult" :: Text), "arg0" .= arg0] + RenderJobError arg0 -> object [ "tag" .= ("RenderJobError" :: Text), "arg0" .= arg0] + +instance FromJSON RenderJobResult where + parseJSON (Object obj) = do + tag <- obj .: "tag" + case tag :: Text of + "RenderJobResult" -> RenderJobResult <$> obj .: "arg0" + "RenderJobError" -> RenderJobError <$> obj .: "arg0" + parseJSON _ = mzero + 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 @@ +-- generated file, do not modify! +-- 2016-01-28T13:15:31.27456Z + +module TestData where +import Prelude +import Data.Generic +import Data.Maybe (Maybe(..)) +import Data.StrMap (StrMap(..)) +import Data.Map (Map(..)) +import Data.List (List(..)) +import Linear + +import Data.Argonaut.Combinators ((~>), (:=), (.?)) +import Data.Argonaut.Core (jsonEmptyObject) +import Data.Argonaut.Printer (printJson) +import Data.Argonaut.Encode (EncodeJson, encodeJson) +import Data.Argonaut.Decode (DecodeJson, decodeJson) + +import LambdaCube.IR +import LambdaCube.Mesh +import LambdaCube.PipelineSchema + +data ClientInfo + = ClientInfo + { clientName :: String + , clientBackend :: Backend + } + + +data Frame + = Frame + { renderCount :: Int + , frameUniforms :: StrMap Value + , frameTextures :: StrMap Int + } + + +data Scene + = Scene + { objectArrays :: StrMap (Array Int) + , renderTargetWidth :: Int + , renderTargetHeight :: Int + , frames :: Array Frame + } + + +data RenderJob + = RenderJob + { meshes :: Array Mesh + , textures :: Array String + , schema :: PipelineSchema + , scenes :: Array Scene + , pipelines :: Array Pipeline + } + + +data FrameResult + = FrameResult + { frRenderTimes :: Array Float + , frImageWidth :: Int + , frImageHeight :: Int + } + + +data RenderJobResult + = RenderJobResult FrameResult + | RenderJobError String + + + +instance encodeJsonClientInfo :: EncodeJson ClientInfo where + encodeJson v = case v of + ClientInfo r -> + "tag" := "ClientInfo" ~> + "clientName" := r.clientName ~> + "clientBackend" := r.clientBackend ~> + jsonEmptyObject + +instance decodeJsonClientInfo :: DecodeJson ClientInfo where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "ClientInfo" -> do + clientName <- obj .? "clientName" + clientBackend <- obj .? "clientBackend" + pure $ ClientInfo + { clientName:clientName + , clientBackend:clientBackend + } + +instance encodeJsonFrame :: EncodeJson Frame where + encodeJson v = case v of + Frame r -> + "tag" := "Frame" ~> + "renderCount" := r.renderCount ~> + "frameUniforms" := r.frameUniforms ~> + "frameTextures" := r.frameTextures ~> + jsonEmptyObject + +instance decodeJsonFrame :: DecodeJson Frame where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "Frame" -> do + renderCount <- obj .? "renderCount" + frameUniforms <- obj .? "frameUniforms" + frameTextures <- obj .? "frameTextures" + pure $ Frame + { renderCount:renderCount + , frameUniforms:frameUniforms + , frameTextures:frameTextures + } + +instance encodeJsonScene :: EncodeJson Scene where + encodeJson v = case v of + Scene r -> + "tag" := "Scene" ~> + "objectArrays" := r.objectArrays ~> + "renderTargetWidth" := r.renderTargetWidth ~> + "renderTargetHeight" := r.renderTargetHeight ~> + "frames" := r.frames ~> + jsonEmptyObject + +instance decodeJsonScene :: DecodeJson Scene where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "Scene" -> do + objectArrays <- obj .? "objectArrays" + renderTargetWidth <- obj .? "renderTargetWidth" + renderTargetHeight <- obj .? "renderTargetHeight" + frames <- obj .? "frames" + pure $ Scene + { objectArrays:objectArrays + , renderTargetWidth:renderTargetWidth + , renderTargetHeight:renderTargetHeight + , frames:frames + } + +instance encodeJsonRenderJob :: EncodeJson RenderJob where + encodeJson v = case v of + RenderJob r -> + "tag" := "RenderJob" ~> + "meshes" := r.meshes ~> + "textures" := r.textures ~> + "schema" := r.schema ~> + "scenes" := r.scenes ~> + "pipelines" := r.pipelines ~> + jsonEmptyObject + +instance decodeJsonRenderJob :: DecodeJson RenderJob where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "RenderJob" -> do + meshes <- obj .? "meshes" + textures <- obj .? "textures" + schema <- obj .? "schema" + scenes <- obj .? "scenes" + pipelines <- obj .? "pipelines" + pure $ RenderJob + { meshes:meshes + , textures:textures + , schema:schema + , scenes:scenes + , pipelines:pipelines + } + +instance encodeJsonFrameResult :: EncodeJson FrameResult where + encodeJson v = case v of + FrameResult r -> + "tag" := "FrameResult" ~> + "frRenderTimes" := r.frRenderTimes ~> + "frImageWidth" := r.frImageWidth ~> + "frImageHeight" := r.frImageHeight ~> + jsonEmptyObject + +instance decodeJsonFrameResult :: DecodeJson FrameResult where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "FrameResult" -> do + frRenderTimes <- obj .? "frRenderTimes" + frImageWidth <- obj .? "frImageWidth" + frImageHeight <- obj .? "frImageHeight" + pure $ FrameResult + { frRenderTimes:frRenderTimes + , frImageWidth:frImageWidth + , frImageHeight:frImageHeight + } + +instance encodeJsonRenderJobResult :: EncodeJson RenderJobResult where + encodeJson v = case v of + RenderJobResult arg0 -> "tag" := "RenderJobResult" ~> "arg0" := arg0 ~> jsonEmptyObject + RenderJobError arg0 -> "tag" := "RenderJobError" ~> "arg0" := arg0 ~> jsonEmptyObject + +instance decodeJsonRenderJobResult :: DecodeJson RenderJobResult where + decodeJson json = do + obj <- decodeJson json + tag <- obj .? "tag" + case tag of + "RenderJobResult" -> RenderJobResult <$> obj .? "arg0" + "RenderJobError" -> RenderJobError <$> obj .? "arg0" + 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 @@ +// generated file, do not modify! +// 2016-01-28T13:15:31.27456Z + +enum ClientInfo { + case ClientInfo(ClientInfo_Data) + struct ClientInfo_Data { + var clientName : String + var clientBackend : Backend + } +} + +enum Frame { + case Frame(Frame_Data) + struct Frame_Data { + var renderCount : Int + var frameUniforms : Dictionary + var frameTextures : Dictionary + } +} + +enum Scene { + case Scene(Scene_Data) + struct Scene_Data { + var objectArrays : Dictionary> + var renderTargetWidth : Int + var renderTargetHeight : Int + var frames : Array + } +} + +enum RenderJob { + case RenderJob(RenderJob_Data) + struct RenderJob_Data { + var meshes : Array + var textures : Array + var schema : PipelineSchema + var scenes : Array + var pipelines : Array + } +} + +enum FrameResult { + case FrameResult(FrameResult_Data) + struct FrameResult_Data { + var frRenderTimes : Array + var frImageWidth : Int + var frImageHeight : Int + } +} + +enum RenderJobResult { + case RenderJobResult(FrameResult) + case RenderJobError(String) +} + + +extension Int { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension Int32 { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension UInt { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension UInt32 { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension Float { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension Bool { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension String { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension Array { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension Dictionary { + var toJSON : [String: AnyObject] { + return ["":""] + } +} +extension Maybe { + var toJSON : [String: AnyObject] { + return ["":""] + } +} + + + +extension ClientInfo { + var toJSON : [String: AnyObject] { + switch self { + case .ClientInfo(let v): + return [ "tag" : "ClientInfo" + , "clientName" : v.clientName.toJSON + , "clientBackend" : v.clientBackend.toJSON + ] + } + } +} +extension Frame { + var toJSON : [String: AnyObject] { + switch self { + case .Frame(let v): + return [ "tag" : "Frame" + , "renderCount" : v.renderCount.toJSON + , "frameUniforms" : v.frameUniforms.toJSON + , "frameTextures" : v.frameTextures.toJSON + ] + } + } +} +extension Scene { + var toJSON : [String: AnyObject] { + switch self { + case .Scene(let v): + return [ "tag" : "Scene" + , "objectArrays" : v.objectArrays.toJSON + , "renderTargetWidth" : v.renderTargetWidth.toJSON + , "renderTargetHeight" : v.renderTargetHeight.toJSON + , "frames" : v.frames.toJSON + ] + } + } +} +extension RenderJob { + var toJSON : [String: AnyObject] { + switch self { + case .RenderJob(let v): + return [ "tag" : "RenderJob" + , "meshes" : v.meshes.toJSON + , "textures" : v.textures.toJSON + , "schema" : v.schema.toJSON + , "scenes" : v.scenes.toJSON + , "pipelines" : v.pipelines.toJSON + ] + } + } +} +extension FrameResult { + var toJSON : [String: AnyObject] { + switch self { + case .FrameResult(let v): + return [ "tag" : "FrameResult" + , "frRenderTimes" : v.frRenderTimes.toJSON + , "frImageWidth" : v.frImageWidth.toJSON + , "frImageHeight" : v.frImageHeight.toJSON + ] + } + } +} +extension RenderJobResult { + var toJSON : [String: AnyObject] { + switch self { + case .RenderJobResult(let arg0): + return [ "tag" : "RenderJobResult", "arg0" : arg0.toJSON] + case .RenderJobError(let arg0): + return [ "tag" : "RenderJobError", "arg0" : arg0.toJSON] + } + } +} + +enum Maybe { + case Nothing + case Just(T) +} + +enum Type { + case Int + case Int32 + case Word + case Word32 + case Float + case Bool + case String + case Array(Type) + case List(Type) + case Maybe(Type) + case Map(Type,Type) + case ClientInfo + case Frame + case Scene + case RenderJob + case FrameResult + case RenderJobResult +} + +func fromJSON(type: Type, personName: String) -> Any { + switch type { + case .Int: return 0 + case .Int32: return 0 + case .Word: return 0 + case .Word32: return 0 + case .Float: return 0.0 + case .Bool: return false + case .String: return "" + case .Array(let a): return fromJSON(a,personName) + case .List(let a): return fromJSON(a,personName) + case .Maybe(let a): return fromJSON(a,personName) + } + return 0; +} \ 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 @@ +// generated file, do not modify! +// 2016-01-28T13:15:31.27456Z + +#ifndef HEADER_TestData_H +#define HEADER_TestData_H + +#include "RT.hpp" + +#include "LambdaCube.IR.hpp" +#include "LambdaCube.Mesh.hpp" +#include "LambdaCube.PipelineSchema.hpp" + +namespace data { + class ClientInfo { + public: + String clientName; + std::shared_ptr<::Backend> clientBackend; + }; +} +class ClientInfo { +public: + enum class tag { + ClientInfo + } tag; + std::shared_ptr ClientInfo; +}; +namespace data { + class Frame { + public: + Int renderCount; + std::map> frameUniforms; + std::map frameTextures; + }; +} +class Frame { +public: + enum class tag { + Frame + } tag; + std::shared_ptr Frame; +}; +namespace data { + class Scene { + public: + std::map> objectArrays; + Int renderTargetWidth; + Int renderTargetHeight; + std::vector> frames; + }; +} +class Scene { +public: + enum class tag { + Scene + } tag; + std::shared_ptr Scene; +}; +namespace data { + class RenderJob { + public: + std::vector> meshes; + std::vector textures; + std::shared_ptr<::PipelineSchema> schema; + std::vector> scenes; + std::vector> pipelines; + }; +} +class RenderJob { +public: + enum class tag { + RenderJob + } tag; + std::shared_ptr RenderJob; +}; +namespace data { + class FrameResult { + public: + std::vector frRenderTimes; + Int frImageWidth; + Int frImageHeight; + }; +} +class FrameResult { +public: + enum class tag { + FrameResult + } tag; + std::shared_ptr FrameResult; +}; +namespace data { + class RenderJobResult { + public: + std::shared_ptr<::FrameResult> _0; + }; + class RenderJobError { + public: + String _0; + }; +} +class RenderJobResult { +public: + enum class tag { + RenderJobResult, + RenderJobError + } tag; + std::shared_ptr RenderJobResult; + std::shared_ptr RenderJobError; +}; +#endif diff --git a/ddl/out/TypeInfo.cpp b/ddl/out/TypeInfo.cpp deleted file mode 100644 index 6834bcc..0000000 --- a/ddl/out/TypeInfo.cpp +++ /dev/null @@ -1,89 +0,0 @@ -// generated file, do not modify! -// 2016-01-18T14:30:08.262123Z - -#include "TypeInfo.hpp" -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::TypeInfo::tag::TypeInfo: - obj["tag"] = "TypeInfo"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["startLine"] = toJSON(tv->startLine); - obj["startColumn"] = toJSON(tv->startColumn); - obj["endLine"] = toJSON(tv->endLine); - obj["endColumn"] = toJSON(tv->endColumn); - obj["text"] = toJSON(tv->text); - } - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::TypeInfo::tag tagType; - std::string tag = obj["tag"]; - if (tag == "TypeInfo") { - tagType = ::TypeInfo::tag::TypeInfo; - std::shared_ptr tv(new data::TypeInfo()); - tv->startLine = fromJSON(W(), obj["startLine"]); - tv->startColumn = fromJSON(W(), obj["startColumn"]); - tv->endLine = fromJSON(W(), obj["endLine"]); - tv->endColumn = fromJSON(W(), obj["endColumn"]); - tv->text = fromJSON(W(), obj["text"]); - return tv; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::TypeInfo> o(new ::TypeInfo()); - o->tag = tagType; - return o; -} - -template<> json toJSON>(std::shared_ptr &v) { - json obj({}); - switch (v->tag) { - case ::MyEither::tag::MyLeft: - obj["tag"] = "MyLeft"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - obj["arg1"] = toJSON(tv->_1); - } - break; - case ::MyEither::tag::MyRight: - obj["tag"] = "MyRight"; - { - std::shared_ptr tv = std::static_pointer_cast(v); - obj["arg0"] = toJSON(tv->_0); - obj["arg1"] = toJSON(tv->_1); - obj["arg2"] = toJSON(tv->_2); - } - break; - } - return obj; -} - -template<> std::shared_ptr fromJSON>(W> v, json &obj) { - enum ::MyEither::tag tagType; - std::string tag = obj["tag"]; - if (tag == "MyLeft") { - tagType = ::MyEither::tag::MyLeft; - std::shared_ptr tv(new data::MyLeft()); - tv->_0 = fromJSON(W>(), obj["arg0"]); - tv->_1 = fromJSON(W>>(), obj["arg1"]); - return tv; - } - else if (tag == "MyRight") { - tagType = ::MyEither::tag::MyRight; - std::shared_ptr tv(new data::MyRight()); - tv->_0 = fromJSON(W(), obj["arg0"]); - tv->_1 = fromJSON(W>(), obj["arg1"]); - tv->_2 = fromJSON(W>>(), obj["arg2"]); - return tv; - } - else throw "unknown constructor: " + tag; - std::shared_ptr<::MyEither> o(new ::MyEither()); - o->tag = tagType; - return o; -} - diff --git a/ddl/out/TypeInfo.hpp b/ddl/out/TypeInfo.hpp deleted file mode 100644 index fdad33d..0000000 --- a/ddl/out/TypeInfo.hpp +++ /dev/null @@ -1,50 +0,0 @@ -// generated file, do not modify! -// 2016-01-18T14:30:08.262123Z - -#ifndef HEADER_TypeInfo_H -#define HEADER_TypeInfo_H - -#include "RT.hpp" - -#include "IR.hpp" - -class TypeInfo { - public: - enum class tag { - TypeInfo - } tag; -}; -namespace data { - class TypeInfo : public ::TypeInfo { - public: - Int startLine; - Int startColumn; - Int endLine; - Int endColumn; - String text; - TypeInfo() { tag = tag::TypeInfo; } - }; -} -class MyEither { - public: - enum class tag { - MyLeft, - MyRight - } tag; -}; -namespace data { - class MyLeft : public ::MyEither { - public: - std::shared_ptr<::TypeInfo> _0; - std::vector> _1; - MyLeft() { tag = tag::MyLeft; } - }; - class MyRight : public ::MyEither { - public: - String _0; - std::shared_ptr<::Pipeline> _1; - std::vector> _2; - MyRight() { tag = tag::MyRight; } - }; -} -#endif diff --git a/ddl/out/TypeInfo.hs b/ddl/out/TypeInfo.hs deleted file mode 100644 index 6891924..0000000 --- a/ddl/out/TypeInfo.hs +++ /dev/null @@ -1,79 +0,0 @@ --- generated file, do not modify! --- 2016-01-18T14:30:08.262123Z - -{-# LANGUAGE OverloadedStrings, RecordWildCards #-} -module TypeInfo where - -import Data.Int -import Data.Word -import Data.Map -import Data.Vector (Vector(..)) -import Linear - -import Data.Text -import Data.Aeson hiding (Value,Bool) -import Data.Aeson.Types hiding (Value,Bool) -import Control.Monad - -import IR - -data TypeInfo - = TypeInfo - { startLine :: Int - , startColumn :: Int - , endLine :: Int - , endColumn :: Int - , text :: String - } - - deriving (Show, Eq, Ord) - -data MyEither - = MyLeft TypeInfo (Vector TypeInfo) - | MyRight String Pipeline (Vector TypeInfo) - deriving (Show, Eq, Ord) - - -instance ToJSON TypeInfo where - toJSON v = case v of - TypeInfo{..} -> object - [ "tag" .= ("TypeInfo" :: Text) - , "startLine" .= startLine - , "startColumn" .= startColumn - , "endLine" .= endLine - , "endColumn" .= endColumn - , "text" .= text - ] - -instance FromJSON TypeInfo where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "TypeInfo" -> do - startLine <- obj .: "startLine" - startColumn <- obj .: "startColumn" - endLine <- obj .: "endLine" - endColumn <- obj .: "endColumn" - text <- obj .: "text" - pure $ TypeInfo - { startLine = startLine - , startColumn = startColumn - , endLine = endLine - , endColumn = endColumn - , text = text - } - parseJSON _ = mzero - -instance ToJSON MyEither where - toJSON v = case v of - MyLeft arg0 arg1 -> object [ "tag" .= ("MyLeft" :: Text), "arg0" .= arg0, "arg1" .= arg1] - MyRight arg0 arg1 arg2 -> object [ "tag" .= ("MyRight" :: Text), "arg0" .= arg0, "arg1" .= arg1, "arg2" .= arg2] - -instance FromJSON MyEither where - parseJSON (Object obj) = do - tag <- obj .: "tag" - case tag :: Text of - "MyLeft" -> MyLeft <$> obj .: "arg0" <*> obj .: "arg1" - "MyRight" -> MyRight <$> obj .: "arg0" <*> obj .: "arg1" <*> obj .: "arg2" - parseJSON _ = mzero - diff --git a/ddl/out/TypeInfo.purs b/ddl/out/TypeInfo.purs deleted file mode 100644 index 667de39..0000000 --- a/ddl/out/TypeInfo.purs +++ /dev/null @@ -1,79 +0,0 @@ --- generated file, do not modify! --- 2016-01-18T14:30:08.262123Z - -module TypeInfo where -import Prelude -import Data.Generic -import Data.Maybe (Maybe(..)) -import Data.StrMap (StrMap(..)) -import Data.Map (Map(..)) -import Data.List (List(..)) -import Linear - -import Data.Argonaut.Combinators ((~>), (:=), (.?)) -import Data.Argonaut.Core (jsonEmptyObject) -import Data.Argonaut.Printer (printJson) -import Data.Argonaut.Encode (EncodeJson, encodeJson) -import Data.Argonaut.Decode (DecodeJson, decodeJson) - -import IR - -data TypeInfo - = TypeInfo - { startLine :: Int - , startColumn :: Int - , endLine :: Int - , endColumn :: Int - , text :: String - } - - -data MyEither - = MyLeft TypeInfo (Array TypeInfo) - | MyRight String Pipeline (Array TypeInfo) - - - -instance encodeJsonTypeInfo :: EncodeJson TypeInfo where - encodeJson v = case v of - TypeInfo r -> - "tag" := "TypeInfo" ~> - "startLine" := r.startLine ~> - "startColumn" := r.startColumn ~> - "endLine" := r.endLine ~> - "endColumn" := r.endColumn ~> - "text" := r.text ~> - jsonEmptyObject - -instance decodeJsonTypeInfo :: DecodeJson TypeInfo where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "TypeInfo" -> do - startLine <- obj .? "startLine" - startColumn <- obj .? "startColumn" - endLine <- obj .? "endLine" - endColumn <- obj .? "endColumn" - text <- obj .? "text" - pure $ TypeInfo - { startLine:startLine - , startColumn:startColumn - , endLine:endLine - , endColumn:endColumn - , text:text - } - -instance encodeJsonMyEither :: EncodeJson MyEither where - encodeJson v = case v of - MyLeft arg0 arg1 -> "tag" := "MyLeft" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject - MyRight arg0 arg1 arg2 -> "tag" := "MyRight" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> "arg2" := arg2 ~> jsonEmptyObject - -instance decodeJsonMyEither :: DecodeJson MyEither where - decodeJson json = do - obj <- decodeJson json - tag <- obj .? "tag" - case tag of - "MyLeft" -> MyLeft <$> obj .? "arg0" <*> obj .? "arg1" - "MyRight" -> MyRight <$> obj .? "arg0" <*> obj .? "arg1" <*> obj .? "arg2" - diff --git a/ddl/out/TypeInfo.swift b/ddl/out/TypeInfo.swift deleted file mode 100644 index c0c3a29..0000000 --- a/ddl/out/TypeInfo.swift +++ /dev/null @@ -1,134 +0,0 @@ -// generated file, do not modify! -// 2016-01-18T14:30:08.262123Z - -enum TypeInfo { - case TypeInfo(TypeInfo_Data) - struct TypeInfo_Data { - var startLine : Int - var startColumn : Int - var endLine : Int - var endColumn : Int - var text : String - } -} - -enum MyEither { - case MyLeft(TypeInfo,Array) - case MyRight(String,Pipeline,Array) -} - - -extension Int { - var toJSON : [String: AnyObject] { - return ["":""] - } -} -extension Int32 { - var toJSON : [String: AnyObject] { - return ["":""] - } -} -extension UInt { - var toJSON : [String: AnyObject] { - return ["":""] - } -} -extension UInt32 { - var toJSON : [String: AnyObject] { - return ["":""] - } -} -extension Float { - var toJSON : [String: AnyObject] { - return ["":""] - } -} -extension Bool { - var toJSON : [String: AnyObject] { - return ["":""] - } -} -extension String { - var toJSON : [String: AnyObject] { - return ["":""] - } -} -extension Array { - var toJSON : [String: AnyObject] { - return ["":""] - } -} -extension Dictionary { - var toJSON : [String: AnyObject] { - return ["":""] - } -} -extension Maybe { - var toJSON : [String: AnyObject] { - return ["":""] - } -} - - - -extension TypeInfo { - var toJSON : [String: AnyObject] { - switch self { - case .TypeInfo(let v): - return [ "tag" : "TypeInfo" - , "startLine" : v.startLine.toJSON - , "startColumn" : v.startColumn.toJSON - , "endLine" : v.endLine.toJSON - , "endColumn" : v.endColumn.toJSON - , "text" : v.text.toJSON - ] - } - } -} -extension MyEither { - var toJSON : [String: AnyObject] { - switch self { - case .MyLeft(let arg0, let arg1): - return [ "tag" : "MyLeft", "arg0" : arg0.toJSON, "arg1" : arg1.toJSON] - case .MyRight(let arg0, let arg1, let arg2): - return [ "tag" : "MyRight", "arg0" : arg0.toJSON, "arg1" : arg1.toJSON, "arg2" : arg2.toJSON] - } - } -} - -enum Maybe { - case Nothing - case Just(T) -} - -enum Type { - case Int - case Int32 - case Word - case Word32 - case Float - case Bool - case String - case Array(Type) - case List(Type) - case Maybe(Type) - case Map(Type,Type) - case TypeInfo - case MyEither -} - -func fromJSON(type: Type, personName: String) -> Any { - switch type { - case .Int: return 0 - case .Int32: return 0 - case .Word: return 0 - case .Word32: return 0 - case .Float: return 0.0 - case .Bool: return false - case .String: return "" - case .Array(let a): return fromJSON(a,personName) - case .List(let a): return fromJSON(a,personName) - case .Maybe(let a): return fromJSON(a,personName) - } - return 0; -} \ No newline at end of file diff --git a/ddl/out/TypeInfo2.hpp b/ddl/out/TypeInfo2.hpp deleted file mode 100644 index 9ac29c9..0000000 --- a/ddl/out/TypeInfo2.hpp +++ /dev/null @@ -1,50 +0,0 @@ -// generated file, do not modify! -// 2016-01-18T14:30:08.262123Z - -#ifndef HEADER_TypeInfo_H -#define HEADER_TypeInfo_H - -#include "RT.hpp" - -#include "IR.hpp" - -namespace data { - class TypeInfo { - public: - Int startLine; - Int startColumn; - Int endLine; - Int endColumn; - String text; - }; -} -class TypeInfo { -public: - enum class tag { - TypeInfo - } tag; - std::shared_ptr TypeInfo; -}; -namespace data { - class MyLeft { - public: - std::shared_ptr<::TypeInfo> _0; - std::vector> _1; - }; - class MyRight { - public: - String _0; - std::shared_ptr<::Pipeline> _1; - std::vector> _2; - }; -} -class MyEither { -public: - enum class tag { - MyLeft, - MyRight - } tag; - std::shared_ptr MyLeft; - std::shared_ptr MyRight; -}; -#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 import Data.Word import Data.Map import Data.Vector (Vector(..)) -import Linear +import LambdaCube.Linear import Data.Text import 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 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: lambdacube-ir -version: 0.1.0.0 +version: 0.2.0.0 -- synopsis: -- description: license: BSD3 @@ -16,10 +16,14 @@ build-type: Simple cabal-version: >=1.10 library - exposed-modules: IR, Linear + exposed-modules: LambdaCube.Linear + LambdaCube.IR + LambdaCube.Mesh + LambdaCube.PipelineSchema + LambdaCube.PipelineSchemaUtil -- other-modules: other-extensions: OverloadedStrings, RecordWildCards, DeriveFunctor -- CAUTION: When the build-depends change, please bump the git submodule in lambdacube-docker repository - 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 + 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 hs-source-dirs: src 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 @@ -../../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/LambdaCube/Linear.hs b/lambdacube-ir.haskell/src/LambdaCube/Linear.hs new file mode 100644 index 0000000..286cc93 --- /dev/null +++ b/lambdacube-ir.haskell/src/LambdaCube/Linear.hs @@ -0,0 +1,60 @@ +{-# LANGUAGE DeriveFunctor, OverloadedStrings #-} +module LambdaCube.Linear where + +import Data.Int +import Data.Word +import Data.Map + +import Data.Text +import Data.Aeson +import Control.Monad + +data V2 a = V2 !a !a deriving (Eq,Ord,Show,Read,Functor) +data V3 a = V3 !a !a !a deriving (Eq,Ord,Show,Read,Functor) +data V4 a = V4 !a !a !a !a deriving (Eq,Ord,Show,Read,Functor) + +-- matrices are stored in column major order +type M22F = V2 V2F +type M23F = V3 V2F +type M24F = V4 V2F +type M32F = V2 V3F +type M33F = V3 V3F +type M34F = V4 V3F +type M42F = V2 V4F +type M43F = V3 V4F +type M44F = V4 V4F + +type V2F = V2 Float +type V3F = V3 Float +type V4F = V4 Float +type V2I = V2 Int32 +type V3I = V3 Int32 +type V4I = V4 Int32 +type V2U = V2 Word32 +type V3U = V3 Word32 +type V4U = V4 Word32 +type V2B = V2 Bool +type V3B = V3 Bool +type V4B = V4 Bool + +instance ToJSON a => ToJSON (V2 a) where + toJSON (V2 x y) = object ["x" .= x, "y" .= y] + +instance ToJSON a => ToJSON (V3 a) where + toJSON (V3 x y z) = object ["x" .= x, "y" .= y, "z" .= z] + +instance ToJSON a => ToJSON (V4 a) where + toJSON (V4 x y z w) = object ["x" .= x, "y" .= y, "z" .= z, "w" .= w] + +instance FromJSON a => FromJSON (V2 a) where + parseJSON (Object obj) = V2 <$> obj .: "x" <*> obj .: "y" + parseJSON _ = mzero + +instance FromJSON a => FromJSON (V3 a) where + parseJSON (Object obj) = V3 <$> obj .: "x" <*> obj .: "y" <*> obj .: "z" + parseJSON _ = mzero + +instance FromJSON a => FromJSON (V4 a) where + parseJSON (Object obj) = V4 <$> obj .: "x" <*> obj .: "y" <*> obj .: "z" <*> obj .: "w" + parseJSON _ = mzero + 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 @@ +{-# LANGUAGE FlexibleContexts, TypeSynonymInstances, FlexibleInstances #-} +module LambdaCube.PipelineSchemaUtil where + +import Control.Monad.Writer +import qualified Data.Map as Map +import LambdaCube.PipelineSchema + +a @: b = tell [(a,b)] +defObjectArray n p m = mapM_ tell [PipelineSchema (Map.singleton n $ ObjectArraySchema p $ Map.singleton a t) mempty | (a,t) <- execWriter m] +defUniforms m = tell $ PipelineSchema mempty $ Map.fromList $ execWriter m +makeSchema a = execWriter a :: PipelineSchema + +unionObjectArraySchema (ObjectArraySchema a1 b1) (ObjectArraySchema a2 b2) = + ObjectArraySchema (if a1 == a2 then a1 else error $ "object array schema primitive mismatch " ++ show (a1,a2)) + (Map.unionWith (\a b -> if a == b then a else error $ "object array schema attribute type mismatch " ++ show (a,b)) b1 b2) + +instance Monoid PipelineSchema where + mempty = PipelineSchema mempty mempty + mappend (PipelineSchema a1 b1) (PipelineSchema a2 b2) = + 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) diff --git a/lambdacube-ir.haskell/src/Linear.hs b/lambdacube-ir.haskell/src/Linear.hs deleted file mode 100644 index 1329841..0000000 --- a/lambdacube-ir.haskell/src/Linear.hs +++ /dev/null @@ -1,60 +0,0 @@ -{-# LANGUAGE DeriveFunctor, OverloadedStrings #-} -module Linear where - -import Data.Int -import Data.Word -import Data.Map - -import Data.Text -import Data.Aeson -import Control.Monad - -data V2 a = V2 !a !a deriving (Eq,Ord,Show,Read,Functor) -data V3 a = V3 !a !a !a deriving (Eq,Ord,Show,Read,Functor) -data V4 a = V4 !a !a !a !a deriving (Eq,Ord,Show,Read,Functor) - --- matrices are stored in column major order -type M22F = V2 V2F -type M23F = V3 V2F -type M24F = V4 V2F -type M32F = V2 V3F -type M33F = V3 V3F -type M34F = V4 V3F -type M42F = V2 V4F -type M43F = V3 V4F -type M44F = V4 V4F - -type V2F = V2 Float -type V3F = V3 Float -type V4F = V4 Float -type V2I = V2 Int32 -type V3I = V3 Int32 -type V4I = V4 Int32 -type V2U = V2 Word32 -type V3U = V3 Word32 -type V4U = V4 Word32 -type V2B = V2 Bool -type V3B = V3 Bool -type V4B = V4 Bool - -instance ToJSON a => ToJSON (V2 a) where - toJSON (V2 x y) = object ["x" .= x, "y" .= y] - -instance ToJSON a => ToJSON (V3 a) where - toJSON (V3 x y z) = object ["x" .= x, "y" .= y, "z" .= z] - -instance ToJSON a => ToJSON (V4 a) where - toJSON (V4 x y z w) = object ["x" .= x, "y" .= y, "z" .= z, "w" .= w] - -instance FromJSON a => FromJSON (V2 a) where - parseJSON (Object obj) = V2 <$> obj .: "x" <*> obj .: "y" - parseJSON _ = mzero - -instance FromJSON a => FromJSON (V3 a) where - parseJSON (Object obj) = V3 <$> obj .: "x" <*> obj .: "y" <*> obj .: "z" - parseJSON _ = mzero - -instance FromJSON a => FromJSON (V4 a) where - parseJSON (Object obj) = V4 <$> obj .: "x" <*> obj .: "y" <*> obj .: "z" <*> obj .: "w" - parseJSON _ = mzero - -- cgit v1.2.3