void FCEFJSStructSerializerBackend::WriteProperty(const FStructSerializerState& State, int32 ArrayIndex) { // booleans if (State.ValueType == UBoolProperty::StaticClass()) { Add(State, Cast<UBoolProperty>(State.ValueProperty)->GetPropertyValue_InContainer(State.ValueData, ArrayIndex)); } // unsigned bytes & enumerations else if (State.ValueType == UByteProperty::StaticClass()) { UByteProperty* ByteProperty = Cast<UByteProperty>(State.ValueProperty); if (ByteProperty->IsEnum()) { Add(State, ByteProperty->Enum->GetEnumName(ByteProperty->GetPropertyValue_InContainer(State.ValueData, ArrayIndex))); } else { Add(State, (double)Cast<UByteProperty>(State.ValueProperty)->GetPropertyValue_InContainer(State.ValueData, ArrayIndex)); } } // floating point numbers else if (State.ValueType == UDoubleProperty::StaticClass()) { Add(State, Cast<UDoubleProperty>(State.ValueProperty)->GetPropertyValue_InContainer(State.ValueData, ArrayIndex)); } else if (State.ValueType == UFloatProperty::StaticClass()) { Add(State, Cast<UFloatProperty>(State.ValueProperty)->GetPropertyValue_InContainer(State.ValueData, ArrayIndex)); } // signed integers else if (State.ValueType == UIntProperty::StaticClass()) { Add(State, (int32)Cast<UIntProperty>(State.ValueProperty)->GetPropertyValue_InContainer(State.ValueData, ArrayIndex)); } else if (State.ValueType == UInt8Property::StaticClass()) { Add(State, (int32)Cast<UInt8Property>(State.ValueProperty)->GetPropertyValue_InContainer(State.ValueData, ArrayIndex)); } else if (State.ValueType == UInt16Property::StaticClass()) { Add(State, (int32)Cast<UInt16Property>(State.ValueProperty)->GetPropertyValue_InContainer(State.ValueData, ArrayIndex)); } else if (State.ValueType == UInt64Property::StaticClass()) { Add(State, (double)Cast<UInt64Property>(State.ValueProperty)->GetPropertyValue_InContainer(State.ValueData, ArrayIndex)); } // unsigned integers else if (State.ValueType == UUInt16Property::StaticClass()) { Add(State, (int32)Cast<UUInt16Property>(State.ValueProperty)->GetPropertyValue_InContainer(State.ValueData, ArrayIndex)); } else if (State.ValueType == UUInt32Property::StaticClass()) { Add(State, (double)Cast<UUInt32Property>(State.ValueProperty)->GetPropertyValue_InContainer(State.ValueData, ArrayIndex)); } else if (State.ValueType == UUInt64Property::StaticClass()) { Add(State, (double)Cast<UUInt64Property>(State.ValueProperty)->GetPropertyValue_InContainer(State.ValueData, ArrayIndex)); } // names & strings else if (State.ValueType == UNameProperty::StaticClass()) { Add(State, Cast<UNameProperty>(State.ValueProperty)->GetPropertyValue_InContainer(State.ValueData, ArrayIndex).ToString()); } else if (State.ValueType == UStrProperty::StaticClass()) { Add(State, Cast<UStrProperty>(State.ValueProperty)->GetPropertyValue_InContainer(State.ValueData, ArrayIndex)); } else if (State.ValueType == UTextProperty::StaticClass()) { Add(State, Cast<UTextProperty>(State.ValueProperty)->GetPropertyValue_InContainer(State.ValueData, ArrayIndex).ToString()); } // classes & objects else if (State.ValueType == UClassProperty::StaticClass()) { Add(State, Cast<UClassProperty>(State.ValueProperty)->GetPropertyValue_InContainer(State.ValueData, ArrayIndex)->GetPathName()); } else if (State.ValueType == UObjectProperty::StaticClass()) { Add(State, Cast<UObjectProperty>(State.ValueProperty)->GetPropertyValue_InContainer(State.ValueData, ArrayIndex)); } // unsupported property type else { GLog->Logf(ELogVerbosity::Warning, TEXT("FCEFJSStructSerializerBackend: Property %s cannot be serialized, because its type (%s) is not supported"), *State.ValueProperty->GetName(), *State.ValueType->GetName()); } }
FWebJSParam FWebJSScripting::ConvertResult(UProperty* Property, uint8* Data) { // booleans if (Property->IsA<UBoolProperty>()) { return FWebJSParam(Cast<UBoolProperty>(Property)->GetPropertyValue_InContainer(Data)); } // unsigned bytes & enumerations else if (Property->IsA<UByteProperty>()) { UByteProperty* ByteProperty = Cast<UByteProperty>(Property); if (ByteProperty->IsEnum()) { return FWebJSParam(ByteProperty->Enum->GetEnumName(ByteProperty->GetPropertyValue_InContainer(Data))); } else { return FWebJSParam((int32)ByteProperty->GetPropertyValue_InContainer(Data)); } } // floating point numbers else if (Property->IsA<UDoubleProperty>()) { return FWebJSParam(Cast<UDoubleProperty>(Property)->GetPropertyValue_InContainer(Data)); } else if (Property->IsA<UFloatProperty>()) { return FWebJSParam(Cast<UFloatProperty>(Property)->GetPropertyValue_InContainer(Data)); } // signed integers else if (Property->IsA<UIntProperty>()) { return FWebJSParam(Cast<UIntProperty>(Property)->GetPropertyValue_InContainer(Data)); } else if (Property->IsA<UInt8Property>()) { return FWebJSParam((int32)Cast<UInt8Property>(Property)->GetPropertyValue_InContainer(Data)); } else if (Property->IsA<UInt16Property>()) { return FWebJSParam((int32)Cast<UInt16Property>(Property)->GetPropertyValue_InContainer(Data)); } else if (Property->IsA<UInt64Property>()) { return FWebJSParam((double)Cast<UInt64Property>(Property)->GetPropertyValue_InContainer(Data)); } // unsigned integers else if (Property->IsA<UUInt16Property>()) { return FWebJSParam((int32)Cast<UUInt16Property>(Property)->GetPropertyValue_InContainer(Data)); } else if (Property->IsA<UUInt32Property>()) { return FWebJSParam((double)Cast<UUInt32Property>(Property)->GetPropertyValue_InContainer(Data)); } else if (Property->IsA<UUInt64Property>()) { return FWebJSParam((double)Cast<UUInt64Property>(Property)->GetPropertyValue_InContainer(Data)); } // names & strings else if (Property->IsA<UNameProperty>()) { return FWebJSParam(Cast<UNameProperty>(Property)->GetPropertyValue_InContainer(Data).ToString()); } else if (Property->IsA<UStrProperty>()) { return FWebJSParam(Cast<UStrProperty>(Property)->GetPropertyValue_InContainer(Data)); } // classes & objects else if (Property->IsA<UClassProperty>()) { return FWebJSParam(Cast<UClassProperty>(Property)->GetPropertyValue_InContainer(Data)->GetPathName()); } else if (Property->IsA<UObjectProperty>()) { return FWebJSParam(Cast<UObjectProperty>(Property)->GetPropertyValue_InContainer(Data)); } else if (Property->IsA<UStructProperty>()) { UStructProperty* StructProperty = Cast<UStructProperty>(Property); return FWebJSParam(StructProperty->Struct, StructProperty->ContainerPtrToValuePtr<void>(Data)); } else { GLog->Logf(ELogVerbosity::Warning, TEXT("FWebJSScripting: %s cannot be serialized, because its type (%s) is not supported"), *Property->GetName(), *Property->GetClass()->GetName()); } return FWebJSParam(); }