Skip to content

Commit

Permalink
release 1.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jagt committed Feb 20, 2024
1 parent 38b61d0 commit 8d4cd7e
Show file tree
Hide file tree
Showing 93 changed files with 1,664 additions and 379 deletions.
1 change: 1 addition & 0 deletions DataConfig/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/Resources/ClangTidy.lua*
*.raddbg*

# Visual Studio 2015 user specific files
.vs/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ FDcResult TestReadDatumEqual(const FDcPropertyDatum& LhsDatum, const FDcProperty
{
return DcOk();
}
case EDcDataEntry::Nil:
case EDcDataEntry::None:
{
DC_TRY(LhsReader.ReadNil());
DC_TRY(RhsReader.ReadNil());
DC_TRY(LhsReader.ReadNone());
DC_TRY(RhsReader.ReadNone());
break;
}
case EDcDataEntry::Bool:
Expand Down Expand Up @@ -232,6 +232,18 @@ FDcResult TestReadDatumEqual(const FDcPropertyDatum& LhsDatum, const FDcProperty
DC_TRY(RhsReader.ReadSetEnd());
break;
}
case EDcDataEntry::OptionalRoot:
{
DC_TRY(LhsReader.ReadOptionalRoot());
DC_TRY(RhsReader.ReadOptionalRoot());
break;
}
case EDcDataEntry::OptionalEnd:
{
DC_TRY(LhsReader.ReadOptionalEnd());
DC_TRY(RhsReader.ReadOptionalEnd());
break;
}
case EDcDataEntry::ObjectReference:
{
UObject* Lhs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
#include "DataConfig/Deserialize/Handlers/MsgPack/DcMsgPackTransientDeserializers.h"
#include "UObject/UnrealType.h"
#include "UObject/TextProperty.h"
#include "Misc/EngineVersionComparison.h"
#if !UE_VERSION_OLDER_THAN(5, 4, 0)
#include "UObject/PropertyOptional.h"
#endif // !UE_VERSION_OLDER_THAN(5, 4, 0)

void DcSetupJsonDeserializeHandlers(FDcDeserializer& Deserializer, EDcJsonDeserializeType Type)
{
Expand Down Expand Up @@ -60,12 +64,16 @@ void DcSetupJsonDeserializeHandlers(FDcDeserializer& Deserializer, EDcJsonDeseri
// Object
Deserializer.AddDirectHandler(FObjectProperty::StaticClass(), FDcDeserializeDelegate::CreateStatic(HandlerObjectReferenceDeserialize));
Deserializer.AddDirectHandler(FClassProperty::StaticClass(), FDcDeserializeDelegate::CreateStatic(HandlerClassReferenceDeserialize));
#if ENGINE_MAJOR_VERSION == 5
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION <= 3
Deserializer.AddDirectHandler(FObjectPtrProperty::StaticClass(), FDcDeserializeDelegate::CreateStatic(HandlerObjectReferenceDeserialize));
Deserializer.AddDirectHandler(FClassPtrProperty::StaticClass(), FDcDeserializeDelegate::CreateStatic(HandlerClassReferenceDeserialize));
#endif //ENGINE_MAJOR_VERSION == 5
#endif //ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION <= 3
Deserializer.AddDirectHandler(FWeakObjectProperty::StaticClass(), FDcDeserializeDelegate::CreateStatic(HandlerWeakObjectReferenceDeserialize));

#if !UE_VERSION_OLDER_THAN(5, 4, 0)
Deserializer.AddDirectHandler(FOptionalProperty::StaticClass(), FDcDeserializeDelegate::CreateStatic(HandlerOptionalDeserialize));
#endif // !UE_VERSION_OLDER_THAN(5, 4, 0)

if (Type == EDcJsonDeserializeType::Default)
{
Deserializer.AddDirectHandler(FSoftObjectProperty::StaticClass(), FDcDeserializeDelegate::CreateStatic(HandlerSoftObjectReferenceDeserialize));
Expand Down Expand Up @@ -99,9 +107,9 @@ void DcSetupPropertyPipeDeserializeHandlers(FDcDeserializer& Deserializer)
Deserializer.AddDirectHandler(UClass::StaticClass(), FDcDeserializeDelegate::CreateStatic(HandlerClassDeserialize));

Deserializer.AddDirectHandler(FObjectProperty::StaticClass(), FDcDeserializeDelegate::CreateStatic(HandlerClassDeserialize));
#if ENGINE_MAJOR_VERSION == 5
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION <= 3
Deserializer.AddDirectHandler(FObjectPtrProperty::StaticClass(), FDcDeserializeDelegate::CreateStatic(HandlerClassDeserialize));
#endif //ENGINE_MAJOR_VERSION == 5
#endif //ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION <= 3

Deserializer.AddDirectHandler(UScriptStruct::StaticClass(), FDcDeserializeDelegate::CreateStatic(HandlerStructDeserialize));
Deserializer.AddDirectHandler(FStructProperty::StaticClass(), FDcDeserializeDelegate::CreateStatic(HandlerStructDeserialize));
Expand All @@ -110,6 +118,10 @@ void DcSetupPropertyPipeDeserializeHandlers(FDcDeserializer& Deserializer)
Deserializer.AddDirectHandler(FSetProperty::StaticClass(), FDcDeserializeDelegate::CreateStatic(HandlerSetDeserialize));
Deserializer.AddDirectHandler(FMapProperty::StaticClass(), FDcDeserializeDelegate::CreateStatic(HandlerMapDeserialize));

#if !UE_VERSION_OLDER_THAN(5, 4, 0)
Deserializer.AddDirectHandler(FOptionalProperty::StaticClass(), FDcDeserializeDelegate::CreateStatic(HandlerOptionalDeserialize));
#endif // !UE_VERSION_OLDER_THAN(5, 4, 0)

DcPropertyUtils::VisitAllEffectivePropertyClass([&](FFieldClass* FieldClass) {
if (!Deserializer.FieldClassDeserializerMap.Contains(FieldClass))
Deserializer.AddDirectHandler(FieldClass, FDcDeserializeDelegate::CreateStatic(DcCommonHandlers::HandlerPipeScalarDeserialize));
Expand All @@ -136,6 +148,10 @@ void DcSetupMsgPackDeserializeHandlers(FDcDeserializer& Deserializer, EDcMsgPack
Deserializer.AddDirectHandler(FArrayProperty::StaticClass(), FDcDeserializeDelegate::CreateStatic(HandlerArrayDeserialize));
Deserializer.AddDirectHandler(FSetProperty::StaticClass(), FDcDeserializeDelegate::CreateStatic(HandlerArrayToSetDeserialize));
Deserializer.AddDirectHandler(FMapProperty::StaticClass(), FDcDeserializeDelegate::CreateStatic(DcMsgPackHandlers::HandlerMapDeserialize));

#if !UE_VERSION_OLDER_THAN(5, 4, 0)
Deserializer.AddDirectHandler(FOptionalProperty::StaticClass(), FDcDeserializeDelegate::CreateStatic(HandlerOptionalDeserialize));
#endif // !UE_VERSION_OLDER_THAN(5, 4, 0)

// Struct
Deserializer.AddDirectHandler(UScriptStruct::StaticClass(), FDcDeserializeDelegate::CreateStatic(HandlerMapToStructDeserialize));
Expand Down Expand Up @@ -168,10 +184,10 @@ void DcSetupMsgPackDeserializeHandlers(FDcDeserializer& Deserializer, EDcMsgPack
Deserializer.AddDirectHandler(FFieldPathProperty::StaticClass(), FDcDeserializeDelegate::CreateStatic(HandlerStringToFieldPathDeserialize));
Deserializer.AddDirectHandler(FObjectProperty::StaticClass(), FDcDeserializeDelegate::CreateStatic(HandlerObjectReferenceDeserialize));
Deserializer.AddDirectHandler(FClassProperty::StaticClass(), FDcDeserializeDelegate::CreateStatic(HandlerClassReferenceDeserialize));
#if ENGINE_MAJOR_VERSION == 5
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION <= 3
Deserializer.AddDirectHandler(FObjectPtrProperty::StaticClass(), FDcDeserializeDelegate::CreateStatic(HandlerObjectReferenceDeserialize));
Deserializer.AddDirectHandler(FClassPtrProperty::StaticClass(), FDcDeserializeDelegate::CreateStatic(HandlerClassReferenceDeserialize));
#endif //ENGINE_MAJOR_VERSION == 5
#endif //ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION <= 3

Deserializer.AddDirectHandler(FWeakObjectProperty::StaticClass(), FDcDeserializeDelegate::CreateStatic(HandlerWeakObjectReferenceDeserialize));

Expand All @@ -195,10 +211,10 @@ void DcSetupMsgPackDeserializeHandlers(FDcDeserializer& Deserializer, EDcMsgPack
Deserializer.AddDirectHandler(FTextProperty::StaticClass(), FDcDeserializeDelegate::CreateStatic(HandlerTransientTextDeserialize));
Deserializer.AddDirectHandler(FObjectProperty::StaticClass(), FDcDeserializeDelegate::CreateStatic(HandlerTransientObjectDeserialize));
Deserializer.AddDirectHandler(FClassProperty::StaticClass(), FDcDeserializeDelegate::CreateStatic(HandlerTransientClassDeserialize));
#if ENGINE_MAJOR_VERSION == 5
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION <= 3
Deserializer.AddDirectHandler(FObjectPtrProperty::StaticClass(), FDcDeserializeDelegate::CreateStatic(HandlerTransientObjectDeserialize));
Deserializer.AddDirectHandler(FClassPtrProperty::StaticClass(), FDcDeserializeDelegate::CreateStatic(HandlerTransientClassDeserialize));
#endif //ENGINE_MAJOR_VERSION == 5
#endif //ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION <= 3
Deserializer.AddDirectHandler(FSoftObjectProperty::StaticClass(), FDcDeserializeDelegate::CreateStatic(HandlerTransientSoftObjectDeserialize));
Deserializer.AddDirectHandler(FSoftClassProperty::StaticClass(), FDcDeserializeDelegate::CreateStatic(HandlerTransientSoftClassDeserialize));
Deserializer.AddDirectHandler(FWeakObjectProperty::StaticClass(), FDcDeserializeDelegate::CreateStatic(HandlerTransientWeakObjectDeserialize));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,25 @@ FDcResult HandlerMapOrArrayOfKeyValueDeserialize(FDcDeserializeContext& Ctx)
return DcOk();
}

FDcResult HandlerOptionalDeserialize(FDcDeserializeContext& Ctx)
{
DC_TRY(Ctx.Writer->WriteOptionalRoot());

EDcDataEntry Next;
DC_TRY(Ctx.Reader->PeekRead(&Next));
if (Next == EDcDataEntry::None)
{
DC_TRY(Ctx.Reader->ReadNone());
DC_TRY(Ctx.Writer->WriteNone());
}
else
{
DC_TRY(DcDeserializeUtils::RecursiveDeserialize(Ctx));
}

DC_TRY(Ctx.Writer->WriteOptionalEnd());
return DcOk();
}

} // namespace DcCommonHandlers

Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ static FORCEINLINE_DEBUGGABLE FDcResult ReadPointerRaw(FDcReader* Reader, void*&
return DcOk();
}

static FORCEINLINE_DEBUGGABLE FDcResult ReadPointerOrNil(FDcReader* Reader, void*& OutPtr)
static FORCEINLINE_DEBUGGABLE FDcResult ReadPointerOrNone(FDcReader* Reader, void*& OutPtr)
{
EDcDataEntry Next;
DC_TRY(Reader->PeekRead(&Next));

if (Next == EDcDataEntry::Nil)
if (Next == EDcDataEntry::None)
{
DC_TRY(Reader->ReadNil());
DC_TRY(Reader->ReadNone());
OutPtr = nullptr;
}
#if PLATFORM_64BITS
Expand All @@ -44,7 +44,7 @@ static FORCEINLINE_DEBUGGABLE FDcResult ReadPointerOrNil(FDcReader* Reader, void
else
{
return DC_FAIL(DcDReadWrite, DataTypeMismatch2)
<< EDcDataEntry::Nil << EDcDataEntry::UInt64 << Next;
<< EDcDataEntry::None << EDcDataEntry::UInt64 << Next;
}
#else
else if (Next == EDcDataEntry::UInt32)
Expand All @@ -54,7 +54,7 @@ static FORCEINLINE_DEBUGGABLE FDcResult ReadPointerOrNil(FDcReader* Reader, void
else
{
return DC_FAIL(DcDReadWrite, DataTypeMismatch2)
<< EDcDataEntry::Nil << EDcDataEntry::UInt32 << Next;
<< EDcDataEntry::None << EDcDataEntry::UInt32 << Next;
}
#endif

Expand Down Expand Up @@ -192,14 +192,14 @@ FDcResult HandlerTransientTextDeserialize(FDcDeserializeContext& Ctx)

FDcResult HandlerTransientObjectDeserialize(FDcDeserializeContext& Ctx)
{
FDcClassAccess Access{FDcClassAccess::EControl::ReferenceOrNil};
FDcClassAccess Access{FDcClassAccess::EControl::ReferenceOrNone};
DC_TRY(Ctx.Writer->WriteClassRootAccess(Access));

void* Ptr;
DC_TRY(DcMsgPackHandlersDetails::ReadPointerOrNil(Ctx.Reader, Ptr));
DC_TRY(DcMsgPackHandlersDetails::ReadPointerOrNone(Ctx.Reader, Ptr));
if (Ptr == nullptr)
{
DC_TRY(Ctx.Writer->WriteNil());
DC_TRY(Ctx.Writer->WriteNone());
}
else
{
Expand All @@ -214,7 +214,7 @@ FDcResult HandlerTransientObjectDeserialize(FDcDeserializeContext& Ctx)
FDcResult HandlerTransientClassDeserialize(FDcDeserializeContext& Ctx)
{
void* Ptr;
DC_TRY(DcMsgPackHandlersDetails::ReadPointerOrNil(Ctx.Reader, Ptr));
DC_TRY(DcMsgPackHandlersDetails::ReadPointerOrNone(Ctx.Reader, Ptr));
DC_TRY(DcPropertyUtils::HeuristicVerifyPointer(Ptr));
DC_TRY(Ctx.Writer->WriteClassReference((UClass*)Ptr));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ FDcResult HandlerClassDeserialize(FDcDeserializeContext& Ctx)
>(Ctx);
}

FDcResult HandlerOptionalDeserialize(FDcDeserializeContext& Ctx)
{
return DcHandlerPipeOptional<
FDcDeserializeContext,
FDcReader,
FDcPropertyWriter,
&DcDeserializeUtils::RecursiveDeserialize
>(Ctx);
}

} // namespace DcPropertyPipeHandlers


Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ FStringFormatArg DcConvertArg(FDcDataVariant& Var)
{
return FStringFormatArg(Var.GetValue<bool>());
}
else if (Var.DataType == EDcDataEntry::Nil)
else if (Var.DataType == EDcDataEntry::None)
{
return FStringFormatArg(TEXT("<null>"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ static FDcDiagnosticDetail _ReadWriteDetails[] = {
{ ReaderCastExpect, TEXT("Reader cast failed. Expected '{0}, Actual '{1}'") },
{ WriterCastExpect, TEXT("Writer cast failed. Expected '{0}, Actual '{1}'") },
{ PeekNoContainerProperty, TEXT("Property Reader/Writer has no container property, Actual: '{0}'"), },
{ WriteObjectReferenceDoNotAcceptNull, TEXT("FPropertyWriter::WriteObjectReference() don't accept nullptr. You should use WriteNil() instead."), },
{ PropertyNotSupportedUEVersion, TEXT("Property not supported by this Unreal Engine version: '{0}'"), },
{ WriteObjectReferenceDoNotAcceptNull, TEXT("FPropertyWriter::WriteObjectReference() don't accept nullptr. You should use WriteNone() instead."), },

// putback reader
{ CantUsePutbackValue, TEXT("Cannot use putback value in '{0}'") },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,21 +126,21 @@ static FORCEINLINE EDcDataEntry TokenTypeToDataEntry(ETokenType TokenType)
{
static EDcDataEntry _Mapping[(int)ETokenType::_Count] = {
EDcDataEntry::Ended,
EDcDataEntry::Nil,
EDcDataEntry::None,
EDcDataEntry::MapRoot,
EDcDataEntry::MapEnd,
EDcDataEntry::ArrayRoot,
EDcDataEntry::ArrayEnd,
EDcDataEntry::Nil,
EDcDataEntry::None,
EDcDataEntry::String,
EDcDataEntry::Double,
EDcDataEntry::Bool,
EDcDataEntry::Bool,
EDcDataEntry::Nil,
EDcDataEntry::None,

EDcDataEntry::Nil,
EDcDataEntry::Nil,
EDcDataEntry::Nil,
EDcDataEntry::None,
EDcDataEntry::None,
EDcDataEntry::None,
};

return _Mapping[(int)TokenType];
Expand Down Expand Up @@ -377,9 +377,9 @@ FDcResult TDcJsonReader<CharType>::PeekRead(EDcDataEntry* OutPtr)
}

template<typename CharType>
FDcResult TDcJsonReader<CharType>::ReadNil()
FDcResult TDcJsonReader<CharType>::ReadNone()
{
DC_TRY(CheckConsumeToken(EDcDataEntry::Nil));
DC_TRY(CheckConsumeToken(EDcDataEntry::None));
if (Token.Type == ETokenType::Null)
{
DC_TRY(CheckNotObjectKey());
Expand All @@ -389,7 +389,7 @@ FDcResult TDcJsonReader<CharType>::ReadNil()
else
{
return DC_FAIL(DcDJSON, ReadTypeMismatch)
<< EDcDataEntry::Nil << FDcJsonReaderDetails<CharType>::TokenTypeToDataEntry(Token.Type)
<< EDcDataEntry::None << FDcJsonReaderDetails<CharType>::TokenTypeToDataEntry(Token.Type)
<< FormatHighlight(Token.Ref);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ FORCEINLINE bool IsValidWriteScalar(EDcDataEntry Entry)
{
switch (Entry)
{
case EDcDataEntry::Nil:
case EDcDataEntry::None:
case EDcDataEntry::Bool:
case EDcDataEntry::Name:
case EDcDataEntry::String:
Expand Down Expand Up @@ -345,7 +345,7 @@ TDcJsonWriter<CharType>::TDcJsonWriter(ConfigType InConfig)
}

template<typename CharType>
FDcResult TDcJsonWriter<CharType>::WriteNil()
FDcResult TDcJsonWriter<CharType>::WriteNone()
{
using Details = FDcJsonWriterDetails<CharType>;

Expand Down
Loading

0 comments on commit 8d4cd7e

Please sign in to comment.