Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
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.7.0-develop.
This file has been generated by the Automatic Component Toolkit (ACT) version 1.8.1-develop.

Abstract: This is an autogenerated plain C Header file in order to allow an easy
use of RTTI
Expand Down Expand Up @@ -73,7 +73,9 @@ RTTIResult LoadRTTIWrapperTable(sRTTIDynamicWrapperTable * pWrapperTable, const

#ifdef _WIN32
// Convert filename to UTF16-string
int nLength = static_cast<int>(strnlen_s(pLibraryFileName, MAX_PATH));
int nLength = 0;
while ((pLibraryFileName[nLength] != 0) && (nLength < MAX_PATH))
nLength++;
int nBufferSize = nLength * 2 + 2;
wchar_t* wsLibraryFileName = (wchar_t*)malloc(nBufferSize*sizeof(wchar_t));
memset(wsLibraryFileName, 0, nBufferSize*sizeof(wchar_t));
Expand Down
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.7.0-develop.
This file has been generated by the Automatic Component Toolkit (ACT) version 1.8.1-develop.

Abstract: This is an autogenerated plain C Header file in order to allow an easy
use of RTTI
Expand Down
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.7.0-develop.
This file has been generated by the Automatic Component Toolkit (ACT) version 1.8.1-develop.

Abstract: This is an autogenerated plain C Header file with basic types in
order to allow an easy use of RTTI
Expand Down
52 changes: 45 additions & 7 deletions Examples/RTTI/RTTI_component/Bindings/CSharp/RTTI.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*++

Copyright (C) 2021 ADSK

All rights reserved.

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

Abstract: This is an autogenerated CSharp file in order to allow an easy
use of RTTI

Interface version: 1.0.0

*/

using System;
using System.Text;
using System.Runtime.InteropServices;
Expand Down Expand Up @@ -114,7 +129,7 @@ public static T PolymorphicFactory<T>(IntPtr Handle) where T : class
}


public class CBase
public class CBase : IDisposable
{
protected IntPtr Handle;

Expand All @@ -123,14 +138,28 @@ public CBase (IntPtr NewHandle)
Handle = NewHandle;
}

~CBase ()
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
// dispose managed state (managed objects).
}
if (Handle != IntPtr.Zero) {
Internal.RTTIWrapper.ReleaseInstance (Handle);
Handle = IntPtr.Zero;
}
}

public void Dispose()
{
// Dispose of unmanaged resources.
Dispose(true);
// Suppress finalization.
GC.SuppressFinalize(this);
}

~CBase () => Dispose(false);

protected void CheckError (Int32 errorCode)
{
if (errorCode != 0) {
Expand Down Expand Up @@ -281,7 +310,7 @@ public CAnimalIterator Iterator ()

}

class Wrapper
public class Wrapper
{
private static void CheckError (Int32 errorCode)
{
Expand All @@ -298,30 +327,39 @@ public static void GetVersion (out UInt32 AMajor, out UInt32 AMinor, out UInt32

public static bool GetLastError (CBase AInstance, out String AErrorMessage)
{
IntPtr AInstanceHandle = IntPtr.Zero;
if (AInstance != null)
AInstanceHandle = AInstance.GetHandle();
Byte resultHasError = 0;
UInt32 sizeErrorMessage = 0;
UInt32 neededErrorMessage = 0;
CheckError(Internal.RTTIWrapper.GetLastError (AInstance.GetHandle(), sizeErrorMessage, out neededErrorMessage, IntPtr.Zero, out resultHasError));
CheckError(Internal.RTTIWrapper.GetLastError (AInstanceHandle, sizeErrorMessage, out neededErrorMessage, IntPtr.Zero, out resultHasError));
sizeErrorMessage = neededErrorMessage;
byte[] bytesErrorMessage = new byte[sizeErrorMessage];
GCHandle dataErrorMessage = GCHandle.Alloc(bytesErrorMessage, GCHandleType.Pinned);

CheckError(Internal.RTTIWrapper.GetLastError (AInstance.GetHandle(), sizeErrorMessage, out neededErrorMessage, dataErrorMessage.AddrOfPinnedObject(), out resultHasError));
CheckError(Internal.RTTIWrapper.GetLastError (AInstanceHandle, sizeErrorMessage, out neededErrorMessage, dataErrorMessage.AddrOfPinnedObject(), out resultHasError));
dataErrorMessage.Free();
AErrorMessage = Encoding.UTF8.GetString(bytesErrorMessage).TrimEnd(char.MinValue);
return (resultHasError != 0);
}

public static void ReleaseInstance (CBase AInstance)
{
IntPtr AInstanceHandle = IntPtr.Zero;
if (AInstance != null)
AInstanceHandle = AInstance.GetHandle();

CheckError(Internal.RTTIWrapper.ReleaseInstance (AInstance.GetHandle()));
CheckError(Internal.RTTIWrapper.ReleaseInstance (AInstanceHandle));
}

public static void AcquireInstance (CBase AInstance)
{
IntPtr AInstanceHandle = IntPtr.Zero;
if (AInstance != null)
AInstanceHandle = AInstance.GetHandle();

CheckError(Internal.RTTIWrapper.AcquireInstance (AInstance.GetHandle()));
CheckError(Internal.RTTIWrapper.AcquireInstance (AInstanceHandle));
}

public static void InjectComponent (String ANameSpace, UInt64 ASymbolAddressMethod)
Expand Down
2 changes: 1 addition & 1 deletion Examples/RTTI/RTTI_component/Bindings/Cpp/rtti_abi.hpp
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.7.0-develop.
This file has been generated by the Automatic Component Toolkit (ACT) version 1.8.1-develop.

Abstract: This is an autogenerated C++-Header file in order to allow an easy
use of RTTI
Expand Down
28 changes: 16 additions & 12 deletions Examples/RTTI/RTTI_component/Bindings/Cpp/rtti_implicit.hpp
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.7.0-develop.
This file has been generated by the Automatic Component Toolkit (ACT) version 1.8.1-develop.

Abstract: This is an autogenerated C++-Header file in order to allow an easy
use of RTTI
Expand Down Expand Up @@ -100,27 +100,29 @@ typedef PZoo PRTTIZoo;

template<class T> class classParam {
private:
std::shared_ptr<T> m_sharedPtr;
const T* m_ptr;

public:
classParam(const T* ptr)
: m_ptr (ptr)
: m_ptr(ptr)
{
}

classParam(std::shared_ptr <T> sharedPtr)
: m_ptr (sharedPtr.get())
: m_sharedPtr(sharedPtr), m_ptr(sharedPtr.get())
{
}

RTTIHandle GetHandle()
{
if (m_ptr != nullptr)
return m_ptr->handle();
return nullptr;
return (RTTIHandle)nullptr;
}
};


/*************************************************************************************************************************
Class ERTTIException
**************************************************************************************************************************/
Expand Down Expand Up @@ -223,12 +225,12 @@ class CInputVector {

public:

explicit CInputVector( const std::vector<T>& vec)
CInputVector(const std::vector<T>& vec)
: m_data( vec.data() ), m_size( vec.size() )
{
}

CInputVector( const T* in_data, size_t in_size)
CInputVector(const T* in_data, size_t in_size)
: m_data( in_data ), m_size(in_size )
{
}
Expand Down Expand Up @@ -360,6 +362,8 @@ class CBase {

friend class CWrapper;
inline RTTI_uint64 ClassTypeId();

protected:
};

/*************************************************************************************************************************
Expand Down Expand Up @@ -625,15 +629,15 @@ inline CBase* CWrapper::polymorphicFactory(RTTIHandle pHandle)
*/
inline PZoo CWrapper::CreateZoo()
{
RTTIHandle hInstance = nullptr;
RTTIHandle hInstance = (RTTIHandle)nullptr;
CheckError(nullptr,rtti_createzoo(&hInstance));

if (!hInstance) {
CheckError(nullptr,RTTI_ERROR_INVALIDPARAM);
}
return std::shared_ptr<CZoo>(dynamic_cast<CZoo*>(this->polymorphicFactory(hInstance)));
}

inline void CWrapper::CheckError(CBase * pBaseClass, RTTIResult nResult)
{
if (nResult != 0) {
Expand Down Expand Up @@ -724,7 +728,7 @@ inline CBase* CWrapper::polymorphicFactory(RTTIHandle pHandle)
*/
PAnimal CAnimalIterator::GetNextAnimal()
{
RTTIHandle hAnimal = nullptr;
RTTIHandle hAnimal = (RTTIHandle)nullptr;
CheckError(rtti_animaliterator_getnextanimal(m_pHandle, &hAnimal));

if (hAnimal) {
Expand All @@ -741,7 +745,7 @@ inline CBase* CWrapper::polymorphicFactory(RTTIHandle pHandle)
*/
bool CAnimalIterator::GetNextOptinalAnimal(PAnimal & pAnimal)
{
RTTIHandle hAnimal = nullptr;
RTTIHandle hAnimal = (RTTIHandle)nullptr;
bool resultError = 0;
CheckError(rtti_animaliterator_getnextoptinalanimal(m_pHandle, &hAnimal, &resultError));
if (hAnimal) {
Expand All @@ -760,7 +764,7 @@ inline CBase* CWrapper::polymorphicFactory(RTTIHandle pHandle)
*/
bool CAnimalIterator::GetNextMandatoryAnimal(PAnimal & pAnimal)
{
RTTIHandle hAnimal = nullptr;
RTTIHandle hAnimal = (RTTIHandle)nullptr;
bool resultError = 0;
CheckError(rtti_animaliterator_getnextmandatoryanimal(m_pHandle, &hAnimal, &resultError));
if (hAnimal) {
Expand All @@ -782,7 +786,7 @@ inline CBase* CWrapper::polymorphicFactory(RTTIHandle pHandle)
*/
PAnimalIterator CZoo::Iterator()
{
RTTIHandle hIterator = nullptr;
RTTIHandle hIterator = (RTTIHandle)nullptr;
CheckError(rtti_zoo_iterator(m_pHandle, &hIterator));

if (!hIterator) {
Expand Down
2 changes: 1 addition & 1 deletion Examples/RTTI/RTTI_component/Bindings/Cpp/rtti_types.hpp
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.7.0-develop.
This file has been generated by the Automatic Component Toolkit (ACT) version 1.8.1-develop.

Abstract: This is an autogenerated C++-Header file with basic types in
order to allow an easy use of RTTI
Expand Down
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.7.0-develop.
This file has been generated by the Automatic Component Toolkit (ACT) version 1.8.1-develop.

Abstract: This is an autogenerated C++-Header file in order to allow an easy
use of RTTI
Expand Down
Loading
Loading