Skip to content

Commit

Permalink
[CL-17413] Update to latest perforce change
Browse files Browse the repository at this point in the history
Change 17413 by waneck@swarm-aaae4552-5b5f-4892-1ad3-abb5c8363d1a on 2018/03/23 16:48:10

[unreal.hx] Make sure that classes that contain instanced references have the appropriate metadata #review @dan
  • Loading branch information
jenkins-proletariat committed Mar 23, 2018
1 parent 9c573bd commit cdb54ce
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Haxe/Static/uhx/runtime/UReflectionGenerator.hx
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,26 @@ public static function addHaxeBlueprintOverrides(clsName:String, uclass:UClass)
}
}

private static function containsInstancedData(def:UPropertyDef) : Bool {
if (def.metas != null) {
for (meta in def.metas) {
if (meta.name.toLowerCase() == 'instanced') {
return true;
}
}
}
switch (def.flags.type) {
case TMap | TArray | TSet:
for (param in def.params) {
if (containsInstancedData(param)) {
return true;
}
}
case _:
}
return false;
}

public static function addProperties(struct:UStruct, uname:String, isNative:Bool) {
#if DEBUG_HOTRELOAD
trace('$id: addProperties $uname $isNative');
Expand Down Expand Up @@ -558,13 +578,18 @@ public static function addHaxeBlueprintOverrides(clsName:String, uclass:UClass)
}
}

var isClass = Std.is(struct, UClass);
var uprops = meta.uclass.uprops,
i = uprops.length;
while (i --> 0) {
var propDef = uprops[i];
if (isNative && propDef.metas != null && propDef.metas.exists(function(m) return m.name == 'UnrealHxExpose')) {
continue;
}
if (isClass && containsInstancedData(propDef)) {
var cls:UClass = cast struct;
cls.ClassFlags = cls.ClassFlags | CLASS_HasInstancedReference;
}
var prop = generateUProperty(struct, struct, propDef, false);
if (prop == null) {
trace('Warning', 'Error while creating property ${propDef.uname} for class $uname');
Expand Down Expand Up @@ -1544,6 +1569,11 @@ public static function addHaxeBlueprintOverrides(clsName:String, uclass:UClass)
prop.PropertyFlags |= CPF_RepNotify;
prop.RepNotifyFunc = 'onRep_' + def.uname;
}
switch(def.flags.type) {
case TMap|TArray|TSet if (containsInstancedData(def)):
prop.PropertyFlags |= CPF_ContainsInstancedReference;
case _:
}

if (def.hxName != null && def.hxName != def.uname) {
prop.SetMetaData(CoreAPI.staticName('HaxeName'), def.hxName);
Expand Down

0 comments on commit cdb54ce

Please sign in to comment.