change type field to @type

This commit is contained in:
2015-08-05 15:40:36 +03:00
parent 2669e56e06
commit 56d8509f8a
2 changed files with 23 additions and 23 deletions

View File

@@ -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",

View File

@@ -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) {