From 56d8509f8ab0bd67e4e0a1ec5a8c8ae3e412578a Mon Sep 17 00:00:00 2001 From: shmyga Date: Wed, 5 Aug 2015 15:40:36 +0300 Subject: [PATCH] change type field to @type --- samples/01-view/src/form.json | 28 +++++++++++++------------- src/main/haxework/gui/build/Builder.hx | 18 ++++++++--------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/samples/01-view/src/form.json b/samples/01-view/src/form.json index f9e39bf..4c48620 100755 --- a/samples/01-view/src/form.json +++ b/samples/01-view/src/form.json @@ -1,50 +1,50 @@ { - "type":"haxework.gui.VGroupView", + "@type":"haxework.gui.VGroupView", "paddings":20, "layoutMargin":10, - "skin":{"type":"haxework.gui.skin.ColorSkin", "color":"0xff0000"}, + "skin":{"@type":"haxework.gui.skin.ColorSkin", "color":"0xff0000"}, "views":[ { - "type":"haxework.gui.SpriteView", + "@type":"haxework.gui.SpriteView", "pWidth":100, "pHeight":100, "leftMargin":5, "rightMargin":10, - "skin":{"type":"haxework.gui.skin.ColorSkin", "color":"0x00ff00"} + "skin":{"@type":"haxework.gui.skin.ColorSkin", "color":"0x00ff00"} }, { - "type":"haxework.gui.SpriteView", + "@type":"haxework.gui.SpriteView", "vAlign":"BOTTOM", "width":50, "height":50, "leftMargin":5, "rightMargin":10, - "skin":{"type":"haxework.gui.skin.ColorSkin", "color":"0x0000ff"} + "skin":{"@type":"haxework.gui.skin.ColorSkin", "color":"0x0000ff"} }, { "id":"panel", - "type":"haxework.gui.HGroupView", + "@type":"haxework.gui.HGroupView", "layoutHAlign":"RIGHT", "pWidth":100, "height":30, "paddings":3, "layoutMargin":3, - "skin":{"type":"haxework.gui.skin.ColorSkin", "color":"0xffff00"}, + "skin":{"@type":"haxework.gui.skin.ColorSkin", "color":"0xffff00"}, "views":[ { "id":"button1", - "type":"haxework.gui.ButtonView", + "@type":"haxework.gui.ButtonView", "width":100, "pHeight":100, - "skin":{"type":"haxework.gui.skin.ButtonColorSkin", "color":"0xcc0000"}, + "skin":{"@type":"haxework.gui.skin.ButtonColorSkin", "color":"0xcc0000"}, "text":"Text1", "onPress":"@link:listener" }, { "id":"button2", - "type":"haxework.gui.ButtonView", + "@type":"haxework.gui.ButtonView", "contentSize":true, - "skin":{"type":"haxework.gui.skin.ButtonColorSkin", "color":"0x00cc00"}, + "skin":{"@type":"haxework.gui.skin.ButtonColorSkin", "color":"0x00cc00"}, "text":"Text2", "fontFamily":"Georgia", "fontColor":"0xffffff", @@ -52,9 +52,9 @@ }, { "id":"button3", - "type":"haxework.gui.ButtonView", + "@type":"haxework.gui.ButtonView", "contentSize":true, - "skin":{"type":"haxework.gui.skin.ButtonColorSkin", "color":"0x00cccc"}, + "skin":{"@type":"haxework.gui.skin.ButtonColorSkin", "color":"0x00cccc"}, "text":"Text 3333333333 ddd", "fontFamily":"Tahoma", "fontColor":"0xff0000", diff --git a/src/main/haxework/gui/build/Builder.hx b/src/main/haxework/gui/build/Builder.hx index f6d6fc6..afda4e4 100755 --- a/src/main/haxework/gui/build/Builder.hx +++ b/src/main/haxework/gui/build/Builder.hx @@ -90,14 +90,14 @@ class Builder { } else if (Std.is(value, Float) || (Std.is(value, Bool))) { value; } else if (value != null) { - if (Reflect.hasField(value, "type")) { + if (Reflect.hasField(value, "@type")) { var n = "a" + i++; - var type = Reflect.field(value, "type"); + var type = Reflect.field(value, "@type"); exprs.push(Context.parse("var " + n + " = new " + type + "()", getPosition(position))); createElement(value, n); n; } else { - Context.error("Need type field", getPosition(position)); + Context.error("Need @type field", getPosition(position)); null; } } else { @@ -106,8 +106,8 @@ class Builder { } private function createElement(template:Dynamic, name:String):String { - if (Reflect.hasField(template, "style")) { - var s = Reflect.field(style, Reflect.field(template, "style")); + if (Reflect.hasField(template, "@style")) { + var s = Reflect.field(style, Reflect.field(template, "@style")); for (key in Reflect.fields(s)) { if (key.charAt(0) != "$" && !Reflect.hasField(template, key)) { Reflect.setField(template, key, Reflect.field(s, key)); @@ -118,9 +118,9 @@ class Builder { if (Reflect.hasField(template, "id")) { var id = Reflect.field(template, "id"); - var type = Reflect.field(template, "type"); + var type = Reflect.field(template, "@type"); var expr = Context.parse("var a:" + type, getPosition()); - var type = switch (expr.expr) { + var complexType = switch (expr.expr) { case EVars(vars): vars[0].type; case _: null; } @@ -128,13 +128,13 @@ class Builder { name: id, access: [APublic], pos: getPosition(), - kind: FProp("default", "null", type) + kind: FProp("default", "null", complexType) }); exprs.push(Context.parse("this." + id + " = " + name, getPosition())); } for (key in Reflect.fields(template)) { - if (key.charAt(0) == "$" || ["type", "style"].indexOf(key) > -1) continue; + if (key.charAt(0) == "$" || key.charAt(0) == "@") continue; var position = Reflect.field(template, "$" + key); var value = getValue(name, key, Reflect.field(template, key), position); if (value != null) {