From 340367db6d24ff097df4e5350704f8f47ed2c9bc Mon Sep 17 00:00:00 2001 From: Anthony Cerruti Date: Mon, 18 May 2020 15:40:20 -0700 Subject: [PATCH 1/7] Start work on Kotlin generation --- ddl/Generate.hs | 6 + ddl/Language.hs | 49 +- ddl/out/kotlin/LambdaCube.IR.kt | 581 ++++++++++++++++++++ ddl/out/kotlin/LambdaCube.Mesh.kt | 51 ++ ddl/out/kotlin/LambdaCube.PipelineSchema.kt | 40 ++ ddl/out/kotlin/LambdaCube.TypeInfo.kt | 44 ++ ddl/out/kotlin/TestData.kt | 54 ++ ddl/templates/data.kt.ede | 30 + 8 files changed, 854 insertions(+), 1 deletion(-) create mode 100644 ddl/out/kotlin/LambdaCube.IR.kt create mode 100644 ddl/out/kotlin/LambdaCube.Mesh.kt create mode 100644 ddl/out/kotlin/LambdaCube.PipelineSchema.kt create mode 100644 ddl/out/kotlin/LambdaCube.TypeInfo.kt create mode 100644 ddl/out/kotlin/TestData.kt create mode 100644 ddl/templates/data.kt.ede diff --git a/ddl/Generate.hs b/ddl/Generate.hs index a2e2191..30e57f1 100644 --- a/ddl/Generate.hs +++ b/ddl/Generate.hs @@ -19,6 +19,7 @@ import Definitions import Language instance Unquote [Field] +instance Unquote [ConstructorDef] instance Unquote [Char] instance Quote [Char] instance Quote [Instance] @@ -31,6 +32,7 @@ main = do dataSwift <- eitherParseFile "templates/data.swift.ede" dataJava <- eitherParseFile "templates/data.java.ede" jsonJava <- eitherParseFile "templates/json.java.ede" + dataKt <- eitherParseFile "templates/data.kt.ede" dataHpp <- eitherParseFile "templates/data.hpp.ede" dataHpp2 <- eitherParseFile "templates/data.hpp2.ede" dataCpp <- eitherParseFile "templates/data.cpp.ede" @@ -52,6 +54,7 @@ main = do mylib :: HashMap Text Term mylib = HashMap.fromList [ "hasFieldNames" @: hasFieldNames + , "nonSingular" @: nonSingular , "parens" @: parens , "constType" @: constType , "hsType" @: hsType aliasMap @@ -60,6 +63,7 @@ main = do , "csType" @: csType name aliasMap , "typeEnum" @: typeEnum aliasMap , "javaType" @: javaType aliasMap + , "ktType" @: ktType aliasMap , "swiftType" @: swiftType aliasMap , "hasEnumConstructor" @: hasEnumConstructor , "psInstances" @: filterInstances PureScript @@ -99,6 +103,8 @@ main = do fname = "out/java/" ++ toPath name ++ "/" ++ dataName d ++ ".java" either error (\x -> writeFileIfDiffer fname $ LText.unpack x) $ dataJava >>= (\t -> eitherRenderWith mylib t env) either error (\x -> writeFileIfDiffer ("out/java/" ++ toPath name ++ "/JSON.java") $ LText.unpack x) $ jsonJava >>= (\t -> eitherRenderWith mylib t env) + -- Kotlin + either error (\x -> writeFileIfDiffer ("out/kotlin/" ++ name ++ ".kt") $ LText.unpack x) $ dataKt >>= (\t -> eitherRenderWith mylib t env) -- C# either error (\x -> writeFileIfDiffer ("out/csharp/" ++ name ++ ".cs") $ LText.unpack x) $ dataCs >>= (\t -> eitherRenderWith mylib t env) -- Swift diff --git a/ddl/Language.hs b/ddl/Language.hs index 9701023..15c5708 100644 --- a/ddl/Language.hs +++ b/ddl/Language.hs @@ -268,6 +268,48 @@ javaType aliasMap a = case normalize aliasMap a of Maybe t -> "Maybe<" ++ parens (javaType aliasMap t) ++ ">" x -> error $ "javaType: " ++ show x +ktType :: AliasMap -> Type -> String +ktType aliasMap = \case + Int -> "Long" + Int32 -> "Int" + Word -> "Long" + Word32 -> "Int" + Float -> "Float" + Bool -> "Bool" + String -> "String" + + V2 Int -> "V2I" + V2 Word -> "V2U" + V2 Float -> "V2F" + V2 Bool -> "V2B" + V2 (V2 Float) -> "M22F" + V2 (V3 Float) -> "M32F" + V2 (V4 Float) -> "M42F" + + V3 Int -> "V3I" + V3 Word -> "V3U" + V3 Float -> "V3F" + V3 Bool -> "V3B" + V3 (V2 Float) -> "M23F" + V3 (V3 Float) -> "M33F" + V3 (V4 Float) -> "M43F" + + V4 Int -> "V4I" + V4 Word -> "V4U" + V4 Float -> "V4F" + V4 Bool -> "V4B" + V4 (V2 Float) -> "M24F" + V4 (V3 Float) -> "M34F" + V4 (V4 Float) -> "M44F" + + Array t -> "Array<" ++ parens (ktType aliasMap t) ++ ">" + List t -> "List<" ++ ktType aliasMap t ++ ">" + Maybe t -> parens (ktType aliasMap t) ++ "?" + Map k v -> "Map<" ++ parens (ktType aliasMap k) ++ ", " ++ parens (hsType aliasMap v) ++ ">" + -- user defined + Data t -> t + x -> error $ "unknown type: " ++ show x + typeEnum :: AliasMap -> Type -> String typeEnum aliasMap a = case normalize aliasMap a of Data t -> t @@ -354,6 +396,11 @@ hasFieldNames :: [Field] -> Bool hasFieldNames [] = False hasFieldNames l = all (not . null . fieldName) l +nonSingular :: [ConstructorDef] -> Bool +nonSingular [] = False +nonSingular (_:[]) = False +nonSingular (_:_:_) = True + constType :: DataDef -> String constType = head . words . show @@ -449,4 +496,4 @@ a #:: b = Field a b serialization: json: encode/decode other? --} \ No newline at end of file +-} diff --git a/ddl/out/kotlin/LambdaCube.IR.kt b/ddl/out/kotlin/LambdaCube.IR.kt new file mode 100644 index 0000000..fc83467 --- /dev/null +++ b/ddl/out/kotlin/LambdaCube.IR.kt @@ -0,0 +1,581 @@ +// generated file, do not modify! +// 2020-05-18T22:30:50.902496Z + +package LambdaCube.IR; + + +typealias StreamName = Long + +typealias ProgramName = Long + +typealias TextureName = Long + +typealias SamplerName = Long + +typealias UniformName = String + +typealias SlotName = Long + +typealias FrameBufferComponent = Long + +typealias TextureUnit = Long + +typealias RenderTargetName = Long + +typealias TextureUnitMapping = Map + +sealed class ArrayValue() +data class VBoolArray( + val _0 : Array, +) : ArrayValue() +data class VIntArray( + val _0 : Array, +) : ArrayValue() +data class VWordArray( + val _0 : Array, +) : ArrayValue() +data class VFloatArray( + val _0 : Array, +) : ArrayValue() + +sealed class Value() +data class VBool( + val _0 : Bool, +) : Value() +data class VV2B( + val _0 : V2B, +) : Value() +data class VV3B( + val _0 : V3B, +) : Value() +data class VV4B( + val _0 : V4B, +) : Value() +data class VWord( + val _0 : Int, +) : Value() +data class VV2U( + val _0 : V2U, +) : Value() +data class VV3U( + val _0 : V3U, +) : Value() +data class VV4U( + val _0 : V4U, +) : Value() +data class VInt( + val _0 : Int, +) : Value() +data class VV2I( + val _0 : V2I, +) : Value() +data class VV3I( + val _0 : V3I, +) : Value() +data class VV4I( + val _0 : V4I, +) : Value() +data class VFloat( + val _0 : Float, +) : Value() +data class VV2F( + val _0 : V2F, +) : Value() +data class VV3F( + val _0 : V3F, +) : Value() +data class VV4F( + val _0 : V4F, +) : Value() +data class VM22F( + val _0 : M22F, +) : Value() +data class VM23F( + val _0 : M23F, +) : Value() +data class VM24F( + val _0 : M24F, +) : Value() +data class VM32F( + val _0 : M32F, +) : Value() +data class VM33F( + val _0 : M33F, +) : Value() +data class VM34F( + val _0 : M34F, +) : Value() +data class VM42F( + val _0 : M42F, +) : Value() +data class VM43F( + val _0 : M43F, +) : Value() +data class VM44F( + val _0 : M44F, +) : Value() + +sealed class InputType() +object Bool : InputType() +object V2B : InputType() +object V3B : InputType() +object V4B : InputType() +object Word : InputType() +object V2U : InputType() +object V3U : InputType() +object V4U : InputType() +object Int : InputType() +object V2I : InputType() +object V3I : InputType() +object V4I : InputType() +object Float : InputType() +object V2F : InputType() +object V3F : InputType() +object V4F : InputType() +object M22F : InputType() +object M23F : InputType() +object M24F : InputType() +object M32F : InputType() +object M33F : InputType() +object M34F : InputType() +object M42F : InputType() +object M43F : InputType() +object M44F : InputType() +object STexture1D : InputType() +object STexture2D : InputType() +object STextureCube : InputType() +object STexture1DArray : InputType() +object STexture2DArray : InputType() +object STexture2DRect : InputType() +object FTexture1D : InputType() +object FTexture2D : InputType() +object FTexture3D : InputType() +object FTextureCube : InputType() +object FTexture1DArray : InputType() +object FTexture2DArray : InputType() +object FTexture2DMS : InputType() +object FTexture2DMSArray : InputType() +object FTextureBuffer : InputType() +object FTexture2DRect : InputType() +object ITexture1D : InputType() +object ITexture2D : InputType() +object ITexture3D : InputType() +object ITextureCube : InputType() +object ITexture1DArray : InputType() +object ITexture2DArray : InputType() +object ITexture2DMS : InputType() +object ITexture2DMSArray : InputType() +object ITextureBuffer : InputType() +object ITexture2DRect : InputType() +object UTexture1D : InputType() +object UTexture2D : InputType() +object UTexture3D : InputType() +object UTextureCube : InputType() +object UTexture1DArray : InputType() +object UTexture2DArray : InputType() +object UTexture2DMS : InputType() +object UTexture2DMSArray : InputType() +object UTextureBuffer : InputType() +object UTexture2DRect : InputType() + +sealed class PointSpriteCoordOrigin() +object LowerLeft : PointSpriteCoordOrigin() +object UpperLeft : PointSpriteCoordOrigin() + +sealed class PointSize() +data class PointSize( + val _0 : Float, +) : PointSize() +object ProgramPointSize : PointSize() + +sealed class PolygonOffset() +object NoOffset : PolygonOffset() +data class Offset( + val _0 : Float, + val _1 : Float, +) : PolygonOffset() + +sealed class FrontFace() +object CCW : FrontFace() +object CW : FrontFace() + +sealed class PolygonMode() +data class PolygonPoint( + val _0 : PointSize, +) : PolygonMode() +data class PolygonLine( + val _0 : Float, +) : PolygonMode() +object PolygonFill : PolygonMode() + +sealed class ProvokingVertex() +object FirstVertex : ProvokingVertex() +object LastVertex : ProvokingVertex() + +sealed class CullMode() +object CullNone : CullMode() +data class CullFront( + val _0 : FrontFace, +) : CullMode() +data class CullBack( + val _0 : FrontFace, +) : CullMode() + +sealed class ComparisonFunction() +object Never : ComparisonFunction() +object Less : ComparisonFunction() +object Equal : ComparisonFunction() +object Lequal : ComparisonFunction() +object Greater : ComparisonFunction() +object Notequal : ComparisonFunction() +object Gequal : ComparisonFunction() +object Always : ComparisonFunction() + +typealias DepthFunction = ComparisonFunction + +sealed class StencilOperation() +object OpZero : StencilOperation() +object OpKeep : StencilOperation() +object OpReplace : StencilOperation() +object OpIncr : StencilOperation() +object OpIncrWrap : StencilOperation() +object OpDecr : StencilOperation() +object OpDecrWrap : StencilOperation() +object OpInvert : StencilOperation() + +sealed class BlendEquation() +object FuncAdd : BlendEquation() +object FuncSubtract : BlendEquation() +object FuncReverseSubtract : BlendEquation() +object Min : BlendEquation() +object Max : BlendEquation() + +sealed class BlendingFactor() +object Zero : BlendingFactor() +object One : BlendingFactor() +object SrcColor : BlendingFactor() +object OneMinusSrcColor : BlendingFactor() +object DstColor : BlendingFactor() +object OneMinusDstColor : BlendingFactor() +object SrcAlpha : BlendingFactor() +object OneMinusSrcAlpha : BlendingFactor() +object DstAlpha : BlendingFactor() +object OneMinusDstAlpha : BlendingFactor() +object ConstantColor : BlendingFactor() +object OneMinusConstantColor : BlendingFactor() +object ConstantAlpha : BlendingFactor() +object OneMinusConstantAlpha : BlendingFactor() +object SrcAlphaSaturate : BlendingFactor() + +sealed class LogicOperation() +object Clear : LogicOperation() +object And : LogicOperation() +object AndReverse : LogicOperation() +object Copy : LogicOperation() +object AndInverted : LogicOperation() +object Noop : LogicOperation() +object Xor : LogicOperation() +object Or : LogicOperation() +object Nor : LogicOperation() +object Equiv : LogicOperation() +object Invert : LogicOperation() +object OrReverse : LogicOperation() +object CopyInverted : LogicOperation() +object OrInverted : LogicOperation() +object Nand : LogicOperation() +object Set : LogicOperation() + +data class StencilOps( + val frontStencilOp : StencilOperation, + val backStencilOp : StencilOperation, +) + +data class StencilTest( + val stencilComparision : ComparisonFunction, + val stencilReference : Int, + val stencilMask : Int, +) + +data class StencilTests( + val _0 : StencilTest, + val _1 : StencilTest, +) + +sealed class FetchPrimitive() +object Points : FetchPrimitive() +object Lines : FetchPrimitive() +object Triangles : FetchPrimitive() +object LinesAdjacency : FetchPrimitive() +object TrianglesAdjacency : FetchPrimitive() + +sealed class OutputPrimitive() +object TrianglesOutput : OutputPrimitive() +object LinesOutput : OutputPrimitive() +object PointsOutput : OutputPrimitive() + +sealed class ColorArity() +object Red : ColorArity() +object RG : ColorArity() +object RGB : ColorArity() +object RGBA : ColorArity() + +sealed class Blending() +object NoBlending : Blending() +data class BlendLogicOp( + val _0 : LogicOperation, +) : Blending() +data class Blend( + val colorEqSrc : BlendEquation, + val alphaEqSrc : BlendEquation, + val colorFSrc : BlendingFactor, + val colorFDst : BlendingFactor, + val alphaFSrc : BlendingFactor, + val alphaFDst : BlendingFactor, + val color : V4F, +) : Blending() + +sealed class RasterContext() +data class PointCtx( + val _0 : PointSize, + val _1 : Float, + val _2 : PointSpriteCoordOrigin, +) : RasterContext() +data class LineCtx( + val _0 : Float, + val _1 : ProvokingVertex, +) : RasterContext() +data class TriangleCtx( + val _0 : CullMode, + val _1 : PolygonMode, + val _2 : PolygonOffset, + val _3 : ProvokingVertex, +) : RasterContext() + +sealed class FragmentOperation() +data class DepthOp( + val _0 : DepthFunction, + val _1 : Bool, +) : FragmentOperation() +data class StencilOp( + val _0 : StencilTests, + val _1 : StencilOps, + val _2 : StencilOps, +) : FragmentOperation() +data class ColorOp( + val _0 : Blending, + val _1 : Value, +) : FragmentOperation() + +data class AccumulationContext( + val accViewportName : String?, + val accOperations : List, +) + +sealed class TextureDataType() +data class FloatT( + val _0 : ColorArity, +) : TextureDataType() +data class IntT( + val _0 : ColorArity, +) : TextureDataType() +data class WordT( + val _0 : ColorArity, +) : TextureDataType() +object ShadowT : TextureDataType() + +sealed class TextureType() +data class Texture1D( + val _0 : TextureDataType, + val _1 : Long, +) : TextureType() +data class Texture2D( + val _0 : TextureDataType, + val _1 : Long, +) : TextureType() +data class Texture3D( + val _0 : TextureDataType, +) : TextureType() +data class TextureCube( + val _0 : TextureDataType, +) : TextureType() +data class TextureRect( + val _0 : TextureDataType, +) : TextureType() +data class Texture2DMS( + val _0 : TextureDataType, + val _1 : Long, + val _2 : Long, + val _3 : Bool, +) : TextureType() +data class TextureBuffer( + val _0 : TextureDataType, +) : TextureType() + +sealed class MipMap() +data class Mip( + val _0 : Long, + val _1 : Long, +) : MipMap() +object NoMip : MipMap() +data class AutoMip( + val _0 : Long, + val _1 : Long, +) : MipMap() + +sealed class Filter() +object Nearest : Filter() +object Linear : Filter() +object NearestMipmapNearest : Filter() +object NearestMipmapLinear : Filter() +object LinearMipmapNearest : Filter() +object LinearMipmapLinear : Filter() + +sealed class EdgeMode() +object Repeat : EdgeMode() +object MirroredRepeat : EdgeMode() +object ClampToEdge : EdgeMode() +object ClampToBorder : EdgeMode() + +sealed class ImageSemantic() +object Depth : ImageSemantic() +object Stencil : ImageSemantic() +object Color : ImageSemantic() + +sealed class ImageRef() +data class TextureImage( + val _0 : TextureName, + val _1 : Long, + val _2 : Long?, +) : ImageRef() +data class Framebuffer( + val _0 : ImageSemantic, +) : ImageRef() + +data class ClearImage( + val imageSemantic : ImageSemantic, + val clearValue : Value, +) + +sealed class Command() +data class SetRasterContext( + val _0 : RasterContext, +) : Command() +data class SetAccumulationContext( + val _0 : AccumulationContext, +) : Command() +data class SetRenderTarget( + val _0 : RenderTargetName, +) : Command() +data class SetProgram( + val _0 : ProgramName, +) : Command() +data class SetSamplerUniform( + val _0 : UniformName, + val _1 : TextureUnit, +) : Command() +data class SetTexture( + val _0 : TextureUnit, + val _1 : TextureName, +) : Command() +data class SetSampler( + val _0 : TextureUnit, + val _1 : SamplerName?, +) : Command() +data class RenderSlot( + val _0 : SlotName, +) : Command() +data class RenderStream( + val _0 : StreamName, +) : Command() +data class ClearRenderTarget( + val _0 : Array, +) : Command() +data class GenerateMipMap( + val _0 : TextureUnit, +) : Command() +data class SaveImage( + val _0 : FrameBufferComponent, + val _1 : ImageRef, +) : Command() +data class LoadImage( + val _0 : ImageRef, + val _1 : FrameBufferComponent, +) : Command() + +data class SamplerDescriptor( + val samplerWrapS : EdgeMode, + val samplerWrapT : EdgeMode?, + val samplerWrapR : EdgeMode?, + val samplerMinFilter : Filter, + val samplerMagFilter : Filter, + val samplerBorderColor : Value, + val samplerMinLod : Float?, + val samplerMaxLod : Float?, + val samplerLodBias : Float, + val samplerCompareFunc : ComparisonFunction?, +) + +data class TextureDescriptor( + val textureType : TextureType, + val textureSize : Value, + val textureSemantic : ImageSemantic, + val textureSampler : SamplerDescriptor, + val textureBaseLevel : Long, + val textureMaxLevel : Long, +) + +data class Parameter( + val name : String, + val ty : InputType, +) + +data class Program( + val programUniforms : Map, + val programStreams : Map, + val programInTextures : Map, + val programOutput : Array, + val vertexShader : String, + val geometryShader : String?, + val fragmentShader : String, +) + +data class Slot( + val slotName : String, + val slotStreams : Map, + val slotUniforms : Map, + val slotPrimitive : FetchPrimitive, + val slotPrograms : Array, +) + +data class StreamData( + val streamData : Map, + val streamType : Map, + val streamPrimitive : FetchPrimitive, + val streamPrograms : Array, +) + +data class TargetItem( + val targetSemantic : ImageSemantic, + val targetRef : ImageRef?, +) + +data class RenderTarget( + val renderTargets : Array, +) + +sealed class Backend() +object WebGL1 : Backend() +object OpenGL33 : Backend() + +data class Pipeline( + val info : String, + val backend : Backend, + val textures : Array, + val samplers : Array, + val targets : Array, + val programs : Array, + val slots : Array, + val streams : Array, + val commands : Array, +) + diff --git a/ddl/out/kotlin/LambdaCube.Mesh.kt b/ddl/out/kotlin/LambdaCube.Mesh.kt new file mode 100644 index 0000000..3bb228b --- /dev/null +++ b/ddl/out/kotlin/LambdaCube.Mesh.kt @@ -0,0 +1,51 @@ +// generated file, do not modify! +// 2020-05-18T22:30:51.113108Z + +package LambdaCube.Mesh; + + +sealed class MeshAttribute() +data class A_Float( + val _0 : Array, +) : MeshAttribute() +data class A_V2F( + val _0 : Array, +) : MeshAttribute() +data class A_V3F( + val _0 : Array, +) : MeshAttribute() +data class A_V4F( + val _0 : Array, +) : MeshAttribute() +data class A_M22F( + val _0 : Array, +) : MeshAttribute() +data class A_M33F( + val _0 : Array, +) : MeshAttribute() +data class A_M44F( + val _0 : Array, +) : MeshAttribute() +data class A_Int( + val _0 : Array, +) : MeshAttribute() +data class A_Word( + val _0 : Array, +) : MeshAttribute() + +sealed class MeshPrimitive() +object P_Points : MeshPrimitive() +object P_TriangleStrip : MeshPrimitive() +object P_Triangles : MeshPrimitive() +data class P_TriangleStripI( + val _0 : Array, +) : MeshPrimitive() +data class P_TrianglesI( + val _0 : Array, +) : MeshPrimitive() + +data class Mesh( + val mAttributes : Map, + val mPrimitive : MeshPrimitive, +) + diff --git a/ddl/out/kotlin/LambdaCube.PipelineSchema.kt b/ddl/out/kotlin/LambdaCube.PipelineSchema.kt new file mode 100644 index 0000000..56e9684 --- /dev/null +++ b/ddl/out/kotlin/LambdaCube.PipelineSchema.kt @@ -0,0 +1,40 @@ +// generated file, do not modify! +// 2020-05-18T22:30:27.770712Z + +package LambdaCube.PipelineSchema; + +import LambdaCube.IR; + +sealed class StreamType() +object Attribute_Word : StreamType() +object Attribute_V2U : StreamType() +object Attribute_V3U : StreamType() +object Attribute_V4U : StreamType() +object Attribute_Int : StreamType() +object Attribute_V2I : StreamType() +object Attribute_V3I : StreamType() +object Attribute_V4I : StreamType() +object Attribute_Float : StreamType() +object Attribute_V2F : StreamType() +object Attribute_V3F : StreamType() +object Attribute_V4F : StreamType() +object Attribute_M22F : StreamType() +object Attribute_M23F : StreamType() +object Attribute_M24F : StreamType() +object Attribute_M32F : StreamType() +object Attribute_M33F : StreamType() +object Attribute_M34F : StreamType() +object Attribute_M42F : StreamType() +object Attribute_M43F : StreamType() +object Attribute_M44F : StreamType() + +data class ObjectArraySchema( + val primitive : FetchPrimitive, + val attributes : Map, +) + +data class PipelineSchema( + val objectArrays : Map, + val uniforms : Map, +) + diff --git a/ddl/out/kotlin/LambdaCube.TypeInfo.kt b/ddl/out/kotlin/LambdaCube.TypeInfo.kt new file mode 100644 index 0000000..0a40c9b --- /dev/null +++ b/ddl/out/kotlin/LambdaCube.TypeInfo.kt @@ -0,0 +1,44 @@ +// generated file, do not modify! +// 2020-05-18T22:30:51.129384Z + +package LambdaCube.TypeInfo; + +import LambdaCube.IR; + +data class Range( + val startLine : Long, + val startColumn : Long, + val endLine : Long, + val endColumn : Long, +) + +data class TypeInfo( + val range : Range, + val text : String, +) + +data class WarningInfo( + val wRange : Range, + val wText : String, +) + +data class ErrorInfo( + val eRange : Range, + val eText : String, +) + +sealed class CompileResult() +data class CompileError( + val _0 : String, + val _1 : Array, + val _2 : Array, + val _3 : Array, +) : CompileResult() +data class Compiled( + val _0 : String, + val _1 : String, + val _2 : Pipeline, + val _3 : Array, + val _4 : Array, +) : CompileResult() + diff --git a/ddl/out/kotlin/TestData.kt b/ddl/out/kotlin/TestData.kt new file mode 100644 index 0000000..94ab61b --- /dev/null +++ b/ddl/out/kotlin/TestData.kt @@ -0,0 +1,54 @@ +// generated file, do not modify! +// 2020-05-18T22:30:51.145413Z + +package TestData; + +import LambdaCube.IR; +import LambdaCube.Mesh; +import LambdaCube.PipelineSchema; + +data class ClientInfo( + val clientName : String, + val clientBackend : Backend, +) + +data class Frame( + val renderCount : Long, + val frameUniforms : Map, + val frameTextures : Map, +) + +data class Scene( + val objectArrays : Map, + val renderTargetWidth : Long, + val renderTargetHeight : Long, + val frames : Array, +) + +data class PipelineInfo( + val pipelineName : String, + val pipeline : Pipeline, +) + +data class RenderJob( + val meshes : Array, + val textures : Array, + val schema : PipelineSchema, + val scenes : Array, + val pipelines : Array, +) + +data class FrameResult( + val frRenderTimes : Array, + val frImageWidth : Long, + val frImageHeight : Long, +) + +sealed class RenderJobResult() +data class RenderJobResult( + val _0 : FrameResult, +) : RenderJobResult() +data class RenderJobError( + val _0 : String, +) : RenderJobResult() + diff --git a/ddl/templates/data.kt.ede b/ddl/templates/data.kt.ede new file mode 100644 index 0000000..47a21db --- /dev/null +++ b/ddl/templates/data.kt.ede @@ -0,0 +1,30 @@ +// generated file, do not modify! +// {{ dateTime }} + +package {{ moduleName }}; + +{% for m in imports %} +import {{ m.value }}; +{% endfor %} + +{% for t in dataAndType %} +{% case t.value | constType %} +{% when "DataDef" %} +{% if t.value.constructors | nonSingular %} +sealed class {{ t.value.dataName }}() +{% endif %} +{% for c in t.value.constructors %} +{% if c.value.fields | empty %} +object {{ c.value.name }}{% if t.value.constructors | nonSingular %} : {{ t.value.dataName }}(){% endif %} +{% else %} +data class {{ c.value.name }}({% for f in c.value.fields %}{% if c.value.fields | hasFieldNames %} + val {{ f.value.fieldName }} : {{ f.value.fieldType | ktType }},{% else %} + val _{{ f.index0 }} : {{ f.value.fieldType | ktType }},{% endif %}{% endfor %} +){% if t.value.constructors | nonSingular %} : {{ t.value.dataName }}(){% endif %} +{% endif %} +{% endfor %} +{% when "TypeAlias" %} +typealias {{ t.value.aliasName }} = {{ t.value.aliasType | ktType }} +{% endcase %} + +{% endfor %} \ No newline at end of file From 53544a38adc1aa20ffb45556785bcb2cf1f340f9 Mon Sep 17 00:00:00 2001 From: Anthony Cerruti Date: Mon, 18 May 2020 15:53:25 -0700 Subject: [PATCH 2/7] Add a rudimentary RT --- ddl/lib/RT.kt | 28 +++++++++++++++++++++ ddl/out/kotlin/LambdaCube.IR.kt | 4 ++- ddl/out/kotlin/LambdaCube.Mesh.kt | 4 ++- ddl/out/kotlin/LambdaCube.PipelineSchema.kt | 4 ++- ddl/out/kotlin/LambdaCube.TypeInfo.kt | 4 ++- ddl/out/kotlin/TestData.kt | 4 ++- ddl/templates/data.kt.ede | 2 ++ 7 files changed, 45 insertions(+), 5 deletions(-) create mode 100644 ddl/lib/RT.kt diff --git a/ddl/lib/RT.kt b/ddl/lib/RT.kt new file mode 100644 index 0000000..452816e --- /dev/null +++ b/ddl/lib/RT.kt @@ -0,0 +1,28 @@ +package RT; + +data class V2(x: A, y: A) +data class V3(x: A, y: A, z: A) +data class V4(x: A, y: A, z: A, w: A) + +typealias M22F = V2 +typealias M23F = V3 +typealias M24F = V4 +typealias M32F = V2 +typealias M33F = V3 +typealias M34F = V4 +typealias M42F = V2 +typealias M43F = V3 +typealias M44F = V4 + +typealias V2F = V2 +typealias V3F = V3 +typealias V4F = V4 +typealias V2I = V2 +typealias V3I = V3 +typealias V4I = V4 +typealias V2U = V2 +typealias V3U = V3 +typealias V4U = V4 +typealias V2B = V2 +typealias V3B = V3 +typealias V4B = V4 diff --git a/ddl/out/kotlin/LambdaCube.IR.kt b/ddl/out/kotlin/LambdaCube.IR.kt index fc83467..e651dbd 100644 --- a/ddl/out/kotlin/LambdaCube.IR.kt +++ b/ddl/out/kotlin/LambdaCube.IR.kt @@ -1,8 +1,10 @@ // generated file, do not modify! -// 2020-05-18T22:30:50.902496Z +// 2020-05-18T22:52:34.098621Z package LambdaCube.IR; +import RT.*; + typealias StreamName = Long diff --git a/ddl/out/kotlin/LambdaCube.Mesh.kt b/ddl/out/kotlin/LambdaCube.Mesh.kt index 3bb228b..70c5d55 100644 --- a/ddl/out/kotlin/LambdaCube.Mesh.kt +++ b/ddl/out/kotlin/LambdaCube.Mesh.kt @@ -1,8 +1,10 @@ // generated file, do not modify! -// 2020-05-18T22:30:51.113108Z +// 2020-05-18T22:52:34.32849Z package LambdaCube.Mesh; +import RT.*; + sealed class MeshAttribute() data class A_Float( diff --git a/ddl/out/kotlin/LambdaCube.PipelineSchema.kt b/ddl/out/kotlin/LambdaCube.PipelineSchema.kt index 56e9684..09ff119 100644 --- a/ddl/out/kotlin/LambdaCube.PipelineSchema.kt +++ b/ddl/out/kotlin/LambdaCube.PipelineSchema.kt @@ -1,8 +1,10 @@ // generated file, do not modify! -// 2020-05-18T22:30:27.770712Z +// 2020-05-18T22:52:34.314708Z package LambdaCube.PipelineSchema; +import RT.*; + import LambdaCube.IR; sealed class StreamType() diff --git a/ddl/out/kotlin/LambdaCube.TypeInfo.kt b/ddl/out/kotlin/LambdaCube.TypeInfo.kt index 0a40c9b..d308263 100644 --- a/ddl/out/kotlin/LambdaCube.TypeInfo.kt +++ b/ddl/out/kotlin/LambdaCube.TypeInfo.kt @@ -1,8 +1,10 @@ // generated file, do not modify! -// 2020-05-18T22:30:51.129384Z +// 2020-05-18T22:52:34.350061Z package LambdaCube.TypeInfo; +import RT.*; + import LambdaCube.IR; data class Range( diff --git a/ddl/out/kotlin/TestData.kt b/ddl/out/kotlin/TestData.kt index 94ab61b..835ea37 100644 --- a/ddl/out/kotlin/TestData.kt +++ b/ddl/out/kotlin/TestData.kt @@ -1,8 +1,10 @@ // generated file, do not modify! -// 2020-05-18T22:30:51.145413Z +// 2020-05-18T22:52:34.367596Z package TestData; +import RT.*; + import LambdaCube.IR; import LambdaCube.Mesh; import LambdaCube.PipelineSchema; diff --git a/ddl/templates/data.kt.ede b/ddl/templates/data.kt.ede index 47a21db..f04ad9f 100644 --- a/ddl/templates/data.kt.ede +++ b/ddl/templates/data.kt.ede @@ -3,6 +3,8 @@ package {{ moduleName }}; +import RT.*; + {% for m in imports %} import {{ m.value }}; {% endfor %} From a4043ce882475fae4aa8811f7244ac98d095ab3c Mon Sep 17 00:00:00 2001 From: Anthony Cerruti Date: Mon, 18 May 2020 15:57:55 -0700 Subject: [PATCH 3/7] Fix forgotten keywords and missing 'ean' in 'Boolean' --- ddl/lib/RT.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ddl/lib/RT.kt b/ddl/lib/RT.kt index 452816e..f7edc2b 100644 --- a/ddl/lib/RT.kt +++ b/ddl/lib/RT.kt @@ -1,8 +1,8 @@ package RT; -data class V2(x: A, y: A) -data class V3(x: A, y: A, z: A) -data class V4(x: A, y: A, z: A, w: A) +data class V2(val x: A, val y: A) +data class V3(val x: A, val y: A, val z: A) +data class V4(val x: A, val y: A, val z: A, val w: A) typealias M22F = V2 typealias M23F = V3 @@ -23,6 +23,6 @@ typealias V4I = V4 typealias V2U = V2 typealias V3U = V3 typealias V4U = V4 -typealias V2B = V2 -typealias V3B = V3 -typealias V4B = V4 +typealias V2B = V2 +typealias V3B = V3 +typealias V4B = V4 From 33b5a6a0fe7460255062872e47b0553b7987a788 Mon Sep 17 00:00:00 2001 From: Anthony Cerruti Date: Mon, 18 May 2020 16:04:19 -0700 Subject: [PATCH 4/7] Import dependencies properly --- ddl/templates/data.kt.ede | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddl/templates/data.kt.ede b/ddl/templates/data.kt.ede index f04ad9f..c481f87 100644 --- a/ddl/templates/data.kt.ede +++ b/ddl/templates/data.kt.ede @@ -6,7 +6,7 @@ package {{ moduleName }}; import RT.*; {% for m in imports %} -import {{ m.value }}; +import {{ m.value }}.*; {% endfor %} {% for t in dataAndType %} From 922d59f71e1561719e1ba228f43c411b719fa73e Mon Sep 17 00:00:00 2001 From: Anthony Cerruti Date: Thu, 21 May 2020 12:12:56 -0700 Subject: [PATCH 5/7] Start work on the JSON (de)serializer I'm gonna have to go in and change data constructors to be like Java, i.e. a base sealed class like Foo and constructors Foo_ and Bar_ because there's conflicts. --- ddl/Generate.hs | 2 + ddl/Language.hs | 4 +- ddl/out/kotlin/JSON.kt | 220 ++++++++++++++++++++ ddl/out/kotlin/LambdaCube.IR.kt | 46 ++-- ddl/out/kotlin/LambdaCube.Mesh.kt | 6 +- ddl/out/kotlin/LambdaCube.PipelineSchema.kt | 8 +- ddl/out/kotlin/LambdaCube.TypeInfo.kt | 16 +- ddl/out/kotlin/TestData.kt | 22 +- ddl/templates/data.kt.ede | 6 +- ddl/templates/json.kt.ede | 123 +++++++++++ 10 files changed, 399 insertions(+), 54 deletions(-) create mode 100644 ddl/out/kotlin/JSON.kt create mode 100644 ddl/templates/json.kt.ede diff --git a/ddl/Generate.hs b/ddl/Generate.hs index 30e57f1..3bdad9d 100644 --- a/ddl/Generate.hs +++ b/ddl/Generate.hs @@ -33,6 +33,7 @@ main = do dataJava <- eitherParseFile "templates/data.java.ede" jsonJava <- eitherParseFile "templates/json.java.ede" dataKt <- eitherParseFile "templates/data.kt.ede" + jsonKt <- eitherParseFile "templates/json.kt.ede" dataHpp <- eitherParseFile "templates/data.hpp.ede" dataHpp2 <- eitherParseFile "templates/data.hpp2.ede" dataCpp <- eitherParseFile "templates/data.cpp.ede" @@ -105,6 +106,7 @@ main = do either error (\x -> writeFileIfDiffer ("out/java/" ++ toPath name ++ "/JSON.java") $ LText.unpack x) $ jsonJava >>= (\t -> eitherRenderWith mylib t env) -- Kotlin either error (\x -> writeFileIfDiffer ("out/kotlin/" ++ name ++ ".kt") $ LText.unpack x) $ dataKt >>= (\t -> eitherRenderWith mylib t env) + either error (\x -> writeFileIfDiffer "out/kotlin/JSON.kt" $ LText.unpack x) $ jsonKt >>= (\t -> eitherRenderWith mylib t env) -- C# either error (\x -> writeFileIfDiffer ("out/csharp/" ++ name ++ ".cs") $ LText.unpack x) $ dataCs >>= (\t -> eitherRenderWith mylib t env) -- Swift diff --git a/ddl/Language.hs b/ddl/Language.hs index 15c5708..6f0c34d 100644 --- a/ddl/Language.hs +++ b/ddl/Language.hs @@ -270,9 +270,9 @@ javaType aliasMap a = case normalize aliasMap a of ktType :: AliasMap -> Type -> String ktType aliasMap = \case - Int -> "Long" + Int -> "Int" Int32 -> "Int" - Word -> "Long" + Word -> "Int" Word32 -> "Int" Float -> "Float" Bool -> "Bool" diff --git a/ddl/out/kotlin/JSON.kt b/ddl/out/kotlin/JSON.kt new file mode 100644 index 0000000..2b9d2a3 --- /dev/null +++ b/ddl/out/kotlin/JSON.kt @@ -0,0 +1,220 @@ +// generated file, do not modify! +// 2020-05-21T19:10:15.739651Z + +package TestData + +import org.json.* +import RT.* + +import LambdaCube.IR.* +import LambdaCube.Mesh.* +import LambdaCube.PipelineSchema.* + +object JSON { + + enum class Type { + Int, + Float, + String, + Array_Int, + Array_Float, + Array_String, + Array_Frame, + Array_Mesh, + Array_PipelineInfo, + Array_Scene, + Map_String_Int, + Map_String_Array_Int, + Map_String_Value, + Backend, + ClientInfo, + Frame, + FrameResult, + Mesh, + Pipeline, + PipelineInfo, + PipelineSchema, + RenderJob, + RenderJobResult, + Scene, + Value, + } + + @Throws(JSONException::class, Exception::class) + fun fromJSON(Type type, Object rawObj): Object { + when (type) { + is Int -> return (rawObj as Number).intValue() + is Float -> return (rawObj as Number).floatValue() + is String -> return rawObj as String + is Array_Int -> { + val obj = rawObj as JSONArray + return Array(obj.length()) { ind: Int -> + fromJSON(Type.Int, obj.get(ind)) as Int + } + } + is Array_Float -> { + val obj = rawObj as JSONArray + return Array(obj.length()) { ind: Int -> + fromJSON(Type.Float, obj.get(ind)) as Float + } + } + is Array_String -> { + val obj = rawObj as JSONArray + return Array(obj.length()) { ind: Int -> + fromJSON(Type.String, obj.get(ind)) as String + } + } + is Array_Frame -> { + val obj = rawObj as JSONArray + return Array(obj.length()) { ind: Int -> + fromJSON(Type.Frame, obj.get(ind)) as Frame + } + } + is Array_Mesh -> { + val obj = rawObj as JSONArray + return Array(obj.length()) { ind: Int -> + fromJSON(Type.Mesh, obj.get(ind)) as Mesh + } + } + is Array_PipelineInfo -> { + val obj = rawObj as JSONArray + return Array(obj.length()) { ind: Int -> + fromJSON(Type.PipelineInfo, obj.get(ind)) as PipelineInfo + } + } + is Array_Scene -> { + val obj = rawObj as JSONArray + return Array(obj.length()) { ind: Int -> + fromJSON(Type.Scene, obj.get(ind)) as Scene + } + } + is Map_String_Int -> { + val obj = rawObj as JSONObject + Map map = Map() + val keyIt = obj.keys() + while(keyIt.hasNext()) { + String key = keyIt.next() + map.put(key, fromJSON(Type.Int, obj.get(key)) as Int) + } + return map + } + is Map_String_Array_Int -> { + val obj = rawObj as JSONObject + Map map = Map() + val keyIt = obj.keys() + while(keyIt.hasNext()) { + String key = keyIt.next() + map.put(key, fromJSON(Type.Array_Int, obj.get(key)) as Array) + } + return map + } + is Map_String_Value -> { + val obj = rawObj as JSONObject + Map map = Map() + val keyIt = obj.keys() + while(keyIt.hasNext()) { + String key = keyIt.next() + map.put(key, fromJSON(Type.Value, obj.get(key)) as Value) + } + return map + } + + is ClientInfo -> { + val obj = rawObj as JSONObject + val tag = obj.getString("tag") + when (tag) { + is "ClientInfo" -> { + return ClientInfo( + clientName = fromJSON(Type.String, obj.get("clientName")) as String, + clientBackend = fromJSON(Type.Backend, obj.get("clientBackend")) as Backend, + ) + } + } + } + is Frame -> { + val obj = rawObj as JSONObject + val tag = obj.getString("tag") + when (tag) { + is "Frame" -> { + return Frame( + renderCount = fromJSON(Type.Int, obj.get("renderCount")) as Int, + frameUniforms = fromJSON(Type.Map_String_Value, obj.get("frameUniforms")) as Map, + frameTextures = fromJSON(Type.Map_String_Int, obj.get("frameTextures")) as Map, + ) + } + } + } + is Scene -> { + val obj = rawObj as JSONObject + val tag = obj.getString("tag") + when (tag) { + is "Scene" -> { + return Scene( + objectArrays = fromJSON(Type.Map_String_Array_Int, obj.get("objectArrays")) as Map, + renderTargetWidth = fromJSON(Type.Int, obj.get("renderTargetWidth")) as Int, + renderTargetHeight = fromJSON(Type.Int, obj.get("renderTargetHeight")) as Int, + frames = fromJSON(Type.Array_Frame, obj.get("frames")) as Array, + ) + } + } + } + is PipelineInfo -> { + val obj = rawObj as JSONObject + val tag = obj.getString("tag") + when (tag) { + is "PipelineInfo" -> { + return PipelineInfo( + pipelineName = fromJSON(Type.String, obj.get("pipelineName")) as String, + pipeline = fromJSON(Type.Pipeline, obj.get("pipeline")) as Pipeline, + ) + } + } + } + is RenderJob -> { + val obj = rawObj as JSONObject + val tag = obj.getString("tag") + when (tag) { + is "RenderJob" -> { + return RenderJob( + meshes = fromJSON(Type.Array_Mesh, obj.get("meshes")) as Array, + textures = fromJSON(Type.Array_String, obj.get("textures")) as Array, + schema = fromJSON(Type.PipelineSchema, obj.get("schema")) as PipelineSchema, + scenes = fromJSON(Type.Array_Scene, obj.get("scenes")) as Array, + pipelines = fromJSON(Type.Array_PipelineInfo, obj.get("pipelines")) as Array, + ) + } + } + } + is FrameResult -> { + val obj = rawObj as JSONObject + val tag = obj.getString("tag") + when (tag) { + is "FrameResult" -> { + return FrameResult( + frRenderTimes = fromJSON(Type.Array_Float, obj.get("frRenderTimes")) as Array, + frImageWidth = fromJSON(Type.Int, obj.get("frImageWidth")) as Int, + frImageHeight = fromJSON(Type.Int, obj.get("frImageHeight")) as Int, + ) + } + } + } + is RenderJobResult -> { + val obj = rawObj as JSONObject + val tag = obj.getString("tag") + when (tag) { + is "RenderJobResult" -> { + return RenderJobResult( + _0 = fromJSON(Type.FrameResult, obj.get("arg0")) as FrameResult, + ) + } + is "RenderJobError" -> { + return RenderJobError( + _0 = fromJSON(Type.String, obj.get("arg0")) as String, + ) + } + } + } + } + } + +} diff --git a/ddl/out/kotlin/LambdaCube.IR.kt b/ddl/out/kotlin/LambdaCube.IR.kt index e651dbd..7e72529 100644 --- a/ddl/out/kotlin/LambdaCube.IR.kt +++ b/ddl/out/kotlin/LambdaCube.IR.kt @@ -1,28 +1,28 @@ // generated file, do not modify! -// 2020-05-18T22:52:34.098621Z +// 2020-05-21T18:52:10.885834Z -package LambdaCube.IR; +package LambdaCube.IR -import RT.*; +import RT.* -typealias StreamName = Long +typealias StreamName = Int -typealias ProgramName = Long +typealias ProgramName = Int -typealias TextureName = Long +typealias TextureName = Int -typealias SamplerName = Long +typealias SamplerName = Int typealias UniformName = String -typealias SlotName = Long +typealias SlotName = Int -typealias FrameBufferComponent = Long +typealias FrameBufferComponent = Int -typealias TextureUnit = Long +typealias TextureUnit = Int -typealias RenderTargetName = Long +typealias RenderTargetName = Int typealias TextureUnitMapping = Map @@ -388,11 +388,11 @@ object ShadowT : TextureDataType() sealed class TextureType() data class Texture1D( val _0 : TextureDataType, - val _1 : Long, + val _1 : Int, ) : TextureType() data class Texture2D( val _0 : TextureDataType, - val _1 : Long, + val _1 : Int, ) : TextureType() data class Texture3D( val _0 : TextureDataType, @@ -405,8 +405,8 @@ data class TextureRect( ) : TextureType() data class Texture2DMS( val _0 : TextureDataType, - val _1 : Long, - val _2 : Long, + val _1 : Int, + val _2 : Int, val _3 : Bool, ) : TextureType() data class TextureBuffer( @@ -415,13 +415,13 @@ data class TextureBuffer( sealed class MipMap() data class Mip( - val _0 : Long, - val _1 : Long, + val _0 : Int, + val _1 : Int, ) : MipMap() object NoMip : MipMap() data class AutoMip( - val _0 : Long, - val _1 : Long, + val _0 : Int, + val _1 : Int, ) : MipMap() sealed class Filter() @@ -446,8 +446,8 @@ object Color : ImageSemantic() sealed class ImageRef() data class TextureImage( val _0 : TextureName, - val _1 : Long, - val _2 : Long?, + val _1 : Int, + val _2 : Int?, ) : ImageRef() data class Framebuffer( val _0 : ImageSemantic, @@ -522,8 +522,8 @@ data class TextureDescriptor( val textureSize : Value, val textureSemantic : ImageSemantic, val textureSampler : SamplerDescriptor, - val textureBaseLevel : Long, - val textureMaxLevel : Long, + val textureBaseLevel : Int, + val textureMaxLevel : Int, ) data class Parameter( diff --git a/ddl/out/kotlin/LambdaCube.Mesh.kt b/ddl/out/kotlin/LambdaCube.Mesh.kt index 70c5d55..70fcb17 100644 --- a/ddl/out/kotlin/LambdaCube.Mesh.kt +++ b/ddl/out/kotlin/LambdaCube.Mesh.kt @@ -1,9 +1,9 @@ // generated file, do not modify! -// 2020-05-18T22:52:34.32849Z +// 2020-05-21T18:29:16.473984Z -package LambdaCube.Mesh; +package LambdaCube.Mesh -import RT.*; +import RT.* sealed class MeshAttribute() diff --git a/ddl/out/kotlin/LambdaCube.PipelineSchema.kt b/ddl/out/kotlin/LambdaCube.PipelineSchema.kt index 09ff119..11961d5 100644 --- a/ddl/out/kotlin/LambdaCube.PipelineSchema.kt +++ b/ddl/out/kotlin/LambdaCube.PipelineSchema.kt @@ -1,11 +1,11 @@ // generated file, do not modify! -// 2020-05-18T22:52:34.314708Z +// 2020-05-21T18:29:16.46264Z -package LambdaCube.PipelineSchema; +package LambdaCube.PipelineSchema -import RT.*; +import RT.* -import LambdaCube.IR; +import LambdaCube.IR.* sealed class StreamType() object Attribute_Word : StreamType() diff --git a/ddl/out/kotlin/LambdaCube.TypeInfo.kt b/ddl/out/kotlin/LambdaCube.TypeInfo.kt index d308263..ddb7387 100644 --- a/ddl/out/kotlin/LambdaCube.TypeInfo.kt +++ b/ddl/out/kotlin/LambdaCube.TypeInfo.kt @@ -1,17 +1,17 @@ // generated file, do not modify! -// 2020-05-18T22:52:34.350061Z +// 2020-05-21T18:52:11.102922Z -package LambdaCube.TypeInfo; +package LambdaCube.TypeInfo -import RT.*; +import RT.* -import LambdaCube.IR; +import LambdaCube.IR.* data class Range( - val startLine : Long, - val startColumn : Long, - val endLine : Long, - val endColumn : Long, + val startLine : Int, + val startColumn : Int, + val endLine : Int, + val endColumn : Int, ) data class TypeInfo( diff --git a/ddl/out/kotlin/TestData.kt b/ddl/out/kotlin/TestData.kt index 835ea37..66cc01c 100644 --- a/ddl/out/kotlin/TestData.kt +++ b/ddl/out/kotlin/TestData.kt @@ -1,13 +1,13 @@ // generated file, do not modify! -// 2020-05-18T22:52:34.367596Z +// 2020-05-21T18:52:11.118474Z -package TestData; +package TestData -import RT.*; +import RT.* -import LambdaCube.IR; -import LambdaCube.Mesh; -import LambdaCube.PipelineSchema; +import LambdaCube.IR.* +import LambdaCube.Mesh.* +import LambdaCube.PipelineSchema.* data class ClientInfo( val clientName : String, @@ -15,15 +15,15 @@ data class ClientInfo( ) data class Frame( - val renderCount : Long, + val renderCount : Int, val frameUniforms : Map, val frameTextures : Map, ) data class Scene( val objectArrays : Map, - val renderTargetWidth : Long, - val renderTargetHeight : Long, + val renderTargetWidth : Int, + val renderTargetHeight : Int, val frames : Array, ) @@ -42,8 +42,8 @@ data class RenderJob( data class FrameResult( val frRenderTimes : Array, - val frImageWidth : Long, - val frImageHeight : Long, + val frImageWidth : Int, + val frImageHeight : Int, ) sealed class RenderJobResult() diff --git a/ddl/templates/data.kt.ede b/ddl/templates/data.kt.ede index c481f87..729d626 100644 --- a/ddl/templates/data.kt.ede +++ b/ddl/templates/data.kt.ede @@ -1,12 +1,12 @@ // generated file, do not modify! // {{ dateTime }} -package {{ moduleName }}; +package {{ moduleName }} -import RT.*; +import RT.* {% for m in imports %} -import {{ m.value }}.*; +import {{ m.value }}.* {% endfor %} {% for t in dataAndType %} diff --git a/ddl/templates/json.kt.ede b/ddl/templates/json.kt.ede new file mode 100644 index 0000000..bfa25df --- /dev/null +++ b/ddl/templates/json.kt.ede @@ -0,0 +1,123 @@ +// generated file, do not modify! +// {{ dateTime }} + +package {{ moduleName }} + +import org.json.* +import RT.* + +{% for m in imports %} +import {{ m.value }}.* +{% endfor %} + +object JSON { + + enum class Type { {% for t in usedTypes %} + {{ t.value | typeEnum }},{% endfor %} + } + + @Throws(JSONException::class, Exception::class) + fun fromJSON(Type type, Object rawObj): Object { + when (type) { + {% for t in usedTypes %} + {% case t.value.tag %} + {% when "Data" %} + {% when "V2" %} + is {{ t.value | typeEnum }} -> { + val obj = rawObj as JSONObject + return {{ t.value | ktType }}( + fromJSON(Type.{{ t.value.type_ | typeEnum }}, obj.get("x")) as {{ t.value.type_ | ktType }}, + fromJSON(Type.{{ t.value.type_ | typeEnum }}, obj.get("y")) as {{ t.value.type_ | ktType }} + ) + } + {% when "V3" %} + is {{ t.value | typeEnum }} -> { + val obj = rawObj as JSONObject + return {{ t.value | ktType }}( + fromJSON(Type.{{ t.value.type_ | typeEnum }}, obj.get("x")) as {{ t.value.type_ | ktType }}, + fromJSON(Type.{{ t.value.type_ | typeEnum }}, obj.get("y")) as {{ t.value.type_ | ktType }}, + fromJSON(Type.{{ t.value.type_ | typeEnum }}, obj.get("z")) as {{ t.value.type_ | ktType }} + ) + } + {% when "V4" %} + is {{ t.value | typeEnum }} -> { + val obj = rawObj as JSONObject + return {{ t.value | ktType }}( + fromJSON(Type.{{ t.value.type_ | typeEnum }}, obj.get("x")) as {{ t.value.type_ | ktType }}, + fromJSON(Type.{{ t.value.type_ | typeEnum }}, obj.get("y")) as {{ t.value.type_ | ktType }}, + fromJSON(Type.{{ t.value.type_ | typeEnum }}, obj.get("z")) as {{ t.value.type_ | ktType }}, + fromJSON(Type.{{ t.value.type_ | typeEnum }}, obj.get("w")) as {{ t.value.type_ | ktType }} + ) + } + {% when "Map" %} + is {{ t.value | typeEnum }} -> { + val obj = rawObj as JSONObject + {{ t.value | ktType }} map = {{ t.value | ktType }}() + val keyIt = obj.keys() + while(keyIt.hasNext()) { + String key = keyIt.next() + map.put(key, fromJSON(Type.{{ t.value.value_ | typeEnum }}, obj.get(key)) as {{ t.value.value_ | ktType }}) + } + return map + } + {% when "Array" %} + is {{ t.value | typeEnum }} -> { + val obj = rawObj as JSONArray + return {{ t.value | ktType }}(obj.length()) { ind: Int -> + fromJSON(Type.{{ t.value.type_ | typeEnum }}, obj.get(ind)) as {{ t.value.type_ | ktType }} + } + } + {% when "List" %} + is {{ t.value | typeEnum }} -> { + val obj = rawObj as JSONArray + return {{ t.value | ktType }}(obj.length()) { ind: Int -> + fromJSON(Type.{{ t.value.type_ | typeEnum }}, obj.get(ind)) as {{ t.value.type_ | ktType }} + } + } + {% when "Maybe" %} + is {{ t.value | typeEnum }} -> { + return if(rawObj == null || rawObj = JSONObject.NULL) { + null + } else { + fromJSON(Type.{{ t.value.type_ | typeEnum }}, rawObj as JSONObject) as {{ t.value.type_ | ktType }} + } + } + {% when "Int" %} + is {{ t.value | typeEnum }} -> return (rawObj as Number).intValue() + {% when "Int32" %} + is {{ t.value | typeEnum }} -> return (rawObj as Number).intValue() + {% when "Word" %} + is {{ t.value | typeEnum }} -> return (rawObj as Number).intValue() + {% when "Word32" %} + is {{ t.value | typeEnum }} -> return (rawObj as Number).intValue() + {% when "Float" %} + is {{ t.value | typeEnum }} -> return (rawObj as Number).floatValue() + {% else %} + is {{ t.value | typeEnum }} -> return rawObj as {{ t.value | ktType }} + {% endcase %} + {% endfor %} + + {% for t in definitions %} + is {{ t.value.dataName }} -> { + val obj = rawObj as JSONObject + val tag = obj.getString("tag") + when (tag) { + {% for c in t.value.constructors %} + is "{{ c.value.name }}" -> { + return {% if c.value.fields | empty %} + {{c.value.name}} + {% else %} + {{c.value.name}}({% for f in c.value.fields %}{% if c.value.fields | hasFieldNames %} + {{ f.value.fieldName }} = fromJSON(Type.{{ f.value.fieldType | typeEnum }}, obj.get("{{ f.value.fieldName }}")) as {{ f.value.fieldType | ktType }}{% else %} + _{{ f.index0 }} = fromJSON(Type.{{ f.value.fieldType | typeEnum }}, obj.get("arg{{ f.index0 }}")) as {{ f.value.fieldType | ktType }}{% endif %},{% endfor %} + ) + {% endif %} + } + {% endfor %} + } + } + {% endfor %} + } + } + +} From ad02b750465dd3014db539b61852e096020af9d3 Mon Sep 17 00:00:00 2001 From: Anthony Cerruti Date: Thu, 21 May 2020 13:28:07 -0700 Subject: [PATCH 6/7] Change nonSingular constructors to use _ --- ddl/out/kotlin/JSON.kt | 6 +- ddl/out/kotlin/LambdaCube.IR.kt | 448 ++++++++++---------- ddl/out/kotlin/LambdaCube.Mesh.kt | 30 +- ddl/out/kotlin/LambdaCube.PipelineSchema.kt | 44 +- ddl/out/kotlin/LambdaCube.TypeInfo.kt | 6 +- ddl/out/kotlin/TestData.kt | 6 +- ddl/templates/data.kt.ede | 4 +- ddl/templates/json.kt.ede | 4 +- 8 files changed, 274 insertions(+), 274 deletions(-) diff --git a/ddl/out/kotlin/JSON.kt b/ddl/out/kotlin/JSON.kt index 2b9d2a3..ecfb4a9 100644 --- a/ddl/out/kotlin/JSON.kt +++ b/ddl/out/kotlin/JSON.kt @@ -1,5 +1,5 @@ // generated file, do not modify! -// 2020-05-21T19:10:15.739651Z +// 2020-05-21T20:27:28.444912Z package TestData @@ -203,12 +203,12 @@ object JSON { val tag = obj.getString("tag") when (tag) { is "RenderJobResult" -> { - return RenderJobResult( + return _RenderJobResult( _0 = fromJSON(Type.FrameResult, obj.get("arg0")) as FrameResult, ) } is "RenderJobError" -> { - return RenderJobError( + return _RenderJobError( _0 = fromJSON(Type.String, obj.get("arg0")) as String, ) } diff --git a/ddl/out/kotlin/LambdaCube.IR.kt b/ddl/out/kotlin/LambdaCube.IR.kt index 7e72529..6fcba73 100644 --- a/ddl/out/kotlin/LambdaCube.IR.kt +++ b/ddl/out/kotlin/LambdaCube.IR.kt @@ -1,5 +1,5 @@ // generated file, do not modify! -// 2020-05-21T18:52:10.885834Z +// 2020-05-21T20:25:27.552277Z package LambdaCube.IR @@ -27,265 +27,265 @@ typealias RenderTargetName = Int typealias TextureUnitMapping = Map sealed class ArrayValue() -data class VBoolArray( +data class _VBoolArray( val _0 : Array, ) : ArrayValue() -data class VIntArray( +data class _VIntArray( val _0 : Array, ) : ArrayValue() -data class VWordArray( +data class _VWordArray( val _0 : Array, ) : ArrayValue() -data class VFloatArray( +data class _VFloatArray( val _0 : Array, ) : ArrayValue() sealed class Value() -data class VBool( +data class _VBool( val _0 : Bool, ) : Value() -data class VV2B( +data class _VV2B( val _0 : V2B, ) : Value() -data class VV3B( +data class _VV3B( val _0 : V3B, ) : Value() -data class VV4B( +data class _VV4B( val _0 : V4B, ) : Value() -data class VWord( +data class _VWord( val _0 : Int, ) : Value() -data class VV2U( +data class _VV2U( val _0 : V2U, ) : Value() -data class VV3U( +data class _VV3U( val _0 : V3U, ) : Value() -data class VV4U( +data class _VV4U( val _0 : V4U, ) : Value() -data class VInt( +data class _VInt( val _0 : Int, ) : Value() -data class VV2I( +data class _VV2I( val _0 : V2I, ) : Value() -data class VV3I( +data class _VV3I( val _0 : V3I, ) : Value() -data class VV4I( +data class _VV4I( val _0 : V4I, ) : Value() -data class VFloat( +data class _VFloat( val _0 : Float, ) : Value() -data class VV2F( +data class _VV2F( val _0 : V2F, ) : Value() -data class VV3F( +data class _VV3F( val _0 : V3F, ) : Value() -data class VV4F( +data class _VV4F( val _0 : V4F, ) : Value() -data class VM22F( +data class _VM22F( val _0 : M22F, ) : Value() -data class VM23F( +data class _VM23F( val _0 : M23F, ) : Value() -data class VM24F( +data class _VM24F( val _0 : M24F, ) : Value() -data class VM32F( +data class _VM32F( val _0 : M32F, ) : Value() -data class VM33F( +data class _VM33F( val _0 : M33F, ) : Value() -data class VM34F( +data class _VM34F( val _0 : M34F, ) : Value() -data class VM42F( +data class _VM42F( val _0 : M42F, ) : Value() -data class VM43F( +data class _VM43F( val _0 : M43F, ) : Value() -data class VM44F( +data class _VM44F( val _0 : M44F, ) : Value() sealed class InputType() -object Bool : InputType() -object V2B : InputType() -object V3B : InputType() -object V4B : InputType() -object Word : InputType() -object V2U : InputType() -object V3U : InputType() -object V4U : InputType() -object Int : InputType() -object V2I : InputType() -object V3I : InputType() -object V4I : InputType() -object Float : InputType() -object V2F : InputType() -object V3F : InputType() -object V4F : InputType() -object M22F : InputType() -object M23F : InputType() -object M24F : InputType() -object M32F : InputType() -object M33F : InputType() -object M34F : InputType() -object M42F : InputType() -object M43F : InputType() -object M44F : InputType() -object STexture1D : InputType() -object STexture2D : InputType() -object STextureCube : InputType() -object STexture1DArray : InputType() -object STexture2DArray : InputType() -object STexture2DRect : InputType() -object FTexture1D : InputType() -object FTexture2D : InputType() -object FTexture3D : InputType() -object FTextureCube : InputType() -object FTexture1DArray : InputType() -object FTexture2DArray : InputType() -object FTexture2DMS : InputType() -object FTexture2DMSArray : InputType() -object FTextureBuffer : InputType() -object FTexture2DRect : InputType() -object ITexture1D : InputType() -object ITexture2D : InputType() -object ITexture3D : InputType() -object ITextureCube : InputType() -object ITexture1DArray : InputType() -object ITexture2DArray : InputType() -object ITexture2DMS : InputType() -object ITexture2DMSArray : InputType() -object ITextureBuffer : InputType() -object ITexture2DRect : InputType() -object UTexture1D : InputType() -object UTexture2D : InputType() -object UTexture3D : InputType() -object UTextureCube : InputType() -object UTexture1DArray : InputType() -object UTexture2DArray : InputType() -object UTexture2DMS : InputType() -object UTexture2DMSArray : InputType() -object UTextureBuffer : InputType() -object UTexture2DRect : InputType() +object _Bool : InputType() +object _V2B : InputType() +object _V3B : InputType() +object _V4B : InputType() +object _Word : InputType() +object _V2U : InputType() +object _V3U : InputType() +object _V4U : InputType() +object _Int : InputType() +object _V2I : InputType() +object _V3I : InputType() +object _V4I : InputType() +object _Float : InputType() +object _V2F : InputType() +object _V3F : InputType() +object _V4F : InputType() +object _M22F : InputType() +object _M23F : InputType() +object _M24F : InputType() +object _M32F : InputType() +object _M33F : InputType() +object _M34F : InputType() +object _M42F : InputType() +object _M43F : InputType() +object _M44F : InputType() +object _STexture1D : InputType() +object _STexture2D : InputType() +object _STextureCube : InputType() +object _STexture1DArray : InputType() +object _STexture2DArray : InputType() +object _STexture2DRect : InputType() +object _FTexture1D : InputType() +object _FTexture2D : InputType() +object _FTexture3D : InputType() +object _FTextureCube : InputType() +object _FTexture1DArray : InputType() +object _FTexture2DArray : InputType() +object _FTexture2DMS : InputType() +object _FTexture2DMSArray : InputType() +object _FTextureBuffer : InputType() +object _FTexture2DRect : InputType() +object _ITexture1D : InputType() +object _ITexture2D : InputType() +object _ITexture3D : InputType() +object _ITextureCube : InputType() +object _ITexture1DArray : InputType() +object _ITexture2DArray : InputType() +object _ITexture2DMS : InputType() +object _ITexture2DMSArray : InputType() +object _ITextureBuffer : InputType() +object _ITexture2DRect : InputType() +object _UTexture1D : InputType() +object _UTexture2D : InputType() +object _UTexture3D : InputType() +object _UTextureCube : InputType() +object _UTexture1DArray : InputType() +object _UTexture2DArray : InputType() +object _UTexture2DMS : InputType() +object _UTexture2DMSArray : InputType() +object _UTextureBuffer : InputType() +object _UTexture2DRect : InputType() sealed class PointSpriteCoordOrigin() -object LowerLeft : PointSpriteCoordOrigin() -object UpperLeft : PointSpriteCoordOrigin() +object _LowerLeft : PointSpriteCoordOrigin() +object _UpperLeft : PointSpriteCoordOrigin() sealed class PointSize() -data class PointSize( +data class _PointSize( val _0 : Float, ) : PointSize() -object ProgramPointSize : PointSize() +object _ProgramPointSize : PointSize() sealed class PolygonOffset() -object NoOffset : PolygonOffset() -data class Offset( +object _NoOffset : PolygonOffset() +data class _Offset( val _0 : Float, val _1 : Float, ) : PolygonOffset() sealed class FrontFace() -object CCW : FrontFace() -object CW : FrontFace() +object _CCW : FrontFace() +object _CW : FrontFace() sealed class PolygonMode() -data class PolygonPoint( +data class _PolygonPoint( val _0 : PointSize, ) : PolygonMode() -data class PolygonLine( +data class _PolygonLine( val _0 : Float, ) : PolygonMode() -object PolygonFill : PolygonMode() +object _PolygonFill : PolygonMode() sealed class ProvokingVertex() -object FirstVertex : ProvokingVertex() -object LastVertex : ProvokingVertex() +object _FirstVertex : ProvokingVertex() +object _LastVertex : ProvokingVertex() sealed class CullMode() -object CullNone : CullMode() -data class CullFront( +object _CullNone : CullMode() +data class _CullFront( val _0 : FrontFace, ) : CullMode() -data class CullBack( +data class _CullBack( val _0 : FrontFace, ) : CullMode() sealed class ComparisonFunction() -object Never : ComparisonFunction() -object Less : ComparisonFunction() -object Equal : ComparisonFunction() -object Lequal : ComparisonFunction() -object Greater : ComparisonFunction() -object Notequal : ComparisonFunction() -object Gequal : ComparisonFunction() -object Always : ComparisonFunction() +object _Never : ComparisonFunction() +object _Less : ComparisonFunction() +object _Equal : ComparisonFunction() +object _Lequal : ComparisonFunction() +object _Greater : ComparisonFunction() +object _Notequal : ComparisonFunction() +object _Gequal : ComparisonFunction() +object _Always : ComparisonFunction() typealias DepthFunction = ComparisonFunction sealed class StencilOperation() -object OpZero : StencilOperation() -object OpKeep : StencilOperation() -object OpReplace : StencilOperation() -object OpIncr : StencilOperation() -object OpIncrWrap : StencilOperation() -object OpDecr : StencilOperation() -object OpDecrWrap : StencilOperation() -object OpInvert : StencilOperation() +object _OpZero : StencilOperation() +object _OpKeep : StencilOperation() +object _OpReplace : StencilOperation() +object _OpIncr : StencilOperation() +object _OpIncrWrap : StencilOperation() +object _OpDecr : StencilOperation() +object _OpDecrWrap : StencilOperation() +object _OpInvert : StencilOperation() sealed class BlendEquation() -object FuncAdd : BlendEquation() -object FuncSubtract : BlendEquation() -object FuncReverseSubtract : BlendEquation() -object Min : BlendEquation() -object Max : BlendEquation() +object _FuncAdd : BlendEquation() +object _FuncSubtract : BlendEquation() +object _FuncReverseSubtract : BlendEquation() +object _Min : BlendEquation() +object _Max : BlendEquation() sealed class BlendingFactor() -object Zero : BlendingFactor() -object One : BlendingFactor() -object SrcColor : BlendingFactor() -object OneMinusSrcColor : BlendingFactor() -object DstColor : BlendingFactor() -object OneMinusDstColor : BlendingFactor() -object SrcAlpha : BlendingFactor() -object OneMinusSrcAlpha : BlendingFactor() -object DstAlpha : BlendingFactor() -object OneMinusDstAlpha : BlendingFactor() -object ConstantColor : BlendingFactor() -object OneMinusConstantColor : BlendingFactor() -object ConstantAlpha : BlendingFactor() -object OneMinusConstantAlpha : BlendingFactor() -object SrcAlphaSaturate : BlendingFactor() +object _Zero : BlendingFactor() +object _One : BlendingFactor() +object _SrcColor : BlendingFactor() +object _OneMinusSrcColor : BlendingFactor() +object _DstColor : BlendingFactor() +object _OneMinusDstColor : BlendingFactor() +object _SrcAlpha : BlendingFactor() +object _OneMinusSrcAlpha : BlendingFactor() +object _DstAlpha : BlendingFactor() +object _OneMinusDstAlpha : BlendingFactor() +object _ConstantColor : BlendingFactor() +object _OneMinusConstantColor : BlendingFactor() +object _ConstantAlpha : BlendingFactor() +object _OneMinusConstantAlpha : BlendingFactor() +object _SrcAlphaSaturate : BlendingFactor() sealed class LogicOperation() -object Clear : LogicOperation() -object And : LogicOperation() -object AndReverse : LogicOperation() -object Copy : LogicOperation() -object AndInverted : LogicOperation() -object Noop : LogicOperation() -object Xor : LogicOperation() -object Or : LogicOperation() -object Nor : LogicOperation() -object Equiv : LogicOperation() -object Invert : LogicOperation() -object OrReverse : LogicOperation() -object CopyInverted : LogicOperation() -object OrInverted : LogicOperation() -object Nand : LogicOperation() -object Set : LogicOperation() +object _Clear : LogicOperation() +object _And : LogicOperation() +object _AndReverse : LogicOperation() +object _Copy : LogicOperation() +object _AndInverted : LogicOperation() +object _Noop : LogicOperation() +object _Xor : LogicOperation() +object _Or : LogicOperation() +object _Nor : LogicOperation() +object _Equiv : LogicOperation() +object _Invert : LogicOperation() +object _OrReverse : LogicOperation() +object _CopyInverted : LogicOperation() +object _OrInverted : LogicOperation() +object _Nand : LogicOperation() +object _Set : LogicOperation() data class StencilOps( val frontStencilOp : StencilOperation, @@ -304,29 +304,29 @@ data class StencilTests( ) sealed class FetchPrimitive() -object Points : FetchPrimitive() -object Lines : FetchPrimitive() -object Triangles : FetchPrimitive() -object LinesAdjacency : FetchPrimitive() -object TrianglesAdjacency : FetchPrimitive() +object _Points : FetchPrimitive() +object _Lines : FetchPrimitive() +object _Triangles : FetchPrimitive() +object _LinesAdjacency : FetchPrimitive() +object _TrianglesAdjacency : FetchPrimitive() sealed class OutputPrimitive() -object TrianglesOutput : OutputPrimitive() -object LinesOutput : OutputPrimitive() -object PointsOutput : OutputPrimitive() +object _TrianglesOutput : OutputPrimitive() +object _LinesOutput : OutputPrimitive() +object _PointsOutput : OutputPrimitive() sealed class ColorArity() -object Red : ColorArity() -object RG : ColorArity() -object RGB : ColorArity() -object RGBA : ColorArity() +object _Red : ColorArity() +object _RG : ColorArity() +object _RGB : ColorArity() +object _RGBA : ColorArity() sealed class Blending() -object NoBlending : Blending() -data class BlendLogicOp( +object _NoBlending : Blending() +data class _BlendLogicOp( val _0 : LogicOperation, ) : Blending() -data class Blend( +data class _Blend( val colorEqSrc : BlendEquation, val alphaEqSrc : BlendEquation, val colorFSrc : BlendingFactor, @@ -337,16 +337,16 @@ data class Blend( ) : Blending() sealed class RasterContext() -data class PointCtx( +data class _PointCtx( val _0 : PointSize, val _1 : Float, val _2 : PointSpriteCoordOrigin, ) : RasterContext() -data class LineCtx( +data class _LineCtx( val _0 : Float, val _1 : ProvokingVertex, ) : RasterContext() -data class TriangleCtx( +data class _TriangleCtx( val _0 : CullMode, val _1 : PolygonMode, val _2 : PolygonOffset, @@ -354,16 +354,16 @@ data class TriangleCtx( ) : RasterContext() sealed class FragmentOperation() -data class DepthOp( +data class _DepthOp( val _0 : DepthFunction, val _1 : Bool, ) : FragmentOperation() -data class StencilOp( +data class _StencilOp( val _0 : StencilTests, val _1 : StencilOps, val _2 : StencilOps, ) : FragmentOperation() -data class ColorOp( +data class _ColorOp( val _0 : Blending, val _1 : Value, ) : FragmentOperation() @@ -374,82 +374,82 @@ data class AccumulationContext( ) sealed class TextureDataType() -data class FloatT( +data class _FloatT( val _0 : ColorArity, ) : TextureDataType() -data class IntT( +data class _IntT( val _0 : ColorArity, ) : TextureDataType() -data class WordT( +data class _WordT( val _0 : ColorArity, ) : TextureDataType() -object ShadowT : TextureDataType() +object _ShadowT : TextureDataType() sealed class TextureType() -data class Texture1D( +data class _Texture1D( val _0 : TextureDataType, val _1 : Int, ) : TextureType() -data class Texture2D( +data class _Texture2D( val _0 : TextureDataType, val _1 : Int, ) : TextureType() -data class Texture3D( +data class _Texture3D( val _0 : TextureDataType, ) : TextureType() -data class TextureCube( +data class _TextureCube( val _0 : TextureDataType, ) : TextureType() -data class TextureRect( +data class _TextureRect( val _0 : TextureDataType, ) : TextureType() -data class Texture2DMS( +data class _Texture2DMS( val _0 : TextureDataType, val _1 : Int, val _2 : Int, val _3 : Bool, ) : TextureType() -data class TextureBuffer( +data class _TextureBuffer( val _0 : TextureDataType, ) : TextureType() sealed class MipMap() -data class Mip( +data class _Mip( val _0 : Int, val _1 : Int, ) : MipMap() -object NoMip : MipMap() -data class AutoMip( +object _NoMip : MipMap() +data class _AutoMip( val _0 : Int, val _1 : Int, ) : MipMap() sealed class Filter() -object Nearest : Filter() -object Linear : Filter() -object NearestMipmapNearest : Filter() -object NearestMipmapLinear : Filter() -object LinearMipmapNearest : Filter() -object LinearMipmapLinear : Filter() +object _Nearest : Filter() +object _Linear : Filter() +object _NearestMipmapNearest : Filter() +object _NearestMipmapLinear : Filter() +object _LinearMipmapNearest : Filter() +object _LinearMipmapLinear : Filter() sealed class EdgeMode() -object Repeat : EdgeMode() -object MirroredRepeat : EdgeMode() -object ClampToEdge : EdgeMode() -object ClampToBorder : EdgeMode() +object _Repeat : EdgeMode() +object _MirroredRepeat : EdgeMode() +object _ClampToEdge : EdgeMode() +object _ClampToBorder : EdgeMode() sealed class ImageSemantic() -object Depth : ImageSemantic() -object Stencil : ImageSemantic() -object Color : ImageSemantic() +object _Depth : ImageSemantic() +object _Stencil : ImageSemantic() +object _Color : ImageSemantic() sealed class ImageRef() -data class TextureImage( +data class _TextureImage( val _0 : TextureName, val _1 : Int, val _2 : Int?, ) : ImageRef() -data class Framebuffer( +data class _Framebuffer( val _0 : ImageSemantic, ) : ImageRef() @@ -459,47 +459,47 @@ data class ClearImage( ) sealed class Command() -data class SetRasterContext( +data class _SetRasterContext( val _0 : RasterContext, ) : Command() -data class SetAccumulationContext( +data class _SetAccumulationContext( val _0 : AccumulationContext, ) : Command() -data class SetRenderTarget( +data class _SetRenderTarget( val _0 : RenderTargetName, ) : Command() -data class SetProgram( +data class _SetProgram( val _0 : ProgramName, ) : Command() -data class SetSamplerUniform( +data class _SetSamplerUniform( val _0 : UniformName, val _1 : TextureUnit, ) : Command() -data class SetTexture( +data class _SetTexture( val _0 : TextureUnit, val _1 : TextureName, ) : Command() -data class SetSampler( +data class _SetSampler( val _0 : TextureUnit, val _1 : SamplerName?, ) : Command() -data class RenderSlot( +data class _RenderSlot( val _0 : SlotName, ) : Command() -data class RenderStream( +data class _RenderStream( val _0 : StreamName, ) : Command() -data class ClearRenderTarget( +data class _ClearRenderTarget( val _0 : Array, ) : Command() -data class GenerateMipMap( +data class _GenerateMipMap( val _0 : TextureUnit, ) : Command() -data class SaveImage( +data class _SaveImage( val _0 : FrameBufferComponent, val _1 : ImageRef, ) : Command() -data class LoadImage( +data class _LoadImage( val _0 : ImageRef, val _1 : FrameBufferComponent, ) : Command() @@ -566,8 +566,8 @@ data class RenderTarget( ) sealed class Backend() -object WebGL1 : Backend() -object OpenGL33 : Backend() +object _WebGL1 : Backend() +object _OpenGL33 : Backend() data class Pipeline( val info : String, diff --git a/ddl/out/kotlin/LambdaCube.Mesh.kt b/ddl/out/kotlin/LambdaCube.Mesh.kt index 70fcb17..bcc676a 100644 --- a/ddl/out/kotlin/LambdaCube.Mesh.kt +++ b/ddl/out/kotlin/LambdaCube.Mesh.kt @@ -1,5 +1,5 @@ // generated file, do not modify! -// 2020-05-21T18:29:16.473984Z +// 2020-05-21T20:25:27.766405Z package LambdaCube.Mesh @@ -7,42 +7,42 @@ import RT.* sealed class MeshAttribute() -data class A_Float( +data class _A_Float( val _0 : Array, ) : MeshAttribute() -data class A_V2F( +data class _A_V2F( val _0 : Array, ) : MeshAttribute() -data class A_V3F( +data class _A_V3F( val _0 : Array, ) : MeshAttribute() -data class A_V4F( +data class _A_V4F( val _0 : Array, ) : MeshAttribute() -data class A_M22F( +data class _A_M22F( val _0 : Array, ) : MeshAttribute() -data class A_M33F( +data class _A_M33F( val _0 : Array, ) : MeshAttribute() -data class A_M44F( +data class _A_M44F( val _0 : Array, ) : MeshAttribute() -data class A_Int( +data class _A_Int( val _0 : Array, ) : MeshAttribute() -data class A_Word( +data class _A_Word( val _0 : Array, ) : MeshAttribute() sealed class MeshPrimitive() -object P_Points : MeshPrimitive() -object P_TriangleStrip : MeshPrimitive() -object P_Triangles : MeshPrimitive() -data class P_TriangleStripI( +object _P_Points : MeshPrimitive() +object _P_TriangleStrip : MeshPrimitive() +object _P_Triangles : MeshPrimitive() +data class _P_TriangleStripI( val _0 : Array, ) : MeshPrimitive() -data class P_TrianglesI( +data class _P_TrianglesI( val _0 : Array, ) : MeshPrimitive() diff --git a/ddl/out/kotlin/LambdaCube.PipelineSchema.kt b/ddl/out/kotlin/LambdaCube.PipelineSchema.kt index 11961d5..3a589ad 100644 --- a/ddl/out/kotlin/LambdaCube.PipelineSchema.kt +++ b/ddl/out/kotlin/LambdaCube.PipelineSchema.kt @@ -1,5 +1,5 @@ // generated file, do not modify! -// 2020-05-21T18:29:16.46264Z +// 2020-05-21T20:25:27.753757Z package LambdaCube.PipelineSchema @@ -8,27 +8,27 @@ import RT.* import LambdaCube.IR.* sealed class StreamType() -object Attribute_Word : StreamType() -object Attribute_V2U : StreamType() -object Attribute_V3U : StreamType() -object Attribute_V4U : StreamType() -object Attribute_Int : StreamType() -object Attribute_V2I : StreamType() -object Attribute_V3I : StreamType() -object Attribute_V4I : StreamType() -object Attribute_Float : StreamType() -object Attribute_V2F : StreamType() -object Attribute_V3F : StreamType() -object Attribute_V4F : StreamType() -object Attribute_M22F : StreamType() -object Attribute_M23F : StreamType() -object Attribute_M24F : StreamType() -object Attribute_M32F : StreamType() -object Attribute_M33F : StreamType() -object Attribute_M34F : StreamType() -object Attribute_M42F : StreamType() -object Attribute_M43F : StreamType() -object Attribute_M44F : StreamType() +object _Attribute_Word : StreamType() +object _Attribute_V2U : StreamType() +object _Attribute_V3U : StreamType() +object _Attribute_V4U : StreamType() +object _Attribute_Int : StreamType() +object _Attribute_V2I : StreamType() +object _Attribute_V3I : StreamType() +object _Attribute_V4I : StreamType() +object _Attribute_Float : StreamType() +object _Attribute_V2F : StreamType() +object _Attribute_V3F : StreamType() +object _Attribute_V4F : StreamType() +object _Attribute_M22F : StreamType() +object _Attribute_M23F : StreamType() +object _Attribute_M24F : StreamType() +object _Attribute_M32F : StreamType() +object _Attribute_M33F : StreamType() +object _Attribute_M34F : StreamType() +object _Attribute_M42F : StreamType() +object _Attribute_M43F : StreamType() +object _Attribute_M44F : StreamType() data class ObjectArraySchema( val primitive : FetchPrimitive, diff --git a/ddl/out/kotlin/LambdaCube.TypeInfo.kt b/ddl/out/kotlin/LambdaCube.TypeInfo.kt index ddb7387..4a09d36 100644 --- a/ddl/out/kotlin/LambdaCube.TypeInfo.kt +++ b/ddl/out/kotlin/LambdaCube.TypeInfo.kt @@ -1,5 +1,5 @@ // generated file, do not modify! -// 2020-05-21T18:52:11.102922Z +// 2020-05-21T20:25:27.786125Z package LambdaCube.TypeInfo @@ -30,13 +30,13 @@ data class ErrorInfo( ) sealed class CompileResult() -data class CompileError( +data class _CompileError( val _0 : String, val _1 : Array, val _2 : Array, val _3 : Array, ) : CompileResult() -data class Compiled( +data class _Compiled( val _0 : String, val _1 : String, val _2 : Pipeline, diff --git a/ddl/out/kotlin/TestData.kt b/ddl/out/kotlin/TestData.kt index 66cc01c..5e904ee 100644 --- a/ddl/out/kotlin/TestData.kt +++ b/ddl/out/kotlin/TestData.kt @@ -1,5 +1,5 @@ // generated file, do not modify! -// 2020-05-21T18:52:11.118474Z +// 2020-05-21T20:25:27.802172Z package TestData @@ -47,10 +47,10 @@ data class FrameResult( ) sealed class RenderJobResult() -data class RenderJobResult( +data class _RenderJobResult( val _0 : FrameResult, ) : RenderJobResult() -data class RenderJobError( +data class _RenderJobError( val _0 : String, ) : RenderJobResult() diff --git a/ddl/templates/data.kt.ede b/ddl/templates/data.kt.ede index 729d626..8ec0822 100644 --- a/ddl/templates/data.kt.ede +++ b/ddl/templates/data.kt.ede @@ -17,9 +17,9 @@ sealed class {{ t.value.dataName }}() {% endif %} {% for c in t.value.constructors %} {% if c.value.fields | empty %} -object {{ c.value.name }}{% if t.value.constructors | nonSingular %} : {{ t.value.dataName }}(){% endif %} +object {% if t.value.constructors | nonSingular %}_{% endif %}{{ c.value.name }}{% if t.value.constructors | nonSingular %} : {{ t.value.dataName }}(){% endif %} {% else %} -data class {{ c.value.name }}({% for f in c.value.fields %}{% if c.value.fields | hasFieldNames %} +data class {% if t.value.constructors | nonSingular %}_{% endif %}{{ c.value.name }}({% for f in c.value.fields %}{% if c.value.fields | hasFieldNames %} val {{ f.value.fieldName }} : {{ f.value.fieldType | ktType }},{% else %} val _{{ f.index0 }} : {{ f.value.fieldType | ktType }},{% endif %}{% endfor %} ){% if t.value.constructors | nonSingular %} : {{ t.value.dataName }}(){% endif %} diff --git a/ddl/templates/json.kt.ede b/ddl/templates/json.kt.ede index bfa25df..a47b8f9 100644 --- a/ddl/templates/json.kt.ede +++ b/ddl/templates/json.kt.ede @@ -105,9 +105,9 @@ object JSON { {% for c in t.value.constructors %} is "{{ c.value.name }}" -> { return {% if c.value.fields | empty %} - {{c.value.name}} + {% if t.value.constructors | nonSingular %}_{% endif %}{{c.value.name}} {% else %} - {{c.value.name}}({% for f in c.value.fields %}{% if c.value.fields | hasFieldNames %} + {% if t.value.constructors | nonSingular %}_{% endif %}{{c.value.name}}({% for f in c.value.fields %}{% if c.value.fields | hasFieldNames %} {{ f.value.fieldName }} = fromJSON(Type.{{ f.value.fieldType | typeEnum }}, obj.get("{{ f.value.fieldName }}")) as {{ f.value.fieldType | ktType }}{% else %} _{{ f.index0 }} = fromJSON(Type.{{ f.value.fieldType | typeEnum }}, obj.get("arg{{ f.index0 }}")) as {{ f.value.fieldType | ktType }}{% endif %},{% endfor %} ) From a9ec5b690134b0a50abe4991cd288a5c4f09f35e Mon Sep 17 00:00:00 2001 From: Anthony Cerruti Date: Thu, 21 May 2020 16:40:41 -0700 Subject: [PATCH 7/7] Fix usage of 'is' and prepend Enum name to Enum matches --- ddl/out/kotlin/JSON.kt | 130 +++++++++++++++++++++++++++++--------- ddl/templates/json.kt.ede | 49 +++++++++----- 2 files changed, 135 insertions(+), 44 deletions(-) diff --git a/ddl/out/kotlin/JSON.kt b/ddl/out/kotlin/JSON.kt index ecfb4a9..8440a8b 100644 --- a/ddl/out/kotlin/JSON.kt +++ b/ddl/out/kotlin/JSON.kt @@ -1,5 +1,5 @@ // generated file, do not modify! -// 2020-05-21T20:27:28.444912Z +// 2020-05-21T23:35:27.114328Z package TestData @@ -43,52 +43,52 @@ object JSON { @Throws(JSONException::class, Exception::class) fun fromJSON(Type type, Object rawObj): Object { when (type) { - is Int -> return (rawObj as Number).intValue() - is Float -> return (rawObj as Number).floatValue() - is String -> return rawObj as String - is Array_Int -> { + Type.Int -> return (rawObj as Number).intValue() + Type.Float -> return (rawObj as Number).floatValue() + Type.String -> return rawObj as String + Type.Array_Int -> { val obj = rawObj as JSONArray return Array(obj.length()) { ind: Int -> fromJSON(Type.Int, obj.get(ind)) as Int } } - is Array_Float -> { + Type.Array_Float -> { val obj = rawObj as JSONArray return Array(obj.length()) { ind: Int -> fromJSON(Type.Float, obj.get(ind)) as Float } } - is Array_String -> { + Type.Array_String -> { val obj = rawObj as JSONArray return Array(obj.length()) { ind: Int -> fromJSON(Type.String, obj.get(ind)) as String } } - is Array_Frame -> { + Type.Array_Frame -> { val obj = rawObj as JSONArray return Array(obj.length()) { ind: Int -> fromJSON(Type.Frame, obj.get(ind)) as Frame } } - is Array_Mesh -> { + Type.Array_Mesh -> { val obj = rawObj as JSONArray return Array(obj.length()) { ind: Int -> fromJSON(Type.Mesh, obj.get(ind)) as Mesh } } - is Array_PipelineInfo -> { + Type.Array_PipelineInfo -> { val obj = rawObj as JSONArray return Array(obj.length()) { ind: Int -> fromJSON(Type.PipelineInfo, obj.get(ind)) as PipelineInfo } } - is Array_Scene -> { + Type.Array_Scene -> { val obj = rawObj as JSONArray return Array(obj.length()) { ind: Int -> fromJSON(Type.Scene, obj.get(ind)) as Scene } } - is Map_String_Int -> { + Type.Map_String_Int -> { val obj = rawObj as JSONObject Map map = Map() val keyIt = obj.keys() @@ -98,7 +98,7 @@ object JSON { } return map } - is Map_String_Array_Int -> { + Type.Map_String_Array_Int -> { val obj = rawObj as JSONObject Map map = Map() val keyIt = obj.keys() @@ -108,7 +108,7 @@ object JSON { } return map } - is Map_String_Value -> { + Type.Map_String_Value -> { val obj = rawObj as JSONObject Map map = Map() val keyIt = obj.keys() @@ -119,11 +119,11 @@ object JSON { return map } - is ClientInfo -> { + Type.ClientInfo -> { val obj = rawObj as JSONObject val tag = obj.getString("tag") when (tag) { - is "ClientInfo" -> { + "ClientInfo" -> { return ClientInfo( clientName = fromJSON(Type.String, obj.get("clientName")) as String, clientBackend = fromJSON(Type.Backend, obj.get("clientBackend")) as Backend, @@ -131,11 +131,11 @@ object JSON { } } } - is Frame -> { + Type.Frame -> { val obj = rawObj as JSONObject val tag = obj.getString("tag") when (tag) { - is "Frame" -> { + "Frame" -> { return Frame( renderCount = fromJSON(Type.Int, obj.get("renderCount")) as Int, frameUniforms = fromJSON(Type.Map_String_Value, obj.get("frameUniforms")) as Map, @@ -144,11 +144,11 @@ object JSON { } } } - is Scene -> { + Type.Scene -> { val obj = rawObj as JSONObject val tag = obj.getString("tag") when (tag) { - is "Scene" -> { + "Scene" -> { return Scene( objectArrays = fromJSON(Type.Map_String_Array_Int, obj.get("objectArrays")) as Map, renderTargetWidth = fromJSON(Type.Int, obj.get("renderTargetWidth")) as Int, @@ -158,11 +158,11 @@ object JSON { } } } - is PipelineInfo -> { + Type.PipelineInfo -> { val obj = rawObj as JSONObject val tag = obj.getString("tag") when (tag) { - is "PipelineInfo" -> { + "PipelineInfo" -> { return PipelineInfo( pipelineName = fromJSON(Type.String, obj.get("pipelineName")) as String, pipeline = fromJSON(Type.Pipeline, obj.get("pipeline")) as Pipeline, @@ -170,11 +170,11 @@ object JSON { } } } - is RenderJob -> { + Type.RenderJob -> { val obj = rawObj as JSONObject val tag = obj.getString("tag") when (tag) { - is "RenderJob" -> { + "RenderJob" -> { return RenderJob( meshes = fromJSON(Type.Array_Mesh, obj.get("meshes")) as Array, textures = fromJSON(Type.Array_String, obj.get("textures")) as Array, @@ -185,11 +185,11 @@ object JSON { } } } - is FrameResult -> { + Type.FrameResult -> { val obj = rawObj as JSONObject val tag = obj.getString("tag") when (tag) { - is "FrameResult" -> { + "FrameResult" -> { return FrameResult( frRenderTimes = fromJSON(Type.Array_Float, obj.get("frRenderTimes")) as Array, frImageWidth = fromJSON(Type.Int, obj.get("frImageWidth")) as Int, @@ -198,16 +198,16 @@ object JSON { } } } - is RenderJobResult -> { + Type.RenderJobResult -> { val obj = rawObj as JSONObject val tag = obj.getString("tag") when (tag) { - is "RenderJobResult" -> { + "RenderJobResult" -> { return _RenderJobResult( _0 = fromJSON(Type.FrameResult, obj.get("arg0")) as FrameResult, ) } - is "RenderJobError" -> { + "RenderJobError" -> { return _RenderJobError( _0 = fromJSON(Type.String, obj.get("arg0")) as String, ) @@ -217,4 +217,76 @@ object JSON { } } + @Throws(JSONException::class, Exception::class) + fn toJSON(Type type, Object rawObj): Object { + when (type) { + Type.ClientInfo -> { + val v = rawObj as ClientInfo + val obj = JSONObject() + when (v) { + is ClientInfo -> { + obj.put("tag", "ClientInfo") + } + } + } + Type.Frame -> { + val v = rawObj as Frame + val obj = JSONObject() + when (v) { + is Frame -> { + obj.put("tag", "Frame") + } + } + } + Type.Scene -> { + val v = rawObj as Scene + val obj = JSONObject() + when (v) { + is Scene -> { + obj.put("tag", "Scene") + } + } + } + Type.PipelineInfo -> { + val v = rawObj as PipelineInfo + val obj = JSONObject() + when (v) { + is PipelineInfo -> { + obj.put("tag", "PipelineInfo") + } + } + } + Type.RenderJob -> { + val v = rawObj as RenderJob + val obj = JSONObject() + when (v) { + is RenderJob -> { + obj.put("tag", "RenderJob") + } + } + } + Type.FrameResult -> { + val v = rawObj as FrameResult + val obj = JSONObject() + when (v) { + is FrameResult -> { + obj.put("tag", "FrameResult") + } + } + } + Type.RenderJobResult -> { + val v = rawObj as RenderJobResult + val obj = JSONObject() + when (v) { + is RenderJobResult -> { + obj.put("tag", "RenderJobResult") + } + is RenderJobError -> { + obj.put("tag", "RenderJobError") + } + } + } + } + } + } diff --git a/ddl/templates/json.kt.ede b/ddl/templates/json.kt.ede index a47b8f9..3e26bd2 100644 --- a/ddl/templates/json.kt.ede +++ b/ddl/templates/json.kt.ede @@ -23,7 +23,7 @@ object JSON { {% case t.value.tag %} {% when "Data" %} {% when "V2" %} - is {{ t.value | typeEnum }} -> { + Type.{{ t.value | typeEnum }} -> { val obj = rawObj as JSONObject return {{ t.value | ktType }}( fromJSON(Type.{{ t.value.type_ | typeEnum }}, obj.get("x")) as {{ t.value.type_ | ktType }}, @@ -31,7 +31,7 @@ object JSON { ) } {% when "V3" %} - is {{ t.value | typeEnum }} -> { + Type.{{ t.value | typeEnum }} -> { val obj = rawObj as JSONObject return {{ t.value | ktType }}( fromJSON(Type.{{ t.value.type_ | typeEnum }}, obj.get("x")) as {{ t.value.type_ | ktType }}, @@ -40,7 +40,7 @@ object JSON { ) } {% when "V4" %} - is {{ t.value | typeEnum }} -> { + Type.{{ t.value | typeEnum }} -> { val obj = rawObj as JSONObject return {{ t.value | ktType }}( fromJSON(Type.{{ t.value.type_ | typeEnum }}, obj.get("x")) as {{ t.value.type_ | ktType }}, @@ -50,7 +50,7 @@ object JSON { ) } {% when "Map" %} - is {{ t.value | typeEnum }} -> { + Type.{{ t.value | typeEnum }} -> { val obj = rawObj as JSONObject {{ t.value | ktType }} map = {{ t.value | ktType }}() val keyIt = obj.keys() @@ -61,21 +61,21 @@ object JSON { return map } {% when "Array" %} - is {{ t.value | typeEnum }} -> { + Type.{{ t.value | typeEnum }} -> { val obj = rawObj as JSONArray return {{ t.value | ktType }}(obj.length()) { ind: Int -> fromJSON(Type.{{ t.value.type_ | typeEnum }}, obj.get(ind)) as {{ t.value.type_ | ktType }} } } {% when "List" %} - is {{ t.value | typeEnum }} -> { + Type.{{ t.value | typeEnum }} -> { val obj = rawObj as JSONArray return {{ t.value | ktType }}(obj.length()) { ind: Int -> fromJSON(Type.{{ t.value.type_ | typeEnum }}, obj.get(ind)) as {{ t.value.type_ | ktType }} } } {% when "Maybe" %} - is {{ t.value | typeEnum }} -> { + Type.{{ t.value | typeEnum }} -> { return if(rawObj == null || rawObj = JSONObject.NULL) { null } else { @@ -83,27 +83,27 @@ object JSON { } } {% when "Int" %} - is {{ t.value | typeEnum }} -> return (rawObj as Number).intValue() + Type.{{ t.value | typeEnum }} -> return (rawObj as Number).intValue() {% when "Int32" %} - is {{ t.value | typeEnum }} -> return (rawObj as Number).intValue() + Type.{{ t.value | typeEnum }} -> return (rawObj as Number).intValue() {% when "Word" %} - is {{ t.value | typeEnum }} -> return (rawObj as Number).intValue() + Type.{{ t.value | typeEnum }} -> return (rawObj as Number).intValue() {% when "Word32" %} - is {{ t.value | typeEnum }} -> return (rawObj as Number).intValue() + Type.{{ t.value | typeEnum }} -> return (rawObj as Number).intValue() {% when "Float" %} - is {{ t.value | typeEnum }} -> return (rawObj as Number).floatValue() + Type.{{ t.value | typeEnum }} -> return (rawObj as Number).floatValue() {% else %} - is {{ t.value | typeEnum }} -> return rawObj as {{ t.value | ktType }} + Type.{{ t.value | typeEnum }} -> return rawObj as {{ t.value | ktType }} {% endcase %} {% endfor %} {% for t in definitions %} - is {{ t.value.dataName }} -> { + Type.{{ t.value.dataName }} -> { val obj = rawObj as JSONObject val tag = obj.getString("tag") when (tag) { {% for c in t.value.constructors %} - is "{{ c.value.name }}" -> { + "{{ c.value.name }}" -> { return {% if c.value.fields | empty %} {% if t.value.constructors | nonSingular %}_{% endif %}{{c.value.name}} {% else %} @@ -120,4 +120,23 @@ object JSON { } } + @Throws(JSONException::class, Exception::class) + fn toJSON(Type type, Object rawObj): Object { + when (type) { + {% for t in definitions %} + Type.{{ t.value.dataName }} -> { + val v = rawObj as {{ t.value.dataName }} + val obj = JSONObject() + when (v) { + {% for c in t.value.constructors %} + is {{ c.value.name }} -> { + obj.put("tag", "{{ c.value.name }}") + } + {% endfor %} + } + } + {% endfor %} + } + } + }