From 9d4744ea8d28199921b9cfac5cf82cb3322003ae Mon Sep 17 00:00:00 2001 From: Oliver Wu Date: Fri, 7 Nov 2025 15:41:28 -0500 Subject: [PATCH 1/2] Use specific class type instead of BaseClassName in ParameterCache template generation The buildOutCacheTemplateParameters function was incorrectly using BaseClassName (e.g., "Base") for ALL class output parameters when building the ParameterCache template type. This meant that methods like GeolocationList::GetAt that return specific types like IGeolocation* were being cached as IBase* instead. When a method signature expects IGeolocation*& (reference to IGeolocation pointer) but the cache uses IBase* in its template, the compiler error occurs because: IBase*& and IGeolocation*& are incompatible types References to pointers cannot be implicitly converted, even with inheritance --- .../Examples/Cpp/RTTI_example.cpp | 42 ++++++++++++++++++ .../Examples/CppDynamic/RTTI_example.cpp | 44 +++++++++++++++++++ Source/buildimplementationcpp.go | 2 +- 3 files changed, 87 insertions(+), 1 deletion(-) diff --git a/Examples/RTTI/RTTI_component/Examples/Cpp/RTTI_example.cpp b/Examples/RTTI/RTTI_component/Examples/Cpp/RTTI_example.cpp index dec8b000..285fdd74 100644 --- a/Examples/RTTI/RTTI_component/Examples/Cpp/RTTI_example.cpp +++ b/Examples/RTTI/RTTI_component/Examples/Cpp/RTTI_example.cpp @@ -99,6 +99,48 @@ int main() animal = iter->GetNextAnimal(); assert(animal == nullptr); + + // Test GetNextOptionalAnimal - class out parameter with bool return + std::cout << std::endl; + std::cout << "Testing GetNextOptinalAnimal:" << std::endl; + auto iter2 = zoo->Iterator(); + PAnimal optionalAnimal; + bool hasError; + + hasError = iter2->GetNextOptinalAnimal(optionalAnimal); + assert(hasError == true); + assert(optionalAnimal != nullptr); + std::cout << " Got animal: " << optionalAnimal->Name() << std::endl; + assert(std::dynamic_pointer_cast(optionalAnimal) != nullptr); + + hasError = iter2->GetNextOptinalAnimal(optionalAnimal); + assert(hasError == true); + assert(optionalAnimal != nullptr); + std::cout << " Got animal: " << optionalAnimal->Name() << std::endl; + assert(std::dynamic_pointer_cast(optionalAnimal) != nullptr); + + std::cout << "✓ GetNextOptinalAnimal test passed" << std::endl; + + // Test GetNextMandatoryAnimal - class out parameter with bool return + std::cout << std::endl; + std::cout << "Testing GetNextMandatoryAnimal:" << std::endl; + auto iter3 = zoo->Iterator(); + PAnimal mandatoryAnimal; + + hasError = iter3->GetNextMandatoryAnimal(mandatoryAnimal); + assert(hasError == true); + assert(mandatoryAnimal != nullptr); + std::cout << " Got animal: " << mandatoryAnimal->Name() << std::endl; + assert(std::dynamic_pointer_cast(mandatoryAnimal) != nullptr); + + hasError = iter3->GetNextMandatoryAnimal(mandatoryAnimal); + assert(hasError == true); + assert(mandatoryAnimal != nullptr); + std::cout << " Got animal: " << mandatoryAnimal->Name() << std::endl; + assert(std::dynamic_pointer_cast(mandatoryAnimal) != nullptr); + + std::cout << "✓ GetNextMandatoryAnimal test passed" << std::endl; + std::cout << std::endl; } catch (std::exception &e) { diff --git a/Examples/RTTI/RTTI_component/Examples/CppDynamic/RTTI_example.cpp b/Examples/RTTI/RTTI_component/Examples/CppDynamic/RTTI_example.cpp index 3ee5e73f..addeb2bc 100644 --- a/Examples/RTTI/RTTI_component/Examples/CppDynamic/RTTI_example.cpp +++ b/Examples/RTTI/RTTI_component/Examples/CppDynamic/RTTI_example.cpp @@ -112,6 +112,50 @@ int main() assert(animal == nullptr); std::cout << "Trace 1" << std::endl; + + // Test GetNextOptionalAnimal - class out parameter with bool return + std::cout << std::endl; + std::cout << "Testing GetNextOptinalAnimal:" << std::endl; + auto iter2 = zoo->Iterator(); + PAnimal optionalAnimal; + bool hasError; + + hasError = iter2->GetNextOptinalAnimal(optionalAnimal); + assert(hasError == true); + assert(optionalAnimal != nullptr); + std::cout << " Got animal: " << optionalAnimal->Name() << std::endl; + assert(std::dynamic_pointer_cast(optionalAnimal) != nullptr); + + hasError = iter2->GetNextOptinalAnimal(optionalAnimal); + assert(hasError == true); + assert(optionalAnimal != nullptr); + std::cout << " Got animal: " << optionalAnimal->Name() << std::endl; + assert(std::dynamic_pointer_cast(optionalAnimal) != nullptr); + + std::cout << "✓ GetNextOptinalAnimal test passed" << std::endl; + + // Test GetNextMandatoryAnimal - class out parameter with bool return + std::cout << std::endl; + std::cout << "Testing GetNextMandatoryAnimal:" << std::endl; + auto iter3 = zoo->Iterator(); + PAnimal mandatoryAnimal; + + hasError = iter3->GetNextMandatoryAnimal(mandatoryAnimal); + assert(hasError == true); + assert(mandatoryAnimal != nullptr); + std::cout << " Got animal: " << mandatoryAnimal->Name() << std::endl; + assert(std::dynamic_pointer_cast(mandatoryAnimal) != nullptr); + + hasError = iter3->GetNextMandatoryAnimal(mandatoryAnimal); + assert(hasError == true); + assert(mandatoryAnimal != nullptr); + std::cout << " Got animal: " << mandatoryAnimal->Name() << std::endl; + assert(std::dynamic_pointer_cast(mandatoryAnimal) != nullptr); + + std::cout << "✓ GetNextMandatoryAnimal test passed" << std::endl; + + std::cout << std::endl; + std::cout << "Trace 2" << std::endl; } catch (std::exception &e) { diff --git a/Source/buildimplementationcpp.go b/Source/buildimplementationcpp.go index e4de8349..06a01a61 100644 --- a/Source/buildimplementationcpp.go +++ b/Source/buildimplementationcpp.go @@ -973,7 +973,7 @@ func buildOutCacheTemplateParameters (method ComponentDefinitionMethod, NameSpac cppParamType := getCppParamType(param, NameSpace, true); if param.ParamType == "class" || param.ParamType == "optionalclass" { - cppParamType = fmt.Sprintf("I%s%s*", ClassIdentifier, BaseClassName) + cppParamType = fmt.Sprintf("I%s%s*", ClassIdentifier, param.ParamClass) } result += cppParamType; } From 5a1a3218ff8349d20189b1d7654bbc8ddbbd9085 Mon Sep 17 00:00:00 2001 From: gangatp Date: Mon, 10 Nov 2025 15:55:41 +0530 Subject: [PATCH 2/2] Update Examples/RTTI/RTTI_component/Examples/Cpp/RTTI_example.cpp Co-authored-by: Paul Davies <40460850+paul-davies-autodesk@users.noreply.github.com> --- Examples/RTTI/RTTI_component/Examples/Cpp/RTTI_example.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/RTTI/RTTI_component/Examples/Cpp/RTTI_example.cpp b/Examples/RTTI/RTTI_component/Examples/Cpp/RTTI_example.cpp index 285fdd74..29537a40 100644 --- a/Examples/RTTI/RTTI_component/Examples/Cpp/RTTI_example.cpp +++ b/Examples/RTTI/RTTI_component/Examples/Cpp/RTTI_example.cpp @@ -102,7 +102,7 @@ int main() // Test GetNextOptionalAnimal - class out parameter with bool return std::cout << std::endl; - std::cout << "Testing GetNextOptinalAnimal:" << std::endl; + std::cout << "Testing GetNextOptionalAnimal:" << std::endl; auto iter2 = zoo->Iterator(); PAnimal optionalAnimal; bool hasError;