fix for empty expression primitive type serialization

Signed-off-by: chcurran <82187351+carlitosan@users.noreply.github.com>
monroegm-disable-blank-issue-2
chcurran 4 years ago
parent 2dd00e2983
commit b7c478b85e

@ -28,6 +28,19 @@ namespace AZ
private:
using VariableDescriptor = ExpressionEvaluation::ExpressionTree::VariableDescriptor;
static constexpr AZStd::string_view EmptyAnyIdentifier = "Empty AZStd::any";
static bool IsEmptyAny(const rapidjson::Value& typeId)
{
if (typeId.IsString())
{
AZStd::string_view typeName(typeId.GetString(), typeId.GetStringLength());
return typeName == EmptyAnyIdentifier;
}
return false;
}
JsonSerializationResult::Result Load
( void* outputValue
, [[maybe_unused]] const Uuid& outputValueTypeId
@ -62,6 +75,8 @@ namespace AZ
, JsonSerialization::TypeIdFieldIdentifier));
}
if (!IsEmptyAny(typeIdMember->value))
{
result.Combine(LoadTypeId(typeId, typeIdMember->value, context));
if (typeId.IsNull())
{
@ -78,6 +93,7 @@ namespace AZ
result.Combine(ContinueLoadingFromJsonObjectField(AZStd::any_cast<void>(&storage), typeId, inputValue, "Value", context));
outputDatum->m_value = storage;
}
// any storage end
return context.Report(result, result.GetProcessing() != JSR::Processing::Halted
@ -123,6 +139,8 @@ namespace AZ
, azrtti_typeid<decltype(inputScriptDataPtr->m_supportedTypes)>()
, context));
if (!inputScriptDataPtr->m_value.empty())
{
rapidjson::Value typeValue;
result.Combine(StoreTypeId(typeValue, inputScriptDataPtr->m_value.type(), context));
outputValue.AddMember
@ -137,6 +155,16 @@ namespace AZ
, defaultScriptDataPtr ? AZStd::any_cast<void>(const_cast<AZStd::any*>(&defaultScriptDataPtr->m_value)) : nullptr
, inputScriptDataPtr->m_value.type()
, context));
}
else
{
rapidjson::Value emptyAny;
emptyAny.SetString(EmptyAnyIdentifier.data(), aznumeric_caster(EmptyAnyIdentifier.size()), context.GetJsonAllocator());
outputValue.AddMember
( rapidjson::StringRef(JsonSerialization::TypeIdFieldIdentifier)
, AZStd::move(emptyAny)
, context.GetJsonAllocator());
}
return context.Report(result, result.GetProcessing() != JSR::Processing::Halted
? "VariableDescriptor Store finished saving VariableDescriptor"

Loading…
Cancel
Save