Minor refactoring
This commit is contained in:
parent
9720731afb
commit
9ade50e55f
@ -122,7 +122,7 @@ class ConVarDecorators {
|
|||||||
// Handle instance fields
|
// Handle instance fields
|
||||||
updateFieldInitialValue(field, macro null);
|
updateFieldInitialValue(field, macro null);
|
||||||
|
|
||||||
var instanceInitExpr = macro {
|
var instanceInitializerExpression = macro {
|
||||||
if (Reflect.field(this, $v{fieldName}) == null) {
|
if (Reflect.field(this, $v{fieldName}) == null) {
|
||||||
Reflect.setField(this, $v{fieldName}, engine.ConVar.registerCVar(
|
Reflect.setField(this, $v{fieldName}, engine.ConVar.registerCVar(
|
||||||
${meta.name},
|
${meta.name},
|
||||||
@ -139,18 +139,20 @@ class ConVarDecorators {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ensureConstructorWithInit(extraFields, instanceInitExpr, pos);
|
ensureConstructorWithInit(extraFields, instanceInitializerExpression, pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Map to check field kinds
|
||||||
|
private static final fieldKindMap:Map<String, haxe.macro.FieldType->Bool> = [
|
||||||
|
"FFun" => function(ft) return switch(ft) { case FFun(_): true; case _: false; },
|
||||||
|
"FVar" => function(ft) return switch(ft) { case FVar(_, _): true; case _: false; },
|
||||||
|
"FProp" => function(ft) return switch(ft) { case FProp(_, _, _, _): true; case _: false; }
|
||||||
|
];
|
||||||
|
|
||||||
// Utility functions
|
// Utility functions
|
||||||
private static function isFieldKind(field:Field, kind:String):Bool {
|
private static function isFieldKind(field:Field, kind:String):Bool {
|
||||||
return switch (field.kind) {
|
return fieldKindMap.exists(kind) ? fieldKindMap.get(kind)(field.kind) : false;
|
||||||
case FFun(_) if (kind == "FFun"): true;
|
|
||||||
case FVar(_, _) if (kind == "FVar"): true;
|
|
||||||
case FProp(_, _, _, _) if (kind == "FProp"): true;
|
|
||||||
case _: false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function getFunctionFromField(field:Field):Function {
|
private static function getFunctionFromField(field:Field):Function {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user