Skip to content

Commit 794460e

Browse files
authored
fix(bindings): Python out parameter handling and improve C# wrapper visibility (#228)
* fix(bindings): Python out parameter handling and improve C# wrapper visibility * make sure in params are handled before out params * fix ordering of params in python binding and c interface * fixing indentation
1 parent d410f2d commit 794460e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+778
-272
lines changed

Examples/RTTI/RTTI_component/Bindings/CDynamic/rtti_dynamic.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Copyright (C) 2021 ADSK
44
55
All rights reserved.
66
7-
This file has been generated by the Automatic Component Toolkit (ACT) version 1.7.0-develop.
7+
This file has been generated by the Automatic Component Toolkit (ACT) version 1.8.1-develop.
88
99
Abstract: This is an autogenerated plain C Header file in order to allow an easy
1010
use of RTTI
@@ -73,7 +73,9 @@ RTTIResult LoadRTTIWrapperTable(sRTTIDynamicWrapperTable * pWrapperTable, const
7373

7474
#ifdef _WIN32
7575
// Convert filename to UTF16-string
76-
int nLength = static_cast<int>(strnlen_s(pLibraryFileName, MAX_PATH));
76+
int nLength = 0;
77+
while ((pLibraryFileName[nLength] != 0) && (nLength < MAX_PATH))
78+
nLength++;
7779
int nBufferSize = nLength * 2 + 2;
7880
wchar_t* wsLibraryFileName = (wchar_t*)malloc(nBufferSize*sizeof(wchar_t));
7981
memset(wsLibraryFileName, 0, nBufferSize*sizeof(wchar_t));

Examples/RTTI/RTTI_component/Bindings/CDynamic/rtti_dynamic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Copyright (C) 2021 ADSK
44
55
All rights reserved.
66
7-
This file has been generated by the Automatic Component Toolkit (ACT) version 1.7.0-develop.
7+
This file has been generated by the Automatic Component Toolkit (ACT) version 1.8.1-develop.
88
99
Abstract: This is an autogenerated plain C Header file in order to allow an easy
1010
use of RTTI

Examples/RTTI/RTTI_component/Bindings/CDynamic/rtti_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Copyright (C) 2021 ADSK
44
55
All rights reserved.
66
7-
This file has been generated by the Automatic Component Toolkit (ACT) version 1.7.0-develop.
7+
This file has been generated by the Automatic Component Toolkit (ACT) version 1.8.1-develop.
88
99
Abstract: This is an autogenerated plain C Header file with basic types in
1010
order to allow an easy use of RTTI

Examples/RTTI/RTTI_component/Bindings/CSharp/RTTI.cs

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/*++
2+
3+
Copyright (C) 2021 ADSK
4+
5+
All rights reserved.
6+
7+
This file has been generated by the Automatic Component Toolkit (ACT) version 1.8.1-develop.
8+
9+
Abstract: This is an autogenerated CSharp file in order to allow an easy
10+
use of RTTI
11+
12+
Interface version: 1.0.0
13+
14+
*/
15+
116
using System;
217
using System.Text;
318
using System.Runtime.InteropServices;
@@ -114,7 +129,7 @@ public static T PolymorphicFactory<T>(IntPtr Handle) where T : class
114129
}
115130

116131

117-
public class CBase
132+
public class CBase : IDisposable
118133
{
119134
protected IntPtr Handle;
120135

@@ -123,14 +138,28 @@ public CBase (IntPtr NewHandle)
123138
Handle = NewHandle;
124139
}
125140

126-
~CBase ()
141+
protected virtual void Dispose(bool disposing)
127142
{
143+
if (disposing)
144+
{
145+
// dispose managed state (managed objects).
146+
}
128147
if (Handle != IntPtr.Zero) {
129148
Internal.RTTIWrapper.ReleaseInstance (Handle);
130149
Handle = IntPtr.Zero;
131150
}
132151
}
133152

153+
public void Dispose()
154+
{
155+
// Dispose of unmanaged resources.
156+
Dispose(true);
157+
// Suppress finalization.
158+
GC.SuppressFinalize(this);
159+
}
160+
161+
~CBase () => Dispose(false);
162+
134163
protected void CheckError (Int32 errorCode)
135164
{
136165
if (errorCode != 0) {
@@ -281,7 +310,7 @@ public CAnimalIterator Iterator ()
281310

282311
}
283312

284-
class Wrapper
313+
public class Wrapper
285314
{
286315
private static void CheckError (Int32 errorCode)
287316
{
@@ -298,30 +327,39 @@ public static void GetVersion (out UInt32 AMajor, out UInt32 AMinor, out UInt32
298327

299328
public static bool GetLastError (CBase AInstance, out String AErrorMessage)
300329
{
330+
IntPtr AInstanceHandle = IntPtr.Zero;
331+
if (AInstance != null)
332+
AInstanceHandle = AInstance.GetHandle();
301333
Byte resultHasError = 0;
302334
UInt32 sizeErrorMessage = 0;
303335
UInt32 neededErrorMessage = 0;
304-
CheckError(Internal.RTTIWrapper.GetLastError (AInstance.GetHandle(), sizeErrorMessage, out neededErrorMessage, IntPtr.Zero, out resultHasError));
336+
CheckError(Internal.RTTIWrapper.GetLastError (AInstanceHandle, sizeErrorMessage, out neededErrorMessage, IntPtr.Zero, out resultHasError));
305337
sizeErrorMessage = neededErrorMessage;
306338
byte[] bytesErrorMessage = new byte[sizeErrorMessage];
307339
GCHandle dataErrorMessage = GCHandle.Alloc(bytesErrorMessage, GCHandleType.Pinned);
308340

309-
CheckError(Internal.RTTIWrapper.GetLastError (AInstance.GetHandle(), sizeErrorMessage, out neededErrorMessage, dataErrorMessage.AddrOfPinnedObject(), out resultHasError));
341+
CheckError(Internal.RTTIWrapper.GetLastError (AInstanceHandle, sizeErrorMessage, out neededErrorMessage, dataErrorMessage.AddrOfPinnedObject(), out resultHasError));
310342
dataErrorMessage.Free();
311343
AErrorMessage = Encoding.UTF8.GetString(bytesErrorMessage).TrimEnd(char.MinValue);
312344
return (resultHasError != 0);
313345
}
314346

315347
public static void ReleaseInstance (CBase AInstance)
316348
{
349+
IntPtr AInstanceHandle = IntPtr.Zero;
350+
if (AInstance != null)
351+
AInstanceHandle = AInstance.GetHandle();
317352

318-
CheckError(Internal.RTTIWrapper.ReleaseInstance (AInstance.GetHandle()));
353+
CheckError(Internal.RTTIWrapper.ReleaseInstance (AInstanceHandle));
319354
}
320355

321356
public static void AcquireInstance (CBase AInstance)
322357
{
358+
IntPtr AInstanceHandle = IntPtr.Zero;
359+
if (AInstance != null)
360+
AInstanceHandle = AInstance.GetHandle();
323361

324-
CheckError(Internal.RTTIWrapper.AcquireInstance (AInstance.GetHandle()));
362+
CheckError(Internal.RTTIWrapper.AcquireInstance (AInstanceHandle));
325363
}
326364

327365
public static void InjectComponent (String ANameSpace, UInt64 ASymbolAddressMethod)

Examples/RTTI/RTTI_component/Bindings/Cpp/rtti_abi.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Copyright (C) 2021 ADSK
44
55
All rights reserved.
66
7-
This file has been generated by the Automatic Component Toolkit (ACT) version 1.7.0-develop.
7+
This file has been generated by the Automatic Component Toolkit (ACT) version 1.8.1-develop.
88
99
Abstract: This is an autogenerated C++-Header file in order to allow an easy
1010
use of RTTI

Examples/RTTI/RTTI_component/Bindings/Cpp/rtti_implicit.hpp

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Copyright (C) 2021 ADSK
44
55
All rights reserved.
66
7-
This file has been generated by the Automatic Component Toolkit (ACT) version 1.7.0-develop.
7+
This file has been generated by the Automatic Component Toolkit (ACT) version 1.8.1-develop.
88
99
Abstract: This is an autogenerated C++-Header file in order to allow an easy
1010
use of RTTI
@@ -100,27 +100,29 @@ typedef PZoo PRTTIZoo;
100100

101101
template<class T> class classParam {
102102
private:
103+
std::shared_ptr<T> m_sharedPtr;
103104
const T* m_ptr;
104105

105106
public:
106107
classParam(const T* ptr)
107-
: m_ptr (ptr)
108+
: m_ptr(ptr)
108109
{
109110
}
110111

111112
classParam(std::shared_ptr <T> sharedPtr)
112-
: m_ptr (sharedPtr.get())
113+
: m_sharedPtr(sharedPtr), m_ptr(sharedPtr.get())
113114
{
114115
}
115116

116117
RTTIHandle GetHandle()
117118
{
118119
if (m_ptr != nullptr)
119120
return m_ptr->handle();
120-
return nullptr;
121+
return (RTTIHandle)nullptr;
121122
}
122123
};
123124

125+
124126
/*************************************************************************************************************************
125127
Class ERTTIException
126128
**************************************************************************************************************************/
@@ -223,12 +225,12 @@ class CInputVector {
223225

224226
public:
225227

226-
explicit CInputVector( const std::vector<T>& vec)
228+
CInputVector(const std::vector<T>& vec)
227229
: m_data( vec.data() ), m_size( vec.size() )
228230
{
229231
}
230232

231-
CInputVector( const T* in_data, size_t in_size)
233+
CInputVector(const T* in_data, size_t in_size)
232234
: m_data( in_data ), m_size(in_size )
233235
{
234236
}
@@ -360,6 +362,8 @@ class CBase {
360362

361363
friend class CWrapper;
362364
inline RTTI_uint64 ClassTypeId();
365+
366+
protected:
363367
};
364368

365369
/*************************************************************************************************************************
@@ -625,15 +629,15 @@ inline CBase* CWrapper::polymorphicFactory(RTTIHandle pHandle)
625629
*/
626630
inline PZoo CWrapper::CreateZoo()
627631
{
628-
RTTIHandle hInstance = nullptr;
632+
RTTIHandle hInstance = (RTTIHandle)nullptr;
629633
CheckError(nullptr,rtti_createzoo(&hInstance));
630634

631635
if (!hInstance) {
632636
CheckError(nullptr,RTTI_ERROR_INVALIDPARAM);
633637
}
634638
return std::shared_ptr<CZoo>(dynamic_cast<CZoo*>(this->polymorphicFactory(hInstance)));
635639
}
636-
640+
637641
inline void CWrapper::CheckError(CBase * pBaseClass, RTTIResult nResult)
638642
{
639643
if (nResult != 0) {
@@ -724,7 +728,7 @@ inline CBase* CWrapper::polymorphicFactory(RTTIHandle pHandle)
724728
*/
725729
PAnimal CAnimalIterator::GetNextAnimal()
726730
{
727-
RTTIHandle hAnimal = nullptr;
731+
RTTIHandle hAnimal = (RTTIHandle)nullptr;
728732
CheckError(rtti_animaliterator_getnextanimal(m_pHandle, &hAnimal));
729733

730734
if (hAnimal) {
@@ -741,7 +745,7 @@ inline CBase* CWrapper::polymorphicFactory(RTTIHandle pHandle)
741745
*/
742746
bool CAnimalIterator::GetNextOptinalAnimal(PAnimal & pAnimal)
743747
{
744-
RTTIHandle hAnimal = nullptr;
748+
RTTIHandle hAnimal = (RTTIHandle)nullptr;
745749
bool resultError = 0;
746750
CheckError(rtti_animaliterator_getnextoptinalanimal(m_pHandle, &hAnimal, &resultError));
747751
if (hAnimal) {
@@ -760,7 +764,7 @@ inline CBase* CWrapper::polymorphicFactory(RTTIHandle pHandle)
760764
*/
761765
bool CAnimalIterator::GetNextMandatoryAnimal(PAnimal & pAnimal)
762766
{
763-
RTTIHandle hAnimal = nullptr;
767+
RTTIHandle hAnimal = (RTTIHandle)nullptr;
764768
bool resultError = 0;
765769
CheckError(rtti_animaliterator_getnextmandatoryanimal(m_pHandle, &hAnimal, &resultError));
766770
if (hAnimal) {
@@ -782,7 +786,7 @@ inline CBase* CWrapper::polymorphicFactory(RTTIHandle pHandle)
782786
*/
783787
PAnimalIterator CZoo::Iterator()
784788
{
785-
RTTIHandle hIterator = nullptr;
789+
RTTIHandle hIterator = (RTTIHandle)nullptr;
786790
CheckError(rtti_zoo_iterator(m_pHandle, &hIterator));
787791

788792
if (!hIterator) {

Examples/RTTI/RTTI_component/Bindings/Cpp/rtti_types.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Copyright (C) 2021 ADSK
44
55
All rights reserved.
66
7-
This file has been generated by the Automatic Component Toolkit (ACT) version 1.7.0-develop.
7+
This file has been generated by the Automatic Component Toolkit (ACT) version 1.8.1-develop.
88
99
Abstract: This is an autogenerated C++-Header file with basic types in
1010
order to allow an easy use of RTTI

Examples/RTTI/RTTI_component/Bindings/CppDynamic/rtti_dynamic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Copyright (C) 2021 ADSK
44
55
All rights reserved.
66
7-
This file has been generated by the Automatic Component Toolkit (ACT) version 1.7.0-develop.
7+
This file has been generated by the Automatic Component Toolkit (ACT) version 1.8.1-develop.
88
99
Abstract: This is an autogenerated C++-Header file in order to allow an easy
1010
use of RTTI

0 commit comments

Comments
 (0)