From 6e7f1c582be0e71c7a280e99644f05a7a25db701 Mon Sep 17 00:00:00 2001 From: vczh Date: Sun, 31 Oct 2021 06:16:02 -0700 Subject: [PATCH] Fix ubuntu build breaks --- Import/Vlpp.h | 2 +- Import/VlppReflection.h | 109 +++++++++++++++++++-------------- Import/VlppWorkflowRuntime.cpp | 3 +- 3 files changed, 65 insertions(+), 49 deletions(-) diff --git a/Import/Vlpp.h b/Import/Vlpp.h index 32fee2f6..f9c593c0 100644 --- a/Import/Vlpp.h +++ b/Import/Vlpp.h @@ -2227,7 +2227,7 @@ Interfaces { auto ref = GetCollectionReference(); if (!ref) return nullptr; - auto sref = ref.Cast(); + auto sref = ref.template Cast(); CHECK_ERROR(sref, L"IEnumerable::TryGetCollectionReference()#The associated collection reference has an unexpected type."); return sref; } diff --git a/Import/VlppReflection.h b/Import/VlppReflection.h index 6deab133..b307a343 100644 --- a/Import/VlppReflection.h +++ b/Import/VlppReflection.h @@ -1888,6 +1888,9 @@ namespace vl namespace description { class IValueReadonlyList; + + template + struct TypedValueSerializerProvider; } namespace description @@ -3676,6 +3679,59 @@ namespace vl { namespace description { + template + struct TypeInfoRetriver; + + /// + /// A reference holder to an unboxed object. + /// + /// The type of the unboxed object. + template + struct Unboxed + { + private: + T* object; + bool owned; + + public: + Unboxed(T* _object, bool _owned) : object(_object), owned(_owned) {} + Unboxed(Unboxed&& unboxed) : object(unboxed.object), owned(unboxed.owned) { unboxed.object = nullptr; } + ~Unboxed() { if (object && owned) { delete object; } } + + Unboxed() = delete; + Unboxed(const Unboxed&&) = delete; + Unboxed& operator=(const Unboxed&) = delete; + Unboxed& operator=(Unboxed&&) = delete; + + /// + /// Get the reference of the unboxed object. + /// It is recommended only to use this reference when the is still alive. + /// + /// The unboxed object. + T& Ref() const { CHECK_ERROR(object, L"vl::reflection::description::Unboxed::Ref()#The object has been moved away."); return *object; } + + /// + /// Test if the unboxed object is owned. + /// + /// + bool IsOwned() const + { + return owned; + } + }; + + template + Value BoxValue(const T& object, ITypeDescriptor* typeDescriptor = nullptr); + + template + T UnboxValue(const Value& value, ITypeDescriptor* typeDescriptor = nullptr, const WString& valueName = WString::Unmanaged(L"value")); + + template + Value BoxParameter(T&& object, ITypeDescriptor* typeDescriptor = nullptr); + + template + Unboxed UnboxParameter(const Value& value, ITypeDescriptor* typeDescriptor = nullptr, const WString& valueName = WString::Unmanaged(L"value")); + #ifndef VCZH_DEBUG_NO_REFLECTION /*********************************************************************** @@ -5040,7 +5096,7 @@ BoxValue, UnboxValue /// The object to box. /// The type descriptor of the object (optional). template - Value BoxValue(const T& object, ITypeDescriptor* typeDescriptor = nullptr) + Value BoxValue(const T& object, ITypeDescriptor* typeDescriptor) { using Type = std::remove_cvref_t; return ValueAccessor::Decorator>::BoxValue(object, typeDescriptor); @@ -5053,7 +5109,7 @@ BoxValue, UnboxValue /// The type descriptor of the object (optional). /// The name of the object to provide a friendly exception message if the conversion is failed (optional). template - T UnboxValue(const Value& value, ITypeDescriptor* typeDescriptor = nullptr, const WString& valueName = WString::Unmanaged(L"value")) + T UnboxValue(const Value& value, ITypeDescriptor* typeDescriptor, const WString& valueName) { using Type = std::remove_cvref_t; return ValueAccessor::Decorator>::UnboxValue(value, typeDescriptor, valueName); @@ -5252,49 +5308,11 @@ BoxParameter, UnboxParameter /// The object to box. /// The type descriptor of the object (optional). template - Value BoxParameter(T&& object, ITypeDescriptor* typeDescriptor = nullptr) + Value BoxParameter(T&& object, ITypeDescriptor* typeDescriptor) { using TIR = TypeInfoRetriver>; return ParameterAccessor, TIR::TypeFlag>::BoxParameter(object, typeDescriptor); } - - /// - /// A reference holder to an unboxed object. - /// - /// The type of the unboxed object. - template - struct Unboxed - { - private: - T* object; - bool owned; - - public: - Unboxed(T* _object, bool _owned) : object(_object), owned(_owned) {} - Unboxed(Unboxed&& unboxed) : object(unboxed.object), owned(unboxed.owned) { unboxed.object = nullptr; } - ~Unboxed() { if (object && owned) { delete object; } } - - Unboxed() = delete; - Unboxed(const Unboxed&&) = delete; - Unboxed& operator=(const Unboxed&) = delete; - Unboxed& operator=(Unboxed&&) = delete; - - /// - /// Get the reference of the unboxed object. - /// It is recommended only to use this reference when the is still alive. - /// - /// The unboxed object. - T& Ref() const { CHECK_ERROR(object, L"vl::reflection::description::Unboxed::Ref()#The object has been moved away."); return *object; } - - /// - /// Test if the unboxed object is owned. - /// - /// - bool IsOwned() const - { - return owned; - } - }; /// Box an reflectable object. It supports generic types such as containers, functions (should be Func<T>), etc. /// Type of the object. @@ -5303,7 +5321,7 @@ BoxParameter, UnboxParameter /// The type descriptor of the object (optional). /// The name of the object to provide a friendly exception message if the conversion is failed (optional). template - Unboxed UnboxParameter(const Value& value, ITypeDescriptor* typeDescriptor = nullptr, const WString& valueName = WString::Unmanaged(L"value")) + Unboxed UnboxParameter(const Value& value, ITypeDescriptor* typeDescriptor , const WString& valueName) { using TIR = TypeInfoRetriver>; return ParameterAccessor::UnboxParameter(value, typeDescriptor, valueName); @@ -6126,7 +6144,7 @@ Collection Wrappers template void ObservableList::NotifyUpdateInternal(vint start, vint count, vint newCount) { - if (auto colref = this->TryGetCollectionReference()) + if (auto colref = this->template TryGetCollectionReference()) { colref->ItemChanged(start, count, newCount); } @@ -6161,7 +6179,7 @@ Containers template class TValueImpl, typename T> auto GetValueCollectionFromCollection(T* collection) -> std::enable_if_t, Ptr> { - auto colref = collection->TryGetCollectionReference>(); + auto colref = collection->template TryGetCollectionReference>(); if (colref) return colref; colref = MakePtr>(collection); collection->SetCollectionReference(colref); @@ -7631,9 +7649,6 @@ Predefined Types #endif - template - struct TypedValueSerializerProvider; - #define DEFINE_TYPED_VALUE_SERIALIZER_PROVIDER(TYPENAME)\ template<>\ struct TypedValueSerializerProvider\ diff --git a/Import/VlppWorkflowRuntime.cpp b/Import/VlppWorkflowRuntime.cpp index a7bea6c8..989fb05c 100644 --- a/Import/VlppWorkflowRuntime.cpp +++ b/Import/VlppWorkflowRuntime.cpp @@ -394,8 +394,9 @@ WfRuntimeThreadContext case WfInsType::U8: CHECK_ERROR(value.typeDescriptor->GetEnumType(), L"WfRuntimeThreadContext::PushValue(const WfRuntimeValue&)#Missing typeDescriptor in WfRuntimeValue!"); return PushValue(value.typeDescriptor->GetEnumType()->ToEnum(value.u8Value)); + default: + CHECK_FAIL(L"WfRuntimeThreadContext::PushValue(const WfRuntimeValue&)#Unexpected type in WfRuntimeValue with typeDescriptor!"); } - CHECK_FAIL(L"WfRuntimeThreadContext::PushValue(const WfRuntimeValue&)#Unexpected type in WfRuntimeValue with typeDescriptor!"); } else {