Improve configData.merge, 'create' fix

This commit is contained in:
Joshua Granick
2014-10-20 10:48:39 -07:00
parent 8b56b03641
commit 5ee3082a39
3 changed files with 79 additions and 42 deletions

View File

@@ -20,44 +20,6 @@ import haxe.ds.StringMap;
}
public static function copyFieldsPreferObjectOverValue<T> (source:T, destination:T):T {
for (field in Reflect.fields (source)) {
var do_copy = true;
var exists = Reflect.hasField( destination, field );
if( exists ) {
var value_source = Reflect.field (source, field);
var value_dest = Reflect.field (destination, field);
var type_source = Type.typeof(value_source).getName();
var type_dest = Type.typeof(value_dest).getName();
// if(LogHelper.verbose) {
// LogHelper.println(field + " / existed in dest as " + type_dest + " / " + type_source );
// }
//if trying to copy a non object over an object, don't
if(type_source != "TObject" && type_dest == "TObject") {
do_copy = false;
if(LogHelper.verbose) {
LogHelper.println(field + " not merged by preference" );
}
}
}
if(do_copy) {
Reflect.setField (destination, field, Reflect.field (source, field));
}
}
return destination;
}
public static function copyMissingFields<T> (source:T, destination:T):T {