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

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