static bool CheckForBadScalableFloats_r(void* Data, UStruct* Struct, UClass* Class) { for (TFieldIterator<UProperty> FieldIt(Struct, EFieldIteratorFlags::IncludeSuper); FieldIt; ++FieldIt) { UProperty* Prop = *FieldIt; CheckForBadScalableFloats_Prop_r(Data, Prop, Class); } return false; }
static bool FindClassesWithScalableFloat_r(const TArray<FString>& Args, UStruct* Struct, UClass* Class) { for (TFieldIterator<UProperty> FieldIt(Struct, EFieldIteratorFlags::ExcludeSuper); FieldIt; ++FieldIt) { UProperty* Prop = *FieldIt; if (FindClassesWithScalableFloat_Prop_r(Args, Prop, Class)) { return true; } } return false; }
/** * Creates a message definition for a group of properties * @param MsgProtoDesc descriptor to fill with the definition * @param FieldIt grouping of properties to define * @param PropertyFlags flags properties must have to be considered for the message * * @return TRUE on successful creation, FALSE otherwise */ bool CreateProtoDeclaration(google::protobuf::DescriptorProto* MsgProtoDesc, UStruct* Object, uint64 PropertyFlags) { bool bSuccess = true; int32 FieldIdx = 1; TFieldIterator<UProperty> FieldIt(Object); for(; FieldIt && (FieldIt->PropertyFlags & PropertyFlags); ++FieldIt) { UProperty* Property = *FieldIt; UClass* PropClass = Property->GetClass(); if (PropClass != UInterfaceProperty::StaticClass() && PropClass != UObjectProperty::StaticClass()) { bool bIsRepeated = false; UArrayProperty* ArrayProperty = Cast<UArrayProperty>(Property); if (ArrayProperty != NULL) { UClass* InnerPropClass = ArrayProperty->Inner->GetClass(); if (InnerPropClass != UInterfaceProperty::StaticClass() && InnerPropClass != UObjectProperty::StaticClass()) { Property = ArrayProperty->Inner; bIsRepeated = true; } else { UE_LOG_ONLINE(Error, TEXT("CreateProtoDeclaration - Unhandled property type '%s': %s"), *PropClass->GetName(), *Property->GetPathName()); bSuccess = false; break; } } else if(Property->ArrayDim != 1) { bIsRepeated = true; } FString SubMsgName; UStructProperty* StructProperty = Cast<UStructProperty>(Property); if (StructProperty != NULL) { FString TypeText, ExtendedTypeText; TypeText = Property->GetCPPType(&ExtendedTypeText, CPPF_None); google::protobuf::DescriptorProto* StructProtDesc = MsgProtoDesc->add_nested_type(); SubMsgName = FString::Printf(TEXT("%s%sMessage"), *TypeText, *ExtendedTypeText); StructProtDesc->set_name(TCHAR_TO_UTF8(*SubMsgName)); if (!CreateProtoDeclaration(StructProtDesc, StructProperty->Struct, CPF_AllFlags)) { StructProtDesc->Clear(); bSuccess = false; break; } } int32 Type = GetTypeFromProperty(Property); if (google::protobuf::FieldDescriptorProto_Type_IsValid(Type)) { google::protobuf::FieldDescriptorProto* MsgFieldProto = MsgProtoDesc->add_field(); MsgFieldProto->set_name(TCHAR_TO_UTF8(*Property->GetNameCPP())); MsgFieldProto->set_number(FieldIdx); MsgFieldProto->set_type((google::protobuf::FieldDescriptorProto_Type)Type); if (SubMsgName.Len() > 0) { MsgFieldProto->set_type_name(TCHAR_TO_UTF8(*SubMsgName)); } if (bIsRepeated) { MsgFieldProto->set_label(google::protobuf::FieldDescriptorProto_Label_LABEL_REPEATED); } else { MsgFieldProto->set_label(google::protobuf::FieldDescriptorProto_Label_LABEL_OPTIONAL); } FieldIdx++; } else { UE_LOG_ONLINE(Error, TEXT("CreateProtoDeclaration - Unhandled property mapping '%s': %s"), *PropClass->GetName(), *Property->GetPathName()); bSuccess = false; break; } } else { UE_LOG_ONLINE(Error, TEXT("CreateProtoDeclaration - Unhandled property type '%s': %s"), *PropClass->GetName(), *Property->GetPathName()); bSuccess = false; break; } } return bSuccess; }