diff --git a/.gitignore b/.gitignore index 7f3848a..eaec275 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ # Rider IDE -.idea \ No newline at end of file +.idea + +# Unity upgrade logs +Unity/Logs \ No newline at end of file diff --git a/README.md b/README.md index ed009f0..8b108f6 100644 --- a/README.md +++ b/README.md @@ -161,9 +161,8 @@ With C++, the workflow looks like this: 1. Download or clone this repo 2. Copy everything in `Unity/Assets` directory to your Unity project's `Assets` directory -3. Copy the `Unity/CppSource` directory to your Unity project directory -4. Edit `NativeScriptTypes.json` and specify what parts of the Unity, .NET, and custom DLL APIs you want access to from C++. -5. Edit `Unity/CppSource/Game/Game.cpp` and `Unity/CppSource/Game/Game.h` to create your game. Some example code is provided, but feel free to delete it. You can add more C++ source (`.cpp`) and header (`.h`) files here as your game grows. +3. Edit `NativeScriptTypes.json` and specify what parts of the Unity, .NET, and custom DLL APIs you want access to from C++. +4. Edit `Unity/Assets/CppSource/Game/Game.cpp` and `Unity/Assets/CppSource/Game/Game.h` to create your game. Some example code is provided, but feel free to delete it. You can add more C++ source (`.cpp`) and header (`.h`) files here as your game grows. # Building the C++ Plugin @@ -193,7 +192,7 @@ With C++, the workflow looks like this: 2. Create a directory for build files. Anywhere is fine. 3. Open a Command Prompt by clicking the Start button, typing "Command Prompt", then clicking the app 4. Execute `cd /path/to/your/build/directory` -5. Execute `cmake -G "Visual Studio VERSION YEAR Win64" -DEDITOR=TRUE /path/to/your/project/CppSource`. Replace `VERSION` and `YEAR` with the version of Visual Studio you want to use. To see the options, execute `cmake --help` and look at the list at the bottom. For example, use `"Visual Studio 15 2017 Win64"` for Visual Studio 2017. Any version, including Community, works just fine. Remove `-DEDITOR=TRUE` for standalone builds. +5. Execute `cmake -G "Visual Studio VERSION YEAR Win64" -DEDITOR=TRUE /path/to/your/project/CppSource`. Replace `VERSION` and `YEAR` with the version of Visual Studio you want to use. To see the options, execute `cmake --help` and look at the list at the bottom. For example, use `"Visual Studio 15 2017 Win64"` for Visual Studio 2017. Any version, including Community, works just fine. Remove `-DEDITOR=TRUE` for standalone builds. If you are using Visual Studio 2019, execute `cmake -G "Visual Studio 16" -A "x64" -DEDITOR=TRUE /path/to/your/project/CppSource` instead. 6. The project files are now generated in your build directory 7. Open `NativeScript.sln` and click `Build > Build Solution`. diff --git a/Unity/Assets/CppSource/CMakeLists.txt b/Unity/Assets/CppSource/CMakeLists.txt index 306ae25..2baa025 100644 --- a/Unity/Assets/CppSource/CMakeLists.txt +++ b/Unity/Assets/CppSource/CMakeLists.txt @@ -79,5 +79,9 @@ if (IOS) set_xcode_property(${PROJECT_NAME} ENABLE_BITCODE "NO") endif() +if(WIN32 AND MINGW) + set_property(TARGET ${PROJECT_NAME} PROPERTY PREFIX "") +endif() + # Enable C++11 set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) \ No newline at end of file diff --git a/Unity/Assets/CppSource/Game/Game.h b/Unity/Assets/CppSource/Game/Game.h index a8e6e5b..79d31ad 100644 --- a/Unity/Assets/CppSource/Game/Game.h +++ b/Unity/Assets/CppSource/Game/Game.h @@ -16,6 +16,7 @@ namespace MyGame { struct BallScript : MyGame::BaseBallScript { + MY_GAME_BALL_SCRIPT_DEFAULT_CONTENTS MY_GAME_BALL_SCRIPT_DEFAULT_CONSTRUCTOR void Update() override; }; diff --git a/Unity/Assets/CppSource/NativeScript/Bindings.cpp b/Unity/Assets/CppSource/NativeScript/Bindings.cpp index a828a47..8cb2e2e 100644 --- a/Unity/Assets/CppSource/NativeScript/Bindings.cpp +++ b/Unity/Assets/CppSource/NativeScript/Bindings.cpp @@ -9,30 +9,18 @@ /// MIT /// -// Type definitions -#include "Bindings.h" - // Game type definitions #include "Game.h" +// Type definitions +#include "Bindings.h" + // For assert() #include -// For int32_t, etc. -#include - -// For malloc(), etc. -#include - // For memset(), etc. #include -// Support placement new -void* operator new(size_t, void* p) -{ - return p; -} - // Macro to put before functions that need to be exposed to C# #ifdef _WIN32 #define DLLEXPORT extern "C" __declspec(dllexport) @@ -76,33 +64,33 @@ namespace Plugin int32_t (*SystemExceptionConstructorSystemString)(int32_t messageHandle); int32_t (*BoxPrimitiveType)(UnityEngine::PrimitiveType val); UnityEngine::PrimitiveType (*UnboxPrimitiveType)(int32_t valHandle); - System::Single (*UnityEngineTimePropertyGetDeltaTime)(); + float (*UnityEngineTimePropertyGetDeltaTime)(); void (*ReleaseBaseBallScript)(int32_t handle); void (*BaseBallScriptConstructor)(int32_t cppHandle, int32_t* handle); int32_t (*BoxBoolean)(uint32_t val); int32_t (*UnboxBoolean)(int32_t valHandle); int32_t (*BoxSByte)(int8_t val); - System::SByte (*UnboxSByte)(int32_t valHandle); + int8_t (*UnboxSByte)(int32_t valHandle); int32_t (*BoxByte)(uint8_t val); - System::Byte (*UnboxByte)(int32_t valHandle); + uint8_t (*UnboxByte)(int32_t valHandle); int32_t (*BoxInt16)(int16_t val); - System::Int16 (*UnboxInt16)(int32_t valHandle); + int16_t (*UnboxInt16)(int32_t valHandle); int32_t (*BoxUInt16)(uint16_t val); - System::UInt16 (*UnboxUInt16)(int32_t valHandle); + uint16_t (*UnboxUInt16)(int32_t valHandle); int32_t (*BoxInt32)(int32_t val); - System::Int32 (*UnboxInt32)(int32_t valHandle); + int32_t (*UnboxInt32)(int32_t valHandle); int32_t (*BoxUInt32)(uint32_t val); - System::UInt32 (*UnboxUInt32)(int32_t valHandle); + uint32_t (*UnboxUInt32)(int32_t valHandle); int32_t (*BoxInt64)(int64_t val); - System::Int64 (*UnboxInt64)(int32_t valHandle); + int64_t (*UnboxInt64)(int32_t valHandle); int32_t (*BoxUInt64)(uint64_t val); - System::UInt64 (*UnboxUInt64)(int32_t valHandle); + uint64_t (*UnboxUInt64)(int32_t valHandle); int32_t (*BoxChar)(uint16_t val); int16_t (*UnboxChar)(int32_t valHandle); int32_t (*BoxSingle)(float val); - System::Single (*UnboxSingle)(int32_t valHandle); + float (*UnboxSingle)(int32_t valHandle); int32_t (*BoxDouble)(double val); - System::Double (*UnboxDouble)(int32_t valHandle); + double (*UnboxDouble)(int32_t valHandle); /*END FUNCTION POINTERS*/ } @@ -978,6 +966,10 @@ namespace System : ManagedType(nullptr) { } + + Object::~Object() + { + } bool Object::operator==(decltype(nullptr)) const { @@ -2490,6 +2482,87 @@ namespace System } } +namespace System +{ + IEquatable_1::IEquatable_1(decltype(nullptr)) + { + } + + IEquatable_1::IEquatable_1(Plugin::InternalUse, int32_t handle) + { + Handle = handle; + if (handle) + { + Plugin::ReferenceManagedClass(handle); + } + } + + IEquatable_1::IEquatable_1(const IEquatable_1& other) + : IEquatable_1(Plugin::InternalUse::Only, other.Handle) + { + } + + IEquatable_1::IEquatable_1(IEquatable_1&& other) + : IEquatable_1(Plugin::InternalUse::Only, other.Handle) + { + other.Handle = 0; + } + + IEquatable_1::~IEquatable_1() + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + } + + IEquatable_1& IEquatable_1::operator=(const IEquatable_1& other) + { + if (this->Handle) + { + Plugin::DereferenceManagedClass(this->Handle); + } + this->Handle = other.Handle; + if (this->Handle) + { + Plugin::ReferenceManagedClass(this->Handle); + } + return *this; + } + + IEquatable_1& IEquatable_1::operator=(decltype(nullptr)) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + return *this; + } + + IEquatable_1& IEquatable_1::operator=(IEquatable_1&& other) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + } + Handle = other.Handle; + other.Handle = 0; + return *this; + } + + bool IEquatable_1::operator==(const IEquatable_1& other) const + { + return Handle == other.Handle; + } + + bool IEquatable_1::operator!=(const IEquatable_1& other) const + { + return Handle != other.Handle; + } +} + namespace System { IComparable_1::IComparable_1(decltype(nullptr)) @@ -3543,6 +3616,93 @@ namespace System } } +namespace System +{ + namespace Runtime + { + namespace Serialization + { + IDeserializationCallback::IDeserializationCallback(decltype(nullptr)) + { + } + + IDeserializationCallback::IDeserializationCallback(Plugin::InternalUse, int32_t handle) + { + Handle = handle; + if (handle) + { + Plugin::ReferenceManagedClass(handle); + } + } + + IDeserializationCallback::IDeserializationCallback(const IDeserializationCallback& other) + : IDeserializationCallback(Plugin::InternalUse::Only, other.Handle) + { + } + + IDeserializationCallback::IDeserializationCallback(IDeserializationCallback&& other) + : IDeserializationCallback(Plugin::InternalUse::Only, other.Handle) + { + other.Handle = 0; + } + + IDeserializationCallback::~IDeserializationCallback() + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + } + + IDeserializationCallback& IDeserializationCallback::operator=(const IDeserializationCallback& other) + { + if (this->Handle) + { + Plugin::DereferenceManagedClass(this->Handle); + } + this->Handle = other.Handle; + if (this->Handle) + { + Plugin::ReferenceManagedClass(this->Handle); + } + return *this; + } + + IDeserializationCallback& IDeserializationCallback::operator=(decltype(nullptr)) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + return *this; + } + + IDeserializationCallback& IDeserializationCallback::operator=(IDeserializationCallback&& other) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + } + Handle = other.Handle; + other.Handle = 0; + return *this; + } + + bool IDeserializationCallback::operator==(const IDeserializationCallback& other) const + { + return Handle == other.Handle; + } + + bool IDeserializationCallback::operator!=(const IDeserializationCallback& other) const + { + return Handle != other.Handle; + } + } + } +} + namespace System { Decimal::Decimal(decltype(nullptr)) @@ -3693,7 +3853,7 @@ namespace System return nullptr; } - System::Decimal::operator System::IFormattable() + System::Decimal::operator System::IComparable() { int32_t handle = Plugin::BoxDecimal(Handle); if (Plugin::unhandledCsharpException) @@ -3706,7 +3866,25 @@ namespace System if (handle) { Plugin::ReferenceManagedClass(handle); - return System::IFormattable(Plugin::InternalUse::Only, handle); + return System::IComparable(Plugin::InternalUse::Only, handle); + } + return nullptr; + } + + System::Decimal::operator System::IComparable_1() + { + int32_t handle = Plugin::BoxDecimal(Handle); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + if (handle) + { + Plugin::ReferenceManagedClass(handle); + return System::IComparable_1(Plugin::InternalUse::Only, handle); } return nullptr; } @@ -3729,7 +3907,7 @@ namespace System return nullptr; } - System::Decimal::operator System::IComparable() + System::Decimal::operator System::IEquatable_1() { int32_t handle = Plugin::BoxDecimal(Handle); if (Plugin::unhandledCsharpException) @@ -3742,12 +3920,12 @@ namespace System if (handle) { Plugin::ReferenceManagedClass(handle); - return System::IComparable(Plugin::InternalUse::Only, handle); + return System::IEquatable_1(Plugin::InternalUse::Only, handle); } return nullptr; } - System::Decimal::operator System::IComparable_1() + System::Decimal::operator System::Runtime::Serialization::IDeserializationCallback() { int32_t handle = Plugin::BoxDecimal(Handle); if (Plugin::unhandledCsharpException) @@ -3760,12 +3938,12 @@ namespace System if (handle) { Plugin::ReferenceManagedClass(handle); - return System::IComparable_1(Plugin::InternalUse::Only, handle); + return System::Runtime::Serialization::IDeserializationCallback(Plugin::InternalUse::Only, handle); } return nullptr; } - System::Decimal::operator System::IEquatable_1() + System::Decimal::operator System::IFormattable() { int32_t handle = Plugin::BoxDecimal(Handle); if (Plugin::unhandledCsharpException) @@ -3778,7 +3956,7 @@ namespace System if (handle) { Plugin::ReferenceManagedClass(handle); - return System::IEquatable_1(Plugin::InternalUse::Only, handle); + return System::IFormattable(Plugin::InternalUse::Only, handle); } return nullptr; } @@ -3867,6 +4045,24 @@ namespace UnityEngine } return nullptr; } + + UnityEngine::Vector3::operator System::IEquatable_1() + { + int32_t handle = Plugin::BoxVector3(*this); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + if (handle) + { + Plugin::ReferenceManagedClass(handle); + return System::IEquatable_1(Plugin::InternalUse::Only, handle); + } + return nullptr; + } } namespace System @@ -5226,7 +5422,7 @@ namespace UnityEngine return nullptr; } - UnityEngine::PrimitiveType::operator System::IFormattable() + UnityEngine::PrimitiveType::operator System::IComparable() { int32_t handle = Plugin::BoxPrimitiveType(*this); if (Plugin::unhandledCsharpException) @@ -5239,7 +5435,7 @@ namespace UnityEngine if (handle) { Plugin::ReferenceManagedClass(handle); - return System::IFormattable(Plugin::InternalUse::Only, handle); + return System::IComparable(Plugin::InternalUse::Only, handle); } return nullptr; } @@ -5262,7 +5458,7 @@ namespace UnityEngine return nullptr; } - UnityEngine::PrimitiveType::operator System::IComparable() + UnityEngine::PrimitiveType::operator System::IFormattable() { int32_t handle = Plugin::BoxPrimitiveType(*this); if (Plugin::unhandledCsharpException) @@ -5275,7 +5471,7 @@ namespace UnityEngine if (handle) { Plugin::ReferenceManagedClass(handle); - return System::IComparable(Plugin::InternalUse::Only, handle); + return System::IFormattable(Plugin::InternalUse::Only, handle); } return nullptr; } @@ -5951,142 +6147,146 @@ enum class InitMode : uint8_t DLLEXPORT void Init( uint8_t* memory, int32_t memorySize, - InitMode initMode, - void (*releaseObject)(int32_t handle), - int32_t (*stringNew)(const char* chars), - void (*setException)(int32_t handle), - int32_t (*arrayGetLength)(int32_t handle), - int32_t (*enumerableGetEnumerator)(int32_t handle), - /*BEGIN INIT PARAMS*/ - int32_t maxManagedObjects, - void (*releaseSystemDecimal)(int32_t handle), - int32_t (*systemDecimalConstructorSystemDouble)(double value), - int32_t (*systemDecimalConstructorSystemUInt64)(uint64_t value), - int32_t (*boxDecimal)(int32_t valHandle), - int32_t (*unboxDecimal)(int32_t valHandle), - UnityEngine::Vector3 (*unityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingle)(float x, float y, float z), - UnityEngine::Vector3 (*unityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3)(UnityEngine::Vector3& a, UnityEngine::Vector3& b), - int32_t (*boxVector3)(UnityEngine::Vector3& val), - UnityEngine::Vector3 (*unboxVector3)(int32_t valHandle), - int32_t (*unityEngineObjectPropertyGetName)(int32_t thisHandle), - void (*unityEngineObjectPropertySetName)(int32_t thisHandle, int32_t valueHandle), - int32_t (*unityEngineComponentPropertyGetTransform)(int32_t thisHandle), - UnityEngine::Vector3 (*unityEngineTransformPropertyGetPosition)(int32_t thisHandle), - void (*unityEngineTransformPropertySetPosition)(int32_t thisHandle, UnityEngine::Vector3& value), - int32_t (*systemCollectionsIEnumeratorPropertyGetCurrent)(int32_t thisHandle), - int32_t (*systemCollectionsIEnumeratorMethodMoveNext)(int32_t thisHandle), - int32_t (*unityEngineGameObjectMethodAddComponentMyGameBaseBallScript)(int32_t thisHandle), - int32_t (*unityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveType)(UnityEngine::PrimitiveType type), - void (*unityEngineDebugMethodLogSystemObject)(int32_t messageHandle), - int32_t (*unityEngineMonoBehaviourPropertyGetTransform)(int32_t thisHandle), - int32_t (*systemExceptionConstructorSystemString)(int32_t messageHandle), - int32_t (*boxPrimitiveType)(UnityEngine::PrimitiveType val), - UnityEngine::PrimitiveType (*unboxPrimitiveType)(int32_t valHandle), - System::Single (*unityEngineTimePropertyGetDeltaTime)(), - void (*releaseBaseBallScript)(int32_t handle), - void (*baseBallScriptConstructor)(int32_t cppHandle, int32_t* handle), - int32_t (*boxBoolean)(uint32_t val), - int32_t (*unboxBoolean)(int32_t valHandle), - int32_t (*boxSByte)(int8_t val), - System::SByte (*unboxSByte)(int32_t valHandle), - int32_t (*boxByte)(uint8_t val), - System::Byte (*unboxByte)(int32_t valHandle), - int32_t (*boxInt16)(int16_t val), - System::Int16 (*unboxInt16)(int32_t valHandle), - int32_t (*boxUInt16)(uint16_t val), - System::UInt16 (*unboxUInt16)(int32_t valHandle), - int32_t (*boxInt32)(int32_t val), - System::Int32 (*unboxInt32)(int32_t valHandle), - int32_t (*boxUInt32)(uint32_t val), - System::UInt32 (*unboxUInt32)(int32_t valHandle), - int32_t (*boxInt64)(int64_t val), - System::Int64 (*unboxInt64)(int32_t valHandle), - int32_t (*boxUInt64)(uint64_t val), - System::UInt64 (*unboxUInt64)(int32_t valHandle), - int32_t (*boxChar)(uint16_t val), - int16_t (*unboxChar)(int32_t valHandle), - int32_t (*boxSingle)(float val), - System::Single (*unboxSingle)(int32_t valHandle), - int32_t (*boxDouble)(double val), - System::Double (*unboxDouble)(int32_t valHandle) - /*END INIT PARAMS*/) + InitMode initMode) { uint8_t* curMemory = memory; + // Read fixed parameters + Plugin::ReleaseObject = *(void (**)(int32_t handle))curMemory; + curMemory += sizeof(Plugin::ReleaseObject); + Plugin::StringNew = *(int32_t (**)(const char*))curMemory; + curMemory += sizeof(Plugin::StringNew); + Plugin::SetException = *(void (**)(int32_t))curMemory; + curMemory += sizeof(Plugin::SetException); + Plugin::ArrayGetLength = *(int32_t (**)(int32_t))curMemory; + curMemory += sizeof(Plugin::ArrayGetLength); + Plugin::EnumerableGetEnumerator = *(int32_t (**)(int32_t))curMemory; + curMemory += sizeof(Plugin::EnumerableGetEnumerator); + + // Read generated parameters + int32_t maxManagedObjects = *(int32_t*)curMemory; + curMemory += sizeof(int32_t); + /*BEGIN INIT BODY PARAMETER READS*/ + Plugin::ReleaseSystemDecimal = *(void (**)(int32_t handle))curMemory; + curMemory += sizeof(Plugin::ReleaseSystemDecimal); + Plugin::SystemDecimalConstructorSystemDouble = *(int32_t (**)(double value))curMemory; + curMemory += sizeof(Plugin::SystemDecimalConstructorSystemDouble); + Plugin::SystemDecimalConstructorSystemUInt64 = *(int32_t (**)(uint64_t value))curMemory; + curMemory += sizeof(Plugin::SystemDecimalConstructorSystemUInt64); + Plugin::BoxDecimal = *(int32_t (**)(int32_t valHandle))curMemory; + curMemory += sizeof(Plugin::BoxDecimal); + Plugin::UnboxDecimal = *(int32_t (**)(int32_t valHandle))curMemory; + curMemory += sizeof(Plugin::UnboxDecimal); + Plugin::UnityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingle = *(UnityEngine::Vector3 (**)(float x, float y, float z))curMemory; + curMemory += sizeof(Plugin::UnityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingle); + Plugin::UnityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3 = *(UnityEngine::Vector3 (**)(UnityEngine::Vector3& a, UnityEngine::Vector3& b))curMemory; + curMemory += sizeof(Plugin::UnityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3); + Plugin::BoxVector3 = *(int32_t (**)(UnityEngine::Vector3& val))curMemory; + curMemory += sizeof(Plugin::BoxVector3); + Plugin::UnboxVector3 = *(UnityEngine::Vector3 (**)(int32_t valHandle))curMemory; + curMemory += sizeof(Plugin::UnboxVector3); + Plugin::UnityEngineObjectPropertyGetName = *(int32_t (**)(int32_t thisHandle))curMemory; + curMemory += sizeof(Plugin::UnityEngineObjectPropertyGetName); + Plugin::UnityEngineObjectPropertySetName = *(void (**)(int32_t thisHandle, int32_t valueHandle))curMemory; + curMemory += sizeof(Plugin::UnityEngineObjectPropertySetName); + Plugin::UnityEngineComponentPropertyGetTransform = *(int32_t (**)(int32_t thisHandle))curMemory; + curMemory += sizeof(Plugin::UnityEngineComponentPropertyGetTransform); + Plugin::UnityEngineTransformPropertyGetPosition = *(UnityEngine::Vector3 (**)(int32_t thisHandle))curMemory; + curMemory += sizeof(Plugin::UnityEngineTransformPropertyGetPosition); + Plugin::UnityEngineTransformPropertySetPosition = *(void (**)(int32_t thisHandle, UnityEngine::Vector3& value))curMemory; + curMemory += sizeof(Plugin::UnityEngineTransformPropertySetPosition); + Plugin::SystemCollectionsIEnumeratorPropertyGetCurrent = *(int32_t (**)(int32_t thisHandle))curMemory; + curMemory += sizeof(Plugin::SystemCollectionsIEnumeratorPropertyGetCurrent); + Plugin::SystemCollectionsIEnumeratorMethodMoveNext = *(int32_t (**)(int32_t thisHandle))curMemory; + curMemory += sizeof(Plugin::SystemCollectionsIEnumeratorMethodMoveNext); + Plugin::UnityEngineGameObjectMethodAddComponentMyGameBaseBallScript = *(int32_t (**)(int32_t thisHandle))curMemory; + curMemory += sizeof(Plugin::UnityEngineGameObjectMethodAddComponentMyGameBaseBallScript); + Plugin::UnityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveType = *(int32_t (**)(UnityEngine::PrimitiveType type))curMemory; + curMemory += sizeof(Plugin::UnityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveType); + Plugin::UnityEngineDebugMethodLogSystemObject = *(void (**)(int32_t messageHandle))curMemory; + curMemory += sizeof(Plugin::UnityEngineDebugMethodLogSystemObject); + Plugin::UnityEngineMonoBehaviourPropertyGetTransform = *(int32_t (**)(int32_t thisHandle))curMemory; + curMemory += sizeof(Plugin::UnityEngineMonoBehaviourPropertyGetTransform); + Plugin::SystemExceptionConstructorSystemString = *(int32_t (**)(int32_t messageHandle))curMemory; + curMemory += sizeof(Plugin::SystemExceptionConstructorSystemString); + Plugin::BoxPrimitiveType = *(int32_t (**)(UnityEngine::PrimitiveType val))curMemory; + curMemory += sizeof(Plugin::BoxPrimitiveType); + Plugin::UnboxPrimitiveType = *(UnityEngine::PrimitiveType (**)(int32_t valHandle))curMemory; + curMemory += sizeof(Plugin::UnboxPrimitiveType); + Plugin::UnityEngineTimePropertyGetDeltaTime = *(float (**)())curMemory; + curMemory += sizeof(Plugin::UnityEngineTimePropertyGetDeltaTime); + Plugin::ReleaseBaseBallScript = *(void (**)(int32_t handle))curMemory; + curMemory += sizeof(Plugin::ReleaseBaseBallScript); + Plugin::BaseBallScriptConstructor = *(void (**)(int32_t cppHandle, int32_t* handle))curMemory; + curMemory += sizeof(Plugin::BaseBallScriptConstructor); + Plugin::BoxBoolean = *(int32_t (**)(uint32_t val))curMemory; + curMemory += sizeof(Plugin::BoxBoolean); + Plugin::UnboxBoolean = *(int32_t (**)(int32_t valHandle))curMemory; + curMemory += sizeof(Plugin::UnboxBoolean); + Plugin::BoxSByte = *(int32_t (**)(int8_t val))curMemory; + curMemory += sizeof(Plugin::BoxSByte); + Plugin::UnboxSByte = *(int8_t (**)(int32_t valHandle))curMemory; + curMemory += sizeof(Plugin::UnboxSByte); + Plugin::BoxByte = *(int32_t (**)(uint8_t val))curMemory; + curMemory += sizeof(Plugin::BoxByte); + Plugin::UnboxByte = *(uint8_t (**)(int32_t valHandle))curMemory; + curMemory += sizeof(Plugin::UnboxByte); + Plugin::BoxInt16 = *(int32_t (**)(int16_t val))curMemory; + curMemory += sizeof(Plugin::BoxInt16); + Plugin::UnboxInt16 = *(int16_t (**)(int32_t valHandle))curMemory; + curMemory += sizeof(Plugin::UnboxInt16); + Plugin::BoxUInt16 = *(int32_t (**)(uint16_t val))curMemory; + curMemory += sizeof(Plugin::BoxUInt16); + Plugin::UnboxUInt16 = *(uint16_t (**)(int32_t valHandle))curMemory; + curMemory += sizeof(Plugin::UnboxUInt16); + Plugin::BoxInt32 = *(int32_t (**)(int32_t val))curMemory; + curMemory += sizeof(Plugin::BoxInt32); + Plugin::UnboxInt32 = *(int32_t (**)(int32_t valHandle))curMemory; + curMemory += sizeof(Plugin::UnboxInt32); + Plugin::BoxUInt32 = *(int32_t (**)(uint32_t val))curMemory; + curMemory += sizeof(Plugin::BoxUInt32); + Plugin::UnboxUInt32 = *(uint32_t (**)(int32_t valHandle))curMemory; + curMemory += sizeof(Plugin::UnboxUInt32); + Plugin::BoxInt64 = *(int32_t (**)(int64_t val))curMemory; + curMemory += sizeof(Plugin::BoxInt64); + Plugin::UnboxInt64 = *(int64_t (**)(int32_t valHandle))curMemory; + curMemory += sizeof(Plugin::UnboxInt64); + Plugin::BoxUInt64 = *(int32_t (**)(uint64_t val))curMemory; + curMemory += sizeof(Plugin::BoxUInt64); + Plugin::UnboxUInt64 = *(uint64_t (**)(int32_t valHandle))curMemory; + curMemory += sizeof(Plugin::UnboxUInt64); + Plugin::BoxChar = *(int32_t (**)(uint16_t val))curMemory; + curMemory += sizeof(Plugin::BoxChar); + Plugin::UnboxChar = *(int16_t (**)(int32_t valHandle))curMemory; + curMemory += sizeof(Plugin::UnboxChar); + Plugin::BoxSingle = *(int32_t (**)(float val))curMemory; + curMemory += sizeof(Plugin::BoxSingle); + Plugin::UnboxSingle = *(float (**)(int32_t valHandle))curMemory; + curMemory += sizeof(Plugin::UnboxSingle); + Plugin::BoxDouble = *(int32_t (**)(double val))curMemory; + curMemory += sizeof(Plugin::BoxDouble); + Plugin::UnboxDouble = *(double (**)(int32_t valHandle))curMemory; + curMemory += sizeof(Plugin::UnboxDouble); + /*END INIT BODY PARAMETER READS*/ + // Init managed object ref counting Plugin::RefCountsLenClass = maxManagedObjects; Plugin::RefCountsClass = (int32_t*)curMemory; curMemory += maxManagedObjects * sizeof(int32_t); - // Init pointers to C# functions - Plugin::StringNew = stringNew; - Plugin::ReleaseObject = releaseObject; - Plugin::SetException = setException; - Plugin::ArrayGetLength = arrayGetLength; - Plugin::EnumerableGetEnumerator = enumerableGetEnumerator; - /*BEGIN INIT BODY*/ - Plugin::ReleaseSystemDecimal = releaseSystemDecimal; + /*BEGIN INIT BODY ARRAYS*/ Plugin::RefCountsSystemDecimal = (int32_t*)curMemory; curMemory += 1000 * sizeof(int32_t); Plugin::RefCountsLenSystemDecimal = 1000; - Plugin::SystemDecimalConstructorSystemDouble = systemDecimalConstructorSystemDouble; - Plugin::SystemDecimalConstructorSystemUInt64 = systemDecimalConstructorSystemUInt64; - Plugin::BoxDecimal = boxDecimal; - Plugin::UnboxDecimal = unboxDecimal; - Plugin::UnityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingle = unityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingle; - Plugin::UnityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3 = unityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3; - Plugin::BoxVector3 = boxVector3; - Plugin::UnboxVector3 = unboxVector3; - Plugin::UnityEngineObjectPropertyGetName = unityEngineObjectPropertyGetName; - Plugin::UnityEngineObjectPropertySetName = unityEngineObjectPropertySetName; - Plugin::UnityEngineComponentPropertyGetTransform = unityEngineComponentPropertyGetTransform; - Plugin::UnityEngineTransformPropertyGetPosition = unityEngineTransformPropertyGetPosition; - Plugin::UnityEngineTransformPropertySetPosition = unityEngineTransformPropertySetPosition; - Plugin::SystemCollectionsIEnumeratorPropertyGetCurrent = systemCollectionsIEnumeratorPropertyGetCurrent; - Plugin::SystemCollectionsIEnumeratorMethodMoveNext = systemCollectionsIEnumeratorMethodMoveNext; - Plugin::UnityEngineGameObjectMethodAddComponentMyGameBaseBallScript = unityEngineGameObjectMethodAddComponentMyGameBaseBallScript; - Plugin::UnityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveType = unityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveType; - Plugin::UnityEngineDebugMethodLogSystemObject = unityEngineDebugMethodLogSystemObject; - Plugin::UnityEngineMonoBehaviourPropertyGetTransform = unityEngineMonoBehaviourPropertyGetTransform; - Plugin::SystemExceptionConstructorSystemString = systemExceptionConstructorSystemString; - Plugin::BoxPrimitiveType = boxPrimitiveType; - Plugin::UnboxPrimitiveType = unboxPrimitiveType; - Plugin::UnityEngineTimePropertyGetDeltaTime = unityEngineTimePropertyGetDeltaTime; + Plugin::BaseBallScriptFreeListSize = 1000; Plugin::BaseBallScriptFreeList = (MyGame::BaseBallScript**)curMemory; curMemory += 1000 * sizeof(MyGame::BaseBallScript*); - Plugin::ReleaseBaseBallScript = releaseBaseBallScript; - Plugin::BaseBallScriptConstructor = baseBallScriptConstructor; Plugin::BaseBallScriptFreeWholeListSize = 1000; Plugin::BaseBallScriptFreeWholeList = (Plugin::BaseBallScriptFreeWholeListEntry*)curMemory; curMemory += 1000 * sizeof(Plugin::BaseBallScriptFreeWholeListEntry); - - Plugin::BoxBoolean = boxBoolean; - Plugin::UnboxBoolean = unboxBoolean; - Plugin::BoxSByte = boxSByte; - Plugin::UnboxSByte = unboxSByte; - Plugin::BoxByte = boxByte; - Plugin::UnboxByte = unboxByte; - Plugin::BoxInt16 = boxInt16; - Plugin::UnboxInt16 = unboxInt16; - Plugin::BoxUInt16 = boxUInt16; - Plugin::UnboxUInt16 = unboxUInt16; - Plugin::BoxInt32 = boxInt32; - Plugin::UnboxInt32 = unboxInt32; - Plugin::BoxUInt32 = boxUInt32; - Plugin::UnboxUInt32 = unboxUInt32; - Plugin::BoxInt64 = boxInt64; - Plugin::UnboxInt64 = unboxInt64; - Plugin::BoxUInt64 = boxUInt64; - Plugin::UnboxUInt64 = unboxUInt64; - Plugin::BoxChar = boxChar; - Plugin::UnboxChar = unboxChar; - Plugin::BoxSingle = boxSingle; - Plugin::UnboxSingle = unboxSingle; - Plugin::BoxDouble = boxDouble; - Plugin::UnboxDouble = unboxDouble; - /*END INIT BODY*/ + /*END INIT BODY ARRAYS*/ // Make sure there was enough memory int32_t usedMemory = (int32_t)(curMemory - (uint8_t*)memory); @@ -6100,6 +6300,7 @@ DLLEXPORT void Init( if (initMode == InitMode::FirstBoot) { + // Clear memory memset(memory, 0, memorySize); /*BEGIN INIT BODY FIRST BOOT*/ @@ -6112,7 +6313,7 @@ DLLEXPORT void Init( for (int32_t i = 0, end = Plugin::BaseBallScriptFreeWholeListSize - 1; i < end; ++i) { - Plugin::BaseBallScriptFreeWholeList[i].Next = Plugin::BaseBallScriptFreeWholeList[i + 1].Next; + Plugin::BaseBallScriptFreeWholeList[i].Next = Plugin::BaseBallScriptFreeWholeList + i + 1; } Plugin::BaseBallScriptFreeWholeList[Plugin::BaseBallScriptFreeWholeListSize - 1].Next = nullptr; Plugin::NextFreeWholeBaseBallScript = Plugin::BaseBallScriptFreeWholeList + 1; diff --git a/Unity/Assets/CppSource/NativeScript/Bindings.h b/Unity/Assets/CppSource/NativeScript/Bindings.h index e7a25bb..4da12a4 100644 --- a/Unity/Assets/CppSource/NativeScript/Bindings.h +++ b/Unity/Assets/CppSource/NativeScript/Bindings.h @@ -13,6 +13,9 @@ // For int32_t, etc. #include +// For size_t to support placement new and delete +#include + //////////////////////////////////////////////////////////////// // Plugin internals. Do not name these in game code as they may // change without warning. For example: @@ -312,6 +315,17 @@ namespace System struct IComparable; } +namespace System +{ + namespace Runtime + { + namespace Serialization + { + struct IDeserializationCallback; + } + } +} + namespace System { struct Decimal; @@ -489,6 +503,11 @@ namespace System template<> struct IEquatable_1; } +namespace System +{ + template<> struct IEquatable_1; +} + namespace System { template<> struct IComparable_1; @@ -566,7 +585,7 @@ namespace System Object(); Object(Plugin::InternalUse iu, int32_t handle); Object(decltype(nullptr)); - virtual ~Object() = default; + virtual ~Object(); bool operator==(decltype(nullptr)) const; bool operator!=(decltype(nullptr)) const; virtual void ThrowReferenceToThis(); @@ -717,11 +736,11 @@ namespace System { template<> struct IEquatable_1 : virtual System::Object { - IEquatable_1(decltype(nullptr)); - IEquatable_1(Plugin::InternalUse, int32_t handle); - IEquatable_1(const IEquatable_1& other); - IEquatable_1(IEquatable_1&& other); - virtual ~IEquatable_1(); + IEquatable_1(decltype(nullptr)); + IEquatable_1(Plugin::InternalUse, int32_t handle); + IEquatable_1(const IEquatable_1& other); + IEquatable_1(IEquatable_1&& other); + virtual ~IEquatable_1(); IEquatable_1& operator=(const IEquatable_1& other); IEquatable_1& operator=(decltype(nullptr)); IEquatable_1& operator=(IEquatable_1&& other); @@ -734,11 +753,11 @@ namespace System { template<> struct IEquatable_1 : virtual System::Object { - IEquatable_1(decltype(nullptr)); - IEquatable_1(Plugin::InternalUse, int32_t handle); - IEquatable_1(const IEquatable_1& other); - IEquatable_1(IEquatable_1&& other); - virtual ~IEquatable_1(); + IEquatable_1(decltype(nullptr)); + IEquatable_1(Plugin::InternalUse, int32_t handle); + IEquatable_1(const IEquatable_1& other); + IEquatable_1(IEquatable_1&& other); + virtual ~IEquatable_1(); IEquatable_1& operator=(const IEquatable_1& other); IEquatable_1& operator=(decltype(nullptr)); IEquatable_1& operator=(IEquatable_1&& other); @@ -751,11 +770,11 @@ namespace System { template<> struct IEquatable_1 : virtual System::Object { - IEquatable_1(decltype(nullptr)); - IEquatable_1(Plugin::InternalUse, int32_t handle); - IEquatable_1(const IEquatable_1& other); - IEquatable_1(IEquatable_1&& other); - virtual ~IEquatable_1(); + IEquatable_1(decltype(nullptr)); + IEquatable_1(Plugin::InternalUse, int32_t handle); + IEquatable_1(const IEquatable_1& other); + IEquatable_1(IEquatable_1&& other); + virtual ~IEquatable_1(); IEquatable_1& operator=(const IEquatable_1& other); IEquatable_1& operator=(decltype(nullptr)); IEquatable_1& operator=(IEquatable_1&& other); @@ -768,11 +787,11 @@ namespace System { template<> struct IEquatable_1 : virtual System::Object { - IEquatable_1(decltype(nullptr)); - IEquatable_1(Plugin::InternalUse, int32_t handle); - IEquatable_1(const IEquatable_1& other); - IEquatable_1(IEquatable_1&& other); - virtual ~IEquatable_1(); + IEquatable_1(decltype(nullptr)); + IEquatable_1(Plugin::InternalUse, int32_t handle); + IEquatable_1(const IEquatable_1& other); + IEquatable_1(IEquatable_1&& other); + virtual ~IEquatable_1(); IEquatable_1& operator=(const IEquatable_1& other); IEquatable_1& operator=(decltype(nullptr)); IEquatable_1& operator=(IEquatable_1&& other); @@ -785,11 +804,11 @@ namespace System { template<> struct IEquatable_1 : virtual System::Object { - IEquatable_1(decltype(nullptr)); - IEquatable_1(Plugin::InternalUse, int32_t handle); - IEquatable_1(const IEquatable_1& other); - IEquatable_1(IEquatable_1&& other); - virtual ~IEquatable_1(); + IEquatable_1(decltype(nullptr)); + IEquatable_1(Plugin::InternalUse, int32_t handle); + IEquatable_1(const IEquatable_1& other); + IEquatable_1(IEquatable_1&& other); + virtual ~IEquatable_1(); IEquatable_1& operator=(const IEquatable_1& other); IEquatable_1& operator=(decltype(nullptr)); IEquatable_1& operator=(IEquatable_1&& other); @@ -802,11 +821,11 @@ namespace System { template<> struct IEquatable_1 : virtual System::Object { - IEquatable_1(decltype(nullptr)); - IEquatable_1(Plugin::InternalUse, int32_t handle); - IEquatable_1(const IEquatable_1& other); - IEquatable_1(IEquatable_1&& other); - virtual ~IEquatable_1(); + IEquatable_1(decltype(nullptr)); + IEquatable_1(Plugin::InternalUse, int32_t handle); + IEquatable_1(const IEquatable_1& other); + IEquatable_1(IEquatable_1&& other); + virtual ~IEquatable_1(); IEquatable_1& operator=(const IEquatable_1& other); IEquatable_1& operator=(decltype(nullptr)); IEquatable_1& operator=(IEquatable_1&& other); @@ -819,11 +838,11 @@ namespace System { template<> struct IEquatable_1 : virtual System::Object { - IEquatable_1(decltype(nullptr)); - IEquatable_1(Plugin::InternalUse, int32_t handle); - IEquatable_1(const IEquatable_1& other); - IEquatable_1(IEquatable_1&& other); - virtual ~IEquatable_1(); + IEquatable_1(decltype(nullptr)); + IEquatable_1(Plugin::InternalUse, int32_t handle); + IEquatable_1(const IEquatable_1& other); + IEquatable_1(IEquatable_1&& other); + virtual ~IEquatable_1(); IEquatable_1& operator=(const IEquatable_1& other); IEquatable_1& operator=(decltype(nullptr)); IEquatable_1& operator=(IEquatable_1&& other); @@ -836,11 +855,11 @@ namespace System { template<> struct IEquatable_1 : virtual System::Object { - IEquatable_1(decltype(nullptr)); - IEquatable_1(Plugin::InternalUse, int32_t handle); - IEquatable_1(const IEquatable_1& other); - IEquatable_1(IEquatable_1&& other); - virtual ~IEquatable_1(); + IEquatable_1(decltype(nullptr)); + IEquatable_1(Plugin::InternalUse, int32_t handle); + IEquatable_1(const IEquatable_1& other); + IEquatable_1(IEquatable_1&& other); + virtual ~IEquatable_1(); IEquatable_1& operator=(const IEquatable_1& other); IEquatable_1& operator=(decltype(nullptr)); IEquatable_1& operator=(IEquatable_1&& other); @@ -853,11 +872,11 @@ namespace System { template<> struct IEquatable_1 : virtual System::Object { - IEquatable_1(decltype(nullptr)); - IEquatable_1(Plugin::InternalUse, int32_t handle); - IEquatable_1(const IEquatable_1& other); - IEquatable_1(IEquatable_1&& other); - virtual ~IEquatable_1(); + IEquatable_1(decltype(nullptr)); + IEquatable_1(Plugin::InternalUse, int32_t handle); + IEquatable_1(const IEquatable_1& other); + IEquatable_1(IEquatable_1&& other); + virtual ~IEquatable_1(); IEquatable_1& operator=(const IEquatable_1& other); IEquatable_1& operator=(decltype(nullptr)); IEquatable_1& operator=(IEquatable_1&& other); @@ -870,11 +889,11 @@ namespace System { template<> struct IEquatable_1 : virtual System::Object { - IEquatable_1(decltype(nullptr)); - IEquatable_1(Plugin::InternalUse, int32_t handle); - IEquatable_1(const IEquatable_1& other); - IEquatable_1(IEquatable_1&& other); - virtual ~IEquatable_1(); + IEquatable_1(decltype(nullptr)); + IEquatable_1(Plugin::InternalUse, int32_t handle); + IEquatable_1(const IEquatable_1& other); + IEquatable_1(IEquatable_1&& other); + virtual ~IEquatable_1(); IEquatable_1& operator=(const IEquatable_1& other); IEquatable_1& operator=(decltype(nullptr)); IEquatable_1& operator=(IEquatable_1&& other); @@ -887,11 +906,11 @@ namespace System { template<> struct IEquatable_1 : virtual System::Object { - IEquatable_1(decltype(nullptr)); - IEquatable_1(Plugin::InternalUse, int32_t handle); - IEquatable_1(const IEquatable_1& other); - IEquatable_1(IEquatable_1&& other); - virtual ~IEquatable_1(); + IEquatable_1(decltype(nullptr)); + IEquatable_1(Plugin::InternalUse, int32_t handle); + IEquatable_1(const IEquatable_1& other); + IEquatable_1(IEquatable_1&& other); + virtual ~IEquatable_1(); IEquatable_1& operator=(const IEquatable_1& other); IEquatable_1& operator=(decltype(nullptr)); IEquatable_1& operator=(IEquatable_1&& other); @@ -904,11 +923,11 @@ namespace System { template<> struct IEquatable_1 : virtual System::Object { - IEquatable_1(decltype(nullptr)); - IEquatable_1(Plugin::InternalUse, int32_t handle); - IEquatable_1(const IEquatable_1& other); - IEquatable_1(IEquatable_1&& other); - virtual ~IEquatable_1(); + IEquatable_1(decltype(nullptr)); + IEquatable_1(Plugin::InternalUse, int32_t handle); + IEquatable_1(const IEquatable_1& other); + IEquatable_1(IEquatable_1&& other); + virtual ~IEquatable_1(); IEquatable_1& operator=(const IEquatable_1& other); IEquatable_1& operator=(decltype(nullptr)); IEquatable_1& operator=(IEquatable_1&& other); @@ -921,11 +940,11 @@ namespace System { template<> struct IEquatable_1 : virtual System::Object { - IEquatable_1(decltype(nullptr)); - IEquatable_1(Plugin::InternalUse, int32_t handle); - IEquatable_1(const IEquatable_1& other); - IEquatable_1(IEquatable_1&& other); - virtual ~IEquatable_1(); + IEquatable_1(decltype(nullptr)); + IEquatable_1(Plugin::InternalUse, int32_t handle); + IEquatable_1(const IEquatable_1& other); + IEquatable_1(IEquatable_1&& other); + virtual ~IEquatable_1(); IEquatable_1& operator=(const IEquatable_1& other); IEquatable_1& operator=(decltype(nullptr)); IEquatable_1& operator=(IEquatable_1&& other); @@ -934,15 +953,32 @@ namespace System }; } +namespace System +{ + template<> struct IEquatable_1 : virtual System::Object + { + IEquatable_1(decltype(nullptr)); + IEquatable_1(Plugin::InternalUse, int32_t handle); + IEquatable_1(const IEquatable_1& other); + IEquatable_1(IEquatable_1&& other); + virtual ~IEquatable_1(); + IEquatable_1& operator=(const IEquatable_1& other); + IEquatable_1& operator=(decltype(nullptr)); + IEquatable_1& operator=(IEquatable_1&& other); + bool operator==(const IEquatable_1& other) const; + bool operator!=(const IEquatable_1& other) const; + }; +} + namespace System { template<> struct IComparable_1 : virtual System::Object { - IComparable_1(decltype(nullptr)); - IComparable_1(Plugin::InternalUse, int32_t handle); - IComparable_1(const IComparable_1& other); - IComparable_1(IComparable_1&& other); - virtual ~IComparable_1(); + IComparable_1(decltype(nullptr)); + IComparable_1(Plugin::InternalUse, int32_t handle); + IComparable_1(const IComparable_1& other); + IComparable_1(IComparable_1&& other); + virtual ~IComparable_1(); IComparable_1& operator=(const IComparable_1& other); IComparable_1& operator=(decltype(nullptr)); IComparable_1& operator=(IComparable_1&& other); @@ -955,11 +991,11 @@ namespace System { template<> struct IComparable_1 : virtual System::Object { - IComparable_1(decltype(nullptr)); - IComparable_1(Plugin::InternalUse, int32_t handle); - IComparable_1(const IComparable_1& other); - IComparable_1(IComparable_1&& other); - virtual ~IComparable_1(); + IComparable_1(decltype(nullptr)); + IComparable_1(Plugin::InternalUse, int32_t handle); + IComparable_1(const IComparable_1& other); + IComparable_1(IComparable_1&& other); + virtual ~IComparable_1(); IComparable_1& operator=(const IComparable_1& other); IComparable_1& operator=(decltype(nullptr)); IComparable_1& operator=(IComparable_1&& other); @@ -972,11 +1008,11 @@ namespace System { template<> struct IComparable_1 : virtual System::Object { - IComparable_1(decltype(nullptr)); - IComparable_1(Plugin::InternalUse, int32_t handle); - IComparable_1(const IComparable_1& other); - IComparable_1(IComparable_1&& other); - virtual ~IComparable_1(); + IComparable_1(decltype(nullptr)); + IComparable_1(Plugin::InternalUse, int32_t handle); + IComparable_1(const IComparable_1& other); + IComparable_1(IComparable_1&& other); + virtual ~IComparable_1(); IComparable_1& operator=(const IComparable_1& other); IComparable_1& operator=(decltype(nullptr)); IComparable_1& operator=(IComparable_1&& other); @@ -989,11 +1025,11 @@ namespace System { template<> struct IComparable_1 : virtual System::Object { - IComparable_1(decltype(nullptr)); - IComparable_1(Plugin::InternalUse, int32_t handle); - IComparable_1(const IComparable_1& other); - IComparable_1(IComparable_1&& other); - virtual ~IComparable_1(); + IComparable_1(decltype(nullptr)); + IComparable_1(Plugin::InternalUse, int32_t handle); + IComparable_1(const IComparable_1& other); + IComparable_1(IComparable_1&& other); + virtual ~IComparable_1(); IComparable_1& operator=(const IComparable_1& other); IComparable_1& operator=(decltype(nullptr)); IComparable_1& operator=(IComparable_1&& other); @@ -1006,11 +1042,11 @@ namespace System { template<> struct IComparable_1 : virtual System::Object { - IComparable_1(decltype(nullptr)); - IComparable_1(Plugin::InternalUse, int32_t handle); - IComparable_1(const IComparable_1& other); - IComparable_1(IComparable_1&& other); - virtual ~IComparable_1(); + IComparable_1(decltype(nullptr)); + IComparable_1(Plugin::InternalUse, int32_t handle); + IComparable_1(const IComparable_1& other); + IComparable_1(IComparable_1&& other); + virtual ~IComparable_1(); IComparable_1& operator=(const IComparable_1& other); IComparable_1& operator=(decltype(nullptr)); IComparable_1& operator=(IComparable_1&& other); @@ -1023,11 +1059,11 @@ namespace System { template<> struct IComparable_1 : virtual System::Object { - IComparable_1(decltype(nullptr)); - IComparable_1(Plugin::InternalUse, int32_t handle); - IComparable_1(const IComparable_1& other); - IComparable_1(IComparable_1&& other); - virtual ~IComparable_1(); + IComparable_1(decltype(nullptr)); + IComparable_1(Plugin::InternalUse, int32_t handle); + IComparable_1(const IComparable_1& other); + IComparable_1(IComparable_1&& other); + virtual ~IComparable_1(); IComparable_1& operator=(const IComparable_1& other); IComparable_1& operator=(decltype(nullptr)); IComparable_1& operator=(IComparable_1&& other); @@ -1040,11 +1076,11 @@ namespace System { template<> struct IComparable_1 : virtual System::Object { - IComparable_1(decltype(nullptr)); - IComparable_1(Plugin::InternalUse, int32_t handle); - IComparable_1(const IComparable_1& other); - IComparable_1(IComparable_1&& other); - virtual ~IComparable_1(); + IComparable_1(decltype(nullptr)); + IComparable_1(Plugin::InternalUse, int32_t handle); + IComparable_1(const IComparable_1& other); + IComparable_1(IComparable_1&& other); + virtual ~IComparable_1(); IComparable_1& operator=(const IComparable_1& other); IComparable_1& operator=(decltype(nullptr)); IComparable_1& operator=(IComparable_1&& other); @@ -1057,11 +1093,11 @@ namespace System { template<> struct IComparable_1 : virtual System::Object { - IComparable_1(decltype(nullptr)); - IComparable_1(Plugin::InternalUse, int32_t handle); - IComparable_1(const IComparable_1& other); - IComparable_1(IComparable_1&& other); - virtual ~IComparable_1(); + IComparable_1(decltype(nullptr)); + IComparable_1(Plugin::InternalUse, int32_t handle); + IComparable_1(const IComparable_1& other); + IComparable_1(IComparable_1&& other); + virtual ~IComparable_1(); IComparable_1& operator=(const IComparable_1& other); IComparable_1& operator=(decltype(nullptr)); IComparable_1& operator=(IComparable_1&& other); @@ -1074,11 +1110,11 @@ namespace System { template<> struct IComparable_1 : virtual System::Object { - IComparable_1(decltype(nullptr)); - IComparable_1(Plugin::InternalUse, int32_t handle); - IComparable_1(const IComparable_1& other); - IComparable_1(IComparable_1&& other); - virtual ~IComparable_1(); + IComparable_1(decltype(nullptr)); + IComparable_1(Plugin::InternalUse, int32_t handle); + IComparable_1(const IComparable_1& other); + IComparable_1(IComparable_1&& other); + virtual ~IComparable_1(); IComparable_1& operator=(const IComparable_1& other); IComparable_1& operator=(decltype(nullptr)); IComparable_1& operator=(IComparable_1&& other); @@ -1091,11 +1127,11 @@ namespace System { template<> struct IComparable_1 : virtual System::Object { - IComparable_1(decltype(nullptr)); - IComparable_1(Plugin::InternalUse, int32_t handle); - IComparable_1(const IComparable_1& other); - IComparable_1(IComparable_1&& other); - virtual ~IComparable_1(); + IComparable_1(decltype(nullptr)); + IComparable_1(Plugin::InternalUse, int32_t handle); + IComparable_1(const IComparable_1& other); + IComparable_1(IComparable_1&& other); + virtual ~IComparable_1(); IComparable_1& operator=(const IComparable_1& other); IComparable_1& operator=(decltype(nullptr)); IComparable_1& operator=(IComparable_1&& other); @@ -1108,11 +1144,11 @@ namespace System { template<> struct IComparable_1 : virtual System::Object { - IComparable_1(decltype(nullptr)); - IComparable_1(Plugin::InternalUse, int32_t handle); - IComparable_1(const IComparable_1& other); - IComparable_1(IComparable_1&& other); - virtual ~IComparable_1(); + IComparable_1(decltype(nullptr)); + IComparable_1(Plugin::InternalUse, int32_t handle); + IComparable_1(const IComparable_1& other); + IComparable_1(IComparable_1&& other); + virtual ~IComparable_1(); IComparable_1& operator=(const IComparable_1& other); IComparable_1& operator=(decltype(nullptr)); IComparable_1& operator=(IComparable_1&& other); @@ -1125,11 +1161,11 @@ namespace System { template<> struct IComparable_1 : virtual System::Object { - IComparable_1(decltype(nullptr)); - IComparable_1(Plugin::InternalUse, int32_t handle); - IComparable_1(const IComparable_1& other); - IComparable_1(IComparable_1&& other); - virtual ~IComparable_1(); + IComparable_1(decltype(nullptr)); + IComparable_1(Plugin::InternalUse, int32_t handle); + IComparable_1(const IComparable_1& other); + IComparable_1(IComparable_1&& other); + virtual ~IComparable_1(); IComparable_1& operator=(const IComparable_1& other); IComparable_1& operator=(decltype(nullptr)); IComparable_1& operator=(IComparable_1&& other); @@ -1142,11 +1178,11 @@ namespace System { template<> struct IComparable_1 : virtual System::Object { - IComparable_1(decltype(nullptr)); - IComparable_1(Plugin::InternalUse, int32_t handle); - IComparable_1(const IComparable_1& other); - IComparable_1(IComparable_1&& other); - virtual ~IComparable_1(); + IComparable_1(decltype(nullptr)); + IComparable_1(Plugin::InternalUse, int32_t handle); + IComparable_1(const IComparable_1& other); + IComparable_1(IComparable_1&& other); + virtual ~IComparable_1(); IComparable_1& operator=(const IComparable_1& other); IComparable_1& operator=(decltype(nullptr)); IComparable_1& operator=(IComparable_1&& other); @@ -1155,6 +1191,29 @@ namespace System }; } +namespace System +{ + namespace Runtime + { + namespace Serialization + { + struct IDeserializationCallback : virtual System::Object + { + IDeserializationCallback(decltype(nullptr)); + IDeserializationCallback(Plugin::InternalUse, int32_t handle); + IDeserializationCallback(const IDeserializationCallback& other); + IDeserializationCallback(IDeserializationCallback&& other); + virtual ~IDeserializationCallback(); + IDeserializationCallback& operator=(const IDeserializationCallback& other); + IDeserializationCallback& operator=(decltype(nullptr)); + IDeserializationCallback& operator=(IDeserializationCallback&& other); + bool operator==(const IDeserializationCallback& other) const; + bool operator!=(const IDeserializationCallback& other) const; + }; + } + } +} + namespace System { struct Decimal : Plugin::ManagedType @@ -1173,11 +1232,12 @@ namespace System Decimal(System::UInt64 value); explicit operator System::ValueType(); explicit operator System::Object(); - explicit operator System::IFormattable(); - explicit operator System::IConvertible(); explicit operator System::IComparable(); explicit operator System::IComparable_1(); + explicit operator System::IConvertible(); explicit operator System::IEquatable_1(); + explicit operator System::Runtime::Serialization::IDeserializationCallback(); + explicit operator System::IFormattable(); }; } @@ -1193,6 +1253,7 @@ namespace UnityEngine UnityEngine::Vector3 operator+(UnityEngine::Vector3& a); explicit operator System::ValueType(); explicit operator System::Object(); + explicit operator System::IEquatable_1(); }; } @@ -1462,9 +1523,9 @@ namespace UnityEngine explicit operator System::Enum(); explicit operator System::ValueType(); explicit operator System::Object(); - explicit operator System::IFormattable(); - explicit operator System::IConvertible(); explicit operator System::IComparable(); + explicit operator System::IConvertible(); + explicit operator System::IFormattable(); }; } @@ -1527,7 +1588,7 @@ namespace MyGame /*BEGIN MACROS*/ #define MY_GAME_BALL_SCRIPT_DEFAULT_CONSTRUCTOR_DECLARATION \ BallScript(Plugin::InternalUse iu, int32_t handle); - + #define MY_GAME_BALL_SCRIPT_DEFAULT_CONSTRUCTOR_DEFINITION \ BallScript::BallScript(Plugin::InternalUse iu, int32_t handle) \ : UnityEngine::Object(nullptr) \ @@ -1535,7 +1596,10 @@ namespace MyGame , UnityEngine::Behaviour(nullptr) \ , UnityEngine::MonoBehaviour(nullptr) \ , MyGame::AbstractBaseBallScript(nullptr) \ - , MyGame::BaseBallScript(iu, handle) + , MyGame::BaseBallScript(iu, handle) \ + { \ + } + #define MY_GAME_BALL_SCRIPT_DEFAULT_CONSTRUCTOR \ BallScript(Plugin::InternalUse iu, int32_t handle) \ : UnityEngine::Object(nullptr) \ @@ -1545,7 +1609,29 @@ namespace MyGame , MyGame::AbstractBaseBallScript(nullptr) \ , MyGame::BaseBallScript(iu, handle) \ { \ + } + +#define MY_GAME_BALL_SCRIPT_DEFAULT_CONTENTS_DECLARATION \ + void* operator new(size_t, void* p) noexcept; \ + void operator delete(void*, size_t) noexcept; \ + +#define MY_GAME_BALL_SCRIPT_DEFAULT_CONTENTS_DEFINITION \ + void* BallScript::operator new(size_t, void* p) noexcept\ + { \ + return p; \ } \ + void BallScript::operator delete(void*, size_t) noexcept \ + { \ + } + +#define MY_GAME_BALL_SCRIPT_DEFAULT_CONTENTS\ + void* operator new(size_t, void* p) noexcept \ + { \ + return p; \ + } \ + void operator delete(void*, size_t) noexcept \ + { \ + } /*END MACROS*/ //////////////////////////////////////////////////////////////// diff --git a/Unity/Assets/NativeScript/Bindings.cs b/Unity/Assets/NativeScript/Bindings.cs index 248ee00..3ae570d 100644 --- a/Unity/Assets/NativeScript/Bindings.cs +++ b/Unity/Assets/NativeScript/Bindings.cs @@ -4,6 +4,7 @@ using System.Collections; using System.IO; using System.Runtime.InteropServices; +using System.Collections.Generic; using UnityEngine; @@ -24,25 +25,25 @@ public static class Bindings // Holds objects and provides handles to them in the form of ints public static class ObjectStore { + // Lookup handles by object. + static Dictionary objectHandleCache; + // Stored objects. The first is never used so 0 can be "null". static object[] objects; - - // Stack of available handles + + // Stack of available handles. static int[] handles; - - // Hash table of stored objects to their handles. - static object[] keys; - static int[] values; - + // Index of the next available handle static int nextHandleIndex; - + // The maximum number of objects to store. Must be positive. static int maxObjects; public static void Init(int maxObjects) { ObjectStore.maxObjects = maxObjects; + objectHandleCache = new Dictionary(maxObjects); // Initialize the objects as all null plus room for the // first to always be null. @@ -58,10 +59,6 @@ public static void Init(int maxObjects) handles[i] = handle; } nextHandleIndex = maxObjects - 1; - - // Initialize the hash table - keys = new object[maxObjects]; - values = new int[maxObjects]; } public static int Store(object obj) @@ -80,22 +77,7 @@ public static int Store(object obj) // Store the object objects[handle] = obj; - - // Insert into the hash table - int initialIndex = (int)( - ((uint)obj.GetHashCode()) % maxObjects); - int index = initialIndex; - do - { - if (object.ReferenceEquals(keys[index], null)) - { - keys[index] = obj; - values[index] = handle; - break; - } - index = (index + 1) % maxObjects; - } - while (index != initialIndex); + objectHandleCache.Add(obj, handle); return handle; } @@ -116,19 +98,13 @@ public static int GetHandle(object obj) lock (objects) { - // Look up the object in the hash table - int initialIndex = (int)( - ((uint)obj.GetHashCode()) % maxObjects); - int index = initialIndex; - do + int handle; + + // Get handle from object cache + if (objectHandleCache.TryGetValue(obj, out handle)) { - if (object.ReferenceEquals(keys[index], obj)) - { - return values[index]; - } - index = (index + 1) % maxObjects; + return handle; } - while (index != initialIndex); } // Object not found @@ -152,26 +128,9 @@ public static object Remove(int handle) // Push the handle onto the stack nextHandleIndex++; handles[nextHandleIndex] = handle; - - // Remove the object from the hash table - int initialIndex = (int)( - ((uint)obj.GetHashCode()) % maxObjects); - int index = initialIndex; - do - { - if (object.ReferenceEquals(keys[index], obj)) - { - // Only the key needs to be removed (set to null) - // because values corresponding to null will never - // be read and the values are just integers, so - // we're not holding on to a managed reference that - // will prevent GC. - keys[index] = null; - break; - } - index = (index + 1) % maxObjects; - } - while (index != initialIndex); + + // Remove the object from the cache + objectHandleCache.Remove(obj); return obj; } @@ -327,105 +286,53 @@ enum InitMode : byte // Handle to the C++ DLL static IntPtr libraryHandle; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] delegate void InitDelegate( IntPtr memory, int memorySize, - InitMode initMode, - IntPtr releaseObject, - IntPtr stringNew, - IntPtr setException, - IntPtr arrayGetLength, - IntPtr enumerableGetEnumerator, - /*BEGIN INIT PARAMS*/ - int maxManagedObjects, - IntPtr releaseSystemDecimal, - IntPtr systemDecimalConstructorSystemDouble, - IntPtr systemDecimalConstructorSystemUInt64, - IntPtr boxDecimal, - IntPtr unboxDecimal, - IntPtr unityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingle, - IntPtr unityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3, - IntPtr boxVector3, - IntPtr unboxVector3, - IntPtr unityEngineObjectPropertyGetName, - IntPtr unityEngineObjectPropertySetName, - IntPtr unityEngineComponentPropertyGetTransform, - IntPtr unityEngineTransformPropertyGetPosition, - IntPtr unityEngineTransformPropertySetPosition, - IntPtr systemCollectionsIEnumeratorPropertyGetCurrent, - IntPtr systemCollectionsIEnumeratorMethodMoveNext, - IntPtr unityEngineGameObjectMethodAddComponentMyGameBaseBallScript, - IntPtr unityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveType, - IntPtr unityEngineDebugMethodLogSystemObject, - IntPtr unityEngineMonoBehaviourPropertyGetTransform, - IntPtr systemExceptionConstructorSystemString, - IntPtr boxPrimitiveType, - IntPtr unboxPrimitiveType, - IntPtr unityEngineTimePropertyGetDeltaTime, - IntPtr releaseBaseBallScript, - IntPtr baseBallScriptConstructor, - IntPtr boxBoolean, - IntPtr unboxBoolean, - IntPtr boxSByte, - IntPtr unboxSByte, - IntPtr boxByte, - IntPtr unboxByte, - IntPtr boxInt16, - IntPtr unboxInt16, - IntPtr boxUInt16, - IntPtr unboxUInt16, - IntPtr boxInt32, - IntPtr unboxInt32, - IntPtr boxUInt32, - IntPtr unboxUInt32, - IntPtr boxInt64, - IntPtr unboxInt64, - IntPtr boxUInt64, - IntPtr unboxUInt64, - IntPtr boxChar, - IntPtr unboxChar, - IntPtr boxSingle, - IntPtr unboxSingle, - IntPtr boxDouble, - IntPtr unboxDouble - /*END INIT PARAMS*/); + InitMode initMode); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void SetCsharpExceptionDelegate(int handle); - /*BEGIN DELEGATES*/ - public delegate int NewBaseBallScriptDelegate(int param0); - public static NewBaseBallScriptDelegate NewBaseBallScript; + /*BEGIN CPP DELEGATES*/ + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate int NewBaseBallScriptDelegateType(int param0); + public static NewBaseBallScriptDelegateType NewBaseBallScript; - public delegate void DestroyBaseBallScriptDelegate(int param0); - public static DestroyBaseBallScriptDelegate DestroyBaseBallScript; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate void DestroyBaseBallScriptDelegateType(int param0); + public static DestroyBaseBallScriptDelegateType DestroyBaseBallScript; - public delegate void MyGameAbstractBaseBallScriptUpdateDelegate(int thisHandle); - public static MyGameAbstractBaseBallScriptUpdateDelegate MyGameAbstractBaseBallScriptUpdate; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate void MyGameAbstractBaseBallScriptUpdateDelegateType(int thisHandle); + public static MyGameAbstractBaseBallScriptUpdateDelegateType MyGameAbstractBaseBallScriptUpdate; - public delegate void SetCsharpExceptionSystemNullReferenceExceptionDelegate(int param0); - public static SetCsharpExceptionSystemNullReferenceExceptionDelegate SetCsharpExceptionSystemNullReferenceException; - /*END DELEGATES*/ + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate void SetCsharpExceptionSystemNullReferenceExceptionDelegateType(int param0); + public static SetCsharpExceptionSystemNullReferenceExceptionDelegateType SetCsharpExceptionSystemNullReferenceException; + /*END CPP DELEGATES*/ #endif #if UNITY_EDITOR_OSX || UNITY_EDITOR_LINUX - [DllImport("__Internal")] + [DllImport("__Internal", CallingConvention = CallingConvention.Cdecl)] static extern IntPtr dlopen( string path, int flag); - [DllImport("__Internal")] + [DllImport("__Internal", CallingConvention = CallingConvention.Cdecl)] static extern IntPtr dlsym( IntPtr handle, string symbolName); - [DllImport("__Internal")] + [DllImport("__Internal", CallingConvention = CallingConvention.Cdecl)] static extern int dlclose( IntPtr handle); static IntPtr OpenLibrary( string path) { - IntPtr handle = dlopen(path, 0); + IntPtr handle = dlopen(path, 1); // 1 = lazy, 2 = now if (handle == IntPtr.Zero) { throw new Exception("Couldn't open native library: " + path); @@ -453,16 +360,16 @@ static T GetDelegate( typeof(T)) as T; } #elif UNITY_EDITOR_WIN - [DllImport("kernel32")] + [DllImport("kernel32", SetLastError=true, CharSet = CharSet.Ansi)] static extern IntPtr LoadLibrary( string path); - [DllImport("kernel32")] + [DllImport("kernel32", CharSet=CharSet.Ansi, ExactSpelling=true, SetLastError=true)] static extern IntPtr GetProcAddress( IntPtr libraryHandle, string symbolName); - [DllImport("kernel32")] + [DllImport("kernel32.dll", SetLastError=true)] static extern bool FreeLibrary( IntPtr libraryHandle); @@ -495,145 +402,146 @@ static T GetDelegate( typeof(T)) as T; } #else - [DllImport(PLUGIN_NAME)] + [DllImport(PLUGIN_NAME, CallingConvention = CallingConvention.Cdecl)] static extern void Init( IntPtr memory, int memorySize, - InitMode initMode, - IntPtr releaseObject, - IntPtr stringNew, - IntPtr setException, - IntPtr arrayGetLength, - IntPtr enumerableGetEnumerator, - /*BEGIN INIT PARAMS*/ - int maxManagedObjects, - IntPtr releaseSystemDecimal, - IntPtr systemDecimalConstructorSystemDouble, - IntPtr systemDecimalConstructorSystemUInt64, - IntPtr boxDecimal, - IntPtr unboxDecimal, - IntPtr unityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingle, - IntPtr unityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3, - IntPtr boxVector3, - IntPtr unboxVector3, - IntPtr unityEngineObjectPropertyGetName, - IntPtr unityEngineObjectPropertySetName, - IntPtr unityEngineComponentPropertyGetTransform, - IntPtr unityEngineTransformPropertyGetPosition, - IntPtr unityEngineTransformPropertySetPosition, - IntPtr systemCollectionsIEnumeratorPropertyGetCurrent, - IntPtr systemCollectionsIEnumeratorMethodMoveNext, - IntPtr unityEngineGameObjectMethodAddComponentMyGameBaseBallScript, - IntPtr unityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveType, - IntPtr unityEngineDebugMethodLogSystemObject, - IntPtr unityEngineMonoBehaviourPropertyGetTransform, - IntPtr systemExceptionConstructorSystemString, - IntPtr boxPrimitiveType, - IntPtr unboxPrimitiveType, - IntPtr unityEngineTimePropertyGetDeltaTime, - IntPtr releaseBaseBallScript, - IntPtr baseBallScriptConstructor, - IntPtr boxBoolean, - IntPtr unboxBoolean, - IntPtr boxSByte, - IntPtr unboxSByte, - IntPtr boxByte, - IntPtr unboxByte, - IntPtr boxInt16, - IntPtr unboxInt16, - IntPtr boxUInt16, - IntPtr unboxUInt16, - IntPtr boxInt32, - IntPtr unboxInt32, - IntPtr boxUInt32, - IntPtr unboxUInt32, - IntPtr boxInt64, - IntPtr unboxInt64, - IntPtr boxUInt64, - IntPtr unboxUInt64, - IntPtr boxChar, - IntPtr unboxChar, - IntPtr boxSingle, - IntPtr unboxSingle, - IntPtr boxDouble, - IntPtr unboxDouble - /*END INIT PARAMS*/); - - [DllImport(PLUGIN_NAME)] + InitMode initMode); + + [DllImport(PLUGIN_NAME, CallingConvention = CallingConvention.Cdecl)] static extern void SetCsharpException(int handle); /*BEGIN IMPORTS*/ - [DllImport(PLUGIN_NAME)] + [DllImport(PLUGIN_NAME, CallingConvention = CallingConvention.Cdecl)] public static extern int NewBaseBallScript(int thisHandle); - [DllImport(PLUGIN_NAME)] + [DllImport(PLUGIN_NAME, CallingConvention = CallingConvention.Cdecl)] public static extern void DestroyBaseBallScript(int thisHandle); - [DllImport(PLUGIN_NAME)] + [DllImport(PLUGIN_NAME, CallingConvention = CallingConvention.Cdecl)] public static extern void MyGameAbstractBaseBallScriptUpdate(int thisHandle); - [DllImport(PLUGIN_NAME)] + [DllImport(PLUGIN_NAME, CallingConvention = CallingConvention.Cdecl)] public static extern void SetCsharpExceptionSystemNullReferenceException(int thisHandle); /*END IMPORTS*/ #endif - delegate void ReleaseObjectDelegate(int handle); - delegate int StringNewDelegate(string chars); - delegate void SetExceptionDelegate(int handle); - delegate int ArrayGetLengthDelegate(int handle); - delegate int EnumerableGetEnumeratorDelegate(int handle); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate void ReleaseObjectDelegateType(int handle); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate int StringNewDelegateType(string chars); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate void SetExceptionDelegateType(int handle); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate int ArrayGetLengthDelegateType(int handle); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate int EnumerableGetEnumeratorDelegateType(int handle); /*BEGIN DELEGATE TYPES*/ - delegate void ReleaseSystemDecimalDelegate(int handle); - delegate int SystemDecimalConstructorSystemDoubleDelegate(double value); - delegate int SystemDecimalConstructorSystemUInt64Delegate(ulong value); - delegate int BoxDecimalDelegate(int valHandle); - delegate int UnboxDecimalDelegate(int valHandle); - delegate UnityEngine.Vector3 UnityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingleDelegate(float x, float y, float z); - delegate UnityEngine.Vector3 UnityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3Delegate(ref UnityEngine.Vector3 a, ref UnityEngine.Vector3 b); - delegate int BoxVector3Delegate(ref UnityEngine.Vector3 val); - delegate UnityEngine.Vector3 UnboxVector3Delegate(int valHandle); - delegate int UnityEngineObjectPropertyGetNameDelegate(int thisHandle); - delegate void UnityEngineObjectPropertySetNameDelegate(int thisHandle, int valueHandle); - delegate int UnityEngineComponentPropertyGetTransformDelegate(int thisHandle); - delegate UnityEngine.Vector3 UnityEngineTransformPropertyGetPositionDelegate(int thisHandle); - delegate void UnityEngineTransformPropertySetPositionDelegate(int thisHandle, ref UnityEngine.Vector3 value); - delegate int SystemCollectionsIEnumeratorPropertyGetCurrentDelegate(int thisHandle); - delegate bool SystemCollectionsIEnumeratorMethodMoveNextDelegate(int thisHandle); - delegate int UnityEngineGameObjectMethodAddComponentMyGameBaseBallScriptDelegate(int thisHandle); - delegate int UnityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveTypeDelegate(UnityEngine.PrimitiveType type); - delegate void UnityEngineDebugMethodLogSystemObjectDelegate(int messageHandle); - delegate int UnityEngineMonoBehaviourPropertyGetTransformDelegate(int thisHandle); - delegate int SystemExceptionConstructorSystemStringDelegate(int messageHandle); - delegate int BoxPrimitiveTypeDelegate(UnityEngine.PrimitiveType val); - delegate UnityEngine.PrimitiveType UnboxPrimitiveTypeDelegate(int valHandle); - delegate float UnityEngineTimePropertyGetDeltaTimeDelegate(); - delegate void BaseBallScriptConstructorDelegate(int cppHandle, ref int handle); - delegate void ReleaseBaseBallScriptDelegate(int handle); - delegate int BoxBooleanDelegate(bool val); - delegate bool UnboxBooleanDelegate(int valHandle); - delegate int BoxSByteDelegate(sbyte val); - delegate sbyte UnboxSByteDelegate(int valHandle); - delegate int BoxByteDelegate(byte val); - delegate byte UnboxByteDelegate(int valHandle); - delegate int BoxInt16Delegate(short val); - delegate short UnboxInt16Delegate(int valHandle); - delegate int BoxUInt16Delegate(ushort val); - delegate ushort UnboxUInt16Delegate(int valHandle); - delegate int BoxInt32Delegate(int val); - delegate int UnboxInt32Delegate(int valHandle); - delegate int BoxUInt32Delegate(uint val); - delegate uint UnboxUInt32Delegate(int valHandle); - delegate int BoxInt64Delegate(long val); - delegate long UnboxInt64Delegate(int valHandle); - delegate int BoxUInt64Delegate(ulong val); - delegate ulong UnboxUInt64Delegate(int valHandle); - delegate int BoxCharDelegate(char val); - delegate char UnboxCharDelegate(int valHandle); - delegate int BoxSingleDelegate(float val); - delegate float UnboxSingleDelegate(int valHandle); - delegate int BoxDoubleDelegate(double val); - delegate double UnboxDoubleDelegate(int valHandle); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate void ReleaseSystemDecimalDelegateType(int handle); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate int SystemDecimalConstructorSystemDoubleDelegateType(double value); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate int SystemDecimalConstructorSystemUInt64DelegateType(ulong value); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate int BoxDecimalDelegateType(int valHandle); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate int UnboxDecimalDelegateType(int valHandle); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate UnityEngine.Vector3 UnityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingleDelegateType(float x, float y, float z); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate UnityEngine.Vector3 UnityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3DelegateType(ref UnityEngine.Vector3 a, ref UnityEngine.Vector3 b); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate int BoxVector3DelegateType(ref UnityEngine.Vector3 val); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate UnityEngine.Vector3 UnboxVector3DelegateType(int valHandle); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate int UnityEngineObjectPropertyGetNameDelegateType(int thisHandle); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate void UnityEngineObjectPropertySetNameDelegateType(int thisHandle, int valueHandle); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate int UnityEngineComponentPropertyGetTransformDelegateType(int thisHandle); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate UnityEngine.Vector3 UnityEngineTransformPropertyGetPositionDelegateType(int thisHandle); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate void UnityEngineTransformPropertySetPositionDelegateType(int thisHandle, ref UnityEngine.Vector3 value); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate int SystemCollectionsIEnumeratorPropertyGetCurrentDelegateType(int thisHandle); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate bool SystemCollectionsIEnumeratorMethodMoveNextDelegateType(int thisHandle); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate int UnityEngineGameObjectMethodAddComponentMyGameBaseBallScriptDelegateType(int thisHandle); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate int UnityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveTypeDelegateType(UnityEngine.PrimitiveType type); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate void UnityEngineDebugMethodLogSystemObjectDelegateType(int messageHandle); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate int UnityEngineMonoBehaviourPropertyGetTransformDelegateType(int thisHandle); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate int SystemExceptionConstructorSystemStringDelegateType(int messageHandle); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate int BoxPrimitiveTypeDelegateType(UnityEngine.PrimitiveType val); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate UnityEngine.PrimitiveType UnboxPrimitiveTypeDelegateType(int valHandle); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate float UnityEngineTimePropertyGetDeltaTimeDelegateType(); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate void BaseBallScriptConstructorDelegateType(int cppHandle, ref int handle); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate void ReleaseBaseBallScriptDelegateType(int handle); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate int BoxBooleanDelegateType(bool val); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate bool UnboxBooleanDelegateType(int valHandle); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate int BoxSByteDelegateType(sbyte val); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate sbyte UnboxSByteDelegateType(int valHandle); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate int BoxByteDelegateType(byte val); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate byte UnboxByteDelegateType(int valHandle); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate int BoxInt16DelegateType(short val); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate short UnboxInt16DelegateType(int valHandle); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate int BoxUInt16DelegateType(ushort val); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate ushort UnboxUInt16DelegateType(int valHandle); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate int BoxInt32DelegateType(int val); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate int UnboxInt32DelegateType(int valHandle); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate int BoxUInt32DelegateType(uint val); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate uint UnboxUInt32DelegateType(int valHandle); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate int BoxInt64DelegateType(long val); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate long UnboxInt64DelegateType(int valHandle); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate int BoxUInt64DelegateType(ulong val); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate ulong UnboxUInt64DelegateType(int valHandle); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate int BoxCharDelegateType(char val); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate char UnboxCharDelegateType(int valHandle); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate int BoxSingleDelegateType(float val); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate float UnboxSingleDelegateType(int valHandle); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate int BoxDoubleDelegateType(double val); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate double UnboxDoubleDelegateType(int valHandle); /*END DELEGATE TYPES*/ #if UNITY_EDITOR_WIN @@ -651,6 +559,67 @@ IntPtr unboxDouble static int destroyQueueCapacity; static object destroyQueueLockObj; + // Fixed delegates + static readonly ReleaseObjectDelegateType ReleaseObjectDelegate = new ReleaseObjectDelegateType(ReleaseObject); + static readonly StringNewDelegateType StringNewDelegate = new StringNewDelegateType(StringNew); + static readonly SetExceptionDelegateType SetExceptionDelegate = new SetExceptionDelegateType(SetException); + static readonly ArrayGetLengthDelegateType ArrayGetLengthDelegate = new ArrayGetLengthDelegateType(ArrayGetLength); + static readonly EnumerableGetEnumeratorDelegateType EnumerableGetEnumeratorDelegate = new EnumerableGetEnumeratorDelegateType(EnumerableGetEnumerator); + + // Generated delegates + /*BEGIN CSHARP DELEGATES*/ + static readonly ReleaseSystemDecimalDelegateType ReleaseSystemDecimalDelegate = new ReleaseSystemDecimalDelegateType(ReleaseSystemDecimal); + static readonly SystemDecimalConstructorSystemDoubleDelegateType SystemDecimalConstructorSystemDoubleDelegate = new SystemDecimalConstructorSystemDoubleDelegateType(SystemDecimalConstructorSystemDouble); + static readonly SystemDecimalConstructorSystemUInt64DelegateType SystemDecimalConstructorSystemUInt64Delegate = new SystemDecimalConstructorSystemUInt64DelegateType(SystemDecimalConstructorSystemUInt64); + static readonly BoxDecimalDelegateType BoxDecimalDelegate = new BoxDecimalDelegateType(BoxDecimal); + static readonly UnboxDecimalDelegateType UnboxDecimalDelegate = new UnboxDecimalDelegateType(UnboxDecimal); + static readonly UnityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingleDelegateType UnityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingleDelegate = new UnityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingleDelegateType(UnityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingle); + static readonly UnityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3DelegateType UnityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3Delegate = new UnityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3DelegateType(UnityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3); + static readonly BoxVector3DelegateType BoxVector3Delegate = new BoxVector3DelegateType(BoxVector3); + static readonly UnboxVector3DelegateType UnboxVector3Delegate = new UnboxVector3DelegateType(UnboxVector3); + static readonly UnityEngineObjectPropertyGetNameDelegateType UnityEngineObjectPropertyGetNameDelegate = new UnityEngineObjectPropertyGetNameDelegateType(UnityEngineObjectPropertyGetName); + static readonly UnityEngineObjectPropertySetNameDelegateType UnityEngineObjectPropertySetNameDelegate = new UnityEngineObjectPropertySetNameDelegateType(UnityEngineObjectPropertySetName); + static readonly UnityEngineComponentPropertyGetTransformDelegateType UnityEngineComponentPropertyGetTransformDelegate = new UnityEngineComponentPropertyGetTransformDelegateType(UnityEngineComponentPropertyGetTransform); + static readonly UnityEngineTransformPropertyGetPositionDelegateType UnityEngineTransformPropertyGetPositionDelegate = new UnityEngineTransformPropertyGetPositionDelegateType(UnityEngineTransformPropertyGetPosition); + static readonly UnityEngineTransformPropertySetPositionDelegateType UnityEngineTransformPropertySetPositionDelegate = new UnityEngineTransformPropertySetPositionDelegateType(UnityEngineTransformPropertySetPosition); + static readonly SystemCollectionsIEnumeratorPropertyGetCurrentDelegateType SystemCollectionsIEnumeratorPropertyGetCurrentDelegate = new SystemCollectionsIEnumeratorPropertyGetCurrentDelegateType(SystemCollectionsIEnumeratorPropertyGetCurrent); + static readonly SystemCollectionsIEnumeratorMethodMoveNextDelegateType SystemCollectionsIEnumeratorMethodMoveNextDelegate = new SystemCollectionsIEnumeratorMethodMoveNextDelegateType(SystemCollectionsIEnumeratorMethodMoveNext); + static readonly UnityEngineGameObjectMethodAddComponentMyGameBaseBallScriptDelegateType UnityEngineGameObjectMethodAddComponentMyGameBaseBallScriptDelegate = new UnityEngineGameObjectMethodAddComponentMyGameBaseBallScriptDelegateType(UnityEngineGameObjectMethodAddComponentMyGameBaseBallScript); + static readonly UnityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveTypeDelegateType UnityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveTypeDelegate = new UnityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveTypeDelegateType(UnityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveType); + static readonly UnityEngineDebugMethodLogSystemObjectDelegateType UnityEngineDebugMethodLogSystemObjectDelegate = new UnityEngineDebugMethodLogSystemObjectDelegateType(UnityEngineDebugMethodLogSystemObject); + static readonly UnityEngineMonoBehaviourPropertyGetTransformDelegateType UnityEngineMonoBehaviourPropertyGetTransformDelegate = new UnityEngineMonoBehaviourPropertyGetTransformDelegateType(UnityEngineMonoBehaviourPropertyGetTransform); + static readonly SystemExceptionConstructorSystemStringDelegateType SystemExceptionConstructorSystemStringDelegate = new SystemExceptionConstructorSystemStringDelegateType(SystemExceptionConstructorSystemString); + static readonly BoxPrimitiveTypeDelegateType BoxPrimitiveTypeDelegate = new BoxPrimitiveTypeDelegateType(BoxPrimitiveType); + static readonly UnboxPrimitiveTypeDelegateType UnboxPrimitiveTypeDelegate = new UnboxPrimitiveTypeDelegateType(UnboxPrimitiveType); + static readonly UnityEngineTimePropertyGetDeltaTimeDelegateType UnityEngineTimePropertyGetDeltaTimeDelegate = new UnityEngineTimePropertyGetDeltaTimeDelegateType(UnityEngineTimePropertyGetDeltaTime); + static readonly ReleaseBaseBallScriptDelegateType ReleaseBaseBallScriptDelegate = new ReleaseBaseBallScriptDelegateType(ReleaseBaseBallScript); + static readonly BaseBallScriptConstructorDelegateType BaseBallScriptConstructorDelegate = new BaseBallScriptConstructorDelegateType(BaseBallScriptConstructor); + static readonly BoxBooleanDelegateType BoxBooleanDelegate = new BoxBooleanDelegateType(BoxBoolean); + static readonly UnboxBooleanDelegateType UnboxBooleanDelegate = new UnboxBooleanDelegateType(UnboxBoolean); + static readonly BoxSByteDelegateType BoxSByteDelegate = new BoxSByteDelegateType(BoxSByte); + static readonly UnboxSByteDelegateType UnboxSByteDelegate = new UnboxSByteDelegateType(UnboxSByte); + static readonly BoxByteDelegateType BoxByteDelegate = new BoxByteDelegateType(BoxByte); + static readonly UnboxByteDelegateType UnboxByteDelegate = new UnboxByteDelegateType(UnboxByte); + static readonly BoxInt16DelegateType BoxInt16Delegate = new BoxInt16DelegateType(BoxInt16); + static readonly UnboxInt16DelegateType UnboxInt16Delegate = new UnboxInt16DelegateType(UnboxInt16); + static readonly BoxUInt16DelegateType BoxUInt16Delegate = new BoxUInt16DelegateType(BoxUInt16); + static readonly UnboxUInt16DelegateType UnboxUInt16Delegate = new UnboxUInt16DelegateType(UnboxUInt16); + static readonly BoxInt32DelegateType BoxInt32Delegate = new BoxInt32DelegateType(BoxInt32); + static readonly UnboxInt32DelegateType UnboxInt32Delegate = new UnboxInt32DelegateType(UnboxInt32); + static readonly BoxUInt32DelegateType BoxUInt32Delegate = new BoxUInt32DelegateType(BoxUInt32); + static readonly UnboxUInt32DelegateType UnboxUInt32Delegate = new UnboxUInt32DelegateType(UnboxUInt32); + static readonly BoxInt64DelegateType BoxInt64Delegate = new BoxInt64DelegateType(BoxInt64); + static readonly UnboxInt64DelegateType UnboxInt64Delegate = new UnboxInt64DelegateType(UnboxInt64); + static readonly BoxUInt64DelegateType BoxUInt64Delegate = new BoxUInt64DelegateType(BoxUInt64); + static readonly UnboxUInt64DelegateType UnboxUInt64Delegate = new UnboxUInt64DelegateType(UnboxUInt64); + static readonly BoxCharDelegateType BoxCharDelegate = new BoxCharDelegateType(BoxChar); + static readonly UnboxCharDelegateType UnboxCharDelegate = new UnboxCharDelegateType(UnboxChar); + static readonly BoxSingleDelegateType BoxSingleDelegate = new BoxSingleDelegateType(BoxSingle); + static readonly UnboxSingleDelegateType UnboxSingleDelegate = new UnboxSingleDelegateType(UnboxSingle); + static readonly BoxDoubleDelegateType BoxDoubleDelegate = new BoxDoubleDelegateType(BoxDouble); + static readonly UnboxDoubleDelegateType UnboxDoubleDelegate = new UnboxDoubleDelegateType(UnboxDouble); + /*END CSHARP DELEGATES*/ + /// /// Open the C++ plugin and call its PluginMain() /// @@ -734,7 +703,7 @@ private static void OpenPlugin(InitMode initMode) string loadPath; #if UNITY_EDITOR_WIN // Copy native library to temporary file - File.Copy(pluginPath, pluginTempPath); + File.Copy(pluginPath, pluginTempPath, true); loadPath = pluginTempPath; #else loadPath = pluginPath; @@ -748,76 +717,147 @@ private static void OpenPlugin(InitMode initMode) libraryHandle, "SetCsharpException"); /*BEGIN GETDELEGATE CALLS*/ - NewBaseBallScript = GetDelegate(libraryHandle, "NewBaseBallScript"); - DestroyBaseBallScript = GetDelegate(libraryHandle, "DestroyBaseBallScript"); - MyGameAbstractBaseBallScriptUpdate = GetDelegate(libraryHandle, "MyGameAbstractBaseBallScriptUpdate"); - SetCsharpExceptionSystemNullReferenceException = GetDelegate(libraryHandle, "SetCsharpExceptionSystemNullReferenceException"); + NewBaseBallScript = GetDelegate(libraryHandle, "NewBaseBallScript"); + DestroyBaseBallScript = GetDelegate(libraryHandle, "DestroyBaseBallScript"); + MyGameAbstractBaseBallScriptUpdate = GetDelegate(libraryHandle, "MyGameAbstractBaseBallScriptUpdate"); + SetCsharpExceptionSystemNullReferenceException = GetDelegate(libraryHandle, "SetCsharpExceptionSystemNullReferenceException"); /*END GETDELEGATE CALLS*/ #endif - // Init C++ library - Init( + // Pass parameters through 'memory' + int curMemory = 0; + Marshal.WriteIntPtr( + memory, + curMemory, + Marshal.GetFunctionPointerForDelegate(ReleaseObjectDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr( + memory, + curMemory, + Marshal.GetFunctionPointerForDelegate(StringNewDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr( + memory, + curMemory, + Marshal.GetFunctionPointerForDelegate(SetExceptionDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr( memory, - memorySize, - initMode, - Marshal.GetFunctionPointerForDelegate(new ReleaseObjectDelegate(ReleaseObject)), - Marshal.GetFunctionPointerForDelegate(new StringNewDelegate(StringNew)), - Marshal.GetFunctionPointerForDelegate(new SetExceptionDelegate(SetException)), - Marshal.GetFunctionPointerForDelegate(new ArrayGetLengthDelegate(ArrayGetLength)), - Marshal.GetFunctionPointerForDelegate(new EnumerableGetEnumeratorDelegate(EnumerableGetEnumerator)), - /*BEGIN INIT CALL*/ - 1000, - Marshal.GetFunctionPointerForDelegate(new ReleaseSystemDecimalDelegate(ReleaseSystemDecimal)), - Marshal.GetFunctionPointerForDelegate(new SystemDecimalConstructorSystemDoubleDelegate(SystemDecimalConstructorSystemDouble)), - Marshal.GetFunctionPointerForDelegate(new SystemDecimalConstructorSystemUInt64Delegate(SystemDecimalConstructorSystemUInt64)), - Marshal.GetFunctionPointerForDelegate(new BoxDecimalDelegate(BoxDecimal)), - Marshal.GetFunctionPointerForDelegate(new UnboxDecimalDelegate(UnboxDecimal)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingleDelegate(UnityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingle)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3Delegate(UnityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3)), - Marshal.GetFunctionPointerForDelegate(new BoxVector3Delegate(BoxVector3)), - Marshal.GetFunctionPointerForDelegate(new UnboxVector3Delegate(UnboxVector3)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineObjectPropertyGetNameDelegate(UnityEngineObjectPropertyGetName)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineObjectPropertySetNameDelegate(UnityEngineObjectPropertySetName)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineComponentPropertyGetTransformDelegate(UnityEngineComponentPropertyGetTransform)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineTransformPropertyGetPositionDelegate(UnityEngineTransformPropertyGetPosition)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineTransformPropertySetPositionDelegate(UnityEngineTransformPropertySetPosition)), - Marshal.GetFunctionPointerForDelegate(new SystemCollectionsIEnumeratorPropertyGetCurrentDelegate(SystemCollectionsIEnumeratorPropertyGetCurrent)), - Marshal.GetFunctionPointerForDelegate(new SystemCollectionsIEnumeratorMethodMoveNextDelegate(SystemCollectionsIEnumeratorMethodMoveNext)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineGameObjectMethodAddComponentMyGameBaseBallScriptDelegate(UnityEngineGameObjectMethodAddComponentMyGameBaseBallScript)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveTypeDelegate(UnityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveType)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineDebugMethodLogSystemObjectDelegate(UnityEngineDebugMethodLogSystemObject)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineMonoBehaviourPropertyGetTransformDelegate(UnityEngineMonoBehaviourPropertyGetTransform)), - Marshal.GetFunctionPointerForDelegate(new SystemExceptionConstructorSystemStringDelegate(SystemExceptionConstructorSystemString)), - Marshal.GetFunctionPointerForDelegate(new BoxPrimitiveTypeDelegate(BoxPrimitiveType)), - Marshal.GetFunctionPointerForDelegate(new UnboxPrimitiveTypeDelegate(UnboxPrimitiveType)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineTimePropertyGetDeltaTimeDelegate(UnityEngineTimePropertyGetDeltaTime)), - Marshal.GetFunctionPointerForDelegate(new ReleaseBaseBallScriptDelegate(ReleaseBaseBallScript)), - Marshal.GetFunctionPointerForDelegate(new BaseBallScriptConstructorDelegate(BaseBallScriptConstructor)), - Marshal.GetFunctionPointerForDelegate(new BoxBooleanDelegate(BoxBoolean)), - Marshal.GetFunctionPointerForDelegate(new UnboxBooleanDelegate(UnboxBoolean)), - Marshal.GetFunctionPointerForDelegate(new BoxSByteDelegate(BoxSByte)), - Marshal.GetFunctionPointerForDelegate(new UnboxSByteDelegate(UnboxSByte)), - Marshal.GetFunctionPointerForDelegate(new BoxByteDelegate(BoxByte)), - Marshal.GetFunctionPointerForDelegate(new UnboxByteDelegate(UnboxByte)), - Marshal.GetFunctionPointerForDelegate(new BoxInt16Delegate(BoxInt16)), - Marshal.GetFunctionPointerForDelegate(new UnboxInt16Delegate(UnboxInt16)), - Marshal.GetFunctionPointerForDelegate(new BoxUInt16Delegate(BoxUInt16)), - Marshal.GetFunctionPointerForDelegate(new UnboxUInt16Delegate(UnboxUInt16)), - Marshal.GetFunctionPointerForDelegate(new BoxInt32Delegate(BoxInt32)), - Marshal.GetFunctionPointerForDelegate(new UnboxInt32Delegate(UnboxInt32)), - Marshal.GetFunctionPointerForDelegate(new BoxUInt32Delegate(BoxUInt32)), - Marshal.GetFunctionPointerForDelegate(new UnboxUInt32Delegate(UnboxUInt32)), - Marshal.GetFunctionPointerForDelegate(new BoxInt64Delegate(BoxInt64)), - Marshal.GetFunctionPointerForDelegate(new UnboxInt64Delegate(UnboxInt64)), - Marshal.GetFunctionPointerForDelegate(new BoxUInt64Delegate(BoxUInt64)), - Marshal.GetFunctionPointerForDelegate(new UnboxUInt64Delegate(UnboxUInt64)), - Marshal.GetFunctionPointerForDelegate(new BoxCharDelegate(BoxChar)), - Marshal.GetFunctionPointerForDelegate(new UnboxCharDelegate(UnboxChar)), - Marshal.GetFunctionPointerForDelegate(new BoxSingleDelegate(BoxSingle)), - Marshal.GetFunctionPointerForDelegate(new UnboxSingleDelegate(UnboxSingle)), - Marshal.GetFunctionPointerForDelegate(new BoxDoubleDelegate(BoxDouble)), - Marshal.GetFunctionPointerForDelegate(new UnboxDoubleDelegate(UnboxDouble)) - /*END INIT CALL*/ - ); + curMemory, + Marshal.GetFunctionPointerForDelegate(ArrayGetLengthDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr( + memory, + curMemory, + Marshal.GetFunctionPointerForDelegate(EnumerableGetEnumeratorDelegate)); + curMemory += IntPtr.Size; + + /*BEGIN INIT CALL*/ + Marshal.WriteInt32(memory, curMemory, 1000); // max managed objects + curMemory += sizeof(int); + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(ReleaseSystemDecimalDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(SystemDecimalConstructorSystemDoubleDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(SystemDecimalConstructorSystemUInt64Delegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(BoxDecimalDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnboxDecimalDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingleDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3Delegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(BoxVector3Delegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnboxVector3Delegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnityEngineObjectPropertyGetNameDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnityEngineObjectPropertySetNameDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnityEngineComponentPropertyGetTransformDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnityEngineTransformPropertyGetPositionDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnityEngineTransformPropertySetPositionDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(SystemCollectionsIEnumeratorPropertyGetCurrentDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(SystemCollectionsIEnumeratorMethodMoveNextDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnityEngineGameObjectMethodAddComponentMyGameBaseBallScriptDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveTypeDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnityEngineDebugMethodLogSystemObjectDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnityEngineMonoBehaviourPropertyGetTransformDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(SystemExceptionConstructorSystemStringDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(BoxPrimitiveTypeDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnboxPrimitiveTypeDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnityEngineTimePropertyGetDeltaTimeDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(ReleaseBaseBallScriptDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(BaseBallScriptConstructorDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(BoxBooleanDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnboxBooleanDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(BoxSByteDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnboxSByteDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(BoxByteDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnboxByteDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(BoxInt16Delegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnboxInt16Delegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(BoxUInt16Delegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnboxUInt16Delegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(BoxInt32Delegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnboxInt32Delegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(BoxUInt32Delegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnboxUInt32Delegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(BoxInt64Delegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnboxInt64Delegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(BoxUInt64Delegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnboxUInt64Delegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(BoxCharDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnboxCharDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(BoxSingleDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnboxSingleDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(BoxDoubleDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnboxDoubleDelegate)); + curMemory += IntPtr.Size; + /*END INIT CALL*/ + + // Init C++ library + Init(memory, memorySize, initMode); if (UnhandledCppException != null) { Exception ex = UnhandledCppException; @@ -908,7 +948,7 @@ static void DestroyAll() // C# functions for C++ to call //////////////////////////////////////////////////////////////// - [MonoPInvokeCallback(typeof(ReleaseObjectDelegate))] + [MonoPInvokeCallback(typeof(ReleaseObjectDelegateType))] static void ReleaseObject( int handle) { @@ -918,7 +958,7 @@ static void ReleaseObject( } } - [MonoPInvokeCallback(typeof(StringNewDelegate))] + [MonoPInvokeCallback(typeof(StringNewDelegateType))] static int StringNew( string chars) { @@ -926,26 +966,26 @@ static int StringNew( return handle; } - [MonoPInvokeCallback(typeof(SetExceptionDelegate))] + [MonoPInvokeCallback(typeof(SetExceptionDelegateType))] static void SetException(int handle) { UnhandledCppException = ObjectStore.Get(handle) as Exception; } - [MonoPInvokeCallback(typeof(ArrayGetLengthDelegate))] + [MonoPInvokeCallback(typeof(ArrayGetLengthDelegateType))] static int ArrayGetLength(int handle) { return ((Array)ObjectStore.Get(handle)).Length; } - [MonoPInvokeCallback(typeof(EnumerableGetEnumeratorDelegate))] + [MonoPInvokeCallback(typeof(EnumerableGetEnumeratorDelegateType))] static int EnumerableGetEnumerator(int handle) { return ObjectStore.Store(((IEnumerable)ObjectStore.Get(handle)).GetEnumerator()); } /*BEGIN FUNCTIONS*/ - [MonoPInvokeCallback(typeof(ReleaseSystemDecimalDelegate))] + [MonoPInvokeCallback(typeof(ReleaseSystemDecimalDelegateType))] static void ReleaseSystemDecimal(int handle) { try @@ -967,7 +1007,7 @@ static void ReleaseSystemDecimal(int handle) } } - [MonoPInvokeCallback(typeof(SystemDecimalConstructorSystemDoubleDelegate))] + [MonoPInvokeCallback(typeof(SystemDecimalConstructorSystemDoubleDelegateType))] static int SystemDecimalConstructorSystemDouble(double value) { try @@ -989,7 +1029,7 @@ static int SystemDecimalConstructorSystemDouble(double value) } } - [MonoPInvokeCallback(typeof(SystemDecimalConstructorSystemUInt64Delegate))] + [MonoPInvokeCallback(typeof(SystemDecimalConstructorSystemUInt64DelegateType))] static int SystemDecimalConstructorSystemUInt64(ulong value) { try @@ -1011,7 +1051,7 @@ static int SystemDecimalConstructorSystemUInt64(ulong value) } } - [MonoPInvokeCallback(typeof(BoxDecimalDelegate))] + [MonoPInvokeCallback(typeof(BoxDecimalDelegateType))] static int BoxDecimal(int valHandle) { try @@ -1034,7 +1074,7 @@ static int BoxDecimal(int valHandle) } } - [MonoPInvokeCallback(typeof(UnboxDecimalDelegate))] + [MonoPInvokeCallback(typeof(UnboxDecimalDelegateType))] static int UnboxDecimal(int valHandle) { try @@ -1057,7 +1097,7 @@ static int UnboxDecimal(int valHandle) } } - [MonoPInvokeCallback(typeof(UnityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingleDelegate))] + [MonoPInvokeCallback(typeof(UnityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingleDelegateType))] static UnityEngine.Vector3 UnityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingle(float x, float y, float z) { try @@ -1079,7 +1119,7 @@ static UnityEngine.Vector3 UnityEngineVector3ConstructorSystemSingle_SystemSingl } } - [MonoPInvokeCallback(typeof(UnityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3Delegate))] + [MonoPInvokeCallback(typeof(UnityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3DelegateType))] static UnityEngine.Vector3 UnityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3(ref UnityEngine.Vector3 a, ref UnityEngine.Vector3 b) { try @@ -1101,7 +1141,7 @@ static UnityEngine.Vector3 UnityEngineVector3Methodop_AdditionUnityEngineVector3 } } - [MonoPInvokeCallback(typeof(BoxVector3Delegate))] + [MonoPInvokeCallback(typeof(BoxVector3DelegateType))] static int BoxVector3(ref UnityEngine.Vector3 val) { try @@ -1123,7 +1163,7 @@ static int BoxVector3(ref UnityEngine.Vector3 val) } } - [MonoPInvokeCallback(typeof(UnboxVector3Delegate))] + [MonoPInvokeCallback(typeof(UnboxVector3DelegateType))] static UnityEngine.Vector3 UnboxVector3(int valHandle) { try @@ -1146,7 +1186,7 @@ static UnityEngine.Vector3 UnboxVector3(int valHandle) } } - [MonoPInvokeCallback(typeof(UnityEngineObjectPropertyGetNameDelegate))] + [MonoPInvokeCallback(typeof(UnityEngineObjectPropertyGetNameDelegateType))] static int UnityEngineObjectPropertyGetName(int thisHandle) { try @@ -1169,7 +1209,7 @@ static int UnityEngineObjectPropertyGetName(int thisHandle) } } - [MonoPInvokeCallback(typeof(UnityEngineObjectPropertySetNameDelegate))] + [MonoPInvokeCallback(typeof(UnityEngineObjectPropertySetNameDelegateType))] static void UnityEngineObjectPropertySetName(int thisHandle, int valueHandle) { try @@ -1190,7 +1230,7 @@ static void UnityEngineObjectPropertySetName(int thisHandle, int valueHandle) } } - [MonoPInvokeCallback(typeof(UnityEngineComponentPropertyGetTransformDelegate))] + [MonoPInvokeCallback(typeof(UnityEngineComponentPropertyGetTransformDelegateType))] static int UnityEngineComponentPropertyGetTransform(int thisHandle) { try @@ -1213,7 +1253,7 @@ static int UnityEngineComponentPropertyGetTransform(int thisHandle) } } - [MonoPInvokeCallback(typeof(UnityEngineTransformPropertyGetPositionDelegate))] + [MonoPInvokeCallback(typeof(UnityEngineTransformPropertyGetPositionDelegateType))] static UnityEngine.Vector3 UnityEngineTransformPropertyGetPosition(int thisHandle) { try @@ -1236,7 +1276,7 @@ static UnityEngine.Vector3 UnityEngineTransformPropertyGetPosition(int thisHandl } } - [MonoPInvokeCallback(typeof(UnityEngineTransformPropertySetPositionDelegate))] + [MonoPInvokeCallback(typeof(UnityEngineTransformPropertySetPositionDelegateType))] static void UnityEngineTransformPropertySetPosition(int thisHandle, ref UnityEngine.Vector3 value) { try @@ -1256,7 +1296,7 @@ static void UnityEngineTransformPropertySetPosition(int thisHandle, ref UnityEng } } - [MonoPInvokeCallback(typeof(SystemCollectionsIEnumeratorPropertyGetCurrentDelegate))] + [MonoPInvokeCallback(typeof(SystemCollectionsIEnumeratorPropertyGetCurrentDelegateType))] static int SystemCollectionsIEnumeratorPropertyGetCurrent(int thisHandle) { try @@ -1279,7 +1319,7 @@ static int SystemCollectionsIEnumeratorPropertyGetCurrent(int thisHandle) } } - [MonoPInvokeCallback(typeof(SystemCollectionsIEnumeratorMethodMoveNextDelegate))] + [MonoPInvokeCallback(typeof(SystemCollectionsIEnumeratorMethodMoveNextDelegateType))] static bool SystemCollectionsIEnumeratorMethodMoveNext(int thisHandle) { try @@ -1302,7 +1342,7 @@ static bool SystemCollectionsIEnumeratorMethodMoveNext(int thisHandle) } } - [MonoPInvokeCallback(typeof(UnityEngineGameObjectMethodAddComponentMyGameBaseBallScriptDelegate))] + [MonoPInvokeCallback(typeof(UnityEngineGameObjectMethodAddComponentMyGameBaseBallScriptDelegateType))] static int UnityEngineGameObjectMethodAddComponentMyGameBaseBallScript(int thisHandle) { try @@ -1325,7 +1365,7 @@ static int UnityEngineGameObjectMethodAddComponentMyGameBaseBallScript(int thisH } } - [MonoPInvokeCallback(typeof(UnityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveTypeDelegate))] + [MonoPInvokeCallback(typeof(UnityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveTypeDelegateType))] static int UnityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveType(UnityEngine.PrimitiveType type) { try @@ -1347,7 +1387,7 @@ static int UnityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveType(Un } } - [MonoPInvokeCallback(typeof(UnityEngineDebugMethodLogSystemObjectDelegate))] + [MonoPInvokeCallback(typeof(UnityEngineDebugMethodLogSystemObjectDelegateType))] static void UnityEngineDebugMethodLogSystemObject(int messageHandle) { try @@ -1367,7 +1407,7 @@ static void UnityEngineDebugMethodLogSystemObject(int messageHandle) } } - [MonoPInvokeCallback(typeof(UnityEngineMonoBehaviourPropertyGetTransformDelegate))] + [MonoPInvokeCallback(typeof(UnityEngineMonoBehaviourPropertyGetTransformDelegateType))] static int UnityEngineMonoBehaviourPropertyGetTransform(int thisHandle) { try @@ -1390,7 +1430,7 @@ static int UnityEngineMonoBehaviourPropertyGetTransform(int thisHandle) } } - [MonoPInvokeCallback(typeof(SystemExceptionConstructorSystemStringDelegate))] + [MonoPInvokeCallback(typeof(SystemExceptionConstructorSystemStringDelegateType))] static int SystemExceptionConstructorSystemString(int messageHandle) { try @@ -1413,7 +1453,7 @@ static int SystemExceptionConstructorSystemString(int messageHandle) } } - [MonoPInvokeCallback(typeof(BoxPrimitiveTypeDelegate))] + [MonoPInvokeCallback(typeof(BoxPrimitiveTypeDelegateType))] static int BoxPrimitiveType(UnityEngine.PrimitiveType val) { try @@ -1435,7 +1475,7 @@ static int BoxPrimitiveType(UnityEngine.PrimitiveType val) } } - [MonoPInvokeCallback(typeof(UnboxPrimitiveTypeDelegate))] + [MonoPInvokeCallback(typeof(UnboxPrimitiveTypeDelegateType))] static UnityEngine.PrimitiveType UnboxPrimitiveType(int valHandle) { try @@ -1458,7 +1498,7 @@ static UnityEngine.PrimitiveType UnboxPrimitiveType(int valHandle) } } - [MonoPInvokeCallback(typeof(UnityEngineTimePropertyGetDeltaTimeDelegate))] + [MonoPInvokeCallback(typeof(UnityEngineTimePropertyGetDeltaTimeDelegateType))] static float UnityEngineTimePropertyGetDeltaTime() { try @@ -1480,7 +1520,7 @@ static float UnityEngineTimePropertyGetDeltaTime() } } - [MonoPInvokeCallback(typeof(BaseBallScriptConstructorDelegate))] + [MonoPInvokeCallback(typeof(BaseBallScriptConstructorDelegateType))] static void BaseBallScriptConstructor(int cppHandle, ref int handle) { try @@ -1502,7 +1542,7 @@ static void BaseBallScriptConstructor(int cppHandle, ref int handle) } } - [MonoPInvokeCallback(typeof(ReleaseBaseBallScriptDelegate))] + [MonoPInvokeCallback(typeof(ReleaseBaseBallScriptDelegateType))] static void ReleaseBaseBallScript(int handle) { try @@ -1526,7 +1566,7 @@ static void ReleaseBaseBallScript(int handle) } } - [MonoPInvokeCallback(typeof(BoxBooleanDelegate))] + [MonoPInvokeCallback(typeof(BoxBooleanDelegateType))] static int BoxBoolean(bool val) { try @@ -1548,7 +1588,7 @@ static int BoxBoolean(bool val) } } - [MonoPInvokeCallback(typeof(UnboxBooleanDelegate))] + [MonoPInvokeCallback(typeof(UnboxBooleanDelegateType))] static bool UnboxBoolean(int valHandle) { try @@ -1571,7 +1611,7 @@ static bool UnboxBoolean(int valHandle) } } - [MonoPInvokeCallback(typeof(BoxSByteDelegate))] + [MonoPInvokeCallback(typeof(BoxSByteDelegateType))] static int BoxSByte(sbyte val) { try @@ -1593,7 +1633,7 @@ static int BoxSByte(sbyte val) } } - [MonoPInvokeCallback(typeof(UnboxSByteDelegate))] + [MonoPInvokeCallback(typeof(UnboxSByteDelegateType))] static sbyte UnboxSByte(int valHandle) { try @@ -1616,7 +1656,7 @@ static sbyte UnboxSByte(int valHandle) } } - [MonoPInvokeCallback(typeof(BoxByteDelegate))] + [MonoPInvokeCallback(typeof(BoxByteDelegateType))] static int BoxByte(byte val) { try @@ -1638,7 +1678,7 @@ static int BoxByte(byte val) } } - [MonoPInvokeCallback(typeof(UnboxByteDelegate))] + [MonoPInvokeCallback(typeof(UnboxByteDelegateType))] static byte UnboxByte(int valHandle) { try @@ -1661,7 +1701,7 @@ static byte UnboxByte(int valHandle) } } - [MonoPInvokeCallback(typeof(BoxInt16Delegate))] + [MonoPInvokeCallback(typeof(BoxInt16DelegateType))] static int BoxInt16(short val) { try @@ -1683,7 +1723,7 @@ static int BoxInt16(short val) } } - [MonoPInvokeCallback(typeof(UnboxInt16Delegate))] + [MonoPInvokeCallback(typeof(UnboxInt16DelegateType))] static short UnboxInt16(int valHandle) { try @@ -1706,7 +1746,7 @@ static short UnboxInt16(int valHandle) } } - [MonoPInvokeCallback(typeof(BoxUInt16Delegate))] + [MonoPInvokeCallback(typeof(BoxUInt16DelegateType))] static int BoxUInt16(ushort val) { try @@ -1728,7 +1768,7 @@ static int BoxUInt16(ushort val) } } - [MonoPInvokeCallback(typeof(UnboxUInt16Delegate))] + [MonoPInvokeCallback(typeof(UnboxUInt16DelegateType))] static ushort UnboxUInt16(int valHandle) { try @@ -1751,7 +1791,7 @@ static ushort UnboxUInt16(int valHandle) } } - [MonoPInvokeCallback(typeof(BoxInt32Delegate))] + [MonoPInvokeCallback(typeof(BoxInt32DelegateType))] static int BoxInt32(int val) { try @@ -1773,7 +1813,7 @@ static int BoxInt32(int val) } } - [MonoPInvokeCallback(typeof(UnboxInt32Delegate))] + [MonoPInvokeCallback(typeof(UnboxInt32DelegateType))] static int UnboxInt32(int valHandle) { try @@ -1796,7 +1836,7 @@ static int UnboxInt32(int valHandle) } } - [MonoPInvokeCallback(typeof(BoxUInt32Delegate))] + [MonoPInvokeCallback(typeof(BoxUInt32DelegateType))] static int BoxUInt32(uint val) { try @@ -1818,7 +1858,7 @@ static int BoxUInt32(uint val) } } - [MonoPInvokeCallback(typeof(UnboxUInt32Delegate))] + [MonoPInvokeCallback(typeof(UnboxUInt32DelegateType))] static uint UnboxUInt32(int valHandle) { try @@ -1841,7 +1881,7 @@ static uint UnboxUInt32(int valHandle) } } - [MonoPInvokeCallback(typeof(BoxInt64Delegate))] + [MonoPInvokeCallback(typeof(BoxInt64DelegateType))] static int BoxInt64(long val) { try @@ -1863,7 +1903,7 @@ static int BoxInt64(long val) } } - [MonoPInvokeCallback(typeof(UnboxInt64Delegate))] + [MonoPInvokeCallback(typeof(UnboxInt64DelegateType))] static long UnboxInt64(int valHandle) { try @@ -1886,7 +1926,7 @@ static long UnboxInt64(int valHandle) } } - [MonoPInvokeCallback(typeof(BoxUInt64Delegate))] + [MonoPInvokeCallback(typeof(BoxUInt64DelegateType))] static int BoxUInt64(ulong val) { try @@ -1908,7 +1948,7 @@ static int BoxUInt64(ulong val) } } - [MonoPInvokeCallback(typeof(UnboxUInt64Delegate))] + [MonoPInvokeCallback(typeof(UnboxUInt64DelegateType))] static ulong UnboxUInt64(int valHandle) { try @@ -1931,7 +1971,7 @@ static ulong UnboxUInt64(int valHandle) } } - [MonoPInvokeCallback(typeof(BoxCharDelegate))] + [MonoPInvokeCallback(typeof(BoxCharDelegateType))] static int BoxChar(char val) { try @@ -1953,7 +1993,7 @@ static int BoxChar(char val) } } - [MonoPInvokeCallback(typeof(UnboxCharDelegate))] + [MonoPInvokeCallback(typeof(UnboxCharDelegateType))] static char UnboxChar(int valHandle) { try @@ -1976,7 +2016,7 @@ static char UnboxChar(int valHandle) } } - [MonoPInvokeCallback(typeof(BoxSingleDelegate))] + [MonoPInvokeCallback(typeof(BoxSingleDelegateType))] static int BoxSingle(float val) { try @@ -1998,7 +2038,7 @@ static int BoxSingle(float val) } } - [MonoPInvokeCallback(typeof(UnboxSingleDelegate))] + [MonoPInvokeCallback(typeof(UnboxSingleDelegateType))] static float UnboxSingle(int valHandle) { try @@ -2021,7 +2061,7 @@ static float UnboxSingle(int valHandle) } } - [MonoPInvokeCallback(typeof(BoxDoubleDelegate))] + [MonoPInvokeCallback(typeof(BoxDoubleDelegateType))] static int BoxDouble(double val) { try @@ -2043,7 +2083,7 @@ static int BoxDouble(double val) } } - [MonoPInvokeCallback(typeof(UnboxDoubleDelegate))] + [MonoPInvokeCallback(typeof(UnboxDoubleDelegateType))] static double UnboxDouble(int valHandle) { try diff --git a/Unity/Assets/NativeScript/BootScene.unity b/Unity/Assets/NativeScript/BootScene.unity index 4c9bb79..8a205bf 100644 --- a/Unity/Assets/NativeScript/BootScene.unity +++ b/Unity/Assets/NativeScript/BootScene.unity @@ -13,7 +13,7 @@ OcclusionCullingSettings: --- !u!104 &2 RenderSettings: m_ObjectHideFlags: 0 - serializedVersion: 8 + serializedVersion: 9 m_Fog: 0 m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} m_FogMode: 3 @@ -38,7 +38,8 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0.37311992, g: 0.38074034, b: 0.35872716, a: 1} + m_IndirectSpecularColor: {r: 0.3731316, g: 0.38074902, b: 0.3587254, a: 1} + m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: m_ObjectHideFlags: 0 @@ -54,11 +55,10 @@ LightmapSettings: m_EnableBakedLightmaps: 1 m_EnableRealtimeLightmaps: 1 m_LightmapEditorSettings: - serializedVersion: 9 + serializedVersion: 10 m_Resolution: 2 m_BakeResolution: 40 - m_TextureWidth: 1024 - m_TextureHeight: 1024 + m_AtlasSize: 1024 m_AO: 0 m_AOMaxDistance: 1 m_CompAOExponent: 1 @@ -88,6 +88,7 @@ LightmapSettings: m_PVRFilteringAtrousPositionSigmaDirect: 0.5 m_PVRFilteringAtrousPositionSigmaIndirect: 2 m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ShowResolutionOverlay: 1 m_LightingDataAsset: {fileID: 0} m_UseShadowmask: 1 --- !u!196 &4 @@ -139,7 +140,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 6b5575a60b7c04c7a87ff4e161573c66, type: 3} m_Name: m_EditorClassIdentifier: - MemorySize: 16777216 + MemorySize: 1048576 AutoReload: 1 AutoReloadPollTime: 1 --- !u!4 &643357610 @@ -218,6 +219,7 @@ Camera: m_TargetEye: 3 m_HDR: 1 m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 m_ForceIntoRT: 0 m_OcclusionCulling: 1 m_StereoConvergence: 10 diff --git a/Unity/Assets/NativeScript/BootScript.cs b/Unity/Assets/NativeScript/BootScript.cs index 1fe063f..74c8268 100644 --- a/Unity/Assets/NativeScript/BootScript.cs +++ b/Unity/Assets/NativeScript/BootScript.cs @@ -1,3 +1,5 @@ +using System; +using UnityEditor; using UnityEngine; namespace NativeScript @@ -25,15 +27,20 @@ public class BootScript : MonoBehaviour public float AutoReloadPollTime = 1.0f; private float lastAutoReloadPollTime; private Coroutine autoReloadCoroutine; + private Action onPlayModeStateChange; #endif - void Awake() + void Start() { #if UNITY_EDITOR lastAutoReloadPollTime = AutoReloadPollTime; #endif DontDestroyOnLoad(gameObject); Bindings.Open(MemorySize); +#if UNITY_EDITOR + onPlayModeStateChange = OnEditorStateChanged; + EditorApplication.playModeStateChanged += onPlayModeStateChange; +#endif } #if UNITY_EDITOR @@ -74,11 +81,15 @@ void Update() } } } -#endif - - void OnApplicationQuit() + + private void OnEditorStateChanged(PlayModeStateChange state) { - Bindings.Close(); + if (state == PlayModeStateChange.EnteredEditMode) + { + EditorApplication.playModeStateChanged -= onPlayModeStateChange; + Bindings.Close(); + } } +#endif } } \ No newline at end of file diff --git a/Unity/Assets/NativeScript/Editor/EditorMenus.cs b/Unity/Assets/NativeScript/Editor/EditorMenus.cs index 12866f1..a444732 100644 --- a/Unity/Assets/NativeScript/Editor/EditorMenus.cs +++ b/Unity/Assets/NativeScript/Editor/EditorMenus.cs @@ -1,7 +1,6 @@ -using UnityEngine; using UnityEditor; -namespace NativeScript +namespace NativeScript.Editor { /// /// Menus for the Unity Editor diff --git a/Unity/Assets/NativeScript/Editor/GenerateBindings.cs b/Unity/Assets/NativeScript/Editor/GenerateBindings.cs index 0b810fd..be815bc 100644 --- a/Unity/Assets/NativeScript/Editor/GenerateBindings.cs +++ b/Unity/Assets/NativeScript/Editor/GenerateBindings.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections; using System.Collections.Generic; using System.IO; @@ -8,7 +8,7 @@ using UnityEditor; using UnityEngine; -namespace NativeScript +namespace NativeScript.Editor { /// /// Code generator that reads a JSON file and outputs C# and C++ code @@ -24,7 +24,7 @@ public static class GenerateBindings { // Disable unused field types. JsonUtility actually uses them, but it // does so with reflection. - #pragma warning disable CS0649 + #pragma warning disable 649 [Serializable] class JsonConstructor @@ -137,8 +137,6 @@ class JsonDocument class StringBuilders { - public readonly StringBuilder CsharpInitParams = - new StringBuilder(InitialStringBuilderCapacity); public readonly StringBuilder CsharpDelegateTypes = new StringBuilder(InitialStringBuilderCapacity); public readonly StringBuilder CsharpStoreInitCalls = @@ -149,7 +147,9 @@ class StringBuilders new StringBuilder(InitialStringBuilderCapacity); public readonly StringBuilder CsharpFunctions = new StringBuilder(InitialStringBuilderCapacity); - public readonly StringBuilder CsharpDelegates = + public readonly StringBuilder CsharpCppDelegates = + new StringBuilder(InitialStringBuilderCapacity); + public readonly StringBuilder CsharpCsharpDelegates = new StringBuilder(InitialStringBuilderCapacity); public readonly StringBuilder CsharpImports = new StringBuilder(InitialStringBuilderCapacity); @@ -171,9 +171,9 @@ class StringBuilders new StringBuilder(InitialStringBuilderCapacity); public readonly StringBuilder CppMethodDefinitions = new StringBuilder(InitialStringBuilderCapacity); - public readonly StringBuilder CppInitParams = + public readonly StringBuilder CppInitBodyParameterReads = new StringBuilder(InitialStringBuilderCapacity); - public readonly StringBuilder CppInitBody = + public readonly StringBuilder CppInitBodyArrays = new StringBuilder(InitialStringBuilderCapacity); public readonly StringBuilder CppInitBodyFirstBoot = new StringBuilder(InitialStringBuilderCapacity); @@ -240,11 +240,17 @@ int IComparer.Compare(object x, object y) { FieldInfo xField = (FieldInfo)x; FieldInfo yField = (FieldInfo)y; - return xField.MetadataToken < yField.MetadataToken - ? -1 - : xField.MetadataToken > yField.MetadataToken + return xField == null + ? yField == null + ? 0 + : -1 + : yField == null ? 1 - : 0; + : xField.MetadataToken < yField.MetadataToken + ? -1 + : xField.MetadataToken > yField.MetadataToken + ? 1 + : 0; } } @@ -255,10 +261,9 @@ struct TypeName public int NumTypeParams; } - const int DEFAULT_MAX_SIMULTANEOUS = 1000; - const int DEFAULT_MAX_SIMULTANEOUS_OBJECTS = 1000; - - static readonly Type[] PRIMITIVE_TYPES = { + const int BaseMaxSimultaneous = 1000; + + static readonly Type[] PrimitiveTypes = { typeof(bool), typeof(sbyte), typeof(byte), @@ -270,7 +275,7 @@ struct TypeName typeof(ulong), typeof(char), typeof(float), - typeof(double), + typeof(double) }; const string PostCompileWorkPref = "NativeScriptGenerateBindingsPostCompileWork"; @@ -282,14 +287,15 @@ struct TypeName new Uri(typeof(GameObject).Assembly.CodeBase).LocalPath ).DirectoryName; static readonly string AssetsDirPath = Application.dataPath; - static readonly string ProjectDirPath = - new DirectoryInfo(AssetsDirPath) - .Parent - .FullName; + private static readonly DirectoryInfo ProjectDir = + new DirectoryInfo(AssetsDirPath).Parent; + static readonly string ProjectDirPath = ProjectDir.FullName; static readonly string CppDirPath = Path.Combine( Path.Combine( - ProjectDirPath, + Path.Combine( + ProjectDirPath, + "Assets"), "CppSource"), "NativeScript"); static readonly string CsharpPath = Path.Combine( @@ -306,9 +312,9 @@ struct TypeName static readonly FieldOrderComparer DefaultFieldOrderComparer = new FieldOrderComparer(); - + // Restore unused field types - #pragma warning restore CS0649 + #pragma warning restore 649 public static void Generate() { @@ -341,7 +347,7 @@ public static void Generate() } } } - determinedNeedStubs:; + determinedNeedStubs: if (needStubs) { @@ -401,10 +407,6 @@ static void AppendStubs( } } } - - // Need at least one init param - builders.CsharpInitParams.Append("object stub"); - builders.CsharpInitCall.Append("null // stub"); } static void AppendStubBaseType( @@ -435,18 +437,18 @@ static void AppendStubBaseType( AppendCSharpTypeParameters( typeParams, output); - output.Append('\n'); + output.AppendLine(); AppendIndent(indent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent(indent + 1, output); output.Append("// Stub version. GenerateBindings is still in progress. "); output.Append(timestamp); - output.Append('\n'); + output.AppendLine(); if (type.IsClass) { - output.Append('\n'); + output.AppendLine(); ConstructorInfo[] constructors = type.GetConstructors(); - if (constructors != null && constructors.Length > 0) + if (constructors.Length > 0) { foreach (ConstructorInfo ctor in constructors) { @@ -461,22 +463,22 @@ static void AppendStubBaseType( AppendCsharpParams( ctorParams, output); - output.Append(")\n"); + output.AppendLine(")"); output.Append("\t\t\t: base("); AppendCsharpFunctionCallParameters( ctorParams, output); - output.Append(")\n"); - output.Append("\t\t{\n"); - output.Append("\t\t}\n"); - output.Append("\t\t\n"); + output.AppendLine(")"); + output.AppendLine("\t\t{"); + output.AppendLine("\t\t}"); + output.AppendLine("\t\t"); break; } } } } AppendIndent(indent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendNamespaceEnding(indent, output); } @@ -505,20 +507,20 @@ static void DoPostCompileWork(bool canRefreshAssetDb) // it's not specified for a specific type int defaultMaxSimultaneous = doc.DefaultMaxSimultaneous != 0 ? doc.DefaultMaxSimultaneous - : DEFAULT_MAX_SIMULTANEOUS; + : BaseMaxSimultaneous; // Init param for max managed Objects - builders.CppInitParams.Append("\tint32_t maxManagedObjects,\n"); - builders.CsharpInitParams.Append("\t\t\tint maxManagedObjects,\n"); - builders.CsharpInitCall.Append("\t\t\t\t"); + builders.CsharpInitCall.Append("\t\t\tMarshal.WriteInt32(memory, curMemory, "); builders.CsharpInitCall.Append(defaultMaxSimultaneous); - builders.CsharpInitCall.Append(",\n"); + builders.CsharpInitCall.AppendLine("); // max managed objects"); + builders.CsharpInitCall.AppendLine("\t\t\tcurMemory += sizeof(int);"); + builders.CsharpInitCall.Append(' '); // C# ObjectStore Init call builders.CsharpStoreInitCalls.Append( "\t\t\tNativeScript.Bindings.ObjectStore.Init("); builders.CsharpStoreInitCalls.Append(defaultMaxSimultaneous); - builders.CsharpStoreInitCalls.Append(");\n"); + builders.CsharpStoreInitCalls.AppendLine(");"); // Generate types if (doc.Types != null) @@ -558,7 +560,7 @@ static void DoPostCompileWork(bool canRefreshAssetDb) } // Generate boxing and unboxing for primitive types - foreach (Type type in PRIMITIVE_TYPES) + foreach (Type type in PrimitiveTypes) { string dummyString; ParameterInfo[] dummyParams; @@ -682,39 +684,56 @@ static Assembly[] GetAssemblies(string[] assemblyNames) assemblies[7] = typeof(UnityEngine.Accessibility.VisionUtility).Assembly; // Unity accessibility module assemblies[8] = typeof(UnityEngine.AI.NavMesh).Assembly; // Unity AI module assemblies[9] = typeof(UnityEngine.Animations.AnimationClipPlayable).Assembly; // Unity animation module +#if !UNITY_2020_1_OR_NEWER //This class migrate to package assemblies[10] = typeof(UnityEngine.XR.ARRenderMode).Assembly; // Unity AR module - assemblies[11] = typeof(UnityEngine.AudioSettings).Assembly; // Unity audio module - assemblies[12] = typeof(UnityEngine.Cloth).Assembly; // Unity cloth module - assemblies[13] = typeof(UnityEngine.ClusterInput).Assembly; // Unity cluster input module - assemblies[14] = typeof(UnityEngine.ClusterNetwork).Assembly; // Unity custer renderer module +#else + assemblies[10] = typeof(UnityEngine.XR.InputDevices).Assembly; // Unity AR module without package +#endif + + assemblies[11] = typeof(AudioSettings).Assembly; // Unity audio module + assemblies[12] = typeof(Cloth).Assembly; // Unity cloth module + assemblies[13] = typeof(ClusterInput).Assembly; // Unity cluster input module + assemblies[14] = typeof(ClusterNetwork).Assembly; // Unity custer renderer module assemblies[15] = typeof(UnityEngine.CrashReportHandler.CrashReportHandler).Assembly; // Unity crash reporting module assemblies[16] = typeof(UnityEngine.Playables.PlayableDirector).Assembly; // Unity director module assemblies[17] = typeof(UnityEngine.SocialPlatforms.IAchievement).Assembly; // Unity game center module - assemblies[18] = typeof(UnityEngine.ImageConversion).Assembly; // Unity image conversion module - assemblies[19] = typeof(UnityEngine.GUI).Assembly; // Unity IMGUI module - assemblies[20] = typeof(UnityEngine.JsonUtility).Assembly; // Unity JSON serialize module - assemblies[21] = typeof(UnityEngine.ParticleSystem).Assembly; // Unity particle system module + assemblies[18] = typeof(ImageConversion).Assembly; // Unity image conversion module + assemblies[19] = typeof(GUI).Assembly; // Unity IMGUI module + assemblies[20] = typeof(JsonUtility).Assembly; // Unity JSON serialize module + assemblies[21] = typeof(ParticleSystem).Assembly; // Unity particle system module assemblies[22] = typeof(UnityEngine.Analytics.PerformanceReporting).Assembly; // Unity performance reporting module - assemblies[23] = typeof(UnityEngine.Physics2D).Assembly; // Unity physics 2D module - assemblies[24] = typeof(UnityEngine.Physics).Assembly; // Unity physics module - assemblies[25] = typeof(UnityEngine.ScreenCapture).Assembly; // Unity screen capture module - assemblies[26] = typeof(UnityEngine.Terrain).Assembly; // Unity terrain module - assemblies[27] = typeof(UnityEngine.TerrainCollider).Assembly; // Unity terrain physics module - assemblies[28] = typeof(UnityEngine.Font).Assembly; // Unity text rendering module + assemblies[23] = typeof(Physics2D).Assembly; // Unity physics 2D module + assemblies[24] = typeof(Physics).Assembly; // Unity physics module + assemblies[25] = typeof(ScreenCapture).Assembly; // Unity screen capture module + assemblies[26] = typeof(Terrain).Assembly; // Unity terrain module + assemblies[27] = typeof(TerrainCollider).Assembly; // Unity terrain physics module + assemblies[28] = typeof(Font).Assembly; // Unity text rendering module assemblies[29] = typeof(UnityEngine.Tilemaps.Tile).Assembly; // Unity tilemap module +#if UNITY_2019_1_OR_NEWER + assemblies[30] = typeof(UnityEngine.UIElements.Button).Assembly; // Unity UI elements module +#else assemblies[30] = typeof(UnityEngine.Experimental.UIElements.Button).Assembly; // Unity UI elements module - assemblies[31] = typeof(UnityEngine.Canvas).Assembly; // Unity UI module - assemblies[32] = typeof(UnityEngine.Networking.NetworkTransport).Assembly; // Unity cloth module +#endif + assemblies[31] = typeof(Canvas).Assembly; // Unity UI module +#if UNITY_2020_1_OR_NEWER + assemblies[32] = typeof(UnityEngine.Networking.Utility).Assembly; // Unity network module +#else + assemblies[32] = typeof(UnityEngine.Networking.NetworkTransport).Assembly; // Unity network module +#endif assemblies[33] = typeof(UnityEngine.Analytics.Analytics).Assembly; // Unity analytics module - assemblies[34] = typeof(UnityEngine.RemoteSettings).Assembly; // Unity Unity connect module + assemblies[34] = typeof(RemoteSettings).Assembly; // Unity Unity connect module assemblies[35] = typeof(UnityEngine.Networking.DownloadHandlerAudioClip).Assembly; // Unity web request audio module - assemblies[36] = typeof(UnityEngine.WWWForm).Assembly; // Unity web request module + assemblies[36] = typeof(WWWForm).Assembly; // Unity web request module assemblies[37] = typeof(UnityEngine.Networking.DownloadHandlerTexture).Assembly; // Unity web request texture module - assemblies[38] = typeof(UnityEngine.WWW).Assembly; // Unity web request WWW module - assemblies[39] = typeof(UnityEngine.WheelCollider).Assembly; // Unity vehicles module +#if !UNITY_2020_1_OR_NEWER + assemblies[38] = typeof(WWW).Assembly; // Unity web request WWW module +#else + assemblies[38] = typeof(UnityEngine.Networking.UnityWebRequest).Assembly; +#endif + assemblies[39] = typeof(WheelCollider).Assembly; // Unity vehicles module assemblies[40] = typeof(UnityEngine.Video.VideoClip).Assembly; // Unity video module assemblies[41] = typeof(UnityEngine.XR.InputTracking).Assembly; // Unity VR module - assemblies[42] = typeof(UnityEngine.WindZone).Assembly; // Unity wind module + assemblies[42] = typeof(WindZone).Assembly; // Unity wind module #endif return assemblies; } @@ -918,7 +937,11 @@ static Type[] GetDirectInterfaces(Type type) minimalInterfaces.Add(iType); } } - minimalInterfaces.Sort((x, y) => x.Name.CompareTo(y.Name)); + minimalInterfaces.Sort( + (x, y) => string.Compare( + x.Name, + y.Name, + StringComparison.InvariantCulture)); return minimalInterfaces.ToArray(); } @@ -955,19 +978,19 @@ static void AppendCppConstructorInitializerList( Type[] interfaceTypes, int indent, StringBuilder output, - string newline = "\n") + string newline = null) { + if (string.IsNullOrWhiteSpace(newline)) + { + newline = Environment.NewLine; + } + string separator = ": "; - for (int i = 0; i < interfaceTypes.Length; ++i) + foreach (Type interfaceType in interfaceTypes) { - Type interfaceType = interfaceTypes[i]; - AppendIndent( - indent, - output); + AppendIndent(indent, output); output.Append(separator); - AppendCppTypeFullName( - interfaceType, - output); + AppendCppTypeFullName( interfaceType, output); output.Append("(nullptr)"); output.Append(newline); separator = ", "; @@ -1427,7 +1450,7 @@ static void AppendTypeNameWithoutSuffixes( } } - static int AppendType( + static void AppendType( JsonType jsonType, Type type, TypeKind typeKind, @@ -1445,11 +1468,9 @@ static int AppendType( typeKind, null, builders); - return 0; } else { - int totalMaxSimultaneous = 0; Type[] genericArgTypes = type.GetGenericArguments(); if (jsonType.GenericParams != null) { @@ -1472,7 +1493,6 @@ static int AppendType( : jsonType.MaxSimultaneous != 0 ? jsonType.MaxSimultaneous : defaultMaxSimultaneous; - totalMaxSimultaneous += maxSimultaneous; AppendType( jsonType, genericArgTypes, @@ -1497,7 +1517,6 @@ static int AppendType( int maxSimultaneous = jsonType.MaxSimultaneous != 0 ? jsonType.MaxSimultaneous : defaultMaxSimultaneous; - totalMaxSimultaneous += maxSimultaneous; AppendType( jsonType, genericArgTypes, @@ -1516,7 +1535,6 @@ static int AppendType( builders); } } - return totalMaxSimultaneous; } } @@ -1541,7 +1559,7 @@ static void AppendType( builders.CsharpStoreInitCalls); builders.CsharpStoreInitCalls.Append(">.Init("); builders.CsharpStoreInitCalls.Append(maxSimultaneous); - builders.CsharpStoreInitCalls.Append(");\n"); + builders.CsharpStoreInitCalls.AppendLine(");"); // Build function name suffix builders.TempStrBuilder.Length = 0; @@ -1560,11 +1578,6 @@ static void AppendType( builders.TempStrBuilder); string funcName = builders.TempStrBuilder.ToString(); - // Build lowercase function name - builders.TempStrBuilder[0] = char.ToLower( - builders.TempStrBuilder[0]); - string funcNameLower = builders.TempStrBuilder.ToString(); - // Build ReleaseX parameters ParameterInfo paramInfo = new ParameterInfo(); paramInfo.Name = "handle"; @@ -1594,15 +1607,15 @@ static void AppendType( typeof(void), parameters, builders.CsharpFunctions); - builders.CsharpFunctions.Append( - "if (handle != 0)\n\t\t\t{\n"); + builders.CsharpFunctions.AppendLine("if (handle != 0)"); + builders.CsharpFunctions.AppendLine("\t\t\t{"); builders.CsharpFunctions.Append( "\t\t\t\tNativeScript.Bindings.StructStore<"); AppendCsharpTypeFullName( type, builders.CsharpFunctions); - builders.CsharpFunctions.Append( - ">.Remove(handle);\n\t\t\t}"); + builders.CsharpFunctions.AppendLine(">.Remove(handle);"); + builders.CsharpFunctions.Append("\t\t\t}"); AppendCsharpFunctionEnd( typeof(void), new Type[0], @@ -1619,85 +1632,80 @@ static void AppendType( typeof(void), builders.CppFunctionPointers); - // C++ init param for ReleaseX - AppendCppInitParam( - funcNameLower, + // C++ init body for ReleaseX + AppendCppInitBodyFunctionPointerParameterRead( + funcName, true, default(TypeName), TypeKind.None, parameters, typeof(void), - builders.CppInitParams); - - // C++ init body for ReleaseX - AppendCppInitBody( - funcName, - funcNameLower, - builders.CppInitBody); - - // C# init param for ReleaseX - AppendCsharpInitParam( - funcNameLower, - builders.CsharpInitParams); + builders.CppInitBodyParameterReads); // C# init call arg for ReleaseX - AppendCsharpInitCallArg( + AppendCsharpCsharpDelegate( funcName, - builders.CsharpInitCall); + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); // C++ init body for handle array length - builders.CppInitBody.Append("\tPlugin::RefCounts"); - builders.CppInitBody.Append(funcNameSuffix); - builders.CppInitBody.Append(" = (int32_t*)curMemory;\n"); - builders.CppInitBody.Append("\tcurMemory += "); - builders.CppInitBody.Append(maxSimultaneous); - builders.CppInitBody.Append(" * sizeof(int32_t);\n"); - builders.CppInitBody.Append("\tPlugin::RefCountsLen"); - builders.CppInitBody.Append(funcNameSuffix); - builders.CppInitBody.Append(" = "); - builders.CppInitBody.Append(maxSimultaneous); - builders.CppInitBody.Append(";\n"); + builders.CppInitBodyArrays.Append("\tPlugin::RefCounts"); + builders.CppInitBodyArrays.Append(funcNameSuffix); + builders.CppInitBodyArrays.AppendLine(" = (int32_t*)curMemory;"); + builders.CppInitBodyArrays.Append("\tcurMemory += "); + builders.CppInitBodyArrays.Append(maxSimultaneous); + builders.CppInitBodyArrays.AppendLine(" * sizeof(int32_t);"); + builders.CppInitBodyArrays.Append("\tPlugin::RefCountsLen"); + builders.CppInitBodyArrays.Append(funcNameSuffix); + builders.CppInitBodyArrays.Append(" = "); + builders.CppInitBodyArrays.Append(maxSimultaneous); + builders.CppInitBodyArrays.AppendLine(";"); + builders.CppInitBodyArrays.AppendLine("\t"); // C++ ref count state and functions builders.CppGlobalStateAndFunctions.Append("\tint32_t RefCountsLen"); builders.CppGlobalStateAndFunctions.Append(funcNameSuffix); - builders.CppGlobalStateAndFunctions.Append(";\n\tint32_t* RefCounts"); + builders.CppGlobalStateAndFunctions.AppendLine(";"); + builders.CppGlobalStateAndFunctions.Append("\tint32_t* RefCounts"); builders.CppGlobalStateAndFunctions.Append(funcNameSuffix); - builders.CppGlobalStateAndFunctions.Append(";\n\t\n\tvoid ReferenceManaged"); + builders.CppGlobalStateAndFunctions.AppendLine(";"); + builders.CppGlobalStateAndFunctions.AppendLine("\t"); + builders.CppGlobalStateAndFunctions.Append("\tvoid ReferenceManaged"); builders.CppGlobalStateAndFunctions.Append(funcNameSuffix); - builders.CppGlobalStateAndFunctions.Append("(int32_t handle)\n"); - builders.CppGlobalStateAndFunctions.Append("\t{\n"); + builders.CppGlobalStateAndFunctions.AppendLine("(int32_t handle)"); + builders.CppGlobalStateAndFunctions.AppendLine("\t{"); builders.CppGlobalStateAndFunctions.Append("\t\tassert(handle >= 0 && handle < RefCountsLen"); builders.CppGlobalStateAndFunctions.Append(funcNameSuffix); - builders.CppGlobalStateAndFunctions.Append(");\n"); - builders.CppGlobalStateAndFunctions.Append("\t\tif (handle != 0)\n"); - builders.CppGlobalStateAndFunctions.Append("\t\t{\n"); + builders.CppGlobalStateAndFunctions.AppendLine(");"); + builders.CppGlobalStateAndFunctions.AppendLine("\t\tif (handle != 0)"); + builders.CppGlobalStateAndFunctions.AppendLine("\t\t{"); builders.CppGlobalStateAndFunctions.Append("\t\t\tRefCounts"); builders.CppGlobalStateAndFunctions.Append(funcNameSuffix); - builders.CppGlobalStateAndFunctions.Append("[handle]++;\n"); - builders.CppGlobalStateAndFunctions.Append("\t\t}\n"); - builders.CppGlobalStateAndFunctions.Append("\t}\n"); - builders.CppGlobalStateAndFunctions.Append("\t\n"); + builders.CppGlobalStateAndFunctions.AppendLine("[handle]++;"); + builders.CppGlobalStateAndFunctions.AppendLine("\t\t}"); + builders.CppGlobalStateAndFunctions.AppendLine("\t}"); + builders.CppGlobalStateAndFunctions.AppendLine("\t"); builders.CppGlobalStateAndFunctions.Append("\tvoid DereferenceManaged"); builders.CppGlobalStateAndFunctions.Append(funcNameSuffix); - builders.CppGlobalStateAndFunctions.Append("(int32_t handle)\n"); - builders.CppGlobalStateAndFunctions.Append("\t{\n"); + builders.CppGlobalStateAndFunctions.AppendLine("(int32_t handle)"); + builders.CppGlobalStateAndFunctions.AppendLine("\t{"); builders.CppGlobalStateAndFunctions.Append("\t\tassert(handle >= 0 && handle < RefCountsLen"); builders.CppGlobalStateAndFunctions.Append(funcNameSuffix); - builders.CppGlobalStateAndFunctions.Append(");\n"); - builders.CppGlobalStateAndFunctions.Append("\t\tif (handle != 0)\n"); - builders.CppGlobalStateAndFunctions.Append("\t\t{\n"); + builders.CppGlobalStateAndFunctions.AppendLine(");"); + builders.CppGlobalStateAndFunctions.AppendLine("\t\tif (handle != 0)"); + builders.CppGlobalStateAndFunctions.AppendLine("\t\t{"); builders.CppGlobalStateAndFunctions.Append("\t\t\tint32_t numRemain = --RefCounts"); builders.CppGlobalStateAndFunctions.Append(funcNameSuffix); - builders.CppGlobalStateAndFunctions.Append("[handle];\n"); - builders.CppGlobalStateAndFunctions.Append("\t\t\tif (numRemain == 0)\n"); - builders.CppGlobalStateAndFunctions.Append("\t\t\t{\n"); + builders.CppGlobalStateAndFunctions.AppendLine("[handle];"); + builders.CppGlobalStateAndFunctions.AppendLine("\t\t\tif (numRemain == 0)"); + builders.CppGlobalStateAndFunctions.AppendLine("\t\t\t{"); builders.CppGlobalStateAndFunctions.Append("\t\t\t\tRelease"); builders.CppGlobalStateAndFunctions.Append(funcNameSuffix); - builders.CppGlobalStateAndFunctions.Append("(handle);\n"); - builders.CppGlobalStateAndFunctions.Append("\t\t\t}\n"); - builders.CppGlobalStateAndFunctions.Append("\t\t}\n"); - builders.CppGlobalStateAndFunctions.Append("\t}\n\t\n"); + builders.CppGlobalStateAndFunctions.AppendLine("(handle);"); + builders.CppGlobalStateAndFunctions.AppendLine("\t\t\t}"); + builders.CppGlobalStateAndFunctions.AppendLine("\t\t}"); + builders.CppGlobalStateAndFunctions.AppendLine("\t}"); + builders.CppGlobalStateAndFunctions.AppendLine("\t"); } // C++ type declaration @@ -2036,15 +2044,14 @@ static void AppendEnum( AppendCppPrimitiveTypeName( underlyingType, builders.CppTypeDefinitions); - builders.CppTypeDefinitions.Append(" Value;\n"); + builders.CppTypeDefinitions.AppendLine(" Value;"); // Enumerator fields FieldInfo[] fields = type.GetFields( BindingFlags.Static | BindingFlags.Public); - for (int i = 0; i < fields.Length; ++i) + foreach (FieldInfo field in fields) { - FieldInfo field = fields[i]; AppendIndent( indent + 1, builders.CppTypeDefinitions); @@ -2054,7 +2061,7 @@ static void AppendEnum( builders.CppTypeDefinitions); builders.CppTypeDefinitions.Append(' '); builders.CppTypeDefinitions.Append(field.Name); - builders.CppTypeDefinitions.Append(";\n"); + builders.CppTypeDefinitions.AppendLine(";"); } // Constructor from primitive type @@ -2067,7 +2074,7 @@ static void AppendEnum( AppendCppPrimitiveTypeName( underlyingType, builders.CppTypeDefinitions); - builders.CppTypeDefinitions.Append(" value);\n"); + builders.CppTypeDefinitions.AppendLine(" value);"); // Conversion operator to primitive type AppendIndent( @@ -2077,7 +2084,7 @@ static void AppendEnum( AppendCppPrimitiveTypeName( underlyingType, builders.CppTypeDefinitions); - builders.CppTypeDefinitions.Append("() const;\n"); + builders.CppTypeDefinitions.AppendLine("() const;"); // Equality operator AppendIndent( @@ -2085,7 +2092,7 @@ static void AppendEnum( builders.CppTypeDefinitions); builders.CppTypeDefinitions.Append("bool operator==("); builders.CppTypeDefinitions.Append(type.Name); - builders.CppTypeDefinitions.Append(" other);\n"); + builders.CppTypeDefinitions.AppendLine(" other);"); // Inequality operator AppendIndent( @@ -2093,7 +2100,7 @@ static void AppendEnum( builders.CppTypeDefinitions); builders.CppTypeDefinitions.Append("bool operator!=("); builders.CppTypeDefinitions.Append(type.Name); - builders.CppTypeDefinitions.Append(" other);\n"); + builders.CppTypeDefinitions.AppendLine(" other);"); AppendNamespaceBeginning( type.Namespace, @@ -2110,23 +2117,23 @@ static void AppendEnum( AppendCppPrimitiveTypeName( underlyingType, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append(" value)\n"); + builders.CppMethodDefinitions.AppendLine(" value)"); AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append(": Value(value)\n"); + builders.CppMethodDefinitions.AppendLine(": Value(value)"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.AppendLine("}"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); + builders.CppMethodDefinitions.AppendLine(); // Conversion operator to primitive type AppendIndent( @@ -2139,23 +2146,23 @@ static void AppendEnum( AppendCppPrimitiveTypeName( underlyingType, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("() const\n"); + builders.CppMethodDefinitions.AppendLine("() const"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("return Value;\n"); + builders.CppMethodDefinitions.AppendLine("return Value;"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.AppendLine("}"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); + builders.CppMethodDefinitions.AppendLine();; // Equality operator AppendIndent( @@ -2167,23 +2174,23 @@ static void AppendEnum( builders.CppMethodDefinitions); builders.CppMethodDefinitions.Append("::operator==("); builders.CppMethodDefinitions.Append(type.Name); - builders.CppMethodDefinitions.Append(" other)\n"); + builders.CppMethodDefinitions.AppendLine(" other)"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("return Value == other.Value;\n"); + builders.CppMethodDefinitions.AppendLine("return Value == other.Value;"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.AppendLine("}"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); + builders.CppMethodDefinitions.AppendLine();; // Inequality operator AppendIndent( @@ -2195,23 +2202,23 @@ static void AppendEnum( builders.CppMethodDefinitions); builders.CppMethodDefinitions.Append("::operator!=("); builders.CppMethodDefinitions.Append(type.Name); - builders.CppMethodDefinitions.Append(" other)\n"); + builders.CppMethodDefinitions.AppendLine(" other)"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("return Value != other.Value;\n"); + builders.CppMethodDefinitions.AppendLine("return Value != other.Value;"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.AppendLine("}"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); + builders.CppMethodDefinitions.AppendLine();; AppendBoxing( type, @@ -2226,16 +2233,15 @@ static void AppendEnum( AppendIndent( indent, builders.CppTypeDefinitions); - builders.CppTypeDefinitions.Append("};\n"); + builders.CppTypeDefinitions.AppendLine("};"); AppendNamespaceEnding( indent, builders.CppTypeDefinitions); - builders.CppTypeDefinitions.Append('\n'); + builders.CppTypeDefinitions.AppendLine();; // Static initialization - for (int i = 0; i < fields.Length; ++i) + foreach (FieldInfo field in fields) { - FieldInfo field = fields[i]; builders.CppMethodDefinitions.Append("const "); AppendCppTypeFullName( type, @@ -2249,9 +2255,9 @@ static void AppendEnum( builders.CppMethodDefinitions.Append('('); builders.CppMethodDefinitions.Append( field.GetRawConstantValue()); - builders.CppMethodDefinitions.Append(");\n"); + builders.CppMethodDefinitions.AppendLine(");"); } - builders.CppMethodDefinitions.Append('\n'); + builders.CppMethodDefinitions.AppendLine();; } static void AppendBoxing( @@ -2343,10 +2349,6 @@ static void AppendBoxingBindings( builders.TempStrBuilder); boxFuncName = builders.TempStrBuilder.ToString(); - builders.TempStrBuilder[0] = char.ToLower( - builders.TempStrBuilder[0]); - string boxFuncNameLower = builders.TempStrBuilder.ToString(); - ParameterInfo[] boxParams = { new ParameterInfo { @@ -2361,11 +2363,6 @@ static void AppendBoxingBindings( boxCppParams = new ParameterInfo[0]; - // C# init params - AppendCsharpInitParam( - boxFuncNameLower, - builders.CsharpInitParams); - // C# delegate types AppendCsharpDelegateType( boxFuncName, @@ -2377,9 +2374,10 @@ static void AppendBoxingBindings( builders.CsharpDelegateTypes); // C# init call args - AppendCsharpInitCallArg( + AppendCsharpCsharpDelegate( boxFuncName, - builders.CsharpInitCall); + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); // C# box function AppendCsharpFunctionBeginning( @@ -2410,21 +2408,15 @@ static void AppendBoxingBindings( typeof(object), builders.CppFunctionPointers); - // C++ init params - AppendCppInitParam( - boxFuncNameLower, + // C++ init body + AppendCppInitBodyFunctionPointerParameterRead( + boxFuncName, true, GetTypeName(type), typeKind, boxParams, typeof(object), - builders.CppInitParams); - - // C++ init body - AppendCppInitBody( - boxFuncName, - boxFuncNameLower, - builders.CppInitBody); + builders.CppInitBodyParameterReads); } static void AppendUnboxing( @@ -2443,10 +2435,6 @@ static void AppendUnboxing( builders.TempStrBuilder); string unboxFuncName = builders.TempStrBuilder.ToString(); - builders.TempStrBuilder[0] = char.ToLower( - builders.TempStrBuilder[0]); - string unboxFuncNameLower = builders.TempStrBuilder.ToString(); - builders.TempStrBuilder.Length = 0; builders.TempStrBuilder.Append("operator "); AppendCppTypeFullName( @@ -2474,10 +2462,7 @@ static void AppendUnboxing( ParameterInfo[] unboxCppParams = new ParameterInfo[0]; // C# init params - AppendCsharpInitParam( - unboxFuncNameLower, - builders.CsharpInitParams); - + // C# delegate types AppendCsharpDelegateType( unboxFuncName, @@ -2489,9 +2474,10 @@ static void AppendUnboxing( builders.CsharpDelegateTypes); // C# init call args - AppendCsharpInitCallArg( + AppendCsharpCsharpDelegate( unboxFuncName, - builders.CsharpInitCall); + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); // C# unbox function AppendCsharpFunctionBeginning( @@ -2569,7 +2555,7 @@ static void AppendUnboxing( AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendIndent( indent + 1, builders.CppMethodDefinitions); @@ -2583,39 +2569,34 @@ static void AppendUnboxing( } builders.CppMethodDefinitions.Append("Plugin::"); builders.CppMethodDefinitions.Append(unboxFuncName); - builders.CppMethodDefinitions.Append("(Handle));\n"); + builders.CppMethodDefinitions.AppendLine("(Handle));"); AppendCppUnhandledExceptionHandling( indent + 1, builders.CppMethodDefinitions); AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("return returnVal;\n"); + builders.CppMethodDefinitions.AppendLine("return returnVal;"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n\t\n"); + builders.CppMethodDefinitions.AppendLine("}"); + builders.CppMethodDefinitions.AppendLine("\t"); // C++ method definitions (end) AppendCppMethodDefinitionsEnd( indent, builders.CppMethodDefinitions); - // C++ init params - AppendCppInitParam( - unboxFuncNameLower, + // C++ init body + AppendCppInitBodyFunctionPointerParameterRead( + unboxFuncName, true, GetTypeName(type), typeKind, unboxParams, type, - builders.CppInitParams); - - // C++ init body - AppendCppInitBody( - unboxFuncName, - unboxFuncNameLower, - builders.CppInitBody); + builders.CppInitBodyParameterReads); } static void AppendCppBoxingMethodNames( @@ -2680,7 +2661,7 @@ static void AppendCppBoxingMethodDefinition( AppendIndent( indent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( indent + 1, output); @@ -2695,20 +2676,20 @@ static void AppendCppBoxingMethodDefinition( { output.Append("*this"); } - output.Append(");\n"); + output.AppendLine(");"); AppendCppUnhandledExceptionHandling( indent + 1, output); AppendIndent( indent + 1, output); - output.Append( - "if (handle)\n"); + output.AppendLine( + "if (handle)"); AppendIndent( indent + 1, output); - output.Append( - "{\n"); + output.AppendLine( + "{"); AppendIndent( indent + 2, output); @@ -2718,7 +2699,7 @@ static void AppendCppBoxingMethodDefinition( null, "handle", output); - output.Append(";\n"); + output.AppendLine(";"); AppendIndent( indent + 2, output); @@ -2726,24 +2707,24 @@ static void AppendCppBoxingMethodDefinition( AppendCppTypeFullName( boxedType, output); - output.Append("(Plugin::InternalUse::Only, handle);\n"); + output.AppendLine("(Plugin::InternalUse::Only, handle);"); AppendIndent( indent + 1, output); - output.Append( - "}\n"); + output.AppendLine( + "}"); AppendIndent( indent + 1, output); - output.Append("return nullptr;\n"); + output.AppendLine("return nullptr;"); AppendIndent( indent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( indent, output); - output.Append('\n'); + output.AppendLine();; } static void AppendHandleStoreTypeName( @@ -2828,11 +2809,6 @@ static void AppendConstructor( builders.TempStrBuilder); string funcName = builders.TempStrBuilder.ToString(); - // Build lowercase function name - builders.TempStrBuilder[0] = char.ToLower( - builders.TempStrBuilder[0]); - string funcNameLower = builders.TempStrBuilder.ToString(); - TypeName enclosingTypeTypeName = GetTypeName(enclosingType); // Build C++ constructor method name @@ -2843,9 +2819,6 @@ static void AppendConstructor( string cppMethodName = builders.TempStrBuilder.ToString(); // C# init param declaration - AppendCsharpInitParam( - funcNameLower, - builders.CsharpInitParams); // C# delegate type Type delegateReturnType; @@ -2867,7 +2840,10 @@ static void AppendConstructor( builders.CsharpDelegateTypes); // C# init call param - AppendCsharpInitCallArg(funcName, builders.CsharpInitCall); + AppendCsharpCsharpDelegate( + funcName, + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); // C# function if (enclosingTypeKind == TypeKind.FullStruct) @@ -2973,7 +2949,7 @@ static void AppendConstructor( AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendCppPluginFunctionCall( true, GetTypeName(enclosingType), @@ -2989,26 +2965,26 @@ static void AppendConstructor( AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "*this = returnValue;\n"); + builders.CppMethodDefinitions.AppendLine( + "*this = returnValue;"); } else { AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "Handle = returnValue;\n"); + builders.CppMethodDefinitions.AppendLine( + "Handle = returnValue;"); AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "if (returnValue)\n"); + builders.CppMethodDefinitions.AppendLine( + "if (returnValue)"); AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "{\n"); + builders.CppMethodDefinitions.AppendLine( + "{"); AppendIndent( indent + 2, builders.CppMethodDefinitions); @@ -3018,37 +2994,31 @@ static void AppendConstructor( enclosingTypeParams, "returnValue", builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append(";\n"); + builders.CppMethodDefinitions.AppendLine(";"); AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "}\n"); + builders.CppMethodDefinitions.AppendLine( + "}"); } AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.AppendLine("}"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); - - // C++ init params - AppendCppInitParam( - funcNameLower, + builders.CppMethodDefinitions.AppendLine();; + + // C++ init body + AppendCppInitBodyFunctionPointerParameterRead( + funcName, true, GetTypeName(enclosingType), enclosingTypeKind, parameters, enclosingType, - builders.CppInitParams); - - // C++ init body - AppendCppInitBody( - funcName, - funcNameLower, - builders.CppInitBody); + builders.CppInitBodyParameterReads); } static void AppendProperty( @@ -3229,7 +3199,7 @@ static void AppendFullValueTypeDefaultConstructor( AppendTypeNameWithoutGenericSuffix( enclosingType.Name, builders.CppTypeDefinitions); - builders.CppTypeDefinitions.Append("();\n"); + builders.CppTypeDefinitions.AppendLine("();"); AppendIndent( indent, @@ -3241,19 +3211,19 @@ static void AppendFullValueTypeDefaultConstructor( AppendTypeNameWithoutGenericSuffix( enclosingType.Name, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("()\n"); + builders.CppMethodDefinitions.AppendLine("()"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.AppendLine("}"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); + builders.CppMethodDefinitions.AppendLine();; } static void AppendFullValueTypeFields( @@ -3276,7 +3246,7 @@ static void AppendFullValueTypeFields( builders.CppTypeDefinitions); builders.CppTypeDefinitions.Append(' '); builders.CppTypeDefinitions.Append(field.Name); - builders.CppTypeDefinitions.Append(";\n"); + builders.CppTypeDefinitions.AppendLine(";"); } } @@ -3419,20 +3389,13 @@ static void AppendEventAddRemoveMethod( builders.TempStrBuilder.Append(uppercaseEventName); string funcName = builders.TempStrBuilder.ToString(); - builders.TempStrBuilder[0] = char.ToLower( - builders.TempStrBuilder[0]); - string funcNameLower = builders.TempStrBuilder.ToString(); - builders.TempStrBuilder.Length = 0; builders.TempStrBuilder.Append(operation); builders.TempStrBuilder.Append(uppercaseEventName); string methodName = builders.TempStrBuilder.ToString(); // C# init param - AppendCsharpInitParam( - funcNameLower, - builders.CsharpInitParams); - + // C# delegate type AppendCsharpDelegateType( funcName, @@ -3444,9 +3407,10 @@ static void AppendEventAddRemoveMethod( builders.CsharpDelegateTypes); // C# init call arg - AppendCsharpInitCallArg( + AppendCsharpCsharpDelegate( funcName, - builders.CsharpInitCall); + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); // C# function AppendCsharpFunctionBeginning( @@ -3463,7 +3427,15 @@ static void AppendEventAddRemoveMethod( builders.CsharpFunctions); builders.CsharpFunctions.Append('.'); builders.CsharpFunctions.Append(eventName); - builders.CsharpFunctions.Append(" += del;"); + // TODO: More safely differenciate between add/removing event delegates + if (funcName.Contains("RemoveEvent")) + { + builders.CsharpFunctions.Append(" -= del;"); + } + else + { + builders.CsharpFunctions.Append(" += del;"); + } AppendCsharpFunctionEnd( typeof(void), null, @@ -3512,7 +3484,7 @@ static void AppendEventAddRemoveMethod( AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendCppPluginFunctionCall( methodIsStatic, GetTypeName(enclosingType), @@ -3526,23 +3498,18 @@ static void AppendEventAddRemoveMethod( AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n\t\n"); + builders.CppMethodDefinitions.AppendLine("}"); + builders.CppMethodDefinitions.AppendLine("\t"); - // C++ init params - AppendCppInitParam( - funcNameLower, + // C++ init body + AppendCppInitBodyFunctionPointerParameterRead( + funcName, methodIsStatic, GetTypeName(enclosingType), enclosingTypeKind, methodParams, typeof(void), - builders.CppInitParams); - - // C++ init body - AppendCppInitBody( - funcName, - funcNameLower, - builders.CppInitBody); + builders.CppInitBodyParameterReads); } static MethodInfo GetMethod( @@ -3845,16 +3812,8 @@ static void AppendMethod( builders.TempStrBuilder); string funcName = builders.TempStrBuilder.ToString(); - // Build lowercase function name - builders.TempStrBuilder[0] = char.ToLower( - builders.TempStrBuilder[0]); - string funcNameLower = builders.TempStrBuilder.ToString(); - // C# init param declaration - AppendCsharpInitParam( - funcNameLower, - builders.CsharpInitParams); - + // C# delegate type AppendCsharpDelegateType( funcName, @@ -3866,9 +3825,10 @@ static void AppendMethod( builders.CsharpDelegateTypes); // C# init call param - AppendCsharpInitCallArg( + AppendCsharpCsharpDelegate( funcName, - builders.CsharpInitCall); + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); // C# function AppendCsharpFunctionBeginning( @@ -4203,7 +4163,8 @@ static void AppendMethod( AppendCppMethodDeclaration( cppMethodName, enclosingTypeIsStatic, - false, + // Mark as virtual if method/class is not static or generic + cppMethodIsStatic || enclosingTypeIsStatic || methodTypeParams != null? false : true, cppMethodIsStatic, cppReturnType, methodTypeParams, @@ -4224,7 +4185,7 @@ static void AppendMethod( AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendCppPluginFunctionCall( methodIsStatic, GetTypeName(enclosingType), @@ -4243,29 +4204,23 @@ static void AppendMethod( AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n\t\n"); + builders.CppMethodDefinitions.AppendLine("}"); + builders.CppMethodDefinitions.AppendLine("\t"); - // C++ init params - AppendCppInitParam( - funcNameLower, + // C++ init body + AppendCppInitBodyFunctionPointerParameterRead( + funcName, methodIsStatic, GetTypeName(enclosingType), enclosingTypeKind, parameters, returnType, - builders.CppInitParams); - - // C++ init body - AppendCppInitBody( - funcName, - funcNameLower, - builders.CppInitBody); + builders.CppInitBodyParameterReads); } static void AppendCSharpTypeParameters( Type[] typeParams, - StringBuilder output - ) + StringBuilder output) { if (typeParams != null && typeParams.Length > 0) { @@ -4336,7 +4291,7 @@ static void AppendCppFunctionCall( } output.Append('('); output.Append(param.Name); - output.Append(");\n"); + output.AppendLine(");"); } } if (!enclosingTypeIsStatic) @@ -4344,8 +4299,8 @@ static void AppendCppFunctionCall( AppendIndent( indent, output); - output.Append( - "int thisHandle = NativeScript.Bindings.ObjectStore.GetHandle(this);\n"); + output.AppendLine( + "int thisHandle = NativeScript.Bindings.ObjectStore.GetHandle(this);"); } AppendIndent( indent, @@ -4379,31 +4334,31 @@ static void AppendCppFunctionCall( output.Append(", "); } } - output.Append(");\n"); + output.AppendLine(");"); AppendIndent( indent, output); - output.Append("if (NativeScript.Bindings.UnhandledCppException != null)\n"); + output.AppendLine("if (NativeScript.Bindings.UnhandledCppException != null)"); AppendIndent( indent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( indent + 1, output); - output.Append("Exception ex = NativeScript.Bindings.UnhandledCppException;\n"); + output.AppendLine("Exception ex = NativeScript.Bindings.UnhandledCppException;"); AppendIndent( indent + 1, output); - output.Append("NativeScript.Bindings.UnhandledCppException = null;\n"); + output.AppendLine("NativeScript.Bindings.UnhandledCppException = null;"); AppendIndent( indent + 1, output); - output.Append("throw ex;\n"); + output.AppendLine("throw ex;"); AppendIndent( indent, output); - output.Append("}\n"); + output.AppendLine("}"); } static void AppendArray( @@ -4512,9 +4467,7 @@ static void AppendArray( GetTypeName(cppArrayTypeName, "System"), false, cppTypeParams, - cppTypeParams != null ? - builders.CppTemplateSpecializationDeclarations : - builders.CppTypeDeclarations); + builders.CppTemplateSpecializationDeclarations); // C++ type definition (beginning) Type[] interfaceTypes = GetDirectInterfaces(arrayType); @@ -4533,6 +4486,7 @@ static void AppendArray( Type[] cppCtorInitTypes = GetCppCtorInitTypes( arrayType, false); + int localRank = rank; int cppMethodDefinitionsIndent = AppendCppMethodDefinitionsBegin( GetTypeName(cppArrayTypeName, "System"), TypeKind.Class, @@ -4544,11 +4498,11 @@ static void AppendArray( extraIndent, builders.CppMethodDefinitions); builders.CppMethodDefinitions.Append(subject); - builders.CppMethodDefinitions.Append( - "InternalLength = 0;\n"); - if (rank > 1) + builders.CppMethodDefinitions.AppendLine( + "InternalLength = 0;"); + if (localRank > 1) { - for (int i = 0; i < rank; ++i) + for (int i = 0; i < localRank; ++i) { AppendIndent( extraIndent, @@ -4557,8 +4511,8 @@ static void AppendArray( builders.CppMethodDefinitions.Append( "InternalLengths["); builders.CppMethodDefinitions.Append(i); - builders.CppMethodDefinitions.Append( - "] = 0;\n"); + builders.CppMethodDefinitions.AppendLine( + "] = 0;"); } } }, @@ -4569,11 +4523,11 @@ static void AppendArray( builders.CppMethodDefinitions.Append( "InternalLength = "); builders.CppMethodDefinitions.Append(subject); - builders.CppMethodDefinitions.Append( - "InternalLength;\n"); - if (rank > 1) + builders.CppMethodDefinitions.AppendLine( + "InternalLength;"); + if (localRank > 1) { - for (int i = 0; i < rank; ++i) + for (int i = 0; i < localRank; ++i) { AppendIndent( extraIndent, @@ -4587,8 +4541,8 @@ static void AppendArray( builders.CppMethodDefinitions.Append( "InternalLengths["); builders.CppMethodDefinitions.Append(i); - builders.CppMethodDefinitions.Append( - "];\n"); + builders.CppMethodDefinitions.AppendLine( + "];"); } } }, @@ -4599,8 +4553,8 @@ static void AppendArray( AppendIndent( indent + 1, builders.CppTypeDefinitions); - builders.CppTypeDefinitions.Append( - "int32_t InternalLength;\n"); + builders.CppTypeDefinitions.AppendLine( + "int32_t InternalLength;"); if (rank > 1) { AppendIndent( @@ -4609,7 +4563,7 @@ static void AppendArray( builders.CppTypeDefinitions.Append( "int32_t InternalLengths["); builders.CppTypeDefinitions.Append(rank); - builders.CppTypeDefinitions.Append("];\n"); + builders.CppTypeDefinitions.AppendLine("];"); } AppendArrayConstructor( @@ -4678,7 +4632,7 @@ static void AppendArray( AppendTypeNameWithoutGenericSuffix( "operator[]", builders.CppTypeDefinitions); - builders.CppTypeDefinitions.Append("(int32_t index);\n"); + builders.CppTypeDefinitions.AppendLine("(int32_t index);"); // C++ operator[] method definition AppendCppArrayIndexOperatorMethodDefinition( @@ -4719,88 +4673,88 @@ static void AppendArrayIterator( StringBuilder cppMethodDefinitions) { // Iterator type definition - cppTypeDefinitions.Append("namespace Plugin\n"); - cppTypeDefinitions.Append("{\n"); + cppTypeDefinitions.AppendLine("namespace Plugin"); + cppTypeDefinitions.AppendLine("{"); cppTypeDefinitions.Append("\tstruct "); cppTypeDefinitions.Append(bindingArrayTypeName); - cppTypeDefinitions.Append("Iterator\n"); - cppTypeDefinitions.Append("\t{\n"); + cppTypeDefinitions.AppendLine("Iterator"); + cppTypeDefinitions.AppendLine("\t{"); cppTypeDefinitions.Append("\t\tSystem::"); cppTypeDefinitions.Append(cppGenericArrayTypeName); - cppTypeDefinitions.Append("& array;\n"); - cppTypeDefinitions.Append("\t\tint index;\n"); + cppTypeDefinitions.AppendLine("& array;"); + cppTypeDefinitions.AppendLine("\t\tint index;"); cppTypeDefinitions.Append("\t\t"); cppTypeDefinitions.Append(bindingArrayTypeName); cppTypeDefinitions.Append("Iterator(System::"); cppTypeDefinitions.Append(cppGenericArrayTypeName); - cppTypeDefinitions.Append("& array, int32_t index);\n"); + cppTypeDefinitions.AppendLine("& array, int32_t index);"); cppTypeDefinitions.Append("\t\t"); cppTypeDefinitions.Append(bindingArrayTypeName); - cppTypeDefinitions.Append("Iterator& operator++();\n"); + cppTypeDefinitions.AppendLine("Iterator& operator++();"); cppTypeDefinitions.Append("\t\tbool operator!=(const "); cppTypeDefinitions.Append(bindingArrayTypeName); - cppTypeDefinitions.Append("Iterator& other);\n"); + cppTypeDefinitions.AppendLine("Iterator& other);"); cppTypeDefinitions.Append("\t\t"); AppendCppTypeFullName( elementType, cppTypeDefinitions); - cppTypeDefinitions.Append(" operator*();\n"); - cppTypeDefinitions.Append("\t};\n"); - cppTypeDefinitions.Append("}\n"); - cppTypeDefinitions.Append('\n'); + cppTypeDefinitions.AppendLine(" operator*();"); + cppTypeDefinitions.AppendLine("\t};"); + cppTypeDefinitions.AppendLine("}"); + cppTypeDefinitions.AppendLine();; // begin() and end() declarations - cppTypeDefinitions.Append("namespace System\n"); - cppTypeDefinitions.Append("{\n"); + cppTypeDefinitions.AppendLine("namespace System"); + cppTypeDefinitions.AppendLine("{"); cppTypeDefinitions.Append("\tPlugin::"); cppTypeDefinitions.Append(bindingArrayTypeName); cppTypeDefinitions.Append("Iterator begin(System::"); cppTypeDefinitions.Append(cppGenericArrayTypeName); - cppTypeDefinitions.Append("& array);\n"); + cppTypeDefinitions.AppendLine("& array);"); cppTypeDefinitions.Append("\tPlugin::"); cppTypeDefinitions.Append(bindingArrayTypeName); cppTypeDefinitions.Append("Iterator end(System::"); cppTypeDefinitions.Append(cppGenericArrayTypeName); - cppTypeDefinitions.Append("& array);\n"); - cppTypeDefinitions.Append("}\n"); - cppTypeDefinitions.Append('\n'); + cppTypeDefinitions.AppendLine("& array);"); + cppTypeDefinitions.AppendLine("}"); + cppTypeDefinitions.AppendLine();; // Iterator method definitions - cppMethodDefinitions.Append("namespace Plugin\n"); - cppMethodDefinitions.Append("{\n"); + cppMethodDefinitions.AppendLine("namespace Plugin"); + cppMethodDefinitions.AppendLine("{"); cppMethodDefinitions.Append('\t'); cppMethodDefinitions.Append(bindingArrayTypeName); cppMethodDefinitions.Append("Iterator::"); cppMethodDefinitions.Append(bindingArrayTypeName); cppMethodDefinitions.Append("Iterator(System::"); cppMethodDefinitions.Append(cppGenericArrayTypeName); - cppMethodDefinitions.Append("& array, int32_t index)\n"); - cppMethodDefinitions.Append("\t\t: array(array)\n"); - cppMethodDefinitions.Append("\t\t, index(index)\n"); - cppMethodDefinitions.Append("\t{\n"); - cppMethodDefinitions.Append("\t}\n"); - cppMethodDefinitions.Append("\t\n"); + cppMethodDefinitions.AppendLine("& array, int32_t index)"); + cppMethodDefinitions.AppendLine("\t\t: array(array)"); + cppMethodDefinitions.AppendLine("\t\t, index(index)"); + cppMethodDefinitions.AppendLine("\t{"); + cppMethodDefinitions.AppendLine("\t}"); + cppMethodDefinitions.AppendLine("\t"); cppMethodDefinitions.Append('\t'); cppMethodDefinitions.Append(bindingArrayTypeName); cppMethodDefinitions.Append("Iterator& "); cppMethodDefinitions.Append(bindingArrayTypeName); cppMethodDefinitions.Append("Iterator::"); - cppMethodDefinitions.Append("operator++()\n"); - cppMethodDefinitions.Append("\t{\n"); - cppMethodDefinitions.Append("\t\tindex++;\n"); - cppMethodDefinitions.Append("\t\treturn *this;\n"); - cppMethodDefinitions.Append("\t}\n"); - cppMethodDefinitions.Append("\t\n"); + cppMethodDefinitions.AppendLine("operator++()"); + cppMethodDefinitions.AppendLine("\t{"); + cppMethodDefinitions.AppendLine("\t\tindex++;"); + cppMethodDefinitions.AppendLine("\t\treturn *this;"); + cppMethodDefinitions.AppendLine("\t}"); + cppMethodDefinitions.AppendLine("\t"); cppMethodDefinitions.Append("\tbool "); cppMethodDefinitions.Append(bindingArrayTypeName); cppMethodDefinitions.Append("Iterator::"); cppMethodDefinitions.Append("operator!=(const "); cppMethodDefinitions.Append(bindingArrayTypeName); - cppMethodDefinitions.Append("Iterator& other)\n"); - cppMethodDefinitions.Append("\t{\n"); - cppMethodDefinitions.Append("\t\treturn index != other.index;\n"); - cppMethodDefinitions.Append("\t}\n"); - cppMethodDefinitions.Append("\t\n"); + cppMethodDefinitions.AppendLine("Iterator& other)"); + cppMethodDefinitions.AppendLine("\t{"); + cppMethodDefinitions.AppendLine("\t\treturn index != other.index;"); + cppMethodDefinitions.AppendLine("\t}"); + cppMethodDefinitions.AppendLine("\t"); cppMethodDefinitions.Append('\t'); AppendCppTypeFullName( elementType, @@ -4808,39 +4762,39 @@ static void AppendArrayIterator( cppMethodDefinitions.Append(' '); cppMethodDefinitions.Append(bindingArrayTypeName); cppMethodDefinitions.Append("Iterator::"); - cppMethodDefinitions.Append("operator*()\n"); - cppMethodDefinitions.Append("\t{\n"); - cppMethodDefinitions.Append("\t\treturn array[index];\n"); - cppMethodDefinitions.Append("\t}\n"); - cppMethodDefinitions.Append("}\n"); - cppMethodDefinitions.Append('\n'); + cppMethodDefinitions.AppendLine("operator*()"); + cppMethodDefinitions.AppendLine("\t{"); + cppMethodDefinitions.AppendLine("\t\treturn array[index];"); + cppMethodDefinitions.AppendLine("\t}"); + cppMethodDefinitions.AppendLine("}"); + cppMethodDefinitions.AppendLine();; // begin() and end() definitions - cppMethodDefinitions.Append("namespace System\n"); - cppMethodDefinitions.Append("{\n"); + cppMethodDefinitions.AppendLine("namespace System"); + cppMethodDefinitions.AppendLine("{"); cppMethodDefinitions.Append("\tPlugin::"); cppMethodDefinitions.Append(bindingArrayTypeName); cppMethodDefinitions.Append("Iterator begin(System::"); cppMethodDefinitions.Append(cppGenericArrayTypeName); - cppMethodDefinitions.Append("& array)\n"); - cppMethodDefinitions.Append("\t{\n"); + cppMethodDefinitions.AppendLine("& array)"); + cppMethodDefinitions.AppendLine("\t{"); cppMethodDefinitions.Append("\t\treturn Plugin::"); cppMethodDefinitions.Append(bindingArrayTypeName); - cppMethodDefinitions.Append("Iterator(array, 0);\n"); - cppMethodDefinitions.Append("\t}\n"); - cppMethodDefinitions.Append("\t\n"); + cppMethodDefinitions.AppendLine("Iterator(array, 0);"); + cppMethodDefinitions.AppendLine("\t}"); + cppMethodDefinitions.AppendLine("\t"); cppMethodDefinitions.Append("\tPlugin::"); cppMethodDefinitions.Append(bindingArrayTypeName); cppMethodDefinitions.Append("Iterator end(System::"); cppMethodDefinitions.Append(cppGenericArrayTypeName); - cppMethodDefinitions.Append("& array)\n"); - cppMethodDefinitions.Append("\t{\n"); + cppMethodDefinitions.AppendLine("& array)"); + cppMethodDefinitions.AppendLine("\t{"); cppMethodDefinitions.Append("\t\treturn Plugin::"); cppMethodDefinitions.Append(bindingArrayTypeName); - cppMethodDefinitions.Append("Iterator(array, array.GetLength() - 1);\n"); - cppMethodDefinitions.Append("\t}\n"); - cppMethodDefinitions.Append("}\n"); - cppMethodDefinitions.Append('\n'); + cppMethodDefinitions.AppendLine("Iterator(array, array.GetLength() - 1);"); + cppMethodDefinitions.AppendLine("\t}"); + cppMethodDefinitions.AppendLine("}"); + cppMethodDefinitions.AppendLine();; } static void AppendGenericEnumerableIterator( @@ -4852,45 +4806,45 @@ static void AppendGenericEnumerableIterator( StringBuilder cppMethodDefinitions) { // Iterator type definition - cppTypeDefinitions.Append("namespace Plugin\n"); - cppTypeDefinitions.Append("{\n"); + cppTypeDefinitions.AppendLine("namespace Plugin"); + cppTypeDefinitions.AppendLine("{"); cppTypeDefinitions.Append("\tstruct "); cppTypeDefinitions.Append(bindingEnumerableTypeName); - cppTypeDefinitions.Append("Iterator\n"); - cppTypeDefinitions.Append("\t{\n"); + cppTypeDefinitions.AppendLine("Iterator"); + cppTypeDefinitions.AppendLine("\t{"); cppTypeDefinitions.Append("\t\t"); AppendCppTypeFullName( enumeratorType, cppTypeDefinitions); - cppTypeDefinitions.Append(" enumerator;\n"); - cppTypeDefinitions.Append("\t\tbool hasMore;\n"); + cppTypeDefinitions.AppendLine(" enumerator;"); + cppTypeDefinitions.AppendLine("\t\tbool hasMore;"); cppTypeDefinitions.Append("\t\t"); cppTypeDefinitions.Append(bindingEnumerableTypeName); - cppTypeDefinitions.Append("Iterator(decltype(nullptr));\n"); + cppTypeDefinitions.AppendLine("Iterator(decltype(nullptr));"); cppTypeDefinitions.Append("\t\t"); cppTypeDefinitions.Append(bindingEnumerableTypeName); cppTypeDefinitions.Append("Iterator("); AppendCppTypeFullName( enumerableType, cppTypeDefinitions); - cppTypeDefinitions.Append("& enumerable);\n"); + cppTypeDefinitions.AppendLine("& enumerable);"); cppTypeDefinitions.Append("\t\t~"); cppTypeDefinitions.Append(bindingEnumerableTypeName); - cppTypeDefinitions.Append("Iterator();\n"); + cppTypeDefinitions.AppendLine("Iterator();"); cppTypeDefinitions.Append("\t\t"); cppTypeDefinitions.Append(bindingEnumerableTypeName); - cppTypeDefinitions.Append("Iterator& operator++();\n"); + cppTypeDefinitions.AppendLine("Iterator& operator++();"); cppTypeDefinitions.Append("\t\tbool operator!=(const "); cppTypeDefinitions.Append(bindingEnumerableTypeName); - cppTypeDefinitions.Append("Iterator& other);\n"); + cppTypeDefinitions.AppendLine("Iterator& other);"); cppTypeDefinitions.Append("\t\t"); AppendCppTypeFullName( elementType, cppTypeDefinitions); - cppTypeDefinitions.Append(" operator*();\n"); - cppTypeDefinitions.Append("\t};\n"); - cppTypeDefinitions.Append("}\n"); - cppTypeDefinitions.Append('\n'); + cppTypeDefinitions.AppendLine(" operator*();"); + cppTypeDefinitions.AppendLine("\t};"); + cppTypeDefinitions.AppendLine("}"); + cppTypeDefinitions.AppendLine();; // begin() and end() declarations int indent = AppendNamespaceBeginning( @@ -4905,7 +4859,7 @@ static void AppendGenericEnumerableIterator( AppendCppTypeFullName( enumerableType, cppTypeDefinitions); - cppTypeDefinitions.Append("& enumerable);\n"); + cppTypeDefinitions.AppendLine("& enumerable);"); AppendIndent( indent, cppTypeDefinitions); @@ -4915,25 +4869,25 @@ static void AppendGenericEnumerableIterator( AppendCppTypeFullName( enumerableType, cppTypeDefinitions); - cppTypeDefinitions.Append("& enumerable);\n"); + cppTypeDefinitions.AppendLine("& enumerable);"); AppendNamespaceEnding( indent, cppTypeDefinitions); - cppTypeDefinitions.Append('\n'); + cppTypeDefinitions.AppendLine();; // Iterator method definitions - cppMethodDefinitions.Append("namespace Plugin\n"); - cppMethodDefinitions.Append("{\n"); + cppMethodDefinitions.AppendLine("namespace Plugin"); + cppMethodDefinitions.AppendLine("{"); cppMethodDefinitions.Append('\t'); cppMethodDefinitions.Append(bindingEnumerableTypeName); cppMethodDefinitions.Append("Iterator::"); cppMethodDefinitions.Append(bindingEnumerableTypeName); - cppMethodDefinitions.Append("Iterator(decltype(nullptr))\n"); - cppMethodDefinitions.Append("\t\t: enumerator(nullptr)\n"); - cppMethodDefinitions.Append("\t\t, hasMore(false)\n"); - cppMethodDefinitions.Append("\t{\n"); - cppMethodDefinitions.Append("\t}\n"); - cppMethodDefinitions.Append("\t\n"); + cppMethodDefinitions.AppendLine("Iterator(decltype(nullptr))"); + cppMethodDefinitions.AppendLine("\t\t: enumerator(nullptr)"); + cppMethodDefinitions.AppendLine("\t\t, hasMore(false)"); + cppMethodDefinitions.AppendLine("\t{"); + cppMethodDefinitions.AppendLine("\t}"); + cppMethodDefinitions.AppendLine("\t"); cppMethodDefinitions.Append('\t'); cppMethodDefinitions.Append(bindingEnumerableTypeName); cppMethodDefinitions.Append("Iterator::"); @@ -4942,45 +4896,45 @@ static void AppendGenericEnumerableIterator( AppendCppTypeFullName( enumerableType, cppMethodDefinitions); - cppMethodDefinitions.Append("& enumerable)\n"); - cppMethodDefinitions.Append("\t\t: enumerator(enumerable.GetEnumerator())\n"); - cppMethodDefinitions.Append("\t{\n"); - cppMethodDefinitions.Append("\t\thasMore = enumerator.MoveNext();\n"); - cppMethodDefinitions.Append("\t}\n"); - cppMethodDefinitions.Append("\t\n"); + cppMethodDefinitions.AppendLine("& enumerable)"); + cppMethodDefinitions.AppendLine("\t\t: enumerator(enumerable.GetEnumerator())"); + cppMethodDefinitions.AppendLine("\t{"); + cppMethodDefinitions.AppendLine("\t\thasMore = enumerator.MoveNext();"); + cppMethodDefinitions.AppendLine("\t}"); + cppMethodDefinitions.AppendLine("\t"); cppMethodDefinitions.Append('\t'); cppMethodDefinitions.Append(bindingEnumerableTypeName); cppMethodDefinitions.Append("Iterator::~"); cppMethodDefinitions.Append(bindingEnumerableTypeName); - cppMethodDefinitions.Append("Iterator()\n"); - cppMethodDefinitions.Append("\t{\n"); - cppMethodDefinitions.Append("\t\tif (enumerator != nullptr)\n"); - cppMethodDefinitions.Append("\t\t{\n"); - cppMethodDefinitions.Append("\t\t\tenumerator.Dispose();\n"); - cppMethodDefinitions.Append("\t\t}\n"); - cppMethodDefinitions.Append("\t}\n"); - cppMethodDefinitions.Append("\t\n"); + cppMethodDefinitions.AppendLine("Iterator()"); + cppMethodDefinitions.AppendLine("\t{"); + cppMethodDefinitions.AppendLine("\t\tif (enumerator != nullptr)"); + cppMethodDefinitions.AppendLine("\t\t{"); + cppMethodDefinitions.AppendLine("\t\t\tenumerator.Dispose();"); + cppMethodDefinitions.AppendLine("\t\t}"); + cppMethodDefinitions.AppendLine("\t}"); + cppMethodDefinitions.AppendLine("\t"); cppMethodDefinitions.Append('\t'); cppMethodDefinitions.Append(bindingEnumerableTypeName); cppMethodDefinitions.Append("Iterator& "); cppMethodDefinitions.Append(bindingEnumerableTypeName); cppMethodDefinitions.Append("Iterator::"); - cppMethodDefinitions.Append("operator++()\n"); - cppMethodDefinitions.Append("\t{\n"); - cppMethodDefinitions.Append("\t\thasMore = enumerator.MoveNext();\n"); - cppMethodDefinitions.Append("\t\treturn *this;\n"); - cppMethodDefinitions.Append("\t}\n"); - cppMethodDefinitions.Append("\t\n"); + cppMethodDefinitions.AppendLine("operator++()"); + cppMethodDefinitions.AppendLine("\t{"); + cppMethodDefinitions.AppendLine("\t\thasMore = enumerator.MoveNext();"); + cppMethodDefinitions.AppendLine("\t\treturn *this;"); + cppMethodDefinitions.AppendLine("\t}"); + cppMethodDefinitions.AppendLine("\t"); cppMethodDefinitions.Append("\tbool "); cppMethodDefinitions.Append(bindingEnumerableTypeName); cppMethodDefinitions.Append("Iterator::"); cppMethodDefinitions.Append("operator!=(const "); cppMethodDefinitions.Append(bindingEnumerableTypeName); - cppMethodDefinitions.Append("Iterator& other)\n"); - cppMethodDefinitions.Append("\t{\n"); - cppMethodDefinitions.Append("\t\treturn hasMore;\n"); - cppMethodDefinitions.Append("\t}\n"); - cppMethodDefinitions.Append("\t\n"); + cppMethodDefinitions.AppendLine("Iterator& other)"); + cppMethodDefinitions.AppendLine("\t{"); + cppMethodDefinitions.AppendLine("\t\treturn hasMore;"); + cppMethodDefinitions.AppendLine("\t}"); + cppMethodDefinitions.AppendLine("\t"); cppMethodDefinitions.Append('\t'); AppendCppTypeFullName( elementType, @@ -4988,12 +4942,12 @@ static void AppendGenericEnumerableIterator( cppMethodDefinitions.Append(' '); cppMethodDefinitions.Append(bindingEnumerableTypeName); cppMethodDefinitions.Append("Iterator::"); - cppMethodDefinitions.Append("operator*()\n"); - cppMethodDefinitions.Append("\t{\n"); - cppMethodDefinitions.Append("\t\treturn enumerator.GetCurrent();\n"); - cppMethodDefinitions.Append("\t}\n"); - cppMethodDefinitions.Append("}\n"); - cppMethodDefinitions.Append('\n'); + cppMethodDefinitions.AppendLine("operator*()"); + cppMethodDefinitions.AppendLine("\t{"); + cppMethodDefinitions.AppendLine("\t\treturn enumerator.GetCurrent();"); + cppMethodDefinitions.AppendLine("\t}"); + cppMethodDefinitions.AppendLine("}"); + cppMethodDefinitions.AppendLine();; // begin() and end() definitions indent = AppendNamespaceBeginning( @@ -5008,25 +4962,25 @@ static void AppendGenericEnumerableIterator( AppendCppTypeFullName( enumerableType, cppMethodDefinitions); - cppMethodDefinitions.Append("& enumerable)\n"); + cppMethodDefinitions.AppendLine("& enumerable)"); AppendIndent( indent, cppMethodDefinitions); - cppMethodDefinitions.Append("{\n"); + cppMethodDefinitions.AppendLine("{"); AppendIndent( indent + 1, cppMethodDefinitions); cppMethodDefinitions.Append("return Plugin::"); cppMethodDefinitions.Append(bindingEnumerableTypeName); - cppMethodDefinitions.Append("Iterator(enumerable);\n"); + cppMethodDefinitions.AppendLine("Iterator(enumerable);"); AppendIndent( indent, cppMethodDefinitions); - cppMethodDefinitions.Append("}\n"); + cppMethodDefinitions.AppendLine("}"); AppendIndent( indent, cppMethodDefinitions); - cppMethodDefinitions.Append('\n'); + cppMethodDefinitions.AppendLine();; AppendIndent( indent, cppMethodDefinitions); @@ -5036,25 +4990,25 @@ static void AppendGenericEnumerableIterator( AppendCppTypeFullName( enumerableType, cppMethodDefinitions); - cppMethodDefinitions.Append("& enumerable)\n"); + cppMethodDefinitions.AppendLine("& enumerable)"); AppendIndent( indent, cppMethodDefinitions); - cppMethodDefinitions.Append("{\n"); + cppMethodDefinitions.AppendLine("{"); AppendIndent( indent + 1, cppMethodDefinitions); cppMethodDefinitions.Append("return Plugin::"); cppMethodDefinitions.Append(bindingEnumerableTypeName); - cppMethodDefinitions.Append("Iterator(nullptr);\n"); + cppMethodDefinitions.AppendLine("Iterator(nullptr);"); AppendIndent( indent, cppMethodDefinitions); - cppMethodDefinitions.Append("}\n"); + cppMethodDefinitions.AppendLine("}"); AppendNamespaceEnding( indent, cppMethodDefinitions); - cppMethodDefinitions.Append('\n'); + cppMethodDefinitions.AppendLine();; } static void AppendCppArrayIndexOperatorMethodDefinition( @@ -5076,11 +5030,11 @@ static void AppendCppArrayIndexOperatorMethodDefinition( AppendTypeNameWithoutGenericSuffix( enclosingTypeTypeName.Name, output); - output.Append("::operator[](int32_t index)\n"); + output.AppendLine("::operator[](int32_t index)"); AppendIndent( indent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( indent + 1, output); @@ -5093,15 +5047,15 @@ static void AppendCppArrayIndexOperatorMethodDefinition( output.Append(i); output.Append(", "); } - output.Append("index);\n"); + output.AppendLine("index);"); AppendIndent( indent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( indent, output); - output.Append('\n'); + output.AppendLine();; } static void AppendCppArrayTypeName( @@ -5282,11 +5236,11 @@ static void AppendArrayElementProxy( AppendTypeNameWithoutGenericSuffix( cppElementProxyTypeName, builders.CppTemplateSpecializationDeclarations); - builders.CppTemplateSpecializationDeclarations.Append(";\n"); + builders.CppTemplateSpecializationDeclarations.AppendLine(";"); AppendNamespaceEnding( indent, builders.CppTemplateSpecializationDeclarations); - builders.CppTemplateSpecializationDeclarations.Append('\n'); + builders.CppTemplateSpecializationDeclarations.AppendLine();; // C++ element proxy type definition AppendNamespaceBeginning( @@ -5297,15 +5251,15 @@ static void AppendArrayElementProxy( builders.CppTypeDefinitions); builders.CppTypeDefinitions.Append("template<> struct "); builders.CppTypeDefinitions.Append(cppElementProxyTypeName); - builders.CppTypeDefinitions.Append('\n'); + builders.CppTypeDefinitions.AppendLine();; AppendIndent( indent, builders.CppTypeDefinitions); - builders.CppTypeDefinitions.Append("{\n"); + builders.CppTypeDefinitions.AppendLine("{"); AppendIndent( indent + 1, builders.CppTypeDefinitions); - builders.CppTypeDefinitions.Append("int32_t Handle;\n"); + builders.CppTypeDefinitions.AppendLine("int32_t Handle;"); for (int i = 0; i < rank; ++i) { AppendIndent( @@ -5313,7 +5267,7 @@ static void AppendArrayElementProxy( builders.CppTypeDefinitions); builders.CppTypeDefinitions.Append("int32_t Index"); builders.CppTypeDefinitions.Append(i); - builders.CppTypeDefinitions.Append(";\n"); + builders.CppTypeDefinitions.AppendLine(";"); } AppendIndent( indent + 1, @@ -5330,7 +5284,7 @@ static void AppendArrayElementProxy( builders.CppTypeDefinitions.Append(", "); } } - builders.CppTypeDefinitions.Append(");\n"); + builders.CppTypeDefinitions.AppendLine(");"); if (rank == maxRank) { AppendIndent( @@ -5340,7 +5294,7 @@ static void AppendArrayElementProxy( AppendCppTypeFullName( elementType, builders.CppTypeDefinitions); - builders.CppTypeDefinitions.Append(" item);\n"); + builders.CppTypeDefinitions.AppendLine(" item);"); AppendIndent( indent + 1, builders.CppTypeDefinitions); @@ -5348,7 +5302,7 @@ static void AppendArrayElementProxy( AppendCppTypeFullName( elementType, builders.CppTypeDefinitions); - builders.CppTypeDefinitions.Append("();\n"); + builders.CppTypeDefinitions.AppendLine("();"); } else { @@ -5362,14 +5316,14 @@ static void AppendArrayElementProxy( elementType, builders.CppTypeDefinitions); builders.CppTypeDefinitions.Append(" operator[]("); - builders.CppTypeDefinitions.Append("int32_t index);\n"); + builders.CppTypeDefinitions.AppendLine("int32_t index);"); } AppendIndent( indent, builders.CppTypeDefinitions); - builders.CppTypeDefinitions.Append("};\n"); - builders.CppTypeDefinitions.Append("}\n"); - builders.CppTypeDefinitions.Append('\n'); + builders.CppTypeDefinitions.AppendLine("};"); + builders.CppTypeDefinitions.AppendLine("}"); + builders.CppTypeDefinitions.AppendLine();; // C++ element proxy method definitions (beginning) int cppMethodDefinitionsIndent = AppendNamespaceBeginning( @@ -5397,15 +5351,15 @@ static void AppendArrayElementProxy( builders.CppMethodDefinitions.Append(", "); } } - builders.CppMethodDefinitions.Append(")\n"); + builders.CppMethodDefinitions.AppendLine(")"); AppendIndent( cppMethodDefinitionsIndent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("Handle = handle;\n"); + builders.CppMethodDefinitions.AppendLine("Handle = handle;"); for (int i = 0; i < rank; ++i) { AppendIndent( @@ -5415,16 +5369,16 @@ static void AppendArrayElementProxy( builders.CppMethodDefinitions.Append(i); builders.CppMethodDefinitions.Append(" = index"); builders.CppMethodDefinitions.Append(i); - builders.CppMethodDefinitions.Append(";\n"); + builders.CppMethodDefinitions.AppendLine(";"); } AppendIndent( cppMethodDefinitionsIndent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.AppendLine("}"); AppendIndent( cppMethodDefinitionsIndent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); + builders.CppMethodDefinitions.AppendLine();; if (rank == maxRank) { @@ -5439,11 +5393,11 @@ static void AppendArrayElementProxy( AppendCppTypeFullName( elementType, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append(" item)\n"); + builders.CppMethodDefinitions.AppendLine(" item)"); AppendIndent( cppMethodDefinitionsIndent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendCppPluginFunctionCall( false, GetTypeName(cppArrayTypeName, "System"), @@ -5457,11 +5411,11 @@ static void AppendArrayElementProxy( AppendIndent( cppMethodDefinitionsIndent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.AppendLine("}"); AppendIndent( cppMethodDefinitionsIndent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); + builders.CppMethodDefinitions.AppendLine();; // C++ element proxy type conversion operator definition AppendIndent( @@ -5473,11 +5427,11 @@ static void AppendArrayElementProxy( AppendCppTypeFullName( elementType, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("()\n"); + builders.CppMethodDefinitions.AppendLine("()"); AppendIndent( cppMethodDefinitionsIndent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendCppPluginFunctionCall( false, GetTypeName(cppArrayTypeName, "System"), @@ -5496,7 +5450,7 @@ static void AppendArrayElementProxy( AppendIndent( cppMethodDefinitionsIndent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.AppendLine("}"); } else { @@ -5536,10 +5490,6 @@ static void AppendArrayConstructor( builders.TempStrBuilder.Append(rank); string funcName = builders.TempStrBuilder.ToString(); - builders.TempStrBuilder[0] = char.ToLower( - builders.TempStrBuilder[0]); - string funcNameLower = builders.TempStrBuilder.ToString(); - ParameterInfo[] parameters = new ParameterInfo[rank]; for (int i = 0; i < rank; ++i) { @@ -5568,15 +5518,13 @@ static void AppendArrayConstructor( builders.CsharpDelegateTypes); // C# Init Call - AppendCsharpInitCallArg( + AppendCsharpCsharpDelegate( funcName, - builders.CsharpInitCall); + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); // C# Init Param - AppendCsharpInitParam( - funcNameLower, - builders.CsharpInitParams); - + // C# function AppendCsharpFunctionBeginning( arrayType, @@ -5622,21 +5570,15 @@ static void AppendArrayConstructor( arrayType, builders.CppFunctionPointers); - // C++ init param - AppendCppInitParam( - funcNameLower, + // C++ init body + AppendCppInitBodyFunctionPointerParameterRead( + funcName, true, cppArrayTypeTypeName, TypeKind.Class, parameters, arrayType, - builders.CppInitParams); - - // C++ init body - AppendCppInitBody( - funcName, - funcNameLower, - builders.CppInitBody); + builders.CppInitBodyParameterReads); // C++ method declaration AppendIndent( @@ -5673,13 +5615,13 @@ static void AppendArrayConstructor( AppendCppTypeFullName( interfaceType, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("(nullptr)\n"); + builders.CppMethodDefinitions.AppendLine("(nullptr)"); separator = ", "; } AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendCppPluginFunctionCall( true, cppArrayTypeTypeName, @@ -5693,18 +5635,18 @@ static void AppendArrayConstructor( AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "Handle = returnValue;\n"); + builders.CppMethodDefinitions.AppendLine( + "Handle = returnValue;"); AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "if (returnValue)\n"); + builders.CppMethodDefinitions.AppendLine( + "if (returnValue)"); AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "{\n"); + builders.CppMethodDefinitions.AppendLine( + "{"); AppendIndent( indent + 2, builders.CppMethodDefinitions); @@ -5714,7 +5656,7 @@ static void AppendArrayConstructor( cppTypeParams, "returnValue", builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append(";\n"); + builders.CppMethodDefinitions.AppendLine(";"); if (rank > 1) { AppendIndent( @@ -5730,7 +5672,7 @@ static void AppendArrayConstructor( builders.CppMethodDefinitions.Append(" * "); } } - builders.CppMethodDefinitions.Append(";\n"); + builders.CppMethodDefinitions.AppendLine(";"); for (int i = 0; i < rank; ++i) { AppendIndent( @@ -5740,7 +5682,7 @@ static void AppendArrayConstructor( builders.CppMethodDefinitions.Append(i); builders.CppMethodDefinitions.Append("] = length"); builders.CppMethodDefinitions.Append(i); - builders.CppMethodDefinitions.Append(";\n"); + builders.CppMethodDefinitions.AppendLine(";"); } } else @@ -5748,22 +5690,22 @@ static void AppendArrayConstructor( AppendIndent( indent + 2, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "InternalLength = length0;\n"); + builders.CppMethodDefinitions.AppendLine( + "InternalLength = length0;"); } AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "}\n"); + builders.CppMethodDefinitions.AppendLine( + "}"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.AppendLine("}"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); + builders.CppMethodDefinitions.AppendLine();; } static void AppendArrayCppGetLengthFunction( @@ -5801,46 +5743,46 @@ static void AppendArrayCppGetLengthFunction( AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "int32_t returnVal = InternalLength;\n"); + builders.CppMethodDefinitions.AppendLine( + "int32_t returnVal = InternalLength;"); AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("if (returnVal == 0)\n"); + builders.CppMethodDefinitions.AppendLine("if (returnVal == 0)"); AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendIndent( indent + 2, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "returnVal = Array::GetLength();\n"); + builders.CppMethodDefinitions.AppendLine( + "returnVal = Array::GetLength();"); AppendIndent( indent + 2, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "InternalLength = returnVal;\n"); + builders.CppMethodDefinitions.AppendLine( + "InternalLength = returnVal;"); AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("};\n"); + builders.CppMethodDefinitions.AppendLine("};"); AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("return returnVal;\n"); + builders.CppMethodDefinitions.AppendLine("return returnVal;"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.AppendLine("}"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); + builders.CppMethodDefinitions.AppendLine();; } static void AppendArrayCppGetRankFunction( @@ -5879,21 +5821,21 @@ static void AppendArrayCppGetRankFunction( AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendIndent( indent + 1, builders.CppMethodDefinitions); builders.CppMethodDefinitions.Append("return "); builders.CppMethodDefinitions.Append(rank); - builders.CppMethodDefinitions.Append(";\n"); + builders.CppMethodDefinitions.AppendLine(";"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.AppendLine("}"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); + builders.CppMethodDefinitions.AppendLine();; } static void AppendArrayMultidimensionalGetLength( @@ -5917,10 +5859,6 @@ static void AppendArrayMultidimensionalGetLength( builders.TempStrBuilder.Append(rank); string funcName = builders.TempStrBuilder.ToString(); - builders.TempStrBuilder[0] = char.ToLower( - builders.TempStrBuilder[0]); - string funcNameLower = builders.TempStrBuilder.ToString(); - ParameterInfo[] parameters = { new ParameterInfo { Name = "dimension", @@ -5947,15 +5885,13 @@ static void AppendArrayMultidimensionalGetLength( builders.CsharpDelegateTypes); // C# Init Call - AppendCsharpInitCallArg( + AppendCsharpCsharpDelegate( funcName, - builders.CsharpInitCall); + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); // C# Init Param - AppendCsharpInitParam( - funcNameLower, - builders.CsharpInitParams); - + // C# function AppendCsharpFunctionBeginning( arrayType, @@ -5985,21 +5921,15 @@ static void AppendArrayMultidimensionalGetLength( arrayType, builders.CppFunctionPointers); - // C++ init param - AppendCppInitParam( - funcNameLower, + // C++ init body + AppendCppInitBodyFunctionPointerParameterRead( + funcName, false, cppArrayTypeTypeName, TypeKind.Class, parameters, arrayType, - builders.CppInitParams); - - // C++ init body - AppendCppInitBody( - funcName, - funcNameLower, - builders.CppInitBody); + builders.CppInitBodyParameterReads); // C++ method declaration AppendIndent( @@ -6029,35 +5959,35 @@ static void AppendArrayMultidimensionalGetLength( AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendIndent( indent + 1, builders.CppMethodDefinitions); builders.CppMethodDefinitions.Append( "assert(dimension >= 0 && dimension < "); builders.CppMethodDefinitions.Append(rank); - builders.CppMethodDefinitions.Append(");\n"); + builders.CppMethodDefinitions.AppendLine(");"); AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "int32_t length = InternalLengths[dimension];\n"); + builders.CppMethodDefinitions.AppendLine( + "int32_t length = InternalLengths[dimension];"); AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("if (length)\n"); + builders.CppMethodDefinitions.AppendLine("if (length)"); AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendIndent( indent + 2, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("return length;\n"); + builders.CppMethodDefinitions.AppendLine("return length;"); AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.AppendLine("}"); AppendCppPluginFunctionCall( false, GetTypeName(cppArrayTypeName, "System"), @@ -6071,8 +6001,8 @@ static void AppendArrayMultidimensionalGetLength( AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "InternalLengths[dimension] = returnValue;\n"); + builders.CppMethodDefinitions.AppendLine( + "InternalLengths[dimension] = returnValue;"); AppendCppMethodReturn( typeof(int), TypeKind.Primitive, @@ -6081,11 +6011,11 @@ static void AppendArrayMultidimensionalGetLength( AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.AppendLine("}"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); + builders.CppMethodDefinitions.AppendLine();; } static void AppendArrayGetItem( @@ -6104,10 +6034,6 @@ static void AppendArrayGetItem( builders.TempStrBuilder); string funcName = builders.TempStrBuilder.ToString(); - builders.TempStrBuilder[0] = char.ToLower( - builders.TempStrBuilder[0]); - string funcNameLower = builders.TempStrBuilder.ToString(); - ParameterInfo[] parameters = BuildArrayGetItemsParams( rank, "index"); @@ -6123,15 +6049,13 @@ static void AppendArrayGetItem( builders.CsharpDelegateTypes); // C# Init Call - AppendCsharpInitCallArg( + AppendCsharpCsharpDelegate( funcName, - builders.CsharpInitCall); + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); // C# Init Param - AppendCsharpInitParam( - funcNameLower, - builders.CsharpInitParams); - + // C# function AppendCsharpFunctionBeginning( arrayType, @@ -6174,21 +6098,15 @@ static void AppendArrayGetItem( elementType, builders.CppFunctionPointers); - // C++ init param - AppendCppInitParam( - funcNameLower, + // C++ init body + AppendCppInitBodyFunctionPointerParameterRead( + funcName, false, cppArrayTypeTypeName, TypeKind.Class, parameters, elementType, - builders.CppInitParams); - - // C++ init body - AppendCppInitBody( - funcName, - funcNameLower, - builders.CppInitBody); + builders.CppInitBodyParameterReads); } static void AppendArraySetItem( @@ -6206,10 +6124,6 @@ static void AppendArraySetItem( builders.TempStrBuilder); string funcName = builders.TempStrBuilder.ToString(); - builders.TempStrBuilder[0] = char.ToLower( - builders.TempStrBuilder[0]); - string funcNameLower = builders.TempStrBuilder.ToString(); - // Build parameters as indexes then element ParameterInfo[] parameters = BuildArraySetItemsParams( rank, @@ -6227,15 +6141,13 @@ static void AppendArraySetItem( builders.CsharpDelegateTypes); // C# Init Call - AppendCsharpInitCallArg( + AppendCsharpCsharpDelegate( funcName, - builders.CsharpInitCall); + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); // C# Init Param - AppendCsharpInitParam( - funcNameLower, - builders.CsharpInitParams); - + // C# function AppendCsharpFunctionBeginning( arrayType, @@ -6278,21 +6190,15 @@ static void AppendArraySetItem( arrayType, builders.CppFunctionPointers); - // C++ init param - AppendCppInitParam( - funcNameLower, + // C++ init body + AppendCppInitBodyFunctionPointerParameterRead( + funcName, false, cppArrayTypeTypeName, TypeKind.Class, parameters, arrayType, - builders.CppInitParams); - - // C++ init body - AppendCppInitBody( - funcName, - funcNameLower, - builders.CppInitBody); + builders.CppInitBodyParameterReads); } static void AppendDelegate( @@ -6306,15 +6212,14 @@ static void AppendDelegate( assemblies); if (jsonDelegate.GenericParams != null) { - foreach (JsonGenericParams jsonGenericParams - in jsonDelegate.GenericParams) + for (int i = 0; i < jsonDelegate.GenericParams.Length; ++i) { // C++ template declaration AppendCppTemplateDeclaration( GetTypeName(type), builders.CppTemplateDeclarations); } - + foreach (JsonGenericParams jsonGenericParams in jsonDelegate.GenericParams) { @@ -6387,37 +6292,21 @@ static void AppendDelegate( builders.TempStrBuilder.Append(bindingTypeName); string releaseFuncName = builders.TempStrBuilder.ToString(); - builders.TempStrBuilder[0] = char.ToLower( - builders.TempStrBuilder[0]); - string releaseFuncNameLower = builders.TempStrBuilder.ToString(); - builders.TempStrBuilder.Length = 0; builders.TempStrBuilder.Append(bindingTypeName); builders.TempStrBuilder.Append("Constructor"); string constructorFuncName = builders.TempStrBuilder.ToString(); - builders.TempStrBuilder[0] = char.ToLower( - builders.TempStrBuilder[0]); - string constructorFuncNameLower = builders.TempStrBuilder.ToString(); - builders.TempStrBuilder.Length = 0; builders.TempStrBuilder.Append(bindingTypeName); builders.TempStrBuilder.Append("Add"); string addFuncName = builders.TempStrBuilder.ToString(); - builders.TempStrBuilder[0] = char.ToLower( - builders.TempStrBuilder[0]); - string addFuncNameLower = builders.TempStrBuilder.ToString(); - builders.TempStrBuilder.Length = 0; builders.TempStrBuilder.Append(bindingTypeName); builders.TempStrBuilder.Append("Remove"); string removeFuncName = builders.TempStrBuilder.ToString(); - builders.TempStrBuilder[0] = char.ToLower( - builders.TempStrBuilder[0]); - string removeFuncNameLower = builders.TempStrBuilder.ToString(); - TypeName typeTypeName = GetTypeName(type); // C++ type declaration @@ -6501,7 +6390,7 @@ static void AppendDelegate( GetTypeName(cppTypeName, type.Namespace), maxSimultaneous, bindingTypeName, - builders.CppInitBody, + builders.CppInitBodyArrays, builders.CppInitBodyFirstBoot); // C++ type definition (begin) @@ -6520,11 +6409,11 @@ static void AppendDelegate( AppendIndent( indent + 1, builders.CppTypeDefinitions); - builders.CppTypeDefinitions.Append("int32_t CppHandle;\n"); + builders.CppTypeDefinitions.AppendLine("int32_t CppHandle;"); AppendIndent( indent + 1, builders.CppTypeDefinitions); - builders.CppTypeDefinitions.Append("int32_t ClassHandle;\n"); + builders.CppTypeDefinitions.AppendLine("int32_t ClassHandle;"); // C++ method declarations AppendIndent( @@ -6598,81 +6487,55 @@ static void AppendDelegate( typeof(void), builders.CppFunctionPointers); - // C++ init params - AppendCppInitParam( - releaseFuncNameLower, + // C++ and C# init params + AppendCppInitBodyFunctionPointerParameterRead( + releaseFuncName, true, default(TypeName), TypeKind.None, releaseParams, typeof(void), - builders.CppInitParams); - AppendCppInitParam( - constructorFuncNameLower, + builders.CppInitBodyParameterReads); + AppendCppInitBodyFunctionPointerParameterRead( + constructorFuncName, true, default(TypeName), TypeKind.None, constructorParams, typeof(void), - builders.CppInitParams); - AppendCppInitParam( - addFuncNameLower, + builders.CppInitBodyParameterReads); + AppendCppInitBodyFunctionPointerParameterRead( + addFuncName, false, default(TypeName), TypeKind.None, addRemoveParams, typeof(void), - builders.CppInitParams); - AppendCppInitParam( - removeFuncNameLower, + builders.CppInitBodyParameterReads); + AppendCppInitBodyFunctionPointerParameterRead( + removeFuncName, false, default(TypeName), TypeKind.None, addRemoveParams, typeof(void), - builders.CppInitParams); - - // C++ and C# init params - AppendCppInitBody( + builders.CppInitBodyParameterReads); + AppendCsharpCsharpDelegate( releaseFuncName, - releaseFuncNameLower, - builders.CppInitBody); - AppendCppInitBody( + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); + AppendCsharpCsharpDelegate( constructorFuncName, - constructorFuncNameLower, - builders.CppInitBody); - AppendCppInitBody( + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); + AppendCsharpCsharpDelegate( addFuncName, - addFuncNameLower, - builders.CppInitBody); - AppendCppInitBody( + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); + AppendCsharpCsharpDelegate( removeFuncName, - removeFuncNameLower, - builders.CppInitBody); - AppendCsharpInitParam( - releaseFuncNameLower, - builders.CsharpInitParams); - AppendCsharpInitParam( - constructorFuncNameLower, - builders.CsharpInitParams); - AppendCsharpInitParam( - addFuncNameLower, - builders.CsharpInitParams); - AppendCsharpInitParam( - removeFuncNameLower, - builders.CsharpInitParams); - AppendCsharpInitCallArg( - releaseFuncName, - builders.CsharpInitCall); - AppendCsharpInitCallArg( - constructorFuncName, - builders.CsharpInitCall); - AppendCsharpInitCallArg( - addFuncName, - builders.CsharpInitCall); - AppendCsharpInitCallArg( - removeFuncName, - builders.CsharpInitCall); + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); // C++ method definitions (end) int cppMethodDefinitionsIndent = AppendNamespaceBeginning( @@ -6790,24 +6653,24 @@ static void AppendDelegate( AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendIndent( indent + 1, builders.CppMethodDefinitions); builders.CppMethodDefinitions.Append("Plugin::"); builders.CppMethodDefinitions.Append(addFuncName); - builders.CppMethodDefinitions.Append("(Handle, del.Handle);\n"); + builders.CppMethodDefinitions.AppendLine("(Handle, del.Handle);"); AppendCppUnhandledExceptionHandling( indent + 1, builders.CppMethodDefinitions); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.AppendLine("}"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); + builders.CppMethodDefinitions.AppendLine();; // C++ remove AppendCppMethodDefinitionBegin( @@ -6822,24 +6685,24 @@ static void AppendDelegate( AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendIndent( indent + 1, builders.CppMethodDefinitions); builders.CppMethodDefinitions.Append("Plugin::"); builders.CppMethodDefinitions.Append(removeFuncName); - builders.CppMethodDefinitions.Append("(Handle, del.Handle);\n"); + builders.CppMethodDefinitions.AppendLine("(Handle, del.Handle);"); AppendCppUnhandledExceptionHandling( indent + 1, builders.CppMethodDefinitions); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.AppendLine("}"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); + builders.CppMethodDefinitions.AppendLine();; // C# GetDelegate call AppendCsharpGetDelegateCall( @@ -6851,27 +6714,27 @@ static void AppendDelegate( // C# class (beginning) builders.CsharpBaseTypes.Append("class "); builders.CsharpBaseTypes.Append(bindingTypeName); - builders.CsharpBaseTypes.Append('\n'); - builders.CsharpBaseTypes.Append("{\n"); + builders.CsharpBaseTypes.AppendLine();; + builders.CsharpBaseTypes.AppendLine("{"); // C# class fields - builders.CsharpBaseTypes.Append("\tpublic int CppHandle;\n"); + builders.CsharpBaseTypes.AppendLine("\tpublic int CppHandle;"); builders.CsharpBaseTypes.Append("\tpublic "); AppendCsharpTypeFullName( type, builders.CsharpBaseTypes); - builders.CsharpBaseTypes.Append(" Delegate;\n"); - builders.CsharpBaseTypes.Append("\t\n"); + builders.CsharpBaseTypes.AppendLine(" Delegate;"); + builders.CsharpBaseTypes.AppendLine("\t"); // C# class constructor builders.CsharpBaseTypes.Append("\tpublic "); builders.CsharpBaseTypes.Append(bindingTypeName); - builders.CsharpBaseTypes.Append("(int cppHandle)\n"); - builders.CsharpBaseTypes.Append("\t{\n"); - builders.CsharpBaseTypes.Append("\t\tCppHandle = cppHandle;\n"); - builders.CsharpBaseTypes.Append("\t\tDelegate = NativeInvoke;\n"); - builders.CsharpBaseTypes.Append("\t}\n"); - builders.CsharpBaseTypes.Append("\t\n"); + builders.CsharpBaseTypes.AppendLine("(int cppHandle)"); + builders.CsharpBaseTypes.AppendLine("\t{"); + builders.CsharpBaseTypes.AppendLine("\t\tCppHandle = cppHandle;"); + builders.CsharpBaseTypes.AppendLine("\t\tDelegate = NativeInvoke;"); + builders.CsharpBaseTypes.AppendLine("\t}"); + builders.CsharpBaseTypes.AppendLine("\t"); // Build the name of the C++ binding function that C# calls builders.TempStrBuilder.Length = 0; @@ -6899,8 +6762,8 @@ static void AppendDelegate( builders); // C# class (ending) - builders.CsharpBaseTypes.Append("}\n"); - builders.CsharpBaseTypes.Append('\n'); + builders.CsharpBaseTypes.AppendLine("}"); + builders.CsharpBaseTypes.AppendLine();; // Invoke() is how C++ invokes the delegate AppendBaseTypeMethodCallsCsharpMethod( @@ -6926,7 +6789,7 @@ static void AppendDelegate( AppendCsharpBaseTypeConstructorFunction( type, GetTypeName(bindingTypeName, string.Empty), - false, + true, constructorFuncName, constructorParams, new ParameterInfo[0], @@ -7037,10 +6900,6 @@ static void AppendBaseType( builders.TempStrBuilder.Append(baseTypeTypeName.Name); string releaseFuncName = builders.TempStrBuilder.ToString(); - builders.TempStrBuilder[0] = char.ToLower( - builders.TempStrBuilder[0]); - string releaseFuncNameLower = builders.TempStrBuilder.ToString(); - builders.TempStrBuilder.Length = 0; AppendCppTypeName( baseTypeTypeName, @@ -7071,7 +6930,7 @@ static void AppendBaseType( throw new Exception(errorBuilder.ToString()); } - jsonConstructors = new JsonConstructor[] + jsonConstructors = new[] { new JsonConstructor { @@ -7153,7 +7012,7 @@ static void AppendBaseType( { cppBaseClass = typeof(object); cppBaseClassTypeParams = null; - cppInterfaceTypes = new Type[] { type }; + cppInterfaceTypes = new [] { type }; } else { @@ -7173,7 +7032,7 @@ static void AppendBaseType( baseTypeTypeName, maxSimultaneous, baseTypeTypeName.Name, - builders.CppInitBody, + builders.CppInitBodyArrays, builders.CppInitBodyFirstBoot); // C++ type declaration @@ -7210,7 +7069,7 @@ static void AppendBaseType( AppendIndent( indent + 1, builders.CppTypeDefinitions); - builders.CppTypeDefinitions.Append("int32_t CppHandle;\n"); + builders.CppTypeDefinitions.AppendLine("int32_t CppHandle;"); // C++ constructor declarations for (int i = 0; i < numConstructors; ++i) @@ -7238,11 +7097,12 @@ static void AppendBaseType( AppendUppercaseWithUnderscores( derivedTypeTypeName.Name, builders.CppMacros); - builders.CppMacros.Append("_DEFAULT_CONSTRUCTOR_DECLARATION \\\n"); + builders.CppMacros.AppendLine("_DEFAULT_CONSTRUCTOR_DECLARATION \\"); AppendIndent(indent, builders.CppMacros); builders.CppMacros.Append(derivedTypeTypeName.Name); - builders.CppMacros.Append("(Plugin::InternalUse iu, int32_t handle);\n"); - builders.CppMacros.Append('\n'); + builders.CppMacros.AppendLine("(Plugin::InternalUse iu, int32_t handle);"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.AppendLine();; // C++ constructor definition macro builders.CppMacros.Append("#define "); @@ -7253,12 +7113,12 @@ static void AppendBaseType( AppendUppercaseWithUnderscores( derivedTypeTypeName.Name, builders.CppMacros); - builders.CppMacros.Append("_DEFAULT_CONSTRUCTOR_DEFINITION \\\n"); + builders.CppMacros.AppendLine("_DEFAULT_CONSTRUCTOR_DEFINITION \\"); AppendIndent(indent, builders.CppMacros); builders.CppMacros.Append(derivedTypeTypeName.Name); builders.CppMacros.Append("::"); builders.CppMacros.Append(derivedTypeTypeName.Name); - builders.CppMacros.Append("(Plugin::InternalUse iu, int32_t handle) \\\n"); + builders.CppMacros.AppendLine("(Plugin::InternalUse iu, int32_t handle) \\"); AppendCppConstructorInitializerList( cppCtorInitTypes, indent + 1, @@ -7269,7 +7129,13 @@ static void AppendBaseType( AppendCppTypeFullName( baseTypeTypeName, builders.CppMacros); - builders.CppMacros.Append("(iu, handle)\n"); + builders.CppMacros.AppendLine("(iu, handle) \\"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.AppendLine("{ \\"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.AppendLine("}"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.AppendLine();; // C++ constructor inline definition macro builders.CppMacros.Append("#define "); @@ -7280,10 +7146,10 @@ static void AppendBaseType( AppendUppercaseWithUnderscores( derivedTypeTypeName.Name, builders.CppMacros); - builders.CppMacros.Append("_DEFAULT_CONSTRUCTOR \\\n"); + builders.CppMacros.AppendLine("_DEFAULT_CONSTRUCTOR \\"); AppendIndent(indent, builders.CppMacros); builders.CppMacros.Append(derivedTypeTypeName.Name); - builders.CppMacros.Append("(Plugin::InternalUse iu, int32_t handle) \\\n"); + builders.CppMacros.AppendLine("(Plugin::InternalUse iu, int32_t handle) \\"); AppendCppConstructorInitializerList( cppCtorInitTypes, indent + 1, @@ -7294,12 +7160,88 @@ static void AppendBaseType( AppendCppTypeFullName( baseTypeTypeName, builders.CppMacros); - builders.CppMacros.Append("(iu, handle) \\\n"); + builders.CppMacros.AppendLine("(iu, handle) \\"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.AppendLine("{ \\"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.AppendLine("}"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.AppendLine();; + + // C++ default contents declaration macro + builders.CppMacros.Append("#define "); + AppendUppercaseWithUnderscores( + derivedTypeTypeName.Namespace, + builders.CppMacros); + builders.CppMacros.Append('_'); + AppendUppercaseWithUnderscores( + derivedTypeTypeName.Name, + builders.CppMacros); + builders.CppMacros.AppendLine("_DEFAULT_CONTENTS_DECLARATION \\"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.AppendLine("void* operator new(size_t, void* p) noexcept; \\"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.AppendLine("void operator delete(void*, size_t) noexcept; \\"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.AppendLine();; + + // C++ default contents definition macro + builders.CppMacros.Append("#define "); + AppendUppercaseWithUnderscores( + derivedTypeTypeName.Namespace, + builders.CppMacros); + builders.CppMacros.Append('_'); + AppendUppercaseWithUnderscores( + derivedTypeTypeName.Name, + builders.CppMacros); + builders.CppMacros.AppendLine("_DEFAULT_CONTENTS_DEFINITION \\"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.Append("void* "); + builders.CppMacros.Append(derivedTypeTypeName.Name); + builders.CppMacros.AppendLine("::operator new(size_t, void* p) noexcept\\"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.AppendLine("{ \\"); + AppendIndent(indent + 1, builders.CppMacros); + builders.CppMacros.AppendLine("return p; \\"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.AppendLine("} \\"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.Append("void "); + builders.CppMacros.Append(derivedTypeTypeName.Name); + builders.CppMacros.AppendLine("::operator delete(void*, size_t) noexcept \\"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.AppendLine("{ \\"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.AppendLine("}"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.AppendLine();; + + // C++ default contents inline definition macro + builders.CppMacros.Append("#define "); + AppendUppercaseWithUnderscores( + derivedTypeTypeName.Namespace, + builders.CppMacros); + builders.CppMacros.Append('_'); + AppendUppercaseWithUnderscores( + derivedTypeTypeName.Name, + builders.CppMacros); + builders.CppMacros.AppendLine("_DEFAULT_CONTENTS\\"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.AppendLine("void* operator new(size_t, void* p) noexcept \\"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.AppendLine("{ \\"); + AppendIndent(indent + 1, builders.CppMacros); + builders.CppMacros.AppendLine("return p; \\"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.AppendLine("} \\"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.AppendLine("void operator delete(void*, size_t) noexcept \\"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.AppendLine("{ \\"); AppendIndent(indent, builders.CppMacros); - builders.CppMacros.Append("{ \\\n"); + builders.CppMacros.AppendLine("}"); AppendIndent(indent, builders.CppMacros); - builders.CppMacros.Append("} \\\n"); - builders.CppMacros.Append('\n'); + builders.CppMacros.AppendLine();; // C++ function pointers AppendCppFunctionPointerDefinition( @@ -7322,52 +7264,34 @@ static void AppendBaseType( builders.CppFunctionPointers); } - // C++ init params - AppendCppInitParam( - releaseFuncNameLower, + // C++ and C# init params + AppendCppInitBodyFunctionPointerParameterRead( + releaseFuncName, true, default(TypeName), TypeKind.None, releaseParams, typeof(void), - builders.CppInitParams); + builders.CppInitBodyParameterReads); + AppendCsharpCsharpDelegate( + releaseFuncName, + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); for (int i = 0; i < numConstructors; ++i) { - AppendCppInitParam( - constructorFuncNameLowers[i], + string funcName = constructorFuncNames[i]; + AppendCppInitBodyFunctionPointerParameterRead( + funcName, true, default(TypeName), TypeKind.None, constructorParams[i], typeof(void), - builders.CppInitParams); - } - - // C++ and C# init params - AppendCppInitBody( - releaseFuncName, - releaseFuncNameLower, - builders.CppInitBody); - AppendCsharpInitParam( - releaseFuncNameLower, - builders.CsharpInitParams); - AppendCsharpInitCallArg( - releaseFuncName, - builders.CsharpInitCall); - for (int i = 0; i < numConstructors; ++i) - { - string funcName = constructorFuncNames[i]; - string funcNameLower = constructorFuncNameLowers[i]; - AppendCppInitBody( + builders.CppInitBodyParameterReads); + AppendCsharpCsharpDelegate( funcName, - funcNameLower, - builders.CppInitBody); - AppendCsharpInitParam( - funcNameLower, - builders.CsharpInitParams); - AppendCsharpInitCallArg( - funcName, - builders.CsharpInitCall); + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); } // C++ method definitions (end) @@ -7487,7 +7411,7 @@ static void AppendBaseType( AppendCppWholeObjectFreeListInit( maxSimultaneous, baseTypeTypeName.Name, - builders.CppInitBody, + builders.CppInitBodyArrays, builders.CppInitBodyFirstBoot); // C++ binding function to create the base class @@ -7500,11 +7424,11 @@ static void AppendBaseType( builders.CppMethodDefinitions); builders.CppMethodDefinitions.Append("DLLEXPORT int32_t "); builders.CppMethodDefinitions.Append(cppDefaultConstructorBindingFunctionName); - builders.CppMethodDefinitions.Append("(int32_t handle)\n"); + builders.CppMethodDefinitions.AppendLine("(int32_t handle)"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendIndent( indent + 1, builders.CppMethodDefinitions); @@ -7513,7 +7437,7 @@ static void AppendBaseType( builders.CppMethodDefinitions); builders.CppMethodDefinitions.Append("* memory = Plugin::StoreWhole"); builders.CppMethodDefinitions.Append(baseTypeTypeName.Name); - builders.CppMethodDefinitions.Append("();\n"); + builders.CppMethodDefinitions.AppendLine("();"); AppendIndent( indent + 1, builders.CppMethodDefinitions); @@ -7524,19 +7448,20 @@ static void AppendBaseType( AppendCppTypeFullName( derivedTypeTypeName, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("(Plugin::InternalUse::Only, handle);\n"); + builders.CppMethodDefinitions.AppendLine("(Plugin::InternalUse::Only, handle);"); AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("return thiz->CppHandle;\n"); + builders.CppMethodDefinitions.AppendLine("return thiz->CppHandle;"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n\n"); + builders.CppMethodDefinitions.AppendLine("}"); + builders.CppMethodDefinitions.AppendLine(); // C# usage of the C++ binding function to create from C# default constructor ParameterInfo[] cppDefaultConstructorBindingFunctionParams = ConvertParameters( - new Type[] { typeof(int) }); + new[] { typeof(int) }); AppendCsharpDelegate( true, GetTypeName(string.Empty, string.Empty), @@ -7545,7 +7470,7 @@ static void AppendBaseType( cppDefaultConstructorBindingFunctionParams, typeof(int), TypeKind.None, - builders.CsharpDelegates); + builders.CsharpCppDelegates); AppendCsharpImport( GetTypeName(string.Empty, string.Empty), null, @@ -7569,11 +7494,11 @@ static void AppendBaseType( builders.CppMethodDefinitions); builders.CppMethodDefinitions.Append("DLLEXPORT void "); builders.CppMethodDefinitions.Append(cppDestroyBindingFunctionName); - builders.CppMethodDefinitions.Append("(int32_t cppHandle)\n"); + builders.CppMethodDefinitions.AppendLine("(int32_t cppHandle)"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendIndent( indent + 1, builders.CppMethodDefinitions); @@ -7582,7 +7507,7 @@ static void AppendBaseType( builders.CppMethodDefinitions); builders.CppMethodDefinitions.Append("* instance = Plugin::Get"); builders.CppMethodDefinitions.Append(baseTypeTypeName.Name); - builders.CppMethodDefinitions.Append("(cppHandle);\n"); + builders.CppMethodDefinitions.AppendLine("(cppHandle);"); AppendIndent( indent + 1, builders.CppMethodDefinitions); @@ -7590,15 +7515,16 @@ static void AppendBaseType( AppendCppTypeName( baseTypeTypeName, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("();\n"); + builders.CppMethodDefinitions.AppendLine("();"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n\n"); + builders.CppMethodDefinitions.AppendLine("}"); + builders.CppMethodDefinitions.AppendLine(); // C# usage of the C++ binding function to destroy from C# default constructor ParameterInfo[] cppDestroyBindingFunctionParams = ConvertParameters( - new Type[] { typeof(int) }); + new [] { typeof(int) }); AppendCsharpDelegate( true, GetTypeName(string.Empty, string.Empty), @@ -7607,7 +7533,7 @@ static void AppendBaseType( cppDestroyBindingFunctionParams, typeof(void), TypeKind.None, - builders.CsharpDelegates); + builders.CsharpCppDelegates); ParameterInfo[] cppDestroyImportFunctionParams = ConvertParameters( new Type[0]); AppendCsharpImport( @@ -7626,23 +7552,23 @@ static void AppendBaseType( // C# DestroyFunction enumerator builders.CsharpDestroyFunctionEnumerators.Append("\t\t\t"); builders.CsharpDestroyFunctionEnumerators.Append(baseTypeTypeName.Name); - builders.CsharpDestroyFunctionEnumerators.Append(",\n"); + builders.CsharpDestroyFunctionEnumerators.AppendLine(","); // C# Destroy queue cases builders.CsharpDestroyQueueCases.Append("\t\t\t\t\t\tcase DestroyFunction."); builders.CsharpDestroyQueueCases.Append(baseTypeTypeName.Name); - builders.CsharpDestroyQueueCases.Append(":\n"); + builders.CsharpDestroyQueueCases.AppendLine(":"); builders.CsharpDestroyQueueCases.Append("\t\t\t\t\t\t\t"); builders.CsharpDestroyQueueCases.Append(cppDestroyBindingFunctionName); - builders.CsharpDestroyQueueCases.Append("(entry.CppHandle);\n"); - builders.CsharpDestroyQueueCases.Append("\t\t\t\t\t\t\tbreak;\n"); + builders.CsharpDestroyQueueCases.AppendLine("(entry.CppHandle);"); + builders.CsharpDestroyQueueCases.AppendLine("\t\t\t\t\t\t\tbreak;"); } // C# class (beginning) builders.CsharpBaseTypes.Append("namespace "); builders.CsharpBaseTypes.Append(baseTypeTypeName.Namespace); - builders.CsharpBaseTypes.Append('\n'); - builders.CsharpBaseTypes.Append("{\n"); + builders.CsharpBaseTypes.AppendLine();; + builders.CsharpBaseTypes.AppendLine("{"); builders.CsharpBaseTypes.Append("\tclass "); builders.CsharpBaseTypes.Append(baseTypeTypeName.Name); if (jsonBaseType != null) @@ -7652,12 +7578,12 @@ static void AppendBaseType( type, builders.CsharpBaseTypes); } - builders.CsharpBaseTypes.Append('\n'); - builders.CsharpBaseTypes.Append("\t{\n"); + builders.CsharpBaseTypes.AppendLine();; + builders.CsharpBaseTypes.AppendLine("\t{"); // C# class fields - builders.CsharpBaseTypes.Append("\t\tpublic int CppHandle;\n"); - builders.CsharpBaseTypes.Append("\t\t\n"); + builders.CsharpBaseTypes.AppendLine("\t\tpublic int CppHandle;"); + builders.CsharpBaseTypes.AppendLine("\t\t"); if (derivedTypeTypeName.Name != null) { @@ -7666,33 +7592,33 @@ static void AppendBaseType( { builders.CsharpBaseTypes.Append("\t\tpublic "); builders.CsharpBaseTypes.Append(baseTypeTypeName.Name); - builders.CsharpBaseTypes.Append("()\n"); - builders.CsharpBaseTypes.Append("\t\t{\n"); - builders.CsharpBaseTypes.Append( - "\t\t\tint handle = NativeScript.Bindings.ObjectStore.Store(this);\n"); + builders.CsharpBaseTypes.AppendLine("()"); + builders.CsharpBaseTypes.AppendLine("\t\t{"); + builders.CsharpBaseTypes.AppendLine( + "\t\t\tint handle = NativeScript.Bindings.ObjectStore.Store(this);"); builders.CsharpBaseTypes.Append( "\t\t\tCppHandle = NativeScript.Bindings.New"); builders.CsharpBaseTypes.Append(baseTypeTypeName.Name); - builders.CsharpBaseTypes.Append("(handle);\n"); - builders.CsharpBaseTypes.Append("\t\t}\n"); - builders.CsharpBaseTypes.Append("\t\t\n"); + builders.CsharpBaseTypes.AppendLine("(handle);"); + builders.CsharpBaseTypes.AppendLine("\t\t}"); + builders.CsharpBaseTypes.AppendLine("\t\t"); } // C# finalizer/destructor builders.CsharpBaseTypes.Append("\t\t~"); builders.CsharpBaseTypes.Append(baseTypeTypeName.Name); - builders.CsharpBaseTypes.Append("()\n"); - builders.CsharpBaseTypes.Append("\t\t{\n"); - builders.CsharpBaseTypes.Append("\t\t\tif (CppHandle != 0)\n"); - builders.CsharpBaseTypes.Append("\t\t\t{\n"); + builders.CsharpBaseTypes.AppendLine("()"); + builders.CsharpBaseTypes.AppendLine("\t\t{"); + builders.CsharpBaseTypes.AppendLine("\t\t\tif (CppHandle != 0)"); + builders.CsharpBaseTypes.AppendLine("\t\t\t{"); builders.CsharpBaseTypes.Append( "\t\t\t\tNativeScript.Bindings.QueueDestroy(NativeScript.Bindings.DestroyFunction."); builders.CsharpBaseTypes.Append(baseTypeTypeName.Name); - builders.CsharpBaseTypes.Append(", CppHandle);\n"); - builders.CsharpBaseTypes.Append("\t\t\t\tCppHandle = 0;\n"); - builders.CsharpBaseTypes.Append("\t\t\t}\n"); - builders.CsharpBaseTypes.Append("\t\t}\n"); - builders.CsharpBaseTypes.Append("\t\t\n"); + builders.CsharpBaseTypes.AppendLine(", CppHandle);"); + builders.CsharpBaseTypes.AppendLine("\t\t\t\tCppHandle = 0;"); + builders.CsharpBaseTypes.AppendLine("\t\t\t}"); + builders.CsharpBaseTypes.AppendLine("\t\t}"); + builders.CsharpBaseTypes.AppendLine("\t\t"); } // C# class constructors @@ -7709,16 +7635,16 @@ static void AppendBaseType( parameters, builders.CsharpBaseTypes); } - builders.CsharpBaseTypes.Append(")\n"); + builders.CsharpBaseTypes.AppendLine(")"); builders.CsharpBaseTypes.Append("\t\t\t: base("); AppendCsharpFunctionCallParameters( parameters, builders.CsharpBaseTypes); - builders.CsharpBaseTypes.Append(")\n"); - builders.CsharpBaseTypes.Append("\t\t{\n"); - builders.CsharpBaseTypes.Append("\t\t\tCppHandle = cppHandle;\n"); - builders.CsharpBaseTypes.Append("\t\t}\n"); - builders.CsharpBaseTypes.Append("\t\t\n"); + builders.CsharpBaseTypes.AppendLine(")"); + builders.CsharpBaseTypes.AppendLine("\t\t{"); + builders.CsharpBaseTypes.AppendLine("\t\t\tCppHandle = cppHandle;"); + builders.CsharpBaseTypes.AppendLine("\t\t}"); + builders.CsharpBaseTypes.AppendLine("\t\t"); } // C# constructor delegate type @@ -8072,9 +7998,9 @@ static void AppendBaseType( } // C# class (ending) - builders.CsharpBaseTypes.Append("\t}\n"); - builders.CsharpBaseTypes.Append("}\n"); - builders.CsharpBaseTypes.Append("\n"); + builders.CsharpBaseTypes.AppendLine("\t}"); + builders.CsharpBaseTypes.AppendLine("}"); + builders.CsharpBaseTypes.AppendLine(); // C++ method definitions (end) AppendCppMethodDefinitionsEnd( @@ -8174,8 +8100,8 @@ static void AppendBaseTypeProperty( builders.CsharpBaseTypes); builders.CsharpBaseTypes.Append(']'); } - builders.CsharpBaseTypes.Append('\n'); - builders.CsharpBaseTypes.Append("\t\t{\n"); + builders.CsharpBaseTypes.AppendLine();; + builders.CsharpBaseTypes.AppendLine("\t\t{"); TypeKind propertyTypeKind = GetTypeKind( propertyInfo.PropertyType); @@ -8212,8 +8138,8 @@ static void AppendBaseTypeProperty( builders); } - builders.CsharpBaseTypes.Append("\t\t}\n"); - builders.CsharpBaseTypes.Append("\t\t\n"); + builders.CsharpBaseTypes.AppendLine("\t\t}"); + builders.CsharpBaseTypes.AppendLine("\t\t"); } static void AppendBaseTypeEvent( @@ -8239,8 +8165,8 @@ static void AppendBaseTypeEvent( builders.CsharpBaseTypes); builders.CsharpBaseTypes.Append(' '); builders.CsharpBaseTypes.Append(eventInfo.Name); - builders.CsharpBaseTypes.Append('\n'); - builders.CsharpBaseTypes.Append("\t\t{\n"); + builders.CsharpBaseTypes.AppendLine();; + builders.CsharpBaseTypes.AppendLine("\t\t{"); TypeKind eventHandlerTypeKind = GetTypeKind( eventInfo.EventHandlerType); @@ -8277,8 +8203,8 @@ static void AppendBaseTypeEvent( builders); } - builders.CsharpBaseTypes.Append("\t\t\t}\n"); - builders.CsharpBaseTypes.Append("\t\t\t\n"); + builders.CsharpBaseTypes.AppendLine("\t\t\t}"); + builders.CsharpBaseTypes.AppendLine("\t\t\t"); } static void AppendBaseTypeNativePropertyOrEvent( @@ -8335,8 +8261,8 @@ static void AppendBaseTypeNativePropertyOrEvent( operationType, 1, operationType.Length - 1); - builders.CsharpBaseTypes.Append('\n'); - builders.CsharpBaseTypes.Append("\t\t\t{\n"); + builders.CsharpBaseTypes.AppendLine();; + builders.CsharpBaseTypes.AppendLine("\t\t\t{"); AppendCsharpBaseTypeCppMethodCallMethodBody( methodInfo, nativeInvokeFuncName, @@ -8344,7 +8270,7 @@ static void AppendBaseTypeNativePropertyOrEvent( propertyOrEventTypeKind, 4, builders.CsharpBaseTypes); - builders.CsharpBaseTypes.Append("\t\t\t}\n"); + builders.CsharpBaseTypes.AppendLine("\t\t\t}"); } static void AppendCsharpParams( @@ -8381,10 +8307,6 @@ static void AppendBaseTypeMethodCallsCsharpMethod( builders.TempStrBuilder.Append(methodName); string funcName = builders.TempStrBuilder.ToString(); - builders.TempStrBuilder[0] = char.ToLower( - builders.TempStrBuilder[0]); - string funcNameLower = builders.TempStrBuilder.ToString(); - // C++ method declaration for the method ParameterInfo[] invokeParams = ConvertParameters( methodInfo.GetParameters()); @@ -8412,24 +8334,18 @@ static void AppendBaseTypeMethodCallsCsharpMethod( builders.CppFunctionPointers); // C++ and C# Init parameter and body for the C# binding function - AppendCppInitParam( - funcNameLower, + AppendCppInitBodyFunctionPointerParameterRead( + funcName, false, default(TypeName), TypeKind.None, invokeParams, methodInfo.ReturnType, - builders.CppInitParams); - AppendCppInitBody( - funcName, - funcNameLower, - builders.CppInitBody); - AppendCsharpInitParam( - funcNameLower, - builders.CsharpInitParams); - AppendCsharpInitCallArg( + builders.CppInitBodyParameterReads); + AppendCsharpCsharpDelegate( funcName, - builders.CsharpInitCall); + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); // C++ method definition for the method TypeKind returnTypeKind = GetTypeKind( @@ -8446,7 +8362,7 @@ static void AppendBaseTypeMethodCallsCsharpMethod( AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendCppPluginFunctionCall( false, GetTypeName(type), @@ -8465,11 +8381,11 @@ static void AppendBaseTypeMethodCallsCsharpMethod( AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.AppendLine("}"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); + builders.CppMethodDefinitions.AppendLine();; // C# delegate type for the binding function that C++ calls ParameterInfo[] invokeParamsWithThis = new ParameterInfo[ @@ -8631,7 +8547,7 @@ static ParameterInfo[] AppendBaseTypeCppNativeInvokeCall( AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); if (invokeMethod.ReturnType != typeof(void)) { TypeKind returnTypeKind = GetTypeKind(invokeMethod.ReturnType); @@ -8641,21 +8557,21 @@ static ParameterInfo[] AppendBaseTypeCppNativeInvokeCall( if (returnTypeKind == TypeKind.Class || returnTypeKind == TypeKind.ManagedStruct) { - builders.CppMethodDefinitions.Append("return nullptr;\n"); + builders.CppMethodDefinitions.AppendLine("return nullptr;"); } else { - builders.CppMethodDefinitions.Append("return {};\n"); + builders.CppMethodDefinitions.AppendLine("return {};"); } } AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.AppendLine("}"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); + builders.CppMethodDefinitions.AppendLine();; // C++ binding function that C# calls. Calls the C++ method. TypeKind invokeReturnTypeKind = GetTypeKind( @@ -8681,7 +8597,7 @@ static ParameterInfo[] AppendBaseTypeCppNativeInvokeCall( invokeParams, invokeMethod.ReturnType, invokeReturnTypeKind, - builders.CsharpDelegates); + builders.CsharpCppDelegates); // C# import for the C++ binding function AppendCsharpImport( @@ -8689,7 +8605,7 @@ static ParameterInfo[] AppendBaseTypeCppNativeInvokeCall( typeParams, funcName, invokeParams, - typeof(void), + invokeMethod.ReturnType, builders.CsharpImports); return invokeParams; @@ -8737,20 +8653,20 @@ static void AppendCsharpBaseTypeReleaseFunction( AppendCsharpTypeFullName( bindingTypeTypeName, output); - output.Append(" thiz;\n"); + output.AppendLine(" thiz;"); } if (typeIsDelegate) { - output.Append("\t\t\t\tif (classHandle != 0)\n"); - output.Append("\t\t\t\t{\n"); + output.AppendLine("\t\t\t\tif (classHandle != 0)"); + output.AppendLine("\t\t\t\t{"); output.Append("\t\t\t\t\tthiz = ("); AppendCsharpTypeFullName( bindingTypeTypeName, output); - output.Append(")ObjectStore.Remove(classHandle);\n"); - output.Append("\t\t\t\t\tthiz.CppHandle = 0;\n"); - output.Append("\t\t\t\t}\n"); - output.Append("\t\t\t\t\n"); + output.AppendLine(")ObjectStore.Remove(classHandle);"); + output.AppendLine("\t\t\t\t\tthiz.CppHandle = 0;"); + output.AppendLine("\t\t\t\t}"); + output.AppendLine("\t\t\t\t"); } if (derivedName != null) { @@ -8758,12 +8674,12 @@ static void AppendCsharpBaseTypeReleaseFunction( AppendCsharpTypeFullName( bindingTypeTypeName, output); - output.Append(")ObjectStore.Get(handle);\n"); - output.Append("\t\t\t\tint cppHandle = thiz.CppHandle;\n"); - output.Append("\t\t\t\tthiz.CppHandle = 0;\n"); + output.AppendLine(")ObjectStore.Get(handle);"); + output.AppendLine("\t\t\t\tint cppHandle = thiz.CppHandle;"); + output.AppendLine("\t\t\t\tthiz.CppHandle = 0;"); output.Append("\t\t\t\tQueueDestroy(DestroyFunction."); output.Append(bindingTypeTypeName.Name); - output.Append(", cppHandle);\n"); + output.AppendLine(", cppHandle);"); } output.Append("\t\t\t\tObjectStore.Remove(handle);"); AppendCsharpFunctionReturn( @@ -8799,8 +8715,8 @@ static void AppendCsharpBaseTypeCppMethodCallMethod( AppendCsharpParams( invokeParams, output); - output.Append(")\n"); - output.Append("\t\t{\n"); + output.AppendLine(")"); + output.AppendLine("\t\t{"); AppendCsharpBaseTypeCppMethodCallMethodBody( invokeMethod, nativeInvokeFuncName, @@ -8808,8 +8724,8 @@ static void AppendCsharpBaseTypeCppMethodCallMethod( invokeReturnTypeKind, 3, output); - output.Append("\t\t}\n"); - output.Append("\t\n"); + output.AppendLine("\t\t}"); + output.AppendLine("\t"); } static void AppendCsharpBaseTypeCppMethodCallMethodBody( @@ -8823,15 +8739,15 @@ static void AppendCsharpBaseTypeCppMethodCallMethodBody( AppendIndent( indent, output); - output.Append("if (CppHandle != 0)\n"); + output.AppendLine("if (CppHandle != 0)"); AppendIndent( indent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( indent + 1, output); - output.Append("int thisHandle = CppHandle;\n"); + output.AppendLine("int thisHandle = CppHandle;"); AppendCppFunctionCall( nativeInvokeFuncName, invokeParamsWithThis, @@ -8860,17 +8776,17 @@ static void AppendCsharpBaseTypeCppMethodCallMethodBody( AppendHandleStoreTypeName( invokeMethod.ReturnType, output); - output.Append(".Get(returnVal);\n"); + output.AppendLine(".Get(returnVal);"); break; default: - output.Append("returnVal;\n"); + output.AppendLine("returnVal;"); break; } } AppendIndent( indent, output); - output.Append("}\n"); + output.AppendLine("}"); if (invokeMethod.ReturnType != typeof(void)) { AppendIndent( @@ -8880,7 +8796,7 @@ static void AppendCsharpBaseTypeCppMethodCallMethodBody( AppendCsharpTypeFullName( invokeMethod.ReturnType, output); - output.Append(");\n"); + output.AppendLine(");"); } } @@ -8911,11 +8827,11 @@ static void AppendCsharpBaseTypeConstructorFunction( cppConstructorParams, output); } - output.Append(");\n"); + output.AppendLine(");"); if (typeIsDelegate) { - output.Append( - "\t\t\t\tclassHandle = NativeScript.Bindings.ObjectStore.Store(thiz);\n"); + output.AppendLine( + "\t\t\t\tclassHandle = NativeScript.Bindings.ObjectStore.Store(thiz);"); output.Append( "\t\t\t\thandle = NativeScript.Bindings.ObjectStore.Store(thiz.Delegate);"); } @@ -9025,22 +8941,21 @@ static void AppendCppBaseTypeMethodInvokeBindingFunction( output.Append(", "); } } - output.Append(")\n"); + output.AppendLine(")"); AppendIndent( indent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( indent + 1, output); - output.Append("try\n"); + output.AppendLine("try"); AppendIndent( indent + 1, output); - output.Append("{\n"); - for (int i = 0; i < methodParams.Length; ++i) + output.AppendLine("{"); + foreach (ParameterInfo parameter in methodParams) { - ParameterInfo parameter = methodParams[i]; if (parameter.Kind == TypeKind.Class || parameter.Kind == TypeKind.ManagedStruct) { @@ -9055,7 +8970,7 @@ static void AppendCppBaseTypeMethodInvokeBindingFunction( output); output.Append("(Plugin::InternalUse::Only, "); output.Append(parameter.Name); - output.Append("Handle);\n"); + output.AppendLine("Handle);"); } } AppendIndent( @@ -9095,45 +9010,45 @@ static void AppendCppBaseTypeMethodInvokeBindingFunction( { output.Append(".Handle"); } - output.Append(";\n"); + output.AppendLine(";"); AppendIndent( indent + 1, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( indent + 1, output); - output.Append( - "catch (System::Exception ex)\n"); + output.AppendLine( + "catch (System::Exception ex)"); AppendIndent( indent + 1, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( indent + 2, output); - output.Append( - "Plugin::SetException(ex.Handle);\n"); + output.AppendLine( + "Plugin::SetException(ex.Handle);"); if (method.ReturnType != typeof(void)) { AppendIndent( indent + 2, output); - output.Append( - "return {};\n"); + output.AppendLine( + "return {};"); } AppendIndent( indent + 1, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( indent + 1, output); - output.Append("catch (...)\n"); + output.AppendLine("catch (...)"); AppendIndent( indent + 1, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( indent + 2, output); @@ -9142,37 +9057,37 @@ static void AppendCppBaseTypeMethodInvokeBindingFunction( AppendCppTypeFullName( type, output); - output.Append("\";\n"); + output.AppendLine("\";"); AppendIndent( indent + 2, output); - output.Append( - "System::Exception ex(msg);\n"); + output.AppendLine( + "System::Exception ex(msg);"); AppendIndent( indent + 2, output); - output.Append( - "Plugin::SetException(ex.Handle);\n"); + output.AppendLine( + "Plugin::SetException(ex.Handle);"); if (method.ReturnType != typeof(void)) { AppendIndent( indent + 2, output); - output.Append( - "return {};\n"); + output.AppendLine( + "return {};"); } AppendIndent( indent + 1, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( indent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( indent, output); - output.Append('\n'); + output.AppendLine();; } static void AppendCppBaseTypeInequalityOperator( @@ -9199,24 +9114,24 @@ static void AppendCppBaseTypeInequalityOperator( AppendCppTypeParameters( typeIsDelegate ? typeParams : null, output); - output.Append("& other) const\n"); + output.AppendLine("& other) const"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append( - "return Handle != other.Handle;\n"); + output.AppendLine( + "return Handle != other.Handle;"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append('\n'); + output.AppendLine();; } static void AppendCppBaseTypeEqualityOperator( @@ -9243,24 +9158,24 @@ static void AppendCppBaseTypeEqualityOperator( AppendCppTypeParameters( typeIsDelegate ? typeParams : null, output); - output.Append("& other) const\n"); + output.AppendLine("& other) const"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append( - "return Handle == other.Handle;\n"); + output.AppendLine( + "return Handle == other.Handle;"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append('\n'); + output.AppendLine();; } static void AppendCppBaseTypeMoveAssignmentOperator( @@ -9295,60 +9210,60 @@ static void AppendCppBaseTypeMoveAssignmentOperator( AppendCppTypeParameters( typeIsDelegate ? typeParams : null, output); - output.Append("&& other)\n"); + output.AppendLine("&& other)"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 1, output); output.Append("Plugin::Remove"); output.Append(bindingTypeName); - output.Append("(CppHandle);\n"); + output.AppendLine("(CppHandle);"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("CppHandle = 0;\n"); + output.AppendLine("CppHandle = 0;"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("if (Handle)\n"); + output.AppendLine("if (Handle)"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append("int32_t handle = Handle;\n"); + output.AppendLine("int32_t handle = Handle;"); if (typeIsDelegate) { AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append("int32_t classHandle = ClassHandle;\n"); + output.AppendLine("int32_t classHandle = ClassHandle;"); } AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append("Handle = 0;\n"); + output.AppendLine("Handle = 0;"); if (typeIsDelegate) { AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append("ClassHandle = 0;\n"); + output.AppendLine("ClassHandle = 0;"); } AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append( - "if (Plugin::DereferenceManagedClassNoRelease(handle))\n"); + output.AppendLine( + "if (Plugin::DereferenceManagedClassNoRelease(handle))"); AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 3, output); @@ -9359,50 +9274,50 @@ static void AppendCppBaseTypeMoveAssignmentOperator( { output.Append(", classHandle"); } - output.Append(");\n"); + output.AppendLine(");"); AppendCppUnhandledExceptionHandling( cppMethodDefinitionsIndent + 3, output); AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("}\n"); + output.AppendLine("}"); if (typeIsDelegate) { AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append( - "ClassHandle = other.ClassHandle;\n"); + output.AppendLine( + "ClassHandle = other.ClassHandle;"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("other.ClassHandle = 0;\n"); + output.AppendLine("other.ClassHandle = 0;"); } AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("Handle = other.Handle;\n"); + output.AppendLine("Handle = other.Handle;"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("other.Handle = 0;\n"); + output.AppendLine("other.Handle = 0;"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("return *this;\n"); + output.AppendLine("return *this;"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append('\n'); + output.AppendLine();; } static void AppendCppBaseTypeAssignmentOperatorNullptr( @@ -9429,51 +9344,51 @@ static void AppendCppBaseTypeAssignmentOperatorNullptr( AppendCppTypeParameters( typeIsDelegate ? typeParams : null, output); - output.Append( - "::operator=(decltype(nullptr))\n"); + output.AppendLine( + "::operator=(decltype(nullptr))"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("if (Handle)\n"); + output.AppendLine("if (Handle)"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append("int32_t handle = Handle;\n"); + output.AppendLine("int32_t handle = Handle;"); if (typeIsDelegate) { AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append("int32_t classHandle = ClassHandle;\n"); + output.AppendLine("int32_t classHandle = ClassHandle;"); } AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append("Handle = 0;\n"); + output.AppendLine("Handle = 0;"); if (typeIsDelegate) { AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append("ClassHandle = 0;\n"); + output.AppendLine("ClassHandle = 0;"); } AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append( - "if (Plugin::DereferenceManagedClassNoRelease(handle))\n"); + output.AppendLine( + "if (Plugin::DereferenceManagedClassNoRelease(handle))"); AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 3, output); @@ -9484,41 +9399,41 @@ static void AppendCppBaseTypeAssignmentOperatorNullptr( { output.Append(", classHandle"); } - output.Append(");\n"); + output.AppendLine(");"); AppendCppUnhandledExceptionHandling( cppMethodDefinitionsIndent + 3, output); AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("}\n"); + output.AppendLine("}"); if (typeIsDelegate) { AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("ClassHandle = 0;\n"); + output.AppendLine("ClassHandle = 0;"); } AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("Handle = 0;\n"); + output.AppendLine("Handle = 0;"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("return *this;\n"); + output.AppendLine("return *this;"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append('\n'); + output.AppendLine();; } static void AppendCppBaseTypeAssignmentOperatorSameType( @@ -9551,11 +9466,11 @@ static void AppendCppBaseTypeAssignmentOperatorSameType( AppendCppTypeParameters( typeIsDelegate ? typeParams : null, output); - output.Append("& other)\n"); + output.AppendLine("& other)"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendSetHandle( typeTypeName, TypeKind.Class, @@ -9569,21 +9484,21 @@ static void AppendCppBaseTypeAssignmentOperatorSameType( AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append( - "ClassHandle = other.ClassHandle;\n"); + output.AppendLine( + "ClassHandle = other.ClassHandle;"); } AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("return *this;\n"); + output.AppendLine("return *this;"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append('\n'); + output.AppendLine();; } static void AppendCppBaseTypeDestructor( @@ -9613,11 +9528,11 @@ static void AppendCppBaseTypeDestructor( AppendCppTypeParameters( typeIsDelegate ? typeParams : null, output); - output.Append("()\n"); + output.AppendLine("()"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("{\n"); + output.AppendLine("{"); if (!string.IsNullOrEmpty(derivedTypeName)) { AppendIndent( @@ -9625,57 +9540,57 @@ static void AppendCppBaseTypeDestructor( output); output.Append("Plugin::RemoveWhole"); output.Append(bindingTypeName); - output.Append("(this);\n"); + output.AppendLine("(this);"); } AppendIndent( cppMethodDefinitionsIndent + 1, output); output.Append("Plugin::Remove"); output.Append(typeName); - output.Append("(CppHandle);\n"); + output.AppendLine("(CppHandle);"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("CppHandle = 0;\n"); + output.AppendLine("CppHandle = 0;"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("if (Handle)\n"); + output.AppendLine("if (Handle)"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append("int32_t handle = Handle;\n"); + output.AppendLine("int32_t handle = Handle;"); if (typeIsDelegate) { AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append("int32_t classHandle = ClassHandle;\n"); + output.AppendLine("int32_t classHandle = ClassHandle;"); } AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append("Handle = 0;\n"); + output.AppendLine("Handle = 0;"); if (typeIsDelegate) { AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append("ClassHandle = 0;\n"); + output.AppendLine("ClassHandle = 0;"); } AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append( - "if (Plugin::DereferenceManagedClassNoRelease(handle))\n"); + output.AppendLine( + "if (Plugin::DereferenceManagedClassNoRelease(handle))"); AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 3, output); @@ -9686,26 +9601,26 @@ static void AppendCppBaseTypeDestructor( { output.Append(", classHandle"); } - output.Append(");\n"); + output.AppendLine(");"); AppendCppUnhandledExceptionHandling( cppMethodDefinitionsIndent + 3, output); AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append('\n'); + output.AppendLine();; } static void AppendCppBaseTypeHandleConstructor( @@ -9730,8 +9645,8 @@ static void AppendCppBaseTypeHandleConstructor( AppendCppTypeName( typeTypeName, output); - output.Append( - "(Plugin::InternalUse, int32_t handle)\n"); + output.AppendLine( + "(Plugin::InternalUse, int32_t handle)"); AppendCppConstructorInitializerList( interfaceTypes, cppMethodDefinitionsIndent + 1, @@ -9739,50 +9654,50 @@ static void AppendCppBaseTypeHandleConstructor( AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("Handle = handle;\n"); + output.AppendLine("Handle = handle;"); AppendIndent( cppMethodDefinitionsIndent + 1, output); output.Append("CppHandle = Plugin::Store"); output.Append(bindingTypeName); - output.Append("(this);\n"); + output.AppendLine("(this);"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("if (Handle)\n"); + output.AppendLine("if (Handle)"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append( - "Plugin::ReferenceManagedClass(Handle);\n"); + output.AppendLine( + "Plugin::ReferenceManagedClass(Handle);"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("}\n"); + output.AppendLine("}"); if (typeIsDelegate) { AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append( - "ClassHandle = 0;\n"); + output.AppendLine( + "ClassHandle = 0;"); } AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append('\n'); + output.AppendLine();; } static void AppendCppBaseTypeMoveConstructor( @@ -9813,7 +9728,7 @@ static void AppendCppBaseTypeMoveConstructor( AppendCppTypeParameters( typeIsDelegate ? typeParams : null, output); - output.Append("&& other)\n"); + output.AppendLine("&& other)"); AppendCppConstructorInitializerList( interfaceTypes, cppMethodDefinitionsIndent + 1, @@ -9821,48 +9736,48 @@ static void AppendCppBaseTypeMoveConstructor( AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append( - "Handle = other.Handle;\n"); + output.AppendLine( + "Handle = other.Handle;"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append( - "CppHandle = other.CppHandle;\n"); + output.AppendLine( + "CppHandle = other.CppHandle;"); if (typeIsDelegate) { AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append( - "ClassHandle = other.ClassHandle;\n"); + output.AppendLine( + "ClassHandle = other.ClassHandle;"); } AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("other.Handle = 0;\n"); + output.AppendLine("other.Handle = 0;"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("other.CppHandle = 0;\n"); + output.AppendLine("other.CppHandle = 0;"); if (typeIsDelegate) { AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("other.ClassHandle = 0;\n"); + output.AppendLine("other.ClassHandle = 0;"); } AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append('\n'); + output.AppendLine();; } static void AppendCppBaseTypeCopyConstructor( @@ -9894,7 +9809,7 @@ static void AppendCppBaseTypeCopyConstructor( AppendCppTypeParameters( typeIsDelegate ? typeParams : null, output); - output.Append("& other)\n"); + output.AppendLine("& other)"); AppendCppConstructorInitializerList( interfaceTypes, cppMethodDefinitionsIndent + 1, @@ -9902,51 +9817,51 @@ static void AppendCppBaseTypeCopyConstructor( AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append( - "Handle = other.Handle;\n"); + output.AppendLine( + "Handle = other.Handle;"); AppendIndent( cppMethodDefinitionsIndent + 1, output); output.Append("CppHandle = Plugin::Store"); output.Append(typeName); - output.Append("(this);\n"); + output.AppendLine("(this);"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("if (Handle)\n"); + output.AppendLine("if (Handle)"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append( - "Plugin::ReferenceManagedClass(Handle);\n"); + output.AppendLine( + "Plugin::ReferenceManagedClass(Handle);"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("}\n"); + output.AppendLine("}"); if (typeIsDelegate) { AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append( - "ClassHandle = other.ClassHandle;\n"); + output.AppendLine( + "ClassHandle = other.ClassHandle;"); } AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append('\n'); + output.AppendLine();; } static void AppendCppBaseTypeNullptrConstructor( @@ -9971,7 +9886,7 @@ static void AppendCppBaseTypeNullptrConstructor( AppendCppTypeName( cppTypeTypeName, output); - output.Append("(decltype(nullptr))\n"); + output.AppendLine("(decltype(nullptr))"); AppendCppConstructorInitializerList( interfaceTypes, cppMethodDefinitionsIndent + 1, @@ -9979,28 +9894,28 @@ static void AppendCppBaseTypeNullptrConstructor( AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 1, output); output.Append("CppHandle = Plugin::Store"); output.Append(typeName); - output.Append("(this);\n"); + output.AppendLine("(this);"); if (typeIsDelegate) { AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("ClassHandle = 0;\n"); + output.AppendLine("ClassHandle = 0;"); } AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append('\n'); + output.AppendLine();; } static void AppendCppBaseTypeConstructor( @@ -10033,27 +9948,27 @@ static void AppendCppBaseTypeConstructor( AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 1, output); output.Append("CppHandle = Plugin::Store"); output.Append(bindingTypeName); - output.Append("(this);\n"); + output.AppendLine("(this);"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("System::Int32* handle = (System::Int32*)&Handle;\n"); + output.AppendLine("System::Int32* handle = (System::Int32*)&Handle;"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("int32_t cppHandle = CppHandle;\n"); + output.AppendLine("int32_t cppHandle = CppHandle;"); if (typeIsDelegate) { AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("System::Int32* classHandle = (System::Int32*)&ClassHandle;\n"); + output.AppendLine("System::Int32* classHandle = (System::Int32*)&ClassHandle;"); } AppendCppPluginFunctionCall( true, @@ -10068,60 +9983,60 @@ static void AppendCppBaseTypeConstructor( AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("if (Handle)\n"); + output.AppendLine("if (Handle)"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append( - "Plugin::ReferenceManagedClass(Handle);\n"); + output.AppendLine( + "Plugin::ReferenceManagedClass(Handle);"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("else\n"); + output.AppendLine("else"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 2, output); output.Append("Plugin::Remove"); output.Append(bindingTypeName); - output.Append("(CppHandle);\n"); + output.AppendLine("(CppHandle);"); if (typeIsDelegate) { AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append("ClassHandle = 0;\n"); + output.AppendLine("ClassHandle = 0;"); } AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append("CppHandle = 0;\n"); + output.AppendLine("CppHandle = 0;"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("}\n"); + output.AppendLine("}"); AppendCppUnhandledExceptionHandling( cppMethodDefinitionsIndent + 1, output); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append('\n'); + output.AppendLine();; } static void AppendCppPointerFreeListInit( @@ -10136,7 +10051,7 @@ static void AppendCppPointerFreeListInit( output.Append(typeName); output.Append("FreeListSize = "); output.Append(maxSimultaneous); - output.Append(";\n"); + output.AppendLine(";"); output.Append("\tPlugin::"); output.Append(typeName); @@ -10147,7 +10062,7 @@ static void AppendCppPointerFreeListInit( AppendCppTypeParameters( typeParams, output); - output.Append("**)curMemory;\n"); + output.AppendLine("**)curMemory;"); output.Append("\tcurMemory += "); output.Append(maxSimultaneous); @@ -10158,14 +10073,14 @@ static void AppendCppPointerFreeListInit( AppendCppTypeParameters( typeParams, output); - output.Append("*);\n"); + output.AppendLine("*);"); - output.Append("\t\n"); + output.AppendLine("\t"); outputFirstBoot.Append("\t\tfor (int32_t i = 0, end = Plugin::"); outputFirstBoot.Append(typeName); - outputFirstBoot.Append("FreeListSize - 1; i < end; ++i)\n"); - outputFirstBoot.Append("\t\t{\n"); + outputFirstBoot.AppendLine("FreeListSize - 1; i < end; ++i)"); + outputFirstBoot.AppendLine("\t\t{"); outputFirstBoot.Append("\t\t\tPlugin::"); outputFirstBoot.Append(typeName); outputFirstBoot.Append("FreeList[i] = ("); @@ -10177,22 +10092,22 @@ static void AppendCppPointerFreeListInit( outputFirstBoot); outputFirstBoot.Append("*)(Plugin::"); outputFirstBoot.Append(typeName); - outputFirstBoot.Append("FreeList + i + 1);\n"); - outputFirstBoot.Append("\t\t}\n"); + outputFirstBoot.AppendLine("FreeList + i + 1);"); + outputFirstBoot.AppendLine("\t\t}"); outputFirstBoot.Append("\t\tPlugin::"); outputFirstBoot.Append(typeName); outputFirstBoot.Append("FreeList[Plugin::"); outputFirstBoot.Append(typeName); - outputFirstBoot.Append("FreeListSize - 1] = nullptr;\n"); + outputFirstBoot.AppendLine("FreeListSize - 1] = nullptr;"); outputFirstBoot.Append("\t\tPlugin::NextFree"); outputFirstBoot.Append(typeName); outputFirstBoot.Append(" = Plugin::"); outputFirstBoot.Append(typeName); - outputFirstBoot.Append("FreeList + 1;\n"); + outputFirstBoot.AppendLine("FreeList + 1;"); - outputFirstBoot.Append("\t\t\n"); + outputFirstBoot.AppendLine("\t\t"); } static void AppendCppPointerFreeListStateAndFunctions( @@ -10209,13 +10124,13 @@ static void AppendCppPointerFreeListStateAndFunctions( AppendCppTypeParameters( typeParams, output); - output.Append(" pointers\n"); - output.Append("\t\n"); + output.AppendLine(" pointers"); + output.AppendLine("\t"); // Size variable output.Append("\tint32_t "); output.Append(bindingTypeName); - output.Append("FreeListSize;\n"); + output.AppendLine("FreeListSize;"); // Free list variable output.Append('\t'); @@ -10227,7 +10142,7 @@ static void AppendCppPointerFreeListStateAndFunctions( output); output.Append("** "); output.Append(bindingTypeName); - output.Append("FreeList;\n"); + output.AppendLine("FreeList;"); // Next free variable output.Append('\t'); @@ -10239,8 +10154,8 @@ static void AppendCppPointerFreeListStateAndFunctions( output); output.Append("** NextFree"); output.Append(bindingTypeName); - output.Append(";\n"); - output.Append("\t\n"); + output.AppendLine(";"); + output.AppendLine("\t"); // Store function output.Append("\tint32_t Store"); @@ -10252,11 +10167,11 @@ static void AppendCppPointerFreeListStateAndFunctions( AppendCppTypeParameters( typeParams, output); - output.Append("* del)\n"); - output.Append("\t{\n"); + output.AppendLine("* del)"); + output.AppendLine("\t{"); output.Append("\t\tassert(NextFree"); output.Append(bindingTypeName); - output.Append(" != nullptr);\n"); + output.AppendLine(" != nullptr);"); output.Append("\t\t"); AppendCppTypeFullName( cppTypeTypeName, @@ -10266,7 +10181,7 @@ static void AppendCppPointerFreeListStateAndFunctions( output); output.Append("** pNext = NextFree"); output.Append(bindingTypeName); - output.Append(";\n"); + output.AppendLine(";"); output.Append("\t\tNextFree"); output.Append(bindingTypeName); output.Append(" = ("); @@ -10276,13 +10191,13 @@ static void AppendCppPointerFreeListStateAndFunctions( AppendCppTypeParameters( typeParams, output); - output.Append("**)*pNext;\n"); - output.Append("\t\t*pNext = del;\n"); + output.AppendLine("**)*pNext;"); + output.AppendLine("\t\t*pNext = del;"); output.Append("\t\treturn (int32_t)(pNext - "); output.Append(bindingTypeName); - output.Append("FreeList);\n"); - output.Append("\t}\n"); - output.Append("\t\n"); + output.AppendLine("FreeList);"); + output.AppendLine("\t}"); + output.AppendLine("\t"); // Get function output.Append('\t'); @@ -10294,23 +10209,23 @@ static void AppendCppPointerFreeListStateAndFunctions( output); output.Append("* Get"); output.Append(bindingTypeName); - output.Append("(int32_t handle)\n"); - output.Append("\t{\n"); + output.AppendLine("(int32_t handle)"); + output.AppendLine("\t{"); output.Append( "\t\tassert(handle >= 0 && handle < "); output.Append(bindingTypeName); - output.Append("FreeListSize);\n"); + output.AppendLine("FreeListSize);"); output.Append("\t\treturn "); output.Append(bindingTypeName); - output.Append("FreeList[handle];\n"); - output.Append("\t}\n"); - output.Append("\t\n"); + output.AppendLine("FreeList[handle];"); + output.AppendLine("\t}"); + output.AppendLine("\t"); // Remove function output.Append("\tvoid Remove"); output.Append(bindingTypeName); - output.Append("(int32_t handle)\n"); - output.Append("\t{\n"); + output.AppendLine("(int32_t handle)"); + output.AppendLine("\t{"); output.Append("\t\t"); AppendCppTypeFullName( cppTypeTypeName, @@ -10320,7 +10235,7 @@ static void AppendCppPointerFreeListStateAndFunctions( output); output.Append("** pRelease = "); output.Append(bindingTypeName); - output.Append("FreeList + handle;\n"); + output.AppendLine("FreeList + handle;"); output.Append("\t\t*pRelease = ("); AppendCppTypeFullName( cppTypeTypeName, @@ -10330,12 +10245,12 @@ static void AppendCppPointerFreeListStateAndFunctions( output); output.Append("*)NextFree"); output.Append(bindingTypeName); - output.Append(";\n"); + output.AppendLine(";"); output.Append("\t\tNextFree"); output.Append(bindingTypeName); - output.Append(" = pRelease;\n"); - output.Append("\t}\n"); - output.Append("\t\n"); + output.AppendLine(" = pRelease;"); + output.AppendLine("\t}"); + output.AppendLine("\t"); } static void AppendCppWholeObjectFreeListInit( @@ -10348,46 +10263,46 @@ static void AppendCppWholeObjectFreeListInit( output.Append(bindingTypeName); output.Append("FreeWholeListSize = "); output.Append(maxSimultaneous); - output.Append(";\n"); + output.AppendLine(";"); output.Append("\tPlugin::"); output.Append(bindingTypeName); output.Append("FreeWholeList = (Plugin::"); output.Append(bindingTypeName); - output.Append("FreeWholeListEntry*)curMemory;\n"); + output.AppendLine("FreeWholeListEntry*)curMemory;"); output.Append("\tcurMemory += "); output.Append(maxSimultaneous); output.Append(" * sizeof(Plugin::"); output.Append(bindingTypeName); - output.Append("FreeWholeListEntry);\n"); + output.AppendLine("FreeWholeListEntry);"); - output.Append("\t\n"); + output.AppendLine("\t"); outputFirstBoot.Append("\t\tfor (int32_t i = 0, end = Plugin::"); outputFirstBoot.Append(bindingTypeName); - outputFirstBoot.Append("FreeWholeListSize - 1; i < end; ++i)\n"); - outputFirstBoot.Append("\t\t{\n"); + outputFirstBoot.AppendLine("FreeWholeListSize - 1; i < end; ++i)"); + outputFirstBoot.AppendLine("\t\t{"); outputFirstBoot.Append("\t\t\tPlugin::"); outputFirstBoot.Append(bindingTypeName); outputFirstBoot.Append("FreeWholeList[i].Next = Plugin::"); outputFirstBoot.Append(bindingTypeName); - outputFirstBoot.Append("FreeWholeList[i + 1].Next;\n"); - outputFirstBoot.Append("\t\t}\n"); + outputFirstBoot.AppendLine("FreeWholeList + i + 1;"); + outputFirstBoot.AppendLine("\t\t}"); outputFirstBoot.Append("\t\tPlugin::"); outputFirstBoot.Append(bindingTypeName); outputFirstBoot.Append("FreeWholeList[Plugin::"); outputFirstBoot.Append(bindingTypeName); - outputFirstBoot.Append("FreeWholeListSize - 1].Next = nullptr;\n"); + outputFirstBoot.AppendLine("FreeWholeListSize - 1].Next = nullptr;"); outputFirstBoot.Append("\t\tPlugin::NextFreeWhole"); outputFirstBoot.Append(bindingTypeName); outputFirstBoot.Append(" = Plugin::"); outputFirstBoot.Append(bindingTypeName); - outputFirstBoot.Append("FreeWholeList + 1;\n"); + outputFirstBoot.AppendLine("FreeWholeList + 1;"); - outputFirstBoot.Append("\t\t\n"); + outputFirstBoot.AppendLine("\t\t"); } static void AppendCppWholeObjectFreeListStateAndFunctions( @@ -10404,17 +10319,17 @@ static void AppendCppWholeObjectFreeListStateAndFunctions( AppendCppTypeParameters( typeParams, output); - output.Append(" objects\n"); - output.Append("\t\n"); + output.AppendLine(" objects"); + output.AppendLine("\t"); // Union with a pointer and a whole object output.Append("\tunion "); output.Append(bindingTypeName); - output.Append("FreeWholeListEntry\n"); - output.Append("\t{\n"); + output.AppendLine("FreeWholeListEntry"); + output.AppendLine("\t{"); output.Append("\t\t"); output.Append(bindingTypeName); - output.Append("FreeWholeListEntry* Next;\n"); + output.AppendLine("FreeWholeListEntry* Next;"); output.Append("\t\t"); AppendCppTypeFullName( cppTypeTypeName, @@ -10422,28 +10337,28 @@ static void AppendCppWholeObjectFreeListStateAndFunctions( AppendCppTypeParameters( typeParams, output); - output.Append(" Value;\n"); - output.Append("\t};\n"); + output.AppendLine(" Value;"); + output.AppendLine("\t};"); // Size output.Append("\tint32_t "); output.Append(bindingTypeName); - output.Append("FreeWholeListSize;\n"); + output.AppendLine("FreeWholeListSize;"); // Free list entries output.Append('\t'); output.Append(bindingTypeName); output.Append("FreeWholeListEntry* "); output.Append(bindingTypeName); - output.Append("FreeWholeList;\n"); + output.AppendLine("FreeWholeList;"); // Pointer to next free entry output.Append('\t'); output.Append(bindingTypeName); output.Append("FreeWholeListEntry* NextFreeWhole"); output.Append(bindingTypeName); - output.Append(";\n"); - output.Append("\t\n"); + output.AppendLine(";"); + output.AppendLine("\t"); // Store function output.Append('\t'); @@ -10455,22 +10370,22 @@ static void AppendCppWholeObjectFreeListStateAndFunctions( output); output.Append("* StoreWhole"); output.Append(bindingTypeName); - output.Append("()\n"); - output.Append("\t{\n"); + output.AppendLine("()"); + output.AppendLine("\t{"); output.Append("\t\tassert(NextFreeWhole"); output.Append(bindingTypeName); - output.Append(" != nullptr);\n"); + output.AppendLine(" != nullptr);"); output.Append("\t\t"); output.Append(bindingTypeName); output.Append("FreeWholeListEntry* pNext = NextFreeWhole"); output.Append(bindingTypeName); - output.Append(";\n"); + output.AppendLine(";"); output.Append("\t\tNextFreeWhole"); output.Append(bindingTypeName); - output.Append(" = pNext->Next;\n"); - output.Append("\t\treturn &pNext->Value;\n"); - output.Append("\t}\n"); - output.Append("\t\n"); + output.AppendLine(" = pNext->Next;"); + output.AppendLine("\t\treturn &pNext->Value;"); + output.AppendLine("\t}"); + output.AppendLine("\t"); // Remove function output.Append("\tvoid RemoveWhole"); @@ -10482,30 +10397,30 @@ static void AppendCppWholeObjectFreeListStateAndFunctions( AppendCppTypeParameters( typeParams, output); - output.Append("* instance)\n"); - output.Append("\t{\n"); + output.AppendLine("* instance)"); + output.AppendLine("\t{"); output.Append("\t\t"); output.Append(bindingTypeName); output.Append("FreeWholeListEntry* pRelease = ("); output.Append(bindingTypeName); - output.Append("FreeWholeListEntry*)instance;\n"); + output.AppendLine("FreeWholeListEntry*)instance;"); output.Append("\t\tif (pRelease >= "); output.Append(bindingTypeName); output.Append("FreeWholeList && pRelease < "); output.Append(bindingTypeName); output.Append("FreeWholeList + ("); output.Append(bindingTypeName); - output.Append("FreeWholeListSize - 1))\n"); - output.Append("\t\t{\n"); + output.AppendLine("FreeWholeListSize - 1))"); + output.AppendLine("\t\t{"); output.Append("\t\t\tpRelease->Next = NextFreeWhole"); output.Append(bindingTypeName); - output.Append(";\n"); + output.AppendLine(";"); output.Append("\t\t\tNextFreeWhole"); output.Append(bindingTypeName); - output.Append(" = pRelease->Next;\n"); - output.Append("\t\t}\n"); - output.Append("\t}\n"); - output.Append("\t\n"); + output.AppendLine(" = pRelease->Next;"); + output.AppendLine("\t\t}"); + output.AppendLine("\t}"); + output.AppendLine("\t"); } static void AppendCsharpDelegate( @@ -10518,6 +10433,7 @@ static void AppendCsharpDelegate( TypeKind returnTypeKind, StringBuilder output) { + output.AppendLine("\t\t[UnmanagedFunctionPointer(CallingConvention.Cdecl)]"); output.Append("\t\tpublic delegate "); if (returnType == typeof(void)) { @@ -10544,7 +10460,7 @@ static void AppendCsharpDelegate( typeParams, funcName, output); - output.Append("Delegate("); + output.Append("DelegateType("); if (!isStatic) { output.Append("int thisHandle"); @@ -10577,20 +10493,21 @@ static void AppendCsharpDelegate( output.Append(", "); } } - output.Append(");\n"); + output.AppendLine(");"); output.Append("\t\tpublic static "); AppendCsharpDelegateName( typeTypeName, typeParams, funcName, output); - output.Append("Delegate "); + output.Append("DelegateType "); AppendCsharpDelegateName( typeTypeName, typeParams, funcName, output); - output.Append(";\n\t\t\n"); + output.AppendLine(";"); + output.AppendLine("\t\t"); } static void AppendCsharpDelegateName( @@ -10630,13 +10547,13 @@ static void AppendCsharpGetDelegateCall( typeParams, funcName, output); - output.Append("Delegate>(libraryHandle, \""); + output.Append("DelegateType>(libraryHandle, \""); AppendCsharpDelegateName( typeTypeName, typeParams, funcName, output); - output.Append("\");\n"); + output.AppendLine("\");"); } static void AppendCsharpImport( @@ -10648,7 +10565,7 @@ static void AppendCsharpImport( StringBuilder output ) { - output.Append("\t\t[DllImport(NativeScriptConstants.PluginName)]\n"); + output.AppendLine("\t\t[DllImport(PLUGIN_NAME, CallingConvention = CallingConvention.Cdecl)]"); output.Append("\t\tpublic static extern "); AppendCsharpTypeFullName(returnType, output); output.Append(' '); @@ -10665,25 +10582,29 @@ StringBuilder output for (int i = 0; i < parameters.Length; ++i) { ParameterInfo param = parameters[i]; - if (param.Kind == TypeKind.FullStruct) - { - AppendCsharpTypeFullName( - param.ParameterType, - output); - output.Append(" param"); - output.Append(i); - } - else + switch (param.Kind) { - output.Append("int param"); - output.Append(i); + case TypeKind.FullStruct: + case TypeKind.Primitive: + case TypeKind.Enum: + AppendCsharpTypeFullName( + param.ParameterType, + output); + output.Append(" param"); + output.Append(i); + break; + default: + output.Append("int param"); + output.Append(i); + break; } if (i != parameters.Length-1) { output.Append(", "); } } - output.Append(");\n\t\t\n"); + output.AppendLine(");"); + output.AppendLine("\t\t"); } static void AppendExceptions( @@ -10772,32 +10693,32 @@ static void AppendExceptions( AppendCppTypeFullName( exceptionType, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); + builders.CppMethodDefinitions.AppendLine();; AppendIndent( throwerIndent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendIndent( throwerIndent + 1, builders.CppMethodDefinitions); builders.CppMethodDefinitions.Append(exceptionType.Name); - builders.CppMethodDefinitions.Append("Thrower(int32_t handle)\n"); + builders.CppMethodDefinitions.AppendLine("Thrower(int32_t handle)"); AppendIndent( throwerIndent + 2, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append(": System::Runtime::InteropServices::_Exception(nullptr)\n"); + builders.CppMethodDefinitions.AppendLine(": System::Runtime::InteropServices::_Exception(nullptr)"); AppendIndent( throwerIndent + 2, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append(", System::Runtime::Serialization::ISerializable(nullptr)\n"); + builders.CppMethodDefinitions.AppendLine(", System::Runtime::Serialization::ISerializable(nullptr)"); AppendIndent( throwerIndent + 2, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append(", System::Exception(nullptr)\n"); + builders.CppMethodDefinitions.AppendLine(", System::Exception(nullptr)"); AppendIndent( throwerIndent + 2, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append(", System::SystemException(nullptr)\n"); + builders.CppMethodDefinitions.AppendLine(", System::SystemException(nullptr)"); AppendIndent( throwerIndent + 2, builders.CppMethodDefinitions); @@ -10805,56 +10726,57 @@ static void AppendExceptions( AppendCppTypeFullName( exceptionType, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("(Plugin::InternalUse::Only, handle)\n"); + builders.CppMethodDefinitions.AppendLine("(Plugin::InternalUse::Only, handle)"); AppendIndent( throwerIndent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendIndent( throwerIndent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.AppendLine("}"); AppendIndent( throwerIndent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); + builders.CppMethodDefinitions.AppendLine();; AppendIndent( throwerIndent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("virtual void ThrowReferenceToThis()\n"); + builders.CppMethodDefinitions.AppendLine("virtual void ThrowReferenceToThis()"); AppendIndent( throwerIndent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendIndent( throwerIndent + 2, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("throw *this;\n"); + builders.CppMethodDefinitions.AppendLine("throw *this;"); AppendIndent( throwerIndent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.AppendLine("}"); AppendIndent( throwerIndent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("};\n"); + builders.CppMethodDefinitions.AppendLine("};"); AppendNamespaceEnding( throwerIndent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); + builders.CppMethodDefinitions.AppendLine();; // C++ function builders.CppMethodDefinitions.Append("DLLEXPORT void "); builders.CppMethodDefinitions.Append(funcName); - builders.CppMethodDefinitions.Append("(int32_t handle)\n"); - builders.CppMethodDefinitions.Append("{\n"); - builders.CppMethodDefinitions.Append("\tdelete Plugin::unhandledCsharpException;\n"); + builders.CppMethodDefinitions.AppendLine("(int32_t handle)"); + builders.CppMethodDefinitions.AppendLine("{"); + builders.CppMethodDefinitions.AppendLine("\tdelete Plugin::unhandledCsharpException;"); builders.CppMethodDefinitions.Append("\tPlugin::unhandledCsharpException = new "); AppendCppTypeFullName( exceptionType, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("Thrower(handle);\n"); - builders.CppMethodDefinitions.Append("}\n\n"); + builders.CppMethodDefinitions.AppendLine("Thrower(handle);"); + builders.CppMethodDefinitions.AppendLine("}"); + builders.CppMethodDefinitions.AppendLine(); // Build parameters ParameterInfo[] parameters = ConvertParameters( @@ -10878,7 +10800,7 @@ static void AppendExceptions( parameters, typeof(void), TypeKind.None, - builders.CsharpDelegates + builders.CsharpCppDelegates ); // C# GetDelegate call @@ -10945,11 +10867,6 @@ static void AppendGetter( builders.TempStrBuilder); string funcName = builders.TempStrBuilder.ToString(); - // Build lowercase function name - builders.TempStrBuilder[0] = char.ToLower( - builders.TempStrBuilder[0]); - string funcNameLower = builders.TempStrBuilder.ToString(); - // Build method name builders.TempStrBuilder.Length = 0; builders.TempStrBuilder.Append("Get"); @@ -10957,9 +10874,6 @@ static void AppendGetter( string methodName = builders.TempStrBuilder.ToString(); // C# init param declaration - AppendCsharpInitParam( - funcNameLower, - builders.CsharpInitParams); // C# delegate type AppendCsharpDelegateType( @@ -10972,9 +10886,10 @@ static void AppendGetter( builders.CsharpDelegateTypes); // C# init call param - AppendCsharpInitCallArg( + AppendCsharpCsharpDelegate( funcName, - builders.CsharpInitCall); + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); // C# function AppendCsharpFunctionBeginning( @@ -11059,7 +10974,7 @@ static void AppendGetter( indent, builders.CppMethodDefinitions); AppendIndent(indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendCppPluginFunctionCall( methodIsStatic, GetTypeName(enclosingType), @@ -11076,25 +10991,19 @@ static void AppendGetter( indent + 1, builders.CppMethodDefinitions); AppendIndent(indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.AppendLine("}"); AppendIndent(indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); - - // C++ init params - AppendCppInitParam( - funcNameLower, + builders.CppMethodDefinitions.AppendLine();; + + // C++ init body + AppendCppInitBodyFunctionPointerParameterRead( + funcName, methodIsStatic, GetTypeName(enclosingType), enclosingTypeKind, parameters, fieldType, - builders.CppInitParams); - - // C++ init body - AppendCppInitBody( - funcName, - funcNameLower, - builders.CppInitBody); + builders.CppInitBodyParameterReads); } static void AppendSetter( @@ -11133,11 +11042,6 @@ static void AppendSetter( builders.TempStrBuilder); string funcName = builders.TempStrBuilder.ToString(); - // Build lowercase function name - builders.TempStrBuilder[0] = char.ToLower( - builders.TempStrBuilder[0]); - string funcNameLower = builders.TempStrBuilder.ToString(); - // Build method name builders.TempStrBuilder.Length = 0; builders.TempStrBuilder.Append("Set"); @@ -11145,10 +11049,7 @@ static void AppendSetter( string methodName = builders.TempStrBuilder.ToString(); // C# init param declaration - AppendCsharpInitParam( - funcNameLower, - builders.CsharpInitParams); - + // C# delegate type AppendCsharpDelegateType( funcName, @@ -11160,9 +11061,10 @@ static void AppendSetter( builders.CsharpDelegateTypes); // C# init call param - AppendCsharpInitCallArg( + AppendCsharpCsharpDelegate( funcName, - builders.CsharpInitCall); + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); // C# function AppendCsharpFunctionBeginning( @@ -11250,7 +11152,7 @@ static void AppendSetter( indent, builders.CppMethodDefinitions); AppendIndent(indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendCppPluginFunctionCall( methodIsStatic, enclosingTypeTypeName, @@ -11262,25 +11164,19 @@ static void AppendSetter( indent + 1, builders.CppMethodDefinitions); AppendIndent(indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.AppendLine("}"); AppendIndent(indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); + builders.CppMethodDefinitions.AppendLine();; - // C++ init params - AppendCppInitParam( - funcNameLower, + // C++ init body + AppendCppInitBodyFunctionPointerParameterRead( + funcName, methodIsStatic, enclosingTypeTypeName, enclosingTypeKind, parameters, typeof(void), - builders.CppInitParams); - - // C++ init body - AppendCppInitBody( - funcName, - funcNameLower, - builders.CppInitBody); + builders.CppInitBodyParameterReads); } static void AppendFieldPropertyFuncName( @@ -11326,11 +11222,11 @@ static void AppendCppTemplateDeclaration( typeTypeName, output); output.Append(";"); - output.Append('\n'); + output.AppendLine();; AppendNamespaceEnding( indent, output); - output.Append('\n'); + output.AppendLine();; } static int AppendCppTypeDeclaration( @@ -11349,9 +11245,9 @@ static int AppendCppTypeDeclaration( AppendTypeNameWithoutGenericSuffix( typeTypeName.Name, output); - output.Append('\n'); + output.AppendLine();; AppendIndent(indent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent(indent, output); output.Append('}'); } @@ -11370,11 +11266,11 @@ static int AppendCppTypeDeclaration( output); output.Append(";"); } - output.Append('\n'); + output.AppendLine();; AppendNamespaceEnding( indent, output); - output.Append('\n'); + output.AppendLine();; return indent; } @@ -11458,11 +11354,11 @@ static void AppendCppTypeDefinitionBegin( break; } } - output.Append('\n'); + output.AppendLine();; AppendIndent( indent, output); - output.Append("{\n"); + output.AppendLine("{"); if (!isStatic) { switch (typeKind) @@ -11474,30 +11370,21 @@ static void AppendCppTypeDefinitionBegin( AppendCppTypeName( typeTypeName, output); - AppendCppTypeParameters( - typeParams, - output); - output.Append("(decltype(nullptr));\n"); + output.AppendLine("(decltype(nullptr));"); // Constructor from handle AppendIndent(indent + 1, output); AppendCppTypeName( typeTypeName, output); - AppendCppTypeParameters( - typeParams, - output); - output.Append( - "(Plugin::InternalUse, int32_t handle);\n"); + output.AppendLine( + "(Plugin::InternalUse, int32_t handle);"); // Copy constructor AppendIndent(indent + 1, output); AppendCppTypeName( typeTypeName, output); - AppendCppTypeParameters( - typeParams, - output); output.Append("(const "); AppendCppTypeName( typeTypeName, @@ -11505,16 +11392,13 @@ static void AppendCppTypeDefinitionBegin( AppendCppTypeParameters( typeParams, output); - output.Append("& other);\n"); + output.AppendLine("& other);"); // Move constructor AppendIndent(indent + 1, output); AppendCppTypeName( typeTypeName, output); - AppendCppTypeParameters( - typeParams, - output); output.Append('('); AppendCppTypeName( typeTypeName, @@ -11522,7 +11406,7 @@ static void AppendCppTypeDefinitionBegin( AppendCppTypeParameters( typeParams, output); - output.Append("&& other);\n"); + output.AppendLine("&& other);"); // Destructor AppendIndent(indent + 1, output); @@ -11530,10 +11414,7 @@ static void AppendCppTypeDefinitionBegin( AppendCppTypeName( typeTypeName, output); - AppendCppTypeParameters( - typeParams, - output); - output.Append("();\n"); + output.AppendLine("();"); // Assignment operator to same type AppendIndent(indent + 1, output); @@ -11550,7 +11431,7 @@ static void AppendCppTypeDefinitionBegin( AppendCppTypeParameters( typeParams, output); - output.Append("& other);\n"); + output.AppendLine("& other);"); // Assignment operator to nullptr AppendIndent(indent + 1, output); @@ -11560,7 +11441,7 @@ static void AppendCppTypeDefinitionBegin( AppendCppTypeParameters( typeParams, output); - output.Append("& operator=(decltype(nullptr));\n"); + output.AppendLine("& operator=(decltype(nullptr));"); // Move assignment operator to same type AppendIndent(indent + 1, output); @@ -11577,7 +11458,7 @@ static void AppendCppTypeDefinitionBegin( AppendCppTypeParameters( typeParams, output); - output.Append("&& other);\n"); + output.AppendLine("&& other);"); // Equality operator with same type AppendIndent(indent + 1, output); @@ -11588,7 +11469,7 @@ static void AppendCppTypeDefinitionBegin( AppendCppTypeParameters( typeParams, output); - output.Append("& other) const;\n"); + output.AppendLine("& other) const;"); // Inequality operator with same type AppendIndent(indent + 1, output); @@ -11599,7 +11480,7 @@ static void AppendCppTypeDefinitionBegin( AppendCppTypeParameters( typeParams, output); - output.Append("& other) const;\n"); + output.AppendLine("& other) const;"); break; } } @@ -11618,11 +11499,11 @@ static void AppendCppTypeDefinitionEnd( { output.Append(';'); } - output.Append('\n'); + output.AppendLine();; AppendNamespaceEnding( indent, output); - output.Append('\n'); + output.AppendLine();; } static int AppendCppMethodDefinitionsBegin( @@ -11655,7 +11536,7 @@ static int AppendCppMethodDefinitionsBegin( AppendCppTypeName( enclosingTypeTypeName, output); - output.Append("(decltype(nullptr))\n"); + output.AppendLine("(decltype(nullptr))"); if (enclosingTypeKind == TypeKind.Class) { AppendCppConstructorInitializerList( @@ -11664,12 +11545,12 @@ static int AppendCppMethodDefinitionsBegin( output); } AppendIndent(indent, output); - output.Append("{\n"); + output.AppendLine("{"); extraDefault(indent + 1, "this->"); AppendIndent(indent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent(indent, output); - output.Append('\n'); + output.AppendLine();; // Handle constructor AppendIndent(indent, output); @@ -11683,7 +11564,7 @@ static int AppendCppMethodDefinitionsBegin( AppendCppTypeName( enclosingTypeTypeName, output); - output.Append("(Plugin::InternalUse, int32_t handle)\n"); + output.AppendLine("(Plugin::InternalUse, int32_t handle)"); if (enclosingTypeKind == TypeKind.Class) { AppendCppConstructorInitializerList( @@ -11692,13 +11573,13 @@ static int AppendCppMethodDefinitionsBegin( output); } AppendIndent(indent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent(indent + 1, output); - output.Append("Handle = handle;\n"); + output.AppendLine("Handle = handle;"); AppendIndent(indent + 1, output); - output.Append("if (handle)\n"); + output.AppendLine("if (handle)"); AppendIndent(indent + 1, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent(indent + 2, output); AppendReferenceManagedHandleFunctionCall( enclosingTypeTypeName, @@ -11706,14 +11587,14 @@ static int AppendCppMethodDefinitionsBegin( enclosingTypeParams, "handle", output); - output.Append(";\n"); + output.AppendLine(";"); AppendIndent(indent + 1, output); - output.Append("}\n"); + output.AppendLine("}"); extraDefault(indent + 1, "this->"); AppendIndent(indent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent(indent, output); - output.Append('\n'); + output.AppendLine();; // Copy constructor AppendIndent(indent, output); @@ -11734,20 +11615,20 @@ static int AppendCppMethodDefinitionsBegin( AppendCppTypeParameters( enclosingTypeParams, output); - output.Append("& other)\n"); + output.AppendLine("& other)"); AppendIndent(indent + 1, output); output.Append(": "); AppendCppTypeName( enclosingTypeTypeName, output); - output.Append("(Plugin::InternalUse::Only, other.Handle)\n"); + output.AppendLine("(Plugin::InternalUse::Only, other.Handle)"); AppendIndent(indent, output); - output.Append("{\n"); + output.AppendLine("{"); extraCopy(indent + 1, "other."); AppendIndent(indent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent(indent, output); - output.Append('\n'); + output.AppendLine();; // Move constructor AppendIndent(indent, output); @@ -11768,23 +11649,23 @@ static int AppendCppMethodDefinitionsBegin( AppendCppTypeParameters( enclosingTypeParams, output); - output.Append("&& other)\n"); + output.AppendLine("&& other)"); AppendIndent(indent, output); output.Append("\t: "); AppendCppTypeName( enclosingTypeTypeName, output); - output.Append("(Plugin::InternalUse::Only, other.Handle)\n"); + output.AppendLine("(Plugin::InternalUse::Only, other.Handle)"); AppendIndent(indent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent(indent + 1, output); - output.Append("other.Handle = 0;\n"); + output.AppendLine("other.Handle = 0;"); extraCopy(indent + 1, "other."); extraDefault(indent + 1, "other."); AppendIndent(indent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent(indent, output); - output.Append('\n'); + output.AppendLine();; // Destructor AppendIndent(indent, output); @@ -11801,13 +11682,13 @@ static int AppendCppMethodDefinitionsBegin( AppendCppTypeParameters( enclosingTypeParams, output); - output.Append("()\n"); + output.AppendLine("()"); AppendIndent(indent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent(indent + 1, output); - output.Append("if (Handle)\n"); + output.AppendLine("if (Handle)"); AppendIndent(indent + 1, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent(indent + 2, output); AppendDereferenceManagedHandleFunctionCall( enclosingTypeTypeName, @@ -11815,15 +11696,15 @@ static int AppendCppMethodDefinitionsBegin( enclosingTypeParams, "Handle", output); - output.Append(";\n"); + output.AppendLine(";"); AppendIndent(indent + 2, output); - output.Append("Handle = 0;\n"); + output.AppendLine("Handle = 0;"); AppendIndent(indent + 1, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent(indent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent(indent, output); - output.Append('\n'); + output.AppendLine();; // Assignment operator to same type AppendIndent(indent, output); @@ -11847,9 +11728,9 @@ static int AppendCppMethodDefinitionsBegin( AppendCppTypeParameters( enclosingTypeParams, output); - output.Append("& other)\n"); + output.AppendLine("& other)"); AppendIndent(indent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendSetHandle( enclosingTypeTypeName, enclosingTypeKind, @@ -11860,11 +11741,11 @@ static int AppendCppMethodDefinitionsBegin( output); extraCopy(indent + 1, "other."); AppendIndent(indent + 1, output); - output.Append("return *this;\n"); + output.AppendLine("return *this;"); AppendIndent(indent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent(indent, output); - output.Append('\n'); + output.AppendLine();; // Assignment operator to nullptr AppendIndent(indent, output); @@ -11881,13 +11762,13 @@ static int AppendCppMethodDefinitionsBegin( AppendCppTypeParameters( enclosingTypeParams, output); - output.Append("::operator=(decltype(nullptr))\n"); + output.AppendLine("::operator=(decltype(nullptr))"); AppendIndent(indent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent(indent + 1, output); - output.Append("if (Handle)\n"); + output.AppendLine("if (Handle)"); AppendIndent(indent + 1, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent(indent + 2, output); AppendDereferenceManagedHandleFunctionCall( enclosingTypeTypeName, @@ -11895,17 +11776,17 @@ static int AppendCppMethodDefinitionsBegin( enclosingTypeParams, "Handle", output); - output.Append(";\n"); + output.AppendLine(";"); AppendIndent(indent + 2, output); - output.Append("Handle = 0;\n"); + output.AppendLine("Handle = 0;"); AppendIndent(indent + 1, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent(indent + 1, output); - output.Append("return *this;\n"); + output.AppendLine("return *this;"); AppendIndent(indent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent(indent, output); - output.Append('\n'); + output.AppendLine();; // Move assignment operator to same type AppendIndent(indent, output); @@ -11929,13 +11810,13 @@ static int AppendCppMethodDefinitionsBegin( AppendCppTypeParameters( enclosingTypeParams, output); - output.Append("&& other)\n"); + output.AppendLine("&& other)"); AppendIndent(indent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent(indent + 1, output); - output.Append("if (Handle)\n"); + output.AppendLine("if (Handle)"); AppendIndent(indent + 1, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent(indent + 2, output); AppendDereferenceManagedHandleFunctionCall( enclosingTypeTypeName, @@ -11943,21 +11824,21 @@ static int AppendCppMethodDefinitionsBegin( enclosingTypeParams, "Handle", output); - output.Append(";\n"); + output.AppendLine(";"); AppendIndent(indent + 1, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent(indent + 1, output); - output.Append("Handle = other.Handle;\n"); + output.AppendLine("Handle = other.Handle;"); extraCopy(indent + 1, "other."); AppendIndent(indent + 1, output); - output.Append("other.Handle = 0;\n"); + output.AppendLine("other.Handle = 0;"); extraDefault(indent + 1, "other."); AppendIndent(indent + 1, output); - output.Append("return *this;\n"); + output.AppendLine("return *this;"); AppendIndent(indent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent(indent, output); - output.Append('\n'); + output.AppendLine();; // Equality operator with same type AppendIndent(indent, output); @@ -11975,15 +11856,15 @@ static int AppendCppMethodDefinitionsBegin( AppendCppTypeParameters( enclosingTypeParams, output); - output.Append("& other) const\n"); + output.AppendLine("& other) const"); AppendIndent(indent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent(indent + 1, output); - output.Append("return Handle == other.Handle;\n"); + output.AppendLine("return Handle == other.Handle;"); AppendIndent(indent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent(indent, output); - output.Append('\n'); + output.AppendLine();; // Inequality operator with same type AppendIndent(indent, output); @@ -12001,15 +11882,15 @@ static int AppendCppMethodDefinitionsBegin( AppendCppTypeParameters( enclosingTypeParams, output); - output.Append("& other) const\n"); + output.AppendLine("& other) const"); AppendIndent(indent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent(indent + 1, output); - output.Append("return Handle != other.Handle;\n"); + output.AppendLine("return Handle != other.Handle;"); AppendIndent(indent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent(indent, output); - output.Append('\n'); + output.AppendLine();; } return cppMethodDefinitionsIndent; } @@ -12027,9 +11908,9 @@ static void AppendSetHandle( AppendIndent(indent, output); output.Append("if ("); output.Append(thisHandleExpression); - output.Append(")\n"); + output.AppendLine(")"); AppendIndent(indent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent(indent + 1, output); AppendDereferenceManagedHandleFunctionCall( enclosingTypeTypeName, @@ -12037,20 +11918,20 @@ static void AppendSetHandle( enclosingTypeParams, thisHandleExpression, output); - output.Append(";\n"); + output.AppendLine(";"); AppendIndent(indent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent(indent, output); output.Append(thisHandleExpression); output.Append(" = "); output.Append(otherHandleExpression); - output.Append(";\n"); + output.AppendLine(";"); AppendIndent(indent, output); output.Append("if ("); output.Append(thisHandleExpression); - output.Append(")\n"); + output.AppendLine(")"); AppendIndent(indent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent(indent + 1, output); AppendReferenceManagedHandleFunctionCall( enclosingTypeTypeName, @@ -12058,9 +11939,9 @@ static void AppendSetHandle( enclosingTypeParams, thisHandleExpression, output); - output.Append(";\n"); + output.AppendLine(";"); AppendIndent(indent, output); - output.Append("}\n"); + output.AppendLine("}"); } static void AppendReferenceManagedHandleFunctionCall( @@ -12116,11 +11997,11 @@ static void AppendCppMethodDefinitionsEnd( StringBuilder output) { RemoveTrailingChars(output); - output.Append('\n'); + output.AppendLine();; AppendNamespaceEnding( indent, output); - output.Append('\n'); + output.AppendLine();; } static int AppendNamespaceBeginning( @@ -12141,9 +12022,9 @@ static int AppendNamespaceBeginning( AppendIndent(indent, output); output.Append("namespace "); output.Append(namespaceName, startIndex, len); - output.Append('\n'); + output.AppendLine();; AppendIndent(indent, output); - output.Append("{\n"); + output.AppendLine("{"); if (separatorIndex < 0) { break; @@ -12163,7 +12044,7 @@ static void AppendNamespaceEnding( for (; indent >= 0; --indent) { AppendIndent(indent, output); - output.Append("}\n"); + output.AppendLine("}"); } } @@ -12173,26 +12054,28 @@ static void AppendIndent( { output.Append('\t', indent); } - - static void AppendCsharpInitParam( + + static void AppendCsharpCsharpDelegate( string funcName, - StringBuilder output) - { - output.Append("\t\t\tIntPtr "); - output.Append(funcName); - output.Append(",\n"); - } - - static void AppendCsharpInitCallArg( - string funcName, - StringBuilder output) - { - output.Append( - "\t\t\t\tMarshal.GetFunctionPointerForDelegate(new "); - output.Append(funcName); - output.Append("Delegate("); - output.Append(funcName); - output.Append(")),\n"); + StringBuilder initCallOutput, + StringBuilder delegateOutput) + { + initCallOutput.Append( + "\t\t\tMarshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate("); + initCallOutput.Append(funcName); + initCallOutput.Append("Delegate"); + initCallOutput.AppendLine("));"); + initCallOutput.AppendLine("\t\t\tcurMemory += IntPtr.Size;"); + + delegateOutput.Append("\t\tstatic readonly "); + delegateOutput.Append(funcName); + delegateOutput.Append("DelegateType "); + delegateOutput.Append(funcName); + delegateOutput.Append("Delegate = new "); + delegateOutput.Append(funcName); + delegateOutput.Append("DelegateType("); + delegateOutput.Append(funcName); + delegateOutput.AppendLine(");"); } static void AppendCsharpDelegateType( @@ -12204,6 +12087,7 @@ static void AppendCsharpDelegateType( ParameterInfo[] parameters, StringBuilder output) { + output.AppendLine("\t\t[UnmanagedFunctionPointer(CallingConvention.Cdecl)]"); output.Append("\t\tdelegate "); // Return type @@ -12220,7 +12104,7 @@ static void AppendCsharpDelegateType( output.Append(' '); output.Append(funcName); - output.Append("Delegate("); + output.Append("DelegateType("); if (!isStatic) { if (enclosingTypeKind == TypeKind.FullStruct) @@ -12243,7 +12127,7 @@ static void AppendCsharpDelegateType( AppendCsharpBindingParameterDeclaration( parameters, output); - output.Append(");\n"); + output.AppendLine(");"); } static void AppendCsharpFunctionBeginning( @@ -12257,7 +12141,8 @@ static void AppendCsharpFunctionBeginning( { output.Append("\t\t[MonoPInvokeCallback(typeof("); output.Append(funcName); - output.Append("Delegate))]\n\t\tstatic "); + output.AppendLine("DelegateType))]"); + output.Append("\t\tstatic "); // Return type if (returnType != null) @@ -12302,10 +12187,14 @@ static void AppendCsharpFunctionBeginning( AppendCsharpBindingParameterDeclaration( parameters, output); - output.Append(")\n\t\t{\n\t\t\t"); + output.AppendLine(")"); + output.AppendLine("\t\t{"); + output.Append("\t\t\t"); // Start try/catch block - output.Append("try\n\t\t\t{\n\t\t\t\t"); + output.AppendLine("try"); + output.AppendLine("\t\t\t{"); + output.Append("\t\t\t\t"); // Get "this" if (!isStatic @@ -12319,8 +12208,10 @@ static void AppendCsharpFunctionBeginning( AppendHandleStoreTypeName( enclosingType, output); + output.AppendLine( + ".Get(thisHandle);"); output.Append( - ".Get(thisHandle);\n\t\t\t\t"); + "\t\t\t\t"); } // Get managed type params from ObjectStore @@ -12342,7 +12233,8 @@ static void AppendCsharpFunctionBeginning( AppendHandleStoreTypeName(paramType, output); output.Append(".Get("); output.Append(param.Name); - output.Append("Handle);\n\t\t\t\t"); + output.AppendLine("Handle);"); + output.Append("\t\t\t\t"); } } @@ -12399,7 +12291,8 @@ static void AppendStructStoreReplace( string structVariable, StringBuilder output) { - output.Append("\n\t\t\t\t"); + output.AppendLine(); + output.Append("\t\t\t\t"); AppendHandleStoreTypeName( enclosingType, output); @@ -12425,7 +12318,8 @@ static void AppendCsharpFunctionReturn( || param.Kind == TypeKind.ManagedStruct) && (param.IsOut || param.IsRef)) { - output.Append("\n\t\t\t\tint "); + output.AppendLine(); + output.Append("\t\t\t\tint "); output.Append(param.Name); output.Append("HandleNew = "); AppendHandleStoreTypeName( @@ -12442,7 +12336,8 @@ static void AppendCsharpFunctionReturn( } output.Append('('); output.Append(param.Name); - output.Append(");\n\t\t\t\t"); + output.AppendLine(");"); + output.Append("\t\t\t\t"); output.Append(param.Name); output.Append("Handle = "); output.Append(param.Name); @@ -12453,7 +12348,8 @@ static void AppendCsharpFunctionReturn( // Return if (returnType != typeof(void)) { - output.Append("\n\t\t\t\treturn "); + output.AppendLine(); + output.Append("\t\t\t\treturn "); if ( forceReturnReturnValue || returnTypeKind == TypeKind.Enum @@ -12495,8 +12391,8 @@ static void AppendCsharpFunctionEnd( ParameterInfo[] parameters, StringBuilder output) { - output.Append('\n'); - output.Append("\t\t\t}\n"); + output.AppendLine();; + output.AppendLine("\t\t\t}"); if (exceptionTypes == null || Array.IndexOf( exceptionTypes, @@ -12524,8 +12420,8 @@ static void AppendCsharpFunctionEnd( returnType, parameters, output); - output.Append("\t\t}\n"); - output.Append("\t\t\n"); + output.AppendLine("\t\t}"); + output.AppendLine("\t\t"); } static void AppendCsharpCatchException( @@ -12538,14 +12434,14 @@ static void AppendCsharpCatchException( AppendCsharpTypeFullName( exceptionType, output); - output.Append(" ex)\n"); - output.Append("\t\t\t{\n"); - output.Append("\t\t\t\tUnityEngine.Debug.LogException(ex);\n"); + output.AppendLine(" ex)"); + output.AppendLine("\t\t\t{"); + output.AppendLine("\t\t\t\tUnityEngine.Debug.LogException(ex);"); output.Append("\t\t\t\tNativeScript.Bindings."); AppendCsharpSetCsharpExceptionFunctionName( exceptionType, output); - output.Append("(NativeScript.Bindings.ObjectStore.Store(ex));\n"); + output.AppendLine("(NativeScript.Bindings.ObjectStore.Store(ex));"); foreach (ParameterInfo param in parameters) { if (param.IsOut) @@ -12555,7 +12451,7 @@ static void AppendCsharpCatchException( if (param.Kind == TypeKind.Class || param.Kind == TypeKind.ManagedStruct) { - output.Append("Handle = default(int);\n"); + output.AppendLine("Handle = default(int);"); } else { @@ -12563,7 +12459,7 @@ static void AppendCsharpCatchException( AppendCsharpTypeFullName( param.DereferencedParameterType, output); - output.Append(");\n"); + output.AppendLine(");"); } } } @@ -12580,9 +12476,9 @@ static void AppendCsharpCatchException( { output.Append("int"); } - output.Append(");\n"); + output.AppendLine(");"); } - output.Append("\t\t\t}\n"); + output.AppendLine("\t\t\t}"); } static void AppendCsharpSetCsharpExceptionFunctionName( @@ -12779,30 +12675,32 @@ static void AppendCppParameterDeclaration( } } } - - static void AppendDefaultStringParamName( - string str, - StringBuilder output) - { - foreach (char c in str) - { - if (char.IsLetterOrDigit(c)) - { - output.Append(c); - } - } - } - static void AppendCppInitBody( + static void AppendCppInitBodyFunctionPointerParameterRead( string globalVariableName, - string paramName, + bool isStatic, + TypeName enclosingTypeTypeName, + TypeKind enclosingTypeKind, + ParameterInfo[] parameters, + Type returnType, StringBuilder output) { output.Append("\tPlugin::"); output.Append(globalVariableName); - output.Append(" = "); - output.Append(paramName); - output.Append(";\n"); + output.Append(" = *("); + AppendCppFunctionPointer( + string.Empty, // function name + isStatic, + enclosingTypeTypeName, + enclosingTypeKind, + parameters, + returnType, + 2, + output); + output.AppendLine(")curMemory;"); + output.Append("\tcurMemory += sizeof(Plugin::"); + output.Append(globalVariableName); + output.AppendLine(");"); } static void AppendCppMethodDefinitionBegin( @@ -12861,7 +12759,7 @@ static void AppendCppMethodDefinitionBegin( null, // don't substitute method type params false, output); - output.Append(")\n"); + output.AppendLine(")"); } static void AppendCppMethodReturn( @@ -12888,7 +12786,7 @@ static void AppendCppMethodReturn( output.Append("(Plugin::InternalUse::Only, returnValue)"); break; } - output.Append(";\n"); + output.AppendLine(";"); } } @@ -12915,7 +12813,7 @@ static void AppendCppPluginFunctionCall( output.Append(param.Name); output.Append("Handle = "); output.Append(param.Name); - output.Append("->Handle;\n"); + output.AppendLine("->Handle;"); } } @@ -12983,7 +12881,7 @@ static void AppendCppPluginFunctionCall( output.Append(", "); } } - output.Append(");\n"); + output.AppendLine(");"); AppendCppUnhandledExceptionHandling( indent, @@ -13013,45 +12911,21 @@ static void AppendCppUnhandledExceptionHandling( StringBuilder output) { AppendIndent(indent, output); - output.Append("if (Plugin::unhandledCsharpException)\n"); + output.AppendLine("if (Plugin::unhandledCsharpException)"); AppendIndent(indent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent(indent + 1, output); - output.Append("System::Exception* ex = Plugin::unhandledCsharpException;\n"); + output.AppendLine("System::Exception* ex = Plugin::unhandledCsharpException;"); AppendIndent(indent + 1, output); - output.Append("Plugin::unhandledCsharpException = nullptr;\n"); + output.AppendLine("Plugin::unhandledCsharpException = nullptr;"); AppendIndent(indent + 1, output); - output.Append("ex->ThrowReferenceToThis();\n"); + output.AppendLine("ex->ThrowReferenceToThis();"); AppendIndent(indent + 1, output); - output.Append("delete ex;\n"); + output.AppendLine("delete ex;"); AppendIndent(indent, output); - output.Append("}\n"); + output.AppendLine("}"); } - - static void AppendCppInitParam( - string funcName, - bool isStatic, - TypeName enclosingTypeTypeName, - TypeKind enclosingTypeKind, - ParameterInfo[] parameters, - Type returnType, - StringBuilder output - ) - { - output.Append('\t'); - AppendCppFunctionPointer( - funcName, - isStatic, - enclosingTypeTypeName, - enclosingTypeKind, - parameters, - returnType, - ',', - output - ); - output.Append('\n'); - } - + static void AppendCppFunctionPointerDefinition( string funcName, bool isStatic, @@ -13070,10 +12944,11 @@ StringBuilder output enclosingTypeKind, parameters, returnType, - ';', + 1, output ); - output.Append('\n'); + output.Append(';'); + output.AppendLine();; } static void AppendCppFunctionPointer( @@ -13083,7 +12958,7 @@ static void AppendCppFunctionPointer( TypeKind enclosingTypeKind, ParameterInfo[] parameters, Type returnType, - char separator, + int numIndirectionLevels, StringBuilder output) { // Return type @@ -13097,6 +12972,10 @@ static void AppendCppFunctionPointer( // C linkage requires us to use primitive types output.Append("int16_t"); } + else if (returnType.IsPrimitive) + { + AppendCppPrimitiveTypeName(returnType, output); + } else if (IsFullValueType(returnType)) { AppendCppTypeFullName(returnType, output); @@ -13106,7 +12985,8 @@ static void AppendCppFunctionPointer( output.Append("int32_t"); } - output.Append(" (*"); + output.Append(" ("); + output.Append('*', numIndirectionLevels); output.Append(funcName); output.Append(")("); if (!isStatic) @@ -13187,7 +13067,6 @@ static void AppendCppFunctionPointer( } } output.Append(')'); - output.Append(separator); } static void AppendCppTemplateTypenames( @@ -13273,7 +13152,7 @@ static void AppendCppMethodDeclaration( output); output.Append(')'); - output.Append(";\n"); + output.AppendLine(";"); } static void AppendCsharpTypeFullName( @@ -13442,16 +13321,9 @@ static void AppendCppTypeFullName( output.Append(rank); output.Append('<'); Type elementType = type.GetElementType(); - for (int i = 0; i < rank; ++i) - { - AppendCppTypeFullName( - elementType, - output); - if (i != rank -1) - { - output.Append(", "); - } - } + AppendCppTypeFullName( + elementType, + output); output.Append('>'); } else if (IsDelegate(type)) @@ -13566,13 +13438,13 @@ static void AppendCppPrimitiveTypeName( static void RemoveTrailingChars( StringBuilders builders) { - RemoveTrailingChars(builders.CsharpInitParams); RemoveTrailingChars(builders.CsharpDelegateTypes); RemoveTrailingChars(builders.CsharpStoreInitCalls); RemoveTrailingChars(builders.CsharpInitCall); RemoveTrailingChars(builders.CsharpBaseTypes); RemoveTrailingChars(builders.CsharpFunctions); - RemoveTrailingChars(builders.CsharpDelegates); + RemoveTrailingChars(builders.CsharpCppDelegates); + RemoveTrailingChars(builders.CsharpCsharpDelegates); RemoveTrailingChars(builders.CsharpImports); RemoveTrailingChars(builders.CsharpGetDelegateCalls); RemoveTrailingChars(builders.CsharpDestroyFunctionEnumerators); @@ -13583,8 +13455,8 @@ static void RemoveTrailingChars( RemoveTrailingChars(builders.CppTemplateSpecializationDeclarations); RemoveTrailingChars(builders.CppTypeDefinitions); RemoveTrailingChars(builders.CppMethodDefinitions); - RemoveTrailingChars(builders.CppInitParams); - RemoveTrailingChars(builders.CppInitBody); + RemoveTrailingChars(builders.CppInitBodyParameterReads); + RemoveTrailingChars(builders.CppInitBodyArrays); RemoveTrailingChars(builders.CppInitBodyFirstBoot); RemoveTrailingChars(builders.CppGlobalStateAndFunctions); RemoveTrailingChars(builders.CppUnboxingMethodDeclarations); @@ -13601,17 +13473,12 @@ static void RemoveTrailingChars( for (i = len - 1; i >= 0; --i) { char cur = builder[i]; - switch (cur) + if (!char.IsWhiteSpace(cur) && cur != ',') { - case '\n': - case '\t': - case ',': - break; - default: - goto after; + break; } } - after: + if (i < len - 1) { builder.Remove(i + 1, len - i - 1); @@ -13627,123 +13494,123 @@ static void InjectBuilders( string cppSourceContents = File.ReadAllText(CppSourcePath); csharpContents = InjectIntoString( csharpContents, - "/*BEGIN INIT PARAMS*/\n", - "\n\t\t\t/*END INIT PARAMS*/", - builders.CsharpInitParams.ToString()); - csharpContents = InjectIntoString( - csharpContents, - "/*BEGIN DELEGATE TYPES*/\n", - "\n\t\t/*END DELEGATE TYPES*/", + "/*BEGIN DELEGATE TYPES*/", + "\t\t/*END DELEGATE TYPES*/", builders.CsharpDelegateTypes.ToString()); csharpContents = InjectIntoString( csharpContents, - "/*BEGIN STORE INIT CALLS*/\n", - "\n\t\t\t/*END STORE INIT CALLS*/", + "/*BEGIN STORE INIT CALLS*/", + "\t\t\t/*END STORE INIT CALLS*/", builders.CsharpStoreInitCalls.ToString()); csharpContents = InjectIntoString( csharpContents, - "/*BEGIN INIT CALL*/\n", - "\n\t\t\t\t/*END INIT CALL*/", + "/*BEGIN INIT CALL*/", + "\t\t\t/*END INIT CALL*/", builders.CsharpInitCall.ToString()); csharpContents = InjectIntoString( csharpContents, - "/*BEGIN BASE TYPES*/\n", - "\n/*END BASE TYPES*/", + "/*BEGIN BASE TYPES*/", + "/*END BASE TYPES*/", builders.CsharpBaseTypes.ToString()); csharpContents = InjectIntoString( csharpContents, - "/*BEGIN FUNCTIONS*/\n", - "\n\t\t/*END FUNCTIONS*/", + "/*BEGIN FUNCTIONS*/", + "\t\t/*END FUNCTIONS*/", builders.CsharpFunctions.ToString()); csharpContents = InjectIntoString( csharpContents, - "/*BEGIN DELEGATES*/\n", - "\n\t\t/*END DELEGATES*/", - builders.CsharpDelegates.ToString()); + "/*BEGIN CPP DELEGATES*/", + "\t\t/*END CPP DELEGATES*/", + builders.CsharpCppDelegates.ToString()); csharpContents = InjectIntoString( csharpContents, - "/*BEGIN IMPORTS*/\n", - "\n\t\t/*END IMPORTS*/", + "/*BEGIN CSHARP DELEGATES*/", + "\t\t/*END CSHARP DELEGATES*/", + builders.CsharpCsharpDelegates.ToString()); + csharpContents = InjectIntoString( + csharpContents, + "/*BEGIN IMPORTS*/", + "\t\t/*END IMPORTS*/", builders.CsharpImports.ToString()); csharpContents = InjectIntoString( csharpContents, - "/*BEGIN GETDELEGATE CALLS*/\n", - "\n\t\t\t/*END GETDELEGATE CALLS*/", + "/*BEGIN GETDELEGATE CALLS*/", + "\t\t\t/*END GETDELEGATE CALLS*/", builders.CsharpGetDelegateCalls.ToString()); csharpContents = InjectIntoString( csharpContents, - "/*BEGIN DESTROY FUNCTION ENUMERATORS*/\n", - "\n\t\t\t/*END DESTROY FUNCTION ENUMERATORS*/", + "/*BEGIN DESTROY FUNCTION ENUMERATORS*/", + "\t\t\t/*END DESTROY FUNCTION ENUMERATORS*/", builders.CsharpDestroyFunctionEnumerators.ToString()); csharpContents = InjectIntoString( csharpContents, - "/*BEGIN DESTROY QUEUE CASES*/\n", - "\n\t\t\t\t\t\t/*END DESTROY QUEUE CASES*/", + "/*BEGIN DESTROY QUEUE CASES*/", + "\t\t\t\t\t\t/*END DESTROY QUEUE CASES*/", builders.CsharpDestroyQueueCases.ToString()); cppSourceContents = InjectIntoString( cppSourceContents, - "/*BEGIN FUNCTION POINTERS*/\n", - "\n\t/*END FUNCTION POINTERS*/", + "/*BEGIN FUNCTION POINTERS*/", + "\t/*END FUNCTION POINTERS*/", builders.CppFunctionPointers.ToString()); cppHeaderContents = InjectIntoString( cppHeaderContents, - "/*BEGIN TYPE DECLARATIONS*/\n", - "\n/*END TYPE DECLARATIONS*/", + "/*BEGIN TYPE DECLARATIONS*/", + "/*END TYPE DECLARATIONS*/", builders.CppTypeDeclarations.ToString()); cppHeaderContents = InjectIntoString( cppHeaderContents, - "/*BEGIN TEMPLATE DECLARATIONS*/\n", - "\n/*END TEMPLATE DECLARATIONS*/", + "/*BEGIN TEMPLATE DECLARATIONS*/", + "/*END TEMPLATE DECLARATIONS*/", builders.CppTemplateDeclarations.ToString()); cppHeaderContents = InjectIntoString( cppHeaderContents, - "/*BEGIN TEMPLATE SPECIALIZATION DECLARATIONS*/\n", - "\n/*END TEMPLATE SPECIALIZATION DECLARATIONS*/", + "/*BEGIN TEMPLATE SPECIALIZATION DECLARATIONS*/", + "/*END TEMPLATE SPECIALIZATION DECLARATIONS*/", builders.CppTemplateSpecializationDeclarations.ToString()); cppHeaderContents = InjectIntoString( cppHeaderContents, - "/*BEGIN TYPE DEFINITIONS*/\n", - "\n/*END TYPE DEFINITIONS*/", + "/*BEGIN TYPE DEFINITIONS*/", + "/*END TYPE DEFINITIONS*/", builders.CppTypeDefinitions.ToString()); cppSourceContents = InjectIntoString( cppSourceContents, - "/*BEGIN METHOD DEFINITIONS*/\n", - "\n/*END METHOD DEFINITIONS*/", + "/*BEGIN METHOD DEFINITIONS*/", + "/*END METHOD DEFINITIONS*/", builders.CppMethodDefinitions.ToString()); cppSourceContents = InjectIntoString( cppSourceContents, - "/*BEGIN INIT PARAMS*/\n", - "\n\t/*END INIT PARAMS*/", - builders.CppInitParams.ToString()); + "/*BEGIN INIT BODY PARAMETER READS*/", + "\t/*END INIT BODY PARAMETER READS*/", + builders.CppInitBodyParameterReads.ToString()); cppSourceContents = InjectIntoString( cppSourceContents, - "/*BEGIN INIT BODY*/\n", - "\n\t/*END INIT BODY*/", - builders.CppInitBody.ToString()); + "/*BEGIN INIT BODY ARRAYS*/", + "\t/*END INIT BODY ARRAYS*/", + builders.CppInitBodyArrays.ToString()); cppSourceContents = InjectIntoString( cppSourceContents, - "/*BEGIN INIT BODY FIRST BOOT*/\n", - "\n\t\t/*END INIT BODY FIRST BOOT*/", + "/*BEGIN INIT BODY FIRST BOOT*/", + "\t\t/*END INIT BODY FIRST BOOT*/", builders.CppInitBodyFirstBoot.ToString()); cppSourceContents = InjectIntoString( cppSourceContents, - "/*BEGIN GLOBAL STATE AND FUNCTIONS*/\n", - "\n\t/*END GLOBAL STATE AND FUNCTIONS*/", + "/*BEGIN GLOBAL STATE AND FUNCTIONS*/", + "\t/*END GLOBAL STATE AND FUNCTIONS*/", builders.CppGlobalStateAndFunctions.ToString()); cppHeaderContents = InjectIntoString( cppHeaderContents, - "/*BEGIN UNBOXING METHOD DECLARATIONS*/\n", - "\n\t\t/*END UNBOXING METHOD DECLARATIONS*/", + "/*BEGIN UNBOXING METHOD DECLARATIONS*/", + "\t\t/*END UNBOXING METHOD DECLARATIONS*/", builders.CppUnboxingMethodDeclarations.ToString()); cppHeaderContents = InjectIntoString( cppHeaderContents, - "/*BEGIN STRING DEFAULT PARAMETERS*/\n", - "\n\t/*END STRING DEFAULT PARAMETERS*/", + "/*BEGIN STRING DEFAULT PARAMETERS*/", + "\t/*END STRING DEFAULT PARAMETERS*/", builders.CppStringDefaultParams.ToString()); cppHeaderContents = InjectIntoString( cppHeaderContents, - "/*BEGIN MACROS*/\n", - "\n/*END MACROS*/", + "/*BEGIN MACROS*/", + "/*END MACROS*/", builders.CppMacros.ToString()); File.WriteAllText(CsharpPath, csharpContents); @@ -13757,15 +13624,16 @@ static string InjectIntoString( string endMarker, string text) { - for (int startIndex = 0; ; ) + int startIndex = 0; + while(true) { - int beginIndex = contents.IndexOf(beginMarker, startIndex); + int beginIndex = contents.IndexOf(beginMarker, startIndex, StringComparison.OrdinalIgnoreCase); if (beginIndex < 0) { return contents; } int afterBeginIndex = beginIndex + beginMarker.Length; - int endIndex = contents.IndexOf(endMarker, afterBeginIndex); + int endIndex = contents.IndexOf(endMarker, afterBeginIndex, StringComparison.OrdinalIgnoreCase); if (endIndex < 0) { throw new Exception( @@ -13778,9 +13646,9 @@ static string InjectIntoString( } string begin = contents.Substring(0, afterBeginIndex); string end = contents.Substring(endIndex); - contents = begin + text + end; + contents = begin + Environment.NewLine + text + Environment.NewLine + end; startIndex = beginIndex + 1; } } } -} \ No newline at end of file +} diff --git a/Unity/Assets/NativeScriptTypes.json b/Unity/Assets/NativeScriptTypes.json index 26511b8..c507547 100644 --- a/Unity/Assets/NativeScriptTypes.json +++ b/Unity/Assets/NativeScriptTypes.json @@ -78,6 +78,11 @@ "Types": [ "System.Decimal" ] + }, + { + "Types": [ + "UnityEngine.Vector3" + ] } ] }, @@ -151,6 +156,9 @@ } ] }, + { + "Name": " System.Runtime.Serialization.IDeserializationCallback" + }, { "Name": "System.Decimal", "Constructors": [ diff --git a/Unity/Packages/manifest.json b/Unity/Packages/manifest.json new file mode 100644 index 0000000..bc19e66 --- /dev/null +++ b/Unity/Packages/manifest.json @@ -0,0 +1,51 @@ +{ + "dependencies": { + "com.unity.2d.sprite": "1.0.0", + "com.unity.2d.tilemap": "1.0.0", + "com.unity.ads": "2.0.8", + "com.unity.analytics": "3.3.2", + "com.unity.collab-proxy": "1.2.16", + "com.unity.ext.nunit": "1.0.0", + "com.unity.ide.rider": "1.0.8", + "com.unity.ide.vscode": "1.0.7", + "com.unity.multiplayer-hlapi": "1.0.2", + "com.unity.package-manager-ui": "2.2.0", + "com.unity.purchasing": "2.0.6", + "com.unity.test-framework": "1.0.13", + "com.unity.textmeshpro": "2.0.1", + "com.unity.timeline": "1.1.0", + "com.unity.ugui": "1.0.0", + "com.unity.xr.legacyinputhelpers": "2.0.2", + "com.unity.modules.ai": "1.0.0", + "com.unity.modules.androidjni": "1.0.0", + "com.unity.modules.animation": "1.0.0", + "com.unity.modules.assetbundle": "1.0.0", + "com.unity.modules.audio": "1.0.0", + "com.unity.modules.cloth": "1.0.0", + "com.unity.modules.director": "1.0.0", + "com.unity.modules.imageconversion": "1.0.0", + "com.unity.modules.imgui": "1.0.0", + "com.unity.modules.jsonserialize": "1.0.0", + "com.unity.modules.particlesystem": "1.0.0", + "com.unity.modules.physics": "1.0.0", + "com.unity.modules.physics2d": "1.0.0", + "com.unity.modules.screencapture": "1.0.0", + "com.unity.modules.terrain": "1.0.0", + "com.unity.modules.terrainphysics": "1.0.0", + "com.unity.modules.tilemap": "1.0.0", + "com.unity.modules.ui": "1.0.0", + "com.unity.modules.uielements": "1.0.0", + "com.unity.modules.umbra": "1.0.0", + "com.unity.modules.unityanalytics": "1.0.0", + "com.unity.modules.unitywebrequest": "1.0.0", + "com.unity.modules.unitywebrequestassetbundle": "1.0.0", + "com.unity.modules.unitywebrequestaudio": "1.0.0", + "com.unity.modules.unitywebrequesttexture": "1.0.0", + "com.unity.modules.unitywebrequestwww": "1.0.0", + "com.unity.modules.vehicles": "1.0.0", + "com.unity.modules.video": "1.0.0", + "com.unity.modules.vr": "1.0.0", + "com.unity.modules.wind": "1.0.0", + "com.unity.modules.xr": "1.0.0" + } +} diff --git a/Unity/ProjectSettings/EditorSettings.asset b/Unity/ProjectSettings/EditorSettings.asset index f33b6fb..4b908a6 100644 --- a/Unity/ProjectSettings/EditorSettings.asset +++ b/Unity/ProjectSettings/EditorSettings.asset @@ -3,14 +3,24 @@ --- !u!159 &1 EditorSettings: m_ObjectHideFlags: 0 - serializedVersion: 4 + serializedVersion: 8 m_ExternalVersionControlSupport: Visible Meta Files m_SerializationMode: 2 + m_LineEndingsForNewScripts: 1 m_DefaultBehaviorMode: 0 + m_PrefabRegularEnvironment: {fileID: 0} + m_PrefabUIEnvironment: {fileID: 0} m_SpritePackerMode: 0 m_SpritePackerPaddingPower: 1 - m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd + m_EtcTextureCompressorBehavior: 0 + m_EtcTextureFastCompressor: 2 + m_EtcTextureNormalCompressor: 2 + m_EtcTextureBestCompressor: 5 + m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmref;asmdef m_ProjectGenerationRootNamespace: - m_UserGeneratedProjectSuffix: m_CollabEditorSettings: inProgressEnabled: 1 + m_EnableTextureStreamingInEditMode: 1 + m_EnableTextureStreamingInPlayMode: 1 + m_AsyncShaderCompilation: 1 + m_ShowLightmapResolutionOverlay: 1 diff --git a/Unity/ProjectSettings/GraphicsSettings.asset b/Unity/ProjectSettings/GraphicsSettings.asset index 77bf2f1..646b92e 100644 --- a/Unity/ProjectSettings/GraphicsSettings.asset +++ b/Unity/ProjectSettings/GraphicsSettings.asset @@ -37,6 +37,8 @@ GraphicsSettings: - {fileID: 10782, guid: 0000000000000000f000000000000000, type: 0} - {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0} - {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 16001, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 16002, guid: 0000000000000000f000000000000000, type: 0} m_PreloadedShaders: [] m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} diff --git a/Unity/ProjectSettings/PresetManager.asset b/Unity/ProjectSettings/PresetManager.asset new file mode 100644 index 0000000..636a595 --- /dev/null +++ b/Unity/ProjectSettings/PresetManager.asset @@ -0,0 +1,6 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1386491679 &1 +PresetManager: + m_ObjectHideFlags: 0 + m_DefaultList: [] diff --git a/Unity/ProjectSettings/ProjectSettings.asset b/Unity/ProjectSettings/ProjectSettings.asset index b6955bb..8602e2b 100644 --- a/Unity/ProjectSettings/ProjectSettings.asset +++ b/Unity/ProjectSettings/ProjectSettings.asset @@ -3,10 +3,11 @@ --- !u!129 &1 PlayerSettings: m_ObjectHideFlags: 0 - serializedVersion: 14 + serializedVersion: 18 productGUID: 435980e4cf9ff4aa8b71e496e8163063 AndroidProfiler: 0 AndroidFilterTouchesWhenObscured: 0 + AndroidEnableSustainedPerformanceMode: 0 defaultScreenOrientation: 4 targetDevice: 2 useOnDemandResources: 0 @@ -51,9 +52,8 @@ PlayerSettings: m_StackTraceTypes: 010000000100000001000000010000000100000001000000 iosShowActivityIndicatorOnLoading: -1 androidShowActivityIndicatorOnLoading: -1 - tizenShowActivityIndicatorOnLoading: -1 - iosAppInBackgroundBehavior: 0 displayResolutionDialog: 1 + iosUseCustomAppBackgroundBehavior: 0 iosAllowHTTPDownload: 1 allowedAutorotateToPortrait: 1 allowedAutorotateToPortraitUpsideDown: 1 @@ -63,8 +63,10 @@ PlayerSettings: use32BitDisplayBuffer: 1 preserveFramebufferAlpha: 0 disableDepthAndStencilBuffers: 0 + androidStartInFullscreen: 1 + androidRenderOutsideSafeArea: 1 + androidUseSwappy: 0 androidBlitType: 0 - defaultIsFullScreen: 1 defaultIsNativeResolution: 1 macRetinaSupport: 1 runInBackground: 0 @@ -78,6 +80,7 @@ PlayerSettings: usePlayerLog: 1 bakeCollisionMeshes: 0 forceSingleInstance: 0 + useFlipModelSwapchain: 1 resizableWindow: 0 useMacAppStoreValidation: 0 macAppStoreCategory: public.app-category.games @@ -91,16 +94,12 @@ PlayerSettings: visibleInBackground: 0 allowFullscreenSwitch: 1 graphicsJobMode: 0 - macFullscreenMode: 2 - d3d11FullscreenMode: 1 + fullscreenMode: 1 xboxSpeechDB: 0 xboxEnableHeadOrientation: 0 xboxEnableGuest: 0 xboxEnablePIXSampling: 0 metalFramebufferOnly: 0 - n3dsDisableStereoscopicView: 0 - n3dsEnableSharedListOpt: 1 - n3dsEnableVSync: 0 xboxOneResolution: 0 xboxOneSResolution: 0 xboxOneXResolution: 3 @@ -108,18 +107,13 @@ PlayerSettings: xboxOneLoggingLevel: 1 xboxOneDisableEsram: 0 xboxOnePresentImmediateThreshold: 0 - videoMemoryForVertexBuffers: 0 - psp2PowerMode: 0 - psp2AcquireBGM: 1 - wiiUTVResolution: 0 - wiiUGamePadMSAA: 1 - wiiUSupportsNunchuk: 0 - wiiUSupportsClassicController: 0 - wiiUSupportsBalanceBoard: 0 - wiiUSupportsMotionPlus: 0 - wiiUSupportsProController: 0 - wiiUAllowScreenCapture: 1 - wiiUControllerCount: 0 + switchQueueCommandMemory: 1048576 + switchQueueControlMemory: 16384 + switchQueueComputeMemory: 262144 + switchNVNShaderPoolsGranularity: 33554432 + switchNVNDefaultPoolsGranularity: 16777216 + switchNVNOtherPoolsGranularity: 16777216 + vulkanEnableSetSRGBWrite: 0 m_SupportedAspectRatios: 4:3: 1 5:4: 1 @@ -147,10 +141,20 @@ PlayerSettings: hololens: depthFormat: 1 depthBufferSharingEnabled: 0 + lumin: + depthFormat: 0 + frameTiming: 2 + enableGLCache: 0 + glCacheMaxBlobSize: 524288 + glCacheMaxFileSize: 8388608 oculus: sharedDepthBuffer: 0 dashSupport: 0 + lowOverheadMode: 0 + enable360StereoCapture: 0 + isWsaHolographicRemotingEnabled: 0 protectGraphicsMemory: 0 + enableFrameTimingStats: 0 useHDRDisplay: 0 m_ColorGamuts: 00000000 targetPixelDensity: 30 @@ -161,10 +165,10 @@ PlayerSettings: Android: com.jacksondunstan.unityplayground Standalone: unity.DefaultCompany.UnityPlayground Tizen: com.jacksondunstan.unityplayground - iOS: com.jacksondunstan.unityplayground + iPhone: com.jacksondunstan.unityplayground tvOS: com.jacksondunstan.unityplayground buildNumber: - iOS: 0 + iPhone: 0 AndroidBundleVersionCode: 1 AndroidMinSdkVersion: 16 AndroidTargetSdkVersion: 0 @@ -179,11 +183,9 @@ PlayerSettings: APKExpansionFiles: 0 keepLoadedShadersAlive: 0 StripUnusedMeshComponents: 0 - VertexChannelCompressionMask: - serializedVersion: 2 - m_Bits: 238 + VertexChannelCompressionMask: 214 iPhoneSdkVersion: 988 - iOSTargetOSVersionString: 7.0 + iOSTargetOSVersionString: 9.0 tvOSSdkVersion: 0 tvOSRequireExtendedGameController: 0 tvOSTargetOSVersionString: 9.0 @@ -205,11 +207,16 @@ PlayerSettings: iPadHighResPortraitSplashScreen: {fileID: 0} iPadLandscapeSplashScreen: {fileID: 0} iPadHighResLandscapeSplashScreen: {fileID: 0} + iPhone65inPortraitSplashScreen: {fileID: 0} + iPhone65inLandscapeSplashScreen: {fileID: 0} + iPhone61inPortraitSplashScreen: {fileID: 0} + iPhone61inLandscapeSplashScreen: {fileID: 0} appleTVSplashScreen: {fileID: 0} appleTVSplashScreen2x: {fileID: 0} tvOSSmallIconLayers: [] tvOSSmallIconLayers2x: [] tvOSLargeIconLayers: [] + tvOSLargeIconLayers2x: [] tvOSTopShelfImageLayers: [] tvOSTopShelfImageLayers2x: [] tvOSTopShelfImageWideLayers: [] @@ -243,23 +250,34 @@ PlayerSettings: appleDeveloperTeamID: iOSManualSigningProvisioningProfileID: tvOSManualSigningProvisioningProfileID: + iOSManualSigningProvisioningProfileType: 0 + tvOSManualSigningProvisioningProfileType: 0 appleEnableAutomaticSigning: 0 + iOSRequireARKit: 0 + iOSAutomaticallyDetectAndAddCapabilities: 1 + appleEnableProMotion: 0 clonedFromGUID: 00000000000000000000000000000000 - AndroidTargetDevice: 3 + templatePackageId: + templateDefaultScene: + AndroidTargetArchitectures: 1 AndroidSplashScreenScale: 0 androidSplashScreen: {fileID: 0} - AndroidKeystoreName: + AndroidKeystoreName: '{inproject}: ' AndroidKeyaliasName: + AndroidBuildApkPerCpuArchitecture: 0 AndroidTVCompatibility: 1 AndroidIsGame: 1 AndroidEnableTango: 0 androidEnableBanner: 1 androidUseLowAccuracyLocation: 0 + androidUseCustomKeystore: 0 m_AndroidBanners: - width: 320 height: 180 banner: {fileID: 0} androidGamepadSupportLevel: 0 + AndroidValidateAppBundleSize: 1 + AndroidAppBundleSizeToValidate: 150 resolutionDialogBanner: {fileID: 0} m_BuildTargetIcons: - m_BuildTarget: @@ -269,6 +287,7 @@ PlayerSettings: m_Width: 128 m_Height: 128 m_Kind: 0 + m_BuildTargetPlatformIcons: [] m_BuildTargetBatching: [] m_BuildTargetGraphicsAPIs: - m_BuildTarget: AndroidPlayer @@ -279,7 +298,7 @@ PlayerSettings: m_Enabled: 0 m_Devices: - Oculus - - m_BuildTarget: Metro + - m_BuildTarget: Windows Store Apps m_Enabled: 0 m_Devices: [] - m_BuildTarget: N3DS @@ -323,15 +342,16 @@ PlayerSettings: - m_BuildTarget: XboxOne m_Enabled: 0 m_Devices: [] - - m_BuildTarget: iOS + - m_BuildTarget: iPhone m_Enabled: 0 m_Devices: [] - m_BuildTarget: tvOS m_Enabled: 0 m_Devices: [] - m_BuildTargetEnableVuforiaSettings: [] openGLRequireES31: 0 openGLRequireES31AEP: 0 + openGLRequireES32: 0 + vuforiaEnabled: 0 m_TemplateCustomTags: {} mobileMTRendering: Android: 1 @@ -344,25 +364,9 @@ PlayerSettings: m_EncodingQuality: 1 - m_BuildTarget: PS4 m_EncodingQuality: 1 - wiiUTitleID: 0005000011000000 - wiiUGroupID: 00010000 - wiiUCommonSaveSize: 4096 - wiiUAccountSaveSize: 2048 - wiiUOlvAccessKey: 0 - wiiUTinCode: 0 - wiiUJoinGameId: 0 - wiiUJoinGameModeMask: 0000000000000000 - wiiUCommonBossSize: 0 - wiiUAccountBossSize: 0 - wiiUAddOnUniqueIDs: [] - wiiUMainThreadStackSize: 3072 - wiiULoaderThreadStackSize: 1024 - wiiUSystemHeapSize: 128 - wiiUTVStartupScreen: {fileID: 0} - wiiUGamePadStartupScreen: {fileID: 0} - wiiUDrcBufferDisabled: 0 - wiiUProfilerLibPath: + m_BuildTargetGroupLightmapSettings: [] playModeTestRunnerEnabled: 0 + runPlayModeTestAsEditModeTest: 0 actionOnDotNetUnhandledException: 1 enableInternalProfiler: 0 logObjCUncaughtExceptions: 1 @@ -482,7 +486,12 @@ PlayerSettings: switchAllowsVideoCapturing: 1 switchAllowsRuntimeAddOnContentInstall: 0 switchDataLossConfirmation: 0 + switchUserAccountLockEnabled: 0 + switchSystemResourceMemory: 16777216 switchSupportedNpadStyles: 3 + switchNativeFsCacheSize: 32 + switchIsHoldTypeHorizontal: 0 + switchSupportedNpadCount: 8 switchSocketConfigEnabled: 0 switchTcpInitialSendBufferSize: 32 switchTcpInitialReceiveBufferSize: 64 @@ -532,12 +541,15 @@ PlayerSettings: ps4DownloadDataSize: 0 ps4GarlicHeapSize: 2048 ps4ProGarlicHeapSize: 2560 + playerPrefsMaxSize: 32768 ps4Passcode: 5PN2qmWqBlQ9wQj99nsQzldVI5ZuGXbE ps4pnSessions: 1 ps4pnPresence: 1 ps4pnFriends: 1 ps4pnGameCustomData: 1 playerPrefsSupport: 0 + enableApplicationExit: 0 + resetTempFolder: 1 restrictedAudioUsageRights: 0 ps4UseResolutionFallback: 0 ps4ReprojectionSupport: 0 @@ -561,56 +573,9 @@ PlayerSettings: ps4attribEyeToEyeDistanceSettingVR: 0 ps4IncludedModules: [] monoEnv: - psp2Splashimage: {fileID: 0} - psp2NPTrophyPackPath: - psp2NPSupportGBMorGJP: 0 - psp2NPAgeRating: 12 - psp2NPTitleDatPath: - psp2NPCommsID: - psp2NPCommunicationsID: - psp2NPCommsPassphrase: - psp2NPCommsSig: - psp2ParamSfxPath: - psp2ManualPath: - psp2LiveAreaGatePath: - psp2LiveAreaBackroundPath: - psp2LiveAreaPath: - psp2LiveAreaTrialPath: - psp2PatchChangeInfoPath: - psp2PatchOriginalPackage: - psp2PackagePassword: 5PN2qmWqBlQ9wQj99nsQzldVI5ZuGXbE - psp2KeystoneFile: - psp2MemoryExpansionMode: 0 - psp2DRMType: 0 - psp2StorageType: 0 - psp2MediaCapacity: 0 - psp2DLCConfigPath: - psp2ThumbnailPath: - psp2BackgroundPath: - psp2SoundPath: - psp2TrophyCommId: - psp2TrophyPackagePath: - psp2PackagedResourcesPath: - psp2SaveDataQuota: 10240 - psp2ParentalLevel: 1 - psp2ShortTitle: Not Set - psp2ContentID: IV0000-ABCD12345_00-0123456789ABCDEF - psp2Category: 0 - psp2MasterVersion: 01.00 - psp2AppVersion: 01.00 - psp2TVBootMode: 0 - psp2EnterButtonAssignment: 2 - psp2TVDisableEmu: 0 - psp2AllowTwitterDialog: 1 - psp2Upgradable: 0 - psp2HealthWarning: 0 - psp2UseLibLocation: 0 - psp2InfoBarOnStartup: 0 - psp2InfoBarColor: 0 - psp2ScriptOptimizationLevel: 0 - psmSplashimage: {fileID: 0} splashScreenBackgroundSourceLandscape: {fileID: 0} splashScreenBackgroundSourcePortrait: {fileID: 0} + blurSplashScreenBackground: 1 spritePackerPolicy: webGLMemorySize: 256 webGLExceptionSupport: 0 @@ -622,21 +587,28 @@ PlayerSettings: webGLTemplate: APPLICATION:Default webGLAnalyzeBuildSize: 0 webGLUseEmbeddedResources: 0 - webGLUseWasm: 0 webGLCompressionFormat: 1 + webGLLinkerTarget: 1 + webGLThreadsSupport: 0 + webGLWasmStreaming: 0 scriptingDefineSymbols: 1: platformArchitecture: - iOS: 0 + iPhone: 0 scriptingBackend: Android: 1 - Standalone: 0 + Standalone: 1 WebGL: 1 - iOS: 1 + iPhone: 1 + il2cppCompilerConfiguration: {} + managedStrippingLevel: {} incrementalIl2cppBuild: - iOS: 0 + iPhone: 0 + allowUnsafeCode: 0 additionalIl2CppArgs: - scriptingRuntimeVersion: 0 + scriptingRuntimeVersion: 1 + gcIncremental: 0 + gcWBarrierValidation: 0 apiCompatibilityLevelPerPlatform: {} m_RenderingPath: 1 m_MobileRenderingPath: 1 @@ -650,40 +622,22 @@ PlayerSettings: metroApplicationDescription: UnityPlayground wsaImages: {} metroTileShortName: - metroCommandLineArgsFile: metroTileShowName: 0 metroMediumTileShowName: 0 metroLargeTileShowName: 0 metroWideTileShowName: 0 + metroSupportStreamingInstall: 0 + metroLastRequiredScene: 0 metroDefaultTileSize: 1 metroTileForegroundText: 1 metroTileBackgroundColor: {r: 0, g: 0, b: 0, a: 1} metroSplashScreenBackgroundColor: {r: 0, g: 0, b: 0, a: 1} metroSplashScreenUseBackgroundColor: 0 platformCapabilities: {} + metroTargetDeviceFamilies: {} metroFTAName: metroFTAFileTypes: [] metroProtocolName: - metroCompilationOverrides: 1 - tizenProductDescription: - tizenProductURL: - tizenSigningProfileName: - tizenGPSPermissions: 0 - tizenMicrophonePermissions: 0 - tizenDeploymentTarget: - tizenDeploymentTargetType: -1579033 - tizenMinOSVersion: 1 - n3dsUseExtSaveData: 0 - n3dsCompressStaticMem: 1 - n3dsExtSaveDataNumber: 0x12345 - n3dsStackSize: 131072 - n3dsTargetPlatform: 2 - n3dsRegion: 7 - n3dsMediaSize: 0 - n3dsLogoStyle: 3 - n3dsTitle: GameName - n3dsProductCode: - n3dsApplicationId: 0xFF3FF XboxOneProductId: XboxOneUpdateKey: XboxOneSandboxId: @@ -693,6 +647,7 @@ PlayerSettings: XboxOneGameOsOverridePath: XboxOnePackagingOverridePath: XboxOneAppManifestOverridePath: + XboxOneVersion: 1.0.0.0 XboxOnePackageEncryption: 0 XboxOnePackageUpdateGranularity: 2 XboxOneDescription: @@ -707,7 +662,8 @@ PlayerSettings: XboxOneAllowedProductIds: [] XboxOnePersistentLocalStorageSize: 0 XboxOneXTitleMemory: 8 - xboxOneScriptCompiler: 0 + xboxOneScriptCompiler: 1 + XboxOneOverrideIdentityName: vrEditorSettings: daydream: daydreamIconForeground: {fileID: 0} @@ -722,11 +678,30 @@ PlayerSettings: Purchasing: 0 UNet: 0 Unity_Ads: 0 + luminIcon: + m_Name: + m_ModelFolderPath: + m_PortalFolderPath: + luminCert: + m_CertPath: + m_SignPackage: 1 + luminIsChannelApp: 0 + luminVersion: + m_VersionCode: 1 + m_VersionName: facebookSdkVersion: 7.9.1 - apiCompatibilityLevel: 2 + facebookAppId: + facebookCookies: 1 + facebookLogging: 1 + facebookStatus: 1 + facebookXfbml: 0 + facebookFrictionlessRequests: 1 + apiCompatibilityLevel: 6 cloudProjectId: + framebufferDepthMemorylessMode: 0 projectName: organizationId: cloudEnabled: 0 enableNativePlatformBackendsForNewInputSystem: 0 disableOldInputManagerSupport: 0 + legacyClampBlendShapeWeights: 1 diff --git a/Unity/ProjectSettings/ProjectVersion.txt b/Unity/ProjectSettings/ProjectVersion.txt index e3618f1..7e64146 100644 --- a/Unity/ProjectSettings/ProjectVersion.txt +++ b/Unity/ProjectSettings/ProjectVersion.txt @@ -1 +1,2 @@ -m_EditorVersion: 2017.4.1f1 +m_EditorVersion: 2019.2.0f1 +m_EditorVersionWithRevision: 2019.2.0f1 (20c1667945cf) diff --git a/Unity/ProjectSettings/UnityConnectSettings.asset b/Unity/ProjectSettings/UnityConnectSettings.asset index 1cc5485..c3ae9a0 100644 --- a/Unity/ProjectSettings/UnityConnectSettings.asset +++ b/Unity/ProjectSettings/UnityConnectSettings.asset @@ -3,29 +3,29 @@ --- !u!310 &1 UnityConnectSettings: m_ObjectHideFlags: 0 - m_Enabled: 0 + serializedVersion: 1 + m_Enabled: 1 m_TestMode: 0 - m_TestEventUrl: - m_TestConfigUrl: + m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events + m_EventUrl: https://cdp.cloud.unity3d.com/v1/events + m_ConfigUrl: https://config.uca.cloud.unity3d.com m_TestInitMode: 0 CrashReportingSettings: - m_EventUrl: https://perf-events.cloud.unity3d.com/api/events/crashes + m_EventUrl: https://perf-events.cloud.unity3d.com m_Enabled: 0 + m_LogBufferSize: 10 m_CaptureEditorExceptions: 1 UnityPurchasingSettings: m_Enabled: 0 m_TestMode: 0 UnityAnalyticsSettings: m_Enabled: 0 - m_InitializeOnStartup: 1 m_TestMode: 0 - m_TestEventUrl: - m_TestConfigUrl: + m_InitializeOnStartup: 1 UnityAdsSettings: m_Enabled: 0 m_InitializeOnStartup: 1 m_TestMode: 0 - m_EnabledPlatforms: 4294967295 m_IosGameId: m_AndroidGameId: m_GameIds: {} diff --git a/Unity/ProjectSettings/VFXManager.asset b/Unity/ProjectSettings/VFXManager.asset new file mode 100644 index 0000000..6e0eaca --- /dev/null +++ b/Unity/ProjectSettings/VFXManager.asset @@ -0,0 +1,11 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!937362698 &1 +VFXManager: + m_ObjectHideFlags: 0 + m_IndirectShader: {fileID: 0} + m_CopyBufferShader: {fileID: 0} + m_SortShader: {fileID: 0} + m_RenderPipeSettingsPath: + m_FixedTimeStep: 0.016666668 + m_MaxDeltaTime: 0.05 diff --git a/Unity/ProjectSettings/XRSettings.asset b/Unity/ProjectSettings/XRSettings.asset new file mode 100644 index 0000000..482590c --- /dev/null +++ b/Unity/ProjectSettings/XRSettings.asset @@ -0,0 +1,10 @@ +{ + "m_SettingKeys": [ + "VR Device Disabled", + "VR Device User Alert" + ], + "m_SettingValues": [ + "False", + "False" + ] +} \ No newline at end of file diff --git a/Unity/UnityPackageManager/manifest.json b/Unity/UnityPackageManager/manifest.json deleted file mode 100644 index 526aca6..0000000 --- a/Unity/UnityPackageManager/manifest.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "dependencies": { - } -}