Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Examples/RTTI/RTTI_component/Bindings/CSharp/RTTI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ namespace RTTI {
/// <summary>
/// Exception class for RTTI errors
/// </summary>
public class RTTIException : Exception
public class ERTTIException : Exception
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exception class is renamed from RTTIException to ERTTIException, but this inconsistency should be resolved. The class name ERTTIException doesn't follow C# naming conventions, which typically don't prefix exception classes with 'E'. Consider using RttiException instead to maintain consistency with .NET naming standards.

Copilot uses AI. Check for mistakes.
{
private readonly int _errorCode;
private readonly string _errorMessage;

/// <summary>
/// Initializes a new instance of the RTTIException class
/// Initializes a new instance of the ERTTIException class
/// </summary>
/// <param name="errorCode">The error code</param>
/// <param name="errorMessage">The error message</param>
public RTTIException(int errorCode, string errorMessage = "") : base(FormatMessage(errorCode, errorMessage))
public ERTTIException(int errorCode, string errorMessage = "") : base(FormatMessage(errorCode, errorMessage))
{
_errorCode = errorCode;
_errorMessage = errorMessage;
Expand Down Expand Up @@ -99,9 +99,9 @@ private static string FormatMessage(int errorCode, string errorMessage)
string errorName = GetErrorName(errorCode);
string errorDesc = GetErrorDescription(errorCode);
if (!string.IsNullOrEmpty(errorMessage))
return $"RTTIException {errorName} ({errorCode}): {errorDesc} - {errorMessage}";
return $"ERTTIException {errorName} ({errorCode}): {errorDesc} - {errorMessage}";
else
return $"RTTIException {errorName} ({errorCode}): {errorDesc}";
return $"ERTTIException {errorName} ({errorCode}): {errorDesc}";
}

private static string GetErrorName(int errorCode)
Expand Down Expand Up @@ -209,7 +209,7 @@ public static void ThrowError(IntPtr Handle, Int32 errorCode)
}
}

throw new RTTIException(errorCode, sMessage);
throw new ERTTIException(errorCode, sMessage);
}

/**
Expand Down
8 changes: 6 additions & 2 deletions Examples/RTTI/RTTI_component/Bindings/Python/RTTI.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,14 @@ def _checkBinaryVersion(self):
raise ERTTIException(ErrorCodes.INCOMPATIBLEBINARYVERSION)

def checkError(self, instance, errorCode):
if errorCode != ErrorCodes.SUCCESS.value:
ec = globals().get('ErrorCodes')
if ec is None:
# Interpreter shutdown: ErrorCodes may already be cleared; avoid noisy teardown
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The word 'noisy' in the comment could be clearer. Consider rephrasing to 'avoid errors during teardown' for better clarity.

Suggested change
# Interpreter shutdown: ErrorCodes may already be cleared; avoid noisy teardown
# Interpreter shutdown: ErrorCodes may already be cleared; avoid errors during teardown

Copilot uses AI. Check for mistakes.
return
if errorCode != ec.SUCCESS.value:
if instance:
if instance._wrapper != self:
raise ERTTIException(ErrorCodes.INVALIDCAST, 'invalid wrapper call')
raise ERTTIException(ec.INVALIDCAST, 'invalid wrapper call')
message,_ = self.GetLastError(instance)
raise ERTTIException(errorCode, message)

Expand Down
6 changes: 3 additions & 3 deletions Examples/RTTI/RTTI_component/Bindings/WASM/rtti_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Copyright (C) 2021 ADSK

All rights reserved.

This file has been generated by the Automatic Component Toolkit (ACT) version 1.8.0-develop.
This file has been generated by the Automatic Component Toolkit (ACT) version 1.8.1-develop.

Abstract: C++ Emscripten wrapper for WebAssembly

Expand Down Expand Up @@ -99,13 +99,13 @@ EMSCRIPTEN_BINDINGS(RTTI) {
class_<CTurtle, base<CReptile>>("CTurtle")
.smart_ptr<std::shared_ptr<CTurtle>>("shared_ptr<CTurtle>")
;
class_<CAnimalIterator>("CAnimalIterator")
class_<CAnimalIterator, base<CBase>>("CAnimalIterator")
.smart_ptr<std::shared_ptr<CAnimalIterator>>("shared_ptr<CAnimalIterator>")
.function("GetNextAnimal", &CAnimalIterator::GetNextAnimal)
.function("GetNextOptinalAnimal", &wrap_AnimalIterator_GetNextOptinalAnimal)
.function("GetNextMandatoryAnimal", &wrap_AnimalIterator_GetNextMandatoryAnimal)
;
class_<CZoo>("CZoo")
class_<CZoo, base<CBase>>("CZoo")
.smart_ptr<std::shared_ptr<CZoo>>("shared_ptr<CZoo>")
.function("Iterator", &CZoo::Iterator)
;
Expand Down
2 changes: 2 additions & 0 deletions Examples/RTTI/RTTI_component/Examples/Python/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ set -euxo pipefail
cd "$(dirname "$0")"
source ../../../../../Build/build.inc

which python3

echo "Test C++ library"
RUN "python3 RTTI_Example.py" $PWD/../../Implementations/Cpp/build

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ interface
**************************************************************************************************************************)

IRTTIBase = interface
['{F71073EA-4326-4BF0-B1B7-6B5326CE0668}']
['{6D5C237C-E78B-4657-B893-C8BE11BC6794}']

function GetLastErrorMessage(out AErrorMessage: String): Boolean;
procedure ClearErrorMessages();
Expand All @@ -48,7 +48,7 @@ interface
**************************************************************************************************************************)

IRTTIAnimal = interface(IRTTIBase)
['{710CB19F-03E6-4023-BACC-3C1A157E4C0A}']
['{8B7F3A98-3978-4C5F-90AC-F3D2FA2CC468}']

function Name(): String;
end;
Expand All @@ -59,7 +59,7 @@ interface
**************************************************************************************************************************)

IRTTIMammal = interface(IRTTIAnimal)
['{B282E29A-0B7B-444D-AFB2-F7E36D634D07}']
['{D9FFF1D8-FFFB-4EB4-AF81-25F9266571AA}']

end;

Expand All @@ -69,7 +69,7 @@ interface
**************************************************************************************************************************)

IRTTIReptile = interface(IRTTIAnimal)
['{9C3113BD-DBDB-479C-8109-0A9373897F4E}']
['{AB96FE19-A8D1-4610-8EE6-0EB949DFB518}']

end;

Expand All @@ -79,7 +79,7 @@ interface
**************************************************************************************************************************)

IRTTIGiraffe = interface(IRTTIMammal)
['{7A758ACC-C9D8-4C26-8758-E0012209395E}']
['{CFF41F38-7171-4D6E-A8DD-F0247C7C8FC2}']

end;

Expand All @@ -89,7 +89,7 @@ interface
**************************************************************************************************************************)

IRTTITiger = interface(IRTTIMammal)
['{8C10281D-9072-4B57-AF39-64903EA0A46B}']
['{B3279D23-3017-4F14-BA80-2481BDC18F9D}']

procedure Roar();
end;
Expand All @@ -100,7 +100,7 @@ interface
**************************************************************************************************************************)

IRTTISnake = interface(IRTTIReptile)
['{F7EA7F1B-BDA5-4E51-BA15-54AB1E92580D}']
['{02B026CC-EBE1-4A50-80C5-3E0E00419AE4}']

end;

Expand All @@ -110,7 +110,7 @@ interface
**************************************************************************************************************************)

IRTTITurtle = interface(IRTTIReptile)
['{E5BFFA76-FC6C-4C82-9302-E1BE903BCCFA}']
['{D5071CDA-CFDB-41A2-BA42-CF2B3EB75381}']

end;

Expand All @@ -120,7 +120,7 @@ interface
**************************************************************************************************************************)

IRTTIAnimalIterator = interface(IRTTIBase)
['{F99A080B-B278-4A43-9523-FB353C9928FA}']
['{30B15DE2-9548-4F1F-8A1C-28798D38ECF5}']

function GetNextAnimal(): TObject;
function GetNextOptinalAnimal(out AAnimal: TObject): Boolean;
Expand All @@ -133,7 +133,7 @@ interface
**************************************************************************************************************************)

IRTTIZoo = interface(IRTTIBase)
['{CA530586-4F80-45D7-B879-8FD0A52388E8}']
['{4CE7CE21-14C4-4F98-801A-3E952D434366}']

function Iterator(): TObject;
end;
Expand Down
8 changes: 6 additions & 2 deletions Source/buildbindingpython.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,10 +402,14 @@ func buildDynamicPythonImplementation(componentdefinition ComponentDefinition, w


w.Writeln(" def checkError(self, instance, errorCode):")
w.Writeln(" if errorCode != ErrorCodes.SUCCESS.value:")
w.Writeln(" ec = globals().get('ErrorCodes')")
w.Writeln(" if ec is None:")
w.Writeln(" # Interpreter shutdown: ErrorCodes may already be cleared; avoid noisy teardown")
w.Writeln(" return")
w.Writeln(" if errorCode != ec.SUCCESS.value:")
w.Writeln(" if instance:")
w.Writeln(" if instance._wrapper != self:")
w.Writeln(" raise E%sException(ErrorCodes.INVALIDCAST, 'invalid wrapper call')", NameSpace)
w.Writeln(" raise E%sException(ec.INVALIDCAST, 'invalid wrapper call')", NameSpace)
w.Writeln(" message,_ = self.%s(instance)", componentdefinition.Global.ErrorMethod)
w.Writeln(" raise E%sException(errorCode, message)", NameSpace)
w.Writeln(" ")
Expand Down
Loading