diff --git a/.gitignore b/.gitignore index aa955b9..eaec275 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ -# Typical location for CMake build files and Visual Studio 2017 generated directories -/cmake -/NativeScript.dir -/x64 +# Rider IDE +.idea + +# Unity upgrade logs +Unity/Logs \ No newline at end of file diff --git a/README.md b/README.md index 55006c6..8b108f6 100644 --- a/README.md +++ b/README.md @@ -16,21 +16,21 @@ This project aims to give you a viable alternative to C#. Scripting in C++ isn't # Reasons to Prefer C++ Over C# # -## Fast Compile Times +## Fast Device Build Times -C++ [compiles much more quickly](https://github.com/jacksondunstan/cscppcompiletimes) than C#. Incremental builds when just one file changes-- the most common builds-- can be 15x faster than with C#. Faster compilation adds up over time to productivity gains. Quicker iteration times make it easier to stay in the "flow" of programming. +Changing one line of C# code requires you to make a new build of the game. Typical Android build times tend to be at least 10 minutes because IL2CPP has to run and then a huge amount of C++ must be compiled. -## Fast Device Build Times +By using C++, we can compile the game as a C++ plugin in about 1 second, swap the plugin into the APK, and then immediately install and run the game. That's a huge productivity boost! -Changing one line of C# code requires you to make a new build of the game. Typical iOS build times tend to be at least 10 minutes because IL2CPP has to run and then Xcode has to compile a huge amount of C++. +## Fast Compile Times -By using C++, we can compile the game as a C++ plugin in about 1 second, swap the plugin into the Xcode project, and then immediately run the game. That's a huge productivity boost! +C++ [compiles much more quickly](https://github.com/jacksondunstan/cscppcompiletimes) than C#. Incremental builds when just one file changes-- the most common builds-- can be 15x faster than with C#. Faster compilation adds up over time to productivity gains. Quicker iteration times make it easier to stay in the "flow" of programming. ## No Garbage Collector Unity's garbage collector is mandatory and has a lot of problems. It's slow, runs on the main thread, collects all garbage at once, fragments the heap, and never shrinks the heap. So your game will experience "frame hitches" and eventually you'll run out of memory and crash. -A significant amount of effort is required to work around the GC and the resulting code is difficult to maintain and slow. This includes techniques like [object pools](http://jacksondunstan.com/articles/3829), which essentially make memory management manual. You've also got to avoid boxing value types like `int` to to managed types like `object`, not use `foreach` loops in some situations, and various other [gotchas](http://jacksondunstan.com/articles/3850). +A significant amount of effort is required to work around the GC and the resulting code is difficult to maintain and slow. This includes techniques like [object pools](https://jacksondunstan.com/articles/3829), which essentially make memory management manual. You've also got to avoid boxing value types like `int` to to managed types like `object`, not use `foreach` loops in some situations, and various other [gotchas](https://jacksondunstan.com/articles/3850). C++ has no required garbage collector and features optional automatic memory management via "smart pointer" types like [shared_ptr](http://en.cppreference.com/w/cpp/memory/shared_ptr). It offers excellent alternatives to Unity's primitive garbage collector. @@ -38,7 +38,7 @@ While using some .NET APIs will still involve garbage creation, the problem is c ## Total Control -By using C++ directly, you gain complete control over the code the CPU will execute. It's much easier to generate optimal code with a C++ compiler than with a C# compiler, IL2CPP, and finally a C++ compiler. Cut out the middle-man and you can take advantage of compiler intrinsics or assembly to directly write machine code using powerful CPU features like [SIMD](http://jacksondunstan.com/articles/3890) and hardware AES encryption for massive performance gains. +By using C++ directly, you gain complete control over the code the CPU will execute. It's much easier to generate optimal code with a C++ compiler than with a C# compiler, IL2CPP, and finally a C++ compiler. Cut out the middle-man and you can take advantage of compiler intrinsics or assembly to directly write machine code using powerful CPU features like [SIMD](https://jacksondunstan.com/articles/3890) and hardware AES encryption for massive performance gains. ## More Features @@ -54,11 +54,17 @@ C++ is a much larger language than C# and some developers will prefer having mor ## No IL2CPP Surprises -While IL2CPP transforms C# into C++ already, it generates a lot of overhead. There are many [surprises](http://jacksondunstan.com/articles/3916) if you read through the generated C++. For example, there's overhead for any function using a static variable and an extra two pointers are stored at the beginning of every class. The same goes for all sorts of features such as `sizeof()`, mandatory null checks, and so forth. Instead, you could write C++ directly and not need to work around IL2CPP. +While IL2CPP transforms C# into C++ already, it generates a lot of overhead. There are many [surprises](https://jacksondunstan.com/articles/3916) if you read through the generated C++. For example, there's overhead for any function using a static variable and an extra two pointers are stored at the beginning of every class. The same goes for all sorts of features such as `sizeof()`, mandatory null checks, and so forth. Instead, you could write C++ directly and not need to work around IL2CPP. + +## Industry Standard Language + +C++ is the standard language for video games as well as many other fields. By programming in C++ you can more easily transfer your skills and code to and from non-Unity projects. For example, you can avoid lock-in by using the same language (C++) that you'd use in the [Unreal](https://www.unrealengine.com) or [Lumberyard](https://aws.amazon.com/lumberyard/) engines. # UnityNativeScripting Features -* Supports Windows, macOS, iOS, and Android (editor and standalone) +* Code generator exposes any C# API to C++ +* Supports Windows, macOS, Linux, iOS, and Android (editor and standalone) +* Works with Unity 2017.x and 5.x * Plays nice with other C# scripts- no need to use 100% C++ * Object-oriented API just like in C# @@ -68,40 +74,68 @@ While IL2CPP transforms C# into C++ already, it generates a lot of overhead. The Vector3 position(1.0f, 2.0f, 3.0f); transform.SetPosition(position); -* No need to reload the Unity editor when changing C++ +* Hot reloading: change C++ without restarting the game * Handle `MonoBehaviour` messages in C++ > void MyScript::Start() { - Debug::Log(String("MyScript has started")); + String message("MyScript has started"); + Debug::Log(message); } -* Platform-dependent compilation via the [usual flags](https://docs.unity3d.com/Manual/PlatformDependentCompilation.html) (e.g. `#if UNITY_EDITOR`) +* Platform-dependent compilation (e.g. `#if TARGET_OS_ANDROID`) * [CMake](https://cmake.org/) build system sets up any IDE project or command-line build -* Code generator exposes any C# API (Unity, .NET, custom DLLs) with a simple JSON config file and runs from a menu in the Unity editor. It supports a wide range of features: - * Class types - * Struct types - * Enumeration types - * Base classes - * Constructors - * Methods - * Fields - * Properties (getters and setters) - * `MonoBehaviour` classes with "message" functions like `Update` - * `out` and `ref` parameters - * Exceptions - * Overloaded operators - * Arrays (single- and multi-dimensional) - * Delegates - * Events - * Boxing and unboxing (e.g. boxing `int` to `object`, casting `object` to `int`) + +# Code Generator + +The core of this project is a code generator. It generates C# and C++ code called "bindings" that make C# APIs available to C++ game code. It supports a wide range of language features: + +* Types + * `class` + * `struct` + * `enum` + * Arrays (single- and multi-dimensional) + * Delegates (e.g. `Action`) + * `decimal` +* Type Contents + * Constructors + * Methods + * Fields + * Properties (`get` and `set` like `obj.x`) + * Indexers (`get` and `set` like `obj[x]`) + * Events (`add` and `remove` delegates) + * Overloaded operators + * Boxing and unboxing (e.g. casting `int` to `object` and visa versa) +* Function Features + * `out` and `ref` parameters + * Generic types and methods + * Default parameters +* Cross-Language Features + * Exceptions (C# to C++ and C++ to C#) + * Implementing C# interfaces with C++ classes + * Deriving from C# classes with C++ classes + +Note that the code generator does not yet support: + +* `Array`, `string`, and `object` methods (e.g. `GetHashCode`) +* Non-null string default parameters and null non-string default parameters +* Implicit `params` parameter (a.k.a. "var args") passing +* C# pointers +* Nested types +* Down-casting + +To configure the code generator, open `Unity/Assets/NativeScriptTypes.json` and notice the existing examples. Add on to this file to expose more C# APIs from Unity, .NET, or custom DLLs to your C++ code. + +To run the code generator, choose `NativeScript > Generate Bindings` from the Unity editor. # Performance Almost all projects will see a net performance win by reducing garbage collection, eliminating IL2CPP overhead, and access to compiler intrinsics and assembly. Calls from C++ into C# incur only a minor performance penalty. In the rare case that almost all of your code is calls to .NET APIs then you may experience a net performance loss. -[Testing and benchmarks article](http://jacksondunstan.com/articles/3952) +[Testing and benchmarks article](https://jacksondunstan.com/articles/3952) + +[Optimizations article](https://jacksondunstan.com/articles/4311) # Project Structure @@ -127,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` 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 @@ -159,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`. @@ -183,33 +216,17 @@ With C++, the workflow looks like this: 6. The build scripts or IDE project files are now generated in your build directory 7. Build as appropriate for your generator. For example, execute `make` if you chose `Unix Makefiles` as your generator. -# The Code Generator - -To run the code generator, choose `NativeScript > Generate Bindings` from the Unity editor. - -To configure the code generator, open `NativeScriptTypes.json` and notice the existing examples. Add on to this file to expose more C# APIs from Unity, .NET, or custom DLLs to your C++ code. - -Note that the code generator does not support (yet): - -* `MonoBehaviour` contents (e.g. fields) except for "message" functions -* `Array` methods (e.g. `IndexOf`) -* `string` methods (e.g. `Substring`) -* Default parameters -* Interfaces -* `decimal` -* C# pointers - # Updating To A New Version To update to a new version of this project, overwrite your Unity project's `Assets/NativeScript` directory with this project's `Unity/Assets/NativeScript` directory and re-run the code generator. # Reference -[Articles](http://jacksondunstan.com/articles/3938) by the author describing the development of this project. +[Articles](https://jacksondunstan.com/articles/3938) by the author describing the development of this project. # Author -[Jackson Dunstan](http://jacksondunstan.com) +[Jackson Dunstan](https://jacksondunstan.com) # Contributing diff --git a/Unity/Assets/CppSource.meta b/Unity/Assets/CppSource.meta new file mode 100644 index 0000000..a8346ff --- /dev/null +++ b/Unity/Assets/CppSource.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ec1b3d1da421646d781f3ccc6960a558 +folderAsset: yes +timeCreated: 1525538114 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/CppSource/CMakeLists.txt b/Unity/Assets/CppSource/CMakeLists.txt similarity index 68% rename from Unity/CppSource/CMakeLists.txt rename to Unity/Assets/CppSource/CMakeLists.txt index 73a28d6..2baa025 100644 --- a/Unity/CppSource/CMakeLists.txt +++ b/Unity/Assets/CppSource/CMakeLists.txt @@ -3,29 +3,29 @@ project(NativeScript CXX) # Set platform-dependent compilation defines matching C# if (EDITOR) - add_definitions(-DUNITY_EDITOR) + add_definitions(-DTARGET_OS_EDITOR) if (WIN32) - add_definitions(-DUNITY_EDITOR_WIN) + add_definitions(-DTARGET_OS_EDITOR_WIN) elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - add_definitions(-DUNITY_EDITOR_OSX) + add_definitions(-DTARGET_OS_EDITOR_OSX) elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux") - add_definitions(-DUNITY_EDITOR_LINUX) + add_definitions(-DTARGET_OS_EDITOR_LINUX) endif() else() - add_definitions(-DUNITY_STANDALONE) + add_definitions(-DTARGET_OS_STANDALONE) if (WIN32) - add_definitions(-DUNITY_STANDALONE_WIN) + add_definitions(-DTARGET_OS_WIN) elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - add_definitions(-DUNITY_STANDALONE_OSX) + add_definitions(-DTARGET_OS_OSX) elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux") - add_definitions(-DUNITY_STANDALONE_LINUX) + add_definitions(-DTARGET_OS_LINUX) endif() endif() if (IOS) - add_definitions(-DUNITY_IOS) + add_definitions(-DTARGET_OS_IPHONE) endif() if (ANDROID_NDK) - add_definitions(-DUNITY_ANDROID) + add_definitions(-DTARGET_OS_ANDROID) endif() # Use NDK on Android @@ -36,22 +36,22 @@ endif() # Set output path if (ANDROID_NDK) - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/../Assets/Plugins/Android) - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/../Assets/Plugins/Android) - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/../Assets/Plugins/Android) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/../Plugins/Android) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/../Plugins/Android) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/../Plugins/Android) elseif (IOS) - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/../Assets/Plugins/iOS) - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/../Assets/Plugins/iOS) - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/../Assets/Plugins/iOS) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/../Plugins/.iOS) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/../Plugins/.iOS) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/../Plugins/.iOS) elseif (WIN32 OR (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") OR (${CMAKE_SYSTEM_NAME} MATCHES "Linux")) if (EDITOR) - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/../Assets/Plugins/Editor) - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/../Assets/Plugins/Editor) - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/../Assets/Plugins/Editor) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/../Plugins/Editor) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/../Plugins/Editor) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/../Plugins/Editor) else() - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/../Assets/Plugins) - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/../Assets/Plugins) - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/../Assets/Plugins) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/../Plugins) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/../Plugins) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/../Plugins) endif() endif() @@ -75,6 +75,13 @@ set( # Build a library. If on an Apple platform, build it in a bundle. add_library(${PROJECT_NAME} MODULE ${SOURCES}) set_target_properties(${PROJECT_NAME} PROPERTIES BUNDLE TRUE) +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/CMakeLists.txt.meta b/Unity/Assets/CppSource/CMakeLists.txt.meta new file mode 100644 index 0000000..3ecd08d --- /dev/null +++ b/Unity/Assets/CppSource/CMakeLists.txt.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: ff824f6dad1204438ac5993f133fa551 +timeCreated: 1525538114 +licenseType: Free +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/CppSource/Game.meta b/Unity/Assets/CppSource/Game.meta new file mode 100644 index 0000000..7121431 --- /dev/null +++ b/Unity/Assets/CppSource/Game.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 5097e8d235bbf426abeae3e4fc76859f +folderAsset: yes +timeCreated: 1525538114 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/CppSource/Game/Game.cpp b/Unity/Assets/CppSource/Game/Game.cpp new file mode 100644 index 0000000..a8baeff --- /dev/null +++ b/Unity/Assets/CppSource/Game/Game.cpp @@ -0,0 +1,85 @@ +/// +/// Game-specific code for the native plugin +/// +/// +/// Jackson Dunstan, 2017, http://JacksonDunstan.com +/// +/// +/// MIT +/// + +#include "Bindings.h" +#include "Game.h" + +using namespace System; +using namespace UnityEngine; + +namespace +{ + struct GameState + { + float BallDir; + }; + + GameState* gameState; +} + +namespace MyGame +{ + void BallScript::Update() + { + Transform transform = GetTransform(); + Vector3 pos = transform.GetPosition(); + const float speed = 1.2f; + const float min = -1.5f; + const float max = 1.5f; + float distance = Time::GetDeltaTime() * speed * gameState->BallDir; + Vector3 offset(distance, 0, 0); + Vector3 newPos = pos + offset; + if (newPos.x > max) + { + gameState->BallDir *= -1.0f; + newPos.x = max - (newPos.x - max); + if (newPos.x < min) + { + newPos.x = min; + } + } + else if (newPos.x < min) + { + gameState->BallDir *= -1.0f; + newPos.x = min + (min - newPos.x); + if (newPos.x > max) + { + newPos.x = max; + } + } + transform.SetPosition(newPos); + } +} + +// Called when the plugin is initialized +// This is mostly full of test code. Feel free to remove it all. +void PluginMain( + void* memory, + int32_t memorySize, + bool isFirstBoot) +{ + gameState = (GameState*)memory; + if (isFirstBoot) + { + String message("Game booted up"); + Debug::Log(message); + + // The ball initially goes right + gameState->BallDir = 1.0f; + + // Create the ball game object out of a sphere primitive + GameObject go = GameObject::CreatePrimitive(PrimitiveType::Sphere); + String name("GameObject with a BallScript"); + go.SetName(name); + + // Attach the ball script to make it bounce back and forth + go.AddComponent(); + } +} diff --git a/Unity/Assets/CppSource/Game/Game.cpp.meta b/Unity/Assets/CppSource/Game/Game.cpp.meta new file mode 100644 index 0000000..6bcf89c --- /dev/null +++ b/Unity/Assets/CppSource/Game/Game.cpp.meta @@ -0,0 +1,26 @@ +fileFormatVersion: 2 +guid: cd5ee8d1b4f5748ed98f1f7cd17c386d +timeCreated: 1525538114 +licenseType: Free +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/CppSource/Game/Game.h b/Unity/Assets/CppSource/Game/Game.h new file mode 100644 index 0000000..79d31ad --- /dev/null +++ b/Unity/Assets/CppSource/Game/Game.h @@ -0,0 +1,23 @@ +/// +/// Declaration of the game types the bindings layer needs to know about +/// +/// +/// Jackson Dunstan, 2018, http://JacksonDunstan.com +/// +/// +/// MIT +/// + +#pragma once + +#include "Bindings.h" + +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/Game/Game.h.meta b/Unity/Assets/CppSource/Game/Game.h.meta new file mode 100644 index 0000000..c81ed01 --- /dev/null +++ b/Unity/Assets/CppSource/Game/Game.h.meta @@ -0,0 +1,26 @@ +fileFormatVersion: 2 +guid: 568849c22711c4c4aaaf09df05a1d812 +timeCreated: 1525538114 +licenseType: Free +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/CppSource/NativeScript.meta b/Unity/Assets/CppSource/NativeScript.meta new file mode 100644 index 0000000..a82c5d8 --- /dev/null +++ b/Unity/Assets/CppSource/NativeScript.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: c48669dd52f8e49b890586dd9a417de5 +folderAsset: yes +timeCreated: 1525538114 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/CppSource/NativeScript/Bindings.cpp b/Unity/Assets/CppSource/NativeScript/Bindings.cpp new file mode 100644 index 0000000..8cb2e2e --- /dev/null +++ b/Unity/Assets/CppSource/NativeScript/Bindings.cpp @@ -0,0 +1,6349 @@ +/// +/// Internals of the bindings between native and .NET code. +/// Game code shouldn't go here. +/// +/// +/// Jackson Dunstan, 2017, http://JacksonDunstan.com +/// +/// +/// MIT +/// + +// Game type definitions +#include "Game.h" + +// Type definitions +#include "Bindings.h" + +// For assert() +#include + +// For memset(), etc. +#include + +// Macro to put before functions that need to be exposed to C# +#ifdef _WIN32 + #define DLLEXPORT extern "C" __declspec(dllexport) +#else + #define DLLEXPORT extern "C" +#endif + +//////////////////////////////////////////////////////////////// +// C# functions for C++ to call +//////////////////////////////////////////////////////////////// + +namespace Plugin +{ + 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 FUNCTION POINTERS*/ + 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); + 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); + int8_t (*UnboxSByte)(int32_t valHandle); + int32_t (*BoxByte)(uint8_t val); + uint8_t (*UnboxByte)(int32_t valHandle); + int32_t (*BoxInt16)(int16_t val); + int16_t (*UnboxInt16)(int32_t valHandle); + int32_t (*BoxUInt16)(uint16_t val); + uint16_t (*UnboxUInt16)(int32_t valHandle); + int32_t (*BoxInt32)(int32_t val); + int32_t (*UnboxInt32)(int32_t valHandle); + int32_t (*BoxUInt32)(uint32_t val); + uint32_t (*UnboxUInt32)(int32_t valHandle); + int32_t (*BoxInt64)(int64_t val); + int64_t (*UnboxInt64)(int32_t valHandle); + int32_t (*BoxUInt64)(uint64_t val); + uint64_t (*UnboxUInt64)(int32_t valHandle); + int32_t (*BoxChar)(uint16_t val); + int16_t (*UnboxChar)(int32_t valHandle); + int32_t (*BoxSingle)(float val); + float (*UnboxSingle)(int32_t valHandle); + int32_t (*BoxDouble)(double val); + double (*UnboxDouble)(int32_t valHandle); + /*END FUNCTION POINTERS*/ +} + +//////////////////////////////////////////////////////////////// +// Global variables +//////////////////////////////////////////////////////////////// + +namespace Plugin +{ + System::String NullString(nullptr); +} + +//////////////////////////////////////////////////////////////// +// Plugin Types +//////////////////////////////////////////////////////////////// + +namespace Plugin +{ + ManagedType::ManagedType() + : Handle(0) + { + } + + ManagedType::ManagedType(decltype(nullptr)) + : Handle(0) + { + } + + ManagedType::ManagedType(Plugin::InternalUse iu, int32_t handle) + : Handle(handle) + { + } +} + +//////////////////////////////////////////////////////////////// +// C# Primitive Types +//////////////////////////////////////////////////////////////// + +namespace System +{ + Boolean::Boolean() + : Value(0) + { + } + + Boolean::Boolean(bool value) + : Value((int32_t)value) + { + } + + Boolean::Boolean(int32_t value) + : Value(value) + { + } + + Boolean::Boolean(uint32_t value) + : Value(value) + { + } + + Boolean::operator bool() const + { + return (bool)Value; + } + + Boolean::operator int32_t() const + { + return Value; + } + + Boolean::operator uint32_t() const + { + return Value; + } + + Boolean::operator Object() const + { + return Object(Plugin::InternalUse::Only, Plugin::BoxBoolean(Value)); + } + + Boolean::operator ValueType() const + { + return ValueType(Plugin::InternalUse::Only, Plugin::BoxBoolean(Value)); + } + + Boolean::operator IComparable() const + { + return IComparable(Plugin::InternalUse::Only, Plugin::BoxBoolean(Value)); + } + + Boolean::operator IFormattable() const + { + return IFormattable(Plugin::InternalUse::Only, Plugin::BoxBoolean(Value)); + } + + Boolean::operator IConvertible() const + { + return IConvertible(Plugin::InternalUse::Only, Plugin::BoxBoolean(Value)); + } + + Boolean::operator IComparable_1() const + { + return IComparable_1(Plugin::InternalUse::Only, Plugin::BoxBoolean(Value)); + } + + Boolean::operator IEquatable_1() const + { + return IEquatable_1(Plugin::InternalUse::Only, Plugin::BoxBoolean(Value)); + } + + Char::Char() + : Value(0) + { + } + + Char::Char(char value) + : Value(value) + { + } + + Char::Char(int16_t value) + : Value(value) + { + } + + Char::operator int16_t() const + { + return Value; + } + + Char::operator Object() const + { + return Object(Plugin::InternalUse::Only, Plugin::BoxChar(Value)); + } + + Char::operator ValueType() const + { + return ValueType(Plugin::InternalUse::Only, Plugin::BoxChar(Value)); + } + + Char::operator IComparable() const + { + return IComparable(Plugin::InternalUse::Only, Plugin::BoxChar(Value)); + } + + Char::operator IFormattable() const + { + return IFormattable(Plugin::InternalUse::Only, Plugin::BoxChar(Value)); + } + + Char::operator IConvertible() const + { + return IConvertible(Plugin::InternalUse::Only, Plugin::BoxChar(Value)); + } + + Char::operator IComparable_1() const + { + return IComparable_1(Plugin::InternalUse::Only, Plugin::BoxChar(Value)); + } + + Char::operator IEquatable_1() const + { + return IEquatable_1(Plugin::InternalUse::Only, Plugin::BoxChar(Value)); + } + + SByte::SByte() + : Value(0) + { + } + + SByte::SByte(int8_t val) + : Value(val) + { + } + + SByte::operator int8_t() const + { + return Value; + } + + SByte::operator Object() const + { + return Object(Plugin::InternalUse::Only, Plugin::BoxSByte(Value)); + } + + SByte::operator ValueType() const + { + return ValueType(Plugin::InternalUse::Only, Plugin::BoxSByte(Value)); + } + + SByte::operator IComparable() const + { + return IComparable(Plugin::InternalUse::Only, Plugin::BoxSByte(Value)); + } + + SByte::operator IFormattable() const + { + return IFormattable(Plugin::InternalUse::Only, Plugin::BoxSByte(Value)); + } + + SByte::operator IConvertible() const + { + return IConvertible(Plugin::InternalUse::Only, Plugin::BoxSByte(Value)); + } + + SByte::operator IComparable_1() const + { + return IComparable_1(Plugin::InternalUse::Only, Plugin::BoxSByte(Value)); + } + + SByte::operator IEquatable_1() const + { + return IEquatable_1(Plugin::InternalUse::Only, Plugin::BoxSByte(Value)); + } + + Byte::Byte() + : Value(0) + { + } + + Byte::Byte(uint8_t value) + : Value(value) + { + } + + Byte::operator uint8_t() const + { + return Value; + } + + Byte::operator Object() const + { + return Object(Plugin::InternalUse::Only, Plugin::BoxByte(Value)); + } + + Byte::operator ValueType() const + { + return ValueType(Plugin::InternalUse::Only, Plugin::BoxByte(Value)); + } + + Byte::operator IComparable() const + { + return IComparable(Plugin::InternalUse::Only, Plugin::BoxByte(Value)); + } + + Byte::operator IFormattable() const + { + return IFormattable(Plugin::InternalUse::Only, Plugin::BoxByte(Value)); + } + + Byte::operator IConvertible() const + { + return IConvertible(Plugin::InternalUse::Only, Plugin::BoxByte(Value)); + } + + Byte::operator IComparable_1() const + { + return IComparable_1(Plugin::InternalUse::Only, Plugin::BoxByte(Value)); + } + + Byte::operator IEquatable_1() const + { + return IEquatable_1(Plugin::InternalUse::Only, Plugin::BoxByte(Value)); + } + + Int16::Int16() + : Value(0) + { + } + + Int16::Int16(int16_t value) + : Value(value) + { + } + + Int16::operator int16_t() const + { + return Value; + } + + Int16::operator Object() const + { + return Object(Plugin::InternalUse::Only, Plugin::BoxInt16(Value)); + } + + Int16::operator ValueType() const + { + return ValueType(Plugin::InternalUse::Only, Plugin::BoxInt16(Value)); + } + + Int16::operator IComparable() const + { + return IComparable(Plugin::InternalUse::Only, Plugin::BoxInt16(Value)); + } + + Int16::operator IFormattable() const + { + return IFormattable(Plugin::InternalUse::Only, Plugin::BoxInt16(Value)); + } + + Int16::operator IConvertible() const + { + return IConvertible(Plugin::InternalUse::Only, Plugin::BoxInt16(Value)); + } + + Int16::operator IComparable_1() const + { + return IComparable_1(Plugin::InternalUse::Only, Plugin::BoxInt16(Value)); + } + + Int16::operator IEquatable_1() const + { + return IEquatable_1(Plugin::InternalUse::Only, Plugin::BoxInt16(Value)); + } + + UInt16::UInt16() + : Value(0) + { + } + + UInt16::UInt16(uint16_t value) + : Value(value) + { + } + + UInt16::operator uint16_t() const + { + return Value; + } + + UInt16::operator Object() const + { + return Object(Plugin::InternalUse::Only, Plugin::BoxUInt16(Value)); + } + + UInt16::operator ValueType() const + { + return ValueType(Plugin::InternalUse::Only, Plugin::BoxUInt16(Value)); + } + + UInt16::operator IComparable() const + { + return IComparable(Plugin::InternalUse::Only, Plugin::BoxUInt16(Value)); + } + + UInt16::operator IFormattable() const + { + return IFormattable(Plugin::InternalUse::Only, Plugin::BoxUInt16(Value)); + } + + UInt16::operator IConvertible() const + { + return IConvertible(Plugin::InternalUse::Only, Plugin::BoxUInt16(Value)); + } + + UInt16::operator IComparable_1() const + { + return IComparable_1(Plugin::InternalUse::Only, Plugin::BoxUInt16(Value)); + } + + UInt16::operator IEquatable_1() const + { + return IEquatable_1(Plugin::InternalUse::Only, Plugin::BoxUInt16(Value)); + } + + Int32::Int32() + : Value(0) + { + } + + Int32::Int32(int32_t value) + : Value(value) + { + } + + Int32::operator int32_t() const + { + return Value; + } + + Int32::operator Object() const + { + return Object(Plugin::InternalUse::Only, Plugin::BoxInt32(Value)); + } + + Int32::operator ValueType() const + { + return ValueType(Plugin::InternalUse::Only, Plugin::BoxInt32(Value)); + } + + Int32::operator IComparable() const + { + return IComparable(Plugin::InternalUse::Only, Plugin::BoxInt32(Value)); + } + + Int32::operator IFormattable() const + { + return IFormattable(Plugin::InternalUse::Only, Plugin::BoxInt32(Value)); + } + + Int32::operator IConvertible() const + { + return IConvertible(Plugin::InternalUse::Only, Plugin::BoxInt32(Value)); + } + + Int32::operator IComparable_1() const + { + return IComparable_1(Plugin::InternalUse::Only, Plugin::BoxInt32(Value)); + } + + Int32::operator IEquatable_1() const + { + return IEquatable_1(Plugin::InternalUse::Only, Plugin::BoxInt32(Value)); + } + + UInt32::UInt32() + : Value(0) + { + } + + UInt32::UInt32(uint32_t value) + : Value(value) + { + } + + UInt32::operator uint32_t() const + { + return Value; + } + + UInt32::operator Object() const + { + return Object(Plugin::InternalUse::Only, Plugin::BoxUInt32(Value)); + } + + UInt32::operator ValueType() const + { + return ValueType(Plugin::InternalUse::Only, Plugin::BoxUInt32(Value)); + } + + UInt32::operator IComparable() const + { + return IComparable(Plugin::InternalUse::Only, Plugin::BoxUInt32(Value)); + } + + UInt32::operator IFormattable() const + { + return IFormattable(Plugin::InternalUse::Only, Plugin::BoxUInt32(Value)); + } + + UInt32::operator IConvertible() const + { + return IConvertible(Plugin::InternalUse::Only, Plugin::BoxUInt32(Value)); + } + + UInt32::operator IComparable_1() const + { + return IComparable_1(Plugin::InternalUse::Only, Plugin::BoxUInt32(Value)); + } + + UInt32::operator IEquatable_1() const + { + return IEquatable_1(Plugin::InternalUse::Only, Plugin::BoxUInt32(Value)); + } + + Int64::Int64() + : Value(0) + { + } + + Int64::Int64(int64_t value) + : Value(value) + { + } + + Int64::operator int64_t() const + { + return Value; + } + + Int64::operator Object() const + { + return Object(Plugin::InternalUse::Only, Plugin::BoxInt64(Value)); + } + + Int64::operator ValueType() const + { + return ValueType(Plugin::InternalUse::Only, Plugin::BoxInt64(Value)); + } + + Int64::operator IComparable() const + { + return IComparable(Plugin::InternalUse::Only, Plugin::BoxInt64(Value)); + } + + Int64::operator IFormattable() const + { + return IFormattable(Plugin::InternalUse::Only, Plugin::BoxInt64(Value)); + } + + Int64::operator IConvertible() const + { + return IConvertible(Plugin::InternalUse::Only, Plugin::BoxInt64(Value)); + } + + Int64::operator IComparable_1() const + { + return IComparable_1(Plugin::InternalUse::Only, Plugin::BoxInt64(Value)); + } + + Int64::operator IEquatable_1() const + { + return IEquatable_1(Plugin::InternalUse::Only, Plugin::BoxInt64(Value)); + } + + UInt64::UInt64() + : Value(0) + { + } + + UInt64::UInt64(uint64_t value) + : Value(value) + { + } + + UInt64::operator uint64_t() const + { + return Value; + } + + UInt64::operator Object() const + { + return Object(Plugin::InternalUse::Only, Plugin::BoxUInt64(Value)); + } + + UInt64::operator ValueType() const + { + return ValueType(Plugin::InternalUse::Only, Plugin::BoxUInt64(Value)); + } + + UInt64::operator IComparable() const + { + return IComparable(Plugin::InternalUse::Only, Plugin::BoxUInt64(Value)); + } + + UInt64::operator IFormattable() const + { + return IFormattable(Plugin::InternalUse::Only, Plugin::BoxUInt64(Value)); + } + + UInt64::operator IConvertible() const + { + return IConvertible(Plugin::InternalUse::Only, Plugin::BoxUInt64(Value)); + } + + UInt64::operator IComparable_1() const + { + return IComparable_1(Plugin::InternalUse::Only, Plugin::BoxUInt64(Value)); + } + + UInt64::operator IEquatable_1() const + { + return IEquatable_1(Plugin::InternalUse::Only, Plugin::BoxUInt64(Value)); + } + + Single::Single() + : Value(0.0f) + { + } + + Single::Single(float value) + : Value(value) + { + } + + Single::operator float() const + { + return Value; + } + + Single::operator Object() const + { + return Object(Plugin::InternalUse::Only, Plugin::BoxSingle(Value)); + } + + Single::operator ValueType() const + { + return ValueType(Plugin::InternalUse::Only, Plugin::BoxSingle(Value)); + } + + Single::operator IComparable() const + { + return IComparable(Plugin::InternalUse::Only, Plugin::BoxSingle(Value)); + } + + Single::operator IFormattable() const + { + return IFormattable(Plugin::InternalUse::Only, Plugin::BoxSingle(Value)); + } + + Single::operator IConvertible() const + { + return IConvertible(Plugin::InternalUse::Only, Plugin::BoxSingle(Value)); + } + + Single::operator IComparable_1() const + { + return IComparable_1(Plugin::InternalUse::Only, Plugin::BoxSingle(Value)); + } + + Single::operator IEquatable_1() const + { + return IEquatable_1(Plugin::InternalUse::Only, Plugin::BoxSingle(Value)); + } + + Double::Double() + : Value(0.0) + { + } + + Double::Double(double value) + : Value(value) + { + } + + Double::operator double() const + { + return Value; + } + + Double::operator Object() const + { + return Object(Plugin::InternalUse::Only, Plugin::BoxDouble(Value)); + } + + Double::operator ValueType() const + { + return ValueType(Plugin::InternalUse::Only, Plugin::BoxDouble(Value)); + } + + Double::operator IComparable() const + { + return IComparable(Plugin::InternalUse::Only, Plugin::BoxDouble(Value)); + } + + Double::operator IFormattable() const + { + return IFormattable(Plugin::InternalUse::Only, Plugin::BoxDouble(Value)); + } + + Double::operator IConvertible() const + { + return IConvertible(Plugin::InternalUse::Only, Plugin::BoxDouble(Value)); + } + + Double::operator IComparable_1() const + { + return IComparable_1(Plugin::InternalUse::Only, Plugin::BoxDouble(Value)); + } + + Double::operator IEquatable_1() const + { + return IEquatable_1(Plugin::InternalUse::Only, Plugin::BoxDouble(Value)); + } +} + +//////////////////////////////////////////////////////////////// +// Support for using IEnumerable with range for loops +//////////////////////////////////////////////////////////////// + +namespace Plugin +{ + // End iterators are dummies full of null + EnumerableIterator::EnumerableIterator(decltype(nullptr)) + : enumerator(nullptr) + , hasMore(false) + { + } + + // Begin iterators keep track of an IEnumerator + EnumerableIterator::EnumerableIterator( + System::Collections::IEnumerable& enumerable) + : enumerator(enumerable.GetEnumerator()) + { + hasMore = enumerator.MoveNext(); + } + + EnumerableIterator& EnumerableIterator::operator++() + { + hasMore = enumerator.MoveNext(); + return *this; + } + + bool EnumerableIterator::operator!=(const EnumerableIterator& other) + { + return hasMore; + } + + System::Object EnumerableIterator::operator*() + { + return enumerator.GetCurrent(); + } +} + +//////////////////////////////////////////////////////////////// +// User-defined literals for creating decimals (System.Decimal) +//////////////////////////////////////////////////////////////// + +System::Decimal operator"" _m(long double x) +{ + return System::Decimal((System::Double)x); +} + +System::Decimal operator"" _m(unsigned long long x) +{ + return System::Decimal((System::UInt64)x); +} + +//////////////////////////////////////////////////////////////// +// Reference counting of managed objects +//////////////////////////////////////////////////////////////// + +namespace Plugin +{ + int32_t RefCountsLenClass; + int32_t* RefCountsClass; + + void ReferenceManagedClass(int32_t handle) + { + assert(handle >= 0 && handle < RefCountsLenClass); + if (handle != 0) + { + RefCountsClass[handle]++; + } + } + + void DereferenceManagedClass(int32_t handle) + { + assert(handle >= 0 && handle < RefCountsLenClass); + if (handle != 0) + { + int32_t numRemain = --RefCountsClass[handle]; + if (numRemain == 0) + { + ReleaseObject(handle); + } + } + } + + bool DereferenceManagedClassNoRelease(int32_t handle) + { + assert(handle >= 0 && handle < RefCountsLenClass); + if (handle != 0) + { + int32_t numRemain = --RefCountsClass[handle]; + if (numRemain == 0) + { + return true; + } + } + return false; + } + + /*BEGIN GLOBAL STATE AND FUNCTIONS*/ + int32_t RefCountsLenSystemDecimal; + int32_t* RefCountsSystemDecimal; + + void ReferenceManagedSystemDecimal(int32_t handle) + { + assert(handle >= 0 && handle < RefCountsLenSystemDecimal); + if (handle != 0) + { + RefCountsSystemDecimal[handle]++; + } + } + + void DereferenceManagedSystemDecimal(int32_t handle) + { + assert(handle >= 0 && handle < RefCountsLenSystemDecimal); + if (handle != 0) + { + int32_t numRemain = --RefCountsSystemDecimal[handle]; + if (numRemain == 0) + { + ReleaseSystemDecimal(handle); + } + } + } + + // Free list for MyGame::BaseBallScript pointers + + int32_t BaseBallScriptFreeListSize; + MyGame::BaseBallScript** BaseBallScriptFreeList; + MyGame::BaseBallScript** NextFreeBaseBallScript; + + int32_t StoreBaseBallScript(MyGame::BaseBallScript* del) + { + assert(NextFreeBaseBallScript != nullptr); + MyGame::BaseBallScript** pNext = NextFreeBaseBallScript; + NextFreeBaseBallScript = (MyGame::BaseBallScript**)*pNext; + *pNext = del; + return (int32_t)(pNext - BaseBallScriptFreeList); + } + + MyGame::BaseBallScript* GetBaseBallScript(int32_t handle) + { + assert(handle >= 0 && handle < BaseBallScriptFreeListSize); + return BaseBallScriptFreeList[handle]; + } + + void RemoveBaseBallScript(int32_t handle) + { + MyGame::BaseBallScript** pRelease = BaseBallScriptFreeList + handle; + *pRelease = (MyGame::BaseBallScript*)NextFreeBaseBallScript; + NextFreeBaseBallScript = pRelease; + } + + // Free list for whole MyGame::BaseBallScript objects + + union BaseBallScriptFreeWholeListEntry + { + BaseBallScriptFreeWholeListEntry* Next; + MyGame::BaseBallScript Value; + }; + int32_t BaseBallScriptFreeWholeListSize; + BaseBallScriptFreeWholeListEntry* BaseBallScriptFreeWholeList; + BaseBallScriptFreeWholeListEntry* NextFreeWholeBaseBallScript; + + MyGame::BaseBallScript* StoreWholeBaseBallScript() + { + assert(NextFreeWholeBaseBallScript != nullptr); + BaseBallScriptFreeWholeListEntry* pNext = NextFreeWholeBaseBallScript; + NextFreeWholeBaseBallScript = pNext->Next; + return &pNext->Value; + } + + void RemoveWholeBaseBallScript(MyGame::BaseBallScript* instance) + { + BaseBallScriptFreeWholeListEntry* pRelease = (BaseBallScriptFreeWholeListEntry*)instance; + if (pRelease >= BaseBallScriptFreeWholeList && pRelease < BaseBallScriptFreeWholeList + (BaseBallScriptFreeWholeListSize - 1)) + { + pRelease->Next = NextFreeWholeBaseBallScript; + NextFreeWholeBaseBallScript = pRelease->Next; + } + } + /*END GLOBAL STATE AND FUNCTIONS*/ +} + +namespace Plugin +{ + // An unhandled exception caused by C++ calling into C# + System::Exception* unhandledCsharpException = nullptr; +} + +//////////////////////////////////////////////////////////////// +// Mirrors of C# types. These wrap the C# functions to present +// a similiar API as in C#. +//////////////////////////////////////////////////////////////// + +namespace System +{ + Object::Object() + : Plugin::ManagedType(nullptr) + { + } + + Object::Object(Plugin::InternalUse iu, int32_t handle) + : ManagedType(Plugin::InternalUse::Only, handle) + { + } + + Object::Object(decltype(nullptr)) + : ManagedType(nullptr) + { + } + + Object::~Object() + { + } + + bool Object::operator==(decltype(nullptr)) const + { + return Handle == 0; + } + + bool Object::operator!=(decltype(nullptr)) const + { + return Handle != 0; + } + + void Object::ThrowReferenceToThis() + { + throw *this; + } + + ValueType::ValueType(Plugin::InternalUse iu, int32_t handle) + : Object(iu, handle) + { + } + + ValueType::ValueType(decltype(nullptr)) + : Object(nullptr) + { + } + + Enum::Enum(Plugin::InternalUse iu, int32_t handle) + : ValueType(iu, handle) + { + } + + Enum::Enum(decltype(nullptr)) + : ValueType(nullptr) + { + } + + String::String(decltype(nullptr)) + : Object(Plugin::InternalUse::Only, 0) + { + } + + String::String(Plugin::InternalUse iu, int32_t handle) + : Object(iu, handle) + { + if (handle) + { + Plugin::ReferenceManagedClass(handle); + } + } + + String::String(const String& other) + : Object(Plugin::InternalUse::Only, other.Handle) + { + if (Handle) + { + Plugin::ReferenceManagedClass(Handle); + } + } + + String::String(String&& other) + : Object(Plugin::InternalUse::Only, other.Handle) + { + other.Handle = 0; + } + + String::~String() + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + } + + String& String::operator=(const String& other) + { + if (Handle != other.Handle) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + } + Handle = other.Handle; + if (Handle) + { + Plugin::ReferenceManagedClass(Handle); + } + } + return *this; + } + + String& String::operator=(decltype(nullptr)) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + return *this; + } + + String& String::operator=(String&& other) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + } + Handle = other.Handle; + other.Handle = 0; + return *this; + } + + String::String(const char* chars) + : Object(Plugin::InternalUse::Only, Plugin::StringNew(chars)) + { + Plugin::ReferenceManagedClass(Handle); + } + + ICloneable::ICloneable(Plugin::InternalUse iu, int32_t handle) + : Object(iu, handle) + { + } + + ICloneable::ICloneable(decltype(nullptr)) + : Object(nullptr) + { + } + + namespace Collections + { + IEnumerable::IEnumerable(Plugin::InternalUse iu, int32_t handle) + : Object(iu, handle) + { + } + + IEnumerable::IEnumerable(decltype(nullptr)) + : Object(nullptr) + { + } + + IEnumerator IEnumerable::GetEnumerator() + { + return IEnumerator( + Plugin::InternalUse::Only, + Plugin::EnumerableGetEnumerator(Handle)); + } + + Plugin::EnumerableIterator begin( + System::Collections::IEnumerable& enumerable) + { + return Plugin::EnumerableIterator(enumerable); + } + + Plugin::EnumerableIterator end( + System::Collections::IEnumerable& enumerable) + { + return Plugin::EnumerableIterator(nullptr); + } + + ICollection::ICollection(Plugin::InternalUse iu, int32_t handle) + : Object(iu, handle) + , IEnumerable(nullptr) + { + } + + ICollection::ICollection(decltype(nullptr)) + : Object(nullptr) + , IEnumerable(nullptr) + { + } + + IList::IList(Plugin::InternalUse iu, int32_t handle) + : Object(iu, handle) + , IEnumerable(nullptr) + , ICollection(nullptr) + { + } + + IList::IList(decltype(nullptr)) + : Object(nullptr) + , IEnumerable(nullptr) + , ICollection(nullptr) + { + } + } + + Array::Array(Plugin::InternalUse iu, int32_t handle) + : Object(iu, handle) + , ICloneable(nullptr) + , Collections::IEnumerable(nullptr) + , Collections::ICollection(nullptr) + , Collections::IList(nullptr) + { + } + + Array::Array(decltype(nullptr)) + : Object(nullptr) + , ICloneable(nullptr) + , Collections::IEnumerable(nullptr) + , Collections::ICollection(nullptr) + , Collections::IList(nullptr) + { + } + + int32_t Array::GetLength() + { + return Plugin::ArrayGetLength(Handle); + } + + int32_t Array::GetRank() + { + return 0; + } +} + +/*BEGIN METHOD DEFINITIONS*/ +namespace System +{ + IFormattable::IFormattable(decltype(nullptr)) + { + } + + IFormattable::IFormattable(Plugin::InternalUse, int32_t handle) + { + Handle = handle; + if (handle) + { + Plugin::ReferenceManagedClass(handle); + } + } + + IFormattable::IFormattable(const IFormattable& other) + : IFormattable(Plugin::InternalUse::Only, other.Handle) + { + } + + IFormattable::IFormattable(IFormattable&& other) + : IFormattable(Plugin::InternalUse::Only, other.Handle) + { + other.Handle = 0; + } + + IFormattable::~IFormattable() + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + } + + IFormattable& IFormattable::operator=(const IFormattable& other) + { + if (this->Handle) + { + Plugin::DereferenceManagedClass(this->Handle); + } + this->Handle = other.Handle; + if (this->Handle) + { + Plugin::ReferenceManagedClass(this->Handle); + } + return *this; + } + + IFormattable& IFormattable::operator=(decltype(nullptr)) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + return *this; + } + + IFormattable& IFormattable::operator=(IFormattable&& other) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + } + Handle = other.Handle; + other.Handle = 0; + return *this; + } + + bool IFormattable::operator==(const IFormattable& other) const + { + return Handle == other.Handle; + } + + bool IFormattable::operator!=(const IFormattable& other) const + { + return Handle != other.Handle; + } +} + +namespace System +{ + IConvertible::IConvertible(decltype(nullptr)) + { + } + + IConvertible::IConvertible(Plugin::InternalUse, int32_t handle) + { + Handle = handle; + if (handle) + { + Plugin::ReferenceManagedClass(handle); + } + } + + IConvertible::IConvertible(const IConvertible& other) + : IConvertible(Plugin::InternalUse::Only, other.Handle) + { + } + + IConvertible::IConvertible(IConvertible&& other) + : IConvertible(Plugin::InternalUse::Only, other.Handle) + { + other.Handle = 0; + } + + IConvertible::~IConvertible() + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + } + + IConvertible& IConvertible::operator=(const IConvertible& other) + { + if (this->Handle) + { + Plugin::DereferenceManagedClass(this->Handle); + } + this->Handle = other.Handle; + if (this->Handle) + { + Plugin::ReferenceManagedClass(this->Handle); + } + return *this; + } + + IConvertible& IConvertible::operator=(decltype(nullptr)) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + return *this; + } + + IConvertible& IConvertible::operator=(IConvertible&& other) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + } + Handle = other.Handle; + other.Handle = 0; + return *this; + } + + bool IConvertible::operator==(const IConvertible& other) const + { + return Handle == other.Handle; + } + + bool IConvertible::operator!=(const IConvertible& other) const + { + return Handle != other.Handle; + } +} + +namespace System +{ + IComparable::IComparable(decltype(nullptr)) + { + } + + IComparable::IComparable(Plugin::InternalUse, int32_t handle) + { + Handle = handle; + if (handle) + { + Plugin::ReferenceManagedClass(handle); + } + } + + IComparable::IComparable(const IComparable& other) + : IComparable(Plugin::InternalUse::Only, other.Handle) + { + } + + IComparable::IComparable(IComparable&& other) + : IComparable(Plugin::InternalUse::Only, other.Handle) + { + other.Handle = 0; + } + + IComparable::~IComparable() + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + } + + IComparable& IComparable::operator=(const IComparable& other) + { + if (this->Handle) + { + Plugin::DereferenceManagedClass(this->Handle); + } + this->Handle = other.Handle; + if (this->Handle) + { + Plugin::ReferenceManagedClass(this->Handle); + } + return *this; + } + + IComparable& IComparable::operator=(decltype(nullptr)) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + return *this; + } + + IComparable& IComparable::operator=(IComparable&& other) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + } + Handle = other.Handle; + other.Handle = 0; + return *this; + } + + bool IComparable::operator==(const IComparable& other) const + { + return Handle == other.Handle; + } + + bool IComparable::operator!=(const IComparable& other) const + { + return Handle != other.Handle; + } +} + +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 +{ + 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 +{ + 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 +{ + 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 +{ + 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 +{ + 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 +{ + 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 +{ + 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 +{ + 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 +{ + 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 +{ + 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 +{ + 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 +{ + 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 +{ + 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)) + { + } + + IComparable_1::IComparable_1(Plugin::InternalUse, int32_t handle) + { + Handle = handle; + if (handle) + { + Plugin::ReferenceManagedClass(handle); + } + } + + IComparable_1::IComparable_1(const IComparable_1& other) + : IComparable_1(Plugin::InternalUse::Only, other.Handle) + { + } + + IComparable_1::IComparable_1(IComparable_1&& other) + : IComparable_1(Plugin::InternalUse::Only, other.Handle) + { + other.Handle = 0; + } + + IComparable_1::~IComparable_1() + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + } + + IComparable_1& IComparable_1::operator=(const IComparable_1& other) + { + if (this->Handle) + { + Plugin::DereferenceManagedClass(this->Handle); + } + this->Handle = other.Handle; + if (this->Handle) + { + Plugin::ReferenceManagedClass(this->Handle); + } + return *this; + } + + IComparable_1& IComparable_1::operator=(decltype(nullptr)) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + return *this; + } + + IComparable_1& IComparable_1::operator=(IComparable_1&& other) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + } + Handle = other.Handle; + other.Handle = 0; + return *this; + } + + bool IComparable_1::operator==(const IComparable_1& other) const + { + return Handle == other.Handle; + } + + bool IComparable_1::operator!=(const IComparable_1& other) const + { + return Handle != other.Handle; + } +} + +namespace System +{ + IComparable_1::IComparable_1(decltype(nullptr)) + { + } + + IComparable_1::IComparable_1(Plugin::InternalUse, int32_t handle) + { + Handle = handle; + if (handle) + { + Plugin::ReferenceManagedClass(handle); + } + } + + IComparable_1::IComparable_1(const IComparable_1& other) + : IComparable_1(Plugin::InternalUse::Only, other.Handle) + { + } + + IComparable_1::IComparable_1(IComparable_1&& other) + : IComparable_1(Plugin::InternalUse::Only, other.Handle) + { + other.Handle = 0; + } + + IComparable_1::~IComparable_1() + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + } + + IComparable_1& IComparable_1::operator=(const IComparable_1& other) + { + if (this->Handle) + { + Plugin::DereferenceManagedClass(this->Handle); + } + this->Handle = other.Handle; + if (this->Handle) + { + Plugin::ReferenceManagedClass(this->Handle); + } + return *this; + } + + IComparable_1& IComparable_1::operator=(decltype(nullptr)) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + return *this; + } + + IComparable_1& IComparable_1::operator=(IComparable_1&& other) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + } + Handle = other.Handle; + other.Handle = 0; + return *this; + } + + bool IComparable_1::operator==(const IComparable_1& other) const + { + return Handle == other.Handle; + } + + bool IComparable_1::operator!=(const IComparable_1& other) const + { + return Handle != other.Handle; + } +} + +namespace System +{ + IComparable_1::IComparable_1(decltype(nullptr)) + { + } + + IComparable_1::IComparable_1(Plugin::InternalUse, int32_t handle) + { + Handle = handle; + if (handle) + { + Plugin::ReferenceManagedClass(handle); + } + } + + IComparable_1::IComparable_1(const IComparable_1& other) + : IComparable_1(Plugin::InternalUse::Only, other.Handle) + { + } + + IComparable_1::IComparable_1(IComparable_1&& other) + : IComparable_1(Plugin::InternalUse::Only, other.Handle) + { + other.Handle = 0; + } + + IComparable_1::~IComparable_1() + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + } + + IComparable_1& IComparable_1::operator=(const IComparable_1& other) + { + if (this->Handle) + { + Plugin::DereferenceManagedClass(this->Handle); + } + this->Handle = other.Handle; + if (this->Handle) + { + Plugin::ReferenceManagedClass(this->Handle); + } + return *this; + } + + IComparable_1& IComparable_1::operator=(decltype(nullptr)) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + return *this; + } + + IComparable_1& IComparable_1::operator=(IComparable_1&& other) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + } + Handle = other.Handle; + other.Handle = 0; + return *this; + } + + bool IComparable_1::operator==(const IComparable_1& other) const + { + return Handle == other.Handle; + } + + bool IComparable_1::operator!=(const IComparable_1& other) const + { + return Handle != other.Handle; + } +} + +namespace System +{ + IComparable_1::IComparable_1(decltype(nullptr)) + { + } + + IComparable_1::IComparable_1(Plugin::InternalUse, int32_t handle) + { + Handle = handle; + if (handle) + { + Plugin::ReferenceManagedClass(handle); + } + } + + IComparable_1::IComparable_1(const IComparable_1& other) + : IComparable_1(Plugin::InternalUse::Only, other.Handle) + { + } + + IComparable_1::IComparable_1(IComparable_1&& other) + : IComparable_1(Plugin::InternalUse::Only, other.Handle) + { + other.Handle = 0; + } + + IComparable_1::~IComparable_1() + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + } + + IComparable_1& IComparable_1::operator=(const IComparable_1& other) + { + if (this->Handle) + { + Plugin::DereferenceManagedClass(this->Handle); + } + this->Handle = other.Handle; + if (this->Handle) + { + Plugin::ReferenceManagedClass(this->Handle); + } + return *this; + } + + IComparable_1& IComparable_1::operator=(decltype(nullptr)) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + return *this; + } + + IComparable_1& IComparable_1::operator=(IComparable_1&& other) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + } + Handle = other.Handle; + other.Handle = 0; + return *this; + } + + bool IComparable_1::operator==(const IComparable_1& other) const + { + return Handle == other.Handle; + } + + bool IComparable_1::operator!=(const IComparable_1& other) const + { + return Handle != other.Handle; + } +} + +namespace System +{ + IComparable_1::IComparable_1(decltype(nullptr)) + { + } + + IComparable_1::IComparable_1(Plugin::InternalUse, int32_t handle) + { + Handle = handle; + if (handle) + { + Plugin::ReferenceManagedClass(handle); + } + } + + IComparable_1::IComparable_1(const IComparable_1& other) + : IComparable_1(Plugin::InternalUse::Only, other.Handle) + { + } + + IComparable_1::IComparable_1(IComparable_1&& other) + : IComparable_1(Plugin::InternalUse::Only, other.Handle) + { + other.Handle = 0; + } + + IComparable_1::~IComparable_1() + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + } + + IComparable_1& IComparable_1::operator=(const IComparable_1& other) + { + if (this->Handle) + { + Plugin::DereferenceManagedClass(this->Handle); + } + this->Handle = other.Handle; + if (this->Handle) + { + Plugin::ReferenceManagedClass(this->Handle); + } + return *this; + } + + IComparable_1& IComparable_1::operator=(decltype(nullptr)) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + return *this; + } + + IComparable_1& IComparable_1::operator=(IComparable_1&& other) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + } + Handle = other.Handle; + other.Handle = 0; + return *this; + } + + bool IComparable_1::operator==(const IComparable_1& other) const + { + return Handle == other.Handle; + } + + bool IComparable_1::operator!=(const IComparable_1& other) const + { + return Handle != other.Handle; + } +} + +namespace System +{ + IComparable_1::IComparable_1(decltype(nullptr)) + { + } + + IComparable_1::IComparable_1(Plugin::InternalUse, int32_t handle) + { + Handle = handle; + if (handle) + { + Plugin::ReferenceManagedClass(handle); + } + } + + IComparable_1::IComparable_1(const IComparable_1& other) + : IComparable_1(Plugin::InternalUse::Only, other.Handle) + { + } + + IComparable_1::IComparable_1(IComparable_1&& other) + : IComparable_1(Plugin::InternalUse::Only, other.Handle) + { + other.Handle = 0; + } + + IComparable_1::~IComparable_1() + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + } + + IComparable_1& IComparable_1::operator=(const IComparable_1& other) + { + if (this->Handle) + { + Plugin::DereferenceManagedClass(this->Handle); + } + this->Handle = other.Handle; + if (this->Handle) + { + Plugin::ReferenceManagedClass(this->Handle); + } + return *this; + } + + IComparable_1& IComparable_1::operator=(decltype(nullptr)) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + return *this; + } + + IComparable_1& IComparable_1::operator=(IComparable_1&& other) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + } + Handle = other.Handle; + other.Handle = 0; + return *this; + } + + bool IComparable_1::operator==(const IComparable_1& other) const + { + return Handle == other.Handle; + } + + bool IComparable_1::operator!=(const IComparable_1& other) const + { + return Handle != other.Handle; + } +} + +namespace System +{ + IComparable_1::IComparable_1(decltype(nullptr)) + { + } + + IComparable_1::IComparable_1(Plugin::InternalUse, int32_t handle) + { + Handle = handle; + if (handle) + { + Plugin::ReferenceManagedClass(handle); + } + } + + IComparable_1::IComparable_1(const IComparable_1& other) + : IComparable_1(Plugin::InternalUse::Only, other.Handle) + { + } + + IComparable_1::IComparable_1(IComparable_1&& other) + : IComparable_1(Plugin::InternalUse::Only, other.Handle) + { + other.Handle = 0; + } + + IComparable_1::~IComparable_1() + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + } + + IComparable_1& IComparable_1::operator=(const IComparable_1& other) + { + if (this->Handle) + { + Plugin::DereferenceManagedClass(this->Handle); + } + this->Handle = other.Handle; + if (this->Handle) + { + Plugin::ReferenceManagedClass(this->Handle); + } + return *this; + } + + IComparable_1& IComparable_1::operator=(decltype(nullptr)) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + return *this; + } + + IComparable_1& IComparable_1::operator=(IComparable_1&& other) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + } + Handle = other.Handle; + other.Handle = 0; + return *this; + } + + bool IComparable_1::operator==(const IComparable_1& other) const + { + return Handle == other.Handle; + } + + bool IComparable_1::operator!=(const IComparable_1& other) const + { + return Handle != other.Handle; + } +} + +namespace System +{ + IComparable_1::IComparable_1(decltype(nullptr)) + { + } + + IComparable_1::IComparable_1(Plugin::InternalUse, int32_t handle) + { + Handle = handle; + if (handle) + { + Plugin::ReferenceManagedClass(handle); + } + } + + IComparable_1::IComparable_1(const IComparable_1& other) + : IComparable_1(Plugin::InternalUse::Only, other.Handle) + { + } + + IComparable_1::IComparable_1(IComparable_1&& other) + : IComparable_1(Plugin::InternalUse::Only, other.Handle) + { + other.Handle = 0; + } + + IComparable_1::~IComparable_1() + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + } + + IComparable_1& IComparable_1::operator=(const IComparable_1& other) + { + if (this->Handle) + { + Plugin::DereferenceManagedClass(this->Handle); + } + this->Handle = other.Handle; + if (this->Handle) + { + Plugin::ReferenceManagedClass(this->Handle); + } + return *this; + } + + IComparable_1& IComparable_1::operator=(decltype(nullptr)) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + return *this; + } + + IComparable_1& IComparable_1::operator=(IComparable_1&& other) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + } + Handle = other.Handle; + other.Handle = 0; + return *this; + } + + bool IComparable_1::operator==(const IComparable_1& other) const + { + return Handle == other.Handle; + } + + bool IComparable_1::operator!=(const IComparable_1& other) const + { + return Handle != other.Handle; + } +} + +namespace System +{ + IComparable_1::IComparable_1(decltype(nullptr)) + { + } + + IComparable_1::IComparable_1(Plugin::InternalUse, int32_t handle) + { + Handle = handle; + if (handle) + { + Plugin::ReferenceManagedClass(handle); + } + } + + IComparable_1::IComparable_1(const IComparable_1& other) + : IComparable_1(Plugin::InternalUse::Only, other.Handle) + { + } + + IComparable_1::IComparable_1(IComparable_1&& other) + : IComparable_1(Plugin::InternalUse::Only, other.Handle) + { + other.Handle = 0; + } + + IComparable_1::~IComparable_1() + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + } + + IComparable_1& IComparable_1::operator=(const IComparable_1& other) + { + if (this->Handle) + { + Plugin::DereferenceManagedClass(this->Handle); + } + this->Handle = other.Handle; + if (this->Handle) + { + Plugin::ReferenceManagedClass(this->Handle); + } + return *this; + } + + IComparable_1& IComparable_1::operator=(decltype(nullptr)) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + return *this; + } + + IComparable_1& IComparable_1::operator=(IComparable_1&& other) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + } + Handle = other.Handle; + other.Handle = 0; + return *this; + } + + bool IComparable_1::operator==(const IComparable_1& other) const + { + return Handle == other.Handle; + } + + bool IComparable_1::operator!=(const IComparable_1& other) const + { + return Handle != other.Handle; + } +} + +namespace System +{ + IComparable_1::IComparable_1(decltype(nullptr)) + { + } + + IComparable_1::IComparable_1(Plugin::InternalUse, int32_t handle) + { + Handle = handle; + if (handle) + { + Plugin::ReferenceManagedClass(handle); + } + } + + IComparable_1::IComparable_1(const IComparable_1& other) + : IComparable_1(Plugin::InternalUse::Only, other.Handle) + { + } + + IComparable_1::IComparable_1(IComparable_1&& other) + : IComparable_1(Plugin::InternalUse::Only, other.Handle) + { + other.Handle = 0; + } + + IComparable_1::~IComparable_1() + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + } + + IComparable_1& IComparable_1::operator=(const IComparable_1& other) + { + if (this->Handle) + { + Plugin::DereferenceManagedClass(this->Handle); + } + this->Handle = other.Handle; + if (this->Handle) + { + Plugin::ReferenceManagedClass(this->Handle); + } + return *this; + } + + IComparable_1& IComparable_1::operator=(decltype(nullptr)) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + return *this; + } + + IComparable_1& IComparable_1::operator=(IComparable_1&& other) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + } + Handle = other.Handle; + other.Handle = 0; + return *this; + } + + bool IComparable_1::operator==(const IComparable_1& other) const + { + return Handle == other.Handle; + } + + bool IComparable_1::operator!=(const IComparable_1& other) const + { + return Handle != other.Handle; + } +} + +namespace System +{ + IComparable_1::IComparable_1(decltype(nullptr)) + { + } + + IComparable_1::IComparable_1(Plugin::InternalUse, int32_t handle) + { + Handle = handle; + if (handle) + { + Plugin::ReferenceManagedClass(handle); + } + } + + IComparable_1::IComparable_1(const IComparable_1& other) + : IComparable_1(Plugin::InternalUse::Only, other.Handle) + { + } + + IComparable_1::IComparable_1(IComparable_1&& other) + : IComparable_1(Plugin::InternalUse::Only, other.Handle) + { + other.Handle = 0; + } + + IComparable_1::~IComparable_1() + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + } + + IComparable_1& IComparable_1::operator=(const IComparable_1& other) + { + if (this->Handle) + { + Plugin::DereferenceManagedClass(this->Handle); + } + this->Handle = other.Handle; + if (this->Handle) + { + Plugin::ReferenceManagedClass(this->Handle); + } + return *this; + } + + IComparable_1& IComparable_1::operator=(decltype(nullptr)) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + return *this; + } + + IComparable_1& IComparable_1::operator=(IComparable_1&& other) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + } + Handle = other.Handle; + other.Handle = 0; + return *this; + } + + bool IComparable_1::operator==(const IComparable_1& other) const + { + return Handle == other.Handle; + } + + bool IComparable_1::operator!=(const IComparable_1& other) const + { + return Handle != other.Handle; + } +} + +namespace System +{ + IComparable_1::IComparable_1(decltype(nullptr)) + { + } + + IComparable_1::IComparable_1(Plugin::InternalUse, int32_t handle) + { + Handle = handle; + if (handle) + { + Plugin::ReferenceManagedClass(handle); + } + } + + IComparable_1::IComparable_1(const IComparable_1& other) + : IComparable_1(Plugin::InternalUse::Only, other.Handle) + { + } + + IComparable_1::IComparable_1(IComparable_1&& other) + : IComparable_1(Plugin::InternalUse::Only, other.Handle) + { + other.Handle = 0; + } + + IComparable_1::~IComparable_1() + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + } + + IComparable_1& IComparable_1::operator=(const IComparable_1& other) + { + if (this->Handle) + { + Plugin::DereferenceManagedClass(this->Handle); + } + this->Handle = other.Handle; + if (this->Handle) + { + Plugin::ReferenceManagedClass(this->Handle); + } + return *this; + } + + IComparable_1& IComparable_1::operator=(decltype(nullptr)) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + return *this; + } + + IComparable_1& IComparable_1::operator=(IComparable_1&& other) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + } + Handle = other.Handle; + other.Handle = 0; + return *this; + } + + bool IComparable_1::operator==(const IComparable_1& other) const + { + return Handle == other.Handle; + } + + bool IComparable_1::operator!=(const IComparable_1& other) const + { + return Handle != other.Handle; + } +} + +namespace System +{ + IComparable_1::IComparable_1(decltype(nullptr)) + { + } + + IComparable_1::IComparable_1(Plugin::InternalUse, int32_t handle) + { + Handle = handle; + if (handle) + { + Plugin::ReferenceManagedClass(handle); + } + } + + IComparable_1::IComparable_1(const IComparable_1& other) + : IComparable_1(Plugin::InternalUse::Only, other.Handle) + { + } + + IComparable_1::IComparable_1(IComparable_1&& other) + : IComparable_1(Plugin::InternalUse::Only, other.Handle) + { + other.Handle = 0; + } + + IComparable_1::~IComparable_1() + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + } + + IComparable_1& IComparable_1::operator=(const IComparable_1& other) + { + if (this->Handle) + { + Plugin::DereferenceManagedClass(this->Handle); + } + this->Handle = other.Handle; + if (this->Handle) + { + Plugin::ReferenceManagedClass(this->Handle); + } + return *this; + } + + IComparable_1& IComparable_1::operator=(decltype(nullptr)) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + return *this; + } + + IComparable_1& IComparable_1::operator=(IComparable_1&& other) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + } + Handle = other.Handle; + other.Handle = 0; + return *this; + } + + bool IComparable_1::operator==(const IComparable_1& other) const + { + return Handle == other.Handle; + } + + bool IComparable_1::operator!=(const IComparable_1& other) const + { + return Handle != other.Handle; + } +} + +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)) + { + } + + Decimal::Decimal(Plugin::InternalUse, int32_t handle) + { + Handle = handle; + if (handle) + { + Plugin::ReferenceManagedSystemDecimal(Handle); + } + } + + Decimal::Decimal(const Decimal& other) + : Decimal(Plugin::InternalUse::Only, other.Handle) + { + } + + Decimal::Decimal(Decimal&& other) + : Decimal(Plugin::InternalUse::Only, other.Handle) + { + other.Handle = 0; + } + + Decimal::~Decimal() + { + if (Handle) + { + Plugin::DereferenceManagedSystemDecimal(Handle); + Handle = 0; + } + } + + Decimal& Decimal::operator=(const Decimal& other) + { + if (this->Handle) + { + Plugin::DereferenceManagedSystemDecimal(Handle); + } + this->Handle = other.Handle; + if (this->Handle) + { + Plugin::ReferenceManagedSystemDecimal(Handle); + } + return *this; + } + + Decimal& Decimal::operator=(decltype(nullptr)) + { + if (Handle) + { + Plugin::DereferenceManagedSystemDecimal(Handle); + Handle = 0; + } + return *this; + } + + Decimal& Decimal::operator=(Decimal&& other) + { + if (Handle) + { + Plugin::DereferenceManagedSystemDecimal(Handle); + } + Handle = other.Handle; + other.Handle = 0; + return *this; + } + + bool Decimal::operator==(const Decimal& other) const + { + return Handle == other.Handle; + } + + bool Decimal::operator!=(const Decimal& other) const + { + return Handle != other.Handle; + } + + System::Decimal::Decimal(System::Double value) + { + auto returnValue = Plugin::SystemDecimalConstructorSystemDouble(value); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + Handle = returnValue; + if (returnValue) + { + Plugin::ReferenceManagedSystemDecimal(Handle); + } + } + + System::Decimal::Decimal(System::UInt64 value) + { + auto returnValue = Plugin::SystemDecimalConstructorSystemUInt64(value); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + Handle = returnValue; + if (returnValue) + { + Plugin::ReferenceManagedSystemDecimal(Handle); + } + } + + System::Decimal::operator System::ValueType() + { + 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::ValueType(Plugin::InternalUse::Only, handle); + } + return nullptr; + } + + System::Decimal::operator System::Object() + { + 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::Object(Plugin::InternalUse::Only, handle); + } + return nullptr; + } + + System::Decimal::operator System::IComparable() + { + 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(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; + } + + System::Decimal::operator System::IConvertible() + { + 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::IConvertible(Plugin::InternalUse::Only, handle); + } + return nullptr; + } + + System::Decimal::operator System::IEquatable_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::IEquatable_1(Plugin::InternalUse::Only, handle); + } + return nullptr; + } + + System::Decimal::operator System::Runtime::Serialization::IDeserializationCallback() + { + 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::Runtime::Serialization::IDeserializationCallback(Plugin::InternalUse::Only, handle); + } + return nullptr; + } + + System::Decimal::operator System::IFormattable() + { + 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::IFormattable(Plugin::InternalUse::Only, handle); + } + return nullptr; + } +} + +namespace System +{ + System::Object::operator System::Decimal() + { + System::Decimal returnVal(Plugin::InternalUse::Only, Plugin::UnboxDecimal(Handle)); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + return returnVal; + } +} + +namespace UnityEngine +{ + Vector3::Vector3() + { + } + + UnityEngine::Vector3::Vector3(System::Single x, System::Single y, System::Single z) + { + auto returnValue = Plugin::UnityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingle(x, y, z); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + *this = returnValue; + } + + UnityEngine::Vector3 UnityEngine::Vector3::operator+(UnityEngine::Vector3& a) + { + auto returnValue = Plugin::UnityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3(*this, a); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + return returnValue; + } + + UnityEngine::Vector3::operator System::ValueType() + { + 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::ValueType(Plugin::InternalUse::Only, handle); + } + return nullptr; + } + + UnityEngine::Vector3::operator System::Object() + { + 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::Object(Plugin::InternalUse::Only, handle); + } + 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 +{ + System::Object::operator UnityEngine::Vector3() + { + UnityEngine::Vector3 returnVal(Plugin::UnboxVector3(Handle)); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + return returnVal; + } +} + +namespace UnityEngine +{ + Object::Object(decltype(nullptr)) + { + } + + Object::Object(Plugin::InternalUse, int32_t handle) + { + Handle = handle; + if (handle) + { + Plugin::ReferenceManagedClass(handle); + } + } + + Object::Object(const Object& other) + : Object(Plugin::InternalUse::Only, other.Handle) + { + } + + Object::Object(Object&& other) + : Object(Plugin::InternalUse::Only, other.Handle) + { + other.Handle = 0; + } + + Object::~Object() + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + } + + Object& Object::operator=(const Object& other) + { + if (this->Handle) + { + Plugin::DereferenceManagedClass(this->Handle); + } + this->Handle = other.Handle; + if (this->Handle) + { + Plugin::ReferenceManagedClass(this->Handle); + } + return *this; + } + + Object& Object::operator=(decltype(nullptr)) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + return *this; + } + + Object& Object::operator=(Object&& other) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + } + Handle = other.Handle; + other.Handle = 0; + return *this; + } + + bool Object::operator==(const Object& other) const + { + return Handle == other.Handle; + } + + bool Object::operator!=(const Object& other) const + { + return Handle != other.Handle; + } + + System::String UnityEngine::Object::GetName() + { + auto returnValue = Plugin::UnityEngineObjectPropertyGetName(Handle); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + return System::String(Plugin::InternalUse::Only, returnValue); + } + + void UnityEngine::Object::SetName(System::String& value) + { + Plugin::UnityEngineObjectPropertySetName(Handle, value.Handle); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + } +} + +namespace UnityEngine +{ + Component::Component(decltype(nullptr)) + : UnityEngine::Object(nullptr) + { + } + + Component::Component(Plugin::InternalUse, int32_t handle) + : UnityEngine::Object(nullptr) + { + Handle = handle; + if (handle) + { + Plugin::ReferenceManagedClass(handle); + } + } + + Component::Component(const Component& other) + : Component(Plugin::InternalUse::Only, other.Handle) + { + } + + Component::Component(Component&& other) + : Component(Plugin::InternalUse::Only, other.Handle) + { + other.Handle = 0; + } + + Component::~Component() + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + } + + Component& Component::operator=(const Component& other) + { + if (this->Handle) + { + Plugin::DereferenceManagedClass(this->Handle); + } + this->Handle = other.Handle; + if (this->Handle) + { + Plugin::ReferenceManagedClass(this->Handle); + } + return *this; + } + + Component& Component::operator=(decltype(nullptr)) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + return *this; + } + + Component& Component::operator=(Component&& other) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + } + Handle = other.Handle; + other.Handle = 0; + return *this; + } + + bool Component::operator==(const Component& other) const + { + return Handle == other.Handle; + } + + bool Component::operator!=(const Component& other) const + { + return Handle != other.Handle; + } + + UnityEngine::Transform UnityEngine::Component::GetTransform() + { + auto returnValue = Plugin::UnityEngineComponentPropertyGetTransform(Handle); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + return UnityEngine::Transform(Plugin::InternalUse::Only, returnValue); + } +} + +namespace UnityEngine +{ + Transform::Transform(decltype(nullptr)) + : UnityEngine::Object(nullptr) + , UnityEngine::Component(nullptr) + , System::Collections::IEnumerable(nullptr) + { + } + + Transform::Transform(Plugin::InternalUse, int32_t handle) + : UnityEngine::Object(nullptr) + , UnityEngine::Component(nullptr) + , System::Collections::IEnumerable(nullptr) + { + Handle = handle; + if (handle) + { + Plugin::ReferenceManagedClass(handle); + } + } + + Transform::Transform(const Transform& other) + : Transform(Plugin::InternalUse::Only, other.Handle) + { + } + + Transform::Transform(Transform&& other) + : Transform(Plugin::InternalUse::Only, other.Handle) + { + other.Handle = 0; + } + + Transform::~Transform() + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + } + + Transform& Transform::operator=(const Transform& other) + { + if (this->Handle) + { + Plugin::DereferenceManagedClass(this->Handle); + } + this->Handle = other.Handle; + if (this->Handle) + { + Plugin::ReferenceManagedClass(this->Handle); + } + return *this; + } + + Transform& Transform::operator=(decltype(nullptr)) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + return *this; + } + + Transform& Transform::operator=(Transform&& other) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + } + Handle = other.Handle; + other.Handle = 0; + return *this; + } + + bool Transform::operator==(const Transform& other) const + { + return Handle == other.Handle; + } + + bool Transform::operator!=(const Transform& other) const + { + return Handle != other.Handle; + } + + UnityEngine::Vector3 UnityEngine::Transform::GetPosition() + { + auto returnValue = Plugin::UnityEngineTransformPropertyGetPosition(Handle); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + return returnValue; + } + + void UnityEngine::Transform::SetPosition(UnityEngine::Vector3& value) + { + Plugin::UnityEngineTransformPropertySetPosition(Handle, value); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + } +} + +namespace System +{ + namespace Collections + { + IEnumerator::IEnumerator(decltype(nullptr)) + { + } + + IEnumerator::IEnumerator(Plugin::InternalUse, int32_t handle) + { + Handle = handle; + if (handle) + { + Plugin::ReferenceManagedClass(handle); + } + } + + IEnumerator::IEnumerator(const IEnumerator& other) + : IEnumerator(Plugin::InternalUse::Only, other.Handle) + { + } + + IEnumerator::IEnumerator(IEnumerator&& other) + : IEnumerator(Plugin::InternalUse::Only, other.Handle) + { + other.Handle = 0; + } + + IEnumerator::~IEnumerator() + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + } + + IEnumerator& IEnumerator::operator=(const IEnumerator& other) + { + if (this->Handle) + { + Plugin::DereferenceManagedClass(this->Handle); + } + this->Handle = other.Handle; + if (this->Handle) + { + Plugin::ReferenceManagedClass(this->Handle); + } + return *this; + } + + IEnumerator& IEnumerator::operator=(decltype(nullptr)) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + return *this; + } + + IEnumerator& IEnumerator::operator=(IEnumerator&& other) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + } + Handle = other.Handle; + other.Handle = 0; + return *this; + } + + bool IEnumerator::operator==(const IEnumerator& other) const + { + return Handle == other.Handle; + } + + bool IEnumerator::operator!=(const IEnumerator& other) const + { + return Handle != other.Handle; + } + + System::Object System::Collections::IEnumerator::GetCurrent() + { + auto returnValue = Plugin::SystemCollectionsIEnumeratorPropertyGetCurrent(Handle); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + return System::Object(Plugin::InternalUse::Only, returnValue); + } + + System::Boolean System::Collections::IEnumerator::MoveNext() + { + auto returnValue = Plugin::SystemCollectionsIEnumeratorMethodMoveNext(Handle); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + return returnValue; + } + } +} + +namespace System +{ + namespace Runtime + { + namespace Serialization + { + ISerializable::ISerializable(decltype(nullptr)) + { + } + + ISerializable::ISerializable(Plugin::InternalUse, int32_t handle) + { + Handle = handle; + if (handle) + { + Plugin::ReferenceManagedClass(handle); + } + } + + ISerializable::ISerializable(const ISerializable& other) + : ISerializable(Plugin::InternalUse::Only, other.Handle) + { + } + + ISerializable::ISerializable(ISerializable&& other) + : ISerializable(Plugin::InternalUse::Only, other.Handle) + { + other.Handle = 0; + } + + ISerializable::~ISerializable() + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + } + + ISerializable& ISerializable::operator=(const ISerializable& other) + { + if (this->Handle) + { + Plugin::DereferenceManagedClass(this->Handle); + } + this->Handle = other.Handle; + if (this->Handle) + { + Plugin::ReferenceManagedClass(this->Handle); + } + return *this; + } + + ISerializable& ISerializable::operator=(decltype(nullptr)) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + return *this; + } + + ISerializable& ISerializable::operator=(ISerializable&& other) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + } + Handle = other.Handle; + other.Handle = 0; + return *this; + } + + bool ISerializable::operator==(const ISerializable& other) const + { + return Handle == other.Handle; + } + + bool ISerializable::operator!=(const ISerializable& other) const + { + return Handle != other.Handle; + } + } + } +} + +namespace System +{ + namespace Runtime + { + namespace InteropServices + { + _Exception::_Exception(decltype(nullptr)) + { + } + + _Exception::_Exception(Plugin::InternalUse, int32_t handle) + { + Handle = handle; + if (handle) + { + Plugin::ReferenceManagedClass(handle); + } + } + + _Exception::_Exception(const _Exception& other) + : _Exception(Plugin::InternalUse::Only, other.Handle) + { + } + + _Exception::_Exception(_Exception&& other) + : _Exception(Plugin::InternalUse::Only, other.Handle) + { + other.Handle = 0; + } + + _Exception::~_Exception() + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + } + + _Exception& _Exception::operator=(const _Exception& other) + { + if (this->Handle) + { + Plugin::DereferenceManagedClass(this->Handle); + } + this->Handle = other.Handle; + if (this->Handle) + { + Plugin::ReferenceManagedClass(this->Handle); + } + return *this; + } + + _Exception& _Exception::operator=(decltype(nullptr)) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + return *this; + } + + _Exception& _Exception::operator=(_Exception&& other) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + } + Handle = other.Handle; + other.Handle = 0; + return *this; + } + + bool _Exception::operator==(const _Exception& other) const + { + return Handle == other.Handle; + } + + bool _Exception::operator!=(const _Exception& other) const + { + return Handle != other.Handle; + } + } + } +} + +namespace UnityEngine +{ + GameObject::GameObject(decltype(nullptr)) + : UnityEngine::Object(nullptr) + { + } + + GameObject::GameObject(Plugin::InternalUse, int32_t handle) + : UnityEngine::Object(nullptr) + { + Handle = handle; + if (handle) + { + Plugin::ReferenceManagedClass(handle); + } + } + + GameObject::GameObject(const GameObject& other) + : GameObject(Plugin::InternalUse::Only, other.Handle) + { + } + + GameObject::GameObject(GameObject&& other) + : GameObject(Plugin::InternalUse::Only, other.Handle) + { + other.Handle = 0; + } + + GameObject::~GameObject() + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + } + + GameObject& GameObject::operator=(const GameObject& other) + { + if (this->Handle) + { + Plugin::DereferenceManagedClass(this->Handle); + } + this->Handle = other.Handle; + if (this->Handle) + { + Plugin::ReferenceManagedClass(this->Handle); + } + return *this; + } + + GameObject& GameObject::operator=(decltype(nullptr)) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + return *this; + } + + GameObject& GameObject::operator=(GameObject&& other) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + } + Handle = other.Handle; + other.Handle = 0; + return *this; + } + + bool GameObject::operator==(const GameObject& other) const + { + return Handle == other.Handle; + } + + bool GameObject::operator!=(const GameObject& other) const + { + return Handle != other.Handle; + } + + template<> MyGame::BaseBallScript UnityEngine::GameObject::AddComponent() + { + auto returnValue = Plugin::UnityEngineGameObjectMethodAddComponentMyGameBaseBallScript(Handle); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + return MyGame::BaseBallScript(Plugin::InternalUse::Only, returnValue); + } + + UnityEngine::GameObject UnityEngine::GameObject::CreatePrimitive(UnityEngine::PrimitiveType type) + { + auto returnValue = Plugin::UnityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveType(type); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + return UnityEngine::GameObject(Plugin::InternalUse::Only, returnValue); + } +} + +namespace UnityEngine +{ + Debug::Debug(decltype(nullptr)) + { + } + + Debug::Debug(Plugin::InternalUse, int32_t handle) + { + Handle = handle; + if (handle) + { + Plugin::ReferenceManagedClass(handle); + } + } + + Debug::Debug(const Debug& other) + : Debug(Plugin::InternalUse::Only, other.Handle) + { + } + + Debug::Debug(Debug&& other) + : Debug(Plugin::InternalUse::Only, other.Handle) + { + other.Handle = 0; + } + + Debug::~Debug() + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + } + + Debug& Debug::operator=(const Debug& other) + { + if (this->Handle) + { + Plugin::DereferenceManagedClass(this->Handle); + } + this->Handle = other.Handle; + if (this->Handle) + { + Plugin::ReferenceManagedClass(this->Handle); + } + return *this; + } + + Debug& Debug::operator=(decltype(nullptr)) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + return *this; + } + + Debug& Debug::operator=(Debug&& other) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + } + Handle = other.Handle; + other.Handle = 0; + return *this; + } + + bool Debug::operator==(const Debug& other) const + { + return Handle == other.Handle; + } + + bool Debug::operator!=(const Debug& other) const + { + return Handle != other.Handle; + } + + void UnityEngine::Debug::Log(System::Object& message) + { + Plugin::UnityEngineDebugMethodLogSystemObject(message.Handle); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + } +} + +namespace UnityEngine +{ + Behaviour::Behaviour(decltype(nullptr)) + : UnityEngine::Object(nullptr) + , UnityEngine::Component(nullptr) + { + } + + Behaviour::Behaviour(Plugin::InternalUse, int32_t handle) + : UnityEngine::Object(nullptr) + , UnityEngine::Component(nullptr) + { + Handle = handle; + if (handle) + { + Plugin::ReferenceManagedClass(handle); + } + } + + Behaviour::Behaviour(const Behaviour& other) + : Behaviour(Plugin::InternalUse::Only, other.Handle) + { + } + + Behaviour::Behaviour(Behaviour&& other) + : Behaviour(Plugin::InternalUse::Only, other.Handle) + { + other.Handle = 0; + } + + Behaviour::~Behaviour() + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + } + + Behaviour& Behaviour::operator=(const Behaviour& other) + { + if (this->Handle) + { + Plugin::DereferenceManagedClass(this->Handle); + } + this->Handle = other.Handle; + if (this->Handle) + { + Plugin::ReferenceManagedClass(this->Handle); + } + return *this; + } + + Behaviour& Behaviour::operator=(decltype(nullptr)) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + return *this; + } + + Behaviour& Behaviour::operator=(Behaviour&& other) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + } + Handle = other.Handle; + other.Handle = 0; + return *this; + } + + bool Behaviour::operator==(const Behaviour& other) const + { + return Handle == other.Handle; + } + + bool Behaviour::operator!=(const Behaviour& other) const + { + return Handle != other.Handle; + } +} + +namespace UnityEngine +{ + MonoBehaviour::MonoBehaviour(decltype(nullptr)) + : UnityEngine::Object(nullptr) + , UnityEngine::Component(nullptr) + , UnityEngine::Behaviour(nullptr) + { + } + + MonoBehaviour::MonoBehaviour(Plugin::InternalUse, int32_t handle) + : UnityEngine::Object(nullptr) + , UnityEngine::Component(nullptr) + , UnityEngine::Behaviour(nullptr) + { + Handle = handle; + if (handle) + { + Plugin::ReferenceManagedClass(handle); + } + } + + MonoBehaviour::MonoBehaviour(const MonoBehaviour& other) + : MonoBehaviour(Plugin::InternalUse::Only, other.Handle) + { + } + + MonoBehaviour::MonoBehaviour(MonoBehaviour&& other) + : MonoBehaviour(Plugin::InternalUse::Only, other.Handle) + { + other.Handle = 0; + } + + MonoBehaviour::~MonoBehaviour() + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + } + + MonoBehaviour& MonoBehaviour::operator=(const MonoBehaviour& other) + { + if (this->Handle) + { + Plugin::DereferenceManagedClass(this->Handle); + } + this->Handle = other.Handle; + if (this->Handle) + { + Plugin::ReferenceManagedClass(this->Handle); + } + return *this; + } + + MonoBehaviour& MonoBehaviour::operator=(decltype(nullptr)) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + return *this; + } + + MonoBehaviour& MonoBehaviour::operator=(MonoBehaviour&& other) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + } + Handle = other.Handle; + other.Handle = 0; + return *this; + } + + bool MonoBehaviour::operator==(const MonoBehaviour& other) const + { + return Handle == other.Handle; + } + + bool MonoBehaviour::operator!=(const MonoBehaviour& other) const + { + return Handle != other.Handle; + } + + UnityEngine::Transform UnityEngine::MonoBehaviour::GetTransform() + { + auto returnValue = Plugin::UnityEngineMonoBehaviourPropertyGetTransform(Handle); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + return UnityEngine::Transform(Plugin::InternalUse::Only, returnValue); + } +} + +namespace System +{ + Exception::Exception(decltype(nullptr)) + : System::Runtime::InteropServices::_Exception(nullptr) + , System::Runtime::Serialization::ISerializable(nullptr) + { + } + + Exception::Exception(Plugin::InternalUse, int32_t handle) + : System::Runtime::InteropServices::_Exception(nullptr) + , System::Runtime::Serialization::ISerializable(nullptr) + { + Handle = handle; + if (handle) + { + Plugin::ReferenceManagedClass(handle); + } + } + + Exception::Exception(const Exception& other) + : Exception(Plugin::InternalUse::Only, other.Handle) + { + } + + Exception::Exception(Exception&& other) + : Exception(Plugin::InternalUse::Only, other.Handle) + { + other.Handle = 0; + } + + Exception::~Exception() + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + } + + Exception& Exception::operator=(const Exception& other) + { + if (this->Handle) + { + Plugin::DereferenceManagedClass(this->Handle); + } + this->Handle = other.Handle; + if (this->Handle) + { + Plugin::ReferenceManagedClass(this->Handle); + } + return *this; + } + + Exception& Exception::operator=(decltype(nullptr)) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + return *this; + } + + Exception& Exception::operator=(Exception&& other) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + } + Handle = other.Handle; + other.Handle = 0; + return *this; + } + + bool Exception::operator==(const Exception& other) const + { + return Handle == other.Handle; + } + + bool Exception::operator!=(const Exception& other) const + { + return Handle != other.Handle; + } + + System::Exception::Exception(System::String& message) + : System::Runtime::InteropServices::_Exception(nullptr) + , System::Runtime::Serialization::ISerializable(nullptr) + { + auto returnValue = Plugin::SystemExceptionConstructorSystemString(message.Handle); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + Handle = returnValue; + if (returnValue) + { + Plugin::ReferenceManagedClass(returnValue); + } + } +} + +namespace System +{ + SystemException::SystemException(decltype(nullptr)) + : System::Runtime::InteropServices::_Exception(nullptr) + , System::Runtime::Serialization::ISerializable(nullptr) + , System::Exception(nullptr) + { + } + + SystemException::SystemException(Plugin::InternalUse, int32_t handle) + : System::Runtime::InteropServices::_Exception(nullptr) + , System::Runtime::Serialization::ISerializable(nullptr) + , System::Exception(nullptr) + { + Handle = handle; + if (handle) + { + Plugin::ReferenceManagedClass(handle); + } + } + + SystemException::SystemException(const SystemException& other) + : SystemException(Plugin::InternalUse::Only, other.Handle) + { + } + + SystemException::SystemException(SystemException&& other) + : SystemException(Plugin::InternalUse::Only, other.Handle) + { + other.Handle = 0; + } + + SystemException::~SystemException() + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + } + + SystemException& SystemException::operator=(const SystemException& other) + { + if (this->Handle) + { + Plugin::DereferenceManagedClass(this->Handle); + } + this->Handle = other.Handle; + if (this->Handle) + { + Plugin::ReferenceManagedClass(this->Handle); + } + return *this; + } + + SystemException& SystemException::operator=(decltype(nullptr)) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + return *this; + } + + SystemException& SystemException::operator=(SystemException&& other) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + } + Handle = other.Handle; + other.Handle = 0; + return *this; + } + + bool SystemException::operator==(const SystemException& other) const + { + return Handle == other.Handle; + } + + bool SystemException::operator!=(const SystemException& other) const + { + return Handle != other.Handle; + } +} + +namespace System +{ + NullReferenceException::NullReferenceException(decltype(nullptr)) + : System::Runtime::InteropServices::_Exception(nullptr) + , System::Runtime::Serialization::ISerializable(nullptr) + , System::Exception(nullptr) + , System::SystemException(nullptr) + { + } + + NullReferenceException::NullReferenceException(Plugin::InternalUse, int32_t handle) + : System::Runtime::InteropServices::_Exception(nullptr) + , System::Runtime::Serialization::ISerializable(nullptr) + , System::Exception(nullptr) + , System::SystemException(nullptr) + { + Handle = handle; + if (handle) + { + Plugin::ReferenceManagedClass(handle); + } + } + + NullReferenceException::NullReferenceException(const NullReferenceException& other) + : NullReferenceException(Plugin::InternalUse::Only, other.Handle) + { + } + + NullReferenceException::NullReferenceException(NullReferenceException&& other) + : NullReferenceException(Plugin::InternalUse::Only, other.Handle) + { + other.Handle = 0; + } + + NullReferenceException::~NullReferenceException() + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + } + + NullReferenceException& NullReferenceException::operator=(const NullReferenceException& other) + { + if (this->Handle) + { + Plugin::DereferenceManagedClass(this->Handle); + } + this->Handle = other.Handle; + if (this->Handle) + { + Plugin::ReferenceManagedClass(this->Handle); + } + return *this; + } + + NullReferenceException& NullReferenceException::operator=(decltype(nullptr)) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + return *this; + } + + NullReferenceException& NullReferenceException::operator=(NullReferenceException&& other) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + } + Handle = other.Handle; + other.Handle = 0; + return *this; + } + + bool NullReferenceException::operator==(const NullReferenceException& other) const + { + return Handle == other.Handle; + } + + bool NullReferenceException::operator!=(const NullReferenceException& other) const + { + return Handle != other.Handle; + } +} + +namespace UnityEngine +{ + PrimitiveType::PrimitiveType(int32_t value) + : Value(value) + { + } + + UnityEngine::PrimitiveType::operator int32_t() const + { + return Value; + } + + bool UnityEngine::PrimitiveType::operator==(PrimitiveType other) + { + return Value == other.Value; + } + + bool UnityEngine::PrimitiveType::operator!=(PrimitiveType other) + { + return Value != other.Value; + } + + UnityEngine::PrimitiveType::operator System::Enum() + { + int32_t handle = Plugin::BoxPrimitiveType(*this); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + if (handle) + { + Plugin::ReferenceManagedClass(handle); + return System::Enum(Plugin::InternalUse::Only, handle); + } + return nullptr; + } + + UnityEngine::PrimitiveType::operator System::ValueType() + { + int32_t handle = Plugin::BoxPrimitiveType(*this); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + if (handle) + { + Plugin::ReferenceManagedClass(handle); + return System::ValueType(Plugin::InternalUse::Only, handle); + } + return nullptr; + } + + UnityEngine::PrimitiveType::operator System::Object() + { + int32_t handle = Plugin::BoxPrimitiveType(*this); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + if (handle) + { + Plugin::ReferenceManagedClass(handle); + return System::Object(Plugin::InternalUse::Only, handle); + } + return nullptr; + } + + UnityEngine::PrimitiveType::operator System::IComparable() + { + int32_t handle = Plugin::BoxPrimitiveType(*this); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + if (handle) + { + Plugin::ReferenceManagedClass(handle); + return System::IComparable(Plugin::InternalUse::Only, handle); + } + return nullptr; + } + + UnityEngine::PrimitiveType::operator System::IConvertible() + { + int32_t handle = Plugin::BoxPrimitiveType(*this); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + if (handle) + { + Plugin::ReferenceManagedClass(handle); + return System::IConvertible(Plugin::InternalUse::Only, handle); + } + return nullptr; + } + + UnityEngine::PrimitiveType::operator System::IFormattable() + { + int32_t handle = Plugin::BoxPrimitiveType(*this); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + if (handle) + { + Plugin::ReferenceManagedClass(handle); + return System::IFormattable(Plugin::InternalUse::Only, handle); + } + return nullptr; + } + +} +const UnityEngine::PrimitiveType UnityEngine::PrimitiveType::Sphere(0); +const UnityEngine::PrimitiveType UnityEngine::PrimitiveType::Capsule(1); +const UnityEngine::PrimitiveType UnityEngine::PrimitiveType::Cylinder(2); +const UnityEngine::PrimitiveType UnityEngine::PrimitiveType::Cube(3); +const UnityEngine::PrimitiveType UnityEngine::PrimitiveType::Plane(4); +const UnityEngine::PrimitiveType UnityEngine::PrimitiveType::Quad(5); + +namespace System +{ + System::Object::operator UnityEngine::PrimitiveType() + { + UnityEngine::PrimitiveType returnVal(Plugin::UnboxPrimitiveType(Handle)); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + return returnVal; + } +} + +namespace UnityEngine +{ + Time::Time(decltype(nullptr)) + { + } + + Time::Time(Plugin::InternalUse, int32_t handle) + { + Handle = handle; + if (handle) + { + Plugin::ReferenceManagedClass(handle); + } + } + + Time::Time(const Time& other) + : Time(Plugin::InternalUse::Only, other.Handle) + { + } + + Time::Time(Time&& other) + : Time(Plugin::InternalUse::Only, other.Handle) + { + other.Handle = 0; + } + + Time::~Time() + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + } + + Time& Time::operator=(const Time& other) + { + if (this->Handle) + { + Plugin::DereferenceManagedClass(this->Handle); + } + this->Handle = other.Handle; + if (this->Handle) + { + Plugin::ReferenceManagedClass(this->Handle); + } + return *this; + } + + Time& Time::operator=(decltype(nullptr)) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + return *this; + } + + Time& Time::operator=(Time&& other) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + } + Handle = other.Handle; + other.Handle = 0; + return *this; + } + + bool Time::operator==(const Time& other) const + { + return Handle == other.Handle; + } + + bool Time::operator!=(const Time& other) const + { + return Handle != other.Handle; + } + + System::Single UnityEngine::Time::GetDeltaTime() + { + auto returnValue = Plugin::UnityEngineTimePropertyGetDeltaTime(); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + return returnValue; + } +} + +namespace MyGame +{ + AbstractBaseBallScript::AbstractBaseBallScript(decltype(nullptr)) + : UnityEngine::Object(nullptr) + , UnityEngine::Component(nullptr) + , UnityEngine::Behaviour(nullptr) + , UnityEngine::MonoBehaviour(nullptr) + { + } + + AbstractBaseBallScript::AbstractBaseBallScript(Plugin::InternalUse, int32_t handle) + : UnityEngine::Object(nullptr) + , UnityEngine::Component(nullptr) + , UnityEngine::Behaviour(nullptr) + , UnityEngine::MonoBehaviour(nullptr) + { + Handle = handle; + if (handle) + { + Plugin::ReferenceManagedClass(handle); + } + } + + AbstractBaseBallScript::AbstractBaseBallScript(const AbstractBaseBallScript& other) + : AbstractBaseBallScript(Plugin::InternalUse::Only, other.Handle) + { + } + + AbstractBaseBallScript::AbstractBaseBallScript(AbstractBaseBallScript&& other) + : AbstractBaseBallScript(Plugin::InternalUse::Only, other.Handle) + { + other.Handle = 0; + } + + AbstractBaseBallScript::~AbstractBaseBallScript() + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + } + + AbstractBaseBallScript& AbstractBaseBallScript::operator=(const AbstractBaseBallScript& other) + { + if (this->Handle) + { + Plugin::DereferenceManagedClass(this->Handle); + } + this->Handle = other.Handle; + if (this->Handle) + { + Plugin::ReferenceManagedClass(this->Handle); + } + return *this; + } + + AbstractBaseBallScript& AbstractBaseBallScript::operator=(decltype(nullptr)) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + return *this; + } + + AbstractBaseBallScript& AbstractBaseBallScript::operator=(AbstractBaseBallScript&& other) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + } + Handle = other.Handle; + other.Handle = 0; + return *this; + } + + bool AbstractBaseBallScript::operator==(const AbstractBaseBallScript& other) const + { + return Handle == other.Handle; + } + + bool AbstractBaseBallScript::operator!=(const AbstractBaseBallScript& other) const + { + return Handle != other.Handle; + } +} + +namespace MyGame +{ + MyGame::BaseBallScript::BaseBallScript() + : UnityEngine::Object(nullptr) + , UnityEngine::Component(nullptr) + , UnityEngine::Behaviour(nullptr) + , UnityEngine::MonoBehaviour(nullptr) + , MyGame::AbstractBaseBallScript(nullptr) + { + CppHandle = Plugin::StoreBaseBallScript(this); + System::Int32* handle = (System::Int32*)&Handle; + int32_t cppHandle = CppHandle; + Plugin::BaseBallScriptConstructor(cppHandle, &handle->Value); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + if (Handle) + { + Plugin::ReferenceManagedClass(Handle); + } + else + { + Plugin::RemoveBaseBallScript(CppHandle); + CppHandle = 0; + } + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + } + + BaseBallScript::BaseBallScript(decltype(nullptr)) + : UnityEngine::Object(nullptr) + , UnityEngine::Component(nullptr) + , UnityEngine::Behaviour(nullptr) + , UnityEngine::MonoBehaviour(nullptr) + , MyGame::AbstractBaseBallScript(nullptr) + { + CppHandle = Plugin::StoreBaseBallScript(this); + } + + MyGame::BaseBallScript::BaseBallScript(const MyGame::BaseBallScript& other) + : UnityEngine::Object(nullptr) + , UnityEngine::Component(nullptr) + , UnityEngine::Behaviour(nullptr) + , UnityEngine::MonoBehaviour(nullptr) + , MyGame::AbstractBaseBallScript(nullptr) + { + Handle = other.Handle; + CppHandle = Plugin::StoreBaseBallScript(this); + if (Handle) + { + Plugin::ReferenceManagedClass(Handle); + } + } + + MyGame::BaseBallScript::BaseBallScript(MyGame::BaseBallScript&& other) + : UnityEngine::Object(nullptr) + , UnityEngine::Component(nullptr) + , UnityEngine::Behaviour(nullptr) + , UnityEngine::MonoBehaviour(nullptr) + , MyGame::AbstractBaseBallScript(nullptr) + { + Handle = other.Handle; + CppHandle = other.CppHandle; + other.Handle = 0; + other.CppHandle = 0; + } + + MyGame::BaseBallScript::BaseBallScript(Plugin::InternalUse, int32_t handle) + : UnityEngine::Object(nullptr) + , UnityEngine::Component(nullptr) + , UnityEngine::Behaviour(nullptr) + , UnityEngine::MonoBehaviour(nullptr) + , MyGame::AbstractBaseBallScript(nullptr) + { + Handle = handle; + CppHandle = Plugin::StoreBaseBallScript(this); + if (Handle) + { + Plugin::ReferenceManagedClass(Handle); + } + } + + MyGame::BaseBallScript::~BaseBallScript() + { + Plugin::RemoveWholeBaseBallScript(this); + Plugin::RemoveBaseBallScript(CppHandle); + CppHandle = 0; + if (Handle) + { + int32_t handle = Handle; + Handle = 0; + if (Plugin::DereferenceManagedClassNoRelease(handle)) + { + Plugin::ReleaseBaseBallScript(handle); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + } + } + } + + MyGame::BaseBallScript& MyGame::BaseBallScript::operator=(const MyGame::BaseBallScript& other) + { + if (this->Handle) + { + Plugin::DereferenceManagedClass(this->Handle); + } + this->Handle = other.Handle; + if (this->Handle) + { + Plugin::ReferenceManagedClass(this->Handle); + } + return *this; + } + + MyGame::BaseBallScript& MyGame::BaseBallScript::operator=(decltype(nullptr)) + { + if (Handle) + { + int32_t handle = Handle; + Handle = 0; + if (Plugin::DereferenceManagedClassNoRelease(handle)) + { + Plugin::ReleaseBaseBallScript(handle); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + } + } + Handle = 0; + return *this; + } + + MyGame::BaseBallScript& MyGame::BaseBallScript::operator=(MyGame::BaseBallScript&& other) + { + Plugin::RemoveBaseBallScript(CppHandle); + CppHandle = 0; + if (Handle) + { + int32_t handle = Handle; + Handle = 0; + if (Plugin::DereferenceManagedClassNoRelease(handle)) + { + Plugin::ReleaseBaseBallScript(handle); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + } + } + Handle = other.Handle; + other.Handle = 0; + return *this; + } + + bool MyGame::BaseBallScript::operator==(const MyGame::BaseBallScript& other) const + { + return Handle == other.Handle; + } + + bool MyGame::BaseBallScript::operator!=(const MyGame::BaseBallScript& other) const + { + return Handle != other.Handle; + } + + DLLEXPORT int32_t NewBaseBallScript(int32_t handle) + { + MyGame::BaseBallScript* memory = Plugin::StoreWholeBaseBallScript(); + MyGame::BallScript* thiz = new (memory) MyGame::BallScript(Plugin::InternalUse::Only, handle); + return thiz->CppHandle; + } + + DLLEXPORT void DestroyBaseBallScript(int32_t cppHandle) + { + MyGame::BaseBallScript* instance = Plugin::GetBaseBallScript(cppHandle); + instance->~BaseBallScript(); + } + + void MyGame::BaseBallScript::Update() + { + } + + DLLEXPORT void MyGameAbstractBaseBallScriptUpdate(int32_t cppHandle) + { + try + { + Plugin::GetBaseBallScript(cppHandle)->Update(); + } + catch (System::Exception ex) + { + Plugin::SetException(ex.Handle); + } + catch (...) + { + System::String msg = "Unhandled exception invoking MyGame::AbstractBaseBallScript"; + System::Exception ex(msg); + Plugin::SetException(ex.Handle); + } + } +} + +namespace System +{ + System::Object::operator System::Boolean() + { + System::Boolean returnVal(Plugin::UnboxBoolean(Handle)); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + return returnVal; + } +} + +namespace System +{ + System::Object::operator System::SByte() + { + System::SByte returnVal(Plugin::UnboxSByte(Handle)); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + return returnVal; + } +} + +namespace System +{ + System::Object::operator System::Byte() + { + System::Byte returnVal(Plugin::UnboxByte(Handle)); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + return returnVal; + } +} + +namespace System +{ + System::Object::operator System::Int16() + { + System::Int16 returnVal(Plugin::UnboxInt16(Handle)); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + return returnVal; + } +} + +namespace System +{ + System::Object::operator System::UInt16() + { + System::UInt16 returnVal(Plugin::UnboxUInt16(Handle)); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + return returnVal; + } +} + +namespace System +{ + System::Object::operator System::Int32() + { + System::Int32 returnVal(Plugin::UnboxInt32(Handle)); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + return returnVal; + } +} + +namespace System +{ + System::Object::operator System::UInt32() + { + System::UInt32 returnVal(Plugin::UnboxUInt32(Handle)); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + return returnVal; + } +} + +namespace System +{ + System::Object::operator System::Int64() + { + System::Int64 returnVal(Plugin::UnboxInt64(Handle)); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + return returnVal; + } +} + +namespace System +{ + System::Object::operator System::UInt64() + { + System::UInt64 returnVal(Plugin::UnboxUInt64(Handle)); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + return returnVal; + } +} + +namespace System +{ + System::Object::operator System::Char() + { + System::Char returnVal(Plugin::UnboxChar(Handle)); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + return returnVal; + } +} + +namespace System +{ + System::Object::operator System::Single() + { + System::Single returnVal(Plugin::UnboxSingle(Handle)); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + return returnVal; + } +} + +namespace System +{ + System::Object::operator System::Double() + { + System::Double returnVal(Plugin::UnboxDouble(Handle)); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + return returnVal; + } +} + +namespace System +{ + struct NullReferenceExceptionThrower : System::NullReferenceException + { + NullReferenceExceptionThrower(int32_t handle) + : System::Runtime::InteropServices::_Exception(nullptr) + , System::Runtime::Serialization::ISerializable(nullptr) + , System::Exception(nullptr) + , System::SystemException(nullptr) + , System::NullReferenceException(Plugin::InternalUse::Only, handle) + { + } + + virtual void ThrowReferenceToThis() + { + throw *this; + } + }; +} + +DLLEXPORT void SetCsharpExceptionSystemNullReferenceException(int32_t handle) +{ + delete Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = new System::NullReferenceExceptionThrower(handle); +} +/*END METHOD DEFINITIONS*/ + +//////////////////////////////////////////////////////////////// +// App-specific functions for this file to call +//////////////////////////////////////////////////////////////// + +// Called when the plugin is initialized +extern void PluginMain( + void* memory, + int32_t memorySize, + bool isFirstBoot); + +//////////////////////////////////////////////////////////////// +// C++ functions for C# to call +//////////////////////////////////////////////////////////////// + +enum class InitMode : uint8_t +{ + FirstBoot, + Reload +}; + +// Init the plugin +DLLEXPORT void Init( + uint8_t* memory, + int32_t memorySize, + 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); + + /*BEGIN INIT BODY ARRAYS*/ + Plugin::RefCountsSystemDecimal = (int32_t*)curMemory; + curMemory += 1000 * sizeof(int32_t); + Plugin::RefCountsLenSystemDecimal = 1000; + + Plugin::BaseBallScriptFreeListSize = 1000; + Plugin::BaseBallScriptFreeList = (MyGame::BaseBallScript**)curMemory; + curMemory += 1000 * sizeof(MyGame::BaseBallScript*); + + Plugin::BaseBallScriptFreeWholeListSize = 1000; + Plugin::BaseBallScriptFreeWholeList = (Plugin::BaseBallScriptFreeWholeListEntry*)curMemory; + curMemory += 1000 * sizeof(Plugin::BaseBallScriptFreeWholeListEntry); + /*END INIT BODY ARRAYS*/ + + // Make sure there was enough memory + int32_t usedMemory = (int32_t)(curMemory - (uint8_t*)memory); + if (usedMemory > memorySize) + { + System::String msg = "Plugin memory size is too low"; + System::Exception ex(msg); + Plugin::SetException(ex.Handle); + return; + } + + if (initMode == InitMode::FirstBoot) + { + // Clear memory + memset(memory, 0, memorySize); + + /*BEGIN INIT BODY FIRST BOOT*/ + for (int32_t i = 0, end = Plugin::BaseBallScriptFreeListSize - 1; i < end; ++i) + { + Plugin::BaseBallScriptFreeList[i] = (MyGame::BaseBallScript*)(Plugin::BaseBallScriptFreeList + i + 1); + } + Plugin::BaseBallScriptFreeList[Plugin::BaseBallScriptFreeListSize - 1] = nullptr; + Plugin::NextFreeBaseBallScript = Plugin::BaseBallScriptFreeList + 1; + + for (int32_t i = 0, end = Plugin::BaseBallScriptFreeWholeListSize - 1; i < end; ++i) + { + Plugin::BaseBallScriptFreeWholeList[i].Next = Plugin::BaseBallScriptFreeWholeList + i + 1; + } + Plugin::BaseBallScriptFreeWholeList[Plugin::BaseBallScriptFreeWholeListSize - 1].Next = nullptr; + Plugin::NextFreeWholeBaseBallScript = Plugin::BaseBallScriptFreeWholeList + 1; + /*END INIT BODY FIRST BOOT*/ + } + + try + { + PluginMain( + curMemory, + (int32_t)(memorySize - usedMemory), + initMode == InitMode::FirstBoot); + } + catch (System::Exception ex) + { + Plugin::SetException(ex.Handle); + } + catch (...) + { + System::String msg = "Unhandled exception in PluginMain"; + System::Exception ex(msg); + Plugin::SetException(ex.Handle); + } +} + +// Receive an unhandled exception from C# +DLLEXPORT void SetCsharpException(int32_t handle) +{ + Plugin::unhandledCsharpException = new System::Exception( + Plugin::InternalUse::Only, + handle); +} + diff --git a/Unity/Assets/CppSource/NativeScript/Bindings.cpp.meta b/Unity/Assets/CppSource/NativeScript/Bindings.cpp.meta new file mode 100644 index 0000000..1b1a472 --- /dev/null +++ b/Unity/Assets/CppSource/NativeScript/Bindings.cpp.meta @@ -0,0 +1,26 @@ +fileFormatVersion: 2 +guid: 6b6c5fe253c434b7db04a6d5165c1001 +timeCreated: 1525538114 +licenseType: Free +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/CppSource/NativeScript/Bindings.h b/Unity/Assets/CppSource/NativeScript/Bindings.h new file mode 100644 index 0000000..4da12a4 --- /dev/null +++ b/Unity/Assets/CppSource/NativeScript/Bindings.h @@ -0,0 +1,1669 @@ +/// +/// Declaration of the various .NET types exposed to C++ +/// +/// +/// Jackson Dunstan, 2017, http://JacksonDunstan.com +/// +/// +/// MIT +/// + +#pragma once + +// 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: +// // Good. Uses behavior, not names. +// int x = myArray[5]; +// // Bad. Directly uses names. +// ArrayElementProxy1_1 proxy = myArray[5]; +// int x = proxy; +//////////////////////////////////////////////////////////////// + +namespace Plugin +{ + enum struct InternalUse + { + Only + }; + + struct ManagedType + { + int32_t Handle; + + ManagedType(); + ManagedType(decltype(nullptr)); + ManagedType(InternalUse, int32_t handle); + }; + + template struct ArrayElementProxy1_1; + + template struct ArrayElementProxy1_2; + template struct ArrayElementProxy2_2; + + template struct ArrayElementProxy1_3; + template struct ArrayElementProxy2_3; + template struct ArrayElementProxy3_3; + + template struct ArrayElementProxy1_4; + template struct ArrayElementProxy2_4; + template struct ArrayElementProxy3_4; + template struct ArrayElementProxy4_4; + + template struct ArrayElementProxy1_5; + template struct ArrayElementProxy2_5; + template struct ArrayElementProxy3_5; + template struct ArrayElementProxy4_5; + template struct ArrayElementProxy5_5; +} + +//////////////////////////////////////////////////////////////// +// C# basic types +//////////////////////////////////////////////////////////////// + +namespace System +{ + struct Object; + struct ValueType; + struct Enum; + struct String; + struct Array; + template struct Array1; + template struct Array2; + template struct Array3; + template struct Array4; + template struct Array5; + struct IComparable; + template struct IComparable_1; + template struct IEquatable_1; + struct IFormattable; + struct IConvertible; + + // .NET booleans are four bytes long + // This struct makes them feel like C++'s bool, int32_t, and uint32_t types + struct Boolean + { + int32_t Value; + + Boolean(); + Boolean(bool value); + Boolean(int32_t value); + Boolean(uint32_t value); + operator bool() const; + operator int32_t() const; + operator uint32_t() const; + explicit operator Object() const; + explicit operator ValueType() const; + explicit operator IComparable() const; + explicit operator IFormattable() const; + explicit operator IConvertible() const; + explicit operator IComparable_1() const; + explicit operator IEquatable_1() const; + }; + + // .NET chars are two bytes long + // This struct helps them interoperate with C++'s char and int16_t types + struct Char + { + int16_t Value; + + Char(); + Char(char value); + Char(int16_t value); + operator int16_t() const; + explicit operator Object() const; + explicit operator ValueType() const; + explicit operator IComparable() const; + explicit operator IFormattable() const; + explicit operator IConvertible() const; + explicit operator IComparable_1() const; + explicit operator IEquatable_1() const; + }; + + struct SByte + { + int8_t Value; + + SByte(); + SByte(int8_t value); + operator int8_t() const; + explicit operator Object() const; + explicit operator ValueType() const; + explicit operator IComparable() const; + explicit operator IFormattable() const; + explicit operator IConvertible() const; + explicit operator IComparable_1() const; + explicit operator IEquatable_1() const; + }; + + struct Byte + { + uint8_t Value; + + Byte(); + Byte(uint8_t value); + operator uint8_t() const; + explicit operator Object() const; + explicit operator ValueType() const; + explicit operator IComparable() const; + explicit operator IFormattable() const; + explicit operator IConvertible() const; + explicit operator IComparable_1() const; + explicit operator IEquatable_1() const; + }; + + struct Int16 + { + int16_t Value; + + Int16(); + Int16(int16_t value); + operator int16_t() const; + explicit operator Object() const; + explicit operator ValueType() const; + explicit operator IComparable() const; + explicit operator IFormattable() const; + explicit operator IConvertible() const; + explicit operator IComparable_1() const; + explicit operator IEquatable_1() const; + }; + + struct UInt16 + { + uint16_t Value; + + UInt16(); + UInt16(uint16_t value); + operator uint16_t() const; + explicit operator Object() const; + explicit operator ValueType() const; + explicit operator IComparable() const; + explicit operator IFormattable() const; + explicit operator IConvertible() const; + explicit operator IComparable_1() const; + explicit operator IEquatable_1() const; + }; + + struct Int32 + { + int32_t Value; + + Int32(); + Int32(int32_t value); + operator int32_t() const; + explicit operator Object() const; + explicit operator ValueType() const; + explicit operator IComparable() const; + explicit operator IFormattable() const; + explicit operator IConvertible() const; + explicit operator IComparable_1() const; + explicit operator IEquatable_1() const; + }; + + struct UInt32 + { + uint32_t Value; + + UInt32(); + UInt32(uint32_t value); + operator uint32_t() const; + explicit operator Object() const; + explicit operator ValueType() const; + explicit operator IComparable() const; + explicit operator IFormattable() const; + explicit operator IConvertible() const; + explicit operator IComparable_1() const; + explicit operator IEquatable_1() const; + }; + + struct Int64 + { + int64_t Value; + + Int64(); + Int64(int64_t value); + operator int64_t() const; + explicit operator Object() const; + explicit operator ValueType() const; + explicit operator IComparable() const; + explicit operator IFormattable() const; + explicit operator IConvertible() const; + explicit operator IComparable_1() const; + explicit operator IEquatable_1() const; + }; + + struct UInt64 + { + uint64_t Value; + + UInt64(); + UInt64(uint64_t value); + operator uint64_t() const; + explicit operator Object() const; + explicit operator ValueType() const; + explicit operator IComparable() const; + explicit operator IFormattable() const; + explicit operator IConvertible() const; + explicit operator IComparable_1() const; + explicit operator IEquatable_1() const; + }; + + struct Single + { + float Value; + + Single(); + Single(float value); + operator float() const; + explicit operator Object() const; + explicit operator ValueType() const; + explicit operator IComparable() const; + explicit operator IFormattable() const; + explicit operator IConvertible() const; + explicit operator IComparable_1() const; + explicit operator IEquatable_1() const; + }; + + struct Double + { + double Value; + + Double(); + Double(double value); + operator double() const; + explicit operator Object() const; + explicit operator ValueType() const; + explicit operator IComparable() const; + explicit operator IFormattable() const; + explicit operator IConvertible() const; + explicit operator IComparable_1() const; + explicit operator IEquatable_1() const; + }; +} + +/*BEGIN TEMPLATE DECLARATIONS*/ +namespace System +{ + template struct IEquatable_1; +} + +namespace System +{ + template struct IComparable_1; +} +/*END TEMPLATE DECLARATIONS*/ + +/*BEGIN TYPE DECLARATIONS*/ +namespace System +{ + struct IFormattable; +} + +namespace System +{ + struct IConvertible; +} + +namespace System +{ + struct IComparable; +} + +namespace System +{ + namespace Runtime + { + namespace Serialization + { + struct IDeserializationCallback; + } + } +} + +namespace System +{ + struct Decimal; +} + +namespace UnityEngine +{ + struct Vector3; +} + +namespace UnityEngine +{ + struct Object; +} + +namespace UnityEngine +{ + struct Component; +} + +namespace UnityEngine +{ + struct Transform; +} + +namespace System +{ + namespace Collections + { + struct IEnumerator; + } +} + +namespace System +{ + namespace Runtime + { + namespace Serialization + { + struct ISerializable; + } + } +} + +namespace System +{ + namespace Runtime + { + namespace InteropServices + { + struct _Exception; + } + } +} + +namespace UnityEngine +{ + struct GameObject; +} + +namespace UnityEngine +{ + struct Debug; +} + +namespace UnityEngine +{ + struct Behaviour; +} + +namespace UnityEngine +{ + struct MonoBehaviour; +} + +namespace System +{ + struct Exception; +} + +namespace System +{ + struct SystemException; +} + +namespace System +{ + struct NullReferenceException; +} + +namespace UnityEngine +{ + struct PrimitiveType; +} + +namespace UnityEngine +{ + struct Time; +} + +namespace MyGame +{ + struct AbstractBaseBallScript; +} + +namespace MyGame +{ + struct BaseBallScript; +} +/*END TYPE DECLARATIONS*/ + +/*BEGIN TEMPLATE SPECIALIZATION DECLARATIONS*/ +namespace System +{ + template<> struct IEquatable_1; +} + +namespace System +{ + template<> struct IEquatable_1; +} + +namespace System +{ + template<> struct IEquatable_1; +} + +namespace System +{ + template<> struct IEquatable_1; +} + +namespace System +{ + template<> struct IEquatable_1; +} + +namespace System +{ + template<> struct IEquatable_1; +} + +namespace System +{ + template<> struct IEquatable_1; +} + +namespace System +{ + template<> struct IEquatable_1; +} + +namespace System +{ + template<> struct IEquatable_1; +} + +namespace System +{ + template<> struct IEquatable_1; +} + +namespace System +{ + template<> struct IEquatable_1; +} + +namespace System +{ + template<> struct IEquatable_1; +} + +namespace System +{ + template<> struct IEquatable_1; +} + +namespace System +{ + template<> struct IEquatable_1; +} + +namespace System +{ + template<> struct IComparable_1; +} + +namespace System +{ + template<> struct IComparable_1; +} + +namespace System +{ + template<> struct IComparable_1; +} + +namespace System +{ + template<> struct IComparable_1; +} + +namespace System +{ + template<> struct IComparable_1; +} + +namespace System +{ + template<> struct IComparable_1; +} + +namespace System +{ + template<> struct IComparable_1; +} + +namespace System +{ + template<> struct IComparable_1; +} + +namespace System +{ + template<> struct IComparable_1; +} + +namespace System +{ + template<> struct IComparable_1; +} + +namespace System +{ + template<> struct IComparable_1; +} + +namespace System +{ + template<> struct IComparable_1; +} + +namespace System +{ + template<> struct IComparable_1; +} +/*END TEMPLATE SPECIALIZATION DECLARATIONS*/ + +//////////////////////////////////////////////////////////////// +// C# type definitions +//////////////////////////////////////////////////////////////// + +namespace System +{ + struct Object : Plugin::ManagedType + { + Object(); + Object(Plugin::InternalUse iu, int32_t handle); + Object(decltype(nullptr)); + virtual ~Object(); + bool operator==(decltype(nullptr)) const; + bool operator!=(decltype(nullptr)) const; + virtual void ThrowReferenceToThis(); + + /*BEGIN UNBOXING METHOD DECLARATIONS*/ + explicit operator System::Decimal(); + explicit operator UnityEngine::Vector3(); + explicit operator UnityEngine::PrimitiveType(); + explicit operator System::Boolean(); + explicit operator System::SByte(); + explicit operator System::Byte(); + explicit operator System::Int16(); + explicit operator System::UInt16(); + explicit operator System::Int32(); + explicit operator System::UInt32(); + explicit operator System::Int64(); + explicit operator System::UInt64(); + explicit operator System::Char(); + explicit operator System::Single(); + explicit operator System::Double(); + /*END UNBOXING METHOD DECLARATIONS*/ + }; + + struct ValueType : virtual Object + { + ValueType(Plugin::InternalUse iu, int32_t handle); + ValueType(decltype(nullptr)); + }; + + struct Enum : virtual ValueType + { + Enum(Plugin::InternalUse iu, int32_t handle); + Enum(decltype(nullptr)); + }; + + struct String : virtual Object + { + String(Plugin::InternalUse iu, int32_t handle); + String(decltype(nullptr)); + String(const String& other); + String(String&& other); + virtual ~String(); + String& operator=(const String& other); + String& operator=(decltype(nullptr)); + String& operator=(String&& other); + String(const char* chars); + }; + + struct ICloneable : virtual Object + { + ICloneable(Plugin::InternalUse iu, int32_t handle); + ICloneable(decltype(nullptr)); + }; + + namespace Collections + { + struct IEnumerable : virtual Object + { + IEnumerable(Plugin::InternalUse iu, int32_t handle); + IEnumerable(decltype(nullptr)); + IEnumerator GetEnumerator(); + }; + + struct ICollection : virtual IEnumerable + { + ICollection(Plugin::InternalUse iu, int32_t handle); + ICollection(decltype(nullptr)); + }; + + struct IList : virtual ICollection, virtual IEnumerable + { + IList(Plugin::InternalUse iu, int32_t handle); + IList(decltype(nullptr)); + }; + } + + struct Array : virtual ICloneable, virtual Collections::IList + { + Array(Plugin::InternalUse iu, int32_t handle); + Array(decltype(nullptr)); + int32_t GetLength(); + int32_t GetRank(); + }; +} + +//////////////////////////////////////////////////////////////// +// Global variables +//////////////////////////////////////////////////////////////// + +namespace Plugin +{ + extern System::String NullString; +} + +/*BEGIN TYPE DEFINITIONS*/ +namespace System +{ + struct IFormattable : virtual System::Object + { + IFormattable(decltype(nullptr)); + IFormattable(Plugin::InternalUse, int32_t handle); + IFormattable(const IFormattable& other); + IFormattable(IFormattable&& other); + virtual ~IFormattable(); + IFormattable& operator=(const IFormattable& other); + IFormattable& operator=(decltype(nullptr)); + IFormattable& operator=(IFormattable&& other); + bool operator==(const IFormattable& other) const; + bool operator!=(const IFormattable& other) const; + }; +} + +namespace System +{ + struct IConvertible : virtual System::Object + { + IConvertible(decltype(nullptr)); + IConvertible(Plugin::InternalUse, int32_t handle); + IConvertible(const IConvertible& other); + IConvertible(IConvertible&& other); + virtual ~IConvertible(); + IConvertible& operator=(const IConvertible& other); + IConvertible& operator=(decltype(nullptr)); + IConvertible& operator=(IConvertible&& other); + bool operator==(const IConvertible& other) const; + bool operator!=(const IConvertible& other) const; + }; +} + +namespace System +{ + struct IComparable : virtual System::Object + { + IComparable(decltype(nullptr)); + IComparable(Plugin::InternalUse, int32_t handle); + IComparable(const IComparable& other); + IComparable(IComparable&& other); + virtual ~IComparable(); + IComparable& operator=(const IComparable& other); + IComparable& operator=(decltype(nullptr)); + IComparable& operator=(IComparable&& other); + bool operator==(const IComparable& other) const; + bool operator!=(const IComparable& other) const; + }; +} + +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 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 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 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 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 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 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 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 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 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 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 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 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 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& operator=(const IComparable_1& other); + IComparable_1& operator=(decltype(nullptr)); + IComparable_1& operator=(IComparable_1&& other); + bool operator==(const IComparable_1& other) const; + bool operator!=(const IComparable_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& operator=(const IComparable_1& other); + IComparable_1& operator=(decltype(nullptr)); + IComparable_1& operator=(IComparable_1&& other); + bool operator==(const IComparable_1& other) const; + bool operator!=(const IComparable_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& operator=(const IComparable_1& other); + IComparable_1& operator=(decltype(nullptr)); + IComparable_1& operator=(IComparable_1&& other); + bool operator==(const IComparable_1& other) const; + bool operator!=(const IComparable_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& operator=(const IComparable_1& other); + IComparable_1& operator=(decltype(nullptr)); + IComparable_1& operator=(IComparable_1&& other); + bool operator==(const IComparable_1& other) const; + bool operator!=(const IComparable_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& operator=(const IComparable_1& other); + IComparable_1& operator=(decltype(nullptr)); + IComparable_1& operator=(IComparable_1&& other); + bool operator==(const IComparable_1& other) const; + bool operator!=(const IComparable_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& operator=(const IComparable_1& other); + IComparable_1& operator=(decltype(nullptr)); + IComparable_1& operator=(IComparable_1&& other); + bool operator==(const IComparable_1& other) const; + bool operator!=(const IComparable_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& operator=(const IComparable_1& other); + IComparable_1& operator=(decltype(nullptr)); + IComparable_1& operator=(IComparable_1&& other); + bool operator==(const IComparable_1& other) const; + bool operator!=(const IComparable_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& operator=(const IComparable_1& other); + IComparable_1& operator=(decltype(nullptr)); + IComparable_1& operator=(IComparable_1&& other); + bool operator==(const IComparable_1& other) const; + bool operator!=(const IComparable_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& operator=(const IComparable_1& other); + IComparable_1& operator=(decltype(nullptr)); + IComparable_1& operator=(IComparable_1&& other); + bool operator==(const IComparable_1& other) const; + bool operator!=(const IComparable_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& operator=(const IComparable_1& other); + IComparable_1& operator=(decltype(nullptr)); + IComparable_1& operator=(IComparable_1&& other); + bool operator==(const IComparable_1& other) const; + bool operator!=(const IComparable_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& operator=(const IComparable_1& other); + IComparable_1& operator=(decltype(nullptr)); + IComparable_1& operator=(IComparable_1&& other); + bool operator==(const IComparable_1& other) const; + bool operator!=(const IComparable_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& operator=(const IComparable_1& other); + IComparable_1& operator=(decltype(nullptr)); + IComparable_1& operator=(IComparable_1&& other); + bool operator==(const IComparable_1& other) const; + bool operator!=(const IComparable_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& operator=(const IComparable_1& other); + IComparable_1& operator=(decltype(nullptr)); + IComparable_1& operator=(IComparable_1&& other); + bool operator==(const IComparable_1& other) const; + bool operator!=(const IComparable_1& other) const; + }; +} + +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 + { + Decimal(decltype(nullptr)); + Decimal(Plugin::InternalUse, int32_t handle); + Decimal(const Decimal& other); + Decimal(Decimal&& other); + virtual ~Decimal(); + Decimal& operator=(const Decimal& other); + Decimal& operator=(decltype(nullptr)); + Decimal& operator=(Decimal&& other); + bool operator==(const Decimal& other) const; + bool operator!=(const Decimal& other) const; + Decimal(System::Double value); + Decimal(System::UInt64 value); + explicit operator System::ValueType(); + explicit operator System::Object(); + 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(); + }; +} + +namespace UnityEngine +{ + struct Vector3 + { + Vector3(); + Vector3(System::Single x, System::Single y, System::Single z); + System::Single x; + System::Single y; + System::Single z; + UnityEngine::Vector3 operator+(UnityEngine::Vector3& a); + explicit operator System::ValueType(); + explicit operator System::Object(); + explicit operator System::IEquatable_1(); + }; +} + +namespace UnityEngine +{ + struct Object : virtual System::Object + { + Object(decltype(nullptr)); + Object(Plugin::InternalUse, int32_t handle); + Object(const Object& other); + Object(Object&& other); + virtual ~Object(); + Object& operator=(const Object& other); + Object& operator=(decltype(nullptr)); + Object& operator=(Object&& other); + bool operator==(const Object& other) const; + bool operator!=(const Object& other) const; + System::String GetName(); + void SetName(System::String& value); + }; +} + +namespace UnityEngine +{ + struct Component : virtual UnityEngine::Object + { + Component(decltype(nullptr)); + Component(Plugin::InternalUse, int32_t handle); + Component(const Component& other); + Component(Component&& other); + virtual ~Component(); + Component& operator=(const Component& other); + Component& operator=(decltype(nullptr)); + Component& operator=(Component&& other); + bool operator==(const Component& other) const; + bool operator!=(const Component& other) const; + UnityEngine::Transform GetTransform(); + }; +} + +namespace UnityEngine +{ + struct Transform : virtual UnityEngine::Component, virtual System::Collections::IEnumerable + { + Transform(decltype(nullptr)); + Transform(Plugin::InternalUse, int32_t handle); + Transform(const Transform& other); + Transform(Transform&& other); + virtual ~Transform(); + Transform& operator=(const Transform& other); + Transform& operator=(decltype(nullptr)); + Transform& operator=(Transform&& other); + bool operator==(const Transform& other) const; + bool operator!=(const Transform& other) const; + UnityEngine::Vector3 GetPosition(); + void SetPosition(UnityEngine::Vector3& value); + }; +} + +namespace System +{ + namespace Collections + { + struct IEnumerator : virtual System::Object + { + IEnumerator(decltype(nullptr)); + IEnumerator(Plugin::InternalUse, int32_t handle); + IEnumerator(const IEnumerator& other); + IEnumerator(IEnumerator&& other); + virtual ~IEnumerator(); + IEnumerator& operator=(const IEnumerator& other); + IEnumerator& operator=(decltype(nullptr)); + IEnumerator& operator=(IEnumerator&& other); + bool operator==(const IEnumerator& other) const; + bool operator!=(const IEnumerator& other) const; + System::Object GetCurrent(); + System::Boolean MoveNext(); + }; + } +} + +namespace System +{ + namespace Runtime + { + namespace Serialization + { + struct ISerializable : virtual System::Object + { + ISerializable(decltype(nullptr)); + ISerializable(Plugin::InternalUse, int32_t handle); + ISerializable(const ISerializable& other); + ISerializable(ISerializable&& other); + virtual ~ISerializable(); + ISerializable& operator=(const ISerializable& other); + ISerializable& operator=(decltype(nullptr)); + ISerializable& operator=(ISerializable&& other); + bool operator==(const ISerializable& other) const; + bool operator!=(const ISerializable& other) const; + }; + } + } +} + +namespace System +{ + namespace Runtime + { + namespace InteropServices + { + struct _Exception : virtual System::Object + { + _Exception(decltype(nullptr)); + _Exception(Plugin::InternalUse, int32_t handle); + _Exception(const _Exception& other); + _Exception(_Exception&& other); + virtual ~_Exception(); + _Exception& operator=(const _Exception& other); + _Exception& operator=(decltype(nullptr)); + _Exception& operator=(_Exception&& other); + bool operator==(const _Exception& other) const; + bool operator!=(const _Exception& other) const; + }; + } + } +} + +namespace UnityEngine +{ + struct GameObject : virtual UnityEngine::Object + { + GameObject(decltype(nullptr)); + GameObject(Plugin::InternalUse, int32_t handle); + GameObject(const GameObject& other); + GameObject(GameObject&& other); + virtual ~GameObject(); + GameObject& operator=(const GameObject& other); + GameObject& operator=(decltype(nullptr)); + GameObject& operator=(GameObject&& other); + bool operator==(const GameObject& other) const; + bool operator!=(const GameObject& other) const; + template MT0 AddComponent(); + static UnityEngine::GameObject CreatePrimitive(UnityEngine::PrimitiveType type); + }; +} + +namespace UnityEngine +{ + struct Debug : virtual System::Object + { + Debug(decltype(nullptr)); + Debug(Plugin::InternalUse, int32_t handle); + Debug(const Debug& other); + Debug(Debug&& other); + virtual ~Debug(); + Debug& operator=(const Debug& other); + Debug& operator=(decltype(nullptr)); + Debug& operator=(Debug&& other); + bool operator==(const Debug& other) const; + bool operator!=(const Debug& other) const; + static void Log(System::Object& message); + }; +} + +namespace UnityEngine +{ + struct Behaviour : virtual UnityEngine::Component + { + Behaviour(decltype(nullptr)); + Behaviour(Plugin::InternalUse, int32_t handle); + Behaviour(const Behaviour& other); + Behaviour(Behaviour&& other); + virtual ~Behaviour(); + Behaviour& operator=(const Behaviour& other); + Behaviour& operator=(decltype(nullptr)); + Behaviour& operator=(Behaviour&& other); + bool operator==(const Behaviour& other) const; + bool operator!=(const Behaviour& other) const; + }; +} + +namespace UnityEngine +{ + struct MonoBehaviour : virtual UnityEngine::Behaviour + { + MonoBehaviour(decltype(nullptr)); + MonoBehaviour(Plugin::InternalUse, int32_t handle); + MonoBehaviour(const MonoBehaviour& other); + MonoBehaviour(MonoBehaviour&& other); + virtual ~MonoBehaviour(); + MonoBehaviour& operator=(const MonoBehaviour& other); + MonoBehaviour& operator=(decltype(nullptr)); + MonoBehaviour& operator=(MonoBehaviour&& other); + bool operator==(const MonoBehaviour& other) const; + bool operator!=(const MonoBehaviour& other) const; + UnityEngine::Transform GetTransform(); + }; +} + +namespace System +{ + struct Exception : virtual System::Runtime::InteropServices::_Exception, virtual System::Runtime::Serialization::ISerializable + { + Exception(decltype(nullptr)); + Exception(Plugin::InternalUse, int32_t handle); + Exception(const Exception& other); + Exception(Exception&& other); + virtual ~Exception(); + Exception& operator=(const Exception& other); + Exception& operator=(decltype(nullptr)); + Exception& operator=(Exception&& other); + bool operator==(const Exception& other) const; + bool operator!=(const Exception& other) const; + Exception(System::String& message); + }; +} + +namespace System +{ + struct SystemException : virtual System::Exception, virtual System::Runtime::InteropServices::_Exception, virtual System::Runtime::Serialization::ISerializable + { + SystemException(decltype(nullptr)); + SystemException(Plugin::InternalUse, int32_t handle); + SystemException(const SystemException& other); + SystemException(SystemException&& other); + virtual ~SystemException(); + SystemException& operator=(const SystemException& other); + SystemException& operator=(decltype(nullptr)); + SystemException& operator=(SystemException&& other); + bool operator==(const SystemException& other) const; + bool operator!=(const SystemException& other) const; + }; +} + +namespace System +{ + struct NullReferenceException : virtual System::SystemException, virtual System::Runtime::InteropServices::_Exception, virtual System::Runtime::Serialization::ISerializable + { + NullReferenceException(decltype(nullptr)); + NullReferenceException(Plugin::InternalUse, int32_t handle); + NullReferenceException(const NullReferenceException& other); + NullReferenceException(NullReferenceException&& other); + virtual ~NullReferenceException(); + NullReferenceException& operator=(const NullReferenceException& other); + NullReferenceException& operator=(decltype(nullptr)); + NullReferenceException& operator=(NullReferenceException&& other); + bool operator==(const NullReferenceException& other) const; + bool operator!=(const NullReferenceException& other) const; + }; +} + +namespace UnityEngine +{ + struct PrimitiveType + { + int32_t Value; + static const UnityEngine::PrimitiveType Sphere; + static const UnityEngine::PrimitiveType Capsule; + static const UnityEngine::PrimitiveType Cylinder; + static const UnityEngine::PrimitiveType Cube; + static const UnityEngine::PrimitiveType Plane; + static const UnityEngine::PrimitiveType Quad; + explicit PrimitiveType(int32_t value); + explicit operator int32_t() const; + bool operator==(PrimitiveType other); + bool operator!=(PrimitiveType other); + explicit operator System::Enum(); + explicit operator System::ValueType(); + explicit operator System::Object(); + explicit operator System::IComparable(); + explicit operator System::IConvertible(); + explicit operator System::IFormattable(); + }; +} + +namespace UnityEngine +{ + struct Time : virtual System::Object + { + Time(decltype(nullptr)); + Time(Plugin::InternalUse, int32_t handle); + Time(const Time& other); + Time(Time&& other); + virtual ~Time(); + Time& operator=(const Time& other); + Time& operator=(decltype(nullptr)); + Time& operator=(Time&& other); + bool operator==(const Time& other) const; + bool operator!=(const Time& other) const; + static System::Single GetDeltaTime(); + }; +} + +namespace MyGame +{ + struct AbstractBaseBallScript : virtual UnityEngine::MonoBehaviour + { + AbstractBaseBallScript(decltype(nullptr)); + AbstractBaseBallScript(Plugin::InternalUse, int32_t handle); + AbstractBaseBallScript(const AbstractBaseBallScript& other); + AbstractBaseBallScript(AbstractBaseBallScript&& other); + virtual ~AbstractBaseBallScript(); + AbstractBaseBallScript& operator=(const AbstractBaseBallScript& other); + AbstractBaseBallScript& operator=(decltype(nullptr)); + AbstractBaseBallScript& operator=(AbstractBaseBallScript&& other); + bool operator==(const AbstractBaseBallScript& other) const; + bool operator!=(const AbstractBaseBallScript& other) const; + }; +} + +namespace MyGame +{ + struct BaseBallScript : virtual MyGame::AbstractBaseBallScript + { + BaseBallScript(decltype(nullptr)); + BaseBallScript(Plugin::InternalUse, int32_t handle); + BaseBallScript(const BaseBallScript& other); + BaseBallScript(BaseBallScript&& other); + virtual ~BaseBallScript(); + BaseBallScript& operator=(const BaseBallScript& other); + BaseBallScript& operator=(decltype(nullptr)); + BaseBallScript& operator=(BaseBallScript&& other); + bool operator==(const BaseBallScript& other) const; + bool operator!=(const BaseBallScript& other) const; + int32_t CppHandle; + BaseBallScript(); + virtual void Update(); + }; +} +/*END TYPE DEFINITIONS*/ + +/*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) \ + , UnityEngine::Component(nullptr) \ + , UnityEngine::Behaviour(nullptr) \ + , UnityEngine::MonoBehaviour(nullptr) \ + , MyGame::AbstractBaseBallScript(nullptr) \ + , MyGame::BaseBallScript(iu, handle) \ + { \ + } + +#define MY_GAME_BALL_SCRIPT_DEFAULT_CONSTRUCTOR \ + BallScript(Plugin::InternalUse iu, int32_t handle) \ + : UnityEngine::Object(nullptr) \ + , UnityEngine::Component(nullptr) \ + , UnityEngine::Behaviour(nullptr) \ + , UnityEngine::MonoBehaviour(nullptr) \ + , 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*/ + +//////////////////////////////////////////////////////////////// +// Support for using IEnumerable with range for loops +//////////////////////////////////////////////////////////////// + +namespace Plugin +{ + struct EnumerableIterator + { + System::Collections::IEnumerator enumerator; + bool hasMore; + EnumerableIterator(decltype(nullptr)); + EnumerableIterator(System::Collections::IEnumerable& enumerable); + EnumerableIterator& operator++(); + bool operator!=(const EnumerableIterator& other); + System::Object operator*(); + }; +} + +namespace System +{ + namespace Collections + { + Plugin::EnumerableIterator begin(IEnumerable& enumerable); + Plugin::EnumerableIterator end(IEnumerable& enumerable); + } +} + +//////////////////////////////////////////////////////////////// +// User-defined literals for creating decimals (System.Decimal) +//////////////////////////////////////////////////////////////// + +System::Decimal operator"" _m(long double x); +System::Decimal operator"" _m(unsigned long long x); diff --git a/Unity/Assets/CppSource/NativeScript/Bindings.h.meta b/Unity/Assets/CppSource/NativeScript/Bindings.h.meta new file mode 100644 index 0000000..615fc4b --- /dev/null +++ b/Unity/Assets/CppSource/NativeScript/Bindings.h.meta @@ -0,0 +1,26 @@ +fileFormatVersion: 2 +guid: 2fa6cfa70e93c4d59a7f05e21c18d56b +timeCreated: 1525538114 +licenseType: Free +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/CppSource/iOS.cmake b/Unity/Assets/CppSource/iOS.cmake similarity index 100% rename from Unity/CppSource/iOS.cmake rename to Unity/Assets/CppSource/iOS.cmake diff --git a/Unity/Assets/CppSource/iOS.cmake.meta b/Unity/Assets/CppSource/iOS.cmake.meta new file mode 100644 index 0000000..f706a0b --- /dev/null +++ b/Unity/Assets/CppSource/iOS.cmake.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 4d9a55f92979e442396f99d94a5e9ec5 +timeCreated: 1525538114 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/Game.meta b/Unity/Assets/Game.meta new file mode 100644 index 0000000..42f3c6b --- /dev/null +++ b/Unity/Assets/Game.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: bb19f2d6c4c0e41c18cdd5ead2b97cec +folderAsset: yes +timeCreated: 1519492407 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/Game/AbstractBaseBallScript.cs b/Unity/Assets/Game/AbstractBaseBallScript.cs new file mode 100644 index 0000000..8694d19 --- /dev/null +++ b/Unity/Assets/Game/AbstractBaseBallScript.cs @@ -0,0 +1,19 @@ +using UnityEngine; + +namespace MyGame +{ + /// + /// Base class of a script used in the example code to make a "ball" bounce + /// back and forth on the screen + /// + /// + /// Jackson Dunstan, 2018, http://JacksonDunstan.com + /// + /// + /// MIT + /// + public abstract class AbstractBaseBallScript : MonoBehaviour + { + public abstract void Update(); + } +} diff --git a/Unity/Assets/Game/AbstractBaseBallScript.cs.meta b/Unity/Assets/Game/AbstractBaseBallScript.cs.meta new file mode 100644 index 0000000..0757588 --- /dev/null +++ b/Unity/Assets/Game/AbstractBaseBallScript.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 7c6c722578a90428dbeacfd4a5aaa3ae +timeCreated: 1520705999 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/NativeScript/Bindings.cs b/Unity/Assets/NativeScript/Bindings.cs index 242ca37..3ae570d 100644 --- a/Unity/Assets/NativeScript/Bindings.cs +++ b/Unity/Assets/NativeScript/Bindings.cs @@ -1,11 +1,12 @@ using AOT; using System; +using System.Collections; using System.IO; using System.Runtime.InteropServices; +using System.Collections.Generic; using UnityEngine; -using UnityEngine.Assertions; namespace NativeScript { @@ -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; } @@ -251,276 +210,129 @@ public static void Remove(int handle) } } + /// + /// A reusable version of UnityEngine.WaitForSecondsRealtime to avoid + /// GC allocs + /// + class ReusableWaitForSecondsRealtime : CustomYieldInstruction + { + private float waitTime; + + public float WaitTime + { + set + { + waitTime = Time.realtimeSinceStartup + value; + } + } + + public override bool keepWaiting + { + get + { + return Time.realtimeSinceStartup < waitTime; + } + } + + public ReusableWaitForSecondsRealtime(float time) + { + WaitTime = time; + } + } + + public enum DestroyFunction + { + /*BEGIN DESTROY FUNCTION ENUMERATORS*/ + BaseBallScript + /*END DESTROY FUNCTION ENUMERATORS*/ + } + + struct DestroyEntry + { + public DestroyFunction Function; + public int CppHandle; + + public DestroyEntry(DestroyFunction function, int cppHandle) + { + Function = function; + CppHandle = cppHandle; + } + } + // Name of the plugin when using [DllImport] - const string PluginName = "NativeScript"; +#if !UNITY_EDITOR && UNITY_IOS + const string PLUGIN_NAME = "__Internal"; +#else + const string PLUGIN_NAME = "NativeScript"; +#endif // Path to load the plugin from when running inside the editor #if UNITY_EDITOR_OSX - const string PluginPath = "/Plugins/Editor/NativeScript.bundle/Contents/MacOS/NativeScript"; + const string PLUGIN_PATH = "/Plugins/Editor/NativeScript.bundle/Contents/MacOS/NativeScript"; #elif UNITY_EDITOR_LINUX - const string PluginPath = "/Plugins/Editor/libNativeScript.so"; + const string PLUGIN_PATH = "/Plugins/Editor/libNativeScript.so"; #elif UNITY_EDITOR_WIN - const string PluginPath = "/Plugins/Editor/NativeScript.dll"; + const string PLUGIN_PATH = "/Plugins/Editor/NativeScript.dll"; + const string PLUGIN_TEMP_PATH = "/Plugins/Editor/NativeScript_temp.dll"; #endif + enum InitMode : byte + { + FirstBoot, + Reload + } + #if UNITY_EDITOR // Handle to the C++ DLL static IntPtr libraryHandle; - + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] delegate void InitDelegate( - int maxManagedObjects, - IntPtr releaseObject, - IntPtr stringNew, - IntPtr setException, - IntPtr arrayGetLength, - IntPtr arrayGetRank, - /*BEGIN INIT PARAMS*/ - IntPtr systemDiagnosticsStopwatchConstructor, - IntPtr systemDiagnosticsStopwatchPropertyGetElapsedMilliseconds, - IntPtr systemDiagnosticsStopwatchMethodStart, - IntPtr systemDiagnosticsStopwatchMethodReset, - IntPtr unityEngineObjectPropertyGetName, - IntPtr unityEngineObjectPropertySetName, - IntPtr unityEngineObjectMethodop_EqualityUnityEngineObject_UnityEngineObject, - IntPtr unityEngineObjectMethodop_ImplicitUnityEngineObject, - IntPtr unityEngineGameObjectConstructor, - IntPtr unityEngineGameObjectConstructorSystemString, - IntPtr unityEngineGameObjectPropertyGetTransform, - IntPtr unityEngineGameObjectMethodAddComponentMyGameMonoBehavioursTestScript, - IntPtr unityEngineComponentPropertyGetTransform, - IntPtr unityEngineTransformPropertyGetPosition, - IntPtr unityEngineTransformPropertySetPosition, - IntPtr unityEngineDebugMethodLogSystemObject, - IntPtr unityEngineAssertionsAssertFieldGetRaiseExceptions, - IntPtr unityEngineAssertionsAssertFieldSetRaiseExceptions, - IntPtr unityEngineAssertionsAssertMethodAreEqualSystemStringSystemString_SystemString, - IntPtr unityEngineAssertionsAssertMethodAreEqualUnityEngineGameObjectUnityEngineGameObject_UnityEngineGameObject, - IntPtr unityEngineAudioSettingsMethodGetDSPBufferSizeSystemInt32_SystemInt32, - IntPtr unityEngineNetworkingNetworkTransportMethodGetBroadcastConnectionInfoSystemInt32_SystemString_SystemInt32_SystemByte, - IntPtr unityEngineNetworkingNetworkTransportMethodInit, - IntPtr unityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingle, - IntPtr unityEngineVector3PropertyGetMagnitude, - IntPtr unityEngineVector3MethodSetSystemSingle_SystemSingle_SystemSingle, - IntPtr unityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3, - IntPtr unityEngineVector3Methodop_UnaryNegationUnityEngineVector3, - IntPtr boxVector3, - IntPtr unboxVector3, - IntPtr unityEngineMatrix4x4PropertyGetItem, - IntPtr unityEngineMatrix4x4PropertySetItem, - IntPtr boxMatrix4x4, - IntPtr unboxMatrix4x4, - IntPtr releaseUnityEngineRaycastHit, - IntPtr unityEngineRaycastHitPropertyGetPoint, - IntPtr unityEngineRaycastHitPropertySetPoint, - IntPtr unityEngineRaycastHitPropertyGetTransform, - IntPtr boxRaycastHit, - IntPtr unboxRaycastHit, - IntPtr boxQueryTriggerInteraction, - IntPtr unboxQueryTriggerInteraction, - IntPtr releaseSystemCollectionsGenericKeyValuePairSystemString_SystemDouble, - IntPtr systemCollectionsGenericKeyValuePairSystemString_SystemDoubleConstructorSystemString_SystemDouble, - IntPtr systemCollectionsGenericKeyValuePairSystemString_SystemDoublePropertyGetKey, - IntPtr systemCollectionsGenericKeyValuePairSystemString_SystemDoublePropertyGetValue, - IntPtr boxKeyValuePairSystemString_SystemDouble, - IntPtr unboxKeyValuePairSystemString_SystemDouble, - IntPtr systemCollectionsGenericListSystemStringConstructor, - IntPtr systemCollectionsGenericListSystemStringPropertyGetItem, - IntPtr systemCollectionsGenericListSystemStringPropertySetItem, - IntPtr systemCollectionsGenericListSystemStringMethodAddSystemString, - IntPtr systemCollectionsGenericLinkedListNodeSystemStringConstructorSystemString, - IntPtr systemCollectionsGenericLinkedListNodeSystemStringPropertyGetValue, - IntPtr systemCollectionsGenericLinkedListNodeSystemStringPropertySetValue, - IntPtr systemRuntimeCompilerServicesStrongBoxSystemStringConstructorSystemString, - IntPtr systemRuntimeCompilerServicesStrongBoxSystemStringFieldGetValue, - IntPtr systemRuntimeCompilerServicesStrongBoxSystemStringFieldSetValue, - IntPtr systemExceptionConstructorSystemString, - IntPtr unityEngineResolutionPropertyGetWidth, - IntPtr unityEngineResolutionPropertySetWidth, - IntPtr unityEngineResolutionPropertyGetHeight, - IntPtr unityEngineResolutionPropertySetHeight, - IntPtr unityEngineResolutionPropertyGetRefreshRate, - IntPtr unityEngineResolutionPropertySetRefreshRate, - IntPtr boxResolution, - IntPtr unboxResolution, - IntPtr unityEngineScreenPropertyGetResolutions, - IntPtr unityEngineRayConstructorUnityEngineVector3_UnityEngineVector3, - IntPtr boxRay, - IntPtr unboxRay, - IntPtr unityEnginePhysicsMethodRaycastNonAllocUnityEngineRay_UnityEngineRaycastHit, - IntPtr unityEnginePhysicsMethodRaycastAllUnityEngineRay, - IntPtr boxColor, - IntPtr unboxColor, - IntPtr boxGradientColorKey, - IntPtr unboxGradientColorKey, - IntPtr unityEngineGradientConstructor, - IntPtr unityEngineGradientPropertyGetColorKeys, - IntPtr unityEngineGradientPropertySetColorKeys, - IntPtr systemAppDomainSetupConstructor, - IntPtr systemAppDomainSetupPropertyGetAppDomainInitializer, - IntPtr systemAppDomainSetupPropertySetAppDomainInitializer, - IntPtr unityEngineApplicationAddEventOnBeforeRender, - IntPtr unityEngineApplicationRemoveEventOnBeforeRender, - IntPtr unityEngineSceneManagementSceneManagerAddEventSceneLoaded, - IntPtr unityEngineSceneManagementSceneManagerRemoveEventSceneLoaded, - IntPtr boxScene, - IntPtr unboxScene, - IntPtr boxLoadSceneMode, - IntPtr unboxLoadSceneMode, - 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, - IntPtr systemSystemInt32Array1Constructor1, - IntPtr systemInt32Array1GetItem1, - IntPtr systemInt32Array1SetItem1, - IntPtr systemSystemSingleArray1Constructor1, - IntPtr systemSingleArray1GetItem1, - IntPtr systemSingleArray1SetItem1, - IntPtr systemSystemSingleArray2Constructor2, - IntPtr systemSystemSingleArray2GetLength2, - IntPtr systemSingleArray2GetItem2, - IntPtr systemSingleArray2SetItem2, - IntPtr systemSystemSingleArray3Constructor3, - IntPtr systemSystemSingleArray3GetLength3, - IntPtr systemSingleArray3GetItem3, - IntPtr systemSingleArray3SetItem3, - IntPtr systemSystemStringArray1Constructor1, - IntPtr systemStringArray1GetItem1, - IntPtr systemStringArray1SetItem1, - IntPtr unityEngineUnityEngineResolutionArray1Constructor1, - IntPtr unityEngineResolutionArray1GetItem1, - IntPtr unityEngineResolutionArray1SetItem1, - IntPtr unityEngineUnityEngineRaycastHitArray1Constructor1, - IntPtr unityEngineRaycastHitArray1GetItem1, - IntPtr unityEngineRaycastHitArray1SetItem1, - IntPtr unityEngineUnityEngineGradientColorKeyArray1Constructor1, - IntPtr unityEngineGradientColorKeyArray1GetItem1, - IntPtr unityEngineGradientColorKeyArray1SetItem1, - IntPtr releaseSystemAction, - IntPtr systemActionConstructor, - IntPtr systemActionInvoke, - IntPtr systemActionAdd, - IntPtr systemActionRemove, - IntPtr releaseSystemActionSystemSingle, - IntPtr systemActionSystemSingleConstructor, - IntPtr systemActionSystemSingleInvoke, - IntPtr systemActionSystemSingleAdd, - IntPtr systemActionSystemSingleRemove, - IntPtr releaseSystemActionSystemSingle_SystemSingle, - IntPtr systemActionSystemSingle_SystemSingleConstructor, - IntPtr systemActionSystemSingle_SystemSingleInvoke, - IntPtr systemActionSystemSingle_SystemSingleAdd, - IntPtr systemActionSystemSingle_SystemSingleRemove, - IntPtr releaseSystemFuncSystemInt32_SystemSingle_SystemDouble, - IntPtr systemFuncSystemInt32_SystemSingle_SystemDoubleConstructor, - IntPtr systemFuncSystemInt32_SystemSingle_SystemDoubleInvoke, - IntPtr systemFuncSystemInt32_SystemSingle_SystemDoubleAdd, - IntPtr systemFuncSystemInt32_SystemSingle_SystemDoubleRemove, - IntPtr releaseSystemFuncSystemInt16_SystemInt32_SystemString, - IntPtr systemFuncSystemInt16_SystemInt32_SystemStringConstructor, - IntPtr systemFuncSystemInt16_SystemInt32_SystemStringInvoke, - IntPtr systemFuncSystemInt16_SystemInt32_SystemStringAdd, - IntPtr systemFuncSystemInt16_SystemInt32_SystemStringRemove, - IntPtr releaseSystemAppDomainInitializer, - IntPtr systemAppDomainInitializerConstructor, - IntPtr systemAppDomainInitializerInvoke, - IntPtr systemAppDomainInitializerAdd, - IntPtr systemAppDomainInitializerRemove, - IntPtr releaseUnityEngineEventsUnityAction, - IntPtr unityEngineEventsUnityActionConstructor, - IntPtr unityEngineEventsUnityActionInvoke, - IntPtr unityEngineEventsUnityActionAdd, - IntPtr unityEngineEventsUnityActionRemove, - IntPtr releaseUnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneMode, - IntPtr unityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeConstructor, - IntPtr unityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeInvoke, - IntPtr unityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeAdd, - IntPtr unityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeRemove - /*END INIT PARAMS*/); + IntPtr memory, + int memorySize, + InitMode initMode); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void SetCsharpExceptionDelegate(int handle); - /*BEGIN MONOBEHAVIOUR DELEGATES*/ - public delegate void MyGameMonoBehavioursTestScriptAwakeDelegate(int thisHandle); - public static MyGameMonoBehavioursTestScriptAwakeDelegate MyGameMonoBehavioursTestScriptAwake; - - public delegate void MyGameMonoBehavioursTestScriptOnAnimatorIKDelegate(int thisHandle, int param0); - public static MyGameMonoBehavioursTestScriptOnAnimatorIKDelegate MyGameMonoBehavioursTestScriptOnAnimatorIK; - - public delegate void MyGameMonoBehavioursTestScriptOnCollisionEnterDelegate(int thisHandle, int param0); - public static MyGameMonoBehavioursTestScriptOnCollisionEnterDelegate MyGameMonoBehavioursTestScriptOnCollisionEnter; - - public delegate void MyGameMonoBehavioursTestScriptUpdateDelegate(int thisHandle); - public static MyGameMonoBehavioursTestScriptUpdateDelegate MyGameMonoBehavioursTestScriptUpdate; - - public delegate void SystemActionCppInvokeDelegate(int thisHandle); - public static SystemActionCppInvokeDelegate SystemActionCppInvoke; - - public delegate void SystemActionSystemSingleCppInvokeDelegate(int thisHandle, float param0); - public static SystemActionSystemSingleCppInvokeDelegate SystemActionSystemSingleCppInvoke; - - public delegate void SystemActionSystemSingle_SystemSingleCppInvokeDelegate(int thisHandle, float param0, float param1); - public static SystemActionSystemSingle_SystemSingleCppInvokeDelegate SystemActionSystemSingle_SystemSingleCppInvoke; - - public delegate double SystemFuncSystemInt32_SystemSingle_SystemDoubleCppInvokeDelegate(int thisHandle, int param0, float param1); - public static SystemFuncSystemInt32_SystemSingle_SystemDoubleCppInvokeDelegate SystemFuncSystemInt32_SystemSingle_SystemDoubleCppInvoke; - - public delegate int SystemFuncSystemInt16_SystemInt32_SystemStringCppInvokeDelegate(int thisHandle, short param0, int param1); - public static SystemFuncSystemInt16_SystemInt32_SystemStringCppInvokeDelegate SystemFuncSystemInt16_SystemInt32_SystemStringCppInvoke; + /*BEGIN CPP DELEGATES*/ + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate int NewBaseBallScriptDelegateType(int param0); + public static NewBaseBallScriptDelegateType NewBaseBallScript; - public delegate void SystemAppDomainInitializerCppInvokeDelegate(int thisHandle, int param0); - public static SystemAppDomainInitializerCppInvokeDelegate SystemAppDomainInitializerCppInvoke; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate void DestroyBaseBallScriptDelegateType(int param0); + public static DestroyBaseBallScriptDelegateType DestroyBaseBallScript; - public delegate void UnityEngineEventsUnityActionCppInvokeDelegate(int thisHandle); - public static UnityEngineEventsUnityActionCppInvokeDelegate UnityEngineEventsUnityActionCppInvoke; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate void MyGameAbstractBaseBallScriptUpdateDelegateType(int thisHandle); + public static MyGameAbstractBaseBallScriptUpdateDelegateType MyGameAbstractBaseBallScriptUpdate; - public delegate void UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeCppInvokeDelegate(int thisHandle, UnityEngine.SceneManagement.Scene param0, UnityEngine.SceneManagement.LoadSceneMode param1); - public static UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeCppInvokeDelegate UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeCppInvoke; - - public delegate void SetCsharpExceptionSystemNullReferenceExceptionDelegate(int param0); - public static SetCsharpExceptionSystemNullReferenceExceptionDelegate SetCsharpExceptionSystemNullReferenceException; - /*END MONOBEHAVIOUR 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); @@ -548,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); @@ -590,674 +402,462 @@ static T GetDelegate( typeof(T)) as T; } #else - [DllImport(PluginName)] + [DllImport(PLUGIN_NAME, CallingConvention = CallingConvention.Cdecl)] static extern void Init( - int maxManagedObjects, - IntPtr releaseObject, - IntPtr stringNew, - IntPtr setException, - IntPtr arrayGetLength, - IntPtr arrayGetRank, - /*BEGIN INIT PARAMS*/ - IntPtr systemDiagnosticsStopwatchConstructor, - IntPtr systemDiagnosticsStopwatchPropertyGetElapsedMilliseconds, - IntPtr systemDiagnosticsStopwatchMethodStart, - IntPtr systemDiagnosticsStopwatchMethodReset, - IntPtr unityEngineObjectPropertyGetName, - IntPtr unityEngineObjectPropertySetName, - IntPtr unityEngineObjectMethodop_EqualityUnityEngineObject_UnityEngineObject, - IntPtr unityEngineObjectMethodop_ImplicitUnityEngineObject, - IntPtr unityEngineGameObjectConstructor, - IntPtr unityEngineGameObjectConstructorSystemString, - IntPtr unityEngineGameObjectPropertyGetTransform, - IntPtr unityEngineGameObjectMethodAddComponentMyGameMonoBehavioursTestScript, - IntPtr unityEngineComponentPropertyGetTransform, - IntPtr unityEngineTransformPropertyGetPosition, - IntPtr unityEngineTransformPropertySetPosition, - IntPtr unityEngineDebugMethodLogSystemObject, - IntPtr unityEngineAssertionsAssertFieldGetRaiseExceptions, - IntPtr unityEngineAssertionsAssertFieldSetRaiseExceptions, - IntPtr unityEngineAssertionsAssertMethodAreEqualSystemStringSystemString_SystemString, - IntPtr unityEngineAssertionsAssertMethodAreEqualUnityEngineGameObjectUnityEngineGameObject_UnityEngineGameObject, - IntPtr unityEngineAudioSettingsMethodGetDSPBufferSizeSystemInt32_SystemInt32, - IntPtr unityEngineNetworkingNetworkTransportMethodGetBroadcastConnectionInfoSystemInt32_SystemString_SystemInt32_SystemByte, - IntPtr unityEngineNetworkingNetworkTransportMethodInit, - IntPtr unityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingle, - IntPtr unityEngineVector3PropertyGetMagnitude, - IntPtr unityEngineVector3MethodSetSystemSingle_SystemSingle_SystemSingle, - IntPtr unityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3, - IntPtr unityEngineVector3Methodop_UnaryNegationUnityEngineVector3, - IntPtr boxVector3, - IntPtr unboxVector3, - IntPtr unityEngineMatrix4x4PropertyGetItem, - IntPtr unityEngineMatrix4x4PropertySetItem, - IntPtr boxMatrix4x4, - IntPtr unboxMatrix4x4, - IntPtr releaseUnityEngineRaycastHit, - IntPtr unityEngineRaycastHitPropertyGetPoint, - IntPtr unityEngineRaycastHitPropertySetPoint, - IntPtr unityEngineRaycastHitPropertyGetTransform, - IntPtr boxRaycastHit, - IntPtr unboxRaycastHit, - IntPtr boxQueryTriggerInteraction, - IntPtr unboxQueryTriggerInteraction, - IntPtr releaseSystemCollectionsGenericKeyValuePairSystemString_SystemDouble, - IntPtr systemCollectionsGenericKeyValuePairSystemString_SystemDoubleConstructorSystemString_SystemDouble, - IntPtr systemCollectionsGenericKeyValuePairSystemString_SystemDoublePropertyGetKey, - IntPtr systemCollectionsGenericKeyValuePairSystemString_SystemDoublePropertyGetValue, - IntPtr boxKeyValuePairSystemString_SystemDouble, - IntPtr unboxKeyValuePairSystemString_SystemDouble, - IntPtr systemCollectionsGenericListSystemStringConstructor, - IntPtr systemCollectionsGenericListSystemStringPropertyGetItem, - IntPtr systemCollectionsGenericListSystemStringPropertySetItem, - IntPtr systemCollectionsGenericListSystemStringMethodAddSystemString, - IntPtr systemCollectionsGenericLinkedListNodeSystemStringConstructorSystemString, - IntPtr systemCollectionsGenericLinkedListNodeSystemStringPropertyGetValue, - IntPtr systemCollectionsGenericLinkedListNodeSystemStringPropertySetValue, - IntPtr systemRuntimeCompilerServicesStrongBoxSystemStringConstructorSystemString, - IntPtr systemRuntimeCompilerServicesStrongBoxSystemStringFieldGetValue, - IntPtr systemRuntimeCompilerServicesStrongBoxSystemStringFieldSetValue, - IntPtr systemExceptionConstructorSystemString, - IntPtr unityEngineResolutionPropertyGetWidth, - IntPtr unityEngineResolutionPropertySetWidth, - IntPtr unityEngineResolutionPropertyGetHeight, - IntPtr unityEngineResolutionPropertySetHeight, - IntPtr unityEngineResolutionPropertyGetRefreshRate, - IntPtr unityEngineResolutionPropertySetRefreshRate, - IntPtr boxResolution, - IntPtr unboxResolution, - IntPtr unityEngineScreenPropertyGetResolutions, - IntPtr unityEngineRayConstructorUnityEngineVector3_UnityEngineVector3, - IntPtr boxRay, - IntPtr unboxRay, - IntPtr unityEnginePhysicsMethodRaycastNonAllocUnityEngineRay_UnityEngineRaycastHit, - IntPtr unityEnginePhysicsMethodRaycastAllUnityEngineRay, - IntPtr boxColor, - IntPtr unboxColor, - IntPtr boxGradientColorKey, - IntPtr unboxGradientColorKey, - IntPtr unityEngineGradientConstructor, - IntPtr unityEngineGradientPropertyGetColorKeys, - IntPtr unityEngineGradientPropertySetColorKeys, - IntPtr systemAppDomainSetupConstructor, - IntPtr systemAppDomainSetupPropertyGetAppDomainInitializer, - IntPtr systemAppDomainSetupPropertySetAppDomainInitializer, - IntPtr unityEngineApplicationAddEventOnBeforeRender, - IntPtr unityEngineApplicationRemoveEventOnBeforeRender, - IntPtr unityEngineSceneManagementSceneManagerAddEventSceneLoaded, - IntPtr unityEngineSceneManagementSceneManagerRemoveEventSceneLoaded, - IntPtr boxScene, - IntPtr unboxScene, - IntPtr boxLoadSceneMode, - IntPtr unboxLoadSceneMode, - 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, - IntPtr systemSystemInt32Array1Constructor1, - IntPtr systemInt32Array1GetItem1, - IntPtr systemInt32Array1SetItem1, - IntPtr systemSystemSingleArray1Constructor1, - IntPtr systemSingleArray1GetItem1, - IntPtr systemSingleArray1SetItem1, - IntPtr systemSystemSingleArray2Constructor2, - IntPtr systemSystemSingleArray2GetLength2, - IntPtr systemSingleArray2GetItem2, - IntPtr systemSingleArray2SetItem2, - IntPtr systemSystemSingleArray3Constructor3, - IntPtr systemSystemSingleArray3GetLength3, - IntPtr systemSingleArray3GetItem3, - IntPtr systemSingleArray3SetItem3, - IntPtr systemSystemStringArray1Constructor1, - IntPtr systemStringArray1GetItem1, - IntPtr systemStringArray1SetItem1, - IntPtr unityEngineUnityEngineResolutionArray1Constructor1, - IntPtr unityEngineResolutionArray1GetItem1, - IntPtr unityEngineResolutionArray1SetItem1, - IntPtr unityEngineUnityEngineRaycastHitArray1Constructor1, - IntPtr unityEngineRaycastHitArray1GetItem1, - IntPtr unityEngineRaycastHitArray1SetItem1, - IntPtr unityEngineUnityEngineGradientColorKeyArray1Constructor1, - IntPtr unityEngineGradientColorKeyArray1GetItem1, - IntPtr unityEngineGradientColorKeyArray1SetItem1, - IntPtr releaseSystemAction, - IntPtr systemActionConstructor, - IntPtr systemActionInvoke, - IntPtr systemActionAdd, - IntPtr systemActionRemove, - IntPtr releaseSystemActionSystemSingle, - IntPtr systemActionSystemSingleConstructor, - IntPtr systemActionSystemSingleInvoke, - IntPtr systemActionSystemSingleAdd, - IntPtr systemActionSystemSingleRemove, - IntPtr releaseSystemActionSystemSingle_SystemSingle, - IntPtr systemActionSystemSingle_SystemSingleConstructor, - IntPtr systemActionSystemSingle_SystemSingleInvoke, - IntPtr systemActionSystemSingle_SystemSingleAdd, - IntPtr systemActionSystemSingle_SystemSingleRemove, - IntPtr releaseSystemFuncSystemInt32_SystemSingle_SystemDouble, - IntPtr systemFuncSystemInt32_SystemSingle_SystemDoubleConstructor, - IntPtr systemFuncSystemInt32_SystemSingle_SystemDoubleInvoke, - IntPtr systemFuncSystemInt32_SystemSingle_SystemDoubleAdd, - IntPtr systemFuncSystemInt32_SystemSingle_SystemDoubleRemove, - IntPtr releaseSystemFuncSystemInt16_SystemInt32_SystemString, - IntPtr systemFuncSystemInt16_SystemInt32_SystemStringConstructor, - IntPtr systemFuncSystemInt16_SystemInt32_SystemStringInvoke, - IntPtr systemFuncSystemInt16_SystemInt32_SystemStringAdd, - IntPtr systemFuncSystemInt16_SystemInt32_SystemStringRemove, - IntPtr releaseSystemAppDomainInitializer, - IntPtr systemAppDomainInitializerConstructor, - IntPtr systemAppDomainInitializerInvoke, - IntPtr systemAppDomainInitializerAdd, - IntPtr systemAppDomainInitializerRemove, - IntPtr releaseUnityEngineEventsUnityAction, - IntPtr unityEngineEventsUnityActionConstructor, - IntPtr unityEngineEventsUnityActionInvoke, - IntPtr unityEngineEventsUnityActionAdd, - IntPtr unityEngineEventsUnityActionRemove, - IntPtr releaseUnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneMode, - IntPtr unityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeConstructor, - IntPtr unityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeInvoke, - IntPtr unityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeAdd, - IntPtr unityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeRemove - /*END INIT PARAMS*/); + IntPtr memory, + int memorySize, + InitMode initMode); - [DllImport(PluginName)] + [DllImport(PLUGIN_NAME, CallingConvention = CallingConvention.Cdecl)] static extern void SetCsharpException(int handle); - /*BEGIN MONOBEHAVIOUR IMPORTS*/ - [DllImport(Constants.PluginName)] - public static extern void MyGameMonoBehavioursTestScriptAwake(int thisHandle); - - [DllImport(Constants.PluginName)] - public static extern void MyGameMonoBehavioursTestScriptOnAnimatorIK(int thisHandle, int param0); - - [DllImport(Constants.PluginName)] - public static extern void MyGameMonoBehavioursTestScriptOnCollisionEnter(int thisHandle, int param0); - - [DllImport(Constants.PluginName)] - public static extern void MyGameMonoBehavioursTestScriptUpdate(int thisHandle); + /*BEGIN IMPORTS*/ + [DllImport(PLUGIN_NAME, CallingConvention = CallingConvention.Cdecl)] + public static extern int NewBaseBallScript(int thisHandle); - [DllImport(Constants.PluginName)] - public static extern void SystemActionCppInvoke(int thisHandle); + [DllImport(PLUGIN_NAME, CallingConvention = CallingConvention.Cdecl)] + public static extern void DestroyBaseBallScript(int thisHandle); - [DllImport(Constants.PluginName)] - public static extern void SystemActionSystemSingleCppInvoke(int thisHandle, int param0); + [DllImport(PLUGIN_NAME, CallingConvention = CallingConvention.Cdecl)] + public static extern void MyGameAbstractBaseBallScriptUpdate(int thisHandle); - [DllImport(Constants.PluginName)] - public static extern void SystemActionSystemSingle_SystemSingleCppInvoke(int thisHandle, int param0, int param1); - - [DllImport(Constants.PluginName)] - public static extern void SystemFuncSystemInt32_SystemSingle_SystemDoubleCppInvoke(int thisHandle, int param0, int param1); - - [DllImport(Constants.PluginName)] - public static extern void SystemFuncSystemInt16_SystemInt32_SystemStringCppInvoke(int thisHandle, int param0, int param1); + [DllImport(PLUGIN_NAME, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetCsharpExceptionSystemNullReferenceException(int thisHandle); + /*END IMPORTS*/ +#endif - [DllImport(Constants.PluginName)] - public static extern void SystemAppDomainInitializerCppInvoke(int thisHandle, int param0); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate void ReleaseObjectDelegateType(int handle); - [DllImport(Constants.PluginName)] - public static extern void UnityEngineEventsUnityActionCppInvoke(int thisHandle); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate int StringNewDelegateType(string chars); - [DllImport(Constants.PluginName)] - public static extern void UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeCppInvoke(int thisHandle, UnityEngine.SceneManagement.Scene param0, int param1); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate void SetExceptionDelegateType(int handle); - [DllImport(Constants.PluginName)] - public static extern void SetCsharpExceptionSystemNullReferenceException(int thisHandle, int param0); - /*END MONOBEHAVIOUR IMPORTS*/ -#endif + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate int ArrayGetLengthDelegateType(int handle); - delegate void ReleaseObjectDelegate(int handle); - delegate int StringNewDelegate(string chars); - delegate void SetExceptionDelegate(int handle); - delegate int ArrayGetLengthDelegate(int handle); - delegate int ArrayGetRankDelegate(int handle); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate int EnumerableGetEnumeratorDelegateType(int handle); /*BEGIN DELEGATE TYPES*/ - delegate int SystemDiagnosticsStopwatchConstructorDelegate(); - delegate long SystemDiagnosticsStopwatchPropertyGetElapsedMillisecondsDelegate(int thisHandle); - delegate void SystemDiagnosticsStopwatchMethodStartDelegate(int thisHandle); - delegate void SystemDiagnosticsStopwatchMethodResetDelegate(int thisHandle); - delegate int UnityEngineObjectPropertyGetNameDelegate(int thisHandle); - delegate void UnityEngineObjectPropertySetNameDelegate(int thisHandle, int valueHandle); - delegate bool UnityEngineObjectMethodop_EqualityUnityEngineObject_UnityEngineObjectDelegate(int xHandle, int yHandle); - delegate bool UnityEngineObjectMethodop_ImplicitUnityEngineObjectDelegate(int existsHandle); - delegate int UnityEngineGameObjectConstructorDelegate(); - delegate int UnityEngineGameObjectConstructorSystemStringDelegate(int nameHandle); - delegate int UnityEngineGameObjectPropertyGetTransformDelegate(int thisHandle); - delegate int UnityEngineGameObjectMethodAddComponentMyGameMonoBehavioursTestScriptDelegate(int thisHandle); - delegate int UnityEngineComponentPropertyGetTransformDelegate(int thisHandle); - delegate UnityEngine.Vector3 UnityEngineTransformPropertyGetPositionDelegate(int thisHandle); - delegate void UnityEngineTransformPropertySetPositionDelegate(int thisHandle, ref UnityEngine.Vector3 value); - delegate void UnityEngineDebugMethodLogSystemObjectDelegate(int messageHandle); - delegate bool UnityEngineAssertionsAssertFieldGetRaiseExceptionsDelegate(); - delegate void UnityEngineAssertionsAssertFieldSetRaiseExceptionsDelegate(bool value); - delegate void UnityEngineAssertionsAssertMethodAreEqualSystemStringSystemString_SystemStringDelegate(int expectedHandle, int actualHandle); - delegate void UnityEngineAssertionsAssertMethodAreEqualUnityEngineGameObjectUnityEngineGameObject_UnityEngineGameObjectDelegate(int expectedHandle, int actualHandle); - delegate void UnityEngineAudioSettingsMethodGetDSPBufferSizeSystemInt32_SystemInt32Delegate(ref int bufferLength, ref int numBuffers); - delegate void UnityEngineNetworkingNetworkTransportMethodGetBroadcastConnectionInfoSystemInt32_SystemString_SystemInt32_SystemByteDelegate(int hostId, ref int addressHandle, ref int port, ref byte error); - delegate void UnityEngineNetworkingNetworkTransportMethodInitDelegate(); - delegate UnityEngine.Vector3 UnityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingleDelegate(float x, float y, float z); - delegate float UnityEngineVector3PropertyGetMagnitudeDelegate(ref UnityEngine.Vector3 thiz); - delegate void UnityEngineVector3MethodSetSystemSingle_SystemSingle_SystemSingleDelegate(ref UnityEngine.Vector3 thiz, float newX, float newY, float newZ); - delegate UnityEngine.Vector3 UnityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3Delegate(ref UnityEngine.Vector3 a, ref UnityEngine.Vector3 b); - delegate UnityEngine.Vector3 UnityEngineVector3Methodop_UnaryNegationUnityEngineVector3Delegate(ref UnityEngine.Vector3 a); - delegate int BoxVector3Delegate(ref UnityEngine.Vector3 val); - delegate UnityEngine.Vector3 UnboxVector3Delegate(int valHandle); - delegate float UnityEngineMatrix4x4PropertyGetItemDelegate(ref UnityEngine.Matrix4x4 thiz, int row, int column); - delegate void UnityEngineMatrix4x4PropertySetItemDelegate(ref UnityEngine.Matrix4x4 thiz, int row, int column, float value); - delegate int BoxMatrix4x4Delegate(ref UnityEngine.Matrix4x4 val); - delegate UnityEngine.Matrix4x4 UnboxMatrix4x4Delegate(int valHandle); - delegate void ReleaseUnityEngineRaycastHitDelegate(int handle); - delegate UnityEngine.Vector3 UnityEngineRaycastHitPropertyGetPointDelegate(int thisHandle); - delegate void UnityEngineRaycastHitPropertySetPointDelegate(int thisHandle, ref UnityEngine.Vector3 value); - delegate int UnityEngineRaycastHitPropertyGetTransformDelegate(int thisHandle); - delegate int BoxRaycastHitDelegate(int valHandle); - delegate int UnboxRaycastHitDelegate(int valHandle); - delegate int BoxQueryTriggerInteractionDelegate(UnityEngine.QueryTriggerInteraction val); - delegate UnityEngine.QueryTriggerInteraction UnboxQueryTriggerInteractionDelegate(int valHandle); - delegate void ReleaseSystemCollectionsGenericKeyValuePairSystemString_SystemDoubleDelegate(int handle); - delegate int SystemCollectionsGenericKeyValuePairSystemString_SystemDoubleConstructorSystemString_SystemDoubleDelegate(int keyHandle, double value); - delegate int SystemCollectionsGenericKeyValuePairSystemString_SystemDoublePropertyGetKeyDelegate(int thisHandle); - delegate double SystemCollectionsGenericKeyValuePairSystemString_SystemDoublePropertyGetValueDelegate(int thisHandle); - delegate int BoxKeyValuePairSystemString_SystemDoubleDelegate(int valHandle); - delegate int UnboxKeyValuePairSystemString_SystemDoubleDelegate(int valHandle); - delegate int SystemCollectionsGenericListSystemStringConstructorDelegate(); - delegate int SystemCollectionsGenericListSystemStringPropertyGetItemDelegate(int thisHandle, int index); - delegate void SystemCollectionsGenericListSystemStringPropertySetItemDelegate(int thisHandle, int index, int valueHandle); - delegate void SystemCollectionsGenericListSystemStringMethodAddSystemStringDelegate(int thisHandle, int itemHandle); - delegate int SystemCollectionsGenericLinkedListNodeSystemStringConstructorSystemStringDelegate(int valueHandle); - delegate int SystemCollectionsGenericLinkedListNodeSystemStringPropertyGetValueDelegate(int thisHandle); - delegate void SystemCollectionsGenericLinkedListNodeSystemStringPropertySetValueDelegate(int thisHandle, int valueHandle); - delegate int SystemRuntimeCompilerServicesStrongBoxSystemStringConstructorSystemStringDelegate(int valueHandle); - delegate int SystemRuntimeCompilerServicesStrongBoxSystemStringFieldGetValueDelegate(int thisHandle); - delegate void SystemRuntimeCompilerServicesStrongBoxSystemStringFieldSetValueDelegate(int thisHandle, int valueHandle); - delegate int SystemExceptionConstructorSystemStringDelegate(int messageHandle); - delegate int UnityEngineResolutionPropertyGetWidthDelegate(ref UnityEngine.Resolution thiz); - delegate void UnityEngineResolutionPropertySetWidthDelegate(ref UnityEngine.Resolution thiz, int value); - delegate int UnityEngineResolutionPropertyGetHeightDelegate(ref UnityEngine.Resolution thiz); - delegate void UnityEngineResolutionPropertySetHeightDelegate(ref UnityEngine.Resolution thiz, int value); - delegate int UnityEngineResolutionPropertyGetRefreshRateDelegate(ref UnityEngine.Resolution thiz); - delegate void UnityEngineResolutionPropertySetRefreshRateDelegate(ref UnityEngine.Resolution thiz, int value); - delegate int BoxResolutionDelegate(ref UnityEngine.Resolution val); - delegate UnityEngine.Resolution UnboxResolutionDelegate(int valHandle); - delegate int UnityEngineScreenPropertyGetResolutionsDelegate(); - delegate UnityEngine.Ray UnityEngineRayConstructorUnityEngineVector3_UnityEngineVector3Delegate(ref UnityEngine.Vector3 origin, ref UnityEngine.Vector3 direction); - delegate int BoxRayDelegate(ref UnityEngine.Ray val); - delegate UnityEngine.Ray UnboxRayDelegate(int valHandle); - delegate int UnityEnginePhysicsMethodRaycastNonAllocUnityEngineRay_UnityEngineRaycastHitDelegate(ref UnityEngine.Ray ray, int resultsHandle); - delegate int UnityEnginePhysicsMethodRaycastAllUnityEngineRayDelegate(ref UnityEngine.Ray ray); - delegate int BoxColorDelegate(ref UnityEngine.Color val); - delegate UnityEngine.Color UnboxColorDelegate(int valHandle); - delegate int BoxGradientColorKeyDelegate(ref UnityEngine.GradientColorKey val); - delegate UnityEngine.GradientColorKey UnboxGradientColorKeyDelegate(int valHandle); - delegate int UnityEngineGradientConstructorDelegate(); - delegate int UnityEngineGradientPropertyGetColorKeysDelegate(int thisHandle); - delegate void UnityEngineGradientPropertySetColorKeysDelegate(int thisHandle, int valueHandle); - delegate int SystemAppDomainSetupConstructorDelegate(); - delegate int SystemAppDomainSetupPropertyGetAppDomainInitializerDelegate(int thisHandle); - delegate void SystemAppDomainSetupPropertySetAppDomainInitializerDelegate(int thisHandle, int valueHandle); - delegate void UnityEngineApplicationAddEventOnBeforeRenderDelegate(int delHandle); - delegate void UnityEngineApplicationRemoveEventOnBeforeRenderDelegate(int delHandle); - delegate void UnityEngineSceneManagementSceneManagerAddEventSceneLoadedDelegate(int delHandle); - delegate void UnityEngineSceneManagementSceneManagerRemoveEventSceneLoadedDelegate(int delHandle); - delegate int BoxSceneDelegate(ref UnityEngine.SceneManagement.Scene val); - delegate UnityEngine.SceneManagement.Scene UnboxSceneDelegate(int valHandle); - delegate int BoxLoadSceneModeDelegate(UnityEngine.SceneManagement.LoadSceneMode val); - delegate UnityEngine.SceneManagement.LoadSceneMode UnboxLoadSceneModeDelegate(int valHandle); - 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); - delegate int SystemSystemInt32Array1Constructor1Delegate(int length0); - delegate int SystemInt32Array1GetItem1Delegate(int thisHandle, int index0); - delegate void SystemInt32Array1SetItem1Delegate(int thisHandle, int index0, int item); - delegate int SystemSystemSingleArray1Constructor1Delegate(int length0); - delegate float SystemSingleArray1GetItem1Delegate(int thisHandle, int index0); - delegate void SystemSingleArray1SetItem1Delegate(int thisHandle, int index0, float item); - delegate int SystemSystemSingleArray2Constructor2Delegate(int length0, int length1); - delegate int SystemSystemSingleArray2GetLength2Delegate(int thisHandle, int dimension); - delegate float SystemSingleArray2GetItem2Delegate(int thisHandle, int index0, int index1); - delegate void SystemSingleArray2SetItem2Delegate(int thisHandle, int index0, int index1, float item); - delegate int SystemSystemSingleArray3Constructor3Delegate(int length0, int length1, int length2); - delegate int SystemSystemSingleArray3GetLength3Delegate(int thisHandle, int dimension); - delegate float SystemSingleArray3GetItem3Delegate(int thisHandle, int index0, int index1, int index2); - delegate void SystemSingleArray3SetItem3Delegate(int thisHandle, int index0, int index1, int index2, float item); - delegate int SystemSystemStringArray1Constructor1Delegate(int length0); - delegate int SystemStringArray1GetItem1Delegate(int thisHandle, int index0); - delegate void SystemStringArray1SetItem1Delegate(int thisHandle, int index0, int itemHandle); - delegate int UnityEngineUnityEngineResolutionArray1Constructor1Delegate(int length0); - delegate UnityEngine.Resolution UnityEngineResolutionArray1GetItem1Delegate(int thisHandle, int index0); - delegate void UnityEngineResolutionArray1SetItem1Delegate(int thisHandle, int index0, ref UnityEngine.Resolution item); - delegate int UnityEngineUnityEngineRaycastHitArray1Constructor1Delegate(int length0); - delegate int UnityEngineRaycastHitArray1GetItem1Delegate(int thisHandle, int index0); - delegate void UnityEngineRaycastHitArray1SetItem1Delegate(int thisHandle, int index0, int itemHandle); - delegate int UnityEngineUnityEngineGradientColorKeyArray1Constructor1Delegate(int length0); - delegate UnityEngine.GradientColorKey UnityEngineGradientColorKeyArray1GetItem1Delegate(int thisHandle, int index0); - delegate void UnityEngineGradientColorKeyArray1SetItem1Delegate(int thisHandle, int index0, ref UnityEngine.GradientColorKey item); - delegate void SystemActionConstructorDelegate(int cppHandle, ref int handle, ref int classHandle); - delegate void ReleaseSystemActionDelegate(int handle, int classHandle); - delegate void SystemActionInvokeDelegate(int thisHandle); - delegate void SystemActionAddDelegate(int thisHandle, int delHandle); - delegate void SystemActionRemoveDelegate(int thisHandle, int delHandle); - delegate void SystemActionSystemSingleConstructorDelegate(int cppHandle, ref int handle, ref int classHandle); - delegate void ReleaseSystemActionSystemSingleDelegate(int handle, int classHandle); - delegate void SystemActionSystemSingleInvokeDelegate(int thisHandle, float obj); - delegate void SystemActionSystemSingleAddDelegate(int thisHandle, int delHandle); - delegate void SystemActionSystemSingleRemoveDelegate(int thisHandle, int delHandle); - delegate void SystemActionSystemSingle_SystemSingleConstructorDelegate(int cppHandle, ref int handle, ref int classHandle); - delegate void ReleaseSystemActionSystemSingle_SystemSingleDelegate(int handle, int classHandle); - delegate void SystemActionSystemSingle_SystemSingleInvokeDelegate(int thisHandle, float arg1, float arg2); - delegate void SystemActionSystemSingle_SystemSingleAddDelegate(int thisHandle, int delHandle); - delegate void SystemActionSystemSingle_SystemSingleRemoveDelegate(int thisHandle, int delHandle); - delegate void SystemFuncSystemInt32_SystemSingle_SystemDoubleConstructorDelegate(int cppHandle, ref int handle, ref int classHandle); - delegate void ReleaseSystemFuncSystemInt32_SystemSingle_SystemDoubleDelegate(int handle, int classHandle); - delegate double SystemFuncSystemInt32_SystemSingle_SystemDoubleInvokeDelegate(int thisHandle, int arg1, float arg2); - delegate void SystemFuncSystemInt32_SystemSingle_SystemDoubleAddDelegate(int thisHandle, int delHandle); - delegate void SystemFuncSystemInt32_SystemSingle_SystemDoubleRemoveDelegate(int thisHandle, int delHandle); - delegate void SystemFuncSystemInt16_SystemInt32_SystemStringConstructorDelegate(int cppHandle, ref int handle, ref int classHandle); - delegate void ReleaseSystemFuncSystemInt16_SystemInt32_SystemStringDelegate(int handle, int classHandle); - delegate int SystemFuncSystemInt16_SystemInt32_SystemStringInvokeDelegate(int thisHandle, short arg1, int arg2); - delegate void SystemFuncSystemInt16_SystemInt32_SystemStringAddDelegate(int thisHandle, int delHandle); - delegate void SystemFuncSystemInt16_SystemInt32_SystemStringRemoveDelegate(int thisHandle, int delHandle); - delegate void SystemAppDomainInitializerConstructorDelegate(int cppHandle, ref int handle, ref int classHandle); - delegate void ReleaseSystemAppDomainInitializerDelegate(int handle, int classHandle); - delegate void SystemAppDomainInitializerInvokeDelegate(int thisHandle, int argsHandle); - delegate void SystemAppDomainInitializerAddDelegate(int thisHandle, int delHandle); - delegate void SystemAppDomainInitializerRemoveDelegate(int thisHandle, int delHandle); - delegate void UnityEngineEventsUnityActionConstructorDelegate(int cppHandle, ref int handle, ref int classHandle); - delegate void ReleaseUnityEngineEventsUnityActionDelegate(int handle, int classHandle); - delegate void UnityEngineEventsUnityActionInvokeDelegate(int thisHandle); - delegate void UnityEngineEventsUnityActionAddDelegate(int thisHandle, int delHandle); - delegate void UnityEngineEventsUnityActionRemoveDelegate(int thisHandle, int delHandle); - delegate void UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeConstructorDelegate(int cppHandle, ref int handle, ref int classHandle); - delegate void ReleaseUnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeDelegate(int handle, int classHandle); - delegate void UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeInvokeDelegate(int thisHandle, ref UnityEngine.SceneManagement.Scene arg0, UnityEngine.SceneManagement.LoadSceneMode arg1); - delegate void UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeAddDelegate(int thisHandle, int delHandle); - delegate void UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeRemoveDelegate(int thisHandle, int delHandle); + [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 + private static readonly string pluginTempPath = Application.dataPath + PLUGIN_TEMP_PATH; +#endif public static Exception UnhandledCppException; +#if UNITY_EDITOR + private static readonly string pluginPath = Application.dataPath + PLUGIN_PATH; public static SetCsharpExceptionDelegate SetCsharpException; +#endif + static IntPtr memory; + static int memorySize; + static DestroyEntry[] destroyQueue; + static int destroyQueueCount; + 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() /// /// - /// - /// Maximum number of simultaneous managed objects that the C++ plugin - /// uses. + /// + /// Number of bytes of memory to make available to the C++ plugin /// - public static void Open( - int maxManagedObjects) + public static void Open(int memorySize) + { + /*BEGIN STORE INIT CALLS*/ + NativeScript.Bindings.ObjectStore.Init(1000); + NativeScript.Bindings.StructStore.Init(1000); + /*END STORE INIT CALLS*/ + + // Allocate unmanaged memory + Bindings.memorySize = memorySize; + memory = Marshal.AllocHGlobal(memorySize); + + // Allocate destroy queue + destroyQueueCapacity = 128; + destroyQueue = new DestroyEntry[destroyQueueCapacity]; + destroyQueueLockObj = new object(); + + OpenPlugin(InitMode.FirstBoot); + } + + // Reloading requires dynamic loading of the C++ plugin, which is only + // available in the editor +#if UNITY_EDITOR + /// + /// Reload the C++ plugin. Its memory is intact and false is passed for + /// the isFirstBoot parameter of PluginMain(). + /// + public static void Reload() { - ObjectStore.Init(maxManagedObjects); - /*BEGIN STRUCTSTORE INIT CALLS*/ - NativeScript.Bindings.StructStore.Init(1000); - NativeScript.Bindings.StructStore>.Init(maxManagedObjects); - /*END STRUCTSTORE INIT CALLS*/ + DestroyAll(); + ClosePlugin(); + OpenPlugin(InitMode.Reload); + } + + /// + /// Poll the plugin for changes and reload if any are found. + /// + /// + /// + /// Number of seconds between polls. + /// + /// + /// + /// Enumerator for this iterator function. Can be passed to + /// MonoBehaviour.StartCoroutine for easy usage. + /// + public static IEnumerator AutoReload(float pollTime) + { + // Get the original time + long lastWriteTime = File.GetLastWriteTime(pluginPath).Ticks; + ReusableWaitForSecondsRealtime poll + = new ReusableWaitForSecondsRealtime(pollTime); + do + { + // Poll. Reload if the last write time changed. + long cur = File.GetLastWriteTime(pluginPath).Ticks; + if (cur != lastWriteTime) + { + lastWriteTime = cur; + Reload(); + } + + // Wait to poll again + poll.WaitTime = pollTime; + yield return poll; + } + while (true); + } +#endif + + private static void OpenPlugin(InitMode initMode) + { #if UNITY_EDITOR - + string loadPath; +#if UNITY_EDITOR_WIN + // Copy native library to temporary file + File.Copy(pluginPath, pluginTempPath, true); + loadPath = pluginTempPath; +#else + loadPath = pluginPath; +#endif // Open native library - libraryHandle = OpenLibrary( - Application.dataPath + PluginPath); + libraryHandle = OpenLibrary(loadPath); InitDelegate Init = GetDelegate( libraryHandle, "Init"); SetCsharpException = GetDelegate( libraryHandle, "SetCsharpException"); - /*BEGIN MONOBEHAVIOUR GETDELEGATE CALLS*/ - MyGameMonoBehavioursTestScriptAwake = GetDelegate(libraryHandle, "MyGameMonoBehavioursTestScriptAwake"); - MyGameMonoBehavioursTestScriptOnAnimatorIK = GetDelegate(libraryHandle, "MyGameMonoBehavioursTestScriptOnAnimatorIK"); - MyGameMonoBehavioursTestScriptOnCollisionEnter = GetDelegate(libraryHandle, "MyGameMonoBehavioursTestScriptOnCollisionEnter"); - MyGameMonoBehavioursTestScriptUpdate = GetDelegate(libraryHandle, "MyGameMonoBehavioursTestScriptUpdate"); - SystemActionCppInvoke = GetDelegate(libraryHandle, "SystemActionCppInvoke"); - SystemActionSystemSingleCppInvoke = GetDelegate(libraryHandle, "SystemActionSystemSingleCppInvoke"); - SystemActionSystemSingle_SystemSingleCppInvoke = GetDelegate(libraryHandle, "SystemActionSystemSingle_SystemSingleCppInvoke"); - SystemFuncSystemInt32_SystemSingle_SystemDoubleCppInvoke = GetDelegate(libraryHandle, "SystemFuncSystemInt32_SystemSingle_SystemDoubleCppInvoke"); - SystemFuncSystemInt16_SystemInt32_SystemStringCppInvoke = GetDelegate(libraryHandle, "SystemFuncSystemInt16_SystemInt32_SystemStringCppInvoke"); - SystemAppDomainInitializerCppInvoke = GetDelegate(libraryHandle, "SystemAppDomainInitializerCppInvoke"); - UnityEngineEventsUnityActionCppInvoke = GetDelegate(libraryHandle, "UnityEngineEventsUnityActionCppInvoke"); - UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeCppInvoke = GetDelegate(libraryHandle, "UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeCppInvoke"); - SetCsharpExceptionSystemNullReferenceException = GetDelegate(libraryHandle, "SetCsharpExceptionSystemNullReferenceException"); - /*END MONOBEHAVIOUR GETDELEGATE CALLS*/ - + /*BEGIN GETDELEGATE CALLS*/ + NewBaseBallScript = GetDelegate(libraryHandle, "NewBaseBallScript"); + DestroyBaseBallScript = GetDelegate(libraryHandle, "DestroyBaseBallScript"); + MyGameAbstractBaseBallScriptUpdate = GetDelegate(libraryHandle, "MyGameAbstractBaseBallScriptUpdate"); + SetCsharpExceptionSystemNullReferenceException = GetDelegate(libraryHandle, "SetCsharpExceptionSystemNullReferenceException"); + /*END GETDELEGATE CALLS*/ #endif + // 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, + 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( - maxManagedObjects, - Marshal.GetFunctionPointerForDelegate(new ReleaseObjectDelegate(ReleaseObject)), - Marshal.GetFunctionPointerForDelegate(new StringNewDelegate(StringNew)), - Marshal.GetFunctionPointerForDelegate(new SetExceptionDelegate(SetException)), - Marshal.GetFunctionPointerForDelegate(new ArrayGetLengthDelegate(ArrayGetLength)), - Marshal.GetFunctionPointerForDelegate(new ArrayGetRankDelegate(ArrayGetRank)), - /*BEGIN INIT CALL*/ - Marshal.GetFunctionPointerForDelegate(new SystemDiagnosticsStopwatchConstructorDelegate(SystemDiagnosticsStopwatchConstructor)), - Marshal.GetFunctionPointerForDelegate(new SystemDiagnosticsStopwatchPropertyGetElapsedMillisecondsDelegate(SystemDiagnosticsStopwatchPropertyGetElapsedMilliseconds)), - Marshal.GetFunctionPointerForDelegate(new SystemDiagnosticsStopwatchMethodStartDelegate(SystemDiagnosticsStopwatchMethodStart)), - Marshal.GetFunctionPointerForDelegate(new SystemDiagnosticsStopwatchMethodResetDelegate(SystemDiagnosticsStopwatchMethodReset)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineObjectPropertyGetNameDelegate(UnityEngineObjectPropertyGetName)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineObjectPropertySetNameDelegate(UnityEngineObjectPropertySetName)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineObjectMethodop_EqualityUnityEngineObject_UnityEngineObjectDelegate(UnityEngineObjectMethodop_EqualityUnityEngineObject_UnityEngineObject)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineObjectMethodop_ImplicitUnityEngineObjectDelegate(UnityEngineObjectMethodop_ImplicitUnityEngineObject)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineGameObjectConstructorDelegate(UnityEngineGameObjectConstructor)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineGameObjectConstructorSystemStringDelegate(UnityEngineGameObjectConstructorSystemString)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineGameObjectPropertyGetTransformDelegate(UnityEngineGameObjectPropertyGetTransform)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineGameObjectMethodAddComponentMyGameMonoBehavioursTestScriptDelegate(UnityEngineGameObjectMethodAddComponentMyGameMonoBehavioursTestScript)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineComponentPropertyGetTransformDelegate(UnityEngineComponentPropertyGetTransform)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineTransformPropertyGetPositionDelegate(UnityEngineTransformPropertyGetPosition)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineTransformPropertySetPositionDelegate(UnityEngineTransformPropertySetPosition)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineDebugMethodLogSystemObjectDelegate(UnityEngineDebugMethodLogSystemObject)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineAssertionsAssertFieldGetRaiseExceptionsDelegate(UnityEngineAssertionsAssertFieldGetRaiseExceptions)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineAssertionsAssertFieldSetRaiseExceptionsDelegate(UnityEngineAssertionsAssertFieldSetRaiseExceptions)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineAssertionsAssertMethodAreEqualSystemStringSystemString_SystemStringDelegate(UnityEngineAssertionsAssertMethodAreEqualSystemStringSystemString_SystemString)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineAssertionsAssertMethodAreEqualUnityEngineGameObjectUnityEngineGameObject_UnityEngineGameObjectDelegate(UnityEngineAssertionsAssertMethodAreEqualUnityEngineGameObjectUnityEngineGameObject_UnityEngineGameObject)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineAudioSettingsMethodGetDSPBufferSizeSystemInt32_SystemInt32Delegate(UnityEngineAudioSettingsMethodGetDSPBufferSizeSystemInt32_SystemInt32)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineNetworkingNetworkTransportMethodGetBroadcastConnectionInfoSystemInt32_SystemString_SystemInt32_SystemByteDelegate(UnityEngineNetworkingNetworkTransportMethodGetBroadcastConnectionInfoSystemInt32_SystemString_SystemInt32_SystemByte)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineNetworkingNetworkTransportMethodInitDelegate(UnityEngineNetworkingNetworkTransportMethodInit)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingleDelegate(UnityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingle)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineVector3PropertyGetMagnitudeDelegate(UnityEngineVector3PropertyGetMagnitude)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineVector3MethodSetSystemSingle_SystemSingle_SystemSingleDelegate(UnityEngineVector3MethodSetSystemSingle_SystemSingle_SystemSingle)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3Delegate(UnityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineVector3Methodop_UnaryNegationUnityEngineVector3Delegate(UnityEngineVector3Methodop_UnaryNegationUnityEngineVector3)), - Marshal.GetFunctionPointerForDelegate(new BoxVector3Delegate(BoxVector3)), - Marshal.GetFunctionPointerForDelegate(new UnboxVector3Delegate(UnboxVector3)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineMatrix4x4PropertyGetItemDelegate(UnityEngineMatrix4x4PropertyGetItem)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineMatrix4x4PropertySetItemDelegate(UnityEngineMatrix4x4PropertySetItem)), - Marshal.GetFunctionPointerForDelegate(new BoxMatrix4x4Delegate(BoxMatrix4x4)), - Marshal.GetFunctionPointerForDelegate(new UnboxMatrix4x4Delegate(UnboxMatrix4x4)), - Marshal.GetFunctionPointerForDelegate(new ReleaseUnityEngineRaycastHitDelegate(ReleaseUnityEngineRaycastHit)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineRaycastHitPropertyGetPointDelegate(UnityEngineRaycastHitPropertyGetPoint)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineRaycastHitPropertySetPointDelegate(UnityEngineRaycastHitPropertySetPoint)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineRaycastHitPropertyGetTransformDelegate(UnityEngineRaycastHitPropertyGetTransform)), - Marshal.GetFunctionPointerForDelegate(new BoxRaycastHitDelegate(BoxRaycastHit)), - Marshal.GetFunctionPointerForDelegate(new UnboxRaycastHitDelegate(UnboxRaycastHit)), - Marshal.GetFunctionPointerForDelegate(new BoxQueryTriggerInteractionDelegate(BoxQueryTriggerInteraction)), - Marshal.GetFunctionPointerForDelegate(new UnboxQueryTriggerInteractionDelegate(UnboxQueryTriggerInteraction)), - Marshal.GetFunctionPointerForDelegate(new ReleaseSystemCollectionsGenericKeyValuePairSystemString_SystemDoubleDelegate(ReleaseSystemCollectionsGenericKeyValuePairSystemString_SystemDouble)), - Marshal.GetFunctionPointerForDelegate(new SystemCollectionsGenericKeyValuePairSystemString_SystemDoubleConstructorSystemString_SystemDoubleDelegate(SystemCollectionsGenericKeyValuePairSystemString_SystemDoubleConstructorSystemString_SystemDouble)), - Marshal.GetFunctionPointerForDelegate(new SystemCollectionsGenericKeyValuePairSystemString_SystemDoublePropertyGetKeyDelegate(SystemCollectionsGenericKeyValuePairSystemString_SystemDoublePropertyGetKey)), - Marshal.GetFunctionPointerForDelegate(new SystemCollectionsGenericKeyValuePairSystemString_SystemDoublePropertyGetValueDelegate(SystemCollectionsGenericKeyValuePairSystemString_SystemDoublePropertyGetValue)), - Marshal.GetFunctionPointerForDelegate(new BoxKeyValuePairSystemString_SystemDoubleDelegate(BoxKeyValuePairSystemString_SystemDouble)), - Marshal.GetFunctionPointerForDelegate(new UnboxKeyValuePairSystemString_SystemDoubleDelegate(UnboxKeyValuePairSystemString_SystemDouble)), - Marshal.GetFunctionPointerForDelegate(new SystemCollectionsGenericListSystemStringConstructorDelegate(SystemCollectionsGenericListSystemStringConstructor)), - Marshal.GetFunctionPointerForDelegate(new SystemCollectionsGenericListSystemStringPropertyGetItemDelegate(SystemCollectionsGenericListSystemStringPropertyGetItem)), - Marshal.GetFunctionPointerForDelegate(new SystemCollectionsGenericListSystemStringPropertySetItemDelegate(SystemCollectionsGenericListSystemStringPropertySetItem)), - Marshal.GetFunctionPointerForDelegate(new SystemCollectionsGenericListSystemStringMethodAddSystemStringDelegate(SystemCollectionsGenericListSystemStringMethodAddSystemString)), - Marshal.GetFunctionPointerForDelegate(new SystemCollectionsGenericLinkedListNodeSystemStringConstructorSystemStringDelegate(SystemCollectionsGenericLinkedListNodeSystemStringConstructorSystemString)), - Marshal.GetFunctionPointerForDelegate(new SystemCollectionsGenericLinkedListNodeSystemStringPropertyGetValueDelegate(SystemCollectionsGenericLinkedListNodeSystemStringPropertyGetValue)), - Marshal.GetFunctionPointerForDelegate(new SystemCollectionsGenericLinkedListNodeSystemStringPropertySetValueDelegate(SystemCollectionsGenericLinkedListNodeSystemStringPropertySetValue)), - Marshal.GetFunctionPointerForDelegate(new SystemRuntimeCompilerServicesStrongBoxSystemStringConstructorSystemStringDelegate(SystemRuntimeCompilerServicesStrongBoxSystemStringConstructorSystemString)), - Marshal.GetFunctionPointerForDelegate(new SystemRuntimeCompilerServicesStrongBoxSystemStringFieldGetValueDelegate(SystemRuntimeCompilerServicesStrongBoxSystemStringFieldGetValue)), - Marshal.GetFunctionPointerForDelegate(new SystemRuntimeCompilerServicesStrongBoxSystemStringFieldSetValueDelegate(SystemRuntimeCompilerServicesStrongBoxSystemStringFieldSetValue)), - Marshal.GetFunctionPointerForDelegate(new SystemExceptionConstructorSystemStringDelegate(SystemExceptionConstructorSystemString)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineResolutionPropertyGetWidthDelegate(UnityEngineResolutionPropertyGetWidth)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineResolutionPropertySetWidthDelegate(UnityEngineResolutionPropertySetWidth)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineResolutionPropertyGetHeightDelegate(UnityEngineResolutionPropertyGetHeight)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineResolutionPropertySetHeightDelegate(UnityEngineResolutionPropertySetHeight)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineResolutionPropertyGetRefreshRateDelegate(UnityEngineResolutionPropertyGetRefreshRate)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineResolutionPropertySetRefreshRateDelegate(UnityEngineResolutionPropertySetRefreshRate)), - Marshal.GetFunctionPointerForDelegate(new BoxResolutionDelegate(BoxResolution)), - Marshal.GetFunctionPointerForDelegate(new UnboxResolutionDelegate(UnboxResolution)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineScreenPropertyGetResolutionsDelegate(UnityEngineScreenPropertyGetResolutions)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineRayConstructorUnityEngineVector3_UnityEngineVector3Delegate(UnityEngineRayConstructorUnityEngineVector3_UnityEngineVector3)), - Marshal.GetFunctionPointerForDelegate(new BoxRayDelegate(BoxRay)), - Marshal.GetFunctionPointerForDelegate(new UnboxRayDelegate(UnboxRay)), - Marshal.GetFunctionPointerForDelegate(new UnityEnginePhysicsMethodRaycastNonAllocUnityEngineRay_UnityEngineRaycastHitDelegate(UnityEnginePhysicsMethodRaycastNonAllocUnityEngineRay_UnityEngineRaycastHit)), - Marshal.GetFunctionPointerForDelegate(new UnityEnginePhysicsMethodRaycastAllUnityEngineRayDelegate(UnityEnginePhysicsMethodRaycastAllUnityEngineRay)), - Marshal.GetFunctionPointerForDelegate(new BoxColorDelegate(BoxColor)), - Marshal.GetFunctionPointerForDelegate(new UnboxColorDelegate(UnboxColor)), - Marshal.GetFunctionPointerForDelegate(new BoxGradientColorKeyDelegate(BoxGradientColorKey)), - Marshal.GetFunctionPointerForDelegate(new UnboxGradientColorKeyDelegate(UnboxGradientColorKey)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineGradientConstructorDelegate(UnityEngineGradientConstructor)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineGradientPropertyGetColorKeysDelegate(UnityEngineGradientPropertyGetColorKeys)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineGradientPropertySetColorKeysDelegate(UnityEngineGradientPropertySetColorKeys)), - Marshal.GetFunctionPointerForDelegate(new SystemAppDomainSetupConstructorDelegate(SystemAppDomainSetupConstructor)), - Marshal.GetFunctionPointerForDelegate(new SystemAppDomainSetupPropertyGetAppDomainInitializerDelegate(SystemAppDomainSetupPropertyGetAppDomainInitializer)), - Marshal.GetFunctionPointerForDelegate(new SystemAppDomainSetupPropertySetAppDomainInitializerDelegate(SystemAppDomainSetupPropertySetAppDomainInitializer)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineApplicationAddEventOnBeforeRenderDelegate(UnityEngineApplicationAddEventOnBeforeRender)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineApplicationRemoveEventOnBeforeRenderDelegate(UnityEngineApplicationRemoveEventOnBeforeRender)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineSceneManagementSceneManagerAddEventSceneLoadedDelegate(UnityEngineSceneManagementSceneManagerAddEventSceneLoaded)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineSceneManagementSceneManagerRemoveEventSceneLoadedDelegate(UnityEngineSceneManagementSceneManagerRemoveEventSceneLoaded)), - Marshal.GetFunctionPointerForDelegate(new BoxSceneDelegate(BoxScene)), - Marshal.GetFunctionPointerForDelegate(new UnboxSceneDelegate(UnboxScene)), - Marshal.GetFunctionPointerForDelegate(new BoxLoadSceneModeDelegate(BoxLoadSceneMode)), - Marshal.GetFunctionPointerForDelegate(new UnboxLoadSceneModeDelegate(UnboxLoadSceneMode)), - 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)), - Marshal.GetFunctionPointerForDelegate(new SystemSystemInt32Array1Constructor1Delegate(SystemSystemInt32Array1Constructor1)), - Marshal.GetFunctionPointerForDelegate(new SystemInt32Array1GetItem1Delegate(SystemInt32Array1GetItem1)), - Marshal.GetFunctionPointerForDelegate(new SystemInt32Array1SetItem1Delegate(SystemInt32Array1SetItem1)), - Marshal.GetFunctionPointerForDelegate(new SystemSystemSingleArray1Constructor1Delegate(SystemSystemSingleArray1Constructor1)), - Marshal.GetFunctionPointerForDelegate(new SystemSingleArray1GetItem1Delegate(SystemSingleArray1GetItem1)), - Marshal.GetFunctionPointerForDelegate(new SystemSingleArray1SetItem1Delegate(SystemSingleArray1SetItem1)), - Marshal.GetFunctionPointerForDelegate(new SystemSystemSingleArray2Constructor2Delegate(SystemSystemSingleArray2Constructor2)), - Marshal.GetFunctionPointerForDelegate(new SystemSystemSingleArray2GetLength2Delegate(SystemSystemSingleArray2GetLength2)), - Marshal.GetFunctionPointerForDelegate(new SystemSingleArray2GetItem2Delegate(SystemSingleArray2GetItem2)), - Marshal.GetFunctionPointerForDelegate(new SystemSingleArray2SetItem2Delegate(SystemSingleArray2SetItem2)), - Marshal.GetFunctionPointerForDelegate(new SystemSystemSingleArray3Constructor3Delegate(SystemSystemSingleArray3Constructor3)), - Marshal.GetFunctionPointerForDelegate(new SystemSystemSingleArray3GetLength3Delegate(SystemSystemSingleArray3GetLength3)), - Marshal.GetFunctionPointerForDelegate(new SystemSingleArray3GetItem3Delegate(SystemSingleArray3GetItem3)), - Marshal.GetFunctionPointerForDelegate(new SystemSingleArray3SetItem3Delegate(SystemSingleArray3SetItem3)), - Marshal.GetFunctionPointerForDelegate(new SystemSystemStringArray1Constructor1Delegate(SystemSystemStringArray1Constructor1)), - Marshal.GetFunctionPointerForDelegate(new SystemStringArray1GetItem1Delegate(SystemStringArray1GetItem1)), - Marshal.GetFunctionPointerForDelegate(new SystemStringArray1SetItem1Delegate(SystemStringArray1SetItem1)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineUnityEngineResolutionArray1Constructor1Delegate(UnityEngineUnityEngineResolutionArray1Constructor1)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineResolutionArray1GetItem1Delegate(UnityEngineResolutionArray1GetItem1)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineResolutionArray1SetItem1Delegate(UnityEngineResolutionArray1SetItem1)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineUnityEngineRaycastHitArray1Constructor1Delegate(UnityEngineUnityEngineRaycastHitArray1Constructor1)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineRaycastHitArray1GetItem1Delegate(UnityEngineRaycastHitArray1GetItem1)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineRaycastHitArray1SetItem1Delegate(UnityEngineRaycastHitArray1SetItem1)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineUnityEngineGradientColorKeyArray1Constructor1Delegate(UnityEngineUnityEngineGradientColorKeyArray1Constructor1)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineGradientColorKeyArray1GetItem1Delegate(UnityEngineGradientColorKeyArray1GetItem1)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineGradientColorKeyArray1SetItem1Delegate(UnityEngineGradientColorKeyArray1SetItem1)), - Marshal.GetFunctionPointerForDelegate(new ReleaseSystemActionDelegate(ReleaseSystemAction)), - Marshal.GetFunctionPointerForDelegate(new SystemActionConstructorDelegate(SystemActionConstructor)), - Marshal.GetFunctionPointerForDelegate(new SystemActionInvokeDelegate(SystemActionInvoke)), - Marshal.GetFunctionPointerForDelegate(new SystemActionAddDelegate(SystemActionAdd)), - Marshal.GetFunctionPointerForDelegate(new SystemActionRemoveDelegate(SystemActionRemove)), - Marshal.GetFunctionPointerForDelegate(new ReleaseSystemActionSystemSingleDelegate(ReleaseSystemActionSystemSingle)), - Marshal.GetFunctionPointerForDelegate(new SystemActionSystemSingleConstructorDelegate(SystemActionSystemSingleConstructor)), - Marshal.GetFunctionPointerForDelegate(new SystemActionSystemSingleInvokeDelegate(SystemActionSystemSingleInvoke)), - Marshal.GetFunctionPointerForDelegate(new SystemActionSystemSingleAddDelegate(SystemActionSystemSingleAdd)), - Marshal.GetFunctionPointerForDelegate(new SystemActionSystemSingleRemoveDelegate(SystemActionSystemSingleRemove)), - Marshal.GetFunctionPointerForDelegate(new ReleaseSystemActionSystemSingle_SystemSingleDelegate(ReleaseSystemActionSystemSingle_SystemSingle)), - Marshal.GetFunctionPointerForDelegate(new SystemActionSystemSingle_SystemSingleConstructorDelegate(SystemActionSystemSingle_SystemSingleConstructor)), - Marshal.GetFunctionPointerForDelegate(new SystemActionSystemSingle_SystemSingleInvokeDelegate(SystemActionSystemSingle_SystemSingleInvoke)), - Marshal.GetFunctionPointerForDelegate(new SystemActionSystemSingle_SystemSingleAddDelegate(SystemActionSystemSingle_SystemSingleAdd)), - Marshal.GetFunctionPointerForDelegate(new SystemActionSystemSingle_SystemSingleRemoveDelegate(SystemActionSystemSingle_SystemSingleRemove)), - Marshal.GetFunctionPointerForDelegate(new ReleaseSystemFuncSystemInt32_SystemSingle_SystemDoubleDelegate(ReleaseSystemFuncSystemInt32_SystemSingle_SystemDouble)), - Marshal.GetFunctionPointerForDelegate(new SystemFuncSystemInt32_SystemSingle_SystemDoubleConstructorDelegate(SystemFuncSystemInt32_SystemSingle_SystemDoubleConstructor)), - Marshal.GetFunctionPointerForDelegate(new SystemFuncSystemInt32_SystemSingle_SystemDoubleInvokeDelegate(SystemFuncSystemInt32_SystemSingle_SystemDoubleInvoke)), - Marshal.GetFunctionPointerForDelegate(new SystemFuncSystemInt32_SystemSingle_SystemDoubleAddDelegate(SystemFuncSystemInt32_SystemSingle_SystemDoubleAdd)), - Marshal.GetFunctionPointerForDelegate(new SystemFuncSystemInt32_SystemSingle_SystemDoubleRemoveDelegate(SystemFuncSystemInt32_SystemSingle_SystemDoubleRemove)), - Marshal.GetFunctionPointerForDelegate(new ReleaseSystemFuncSystemInt16_SystemInt32_SystemStringDelegate(ReleaseSystemFuncSystemInt16_SystemInt32_SystemString)), - Marshal.GetFunctionPointerForDelegate(new SystemFuncSystemInt16_SystemInt32_SystemStringConstructorDelegate(SystemFuncSystemInt16_SystemInt32_SystemStringConstructor)), - Marshal.GetFunctionPointerForDelegate(new SystemFuncSystemInt16_SystemInt32_SystemStringInvokeDelegate(SystemFuncSystemInt16_SystemInt32_SystemStringInvoke)), - Marshal.GetFunctionPointerForDelegate(new SystemFuncSystemInt16_SystemInt32_SystemStringAddDelegate(SystemFuncSystemInt16_SystemInt32_SystemStringAdd)), - Marshal.GetFunctionPointerForDelegate(new SystemFuncSystemInt16_SystemInt32_SystemStringRemoveDelegate(SystemFuncSystemInt16_SystemInt32_SystemStringRemove)), - Marshal.GetFunctionPointerForDelegate(new ReleaseSystemAppDomainInitializerDelegate(ReleaseSystemAppDomainInitializer)), - Marshal.GetFunctionPointerForDelegate(new SystemAppDomainInitializerConstructorDelegate(SystemAppDomainInitializerConstructor)), - Marshal.GetFunctionPointerForDelegate(new SystemAppDomainInitializerInvokeDelegate(SystemAppDomainInitializerInvoke)), - Marshal.GetFunctionPointerForDelegate(new SystemAppDomainInitializerAddDelegate(SystemAppDomainInitializerAdd)), - Marshal.GetFunctionPointerForDelegate(new SystemAppDomainInitializerRemoveDelegate(SystemAppDomainInitializerRemove)), - Marshal.GetFunctionPointerForDelegate(new ReleaseUnityEngineEventsUnityActionDelegate(ReleaseUnityEngineEventsUnityAction)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineEventsUnityActionConstructorDelegate(UnityEngineEventsUnityActionConstructor)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineEventsUnityActionInvokeDelegate(UnityEngineEventsUnityActionInvoke)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineEventsUnityActionAddDelegate(UnityEngineEventsUnityActionAdd)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineEventsUnityActionRemoveDelegate(UnityEngineEventsUnityActionRemove)), - Marshal.GetFunctionPointerForDelegate(new ReleaseUnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeDelegate(ReleaseUnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneMode)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeConstructorDelegate(UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeConstructor)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeInvokeDelegate(UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeInvoke)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeAddDelegate(UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeAdd)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeRemoveDelegate(UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeRemove)) - /*END INIT CALL*/ - ); + Init(memory, memorySize, initMode); if (UnhandledCppException != null) { Exception ex = UnhandledCppException; @@ -1271,17 +871,84 @@ public static void Open( /// public static void Close() { + ClosePlugin(); + Marshal.FreeHGlobal(memory); + memory = IntPtr.Zero; + } + + /// + /// Perform updates over time + /// + public static void Update() + { + DestroyAll(); + } + + private static void ClosePlugin() + { #if UNITY_EDITOR CloseLibrary(libraryHandle); libraryHandle = IntPtr.Zero; #endif +#if UNITY_EDITOR_WIN + File.Delete(pluginTempPath); +#endif + } + + public static void QueueDestroy(DestroyFunction function, int cppHandle) + { + lock (destroyQueueLockObj) + { + // Grow capacity if necessary + int count = destroyQueueCount; + int capacity = destroyQueueCapacity; + DestroyEntry[] queue = destroyQueue; + if (count == capacity) + { + int newCapacity = capacity * 2; + DestroyEntry[] newQueue = new DestroyEntry[newCapacity]; + for (int i = 0; i < capacity; ++i) + { + newQueue[i] = queue[i]; + } + destroyQueueCapacity = newCapacity; + destroyQueue = newQueue; + queue = newQueue; + } + + // Add to the end + queue[count] = new DestroyEntry(function, cppHandle); + destroyQueueCount = count + 1; + } + } + + static void DestroyAll() + { + lock (destroyQueueLockObj) + { + int count = destroyQueueCount; + DestroyEntry[] queue = destroyQueue; + for (int i = 0; i < count; ++i) + { + DestroyEntry entry = queue[i]; + switch (entry.Function) + { + /*BEGIN DESTROY QUEUE CASES*/ + case DestroyFunction.BaseBallScript: + DestroyBaseBallScript(entry.CppHandle); + break; + /*END DESTROY QUEUE CASES*/ + } + } + destroyQueueCount = 0; + } } //////////////////////////////////////////////////////////////// // C# functions for C++ to call //////////////////////////////////////////////////////////////// - [MonoPInvokeCallback(typeof(ReleaseObjectDelegate))] + [MonoPInvokeCallback(typeof(ReleaseObjectDelegateType))] static void ReleaseObject( int handle) { @@ -1291,7 +958,7 @@ static void ReleaseObject( } } - [MonoPInvokeCallback(typeof(StringNewDelegate))] + [MonoPInvokeCallback(typeof(StringNewDelegateType))] static int StringNew( string chars) { @@ -1299,118 +966,99 @@ 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(ArrayGetRankDelegate))] - static int ArrayGetRank(int handle) + [MonoPInvokeCallback(typeof(EnumerableGetEnumeratorDelegateType))] + static int EnumerableGetEnumerator(int handle) { - return ((Array)ObjectStore.Get(handle)).Rank; + return ObjectStore.Store(((IEnumerable)ObjectStore.Get(handle)).GetEnumerator()); } - + /*BEGIN FUNCTIONS*/ - [MonoPInvokeCallback(typeof(SystemDiagnosticsStopwatchConstructorDelegate))] - static int SystemDiagnosticsStopwatchConstructor() + [MonoPInvokeCallback(typeof(ReleaseSystemDecimalDelegateType))] + static void ReleaseSystemDecimal(int handle) { try { - var returnValue = NativeScript.Bindings.ObjectStore.Store(new System.Diagnostics.Stopwatch()); - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) + if (handle != 0) { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); + NativeScript.Bindings.StructStore.Remove(handle); } - } - - [MonoPInvokeCallback(typeof(SystemDiagnosticsStopwatchPropertyGetElapsedMillisecondsDelegate))] - static long SystemDiagnosticsStopwatchPropertyGetElapsedMilliseconds(int thisHandle) - { - try - { - var thiz = (System.Diagnostics.Stopwatch)NativeScript.Bindings.ObjectStore.Get(thisHandle); - var returnValue = thiz.ElapsedMilliseconds; - return returnValue; } catch (System.NullReferenceException ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(long); } catch (System.Exception ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(long); } } - [MonoPInvokeCallback(typeof(SystemDiagnosticsStopwatchMethodStartDelegate))] - static void SystemDiagnosticsStopwatchMethodStart(int thisHandle) + [MonoPInvokeCallback(typeof(SystemDecimalConstructorSystemDoubleDelegateType))] + static int SystemDecimalConstructorSystemDouble(double value) { try { - var thiz = (System.Diagnostics.Stopwatch)NativeScript.Bindings.ObjectStore.Get(thisHandle); - thiz.Start(); + var returnValue = NativeScript.Bindings.StructStore.Store(new System.Decimal(value)); + return returnValue; } catch (System.NullReferenceException ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); + return default(int); } catch (System.Exception ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); + return default(int); } } - [MonoPInvokeCallback(typeof(SystemDiagnosticsStopwatchMethodResetDelegate))] - static void SystemDiagnosticsStopwatchMethodReset(int thisHandle) + [MonoPInvokeCallback(typeof(SystemDecimalConstructorSystemUInt64DelegateType))] + static int SystemDecimalConstructorSystemUInt64(ulong value) { try { - var thiz = (System.Diagnostics.Stopwatch)NativeScript.Bindings.ObjectStore.Get(thisHandle); - thiz.Reset(); + var returnValue = NativeScript.Bindings.StructStore.Store(new System.Decimal(value)); + return returnValue; } catch (System.NullReferenceException ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); + return default(int); } catch (System.Exception ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); + return default(int); } } - [MonoPInvokeCallback(typeof(UnityEngineObjectPropertyGetNameDelegate))] - static int UnityEngineObjectPropertyGetName(int thisHandle) + [MonoPInvokeCallback(typeof(BoxDecimalDelegateType))] + static int BoxDecimal(int valHandle) { try { - var thiz = (UnityEngine.Object)NativeScript.Bindings.ObjectStore.Get(thisHandle); - var returnValue = thiz.name; - return NativeScript.Bindings.ObjectStore.GetHandle(returnValue); + var val = (System.Decimal)NativeScript.Bindings.StructStore.Get(valHandle); + var returnValue = NativeScript.Bindings.ObjectStore.Store((object)val); + return returnValue; } catch (System.NullReferenceException ex) { @@ -1426,80 +1074,79 @@ static int UnityEngineObjectPropertyGetName(int thisHandle) } } - [MonoPInvokeCallback(typeof(UnityEngineObjectPropertySetNameDelegate))] - static void UnityEngineObjectPropertySetName(int thisHandle, int valueHandle) + [MonoPInvokeCallback(typeof(UnboxDecimalDelegateType))] + static int UnboxDecimal(int valHandle) { try { - var thiz = (UnityEngine.Object)NativeScript.Bindings.ObjectStore.Get(thisHandle); - var value = (string)NativeScript.Bindings.ObjectStore.Get(valueHandle); - thiz.name = value; + var val = NativeScript.Bindings.ObjectStore.Get(valHandle); + var returnValue = NativeScript.Bindings.StructStore.Store((System.Decimal)val); + return returnValue; } catch (System.NullReferenceException ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); + return default(int); } catch (System.Exception ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); + return default(int); } } - [MonoPInvokeCallback(typeof(UnityEngineObjectMethodop_EqualityUnityEngineObject_UnityEngineObjectDelegate))] - static bool UnityEngineObjectMethodop_EqualityUnityEngineObject_UnityEngineObject(int xHandle, int yHandle) + [MonoPInvokeCallback(typeof(UnityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingleDelegateType))] + static UnityEngine.Vector3 UnityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingle(float x, float y, float z) { try { - var x = (UnityEngine.Object)NativeScript.Bindings.ObjectStore.Get(xHandle); - var y = (UnityEngine.Object)NativeScript.Bindings.ObjectStore.Get(yHandle); - var returnValue = x == y; + var returnValue = new UnityEngine.Vector3(x, y, z); return returnValue; } catch (System.NullReferenceException ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(bool); + return default(UnityEngine.Vector3); } catch (System.Exception ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(bool); + return default(UnityEngine.Vector3); } } - [MonoPInvokeCallback(typeof(UnityEngineObjectMethodop_ImplicitUnityEngineObjectDelegate))] - static bool UnityEngineObjectMethodop_ImplicitUnityEngineObject(int existsHandle) + [MonoPInvokeCallback(typeof(UnityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3DelegateType))] + static UnityEngine.Vector3 UnityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3(ref UnityEngine.Vector3 a, ref UnityEngine.Vector3 b) { try { - var exists = (UnityEngine.Object)NativeScript.Bindings.ObjectStore.Get(existsHandle); - var returnValue = exists; + var returnValue = a + b; return returnValue; } catch (System.NullReferenceException ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(bool); + return default(UnityEngine.Vector3); } catch (System.Exception ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(bool); + return default(UnityEngine.Vector3); } } - [MonoPInvokeCallback(typeof(UnityEngineGameObjectConstructorDelegate))] - static int UnityEngineGameObjectConstructor() + [MonoPInvokeCallback(typeof(BoxVector3DelegateType))] + static int BoxVector3(ref UnityEngine.Vector3 val) { try { - var returnValue = NativeScript.Bindings.ObjectStore.Store(new UnityEngine.GameObject()); + var returnValue = NativeScript.Bindings.ObjectStore.Store((object)val); return returnValue; } catch (System.NullReferenceException ex) @@ -1516,36 +1163,36 @@ static int UnityEngineGameObjectConstructor() } } - [MonoPInvokeCallback(typeof(UnityEngineGameObjectConstructorSystemStringDelegate))] - static int UnityEngineGameObjectConstructorSystemString(int nameHandle) + [MonoPInvokeCallback(typeof(UnboxVector3DelegateType))] + static UnityEngine.Vector3 UnboxVector3(int valHandle) { try { - var name = (string)NativeScript.Bindings.ObjectStore.Get(nameHandle); - var returnValue = NativeScript.Bindings.ObjectStore.Store(new UnityEngine.GameObject(name)); + var val = NativeScript.Bindings.ObjectStore.Get(valHandle); + var returnValue = (UnityEngine.Vector3)val; return returnValue; } catch (System.NullReferenceException ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); + return default(UnityEngine.Vector3); } catch (System.Exception ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); + return default(UnityEngine.Vector3); } } - [MonoPInvokeCallback(typeof(UnityEngineGameObjectPropertyGetTransformDelegate))] - static int UnityEngineGameObjectPropertyGetTransform(int thisHandle) + [MonoPInvokeCallback(typeof(UnityEngineObjectPropertyGetNameDelegateType))] + static int UnityEngineObjectPropertyGetName(int thisHandle) { try { - var thiz = (UnityEngine.GameObject)NativeScript.Bindings.ObjectStore.Get(thisHandle); - var returnValue = thiz.transform; + var thiz = (UnityEngine.Object)NativeScript.Bindings.ObjectStore.Get(thisHandle); + var returnValue = thiz.name; return NativeScript.Bindings.ObjectStore.GetHandle(returnValue); } catch (System.NullReferenceException ex) @@ -1562,30 +1209,28 @@ static int UnityEngineGameObjectPropertyGetTransform(int thisHandle) } } - [MonoPInvokeCallback(typeof(UnityEngineGameObjectMethodAddComponentMyGameMonoBehavioursTestScriptDelegate))] - static int UnityEngineGameObjectMethodAddComponentMyGameMonoBehavioursTestScript(int thisHandle) + [MonoPInvokeCallback(typeof(UnityEngineObjectPropertySetNameDelegateType))] + static void UnityEngineObjectPropertySetName(int thisHandle, int valueHandle) { try { - var thiz = (UnityEngine.GameObject)NativeScript.Bindings.ObjectStore.Get(thisHandle); - var returnValue = thiz.AddComponent(); - return NativeScript.Bindings.ObjectStore.GetHandle(returnValue); + var thiz = (UnityEngine.Object)NativeScript.Bindings.ObjectStore.Get(thisHandle); + var value = (string)NativeScript.Bindings.ObjectStore.Get(valueHandle); + thiz.name = value; } catch (System.NullReferenceException ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); } catch (System.Exception ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); } } - [MonoPInvokeCallback(typeof(UnityEngineComponentPropertyGetTransformDelegate))] + [MonoPInvokeCallback(typeof(UnityEngineComponentPropertyGetTransformDelegateType))] static int UnityEngineComponentPropertyGetTransform(int thisHandle) { try @@ -1608,7 +1253,7 @@ static int UnityEngineComponentPropertyGetTransform(int thisHandle) } } - [MonoPInvokeCallback(typeof(UnityEngineTransformPropertyGetPositionDelegate))] + [MonoPInvokeCallback(typeof(UnityEngineTransformPropertyGetPositionDelegateType))] static UnityEngine.Vector3 UnityEngineTransformPropertyGetPosition(int thisHandle) { try @@ -1631,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 @@ -1651,32 +1296,36 @@ static void UnityEngineTransformPropertySetPosition(int thisHandle, ref UnityEng } } - [MonoPInvokeCallback(typeof(UnityEngineDebugMethodLogSystemObjectDelegate))] - static void UnityEngineDebugMethodLogSystemObject(int messageHandle) + [MonoPInvokeCallback(typeof(SystemCollectionsIEnumeratorPropertyGetCurrentDelegateType))] + static int SystemCollectionsIEnumeratorPropertyGetCurrent(int thisHandle) { try { - var message = NativeScript.Bindings.ObjectStore.Get(messageHandle); - UnityEngine.Debug.Log(message); + var thiz = (System.Collections.IEnumerator)NativeScript.Bindings.ObjectStore.Get(thisHandle); + var returnValue = thiz.Current; + return NativeScript.Bindings.ObjectStore.GetHandle(returnValue); } catch (System.NullReferenceException ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); + return default(int); } catch (System.Exception ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); + return default(int); } } - [MonoPInvokeCallback(typeof(UnityEngineAssertionsAssertFieldGetRaiseExceptionsDelegate))] - static bool UnityEngineAssertionsAssertFieldGetRaiseExceptions() + [MonoPInvokeCallback(typeof(SystemCollectionsIEnumeratorMethodMoveNextDelegateType))] + static bool SystemCollectionsIEnumeratorMethodMoveNext(int thisHandle) { try { - var returnValue = UnityEngine.Assertions.Assert.raiseExceptions; + var thiz = (System.Collections.IEnumerator)NativeScript.Bindings.ObjectStore.Get(thisHandle); + var returnValue = thiz.MoveNext(); return returnValue; } catch (System.NullReferenceException ex) @@ -1693,54 +1342,58 @@ static bool UnityEngineAssertionsAssertFieldGetRaiseExceptions() } } - [MonoPInvokeCallback(typeof(UnityEngineAssertionsAssertFieldSetRaiseExceptionsDelegate))] - static void UnityEngineAssertionsAssertFieldSetRaiseExceptions(bool value) + [MonoPInvokeCallback(typeof(UnityEngineGameObjectMethodAddComponentMyGameBaseBallScriptDelegateType))] + static int UnityEngineGameObjectMethodAddComponentMyGameBaseBallScript(int thisHandle) { try { - UnityEngine.Assertions.Assert.raiseExceptions = value; + var thiz = (UnityEngine.GameObject)NativeScript.Bindings.ObjectStore.Get(thisHandle); + var returnValue = thiz.AddComponent(); + return NativeScript.Bindings.ObjectStore.GetHandle(returnValue); } catch (System.NullReferenceException ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); + return default(int); } catch (System.Exception ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); + return default(int); } } - [MonoPInvokeCallback(typeof(UnityEngineAssertionsAssertMethodAreEqualSystemStringSystemString_SystemStringDelegate))] - static void UnityEngineAssertionsAssertMethodAreEqualSystemStringSystemString_SystemString(int expectedHandle, int actualHandle) + [MonoPInvokeCallback(typeof(UnityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveTypeDelegateType))] + static int UnityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveType(UnityEngine.PrimitiveType type) { try { - var expected = (string)NativeScript.Bindings.ObjectStore.Get(expectedHandle); - var actual = (string)NativeScript.Bindings.ObjectStore.Get(actualHandle); - UnityEngine.Assertions.Assert.AreEqual(expected, actual); + var returnValue = UnityEngine.GameObject.CreatePrimitive(type); + return NativeScript.Bindings.ObjectStore.GetHandle(returnValue); } catch (System.NullReferenceException ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); + return default(int); } catch (System.Exception ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); + return default(int); } } - [MonoPInvokeCallback(typeof(UnityEngineAssertionsAssertMethodAreEqualUnityEngineGameObjectUnityEngineGameObject_UnityEngineGameObjectDelegate))] - static void UnityEngineAssertionsAssertMethodAreEqualUnityEngineGameObjectUnityEngineGameObject_UnityEngineGameObject(int expectedHandle, int actualHandle) + [MonoPInvokeCallback(typeof(UnityEngineDebugMethodLogSystemObjectDelegateType))] + static void UnityEngineDebugMethodLogSystemObject(int messageHandle) { try { - var expected = (UnityEngine.GameObject)NativeScript.Bindings.ObjectStore.Get(expectedHandle); - var actual = (UnityEngine.GameObject)NativeScript.Bindings.ObjectStore.Get(actualHandle); - UnityEngine.Assertions.Assert.AreEqual(expected, actual); + var message = NativeScript.Bindings.ObjectStore.Get(messageHandle); + UnityEngine.Debug.Log(message); } catch (System.NullReferenceException ex) { @@ -1754,94 +1407,103 @@ static void UnityEngineAssertionsAssertMethodAreEqualUnityEngineGameObjectUnityE } } - [MonoPInvokeCallback(typeof(UnityEngineAudioSettingsMethodGetDSPBufferSizeSystemInt32_SystemInt32Delegate))] - static void UnityEngineAudioSettingsMethodGetDSPBufferSizeSystemInt32_SystemInt32(ref int bufferLength, ref int numBuffers) + [MonoPInvokeCallback(typeof(UnityEngineMonoBehaviourPropertyGetTransformDelegateType))] + static int UnityEngineMonoBehaviourPropertyGetTransform(int thisHandle) { try { - UnityEngine.AudioSettings.GetDSPBufferSize(out bufferLength, out numBuffers); + var thiz = (UnityEngine.MonoBehaviour)NativeScript.Bindings.ObjectStore.Get(thisHandle); + var returnValue = thiz.transform; + return NativeScript.Bindings.ObjectStore.GetHandle(returnValue); } catch (System.NullReferenceException ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); + return default(int); } catch (System.Exception ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); + return default(int); } } - [MonoPInvokeCallback(typeof(UnityEngineNetworkingNetworkTransportMethodGetBroadcastConnectionInfoSystemInt32_SystemString_SystemInt32_SystemByteDelegate))] - static void UnityEngineNetworkingNetworkTransportMethodGetBroadcastConnectionInfoSystemInt32_SystemString_SystemInt32_SystemByte(int hostId, ref int addressHandle, ref int port, ref byte error) + [MonoPInvokeCallback(typeof(SystemExceptionConstructorSystemStringDelegateType))] + static int SystemExceptionConstructorSystemString(int messageHandle) { try { - var address = (string)NativeScript.Bindings.ObjectStore.Get(addressHandle); - UnityEngine.Networking.NetworkTransport.GetBroadcastConnectionInfo(hostId, out address, out port, out error); - int addressHandleNew = NativeScript.Bindings.ObjectStore.GetHandle(address); - addressHandle = addressHandleNew; + var message = (string)NativeScript.Bindings.ObjectStore.Get(messageHandle); + var returnValue = NativeScript.Bindings.ObjectStore.Store(new System.Exception(message)); + return returnValue; } catch (System.NullReferenceException ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); + return default(int); } catch (System.Exception ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); + return default(int); } } - [MonoPInvokeCallback(typeof(UnityEngineNetworkingNetworkTransportMethodInitDelegate))] - static void UnityEngineNetworkingNetworkTransportMethodInit() + [MonoPInvokeCallback(typeof(BoxPrimitiveTypeDelegateType))] + static int BoxPrimitiveType(UnityEngine.PrimitiveType val) { try { - UnityEngine.Networking.NetworkTransport.Init(); + var returnValue = NativeScript.Bindings.ObjectStore.Store((object)val); + return returnValue; } catch (System.NullReferenceException ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); + return default(int); } catch (System.Exception ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); + return default(int); } } - [MonoPInvokeCallback(typeof(UnityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingleDelegate))] - static UnityEngine.Vector3 UnityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingle(float x, float y, float z) + [MonoPInvokeCallback(typeof(UnboxPrimitiveTypeDelegateType))] + static UnityEngine.PrimitiveType UnboxPrimitiveType(int valHandle) { try { - var returnValue = new UnityEngine.Vector3(x, y, z); + var val = NativeScript.Bindings.ObjectStore.Get(valHandle); + var returnValue = (UnityEngine.PrimitiveType)val; return returnValue; } catch (System.NullReferenceException ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(UnityEngine.Vector3); + return default(UnityEngine.PrimitiveType); } catch (System.Exception ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(UnityEngine.Vector3); + return default(UnityEngine.PrimitiveType); } } - [MonoPInvokeCallback(typeof(UnityEngineVector3PropertyGetMagnitudeDelegate))] - static float UnityEngineVector3PropertyGetMagnitude(ref UnityEngine.Vector3 thiz) + [MonoPInvokeCallback(typeof(UnityEngineTimePropertyGetDeltaTimeDelegateType))] + static float UnityEngineTimePropertyGetDeltaTime() { try { - var returnValue = thiz.magnitude; + var returnValue = UnityEngine.Time.deltaTime; return returnValue; } catch (System.NullReferenceException ex) @@ -1858,75 +1520,58 @@ static float UnityEngineVector3PropertyGetMagnitude(ref UnityEngine.Vector3 thiz } } - [MonoPInvokeCallback(typeof(UnityEngineVector3MethodSetSystemSingle_SystemSingle_SystemSingleDelegate))] - static void UnityEngineVector3MethodSetSystemSingle_SystemSingle_SystemSingle(ref UnityEngine.Vector3 thiz, float newX, float newY, float newZ) + [MonoPInvokeCallback(typeof(BaseBallScriptConstructorDelegateType))] + static void BaseBallScriptConstructor(int cppHandle, ref int handle) { try { - thiz.Set(newX, newY, newZ); + var thiz = new MyGame.BaseBallScript(cppHandle); + handle = NativeScript.Bindings.ObjectStore.Store(thiz); } catch (System.NullReferenceException ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); + handle = default(int); } catch (System.Exception ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); + handle = default(int); } } - [MonoPInvokeCallback(typeof(UnityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3Delegate))] - static UnityEngine.Vector3 UnityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3(ref UnityEngine.Vector3 a, ref UnityEngine.Vector3 b) + [MonoPInvokeCallback(typeof(ReleaseBaseBallScriptDelegateType))] + static void ReleaseBaseBallScript(int handle) { try { - var returnValue = a + b; - return returnValue; + MyGame.BaseBallScript thiz; + thiz = (MyGame.BaseBallScript)ObjectStore.Get(handle); + int cppHandle = thiz.CppHandle; + thiz.CppHandle = 0; + QueueDestroy(DestroyFunction.BaseBallScript, cppHandle); + ObjectStore.Remove(handle); } catch (System.NullReferenceException ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(UnityEngine.Vector3); } catch (System.Exception ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(UnityEngine.Vector3); } } - [MonoPInvokeCallback(typeof(UnityEngineVector3Methodop_UnaryNegationUnityEngineVector3Delegate))] - static UnityEngine.Vector3 UnityEngineVector3Methodop_UnaryNegationUnityEngineVector3(ref UnityEngine.Vector3 a) + [MonoPInvokeCallback(typeof(BoxBooleanDelegateType))] + static int BoxBoolean(bool val) { try { - var returnValue = -a; - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(UnityEngine.Vector3); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(UnityEngine.Vector3); - } - } - - [MonoPInvokeCallback(typeof(BoxVector3Delegate))] - static int BoxVector3(ref UnityEngine.Vector3 val) - { - try - { - var returnValue = NativeScript.Bindings.ObjectStore.Store((object)val); + var returnValue = NativeScript.Bindings.ObjectStore.Store((object)val); return returnValue; } catch (System.NullReferenceException ex) @@ -1943,72 +1588,76 @@ static int BoxVector3(ref UnityEngine.Vector3 val) } } - [MonoPInvokeCallback(typeof(UnboxVector3Delegate))] - static UnityEngine.Vector3 UnboxVector3(int valHandle) + [MonoPInvokeCallback(typeof(UnboxBooleanDelegateType))] + static bool UnboxBoolean(int valHandle) { try { var val = NativeScript.Bindings.ObjectStore.Get(valHandle); - var returnValue = (UnityEngine.Vector3)val; + var returnValue = (bool)val; return returnValue; } catch (System.NullReferenceException ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(UnityEngine.Vector3); + return default(bool); } catch (System.Exception ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(UnityEngine.Vector3); + return default(bool); } } - [MonoPInvokeCallback(typeof(UnityEngineMatrix4x4PropertyGetItemDelegate))] - static float UnityEngineMatrix4x4PropertyGetItem(ref UnityEngine.Matrix4x4 thiz, int row, int column) + [MonoPInvokeCallback(typeof(BoxSByteDelegateType))] + static int BoxSByte(sbyte val) { try { - var returnValue = thiz[row, row]; + var returnValue = NativeScript.Bindings.ObjectStore.Store((object)val); return returnValue; } catch (System.NullReferenceException ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(float); + return default(int); } catch (System.Exception ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(float); + return default(int); } } - [MonoPInvokeCallback(typeof(UnityEngineMatrix4x4PropertySetItemDelegate))] - static void UnityEngineMatrix4x4PropertySetItem(ref UnityEngine.Matrix4x4 thiz, int row, int column, float value) + [MonoPInvokeCallback(typeof(UnboxSByteDelegateType))] + static sbyte UnboxSByte(int valHandle) { try { - thiz[row, column] = column; + var val = NativeScript.Bindings.ObjectStore.Get(valHandle); + var returnValue = (sbyte)val; + return returnValue; } catch (System.NullReferenceException ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); + return default(sbyte); } catch (System.Exception ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); + return default(sbyte); } } - [MonoPInvokeCallback(typeof(BoxMatrix4x4Delegate))] - static int BoxMatrix4x4(ref UnityEngine.Matrix4x4 val) + [MonoPInvokeCallback(typeof(BoxByteDelegateType))] + static int BoxByte(byte val) { try { @@ -2029,124 +1678,124 @@ static int BoxMatrix4x4(ref UnityEngine.Matrix4x4 val) } } - [MonoPInvokeCallback(typeof(UnboxMatrix4x4Delegate))] - static UnityEngine.Matrix4x4 UnboxMatrix4x4(int valHandle) + [MonoPInvokeCallback(typeof(UnboxByteDelegateType))] + static byte UnboxByte(int valHandle) { try { var val = NativeScript.Bindings.ObjectStore.Get(valHandle); - var returnValue = (UnityEngine.Matrix4x4)val; + var returnValue = (byte)val; return returnValue; } catch (System.NullReferenceException ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(UnityEngine.Matrix4x4); + return default(byte); } catch (System.Exception ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(UnityEngine.Matrix4x4); + return default(byte); } } - [MonoPInvokeCallback(typeof(ReleaseUnityEngineRaycastHitDelegate))] - static void ReleaseUnityEngineRaycastHit(int handle) + [MonoPInvokeCallback(typeof(BoxInt16DelegateType))] + static int BoxInt16(short val) { try { - if (handle != 0) - { - NativeScript.Bindings.StructStore.Remove(handle); - } + var returnValue = NativeScript.Bindings.ObjectStore.Store((object)val); + return returnValue; } catch (System.NullReferenceException ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); + return default(int); } catch (System.Exception ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); + return default(int); } } - [MonoPInvokeCallback(typeof(UnityEngineRaycastHitPropertyGetPointDelegate))] - static UnityEngine.Vector3 UnityEngineRaycastHitPropertyGetPoint(int thisHandle) + [MonoPInvokeCallback(typeof(UnboxInt16DelegateType))] + static short UnboxInt16(int valHandle) { try { - var thiz = (UnityEngine.RaycastHit)NativeScript.Bindings.StructStore.Get(thisHandle); - var returnValue = thiz.point; + var val = NativeScript.Bindings.ObjectStore.Get(valHandle); + var returnValue = (short)val; return returnValue; } catch (System.NullReferenceException ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(UnityEngine.Vector3); + return default(short); } catch (System.Exception ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(UnityEngine.Vector3); + return default(short); } } - [MonoPInvokeCallback(typeof(UnityEngineRaycastHitPropertySetPointDelegate))] - static void UnityEngineRaycastHitPropertySetPoint(int thisHandle, ref UnityEngine.Vector3 value) + [MonoPInvokeCallback(typeof(BoxUInt16DelegateType))] + static int BoxUInt16(ushort val) { try { - var thiz = (UnityEngine.RaycastHit)NativeScript.Bindings.StructStore.Get(thisHandle); - thiz.point = value; - NativeScript.Bindings.StructStore.Replace(thisHandle, ref thiz); + var returnValue = NativeScript.Bindings.ObjectStore.Store((object)val); + return returnValue; } catch (System.NullReferenceException ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); + return default(int); } catch (System.Exception ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); + return default(int); } } - [MonoPInvokeCallback(typeof(UnityEngineRaycastHitPropertyGetTransformDelegate))] - static int UnityEngineRaycastHitPropertyGetTransform(int thisHandle) + [MonoPInvokeCallback(typeof(UnboxUInt16DelegateType))] + static ushort UnboxUInt16(int valHandle) { try { - var thiz = (UnityEngine.RaycastHit)NativeScript.Bindings.StructStore.Get(thisHandle); - var returnValue = thiz.transform; - return NativeScript.Bindings.ObjectStore.GetHandle(returnValue); + var val = NativeScript.Bindings.ObjectStore.Get(valHandle); + var returnValue = (ushort)val; + return returnValue; } catch (System.NullReferenceException ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); + return default(ushort); } catch (System.Exception ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); + return default(ushort); } } - [MonoPInvokeCallback(typeof(BoxRaycastHitDelegate))] - static int BoxRaycastHit(int valHandle) + [MonoPInvokeCallback(typeof(BoxInt32DelegateType))] + static int BoxInt32(int val) { try { - var val = (UnityEngine.RaycastHit)NativeScript.Bindings.StructStore.Get(valHandle); var returnValue = NativeScript.Bindings.ObjectStore.Store((object)val); return returnValue; } @@ -2164,13 +1813,13 @@ static int BoxRaycastHit(int valHandle) } } - [MonoPInvokeCallback(typeof(UnboxRaycastHitDelegate))] - static int UnboxRaycastHit(int valHandle) + [MonoPInvokeCallback(typeof(UnboxInt32DelegateType))] + static int UnboxInt32(int valHandle) { try { var val = NativeScript.Bindings.ObjectStore.Get(valHandle); - var returnValue = NativeScript.Bindings.StructStore.Store((UnityEngine.RaycastHit)val); + var returnValue = (int)val; return returnValue; } catch (System.NullReferenceException ex) @@ -2187,8 +1836,8 @@ static int UnboxRaycastHit(int valHandle) } } - [MonoPInvokeCallback(typeof(BoxQueryTriggerInteractionDelegate))] - static int BoxQueryTriggerInteraction(UnityEngine.QueryTriggerInteraction val) + [MonoPInvokeCallback(typeof(BoxUInt32DelegateType))] + static int BoxUInt32(uint val) { try { @@ -2209,58 +1858,35 @@ static int BoxQueryTriggerInteraction(UnityEngine.QueryTriggerInteraction val) } } - [MonoPInvokeCallback(typeof(UnboxQueryTriggerInteractionDelegate))] - static UnityEngine.QueryTriggerInteraction UnboxQueryTriggerInteraction(int valHandle) + [MonoPInvokeCallback(typeof(UnboxUInt32DelegateType))] + static uint UnboxUInt32(int valHandle) { try { var val = NativeScript.Bindings.ObjectStore.Get(valHandle); - var returnValue = (UnityEngine.QueryTriggerInteraction)val; + var returnValue = (uint)val; return returnValue; } catch (System.NullReferenceException ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(UnityEngine.QueryTriggerInteraction); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(UnityEngine.QueryTriggerInteraction); - } - } - - [MonoPInvokeCallback(typeof(ReleaseSystemCollectionsGenericKeyValuePairSystemString_SystemDoubleDelegate))] - static void ReleaseSystemCollectionsGenericKeyValuePairSystemString_SystemDouble(int handle) - { - try - { - if (handle != 0) - { - NativeScript.Bindings.StructStore>.Remove(handle); - } - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); + return default(uint); } catch (System.Exception ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); + return default(uint); } } - [MonoPInvokeCallback(typeof(SystemCollectionsGenericKeyValuePairSystemString_SystemDoubleConstructorSystemString_SystemDoubleDelegate))] - static int SystemCollectionsGenericKeyValuePairSystemString_SystemDoubleConstructorSystemString_SystemDouble(int keyHandle, double value) + [MonoPInvokeCallback(typeof(BoxInt64DelegateType))] + static int BoxInt64(long val) { try { - var key = (string)NativeScript.Bindings.ObjectStore.Get(keyHandle); - var returnValue = NativeScript.Bindings.StructStore>.Store(new System.Collections.Generic.KeyValuePair(key, value)); + var returnValue = NativeScript.Bindings.ObjectStore.Store((object)val); return returnValue; } catch (System.NullReferenceException ex) @@ -2277,58 +1903,34 @@ static int SystemCollectionsGenericKeyValuePairSystemString_SystemDoubleConstruc } } - [MonoPInvokeCallback(typeof(SystemCollectionsGenericKeyValuePairSystemString_SystemDoublePropertyGetKeyDelegate))] - static int SystemCollectionsGenericKeyValuePairSystemString_SystemDoublePropertyGetKey(int thisHandle) - { - try - { - var thiz = (System.Collections.Generic.KeyValuePair)NativeScript.Bindings.StructStore>.Get(thisHandle); - var returnValue = thiz.Key; - return NativeScript.Bindings.ObjectStore.GetHandle(returnValue); - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(SystemCollectionsGenericKeyValuePairSystemString_SystemDoublePropertyGetValueDelegate))] - static double SystemCollectionsGenericKeyValuePairSystemString_SystemDoublePropertyGetValue(int thisHandle) + [MonoPInvokeCallback(typeof(UnboxInt64DelegateType))] + static long UnboxInt64(int valHandle) { try { - var thiz = (System.Collections.Generic.KeyValuePair)NativeScript.Bindings.StructStore>.Get(thisHandle); - var returnValue = thiz.Value; + var val = NativeScript.Bindings.ObjectStore.Get(valHandle); + var returnValue = (long)val; return returnValue; } catch (System.NullReferenceException ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(double); + return default(long); } catch (System.Exception ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(double); + return default(long); } } - [MonoPInvokeCallback(typeof(BoxKeyValuePairSystemString_SystemDoubleDelegate))] - static int BoxKeyValuePairSystemString_SystemDouble(int valHandle) + [MonoPInvokeCallback(typeof(BoxUInt64DelegateType))] + static int BoxUInt64(ulong val) { try { - var val = (System.Collections.Generic.KeyValuePair)NativeScript.Bindings.StructStore>.Get(valHandle); var returnValue = NativeScript.Bindings.ObjectStore.Store((object)val); return returnValue; } @@ -2346,35 +1948,35 @@ static int BoxKeyValuePairSystemString_SystemDouble(int valHandle) } } - [MonoPInvokeCallback(typeof(UnboxKeyValuePairSystemString_SystemDoubleDelegate))] - static int UnboxKeyValuePairSystemString_SystemDouble(int valHandle) + [MonoPInvokeCallback(typeof(UnboxUInt64DelegateType))] + static ulong UnboxUInt64(int valHandle) { try { var val = NativeScript.Bindings.ObjectStore.Get(valHandle); - var returnValue = NativeScript.Bindings.StructStore>.Store((System.Collections.Generic.KeyValuePair)val); + var returnValue = (ulong)val; return returnValue; } catch (System.NullReferenceException ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); + return default(ulong); } catch (System.Exception ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); + return default(ulong); } } - [MonoPInvokeCallback(typeof(SystemCollectionsGenericListSystemStringConstructorDelegate))] - static int SystemCollectionsGenericListSystemStringConstructor() + [MonoPInvokeCallback(typeof(BoxCharDelegateType))] + static int BoxChar(char val) { try { - var returnValue = NativeScript.Bindings.ObjectStore.Store(new System.Collections.Generic.List()); + var returnValue = NativeScript.Bindings.ObjectStore.Store((object)val); return returnValue; } catch (System.NullReferenceException ex) @@ -2391,102 +1993,81 @@ static int SystemCollectionsGenericListSystemStringConstructor() } } - [MonoPInvokeCallback(typeof(SystemCollectionsGenericListSystemStringPropertyGetItemDelegate))] - static int SystemCollectionsGenericListSystemStringPropertyGetItem(int thisHandle, int index) - { - try - { - var thiz = (System.Collections.Generic.List)NativeScript.Bindings.ObjectStore.Get(thisHandle); - var returnValue = thiz[index]; - return NativeScript.Bindings.ObjectStore.GetHandle(returnValue); - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(SystemCollectionsGenericListSystemStringPropertySetItemDelegate))] - static void SystemCollectionsGenericListSystemStringPropertySetItem(int thisHandle, int index, int valueHandle) + [MonoPInvokeCallback(typeof(UnboxCharDelegateType))] + static char UnboxChar(int valHandle) { try { - var thiz = (System.Collections.Generic.List)NativeScript.Bindings.ObjectStore.Get(thisHandle); - var value = (string)NativeScript.Bindings.ObjectStore.Get(valueHandle); - thiz[index] = value; + var val = NativeScript.Bindings.ObjectStore.Get(valHandle); + var returnValue = (char)val; + return returnValue; } catch (System.NullReferenceException ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); + return default(char); } catch (System.Exception ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); + return default(char); } } - [MonoPInvokeCallback(typeof(SystemCollectionsGenericListSystemStringMethodAddSystemStringDelegate))] - static void SystemCollectionsGenericListSystemStringMethodAddSystemString(int thisHandle, int itemHandle) + [MonoPInvokeCallback(typeof(BoxSingleDelegateType))] + static int BoxSingle(float val) { try { - var thiz = (System.Collections.Generic.List)NativeScript.Bindings.ObjectStore.Get(thisHandle); - var item = (string)NativeScript.Bindings.ObjectStore.Get(itemHandle); - thiz.Add(item); + var returnValue = NativeScript.Bindings.ObjectStore.Store((object)val); + return returnValue; } catch (System.NullReferenceException ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); + return default(int); } catch (System.Exception ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); + return default(int); } } - [MonoPInvokeCallback(typeof(SystemCollectionsGenericLinkedListNodeSystemStringConstructorSystemStringDelegate))] - static int SystemCollectionsGenericLinkedListNodeSystemStringConstructorSystemString(int valueHandle) + [MonoPInvokeCallback(typeof(UnboxSingleDelegateType))] + static float UnboxSingle(int valHandle) { try { - var value = (string)NativeScript.Bindings.ObjectStore.Get(valueHandle); - var returnValue = NativeScript.Bindings.ObjectStore.Store(new System.Collections.Generic.LinkedListNode(value)); + var val = NativeScript.Bindings.ObjectStore.Get(valHandle); + var returnValue = (float)val; return returnValue; } catch (System.NullReferenceException ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); + return default(float); } catch (System.Exception ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); + return default(float); } } - [MonoPInvokeCallback(typeof(SystemCollectionsGenericLinkedListNodeSystemStringPropertyGetValueDelegate))] - static int SystemCollectionsGenericLinkedListNodeSystemStringPropertyGetValue(int thisHandle) + [MonoPInvokeCallback(typeof(BoxDoubleDelegateType))] + static int BoxDouble(double val) { try { - var thiz = (System.Collections.Generic.LinkedListNode)NativeScript.Bindings.ObjectStore.Get(thisHandle); - var returnValue = thiz.Value; - return NativeScript.Bindings.ObjectStore.GetHandle(returnValue); + var returnValue = NativeScript.Bindings.ObjectStore.Store((object)val); + return returnValue; } catch (System.NullReferenceException ex) { @@ -2502,3046 +2083,66 @@ static int SystemCollectionsGenericLinkedListNodeSystemStringPropertyGetValue(in } } - [MonoPInvokeCallback(typeof(SystemCollectionsGenericLinkedListNodeSystemStringPropertySetValueDelegate))] - static void SystemCollectionsGenericLinkedListNodeSystemStringPropertySetValue(int thisHandle, int valueHandle) + [MonoPInvokeCallback(typeof(UnboxDoubleDelegateType))] + static double UnboxDouble(int valHandle) { try { - var thiz = (System.Collections.Generic.LinkedListNode)NativeScript.Bindings.ObjectStore.Get(thisHandle); - var value = (string)NativeScript.Bindings.ObjectStore.Get(valueHandle); - thiz.Value = value; + var val = NativeScript.Bindings.ObjectStore.Get(valHandle); + var returnValue = (double)val; + return returnValue; } catch (System.NullReferenceException ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); + return default(double); } catch (System.Exception ex) { UnityEngine.Debug.LogException(ex); NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); + return default(double); } } + /*END FUNCTIONS*/ + } +} + +/*BEGIN BASE TYPES*/ +namespace MyGame +{ + class BaseBallScript : MyGame.AbstractBaseBallScript + { + public int CppHandle; - [MonoPInvokeCallback(typeof(SystemRuntimeCompilerServicesStrongBoxSystemStringConstructorSystemStringDelegate))] - static int SystemRuntimeCompilerServicesStrongBoxSystemStringConstructorSystemString(int valueHandle) + public BaseBallScript() { - try - { - var value = (string)NativeScript.Bindings.ObjectStore.Get(valueHandle); - var returnValue = NativeScript.Bindings.ObjectStore.Store(new System.Runtime.CompilerServices.StrongBox(value)); - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } + int handle = NativeScript.Bindings.ObjectStore.Store(this); + CppHandle = NativeScript.Bindings.NewBaseBallScript(handle); } - [MonoPInvokeCallback(typeof(SystemRuntimeCompilerServicesStrongBoxSystemStringFieldGetValueDelegate))] - static int SystemRuntimeCompilerServicesStrongBoxSystemStringFieldGetValue(int thisHandle) + ~BaseBallScript() { - try - { - var thiz = (System.Runtime.CompilerServices.StrongBox)NativeScript.Bindings.ObjectStore.Get(thisHandle); - var returnValue = thiz.Value; - return NativeScript.Bindings.ObjectStore.GetHandle(returnValue); - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) + if (CppHandle != 0) { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); + NativeScript.Bindings.QueueDestroy(NativeScript.Bindings.DestroyFunction.BaseBallScript, CppHandle); + CppHandle = 0; } } - [MonoPInvokeCallback(typeof(SystemRuntimeCompilerServicesStrongBoxSystemStringFieldSetValueDelegate))] - static void SystemRuntimeCompilerServicesStrongBoxSystemStringFieldSetValue(int thisHandle, int valueHandle) + public BaseBallScript(int cppHandle) + : base() { - try - { - var thiz = (System.Runtime.CompilerServices.StrongBox)NativeScript.Bindings.ObjectStore.Get(thisHandle); - var value = (string)NativeScript.Bindings.ObjectStore.Get(valueHandle); - thiz.Value = value; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } + CppHandle = cppHandle; } - [MonoPInvokeCallback(typeof(SystemExceptionConstructorSystemStringDelegate))] - static int SystemExceptionConstructorSystemString(int messageHandle) + public override void Update() { - try - { - var message = (string)NativeScript.Bindings.ObjectStore.Get(messageHandle); - var returnValue = NativeScript.Bindings.ObjectStore.Store(new System.Exception(message)); - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(UnityEngineResolutionPropertyGetWidthDelegate))] - static int UnityEngineResolutionPropertyGetWidth(ref UnityEngine.Resolution thiz) - { - try - { - var returnValue = thiz.width; - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(UnityEngineResolutionPropertySetWidthDelegate))] - static void UnityEngineResolutionPropertySetWidth(ref UnityEngine.Resolution thiz, int value) - { - try - { - thiz.width = value; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(UnityEngineResolutionPropertyGetHeightDelegate))] - static int UnityEngineResolutionPropertyGetHeight(ref UnityEngine.Resolution thiz) - { - try - { - var returnValue = thiz.height; - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(UnityEngineResolutionPropertySetHeightDelegate))] - static void UnityEngineResolutionPropertySetHeight(ref UnityEngine.Resolution thiz, int value) - { - try - { - thiz.height = value; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(UnityEngineResolutionPropertyGetRefreshRateDelegate))] - static int UnityEngineResolutionPropertyGetRefreshRate(ref UnityEngine.Resolution thiz) - { - try - { - var returnValue = thiz.refreshRate; - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(UnityEngineResolutionPropertySetRefreshRateDelegate))] - static void UnityEngineResolutionPropertySetRefreshRate(ref UnityEngine.Resolution thiz, int value) - { - try - { - thiz.refreshRate = value; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(BoxResolutionDelegate))] - static int BoxResolution(ref UnityEngine.Resolution val) - { - try - { - var returnValue = NativeScript.Bindings.ObjectStore.Store((object)val); - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(UnboxResolutionDelegate))] - static UnityEngine.Resolution UnboxResolution(int valHandle) - { - try - { - var val = NativeScript.Bindings.ObjectStore.Get(valHandle); - var returnValue = (UnityEngine.Resolution)val; - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(UnityEngine.Resolution); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(UnityEngine.Resolution); - } - } - - [MonoPInvokeCallback(typeof(UnityEngineScreenPropertyGetResolutionsDelegate))] - static int UnityEngineScreenPropertyGetResolutions() - { - try - { - var returnValue = UnityEngine.Screen.resolutions; - return NativeScript.Bindings.ObjectStore.GetHandle(returnValue); - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(UnityEngineRayConstructorUnityEngineVector3_UnityEngineVector3Delegate))] - static UnityEngine.Ray UnityEngineRayConstructorUnityEngineVector3_UnityEngineVector3(ref UnityEngine.Vector3 origin, ref UnityEngine.Vector3 direction) - { - try - { - var returnValue = new UnityEngine.Ray(origin, direction); - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(UnityEngine.Ray); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(UnityEngine.Ray); - } - } - - [MonoPInvokeCallback(typeof(BoxRayDelegate))] - static int BoxRay(ref UnityEngine.Ray val) - { - try - { - var returnValue = NativeScript.Bindings.ObjectStore.Store((object)val); - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(UnboxRayDelegate))] - static UnityEngine.Ray UnboxRay(int valHandle) - { - try - { - var val = NativeScript.Bindings.ObjectStore.Get(valHandle); - var returnValue = (UnityEngine.Ray)val; - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(UnityEngine.Ray); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(UnityEngine.Ray); - } - } - - [MonoPInvokeCallback(typeof(UnityEnginePhysicsMethodRaycastNonAllocUnityEngineRay_UnityEngineRaycastHitDelegate))] - static int UnityEnginePhysicsMethodRaycastNonAllocUnityEngineRay_UnityEngineRaycastHit(ref UnityEngine.Ray ray, int resultsHandle) - { - try - { - var results = (UnityEngine.RaycastHit[])NativeScript.Bindings.ObjectStore.Get(resultsHandle); - var returnValue = UnityEngine.Physics.RaycastNonAlloc(ray, results); - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(UnityEnginePhysicsMethodRaycastAllUnityEngineRayDelegate))] - static int UnityEnginePhysicsMethodRaycastAllUnityEngineRay(ref UnityEngine.Ray ray) - { - try - { - var returnValue = UnityEngine.Physics.RaycastAll(ray); - return NativeScript.Bindings.ObjectStore.GetHandle(returnValue); - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(BoxColorDelegate))] - static int BoxColor(ref UnityEngine.Color val) - { - try - { - var returnValue = NativeScript.Bindings.ObjectStore.Store((object)val); - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(UnboxColorDelegate))] - static UnityEngine.Color UnboxColor(int valHandle) - { - try - { - var val = NativeScript.Bindings.ObjectStore.Get(valHandle); - var returnValue = (UnityEngine.Color)val; - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(UnityEngine.Color); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(UnityEngine.Color); - } - } - - [MonoPInvokeCallback(typeof(BoxGradientColorKeyDelegate))] - static int BoxGradientColorKey(ref UnityEngine.GradientColorKey val) - { - try - { - var returnValue = NativeScript.Bindings.ObjectStore.Store((object)val); - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(UnboxGradientColorKeyDelegate))] - static UnityEngine.GradientColorKey UnboxGradientColorKey(int valHandle) - { - try - { - var val = NativeScript.Bindings.ObjectStore.Get(valHandle); - var returnValue = (UnityEngine.GradientColorKey)val; - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(UnityEngine.GradientColorKey); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(UnityEngine.GradientColorKey); - } - } - - [MonoPInvokeCallback(typeof(UnityEngineGradientConstructorDelegate))] - static int UnityEngineGradientConstructor() - { - try - { - var returnValue = NativeScript.Bindings.ObjectStore.Store(new UnityEngine.Gradient()); - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(UnityEngineGradientPropertyGetColorKeysDelegate))] - static int UnityEngineGradientPropertyGetColorKeys(int thisHandle) - { - try - { - var thiz = (UnityEngine.Gradient)NativeScript.Bindings.ObjectStore.Get(thisHandle); - var returnValue = thiz.colorKeys; - return NativeScript.Bindings.ObjectStore.GetHandle(returnValue); - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(UnityEngineGradientPropertySetColorKeysDelegate))] - static void UnityEngineGradientPropertySetColorKeys(int thisHandle, int valueHandle) - { - try - { - var thiz = (UnityEngine.Gradient)NativeScript.Bindings.ObjectStore.Get(thisHandle); - var value = (UnityEngine.GradientColorKey[])NativeScript.Bindings.ObjectStore.Get(valueHandle); - thiz.colorKeys = value; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(SystemAppDomainSetupConstructorDelegate))] - static int SystemAppDomainSetupConstructor() - { - try - { - var returnValue = NativeScript.Bindings.ObjectStore.Store(new System.AppDomainSetup()); - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(SystemAppDomainSetupPropertyGetAppDomainInitializerDelegate))] - static int SystemAppDomainSetupPropertyGetAppDomainInitializer(int thisHandle) - { - try - { - var thiz = (System.AppDomainSetup)NativeScript.Bindings.ObjectStore.Get(thisHandle); - var returnValue = thiz.AppDomainInitializer; - return NativeScript.Bindings.ObjectStore.GetHandle(returnValue); - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(SystemAppDomainSetupPropertySetAppDomainInitializerDelegate))] - static void SystemAppDomainSetupPropertySetAppDomainInitializer(int thisHandle, int valueHandle) - { - try - { - var thiz = (System.AppDomainSetup)NativeScript.Bindings.ObjectStore.Get(thisHandle); - var value = (System.AppDomainInitializer)NativeScript.Bindings.ObjectStore.Get(valueHandle); - thiz.AppDomainInitializer = value; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(UnityEngineApplicationAddEventOnBeforeRenderDelegate))] - static void UnityEngineApplicationAddEventOnBeforeRender(int delHandle) - { - try - { - var del = (UnityEngine.Events.UnityAction)NativeScript.Bindings.ObjectStore.Get(delHandle); - UnityEngine.Application.onBeforeRender += del; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(UnityEngineApplicationRemoveEventOnBeforeRenderDelegate))] - static void UnityEngineApplicationRemoveEventOnBeforeRender(int delHandle) - { - try - { - var del = (UnityEngine.Events.UnityAction)NativeScript.Bindings.ObjectStore.Get(delHandle); - UnityEngine.Application.onBeforeRender += del; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(UnityEngineSceneManagementSceneManagerAddEventSceneLoadedDelegate))] - static void UnityEngineSceneManagementSceneManagerAddEventSceneLoaded(int delHandle) - { - try - { - var del = (UnityEngine.Events.UnityAction)NativeScript.Bindings.ObjectStore.Get(delHandle); - UnityEngine.SceneManagement.SceneManager.sceneLoaded += del; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(UnityEngineSceneManagementSceneManagerRemoveEventSceneLoadedDelegate))] - static void UnityEngineSceneManagementSceneManagerRemoveEventSceneLoaded(int delHandle) - { - try - { - var del = (UnityEngine.Events.UnityAction)NativeScript.Bindings.ObjectStore.Get(delHandle); - UnityEngine.SceneManagement.SceneManager.sceneLoaded += del; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(BoxSceneDelegate))] - static int BoxScene(ref UnityEngine.SceneManagement.Scene val) - { - try - { - var returnValue = NativeScript.Bindings.ObjectStore.Store((object)val); - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(UnboxSceneDelegate))] - static UnityEngine.SceneManagement.Scene UnboxScene(int valHandle) - { - try - { - var val = NativeScript.Bindings.ObjectStore.Get(valHandle); - var returnValue = (UnityEngine.SceneManagement.Scene)val; - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(UnityEngine.SceneManagement.Scene); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(UnityEngine.SceneManagement.Scene); - } - } - - [MonoPInvokeCallback(typeof(BoxLoadSceneModeDelegate))] - static int BoxLoadSceneMode(UnityEngine.SceneManagement.LoadSceneMode val) - { - try - { - var returnValue = NativeScript.Bindings.ObjectStore.Store((object)val); - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(UnboxLoadSceneModeDelegate))] - static UnityEngine.SceneManagement.LoadSceneMode UnboxLoadSceneMode(int valHandle) - { - try - { - var val = NativeScript.Bindings.ObjectStore.Get(valHandle); - var returnValue = (UnityEngine.SceneManagement.LoadSceneMode)val; - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(UnityEngine.SceneManagement.LoadSceneMode); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(UnityEngine.SceneManagement.LoadSceneMode); - } - } - - [MonoPInvokeCallback(typeof(BoxBooleanDelegate))] - static int BoxBoolean(bool val) - { - try - { - var returnValue = NativeScript.Bindings.ObjectStore.Store((object)val); - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(UnboxBooleanDelegate))] - static bool UnboxBoolean(int valHandle) - { - try - { - var val = NativeScript.Bindings.ObjectStore.Get(valHandle); - var returnValue = (bool)val; - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(bool); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(bool); - } - } - - [MonoPInvokeCallback(typeof(BoxSByteDelegate))] - static int BoxSByte(sbyte val) - { - try - { - var returnValue = NativeScript.Bindings.ObjectStore.Store((object)val); - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(UnboxSByteDelegate))] - static sbyte UnboxSByte(int valHandle) - { - try - { - var val = NativeScript.Bindings.ObjectStore.Get(valHandle); - var returnValue = (sbyte)val; - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(sbyte); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(sbyte); - } - } - - [MonoPInvokeCallback(typeof(BoxByteDelegate))] - static int BoxByte(byte val) - { - try - { - var returnValue = NativeScript.Bindings.ObjectStore.Store((object)val); - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(UnboxByteDelegate))] - static byte UnboxByte(int valHandle) - { - try - { - var val = NativeScript.Bindings.ObjectStore.Get(valHandle); - var returnValue = (byte)val; - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(byte); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(byte); - } - } - - [MonoPInvokeCallback(typeof(BoxInt16Delegate))] - static int BoxInt16(short val) - { - try - { - var returnValue = NativeScript.Bindings.ObjectStore.Store((object)val); - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(UnboxInt16Delegate))] - static short UnboxInt16(int valHandle) - { - try - { - var val = NativeScript.Bindings.ObjectStore.Get(valHandle); - var returnValue = (short)val; - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(short); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(short); - } - } - - [MonoPInvokeCallback(typeof(BoxUInt16Delegate))] - static int BoxUInt16(ushort val) - { - try - { - var returnValue = NativeScript.Bindings.ObjectStore.Store((object)val); - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(UnboxUInt16Delegate))] - static ushort UnboxUInt16(int valHandle) - { - try - { - var val = NativeScript.Bindings.ObjectStore.Get(valHandle); - var returnValue = (ushort)val; - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(ushort); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(ushort); - } - } - - [MonoPInvokeCallback(typeof(BoxInt32Delegate))] - static int BoxInt32(int val) - { - try - { - var returnValue = NativeScript.Bindings.ObjectStore.Store((object)val); - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(UnboxInt32Delegate))] - static int UnboxInt32(int valHandle) - { - try - { - var val = NativeScript.Bindings.ObjectStore.Get(valHandle); - var returnValue = (int)val; - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(BoxUInt32Delegate))] - static int BoxUInt32(uint val) - { - try - { - var returnValue = NativeScript.Bindings.ObjectStore.Store((object)val); - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(UnboxUInt32Delegate))] - static uint UnboxUInt32(int valHandle) - { - try - { - var val = NativeScript.Bindings.ObjectStore.Get(valHandle); - var returnValue = (uint)val; - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(uint); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(uint); - } - } - - [MonoPInvokeCallback(typeof(BoxInt64Delegate))] - static int BoxInt64(long val) - { - try - { - var returnValue = NativeScript.Bindings.ObjectStore.Store((object)val); - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(UnboxInt64Delegate))] - static long UnboxInt64(int valHandle) - { - try - { - var val = NativeScript.Bindings.ObjectStore.Get(valHandle); - var returnValue = (long)val; - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(long); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(long); - } - } - - [MonoPInvokeCallback(typeof(BoxUInt64Delegate))] - static int BoxUInt64(ulong val) - { - try - { - var returnValue = NativeScript.Bindings.ObjectStore.Store((object)val); - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(UnboxUInt64Delegate))] - static ulong UnboxUInt64(int valHandle) - { - try - { - var val = NativeScript.Bindings.ObjectStore.Get(valHandle); - var returnValue = (ulong)val; - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(ulong); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(ulong); - } - } - - [MonoPInvokeCallback(typeof(BoxCharDelegate))] - static int BoxChar(char val) - { - try - { - var returnValue = NativeScript.Bindings.ObjectStore.Store((object)val); - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(UnboxCharDelegate))] - static char UnboxChar(int valHandle) - { - try - { - var val = NativeScript.Bindings.ObjectStore.Get(valHandle); - var returnValue = (char)val; - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(char); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(char); - } - } - - [MonoPInvokeCallback(typeof(BoxSingleDelegate))] - static int BoxSingle(float val) - { - try - { - var returnValue = NativeScript.Bindings.ObjectStore.Store((object)val); - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(UnboxSingleDelegate))] - static float UnboxSingle(int valHandle) - { - try - { - var val = NativeScript.Bindings.ObjectStore.Get(valHandle); - var returnValue = (float)val; - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(float); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(float); - } - } - - [MonoPInvokeCallback(typeof(BoxDoubleDelegate))] - static int BoxDouble(double val) - { - try - { - var returnValue = NativeScript.Bindings.ObjectStore.Store((object)val); - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(UnboxDoubleDelegate))] - static double UnboxDouble(int valHandle) - { - try - { - var val = NativeScript.Bindings.ObjectStore.Get(valHandle); - var returnValue = (double)val; - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(double); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(double); - } - } - - [MonoPInvokeCallback(typeof(SystemSystemInt32Array1Constructor1Delegate))] - static int SystemSystemInt32Array1Constructor1(int length0) - { - try - { - var returnValue = NativeScript.Bindings.ObjectStore.Store(new int[length0]); - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(SystemInt32Array1GetItem1Delegate))] - static int SystemInt32Array1GetItem1(int thisHandle, int index0) - { - try - { - var thiz = (int[])NativeScript.Bindings.ObjectStore.Get(thisHandle); - var returnValue = thiz[index0]; - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(SystemInt32Array1SetItem1Delegate))] - static void SystemInt32Array1SetItem1(int thisHandle, int index0, int item) - { - try - { - var thiz = (int[])NativeScript.Bindings.ObjectStore.Get(thisHandle); - thiz[index0] = item; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(SystemSystemSingleArray1Constructor1Delegate))] - static int SystemSystemSingleArray1Constructor1(int length0) - { - try - { - var returnValue = NativeScript.Bindings.ObjectStore.Store(new float[length0]); - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(SystemSingleArray1GetItem1Delegate))] - static float SystemSingleArray1GetItem1(int thisHandle, int index0) - { - try - { - var thiz = (float[])NativeScript.Bindings.ObjectStore.Get(thisHandle); - var returnValue = thiz[index0]; - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(float); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(float); - } - } - - [MonoPInvokeCallback(typeof(SystemSingleArray1SetItem1Delegate))] - static void SystemSingleArray1SetItem1(int thisHandle, int index0, float item) - { - try - { - var thiz = (float[])NativeScript.Bindings.ObjectStore.Get(thisHandle); - thiz[index0] = item; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(SystemSystemSingleArray2Constructor2Delegate))] - static int SystemSystemSingleArray2Constructor2(int length0, int length1) - { - try - { - var returnValue = NativeScript.Bindings.ObjectStore.Store(new float[length0, length1]); - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(SystemSystemSingleArray2GetLength2Delegate))] - static int SystemSystemSingleArray2GetLength2(int thisHandle, int dimension) - { - try - { - var thiz = (float[,])NativeScript.Bindings.ObjectStore.Get(thisHandle); - var returnValue = thiz.GetLength(dimension); - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(SystemSingleArray2GetItem2Delegate))] - static float SystemSingleArray2GetItem2(int thisHandle, int index0, int index1) - { - try - { - var thiz = (float[,])NativeScript.Bindings.ObjectStore.Get(thisHandle); - var returnValue = thiz[index0, index1]; - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(float); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(float); - } - } - - [MonoPInvokeCallback(typeof(SystemSingleArray2SetItem2Delegate))] - static void SystemSingleArray2SetItem2(int thisHandle, int index0, int index1, float item) - { - try - { - var thiz = (float[,])NativeScript.Bindings.ObjectStore.Get(thisHandle); - thiz[index0, index1] = item; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(SystemSystemSingleArray3Constructor3Delegate))] - static int SystemSystemSingleArray3Constructor3(int length0, int length1, int length2) - { - try - { - var returnValue = NativeScript.Bindings.ObjectStore.Store(new float[length0, length1, length2]); - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(SystemSystemSingleArray3GetLength3Delegate))] - static int SystemSystemSingleArray3GetLength3(int thisHandle, int dimension) - { - try - { - var thiz = (float[,,])NativeScript.Bindings.ObjectStore.Get(thisHandle); - var returnValue = thiz.GetLength(dimension); - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(SystemSingleArray3GetItem3Delegate))] - static float SystemSingleArray3GetItem3(int thisHandle, int index0, int index1, int index2) - { - try - { - var thiz = (float[,,])NativeScript.Bindings.ObjectStore.Get(thisHandle); - var returnValue = thiz[index0, index1, index2]; - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(float); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(float); - } - } - - [MonoPInvokeCallback(typeof(SystemSingleArray3SetItem3Delegate))] - static void SystemSingleArray3SetItem3(int thisHandle, int index0, int index1, int index2, float item) - { - try - { - var thiz = (float[,,])NativeScript.Bindings.ObjectStore.Get(thisHandle); - thiz[index0, index1, index2] = item; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(SystemSystemStringArray1Constructor1Delegate))] - static int SystemSystemStringArray1Constructor1(int length0) - { - try - { - var returnValue = NativeScript.Bindings.ObjectStore.Store(new string[length0]); - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(SystemStringArray1GetItem1Delegate))] - static int SystemStringArray1GetItem1(int thisHandle, int index0) - { - try - { - var thiz = (string[])NativeScript.Bindings.ObjectStore.Get(thisHandle); - var returnValue = thiz[index0]; - return NativeScript.Bindings.ObjectStore.GetHandle(returnValue); - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(SystemStringArray1SetItem1Delegate))] - static void SystemStringArray1SetItem1(int thisHandle, int index0, int itemHandle) - { - try - { - var thiz = (string[])NativeScript.Bindings.ObjectStore.Get(thisHandle); - var item = (string)NativeScript.Bindings.ObjectStore.Get(itemHandle); - thiz[index0] = item; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(UnityEngineUnityEngineResolutionArray1Constructor1Delegate))] - static int UnityEngineUnityEngineResolutionArray1Constructor1(int length0) - { - try - { - var returnValue = NativeScript.Bindings.ObjectStore.Store(new UnityEngine.Resolution[length0]); - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(UnityEngineResolutionArray1GetItem1Delegate))] - static UnityEngine.Resolution UnityEngineResolutionArray1GetItem1(int thisHandle, int index0) - { - try - { - var thiz = (UnityEngine.Resolution[])NativeScript.Bindings.ObjectStore.Get(thisHandle); - var returnValue = thiz[index0]; - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(UnityEngine.Resolution); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(UnityEngine.Resolution); - } - } - - [MonoPInvokeCallback(typeof(UnityEngineResolutionArray1SetItem1Delegate))] - static void UnityEngineResolutionArray1SetItem1(int thisHandle, int index0, ref UnityEngine.Resolution item) - { - try - { - var thiz = (UnityEngine.Resolution[])NativeScript.Bindings.ObjectStore.Get(thisHandle); - thiz[index0] = item; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(UnityEngineUnityEngineRaycastHitArray1Constructor1Delegate))] - static int UnityEngineUnityEngineRaycastHitArray1Constructor1(int length0) - { - try - { - var returnValue = NativeScript.Bindings.ObjectStore.Store(new UnityEngine.RaycastHit[length0]); - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(UnityEngineRaycastHitArray1GetItem1Delegate))] - static int UnityEngineRaycastHitArray1GetItem1(int thisHandle, int index0) - { - try - { - var thiz = (UnityEngine.RaycastHit[])NativeScript.Bindings.ObjectStore.Get(thisHandle); - var returnValue = thiz[index0]; - return NativeScript.Bindings.StructStore.Store(returnValue); - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(UnityEngineRaycastHitArray1SetItem1Delegate))] - static void UnityEngineRaycastHitArray1SetItem1(int thisHandle, int index0, int itemHandle) - { - try - { - var thiz = (UnityEngine.RaycastHit[])NativeScript.Bindings.ObjectStore.Get(thisHandle); - var item = (UnityEngine.RaycastHit)NativeScript.Bindings.StructStore.Get(itemHandle); - thiz[index0] = item; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(UnityEngineUnityEngineGradientColorKeyArray1Constructor1Delegate))] - static int UnityEngineUnityEngineGradientColorKeyArray1Constructor1(int length0) - { - try - { - var returnValue = NativeScript.Bindings.ObjectStore.Store(new UnityEngine.GradientColorKey[length0]); - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(UnityEngineGradientColorKeyArray1GetItem1Delegate))] - static UnityEngine.GradientColorKey UnityEngineGradientColorKeyArray1GetItem1(int thisHandle, int index0) - { - try - { - var thiz = (UnityEngine.GradientColorKey[])NativeScript.Bindings.ObjectStore.Get(thisHandle); - var returnValue = thiz[index0]; - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(UnityEngine.GradientColorKey); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(UnityEngine.GradientColorKey); - } - } - - [MonoPInvokeCallback(typeof(UnityEngineGradientColorKeyArray1SetItem1Delegate))] - static void UnityEngineGradientColorKeyArray1SetItem1(int thisHandle, int index0, ref UnityEngine.GradientColorKey item) - { - try - { - var thiz = (UnityEngine.GradientColorKey[])NativeScript.Bindings.ObjectStore.Get(thisHandle); - thiz[index0] = item; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - class SystemAction - { - public int CppHandle; - public System.Action Delegate; - - public SystemAction(int cppHandle) - { - CppHandle = cppHandle; - Delegate = Invoke; - } - - public void Invoke() - { - if (CppHandle != 0) - { - int thisHandle = CppHandle; - NativeScript.Bindings.SystemActionCppInvoke(thisHandle); - if (NativeScript.Bindings.UnhandledCppException != null) - { - Exception ex = NativeScript.Bindings.UnhandledCppException; - NativeScript.Bindings.UnhandledCppException = null; - throw ex; - } - } - } - } - - [MonoPInvokeCallback(typeof(SystemActionConstructorDelegate))] - static void SystemActionConstructor(int cppHandle, ref int handle, ref int classHandle) - { - try - { - var thiz = new SystemAction(cppHandle); - classHandle = NativeScript.Bindings.ObjectStore.Store(thiz); - handle = NativeScript.Bindings.ObjectStore.Store(thiz.Delegate); - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(ReleaseSystemActionDelegate))] - static void ReleaseSystemAction(int handle, int classHandle) - { - try - { - if (classHandle != 0) - { - var thiz = (SystemAction)NativeScript.Bindings.ObjectStore.Remove(classHandle); - thiz.CppHandle = 0; - } - NativeScript.Bindings.ObjectStore.Remove(handle); - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(SystemActionInvokeDelegate))] - static void SystemActionInvoke(int thisHandle) - { - try - { - ((System.Action)NativeScript.Bindings.ObjectStore.Get(thisHandle))(); - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(SystemActionAddDelegate))] - static void SystemActionAdd(int thisHandle, int delHandle) - { - try - { - var thiz = (System.Action)NativeScript.Bindings.ObjectStore.Get(thisHandle); - var del = (System.Action)NativeScript.Bindings.ObjectStore.Get(delHandle); - thiz += del; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(SystemActionRemoveDelegate))] - static void SystemActionRemove(int thisHandle, int delHandle) - { - try - { - var thiz = (System.Action)NativeScript.Bindings.ObjectStore.Get(thisHandle); - var del = (System.Action)NativeScript.Bindings.ObjectStore.Get(delHandle); - thiz -= del; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - class SystemActionSystemSingle - { - public int CppHandle; - public System.Action Delegate; - - public SystemActionSystemSingle(int cppHandle) - { - CppHandle = cppHandle; - Delegate = Invoke; - } - - public void Invoke(float obj) - { - if (CppHandle != 0) - { - int thisHandle = CppHandle; - NativeScript.Bindings.SystemActionSystemSingleCppInvoke(thisHandle, obj); - if (NativeScript.Bindings.UnhandledCppException != null) - { - Exception ex = NativeScript.Bindings.UnhandledCppException; - NativeScript.Bindings.UnhandledCppException = null; - throw ex; - } - } - } - } - - [MonoPInvokeCallback(typeof(SystemActionSystemSingleConstructorDelegate))] - static void SystemActionSystemSingleConstructor(int cppHandle, ref int handle, ref int classHandle) - { - try - { - var thiz = new SystemActionSystemSingle(cppHandle); - classHandle = NativeScript.Bindings.ObjectStore.Store(thiz); - handle = NativeScript.Bindings.ObjectStore.Store(thiz.Delegate); - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(ReleaseSystemActionSystemSingleDelegate))] - static void ReleaseSystemActionSystemSingle(int handle, int classHandle) - { - try - { - if (classHandle != 0) - { - var thiz = (SystemActionSystemSingle)NativeScript.Bindings.ObjectStore.Remove(classHandle); - thiz.CppHandle = 0; - } - NativeScript.Bindings.ObjectStore.Remove(handle); - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(SystemActionSystemSingleInvokeDelegate))] - static void SystemActionSystemSingleInvoke(int thisHandle, float obj) - { - try - { - ((System.Action)NativeScript.Bindings.ObjectStore.Get(thisHandle))(obj); - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(SystemActionSystemSingleAddDelegate))] - static void SystemActionSystemSingleAdd(int thisHandle, int delHandle) - { - try - { - var thiz = (System.Action)NativeScript.Bindings.ObjectStore.Get(thisHandle); - var del = (System.Action)NativeScript.Bindings.ObjectStore.Get(delHandle); - thiz += del; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(SystemActionSystemSingleRemoveDelegate))] - static void SystemActionSystemSingleRemove(int thisHandle, int delHandle) - { - try - { - var thiz = (System.Action)NativeScript.Bindings.ObjectStore.Get(thisHandle); - var del = (System.Action)NativeScript.Bindings.ObjectStore.Get(delHandle); - thiz -= del; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - class SystemActionSystemSingle_SystemSingle - { - public int CppHandle; - public System.Action Delegate; - - public SystemActionSystemSingle_SystemSingle(int cppHandle) - { - CppHandle = cppHandle; - Delegate = Invoke; - } - - public void Invoke(float arg1, float arg2) - { - if (CppHandle != 0) - { - int thisHandle = CppHandle; - NativeScript.Bindings.SystemActionSystemSingle_SystemSingleCppInvoke(thisHandle, arg1, arg2); - if (NativeScript.Bindings.UnhandledCppException != null) - { - Exception ex = NativeScript.Bindings.UnhandledCppException; - NativeScript.Bindings.UnhandledCppException = null; - throw ex; - } - } - } - } - - [MonoPInvokeCallback(typeof(SystemActionSystemSingle_SystemSingleConstructorDelegate))] - static void SystemActionSystemSingle_SystemSingleConstructor(int cppHandle, ref int handle, ref int classHandle) - { - try - { - var thiz = new SystemActionSystemSingle_SystemSingle(cppHandle); - classHandle = NativeScript.Bindings.ObjectStore.Store(thiz); - handle = NativeScript.Bindings.ObjectStore.Store(thiz.Delegate); - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(ReleaseSystemActionSystemSingle_SystemSingleDelegate))] - static void ReleaseSystemActionSystemSingle_SystemSingle(int handle, int classHandle) - { - try - { - if (classHandle != 0) - { - var thiz = (SystemActionSystemSingle_SystemSingle)NativeScript.Bindings.ObjectStore.Remove(classHandle); - thiz.CppHandle = 0; - } - NativeScript.Bindings.ObjectStore.Remove(handle); - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(SystemActionSystemSingle_SystemSingleInvokeDelegate))] - static void SystemActionSystemSingle_SystemSingleInvoke(int thisHandle, float arg1, float arg2) - { - try - { - ((System.Action)NativeScript.Bindings.ObjectStore.Get(thisHandle))(arg1, arg2); - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(SystemActionSystemSingle_SystemSingleAddDelegate))] - static void SystemActionSystemSingle_SystemSingleAdd(int thisHandle, int delHandle) - { - try - { - var thiz = (System.Action)NativeScript.Bindings.ObjectStore.Get(thisHandle); - var del = (System.Action)NativeScript.Bindings.ObjectStore.Get(delHandle); - thiz += del; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(SystemActionSystemSingle_SystemSingleRemoveDelegate))] - static void SystemActionSystemSingle_SystemSingleRemove(int thisHandle, int delHandle) - { - try - { - var thiz = (System.Action)NativeScript.Bindings.ObjectStore.Get(thisHandle); - var del = (System.Action)NativeScript.Bindings.ObjectStore.Get(delHandle); - thiz -= del; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - class SystemFuncSystemInt32_SystemSingle_SystemDouble - { - public int CppHandle; - public System.Func Delegate; - - public SystemFuncSystemInt32_SystemSingle_SystemDouble(int cppHandle) - { - CppHandle = cppHandle; - Delegate = Invoke; - } - - public double Invoke(int arg1, float arg2) - { - if (CppHandle != 0) - { - int thisHandle = CppHandle; - var returnVal = NativeScript.Bindings.SystemFuncSystemInt32_SystemSingle_SystemDoubleCppInvoke(thisHandle, arg1, arg2); - if (NativeScript.Bindings.UnhandledCppException != null) - { - Exception ex = NativeScript.Bindings.UnhandledCppException; - NativeScript.Bindings.UnhandledCppException = null; - throw ex; - } - return returnVal; - } - return default(double); - } - } - - [MonoPInvokeCallback(typeof(SystemFuncSystemInt32_SystemSingle_SystemDoubleConstructorDelegate))] - static void SystemFuncSystemInt32_SystemSingle_SystemDoubleConstructor(int cppHandle, ref int handle, ref int classHandle) - { - try - { - var thiz = new SystemFuncSystemInt32_SystemSingle_SystemDouble(cppHandle); - classHandle = NativeScript.Bindings.ObjectStore.Store(thiz); - handle = NativeScript.Bindings.ObjectStore.Store(thiz.Delegate); - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(ReleaseSystemFuncSystemInt32_SystemSingle_SystemDoubleDelegate))] - static void ReleaseSystemFuncSystemInt32_SystemSingle_SystemDouble(int handle, int classHandle) - { - try - { - if (classHandle != 0) - { - var thiz = (SystemFuncSystemInt32_SystemSingle_SystemDouble)NativeScript.Bindings.ObjectStore.Remove(classHandle); - thiz.CppHandle = 0; - } - NativeScript.Bindings.ObjectStore.Remove(handle); - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(SystemFuncSystemInt32_SystemSingle_SystemDoubleInvokeDelegate))] - static double SystemFuncSystemInt32_SystemSingle_SystemDoubleInvoke(int thisHandle, int arg1, float arg2) - { - try - { - var returnValue = ((System.Func)NativeScript.Bindings.ObjectStore.Get(thisHandle))(arg1, arg2); - return returnValue; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(double); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(double); - } - } - - [MonoPInvokeCallback(typeof(SystemFuncSystemInt32_SystemSingle_SystemDoubleAddDelegate))] - static void SystemFuncSystemInt32_SystemSingle_SystemDoubleAdd(int thisHandle, int delHandle) - { - try - { - var thiz = (System.Func)NativeScript.Bindings.ObjectStore.Get(thisHandle); - var del = (System.Func)NativeScript.Bindings.ObjectStore.Get(delHandle); - thiz += del; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(SystemFuncSystemInt32_SystemSingle_SystemDoubleRemoveDelegate))] - static void SystemFuncSystemInt32_SystemSingle_SystemDoubleRemove(int thisHandle, int delHandle) - { - try - { - var thiz = (System.Func)NativeScript.Bindings.ObjectStore.Get(thisHandle); - var del = (System.Func)NativeScript.Bindings.ObjectStore.Get(delHandle); - thiz -= del; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - class SystemFuncSystemInt16_SystemInt32_SystemString - { - public int CppHandle; - public System.Func Delegate; - - public SystemFuncSystemInt16_SystemInt32_SystemString(int cppHandle) - { - CppHandle = cppHandle; - Delegate = Invoke; - } - - public string Invoke(short arg1, int arg2) - { - if (CppHandle != 0) - { - int thisHandle = CppHandle; - var returnVal = NativeScript.Bindings.SystemFuncSystemInt16_SystemInt32_SystemStringCppInvoke(thisHandle, arg1, arg2); - if (NativeScript.Bindings.UnhandledCppException != null) - { - Exception ex = NativeScript.Bindings.UnhandledCppException; - NativeScript.Bindings.UnhandledCppException = null; - throw ex; - } - return (string)NativeScript.Bindings.ObjectStore.Get(returnVal); - } - return default(string); - } - } - - [MonoPInvokeCallback(typeof(SystemFuncSystemInt16_SystemInt32_SystemStringConstructorDelegate))] - static void SystemFuncSystemInt16_SystemInt32_SystemStringConstructor(int cppHandle, ref int handle, ref int classHandle) - { - try - { - var thiz = new SystemFuncSystemInt16_SystemInt32_SystemString(cppHandle); - classHandle = NativeScript.Bindings.ObjectStore.Store(thiz); - handle = NativeScript.Bindings.ObjectStore.Store(thiz.Delegate); - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(ReleaseSystemFuncSystemInt16_SystemInt32_SystemStringDelegate))] - static void ReleaseSystemFuncSystemInt16_SystemInt32_SystemString(int handle, int classHandle) - { - try - { - if (classHandle != 0) - { - var thiz = (SystemFuncSystemInt16_SystemInt32_SystemString)NativeScript.Bindings.ObjectStore.Remove(classHandle); - thiz.CppHandle = 0; - } - NativeScript.Bindings.ObjectStore.Remove(handle); - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(SystemFuncSystemInt16_SystemInt32_SystemStringInvokeDelegate))] - static int SystemFuncSystemInt16_SystemInt32_SystemStringInvoke(int thisHandle, short arg1, int arg2) - { - try - { - var returnValue = ((System.Func)NativeScript.Bindings.ObjectStore.Get(thisHandle))(arg1, arg2); - return NativeScript.Bindings.ObjectStore.GetHandle(returnValue); - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - return default(int); - } - } - - [MonoPInvokeCallback(typeof(SystemFuncSystemInt16_SystemInt32_SystemStringAddDelegate))] - static void SystemFuncSystemInt16_SystemInt32_SystemStringAdd(int thisHandle, int delHandle) - { - try - { - var thiz = (System.Func)NativeScript.Bindings.ObjectStore.Get(thisHandle); - var del = (System.Func)NativeScript.Bindings.ObjectStore.Get(delHandle); - thiz += del; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(SystemFuncSystemInt16_SystemInt32_SystemStringRemoveDelegate))] - static void SystemFuncSystemInt16_SystemInt32_SystemStringRemove(int thisHandle, int delHandle) - { - try - { - var thiz = (System.Func)NativeScript.Bindings.ObjectStore.Get(thisHandle); - var del = (System.Func)NativeScript.Bindings.ObjectStore.Get(delHandle); - thiz -= del; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - class SystemAppDomainInitializer - { - public int CppHandle; - public System.AppDomainInitializer Delegate; - - public SystemAppDomainInitializer(int cppHandle) - { - CppHandle = cppHandle; - Delegate = Invoke; - } - - public void Invoke(string[] args) - { - if (CppHandle != 0) - { - int thisHandle = CppHandle; - int argsHandle = NativeScript.Bindings.ObjectStore.GetHandle(args); - NativeScript.Bindings.SystemAppDomainInitializerCppInvoke(thisHandle, argsHandle); - if (NativeScript.Bindings.UnhandledCppException != null) - { - Exception ex = NativeScript.Bindings.UnhandledCppException; - NativeScript.Bindings.UnhandledCppException = null; - throw ex; - } - } - } - } - - [MonoPInvokeCallback(typeof(SystemAppDomainInitializerConstructorDelegate))] - static void SystemAppDomainInitializerConstructor(int cppHandle, ref int handle, ref int classHandle) - { - try - { - var thiz = new SystemAppDomainInitializer(cppHandle); - classHandle = NativeScript.Bindings.ObjectStore.Store(thiz); - handle = NativeScript.Bindings.ObjectStore.Store(thiz.Delegate); - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(ReleaseSystemAppDomainInitializerDelegate))] - static void ReleaseSystemAppDomainInitializer(int handle, int classHandle) - { - try - { - if (classHandle != 0) - { - var thiz = (SystemAppDomainInitializer)NativeScript.Bindings.ObjectStore.Remove(classHandle); - thiz.CppHandle = 0; - } - NativeScript.Bindings.ObjectStore.Remove(handle); - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(SystemAppDomainInitializerInvokeDelegate))] - static void SystemAppDomainInitializerInvoke(int thisHandle, int argsHandle) - { - try - { - var args = (string[])NativeScript.Bindings.ObjectStore.Get(argsHandle); - ((System.AppDomainInitializer)NativeScript.Bindings.ObjectStore.Get(thisHandle))(args); - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(SystemAppDomainInitializerAddDelegate))] - static void SystemAppDomainInitializerAdd(int thisHandle, int delHandle) - { - try - { - var thiz = (System.AppDomainInitializer)NativeScript.Bindings.ObjectStore.Get(thisHandle); - var del = (System.AppDomainInitializer)NativeScript.Bindings.ObjectStore.Get(delHandle); - thiz += del; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(SystemAppDomainInitializerRemoveDelegate))] - static void SystemAppDomainInitializerRemove(int thisHandle, int delHandle) - { - try - { - var thiz = (System.AppDomainInitializer)NativeScript.Bindings.ObjectStore.Get(thisHandle); - var del = (System.AppDomainInitializer)NativeScript.Bindings.ObjectStore.Get(delHandle); - thiz -= del; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - class UnityEngineEventsUnityAction - { - public int CppHandle; - public UnityEngine.Events.UnityAction Delegate; - - public UnityEngineEventsUnityAction(int cppHandle) - { - CppHandle = cppHandle; - Delegate = Invoke; - } - - public void Invoke() - { - if (CppHandle != 0) - { - int thisHandle = CppHandle; - NativeScript.Bindings.UnityEngineEventsUnityActionCppInvoke(thisHandle); - if (NativeScript.Bindings.UnhandledCppException != null) - { - Exception ex = NativeScript.Bindings.UnhandledCppException; - NativeScript.Bindings.UnhandledCppException = null; - throw ex; - } - } - } - } - - [MonoPInvokeCallback(typeof(UnityEngineEventsUnityActionConstructorDelegate))] - static void UnityEngineEventsUnityActionConstructor(int cppHandle, ref int handle, ref int classHandle) - { - try - { - var thiz = new UnityEngineEventsUnityAction(cppHandle); - classHandle = NativeScript.Bindings.ObjectStore.Store(thiz); - handle = NativeScript.Bindings.ObjectStore.Store(thiz.Delegate); - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(ReleaseUnityEngineEventsUnityActionDelegate))] - static void ReleaseUnityEngineEventsUnityAction(int handle, int classHandle) - { - try - { - if (classHandle != 0) - { - var thiz = (UnityEngineEventsUnityAction)NativeScript.Bindings.ObjectStore.Remove(classHandle); - thiz.CppHandle = 0; - } - NativeScript.Bindings.ObjectStore.Remove(handle); - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(UnityEngineEventsUnityActionInvokeDelegate))] - static void UnityEngineEventsUnityActionInvoke(int thisHandle) - { - try - { - ((UnityEngine.Events.UnityAction)NativeScript.Bindings.ObjectStore.Get(thisHandle))(); - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(UnityEngineEventsUnityActionAddDelegate))] - static void UnityEngineEventsUnityActionAdd(int thisHandle, int delHandle) - { - try - { - var thiz = (UnityEngine.Events.UnityAction)NativeScript.Bindings.ObjectStore.Get(thisHandle); - var del = (UnityEngine.Events.UnityAction)NativeScript.Bindings.ObjectStore.Get(delHandle); - thiz += del; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(UnityEngineEventsUnityActionRemoveDelegate))] - static void UnityEngineEventsUnityActionRemove(int thisHandle, int delHandle) - { - try - { - var thiz = (UnityEngine.Events.UnityAction)NativeScript.Bindings.ObjectStore.Get(thisHandle); - var del = (UnityEngine.Events.UnityAction)NativeScript.Bindings.ObjectStore.Get(delHandle); - thiz -= del; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - class UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneMode - { - public int CppHandle; - public UnityEngine.Events.UnityAction Delegate; - - public UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneMode(int cppHandle) - { - CppHandle = cppHandle; - Delegate = Invoke; - } - - public void Invoke(UnityEngine.SceneManagement.Scene arg0, UnityEngine.SceneManagement.LoadSceneMode arg1) - { - if (CppHandle != 0) - { - int thisHandle = CppHandle; - NativeScript.Bindings.UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeCppInvoke(thisHandle, arg0, arg1); - if (NativeScript.Bindings.UnhandledCppException != null) - { - Exception ex = NativeScript.Bindings.UnhandledCppException; - NativeScript.Bindings.UnhandledCppException = null; - throw ex; - } - } - } - } - - [MonoPInvokeCallback(typeof(UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeConstructorDelegate))] - static void UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeConstructor(int cppHandle, ref int handle, ref int classHandle) - { - try - { - var thiz = new UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneMode(cppHandle); - classHandle = NativeScript.Bindings.ObjectStore.Store(thiz); - handle = NativeScript.Bindings.ObjectStore.Store(thiz.Delegate); - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(ReleaseUnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeDelegate))] - static void ReleaseUnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneMode(int handle, int classHandle) - { - try - { - if (classHandle != 0) - { - var thiz = (UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneMode)NativeScript.Bindings.ObjectStore.Remove(classHandle); - thiz.CppHandle = 0; - } - NativeScript.Bindings.ObjectStore.Remove(handle); - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeInvokeDelegate))] - static void UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeInvoke(int thisHandle, ref UnityEngine.SceneManagement.Scene arg0, UnityEngine.SceneManagement.LoadSceneMode arg1) - { - try - { - ((UnityEngine.Events.UnityAction)NativeScript.Bindings.ObjectStore.Get(thisHandle))(arg0, arg1); - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeAddDelegate))] - static void UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeAdd(int thisHandle, int delHandle) - { - try - { - var thiz = (UnityEngine.Events.UnityAction)NativeScript.Bindings.ObjectStore.Get(thisHandle); - var del = (UnityEngine.Events.UnityAction)NativeScript.Bindings.ObjectStore.Get(delHandle); - thiz += del; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - - [MonoPInvokeCallback(typeof(UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeRemoveDelegate))] - static void UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeRemove(int thisHandle, int delHandle) - { - try - { - var thiz = (UnityEngine.Events.UnityAction)NativeScript.Bindings.ObjectStore.Get(thisHandle); - var del = (UnityEngine.Events.UnityAction)NativeScript.Bindings.ObjectStore.Get(delHandle); - thiz -= del; - } - catch (System.NullReferenceException ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpExceptionSystemNullReferenceException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - catch (System.Exception ex) - { - UnityEngine.Debug.LogException(ex); - NativeScript.Bindings.SetCsharpException(NativeScript.Bindings.ObjectStore.Store(ex)); - } - } - /*END FUNCTIONS*/ - } -} - -/*BEGIN MONOBEHAVIOURS*/ -namespace MyGame -{ - namespace MonoBehaviours - { - public class TestScript : UnityEngine.MonoBehaviour - { - public void Awake() - { - int thisHandle = NativeScript.Bindings.ObjectStore.GetHandle(this); - NativeScript.Bindings.MyGameMonoBehavioursTestScriptAwake(thisHandle); - if (NativeScript.Bindings.UnhandledCppException != null) - { - Exception ex = NativeScript.Bindings.UnhandledCppException; - NativeScript.Bindings.UnhandledCppException = null; - throw ex; - } - } - - public void OnAnimatorIK(int param0) - { - int thisHandle = NativeScript.Bindings.ObjectStore.GetHandle(this); - NativeScript.Bindings.MyGameMonoBehavioursTestScriptOnAnimatorIK(thisHandle, param0); - if (NativeScript.Bindings.UnhandledCppException != null) - { - Exception ex = NativeScript.Bindings.UnhandledCppException; - NativeScript.Bindings.UnhandledCppException = null; - throw ex; - } - } - - public void OnCollisionEnter(UnityEngine.Collision param0) - { - int param0Handle = NativeScript.Bindings.ObjectStore.GetHandle(param0); - int thisHandle = NativeScript.Bindings.ObjectStore.GetHandle(this); - NativeScript.Bindings.MyGameMonoBehavioursTestScriptOnCollisionEnter(thisHandle, param0Handle); - if (NativeScript.Bindings.UnhandledCppException != null) - { - Exception ex = NativeScript.Bindings.UnhandledCppException; - NativeScript.Bindings.UnhandledCppException = null; - throw ex; - } - } - - public void Update() + if (CppHandle != 0) { - int thisHandle = NativeScript.Bindings.ObjectStore.GetHandle(this); - NativeScript.Bindings.MyGameMonoBehavioursTestScriptUpdate(thisHandle); + int thisHandle = CppHandle; + NativeScript.Bindings.MyGameAbstractBaseBallScriptUpdate(thisHandle); if (NativeScript.Bindings.UnhandledCppException != null) { Exception ex = NativeScript.Bindings.UnhandledCppException; @@ -5550,6 +2151,7 @@ public void Update() } } } + } } -/*END MONOBEHAVIOURS*/ \ No newline at end of file +/*END BASE TYPES*/ \ No newline at end of file diff --git a/Unity/Assets/NativeScript/BootScene.unity b/Unity/Assets/NativeScript/BootScene.unity index 49ab8b7..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 @@ -77,15 +77,18 @@ LightmapSettings: m_PVRDirectSampleCount: 32 m_PVRSampleCount: 500 m_PVRBounces: 2 - m_PVRFiltering: 0 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 m_PVRFilteringMode: 1 m_PVRCulling: 1 m_PVRFilteringGaussRadiusDirect: 1 m_PVRFilteringGaussRadiusIndirect: 5 m_PVRFilteringGaussRadiusAO: 2 - m_PVRFilteringAtrousColorSigma: 1 - m_PVRFilteringAtrousNormalSigma: 1 - m_PVRFilteringAtrousPositionSigma: 1 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ShowResolutionOverlay: 1 m_LightingDataAsset: {fileID: 0} m_UseShadowmask: 1 --- !u!196 &4 @@ -107,6 +110,8 @@ NavMeshSettings: manualTileSize: 0 tileSize: 256 accuratePlacement: 0 + debug: + m_Flags: 0 m_NavMeshData: {fileID: 0} --- !u!1 &643357608 GameObject: @@ -135,7 +140,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 6b5575a60b7c04c7a87ff4e161573c66, type: 3} m_Name: m_EditorClassIdentifier: - MaxManagedObjects: 1024 + MemorySize: 1048576 + AutoReload: 1 + AutoReloadPollTime: 1 --- !u!4 &643357610 Transform: m_ObjectHideFlags: 0 @@ -149,83 +156,82 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &1835393739 +--- !u!1 &1667680821 GameObject: m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} serializedVersion: 5 m_Component: - - component: {fileID: 1835393743} - - component: {fileID: 1835393742} - - component: {fileID: 1835393741} - - component: {fileID: 1835393740} + - component: {fileID: 1667680825} + - component: {fileID: 1667680824} + - component: {fileID: 1667680823} + - component: {fileID: 1667680822} m_Layer: 0 - m_Name: Sphere + m_Name: Camera m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!23 &1835393740 -MeshRenderer: +--- !u!81 &1667680822 +AudioListener: m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1835393739} + m_GameObject: {fileID: 1667680821} m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_PreserveUVs: 1 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 ---- !u!135 &1835393741 -SphereCollider: +--- !u!124 &1667680823 +Behaviour: m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1835393739} - m_Material: {fileID: 0} - m_IsTrigger: 0 + m_GameObject: {fileID: 1667680821} m_Enabled: 1 - serializedVersion: 2 - m_Radius: 0.5 - m_Center: {x: 0, y: 0, z: 0} ---- !u!33 &1835393742 -MeshFilter: +--- !u!20 &1667680824 +Camera: m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1835393739} - m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0} ---- !u!4 &1835393743 + m_GameObject: {fileID: 1667680821} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &1667680825 Transform: m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1835393739} + m_GameObject: {fileID: 1667680821} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalPosition: {x: 0, y: 0, z: -2} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} diff --git a/Unity/Assets/NativeScript/BootScript.cs b/Unity/Assets/NativeScript/BootScript.cs index 356f3a5..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 @@ -5,25 +7,89 @@ namespace NativeScript /// /// Script to run at app startup that initializes and runs the native plugin /// + /// /// /// Jackson Dunstan, 2017, http://JacksonDunstan.com /// + /// /// /// MIT /// - class BootScript : MonoBehaviour + public class BootScript : MonoBehaviour { - public int MaxManagedObjects = 1024; + public int MemorySize = 1024 * 1024 * 16; - void Awake() + // Reloading requires dynamic loading of the C++ plugin, which is only + // available in the editor +#if UNITY_EDITOR + public bool AutoReload; + + public float AutoReloadPollTime = 1.0f; + private float lastAutoReloadPollTime; + private Coroutine autoReloadCoroutine; + private Action onPlayModeStateChange; +#endif + + void Start() { +#if UNITY_EDITOR + lastAutoReloadPollTime = AutoReloadPollTime; +#endif DontDestroyOnLoad(gameObject); - Bindings.Open(MaxManagedObjects); + Bindings.Open(MemorySize); +#if UNITY_EDITOR + onPlayModeStateChange = OnEditorStateChanged; + EditorApplication.playModeStateChanged += onPlayModeStateChange; +#endif } - void OnApplicationQuit() +#if UNITY_EDITOR + void Update() + { + Bindings.Update(); + + if (AutoReload) + { + if (AutoReloadPollTime > 0) + { + // Not started yet. Start. + if (autoReloadCoroutine == null) + { + lastAutoReloadPollTime = AutoReloadPollTime; + autoReloadCoroutine = StartCoroutine( + Bindings.AutoReload( + AutoReloadPollTime)); + } + // Poll time changed. Restart. + else if (AutoReloadPollTime != lastAutoReloadPollTime) + { + StopCoroutine(autoReloadCoroutine); + lastAutoReloadPollTime = AutoReloadPollTime; + autoReloadCoroutine = StartCoroutine( + Bindings.AutoReload( + AutoReloadPollTime)); + } + } + } + else + { + // Not stopped yet. Stop. + if (autoReloadCoroutine != null) + { + StopCoroutine(autoReloadCoroutine); + autoReloadCoroutine = null; + } + } + } + + 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 new file mode 100644 index 0000000..a444732 --- /dev/null +++ b/Unity/Assets/NativeScript/Editor/EditorMenus.cs @@ -0,0 +1,30 @@ +using UnityEditor; + +namespace NativeScript.Editor +{ + /// + /// Menus for the Unity Editor + /// + /// + /// + /// Jackson Dunstan, 2018, http://JacksonDunstan.com + /// + /// + /// + /// MIT + /// + public static class EditorMenus + { + [MenuItem("NativeScript/Generate Bindings #%g")] + public static void Generate() + { + GenerateBindings.Generate(); + } + + [MenuItem("NativeScript/Reload Plugin #%r")] + public static void Reload() + { + Bindings.Reload(); + } + } +} diff --git a/Unity/Assets/NativeScript/Editor/EditorMenus.cs.meta b/Unity/Assets/NativeScript/Editor/EditorMenus.cs.meta new file mode 100644 index 0000000..ae3469a --- /dev/null +++ b/Unity/Assets/NativeScript/Editor/EditorMenus.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 5aad51de55c544325a293e98c996a550 +timeCreated: 1515806821 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/NativeScript/Editor/GenerateBindings.cs b/Unity/Assets/NativeScript/Editor/GenerateBindings.cs index 0ddb332..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,12 +8,11 @@ using UnityEditor; using UnityEngine; -namespace NativeScript +namespace NativeScript.Editor { /// /// Code generator that reads a JSON file and outputs C# and C++ code - /// bindings so C++ can call managed functions and MonoBehaviour "messages" - /// like Update() can call their C++ counterparts. + /// bindings so the languages can call each other. /// /// /// Jackson Dunstan, 2017, http://JacksonDunstan.com @@ -25,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 @@ -92,13 +91,20 @@ class JsonType public JsonEvent[] Events; public JsonGenericParams[] GenericParams; public int MaxSimultaneous; + public JsonBaseType[] BaseTypes; } [Serializable] - class JsonMonoBehaviour + class JsonBaseType { - public string Name; - public string[] Messages; + public string BaseName; + public string DerivedName; + public string[] GenericTypes; + public int MaxSimultaneous; + public JsonConstructor[] Constructors; + public JsonMethod[] OverrideMethods; + public JsonProperty[] OverrideProperties; + public JsonEvent[] OverrideEvents; } [Serializable] @@ -119,9 +125,10 @@ class JsonDelegate [Serializable] class JsonDocument { + public int MaxSimultaneousObjects; + public int DefaultMaxSimultaneous; public string[] Assemblies; public JsonType[] Types; - public JsonMonoBehaviour[] MonoBehaviours; public JsonArray[] Arrays; public JsonDelegate[] Delegates; } @@ -130,43 +137,55 @@ class JsonDocument class StringBuilders { - public StringBuilder CsharpInitParams = + public readonly StringBuilder CsharpDelegateTypes = + new StringBuilder(InitialStringBuilderCapacity); + public readonly StringBuilder CsharpStoreInitCalls = + new StringBuilder(InitialStringBuilderCapacity); + public readonly StringBuilder CsharpInitCall = + new StringBuilder(InitialStringBuilderCapacity); + public readonly StringBuilder CsharpBaseTypes = + new StringBuilder(InitialStringBuilderCapacity); + public readonly StringBuilder CsharpFunctions = + new StringBuilder(InitialStringBuilderCapacity); + public readonly StringBuilder CsharpCppDelegates = new StringBuilder(InitialStringBuilderCapacity); - public StringBuilder CsharpDelegateTypes = + public readonly StringBuilder CsharpCsharpDelegates = new StringBuilder(InitialStringBuilderCapacity); - public StringBuilder CsharpStructStoreInitCalls = + public readonly StringBuilder CsharpImports = new StringBuilder(InitialStringBuilderCapacity); - public StringBuilder CsharpInitCall = + public readonly StringBuilder CsharpGetDelegateCalls = new StringBuilder(InitialStringBuilderCapacity); - public StringBuilder CsharpFunctions = + public readonly StringBuilder CsharpDestroyFunctionEnumerators = new StringBuilder(InitialStringBuilderCapacity); - public StringBuilder CsharpMonoBehaviours = + public readonly StringBuilder CsharpDestroyQueueCases = new StringBuilder(InitialStringBuilderCapacity); - public StringBuilder CsharpDelegates = + public readonly StringBuilder CppFunctionPointers = new StringBuilder(InitialStringBuilderCapacity); - public StringBuilder CsharpImports = + public readonly StringBuilder CppTypeDeclarations = new StringBuilder(InitialStringBuilderCapacity); - public StringBuilder CsharpGetDelegateCalls = + public readonly StringBuilder CppTemplateDeclarations = new StringBuilder(InitialStringBuilderCapacity); - public StringBuilder CppFunctionPointers = + public readonly StringBuilder CppTemplateSpecializationDeclarations = new StringBuilder(InitialStringBuilderCapacity); - public StringBuilder CppTypeDeclarations = + public readonly StringBuilder CppTypeDefinitions = new StringBuilder(InitialStringBuilderCapacity); - public StringBuilder CppTypeDefinitions = + public readonly StringBuilder CppMethodDefinitions = new StringBuilder(InitialStringBuilderCapacity); - public StringBuilder CppMethodDefinitions = + public readonly StringBuilder CppInitBodyParameterReads = new StringBuilder(InitialStringBuilderCapacity); - public StringBuilder CppInitParams = + public readonly StringBuilder CppInitBodyArrays = new StringBuilder(InitialStringBuilderCapacity); - public StringBuilder CppInitBody = + public readonly StringBuilder CppInitBodyFirstBoot = new StringBuilder(InitialStringBuilderCapacity); - public StringBuilder CppMonoBehaviourMessages = + public readonly StringBuilder CppGlobalStateAndFunctions = new StringBuilder(InitialStringBuilderCapacity); - public StringBuilder CppGlobalStateAndFunctions = + public readonly StringBuilder CppUnboxingMethodDeclarations = new StringBuilder(InitialStringBuilderCapacity); - public StringBuilder CppBoxingMethodDeclarations = + public readonly StringBuilder CppStringDefaultParams = new StringBuilder(InitialStringBuilderCapacity); - public StringBuilder TempStrBuilder = + public readonly StringBuilder CppMacros = + new StringBuilder(InitialStringBuilderCapacity); + public readonly StringBuilder TempStrBuilder = new StringBuilder(InitialStringBuilderCapacity); } @@ -179,6 +198,9 @@ class ParameterInfo public bool IsRef; public TypeKind Kind; public bool IsVirtual; + public bool HasDefault; + public object DefaultValue; + public bool IsVarArg; } enum TypeKind @@ -206,10 +228,7 @@ enum TypeKind Primitive, // A pointer to any type, either X*, IntPtr, or UIntPtr - Pointer, - - // The decimal type - Decimal + Pointer } // Compares by field declaration order @@ -221,96 +240,30 @@ 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; } } - - class MessageInfo + + struct TypeName { public string Name; - public Type[] ParameterTypes; - public bool Selected; - - public MessageInfo( - string name, - params Type[] parameterTypes) - { - Name = name; - ParameterTypes = parameterTypes; - } - } - - static readonly MessageInfo[] messageInfos = new[] { - new MessageInfo("Awake"), - new MessageInfo("FixedUpdate"), - new MessageInfo("LateUpdate"), - new MessageInfo("OnAnimatorIK", typeof(int)), - new MessageInfo("OnAnimatorMove"), - new MessageInfo("OnApplicationFocus", typeof(bool)), - new MessageInfo("OnApplicationPause", typeof(bool)), - new MessageInfo("OnApplicationQuit"), - new MessageInfo("OnAudioFilterRead", typeof(float[]), typeof(int)), - new MessageInfo("OnBecameInvisible"), - new MessageInfo("OnBecameVisible"), - new MessageInfo("OnCollisionEnter", typeof(Collision)), - new MessageInfo("OnCollisionEnter2D", typeof(Collision2D)), - new MessageInfo("OnCollisionExit", typeof(Collision)), - new MessageInfo("OnCollisionExit2D", typeof(Collision2D)), - new MessageInfo("OnCollisionStay", typeof(Collision)), - new MessageInfo("OnCollisionStay2D", typeof(Collision2D)), - new MessageInfo("OnConnectedToServer"), - new MessageInfo("OnControllerColliderHit", typeof(ControllerColliderHit)), - new MessageInfo("OnDestroy"), - new MessageInfo("OnDisable"), - new MessageInfo("OnDisconnectedFromServer", typeof(NetworkDisconnection)), - new MessageInfo("OnDrawGizmos"), - new MessageInfo("OnDrawGizmosSelected"), - new MessageInfo("OnEnable"), - new MessageInfo("OnFailedToConnect", typeof(NetworkConnectionError)), - new MessageInfo("OnFailedToConnectToMasterServer", typeof(NetworkConnectionError)), - new MessageInfo("OnGUI"), - new MessageInfo("OnJointBreak", typeof(float)), - new MessageInfo("OnJointBreak2D", typeof(Joint2D)), - new MessageInfo("OnMasterServerEvent", typeof(MasterServerEvent)), - new MessageInfo("OnMouseDown"), - new MessageInfo("OnMouseDrag"), - new MessageInfo("OnMouseEnter"), - new MessageInfo("OnMouseExit"), - new MessageInfo("OnMouseOver"), - new MessageInfo("OnMouseUp"), - new MessageInfo("OnMouseUpAsButton"), - new MessageInfo("OnNetworkInstantiate", typeof(NetworkMessageInfo)), - new MessageInfo("OnParticleCollision", typeof(GameObject)), - new MessageInfo("OnParticleTrigger"), - new MessageInfo("OnPlayerConnected", typeof(NetworkPlayer)), - new MessageInfo("OnPlayerDisconnected", typeof(NetworkPlayer)), - new MessageInfo("OnPostRender"), - new MessageInfo("OnPreCull"), - new MessageInfo("OnPreRender"), - new MessageInfo("OnRenderImage", typeof(RenderTexture), typeof(RenderTexture)), - new MessageInfo("OnRenderObject"), - new MessageInfo("OnSerializeNetworkView", typeof(BitStream), typeof(NetworkMessageInfo)), - new MessageInfo("OnServerInitialized"), - new MessageInfo("OnTransformChildrenChanged"), - new MessageInfo("OnTransformParentChanged"), - new MessageInfo("OnTriggerEnter", typeof(Collider)), - new MessageInfo("OnTriggerEnter2D", typeof(Collider2D)), - new MessageInfo("OnTriggerExit", typeof(Collider)), - new MessageInfo("OnTriggerExit2D", typeof(Collider2D)), - new MessageInfo("OnTriggerStay", typeof(Collider)), - new MessageInfo("OnTriggerStay2D", typeof(Collider2D)), - new MessageInfo("OnValidate"), - new MessageInfo("OnWillRenderObject"), - new MessageInfo("Reset"), - new MessageInfo("Start"), - new MessageInfo("Update"), - }; + public string Namespace; + public int NumTypeParams; + } + + const int BaseMaxSimultaneous = 1000; - private static readonly Type[] PRIMITIVE_TYPES = new [] { + static readonly Type[] PrimitiveTypes = { typeof(bool), typeof(sbyte), typeof(byte), @@ -322,11 +275,10 @@ public MessageInfo( typeof(ulong), typeof(char), typeof(float), - typeof(double), + typeof(double) }; const string PostCompileWorkPref = "NativeScriptGenerateBindingsPostCompileWork"; - const string DryRunPref = "NativeScriptGenerateBindingsDryRun"; static readonly string DotNetDllsDirPath = new FileInfo( new Uri(typeof(string).Assembly.CodeBase).LocalPath @@ -335,14 +287,15 @@ public MessageInfo( 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( @@ -359,142 +312,174 @@ public MessageInfo( static readonly FieldOrderComparer DefaultFieldOrderComparer = new FieldOrderComparer(); - + // Restore unused field types - #pragma warning restore CS0649 + #pragma warning restore 649 - [MenuItem("NativeScript/Generate Bindings #%g")] public static void Generate() - { - Generate(false); - } - - [MenuItem("NativeScript/Generate Bindings (dry run) #%&g")] - public static void GenerateDryRun() - { - Generate(true); - } - - static void Generate(bool dryRun) { EditorPrefs.DeleteKey(PostCompileWorkPref); - EditorPrefs.SetBool(DryRunPref, dryRun); - if (dryRun) - { - DoPostCompileWork(true); - } - else + JsonDocument doc = LoadJson(); + Assembly[] assemblies = GetAssemblies(doc.Assemblies); + + // Determine whether we need to generate stubs + // We can skip this step if we've already generated all the + // required base types + bool needStubs = false; + if (doc.Types != null) { - JsonDocument doc = LoadJson(); - Assembly[] assemblies = GetAssemblies(doc.Assemblies); - - // Determine whether we need to generate stubs - // We can skip this step if we've already generated all the - // required MonoBehaviour classes and their messages - bool needStubs = false; - foreach (JsonMonoBehaviour monoBehaviour in doc.MonoBehaviours) - { - // Check if the MonoBehaviour type is already generated - Type type = TryGetType( - monoBehaviour.Name, - assemblies); - if (type == null) - { - needStubs = true; - break; - } - - // Check if all the messages are already generated - foreach (string message in monoBehaviour.Messages) + foreach (JsonType jsonType in doc.Types) + { + if (jsonType.BaseTypes != null) { - MethodInfo methodInfo = type.GetMethod(message); - if (methodInfo == null) + foreach (JsonBaseType jsonBaseType in jsonType.BaseTypes) { - needStubs = true; - goto determinedNeedStubs; + // Check if the type is already generated + Type type = TryGetType( + jsonBaseType.BaseName, + assemblies); + if (type == null) + { + needStubs = true; + goto determinedNeedStubs; + } } } } - determinedNeedStubs:; + } + determinedNeedStubs: + + if (needStubs) + { + // We'll need to be able to get these via reflection later + StringBuilders builders = new StringBuilders(); + string timestamp = DateTime.Now.ToLongTimeString(); + AppendStubs( + doc.Types, + assemblies, + timestamp, + builders); + InjectBuilders(builders); - if (needStubs) - { - // We'll need to be able to get these via reflection later - StringBuilder csharpMonoBehaviours = new StringBuilder( - InitialStringBuilderCapacity); - string timestamp = DateTime.Now.ToLongTimeString(); - AppendStubMonoBehaviours( - doc.MonoBehaviours, - timestamp, - csharpMonoBehaviours); - - // Inject - string csharpContents = File.ReadAllText(CsharpPath); - csharpContents = InjectIntoString( - csharpContents, - "/*BEGIN MONOBEHAVIOURS*/\n", - "\n/*END MONOBEHAVIOURS*/", - csharpMonoBehaviours.ToString()); - File.WriteAllText(CsharpPath, csharpContents); - - // Compile and continue after scripts are refreshed - Debug.Log("Waiting for compile..."); - AssetDatabase.Refresh(); - EditorPrefs.SetBool(PostCompileWorkPref, true); - } - else - { - DoPostCompileWork(true); - } + // Compile and continue after scripts are refreshed + Debug.Log("Waiting for compile..."); + EditorPrefs.SetBool(PostCompileWorkPref, true); + AssetDatabase.Refresh(); + } + else + { + DoPostCompileWork(true); } } - static void AppendStubMonoBehaviours( - JsonMonoBehaviour[] monoBehaviours, + static void AppendStubs( + JsonType[] jsonTypes, + Assembly[] assemblies, string timestamp, - StringBuilder output) + StringBuilders builders) { - if (monoBehaviours != null) + // Base types + foreach (JsonType jsonType in jsonTypes) { - foreach (JsonMonoBehaviour jsonMonoBehaviour in monoBehaviours) + if (jsonType.BaseTypes != null) { - // Split namespace from name - string fullName = jsonMonoBehaviour.Name; - string monoBehaviourName; - string monoBehaviourNamespace; - int index = fullName.LastIndexOf('.'); - if (index >= 0) + foreach (JsonBaseType jsonBaseType in jsonType.BaseTypes) { - monoBehaviourNamespace = fullName.Substring( - 0, - index); - monoBehaviourName = fullName.Substring( - index + 1); + string typeFullName = jsonType.Name; + TypeName typeName = SplitJsonTypeName(typeFullName); + + string baseTypeFullName = jsonBaseType.BaseName; + TypeName baseTypeName = SplitJsonTypeName(baseTypeFullName); + + Type type = GetType(typeFullName, assemblies); + + Type[] typeParams = GetTypes( + jsonBaseType.GenericTypes, + assemblies); + + AppendStubBaseType( + typeName, + baseTypeName, + typeParams, + type, + timestamp, + builders.CsharpBaseTypes); } - else + } + } + } + + static void AppendStubBaseType( + TypeName typeName, + TypeName baseTypeName, + Type[] typeParams, + Type type, + string timestamp, + StringBuilder output) + { + int indent = AppendNamespaceBeginning( + baseTypeName.Namespace, + output); + AppendIndent(indent, output); + if (type.IsClass) + { + output.Append("abstract public class "); + } + else + { + output.Append("public interface "); + } + output.Append(baseTypeName.Name); + output.Append(" : "); + AppendCsharpTypeFullName( + typeName, + output); + AppendCSharpTypeParameters( + typeParams, + output); + output.AppendLine(); + AppendIndent(indent, output); + output.AppendLine("{"); + AppendIndent(indent + 1, output); + output.Append("// Stub version. GenerateBindings is still in progress. "); + output.Append(timestamp); + output.AppendLine(); + if (type.IsClass) + { + output.AppendLine(); + ConstructorInfo[] constructors = type.GetConstructors(); + if (constructors.Length > 0) + { + foreach (ConstructorInfo ctor in constructors) { - monoBehaviourName = fullName; - monoBehaviourNamespace = string.Empty; + if (ctor.IsPublic + && ctor.GetCustomAttributes(typeof(ObsoleteAttribute), true).Length == 0) + { + ParameterInfo[] ctorParams = ConvertParameters( + ctor.GetParameters()); + output.Append("\t\t"); + output.Append(baseTypeName.Name); + output.Append('('); + AppendCsharpParams( + ctorParams, + output); + output.AppendLine(")"); + output.Append("\t\t\t: base("); + AppendCsharpFunctionCallParameters( + ctorParams, + output); + output.AppendLine(")"); + output.AppendLine("\t\t{"); + output.AppendLine("\t\t}"); + output.AppendLine("\t\t"); + break; + } } - - int indent = AppendNamespaceBeginning( - monoBehaviourNamespace, - output); - AppendIndent(indent, output); - output.Append("public class "); - output.Append(monoBehaviourName); - output.Append(" : UnityEngine.MonoBehaviour\n"); - AppendIndent(indent, output); - output.Append("{\n"); - AppendIndent(indent + 1, output); - output.Append("// Stub version. GenerateBindings is still in progress. "); - output.Append(timestamp); - output.Append('\n'); - AppendIndent(indent, output); - output.Append("}\n"); - AppendNamespaceEnding(indent, output); } } + AppendIndent(indent, output); + output.AppendLine("}"); + AppendNamespaceEnding(indent, output); } [UnityEditor.Callbacks.DidReloadScripts] @@ -512,47 +497,87 @@ static void OnScriptsReloaded() static void DoPostCompileWork(bool canRefreshAssetDb) { - bool dryRun = EditorPrefs.GetBool(DryRunPref); - EditorPrefs.DeleteKey(DryRunPref); - DateTime beforeTime = DateTime.Now; JsonDocument doc = LoadJson(); Assembly[] assemblies = GetAssemblies(doc.Assemblies); StringBuilders builders = new StringBuilders(); + // Get the default number of maximum simultaneous objects in case + // it's not specified for a specific type + int defaultMaxSimultaneous = doc.DefaultMaxSimultaneous != 0 + ? doc.DefaultMaxSimultaneous + : BaseMaxSimultaneous; + + // Init param for max managed Objects + builders.CsharpInitCall.Append("\t\t\tMarshal.WriteInt32(memory, curMemory, "); + builders.CsharpInitCall.Append(defaultMaxSimultaneous); + 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.AppendLine(");"); + // Generate types - foreach (JsonType jsonType in doc.Types) + if (doc.Types != null) { - AppendType( - jsonType, - assemblies, - builders); + foreach (JsonType jsonType in doc.Types) + { + Type type = GetType(jsonType.Name, assemblies); + TypeKind typeKind = GetTypeKind(type); + AppendType( + jsonType, + type, + typeKind, + assemblies, + defaultMaxSimultaneous, + builders); + + if (jsonType.BaseTypes != null) + { + Type[] genericArgTypes = type.GetGenericArguments(); + foreach (JsonBaseType jsonBaseType in jsonType.BaseTypes) + { + TypeName baseTypeTypeName = GetBaseTypeBaseNameAndNamespace( + jsonBaseType, + type, + genericArgTypes, + builders.TempStrBuilder); + AppendBaseType( + type, + baseTypeTypeName, + jsonBaseType, + assemblies, + defaultMaxSimultaneous, + builders); + } + } + } } // Generate boxing and unboxing for primitive types - foreach (Type type in PRIMITIVE_TYPES) + foreach (Type type in PrimitiveTypes) { - AppendBoxingUnboxing( + string dummyString; + ParameterInfo[] dummyParams; + AppendBoxingBindings( + type, + TypeKind.Primitive, + null, + builders, + out dummyString, + out dummyParams); + AppendUnboxing( type, TypeKind.Primitive, null, - assemblies, builders); } - // Generate MonoBehaviours - if (doc.MonoBehaviours != null) - { - foreach (JsonMonoBehaviour monoBehaviour in doc.MonoBehaviours) - { - AppendMonoBehaviour( - monoBehaviour, - assemblies, - builders); - } - } - // Generate arrays if (doc.Arrays != null) { @@ -565,6 +590,7 @@ static void DoPostCompileWork(bool canRefreshAssetDb) } } + // Generate delegates if (doc.Delegates != null) { foreach (JsonDelegate del in doc.Delegates) @@ -572,6 +598,7 @@ static void DoPostCompileWork(bool canRefreshAssetDb) AppendDelegate( del, assemblies, + defaultMaxSimultaneous, builders); } } @@ -582,31 +609,26 @@ static void DoPostCompileWork(bool canRefreshAssetDb) assemblies, builders); + // Output source files RemoveTrailingChars(builders); + InjectBuilders(builders); - if (dryRun) + // Inform the user of the result + if (canRefreshAssetDb) { - LogStringBuilders(builders); + AssetDatabase.Refresh(); + DateTime afterTime = DateTime.Now; + TimeSpan duration = afterTime - beforeTime; + Debug.LogFormat( + "Done generating bindings in {0} seconds.", + duration.TotalSeconds); } else { - InjectBuilders(builders); - if (canRefreshAssetDb) - { - AssetDatabase.Refresh(); - DateTime afterTime = DateTime.Now; - TimeSpan duration = afterTime - beforeTime; - Debug.LogFormat( - "Done generating bindings in {0} seconds.", - duration.TotalSeconds); - } - else - { - Debug.LogWarning( - "Can't auto-refresh due to a bug in Unity. " + - "Please manually refresh assets with " + - "Assets -> Refresh to finish generating bindings"); - } + Debug.LogWarning( + "Can't auto-refresh due to a bug in Unity. " + + "Please manually refresh assets with " + + "Assets -> Refresh to finish generating bindings"); } } @@ -614,7 +636,7 @@ static JsonDocument LoadJson() { string jsonPath = Path.Combine( Application.dataPath, - NativeScriptConstants.ExposedTypesJsonPath); + NativeScriptConstants.JSON_CONFIG_PATH); string json = File.ReadAllText(jsonPath); return JsonUtility.FromJson(json); } @@ -662,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; } @@ -790,6 +829,7 @@ static TypeKind GetTypeKind(Type type) static ParameterInfo[] GetConstructorParameters( Type type, + bool allowDefault, string[] paramTypeNames) { foreach (ConstructorInfo ctor in type.GetConstructors()) @@ -804,10 +844,15 @@ System.Reflection.ParameterInfo[] reflectionParams } } + if (allowDefault) + { + return new ParameterInfo[0]; + } + // Throw an exception so the user knows what to fix in the JSON StringBuilder errorBuilder = new StringBuilder(1024); errorBuilder.Append("Constructor \""); - AppendCsharpTypeName(type, errorBuilder); + AppendCsharpTypeFullName(type, errorBuilder); errorBuilder.Append('('); for (int i = 0; i < paramTypeNames.Length; ++i) { @@ -825,7 +870,8 @@ static MethodInfo GetMethod( Type type, MethodInfo[] methods, string methodName, - string[] paramTypeNames) + string[] paramTypeNames, + string[] genericTypeNames) { foreach (MethodInfo method in methods) { @@ -836,9 +882,17 @@ static MethodInfo GetMethod( } // All parameters must match - if (CheckParametersMatch( + if (!CheckParametersMatch( paramTypeNames, method.GetParameters())) + { + continue; + } + + // Generic arg count must match + Type[] methodGenericArgs = method.GetGenericArguments(); + int numGenericTypeNames = genericTypeNames == null ? 0 : genericTypeNames.Length; + if (methodGenericArgs.Length == numGenericTypeNames) { return method; } @@ -847,7 +901,7 @@ static MethodInfo GetMethod( // Throw an exception so the user knows what to fix in the JSON StringBuilder errorBuilder = new StringBuilder(1024); errorBuilder.Append("Method \""); - AppendCsharpTypeName(type, errorBuilder); + AppendCsharpTypeFullName(type, errorBuilder); errorBuilder.Append('.'); errorBuilder.Append(methodName); errorBuilder.Append('('); @@ -863,6 +917,108 @@ static MethodInfo GetMethod( throw new Exception(errorBuilder.ToString()); } + static Type[] GetDirectInterfaces(Type type) + { + Type[] allInterfaces = type.GetInterfaces(); + List minimalInterfaces = new List(); + foreach(Type iType in allInterfaces) + { + bool contains = false; + foreach (Type t in allInterfaces) + { + if (Array.IndexOf(t.GetInterfaces(), iType) >= 0) + { + contains = true; + break; + } + } + if (!contains) + { + minimalInterfaces.Add(iType); + } + } + minimalInterfaces.Sort( + (x, y) => string.Compare( + x.Name, + y.Name, + StringComparison.InvariantCulture)); + return minimalInterfaces.ToArray(); + } + + static void AddCppCtorInitType(Type type, List types) + { + if (type.BaseType != null + && type.BaseType != typeof(object) + && type.BaseType != typeof(ValueType)) + { + AddCppCtorInitType(type.BaseType, types); + } + foreach (Type interfaceType in GetDirectInterfaces(type)) + { + AddCppCtorInitType(interfaceType, types); + } + if (!types.Contains(type)) + { + types.Add(type); + } + } + + static Type[] GetCppCtorInitTypes(Type type, bool includeSelf) + { + List types = new List(); + AddCppCtorInitType(type, types); + if (!includeSelf) + { + types.RemoveAll(t => t == type); + } + return types.ToArray(); + } + + static void AppendCppConstructorInitializerList( + Type[] interfaceTypes, + int indent, + StringBuilder output, + string newline = null) + { + if (string.IsNullOrWhiteSpace(newline)) + { + newline = Environment.NewLine; + } + + string separator = ": "; + foreach (Type interfaceType in interfaceTypes) + { + AppendIndent(indent, output); + output.Append(separator); + AppendCppTypeFullName( interfaceType, output); + output.Append("(nullptr)"); + output.Append(newline); + separator = ", "; + } + } + + static void AppendUppercaseWithUnderscores( + string str, + StringBuilder output) + { + if (string.IsNullOrEmpty(str)) + { + return; + } + char prev = str[0]; + output.Append(char.ToUpper(prev)); + for (int i = 1; i < str.Length; ++i) + { + char cur = str[i]; + if (char.IsUpper(cur) && char.IsLower(prev)) + { + output.Append('_'); + } + output.Append(char.ToUpper(cur)); + prev = cur; + } + } + static bool CheckParametersMatch( string[] paramTypeNames, System.Reflection.ParameterInfo[] reflectionParams) @@ -946,6 +1102,11 @@ static void AppendParameterTypeNames( AppendTypeNameWithoutSuffixes( type.Name, output); + if (type.IsArray) + { + output.Append("Array"); + output.Append(type.GetArrayRank()); + } if (i != len - 1) { output.Append('_'); @@ -954,14 +1115,14 @@ static void AppendParameterTypeNames( } static void AppendTypeNames( - Type[] typeParams, + Type[] typeNames, StringBuilder output) { - if (typeParams != null) + if (typeNames != null) { - for (int i = 0, len = typeParams.Length; i < len; ++i) + for (int i = 0, len = typeNames.Length; i < len; ++i) { - Type curType = typeParams[i]; + Type curType = typeNames[i]; AppendNamespace( curType.Namespace, string.Empty, @@ -976,6 +1137,37 @@ static void AppendTypeNames( } } } + + static TypeName GetBaseTypeBaseNameAndNamespace( + JsonBaseType jsonBaseType, + Type type, + Type[] typeParams, + StringBuilder tempStringBuilder) + { + // Get specified (optional) base type name + TypeName baseTypeTypeName = SplitJsonTypeName(jsonBaseType.BaseName); + + // If base type name isn't provided, make one + if (string.IsNullOrEmpty(baseTypeTypeName.Name)) + { + tempStringBuilder.Length = 0; + AppendNamespace( + type.Namespace, + string.Empty, + tempStringBuilder); + tempStringBuilder.Append("Base"); + AppendTypeNameWithoutSuffixes( + type.Name, + tempStringBuilder); + AppendTypeNames( + typeParams, + tempStringBuilder); + baseTypeTypeName.Name = tempStringBuilder.ToString(); + } + + baseTypeTypeName.NumTypeParams = typeParams.Length; + return baseTypeTypeName; + } static void AppendNamespace( string namespaceName, @@ -999,7 +1191,6 @@ static void AppendNamespace( { break; } - break; } output.Append( namespaceName, @@ -1015,15 +1206,48 @@ static void AppendNamespace( namespaceName.Length - startIndex); } } + + static TypeName SplitJsonTypeName(string fullName) + { + string typeName; + string typeNamespace; + + // No full name + if (string.IsNullOrEmpty(fullName)) + { + typeName = string.Empty; + typeNamespace = string.Empty; + } + else + { + // Has a namespace + int index = fullName.LastIndexOf('.'); + if (index >= 0) + { + typeNamespace = fullName.Substring(0, index); + typeName = fullName.Substring(index + 1); + } + // No namespace. Just name. + else + { + typeName = fullName; + typeNamespace = string.Empty; + } + } + + return GetTypeName(typeName, typeNamespace); + } static ParameterInfo[] ConvertParameters( - System.Reflection.ParameterInfo[] reflectionParameters) + System.Reflection.ParameterInfo[] reflectionParameters, + int start = 0) { - int num = reflectionParameters.Length; + int num = reflectionParameters.Length - start; ParameterInfo[] parameters = new ParameterInfo[num]; - for (int i = 0; i < num; ++i) + for (int i = start; i < num; ++i) { - var reflectionInfo = reflectionParameters[i]; + System.Reflection.ParameterInfo reflectionInfo = + reflectionParameters[i]; ParameterInfo info = new ParameterInfo(); info.Name = reflectionInfo.Name; info.ParameterType = reflectionInfo.ParameterType; @@ -1033,7 +1257,14 @@ static ParameterInfo[] ConvertParameters( reflectionInfo); info.Kind = GetTypeKind( info.DereferencedParameterType); - parameters[i] = info; + info.HasDefault = (reflectionInfo.Attributes & + ParameterAttributes.HasDefault) == + ParameterAttributes.HasDefault; + info.DefaultValue = reflectionInfo.DefaultValue; + info.IsVarArg = reflectionInfo.IsDefined( + typeof(ParamArrayAttribute), + false); + parameters[i - start] = info; } return parameters; } @@ -1069,13 +1300,55 @@ static ParameterInfo[] ConvertParameters( } return parameters; } - - static bool IsStatic(Type type) + + static TypeName GetTypeName(Type type) { - return type.IsAbstract && type.IsSealed; + TypeName typeName; + typeName.Name = type.Name; + typeName.Namespace = type.Namespace; + typeName.NumTypeParams = type.GetGenericArguments().Length; + return typeName; } - - static bool IsManagedValueType(Type type) + + static TypeName GetTypeName( + string name, + string namespaceName) + { + TypeName typeName; + typeName.Name = name; + typeName.Namespace = namespaceName; + typeName.NumTypeParams = 0; + return typeName; + } + + static TypeName GetTypeName( + string name, + string namespaceName, + int numTypeParams) + { + TypeName typeName; + typeName.Name = name; + typeName.Namespace = namespaceName; + typeName.NumTypeParams = numTypeParams; + return typeName; + } + + static bool IsStatic(Type type) + { + return type.IsAbstract && type.IsSealed; + } + + static bool IsDelegate(Type type) + { + return typeof(Delegate).IsAssignableFrom(type); + } + + static bool IsNonDelegateClass(Type type) + { + return type.IsClass && !IsDelegate(type); + } + + static bool IsManagedValueType(Type type) { return type.IsValueType && !IsFullValueType(type); } @@ -1086,7 +1359,7 @@ static bool IsFullValueType(Type type) { return false; } - if (type.IsPrimitive || type.IsEnum) + if (type.IsPrimitive || type.IsEnum || type == typeof(void)) { return true; } @@ -1096,8 +1369,9 @@ static bool IsFullValueType(Type type) | BindingFlags.Public; foreach (FieldInfo field in type.GetFields(bindingFlags)) { - if (!field.IsStatic - && !IsFullValueType(field.FieldType)) + if (!field.IsPublic + || (!field.IsStatic + && !IsFullValueType(field.FieldType))) { return false; } @@ -1105,6 +1379,13 @@ static bool IsFullValueType(Type type) return true; } + static int ArrayIndexOf(T[] array, T value) + { + return array != null ? + Array.IndexOf(array, value) : + -1; + } + static void AppendTypeNameWithoutGenericSuffix( string typeName, StringBuilder output) @@ -1171,22 +1452,21 @@ static void AppendTypeNameWithoutSuffixes( static void AppendType( JsonType jsonType, + Type type, + TypeKind typeKind, Assembly[] assemblies, + int defaultMaxSimultaneous, StringBuilders builders) { - Type type = GetType(jsonType.Name, assemblies); - TypeKind typeKind = GetTypeKind(type); if (typeKind == TypeKind.Enum) { AppendEnum( type, - assemblies, builders); - AppendBoxingUnboxing( + AppendUnboxing( type, typeKind, null, - assemblies, builders); } else @@ -1197,10 +1477,8 @@ static void AppendType( if (!IsStatic(type)) { AppendCppTemplateDeclaration( - type.Name, - type.Namespace, - genericArgTypes.Length, - builders.CppTypeDeclarations); + GetTypeName(type), + builders.CppTemplateDeclarations); } foreach (JsonGenericParams jsonGenericParams @@ -1210,50 +1488,50 @@ static void AppendType( jsonGenericParams.Types, assemblies); Type genericType = type.MakeGenericType(typeParams); - int? maxSimultaneous = jsonGenericParams.MaxSimultaneous != 0 + int maxSimultaneous = jsonGenericParams.MaxSimultaneous != 0 ? jsonGenericParams.MaxSimultaneous : jsonType.MaxSimultaneous != 0 ? jsonType.MaxSimultaneous - : default(int?); + : defaultMaxSimultaneous; AppendType( jsonType, genericArgTypes, genericType, + typeKind, typeParams, maxSimultaneous, assemblies, builders); if (typeKind != TypeKind.Class) { - AppendBoxingUnboxing( + AppendUnboxing( genericType, typeKind, typeParams, - assemblies, builders); } } } else { - int? maxSimultaneous = jsonType.MaxSimultaneous != 0 + int maxSimultaneous = jsonType.MaxSimultaneous != 0 ? jsonType.MaxSimultaneous - : default(int?); + : defaultMaxSimultaneous; AppendType( jsonType, genericArgTypes, type, + typeKind, null, maxSimultaneous, assemblies, builders); if (typeKind != TypeKind.Class) { - AppendBoxingUnboxing( + AppendUnboxing( type, typeKind, null, - assemblies, builders); } } @@ -1264,49 +1542,29 @@ static void AppendType( JsonType jsonType, Type[] genericArgTypes, Type type, + TypeKind typeKind, Type[] typeParams, - int? maxSimultaneous, + int maxSimultaneous, Assembly[] assemblies, StringBuilders builders) { - builders.TempStrBuilder.Length = 0; - AppendTypeNameWithoutGenericSuffix( - type.Name, - builders.TempStrBuilder); - builders.TempStrBuilder[0] = char.ToLower( - builders.TempStrBuilder[0]); - string typeNameLower = builders.TempStrBuilder.ToString(); - bool isStatic = IsStatic(type); - TypeKind typeKind = GetTypeKind(type); if (!isStatic && typeKind == TypeKind.ManagedStruct) { // C# StructStore Init call - builders.CsharpStructStoreInitCalls.Append( + builders.CsharpStoreInitCalls.Append( "\t\t\tNativeScript.Bindings.StructStore<"); - AppendCsharpTypeName( + AppendCsharpTypeFullName( type, - builders.CsharpStructStoreInitCalls); - builders.CsharpStructStoreInitCalls.Append( - ">.Init("); - if (maxSimultaneous.HasValue) - { - builders.CsharpStructStoreInitCalls.Append( - maxSimultaneous.Value); - } - else - { - builders.CsharpStructStoreInitCalls.Append( - "maxManagedObjects"); - } - builders.CsharpStructStoreInitCalls.Append( - ");\n"); + builders.CsharpStoreInitCalls); + builders.CsharpStoreInitCalls.Append(">.Init("); + builders.CsharpStoreInitCalls.Append(maxSimultaneous); + builders.CsharpStoreInitCalls.AppendLine(");"); // Build function name suffix builders.TempStrBuilder.Length = 0; AppendReleaseFunctionNameSuffix( - type.Name, - type.Namespace, + GetTypeName(type), typeParams, builders.TempStrBuilder); string funcNameSuffix = builders.TempStrBuilder.ToString(); @@ -1315,17 +1573,11 @@ static void AppendType( builders.TempStrBuilder.Length = 0; builders.TempStrBuilder.Append("Release"); AppendReleaseFunctionNameSuffix( - type.Name, - type.Namespace, + GetTypeName(type), typeParams, 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"; @@ -1334,7 +1586,7 @@ static void AppendType( paramInfo.IsRef = false; paramInfo.DereferencedParameterType = typeof(int); paramInfo.Kind = TypeKind.Primitive; - ParameterInfo[] parameters = new[] { paramInfo }; + ParameterInfo[] parameters = { paramInfo }; // ReleaseX C# delegate type AppendCsharpDelegateType( @@ -1353,148 +1605,175 @@ static void AppendType( true, typeKind, typeof(void), - null, 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<"); - AppendCsharpTypeName( + 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], + parameters, builders.CsharpFunctions); // C++ function pointer definition AppendCppFunctionPointerDefinition( funcName, true, - null, - null, + default(TypeName), TypeKind.None, parameters, typeof(void), builders.CppFunctionPointers); - // C++ init param for ReleaseX - AppendCppInitParam( - funcNameLower, + // C++ init body for ReleaseX + AppendCppInitBodyFunctionPointerParameterRead( + funcName, true, - null, - null, + 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(" = new int32_t["); - if (maxSimultaneous.HasValue) - { - builders.CppInitBody.Append(maxSimultaneous.Value); - } - else - { - builders.CppInitBody.Append("maxManagedObjects"); - } - 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 int indent = AppendCppTypeDeclaration( - type.Namespace, - type.Name, + GetTypeName(type), isStatic, typeParams, - builders.CppTypeDeclarations); + typeParams != null ? + builders.CppTemplateSpecializationDeclarations : + builders.CppTypeDeclarations); // C++ type definition (beginning) + Type[] interfaceTypes = GetDirectInterfaces(type); + string baseTypeName; + string baseTypeNamespace; + Type[] baseTypeTypeParams; + switch (typeKind) + { + case TypeKind.FullStruct: + baseTypeName = null; + baseTypeNamespace = null; + baseTypeTypeParams = null; + break; + case TypeKind.ManagedStruct: + if (interfaceTypes.Length == 0) + { + baseTypeName = "ManagedType"; + baseTypeNamespace = "Plugin"; + baseTypeTypeParams = null; + } + else + { + baseTypeName = null; + baseTypeNamespace = null; + baseTypeTypeParams = null; + } + break; + default: + Type baseType = type.BaseType ?? typeof(object); + baseTypeName = baseType.Name; + baseTypeNamespace = baseType.Namespace; + baseTypeTypeParams = baseType.GetGenericArguments(); + break; + } + AppendCppTypeDefinitionBegin( - type.Name, - type.Namespace, + GetTypeName(type), typeKind, typeParams, - type.BaseType.Name, - type.BaseType.Namespace, - type.BaseType.GetGenericArguments(), + GetTypeName(baseTypeName, baseTypeNamespace), + baseTypeTypeParams, + interfaceTypes, isStatic, indent, builders.CppTypeDefinitions); // C++ method definition + Type[] cppCtorInterfaceTypes = GetCppCtorInitTypes( + type, + false); int cppMethodDefinitionsIndent = AppendCppMethodDefinitionsBegin( - type.Name, - type.Namespace, + GetTypeName(type), typeKind, typeParams, - type.BaseType.Name, - type.BaseType.Namespace, - type.BaseType.GetGenericArguments(), + cppCtorInterfaceTypes, isStatic, + (extraIndent, subject) => {}, + (extraIndent, subject) => {}, indent, builders.CppMethodDefinitions); @@ -1519,7 +1798,7 @@ static void AppendType( assemblies, typeParams, genericArgTypes, - typeNameLower, + cppCtorInterfaceTypes, indent, builders); } @@ -1571,6 +1850,7 @@ static void AppendType( } } + // Events if (jsonType.Events != null) { foreach (JsonEvent jsonEvent in jsonType.Events) @@ -1581,7 +1861,6 @@ static void AppendType( isStatic, typeKind, typeParams, - genericArgTypes, indent, builders ); @@ -1602,13 +1881,23 @@ static void AppendType( typeKind, methods, typeParams, - typeNameLower, genericArgTypes, indent, builders); } } + // Boxing + if (typeKind != TypeKind.Class) + { + AppendBoxing( + type, + typeKind, + typeParams, + indent, + builders); + } + // C++ type definition (ending) AppendCppTypeDefinitionEnd( isStatic, @@ -1619,20 +1908,90 @@ static void AppendType( AppendCppMethodDefinitionsEnd( cppMethodDefinitionsIndent, builders.CppMethodDefinitions); + + // Generate iterator if this type implements IEnumerable + Type[] allInterfaces = type.GetInterfaces(); + foreach (Type interfaceType in allInterfaces) + { + if (interfaceType.IsGenericType + && interfaceType.GetGenericTypeDefinition() == typeof(IEnumerable<>)) + { + builders.TempStrBuilder.Length = 0; + AppendNamespace( + type.Namespace, + string.Empty, + builders.TempStrBuilder); + AppendTypeNameWithoutGenericSuffix( + type.Name, + builders.TempStrBuilder); + AppendTypeNames( + typeParams, + builders.TempStrBuilder); + string bindingEnumerableTypeName = builders.TempStrBuilder.ToString(); + + Type elementType = interfaceType.GetGenericArguments()[0]; + AppendGenericEnumerableIterator( + type, + typeof(IEnumerator<>).MakeGenericType(elementType), + elementType, + bindingEnumerableTypeName, + builders.CppTypeDefinitions, + builders.CppMethodDefinitions); + break; + } + } + } + + static void AppendBaseType( + Type type, + TypeName cppBaseTypeTypeName, + JsonBaseType jsonBaseType, + Assembly[] assemblies, + int defaultMaxSimultaneous, + StringBuilders builders) + { + int maxSimultaneous = jsonBaseType.MaxSimultaneous != 0 + ? jsonBaseType.MaxSimultaneous + : defaultMaxSimultaneous; + if (jsonBaseType.GenericTypes != null) + { + Type[] typeParams = GetTypes( + jsonBaseType.GenericTypes, + assemblies); + Type genericType = type.MakeGenericType(typeParams); + AppendBaseType( + genericType, + jsonBaseType, + cppBaseTypeTypeName, + typeParams, + maxSimultaneous, + assemblies, + builders); + } + else + { + AppendBaseType( + type, + jsonBaseType, + cppBaseTypeTypeName, + null, + maxSimultaneous, + assemblies, + builders); + } } static void AppendReleaseFunctionNameSuffix( - string typeName, - string typeNamespace, + TypeName typeTypeName, Type[] typeParams, StringBuilder output) { AppendNamespace( - typeNamespace, + typeTypeName.Namespace, string.Empty, output); AppendTypeNameWithoutSuffixes( - typeName, + typeTypeName.Name, output); if (typeParams != null) { @@ -1656,136 +2015,353 @@ static void AppendReleaseFunctionNameSuffix( static void AppendEnum( Type type, - Assembly[] assemblies, StringBuilders builders) { - // C++ type declaration (actually definition) - int indent = AppendNamespaceBeginning( - type.Namespace, + // C++ type declaration + int indent = AppendCppTypeDeclaration( + GetTypeName(type), + false, + null, builders.CppTypeDeclarations); - AppendIndent( + + // C++ type definition (begin) + AppendCppTypeDefinitionBegin( + GetTypeName(type), + TypeKind.FullStruct, + null, + default(TypeName), + null, + null, + false, indent, - builders.CppTypeDeclarations); - builders.CppTypeDeclarations.Append("enum struct "); - builders.CppTypeDeclarations.Append(type.Name); - builders.CppTypeDeclarations.Append(" : "); - AppendCppTypeName( - Enum.GetUnderlyingType(type), - builders.CppTypeDeclarations); - builders.CppTypeDeclarations.Append('\n'); + builders.CppTypeDefinitions); AppendIndent( - indent, - builders.CppTypeDeclarations); - builders.CppTypeDeclarations.Append("{\n"); + indent + 1, + builders.CppTypeDefinitions); + + // Primitive type field + Type underlyingType = Enum.GetUnderlyingType(type); + AppendCppPrimitiveTypeName( + underlyingType, + builders.CppTypeDefinitions); + 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.CppTypeDeclarations); - builders.CppTypeDeclarations.Append(field.Name); - builders.CppTypeDeclarations.Append(" = "); - builders.CppTypeDeclarations.Append( - field.GetRawConstantValue()); - if (i != fields.Length - 1) - { - builders.CppTypeDeclarations.Append(','); - } - builders.CppTypeDeclarations.Append('\n'); + builders.CppTypeDefinitions); + builders.CppTypeDefinitions.Append("static const "); + AppendCppTypeFullName( + type, + builders.CppTypeDefinitions); + builders.CppTypeDefinitions.Append(' '); + builders.CppTypeDefinitions.Append(field.Name); + builders.CppTypeDefinitions.AppendLine(";"); } + + // Constructor from primitive type AppendIndent( - indent, - builders.CppTypeDeclarations); - builders.CppTypeDeclarations.Append("};\n"); - AppendNamespaceEnding( - indent, - builders.CppTypeDeclarations); - builders.CppTypeDeclarations.Append('\n'); - } - - static void AppendBoxingUnboxing( - Type type, - TypeKind typeKind, - Type[] typeParams, - Assembly[] assemblies, - StringBuilders builders) - { - builders.TempStrBuilder.Length = 0; - builders.TempStrBuilder.Append("Box"); - AppendTypeNameWithoutSuffixes( - type.Name, - builders.TempStrBuilder); - AppendTypeNames( - typeParams, - builders.TempStrBuilder); - string boxFuncName = builders.TempStrBuilder.ToString(); + indent + 1, + builders.CppTypeDefinitions); + builders.CppTypeDefinitions.Append("explicit "); + builders.CppTypeDefinitions.Append(type.Name); + builders.CppTypeDefinitions.Append('('); + AppendCppPrimitiveTypeName( + underlyingType, + builders.CppTypeDefinitions); + builders.CppTypeDefinitions.AppendLine(" value);"); - builders.TempStrBuilder[0] = char.ToLower( - builders.TempStrBuilder[0]); - string boxFuncNameLower = builders.TempStrBuilder.ToString(); + // Conversion operator to primitive type + AppendIndent( + indent + 1, + builders.CppTypeDefinitions); + builders.CppTypeDefinitions.Append("explicit operator "); + AppendCppPrimitiveTypeName( + underlyingType, + builders.CppTypeDefinitions); + builders.CppTypeDefinitions.AppendLine("() const;"); - builders.TempStrBuilder.Length = 0; - builders.TempStrBuilder.Append("Unbox"); - AppendTypeNameWithoutSuffixes( - type.Name, - builders.TempStrBuilder); - AppendTypeNames( - typeParams, - builders.TempStrBuilder); - string unboxFuncName = builders.TempStrBuilder.ToString(); + // Equality operator + AppendIndent( + indent + 1, + builders.CppTypeDefinitions); + builders.CppTypeDefinitions.Append("bool operator==("); + builders.CppTypeDefinitions.Append(type.Name); + builders.CppTypeDefinitions.AppendLine(" other);"); - builders.TempStrBuilder[0] = char.ToLower( - builders.TempStrBuilder[0]); - string unboxFuncNameLower = builders.TempStrBuilder.ToString(); + // Inequality operator + AppendIndent( + indent + 1, + builders.CppTypeDefinitions); + builders.CppTypeDefinitions.Append("bool operator!=("); + builders.CppTypeDefinitions.Append(type.Name); + builders.CppTypeDefinitions.AppendLine(" other);"); - builders.TempStrBuilder.Length = 0; - builders.TempStrBuilder.Append("operator "); - AppendCppTypeName( - type, - builders.TempStrBuilder); - string unboxMethodDefinitionName = builders.TempStrBuilder.ToString(); + AppendNamespaceBeginning( + type.Namespace, + builders.CppMethodDefinitions); - builders.TempStrBuilder.Length = 0; - builders.TempStrBuilder.Append("explicit "); - builders.TempStrBuilder.Append(unboxMethodDefinitionName); - string unboxMethodDeclarationName = builders.TempStrBuilder.ToString(); + // Constructor from primitive type + AppendIndent( + indent, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.Append(type.Name); + builders.CppMethodDefinitions.Append("::"); + builders.CppMethodDefinitions.Append(type.Name); + builders.CppMethodDefinitions.Append('('); + AppendCppPrimitiveTypeName( + underlyingType, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine(" value)"); + AppendIndent( + indent + 1, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine(": Value(value)"); + AppendIndent( + indent, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine("{"); + AppendIndent( + indent, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine("}"); + AppendIndent( + indent, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine(); - ParameterInfo[] boxParams = new [] { - new ParameterInfo - { - Name = "val", - ParameterType = type, - DereferencedParameterType = type, - IsOut = false, - IsRef = false, - Kind = typeKind - } - }; + // Conversion operator to primitive type + AppendIndent( + indent, + builders.CppMethodDefinitions); + AppendCppTypeFullName( + type, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.Append("::operator "); + AppendCppPrimitiveTypeName( + underlyingType, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine("() const"); + AppendIndent( + indent, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine("{"); + AppendIndent( + indent + 1, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine("return Value;"); + AppendIndent( + indent, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine("}"); + AppendIndent( + indent, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine();; + + // Equality operator + AppendIndent( + indent, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.Append("bool "); + AppendCppTypeFullName( + type, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.Append("::operator==("); + builders.CppMethodDefinitions.Append(type.Name); + builders.CppMethodDefinitions.AppendLine(" other)"); + AppendIndent( + indent, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine("{"); + AppendIndent( + indent + 1, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine("return Value == other.Value;"); + AppendIndent( + indent, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine("}"); + AppendIndent( + indent, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine();; + + // Inequality operator + AppendIndent( + indent, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.Append("bool "); + AppendCppTypeFullName( + type, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.Append("::operator!=("); + builders.CppMethodDefinitions.Append(type.Name); + builders.CppMethodDefinitions.AppendLine(" other)"); + AppendIndent( + indent, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine("{"); + AppendIndent( + indent + 1, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine("return Value != other.Value;"); + AppendIndent( + indent, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine("}"); + AppendIndent( + indent, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine();; + + AppendBoxing( + type, + TypeKind.Enum, + null, + indent, + builders); + + AppendNamespaceEnding( + indent, + builders.CppMethodDefinitions); + AppendIndent( + indent, + builders.CppTypeDefinitions); + builders.CppTypeDefinitions.AppendLine("};"); + AppendNamespaceEnding( + indent, + builders.CppTypeDefinitions); + builders.CppTypeDefinitions.AppendLine();; + + // Static initialization + foreach (FieldInfo field in fields) + { + builders.CppMethodDefinitions.Append("const "); + AppendCppTypeFullName( + type, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.Append(' '); + AppendCppTypeFullName( + type, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.Append("::"); + builders.CppMethodDefinitions.Append(field.Name); + builders.CppMethodDefinitions.Append('('); + builders.CppMethodDefinitions.Append( + field.GetRawConstantValue()); + builders.CppMethodDefinitions.AppendLine(");"); + } + builders.CppMethodDefinitions.AppendLine();; + } + + static void AppendBoxing( + Type type, + TypeKind typeKind, + Type[] typeParams, + int indent, + StringBuilders builders) + { + string boxFuncName; + ParameterInfo[] boxCppParams; + AppendBoxingBindings( + type, + typeKind, + typeParams, + builders, + out boxFuncName, + out boxCppParams); + + for (Type baseType = type.BaseType; + baseType != null; + baseType = baseType.BaseType) + { + string boxMethodDefinitionName; + string boxMethodDeclarationName; + AppendCppBoxingMethodNames( + baseType, + builders.TempStrBuilder, + out boxMethodDefinitionName, + out boxMethodDeclarationName); + AppendCppBoxingMethodDeclaration( + boxMethodDeclarationName, + boxCppParams, + indent + 1, + builders.CppTypeDefinitions); + AppendCppBoxingMethodDefinition( + type, + typeParams, + baseType, + typeKind, + boxMethodDefinitionName, + boxFuncName, + boxCppParams, + indent, + builders.CppMethodDefinitions); + } + foreach (Type interfaceType in type.GetInterfaces()) + { + string boxMethodDefinitionName; + string boxMethodDeclarationName; + AppendCppBoxingMethodNames( + interfaceType, + builders.TempStrBuilder, + out boxMethodDefinitionName, + out boxMethodDeclarationName); + AppendCppBoxingMethodDeclaration( + boxMethodDeclarationName, + boxCppParams, + indent + 1, + builders.CppTypeDefinitions); + AppendCppBoxingMethodDefinition( + type, + typeParams, + interfaceType, + typeKind, + boxMethodDefinitionName, + boxFuncName, + boxCppParams, + indent, + builders.CppMethodDefinitions); + } + } + + static void AppendBoxingBindings( + Type type, + TypeKind typeKind, + Type[] typeParams, + StringBuilders builders, + out string boxFuncName, + out ParameterInfo[] boxCppParams) + { + builders.TempStrBuilder.Length = 0; + builders.TempStrBuilder.Append("Box"); + AppendTypeNameWithoutSuffixes( + type.Name, + builders.TempStrBuilder); + AppendTypeNames( + typeParams, + builders.TempStrBuilder); + boxFuncName = builders.TempStrBuilder.ToString(); - ParameterInfo[] unboxParams = new [] { + ParameterInfo[] boxParams = { new ParameterInfo { Name = "val", - ParameterType = typeof(object), - DereferencedParameterType = typeof(object), + ParameterType = type, + DereferencedParameterType = type, IsOut = false, IsRef = false, - Kind = TypeKind.Class + Kind = typeKind } }; - ParameterInfo[] unboxCppParams = new ParameterInfo[0]; - - // C# init params - AppendCsharpInitParam( - boxFuncNameLower, - builders.CsharpInitParams); - AppendCsharpInitParam( - unboxFuncNameLower, - builders.CsharpInitParams); + boxCppParams = new ParameterInfo[0]; // C# delegate types AppendCsharpDelegateType( @@ -1796,22 +2372,12 @@ static void AppendBoxingUnboxing( typeof(object), boxParams, builders.CsharpDelegateTypes); - AppendCsharpDelegateType( - unboxFuncName, - true, - type, - typeKind, - type, - unboxParams, - builders.CsharpDelegateTypes); // C# init call args - AppendCsharpInitCallArg( + AppendCsharpCsharpDelegate( boxFuncName, - builders.CsharpInitCall); - AppendCsharpInitCallArg( - unboxFuncName, - builders.CsharpInitCall); + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); // C# box function AppendCsharpFunctionBeginning( @@ -1820,7 +2386,6 @@ static void AppendBoxingUnboxing( true, TypeKind.Class, typeof(object), - typeParams, boxParams, builders.CsharpFunctions); builders.CsharpFunctions.Append( @@ -1833,6 +2398,87 @@ static void AppendBoxingUnboxing( true, builders.CsharpFunctions); + // C++ function pointers + AppendCppFunctionPointerDefinition( + boxFuncName, + true, + GetTypeName(type), + typeKind, + boxParams, + typeof(object), + builders.CppFunctionPointers); + + // C++ init body + AppendCppInitBodyFunctionPointerParameterRead( + boxFuncName, + true, + GetTypeName(type), + typeKind, + boxParams, + typeof(object), + builders.CppInitBodyParameterReads); + } + + static void AppendUnboxing( + Type type, + TypeKind typeKind, + Type[] typeParams, + StringBuilders builders) + { + builders.TempStrBuilder.Length = 0; + builders.TempStrBuilder.Append("Unbox"); + AppendTypeNameWithoutSuffixes( + type.Name, + builders.TempStrBuilder); + AppendTypeNames( + typeParams, + builders.TempStrBuilder); + string unboxFuncName = builders.TempStrBuilder.ToString(); + + builders.TempStrBuilder.Length = 0; + builders.TempStrBuilder.Append("operator "); + AppendCppTypeFullName( + type, + builders.TempStrBuilder); + string unboxMethodDefinitionName = builders.TempStrBuilder.ToString(); + + builders.TempStrBuilder.Length = 0; + builders.TempStrBuilder.Append("explicit "); + builders.TempStrBuilder.Append(unboxMethodDefinitionName); + string unboxMethodDeclarationName = builders.TempStrBuilder.ToString(); + + ParameterInfo[] unboxParams = { + new ParameterInfo + { + Name = "val", + ParameterType = typeof(object), + DereferencedParameterType = typeof(object), + IsOut = false, + IsRef = false, + Kind = TypeKind.Class + } + }; + + ParameterInfo[] unboxCppParams = new ParameterInfo[0]; + + // C# init params + + // C# delegate types + AppendCsharpDelegateType( + unboxFuncName, + true, + type, + typeKind, + type, + unboxParams, + builders.CsharpDelegateTypes); + + // C# init call args + AppendCsharpCsharpDelegate( + unboxFuncName, + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); + // C# unbox function AppendCsharpFunctionBeginning( typeof(object), @@ -1840,7 +2486,6 @@ static void AppendBoxingUnboxing( true, TypeKind.Class, type, - null, unboxParams, builders.CsharpFunctions); switch (typeKind) @@ -1851,14 +2496,14 @@ static void AppendBoxingUnboxing( type, builders.CsharpFunctions); builders.CsharpFunctions.Append(".Store(("); - AppendCsharpTypeName( + AppendCsharpTypeFullName( type, builders.CsharpFunctions); builders.CsharpFunctions.Append(")val);"); break; default: builders.CsharpFunctions.Append('('); - AppendCsharpTypeName( + AppendCsharpTypeFullName( type, builders.CsharpFunctions); builders.CsharpFunctions.Append(")val;"); @@ -1873,41 +2518,19 @@ static void AppendBoxingUnboxing( builders.CsharpFunctions); // C++ function pointers - AppendCppFunctionPointerDefinition( - boxFuncName, - true, - type.Name, - type.Namespace, - typeKind, - boxParams, - typeof(object), - builders.CppFunctionPointers); AppendCppFunctionPointerDefinition( unboxFuncName, true, - type.Name, - type.Namespace, + GetTypeName(type), typeKind, unboxParams, type, builders.CppFunctionPointers); - // C++ method declarations - AppendIndent( - 2, - builders.CppBoxingMethodDeclarations); - AppendCppMethodDeclaration( - "Object", - false, - false, - false, - null, - null, - boxParams, - builders.CppBoxingMethodDeclarations); + // C++ unbox method declaration and definition AppendIndent( 2, - builders.CppBoxingMethodDeclarations); + builders.CppUnboxingMethodDeclarations); AppendCppMethodDeclaration( unboxMethodDeclarationName, false, @@ -1916,150 +2539,192 @@ static void AppendBoxingUnboxing( null, null, unboxCppParams, - builders.CppBoxingMethodDeclarations); - - // C++ method definitions (begin) + builders.CppUnboxingMethodDeclarations); int indent = AppendNamespaceBeginning( "System", builders.CppMethodDefinitions); - - // C++ box method definition AppendCppMethodDefinitionBegin( - "Object", + GetTypeName(typeof(object)), null, - "Object", + unboxMethodDefinitionName, null, null, - boxParams, + unboxCppParams, indent, builders.CppMethodDefinitions); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("int32_t handle = Plugin::"); - builders.CppMethodDefinitions.Append(boxFuncName); - builders.CppMethodDefinitions.Append("(val"); + AppendCppTypeFullName( + type, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.Append(" returnVal("); if (typeKind == TypeKind.ManagedStruct) { - builders.CppMethodDefinitions.Append(".Handle"); + builders.CppMethodDefinitions.Append("Plugin::InternalUse::Only, "); } - builders.CppMethodDefinitions.Append(");\n"); + builders.CppMethodDefinitions.Append("Plugin::"); + builders.CppMethodDefinitions.Append(unboxFuncName); + builders.CppMethodDefinitions.AppendLine("(Handle));"); AppendCppUnhandledExceptionHandling( indent + 1, builders.CppMethodDefinitions); AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "if (handle)\n"); + builders.CppMethodDefinitions.AppendLine("return returnVal;"); AppendIndent( - indent + 1, + indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "{\n"); - AppendIndent( - indent + 2, - builders.CppMethodDefinitions); - AppendReferenceManagedHandleFunctionCall( - "Object", - "System", - TypeKind.Class, - null, - "handle", - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append(";\n"); - AppendIndent( - indent + 2, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("Handle = handle;\n"); - AppendIndent( - indent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "}\n"); - AppendIndent( + builders.CppMethodDefinitions.AppendLine("}"); + builders.CppMethodDefinitions.AppendLine("\t"); + + // C++ method definitions (end) + AppendCppMethodDefinitionsEnd( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n\t\n"); - // C++ unbox method definition - AppendCppMethodDefinitionBegin( - "Object", + // C++ init body + AppendCppInitBodyFunctionPointerParameterRead( + unboxFuncName, + true, + GetTypeName(type), + typeKind, + unboxParams, + type, + builders.CppInitBodyParameterReads); + } + + static void AppendCppBoxingMethodNames( + Type baseType, + StringBuilder tempBuilder, + out string boxMethodDefinitionName, + out string boxMethodDeclarationName) + { + tempBuilder.Length = 0; + tempBuilder.Append("operator "); + AppendCppTypeFullName( + baseType, + tempBuilder); + boxMethodDefinitionName = tempBuilder.ToString(); + + tempBuilder.Length = 0; + tempBuilder.Append("explicit "); + tempBuilder.Append(boxMethodDefinitionName); + boxMethodDeclarationName = tempBuilder.ToString(); + } + + static void AppendCppBoxingMethodDeclaration( + string boxMethodDeclarationName, + ParameterInfo[] boxCppParams, + int indent, + StringBuilder output) + { + AppendIndent( + indent, + output); + AppendCppMethodDeclaration( + boxMethodDeclarationName, + false, + false, + false, null, - unboxMethodDefinitionName, null, + boxCppParams, + output); + } + + static void AppendCppBoxingMethodDefinition( + Type enclosingType, + Type[] enclosingTypeTypeParams, + Type boxedType, + TypeKind typeKind, + string boxMethodDefinitionName, + string boxFuncName, + ParameterInfo[] boxCppParams, + int indent, + StringBuilder output) + { + AppendCppMethodDefinitionBegin( + GetTypeName(enclosingType), + null, + boxMethodDefinitionName, + enclosingTypeTypeParams, null, - unboxCppParams, + boxCppParams, indent, - builders.CppMethodDefinitions); + output); AppendIndent( indent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + output); + output.AppendLine("{"); AppendIndent( indent + 1, - builders.CppMethodDefinitions); - AppendCppTypeName( - type, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append(" returnVal("); + output); + output.Append("int32_t handle = Plugin::"); + output.Append(boxFuncName); + output.Append('('); if (typeKind == TypeKind.ManagedStruct) { - builders.CppMethodDefinitions.Append("Plugin::InternalUse::Only, "); + output.Append("Handle"); } - builders.CppMethodDefinitions.Append("Plugin::"); - builders.CppMethodDefinitions.Append(unboxFuncName); - builders.CppMethodDefinitions.Append("(Handle));\n"); + else + { + output.Append("*this"); + } + output.AppendLine(");"); AppendCppUnhandledExceptionHandling( indent + 1, - builders.CppMethodDefinitions); + output); AppendIndent( indent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("return returnVal;\n"); + output); + output.AppendLine( + "if (handle)"); + AppendIndent( + indent + 1, + output); + output.AppendLine( + "{"); + AppendIndent( + indent + 2, + output); + AppendReferenceManagedHandleFunctionCall( + GetTypeName(typeof(object)), + TypeKind.Class, + null, + "handle", + output); + output.AppendLine(";"); + AppendIndent( + indent + 2, + output); + output.Append("return "); + AppendCppTypeFullName( + boxedType, + output); + output.AppendLine("(Plugin::InternalUse::Only, handle);"); + AppendIndent( + indent + 1, + output); + output.AppendLine( + "}"); + AppendIndent( + indent + 1, + output); + output.AppendLine("return nullptr;"); AppendIndent( indent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n\t\n"); - - // C++ method definitions (end) - AppendCppMethodDefinitionsEnd( + output); + output.AppendLine("}"); + AppendIndent( indent, - builders.CppMethodDefinitions); - - // C++ init params - AppendCppInitParam( - boxFuncNameLower, - true, - type.Name, - type.Namespace, - typeKind, - boxParams, - typeof(object), - builders.CppInitParams); - AppendCppInitParam( - unboxFuncNameLower, - true, - type.Name, - type.Namespace, - typeKind, - unboxParams, - type, - builders.CppInitParams); - - // C++ init body - AppendCppInitBody( - boxFuncName, - boxFuncNameLower, - builders.CppInitBody); - AppendCppInitBody( - unboxFuncName, - unboxFuncNameLower, - builders.CppInitBody); + output); + output.AppendLine();; } static void AppendHandleStoreTypeName( @@ -2070,7 +2735,7 @@ static void AppendHandleStoreTypeName( if (IsManagedValueType(type)) { output.Append("StructStore<"); - AppendCsharpTypeName(type, output); + AppendCsharpTypeFullName(type, output); output.Append('>'); } else @@ -2088,7 +2753,7 @@ static void AppendConstructor( Assembly[] assemblies, Type[] enclosingTypeParams, Type[] genericArgTypes, - string typeNameLower, + Type[] interfaceTypes, int indent, StringBuilders builders) { @@ -2118,6 +2783,7 @@ static void AppendConstructor( } parameters = GetConstructorParameters( enclosingType, + false, constructorParamTypeNames); } @@ -2143,15 +2809,16 @@ 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 + builders.TempStrBuilder.Length = 0; + AppendCppTypeName( + enclosingTypeTypeName, + builders.TempStrBuilder); + string cppMethodName = builders.TempStrBuilder.ToString(); // C# init param declaration - AppendCsharpInitParam( - funcNameLower, - builders.CsharpInitParams); // C# delegate type Type delegateReturnType; @@ -2173,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) @@ -2184,18 +2854,17 @@ static void AppendConstructor( true, enclosingTypeKind, enclosingType, - null, parameters, builders.CsharpFunctions); builders.CsharpFunctions.Append("new "); - AppendCsharpTypeName( + AppendCsharpTypeFullName( enclosingType, builders.CsharpFunctions); + builders.CsharpFunctions.Append('('); AppendCsharpFunctionCallParameters( - true, parameters, builders.CsharpFunctions); - builders.CsharpFunctions.Append(";"); + builders.CsharpFunctions.Append(");"); AppendCsharpFunctionReturn( parameters, enclosingType, @@ -2212,7 +2881,6 @@ static void AppendConstructor( true, enclosingTypeKind, typeof(int), - null, parameters, builders.CsharpFunctions); AppendHandleStoreTypeName( @@ -2220,14 +2888,14 @@ static void AppendConstructor( builders.CsharpFunctions); builders.CsharpFunctions.Append( ".Store(new "); - AppendCsharpTypeName( + AppendCsharpTypeFullName( enclosingType, builders.CsharpFunctions); + builders.CsharpFunctions.Append('('); AppendCsharpFunctionCallParameters( - true, parameters, builders.CsharpFunctions); - builders.CsharpFunctions.Append(");"); + builders.CsharpFunctions.Append("));"); AppendCsharpFunctionReturn( parameters, typeof(int), @@ -2241,8 +2909,7 @@ static void AppendConstructor( AppendCppFunctionPointerDefinition( funcName, true, - enclosingType.Name, - enclosingType.Namespace, + enclosingTypeTypeName, enclosingTypeKind, parameters, enclosingType, @@ -2253,7 +2920,7 @@ static void AppendConstructor( indent + 1, builders.CppTypeDefinitions); AppendCppMethodDeclaration( - enclosingType.Name, + cppMethodName, enclosingTypeIsStatic, false, false, @@ -2264,33 +2931,28 @@ static void AppendConstructor( // C++ method definition AppendCppMethodDefinitionBegin( - enclosingType.Name, + GetTypeName(enclosingType), null, - enclosingType.Name, + cppMethodName, enclosingTypeParams, null, parameters, indent, builders.CppMethodDefinitions); - if (enclosingTypeKind != TypeKind.FullStruct) + if (enclosingTypeKind == TypeKind.Class) { - AppendIndent( + AppendCppConstructorInitializerList( + interfaceTypes, indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append(" : "); - AppendCppTypeName( - enclosingType.BaseType, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("(nullptr)\n"); } AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendCppPluginFunctionCall( true, - enclosingType.Name, - enclosingType.Namespace, + GetTypeName(enclosingType), enclosingTypeKind, enclosingTypeParams, enclosingType, @@ -2303,68 +2965,60 @@ 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); AppendReferenceManagedHandleFunctionCall( - enclosingType.Name, - enclosingType.Namespace, + GetTypeName(enclosingType), enclosingTypeKind, 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, - enclosingType.Name, - enclosingType.Namespace, + GetTypeName(enclosingType), enclosingTypeKind, parameters, enclosingType, - builders.CppInitParams); - - // C++ init body - AppendCppInitBody( - funcName, - funcNameLower, - builders.CppInitBody); + builders.CppInitBodyParameterReads); } static void AppendProperty( @@ -2382,7 +3036,7 @@ static void AppendProperty( if (jsonPropertyGet != null) { PropertyInfo property = null; - MethodInfo getMethod = null; + MethodInfo getMethod; if (jsonPropertyGet.ParamTypes != null) { PropertyInfo[] properties = enclosingType.GetProperties(); @@ -2414,9 +3068,19 @@ static void AppendProperty( else { property = enclosingType.GetProperty(jsonProperty.Name); - getMethod = property.GetGetMethod(); } + if (property == null) + { + builders.TempStrBuilder.Length = 0; + builders.TempStrBuilder.Append("Property '"); + builders.TempStrBuilder.Append(jsonProperty.Name); + builders.TempStrBuilder.Append("' not found on "); + builders.TempStrBuilder.Append(enclosingType); + throw new Exception(builders.TempStrBuilder.ToString()); + } + + getMethod = property.GetGetMethod(); if (getMethod != null) { Type propertyType = property.PropertyType; @@ -2452,7 +3116,6 @@ static void AppendProperty( if (jsonPropertySet != null) { PropertyInfo property = null; - MethodInfo setMethod = null; if (jsonPropertySet.ParamTypes != null) { PropertyInfo[] properties = enclosingType.GetProperties(); @@ -2465,7 +3128,7 @@ static void AppendProperty( } // Must have a set method - setMethod = curProperty.GetSetMethod(); + MethodInfo setMethod = curProperty.GetSetMethod(); if (setMethod == null) { continue; @@ -2484,7 +3147,16 @@ static void AppendProperty( else { property = enclosingType.GetProperty(jsonProperty.Name); - setMethod = property.GetSetMethod(); + } + + if (property == null) + { + builders.TempStrBuilder.Length = 0; + builders.TempStrBuilder.Append("Property '"); + builders.TempStrBuilder.Append(jsonProperty.Name); + builders.TempStrBuilder.Append("' not found on "); + builders.TempStrBuilder.Append(enclosingType); + throw new Exception(builders.TempStrBuilder.ToString()); } MethodInfo method = property.GetSetMethod(); @@ -2509,7 +3181,6 @@ static void AppendProperty( jsonPropertySet.IsReadOnly, enclosingType, typeParams, - property.PropertyType, indent, exceptionTypes, builders); @@ -2528,7 +3199,7 @@ static void AppendFullValueTypeDefaultConstructor( AppendTypeNameWithoutGenericSuffix( enclosingType.Name, builders.CppTypeDefinitions); - builders.CppTypeDefinitions.Append("();\n"); + builders.CppTypeDefinitions.AppendLine("();"); AppendIndent( indent, @@ -2540,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( @@ -2570,12 +3241,12 @@ static void AppendFullValueTypeFields( AppendIndent( indent, builders.CppTypeDefinitions); - AppendCppTypeName( + AppendCppTypeFullName( field.FieldType, builders.CppTypeDefinitions); builders.CppTypeDefinitions.Append(' '); builders.CppTypeDefinitions.Append(field.Name); - builders.CppTypeDefinitions.Append(";\n"); + builders.CppTypeDefinitions.AppendLine(";"); } } @@ -2619,7 +3290,7 @@ static void AppendField( setParam.DereferencedParameterType = setParam.ParameterType; setParam.Kind = GetTypeKind( setParam.DereferencedParameterType); - ParameterInfo[] parameters = new []{ setParam }; + ParameterInfo[] parameters = { setParam }; AppendSetter( field.Name, "Field", @@ -2630,7 +3301,6 @@ static void AppendField( false, enclosingType, typeTypeParams, - fieldType, indent, exceptionTypes, builders); @@ -2642,7 +3312,6 @@ static void AppendEvent( bool enclosingTypeIsStatic, TypeKind enclosingTypeKind, Type[] typeTypeParams, - Type[] typeGenericArgumentTypes, int indent, StringBuilders builders) { @@ -2653,7 +3322,7 @@ static void AppendEvent( string uppercaseEventName = char.ToUpper(jsonEvent.Name[0]) + jsonEvent.Name.Substring(1); - ParameterInfo[] addRemoveParams = new ParameterInfo[] { + ParameterInfo[] addRemoveParams = { new ParameterInfo { Name = "del", ParameterType = eventType, @@ -2720,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, @@ -2745,9 +3407,10 @@ static void AppendEventAddRemoveMethod( builders.CsharpDelegateTypes); // C# init call arg - AppendCsharpInitCallArg( + AppendCsharpCsharpDelegate( funcName, - builders.CsharpInitCall); + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); // C# function AppendCsharpFunctionBeginning( @@ -2756,7 +3419,6 @@ static void AppendEventAddRemoveMethod( methodIsStatic, enclosingTypeKind, typeof(void), - typeTypeParams, methodParams, builders.CsharpFunctions); AppendCsharpFunctionCallSubject( @@ -2765,33 +3427,37 @@ 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, + methodParams, builders.CsharpFunctions); // C++ function pointer AppendCppFunctionPointerDefinition( funcName, methodIsStatic, - enclosingType.Name, - enclosingType.Namespace, + GetTypeName(enclosingType), enclosingTypeKind, methodParams, typeof(void), builders.CppFunctionPointers); // C++ method declaration - string cppMethodName; - bool cppMethodIsStatic; - ParameterInfo[] cppParameters; - ParameterInfo[] cppCallParameters; Type cppReturnType = typeof(void); - cppMethodName = methodName; - cppMethodIsStatic = methodIsStatic; - cppParameters = methodParams; - cppCallParameters = methodParams; + string cppMethodName = methodName; + bool cppMethodIsStatic = methodIsStatic; + ParameterInfo[] cppParameters = methodParams; + ParameterInfo[] cppCallParameters = methodParams; AppendIndent( indent + 1, builders.CppTypeDefinitions); @@ -2807,7 +3473,7 @@ static void AppendEventAddRemoveMethod( // C++ method definition AppendCppMethodDefinitionBegin( - enclosingType.Name, + GetTypeName(enclosingType), cppReturnType, cppMethodName, typeTypeParams, @@ -2818,11 +3484,10 @@ static void AppendEventAddRemoveMethod( AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendCppPluginFunctionCall( methodIsStatic, - enclosingType.Name, - enclosingType.Namespace, + GetTypeName(enclosingType), enclosingTypeKind, typeTypeParams, typeof(void), @@ -2833,38 +3498,27 @@ 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, - enclosingType.Name, - enclosingType.Namespace, + GetTypeName(enclosingType), enclosingTypeKind, methodParams, typeof(void), - builders.CppInitParams); - - // C++ init body - AppendCppInitBody( - funcName, - funcNameLower, - builders.CppInitBody); + builders.CppInitBodyParameterReads); } - static void AppendMethod( + static MethodInfo GetMethod( JsonMethod jsonMethod, - Assembly[] assemblies, Type enclosingType, - bool enclosingTypeIsStatic, - TypeKind enclosingTypeKind, - MethodInfo[] methods, Type[] typeTypeParams, - string typeNameLower, Type[] genericArgTypes, - int indent, - StringBuilders builders) + MethodInfo[] methods, + string[] methodGenericTypeNames) { // Map convenience method names to actual method names switch (jsonMethod.Name) @@ -2949,29 +3603,42 @@ static void AppendMethod( break; } - // Get the method - MethodInfo method; if (enclosingType.IsGenericType) { string[] overriddenParamTypeNames = OverrideGenericTypeNames( jsonMethod.ParamTypes, genericArgTypes, typeTypeParams); - method = GetMethod( + return GetMethod( enclosingType, methods, jsonMethod.Name, - overriddenParamTypeNames); + overriddenParamTypeNames, + methodGenericTypeNames); } else { - method = GetMethod( + return GetMethod( enclosingType, methods, jsonMethod.Name, - jsonMethod.ParamTypes); + jsonMethod.ParamTypes, + methodGenericTypeNames); } - + } + + static void AppendMethod( + JsonMethod jsonMethod, + Assembly[] assemblies, + Type enclosingType, + bool enclosingTypeIsStatic, + TypeKind enclosingTypeKind, + MethodInfo[] methods, + Type[] typeTypeParams, + Type[] genericArgTypes, + int indent, + StringBuilders builders) + { Type[] exceptionTypes = GetTypes( jsonMethod.Exceptions, assemblies); @@ -2979,9 +3646,17 @@ static void AppendMethod( if (jsonMethod.GenericParams != null) { // Generate for each set of generic types + bool generateDeclaration = true; foreach (JsonGenericParams jsonGenericParams in jsonMethod.GenericParams) { + MethodInfo method = GetMethod( + jsonMethod, + enclosingType, + typeTypeParams, + genericArgTypes, + methods, + jsonGenericParams.Types); Type[] methodTypeParams = GetTypes( jsonGenericParams.Types, assemblies); @@ -2992,8 +3667,6 @@ static void AppendMethod( TypeKind returnTypeKind = GetTypeKind(returnType); AppendMethod( enclosingType, - assemblies, - typeNameLower, method.Name, enclosingTypeIsStatic, enclosingTypeKind, @@ -3004,21 +3677,28 @@ static void AppendMethod( typeTypeParams, methodTypeParams, parameters, + generateDeclaration, indent, exceptionTypes, builders); + generateDeclaration = false; } } else { + MethodInfo method = GetMethod( + jsonMethod, + enclosingType, + typeTypeParams, + genericArgTypes, + methods, + null); ParameterInfo[] parameters = ConvertParameters( method.GetParameters()); Type returnType = method.ReturnType; TypeKind returnTypeKind = GetTypeKind(returnType); AppendMethod( enclosingType, - assemblies, - typeNameLower, method.Name, enclosingTypeIsStatic, enclosingTypeKind, @@ -3029,6 +3709,7 @@ static void AppendMethod( typeTypeParams, null, parameters, + true, indent, exceptionTypes, builders); @@ -3044,7 +3725,7 @@ static Type OverrideGenericType( { for (int i = 0, len = genericArgumentTypes.Length; i < len; ++i) { - if (genericType.Equals(genericArgumentTypes[i])) + if (genericType == genericArgumentTypes[i]) { return overrideTypes[i]; } @@ -3058,9 +3739,8 @@ static void OverrideGenericParameterTypes( Type[] typeGenericArgumentTypes, Type[] typeParams) { - for (int i = 0; i < parameters.Length; ++i) + foreach (ParameterInfo info in parameters) { - ParameterInfo info = parameters[i]; info.ParameterType = OverrideGenericType( info.ParameterType, typeGenericArgumentTypes, @@ -3078,11 +3758,11 @@ static string[] OverrideGenericTypeNames( for (int i = 0; i < numParams; ++i) { string typeName = typeNames[i]; - for (int j = 0; j < genericArgTypes.Length; ++j) + foreach (Type genericArgType in genericArgTypes) { if (CheckTypeNameMatches( typeName, - genericArgTypes[j])) + genericArgType)) { typeName = typeParams[i].FullName; break; @@ -3095,8 +3775,6 @@ static string[] OverrideGenericTypeNames( static void AppendMethod( Type enclosingType, - Assembly[] assemblies, - string typeNameLower, string methodName, bool enclosingTypeIsStatic, TypeKind enclosingTypeKind, @@ -3107,6 +3785,7 @@ static void AppendMethod( Type[] enclosingTypeParams, Type[] methodTypeParams, ParameterInfo[] parameters, + bool generateDeclaration, int indent, Type[] exceptionTypes, StringBuilders builders) @@ -3133,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, @@ -3154,9 +3825,10 @@ static void AppendMethod( builders.CsharpDelegateTypes); // C# init call param - AppendCsharpInitCallArg( + AppendCsharpCsharpDelegate( funcName, - builders.CsharpInitCall); + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); // C# function AppendCsharpFunctionBeginning( @@ -3165,7 +3837,6 @@ static void AppendMethod( methodIsStatic, enclosingTypeKind, returnType, - methodTypeParams, parameters, builders.CsharpFunctions); if (methodName.StartsWith("op_")) @@ -3291,13 +3962,15 @@ static void AppendMethod( AppendCSharpTypeParameters( methodTypeParams, builders.CsharpFunctions); + builders.CsharpFunctions.Append('('); AppendCsharpFunctionCallParameters( - methodIsStatic, parameters, builders.CsharpFunctions); + builders.CsharpFunctions.Append(')'); } builders.CsharpFunctions.Append(';'); if (!isReadOnly + && !methodIsStatic && enclosingTypeKind == TypeKind.ManagedStruct) { AppendStructStoreReplace( @@ -3318,8 +3991,7 @@ static void AppendMethod( AppendCppFunctionPointerDefinition( funcName, methodIsStatic, - enclosingType.Name, - enclosingType.Namespace, + GetTypeName(enclosingType), enclosingTypeKind, parameters, returnType, @@ -3356,7 +4028,7 @@ static void AppendMethod( case "op_Implicit": builders.TempStrBuilder.Length = 0; builders.TempStrBuilder.Append("operator "); - AppendCppTypeName( + AppendCppTypeFullName( returnType, builders.TempStrBuilder); cppMethodName = builders.TempStrBuilder.ToString(); @@ -3365,7 +4037,7 @@ static void AppendMethod( case "op_Explicit": builders.TempStrBuilder.Length = 0; builders.TempStrBuilder.Append("explicit operator "); - AppendCppTypeName( + AppendCppTypeFullName( returnType, builders.TempStrBuilder); cppMethodName = builders.TempStrBuilder.ToString(); @@ -3483,22 +4155,26 @@ static void AppendMethod( cppParameters = parameters; cppCallParameters = parameters; } - AppendIndent( - indent + 1, - builders.CppTypeDefinitions); - AppendCppMethodDeclaration( - cppMethodName, - enclosingTypeIsStatic, - false, - cppMethodIsStatic, - cppReturnType, - methodTypeParams, - cppParameters, - builders.CppTypeDefinitions); - + if (generateDeclaration) + { + AppendIndent( + indent + 1, + builders.CppTypeDefinitions); + AppendCppMethodDeclaration( + cppMethodName, + enclosingTypeIsStatic, + // Mark as virtual if method/class is not static or generic + cppMethodIsStatic || enclosingTypeIsStatic || methodTypeParams != null? false : true, + cppMethodIsStatic, + cppReturnType, + methodTypeParams, + cppParameters, + builders.CppTypeDefinitions); + } + // C++ method definition AppendCppMethodDefinitionBegin( - enclosingType.Name, + GetTypeName(enclosingType), cppReturnType, cppMethodName, enclosingTypeParams, @@ -3509,11 +4185,10 @@ static void AppendMethod( AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendCppPluginFunctionCall( methodIsStatic, - enclosingType.Name, - enclosingType.Namespace, + GetTypeName(enclosingType), enclosingTypeKind, enclosingTypeParams, returnType, @@ -3529,30 +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, - enclosingType.Name, - enclosingType.Namespace, + 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) { @@ -3560,7 +4228,7 @@ StringBuilder output for (int i = 0; i < typeParams.Length; ++i) { Type typeParam = typeParams[i]; - AppendCsharpTypeName(typeParam, output); + AppendCsharpTypeFullName(typeParam, output); if (i != typeParams.Length - 1) { output.Append(", "); @@ -3580,7 +4248,7 @@ static void AppendCppTypeParameters( for (int i = 0; i < typeParams.Length; ++i) { Type typeParam = typeParams[i]; - AppendCppTypeName(typeParam, output); + AppendCppTypeFullName(typeParam, output); if (i != typeParams.Length - 1) { output.Append(", "); @@ -3589,311 +4257,19 @@ static void AppendCppTypeParameters( output.Append('>'); } } - - static void AppendMonoBehaviour( - JsonMonoBehaviour jsonMonoBehaviour, - Assembly[] assemblies, - StringBuilders builders) - { - Type type = GetType( - jsonMonoBehaviour.Name, - assemblies); - - // C++ Type Declaration - int cppIndent = AppendCppTypeDeclaration( - type.Namespace, - type.Name, - false, - null, - builders.CppTypeDeclarations); - - // C++ Type Definition (begin) - AppendCppTypeDefinitionBegin( - type.Name, - type.Namespace, - TypeKind.Class, - null, - "MonoBehaviour", - "UnityEngine", - null, - false, - cppIndent, - builders.CppTypeDefinitions); - - // C++ method definition - int cppMethodDefinitionsIndent = AppendCppMethodDefinitionsBegin( - type.Name, - type.Namespace, - TypeKind.Class, - null, - "MonoBehaviour", - "UnityEngine", - null, - false, - cppIndent, - builders.CppMethodDefinitions); - AppendCppMethodDefinitionsEnd( - cppMethodDefinitionsIndent, - builders.CppMethodDefinitions); - - // C# Class extending MonoBehaviour - int csharpIndent = AppendNamespaceBeginning( - type.Namespace, - builders.CsharpMonoBehaviours); - AppendIndent(csharpIndent, builders.CsharpMonoBehaviours); - builders.CsharpMonoBehaviours.Append("public class "); - builders.CsharpMonoBehaviours.Append(type.Name); - builders.CsharpMonoBehaviours.Append(" : UnityEngine.MonoBehaviour\n"); - AppendIndent(csharpIndent, builders.CsharpMonoBehaviours); - builders.CsharpMonoBehaviours.Append("{\n"); - for ( - int messageIndex = 0; - messageIndex < jsonMonoBehaviour.Messages.Length; - ++messageIndex) - { - // Find the MessageInfo - string message = jsonMonoBehaviour.Messages[messageIndex]; - MessageInfo messageInfo = null; - foreach (MessageInfo mi in messageInfos) - { - if (mi.Name == message) - { - messageInfo = mi; - break; - } - } - - // Build the C++ function name - builders.TempStrBuilder.Length = 0; - AppendNamespace( - type.Namespace, - string.Empty, - builders.TempStrBuilder); - builders.TempStrBuilder.Append(type.Name); - builders.TempStrBuilder.Append(messageInfo.Name); - string cppFunctionName = builders.TempStrBuilder.ToString(); - - // Build ParameterInfos - ParameterInfo[] parameters = ConvertParameters( - messageInfo.ParameterTypes); - int numParams = parameters.Length; - - // C++ Method Declaration - AppendIndent( - cppIndent + 1, - builders.CppTypeDefinitions); - AppendCppMethodDeclaration( - messageInfo.Name, - false, - false, - false, - typeof(void), - null, - parameters, - builders.CppTypeDefinitions); - - // C# message function - AppendIndent( - csharpIndent + 1, - builders.CsharpMonoBehaviours); - builders.CsharpMonoBehaviours.Append("public "); - AppendCsharpTypeName( - typeof(void), - builders.CsharpMonoBehaviours); - builders.CsharpMonoBehaviours.Append(' '); - builders.CsharpMonoBehaviours.Append(messageInfo.Name); - builders.CsharpMonoBehaviours.Append('('); - for (int i = 0; i < numParams; ++i) - { - Type paramType = parameters[i].ParameterType; - AppendCsharpTypeName( - paramType, - builders.CsharpMonoBehaviours); - builders.CsharpMonoBehaviours.Append(' '); - builders.CsharpMonoBehaviours.Append("param"); - builders.CsharpMonoBehaviours.Append(i); - if (i != numParams - 1) - { - builders.CsharpMonoBehaviours.Append(", "); - } - } - builders.CsharpMonoBehaviours.Append(")\n"); - AppendIndent( - csharpIndent + 1, - builders.CsharpMonoBehaviours); - builders.CsharpMonoBehaviours.Append("{\n"); - AppendCppFunctionCall( - cppFunctionName, - parameters, - typeof(void), - type.Name, - type.Namespace, - false, - csharpIndent + 2, - builders.CsharpMonoBehaviours); - AppendIndent( - csharpIndent + 1, - builders.CsharpMonoBehaviours); - builders.CsharpMonoBehaviours.Append("}\n"); - if (messageIndex != jsonMonoBehaviour.Messages.Length - 1) - { - AppendIndent( - csharpIndent + 1, - builders.CsharpMonoBehaviours); - builders.CsharpMonoBehaviours.Append('\n'); - } - - // C# Delegate - AppendCsharpDelegate( - false, - type.Name, - type.Namespace, - null, - messageInfo.Name, - parameters, - typeof(void), - TypeKind.None, - builders.CsharpDelegates); - - // C# Import - AppendCsharpImport( - type.Name, - type.Namespace, - null, - messageInfo.Name, - parameters, - builders.CsharpImports); - - // C# GetDelegate Call - AppendCsharpGetDelegateCall( - type.Name, - type.Namespace, - null, - messageInfo.Name, - builders.CsharpGetDelegateCalls); - - // C++ Message - builders.CppMonoBehaviourMessages.Append("DLLEXPORT void "); - AppendCsharpDelegateName( - type.Name, - type.Namespace, - null, - messageInfo.Name, - builders.CppMonoBehaviourMessages); - builders.CppMonoBehaviourMessages.Append("(int32_t thisHandle"); - if (numParams > 0) - { - builders.CppMonoBehaviourMessages.Append(", "); - } - for (int i = 0; i < numParams; ++i) - { - ParameterInfo param = parameters[i]; - switch (param.Kind) - { - case TypeKind.FullStruct: - case TypeKind.Primitive: - case TypeKind.Enum: - AppendCppTypeName( - param.ParameterType, - builders.CppMonoBehaviourMessages); - builders.CppMonoBehaviourMessages.Append(" param"); - builders.CppMonoBehaviourMessages.Append(i); - break; - default: - builders.CppMonoBehaviourMessages.Append("int32_t param"); - builders.CppMonoBehaviourMessages.Append(i); - builders.CppMonoBehaviourMessages.Append("Handle"); - break; - } - if (i != numParams-1) - { - builders.CppMonoBehaviourMessages.Append(", "); - } - } - builders.CppMonoBehaviourMessages.Append(")\n{\n\t"); - AppendCppTypeName( - type, - builders.CppMonoBehaviourMessages); - builders.CppMonoBehaviourMessages.Append(" thiz(Plugin::InternalUse::Only, thisHandle);\n"); - for (int i = 0; i < numParams; ++i) - { - ParameterInfo param = parameters[i]; - if (param.Kind == TypeKind.Class - || param.Kind == TypeKind.ManagedStruct) - { - builders.CppMonoBehaviourMessages.Append('\t'); - AppendCppTypeName( - param.ParameterType, - builders.CppMonoBehaviourMessages); - builders.CppMonoBehaviourMessages.Append(" param"); - builders.CppMonoBehaviourMessages.Append(i); - builders.CppMonoBehaviourMessages.Append("(Plugin::InternalUse::Only, param"); - builders.CppMonoBehaviourMessages.Append(i); - builders.CppMonoBehaviourMessages.Append("Handle);\n"); - } - } - builders.CppMonoBehaviourMessages.Append("\ttry\n"); - builders.CppMonoBehaviourMessages.Append("\t{\n"); - builders.CppMonoBehaviourMessages.Append("\t\tthiz."); - builders.CppMonoBehaviourMessages.Append(messageInfo.Name); - builders.CppMonoBehaviourMessages.Append("("); - for (int i = 0; i < numParams; ++i) - { - builders.CppMonoBehaviourMessages.Append("param"); - builders.CppMonoBehaviourMessages.Append(i); - if (i != numParams-1) - { - builders.CppMonoBehaviourMessages.Append(", "); - } - } - builders.CppMonoBehaviourMessages.Append(");\n"); - builders.CppMonoBehaviourMessages.Append("\t}\n"); - builders.CppMonoBehaviourMessages.Append("\tcatch (System::Exception ex)\n"); - builders.CppMonoBehaviourMessages.Append("\t{\n"); - builders.CppMonoBehaviourMessages.Append("\t\tPlugin::SetException(ex.Handle);\n"); - builders.CppMonoBehaviourMessages.Append("\t}\n"); - builders.CppMonoBehaviourMessages.Append("\tcatch (...)\n"); - builders.CppMonoBehaviourMessages.Append("\t{\n"); - builders.CppMonoBehaviourMessages.Append("\t\tSystem::String msg = \"Unhandled exception in "); - AppendCppTypeName( - type, - builders.CppMonoBehaviourMessages); - builders.CppMonoBehaviourMessages.Append("::"); - builders.CppMonoBehaviourMessages.Append(messageInfo.Name); - builders.CppMonoBehaviourMessages.Append("\";\n"); - builders.CppMonoBehaviourMessages.Append("\t\tSystem::Exception ex(msg);\n"); - builders.CppMonoBehaviourMessages.Append("\t\tPlugin::SetException(ex.Handle);\n"); - builders.CppMonoBehaviourMessages.Append("\t}\n"); - builders.CppMonoBehaviourMessages.Append("}\n\n\n"); - } - - // C# Class extending MonoBehaviour (end) - AppendIndent(csharpIndent, builders.CsharpMonoBehaviours); - builders.CsharpMonoBehaviours.Append("}\n"); - AppendNamespaceEnding(csharpIndent, builders.CsharpMonoBehaviours); - - // C++ Type Definition (end) - AppendCppTypeDefinitionEnd( - false, - cppIndent, - builders.CppTypeDefinitions); - } - + static void AppendCppFunctionCall( string funcName, ParameterInfo[] parameters, Type returnType, - string enclosingTypeName, - string enclosingTypeNamespace, bool enclosingTypeIsStatic, int indent, StringBuilder output) { - for (int i = 0; i < parameters.Length; ++i) + foreach (ParameterInfo param in parameters) { - ParameterInfo param = parameters[i]; if (param.Kind == TypeKind.Class - || param.Kind == TypeKind.ManagedStruct) + || param.Kind == TypeKind.ManagedStruct) { AppendIndent( indent, @@ -3915,7 +4291,7 @@ static void AppendCppFunctionCall( } output.Append('('); output.Append(param.Name); - output.Append(");\n"); + output.AppendLine(");"); } } if (!enclosingTypeIsStatic) @@ -3923,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, @@ -3958,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( @@ -4001,7 +4377,7 @@ static void AppendArray( if (jsonArray.Ranks == null || jsonArray.Ranks.Length == 0) { - ranks = new int[]{ 1 }; + ranks = new[]{ 1 }; } else { @@ -4009,7 +4385,7 @@ static void AppendArray( } // C++ element proxy for [1-R] for all ranks R - Type[] cppTypeParams = new Type[]{ elementType }; + Type[] cppTypeParams = { elementType }; foreach (int rank in ranks) { // Build array name @@ -4019,31 +4395,15 @@ static void AppendArray( builders.TempStrBuilder); string cppArrayTypeName = builders.TempStrBuilder.ToString(); - // Build "TypeArray" name - builders.TempStrBuilder.Length = 0; - AppendBindingArrayTypeName( - elementType.Name, - elementType.Namespace, - cppArrayTypeName, - builders.TempStrBuilder); - string bindingArrayTypeName = builders.TempStrBuilder.ToString(); - - // GetItem params - ParameterInfo[] getItemParams = BuildArrayGetItemsParams( - rank, - "index"); - for (int i = 1; i <= rank; ++i) { AppendArrayElementProxy( elementType, elementTypeKind, - bindingArrayTypeName, i, rank, cppTypeParams, cppArrayTypeName, - getItemParams, builders); } } @@ -4059,7 +4419,7 @@ static void AppendArray( // Build array name with element type builders.TempStrBuilder.Append('<'); - AppendCppTypeName( + AppendCppTypeFullName( elementType, builders.TempStrBuilder); builders.TempStrBuilder.Append('>'); @@ -4076,11 +4436,14 @@ static void AppendArray( // Build "TypeArray" name builders.TempStrBuilder.Length = 0; - AppendBindingArrayTypeName( - elementType.Name, + AppendNamespace( elementType.Namespace, - cppArrayTypeName, + string.Empty, + builders.TempStrBuilder); + AppendTypeNameWithoutGenericSuffix( + elementType.Name, builders.TempStrBuilder); + builders.TempStrBuilder.Append(cppArrayTypeName); string bindingArrayTypeName = builders.TempStrBuilder.ToString(); // MakeArrayType() creates a Type for a "vector" @@ -4101,59 +4464,129 @@ static void AppendArray( // C++ type declaration int indent = AppendCppTypeDeclaration( - "System", - cppArrayTypeName, + GetTypeName(cppArrayTypeName, "System"), false, cppTypeParams, - builders.CppTypeDeclarations); + builders.CppTemplateSpecializationDeclarations); // C++ type definition (beginning) + Type[] interfaceTypes = GetDirectInterfaces(arrayType); AppendCppTypeDefinitionBegin( - cppArrayTypeName, - "System", + GetTypeName(cppArrayTypeName, "System"), TypeKind.Class, cppTypeParams, - "Array", - "System", + GetTypeName("Array", "System"), null, + interfaceTypes, false, indent, builders.CppTypeDefinitions); // C++ method definitions (beginning) + Type[] cppCtorInitTypes = GetCppCtorInitTypes( + arrayType, + false); + int localRank = rank; int cppMethodDefinitionsIndent = AppendCppMethodDefinitionsBegin( - cppArrayTypeName, - "System", + GetTypeName(cppArrayTypeName, "System"), TypeKind.Class, cppTypeParams, - "Array", - "System", - null, + cppCtorInitTypes, false, + (extraIndent, subject) => { + AppendIndent( + extraIndent, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.Append(subject); + builders.CppMethodDefinitions.AppendLine( + "InternalLength = 0;"); + if (localRank > 1) + { + for (int i = 0; i < localRank; ++i) + { + AppendIndent( + extraIndent, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.Append(subject); + builders.CppMethodDefinitions.Append( + "InternalLengths["); + builders.CppMethodDefinitions.Append(i); + builders.CppMethodDefinitions.AppendLine( + "] = 0;"); + } + } + }, + (extraIndent, subject) => { + AppendIndent( + extraIndent, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.Append( + "InternalLength = "); + builders.CppMethodDefinitions.Append(subject); + builders.CppMethodDefinitions.AppendLine( + "InternalLength;"); + if (localRank > 1) + { + for (int i = 0; i < localRank; ++i) + { + AppendIndent( + extraIndent, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.Append( + "InternalLengths["); + builders.CppMethodDefinitions.Append(i); + builders.CppMethodDefinitions.Append( + "] = "); + builders.CppMethodDefinitions.Append(subject); + builders.CppMethodDefinitions.Append( + "InternalLengths["); + builders.CppMethodDefinitions.Append(i); + builders.CppMethodDefinitions.AppendLine( + "];"); + } + } + }, indent, builders.CppMethodDefinitions); + // C++ fields + AppendIndent( + indent + 1, + builders.CppTypeDefinitions); + builders.CppTypeDefinitions.AppendLine( + "int32_t InternalLength;"); + if (rank > 1) + { + AppendIndent( + indent + 1, + builders.CppTypeDefinitions); + builders.CppTypeDefinitions.Append( + "int32_t InternalLengths["); + builders.CppTypeDefinitions.Append(rank); + builders.CppTypeDefinitions.AppendLine("];"); + } + AppendArrayConstructor( elementType, arrayType, cppArrayTypeName, rank, bindingArrayTypeName, + cppCtorInitTypes, indent, builders); // Base GetLength - AppendArrayCppCallBaseGetIntFunction( + AppendArrayCppGetLengthFunction( indent, cppArrayTypeName, - "GetLength", cppTypeParams, builders); // GetLength for multi-dimensional arrays if (rank > 1) { - AppendArrayGetLength( + AppendArrayMultidimensionalGetLength( elementType, arrayType, cppArrayTypeName, @@ -4163,11 +4596,11 @@ static void AppendArray( builders); } - AppendArrayCppCallBaseGetIntFunction( + AppendArrayCppGetRankFunction( indent, cppArrayTypeName, - "GetRank", cppTypeParams, + rank, builders); AppendArrayGetItem( @@ -4176,8 +4609,6 @@ static void AppendArray( arrayType, cppArrayTypeName, rank, - bindingArrayTypeName, - indent, builders); AppendArraySetItem( @@ -4185,8 +4616,6 @@ static void AppendArray( arrayType, cppArrayTypeName, rank, - bindingArrayTypeName, - indent, builders); // C++ operator[] method declaration @@ -4203,14 +4632,13 @@ 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( 0, cppMethodDefinitionsIndent, - cppGenericArrayTypeName, - "System", + GetTypeName(cppGenericArrayTypeName, "System"), cppElementProxyTypeName, builders.CppMethodDefinitions); @@ -4224,35 +4652,389 @@ static void AppendArray( AppendCppMethodDefinitionsEnd( cppMethodDefinitionsIndent, builders.CppMethodDefinitions); + + if (rank == 1) + { + AppendArrayIterator( + elementType, + cppGenericArrayTypeName, + bindingArrayTypeName, + builders.CppTypeDefinitions, + builders.CppMethodDefinitions); + } } } + static void AppendArrayIterator( + Type elementType, + string cppGenericArrayTypeName, + string bindingArrayTypeName, + StringBuilder cppTypeDefinitions, + StringBuilder cppMethodDefinitions) + { + // Iterator type definition + cppTypeDefinitions.AppendLine("namespace Plugin"); + cppTypeDefinitions.AppendLine("{"); + cppTypeDefinitions.Append("\tstruct "); + cppTypeDefinitions.Append(bindingArrayTypeName); + cppTypeDefinitions.AppendLine("Iterator"); + cppTypeDefinitions.AppendLine("\t{"); + cppTypeDefinitions.Append("\t\tSystem::"); + cppTypeDefinitions.Append(cppGenericArrayTypeName); + cppTypeDefinitions.AppendLine("& array;"); + cppTypeDefinitions.AppendLine("\t\tint index;"); + cppTypeDefinitions.Append("\t\t"); + cppTypeDefinitions.Append(bindingArrayTypeName); + cppTypeDefinitions.Append("Iterator(System::"); + cppTypeDefinitions.Append(cppGenericArrayTypeName); + cppTypeDefinitions.AppendLine("& array, int32_t index);"); + cppTypeDefinitions.Append("\t\t"); + cppTypeDefinitions.Append(bindingArrayTypeName); + cppTypeDefinitions.AppendLine("Iterator& operator++();"); + cppTypeDefinitions.Append("\t\tbool operator!=(const "); + cppTypeDefinitions.Append(bindingArrayTypeName); + cppTypeDefinitions.AppendLine("Iterator& other);"); + cppTypeDefinitions.Append("\t\t"); + AppendCppTypeFullName( + elementType, + cppTypeDefinitions); + cppTypeDefinitions.AppendLine(" operator*();"); + cppTypeDefinitions.AppendLine("\t};"); + cppTypeDefinitions.AppendLine("}"); + cppTypeDefinitions.AppendLine();; + + // begin() and end() declarations + cppTypeDefinitions.AppendLine("namespace System"); + cppTypeDefinitions.AppendLine("{"); + cppTypeDefinitions.Append("\tPlugin::"); + cppTypeDefinitions.Append(bindingArrayTypeName); + cppTypeDefinitions.Append("Iterator begin(System::"); + cppTypeDefinitions.Append(cppGenericArrayTypeName); + cppTypeDefinitions.AppendLine("& array);"); + cppTypeDefinitions.Append("\tPlugin::"); + cppTypeDefinitions.Append(bindingArrayTypeName); + cppTypeDefinitions.Append("Iterator end(System::"); + cppTypeDefinitions.Append(cppGenericArrayTypeName); + cppTypeDefinitions.AppendLine("& array);"); + cppTypeDefinitions.AppendLine("}"); + cppTypeDefinitions.AppendLine();; + + // Iterator method definitions + 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.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.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.AppendLine("Iterator& other)"); + cppMethodDefinitions.AppendLine("\t{"); + cppMethodDefinitions.AppendLine("\t\treturn index != other.index;"); + cppMethodDefinitions.AppendLine("\t}"); + cppMethodDefinitions.AppendLine("\t"); + cppMethodDefinitions.Append('\t'); + AppendCppTypeFullName( + elementType, + cppMethodDefinitions); + cppMethodDefinitions.Append(' '); + cppMethodDefinitions.Append(bindingArrayTypeName); + cppMethodDefinitions.Append("Iterator::"); + cppMethodDefinitions.AppendLine("operator*()"); + cppMethodDefinitions.AppendLine("\t{"); + cppMethodDefinitions.AppendLine("\t\treturn array[index];"); + cppMethodDefinitions.AppendLine("\t}"); + cppMethodDefinitions.AppendLine("}"); + cppMethodDefinitions.AppendLine();; + + // begin() and end() definitions + cppMethodDefinitions.AppendLine("namespace System"); + cppMethodDefinitions.AppendLine("{"); + cppMethodDefinitions.Append("\tPlugin::"); + cppMethodDefinitions.Append(bindingArrayTypeName); + cppMethodDefinitions.Append("Iterator begin(System::"); + cppMethodDefinitions.Append(cppGenericArrayTypeName); + cppMethodDefinitions.AppendLine("& array)"); + cppMethodDefinitions.AppendLine("\t{"); + cppMethodDefinitions.Append("\t\treturn Plugin::"); + cppMethodDefinitions.Append(bindingArrayTypeName); + 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.AppendLine("& array)"); + cppMethodDefinitions.AppendLine("\t{"); + cppMethodDefinitions.Append("\t\treturn Plugin::"); + cppMethodDefinitions.Append(bindingArrayTypeName); + cppMethodDefinitions.AppendLine("Iterator(array, array.GetLength() - 1);"); + cppMethodDefinitions.AppendLine("\t}"); + cppMethodDefinitions.AppendLine("}"); + cppMethodDefinitions.AppendLine();; + } + + static void AppendGenericEnumerableIterator( + Type enumerableType, + Type enumeratorType, + Type elementType, + string bindingEnumerableTypeName, + StringBuilder cppTypeDefinitions, + StringBuilder cppMethodDefinitions) + { + // Iterator type definition + cppTypeDefinitions.AppendLine("namespace Plugin"); + cppTypeDefinitions.AppendLine("{"); + cppTypeDefinitions.Append("\tstruct "); + cppTypeDefinitions.Append(bindingEnumerableTypeName); + cppTypeDefinitions.AppendLine("Iterator"); + cppTypeDefinitions.AppendLine("\t{"); + cppTypeDefinitions.Append("\t\t"); + AppendCppTypeFullName( + enumeratorType, + cppTypeDefinitions); + cppTypeDefinitions.AppendLine(" enumerator;"); + cppTypeDefinitions.AppendLine("\t\tbool hasMore;"); + cppTypeDefinitions.Append("\t\t"); + cppTypeDefinitions.Append(bindingEnumerableTypeName); + cppTypeDefinitions.AppendLine("Iterator(decltype(nullptr));"); + cppTypeDefinitions.Append("\t\t"); + cppTypeDefinitions.Append(bindingEnumerableTypeName); + cppTypeDefinitions.Append("Iterator("); + AppendCppTypeFullName( + enumerableType, + cppTypeDefinitions); + cppTypeDefinitions.AppendLine("& enumerable);"); + cppTypeDefinitions.Append("\t\t~"); + cppTypeDefinitions.Append(bindingEnumerableTypeName); + cppTypeDefinitions.AppendLine("Iterator();"); + cppTypeDefinitions.Append("\t\t"); + cppTypeDefinitions.Append(bindingEnumerableTypeName); + cppTypeDefinitions.AppendLine("Iterator& operator++();"); + cppTypeDefinitions.Append("\t\tbool operator!=(const "); + cppTypeDefinitions.Append(bindingEnumerableTypeName); + cppTypeDefinitions.AppendLine("Iterator& other);"); + cppTypeDefinitions.Append("\t\t"); + AppendCppTypeFullName( + elementType, + cppTypeDefinitions); + cppTypeDefinitions.AppendLine(" operator*();"); + cppTypeDefinitions.AppendLine("\t};"); + cppTypeDefinitions.AppendLine("}"); + cppTypeDefinitions.AppendLine();; + + // begin() and end() declarations + int indent = AppendNamespaceBeginning( + enumerableType.Namespace, + cppTypeDefinitions); + AppendIndent( + indent, + cppTypeDefinitions); + cppTypeDefinitions.Append("Plugin::"); + cppTypeDefinitions.Append(bindingEnumerableTypeName); + cppTypeDefinitions.Append("Iterator begin("); + AppendCppTypeFullName( + enumerableType, + cppTypeDefinitions); + cppTypeDefinitions.AppendLine("& enumerable);"); + AppendIndent( + indent, + cppTypeDefinitions); + cppTypeDefinitions.Append("Plugin::"); + cppTypeDefinitions.Append(bindingEnumerableTypeName); + cppTypeDefinitions.Append("Iterator end("); + AppendCppTypeFullName( + enumerableType, + cppTypeDefinitions); + cppTypeDefinitions.AppendLine("& enumerable);"); + AppendNamespaceEnding( + indent, + cppTypeDefinitions); + cppTypeDefinitions.AppendLine();; + + // Iterator method definitions + cppMethodDefinitions.AppendLine("namespace Plugin"); + cppMethodDefinitions.AppendLine("{"); + cppMethodDefinitions.Append('\t'); + cppMethodDefinitions.Append(bindingEnumerableTypeName); + cppMethodDefinitions.Append("Iterator::"); + cppMethodDefinitions.Append(bindingEnumerableTypeName); + 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::"); + cppMethodDefinitions.Append(bindingEnumerableTypeName); + cppMethodDefinitions.Append("Iterator("); + AppendCppTypeFullName( + enumerableType, + cppMethodDefinitions); + 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.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.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.AppendLine("Iterator& other)"); + cppMethodDefinitions.AppendLine("\t{"); + cppMethodDefinitions.AppendLine("\t\treturn hasMore;"); + cppMethodDefinitions.AppendLine("\t}"); + cppMethodDefinitions.AppendLine("\t"); + cppMethodDefinitions.Append('\t'); + AppendCppTypeFullName( + elementType, + cppMethodDefinitions); + cppMethodDefinitions.Append(' '); + cppMethodDefinitions.Append(bindingEnumerableTypeName); + cppMethodDefinitions.Append("Iterator::"); + 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( + enumerableType.Namespace, + cppMethodDefinitions); + AppendIndent( + indent, + cppMethodDefinitions); + cppMethodDefinitions.Append("Plugin::"); + cppMethodDefinitions.Append(bindingEnumerableTypeName); + cppMethodDefinitions.Append("Iterator begin("); + AppendCppTypeFullName( + enumerableType, + cppMethodDefinitions); + cppMethodDefinitions.AppendLine("& enumerable)"); + AppendIndent( + indent, + cppMethodDefinitions); + cppMethodDefinitions.AppendLine("{"); + AppendIndent( + indent + 1, + cppMethodDefinitions); + cppMethodDefinitions.Append("return Plugin::"); + cppMethodDefinitions.Append(bindingEnumerableTypeName); + cppMethodDefinitions.AppendLine("Iterator(enumerable);"); + AppendIndent( + indent, + cppMethodDefinitions); + cppMethodDefinitions.AppendLine("}"); + AppendIndent( + indent, + cppMethodDefinitions); + cppMethodDefinitions.AppendLine();; + AppendIndent( + indent, + cppMethodDefinitions); + cppMethodDefinitions.Append("Plugin::"); + cppMethodDefinitions.Append(bindingEnumerableTypeName); + cppMethodDefinitions.Append("Iterator end("); + AppendCppTypeFullName( + enumerableType, + cppMethodDefinitions); + cppMethodDefinitions.AppendLine("& enumerable)"); + AppendIndent( + indent, + cppMethodDefinitions); + cppMethodDefinitions.AppendLine("{"); + AppendIndent( + indent + 1, + cppMethodDefinitions); + cppMethodDefinitions.Append("return Plugin::"); + cppMethodDefinitions.Append(bindingEnumerableTypeName); + cppMethodDefinitions.AppendLine("Iterator(nullptr);"); + AppendIndent( + indent, + cppMethodDefinitions); + cppMethodDefinitions.AppendLine("}"); + AppendNamespaceEnding( + indent, + cppMethodDefinitions); + cppMethodDefinitions.AppendLine();; + } + static void AppendCppArrayIndexOperatorMethodDefinition( int rank, int indent, - string enclosingTypeName, - string enclosingTypeNamespace, + TypeName enclosingTypeTypeName, string nextCppElementProxyTypeName, StringBuilder output) { AppendIndent( indent, output); - AppendCppTypeName( - "Plugin", - nextCppElementProxyTypeName, + AppendCppTypeFullName( + GetTypeName(nextCppElementProxyTypeName, "Plugin"), output); output.Append(' '); - output.Append(enclosingTypeNamespace); + output.Append(enclosingTypeTypeName.Namespace); output.Append("::"); AppendTypeNameWithoutGenericSuffix( - enclosingTypeName, + 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); @@ -4265,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( @@ -4295,28 +5077,12 @@ static void AppendCppArrayElementProxyName( output.Append('_'); output.Append(maxRank); output.Append('<'); - AppendCppTypeName( + AppendCppTypeFullName( elementType, output); output.Append('>'); } - - static void AppendBindingArrayTypeName( - string elementTypeName, - string elementTypeNamespace, - string cppArrayTypeName, - StringBuilder output) - { - AppendNamespace( - elementTypeNamespace, - string.Empty, - output); - AppendTypeNameWithoutGenericSuffix( - elementTypeName, - output); - output.Append(cppArrayTypeName); - } - + static ParameterInfo[] BuildArrayGetItemsParams( int rank, string indexName) @@ -4370,17 +5136,16 @@ static ParameterInfo[] BuildArraySetItemsParams( } static void AppendArrayGetItemFuncName( - string elementTypeName, - string elementTypeNamespace, + TypeName elementTypeTypeName, string bindingArrayTypeName, int rank, StringBuilder output) { AppendNamespace( - elementTypeNamespace, + elementTypeTypeName.Namespace, string.Empty, output); - output.Append(elementTypeName); + output.Append(elementTypeTypeName.Name); AppendTypeNameWithoutGenericSuffix( bindingArrayTypeName, output); @@ -4389,17 +5154,16 @@ static void AppendArrayGetItemFuncName( } static void AppendArraySetItemFuncName( - string elementTypeName, - string elementTypeNamespace, + TypeName elementTypeTypeName, string bindingArrayTypeName, int rank, StringBuilder output) { AppendNamespace( - elementTypeNamespace, + elementTypeTypeName.Namespace, string.Empty, output); - output.Append(elementTypeName); + output.Append(elementTypeTypeName.Name); AppendTypeNameWithoutGenericSuffix( bindingArrayTypeName, output); @@ -4410,12 +5174,10 @@ static void AppendArraySetItemFuncName( static void AppendArrayElementProxy( Type elementType, TypeKind elementTypeKind, - string bindingArrayTypeName, int rank, int maxRank, Type[] cppTypeParams, string cppArrayTypeName, - ParameterInfo[] getItemParams, StringBuilders builders) { // Build element proxy name @@ -4439,8 +5201,7 @@ static void AppendArrayElementProxy( // GetItem name builders.TempStrBuilder.Length = 0; AppendArrayGetItemFuncName( - elementType.Name, - elementType.Namespace, + GetTypeName(elementType), cppArrayTypeName, rank, builders.TempStrBuilder); @@ -4449,8 +5210,7 @@ static void AppendArrayElementProxy( // SetItem name builders.TempStrBuilder.Length = 0; AppendArraySetItemFuncName( - elementType.Name, - elementType.Namespace, + GetTypeName(elementType), cppArrayTypeName, rank, builders.TempStrBuilder); @@ -4470,17 +5230,17 @@ static void AppendArrayElementProxy( // C++ element proxy type declaration int indent = AppendNamespaceBeginning( "Plugin", - builders.CppTypeDeclarations); - AppendIndent(indent, builders.CppTypeDeclarations); - builders.CppTypeDeclarations.Append("template<> struct "); + builders.CppTemplateSpecializationDeclarations); + AppendIndent(indent, builders.CppTemplateSpecializationDeclarations); + builders.CppTemplateSpecializationDeclarations.Append("template<> struct "); AppendTypeNameWithoutGenericSuffix( cppElementProxyTypeName, - builders.CppTypeDeclarations); - builders.CppTypeDeclarations.Append(";\n"); + builders.CppTemplateSpecializationDeclarations); + builders.CppTemplateSpecializationDeclarations.AppendLine(";"); AppendNamespaceEnding( indent, - builders.CppTypeDeclarations); - builders.CppTypeDeclarations.Append('\n'); + builders.CppTemplateSpecializationDeclarations); + builders.CppTemplateSpecializationDeclarations.AppendLine();; // C++ element proxy type definition AppendNamespaceBeginning( @@ -4491,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( @@ -4507,14 +5267,14 @@ 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, builders.CppTypeDefinitions); builders.CppTypeDefinitions.Append(cppElementProxyTypeName); builders.CppTypeDefinitions.Append( - "(Plugin::InternalUse iu, int32_t handle, "); + "(Plugin::InternalUse, int32_t handle, "); for (int i = 0; i < rank; ++i) { builders.CppTypeDefinitions.Append("int32_t index"); @@ -4524,25 +5284,25 @@ static void AppendArrayElementProxy( builders.CppTypeDefinitions.Append(", "); } } - builders.CppTypeDefinitions.Append(");\n"); + builders.CppTypeDefinitions.AppendLine(");"); if (rank == maxRank) { AppendIndent( indent + 1, builders.CppTypeDefinitions); builders.CppTypeDefinitions.Append("void operator=("); - AppendCppTypeName( + AppendCppTypeFullName( elementType, builders.CppTypeDefinitions); - builders.CppTypeDefinitions.Append(" item);\n"); + builders.CppTypeDefinitions.AppendLine(" item);"); AppendIndent( indent + 1, builders.CppTypeDefinitions); builders.CppTypeDefinitions.Append("operator "); - AppendCppTypeName( + AppendCppTypeFullName( elementType, builders.CppTypeDefinitions); - builders.CppTypeDefinitions.Append("();\n"); + builders.CppTypeDefinitions.AppendLine("();"); } else { @@ -4556,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( @@ -4581,7 +5341,7 @@ static void AppendArrayElementProxy( builders.CppMethodDefinitions.Append('_'); builders.CppMethodDefinitions.Append(maxRank); builders.CppMethodDefinitions.Append( - "(Plugin::InternalUse iu, int32_t handle, "); + "(Plugin::InternalUse, int32_t handle, "); for (int i = 0; i < rank; ++i) { builders.CppMethodDefinitions.Append("int32_t index"); @@ -4591,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( @@ -4609,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) { @@ -4630,18 +5390,17 @@ static void AppendArrayElementProxy( builders.CppMethodDefinitions.Append(cppElementProxyTypeName); builders.CppMethodDefinitions.Append("::"); builders.CppMethodDefinitions.Append("operator=("); - AppendCppTypeName( + 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, - cppArrayTypeName, - "System", + GetTypeName(cppArrayTypeName, "System"), TypeKind.Class, cppTypeParams, typeof(void), @@ -4652,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( @@ -4665,18 +5424,17 @@ static void AppendArrayElementProxy( builders.CppMethodDefinitions.Append(cppElementProxyTypeName); builders.CppMethodDefinitions.Append("::"); builders.CppMethodDefinitions.Append("operator "); - AppendCppTypeName( + AppendCppTypeFullName( elementType, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("()\n"); + builders.CppMethodDefinitions.AppendLine("()"); AppendIndent( cppMethodDefinitionsIndent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendCppPluginFunctionCall( false, - cppArrayTypeName, - "System", + GetTypeName(cppArrayTypeName, "System"), TypeKind.Class, cppTypeParams, elementType, @@ -4692,15 +5450,14 @@ static void AppendArrayElementProxy( AppendIndent( cppMethodDefinitionsIndent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.AppendLine("}"); } else { AppendCppArrayIndexOperatorMethodDefinition( rank, cppMethodDefinitionsIndent, - cppElementProxyTypeName, - "Plugin", + GetTypeName(cppElementProxyTypeName, "Plugin"), nextCppElementProxyTypeName, builders.CppMethodDefinitions); } @@ -4717,6 +5474,7 @@ static void AppendArrayConstructor( string cppArrayTypeName, int rank, string csharpTypeName, + Type[] cppCtorInitTypes, int indent, StringBuilders builders) { @@ -4732,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) { @@ -4748,6 +5502,10 @@ static void AppendArrayConstructor( info.Kind = TypeKind.Primitive; parameters[i] = info; } + + TypeName cppArrayTypeTypeName = GetTypeName( + cppArrayTypeName, + "System"); // C# Delegate Type AppendCsharpDelegateType( @@ -4760,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, @@ -4776,14 +5532,13 @@ static void AppendArrayConstructor( true, TypeKind.Class, arrayType, - null, parameters, builders.CsharpFunctions); AppendHandleStoreTypeName( arrayType, builders.CsharpFunctions); builders.CsharpFunctions.Append(".Store(new "); - AppendCsharpTypeName( + AppendCsharpTypeFullName( elementType, builders.CsharpFunctions); builders.CsharpFunctions.Append('['); @@ -4809,29 +5564,21 @@ static void AppendArrayConstructor( AppendCppFunctionPointerDefinition( funcName, true, - cppArrayTypeName, - "System", + cppArrayTypeTypeName, TypeKind.Class, parameters, arrayType, builders.CppFunctionPointers); - // C++ init param - AppendCppInitParam( - funcNameLower, + // C++ init body + AppendCppInitBodyFunctionPointerParameterRead( + funcName, true, - cppArrayTypeName, - "System", + cppArrayTypeTypeName, TypeKind.Class, parameters, arrayType, - builders.CppInitParams); - - // C++ init body - AppendCppInitBody( - funcName, - funcNameLower, - builders.CppInitBody); + builders.CppInitBodyParameterReads); // C++ method declaration AppendIndent( @@ -4848,9 +5595,9 @@ static void AppendArrayConstructor( builders.CppTypeDefinitions); // C++ method definition - Type[] cppTypeParams = new Type[] { elementType }; + Type[] cppTypeParams = { elementType }; AppendCppMethodDefinitionBegin( - cppArrayTypeName, + GetTypeName(cppArrayTypeName, "System"), null, cppArrayTypeName, cppTypeParams, @@ -4858,23 +5605,26 @@ static void AppendArrayConstructor( parameters, indent, builders.CppMethodDefinitions); - AppendIndent( - indent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append(" : "); - AppendCppTypeName( - "System", - "Array", - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("(nullptr)\n"); + string separator = ": "; + foreach (Type interfaceType in cppCtorInitTypes) + { + AppendIndent( + indent + 1, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.Append(separator); + AppendCppTypeFullName( + interfaceType, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine("(nullptr)"); + separator = ", "; + } AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendCppPluginFunctionCall( true, - cppArrayTypeName, - "System", + cppArrayTypeTypeName, TypeKind.Class, cppTypeParams, arrayType, @@ -4885,51 +5635,84 @@ 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); AppendReferenceManagedHandleFunctionCall( - cppArrayTypeName, - "System", + cppArrayTypeTypeName, TypeKind.Class, cppTypeParams, "returnValue", builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append(";\n"); + builders.CppMethodDefinitions.AppendLine(";"); + if (rank > 1) + { + AppendIndent( + indent + 2, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.Append("InternalLength = "); + for (int i = 0; i < rank; ++i) + { + builders.CppMethodDefinitions.Append("length"); + builders.CppMethodDefinitions.Append(i); + if (i != rank - 1) + { + builders.CppMethodDefinitions.Append(" * "); + } + } + builders.CppMethodDefinitions.AppendLine(";"); + for (int i = 0; i < rank; ++i) + { + AppendIndent( + indent + 2, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.Append("InternalLengths["); + builders.CppMethodDefinitions.Append(i); + builders.CppMethodDefinitions.Append("] = length"); + builders.CppMethodDefinitions.Append(i); + builders.CppMethodDefinitions.AppendLine(";"); + } + } + else + { + AppendIndent( + indent + 2, + builders.CppMethodDefinitions); + 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 AppendArrayCppCallBaseGetIntFunction( + static void AppendArrayCppGetLengthFunction( int indent, string cppArrayTypeName, - string baseFunctionName, Type[] cppTypeParams, - StringBuilders builders - ) + StringBuilders builders) { ParameterInfo[] parameters = new ParameterInfo[0]; @@ -4938,7 +5721,7 @@ StringBuilders builders indent + 1, builders.CppTypeDefinitions); AppendCppMethodDeclaration( - baseFunctionName, + "GetLength", false, false, false, @@ -4949,27 +5732,113 @@ StringBuilders builders // C++ method definition AppendCppMethodDefinitionBegin( - cppArrayTypeName, + GetTypeName(cppArrayTypeName, "System"), typeof(int), - baseFunctionName, + "GetLength", cppTypeParams, null, parameters, indent, builders.CppMethodDefinitions); - AppendIndent(indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); - AppendIndent(indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("return Array::"); - builders.CppMethodDefinitions.Append(baseFunctionName); - builders.CppMethodDefinitions.Append("();\n"); - AppendIndent(indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); - AppendIndent(indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); + AppendIndent( + indent, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine("{"); + AppendIndent( + indent + 1, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine( + "int32_t returnVal = InternalLength;"); + AppendIndent( + indent + 1, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine("if (returnVal == 0)"); + AppendIndent( + indent + 1, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine("{"); + AppendIndent( + indent + 2, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine( + "returnVal = Array::GetLength();"); + AppendIndent( + indent + 2, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine( + "InternalLength = returnVal;"); + AppendIndent( + indent + 1, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine("};"); + AppendIndent( + indent + 1, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine("return returnVal;"); + AppendIndent( + indent, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine("}"); + AppendIndent( + indent, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine();; + } + + static void AppendArrayCppGetRankFunction( + int indent, + string cppArrayTypeName, + Type[] cppTypeParams, + int rank, + StringBuilders builders) + { + ParameterInfo[] parameters = new ParameterInfo[0]; + + // C++ method declaration + AppendIndent( + indent + 1, + builders.CppTypeDefinitions); + AppendCppMethodDeclaration( + "GetRank", + false, + false, + false, + typeof(int), + null, + parameters, + builders.CppTypeDefinitions); + + // C++ method definition + AppendCppMethodDefinitionBegin( + GetTypeName(cppArrayTypeName, "System"), + typeof(int), + "GetRank", + cppTypeParams, + null, + parameters, + indent, + builders.CppMethodDefinitions); + AppendIndent( + indent, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine("{"); + AppendIndent( + indent + 1, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.Append("return "); + builders.CppMethodDefinitions.Append(rank); + builders.CppMethodDefinitions.AppendLine(";"); + AppendIndent( + indent, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine("}"); + AppendIndent( + indent, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine();; } - static void AppendArrayGetLength( + static void AppendArrayMultidimensionalGetLength( Type elementType, Type arrayType, string cppArrayTypeName, @@ -4990,11 +5859,7 @@ static void AppendArrayGetLength( 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[] { + ParameterInfo[] parameters = { new ParameterInfo { Name = "dimension", ParameterType = typeof(int), @@ -5004,6 +5869,10 @@ static void AppendArrayGetLength( Kind = TypeKind.Primitive, } }; + + TypeName cppArrayTypeTypeName = GetTypeName( + cppArrayTypeName, + "System"); // C# Delegate Type AppendCsharpDelegateType( @@ -5016,15 +5885,13 @@ static void AppendArrayGetLength( 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, @@ -5032,7 +5899,6 @@ static void AppendArrayGetLength( false, TypeKind.Class, typeof(int), - null, parameters, builders.CsharpFunctions); builders.CsharpFunctions.Append( @@ -5049,29 +5915,21 @@ static void AppendArrayGetLength( AppendCppFunctionPointerDefinition( funcName, false, - cppArrayTypeName, - "System", + cppArrayTypeTypeName, TypeKind.Class, parameters, arrayType, builders.CppFunctionPointers); - // C++ init param - AppendCppInitParam( - funcNameLower, + // C++ init body + AppendCppInitBodyFunctionPointerParameterRead( + funcName, false, - cppArrayTypeName, - "System", + cppArrayTypeTypeName, TypeKind.Class, parameters, arrayType, - builders.CppInitParams); - - // C++ init body - AppendCppInitBody( - funcName, - funcNameLower, - builders.CppInitBody); + builders.CppInitBodyParameterReads); // C++ method declaration AppendIndent( @@ -5088,9 +5946,9 @@ static void AppendArrayGetLength( builders.CppTypeDefinitions); // C++ method definition - Type[] cppTypeParams = new Type[] { elementType }; + Type[] cppTypeParams = { elementType }; AppendCppMethodDefinitionBegin( - cppArrayTypeName, + GetTypeName(cppArrayTypeName, "System"), typeof(int), "GetLength", cppTypeParams, @@ -5098,12 +5956,41 @@ static void AppendArrayGetLength( parameters, indent, builders.CppMethodDefinitions); - AppendIndent(indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + AppendIndent( + indent, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine("{"); + AppendIndent( + indent + 1, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.Append( + "assert(dimension >= 0 && dimension < "); + builders.CppMethodDefinitions.Append(rank); + builders.CppMethodDefinitions.AppendLine(");"); + AppendIndent( + indent + 1, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine( + "int32_t length = InternalLengths[dimension];"); + AppendIndent( + indent + 1, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine("if (length)"); + AppendIndent( + indent + 1, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine("{"); + AppendIndent( + indent + 2, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine("return length;"); + AppendIndent( + indent + 1, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine("}"); AppendCppPluginFunctionCall( false, - cppArrayTypeName, - "System", + GetTypeName(cppArrayTypeName, "System"), TypeKind.Class, cppTypeParams, typeof(int), @@ -5111,15 +5998,24 @@ static void AppendArrayGetLength( parameters, indent + 1, builders.CppMethodDefinitions); + AppendIndent( + indent + 1, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine( + "InternalLengths[dimension] = returnValue;"); AppendCppMethodReturn( typeof(int), TypeKind.Primitive, indent + 1, builders.CppMethodDefinitions); - AppendIndent(indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); - AppendIndent(indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); + AppendIndent( + indent, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine("}"); + AppendIndent( + indent, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine();; } static void AppendArrayGetItem( @@ -5128,23 +6024,16 @@ static void AppendArrayGetItem( Type arrayType, string cppArrayTypeName, int rank, - string csharpTypeName, - int indent, StringBuilders builders) { builders.TempStrBuilder.Length = 0; AppendArrayGetItemFuncName( - elementType.Name, - elementType.Namespace, + GetTypeName(elementType), cppArrayTypeName, rank, 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"); @@ -5160,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, @@ -5176,7 +6063,6 @@ static void AppendArrayGetItem( false, TypeKind.Class, elementType, - null, parameters, builders.CsharpFunctions); builders.CsharpFunctions.Append("thiz["); @@ -5197,34 +6083,30 @@ static void AppendArrayGetItem( null, false, builders.CsharpFunctions); - + + TypeName cppArrayTypeTypeName = GetTypeName( + "System", + cppArrayTypeName); + // C++ function pointer definition AppendCppFunctionPointerDefinition( funcName, false, - cppArrayTypeName, - "System", + cppArrayTypeTypeName, TypeKind.Class, parameters, elementType, builders.CppFunctionPointers); - // C++ init param - AppendCppInitParam( - funcNameLower, + // C++ init body + AppendCppInitBodyFunctionPointerParameterRead( + funcName, false, - cppArrayTypeName, - "System", + cppArrayTypeTypeName, TypeKind.Class, parameters, elementType, - builders.CppInitParams); - - // C++ init body - AppendCppInitBody( - funcName, - funcNameLower, - builders.CppInitBody); + builders.CppInitBodyParameterReads); } static void AppendArraySetItem( @@ -5232,23 +6114,16 @@ static void AppendArraySetItem( Type arrayType, string cppArrayTypeName, int rank, - string csharpTypeName, - int indent, StringBuilders builders) { builders.TempStrBuilder.Length = 0; AppendArraySetItemFuncName( - elementType.Name, - elementType.Namespace, + GetTypeName(elementType), cppArrayTypeName, rank, 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, @@ -5266,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, @@ -5282,7 +6155,6 @@ static void AppendArraySetItem( false, TypeKind.Class, typeof(void), - null, parameters, builders.CsharpFunctions); builders.CsharpFunctions.Append("thiz["); @@ -5303,67 +6175,51 @@ static void AppendArraySetItem( null, false, builders.CsharpFunctions); - + + TypeName cppArrayTypeTypeName = GetTypeName( + "System", + cppArrayTypeName); + // C++ function pointer definition AppendCppFunctionPointerDefinition( funcName, false, - cppArrayTypeName, - "System", + cppArrayTypeTypeName, TypeKind.Class, parameters, arrayType, builders.CppFunctionPointers); - // C++ init param - AppendCppInitParam( - funcNameLower, + // C++ init body + AppendCppInitBodyFunctionPointerParameterRead( + funcName, false, - cppArrayTypeName, - "System", + cppArrayTypeTypeName, TypeKind.Class, parameters, arrayType, - builders.CppInitParams); - - // C++ init body - AppendCppInitBody( - funcName, - funcNameLower, - builders.CppInitBody); + builders.CppInitBodyParameterReads); } static void AppendDelegate( JsonDelegate jsonDelegate, Assembly[] assemblies, + int defaultMaxSimultaneous, StringBuilders builders) { Type type = GetType( jsonDelegate.Type, assemblies); - Type[] genericArgTypes = type.GetGenericArguments(); if (jsonDelegate.GenericParams != null) { - foreach (JsonGenericParams jsonGenericParams - in jsonDelegate.GenericParams) + for (int i = 0; i < jsonDelegate.GenericParams.Length; ++i) { - // Build numbered C++ class name (e.g. Action2) - builders.TempStrBuilder.Length = 0; - AppendTypeNameWithoutSuffixes( - type.Name, - builders.TempStrBuilder); - builders.TempStrBuilder.Append( - jsonGenericParams.Types.Length); - string numberedTypeName = builders.TempStrBuilder.ToString(); - // C++ template declaration AppendCppTemplateDeclaration( - numberedTypeName, - type.Namespace, - genericArgTypes.Length, - builders.CppTypeDeclarations); + GetTypeName(type), + builders.CppTemplateDeclarations); } - + foreach (JsonGenericParams jsonGenericParams in jsonDelegate.GenericParams) { @@ -5372,58 +6228,50 @@ static void AppendDelegate( assemblies); Type genericType = type.MakeGenericType(typeParams); - // Build numbered C++ class name (e.g. Action2) + // Build numbered C++ class name (e.g. Action_2) builders.TempStrBuilder.Length = 0; AppendTypeNameWithoutSuffixes( type.Name, builders.TempStrBuilder); + builders.TempStrBuilder.Append('_'); builders.TempStrBuilder.Append( jsonGenericParams.Types.Length); - string numberedTypeName = builders.TempStrBuilder.ToString(); + string cppTypeName = builders.TempStrBuilder.ToString(); // Max simultaneous handles of this type - int? maxSimultaneous = jsonGenericParams.MaxSimultaneous != 0 + int maxSimultaneous = jsonGenericParams.MaxSimultaneous != 0 ? jsonGenericParams.MaxSimultaneous : jsonDelegate.MaxSimultaneous != 0 ? jsonDelegate.MaxSimultaneous - : default(int?); + : defaultMaxSimultaneous; AppendDelegate( genericType, - numberedTypeName, - jsonDelegate, - genericArgTypes, + cppTypeName, typeParams, maxSimultaneous, - assemblies, builders); } } else { - int? maxSimultaneous = jsonDelegate.MaxSimultaneous != 0 + int maxSimultaneous = jsonDelegate.MaxSimultaneous != 0 ? jsonDelegate.MaxSimultaneous - : default(int?); + : defaultMaxSimultaneous; AppendDelegate( type, type.Name, - jsonDelegate, - genericArgTypes, null, maxSimultaneous, - assemblies, builders); } } - + static void AppendDelegate( Type type, - string numberedTypeName, - JsonDelegate jsonDelegate, - Type[] genericArgTypes, + string cppTypeName, Type[] typeParams, - int? maxSimultaneous, - Assembly[] assemblies, + int maxSimultaneous, StringBuilders builders) { builders.TempStrBuilder.Length = 0; @@ -5437,83 +6285,40 @@ static void AppendDelegate( AppendTypeNames( typeParams, builders.TempStrBuilder); - string typeName = builders.TempStrBuilder.ToString(); + string bindingTypeName = builders.TempStrBuilder.ToString(); builders.TempStrBuilder.Length = 0; builders.TempStrBuilder.Append("Release"); - builders.TempStrBuilder.Append(typeName); + 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(typeName); + 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(typeName); - builders.TempStrBuilder.Append("Invoke"); - string invokeFuncName = builders.TempStrBuilder.ToString(); - - builders.TempStrBuilder[0] = char.ToLower( - builders.TempStrBuilder[0]); - string invokeFuncNameLower = builders.TempStrBuilder.ToString(); - builders.TempStrBuilder.Length = 0; - builders.TempStrBuilder.Append(typeName); + 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(typeName); + 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(); - - builders.TempStrBuilder.Length = 0; - AppendCsharpDelegateName( - type.Name, - type.Namespace, + TypeName typeTypeName = GetTypeName(type); + + // C++ type declaration + int indent = AppendCppTypeDeclaration( + typeTypeName, + false, typeParams, - "CppInvoke", - builders.TempStrBuilder); - string cppInvokeFuncName = builders.TempStrBuilder.ToString(); - - MethodInfo invokeMethod = type.GetMethod("Invoke"); - TypeKind invokeReturnTypeKind = GetTypeKind( - invokeMethod.ReturnType); - ParameterInfo[] invokeParams = ConvertParameters( - invokeMethod.GetParameters()); - ParameterInfo[] invokeParamsWithThis = new ParameterInfo[ - invokeParams.Length + 1]; - for (int i = 0; i < invokeParams.Length; ++i) - { - invokeParamsWithThis[i+1] = invokeParams[i]; - } - invokeParamsWithThis[0] = new ParameterInfo { - Name = "thisHandle", - ParameterType = typeof(int), - DereferencedParameterType = typeof(int), - IsOut = false, - IsRef = false, - Kind = TypeKind.Primitive - }; + typeParams != null ? + builders.CppTemplateSpecializationDeclarations : + builders.CppTypeDeclarations); - ParameterInfo[] addRemoveParams = new ParameterInfo[] { + ParameterInfo[] addRemoveParams = { new ParameterInfo { Name = "del", @@ -5525,7 +6330,7 @@ static void AppendDelegate( IsVirtual = true }}; - ParameterInfo[] releaseParams = new ParameterInfo[] { + ParameterInfo[] releaseParams = { new ParameterInfo { Name = "handle", @@ -5545,7 +6350,7 @@ static void AppendDelegate( Kind = TypeKind.Primitive }}; - ParameterInfo[] constructorParams = new ParameterInfo[] { + ParameterInfo[] constructorParams = { new ParameterInfo { Name = "cppHandle", @@ -5574,158 +6379,27 @@ static void AppendDelegate( Kind = TypeKind.Primitive }}; - // Free list state and functions - builders.CppGlobalStateAndFunctions.Append("\tint32_t "); - builders.CppGlobalStateAndFunctions.Append(typeName); - builders.CppGlobalStateAndFunctions.Append("FreeListSize;\n"); - builders.CppGlobalStateAndFunctions.Append('\t'); - AppendCppTypeName( - type, - builders.CppGlobalStateAndFunctions); - builders.CppGlobalStateAndFunctions.Append("** "); - builders.CppGlobalStateAndFunctions.Append(typeName); - builders.CppGlobalStateAndFunctions.Append("FreeList;\n"); - builders.CppGlobalStateAndFunctions.Append('\t'); - AppendCppTypeName( - type, - builders.CppGlobalStateAndFunctions); - builders.CppGlobalStateAndFunctions.Append("** NextFree"); - builders.CppGlobalStateAndFunctions.Append(typeName); - builders.CppGlobalStateAndFunctions.Append(";\n"); - builders.CppGlobalStateAndFunctions.Append("\t\n"); - builders.CppGlobalStateAndFunctions.Append("\tint32_t Store"); - builders.CppGlobalStateAndFunctions.Append(typeName); - builders.CppGlobalStateAndFunctions.Append('('); - AppendCppTypeName( - type, - builders.CppGlobalStateAndFunctions); - builders.CppGlobalStateAndFunctions.Append("* del)\n"); - builders.CppGlobalStateAndFunctions.Append("\t{\n"); - builders.CppGlobalStateAndFunctions.Append("\t\tassert(NextFree"); - builders.CppGlobalStateAndFunctions.Append(typeName); - builders.CppGlobalStateAndFunctions.Append(" != nullptr);\n"); - builders.CppGlobalStateAndFunctions.Append("\t\t"); - AppendCppTypeName( - type, - builders.CppGlobalStateAndFunctions); - builders.CppGlobalStateAndFunctions.Append("** pNext = NextFree"); - builders.CppGlobalStateAndFunctions.Append(typeName); - builders.CppGlobalStateAndFunctions.Append(";\n"); - builders.CppGlobalStateAndFunctions.Append("\t\tNextFree"); - builders.CppGlobalStateAndFunctions.Append(typeName); - builders.CppGlobalStateAndFunctions.Append(" = ("); - AppendCppTypeName( - type, - builders.CppGlobalStateAndFunctions); - builders.CppGlobalStateAndFunctions.Append("**)*pNext;\n"); - builders.CppGlobalStateAndFunctions.Append("\t\t*pNext = del;\n"); - builders.CppGlobalStateAndFunctions.Append("\t\treturn (int32_t)(pNext - "); - builders.CppGlobalStateAndFunctions.Append(typeName); - builders.CppGlobalStateAndFunctions.Append("FreeList);\n"); - builders.CppGlobalStateAndFunctions.Append("\t}\n"); - builders.CppGlobalStateAndFunctions.Append("\t\n"); - builders.CppGlobalStateAndFunctions.Append('\t'); - AppendCppTypeName( - type, - builders.CppGlobalStateAndFunctions); - builders.CppGlobalStateAndFunctions.Append("* Get"); - builders.CppGlobalStateAndFunctions.Append(typeName); - builders.CppGlobalStateAndFunctions.Append("(int32_t handle)\n"); - builders.CppGlobalStateAndFunctions.Append("\t{\n"); - builders.CppGlobalStateAndFunctions.Append("\t\tassert(handle >= 0 && handle < "); - builders.CppGlobalStateAndFunctions.Append(typeName); - builders.CppGlobalStateAndFunctions.Append("FreeListSize);\n"); - builders.CppGlobalStateAndFunctions.Append("\t\treturn "); - builders.CppGlobalStateAndFunctions.Append(typeName); - builders.CppGlobalStateAndFunctions.Append("FreeList[handle];\n"); - builders.CppGlobalStateAndFunctions.Append("\t}\n"); - builders.CppGlobalStateAndFunctions.Append("\t\n"); - builders.CppGlobalStateAndFunctions.Append("\tvoid Remove"); - builders.CppGlobalStateAndFunctions.Append(typeName); - builders.CppGlobalStateAndFunctions.Append("(int32_t handle)\n"); - builders.CppGlobalStateAndFunctions.Append("\t{\n"); - builders.CppGlobalStateAndFunctions.Append("\t\t"); - AppendCppTypeName( - type, - builders.CppGlobalStateAndFunctions); - builders.CppGlobalStateAndFunctions.Append("** pRelease = "); - builders.CppGlobalStateAndFunctions.Append(typeName); - builders.CppGlobalStateAndFunctions.Append("FreeList + handle;\n"); - builders.CppGlobalStateAndFunctions.Append("\t\t*pRelease = ("); - AppendCppTypeName( - type, + AppendCppPointerFreeListStateAndFunctions( + GetTypeName(cppTypeName, type.Namespace), + typeParams, + bindingTypeName, builders.CppGlobalStateAndFunctions); - builders.CppGlobalStateAndFunctions.Append("*)NextFree"); - builders.CppGlobalStateAndFunctions.Append(typeName); - builders.CppGlobalStateAndFunctions.Append(";\n"); - builders.CppGlobalStateAndFunctions.Append("\t\tNextFree"); - builders.CppGlobalStateAndFunctions.Append(typeName); - builders.CppGlobalStateAndFunctions.Append(" = pRelease;\n"); - builders.CppGlobalStateAndFunctions.Append("\t}\n"); - - // Free list init - builders.CppInitBody.Append('\t'); - builders.CppInitBody.Append(typeName); - builders.CppInitBody.Append("FreeListSize = "); - if (maxSimultaneous.HasValue) - { - builders.CppInitBody.Append(maxSimultaneous); - } - else - { - builders.CppInitBody.Append("maxManagedObjects"); - } - builders.CppInitBody.Append(";\n"); - builders.CppInitBody.Append("\t"); - builders.CppInitBody.Append(typeName); - builders.CppInitBody.Append("FreeList = new "); - AppendCppTypeName( - type, - builders.CppInitBody); - builders.CppInitBody.Append("*["); - builders.CppInitBody.Append(typeName); - builders.CppInitBody.Append("FreeListSize];\n"); - builders.CppInitBody.Append("\tfor (int32_t i = 0, end = "); - builders.CppInitBody.Append(typeName); - builders.CppInitBody.Append("FreeListSize - 1; i < end; ++i)\n"); - builders.CppInitBody.Append("\t{\n"); - builders.CppInitBody.Append("\t "); - builders.CppInitBody.Append(typeName); - builders.CppInitBody.Append("FreeList[i] = ("); - AppendCppTypeName( - type, - builders.CppInitBody); - builders.CppInitBody.Append("*)("); - builders.CppInitBody.Append(typeName); - builders.CppInitBody.Append("FreeList + i + 1);\n"); - builders.CppInitBody.Append("\t}\n"); - builders.CppInitBody.Append('\t'); - builders.CppInitBody.Append(typeName); - builders.CppInitBody.Append("FreeList["); - builders.CppInitBody.Append(typeName); - builders.CppInitBody.Append("FreeListSize - 1] = nullptr;\n"); - builders.CppInitBody.Append("\tNextFree"); - builders.CppInitBody.Append(typeName); - builders.CppInitBody.Append(" = "); - builders.CppInitBody.Append(typeName); - builders.CppInitBody.Append("FreeList + 1;\n"); - - // C++ type declaration - int indent = AppendCppTypeDeclaration( - type.Namespace, - numberedTypeName, - false, + + AppendCppPointerFreeListInit( typeParams, - builders.CppTypeDeclarations); - + GetTypeName(cppTypeName, type.Namespace), + maxSimultaneous, + bindingTypeName, + builders.CppInitBodyArrays, + builders.CppInitBodyFirstBoot); + // C++ type definition (begin) AppendCppTypeDefinitionBegin( - numberedTypeName, - type.Namespace, + GetTypeName(cppTypeName, type.Namespace), TypeKind.Class, typeParams, - "Object", - "System", + GetTypeName(typeof(object)), + null, null, false, indent, @@ -5735,18 +6409,18 @@ 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( indent + 1, builders.CppTypeDefinitions); AppendCppMethodDeclaration( - numberedTypeName, + cppTypeName, false, false, false, @@ -5757,30 +6431,6 @@ static void AppendDelegate( AppendIndent( indent + 1, builders.CppTypeDefinitions); - AppendCppMethodDeclaration( - "Invoke", - false, - false, - false, - invokeMethod.ReturnType, - null, - invokeParams, - builders.CppTypeDefinitions); - AppendIndent( - indent + 1, - builders.CppTypeDefinitions); - AppendCppMethodDeclaration( - "operator()", - false, - true, - false, - invokeMethod.ReturnType, - null, - invokeParams, - builders.CppTypeDefinitions); - AppendIndent( - indent + 1, - builders.CppTypeDefinitions); AppendCppMethodDeclaration( "operator+=", false, @@ -5807,8 +6457,7 @@ static void AppendDelegate( AppendCppFunctionPointerDefinition( releaseFuncName, true, - null, - null, + default(TypeName), TypeKind.None, releaseParams, typeof(void), @@ -5816,26 +6465,15 @@ static void AppendDelegate( AppendCppFunctionPointerDefinition( constructorFuncName, true, - null, - null, + default(TypeName), TypeKind.None, constructorParams, typeof(void), builders.CppFunctionPointers); - AppendCppFunctionPointerDefinition( - invokeFuncName, - false, - null, - null, - TypeKind.None, - invokeParams, - invokeMethod.ReturnType, - builders.CppFunctionPointers); AppendCppFunctionPointerDefinition( addFuncName, false, - null, - null, + default(TypeName), TypeKind.None, addRemoveParams, typeof(void), @@ -5843,1497 +6481,3951 @@ static void AppendDelegate( AppendCppFunctionPointerDefinition( removeFuncName, false, - null, - null, + default(TypeName), TypeKind.None, addRemoveParams, typeof(void), builders.CppFunctionPointers); - // C++ init params - AppendCppInitParam( - releaseFuncNameLower, + // C++ and C# init params + AppendCppInitBodyFunctionPointerParameterRead( + releaseFuncName, true, - null, - null, + default(TypeName), TypeKind.None, releaseParams, typeof(void), - builders.CppInitParams); - AppendCppInitParam( - constructorFuncNameLower, + builders.CppInitBodyParameterReads); + AppendCppInitBodyFunctionPointerParameterRead( + constructorFuncName, true, - null, - null, + default(TypeName), TypeKind.None, constructorParams, typeof(void), - builders.CppInitParams); - AppendCppInitParam( - invokeFuncNameLower, - false, - null, - null, - TypeKind.None, - invokeParams, - invokeMethod.ReturnType, - builders.CppInitParams); - AppendCppInitParam( - addFuncNameLower, + builders.CppInitBodyParameterReads); + AppendCppInitBodyFunctionPointerParameterRead( + addFuncName, false, - null, - null, + default(TypeName), TypeKind.None, addRemoveParams, typeof(void), - builders.CppInitParams); - AppendCppInitParam( - removeFuncNameLower, + builders.CppInitBodyParameterReads); + AppendCppInitBodyFunctionPointerParameterRead( + removeFuncName, false, - null, - null, + default(TypeName), TypeKind.None, addRemoveParams, typeof(void), - builders.CppInitParams); - - // C++ init body - AppendCppInitBody( + builders.CppInitBodyParameterReads); + AppendCsharpCsharpDelegate( releaseFuncName, - releaseFuncNameLower, - builders.CppInitBody); - AppendCppInitBody( + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); + AppendCsharpCsharpDelegate( constructorFuncName, - constructorFuncNameLower, - builders.CppInitBody); - AppendCppInitBody( - invokeFuncName, - invokeFuncNameLower, - builders.CppInitBody); - AppendCppInitBody( + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); + AppendCsharpCsharpDelegate( addFuncName, - addFuncNameLower, - builders.CppInitBody); - AppendCppInitBody( + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); + AppendCsharpCsharpDelegate( removeFuncName, - removeFuncNameLower, - builders.CppInitBody); + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); // C++ method definitions (end) int cppMethodDefinitionsIndent = AppendNamespaceBeginning( type.Namespace, builders.CppMethodDefinitions); - // C++ default constructor - AppendCppMethodDefinitionBegin( - numberedTypeName, - null, - numberedTypeName, + AppendCppBaseTypeConstructor( + bindingTypeName, + typeTypeName, + TypeKind.Class, + cppTypeName, typeParams, - null, + new Type[0], new ParameterInfo[0], + constructorParams, + true, + constructorFuncName, cppMethodDefinitionsIndent, builders.CppMethodDefinitions); - AppendIndent( - cppMethodDefinitionsIndent + 1, + + AppendCppBaseTypeNullptrConstructor( + bindingTypeName, + typeTypeName, + typeParams, + new Type[0], + true, + cppMethodDefinitionsIndent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append(" : System::Object(nullptr)\n"); - AppendIndent( + + AppendCppBaseTypeCopyConstructor( + bindingTypeName, + typeTypeName, + typeParams, + new Type[0], + true, cppMethodDefinitionsIndent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); - AppendIndent( - cppMethodDefinitionsIndent + 1, + + AppendCppBaseTypeMoveConstructor( + typeTypeName, + typeParams, + new Type[0], + true, + cppMethodDefinitionsIndent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("CppHandle = Plugin::Store"); - builders.CppMethodDefinitions.Append(typeName); - builders.CppMethodDefinitions.Append("(this);\n"); - AppendIndent( - cppMethodDefinitionsIndent + 1, + + AppendCppBaseTypeHandleConstructor( + bindingTypeName, + typeTypeName, + typeParams, + new Type[0], + true, + cppMethodDefinitionsIndent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("Plugin::"); - builders.CppMethodDefinitions.Append(constructorFuncName); - builders.CppMethodDefinitions.Append("(CppHandle, &Handle, &ClassHandle);\n"); - AppendIndent( - cppMethodDefinitionsIndent + 1, + + AppendCppBaseTypeDestructor( + bindingTypeName, + typeTypeName, + typeParams, + true, + string.Empty, + releaseFuncName, + bindingTypeName, + cppMethodDefinitionsIndent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("if (Handle)\n"); - AppendIndent( - cppMethodDefinitionsIndent + 1, + + AppendCppBaseTypeAssignmentOperatorSameType( + typeTypeName, + typeParams, + true, + cppMethodDefinitionsIndent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); - AppendIndent( - cppMethodDefinitionsIndent + 2, + + AppendCppBaseTypeAssignmentOperatorNullptr( + typeTypeName, + typeParams, + true, + releaseFuncName, + cppMethodDefinitionsIndent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "Plugin::ReferenceManagedClass(Handle);\n"); - AppendIndent( - cppMethodDefinitionsIndent + 1, + + AppendCppBaseTypeMoveAssignmentOperator( + bindingTypeName, + typeTypeName, + typeParams, + true, + releaseFuncName, + cppMethodDefinitionsIndent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); - AppendIndent( - cppMethodDefinitionsIndent + 1, + + AppendCppBaseTypeEqualityOperator( + typeTypeName, + typeParams, + cppMethodDefinitionsIndent, + true, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("else\n"); - AppendIndent( - cppMethodDefinitionsIndent + 1, + + AppendCppBaseTypeInequalityOperator( + typeTypeName, + typeParams, + cppMethodDefinitionsIndent, + true, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); - AppendIndent( - cppMethodDefinitionsIndent + 2, + + // C++ add + AppendCppMethodDefinitionBegin( + GetTypeName(type), + typeof(void), + "operator+=", + typeParams, + null, + addRemoveParams, + indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("Plugin::Remove"); - builders.CppMethodDefinitions.Append(typeName); - builders.CppMethodDefinitions.Append("(CppHandle);\n"); AppendIndent( - cppMethodDefinitionsIndent + 2, + indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("ClassHandle = 0;\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendIndent( - cppMethodDefinitionsIndent + 2, + indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("CppHandle = 0;\n"); - AppendIndent( - cppMethodDefinitionsIndent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.Append("Plugin::"); + builders.CppMethodDefinitions.Append(addFuncName); + builders.CppMethodDefinitions.AppendLine("(Handle, del.Handle);"); AppendCppUnhandledExceptionHandling( - cppMethodDefinitionsIndent + 1, + indent + 1, builders.CppMethodDefinitions); AppendIndent( - cppMethodDefinitionsIndent, + indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.AppendLine("}"); AppendIndent( - cppMethodDefinitionsIndent, + indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); + builders.CppMethodDefinitions.AppendLine();; - // Construct with nullptr_t - AppendIndent( - cppMethodDefinitionsIndent, - builders.CppMethodDefinitions); - AppendTypeNameWithoutGenericSuffix( - numberedTypeName, - builders.CppMethodDefinitions); - AppendCppTypeParameters( + // C++ remove + AppendCppMethodDefinitionBegin( + GetTypeName(type), + typeof(void), + "operator-=", typeParams, + null, + addRemoveParams, + indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("::"); - AppendTypeNameWithoutGenericSuffix( - numberedTypeName, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("(std::nullptr_t n)\n"); - AppendIndent( - cppMethodDefinitionsIndent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "\t: System::Object(Plugin::InternalUse::Only, 0)\n"); AppendIndent( - cppMethodDefinitionsIndent, + indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendIndent( - cppMethodDefinitionsIndent + 1, + indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("CppHandle = Plugin::Store"); - builders.CppMethodDefinitions.Append(typeName); - builders.CppMethodDefinitions.Append("(this);\n"); - AppendIndent( - cppMethodDefinitionsIndent + 1, + builders.CppMethodDefinitions.Append("Plugin::"); + builders.CppMethodDefinitions.Append(removeFuncName); + builders.CppMethodDefinitions.AppendLine("(Handle, del.Handle);"); + AppendCppUnhandledExceptionHandling( + indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("ClassHandle = 0;\n"); AppendIndent( - cppMethodDefinitionsIndent, + indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.AppendLine("}"); AppendIndent( - cppMethodDefinitionsIndent, + indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("\n"); + builders.CppMethodDefinitions.AppendLine();; - // Copy constructor - AppendIndent( - cppMethodDefinitionsIndent, - builders.CppMethodDefinitions); - AppendTypeNameWithoutGenericSuffix( - numberedTypeName, - builders.CppMethodDefinitions); - AppendCppTypeParameters( - typeParams, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("::"); - AppendTypeNameWithoutGenericSuffix( - numberedTypeName, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("(const "); - AppendTypeNameWithoutGenericSuffix( - numberedTypeName, - builders.CppMethodDefinitions); - AppendCppTypeParameters( + // C# GetDelegate call + AppendCsharpGetDelegateCall( + GetTypeName(type), typeParams, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("& other)\n"); - AppendIndent( - cppMethodDefinitionsIndent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "\t: System::Object(Plugin::InternalUse::Only, other.Handle)\n"); - AppendIndent( - cppMethodDefinitionsIndent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); - AppendIndent( - cppMethodDefinitionsIndent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("CppHandle = Plugin::Store"); - builders.CppMethodDefinitions.Append(typeName); - builders.CppMethodDefinitions.Append("(this);\n"); - AppendIndent( - cppMethodDefinitionsIndent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("if (Handle)\n"); - AppendIndent( - cppMethodDefinitionsIndent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); - AppendIndent( - cppMethodDefinitionsIndent + 2, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "Plugin::ReferenceManagedClass(Handle);\n"); - AppendIndent( - cppMethodDefinitionsIndent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); - AppendIndent( - cppMethodDefinitionsIndent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "ClassHandle = other.ClassHandle;\n"); - AppendIndent( - cppMethodDefinitionsIndent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); - AppendIndent( - cppMethodDefinitionsIndent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("\n"); + "NativeInvoke", + builders.CsharpGetDelegateCalls); - // Move constructor - AppendIndent( - cppMethodDefinitionsIndent, - builders.CppMethodDefinitions); - AppendTypeNameWithoutGenericSuffix( - numberedTypeName, - builders.CppMethodDefinitions); - AppendCppTypeParameters( - typeParams, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("::"); - AppendTypeNameWithoutGenericSuffix( - numberedTypeName, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("("); - AppendTypeNameWithoutGenericSuffix( - numberedTypeName, - builders.CppMethodDefinitions); - AppendCppTypeParameters( + // C# class (beginning) + builders.CsharpBaseTypes.Append("class "); + builders.CsharpBaseTypes.Append(bindingTypeName); + builders.CsharpBaseTypes.AppendLine();; + builders.CsharpBaseTypes.AppendLine("{"); + + // C# class fields + builders.CsharpBaseTypes.AppendLine("\tpublic int CppHandle;"); + builders.CsharpBaseTypes.Append("\tpublic "); + AppendCsharpTypeFullName( + type, + builders.CsharpBaseTypes); + builders.CsharpBaseTypes.AppendLine(" Delegate;"); + builders.CsharpBaseTypes.AppendLine("\t"); + + // C# class constructor + builders.CsharpBaseTypes.Append("\tpublic "); + builders.CsharpBaseTypes.Append(bindingTypeName); + 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; + AppendNativeInvokeFuncName( + type, typeParams, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("&& other)\n"); - AppendIndent( - cppMethodDefinitionsIndent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "\t: System::Object(Plugin::InternalUse::Only, other.Handle)\n"); - AppendIndent( - cppMethodDefinitionsIndent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); - AppendIndent( - cppMethodDefinitionsIndent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "CppHandle = other.CppHandle;\n"); - AppendIndent( - cppMethodDefinitionsIndent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "ClassHandle = other.ClassHandle;\n"); - AppendIndent( - cppMethodDefinitionsIndent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("other.Handle = 0;\n"); - AppendIndent( - cppMethodDefinitionsIndent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("other.CppHandle = 0;\n"); - AppendIndent( - cppMethodDefinitionsIndent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("other.ClassHandle = 0;\n"); - AppendIndent( - cppMethodDefinitionsIndent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); - AppendIndent( - cppMethodDefinitionsIndent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("\n"); + "NativeInvoke", + builders.TempStrBuilder); + string nativeInvokeFuncName = builders.TempStrBuilder.ToString(); - // Handle constructor - AppendIndent( - cppMethodDefinitionsIndent, - builders.CppMethodDefinitions); - AppendTypeNameWithoutGenericSuffix( - numberedTypeName, - builders.CppMethodDefinitions); - AppendCppTypeParameters( + // operator() is how C# forwards the delegate invocation to C++ + MethodInfo invokeMethod = type.GetMethod("Invoke"); + AppendBaseTypeCppMethodCall( + type, + bindingTypeName, + typeTypeName, typeParams, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("::"); - AppendTypeNameWithoutGenericSuffix( - numberedTypeName, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "(Plugin::InternalUse iu, int32_t handle)\n"); - AppendIndent( - cppMethodDefinitionsIndent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "\t: System::Object(iu, handle)\n"); - AppendIndent( - cppMethodDefinitionsIndent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); - AppendIndent( - cppMethodDefinitionsIndent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("CppHandle = Plugin::Store"); - builders.CppMethodDefinitions.Append(typeName); - builders.CppMethodDefinitions.Append("(this);\n"); - AppendIndent( - cppMethodDefinitionsIndent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("if (Handle)\n"); - AppendIndent( - cppMethodDefinitionsIndent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); - AppendIndent( - cppMethodDefinitionsIndent + 2, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "Plugin::ReferenceManagedClass(Handle);\n"); - AppendIndent( - cppMethodDefinitionsIndent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); - AppendIndent( - cppMethodDefinitionsIndent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "ClassHandle = 0;\n"); - AppendIndent( - cppMethodDefinitionsIndent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); - AppendIndent( - cppMethodDefinitionsIndent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("\n"); + invokeMethod, + "NativeInvoke", + nativeInvokeFuncName, + "operator()", + false, + true, + indent, + builders); - // Destructor - AppendIndent( - cppMethodDefinitionsIndent, - builders.CppMethodDefinitions); - AppendTypeNameWithoutGenericSuffix( - numberedTypeName, - builders.CppMethodDefinitions); - AppendCppTypeParameters( + // C# class (ending) + builders.CsharpBaseTypes.AppendLine("}"); + builders.CsharpBaseTypes.AppendLine();; + + // Invoke() is how C++ invokes the delegate + AppendBaseTypeMethodCallsCsharpMethod( + type, + bindingTypeName, typeParams, + invokeMethod, + "Invoke", + null, + indent, + builders); + + // C# constructor delegate type + AppendCsharpDelegateType( + constructorFuncName, + true, + type, + TypeKind.Class, + typeof(void), + constructorParams, + builders.CsharpDelegateTypes); + + AppendCsharpBaseTypeConstructorFunction( + type, + GetTypeName(bindingTypeName, string.Empty), + true, + constructorFuncName, + constructorParams, + new ParameterInfo[0], + builders.CsharpFunctions); + + // C# release delegate type + AppendCsharpDelegateType( + releaseFuncName, + true, + type, + TypeKind.Class, + typeof(void), + releaseParams, + builders.CsharpDelegateTypes); + + AppendCsharpBaseTypeReleaseFunction( + type, + GetTypeName(bindingTypeName, string.Empty), + true, + releaseFuncName, + null, + releaseParams, + builders.CsharpFunctions); + + // C# add delegate type + AppendCsharpDelegateType( + addFuncName, + false, + type, + TypeKind.Class, + typeof(void), + addRemoveParams, + builders.CsharpDelegateTypes); + + // C# add function + AppendCsharpFunctionBeginning( + type, + addFuncName, + false, + TypeKind.Class, + typeof(void), + addRemoveParams, + builders.CsharpFunctions); + builders.CsharpFunctions.Append("thiz += del;"); + AppendCsharpFunctionReturn( + addRemoveParams, + typeof(void), + TypeKind.Class, + null, + false, + builders.CsharpFunctions); + + // C# remove delegate type + AppendCsharpDelegateType( + removeFuncName, + false, + type, + TypeKind.Class, + typeof(void), + addRemoveParams, + builders.CsharpDelegateTypes); + + // C# remove function + AppendCsharpFunctionBeginning( + type, + removeFuncName, + false, + TypeKind.Class, + typeof(void), + addRemoveParams, + builders.CsharpFunctions); + builders.CsharpFunctions.Append("thiz -= del;"); + AppendCsharpFunctionReturn( + addRemoveParams, + typeof(void), + TypeKind.Class, + null, + false, + builders.CsharpFunctions); + + // C++ method definitions (end) + AppendCppMethodDefinitionsEnd( + indent, + builders.CppMethodDefinitions); + + // C++ type definition (end) + AppendCppTypeDefinitionEnd( + false, + indent, + builders.CppTypeDefinitions); + } + + static void AppendBaseType( + Type type, + JsonBaseType jsonBaseType, + TypeName baseTypeTypeName, + Type[] typeParams, + int maxSimultaneous, + Assembly[] assemblies, + StringBuilders builders) + { + // Get specified derived type name + TypeName derivedTypeTypeName = SplitJsonTypeName( + jsonBaseType.DerivedName); + + builders.TempStrBuilder.Length = 0; + builders.TempStrBuilder.Append("Release"); + builders.TempStrBuilder.Append(baseTypeTypeName.Name); + string releaseFuncName = builders.TempStrBuilder.ToString(); + + builders.TempStrBuilder.Length = 0; + AppendCppTypeName( + baseTypeTypeName, + builders.TempStrBuilder); + string cppBaseTypeName = builders.TempStrBuilder.ToString(); + + bool hasDefaultConstructor = !type.IsClass || + (type.GetConstructor(new Type[0]) != null || + type.GetConstructors().Length == 0); + + // Either use specified constructors, the default constructor, or + // nothing in the case of MonoBehaviour (where you can't call 'new') + JsonConstructor[] jsonConstructors = jsonBaseType.Constructors; + if (jsonConstructors == null) + { + // Base classes must have a default constructor or no + // constructors at all + if (!hasDefaultConstructor) + { + // Throw an exception so the user knows what to fix in the JSON + StringBuilder errorBuilder = new StringBuilder(1024); + errorBuilder.Append("Base type \""); + AppendCsharpTypeFullName( + type, + errorBuilder); + errorBuilder.Append( + ")\" doesn't have any specified constructors or a default constructor"); + throw new Exception(errorBuilder.ToString()); + } + + jsonConstructors = new[] + { + new JsonConstructor + { + ParamTypes = new string[0] + } + }; + } + + // Build constructor function names and parameter lists + int numConstructors = jsonConstructors.Length; + string[] constructorFuncNames = new string[numConstructors]; + string[] constructorFuncNameLowers = new string[numConstructors]; + ParameterInfo[][] cppConstructorParams = new ParameterInfo[numConstructors][]; + ParameterInfo[][] constructorParams = new ParameterInfo[numConstructors][]; + for (int i = 0; i < numConstructors; ++i) + { + JsonConstructor jsonCtor = jsonConstructors[i]; + Type[] paramTypes = GetTypes( + jsonCtor.ParamTypes, + assemblies); + + builders.TempStrBuilder.Length = 0; + builders.TempStrBuilder.Append(baseTypeTypeName.Name); + builders.TempStrBuilder.Append("Constructor"); + AppendTypeNames( + paramTypes, + builders.TempStrBuilder); + string constructorFuncName = builders.TempStrBuilder.ToString(); + + builders.TempStrBuilder[0] = char.ToLower( + builders.TempStrBuilder[0]); + string constructorFuncNameLower = builders.TempStrBuilder.ToString(); + + ParameterInfo[] parameters = GetConstructorParameters( + type, + true, + jsonCtor.ParamTypes); + int numParams = parameters.Length; + ParameterInfo[] fullParams = new ParameterInfo[numParams + 2]; + fullParams[0] = new ParameterInfo + { + Name = "cppHandle", + ParameterType = typeof(int), + DereferencedParameterType = typeof(int), + IsOut = false, + IsRef = false, + Kind = TypeKind.Primitive + }; + fullParams[1] = new ParameterInfo + { + Name = "handle", + ParameterType = typeof(int), + DereferencedParameterType = typeof(int), + IsOut = true, + IsRef = false, + Kind = TypeKind.Primitive + }; + Array.Copy( + parameters, + 0, + fullParams, + 2, + numParams); + + constructorFuncNames[i] = constructorFuncName; + constructorFuncNameLowers[i] = constructorFuncNameLower; + cppConstructorParams[i] = parameters; + constructorParams[i] = fullParams; + } + + // Determine what the C++ class should derive from + Type cppBaseClass; + Type[] cppBaseClassTypeParams; + Type[] cppCtorInitTypes = GetCppCtorInitTypes( + type, + true); + Type[] cppInterfaceTypes; + if (type.IsInterface) + { + cppBaseClass = typeof(object); + cppBaseClassTypeParams = null; + cppInterfaceTypes = new [] { type }; + } + else + { + cppBaseClass = type; + cppBaseClassTypeParams = typeParams; + cppInterfaceTypes = new Type[0]; + } + + AppendCppPointerFreeListStateAndFunctions( + baseTypeTypeName, + null, + baseTypeTypeName.Name, + builders.CppGlobalStateAndFunctions); + + AppendCppPointerFreeListInit( + null, + baseTypeTypeName, + maxSimultaneous, + baseTypeTypeName.Name, + builders.CppInitBodyArrays, + builders.CppInitBodyFirstBoot); + + // C++ type declaration + int indent = AppendCppTypeDeclaration( + baseTypeTypeName, + false, + null, + builders.CppTypeDeclarations); + + ParameterInfo[] releaseParams = { + new ParameterInfo + { + Name = "handle", + ParameterType = typeof(int), + DereferencedParameterType = typeof(int), + IsOut = false, + IsRef = false, + Kind = TypeKind.Primitive + }}; + + // C++ type definition (begin) + AppendCppTypeDefinitionBegin( + baseTypeTypeName, + TypeKind.Class, + null, + GetTypeName(cppBaseClass), + cppBaseClassTypeParams, + cppInterfaceTypes, + false, + indent, + builders.CppTypeDefinitions); + + // C++ type fields + AppendIndent( + indent + 1, + builders.CppTypeDefinitions); + builders.CppTypeDefinitions.AppendLine("int32_t CppHandle;"); + + // C++ constructor declarations + for (int i = 0; i < numConstructors; ++i) + { + AppendIndent( + indent + 1, + builders.CppTypeDefinitions); + AppendCppMethodDeclaration( + cppBaseTypeName, + false, + false, + false, + null, + null, + cppConstructorParams[i], + builders.CppTypeDefinitions); + } + + // C++ constructor declaration macro + builders.CppMacros.Append("#define "); + AppendUppercaseWithUnderscores( + derivedTypeTypeName.Namespace, + builders.CppMacros); + builders.CppMacros.Append('_'); + AppendUppercaseWithUnderscores( + derivedTypeTypeName.Name, + builders.CppMacros); + builders.CppMacros.AppendLine("_DEFAULT_CONSTRUCTOR_DECLARATION \\"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.Append(derivedTypeTypeName.Name); + builders.CppMacros.AppendLine("(Plugin::InternalUse iu, int32_t handle);"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.AppendLine();; + + // C++ constructor definition macro + builders.CppMacros.Append("#define "); + AppendUppercaseWithUnderscores( + derivedTypeTypeName.Namespace, + builders.CppMacros); + builders.CppMacros.Append('_'); + AppendUppercaseWithUnderscores( + derivedTypeTypeName.Name, + builders.CppMacros); + 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.AppendLine("(Plugin::InternalUse iu, int32_t handle) \\"); + AppendCppConstructorInitializerList( + cppCtorInitTypes, + indent + 1, + builders.CppMacros, + " \\\n"); + AppendIndent(indent + 1, builders.CppMacros); + builders.CppMacros.Append(", "); + AppendCppTypeFullName( + baseTypeTypeName, + builders.CppMacros); + 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 "); + AppendUppercaseWithUnderscores( + derivedTypeTypeName.Namespace, + builders.CppMacros); + builders.CppMacros.Append('_'); + AppendUppercaseWithUnderscores( + derivedTypeTypeName.Name, + builders.CppMacros); + builders.CppMacros.AppendLine("_DEFAULT_CONSTRUCTOR \\"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.Append(derivedTypeTypeName.Name); + builders.CppMacros.AppendLine("(Plugin::InternalUse iu, int32_t handle) \\"); + AppendCppConstructorInitializerList( + cppCtorInitTypes, + indent + 1, + builders.CppMacros, + " \\\n"); + AppendIndent(indent + 1, builders.CppMacros); + builders.CppMacros.Append(", "); + AppendCppTypeFullName( + baseTypeTypeName, + builders.CppMacros); + 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.AppendLine("}"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.AppendLine();; + + // C++ function pointers + AppendCppFunctionPointerDefinition( + releaseFuncName, + true, + default(TypeName), + TypeKind.None, + releaseParams, + typeof(void), + builders.CppFunctionPointers); + for (int i = 0; i < numConstructors; ++i) + { + AppendCppFunctionPointerDefinition( + constructorFuncNames[i], + true, + default(TypeName), + TypeKind.None, + constructorParams[i], + typeof(void), + builders.CppFunctionPointers); + } + + // C++ and C# init params + AppendCppInitBodyFunctionPointerParameterRead( + releaseFuncName, + true, + default(TypeName), + TypeKind.None, + releaseParams, + typeof(void), + builders.CppInitBodyParameterReads); + AppendCsharpCsharpDelegate( + releaseFuncName, + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); + for (int i = 0; i < numConstructors; ++i) + { + string funcName = constructorFuncNames[i]; + AppendCppInitBodyFunctionPointerParameterRead( + funcName, + true, + default(TypeName), + TypeKind.None, + constructorParams[i], + typeof(void), + builders.CppInitBodyParameterReads); + AppendCsharpCsharpDelegate( + funcName, + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); + } + + // C++ method definitions (end) + int cppMethodDefinitionsIndent = AppendNamespaceBeginning( + baseTypeTypeName.Namespace, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("::~"); - AppendTypeNameWithoutGenericSuffix( - numberedTypeName, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("()\n"); - AppendIndent( - cppMethodDefinitionsIndent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); - AppendIndent( - cppMethodDefinitionsIndent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("Plugin::Remove"); - builders.CppMethodDefinitions.Append(typeName); - builders.CppMethodDefinitions.Append("(CppHandle);\n"); - AppendIndent( - cppMethodDefinitionsIndent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("CppHandle = 0;\n"); - AppendIndent( - cppMethodDefinitionsIndent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("if (Handle)\n"); - AppendIndent( - cppMethodDefinitionsIndent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); - AppendIndent( - cppMethodDefinitionsIndent + 2, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("int32_t handle = Handle;\n"); - AppendIndent( - cppMethodDefinitionsIndent + 2, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("int32_t classHandle = ClassHandle;\n"); - AppendIndent( - cppMethodDefinitionsIndent + 2, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("Handle = 0;\n"); - AppendIndent( - cppMethodDefinitionsIndent + 2, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("ClassHandle = 0;\n"); - AppendIndent( - cppMethodDefinitionsIndent + 2, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "if (Plugin::DereferenceManagedClassNoRelease(handle))\n"); - AppendIndent( - cppMethodDefinitionsIndent + 2, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); - AppendIndent( - cppMethodDefinitionsIndent + 3, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("Plugin::"); - builders.CppMethodDefinitions.Append(releaseFuncName); - builders.CppMethodDefinitions.Append("(handle, classHandle);\n"); - AppendCppUnhandledExceptionHandling( - cppMethodDefinitionsIndent + 3, - builders.CppMethodDefinitions); - AppendIndent( - cppMethodDefinitionsIndent + 2, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); - AppendIndent( - cppMethodDefinitionsIndent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); - AppendIndent( - cppMethodDefinitionsIndent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + + for (int i = 0; i < numConstructors; ++i) + { + AppendCppBaseTypeConstructor( + baseTypeTypeName.Name, + baseTypeTypeName, + TypeKind.Class, + cppBaseTypeName, + typeParams, + cppCtorInitTypes, + cppConstructorParams[i], + constructorParams[i], + false, + constructorFuncNames[i], + cppMethodDefinitionsIndent, + builders.CppMethodDefinitions); + } + + AppendCppBaseTypeNullptrConstructor( + baseTypeTypeName.Name, + baseTypeTypeName, + typeParams, + cppCtorInitTypes, + false, + cppMethodDefinitionsIndent, + builders.CppMethodDefinitions); + + AppendCppBaseTypeCopyConstructor( + baseTypeTypeName.Name, + baseTypeTypeName, + typeParams, + cppCtorInitTypes, + false, + cppMethodDefinitionsIndent, + builders.CppMethodDefinitions); + + AppendCppBaseTypeMoveConstructor( + baseTypeTypeName, + typeParams, + cppCtorInitTypes, + false, + cppMethodDefinitionsIndent, + builders.CppMethodDefinitions); + + AppendCppBaseTypeHandleConstructor( + baseTypeTypeName.Name, + baseTypeTypeName, + typeParams, + cppCtorInitTypes, + false, + cppMethodDefinitionsIndent, + builders.CppMethodDefinitions); + + AppendCppBaseTypeDestructor( + baseTypeTypeName.Name, + baseTypeTypeName, + typeParams, + false, + derivedTypeTypeName.Name, + releaseFuncName, + baseTypeTypeName.Name, + cppMethodDefinitionsIndent, + builders.CppMethodDefinitions); + + AppendCppBaseTypeAssignmentOperatorSameType( + baseTypeTypeName, + typeParams, + false, + cppMethodDefinitionsIndent, + builders.CppMethodDefinitions); + + AppendCppBaseTypeAssignmentOperatorNullptr( + baseTypeTypeName, + typeParams, + false, + releaseFuncName, + cppMethodDefinitionsIndent, + builders.CppMethodDefinitions); + + AppendCppBaseTypeMoveAssignmentOperator( + baseTypeTypeName.Name, + baseTypeTypeName, + typeParams, + false, + releaseFuncName, + cppMethodDefinitionsIndent, + builders.CppMethodDefinitions); + + AppendCppBaseTypeEqualityOperator( + baseTypeTypeName, + typeParams, + cppMethodDefinitionsIndent, + false, + builders.CppMethodDefinitions); + + AppendCppBaseTypeInequalityOperator( + baseTypeTypeName, + typeParams, + cppMethodDefinitionsIndent, + false, + builders.CppMethodDefinitions); + + if (!string.IsNullOrEmpty(derivedTypeTypeName.Name)) + { + // C++ whole object free list + AppendCppWholeObjectFreeListStateAndFunctions( + null, + baseTypeTypeName, + baseTypeTypeName.Name, + builders.CppGlobalStateAndFunctions); + AppendCppWholeObjectFreeListInit( + maxSimultaneous, + baseTypeTypeName.Name, + builders.CppInitBodyArrays, + builders.CppInitBodyFirstBoot); + + // C++ binding function to create the base class + builders.TempStrBuilder.Length = 0; + builders.TempStrBuilder.Append("New"); + builders.TempStrBuilder.Append(baseTypeTypeName.Name); + string cppDefaultConstructorBindingFunctionName = builders.TempStrBuilder.ToString(); + AppendIndent( + indent, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.Append("DLLEXPORT int32_t "); + builders.CppMethodDefinitions.Append(cppDefaultConstructorBindingFunctionName); + builders.CppMethodDefinitions.AppendLine("(int32_t handle)"); + AppendIndent( + indent, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine("{"); + AppendIndent( + indent + 1, + builders.CppMethodDefinitions); + AppendCppTypeFullName( + baseTypeTypeName, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.Append("* memory = Plugin::StoreWhole"); + builders.CppMethodDefinitions.Append(baseTypeTypeName.Name); + builders.CppMethodDefinitions.AppendLine("();"); + AppendIndent( + indent + 1, + builders.CppMethodDefinitions); + AppendCppTypeFullName( + derivedTypeTypeName, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.Append("* thiz = new (memory) "); + AppendCppTypeFullName( + derivedTypeTypeName, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine("(Plugin::InternalUse::Only, handle);"); + AppendIndent( + indent + 1, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine("return thiz->CppHandle;"); + AppendIndent( + indent, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine("}"); + builders.CppMethodDefinitions.AppendLine(); + + // C# usage of the C++ binding function to create from C# default constructor + ParameterInfo[] cppDefaultConstructorBindingFunctionParams = ConvertParameters( + new[] { typeof(int) }); + AppendCsharpDelegate( + true, + GetTypeName(string.Empty, string.Empty), + null, + cppDefaultConstructorBindingFunctionName, + cppDefaultConstructorBindingFunctionParams, + typeof(int), + TypeKind.None, + builders.CsharpCppDelegates); + AppendCsharpImport( + GetTypeName(string.Empty, string.Empty), + null, + cppDefaultConstructorBindingFunctionName, + ConvertParameters(Type.EmptyTypes), + typeof(int), + builders.CsharpImports); + AppendCsharpGetDelegateCall( + GetTypeName(string.Empty, string.Empty), + null, + cppDefaultConstructorBindingFunctionName, + builders.CsharpGetDelegateCalls); + + // C++ binding function to destroy the base class + builders.TempStrBuilder.Length = 0; + builders.TempStrBuilder.Append("Destroy"); + builders.TempStrBuilder.Append(baseTypeTypeName.Name); + string cppDestroyBindingFunctionName = builders.TempStrBuilder.ToString(); + AppendIndent( + indent, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.Append("DLLEXPORT void "); + builders.CppMethodDefinitions.Append(cppDestroyBindingFunctionName); + builders.CppMethodDefinitions.AppendLine("(int32_t cppHandle)"); + AppendIndent( + indent, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine("{"); + AppendIndent( + indent + 1, + builders.CppMethodDefinitions); + AppendCppTypeFullName( + baseTypeTypeName, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.Append("* instance = Plugin::Get"); + builders.CppMethodDefinitions.Append(baseTypeTypeName.Name); + builders.CppMethodDefinitions.AppendLine("(cppHandle);"); + AppendIndent( + indent + 1, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.Append("instance->~"); + AppendCppTypeName( + baseTypeTypeName, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine("();"); + AppendIndent( + indent, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine("}"); + builders.CppMethodDefinitions.AppendLine(); + + // C# usage of the C++ binding function to destroy from C# default constructor + ParameterInfo[] cppDestroyBindingFunctionParams = ConvertParameters( + new [] { typeof(int) }); + AppendCsharpDelegate( + true, + GetTypeName(string.Empty, string.Empty), + null, + cppDestroyBindingFunctionName, + cppDestroyBindingFunctionParams, + typeof(void), + TypeKind.None, + builders.CsharpCppDelegates); + ParameterInfo[] cppDestroyImportFunctionParams = ConvertParameters( + new Type[0]); + AppendCsharpImport( + GetTypeName(string.Empty, string.Empty), + null, + cppDestroyBindingFunctionName, + cppDestroyImportFunctionParams, + typeof(void), + builders.CsharpImports); + AppendCsharpGetDelegateCall( + GetTypeName(string.Empty, string.Empty), + null, + cppDestroyBindingFunctionName, + builders.CsharpGetDelegateCalls); + + // C# DestroyFunction enumerator + builders.CsharpDestroyFunctionEnumerators.Append("\t\t\t"); + builders.CsharpDestroyFunctionEnumerators.Append(baseTypeTypeName.Name); + builders.CsharpDestroyFunctionEnumerators.AppendLine(","); + + // C# Destroy queue cases + builders.CsharpDestroyQueueCases.Append("\t\t\t\t\t\tcase DestroyFunction."); + builders.CsharpDestroyQueueCases.Append(baseTypeTypeName.Name); + builders.CsharpDestroyQueueCases.AppendLine(":"); + builders.CsharpDestroyQueueCases.Append("\t\t\t\t\t\t\t"); + builders.CsharpDestroyQueueCases.Append(cppDestroyBindingFunctionName); + 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.AppendLine();; + builders.CsharpBaseTypes.AppendLine("{"); + builders.CsharpBaseTypes.Append("\tclass "); + builders.CsharpBaseTypes.Append(baseTypeTypeName.Name); + if (jsonBaseType != null) + { + builders.CsharpBaseTypes.Append(" : "); + AppendCsharpTypeFullName( + type, + builders.CsharpBaseTypes); + } + builders.CsharpBaseTypes.AppendLine();; + builders.CsharpBaseTypes.AppendLine("\t{"); + + // C# class fields + builders.CsharpBaseTypes.AppendLine("\t\tpublic int CppHandle;"); + builders.CsharpBaseTypes.AppendLine("\t\t"); + + if (derivedTypeTypeName.Name != null) + { + // C# class default constructor if the base class has one + if (hasDefaultConstructor) + { + builders.CsharpBaseTypes.Append("\t\tpublic "); + builders.CsharpBaseTypes.Append(baseTypeTypeName.Name); + 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.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.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.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 + for (int i = 0; i < numConstructors; ++i) + { + builders.CsharpBaseTypes.Append("\t\tpublic "); + builders.CsharpBaseTypes.Append(baseTypeTypeName.Name); + builders.CsharpBaseTypes.Append("(int cppHandle"); + ParameterInfo[] parameters = cppConstructorParams[i]; + if (parameters.Length > 0) + { + builders.CsharpBaseTypes.Append(", "); + AppendCsharpParams( + parameters, + builders.CsharpBaseTypes); + } + builders.CsharpBaseTypes.AppendLine(")"); + builders.CsharpBaseTypes.Append("\t\t\t: base("); + AppendCsharpFunctionCallParameters( + parameters, + builders.CsharpBaseTypes); + 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 + for (int i = 0; i < numConstructors; ++i) + { + AppendCsharpDelegateType( + constructorFuncNames[i], + true, + type, + TypeKind.Class, + typeof(void), + constructorParams[i], + builders.CsharpDelegateTypes); + } + + for (int i = 0; i < numConstructors; ++i) + { + AppendCsharpBaseTypeConstructorFunction( + type, + baseTypeTypeName, + false, + constructorFuncNames[i], + constructorParams[i], + cppConstructorParams[i], + builders.CsharpFunctions); + } + + // C# release delegate type + AppendCsharpDelegateType( + releaseFuncName, + true, + type, + TypeKind.Class, + typeof(void), + releaseParams, + builders.CsharpDelegateTypes); + + AppendCsharpBaseTypeReleaseFunction( + type, + baseTypeTypeName, + false, + releaseFuncName, + jsonBaseType.DerivedName, + releaseParams, + builders.CsharpFunctions); + + // All abstract methods + foreach (MethodInfo methodInfo in type.GetMethods()) + { + // Property methods like "get_X" have a "special name" + if (methodInfo.IsAbstract && !methodInfo.IsSpecialName) + { + AppendBaseTypeNativeMethod( + type, + baseTypeTypeName, + typeParams, + methodInfo, + false, + indent, + builders); + } + } + + // All interface methods + if (type.IsInterface) + { + foreach (Type interfaceType in type.GetInterfaces()) + { + foreach (MethodInfo methodInfo in interfaceType.GetMethods()) + { + // Property methods like "get_X" have a "special name" + if (methodInfo.IsAbstract && !methodInfo.IsSpecialName) + { + AppendBaseTypeNativeMethod( + type, + baseTypeTypeName, + typeParams, + methodInfo, + false, + indent, + builders); + } + } + } + } + + // Specified virtual methods + if (jsonBaseType.OverrideMethods != null) + { + MethodInfo[] methods = type.GetMethods(); + Type[] genericArgTypes = type.GetGenericArguments(); + foreach (JsonMethod jsonMethod in jsonBaseType.OverrideMethods) + { + if (jsonMethod.GenericParams != null) + { + foreach (JsonGenericParams jsonGenericParams in + jsonMethod.GenericParams) + { + MethodInfo methodInfo = GetMethod( + jsonMethod, + type, + typeParams, + genericArgTypes, + methods, + jsonGenericParams.Types); + AppendBaseTypeNativeMethod( + type, + baseTypeTypeName, + typeParams, + methodInfo, + false, + indent, + builders); + } + } + else + { + MethodInfo methodInfo = GetMethod( + jsonMethod, + type, + typeParams, + genericArgTypes, + methods, + null); + AppendBaseTypeNativeMethod( + type, + baseTypeTypeName, + typeParams, + methodInfo, + false, + indent, + builders); + } + } + } + + // All abstract properties + foreach (PropertyInfo propertyInfo in type.GetProperties()) + { + MethodInfo getMethodInfo = propertyInfo.GetGetMethod(); + MethodInfo setMethodInfo = propertyInfo.GetSetMethod(); + if ((getMethodInfo == null || !getMethodInfo.IsAbstract) && + (setMethodInfo == null || !setMethodInfo.IsAbstract)) + { + continue; + } + AppendBaseTypeProperty( + type, + baseTypeTypeName.Name, + baseTypeTypeName, + typeParams, + propertyInfo, + getMethodInfo, + setMethodInfo, + indent, + builders); + } + + // All interface properties + if (type.IsInterface) + { + foreach (Type interfaceType in type.GetInterfaces()) + { + foreach (PropertyInfo propertyInfo in + interfaceType.GetProperties()) + { + MethodInfo getMethodInfo = propertyInfo.GetGetMethod(); + MethodInfo setMethodInfo = propertyInfo.GetSetMethod(); + if ((getMethodInfo == null || !getMethodInfo.IsAbstract) && + (setMethodInfo == null || !setMethodInfo.IsAbstract)) + { + continue; + } + AppendBaseTypeProperty( + type, + baseTypeTypeName.Name, + baseTypeTypeName, + typeParams, + propertyInfo, + getMethodInfo, + setMethodInfo, + indent, + builders); + } + } + } + + // Specified virtual properties + if (jsonBaseType.OverrideProperties != null) + { + PropertyInfo[] properties = type.GetProperties(); + foreach (JsonProperty jsonProperty in jsonBaseType.OverrideProperties) + { + PropertyInfo propertyInfo = null; + foreach (PropertyInfo curPropertyInfo in properties) + { + if (curPropertyInfo.Name == jsonProperty.Name) + { + propertyInfo = curPropertyInfo; + break; + } + } + if (propertyInfo == null) + { + // Throw an exception so the user knows what to fix in the JSON + StringBuilder errorBuilder = new StringBuilder(1024); + errorBuilder.Append("Property \""); + AppendCsharpTypeFullName( + type, + errorBuilder); + errorBuilder.Append('.'); + errorBuilder.Append(jsonProperty.Name); + errorBuilder.Append(")\" not found"); + throw new Exception(errorBuilder.ToString()); + } + + MethodInfo getMethodInfo = propertyInfo.GetGetMethod(); + MethodInfo setMethodInfo = propertyInfo.GetSetMethod(); + if ((getMethodInfo == null || !getMethodInfo.IsVirtual) && + (setMethodInfo == null || !setMethodInfo.IsVirtual)) + { + // Throw an exception so the user knows what to fix in the JSON + StringBuilder errorBuilder = new StringBuilder(1024); + errorBuilder.Append("Property \""); + AppendCsharpTypeFullName( + type, + errorBuilder); + errorBuilder.Append('.'); + errorBuilder.Append(jsonProperty.Name); + errorBuilder.Append( + ")\" doesn't have either a virtual 'get' or 'set' to override"); + throw new Exception(errorBuilder.ToString()); + } + AppendBaseTypeProperty( + type, + baseTypeTypeName.Name, + baseTypeTypeName, + typeParams, + propertyInfo, + getMethodInfo, + setMethodInfo, + indent, + builders); + } + } + + // All abstract events + foreach (EventInfo eventInfo in type.GetEvents()) + { + MethodInfo addMethodInfo = eventInfo.GetAddMethod(); + MethodInfo removeMethodInfo = eventInfo.GetRemoveMethod(); + if ((addMethodInfo == null || !addMethodInfo.IsAbstract) && + (removeMethodInfo == null || !removeMethodInfo.IsAbstract)) + { + continue; + } + AppendBaseTypeEvent( + type, + baseTypeTypeName, + typeParams, + eventInfo, + addMethodInfo, + removeMethodInfo, + indent, + builders); + } + + // All interface events + if (type.IsInterface) + { + foreach (Type interfaceType in type.GetInterfaces()) + { + foreach (EventInfo eventInfo in interfaceType.GetEvents()) + { + MethodInfo addMethodInfo = eventInfo.GetAddMethod(); + MethodInfo removeMethodInfo = eventInfo.GetRemoveMethod(); + if ((addMethodInfo == null || !addMethodInfo.IsAbstract) && + (removeMethodInfo == null || !removeMethodInfo.IsAbstract)) + { + continue; + } + AppendBaseTypeEvent( + type, + baseTypeTypeName, + typeParams, + eventInfo, + addMethodInfo, + removeMethodInfo, + indent, + builders); + } + } + } + + // Specified virtual events + if (jsonBaseType.OverrideEvents != null) + { + EventInfo[] events = type.GetEvents(); + foreach (JsonEvent jsonEvent in jsonBaseType.OverrideEvents) + { + EventInfo eventInfo = null; + foreach (EventInfo curEventInfo in events) + { + if (curEventInfo.Name == jsonEvent.Name) + { + eventInfo = curEventInfo; + break; + } + } + if (eventInfo == null) + { + // Throw an exception so the user knows what to fix in the JSON + StringBuilder errorBuilder = new StringBuilder(1024); + errorBuilder.Append("Event \""); + AppendCsharpTypeFullName( + type, + errorBuilder); + errorBuilder.Append('.'); + errorBuilder.Append(jsonEvent.Name); + errorBuilder.Append(")\" not found"); + throw new Exception(errorBuilder.ToString()); + } + + MethodInfo addMethodInfo = eventInfo.GetAddMethod(); + MethodInfo removeMethodInfo = eventInfo.GetRemoveMethod(); + if ((addMethodInfo == null || !addMethodInfo.IsVirtual) && + (removeMethodInfo == null || !removeMethodInfo.IsVirtual)) + { + // Throw an exception so the user knows what to fix in the JSON + StringBuilder errorBuilder = new StringBuilder(1024); + errorBuilder.Append("Event \""); + AppendCsharpTypeFullName( + type, + errorBuilder); + errorBuilder.Append('.'); + errorBuilder.Append(jsonEvent.Name); + errorBuilder.Append( + ")\" doesn't have either a virtual 'add' or 'remove' to override"); + throw new Exception(errorBuilder.ToString()); + } + AppendBaseTypeEvent( + type, + baseTypeTypeName, + typeParams, + eventInfo, + addMethodInfo, + removeMethodInfo, + indent, + builders); + } + } + + // C# class (ending) + builders.CsharpBaseTypes.AppendLine("\t}"); + builders.CsharpBaseTypes.AppendLine("}"); + builders.CsharpBaseTypes.AppendLine(); + + // C++ method definitions (end) + AppendCppMethodDefinitionsEnd( + indent, + builders.CppMethodDefinitions); + + // C++ type definition (end) + AppendCppTypeDefinitionEnd( + false, + indent, + builders.CppTypeDefinitions); + } + + static void AppendBaseTypeNativeMethod( + Type type, + TypeName typeTypeName, + Type[] typeParams, + MethodInfo methodInfo, + bool typeIsDelegate, + int indent, + StringBuilders builders) + { + AppendCsharpGetDelegateCall( + GetTypeName(type), + typeParams, + methodInfo.Name, + builders.CsharpGetDelegateCalls); + + // Build the name of the C++ binding function that C# calls + builders.TempStrBuilder.Length = 0; + AppendNativeInvokeFuncName( + type, + typeParams, + methodInfo.Name, + builders.TempStrBuilder); + string nativeInvokeFuncName = builders.TempStrBuilder.ToString(); + + AppendBaseTypeCppMethodCall( + type, + typeTypeName.Name, + typeTypeName, + typeParams, + methodInfo, + methodInfo.Name, + nativeInvokeFuncName, + methodInfo.Name, + IsNonDelegateClass(type), + typeIsDelegate, + indent, + builders); + } + + static void AppendBaseTypeProperty( + Type type, + string typeName, + TypeName typeTypeName, + Type[] typeParams, + PropertyInfo propertyInfo, + MethodInfo getMethodInfo, + MethodInfo setMethodInfo, + int indent, + StringBuilders builders) + { + bool isOverride = IsNonDelegateClass(type); + + ParameterInfo[] parameters; + if (getMethodInfo != null && getMethodInfo.IsVirtual) + { + parameters = ConvertParameters( + getMethodInfo.GetParameters()); + } + else + { + System.Reflection.ParameterInfo[] setParams = + setMethodInfo.GetParameters(); + parameters = ConvertParameters(setParams, 1); + } + + builders.CsharpBaseTypes.Append("\t\tpublic "); + if (isOverride) + { + builders.CsharpBaseTypes.Append("override "); + } + AppendCsharpTypeFullName( + propertyInfo.PropertyType, + builders.CsharpBaseTypes); + builders.CsharpBaseTypes.Append(' '); + if (parameters.Length == 0) + { + builders.CsharpBaseTypes.Append(propertyInfo.Name); + } + else + { + builders.CsharpBaseTypes.Append("this["); + AppendCsharpParams( + parameters, + builders.CsharpBaseTypes); + builders.CsharpBaseTypes.Append(']'); + } + builders.CsharpBaseTypes.AppendLine();; + builders.CsharpBaseTypes.AppendLine("\t\t{"); + + TypeKind propertyTypeKind = GetTypeKind( + propertyInfo.PropertyType); + + if (getMethodInfo != null && getMethodInfo.IsVirtual) + { + AppendBaseTypeNativePropertyOrEvent( + type, + typeName, + typeParams, + typeTypeName, + propertyInfo.Name, + propertyTypeKind, + getMethodInfo, + "Get", + false, + indent, + builders); + } + + if (setMethodInfo != null && setMethodInfo.IsVirtual) + { + AppendBaseTypeNativePropertyOrEvent( + type, + typeName, + typeParams, + typeTypeName, + propertyInfo.Name, + propertyTypeKind, + setMethodInfo, + "Set", + false, + indent, + builders); + } + + builders.CsharpBaseTypes.AppendLine("\t\t}"); + builders.CsharpBaseTypes.AppendLine("\t\t"); + } + + static void AppendBaseTypeEvent( + Type type, + TypeName typeTypeName, + Type[] typeParams, + EventInfo eventInfo, + MethodInfo addMethodInfo, + MethodInfo removeMethodInfo, + int indent, + StringBuilders builders) + { + bool isOverride = IsNonDelegateClass(type); + + builders.CsharpBaseTypes.Append("\t\tpublic "); + if (isOverride) + { + builders.CsharpBaseTypes.Append("override "); + } + builders.CsharpBaseTypes.Append("event "); + AppendCsharpTypeFullName( + eventInfo.EventHandlerType, + builders.CsharpBaseTypes); + builders.CsharpBaseTypes.Append(' '); + builders.CsharpBaseTypes.Append(eventInfo.Name); + builders.CsharpBaseTypes.AppendLine();; + builders.CsharpBaseTypes.AppendLine("\t\t{"); + + TypeKind eventHandlerTypeKind = GetTypeKind( + eventInfo.EventHandlerType); + + if (addMethodInfo != null && addMethodInfo.IsVirtual) + { + AppendBaseTypeNativePropertyOrEvent( + type, + typeTypeName.Name, + typeParams, + typeTypeName, + eventInfo.Name, + eventHandlerTypeKind, + addMethodInfo, + "Add", + false, + indent, + builders); + } + + if (removeMethodInfo != null && removeMethodInfo.IsVirtual) + { + AppendBaseTypeNativePropertyOrEvent( + type, + typeTypeName.Name, + typeParams, + typeTypeName, + eventInfo.Name, + eventHandlerTypeKind, + removeMethodInfo, + "Remove", + false, + indent, + builders); + } + + builders.CsharpBaseTypes.AppendLine("\t\t\t}"); + builders.CsharpBaseTypes.AppendLine("\t\t\t"); + } + + static void AppendBaseTypeNativePropertyOrEvent( + Type type, + string typeName, + Type[] typeParams, + TypeName typeTypeName, + string propertyOrEventName, + TypeKind propertyOrEventTypeKind, + MethodInfo methodInfo, + string operationType, + bool typeIsDelegate, + int indent, + StringBuilders builders) + { + builders.TempStrBuilder.Length = 0; + builders.TempStrBuilder.Append(operationType); + builders.TempStrBuilder.Append(propertyOrEventName); + string funcName = builders.TempStrBuilder.ToString(); + + AppendCsharpGetDelegateCall( + GetTypeName(type), + typeParams, + funcName, + builders.CsharpGetDelegateCalls); + + // Build the name of the C++ binding function that C# calls + builders.TempStrBuilder.Length = 0; + AppendNativeInvokeFuncName( + type, + typeParams, + funcName, + builders.TempStrBuilder); + string nativeInvokeFuncName = builders.TempStrBuilder.ToString(); + + ParameterInfo[] invokeParams = AppendBaseTypeCppNativeInvokeCall( + type, + typeName, + typeTypeName, + typeParams, + methodInfo, + funcName, + funcName, + typeIsDelegate, + indent, + builders); + + // C# method that calls the C++ binding function + ParameterInfo[] invokeParamsWithThis = PrependThisParameter( + invokeParams); + builders.CsharpBaseTypes.Append("\t\t\t"); + builders.CsharpBaseTypes.Append(char.ToLower(operationType[0])); + builders.CsharpBaseTypes.Append( + operationType, + 1, + operationType.Length - 1); + builders.CsharpBaseTypes.AppendLine();; + builders.CsharpBaseTypes.AppendLine("\t\t\t{"); + AppendCsharpBaseTypeCppMethodCallMethodBody( + methodInfo, + nativeInvokeFuncName, + invokeParamsWithThis, + propertyOrEventTypeKind, + 4, + builders.CsharpBaseTypes); + builders.CsharpBaseTypes.AppendLine("\t\t\t}"); + } + + static void AppendCsharpParams( + ParameterInfo[] parameters, + StringBuilder output) + { + for (int i = 0; i < parameters.Length; ++i) + { + ParameterInfo param = parameters[i]; + AppendCsharpTypeFullName( + param.ParameterType, + output); + output.Append(' '); + output.Append(param.Name); + if (i != parameters.Length - 1) + { + output.Append(", "); + } + } + } + + static void AppendBaseTypeMethodCallsCsharpMethod( + Type type, + string typeName, + Type[] typeParams, + MethodInfo methodInfo, + string methodName, + string csharpMethodName, + int indent, + StringBuilders builders) + { + builders.TempStrBuilder.Length = 0; + builders.TempStrBuilder.Append(typeName); + builders.TempStrBuilder.Append(methodName); + string funcName = builders.TempStrBuilder.ToString(); + + // C++ method declaration for the method + ParameterInfo[] invokeParams = ConvertParameters( + methodInfo.GetParameters()); + AppendIndent( + indent + 1, + builders.CppTypeDefinitions); + AppendCppMethodDeclaration( + methodName, + false, + false, + false, + methodInfo.ReturnType, + null, + invokeParams, + builders.CppTypeDefinitions); + + // C++ function pointer for the C# binding function + AppendCppFunctionPointerDefinition( + funcName, + false, + default(TypeName), + TypeKind.None, + invokeParams, + methodInfo.ReturnType, + builders.CppFunctionPointers); + + // C++ and C# Init parameter and body for the C# binding function + AppendCppInitBodyFunctionPointerParameterRead( + funcName, + false, + default(TypeName), + TypeKind.None, + invokeParams, + methodInfo.ReturnType, + builders.CppInitBodyParameterReads); + AppendCsharpCsharpDelegate( + funcName, + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); + + // C++ method definition for the method + TypeKind returnTypeKind = GetTypeKind( + methodInfo.ReturnType); + AppendCppMethodDefinitionBegin( + GetTypeName(type), + methodInfo.ReturnType, + methodName, + typeParams, + null, + invokeParams, + indent, + builders.CppMethodDefinitions); + AppendIndent( + indent, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine("{"); + AppendCppPluginFunctionCall( + false, + GetTypeName(type), + TypeKind.Class, + typeParams, + methodInfo.ReturnType, + funcName, + invokeParams, + indent + 1, + builders.CppMethodDefinitions); + AppendCppMethodReturn( + methodInfo.ReturnType, + returnTypeKind, + indent + 1, + builders.CppMethodDefinitions); + AppendIndent( + indent, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine("}"); + AppendIndent( + indent, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine();; + + // C# delegate type for the binding function that C++ calls + ParameterInfo[] invokeParamsWithThis = new ParameterInfo[ + invokeParams.Length + 1]; + for (int i = 0; i < invokeParams.Length; ++i) + { + invokeParamsWithThis[i+1] = invokeParams[i]; + } + invokeParamsWithThis[0] = new ParameterInfo { + Name = "thisHandle", + ParameterType = typeof(int), + DereferencedParameterType = typeof(int), + IsOut = false, + IsRef = false, + Kind = TypeKind.Primitive + }; + AppendCsharpDelegateType( + funcName, + true, + type, + TypeKind.Class, + methodInfo.ReturnType, + invokeParamsWithThis, + builders.CsharpDelegateTypes); + + // C# binding function that C++ calls to invoke the method + AppendCsharpFunctionBeginning( + type, + funcName, + true, + TypeKind.Class, + methodInfo.ReturnType, + invokeParamsWithThis, + builders.CsharpFunctions); + builders.CsharpFunctions.Append("(("); + AppendCsharpTypeFullName( + type, + builders.CsharpFunctions); + builders.CsharpFunctions.Append( + ")NativeScript.Bindings.ObjectStore.Get(thisHandle))"); + if (csharpMethodName != null) + { + builders.CsharpFunctions.Append('.'); + builders.CsharpFunctions.Append(csharpMethodName); + } + builders.CsharpFunctions.Append('('); + AppendCsharpFunctionCallParameters( + invokeParams, + builders.CsharpFunctions); + builders.CsharpFunctions.Append(");"); + AppendCsharpFunctionReturn( + invokeParams, + methodInfo.ReturnType, + returnTypeKind, + null, + false, + builders.CsharpFunctions); + } + + static void AppendNativeInvokeFuncName( + Type type, + Type[] typeParams, + string funcName, + StringBuilder output) + { + AppendNamespace( + type.Namespace, + string.Empty, + output); + AppendTypeNameWithoutSuffixes( + type.Name, + output); + AppendTypeNames( + typeParams, + output); + output.Append(funcName); + } + + static void AppendBaseTypeCppMethodCall( + Type type, + string typeName, + TypeName typeTypeName, + Type[] typeParams, + MethodInfo invokeMethod, + string funcName, + string nativeInvokeFuncName, + string methodName, + bool isOverride, + bool typeIsDelegate, + int indent, + StringBuilders builders) + { + ParameterInfo[] invokeParams = AppendBaseTypeCppNativeInvokeCall( + type, + typeName, + typeTypeName, + typeParams, + invokeMethod, + funcName, + methodName, + typeIsDelegate, + indent, + builders); + + // C# method that calls the C++ binding function + ParameterInfo[] invokeParamsWithThis = PrependThisParameter( + invokeParams); + TypeKind invokeReturnTypeKind = GetTypeKind( + invokeMethod.ReturnType); + AppendCsharpBaseTypeCppMethodCallMethod( + isOverride, + invokeMethod, + funcName, + invokeParams, + nativeInvokeFuncName, + invokeParamsWithThis, + invokeReturnTypeKind, + builders.CsharpBaseTypes); + } + + static ParameterInfo[] AppendBaseTypeCppNativeInvokeCall( + Type type, + string typeName, + TypeName typeTypeName, + Type[] typeParams, + MethodInfo invokeMethod, + string funcName, + string methodName, + bool typeIsDelegate, + int indent, + StringBuilders builders) + { + // C++ method declaration + ParameterInfo[] invokeParams = ConvertParameters( + invokeMethod.GetParameters()); + AppendIndent( + indent + 1, + builders.CppTypeDefinitions); + AppendCppMethodDeclaration( + methodName, + false, + true, + false, + invokeMethod.ReturnType, + null, + invokeParams, + builders.CppTypeDefinitions); + + // C++ method definition. This is a no-op that game code overrides. + AppendCppMethodDefinitionBegin( + typeTypeName, + invokeMethod.ReturnType, + methodName, + typeIsDelegate ? typeParams : null, + null, + invokeParams, + indent, + builders.CppMethodDefinitions); + AppendIndent( + indent, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine("{"); + if (invokeMethod.ReturnType != typeof(void)) + { + TypeKind returnTypeKind = GetTypeKind(invokeMethod.ReturnType); + AppendIndent( + indent + 1, + builders.CppMethodDefinitions); + if (returnTypeKind == TypeKind.Class || + returnTypeKind == TypeKind.ManagedStruct) + { + builders.CppMethodDefinitions.AppendLine("return nullptr;"); + } + else + { + builders.CppMethodDefinitions.AppendLine("return {};"); + } + } + AppendIndent( + indent, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine("}"); + AppendIndent( + indent, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine();; + + // C++ binding function that C# calls. Calls the C++ method. + TypeKind invokeReturnTypeKind = GetTypeKind( + invokeMethod.ReturnType); + AppendCppBaseTypeMethodInvokeBindingFunction( + funcName, + type, + typeParams, + invokeMethod, + methodName, + invokeReturnTypeKind, + invokeParams, + indent, + typeName, + builders.CppMethodDefinitions); + + // C# delegate for the C++ binding function + AppendCsharpDelegate( + false, + GetTypeName(type), + typeParams, + funcName, + invokeParams, + invokeMethod.ReturnType, + invokeReturnTypeKind, + builders.CsharpCppDelegates); + + // C# import for the C++ binding function + AppendCsharpImport( + GetTypeName(type), + typeParams, + funcName, + invokeParams, + invokeMethod.ReturnType, + builders.CsharpImports); + + return invokeParams; + } + + static ParameterInfo[] PrependThisParameter( + ParameterInfo[] invokeParams) + { + ParameterInfo[] invokeParamsWithThis = new ParameterInfo[ + invokeParams.Length + 1]; + for (int i = 0; i < invokeParams.Length; ++i) + { + invokeParamsWithThis[i+1] = invokeParams[i]; + } + invokeParamsWithThis[0] = new ParameterInfo { + Name = "thisHandle", + ParameterType = typeof(int), + DereferencedParameterType = typeof(int), + IsOut = false, + IsRef = false, + Kind = TypeKind.Primitive + }; + return invokeParamsWithThis; + } + + static void AppendCsharpBaseTypeReleaseFunction( + Type type, + TypeName bindingTypeTypeName, + bool typeIsDelegate, + string releaseFuncName, + string derivedName, + ParameterInfo[] releaseParams, + StringBuilder output) + { + AppendCsharpFunctionBeginning( + type, + releaseFuncName, + true, + TypeKind.Class, + typeof(void), + releaseParams, + output); + if (typeIsDelegate || derivedName != null) + { + AppendCsharpTypeFullName( + bindingTypeTypeName, + output); + output.AppendLine(" thiz;"); + } + if (typeIsDelegate) + { + 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.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) + { + output.Append("\t\t\t\tthiz = ("); + AppendCsharpTypeFullName( + bindingTypeTypeName, + output); + 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.AppendLine(", cppHandle);"); + } + output.Append("\t\t\t\tObjectStore.Remove(handle);"); + AppendCsharpFunctionReturn( + releaseParams, + typeof(void), + TypeKind.Class, + null, + true, + output); + } + + static void AppendCsharpBaseTypeCppMethodCallMethod( + bool isOverride, + MethodInfo invokeMethod, + string funcName, + ParameterInfo[] invokeParams, + string nativeInvokeFuncName, + ParameterInfo[] invokeParamsWithThis, + TypeKind invokeReturnTypeKind, + StringBuilder output) + { + output.Append("\t\tpublic "); + if (isOverride) + { + output.Append("override "); + } + AppendCsharpTypeFullName( + invokeMethod.ReturnType, + output); + output.Append(' '); + output.Append(funcName); + output.Append("("); + AppendCsharpParams( + invokeParams, + output); + output.AppendLine(")"); + output.AppendLine("\t\t{"); + AppendCsharpBaseTypeCppMethodCallMethodBody( + invokeMethod, + nativeInvokeFuncName, + invokeParamsWithThis, + invokeReturnTypeKind, + 3, + output); + output.AppendLine("\t\t}"); + output.AppendLine("\t"); + } + + static void AppendCsharpBaseTypeCppMethodCallMethodBody( + MethodInfo invokeMethod, + string nativeInvokeFuncName, + ParameterInfo[] invokeParamsWithThis, + TypeKind invokeReturnTypeKind, + int indent, + StringBuilder output) + { + AppendIndent( + indent, + output); + output.AppendLine("if (CppHandle != 0)"); + AppendIndent( + indent, + output); + output.AppendLine("{"); + AppendIndent( + indent + 1, + output); + output.AppendLine("int thisHandle = CppHandle;"); + AppendCppFunctionCall( + nativeInvokeFuncName, + invokeParamsWithThis, + invokeMethod.ReturnType, + true, + indent + 1, + output); + if (invokeMethod.ReturnType != typeof(void)) + { + AppendIndent( + indent + 1, + output); + output.Append("return "); + switch (invokeReturnTypeKind) + { + case TypeKind.Class: + case TypeKind.ManagedStruct: + if (invokeMethod.ReturnType != typeof(object)) + { + output.Append('('); + AppendCsharpTypeFullName( + invokeMethod.ReturnType, + output); + output.Append(')'); + } + AppendHandleStoreTypeName( + invokeMethod.ReturnType, + output); + output.AppendLine(".Get(returnVal);"); + break; + default: + output.AppendLine("returnVal;"); + break; + } + } + AppendIndent( + indent, + output); + output.AppendLine("}"); + if (invokeMethod.ReturnType != typeof(void)) + { + AppendIndent( + indent, + output); + output.Append("return default("); + AppendCsharpTypeFullName( + invokeMethod.ReturnType, + output); + output.AppendLine(");"); + } + } + + static void AppendCsharpBaseTypeConstructorFunction( + Type type, + TypeName typeTypeName, + bool typeIsDelegate, + string constructorFuncName, + ParameterInfo[] constructorParams, + ParameterInfo[] cppConstructorParams, + StringBuilder output) + { + AppendCsharpFunctionBeginning( + type, + constructorFuncName, + true, + TypeKind.Class, + typeof(void), + constructorParams, + output); + output.Append("var thiz = new "); + AppendCsharpTypeFullName(typeTypeName, output); + output.Append("(cppHandle"); + if (cppConstructorParams.Length > 0) + { + output.Append(", "); + AppendCsharpFunctionCallParameters( + cppConstructorParams, + output); + } + output.AppendLine(");"); + if (typeIsDelegate) + { + output.AppendLine( + "\t\t\t\tclassHandle = NativeScript.Bindings.ObjectStore.Store(thiz);"); + output.Append( + "\t\t\t\thandle = NativeScript.Bindings.ObjectStore.Store(thiz.Delegate);"); + } + else + { + output.Append( + "\t\t\t\thandle = NativeScript.Bindings.ObjectStore.Store(thiz);"); + } + AppendCsharpFunctionReturn( + constructorParams, + typeof(void), + TypeKind.Class, + null, + true, + output); + } + + static void AppendCppBaseTypeMethodInvokeBindingFunction( + string funcName, + Type type, + Type[] typeParams, + MethodInfo method, + string methodName, + TypeKind methodReturnTypeKind, + ParameterInfo[] methodParams, + int indent, + string typeName, + StringBuilder output) + { + AppendIndent( + indent, + output); + output.Append("DLLEXPORT "); + if (method.ReturnType == typeof(void)) + { + output.Append("void"); + } + else if (method.ReturnType == typeof(bool)) + { + // C linkage requires us to use primitive types + output.Append("int32_t"); + } + else if (method.ReturnType == typeof(char)) + { + // C linkage requires us to use primitive types + output.Append("int16_t"); + } + else + { + switch (methodReturnTypeKind) + { + case TypeKind.Class: + case TypeKind.ManagedStruct: + output.Append("int32_t"); + break; + case TypeKind.Primitive: + AppendCppPrimitiveTypeName( + method.ReturnType, + output); + break; + default: + AppendCppTypeFullName( + method.ReturnType, + output); + break; + } + } + output.Append(' '); + AppendCsharpDelegateName( + GetTypeName(type), + typeParams, + funcName, + output); + output.Append("(int32_t cppHandle"); + if (methodParams.Length > 0) + { + output.Append(", "); + } + for (int i = 0; i < methodParams.Length; ++i) + { + ParameterInfo param = methodParams[i]; + switch (param.Kind) + { + case TypeKind.Class: + case TypeKind.ManagedStruct: + output.Append("int32_t "); + output.Append(param.Name); + output.Append("Handle"); + break; + case TypeKind.Primitive: + AppendCppPrimitiveTypeName( + param.ParameterType, + output); + output.Append(' '); + output.Append(param.Name); + break; + default: + AppendCppTypeFullName( + param.ParameterType, + output); + output.Append(' '); + output.Append(param.Name); + break; + } + if (i != methodParams.Length - 1) + { + output.Append(", "); + } + } + output.AppendLine(")"); + AppendIndent( + indent, + output); + output.AppendLine("{"); + AppendIndent( + indent + 1, + output); + output.AppendLine("try"); + AppendIndent( + indent + 1, + output); + output.AppendLine("{"); + foreach (ParameterInfo parameter in methodParams) + { + if (parameter.Kind == TypeKind.Class || + parameter.Kind == TypeKind.ManagedStruct) + { + AppendIndent( + indent + 2, + output); + output.Append("auto "); + output.Append(parameter.Name); + output.Append(" = "); + AppendCppTypeFullName( + parameter.ParameterType, + output); + output.Append("(Plugin::InternalUse::Only, "); + output.Append(parameter.Name); + output.AppendLine("Handle);"); + } + } + AppendIndent( + indent + 2, + output); + if (method.ReturnType != typeof(void)) + { + output.Append("return "); + } + output.Append("Plugin::Get"); + output.Append(typeName); + output.Append("(cppHandle)->"); + output.Append(methodName); + output.Append("("); + for (int i = 0; i < methodParams.Length; ++i) + { + ParameterInfo parameter = methodParams[i]; + if (parameter.Kind == TypeKind.Class || + parameter.Kind == TypeKind.ManagedStruct) + { + output.Append(parameter.Name); + } + else + { + output.Append(parameter.Name); + } + if (i != methodParams.Length - 1) + { + output.Append(", "); + } + } + output.Append(")"); + if ( + method.ReturnType != typeof(void) && + (methodReturnTypeKind == TypeKind.Class || + methodReturnTypeKind == TypeKind.ManagedStruct)) + { + output.Append(".Handle"); + } + output.AppendLine(";"); + AppendIndent( + indent + 1, + output); + output.AppendLine("}"); + AppendIndent( + indent + 1, + output); + output.AppendLine( + "catch (System::Exception ex)"); + AppendIndent( + indent + 1, + output); + output.AppendLine("{"); + AppendIndent( + indent + 2, + output); + output.AppendLine( + "Plugin::SetException(ex.Handle);"); + if (method.ReturnType != typeof(void)) + { + AppendIndent( + indent + 2, + output); + output.AppendLine( + "return {};"); + } + AppendIndent( + indent + 1, + output); + output.AppendLine("}"); + AppendIndent( + indent + 1, + output); + output.AppendLine("catch (...)"); + AppendIndent( + indent + 1, + output); + output.AppendLine("{"); + AppendIndent( + indent + 2, + output); + output.Append( + "System::String msg = \"Unhandled exception invoking "); + AppendCppTypeFullName( + type, + output); + output.AppendLine("\";"); + AppendIndent( + indent + 2, + output); + output.AppendLine( + "System::Exception ex(msg);"); + AppendIndent( + indent + 2, + output); + output.AppendLine( + "Plugin::SetException(ex.Handle);"); + if (method.ReturnType != typeof(void)) + { + AppendIndent( + indent + 2, + output); + output.AppendLine( + "return {};"); + } AppendIndent( - cppMethodDefinitionsIndent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("\n"); - - // Assignment operator to same type + indent + 1, + output); + output.AppendLine("}"); + AppendIndent( + indent, + output); + output.AppendLine("}"); + AppendIndent( + indent, + output); + output.AppendLine();; + } + + static void AppendCppBaseTypeInequalityOperator( + TypeName typeTypeName, + Type[] typeParams, + int cppMethodDefinitionsIndent, + bool typeIsDelegate, + StringBuilder output) + { AppendIndent( cppMethodDefinitionsIndent, - builders.CppMethodDefinitions); - AppendTypeNameWithoutGenericSuffix( - numberedTypeName, - builders.CppMethodDefinitions); - AppendCppTypeParameters( - typeParams, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("& "); - AppendTypeNameWithoutGenericSuffix( - numberedTypeName, - builders.CppMethodDefinitions); + output); + output.Append("bool "); + AppendCppTypeFullName( + typeTypeName, + output); AppendCppTypeParameters( - typeParams, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("::operator=(const "); - AppendTypeNameWithoutGenericSuffix( - numberedTypeName, - builders.CppMethodDefinitions); + typeIsDelegate ? typeParams : null, + output); + output.Append("::operator!=(const "); + AppendCppTypeFullName( + typeTypeName, + output); AppendCppTypeParameters( - typeParams, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("& other)\n"); + typeIsDelegate ? typeParams : null, + output); + output.AppendLine("& other) const"); AppendIndent( cppMethodDefinitionsIndent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); - AppendSetHandle( - numberedTypeName, - type.Namespace, - TypeKind.Class, - typeParams, - cppMethodDefinitionsIndent + 1, - "this", - "other.Handle", - builders.CppMethodDefinitions); + output); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "ClassHandle = other.ClassHandle;\n"); + output); + output.AppendLine( + "return Handle != other.Handle;"); + AppendIndent( + cppMethodDefinitionsIndent, + output); + output.AppendLine("}"); + AppendIndent( + cppMethodDefinitionsIndent, + output); + output.AppendLine();; + } + + static void AppendCppBaseTypeEqualityOperator( + TypeName typeTypeName, + Type[] typeParams, + int cppMethodDefinitionsIndent, + bool typeIsDelegate, + StringBuilder output) + { + AppendIndent( + cppMethodDefinitionsIndent, + output); + output.Append("bool "); + AppendCppTypeFullName( + typeTypeName, + output); + AppendCppTypeParameters( + typeIsDelegate ? typeParams : null, + output); + output.Append("::operator==(const "); + AppendCppTypeFullName( + typeTypeName, + output); + AppendCppTypeParameters( + typeIsDelegate ? typeParams : null, + output); + output.AppendLine("& other) const"); + AppendIndent( + cppMethodDefinitionsIndent, + output); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("return *this;\n"); + output); + output.AppendLine( + "return Handle == other.Handle;"); AppendIndent( cppMethodDefinitionsIndent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + output); + output.AppendLine("}"); AppendIndent( cppMethodDefinitionsIndent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("\n"); - - // Assignment operator to nullptr_t + output); + output.AppendLine();; + } + + static void AppendCppBaseTypeMoveAssignmentOperator( + string bindingTypeName, + TypeName typeTypeName, + Type[] typeParams, + bool typeIsDelegate, + string releaseFuncName, + int cppMethodDefinitionsIndent, + StringBuilder output) + { AppendIndent( cppMethodDefinitionsIndent, - builders.CppMethodDefinitions); - AppendTypeNameWithoutGenericSuffix( - numberedTypeName, - builders.CppMethodDefinitions); + output); + AppendCppTypeFullName( + typeTypeName, + output); AppendCppTypeParameters( - typeParams, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("& "); - AppendTypeNameWithoutGenericSuffix( - numberedTypeName, - builders.CppMethodDefinitions); + typeIsDelegate ? typeParams : null, + output); + output.Append("& "); + AppendCppTypeFullName( + typeTypeName, + output); AppendCppTypeParameters( - typeParams, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "::operator=(std::nullptr_t other)\n"); + typeIsDelegate ? typeParams : null, + output); + output.Append("::operator=("); + AppendCppTypeFullName( + typeTypeName, + output); + AppendCppTypeParameters( + typeIsDelegate ? typeParams : null, + output); + output.AppendLine("&& other)"); AppendIndent( cppMethodDefinitionsIndent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + output); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("if (Handle)\n"); + output); + output.Append("Plugin::Remove"); + output.Append(bindingTypeName); + output.AppendLine("(CppHandle);"); AppendIndent( cppMethodDefinitionsIndent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + output); + output.AppendLine("CppHandle = 0;"); + AppendIndent( + cppMethodDefinitionsIndent + 1, + output); + output.AppendLine("if (Handle)"); + AppendIndent( + cppMethodDefinitionsIndent + 1, + output); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 2, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("int32_t handle = Handle;\n"); + output); + output.AppendLine("int32_t handle = Handle;"); + if (typeIsDelegate) + { + AppendIndent( + cppMethodDefinitionsIndent + 2, + output); + output.AppendLine("int32_t classHandle = ClassHandle;"); + } AppendIndent( cppMethodDefinitionsIndent + 2, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("int32_t classHandle = ClassHandle;\n"); + output); + output.AppendLine("Handle = 0;"); + if (typeIsDelegate) + { + AppendIndent( + cppMethodDefinitionsIndent + 2, + output); + output.AppendLine("ClassHandle = 0;"); + } AppendIndent( cppMethodDefinitionsIndent + 2, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("Handle = 0;\n"); + output); + output.AppendLine( + "if (Plugin::DereferenceManagedClassNoRelease(handle))"); AppendIndent( cppMethodDefinitionsIndent + 2, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("ClassHandle = 0;\n"); + output); + output.AppendLine("{"); + AppendIndent( + cppMethodDefinitionsIndent + 3, + output); + output.Append("Plugin::"); + output.Append(releaseFuncName); + output.Append("(handle"); + if (typeIsDelegate) + { + output.Append(", classHandle"); + } + output.AppendLine(");"); + AppendCppUnhandledExceptionHandling( + cppMethodDefinitionsIndent + 3, + output); AppendIndent( cppMethodDefinitionsIndent + 2, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "if (Plugin::DereferenceManagedClassNoRelease(handle))\n"); + output); + output.AppendLine("}"); + AppendIndent( + cppMethodDefinitionsIndent + 1, + output); + output.AppendLine("}"); + if (typeIsDelegate) + { + AppendIndent( + cppMethodDefinitionsIndent + 1, + output); + output.AppendLine( + "ClassHandle = other.ClassHandle;"); + AppendIndent( + cppMethodDefinitionsIndent + 1, + output); + output.AppendLine("other.ClassHandle = 0;"); + } + AppendIndent( + cppMethodDefinitionsIndent + 1, + output); + output.AppendLine("Handle = other.Handle;"); + AppendIndent( + cppMethodDefinitionsIndent + 1, + output); + output.AppendLine("other.Handle = 0;"); + AppendIndent( + cppMethodDefinitionsIndent + 1, + output); + output.AppendLine("return *this;"); + AppendIndent( + cppMethodDefinitionsIndent, + output); + output.AppendLine("}"); + AppendIndent( + cppMethodDefinitionsIndent, + output); + output.AppendLine();; + } + + static void AppendCppBaseTypeAssignmentOperatorNullptr( + TypeName typeTypeName, + Type[] typeParams, + bool typeIsDelegate, + string releaseFuncName, + int cppMethodDefinitionsIndent, + StringBuilder output) + { + AppendIndent( + cppMethodDefinitionsIndent, + output); + AppendCppTypeFullName( + typeTypeName, + output); + AppendCppTypeParameters( + typeIsDelegate ? typeParams : null, + output); + output.Append("& "); + AppendCppTypeFullName( + typeTypeName, + output); + AppendCppTypeParameters( + typeIsDelegate ? typeParams : null, + output); + output.AppendLine( + "::operator=(decltype(nullptr))"); + AppendIndent( + cppMethodDefinitionsIndent, + output); + output.AppendLine("{"); + AppendIndent( + cppMethodDefinitionsIndent + 1, + output); + output.AppendLine("if (Handle)"); + AppendIndent( + cppMethodDefinitionsIndent + 1, + output); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 2, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + output); + output.AppendLine("int32_t handle = Handle;"); + if (typeIsDelegate) + { + AppendIndent( + cppMethodDefinitionsIndent + 2, + output); + output.AppendLine("int32_t classHandle = ClassHandle;"); + } + AppendIndent( + cppMethodDefinitionsIndent + 2, + output); + output.AppendLine("Handle = 0;"); + if (typeIsDelegate) + { + AppendIndent( + cppMethodDefinitionsIndent + 2, + output); + output.AppendLine("ClassHandle = 0;"); + } + AppendIndent( + cppMethodDefinitionsIndent + 2, + output); + output.AppendLine( + "if (Plugin::DereferenceManagedClassNoRelease(handle))"); + AppendIndent( + cppMethodDefinitionsIndent + 2, + output); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 3, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("Plugin::"); - builders.CppMethodDefinitions.Append(releaseFuncName); - builders.CppMethodDefinitions.Append("(handle, classHandle);\n"); + output); + output.Append("Plugin::"); + output.Append(releaseFuncName); + output.Append("(handle"); + if (typeIsDelegate) + { + output.Append(", classHandle"); + } + output.AppendLine(");"); AppendCppUnhandledExceptionHandling( cppMethodDefinitionsIndent + 3, - builders.CppMethodDefinitions); + output); AppendIndent( cppMethodDefinitionsIndent + 2, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + output); + output.AppendLine("}"); AppendIndent( cppMethodDefinitionsIndent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + output); + output.AppendLine("}"); + if (typeIsDelegate) + { + AppendIndent( + cppMethodDefinitionsIndent + 1, + output); + output.AppendLine("ClassHandle = 0;"); + } AppendIndent( cppMethodDefinitionsIndent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("ClassHandle = 0;\n"); + output); + output.AppendLine("Handle = 0;"); + AppendIndent( + cppMethodDefinitionsIndent + 1, + output); + output.AppendLine("return *this;"); + AppendIndent( + cppMethodDefinitionsIndent, + output); + output.AppendLine("}"); + AppendIndent( + cppMethodDefinitionsIndent, + output); + output.AppendLine();; + } + + static void AppendCppBaseTypeAssignmentOperatorSameType( + TypeName typeTypeName, + Type[] typeParams, + bool typeIsDelegate, + int cppMethodDefinitionsIndent, + StringBuilder output) + { + AppendIndent( + cppMethodDefinitionsIndent, + output); + AppendCppTypeFullName( + typeTypeName, + output); + AppendCppTypeParameters( + typeIsDelegate ? typeParams : null, + output); + output.Append("& "); + AppendCppTypeFullName( + typeTypeName, + output); + AppendCppTypeParameters( + typeIsDelegate ? typeParams : null, + output); + output.Append("::operator=(const "); + AppendCppTypeFullName( + typeTypeName, + output); + AppendCppTypeParameters( + typeIsDelegate ? typeParams : null, + output); + output.AppendLine("& other)"); AppendIndent( + cppMethodDefinitionsIndent, + output); + output.AppendLine("{"); + AppendSetHandle( + typeTypeName, + TypeKind.Class, + typeParams, cppMethodDefinitionsIndent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("Handle = 0;\n"); + "this", + "other.Handle", + output); + if (typeIsDelegate) + { + AppendIndent( + cppMethodDefinitionsIndent + 1, + output); + output.AppendLine( + "ClassHandle = other.ClassHandle;"); + } AppendIndent( cppMethodDefinitionsIndent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("return *this;\n"); + output); + output.AppendLine("return *this;"); AppendIndent( cppMethodDefinitionsIndent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + output); + output.AppendLine("}"); AppendIndent( cppMethodDefinitionsIndent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("\n"); - - // Move assignment operator to same type + output); + output.AppendLine();; + } + + static void AppendCppBaseTypeDestructor( + string typeName, + TypeName typeTypeName, + Type[] typeParams, + bool typeIsDelegate, + string derivedTypeName, + string releaseFuncName, + string bindingTypeName, + int cppMethodDefinitionsIndent, + StringBuilder output) + { AppendIndent( cppMethodDefinitionsIndent, - builders.CppMethodDefinitions); - AppendTypeNameWithoutGenericSuffix( - numberedTypeName, - builders.CppMethodDefinitions); - AppendCppTypeParameters( - typeParams, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("& "); - AppendTypeNameWithoutGenericSuffix( - numberedTypeName, - builders.CppMethodDefinitions); + output); + AppendCppTypeFullName( + typeTypeName, + output); AppendCppTypeParameters( - typeParams, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("::operator=("); - AppendTypeNameWithoutGenericSuffix( - numberedTypeName, - builders.CppMethodDefinitions); + typeIsDelegate ? typeParams : null, + output); + output.Append("::~"); + AppendCppTypeName( + typeTypeName, + output); AppendCppTypeParameters( - typeParams, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("&& other)\n"); + typeIsDelegate ? typeParams : null, + output); + output.AppendLine("()"); AppendIndent( cppMethodDefinitionsIndent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + output); + output.AppendLine("{"); + if (!string.IsNullOrEmpty(derivedTypeName)) + { + AppendIndent( + cppMethodDefinitionsIndent + 1, + output); + output.Append("Plugin::RemoveWhole"); + output.Append(bindingTypeName); + output.AppendLine("(this);"); + } AppendIndent( cppMethodDefinitionsIndent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("Plugin::Remove"); - builders.CppMethodDefinitions.Append(typeName); - builders.CppMethodDefinitions.Append("(CppHandle);\n"); + output); + output.Append("Plugin::Remove"); + output.Append(typeName); + output.AppendLine("(CppHandle);"); AppendIndent( cppMethodDefinitionsIndent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("CppHandle = 0;\n"); + output); + output.AppendLine("CppHandle = 0;"); AppendIndent( cppMethodDefinitionsIndent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("if (Handle)\n"); + output); + output.AppendLine("if (Handle)"); AppendIndent( cppMethodDefinitionsIndent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); - AppendIndent( - cppMethodDefinitionsIndent + 2, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("int32_t handle = Handle;\n"); - AppendIndent( - cppMethodDefinitionsIndent + 2, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("int32_t classHandle = ClassHandle;\n"); + output); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 2, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("Handle = 0;\n"); + output); + output.AppendLine("int32_t handle = Handle;"); + if (typeIsDelegate) + { + AppendIndent( + cppMethodDefinitionsIndent + 2, + output); + output.AppendLine("int32_t classHandle = ClassHandle;"); + } AppendIndent( cppMethodDefinitionsIndent + 2, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("ClassHandle = 0;\n"); + output); + output.AppendLine("Handle = 0;"); + if (typeIsDelegate) + { + AppendIndent( + cppMethodDefinitionsIndent + 2, + output); + output.AppendLine("ClassHandle = 0;"); + } AppendIndent( cppMethodDefinitionsIndent + 2, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "if (Plugin::DereferenceManagedClassNoRelease(handle))\n"); + output); + output.AppendLine( + "if (Plugin::DereferenceManagedClassNoRelease(handle))"); AppendIndent( cppMethodDefinitionsIndent + 2, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + output); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 3, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("Plugin::"); - builders.CppMethodDefinitions.Append(releaseFuncName); - builders.CppMethodDefinitions.Append("(handle, classHandle);\n"); + output); + output.Append("Plugin::"); + output.Append(releaseFuncName); + output.Append("(handle"); + if (typeIsDelegate) + { + output.Append(", classHandle"); + } + output.AppendLine(");"); AppendCppUnhandledExceptionHandling( cppMethodDefinitionsIndent + 3, - builders.CppMethodDefinitions); + output); AppendIndent( cppMethodDefinitionsIndent + 2, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + output); + output.AppendLine("}"); AppendIndent( cppMethodDefinitionsIndent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + output); + output.AppendLine("}"); AppendIndent( - cppMethodDefinitionsIndent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "ClassHandle = other.ClassHandle;\n"); + cppMethodDefinitionsIndent, + output); + output.AppendLine("}"); AppendIndent( - cppMethodDefinitionsIndent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("other.ClassHandle = 0;\n"); + cppMethodDefinitionsIndent, + output); + output.AppendLine();; + } + + static void AppendCppBaseTypeHandleConstructor( + string bindingTypeName, + TypeName typeTypeName, + Type[] typeParams, + Type[] interfaceTypes, + bool typeIsDelegate, + int cppMethodDefinitionsIndent, + StringBuilder output) + { AppendIndent( + cppMethodDefinitionsIndent, + output); + AppendCppTypeFullName( + typeTypeName, + output); + AppendCppTypeParameters( + typeIsDelegate ? typeParams : null, + output); + output.Append("::"); + AppendCppTypeName( + typeTypeName, + output); + output.AppendLine( + "(Plugin::InternalUse, int32_t handle)"); + AppendCppConstructorInitializerList( + interfaceTypes, cppMethodDefinitionsIndent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("Handle = other.Handle;\n"); + output); AppendIndent( - cppMethodDefinitionsIndent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("other.Handle = 0;\n"); + cppMethodDefinitionsIndent, + output); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("return *this;\n"); + output); + output.AppendLine("Handle = handle;"); AppendIndent( - cppMethodDefinitionsIndent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + cppMethodDefinitionsIndent + 1, + output); + output.Append("CppHandle = Plugin::Store"); + output.Append(bindingTypeName); + output.AppendLine("(this);"); AppendIndent( - cppMethodDefinitionsIndent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("\n"); - - // Equality operator with same type + cppMethodDefinitionsIndent + 1, + output); + output.AppendLine("if (Handle)"); AppendIndent( - cppMethodDefinitionsIndent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("bool "); - AppendTypeNameWithoutGenericSuffix( - numberedTypeName, - builders.CppMethodDefinitions); - AppendCppTypeParameters( - typeParams, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("::operator==(const "); - AppendTypeNameWithoutGenericSuffix( - numberedTypeName, - builders.CppMethodDefinitions); - AppendCppTypeParameters( - typeParams, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("& other) const\n"); + cppMethodDefinitionsIndent + 1, + output); + output.AppendLine("{"); AppendIndent( - cppMethodDefinitionsIndent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + cppMethodDefinitionsIndent + 2, + output); + output.AppendLine( + "Plugin::ReferenceManagedClass(Handle);"); AppendIndent( cppMethodDefinitionsIndent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "return Handle == other.Handle;\n"); + output); + output.AppendLine("}"); + if (typeIsDelegate) + { + AppendIndent( + cppMethodDefinitionsIndent + 1, + output); + output.AppendLine( + "ClassHandle = 0;"); + } AppendIndent( cppMethodDefinitionsIndent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + output); + output.AppendLine("}"); AppendIndent( cppMethodDefinitionsIndent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); - - // Inequality operator with same type + output); + output.AppendLine();; + } + + static void AppendCppBaseTypeMoveConstructor( + TypeName typeTypeName, + Type[] typeParams, + Type[] interfaceTypes, + bool typeIsDelegate, + int cppMethodDefinitionsIndent, + StringBuilder output) + { AppendIndent( cppMethodDefinitionsIndent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("bool "); - AppendTypeNameWithoutGenericSuffix( - numberedTypeName, - builders.CppMethodDefinitions); + output); + AppendCppTypeFullName( + typeTypeName, + output); AppendCppTypeParameters( - typeParams, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("::operator!=(const "); - AppendTypeNameWithoutGenericSuffix( - numberedTypeName, - builders.CppMethodDefinitions); + typeIsDelegate ? typeParams : null, + output); + output.Append("::"); + AppendCppTypeName( + typeTypeName, + output); + output.Append("("); + AppendCppTypeFullName( + typeTypeName, + output); AppendCppTypeParameters( - typeParams, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("& other) const\n"); - AppendIndent( - cppMethodDefinitionsIndent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); - AppendIndent( + typeIsDelegate ? typeParams : null, + output); + output.AppendLine("&& other)"); + AppendCppConstructorInitializerList( + interfaceTypes, cppMethodDefinitionsIndent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "return Handle != other.Handle;\n"); + output); AppendIndent( cppMethodDefinitionsIndent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + output); + output.AppendLine("{"); AppendIndent( - cppMethodDefinitionsIndent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); - - // C++ operator() - AppendCppMethodDefinitionBegin( - numberedTypeName, - invokeMethod.ReturnType, - "operator()", - typeParams, - null, - invokeParams, - indent, - builders.CppMethodDefinitions); + cppMethodDefinitionsIndent + 1, + output); + output.AppendLine( + "Handle = other.Handle;"); AppendIndent( - indent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); - if (invokeMethod.ReturnType != typeof(void)) + cppMethodDefinitionsIndent + 1, + output); + output.AppendLine( + "CppHandle = other.CppHandle;"); + if (typeIsDelegate) { AppendIndent( - indent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("return {};\n"); + cppMethodDefinitionsIndent + 1, + output); + output.AppendLine( + "ClassHandle = other.ClassHandle;"); } AppendIndent( - indent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); - AppendIndent( - indent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); - - // C++ Invoke - AppendCppMethodDefinitionBegin( - numberedTypeName, - invokeMethod.ReturnType, - "Invoke", - typeParams, - null, - invokeParams, - indent, - builders.CppMethodDefinitions); - AppendIndent( - indent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); - AppendCppPluginFunctionCall( - false, - type.Name, - type.Namespace, - TypeKind.Class, - typeParams, - invokeMethod.ReturnType, - invokeFuncName, - invokeParams, - indent + 1, - builders.CppMethodDefinitions); - AppendCppMethodReturn( - invokeMethod.ReturnType, - invokeReturnTypeKind, - indent + 1, - builders.CppMethodDefinitions); + cppMethodDefinitionsIndent + 1, + output); + output.AppendLine("other.Handle = 0;"); AppendIndent( - indent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + cppMethodDefinitionsIndent + 1, + output); + output.AppendLine("other.CppHandle = 0;"); + if (typeIsDelegate) + { + AppendIndent( + cppMethodDefinitionsIndent + 1, + output); + output.AppendLine("other.ClassHandle = 0;"); + } AppendIndent( - indent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); - - // C++ add - AppendCppMethodDefinitionBegin( - numberedTypeName, - typeof(void), - "operator+=", - typeParams, - null, - addRemoveParams, - indent, - builders.CppMethodDefinitions); + cppMethodDefinitionsIndent, + output); + output.AppendLine("}"); AppendIndent( - indent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + cppMethodDefinitionsIndent, + output); + output.AppendLine();; + } + + static void AppendCppBaseTypeCopyConstructor( + string typeName, + TypeName typeTypeName, + Type[] typeParams, + Type[] interfaceTypes, + bool typeIsDelegate, + int cppMethodDefinitionsIndent, + StringBuilder output) + { AppendIndent( - indent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("Plugin::"); - builders.CppMethodDefinitions.Append(addFuncName); - builders.CppMethodDefinitions.Append("(Handle, del.Handle);\n"); - AppendCppUnhandledExceptionHandling( - indent + 1, - builders.CppMethodDefinitions); + cppMethodDefinitionsIndent, + output); + AppendCppTypeFullName( + typeTypeName, + output); + AppendCppTypeParameters( + typeIsDelegate ? typeParams : null, + output); + output.Append("::"); + AppendCppTypeName( + typeTypeName, + output); + output.Append("(const "); + AppendCppTypeFullName( + typeTypeName, + output); + AppendCppTypeParameters( + typeIsDelegate ? typeParams : null, + output); + output.AppendLine("& other)"); + AppendCppConstructorInitializerList( + interfaceTypes, + cppMethodDefinitionsIndent + 1, + output); AppendIndent( - indent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + cppMethodDefinitionsIndent, + output); + output.AppendLine("{"); AppendIndent( - indent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("\n"); - - // C++ remove - AppendCppMethodDefinitionBegin( - numberedTypeName, - typeof(void), - "operator-=", - typeParams, - null, - addRemoveParams, - indent, - builders.CppMethodDefinitions); + cppMethodDefinitionsIndent + 1, + output); + output.AppendLine( + "Handle = other.Handle;"); AppendIndent( - indent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + cppMethodDefinitionsIndent + 1, + output); + output.Append("CppHandle = Plugin::Store"); + output.Append(typeName); + output.AppendLine("(this);"); AppendIndent( - indent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("Plugin::"); - builders.CppMethodDefinitions.Append(removeFuncName); - builders.CppMethodDefinitions.Append("(Handle, del.Handle);\n"); - AppendCppUnhandledExceptionHandling( - indent + 1, - builders.CppMethodDefinitions); + cppMethodDefinitionsIndent + 1, + output); + output.AppendLine("if (Handle)"); AppendIndent( - indent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + cppMethodDefinitionsIndent + 1, + output); + output.AppendLine("{"); AppendIndent( - indent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("\n"); - - // C++ CppInvoke function + cppMethodDefinitionsIndent + 2, + output); + output.AppendLine( + "Plugin::ReferenceManagedClass(Handle);"); AppendIndent( - indent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("DLLEXPORT "); - if (invokeMethod.ReturnType == typeof(void)) - { - builders.CppMethodDefinitions.Append("void"); - } - else - { - switch (invokeReturnTypeKind) - { - case TypeKind.Class: - case TypeKind.ManagedStruct: - builders.CppMethodDefinitions.Append("int32_t"); - break; - default: - AppendCppTypeName( - invokeMethod.ReturnType, - builders.CppMethodDefinitions); - break; - } - } - builders.CppMethodDefinitions.Append(' '); - AppendCsharpDelegateName( - type.Name, - type.Namespace, - typeParams, - "CppInvoke", - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("(int32_t cppHandle"); - if (invokeParams.Length > 0) - { - builders.CppMethodDefinitions.Append(", "); - } - for (int i = 0; i < invokeParams.Length; ++i) + cppMethodDefinitionsIndent + 1, + output); + output.AppendLine("}"); + if (typeIsDelegate) { - ParameterInfo param = invokeParams[i]; - switch (param.Kind) - { - case TypeKind.Class: - case TypeKind.ManagedStruct: - builders.CppMethodDefinitions.Append("int32_t "); - builders.CppMethodDefinitions.Append(param.Name); - builders.CppMethodDefinitions.Append("Handle"); - break; - default: - AppendCppTypeName( - param.ParameterType, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append(' '); - builders.CppMethodDefinitions.Append(param.Name); - break; - } - if (i != invokeParams.Length - 1) - { - builders.CppMethodDefinitions.Append(", "); - } + AppendIndent( + cppMethodDefinitionsIndent + 1, + output); + output.AppendLine( + "ClassHandle = other.ClassHandle;"); } - builders.CppMethodDefinitions.Append(")\n"); AppendIndent( - indent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + cppMethodDefinitionsIndent, + output); + output.AppendLine("}"); AppendIndent( - indent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("try\n"); + cppMethodDefinitionsIndent, + output); + output.AppendLine();; + } + + static void AppendCppBaseTypeNullptrConstructor( + string typeName, + TypeName cppTypeTypeName, + Type[] typeParams, + Type[] interfaceTypes, + bool typeIsDelegate, + int cppMethodDefinitionsIndent, + StringBuilder output) + { AppendIndent( - indent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + cppMethodDefinitionsIndent, + output); + AppendCppTypeName( + cppTypeTypeName, + output); + AppendCppTypeParameters( + typeIsDelegate ? typeParams : null, + output); + output.Append("::"); + AppendCppTypeName( + cppTypeTypeName, + output); + output.AppendLine("(decltype(nullptr))"); + AppendCppConstructorInitializerList( + interfaceTypes, + cppMethodDefinitionsIndent + 1, + output); AppendIndent( - indent + 2, - builders.CppMethodDefinitions); - if (invokeMethod.ReturnType != typeof(void)) - { - builders.CppMethodDefinitions.Append("return "); - } - builders.CppMethodDefinitions.Append("(*Plugin::Get"); - builders.CppMethodDefinitions.Append(typeName); - builders.CppMethodDefinitions.Append("(cppHandle))("); - for (int i = 0; i < invokeParams.Length; ++i) - { - ParameterInfo parameter = invokeParams[i]; - if (parameter.Kind == TypeKind.Class - || parameter.Kind == TypeKind.ManagedStruct) - { - AppendCppTypeName( - parameter.ParameterType, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("(Plugin::InternalUse::Only, "); - builders.CppMethodDefinitions.Append(parameter.Name); - builders.CppMethodDefinitions.Append("Handle)"); - } - else - { - builders.CppMethodDefinitions.Append(parameter.Name); - } - if (i != invokeParams.Length - 1) - { - builders.CppMethodDefinitions.Append(", "); - } - } - builders.CppMethodDefinitions.Append(")"); - if ( - invokeMethod.ReturnType != typeof(void) && - (invokeReturnTypeKind == TypeKind.Class || - invokeReturnTypeKind == TypeKind.ManagedStruct)) + cppMethodDefinitionsIndent, + output); + output.AppendLine("{"); + AppendIndent( + cppMethodDefinitionsIndent + 1, + output); + output.Append("CppHandle = Plugin::Store"); + output.Append(typeName); + output.AppendLine("(this);"); + if (typeIsDelegate) { - builders.CppMethodDefinitions.Append(".Handle"); + AppendIndent( + cppMethodDefinitionsIndent + 1, + output); + output.AppendLine("ClassHandle = 0;"); } - builders.CppMethodDefinitions.Append(";\n"); AppendIndent( - indent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + cppMethodDefinitionsIndent, + output); + output.AppendLine("}"); AppendIndent( - indent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "catch (System::Exception ex)\n"); + cppMethodDefinitionsIndent, + output); + output.AppendLine();; + } + + static void AppendCppBaseTypeConstructor( + string bindingTypeName, + TypeName typeTypeName, + TypeKind typeKind, + string cppTypeName, + Type[] typeParams, + Type[] interfaceTypes, + ParameterInfo[] cppParameters, + ParameterInfo[] parameters, + bool typeIsDelegate, + string constructorFuncName, + int cppMethodDefinitionsIndent, + StringBuilder output) + { + AppendCppMethodDefinitionBegin( + typeTypeName, + null, + cppTypeName, + typeIsDelegate ? typeParams : null, + null, + cppParameters, + cppMethodDefinitionsIndent, + output); + AppendCppConstructorInitializerList( + interfaceTypes, + cppMethodDefinitionsIndent + 1, + output); AppendIndent( - indent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + cppMethodDefinitionsIndent, + output); + output.AppendLine("{"); AppendIndent( - indent + 2, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "Plugin::SetException(ex.Handle);\n"); - if (invokeMethod.ReturnType != typeof(void)) + cppMethodDefinitionsIndent + 1, + output); + output.Append("CppHandle = Plugin::Store"); + output.Append(bindingTypeName); + output.AppendLine("(this);"); + AppendIndent( + cppMethodDefinitionsIndent + 1, + output); + output.AppendLine("System::Int32* handle = (System::Int32*)&Handle;"); + AppendIndent( + cppMethodDefinitionsIndent + 1, + output); + output.AppendLine("int32_t cppHandle = CppHandle;"); + if (typeIsDelegate) { AppendIndent( - indent + 2, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "return {};\n"); + cppMethodDefinitionsIndent + 1, + output); + output.AppendLine("System::Int32* classHandle = (System::Int32*)&ClassHandle;"); } + AppendCppPluginFunctionCall( + true, + GetTypeName(bindingTypeName, typeTypeName.Namespace), + typeKind, + typeParams, + null, + constructorFuncName, + parameters, + cppMethodDefinitionsIndent + 1, + output); AppendIndent( - indent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + cppMethodDefinitionsIndent + 1, + output); + output.AppendLine("if (Handle)"); + AppendIndent( + cppMethodDefinitionsIndent + 1, + output); + output.AppendLine("{"); AppendIndent( - indent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("catch (...)\n"); + cppMethodDefinitionsIndent + 2, + output); + output.AppendLine( + "Plugin::ReferenceManagedClass(Handle);"); AppendIndent( - indent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + cppMethodDefinitionsIndent + 1, + output); + output.AppendLine("}"); AppendIndent( - indent + 2, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "System::String msg = \"Unhandled exception invoking "); - AppendCppTypeName( - type, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("\";\n"); + cppMethodDefinitionsIndent + 1, + output); + output.AppendLine("else"); AppendIndent( - indent + 2, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "System::Exception ex(msg);\n"); + cppMethodDefinitionsIndent + 1, + output); + output.AppendLine("{"); AppendIndent( - indent + 2, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "Plugin::SetException(ex.Handle);\n"); - if (invokeMethod.ReturnType != typeof(void)) + cppMethodDefinitionsIndent + 2, + output); + output.Append("Plugin::Remove"); + output.Append(bindingTypeName); + output.AppendLine("(CppHandle);"); + if (typeIsDelegate) { AppendIndent( - indent + 2, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "return {};\n"); + cppMethodDefinitionsIndent + 2, + output); + output.AppendLine("ClassHandle = 0;"); } AppendIndent( - indent + 1, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + cppMethodDefinitionsIndent + 2, + output); + output.AppendLine("CppHandle = 0;"); AppendIndent( - indent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + cppMethodDefinitionsIndent + 1, + output); + output.AppendLine("}"); + AppendCppUnhandledExceptionHandling( + cppMethodDefinitionsIndent + 1, + output); AppendIndent( - indent, - builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("\n"); - - // C++ method definitions (end) - AppendCppMethodDefinitionsEnd( - indent, - builders.CppMethodDefinitions); - - // C++ type definition (end) - AppendCppTypeDefinitionEnd( - false, - indent, - builders.CppTypeDefinitions); + cppMethodDefinitionsIndent, + output); + output.AppendLine("}"); + AppendIndent( + cppMethodDefinitionsIndent, + output); + output.AppendLine();; + } + + static void AppendCppPointerFreeListInit( + Type[] typeParams, + TypeName cppTypeTypeName, + int maxSimultaneous, + string typeName, + StringBuilder output, + StringBuilder outputFirstBoot) + { + output.Append("\tPlugin::"); + output.Append(typeName); + output.Append("FreeListSize = "); + output.Append(maxSimultaneous); + output.AppendLine(";"); - // C# delegate - AppendCsharpDelegate( - false, - type.Name, - type.Namespace, + output.Append("\tPlugin::"); + output.Append(typeName); + output.Append("FreeList = ("); + AppendCppTypeFullName( + cppTypeTypeName, + output); + AppendCppTypeParameters( typeParams, - "CppInvoke", - invokeParams, - invokeMethod.ReturnType, - invokeReturnTypeKind, - builders.CsharpDelegates); + output); + output.AppendLine("**)curMemory;"); - // C# GetDelegate call - AppendCsharpGetDelegateCall( - type.Name, - type.Namespace, + output.Append("\tcurMemory += "); + output.Append(maxSimultaneous); + output.Append(" * sizeof("); + AppendCppTypeFullName( + cppTypeTypeName, + output); + AppendCppTypeParameters( typeParams, - "CppInvoke", - builders.CsharpGetDelegateCalls); - - // C# import - AppendCsharpImport( - type.Name, - type.Namespace, + output); + output.AppendLine("*);"); + + output.AppendLine("\t"); + + outputFirstBoot.Append("\t\tfor (int32_t i = 0, end = Plugin::"); + outputFirstBoot.Append(typeName); + outputFirstBoot.AppendLine("FreeListSize - 1; i < end; ++i)"); + outputFirstBoot.AppendLine("\t\t{"); + outputFirstBoot.Append("\t\t\tPlugin::"); + outputFirstBoot.Append(typeName); + outputFirstBoot.Append("FreeList[i] = ("); + AppendCppTypeFullName( + cppTypeTypeName, + outputFirstBoot); + AppendCppTypeParameters( typeParams, - "CppInvoke", - invokeParams, - builders.CsharpImports); - - // C# class - builders.CsharpFunctions.Append("\t\tclass "); - builders.CsharpFunctions.Append(typeName); - builders.CsharpFunctions.Append("\n"); - builders.CsharpFunctions.Append("\t\t{\n"); - builders.CsharpFunctions.Append("\t\t\tpublic int CppHandle;\n"); - builders.CsharpFunctions.Append("\t\t\tpublic "); - AppendCsharpTypeName( - type, - builders.CsharpFunctions); - builders.CsharpFunctions.Append(" Delegate;\n"); - builders.CsharpFunctions.Append("\t\t\t\n"); - builders.CsharpFunctions.Append("\t\t\tpublic "); - builders.CsharpFunctions.Append(typeName); - builders.CsharpFunctions.Append("(int cppHandle)\n"); - builders.CsharpFunctions.Append("\t\t\t{\n"); - builders.CsharpFunctions.Append("\t\t\t\tCppHandle = cppHandle;\n"); - builders.CsharpFunctions.Append("\t\t\t\tDelegate = Invoke;\n"); - builders.CsharpFunctions.Append("\t\t\t}\n"); - builders.CsharpFunctions.Append("\t\t\t\n"); - builders.CsharpFunctions.Append("\t\t\tpublic "); - AppendCsharpTypeName( - invokeMethod.ReturnType, - builders.CsharpFunctions); - builders.CsharpFunctions.Append(" Invoke("); - for (int i = 0; i < invokeParams.Length; ++i) - { - ParameterInfo param = invokeParams[i]; - AppendCsharpTypeName( - param.ParameterType, - builders.CsharpFunctions); - builders.CsharpFunctions.Append(' '); - builders.CsharpFunctions.Append(param.Name); - if (i != invokeParams.Length - 1) - { - builders.CsharpFunctions.Append(", "); - } - } - builders.CsharpFunctions.Append(")\n"); - builders.CsharpFunctions.Append("\t\t\t{\n"); - builders.CsharpFunctions.Append("\t\t\t\tif (CppHandle != 0)\n"); - builders.CsharpFunctions.Append("\t\t\t\t{\n"); - builders.CsharpFunctions.Append("\t\t\t\t\tint thisHandle = CppHandle;\n"); - AppendCppFunctionCall( - cppInvokeFuncName, - invokeParamsWithThis, - invokeMethod.ReturnType, - type.Name, - type.Namespace, - true, - 5, - builders.CsharpFunctions); - if (invokeMethod.ReturnType != typeof(void)) - { - builders.CsharpFunctions.Append("\t\t\t\t\treturn "); - switch (invokeReturnTypeKind) - { - case TypeKind.Class: - case TypeKind.ManagedStruct: - if (invokeMethod.ReturnType != typeof(object)) - { - builders.CsharpFunctions.Append('('); - AppendCsharpTypeName( - invokeMethod.ReturnType, - builders.CsharpFunctions); - builders.CsharpFunctions.Append(')'); - } - AppendHandleStoreTypeName( - invokeMethod.ReturnType, - builders.CsharpFunctions); - builders.CsharpFunctions.Append(".Get(returnVal);\n"); - break; - default: - builders.CsharpFunctions.Append("returnVal;\n"); - break; - } - } - builders.CsharpFunctions.Append("\t\t\t\t}\n"); - if (invokeMethod.ReturnType != typeof(void)) - { - builders.CsharpFunctions.Append("\t\t\t\treturn default("); - AppendCsharpTypeName( - invokeMethod.ReturnType, - builders.CsharpFunctions); - builders.CsharpFunctions.Append(");\n"); - } - builders.CsharpFunctions.Append("\t\t\t}\n"); - builders.CsharpFunctions.Append("\t\t}\n"); - builders.CsharpFunctions.Append("\t\t\n"); - - // C# constructor delegate type - AppendCsharpDelegateType( - constructorFuncName, - true, - type, - TypeKind.Class, - typeof(void), - constructorParams, - builders.CsharpDelegateTypes); - - // C# constructor function - AppendCsharpFunctionBeginning( - type, - constructorFuncName, - true, - TypeKind.Class, - typeof(void), + outputFirstBoot); + outputFirstBoot.Append("*)(Plugin::"); + outputFirstBoot.Append(typeName); + outputFirstBoot.AppendLine("FreeList + i + 1);"); + outputFirstBoot.AppendLine("\t\t}"); + + outputFirstBoot.Append("\t\tPlugin::"); + outputFirstBoot.Append(typeName); + outputFirstBoot.Append("FreeList[Plugin::"); + outputFirstBoot.Append(typeName); + outputFirstBoot.AppendLine("FreeListSize - 1] = nullptr;"); + + outputFirstBoot.Append("\t\tPlugin::NextFree"); + outputFirstBoot.Append(typeName); + outputFirstBoot.Append(" = Plugin::"); + outputFirstBoot.Append(typeName); + outputFirstBoot.AppendLine("FreeList + 1;"); + + outputFirstBoot.AppendLine("\t\t"); + } + + static void AppendCppPointerFreeListStateAndFunctions( + TypeName cppTypeTypeName, + Type[] typeParams, + string bindingTypeName, + StringBuilder output) + { + // Section comment + output.Append("\t// Free list for "); + AppendCppTypeFullName( + cppTypeTypeName, + output); + AppendCppTypeParameters( typeParams, - constructorParams, - builders.CsharpFunctions); - builders.CsharpFunctions.Append("var thiz = new "); - builders.CsharpFunctions.Append(typeName); - builders.CsharpFunctions.Append("(cppHandle);\n"); - builders.CsharpFunctions.Append("\t\t\t\tclassHandle = NativeScript.Bindings.ObjectStore.Store(thiz);\n"); - builders.CsharpFunctions.Append("\t\t\t\thandle = NativeScript.Bindings.ObjectStore.Store(thiz.Delegate);"); - AppendCsharpFunctionReturn( - constructorParams, - typeof(void), - TypeKind.Class, - null, - true, - builders.CsharpFunctions); - - // C# release delegate type - AppendCsharpDelegateType( - releaseFuncName, - true, - type, - TypeKind.Class, - typeof(void), - releaseParams, - builders.CsharpDelegateTypes); - - // C# release function - AppendCsharpFunctionBeginning( - type, - releaseFuncName, - true, - TypeKind.Class, - typeof(void), + output); + output.AppendLine(" pointers"); + output.AppendLine("\t"); + + // Size variable + output.Append("\tint32_t "); + output.Append(bindingTypeName); + output.AppendLine("FreeListSize;"); + + // Free list variable + output.Append('\t'); + AppendCppTypeFullName( + cppTypeTypeName, + output); + AppendCppTypeParameters( typeParams, - releaseParams, - builders.CsharpFunctions); - builders.CsharpFunctions.Append("if (classHandle != 0)\n"); - builders.CsharpFunctions.Append("\t\t\t\t{\n"); - builders.CsharpFunctions.Append("\t\t\t\t\tvar thiz = ("); - builders.CsharpFunctions.Append(typeName); - builders.CsharpFunctions.Append(")NativeScript.Bindings.ObjectStore.Remove(classHandle);\n"); - builders.CsharpFunctions.Append("\t\t\t\t\tthiz.CppHandle = 0;\n"); - builders.CsharpFunctions.Append("\t\t\t\t}\n"); - builders.CsharpFunctions.Append("\t\t\t\tNativeScript.Bindings.ObjectStore.Remove(handle);"); - AppendCsharpFunctionReturn( - releaseParams, - typeof(void), - TypeKind.Class, - null, - true, - builders.CsharpFunctions); - - // C# invoke delegate type - AppendCsharpDelegateType( - invokeFuncName, - true, - type, - TypeKind.Class, - invokeMethod.ReturnType, - invokeParamsWithThis, - builders.CsharpDelegateTypes); - - // C# invoke function - AppendCsharpFunctionBeginning( - type, - invokeFuncName, - true, - TypeKind.Class, - invokeMethod.ReturnType, + output); + output.Append("** "); + output.Append(bindingTypeName); + output.AppendLine("FreeList;"); + + // Next free variable + output.Append('\t'); + AppendCppTypeFullName( + cppTypeTypeName, + output); + AppendCppTypeParameters( + typeParams, + output); + output.Append("** NextFree"); + output.Append(bindingTypeName); + output.AppendLine(";"); + output.AppendLine("\t"); + + // Store function + output.Append("\tint32_t Store"); + output.Append(bindingTypeName); + output.Append('('); + AppendCppTypeFullName( + cppTypeTypeName, + output); + AppendCppTypeParameters( + typeParams, + output); + output.AppendLine("* del)"); + output.AppendLine("\t{"); + output.Append("\t\tassert(NextFree"); + output.Append(bindingTypeName); + output.AppendLine(" != nullptr);"); + output.Append("\t\t"); + AppendCppTypeFullName( + cppTypeTypeName, + output); + AppendCppTypeParameters( + typeParams, + output); + output.Append("** pNext = NextFree"); + output.Append(bindingTypeName); + output.AppendLine(";"); + output.Append("\t\tNextFree"); + output.Append(bindingTypeName); + output.Append(" = ("); + AppendCppTypeFullName( + cppTypeTypeName, + output); + AppendCppTypeParameters( + typeParams, + output); + output.AppendLine("**)*pNext;"); + output.AppendLine("\t\t*pNext = del;"); + output.Append("\t\treturn (int32_t)(pNext - "); + output.Append(bindingTypeName); + output.AppendLine("FreeList);"); + output.AppendLine("\t}"); + output.AppendLine("\t"); + + // Get function + output.Append('\t'); + AppendCppTypeFullName( + cppTypeTypeName, + output); + AppendCppTypeParameters( + typeParams, + output); + output.Append("* Get"); + output.Append(bindingTypeName); + output.AppendLine("(int32_t handle)"); + output.AppendLine("\t{"); + output.Append( + "\t\tassert(handle >= 0 && handle < "); + output.Append(bindingTypeName); + output.AppendLine("FreeListSize);"); + output.Append("\t\treturn "); + output.Append(bindingTypeName); + output.AppendLine("FreeList[handle];"); + output.AppendLine("\t}"); + output.AppendLine("\t"); + + // Remove function + output.Append("\tvoid Remove"); + output.Append(bindingTypeName); + output.AppendLine("(int32_t handle)"); + output.AppendLine("\t{"); + output.Append("\t\t"); + AppendCppTypeFullName( + cppTypeTypeName, + output); + AppendCppTypeParameters( + typeParams, + output); + output.Append("** pRelease = "); + output.Append(bindingTypeName); + output.AppendLine("FreeList + handle;"); + output.Append("\t\t*pRelease = ("); + AppendCppTypeFullName( + cppTypeTypeName, + output); + AppendCppTypeParameters( + typeParams, + output); + output.Append("*)NextFree"); + output.Append(bindingTypeName); + output.AppendLine(";"); + output.Append("\t\tNextFree"); + output.Append(bindingTypeName); + output.AppendLine(" = pRelease;"); + output.AppendLine("\t}"); + output.AppendLine("\t"); + } + + static void AppendCppWholeObjectFreeListInit( + int maxSimultaneous, + string bindingTypeName, + StringBuilder output, + StringBuilder outputFirstBoot) + { + output.Append("\tPlugin::"); + output.Append(bindingTypeName); + output.Append("FreeWholeListSize = "); + output.Append(maxSimultaneous); + output.AppendLine(";"); + + output.Append("\tPlugin::"); + output.Append(bindingTypeName); + output.Append("FreeWholeList = (Plugin::"); + output.Append(bindingTypeName); + output.AppendLine("FreeWholeListEntry*)curMemory;"); + + output.Append("\tcurMemory += "); + output.Append(maxSimultaneous); + output.Append(" * sizeof(Plugin::"); + output.Append(bindingTypeName); + output.AppendLine("FreeWholeListEntry);"); + + output.AppendLine("\t"); + + outputFirstBoot.Append("\t\tfor (int32_t i = 0, end = Plugin::"); + outputFirstBoot.Append(bindingTypeName); + 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.AppendLine("FreeWholeList + i + 1;"); + outputFirstBoot.AppendLine("\t\t}"); + + outputFirstBoot.Append("\t\tPlugin::"); + outputFirstBoot.Append(bindingTypeName); + outputFirstBoot.Append("FreeWholeList[Plugin::"); + outputFirstBoot.Append(bindingTypeName); + outputFirstBoot.AppendLine("FreeWholeListSize - 1].Next = nullptr;"); + + outputFirstBoot.Append("\t\tPlugin::NextFreeWhole"); + outputFirstBoot.Append(bindingTypeName); + outputFirstBoot.Append(" = Plugin::"); + outputFirstBoot.Append(bindingTypeName); + outputFirstBoot.AppendLine("FreeWholeList + 1;"); + + outputFirstBoot.AppendLine("\t\t"); + } + + static void AppendCppWholeObjectFreeListStateAndFunctions( + Type[] typeParams, + TypeName cppTypeTypeName, + string bindingTypeName, + StringBuilder output) + { + // Section comment + output.Append("\t// Free list for whole "); + AppendCppTypeFullName( + cppTypeTypeName, + output); + AppendCppTypeParameters( typeParams, - invokeParamsWithThis, - builders.CsharpFunctions); - builders.CsharpFunctions.Append("(("); - AppendCsharpTypeName( - type, - builders.CsharpFunctions); - builders.CsharpFunctions.Append(")NativeScript.Bindings.ObjectStore.Get(thisHandle))"); - AppendCsharpFunctionCallParameters( - true, - invokeParams, - builders.CsharpFunctions); - builders.CsharpFunctions.Append(';'); - AppendCsharpFunctionReturn( - invokeParams, - invokeMethod.ReturnType, - invokeReturnTypeKind, - null, - false, - builders.CsharpFunctions); - - // C# add delegate type - AppendCsharpDelegateType( - addFuncName, - false, - type, - TypeKind.Class, - typeof(void), - addRemoveParams, - builders.CsharpDelegateTypes); - - // C# add function - AppendCsharpFunctionBeginning( - type, - addFuncName, - false, - TypeKind.Class, - typeof(void), + output); + output.AppendLine(" objects"); + output.AppendLine("\t"); + + // Union with a pointer and a whole object + output.Append("\tunion "); + output.Append(bindingTypeName); + output.AppendLine("FreeWholeListEntry"); + output.AppendLine("\t{"); + output.Append("\t\t"); + output.Append(bindingTypeName); + output.AppendLine("FreeWholeListEntry* Next;"); + output.Append("\t\t"); + AppendCppTypeFullName( + cppTypeTypeName, + output); + AppendCppTypeParameters( typeParams, - addRemoveParams, - builders.CsharpFunctions); - builders.CsharpFunctions.Append("thiz += del;"); - AppendCsharpFunctionReturn( - addRemoveParams, - typeof(void), - TypeKind.Class, - null, - false, - builders.CsharpFunctions); - - // C# remove delegate type - AppendCsharpDelegateType( - removeFuncName, - false, - type, - TypeKind.Class, - typeof(void), - addRemoveParams, - builders.CsharpDelegateTypes); - - // C# remove function - AppendCsharpFunctionBeginning( - type, - removeFuncName, - false, - TypeKind.Class, - typeof(void), + output); + output.AppendLine(" Value;"); + output.AppendLine("\t};"); + + // Size + output.Append("\tint32_t "); + output.Append(bindingTypeName); + output.AppendLine("FreeWholeListSize;"); + + // Free list entries + output.Append('\t'); + output.Append(bindingTypeName); + output.Append("FreeWholeListEntry* "); + output.Append(bindingTypeName); + output.AppendLine("FreeWholeList;"); + + // Pointer to next free entry + output.Append('\t'); + output.Append(bindingTypeName); + output.Append("FreeWholeListEntry* NextFreeWhole"); + output.Append(bindingTypeName); + output.AppendLine(";"); + output.AppendLine("\t"); + + // Store function + output.Append('\t'); + AppendCppTypeFullName( + cppTypeTypeName, + output); + AppendCppTypeParameters( typeParams, - addRemoveParams, - builders.CsharpFunctions); - builders.CsharpFunctions.Append("thiz -= del;"); - AppendCsharpFunctionReturn( - addRemoveParams, - typeof(void), - TypeKind.Class, - null, - false, - builders.CsharpFunctions); - - // C# init params - AppendCsharpInitParam( - releaseFuncNameLower, - builders.CsharpInitParams); - AppendCsharpInitParam( - constructorFuncNameLower, - builders.CsharpInitParams); - AppendCsharpInitParam( - invokeFuncNameLower, - builders.CsharpInitParams); - AppendCsharpInitParam( - addFuncNameLower, - builders.CsharpInitParams); - AppendCsharpInitParam( - removeFuncNameLower, - builders.CsharpInitParams); - - // C# init call args - AppendCsharpInitCallArg( - releaseFuncName, - builders.CsharpInitCall); - AppendCsharpInitCallArg( - constructorFuncName, - builders.CsharpInitCall); - AppendCsharpInitCallArg( - invokeFuncName, - builders.CsharpInitCall); - AppendCsharpInitCallArg( - addFuncName, - builders.CsharpInitCall); - AppendCsharpInitCallArg( - removeFuncName, - builders.CsharpInitCall); + output); + output.Append("* StoreWhole"); + output.Append(bindingTypeName); + output.AppendLine("()"); + output.AppendLine("\t{"); + output.Append("\t\tassert(NextFreeWhole"); + output.Append(bindingTypeName); + output.AppendLine(" != nullptr);"); + output.Append("\t\t"); + output.Append(bindingTypeName); + output.Append("FreeWholeListEntry* pNext = NextFreeWhole"); + output.Append(bindingTypeName); + output.AppendLine(";"); + output.Append("\t\tNextFreeWhole"); + output.Append(bindingTypeName); + output.AppendLine(" = pNext->Next;"); + output.AppendLine("\t\treturn &pNext->Value;"); + output.AppendLine("\t}"); + output.AppendLine("\t"); + + // Remove function + output.Append("\tvoid RemoveWhole"); + output.Append(bindingTypeName); + output.Append('('); + AppendCppTypeFullName( + cppTypeTypeName, + output); + AppendCppTypeParameters( + typeParams, + output); + output.AppendLine("* instance)"); + output.AppendLine("\t{"); + output.Append("\t\t"); + output.Append(bindingTypeName); + output.Append("FreeWholeListEntry* pRelease = ("); + output.Append(bindingTypeName); + 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.AppendLine("FreeWholeListSize - 1))"); + output.AppendLine("\t\t{"); + output.Append("\t\t\tpRelease->Next = NextFreeWhole"); + output.Append(bindingTypeName); + output.AppendLine(";"); + output.Append("\t\t\tNextFreeWhole"); + output.Append(bindingTypeName); + output.AppendLine(" = pRelease->Next;"); + output.AppendLine("\t\t}"); + output.AppendLine("\t}"); + output.AppendLine("\t"); } - + static void AppendCsharpDelegate( bool isStatic, - string typeName, - string typeNamespace, + TypeName typeTypeName, Type[] typeParams, string funcName, ParameterInfo[] parameters, @@ -7341,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)) { @@ -7355,7 +10448,7 @@ static void AppendCsharpDelegate( output.Append("int"); break; default: - AppendCsharpTypeName( + AppendCsharpTypeFullName( returnType, output); break; @@ -7363,12 +10456,11 @@ static void AppendCsharpDelegate( } output.Append(' '); AppendCsharpDelegateName( - typeName, - typeNamespace, + typeTypeName, typeParams, funcName, output); - output.Append("Delegate("); + output.Append("DelegateType("); if (!isStatic) { output.Append("int thisHandle"); @@ -7385,7 +10477,7 @@ static void AppendCsharpDelegate( case TypeKind.FullStruct: case TypeKind.Primitive: case TypeKind.Enum: - AppendCsharpTypeName( + AppendCsharpTypeFullName( param.ParameterType, output); output.Append(" param"); @@ -7401,37 +10493,35 @@ static void AppendCsharpDelegate( output.Append(", "); } } - output.Append(");\n"); + output.AppendLine(");"); output.Append("\t\tpublic static "); AppendCsharpDelegateName( - typeName, - typeNamespace, + typeTypeName, typeParams, funcName, output); - output.Append("Delegate "); + output.Append("DelegateType "); AppendCsharpDelegateName( - typeName, - typeNamespace, + typeTypeName, typeParams, funcName, output); - output.Append(";\n\t\t\n"); + output.AppendLine(";"); + output.AppendLine("\t\t"); } static void AppendCsharpDelegateName( - string typeName, - string typeNamespace, + TypeName typeTypeName, Type[] typeParams, string funcName, StringBuilder output) { AppendNamespace( - typeNamespace, + typeTypeName.Namespace, string.Empty, output); AppendTypeNameWithoutSuffixes( - typeName, + typeTypeName.Name, output); AppendTypeNames( typeParams, @@ -7440,50 +10530,47 @@ static void AppendCsharpDelegateName( } static void AppendCsharpGetDelegateCall( - string typeName, - string typeNamespace, + TypeName typeTypeName, Type[] typeParams, string funcName, StringBuilder output) { output.Append("\t\t\t"); AppendCsharpDelegateName( - typeName, - typeNamespace, + typeTypeName, typeParams, funcName, output); output.Append(" = GetDelegate<"); AppendCsharpDelegateName( - typeName, - typeNamespace, + typeTypeName, typeParams, funcName, output); - output.Append("Delegate>(libraryHandle, \""); + output.Append("DelegateType>(libraryHandle, \""); AppendCsharpDelegateName( - typeName, - typeNamespace, + typeTypeName, typeParams, funcName, output); - output.Append("\");\n"); + output.AppendLine("\");"); } static void AppendCsharpImport( - string typeName, - string typeNamespace, + TypeName typeTypeName, Type[] typeParams, string funcName, ParameterInfo[] parameters, + Type returnType, StringBuilder output ) { - output.Append("\t\t[DllImport(Constants.PluginName)]\n"); - output.Append("\t\tpublic static extern void "); + output.AppendLine("\t\t[DllImport(PLUGIN_NAME, CallingConvention = CallingConvention.Cdecl)]"); + output.Append("\t\tpublic static extern "); + AppendCsharpTypeFullName(returnType, output); + output.Append(' '); AppendCsharpDelegateName( - typeName, - typeNamespace, + typeTypeName, typeParams, funcName, output); @@ -7495,25 +10582,29 @@ StringBuilder output for (int i = 0; i < parameters.Length; ++i) { ParameterInfo param = parameters[i]; - if (param.Kind == TypeKind.FullStruct) - { - AppendCsharpTypeName( - 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( @@ -7599,107 +10690,122 @@ static void AppendExceptions( builders.CppMethodDefinitions.Append("struct "); builders.CppMethodDefinitions.Append(exceptionType.Name); builders.CppMethodDefinitions.Append("Thrower : "); - AppendCppTypeName( + 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(": "); - AppendCppTypeName( + builders.CppMethodDefinitions.AppendLine(": System::Runtime::InteropServices::_Exception(nullptr)"); + AppendIndent( + throwerIndent + 2, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine(", System::Runtime::Serialization::ISerializable(nullptr)"); + AppendIndent( + throwerIndent + 2, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine(", System::Exception(nullptr)"); + AppendIndent( + throwerIndent + 2, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.AppendLine(", System::SystemException(nullptr)"); + AppendIndent( + throwerIndent + 2, + builders.CppMethodDefinitions); + builders.CppMethodDefinitions.Append(", "); + 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 "); - AppendCppTypeName( + 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( - new Type[]{ typeof(int) }); + new[]{ typeof(int) }); // C# imports AppendCsharpImport( - string.Empty, - string.Empty, + GetTypeName(string.Empty, string.Empty), null, funcName, - parameters, + ConvertParameters(Type.EmptyTypes), + typeof(void), builders.CsharpImports); // C# delegate AppendCsharpDelegate( true, - string.Empty, - string.Empty, + GetTypeName(string.Empty, string.Empty), null, funcName, parameters, typeof(void), TypeKind.None, - builders.CsharpDelegates + builders.CsharpCppDelegates ); // C# GetDelegate call AppendCsharpGetDelegateCall( - string.Empty, - string.Empty, + GetTypeName(string.Empty, string.Empty), null, funcName, builders.CsharpGetDelegateCalls); @@ -7752,26 +10858,15 @@ static void AppendGetter( // Build uppercase function name builders.TempStrBuilder.Length = 0; - AppendNamespace( - enclosingType.Namespace, - string.Empty, - builders.TempStrBuilder); - AppendTypeNameWithoutGenericSuffix( - enclosingType.Name, - builders.TempStrBuilder); - AppendTypeNames( + AppendFieldPropertyFuncName( + GetTypeName(enclosingType), enclosingTypeParams, + syntaxType, + "Get", + fieldName, builders.TempStrBuilder); - builders.TempStrBuilder.Append(syntaxType); - builders.TempStrBuilder.Append("Get"); - builders.TempStrBuilder.Append(fieldNameUpper); 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"); @@ -7779,9 +10874,6 @@ static void AppendGetter( string methodName = builders.TempStrBuilder.ToString(); // C# init param declaration - AppendCsharpInitParam( - funcNameLower, - builders.CsharpInitParams); // C# delegate type AppendCsharpDelegateType( @@ -7794,9 +10886,10 @@ static void AppendGetter( builders.CsharpDelegateTypes); // C# init call param - AppendCsharpInitCallArg( + AppendCsharpCsharpDelegate( funcName, - builders.CsharpInitCall); + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); // C# function AppendCsharpFunctionBeginning( @@ -7805,7 +10898,6 @@ static void AppendGetter( methodIsStatic, enclosingTypeKind, fieldType, - enclosingTypeParams, parameters, builders.CsharpFunctions); AppendCsharpFunctionCallSubject( @@ -7832,6 +10924,7 @@ static void AppendGetter( } builders.CsharpFunctions.Append(';'); if (!isReadOnly + && !methodIsStatic && enclosingTypeKind == TypeKind.ManagedStruct) { AppendStructStoreReplace( @@ -7852,8 +10945,7 @@ static void AppendGetter( AppendCppFunctionPointerDefinition( funcName, methodIsStatic, - enclosingType.Name, - enclosingType.Namespace, + GetTypeName(enclosingType), enclosingTypeKind, parameters, fieldType, @@ -7873,7 +10965,7 @@ static void AppendGetter( // C++ method definition AppendCppMethodDefinitionBegin( - enclosingType.Name, + GetTypeName(enclosingType), fieldType, methodName, enclosingTypeParams, @@ -7882,11 +10974,10 @@ static void AppendGetter( indent, builders.CppMethodDefinitions); AppendIndent(indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendCppPluginFunctionCall( methodIsStatic, - enclosingType.Name, - enclosingType.Namespace, + GetTypeName(enclosingType), enclosingTypeKind, enclosingTypeParams, fieldType, @@ -7900,26 +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, - enclosingType.Name, - enclosingType.Namespace, + GetTypeName(enclosingType), enclosingTypeKind, parameters, fieldType, - builders.CppInitParams); - - // C++ init body - AppendCppInitBody( - funcName, - funcNameLower, - builders.CppInitBody); + builders.CppInitBodyParameterReads); } static void AppendSetter( @@ -7932,11 +11016,12 @@ static void AppendSetter( bool isReadOnly, Type enclosingType, Type[] enclosingTypeParams, - Type fieldType, int indent, Type[] exceptionTypes, StringBuilders builders) { + TypeName enclosingTypeTypeName = GetTypeName(enclosingType); + // Build uppercased field name builders.TempStrBuilder.Length = 0; builders.TempStrBuilder.Append(char.ToUpper(fieldName[0])); @@ -7948,26 +11033,15 @@ static void AppendSetter( // Build uppercase function name builders.TempStrBuilder.Length = 0; - AppendNamespace( - enclosingType.Namespace, - string.Empty, - builders.TempStrBuilder); - AppendTypeNameWithoutGenericSuffix( - enclosingType.Name, - builders.TempStrBuilder); - AppendTypeNames( + AppendFieldPropertyFuncName( + enclosingTypeTypeName, enclosingTypeParams, + syntaxType, + "Set", + fieldName, builders.TempStrBuilder); - builders.TempStrBuilder.Append(syntaxType); - builders.TempStrBuilder.Append("Set"); - builders.TempStrBuilder.Append(fieldNameUpper); 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"); @@ -7975,10 +11049,7 @@ static void AppendSetter( string methodName = builders.TempStrBuilder.ToString(); // C# init param declaration - AppendCsharpInitParam( - funcNameLower, - builders.CsharpInitParams); - + // C# delegate type AppendCsharpDelegateType( funcName, @@ -7990,9 +11061,10 @@ static void AppendSetter( builders.CsharpDelegateTypes); // C# init call param - AppendCsharpInitCallArg( + AppendCsharpCsharpDelegate( funcName, - builders.CsharpInitCall); + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); // C# function AppendCsharpFunctionBeginning( @@ -8001,7 +11073,6 @@ static void AppendSetter( methodIsStatic, enclosingTypeKind, typeof(void), - enclosingTypeParams, parameters, builders.CsharpFunctions); AppendCsharpFunctionCallSubject( @@ -8031,6 +11102,7 @@ static void AppendSetter( } builders.CsharpFunctions.Append(';'); if (!isReadOnly + && !methodIsStatic && enclosingTypeKind == TypeKind.ManagedStruct) { AppendStructStoreReplace( @@ -8051,8 +11123,7 @@ static void AppendSetter( AppendCppFunctionPointerDefinition( funcName, methodIsStatic, - enclosingType.Name, - enclosingType.Namespace, + enclosingTypeTypeName, enclosingTypeKind, parameters, typeof(void), @@ -8072,7 +11143,7 @@ static void AppendSetter( // C++ method definition AppendCppMethodDefinitionBegin( - enclosingType.Name, + GetTypeName(enclosingType), typeof(void), methodName, enclosingTypeParams, @@ -8081,11 +11152,10 @@ static void AppendSetter( indent, builders.CppMethodDefinitions); AppendIndent(indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendCppPluginFunctionCall( methodIsStatic, - enclosingType.Name, - enclosingType.Namespace, + enclosingTypeTypeName, enclosingTypeKind, enclosingTypeParams, null, @@ -8094,75 +11164,90 @@ 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, - enclosingType.Name, - enclosingType.Namespace, + enclosingTypeTypeName, enclosingTypeKind, parameters, typeof(void), - builders.CppInitParams); - - // C++ init body - AppendCppInitBody( - funcName, - funcNameLower, - builders.CppInitBody); + builders.CppInitBodyParameterReads); + } + + static void AppendFieldPropertyFuncName( + TypeName enclosingTypeTypeName, + Type[] enclosingTypeParams, + string syntaxType, + string operationType, + string fieldName, + StringBuilder output) + { + AppendNamespace( + enclosingTypeTypeName.Namespace, + string.Empty, + output); + AppendTypeNameWithoutGenericSuffix( + enclosingTypeTypeName.Name, + output); + AppendTypeNames( + enclosingTypeParams, + output); + output.Append(syntaxType); + output.Append(operationType); + output.Append(char.ToUpper(fieldName[0])); + output.Append(fieldName, 1, fieldName.Length-1); } static void AppendCppTemplateDeclaration( - string typeName, - string typeNamespace, - int numTypeParameters, + TypeName typeTypeName, StringBuilder output) { int indent = AppendNamespaceBeginning( - typeNamespace, + typeTypeName.Namespace, output); AppendIndent( indent, output); AppendCppTemplateTypenames( - numTypeParameters, + typeTypeName.NumTypeParams, + 'T', output); output.Append("struct "); - AppendTypeNameWithoutGenericSuffix( - typeName, + AppendCppTypeName( + typeTypeName, output); output.Append(";"); - output.Append('\n'); + output.AppendLine();; AppendNamespaceEnding( indent, output); - output.Append('\n'); + output.AppendLine();; } static int AppendCppTypeDeclaration( - string typeNamespace, - string typeName, + TypeName typeTypeName, bool isStatic, Type[] typeParams, StringBuilder output) { int indent = AppendNamespaceBeginning( - typeNamespace, + typeTypeName.Namespace, output); AppendIndent(indent, output); if (isStatic) { output.Append("namespace "); AppendTypeNameWithoutGenericSuffix( - typeName, + typeTypeName.Name, output); - output.Append('\n'); + output.AppendLine();; AppendIndent(indent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent(indent, output); output.Append('}'); } @@ -8173,36 +11258,35 @@ static int AppendCppTypeDeclaration( output.Append("template<> "); } output.Append("struct "); - AppendTypeNameWithoutGenericSuffix( - typeName, + AppendCppTypeName( + typeTypeName, output); AppendCppTypeParameters( typeParams, output); output.Append(";"); } - output.Append('\n'); + output.AppendLine();; AppendNamespaceEnding( indent, output); - output.Append('\n'); + output.AppendLine();; return indent; } static void AppendCppTypeDefinitionBegin( - string typeName, - string typeNamespace, + TypeName typeTypeName, TypeKind typeKind, Type[] typeParams, - string baseTypeName, - string baseTypeNamespace, + TypeName baseTypeTypeName, Type[] baseTypeTypeParams, + Type[] interfaceTypes, bool isStatic, int indent, StringBuilder output) { AppendNamespaceBeginning( - typeNamespace, + typeTypeName.Namespace, output); AppendIndent( indent, @@ -8211,7 +11295,7 @@ static void AppendCppTypeDefinitionBegin( { output.Append("namespace "); AppendTypeNameWithoutGenericSuffix( - typeName, + typeTypeName.Name, output); } else @@ -8221,170 +11305,182 @@ static void AppendCppTypeDefinitionBegin( output.Append("template<> "); } output.Append("struct "); - AppendTypeNameWithoutGenericSuffix( - typeName, + AppendCppTypeName( + typeTypeName, output); AppendCppTypeParameters(typeParams, output); - if (baseTypeName != null) + switch (typeKind) { - switch (typeKind) - { - case TypeKind.Class: - case TypeKind.ManagedStruct: - output.Append(" : "); - AppendCppTypeName( - baseTypeNamespace, - baseTypeName, + case TypeKind.Class: + // Only add the base type if it's not System.Object or + // there are no interfaces (since they always extend it) + string separator = " : virtual "; + if ( + (baseTypeTypeName.Name != null && + (baseTypeTypeName.Namespace != "System" || + baseTypeTypeName.Name != "Object")) || + (interfaceTypes == null || + interfaceTypes.Length == 0)) + { + output.Append(separator); + separator = ", virtual "; + AppendCppTypeFullName( + GetTypeName( + baseTypeTypeName.Name ?? "Object", + baseTypeTypeName.Namespace ?? "System", + baseTypeTypeParams != null ? baseTypeTypeParams.Length : 0), output); AppendCppTypeParameters( baseTypeTypeParams, output); - break; - } + } + if (interfaceTypes != null) + { + foreach (Type interfaceType in interfaceTypes) + { + output.Append(separator); + separator = ", virtual "; + AppendCppTypeFullName( + GetTypeName(interfaceType), + output); + AppendCppTypeParameters( + interfaceType.GetGenericArguments(), + output); + } + } + break; + case TypeKind.ManagedStruct: + output.Append(" : Plugin::ManagedType"); + break; } } - output.Append('\n'); + output.AppendLine();; AppendIndent( indent, output); - output.Append("{\n"); + output.AppendLine("{"); if (!isStatic) { switch (typeKind) { case TypeKind.Class: case TypeKind.ManagedStruct: - // Constructor from nullptr_t + // Constructor from nullptr AppendIndent(indent + 1, output); - AppendTypeNameWithoutGenericSuffix( - typeName, - output); - AppendCppTypeParameters( - typeParams, + AppendCppTypeName( + typeTypeName, output); - output.Append("(std::nullptr_t n);\n"); + output.AppendLine("(decltype(nullptr));"); // Constructor from handle AppendIndent(indent + 1, output); - AppendTypeNameWithoutGenericSuffix( - typeName, - output); - AppendCppTypeParameters( - typeParams, + AppendCppTypeName( + typeTypeName, output); - output.Append( - "(Plugin::InternalUse iu, int32_t handle);\n"); + output.AppendLine( + "(Plugin::InternalUse, int32_t handle);"); // Copy constructor AppendIndent(indent + 1, output); - AppendTypeNameWithoutGenericSuffix( - typeName, - output); - AppendCppTypeParameters( - typeParams, + AppendCppTypeName( + typeTypeName, output); output.Append("(const "); - AppendTypeNameWithoutGenericSuffix( - typeName, + AppendCppTypeName( + typeTypeName, output); AppendCppTypeParameters( typeParams, output); - output.Append("& other);\n"); + output.AppendLine("& other);"); // Move constructor AppendIndent(indent + 1, output); - AppendTypeNameWithoutGenericSuffix( - typeName, - output); - AppendCppTypeParameters( - typeParams, + AppendCppTypeName( + typeTypeName, output); output.Append('('); - AppendTypeNameWithoutGenericSuffix( - typeName, + AppendCppTypeName( + typeTypeName, output); AppendCppTypeParameters( typeParams, output); - output.Append("&& other);\n"); + output.AppendLine("&& other);"); // Destructor AppendIndent(indent + 1, output); output.Append("virtual ~"); - AppendTypeNameWithoutGenericSuffix( - typeName, - output); - AppendCppTypeParameters( - typeParams, + AppendCppTypeName( + typeTypeName, output); - output.Append("();\n"); + output.AppendLine("();"); // Assignment operator to same type AppendIndent(indent + 1, output); - AppendTypeNameWithoutGenericSuffix( - typeName, + AppendCppTypeName( + typeTypeName, output); AppendCppTypeParameters( typeParams, output); output.Append("& operator=(const "); - AppendTypeNameWithoutGenericSuffix( - typeName, + AppendCppTypeName( + typeTypeName, output); AppendCppTypeParameters( typeParams, output); - output.Append("& other);\n"); + output.AppendLine("& other);"); - // Assignment operator to nullptr_t + // Assignment operator to nullptr AppendIndent(indent + 1, output); - AppendTypeNameWithoutGenericSuffix( - typeName, + AppendCppTypeName( + typeTypeName, output); AppendCppTypeParameters( typeParams, output); - output.Append("& operator=(std::nullptr_t other);\n"); + output.AppendLine("& operator=(decltype(nullptr));"); // Move assignment operator to same type AppendIndent(indent + 1, output); - AppendTypeNameWithoutGenericSuffix( - typeName, + AppendCppTypeName( + typeTypeName, output); AppendCppTypeParameters( typeParams, output); output.Append("& operator=("); - AppendTypeNameWithoutGenericSuffix( - typeName, + AppendCppTypeName( + typeTypeName, output); AppendCppTypeParameters( typeParams, output); - output.Append("&& other);\n"); + output.AppendLine("&& other);"); // Equality operator with same type AppendIndent(indent + 1, output); output.Append("bool operator==(const "); - AppendTypeNameWithoutGenericSuffix( - typeName, + AppendCppTypeName( + typeTypeName, output); AppendCppTypeParameters( typeParams, output); - output.Append("& other) const;\n"); + output.AppendLine("& other) const;"); // Inequality operator with same type AppendIndent(indent + 1, output); output.Append("bool operator!=(const "); - AppendTypeNameWithoutGenericSuffix( - typeName, + AppendCppTypeName( + typeTypeName, output); AppendCppTypeParameters( typeParams, output); - output.Append("& other) const;\n"); + output.AppendLine("& other) const;"); break; } } @@ -8403,409 +11499,404 @@ static void AppendCppTypeDefinitionEnd( { output.Append(';'); } - output.Append('\n'); + output.AppendLine();; AppendNamespaceEnding( indent, output); - output.Append('\n'); + output.AppendLine();; } static int AppendCppMethodDefinitionsBegin( - string enclosingTypeName, - string enclosingTypeNamespace, + TypeName enclosingTypeTypeName, TypeKind enclosingTypeKind, Type[] enclosingTypeParams, - string baseTypeName, - string baseTypeNamespace, - Type[] baseTypeTypeParams, + Type[] interfaceTypes, bool isStatic, + Action extraDefault, + Action extraCopy, int indent, StringBuilder output) { int cppMethodDefinitionsIndent = AppendNamespaceBeginning( - enclosingTypeNamespace, + enclosingTypeTypeName.Namespace, output); if (!isStatic && ( enclosingTypeKind == TypeKind.Class || enclosingTypeKind == TypeKind.ManagedStruct)) { - if (baseTypeName == null) - { - baseTypeName = "Object"; - baseTypeNamespace = "System"; - } - - // Construct with nullptr_t + // Construct with nullptr AppendIndent(indent, output); - AppendTypeNameWithoutGenericSuffix( - enclosingTypeName, + AppendCppTypeName( + enclosingTypeTypeName, output); AppendCppTypeParameters( enclosingTypeParams, output); output.Append("::"); - AppendTypeNameWithoutGenericSuffix( - enclosingTypeName, - output); - output.Append("(std::nullptr_t n)\n"); - AppendIndent(indent, output); - output.Append("\t: "); - AppendTypeNameWithoutGenericSuffix( - enclosingTypeName, + AppendCppTypeName( + enclosingTypeTypeName, output); - output.Append("(Plugin::InternalUse::Only, 0)\n"); + output.AppendLine("(decltype(nullptr))"); + if (enclosingTypeKind == TypeKind.Class) + { + AppendCppConstructorInitializerList( + interfaceTypes, + indent + 1, + 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); - AppendTypeNameWithoutGenericSuffix( - enclosingTypeName, + AppendCppTypeName( + enclosingTypeTypeName, output); AppendCppTypeParameters( enclosingTypeParams, output); output.Append("::"); - AppendTypeNameWithoutGenericSuffix( - enclosingTypeName, - output); - output.Append("(Plugin::InternalUse iu, int32_t handle)\n"); - AppendIndent(indent, output); - output.Append("\t: "); AppendCppTypeName( - baseTypeNamespace, - baseTypeName, - output); - AppendCppTypeParameters( - baseTypeTypeParams, + enclosingTypeTypeName, output); - output.Append("(iu, handle)\n"); + output.AppendLine("(Plugin::InternalUse, int32_t handle)"); + if (enclosingTypeKind == TypeKind.Class) + { + AppendCppConstructorInitializerList( + interfaceTypes, + indent + 1, + output); + } AppendIndent(indent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent(indent + 1, output); - output.Append("if (handle)\n"); + output.AppendLine("Handle = handle;"); AppendIndent(indent + 1, output); - output.Append("{\n"); + output.AppendLine("if (handle)"); + AppendIndent(indent + 1, output); + output.AppendLine("{"); AppendIndent(indent + 2, output); AppendReferenceManagedHandleFunctionCall( - enclosingTypeName, - enclosingTypeNamespace, + enclosingTypeTypeName, enclosingTypeKind, 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); - AppendTypeNameWithoutGenericSuffix( - enclosingTypeName, + AppendCppTypeName( + enclosingTypeTypeName, output); AppendCppTypeParameters( enclosingTypeParams, output); output.Append("::"); - AppendTypeNameWithoutGenericSuffix( - enclosingTypeName, + AppendCppTypeName( + enclosingTypeTypeName, output); output.Append("(const "); - AppendTypeNameWithoutGenericSuffix( - enclosingTypeName, + AppendCppTypeName( + enclosingTypeTypeName, output); AppendCppTypeParameters( enclosingTypeParams, output); - output.Append("& other)\n"); - AppendIndent(indent, output); - output.Append("\t: "); - AppendTypeNameWithoutGenericSuffix( - enclosingTypeName, + 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); - AppendTypeNameWithoutGenericSuffix( - enclosingTypeName, + AppendCppTypeName( + enclosingTypeTypeName, output); AppendCppTypeParameters( enclosingTypeParams, output); output.Append("::"); - AppendTypeNameWithoutGenericSuffix( - enclosingTypeName, + AppendCppTypeName( + enclosingTypeTypeName, output); output.Append("("); - AppendTypeNameWithoutGenericSuffix( - enclosingTypeName, + AppendCppTypeName( + enclosingTypeTypeName, output); AppendCppTypeParameters( enclosingTypeParams, output); - output.Append("&& other)\n"); + output.AppendLine("&& other)"); AppendIndent(indent, output); output.Append("\t: "); - AppendTypeNameWithoutGenericSuffix( - enclosingTypeName, + 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); - AppendTypeNameWithoutGenericSuffix( - enclosingTypeName, + AppendCppTypeName( + enclosingTypeTypeName, output); AppendCppTypeParameters( enclosingTypeParams, output); output.Append("::~"); - AppendTypeNameWithoutGenericSuffix( - enclosingTypeName, + AppendCppTypeName( + enclosingTypeTypeName, output); 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( - enclosingTypeName, - enclosingTypeNamespace, + enclosingTypeTypeName, enclosingTypeKind, 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); - AppendTypeNameWithoutGenericSuffix( - enclosingTypeName, + AppendCppTypeName( + enclosingTypeTypeName, output); AppendCppTypeParameters( enclosingTypeParams, output); output.Append("& "); - AppendTypeNameWithoutGenericSuffix( - enclosingTypeName, + AppendCppTypeName( + enclosingTypeTypeName, output); AppendCppTypeParameters( enclosingTypeParams, output); output.Append("::operator=(const "); - AppendTypeNameWithoutGenericSuffix( - enclosingTypeName, + AppendCppTypeName( + enclosingTypeTypeName, output); AppendCppTypeParameters( enclosingTypeParams, output); - output.Append("& other)\n"); + output.AppendLine("& other)"); AppendIndent(indent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendSetHandle( - enclosingTypeName, - enclosingTypeNamespace, + enclosingTypeTypeName, enclosingTypeKind, enclosingTypeParams, indent + 1, "this", "other.Handle", output); + extraCopy(indent + 1, "other."); + AppendIndent(indent + 1, output); + output.AppendLine("return *this;"); AppendIndent(indent, output); - output.Append("\treturn *this;\n"); - AppendIndent(indent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent(indent, output); - output.Append("\n"); + output.AppendLine();; - // Assignment operator to nullptr_t + // Assignment operator to nullptr AppendIndent(indent, output); - AppendTypeNameWithoutGenericSuffix( - enclosingTypeName, + AppendCppTypeName( + enclosingTypeTypeName, output); AppendCppTypeParameters( enclosingTypeParams, output); output.Append("& "); - AppendTypeNameWithoutGenericSuffix( - enclosingTypeName, + AppendCppTypeName( + enclosingTypeTypeName, output); AppendCppTypeParameters( enclosingTypeParams, output); - output.Append("::operator=(std::nullptr_t other)\n"); + output.AppendLine("::operator=(decltype(nullptr))"); AppendIndent(indent, output); - output.Append("{\n"); - AppendIndent(indent, output); - output.Append("\tif (Handle)\n"); - AppendIndent(indent, output); - output.Append("\t{\n"); - AppendIndent(indent, output); - output.Append("\t\t"); + output.AppendLine("{"); + AppendIndent(indent + 1, output); + output.AppendLine("if (Handle)"); + AppendIndent(indent + 1, output); + output.AppendLine("{"); + AppendIndent(indent + 2, output); AppendDereferenceManagedHandleFunctionCall( - enclosingTypeName, - enclosingTypeNamespace, + enclosingTypeTypeName, enclosingTypeKind, enclosingTypeParams, "Handle", output); - output.Append(";\n"); - AppendIndent(indent, output); - output.Append("\t\tHandle = 0;\n"); - AppendIndent(indent, output); - output.Append("\t}\n"); - AppendIndent(indent, output); - output.Append("\treturn *this;\n"); + output.AppendLine(";"); + AppendIndent(indent + 2, output); + output.AppendLine("Handle = 0;"); + AppendIndent(indent + 1, output); + output.AppendLine("}"); + AppendIndent(indent + 1, output); + 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); - AppendTypeNameWithoutGenericSuffix( - enclosingTypeName, + AppendCppTypeName( + enclosingTypeTypeName, output); AppendCppTypeParameters( enclosingTypeParams, output); output.Append("& "); - AppendTypeNameWithoutGenericSuffix( - enclosingTypeName, + AppendCppTypeName( + enclosingTypeTypeName, output); AppendCppTypeParameters( enclosingTypeParams, output); output.Append("::operator=("); - AppendTypeNameWithoutGenericSuffix( - enclosingTypeName, + AppendCppTypeName( + enclosingTypeTypeName, output); AppendCppTypeParameters( enclosingTypeParams, output); - output.Append("&& other)\n"); - AppendIndent(indent, output); - output.Append("{\n"); - AppendIndent(indent, output); - output.Append("\tif (Handle)\n"); + output.AppendLine("&& other)"); AppendIndent(indent, output); - output.Append("\t{\n"); - AppendIndent(indent, output); - output.Append("\t\t"); + output.AppendLine("{"); + AppendIndent(indent + 1, output); + output.AppendLine("if (Handle)"); + AppendIndent(indent + 1, output); + output.AppendLine("{"); + AppendIndent(indent + 2, output); AppendDereferenceManagedHandleFunctionCall( - enclosingTypeName, - enclosingTypeNamespace, + enclosingTypeTypeName, enclosingTypeKind, enclosingTypeParams, "Handle", output); - output.Append(";\n"); - AppendIndent(indent, output); - output.Append("\t}\n"); - AppendIndent(indent, output); - output.Append("\tHandle = other.Handle;\n"); - AppendIndent(indent, output); - output.Append("\tother.Handle = 0;\n"); - AppendIndent(indent, output); - output.Append("\treturn *this;\n"); + output.AppendLine(";"); + AppendIndent(indent + 1, output); + output.AppendLine("}"); + AppendIndent(indent + 1, output); + output.AppendLine("Handle = other.Handle;"); + extraCopy(indent + 1, "other."); + AppendIndent(indent + 1, output); + output.AppendLine("other.Handle = 0;"); + extraDefault(indent + 1, "other."); + AppendIndent(indent + 1, output); + 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); output.Append("bool "); - AppendTypeNameWithoutGenericSuffix( - enclosingTypeName, + AppendCppTypeName( + enclosingTypeTypeName, output); AppendCppTypeParameters( enclosingTypeParams, output); output.Append("::operator==(const "); - AppendTypeNameWithoutGenericSuffix( - enclosingTypeName, + AppendCppTypeName( + enclosingTypeTypeName, output); 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); output.Append("bool "); - AppendTypeNameWithoutGenericSuffix( - enclosingTypeName, + AppendCppTypeName( + enclosingTypeTypeName, output); AppendCppTypeParameters( enclosingTypeParams, output); output.Append("::operator!=(const "); - AppendTypeNameWithoutGenericSuffix( - enclosingTypeName, + AppendCppTypeName( + enclosingTypeTypeName, output); 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; } static void AppendSetHandle( - string enclosingTypeName, - string enclosingTypeNamespace, + TypeName enclosingTypeTypeName, TypeKind enclosingTypeKind, Type[] enclosingTypeParams, int indent, @@ -8817,47 +11908,44 @@ 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( - enclosingTypeName, - enclosingTypeNamespace, + enclosingTypeTypeName, enclosingTypeKind, 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( - enclosingTypeName, - enclosingTypeNamespace, + enclosingTypeTypeName, enclosingTypeKind, enclosingTypeParams, thisHandleExpression, output); - output.Append(";\n"); + output.AppendLine(";"); AppendIndent(indent, output); - output.Append("}\n"); + output.AppendLine("}"); } static void AppendReferenceManagedHandleFunctionCall( - string enclosingTypeName, - string enclosingTypeNamespace, + TypeName enclosingTypeTypeName, TypeKind enclosingTypeKind, Type[] enclosingTypeParams, string handleVariable, @@ -8867,8 +11955,7 @@ static void AppendReferenceManagedHandleFunctionCall( { output.Append("Plugin::ReferenceManaged"); AppendReleaseFunctionNameSuffix( - enclosingTypeName, - enclosingTypeNamespace, + enclosingTypeTypeName, enclosingTypeParams, output); output.Append("(Handle)"); @@ -8882,8 +11969,7 @@ static void AppendReferenceManagedHandleFunctionCall( } static void AppendDereferenceManagedHandleFunctionCall( - string enclosingTypeName, - string enclosingTypeNamespace, + TypeName enclosingTypeTypeName, TypeKind enclosingTypeKind, Type[] enclosingTypeParams, string handleVariable, @@ -8893,8 +11979,7 @@ static void AppendDereferenceManagedHandleFunctionCall( { output.Append("Plugin::DereferenceManaged"); AppendReleaseFunctionNameSuffix( - enclosingTypeName, - enclosingTypeNamespace, + enclosingTypeTypeName, enclosingTypeParams, output); output.Append("(Handle)"); @@ -8912,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( @@ -8937,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; @@ -8959,7 +12044,7 @@ static void AppendNamespaceEnding( for (; indent >= 0; --indent) { AppendIndent(indent, output); - output.Append("}\n"); + output.AppendLine("}"); } } @@ -8969,26 +12054,28 @@ static void AppendIndent( { output.Append('\t', indent); } - - static void AppendCsharpInitParam( - string funcName, - StringBuilder output) - { - output.Append("\t\t\tIntPtr "); - output.Append(funcName); - output.Append(",\n"); - } - - static void AppendCsharpInitCallArg( + + static void AppendCsharpCsharpDelegate( 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( @@ -9000,12 +12087,13 @@ static void AppendCsharpDelegateType( ParameterInfo[] parameters, StringBuilder output) { + output.AppendLine("\t\t[UnmanagedFunctionPointer(CallingConvention.Cdecl)]"); output.Append("\t\tdelegate "); // Return type if (IsFullValueType(returnType)) { - AppendCsharpTypeName( + AppendCsharpTypeFullName( returnType, output); } @@ -9016,13 +12104,13 @@ static void AppendCsharpDelegateType( output.Append(' '); output.Append(funcName); - output.Append("Delegate("); + output.Append("DelegateType("); if (!isStatic) { if (enclosingTypeKind == TypeKind.FullStruct) { output.Append("ref "); - AppendCsharpTypeName( + AppendCsharpTypeFullName( enclosingType, output); output.Append(" thiz"); @@ -9036,10 +12124,10 @@ static void AppendCsharpDelegateType( output.Append(", "); } } - AppendCsharpParameterDeclaration( + AppendCsharpBindingParameterDeclaration( parameters, output); - output.Append(");\n"); + output.AppendLine(");"); } static void AppendCsharpFunctionBeginning( @@ -9048,20 +12136,20 @@ static void AppendCsharpFunctionBeginning( bool isStatic, TypeKind enclosingTypeKind, Type returnType, - Type[] typeParams, ParameterInfo[] parameters, StringBuilder output) { 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) { if (IsFullValueType(returnType)) { - AppendCsharpTypeName( + AppendCsharpTypeFullName( returnType, output); } @@ -9082,7 +12170,7 @@ static void AppendCsharpFunctionBeginning( if (enclosingTypeKind == TypeKind.FullStruct) { output.Append("ref "); - AppendCsharpTypeName( + AppendCsharpTypeFullName( enclosingType, output); output.Append(" thiz"); @@ -9096,28 +12184,34 @@ static void AppendCsharpFunctionBeginning( output.Append(", "); } } - AppendCsharpParameterDeclaration( + 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 && enclosingTypeKind != TypeKind.FullStruct) { output.Append("var thiz = ("); - AppendCsharpTypeName( + AppendCsharpTypeFullName( enclosingType, output); output.Append(')'); 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 @@ -9130,24 +12224,25 @@ static void AppendCsharpFunctionBeginning( output.Append("var "); output.Append(param.Name); output.Append(" = "); - if (!paramType.Equals(typeof(object))) + if (paramType != typeof(object)) { output.Append('('); - AppendCsharpTypeName(paramType, output); + AppendCsharpTypeFullName(paramType, output); output.Append(')'); } 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"); } } // Save return value as local variable - if (!returnType.Equals(typeof(void))) + if (returnType != typeof(void)) { output.Append("var returnValue = "); - }; + } } static void AppendCsharpFunctionCallSubject( @@ -9157,7 +12252,7 @@ static void AppendCsharpFunctionCallSubject( { if (isStatic) { - AppendCsharpTypeName( + AppendCsharpTypeFullName( enclosingType, output); } @@ -9168,11 +12263,9 @@ static void AppendCsharpFunctionCallSubject( } static void AppendCsharpFunctionCallParameters( - bool isStatic, ParameterInfo[] parameters, StringBuilder output) { - output.Append('('); for (int i = 0; i < parameters.Length; ++i) { ParameterInfo param = parameters[i]; @@ -9190,7 +12283,6 @@ static void AppendCsharpFunctionCallParameters( output.Append(", "); } } - output.Append(')'); } static void AppendStructStoreReplace( @@ -9199,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); @@ -9225,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( @@ -9242,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); @@ -9251,9 +12346,10 @@ static void AppendCsharpFunctionReturn( } // Return - if (!returnType.Equals(typeof(void))) + if (returnType != typeof(void)) { - output.Append("\n\t\t\t\treturn "); + output.AppendLine(); + output.Append("\t\t\t\treturn "); if ( forceReturnReturnValue || returnTypeKind == TypeKind.Enum @@ -9285,16 +12381,18 @@ static void AppendCsharpFunctionReturn( AppendCsharpFunctionEnd( returnType, exceptionTypes, + parameters, output); } static void AppendCsharpFunctionEnd( Type returnType, Type[] exceptionTypes, + 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, @@ -9303,6 +12401,7 @@ static void AppendCsharpFunctionEnd( AppendCsharpCatchException( typeof(NullReferenceException), returnType, + parameters, output); } if (exceptionTypes != null) @@ -9312,40 +12411,64 @@ static void AppendCsharpFunctionEnd( AppendCsharpCatchException( exceptionType, returnType, + parameters, output); } } AppendCsharpCatchException( typeof(Exception), returnType, + parameters, output); - output.Append("\t\t}\n"); - output.Append("\t\t\n"); + output.AppendLine("\t\t}"); + output.AppendLine("\t\t"); } static void AppendCsharpCatchException( Type exceptionType, Type returnType, + ParameterInfo[] parameters, StringBuilder output) { output.Append("\t\t\tcatch ("); - AppendCsharpTypeName( + 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) + { + output.Append("\t\t\t\t"); + output.Append(param.Name); + if (param.Kind == TypeKind.Class + || param.Kind == TypeKind.ManagedStruct) + { + output.AppendLine("Handle = default(int);"); + } + else + { + output.Append(" = default("); + AppendCsharpTypeFullName( + param.DereferencedParameterType, + output); + output.AppendLine(");"); + } + } + } if (returnType != typeof(void)) { output.Append("\t\t\t\treturn default("); if (IsFullValueType(returnType)) { - AppendCsharpTypeName( + AppendCsharpTypeFullName( returnType, output); } @@ -9353,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( @@ -9376,7 +12499,7 @@ StringBuilder output } } - static void AppendCsharpParameterDeclaration( + static void AppendCsharpBindingParameterDeclaration( ParameterInfo[] parameters, StringBuilder output) { @@ -9416,7 +12539,7 @@ static void AppendCsharpParameterDeclaration( output.Append("int"); break; default: - AppendCsharpTypeName( + AppendCsharpTypeFullName( param.DereferencedParameterType, output); break; @@ -9442,14 +12565,31 @@ static void AppendCsharpParameterDeclaration( static void AppendCppParameterDeclaration( ParameterInfo[] parameters, + Type[] methodTypeParameters, + bool includeDefaults, StringBuilder output) { + bool hasVarArgs = parameters.Length > 0 && + parameters[parameters.Length-1].IsVarArg; for (int i = 0; i < parameters.Length; ++i) { ParameterInfo param = parameters[i]; - AppendCppTypeName( - param.DereferencedParameterType, - output); + Type paramType = param.DereferencedParameterType; + + int typeParamIndex = ArrayIndexOf( + methodTypeParameters, + paramType); + if (typeParamIndex >= 0) + { + output.Append("MT"); + output.Append(typeParamIndex); + } + else + { + AppendCppTypeFullName( + paramType, + output); + } // Pointer (*) or reference (&) suffix if necessary if (param.IsOut || param.IsRef) @@ -9458,61 +12598,116 @@ static void AppendCppParameterDeclaration( } else if ( param.Kind == TypeKind.FullStruct || + param.Kind == TypeKind.ManagedStruct || + param.Kind == TypeKind.Class || param.IsVirtual) { output.Append('&'); } - // Param name - output.Append(' '); - output.Append(param.Name); - + // Param name + output.Append(' '); + output.Append(param.Name); + + // Default if desired, present, and the method has no var args + if (includeDefaults && param.HasDefault && !hasVarArgs) + { + output.Append(" = "); + if (param.DereferencedParameterType == typeof(string)) + { + if (param.DefaultValue != null) + { + throw new Exception( + "Non-null string default parameters aren't supported"); + } + output.Append("Plugin::NullString"); + } + else if (param.DefaultValue is bool) + { + bool val = (bool)param.DefaultValue; + output.Append(val ? "true" : "false"); + } + else if (param.DefaultValue is char) + { + char val = (char)param.DefaultValue; + output.Append('\''); + output.Append(val); + output.Append('\''); + } + else if ((param.DefaultValue is sbyte) || + (param.DefaultValue is byte) || + (param.DefaultValue is short) || + (param.DefaultValue is ushort) || + (param.DefaultValue is int) || + (param.DefaultValue is uint) || + (param.DefaultValue is long) || + (param.DefaultValue is ulong)) + { + output.Append(param.DefaultValue); + } + else + { + Type type = param.DefaultValue.GetType(); + if (type.IsEnum) + { + AppendCppTypeFullName( + type, + output); + output.Append("::"); + output.Append(param.DefaultValue); + } + else + { + StringBuilder error = new StringBuilder(); + error.Append("Default parameter type ("); + AppendCsharpTypeFullName( + param.DefaultValue.GetType(), + error); + error.Append(") not supported"); + throw new Exception(error.ToString()); + } + } + } + if (i != parameters.Length - 1) { output.Append(", "); } } } - - static void AppendParameterCall( - ParameterInfo[] parameters, - string separator, - StringBuilder output) - { - for (int i = 0; i < parameters.Length; ++i) - { - ParameterInfo parameter = parameters[i]; - output.Append(parameter.Name); - if (parameter.Kind == TypeKind.Class - || parameter.Kind == TypeKind.ManagedStruct) - { - output.Append("Handle"); - } - if (i != parameters.Length - 1) - { - output.Append(','); - output.Append(separator); - } - } - } - - 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( - string enclosingTypeName, + TypeName enclosingTypeTypeName, Type returnType, string methodName, - Type[] typeTypeParams, + Type[] enclosingTypeTypeParams, Type[] methodTypeParams, ParameterInfo[] parameters, int indent, @@ -9532,18 +12727,18 @@ static void AppendCppMethodDefinitionBegin( // Return type if (returnType != null) { - AppendCppTypeName( + AppendCppTypeFullName( returnType, output); output.Append(' '); } - + // Type name - AppendTypeNameWithoutGenericSuffix( - enclosingTypeName, + AppendCppTypeFullName( + enclosingTypeTypeName, output); AppendCppTypeParameters( - typeTypeParams, + enclosingTypeTypeParams, output); output.Append("::"); @@ -9561,8 +12756,10 @@ static void AppendCppMethodDefinitionBegin( output.Append('('); AppendCppParameterDeclaration( parameters, + null, // don't substitute method type params + false, output); - output.Append(")\n"); + output.AppendLine(")"); } static void AppendCppMethodReturn( @@ -9571,7 +12768,7 @@ static void AppendCppMethodReturn( int indent, StringBuilder output) { - if (returnType != null && !returnType.Equals(typeof(void))) + if (returnType != null && returnType != typeof(void)) { AppendIndent(indent, output); output.Append("return "); @@ -9583,20 +12780,19 @@ static void AppendCppMethodReturn( output.Append("returnValue"); break; default: - AppendCppTypeName( + AppendCppTypeFullName( returnType, output); output.Append("(Plugin::InternalUse::Only, returnValue)"); break; } - output.Append(";\n"); + output.AppendLine(";"); } } static void AppendCppPluginFunctionCall( bool isStatic, - string enclosingTypeName, - string enclosingTypeNamespace, + TypeName enclosingTypeTypeName, TypeKind enclosingTypeKind, Type[] enclosingTypeParams, Type returnType, @@ -9617,7 +12813,7 @@ static void AppendCppPluginFunctionCall( output.Append(param.Name); output.Append("Handle = "); output.Append(param.Name); - output.Append("->Handle;\n"); + output.AppendLine("->Handle;"); } } @@ -9651,10 +12847,21 @@ static void AppendCppPluginFunctionCall( switch (param.Kind) { case TypeKind.FullStruct: - case TypeKind.Primitive: case TypeKind.Enum: output.Append(param.Name); break; + case TypeKind.Primitive: + if (param.IsOut || param.IsRef) + { + output.Append("&"); + output.Append(param.Name); + output.Append("->Value"); + } + else + { + output.Append(param.Name); + } + break; default: if (param.IsOut || param.IsRef) { @@ -9674,7 +12881,7 @@ static void AppendCppPluginFunctionCall( output.Append(", "); } } - output.Append(");\n"); + output.AppendLine(");"); AppendCppUnhandledExceptionHandling( indent, @@ -9688,8 +12895,7 @@ static void AppendCppPluginFunctionCall( && (param.IsOut || param.IsRef)) { AppendSetHandle( - enclosingTypeName, - enclosingTypeNamespace, + enclosingTypeTypeName, enclosingTypeKind, enclosingTypeParams, indent, @@ -9705,52 +12911,25 @@ 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"); - } - - static void AppendCppInitParam( - string funcName, - bool isStatic, - string enclosingTypeName, - string enclosingTypeNamespace, - TypeKind enclosingTypeKind, - ParameterInfo[] parameters, - Type returnType, - StringBuilder output - ) - { - output.Append('\t'); - AppendCppFunctionPointer( - funcName, - isStatic, - enclosingTypeName, - enclosingTypeNamespace, - enclosingTypeKind, - parameters, - returnType, - ',', - output - ); - output.Append('\n'); + output.AppendLine("}"); } - + static void AppendCppFunctionPointerDefinition( string funcName, bool isStatic, - string enclosingTypeName, - string enclosingTypeNamespace, + TypeName enclosingTypeTypeName, TypeKind enclosingTypeKind, ParameterInfo[] parameters, Type returnType, @@ -9761,39 +12940,53 @@ StringBuilder output AppendCppFunctionPointer( funcName, isStatic, - enclosingTypeName, - enclosingTypeNamespace, + enclosingTypeTypeName, enclosingTypeKind, parameters, returnType, - ';', + 1, output ); - output.Append('\n'); + output.Append(';'); + output.AppendLine();; } static void AppendCppFunctionPointer( string funcName, bool isStatic, - string enclosingTypeName, - string enclosingTypeNamespace, + TypeName enclosingTypeTypeName, TypeKind enclosingTypeKind, ParameterInfo[] parameters, Type returnType, - char separator, + int numIndirectionLevels, StringBuilder output) { // Return type - if (IsFullValueType(returnType)) + if (returnType == typeof(bool)) + { + // C linkage requires us to use primitive types + output.Append("int32_t"); + } + else if (returnType == typeof(char)) { - AppendCppTypeName(returnType, output); + // 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); } else { output.Append("int32_t"); } - output.Append(" (*"); + output.Append(" ("); + output.Append('*', numIndirectionLevels); output.Append(funcName); output.Append(")("); if (!isStatic) @@ -9802,9 +12995,8 @@ static void AppendCppFunctionPointer( { case TypeKind.FullStruct: case TypeKind.Primitive: - AppendCppTypeName( - enclosingTypeNamespace, - enclosingTypeName, + AppendCppTypeFullName( + enclosingTypeTypeName, output); output.Append("* thiz"); break; @@ -9823,8 +13015,16 @@ static void AppendCppFunctionPointer( switch (param.Kind) { case TypeKind.Primitive: + AppendCppPrimitiveTypeName( + param.DereferencedParameterType, + output); + if (param.IsOut || param.IsRef) + { + output.Append('*'); + } + break; case TypeKind.Enum: - AppendCppTypeName( + AppendCppTypeFullName( param.DereferencedParameterType, output); if (param.IsOut || param.IsRef) @@ -9833,7 +13033,7 @@ static void AppendCppFunctionPointer( } break; case TypeKind.FullStruct: - AppendCppTypeName( + AppendCppTypeFullName( param.DereferencedParameterType, output); if (param.IsOut || param.IsRef) @@ -9867,11 +13067,11 @@ static void AppendCppFunctionPointer( } } output.Append(')'); - output.Append(separator); } static void AppendCppTemplateTypenames( int numTypeParameters, + char prefix, StringBuilder output) { if (numTypeParameters > 0) @@ -9879,7 +13079,9 @@ static void AppendCppTemplateTypenames( output.Append("template<"); for (int i = 0; i < numTypeParameters; ++i) { - output.Append("typename T"); + output.Append("typename "); + output.Append(prefix); + output.Append('T'); output.Append(i); if (i != numTypeParameters - 1) { @@ -9896,12 +13098,13 @@ static void AppendCppMethodDeclaration( bool methodIsVirtual, bool methodIsStatic, Type returnType, - Type[] typeParameters, + Type[] methodTypeParameters, ParameterInfo[] parameters, StringBuilder output) { AppendCppTemplateTypenames( - typeParameters == null ? 0 : typeParameters.Length, + methodTypeParameters == null ? 0 : methodTypeParameters.Length, + 'M', output); if (!enclosingTypeIsStatic && methodIsStatic) @@ -9917,9 +13120,20 @@ static void AppendCppMethodDeclaration( // Return type if (returnType != null) { - AppendCppTypeName( - returnType, - output); + int typeParamIndex = ArrayIndexOf( + methodTypeParameters, + returnType); + if (typeParamIndex >= 0) + { + output.Append("MT"); + output.Append(typeParamIndex); + } + else + { + AppendCppTypeFullName( + returnType, + output); + } output.Append(' '); } @@ -9933,75 +13147,81 @@ static void AppendCppMethodDeclaration( output.Append('('); AppendCppParameterDeclaration( parameters, + methodTypeParameters, + true, output); output.Append(')'); - output.Append(";\n"); + output.AppendLine(";"); } - static void AppendCsharpTypeName( + static void AppendCsharpTypeFullName( Type type, StringBuilder output) { - if (type.Equals(typeof(void))) + if (type == typeof(void)) { output.Append("void"); } - else if (type.Equals(typeof(bool))) + else if (type == typeof(bool)) { output.Append("bool"); } - else if (type.Equals(typeof(sbyte))) + else if (type == typeof(sbyte)) { output.Append("sbyte"); } - else if (type.Equals(typeof(byte))) + else if (type == typeof(byte)) { output.Append("byte"); } - else if (type.Equals(typeof(short))) + else if (type == typeof(short)) { output.Append("short"); } - else if (type.Equals(typeof(ushort))) + else if (type == typeof(ushort)) { output.Append("ushort"); } - else if (type.Equals(typeof(int))) + else if (type == typeof(int)) { output.Append("int"); } - else if (type.Equals(typeof(uint))) + else if (type == typeof(uint)) { output.Append("uint"); } - else if (type.Equals(typeof(long))) + else if (type == typeof(long)) { output.Append("long"); } - else if (type.Equals(typeof(ulong))) + else if (type == typeof(ulong)) { output.Append("ulong"); } - else if (type.Equals(typeof(char))) + else if (type == typeof(char)) { output.Append("char"); } - else if (type.Equals(typeof(float))) + else if (type == typeof(float)) { output.Append("float"); } - else if (type.Equals(typeof(double))) + else if (type == typeof(double)) { output.Append("double"); } - else if (type.Equals(typeof(string))) + else if (type == typeof(string)) { output.Append("string"); } + else if (type == typeof(object)) + { + output.Append("object"); + } else if (type.IsArray) { - AppendCsharpTypeName( + AppendCsharpTypeFullName( type.GetElementType(), output); output.Append('['); @@ -10010,78 +13230,90 @@ static void AppendCsharpTypeName( } else { - output.Append(type.Namespace); - output.Append('.'); - AppendTypeNameWithoutGenericSuffix( - type.Name, - output); + AppendCsharpTypeFullName(GetTypeName(type), output); Type[] genTypes = type.GetGenericArguments(); AppendCSharpTypeParameters( genTypes, output); } } + + static void AppendCsharpTypeFullName( + TypeName typeName, + StringBuilder output) + { + if (!string.IsNullOrEmpty(typeName.Namespace)) + { + output.Append(typeName.Namespace); + output.Append('.'); + } + AppendTypeNameWithoutGenericSuffix(typeName.Name, output); + } - static void AppendCppTypeName( + static void AppendCppTypeFullName( Type type, StringBuilder output) { - if (type.Equals(typeof(void))) + if (type == typeof(void)) { output.Append("void"); } - else if (type.Equals(typeof(bool))) + else if (type == typeof(bool)) { output.Append("System::Boolean"); } - else if (type.Equals(typeof(sbyte))) + else if (type == typeof(sbyte)) { - output.Append("int8_t"); + output.Append("System::SByte"); } - else if (type.Equals(typeof(byte))) + else if (type == typeof(byte)) { - output.Append("uint8_t"); + output.Append("System::Byte"); } - else if (type.Equals(typeof(short))) + else if (type == typeof(short)) { - output.Append("int16_t"); + output.Append("System::Int16"); } - else if (type.Equals(typeof(ushort))) + else if (type == typeof(ushort)) { - output.Append("uint16_t"); + output.Append("System::UInt16"); } - else if (type.Equals(typeof(int))) + else if (type == typeof(int)) { - output.Append("int32_t"); + output.Append("System::Int32"); } - else if (type.Equals(typeof(uint))) + else if (type == typeof(uint)) { - output.Append("uint32_t"); + output.Append("System::UInt32"); } - else if (type.Equals(typeof(long))) + else if (type == typeof(long)) { - output.Append("int64_t"); + output.Append("System::Int64"); } - else if (type.Equals(typeof(ulong))) + else if (type == typeof(ulong)) { - output.Append("uint64_t"); + output.Append("System::UInt64"); } - else if (type.Equals(typeof(char))) + else if (type == typeof(char)) { output.Append("System::Char"); } - else if (type.Equals(typeof(float))) + else if (type == typeof(float)) { - output.Append("float"); + output.Append("System::Single"); } - else if (type.Equals(typeof(double))) + else if (type == typeof(double)) { - output.Append("double"); + output.Append("System::Double"); } - else if (type.Equals(typeof(string))) + else if (type == typeof(string)) { output.Append("System::String"); } + else if (type == typeof(IntPtr)) + { + output.Append("void*"); + } else if (type.IsArray) { int rank = type.GetArrayRank(); @@ -10089,140 +13321,147 @@ static void AppendCppTypeName( output.Append(rank); output.Append('<'); Type elementType = type.GetElementType(); - for (int i = 0; i < rank; ++i) - { - AppendCppTypeName( - elementType, - output); - if (i != rank -1) - { - output.Append(", "); - } - } + AppendCppTypeFullName( + elementType, + output); output.Append('>'); } - else if (typeof(Delegate).IsAssignableFrom(type)) + else if (IsDelegate(type)) { - AppendCppTypeName( - type.Namespace, - type.Name, + AppendCppTypeFullName( + GetTypeName(type), output); Type[] genTypes = type.GetGenericArguments(); - if (genTypes != null && genTypes.Length > 0) - { - output.Append(genTypes.Length); - } AppendCppTypeParameters( genTypes, output); } else { - AppendCppTypeName( - type.Namespace, - type.Name, - output); + TypeName typeName = GetTypeName(type); + AppendCppTypeFullName(typeName, output); Type[] genTypes = type.GetGenericArguments(); - AppendCppTypeParameters( - genTypes, - output); + AppendCppTypeParameters(genTypes, output); } } + static void AppendCppTypeFullName( + TypeName typeName, + StringBuilder output) + { + AppendNamespace(typeName.Namespace, "::", output); + if (!string.IsNullOrEmpty(typeName.Namespace)) + { + output.Append("::"); + } + AppendCppTypeName(typeName, output); + } + static void AppendCppTypeName( - string namespaceName, - string name, + TypeName typeName, StringBuilder output) { - AppendNamespace(namespaceName, "::", output); - output.Append("::"); - AppendTypeNameWithoutGenericSuffix( - name, - output); + AppendTypeNameWithoutGenericSuffix(typeName.Name, output); + if (typeName.NumTypeParams > 0) + { + output.Append('_'); + output.Append(typeName.NumTypeParams); + } } - static void LogStringBuilders( - StringBuilders builders) - { - LogStringBuilder( - "C# init params", - builders.CsharpInitParams); - LogStringBuilder( - "C# delegates", - builders.CsharpDelegateTypes); - LogStringBuilder( - "C# StructStore Init calls", - builders.CsharpStructStoreInitCalls); - LogStringBuilder( - "C# init call", - builders.CsharpInitCall); - LogStringBuilder( - "C# functions", - builders.CsharpFunctions); - LogStringBuilder( - "C# MonoBehaviours", - builders.CsharpMonoBehaviours); - LogStringBuilder( - "C# MonoBehaviour Delegates", - builders.CsharpDelegates); - LogStringBuilder( - "C# MonoBehaviour Imports", - builders.CsharpImports); - LogStringBuilder( - "C# MonoBehaviour GetDelegate Calls", - builders.CsharpGetDelegateCalls); - LogStringBuilder( - "C++ function pointers", - builders.CppFunctionPointers); - LogStringBuilder( - "C++ type declarations", - builders.CppTypeDeclarations); - LogStringBuilder( - "C++ type definitions", - builders.CppTypeDefinitions); - LogStringBuilder( - "C++ method definitions", - builders.CppMethodDefinitions); - LogStringBuilder( - "C++ init params", - builders.CppInitParams); - LogStringBuilder( - "C++ init body", - builders.CppInitBody); - LogStringBuilder( - "C++ MonoBehaviour messages", - builders.CppMonoBehaviourMessages); - } - - static void LogStringBuilder( - string title, - StringBuilder builder) + static void AppendCppPrimitiveTypeName( + Type type, + StringBuilder output) { - Debug.LogFormat( - "{0}:\n\n{1}\n\n", - title, - builder); + if (type == typeof(void)) + { + output.Append("void"); + } + else if (type == typeof(bool)) + { + output.Append("uint32_t"); // C# bool is 4 bytes + } + else if (type == typeof(sbyte)) + { + output.Append("int8_t"); + } + else if (type == typeof(byte)) + { + output.Append("uint8_t"); + } + else if (type == typeof(short)) + { + output.Append("int16_t"); + } + else if (type == typeof(ushort)) + { + output.Append("uint16_t"); + } + else if (type == typeof(int)) + { + output.Append("int32_t"); + } + else if (type == typeof(uint)) + { + output.Append("uint32_t"); + } + else if (type == typeof(long)) + { + output.Append("int64_t"); + } + else if (type == typeof(ulong)) + { + output.Append("uint64_t"); + } + else if (type == typeof(char)) + { + output.Append("uint16_t"); // C# char is 2 bytes + } + else if (type == typeof(float)) + { + output.Append("float"); + } + else if (type == typeof(double)) + { + output.Append("double"); + } + else if (type == typeof(IntPtr)) + { + output.Append("void*"); + } + else + { + throw new Exception(type + " is not a C++ primitive"); + } } static void RemoveTrailingChars( StringBuilders builders) { - RemoveTrailingChars(builders.CsharpInitParams); RemoveTrailingChars(builders.CsharpDelegateTypes); - RemoveTrailingChars(builders.CsharpStructStoreInitCalls); + RemoveTrailingChars(builders.CsharpStoreInitCalls); RemoveTrailingChars(builders.CsharpInitCall); + RemoveTrailingChars(builders.CsharpBaseTypes); RemoveTrailingChars(builders.CsharpFunctions); - RemoveTrailingChars(builders.CsharpMonoBehaviours); - RemoveTrailingChars(builders.CsharpDelegates); + RemoveTrailingChars(builders.CsharpCppDelegates); + RemoveTrailingChars(builders.CsharpCsharpDelegates); RemoveTrailingChars(builders.CsharpImports); RemoveTrailingChars(builders.CsharpGetDelegateCalls); + RemoveTrailingChars(builders.CsharpDestroyFunctionEnumerators); + RemoveTrailingChars(builders.CsharpDestroyQueueCases); RemoveTrailingChars(builders.CppFunctionPointers); RemoveTrailingChars(builders.CppTypeDeclarations); - RemoveTrailingChars(builders.CppMethodDefinitions); + RemoveTrailingChars(builders.CppTemplateDeclarations); + RemoveTrailingChars(builders.CppTemplateSpecializationDeclarations); RemoveTrailingChars(builders.CppTypeDefinitions); - RemoveTrailingChars(builders.CppInitParams); - RemoveTrailingChars(builders.CppInitBody); - RemoveTrailingChars(builders.CppMonoBehaviourMessages); + RemoveTrailingChars(builders.CppMethodDefinitions); + RemoveTrailingChars(builders.CppInitBodyParameterReads); + RemoveTrailingChars(builders.CppInitBodyArrays); + RemoveTrailingChars(builders.CppInitBodyFirstBoot); + RemoveTrailingChars(builders.CppGlobalStateAndFunctions); + RemoveTrailingChars(builders.CppUnboxingMethodDeclarations); + RemoveTrailingChars(builders.CppStringDefaultParams); + RemoveTrailingChars(builders.CppMacros); } // Remove trailing chars (e.g. commas) for last elements @@ -10234,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); @@ -10260,94 +13494,124 @@ 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 STRUCTSTORE INIT CALLS*/\n", - "\n\t\t\t/*END STRUCTSTORE INIT CALLS*/", - builders.CsharpStructStoreInitCalls.ToString()); + "/*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 FUNCTIONS*/\n", - "\n\t\t/*END FUNCTIONS*/", + "/*BEGIN BASE TYPES*/", + "/*END BASE TYPES*/", + builders.CsharpBaseTypes.ToString()); + csharpContents = InjectIntoString( + csharpContents, + "/*BEGIN FUNCTIONS*/", + "\t\t/*END FUNCTIONS*/", builders.CsharpFunctions.ToString()); csharpContents = InjectIntoString( csharpContents, - "/*BEGIN MONOBEHAVIOURS*/\n", - "\n/*END MONOBEHAVIOURS*/", - builders.CsharpMonoBehaviours.ToString()); + "/*BEGIN CPP DELEGATES*/", + "\t\t/*END CPP DELEGATES*/", + builders.CsharpCppDelegates.ToString()); csharpContents = InjectIntoString( csharpContents, - "/*BEGIN MONOBEHAVIOUR DELEGATES*/\n", - "\n\t\t/*END MONOBEHAVIOUR DELEGATES*/", - builders.CsharpDelegates.ToString()); + "/*BEGIN CSHARP DELEGATES*/", + "\t\t/*END CSHARP DELEGATES*/", + builders.CsharpCsharpDelegates.ToString()); csharpContents = InjectIntoString( csharpContents, - "/*BEGIN MONOBEHAVIOUR IMPORTS*/\n", - "\n\t\t/*END MONOBEHAVIOUR IMPORTS*/", + "/*BEGIN IMPORTS*/", + "\t\t/*END IMPORTS*/", builders.CsharpImports.ToString()); csharpContents = InjectIntoString( csharpContents, - "/*BEGIN MONOBEHAVIOUR GETDELEGATE CALLS*/\n", - "\n\t\t\t/*END MONOBEHAVIOUR GETDELEGATE CALLS*/", + "/*BEGIN GETDELEGATE CALLS*/", + "\t\t\t/*END GETDELEGATE CALLS*/", builders.CsharpGetDelegateCalls.ToString()); + csharpContents = InjectIntoString( + csharpContents, + "/*BEGIN DESTROY FUNCTION ENUMERATORS*/", + "\t\t\t/*END DESTROY FUNCTION ENUMERATORS*/", + builders.CsharpDestroyFunctionEnumerators.ToString()); + csharpContents = InjectIntoString( + csharpContents, + "/*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 TYPE DEFINITIONS*/\n", - "\n/*END TYPE DEFINITIONS*/", + "/*BEGIN TEMPLATE DECLARATIONS*/", + "/*END TEMPLATE DECLARATIONS*/", + builders.CppTemplateDeclarations.ToString()); + cppHeaderContents = InjectIntoString( + cppHeaderContents, + "/*BEGIN TEMPLATE SPECIALIZATION DECLARATIONS*/", + "/*END TEMPLATE SPECIALIZATION DECLARATIONS*/", + builders.CppTemplateSpecializationDeclarations.ToString()); + cppHeaderContents = InjectIntoString( + cppHeaderContents, + "/*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 MONOBEHAVIOUR MESSAGES*/\n", - "\n/*END MONOBEHAVIOUR MESSAGES*/", - builders.CppMonoBehaviourMessages.ToString()); + "/*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 BOXING METHOD DECLARATIONS*/\n", - "\n\t\t/*END BOXING METHOD DECLARATIONS*/", - builders.CppBoxingMethodDeclarations.ToString()); + "/*BEGIN UNBOXING METHOD DECLARATIONS*/", + "\t\t/*END UNBOXING METHOD DECLARATIONS*/", + builders.CppUnboxingMethodDeclarations.ToString()); + cppHeaderContents = InjectIntoString( + cppHeaderContents, + "/*BEGIN STRING DEFAULT PARAMETERS*/", + "\t/*END STRING DEFAULT PARAMETERS*/", + builders.CppStringDefaultParams.ToString()); + cppHeaderContents = InjectIntoString( + cppHeaderContents, + "/*BEGIN MACROS*/", + "/*END MACROS*/", + builders.CppMacros.ToString()); File.WriteAllText(CsharpPath, csharpContents); File.WriteAllText(CppHeaderPath, cppHeaderContents); @@ -10360,15 +13624,16 @@ static string InjectIntoString( string endMarker, string text) { - for (int startIndex = 0; true; ) + 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( @@ -10381,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/NativeScriptConstants.cs b/Unity/Assets/NativeScriptConstants.cs index 8d8f46e..54e6923 100644 --- a/Unity/Assets/NativeScriptConstants.cs +++ b/Unity/Assets/NativeScriptConstants.cs @@ -13,5 +13,5 @@ public static class NativeScriptConstants /// /// Path within the Unity project to the exposed types JSON file /// - public const string ExposedTypesJsonPath = "NativeScriptTypes.json"; + public const string JSON_CONFIG_PATH = "NativeScriptTypes.json"; } \ No newline at end of file diff --git a/Unity/Assets/NativeScriptTypes.json b/Unity/Assets/NativeScriptTypes.json index be0f906..c507547 100644 --- a/Unity/Assets/NativeScriptTypes.json +++ b/Unity/Assets/NativeScriptTypes.json @@ -1,193 +1,176 @@ { "Assemblies": [ - "DOTNET_DLLS/System.Xml.dll" ], "Types": [ { - "Name": "System.Diagnostics.Stopwatch", - "Constructors": [ + "Name": " System.IFormattable" + }, + { + "Name": " System.IConvertible" + }, + { + "Name": " System.IComparable" + }, + { + "Name": "System.IEquatable`1", + "GenericParams": [ { - "ParamTypes": [] - } - ], - "Methods": [ + "Types": [ + "System.Boolean" + ] + }, { - "Name": "Start", - "ParamTypes": [] + "Types": [ + "System.Char" + ] }, { - "Name": "Reset", - "ParamTypes": [] - } - ], - "Properties": [ + "Types": [ + "System.SByte" + ] + }, { - "Name": "ElapsedMilliseconds", - "Get": {} - } - ] - }, - { - "Name": "UnityEngine.Object", - "Properties": [ + "Types": [ + "System.Byte" + ] + }, { - "Name": "name", - "Get": {}, - "Set": {} - } - ], - "Methods": [ + "Types": [ + "System.Int16" + ] + }, { - "Name": "x==y", - "ParamTypes": [ - "UnityEngine.Object", - "UnityEngine.Object" + "Types": [ + "System.UInt16" ] }, { - "Name": "implicit", - "ParamTypes": [ - "UnityEngine.Object" + "Types": [ + "System.Int32" ] - } - ] - }, - { - "Name": "UnityEngine.GameObject", - "Constructors": [ + }, { - "ParamTypes": [] + "Types": [ + "System.UInt32" + ] }, { - "ParamTypes": [ - "System.String" + "Types": [ + "System.Int64" ] - } - ], - "Methods": [ + }, { - "Name": "AddComponent", - "ParamTypes": [], - "GenericParams": [ - { - "Types": [ - "MyGame.MonoBehaviours.TestScript" - ] - } - ], - "Exceptions": [ - "System.NullReferenceException" + "Types": [ + "System.UInt64" ] - } - ], - "Properties": [ + }, { - "Name": "transform", - "Get": { - "Exceptions": [ - "System.NullReferenceException" - ] - } - } - ] - }, - { - "Name": "UnityEngine.Component", - "Properties": [ + "Types": [ + "System.Single" + ] + }, { - "Name": "transform", - "Get": {} - } - ] - }, - { - "Name": "UnityEngine.Transform", - "Properties": [ + "Types": [ + "System.Double" + ] + }, { - "Name": "position", - "Get": {}, - "Set": { - "Exceptions": [ - "System.NullReferenceException" - ] - } - } - ] - }, - { - "Name": "UnityEngine.Debug", - "Methods": [ + "Types": [ + "System.Decimal" + ] + }, { - "Name": "Log", - "ParamTypes": [ - "System.Object" + "Types": [ + "UnityEngine.Vector3" ] } ] }, { - "Name": "UnityEngine.Assertions.Assert", - "Fields": [ - "raiseExceptions" - ], - "Methods": [ + "Name": "System.IComparable`1", + "GenericParams": [ { - "Name": "AreEqual", - "ParamTypes": [ - "T", - "T" - ], - "GenericParams": [ - { - "Types": [ - "System.String" - ] - }, - { - "Types": [ - "UnityEngine.GameObject" - ] - } + "Types": [ + "System.Boolean" ] - } - ] - }, - { - "Name": "UnityEngine.Collision" - }, - { - "Name": "UnityEngine.Behaviour" - }, - { - "Name": "UnityEngine.MonoBehaviour" - }, - { - "Name": "UnityEngine.AudioSettings", - "Methods": [ + }, { - "Name": "GetDSPBufferSize", - "ParamTypes": [ - "System.Int32", + "Types": [ + "System.Char" + ] + }, + { + "Types": [ + "System.SByte" + ] + }, + { + "Types": [ + "System.Byte" + ] + }, + { + "Types": [ + "System.Int16" + ] + }, + { + "Types": [ + "System.UInt16" + ] + }, + { + "Types": [ "System.Int32" ] + }, + { + "Types": [ + "System.UInt32" + ] + }, + { + "Types": [ + "System.Int64" + ] + }, + { + "Types": [ + "System.UInt64" + ] + }, + { + "Types": [ + "System.Single" + ] + }, + { + "Types": [ + "System.Double" + ] + }, + { + "Types": [ + "System.Decimal" + ] } ] }, { - "Name": "UnityEngine.Networking.NetworkTransport", - "Methods": [ + "Name": " System.Runtime.Serialization.IDeserializationCallback" + }, + { + "Name": "System.Decimal", + "Constructors": [ { - "Name": "GetBroadcastConnectionInfo", "ParamTypes": [ - "System.Int32", - "System.String", - "System.Int32", - "System.Byte" + "System.Double" ] }, { - "Name": "Init", - "ParamTypes": [] + "ParamTypes": [ + "System.UInt64" + ] } ] }, @@ -203,64 +186,28 @@ } ], "Methods": [ - { - "Name": "Set", - "ParamTypes": [ - "System.Single", - "System.Single", - "System.Single" - ] - }, { "Name": "x+y", "ParamTypes": [ "UnityEngine.Vector3", "UnityEngine.Vector3" ] - }, - { - "Name": "-x", - "ParamTypes": [ - "UnityEngine.Vector3" - ] - } - ], - "Properties": [ - { - "Name": "magnitude", - "Get": {} } ] }, { - "Name": "UnityEngine.Matrix4x4", + "Name": "UnityEngine.Object", "Properties": [ { - "Name": "Item", - "Get": { - "ParamTypes": [ - "System.Int32", - "System.Int32" - ] - }, - "Set": { - "ParamTypes": [ - "System.Int32", - "System.Int32", - "System.Single" - ] - } + "Name": "name", + "Get": {}, + "Set": {} } ] }, { - "Name": "UnityEngine.RaycastHit", - "MaxSimultaneous": 1000, + "Name": "UnityEngine.Component", "Properties": [ - { - "Name": "point", - "Get": {} - }, { "Name": "transform", "Get": {} @@ -268,363 +215,130 @@ ] }, { - "Name": "UnityEngine.QueryTriggerInteraction" - }, - { - "Name": "System.Collections.Generic.KeyValuePair`2", - "GenericParams": [ - { - "Types": [ - "System.String", - "System.Double" - ] - } - ], - "Constructors": [ - { - "ParamTypes": [ - "TKey", - "TValue" - ] - } - ], + "Name": "UnityEngine.Transform", "Properties": [ { - "Name": "Key", - "Get": {}, - "Set": {} - }, - { - "Name": "Value", + "Name": "position", "Get": {}, - "Set": {} + "Set": { + "Exceptions": [ + "System.NullReferenceException" + ] + } } ] }, { - "Name": "System.Collections.Generic.List`1", - "GenericParams": [ - { - "Types": [ - "System.String" - ] - } - ], - "Constructors": [ + "Name": "System.Collections.IEnumerator", + "Methods": [ { + "Name": "MoveNext", "ParamTypes": [] } ], "Properties": [ { - "Name": "Item", + "Name": "Current", "Get": {}, "Set": {} } - ], - "Methods": [ - { - "Name": "Add", - "ParamTypes": [ - "T" - ] - } ] }, { - "Name": "System.Collections.Generic.LinkedListNode`1", - "GenericParams": [ - { - "Types": [ - "System.String" - ] - } - ], - "Constructors": [ - { - "ParamTypes": [ - "T" - ] - } - ], - "Properties": [ - { - "Name": "Value", - "Get": {}, - "Set": {} - } - ] + "Name": "System.Runtime.Serialization.ISerializable" }, { - "Name": " System.Runtime.CompilerServices.StrongBox`1", - "GenericParams": [ - { - "Types": [ - "System.String" - ] - } - ], - "Fields": [ - "Value" - ], - "Constructors": [ - { - "ParamTypes": [ - "T" - ] - } - ] + "Name": "System.Runtime.InteropServices._Exception" }, { - "Name": "System.Collections.ObjectModel.Collection`1", - "GenericParams": [ + "Name": "UnityEngine.GameObject", + "Constructors": [ + ], + "Methods": [ { - "Types": [ - "System.Int32" + "Name": "AddComponent", + "ParamTypes": [], + "GenericParams": [ + { + "Types": [ + "MyGame.BaseBallScript" + ] + } ] - } - ] - }, - { - "Name": "System.Collections.ObjectModel.KeyedCollection`2", - "GenericParams": [ + }, { - "Types": [ - "System.String", - "System.Int32" + "Name": "CreatePrimitive", + "ParamTypes": [ + "UnityEngine.PrimitiveType" ] } ] }, { - "Name": "System.Exception", - "Constructors": [ + "Name": "UnityEngine.Debug", + "Methods": [ { + "Name": "Log", "ParamTypes": [ - "System.String" + "System.Object" ] } ] }, { - "Name": "System.SystemException" - }, - { - "Name": "System.NullReferenceException" + "Name": "UnityEngine.Behaviour" }, { - "Name": "UnityEngine.Resolution", + "Name": "UnityEngine.MonoBehaviour", "Properties": [ { - "Name": "width", - "Get": {}, - "Set": {} - }, - { - "Name": "height", - "Get": {}, - "Set": {} - }, - { - "Name": "refreshRate", + "Name": "transform", "Get": {}, "Set": {} } ] }, { - "Name": "UnityEngine.Screen", - "Properties": [ - { - "Name": "resolutions", - "Get": {} - } - ] - }, - { - "Name": "UnityEngine.Ray", + "Name": "System.Exception", "Constructors": [ { "ParamTypes": [ - "UnityEngine.Vector3", - "UnityEngine.Vector3" - ] - } - ] - }, - { - "Name": "UnityEngine.Physics", - "Methods": [ - { - "Name": "RaycastNonAlloc", - "ParamTypes": [ - "UnityEngine.Ray", - "UnityEngine.RaycastHit[]" - ] - }, - { - "Name": "RaycastAll", - "ParamTypes": [ - "UnityEngine.Ray" + "System.String" ] } ] }, { - "Name": "UnityEngine.Color" + "Name": "System.SystemException" }, { - "Name": "UnityEngine.GradientColorKey" + "Name": "System.NullReferenceException" }, { - "Name": "UnityEngine.Gradient", - "Constructors": [ - { - "ParamTypes": [] - } - ], - "Properties": [ - { - "Name": "colorKeys", - "Get": {}, - "Set": {} - } - ] + "Name": "UnityEngine.PrimitiveType" }, { - "Name": "System.AppDomainSetup", - "Constructors": [ - { - "ParamTypes": [] - } - ], + "Name": "UnityEngine.Time", "Properties": [ { - "Name": "AppDomainInitializer", + "Name": "deltaTime", "Get": {}, "Set": {} } ] }, { - "Name": "UnityEngine.Application", - "Events": [ - { - "Name": "onBeforeRender" - } - ] - }, - { - "Name": "UnityEngine.SceneManagement.SceneManager", - "Events": [ + "Name": "MyGame.AbstractBaseBallScript", + "BaseTypes": [ { - "Name": "sceneLoaded" + "BaseName": "MyGame.BaseBallScript", + "DerivedName": "MyGame.BallScript" } ] - }, - { - "Name": "UnityEngine.SceneManagement.Scene" - }, - { - "Name": "UnityEngine.SceneManagement.LoadSceneMode" - } - ], - "MonoBehaviours": [ - { - "Name": "MyGame.MonoBehaviours.TestScript", - "Messages": [ - "Awake", - "OnAnimatorIK", - "OnCollisionEnter", - "Update" - ] } ], "Arrays": [ - { - "Type": "System.Int32" - }, - { - "Type": "System.Single", - "Ranks": [ 1, 2, 3 ] - }, - { - "Type": "System.String" - }, - { - "Type": "UnityEngine.Resolution" - }, - { - "Type": "UnityEngine.RaycastHit" - }, - { - "Type": "UnityEngine.GradientColorKey" - } ], "Delegates": [ - { - "Type": "System.Action" - }, - { - "Type": "System.Action`1", - "GenericParams": [ - { - "Types": [ - "System.Single" - ] - } - ] - }, - { - "Type": "System.Action`2", - "GenericParams": [ - { - "Types": [ - "System.Single", - "System.Single" - ], - "MaxSimultaneous": 100 - } - ] - }, - { - "Type": "System.Func`3", - "GenericParams": [ - { - "Types": [ - "System.Int32", - "System.Single", - "System.Double" - ], - "MaxSimultaneous": 50 - }, - { - "Types": [ - "System.Int16", - "System.Int32", - "System.String" - ], - "MaxSimultaneous": 25 - } - ] - }, - { - "Type": "System.AppDomainInitializer" - }, - { - "Type": "UnityEngine.Events.UnityAction" - }, - { - "Type": "UnityEngine.Events.UnityAction`2", - "GenericParams": [ - { - "Types": [ - "UnityEngine.SceneManagement.Scene", - "UnityEngine.SceneManagement.LoadSceneMode" - ], - "MaxSimultaneous": 10 - } - ] - } ] } \ No newline at end of file diff --git a/Unity/CppSource/Game.cpp.meta b/Unity/CppSource/Game.cpp.meta deleted file mode 100644 index bf03a81..0000000 --- a/Unity/CppSource/Game.cpp.meta +++ /dev/null @@ -1,27 +0,0 @@ -fileFormatVersion: 2 -guid: 5189acf91e865474290ba468798fb338 -timeCreated: 1501907744 -licenseType: Free -PluginImporter: - serializedVersion: 2 - iconMap: {} - executionOrder: {} - isPreloaded: 0 - isOverridable: 0 - platformData: - data: - first: - Any: - second: - enabled: 1 - settings: {} - data: - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - userData: - assetBundleName: - assetBundleVariant: diff --git a/Unity/CppSource/Game/Game.cpp b/Unity/CppSource/Game/Game.cpp deleted file mode 100644 index 4d3c5c5..0000000 --- a/Unity/CppSource/Game/Game.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/// -/// Game-specific code for the native plugin -/// -/// -/// Jackson Dunstan, 2017, http://JacksonDunstan.com -/// -/// -/// MIT -/// - -#include "Bindings.h" - -using namespace System; -using namespace UnityEngine; - -void PrintPlatformDefines(); - -// Called when the plugin is initialized -// This is mostly full of test code. Feel free to remove it all. -void PluginMain() -{ - PrintPlatformDefines(); - Debug::Log(String("Game booted up")); - - GameObject go(String("GameObject with a TestScript")); - go.AddComponent(); -} - -void MyGame::MonoBehaviours::TestScript::Awake() -{ - Debug::Log(String("C++ TestScript Awake")); -} - -void MyGame::MonoBehaviours::TestScript::OnAnimatorIK(int32_t param0) -{ - Debug::Log(String("C++ TestScript OnAnimatorIK")); -} - -void MyGame::MonoBehaviours::TestScript::OnCollisionEnter(UnityEngine::Collision param0) -{ - Debug::Log(String("C++ TestScript OnCollisionEnter")); -} - -void MyGame::MonoBehaviours::TestScript::Update() -{ - static int32_t numCreated = 0; - if (numCreated < 10) - { - GameObject go; - Transform transform = go.GetTransform(); - float comp = (float)numCreated; - Vector3 position(comp, comp*10.0f, comp*100.0f); - transform.SetPosition(position); - numCreated++; - if (numCreated == 10) - { - Debug::Log(String("Done spawning game objects")); - } - } -} - -void PrintPlatformDefines() -{ -#if defined(UNITY_EDITOR) - Debug::Log(String("UNITY_EDITOR")); -#endif -#if defined(UNITY_STANDALONE) - Debug::Log(String("UNITY_STANDALONE")); -#endif -#if defined(UNITY_IOS) - Debug::Log(String("UNITY_IOS")); -#endif -#if defined(UNITY_ANDROID) - Debug::Log(String("UNITY_ANDROID")); -#endif -#if defined(UNITY_EDITOR_WIN) - Debug::Log(String("UNITY_EDITOR_WIN")); -#endif -#if defined(UNITY_EDITOR_OSX) - Debug::Log(String("UNITY_EDITOR_OSX")); -#endif -#if defined(UNITY_EDITOR_LINUX) - Debug::Log(String("UNITY_EDITOR_LINUX")); -#endif -#if defined(UNITY_STANDALONE_OSX) - Debug::Log(String("UNITY_STANDALONE_OSX")); -#endif -#if defined(UNITY_STANDALONE_WIN) - Debug::Log(String("UNITY_STANDALONE_WIN")); -#endif -#if defined(UNITY_STANDALONE_LINUX) - Debug::Log(String("UNITY_STANDALONE_LINUX")); -#endif -} diff --git a/Unity/CppSource/NativeScript/Bindings.cpp b/Unity/CppSource/NativeScript/Bindings.cpp deleted file mode 100644 index 2c42ed2..0000000 --- a/Unity/CppSource/NativeScript/Bindings.cpp +++ /dev/null @@ -1,8435 +0,0 @@ -/// -/// Internals of the bindings between native and .NET code. -/// Game code shouldn't go here. -/// -/// -/// Jackson Dunstan, 2017, http://JacksonDunstan.com -/// -/// -/// MIT -/// - -// Type definitions -#include "Bindings.h" - -// For assert() -#include - -// For int32_t, etc. -#include - -// For malloc(), etc. -#include - -// Macro to put before functions that need to be exposed to C# -#ifdef _WIN32 - #define DLLEXPORT extern "C" __declspec(dllexport) -#else - #define DLLEXPORT extern "C" -#endif - -//////////////////////////////////////////////////////////////// -// C# functions for C++ to call -//////////////////////////////////////////////////////////////// - -namespace Plugin -{ - void (*ReleaseObject)(int32_t handle); - int32_t (*StringNew)(const char* chars); - void (*SetException)(int32_t handle); - int32_t (*ArrayGetLength)(int32_t handle); - int32_t (*ArrayGetRank)(int32_t handle); - - /*BEGIN FUNCTION POINTERS*/ - int32_t (*SystemDiagnosticsStopwatchConstructor)(); - int64_t (*SystemDiagnosticsStopwatchPropertyGetElapsedMilliseconds)(int32_t thisHandle); - void (*SystemDiagnosticsStopwatchMethodStart)(int32_t thisHandle); - void (*SystemDiagnosticsStopwatchMethodReset)(int32_t thisHandle); - int32_t (*UnityEngineObjectPropertyGetName)(int32_t thisHandle); - void (*UnityEngineObjectPropertySetName)(int32_t thisHandle, int32_t valueHandle); - System::Boolean (*UnityEngineObjectMethodop_EqualityUnityEngineObject_UnityEngineObject)(int32_t xHandle, int32_t yHandle); - System::Boolean (*UnityEngineObjectMethodop_ImplicitUnityEngineObject)(int32_t existsHandle); - int32_t (*UnityEngineGameObjectConstructor)(); - int32_t (*UnityEngineGameObjectConstructorSystemString)(int32_t nameHandle); - int32_t (*UnityEngineGameObjectPropertyGetTransform)(int32_t thisHandle); - int32_t (*UnityEngineGameObjectMethodAddComponentMyGameMonoBehavioursTestScript)(int32_t thisHandle); - int32_t (*UnityEngineComponentPropertyGetTransform)(int32_t thisHandle); - UnityEngine::Vector3 (*UnityEngineTransformPropertyGetPosition)(int32_t thisHandle); - void (*UnityEngineTransformPropertySetPosition)(int32_t thisHandle, UnityEngine::Vector3& value); - void (*UnityEngineDebugMethodLogSystemObject)(int32_t messageHandle); - System::Boolean (*UnityEngineAssertionsAssertFieldGetRaiseExceptions)(); - void (*UnityEngineAssertionsAssertFieldSetRaiseExceptions)(System::Boolean value); - void (*UnityEngineAssertionsAssertMethodAreEqualSystemStringSystemString_SystemString)(int32_t expectedHandle, int32_t actualHandle); - void (*UnityEngineAssertionsAssertMethodAreEqualUnityEngineGameObjectUnityEngineGameObject_UnityEngineGameObject)(int32_t expectedHandle, int32_t actualHandle); - void (*UnityEngineAudioSettingsMethodGetDSPBufferSizeSystemInt32_SystemInt32)(int32_t* bufferLength, int32_t* numBuffers); - void (*UnityEngineNetworkingNetworkTransportMethodGetBroadcastConnectionInfoSystemInt32_SystemString_SystemInt32_SystemByte)(int32_t hostId, int32_t* addressHandle, int32_t* port, uint8_t* error); - void (*UnityEngineNetworkingNetworkTransportMethodInit)(); - UnityEngine::Vector3 (*UnityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingle)(float x, float y, float z); - float (*UnityEngineVector3PropertyGetMagnitude)(UnityEngine::Vector3* thiz); - void (*UnityEngineVector3MethodSetSystemSingle_SystemSingle_SystemSingle)(UnityEngine::Vector3* thiz, float newX, float newY, float newZ); - UnityEngine::Vector3 (*UnityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3)(UnityEngine::Vector3& a, UnityEngine::Vector3& b); - UnityEngine::Vector3 (*UnityEngineVector3Methodop_UnaryNegationUnityEngineVector3)(UnityEngine::Vector3& a); - int32_t (*BoxVector3)(UnityEngine::Vector3& val); - UnityEngine::Vector3 (*UnboxVector3)(int32_t valHandle); - float (*UnityEngineMatrix4x4PropertyGetItem)(UnityEngine::Matrix4x4* thiz, int32_t row, int32_t column); - void (*UnityEngineMatrix4x4PropertySetItem)(UnityEngine::Matrix4x4* thiz, int32_t row, int32_t column, float value); - int32_t (*BoxMatrix4x4)(UnityEngine::Matrix4x4& val); - UnityEngine::Matrix4x4 (*UnboxMatrix4x4)(int32_t valHandle); - void (*ReleaseUnityEngineRaycastHit)(int32_t handle); - UnityEngine::Vector3 (*UnityEngineRaycastHitPropertyGetPoint)(int32_t thisHandle); - void (*UnityEngineRaycastHitPropertySetPoint)(int32_t thisHandle, UnityEngine::Vector3& value); - int32_t (*UnityEngineRaycastHitPropertyGetTransform)(int32_t thisHandle); - int32_t (*BoxRaycastHit)(int32_t valHandle); - int32_t (*UnboxRaycastHit)(int32_t valHandle); - int32_t (*BoxQueryTriggerInteraction)(UnityEngine::QueryTriggerInteraction val); - UnityEngine::QueryTriggerInteraction (*UnboxQueryTriggerInteraction)(int32_t valHandle); - void (*ReleaseSystemCollectionsGenericKeyValuePairSystemString_SystemDouble)(int32_t handle); - int32_t (*SystemCollectionsGenericKeyValuePairSystemString_SystemDoubleConstructorSystemString_SystemDouble)(int32_t keyHandle, double value); - int32_t (*SystemCollectionsGenericKeyValuePairSystemString_SystemDoublePropertyGetKey)(int32_t thisHandle); - double (*SystemCollectionsGenericKeyValuePairSystemString_SystemDoublePropertyGetValue)(int32_t thisHandle); - int32_t (*BoxKeyValuePairSystemString_SystemDouble)(int32_t valHandle); - int32_t (*UnboxKeyValuePairSystemString_SystemDouble)(int32_t valHandle); - int32_t (*SystemCollectionsGenericListSystemStringConstructor)(); - int32_t (*SystemCollectionsGenericListSystemStringPropertyGetItem)(int32_t thisHandle, int32_t index); - void (*SystemCollectionsGenericListSystemStringPropertySetItem)(int32_t thisHandle, int32_t index, int32_t valueHandle); - void (*SystemCollectionsGenericListSystemStringMethodAddSystemString)(int32_t thisHandle, int32_t itemHandle); - int32_t (*SystemCollectionsGenericLinkedListNodeSystemStringConstructorSystemString)(int32_t valueHandle); - int32_t (*SystemCollectionsGenericLinkedListNodeSystemStringPropertyGetValue)(int32_t thisHandle); - void (*SystemCollectionsGenericLinkedListNodeSystemStringPropertySetValue)(int32_t thisHandle, int32_t valueHandle); - int32_t (*SystemRuntimeCompilerServicesStrongBoxSystemStringConstructorSystemString)(int32_t valueHandle); - int32_t (*SystemRuntimeCompilerServicesStrongBoxSystemStringFieldGetValue)(int32_t thisHandle); - void (*SystemRuntimeCompilerServicesStrongBoxSystemStringFieldSetValue)(int32_t thisHandle, int32_t valueHandle); - int32_t (*SystemExceptionConstructorSystemString)(int32_t messageHandle); - int32_t (*UnityEngineResolutionPropertyGetWidth)(UnityEngine::Resolution* thiz); - void (*UnityEngineResolutionPropertySetWidth)(UnityEngine::Resolution* thiz, int32_t value); - int32_t (*UnityEngineResolutionPropertyGetHeight)(UnityEngine::Resolution* thiz); - void (*UnityEngineResolutionPropertySetHeight)(UnityEngine::Resolution* thiz, int32_t value); - int32_t (*UnityEngineResolutionPropertyGetRefreshRate)(UnityEngine::Resolution* thiz); - void (*UnityEngineResolutionPropertySetRefreshRate)(UnityEngine::Resolution* thiz, int32_t value); - int32_t (*BoxResolution)(UnityEngine::Resolution& val); - UnityEngine::Resolution (*UnboxResolution)(int32_t valHandle); - int32_t (*UnityEngineScreenPropertyGetResolutions)(); - UnityEngine::Ray (*UnityEngineRayConstructorUnityEngineVector3_UnityEngineVector3)(UnityEngine::Vector3& origin, UnityEngine::Vector3& direction); - int32_t (*BoxRay)(UnityEngine::Ray& val); - UnityEngine::Ray (*UnboxRay)(int32_t valHandle); - int32_t (*UnityEnginePhysicsMethodRaycastNonAllocUnityEngineRay_UnityEngineRaycastHit)(UnityEngine::Ray& ray, int32_t resultsHandle); - int32_t (*UnityEnginePhysicsMethodRaycastAllUnityEngineRay)(UnityEngine::Ray& ray); - int32_t (*BoxColor)(UnityEngine::Color& val); - UnityEngine::Color (*UnboxColor)(int32_t valHandle); - int32_t (*BoxGradientColorKey)(UnityEngine::GradientColorKey& val); - UnityEngine::GradientColorKey (*UnboxGradientColorKey)(int32_t valHandle); - int32_t (*UnityEngineGradientConstructor)(); - int32_t (*UnityEngineGradientPropertyGetColorKeys)(int32_t thisHandle); - void (*UnityEngineGradientPropertySetColorKeys)(int32_t thisHandle, int32_t valueHandle); - int32_t (*SystemAppDomainSetupConstructor)(); - int32_t (*SystemAppDomainSetupPropertyGetAppDomainInitializer)(int32_t thisHandle); - void (*SystemAppDomainSetupPropertySetAppDomainInitializer)(int32_t thisHandle, int32_t valueHandle); - void (*UnityEngineApplicationAddEventOnBeforeRender)(int32_t delHandle); - void (*UnityEngineApplicationRemoveEventOnBeforeRender)(int32_t delHandle); - void (*UnityEngineSceneManagementSceneManagerAddEventSceneLoaded)(int32_t delHandle); - void (*UnityEngineSceneManagementSceneManagerRemoveEventSceneLoaded)(int32_t delHandle); - int32_t (*BoxScene)(UnityEngine::SceneManagement::Scene& val); - UnityEngine::SceneManagement::Scene (*UnboxScene)(int32_t valHandle); - int32_t (*BoxLoadSceneMode)(UnityEngine::SceneManagement::LoadSceneMode val); - UnityEngine::SceneManagement::LoadSceneMode (*UnboxLoadSceneMode)(int32_t valHandle); - int32_t (*BoxBoolean)(System::Boolean val); - System::Boolean (*UnboxBoolean)(int32_t valHandle); - int32_t (*BoxSByte)(int8_t val); - int8_t (*UnboxSByte)(int32_t valHandle); - int32_t (*BoxByte)(uint8_t val); - uint8_t (*UnboxByte)(int32_t valHandle); - int32_t (*BoxInt16)(int16_t val); - int16_t (*UnboxInt16)(int32_t valHandle); - int32_t (*BoxUInt16)(uint16_t val); - uint16_t (*UnboxUInt16)(int32_t valHandle); - int32_t (*BoxInt32)(int32_t val); - int32_t (*UnboxInt32)(int32_t valHandle); - int32_t (*BoxUInt32)(uint32_t val); - uint32_t (*UnboxUInt32)(int32_t valHandle); - int32_t (*BoxInt64)(int64_t val); - int64_t (*UnboxInt64)(int32_t valHandle); - int32_t (*BoxUInt64)(uint64_t val); - uint64_t (*UnboxUInt64)(int32_t valHandle); - int32_t (*BoxChar)(System::Char val); - System::Char (*UnboxChar)(int32_t valHandle); - int32_t (*BoxSingle)(float val); - float (*UnboxSingle)(int32_t valHandle); - int32_t (*BoxDouble)(double val); - double (*UnboxDouble)(int32_t valHandle); - int32_t (*SystemSystemInt32Array1Constructor1)(int32_t length0); - int32_t (*SystemInt32Array1GetItem1)(int32_t thisHandle, int32_t index0); - int32_t (*SystemInt32Array1SetItem1)(int32_t thisHandle, int32_t index0, int32_t item); - int32_t (*SystemSystemSingleArray1Constructor1)(int32_t length0); - float (*SystemSingleArray1GetItem1)(int32_t thisHandle, int32_t index0); - int32_t (*SystemSingleArray1SetItem1)(int32_t thisHandle, int32_t index0, float item); - int32_t (*SystemSystemSingleArray2Constructor2)(int32_t length0, int32_t length1); - int32_t (*SystemSystemSingleArray2GetLength2)(int32_t thisHandle, int32_t dimension); - float (*SystemSingleArray2GetItem2)(int32_t thisHandle, int32_t index0, int32_t index1); - int32_t (*SystemSingleArray2SetItem2)(int32_t thisHandle, int32_t index0, int32_t index1, float item); - int32_t (*SystemSystemSingleArray3Constructor3)(int32_t length0, int32_t length1, int32_t length2); - int32_t (*SystemSystemSingleArray3GetLength3)(int32_t thisHandle, int32_t dimension); - float (*SystemSingleArray3GetItem3)(int32_t thisHandle, int32_t index0, int32_t index1, int32_t index2); - int32_t (*SystemSingleArray3SetItem3)(int32_t thisHandle, int32_t index0, int32_t index1, int32_t index2, float item); - int32_t (*SystemSystemStringArray1Constructor1)(int32_t length0); - int32_t (*SystemStringArray1GetItem1)(int32_t thisHandle, int32_t index0); - int32_t (*SystemStringArray1SetItem1)(int32_t thisHandle, int32_t index0, int32_t itemHandle); - int32_t (*UnityEngineUnityEngineResolutionArray1Constructor1)(int32_t length0); - UnityEngine::Resolution (*UnityEngineResolutionArray1GetItem1)(int32_t thisHandle, int32_t index0); - int32_t (*UnityEngineResolutionArray1SetItem1)(int32_t thisHandle, int32_t index0, UnityEngine::Resolution& item); - int32_t (*UnityEngineUnityEngineRaycastHitArray1Constructor1)(int32_t length0); - int32_t (*UnityEngineRaycastHitArray1GetItem1)(int32_t thisHandle, int32_t index0); - int32_t (*UnityEngineRaycastHitArray1SetItem1)(int32_t thisHandle, int32_t index0, int32_t itemHandle); - int32_t (*UnityEngineUnityEngineGradientColorKeyArray1Constructor1)(int32_t length0); - UnityEngine::GradientColorKey (*UnityEngineGradientColorKeyArray1GetItem1)(int32_t thisHandle, int32_t index0); - int32_t (*UnityEngineGradientColorKeyArray1SetItem1)(int32_t thisHandle, int32_t index0, UnityEngine::GradientColorKey& item); - void (*ReleaseSystemAction)(int32_t handle, int32_t classHandle); - void (*SystemActionConstructor)(int32_t cppHandle, int32_t* handle, int32_t* classHandle); - void (*SystemActionInvoke)(int32_t thisHandle); - void (*SystemActionAdd)(int32_t thisHandle, int32_t delHandle); - void (*SystemActionRemove)(int32_t thisHandle, int32_t delHandle); - void (*ReleaseSystemActionSystemSingle)(int32_t handle, int32_t classHandle); - void (*SystemActionSystemSingleConstructor)(int32_t cppHandle, int32_t* handle, int32_t* classHandle); - void (*SystemActionSystemSingleInvoke)(int32_t thisHandle, float obj); - void (*SystemActionSystemSingleAdd)(int32_t thisHandle, int32_t delHandle); - void (*SystemActionSystemSingleRemove)(int32_t thisHandle, int32_t delHandle); - void (*ReleaseSystemActionSystemSingle_SystemSingle)(int32_t handle, int32_t classHandle); - void (*SystemActionSystemSingle_SystemSingleConstructor)(int32_t cppHandle, int32_t* handle, int32_t* classHandle); - void (*SystemActionSystemSingle_SystemSingleInvoke)(int32_t thisHandle, float arg1, float arg2); - void (*SystemActionSystemSingle_SystemSingleAdd)(int32_t thisHandle, int32_t delHandle); - void (*SystemActionSystemSingle_SystemSingleRemove)(int32_t thisHandle, int32_t delHandle); - void (*ReleaseSystemFuncSystemInt32_SystemSingle_SystemDouble)(int32_t handle, int32_t classHandle); - void (*SystemFuncSystemInt32_SystemSingle_SystemDoubleConstructor)(int32_t cppHandle, int32_t* handle, int32_t* classHandle); - double (*SystemFuncSystemInt32_SystemSingle_SystemDoubleInvoke)(int32_t thisHandle, int32_t arg1, float arg2); - void (*SystemFuncSystemInt32_SystemSingle_SystemDoubleAdd)(int32_t thisHandle, int32_t delHandle); - void (*SystemFuncSystemInt32_SystemSingle_SystemDoubleRemove)(int32_t thisHandle, int32_t delHandle); - void (*ReleaseSystemFuncSystemInt16_SystemInt32_SystemString)(int32_t handle, int32_t classHandle); - void (*SystemFuncSystemInt16_SystemInt32_SystemStringConstructor)(int32_t cppHandle, int32_t* handle, int32_t* classHandle); - int32_t (*SystemFuncSystemInt16_SystemInt32_SystemStringInvoke)(int32_t thisHandle, int16_t arg1, int32_t arg2); - void (*SystemFuncSystemInt16_SystemInt32_SystemStringAdd)(int32_t thisHandle, int32_t delHandle); - void (*SystemFuncSystemInt16_SystemInt32_SystemStringRemove)(int32_t thisHandle, int32_t delHandle); - void (*ReleaseSystemAppDomainInitializer)(int32_t handle, int32_t classHandle); - void (*SystemAppDomainInitializerConstructor)(int32_t cppHandle, int32_t* handle, int32_t* classHandle); - void (*SystemAppDomainInitializerInvoke)(int32_t thisHandle, int32_t argsHandle); - void (*SystemAppDomainInitializerAdd)(int32_t thisHandle, int32_t delHandle); - void (*SystemAppDomainInitializerRemove)(int32_t thisHandle, int32_t delHandle); - void (*ReleaseUnityEngineEventsUnityAction)(int32_t handle, int32_t classHandle); - void (*UnityEngineEventsUnityActionConstructor)(int32_t cppHandle, int32_t* handle, int32_t* classHandle); - void (*UnityEngineEventsUnityActionInvoke)(int32_t thisHandle); - void (*UnityEngineEventsUnityActionAdd)(int32_t thisHandle, int32_t delHandle); - void (*UnityEngineEventsUnityActionRemove)(int32_t thisHandle, int32_t delHandle); - void (*ReleaseUnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneMode)(int32_t handle, int32_t classHandle); - void (*UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeConstructor)(int32_t cppHandle, int32_t* handle, int32_t* classHandle); - void (*UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeInvoke)(int32_t thisHandle, UnityEngine::SceneManagement::Scene& arg0, UnityEngine::SceneManagement::LoadSceneMode arg1); - void (*UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeAdd)(int32_t thisHandle, int32_t delHandle); - void (*UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeRemove)(int32_t thisHandle, int32_t delHandle); - /*END FUNCTION POINTERS*/ -} - -//////////////////////////////////////////////////////////////// -// Reference counting of managed objects -//////////////////////////////////////////////////////////////// - -namespace Plugin -{ - int32_t RefCountsLenClass; - int32_t* RefCountsClass; - - void ReferenceManagedClass(int32_t handle) - { - assert(handle >= 0 && handle < RefCountsLenClass); - if (handle != 0) - { - RefCountsClass[handle]++; - } - } - - void DereferenceManagedClass(int32_t handle) - { - assert(handle >= 0 && handle < RefCountsLenClass); - if (handle != 0) - { - int32_t numRemain = --RefCountsClass[handle]; - if (numRemain == 0) - { - ReleaseObject(handle); - } - } - } - - bool DereferenceManagedClassNoRelease(int32_t handle) - { - assert(handle >= 0 && handle < RefCountsLenClass); - if (handle != 0) - { - int32_t numRemain = --RefCountsClass[handle]; - if (numRemain == 0) - { - return true; - } - } - return false; - } - - /*BEGIN GLOBAL STATE AND FUNCTIONS*/ - int32_t RefCountsLenUnityEngineRaycastHit; - int32_t* RefCountsUnityEngineRaycastHit; - - void ReferenceManagedUnityEngineRaycastHit(int32_t handle) - { - assert(handle >= 0 && handle < RefCountsLenUnityEngineRaycastHit); - if (handle != 0) - { - RefCountsUnityEngineRaycastHit[handle]++; - } - } - - void DereferenceManagedUnityEngineRaycastHit(int32_t handle) - { - assert(handle >= 0 && handle < RefCountsLenUnityEngineRaycastHit); - if (handle != 0) - { - int32_t numRemain = --RefCountsUnityEngineRaycastHit[handle]; - if (numRemain == 0) - { - ReleaseUnityEngineRaycastHit(handle); - } - } - } - - int32_t RefCountsLenSystemCollectionsGenericKeyValuePairSystemString_SystemDouble; - int32_t* RefCountsSystemCollectionsGenericKeyValuePairSystemString_SystemDouble; - - void ReferenceManagedSystemCollectionsGenericKeyValuePairSystemString_SystemDouble(int32_t handle) - { - assert(handle >= 0 && handle < RefCountsLenSystemCollectionsGenericKeyValuePairSystemString_SystemDouble); - if (handle != 0) - { - RefCountsSystemCollectionsGenericKeyValuePairSystemString_SystemDouble[handle]++; - } - } - - void DereferenceManagedSystemCollectionsGenericKeyValuePairSystemString_SystemDouble(int32_t handle) - { - assert(handle >= 0 && handle < RefCountsLenSystemCollectionsGenericKeyValuePairSystemString_SystemDouble); - if (handle != 0) - { - int32_t numRemain = --RefCountsSystemCollectionsGenericKeyValuePairSystemString_SystemDouble[handle]; - if (numRemain == 0) - { - ReleaseSystemCollectionsGenericKeyValuePairSystemString_SystemDouble(handle); - } - } - } - - int32_t SystemActionFreeListSize; - System::Action** SystemActionFreeList; - System::Action** NextFreeSystemAction; - - int32_t StoreSystemAction(System::Action* del) - { - assert(NextFreeSystemAction != nullptr); - System::Action** pNext = NextFreeSystemAction; - NextFreeSystemAction = (System::Action**)*pNext; - *pNext = del; - return (int32_t)(pNext - SystemActionFreeList); - } - - System::Action* GetSystemAction(int32_t handle) - { - assert(handle >= 0 && handle < SystemActionFreeListSize); - return SystemActionFreeList[handle]; - } - - void RemoveSystemAction(int32_t handle) - { - System::Action** pRelease = SystemActionFreeList + handle; - *pRelease = (System::Action*)NextFreeSystemAction; - NextFreeSystemAction = pRelease; - } - int32_t SystemActionSystemSingleFreeListSize; - System::Action1** SystemActionSystemSingleFreeList; - System::Action1** NextFreeSystemActionSystemSingle; - - int32_t StoreSystemActionSystemSingle(System::Action1* del) - { - assert(NextFreeSystemActionSystemSingle != nullptr); - System::Action1** pNext = NextFreeSystemActionSystemSingle; - NextFreeSystemActionSystemSingle = (System::Action1**)*pNext; - *pNext = del; - return (int32_t)(pNext - SystemActionSystemSingleFreeList); - } - - System::Action1* GetSystemActionSystemSingle(int32_t handle) - { - assert(handle >= 0 && handle < SystemActionSystemSingleFreeListSize); - return SystemActionSystemSingleFreeList[handle]; - } - - void RemoveSystemActionSystemSingle(int32_t handle) - { - System::Action1** pRelease = SystemActionSystemSingleFreeList + handle; - *pRelease = (System::Action1*)NextFreeSystemActionSystemSingle; - NextFreeSystemActionSystemSingle = pRelease; - } - int32_t SystemActionSystemSingle_SystemSingleFreeListSize; - System::Action2** SystemActionSystemSingle_SystemSingleFreeList; - System::Action2** NextFreeSystemActionSystemSingle_SystemSingle; - - int32_t StoreSystemActionSystemSingle_SystemSingle(System::Action2* del) - { - assert(NextFreeSystemActionSystemSingle_SystemSingle != nullptr); - System::Action2** pNext = NextFreeSystemActionSystemSingle_SystemSingle; - NextFreeSystemActionSystemSingle_SystemSingle = (System::Action2**)*pNext; - *pNext = del; - return (int32_t)(pNext - SystemActionSystemSingle_SystemSingleFreeList); - } - - System::Action2* GetSystemActionSystemSingle_SystemSingle(int32_t handle) - { - assert(handle >= 0 && handle < SystemActionSystemSingle_SystemSingleFreeListSize); - return SystemActionSystemSingle_SystemSingleFreeList[handle]; - } - - void RemoveSystemActionSystemSingle_SystemSingle(int32_t handle) - { - System::Action2** pRelease = SystemActionSystemSingle_SystemSingleFreeList + handle; - *pRelease = (System::Action2*)NextFreeSystemActionSystemSingle_SystemSingle; - NextFreeSystemActionSystemSingle_SystemSingle = pRelease; - } - int32_t SystemFuncSystemInt32_SystemSingle_SystemDoubleFreeListSize; - System::Func3** SystemFuncSystemInt32_SystemSingle_SystemDoubleFreeList; - System::Func3** NextFreeSystemFuncSystemInt32_SystemSingle_SystemDouble; - - int32_t StoreSystemFuncSystemInt32_SystemSingle_SystemDouble(System::Func3* del) - { - assert(NextFreeSystemFuncSystemInt32_SystemSingle_SystemDouble != nullptr); - System::Func3** pNext = NextFreeSystemFuncSystemInt32_SystemSingle_SystemDouble; - NextFreeSystemFuncSystemInt32_SystemSingle_SystemDouble = (System::Func3**)*pNext; - *pNext = del; - return (int32_t)(pNext - SystemFuncSystemInt32_SystemSingle_SystemDoubleFreeList); - } - - System::Func3* GetSystemFuncSystemInt32_SystemSingle_SystemDouble(int32_t handle) - { - assert(handle >= 0 && handle < SystemFuncSystemInt32_SystemSingle_SystemDoubleFreeListSize); - return SystemFuncSystemInt32_SystemSingle_SystemDoubleFreeList[handle]; - } - - void RemoveSystemFuncSystemInt32_SystemSingle_SystemDouble(int32_t handle) - { - System::Func3** pRelease = SystemFuncSystemInt32_SystemSingle_SystemDoubleFreeList + handle; - *pRelease = (System::Func3*)NextFreeSystemFuncSystemInt32_SystemSingle_SystemDouble; - NextFreeSystemFuncSystemInt32_SystemSingle_SystemDouble = pRelease; - } - int32_t SystemFuncSystemInt16_SystemInt32_SystemStringFreeListSize; - System::Func3** SystemFuncSystemInt16_SystemInt32_SystemStringFreeList; - System::Func3** NextFreeSystemFuncSystemInt16_SystemInt32_SystemString; - - int32_t StoreSystemFuncSystemInt16_SystemInt32_SystemString(System::Func3* del) - { - assert(NextFreeSystemFuncSystemInt16_SystemInt32_SystemString != nullptr); - System::Func3** pNext = NextFreeSystemFuncSystemInt16_SystemInt32_SystemString; - NextFreeSystemFuncSystemInt16_SystemInt32_SystemString = (System::Func3**)*pNext; - *pNext = del; - return (int32_t)(pNext - SystemFuncSystemInt16_SystemInt32_SystemStringFreeList); - } - - System::Func3* GetSystemFuncSystemInt16_SystemInt32_SystemString(int32_t handle) - { - assert(handle >= 0 && handle < SystemFuncSystemInt16_SystemInt32_SystemStringFreeListSize); - return SystemFuncSystemInt16_SystemInt32_SystemStringFreeList[handle]; - } - - void RemoveSystemFuncSystemInt16_SystemInt32_SystemString(int32_t handle) - { - System::Func3** pRelease = SystemFuncSystemInt16_SystemInt32_SystemStringFreeList + handle; - *pRelease = (System::Func3*)NextFreeSystemFuncSystemInt16_SystemInt32_SystemString; - NextFreeSystemFuncSystemInt16_SystemInt32_SystemString = pRelease; - } - int32_t SystemAppDomainInitializerFreeListSize; - System::AppDomainInitializer** SystemAppDomainInitializerFreeList; - System::AppDomainInitializer** NextFreeSystemAppDomainInitializer; - - int32_t StoreSystemAppDomainInitializer(System::AppDomainInitializer* del) - { - assert(NextFreeSystemAppDomainInitializer != nullptr); - System::AppDomainInitializer** pNext = NextFreeSystemAppDomainInitializer; - NextFreeSystemAppDomainInitializer = (System::AppDomainInitializer**)*pNext; - *pNext = del; - return (int32_t)(pNext - SystemAppDomainInitializerFreeList); - } - - System::AppDomainInitializer* GetSystemAppDomainInitializer(int32_t handle) - { - assert(handle >= 0 && handle < SystemAppDomainInitializerFreeListSize); - return SystemAppDomainInitializerFreeList[handle]; - } - - void RemoveSystemAppDomainInitializer(int32_t handle) - { - System::AppDomainInitializer** pRelease = SystemAppDomainInitializerFreeList + handle; - *pRelease = (System::AppDomainInitializer*)NextFreeSystemAppDomainInitializer; - NextFreeSystemAppDomainInitializer = pRelease; - } - int32_t UnityEngineEventsUnityActionFreeListSize; - UnityEngine::Events::UnityAction** UnityEngineEventsUnityActionFreeList; - UnityEngine::Events::UnityAction** NextFreeUnityEngineEventsUnityAction; - - int32_t StoreUnityEngineEventsUnityAction(UnityEngine::Events::UnityAction* del) - { - assert(NextFreeUnityEngineEventsUnityAction != nullptr); - UnityEngine::Events::UnityAction** pNext = NextFreeUnityEngineEventsUnityAction; - NextFreeUnityEngineEventsUnityAction = (UnityEngine::Events::UnityAction**)*pNext; - *pNext = del; - return (int32_t)(pNext - UnityEngineEventsUnityActionFreeList); - } - - UnityEngine::Events::UnityAction* GetUnityEngineEventsUnityAction(int32_t handle) - { - assert(handle >= 0 && handle < UnityEngineEventsUnityActionFreeListSize); - return UnityEngineEventsUnityActionFreeList[handle]; - } - - void RemoveUnityEngineEventsUnityAction(int32_t handle) - { - UnityEngine::Events::UnityAction** pRelease = UnityEngineEventsUnityActionFreeList + handle; - *pRelease = (UnityEngine::Events::UnityAction*)NextFreeUnityEngineEventsUnityAction; - NextFreeUnityEngineEventsUnityAction = pRelease; - } - int32_t UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeFreeListSize; - UnityEngine::Events::UnityAction2** UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeFreeList; - UnityEngine::Events::UnityAction2** NextFreeUnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneMode; - - int32_t StoreUnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneMode(UnityEngine::Events::UnityAction2* del) - { - assert(NextFreeUnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneMode != nullptr); - UnityEngine::Events::UnityAction2** pNext = NextFreeUnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneMode; - NextFreeUnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneMode = (UnityEngine::Events::UnityAction2**)*pNext; - *pNext = del; - return (int32_t)(pNext - UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeFreeList); - } - - UnityEngine::Events::UnityAction2* GetUnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneMode(int32_t handle) - { - assert(handle >= 0 && handle < UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeFreeListSize); - return UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeFreeList[handle]; - } - - void RemoveUnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneMode(int32_t handle) - { - UnityEngine::Events::UnityAction2** pRelease = UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeFreeList + handle; - *pRelease = (UnityEngine::Events::UnityAction2*)NextFreeUnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneMode; - NextFreeUnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneMode = pRelease; - } - - /*END GLOBAL STATE AND FUNCTIONS*/ -} - -namespace Plugin -{ - // An unhandled exception caused by C++ calling into C# - System::Exception* unhandledCsharpException = nullptr; -} - -//////////////////////////////////////////////////////////////// -// Mirrors of C# types. These wrap the C# functions to present -// a similiar API as in C#. -//////////////////////////////////////////////////////////////// - -namespace System -{ - Object::Object(Plugin::InternalUse iu, int32_t handle) - : Handle(handle) - { - } - - Object::Object(std::nullptr_t n) - : Handle(0) - { - } - - bool Object::operator==(std::nullptr_t other) const - { - return Handle == 0; - } - - bool Object::operator!=(std::nullptr_t other) const - { - return Handle != 0; - } - - void Object::ThrowReferenceToThis() - { - throw *this; - } - - ValueType::ValueType(Plugin::InternalUse iu, int32_t handle) - { - Handle = handle; - } - - ValueType::ValueType(std::nullptr_t n) - { - Handle = 0; - } - - String::String(std::nullptr_t n) - : Object(Plugin::InternalUse::Only, 0) - { - } - - String::String(Plugin::InternalUse iu, int32_t handle) - : Object(iu, handle) - { - if (handle) - { - Plugin::ReferenceManagedClass(handle); - } - } - - String::String(const String& other) - : Object(Plugin::InternalUse::Only, other.Handle) - { - if (Handle) - { - Plugin::ReferenceManagedClass(Handle); - } - } - - String::String(String&& other) - : Object(Plugin::InternalUse::Only, other.Handle) - { - other.Handle = 0; - } - - String::~String() - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - } - - String& String::operator=(const String& other) - { - if (Handle != other.Handle) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - } - Handle = other.Handle; - if (Handle) - { - Plugin::ReferenceManagedClass(Handle); - } - } - return *this; - } - - String& String::operator=(std::nullptr_t other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - return *this; - } - - String& String::operator=(String&& other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - } - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - String::String() - : Object(nullptr) - { - } - - String::String(const char* chars) - : Object(Plugin::InternalUse::Only, Plugin::StringNew(chars)) - { - } - - Array::Array(Plugin::InternalUse iu, int32_t handle) - : Object(iu, handle) - { - } - - Array::Array(std::nullptr_t n) - : Object(Plugin::InternalUse::Only, 0) - { - } - - int32_t Array::GetLength() - { - return Plugin::ArrayGetLength(Handle); - } - - int32_t Array::GetRank() - { - return Plugin::ArrayGetRank(Handle); - } -} - -/*BEGIN METHOD DEFINITIONS*/ -namespace System -{ - namespace Diagnostics - { - Stopwatch::Stopwatch(std::nullptr_t n) - : Stopwatch(Plugin::InternalUse::Only, 0) - { - } - - Stopwatch::Stopwatch(Plugin::InternalUse iu, int32_t handle) - : System::Object(iu, handle) - { - if (handle) - { - Plugin::ReferenceManagedClass(handle); - } - } - - Stopwatch::Stopwatch(const Stopwatch& other) - : Stopwatch(Plugin::InternalUse::Only, other.Handle) - { - } - - Stopwatch::Stopwatch(Stopwatch&& other) - : Stopwatch(Plugin::InternalUse::Only, other.Handle) - { - other.Handle = 0; - } - - Stopwatch::~Stopwatch() - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - } - - Stopwatch& Stopwatch::operator=(const Stopwatch& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedClass(this->Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedClass(this->Handle); - } - return *this; - } - - Stopwatch& Stopwatch::operator=(std::nullptr_t other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - return *this; - } - - Stopwatch& Stopwatch::operator=(Stopwatch&& other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - } - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool Stopwatch::operator==(const Stopwatch& other) const - { - return Handle == other.Handle; - } - - bool Stopwatch::operator!=(const Stopwatch& other) const - { - return Handle != other.Handle; - } - - Stopwatch::Stopwatch() - : System::Object(nullptr) - { - auto returnValue = Plugin::SystemDiagnosticsStopwatchConstructor(); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - Handle = returnValue; - if (returnValue) - { - Plugin::ReferenceManagedClass(returnValue); - } - } - - int64_t Stopwatch::GetElapsedMilliseconds() - { - auto returnValue = Plugin::SystemDiagnosticsStopwatchPropertyGetElapsedMilliseconds(Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnValue; - } - - void Stopwatch::Start() - { - Plugin::SystemDiagnosticsStopwatchMethodStart(Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - void Stopwatch::Reset() - { - Plugin::SystemDiagnosticsStopwatchMethodReset(Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - } -} - -namespace UnityEngine -{ - Object::Object(std::nullptr_t n) - : Object(Plugin::InternalUse::Only, 0) - { - } - - Object::Object(Plugin::InternalUse iu, int32_t handle) - : System::Object(iu, handle) - { - if (handle) - { - Plugin::ReferenceManagedClass(handle); - } - } - - Object::Object(const Object& other) - : Object(Plugin::InternalUse::Only, other.Handle) - { - } - - Object::Object(Object&& other) - : Object(Plugin::InternalUse::Only, other.Handle) - { - other.Handle = 0; - } - - Object::~Object() - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - } - - Object& Object::operator=(const Object& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedClass(this->Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedClass(this->Handle); - } - return *this; - } - - Object& Object::operator=(std::nullptr_t other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - return *this; - } - - Object& Object::operator=(Object&& other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - } - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool Object::operator==(const Object& other) const - { - return Handle == other.Handle; - } - - bool Object::operator!=(const Object& other) const - { - return Handle != other.Handle; - } - - System::String Object::GetName() - { - auto returnValue = Plugin::UnityEngineObjectPropertyGetName(Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return System::String(Plugin::InternalUse::Only, returnValue); - } - - void Object::SetName(System::String value) - { - Plugin::UnityEngineObjectPropertySetName(Handle, value.Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - System::Boolean Object::operator==(UnityEngine::Object x) - { - auto returnValue = Plugin::UnityEngineObjectMethodop_EqualityUnityEngineObject_UnityEngineObject(Handle, x.Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnValue; - } - - Object::operator System::Boolean() - { - auto returnValue = Plugin::UnityEngineObjectMethodop_ImplicitUnityEngineObject(Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnValue; - } -} - -namespace UnityEngine -{ - GameObject::GameObject(std::nullptr_t n) - : GameObject(Plugin::InternalUse::Only, 0) - { - } - - GameObject::GameObject(Plugin::InternalUse iu, int32_t handle) - : UnityEngine::Object(iu, handle) - { - if (handle) - { - Plugin::ReferenceManagedClass(handle); - } - } - - GameObject::GameObject(const GameObject& other) - : GameObject(Plugin::InternalUse::Only, other.Handle) - { - } - - GameObject::GameObject(GameObject&& other) - : GameObject(Plugin::InternalUse::Only, other.Handle) - { - other.Handle = 0; - } - - GameObject::~GameObject() - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - } - - GameObject& GameObject::operator=(const GameObject& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedClass(this->Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedClass(this->Handle); - } - return *this; - } - - GameObject& GameObject::operator=(std::nullptr_t other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - return *this; - } - - GameObject& GameObject::operator=(GameObject&& other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - } - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool GameObject::operator==(const GameObject& other) const - { - return Handle == other.Handle; - } - - bool GameObject::operator!=(const GameObject& other) const - { - return Handle != other.Handle; - } - - GameObject::GameObject() - : UnityEngine::Object(nullptr) - { - auto returnValue = Plugin::UnityEngineGameObjectConstructor(); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - Handle = returnValue; - if (returnValue) - { - Plugin::ReferenceManagedClass(returnValue); - } - } - - GameObject::GameObject(System::String name) - : UnityEngine::Object(nullptr) - { - auto returnValue = Plugin::UnityEngineGameObjectConstructorSystemString(name.Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - Handle = returnValue; - if (returnValue) - { - Plugin::ReferenceManagedClass(returnValue); - } - } - - UnityEngine::Transform GameObject::GetTransform() - { - auto returnValue = Plugin::UnityEngineGameObjectPropertyGetTransform(Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return UnityEngine::Transform(Plugin::InternalUse::Only, returnValue); - } - - template<> MyGame::MonoBehaviours::TestScript GameObject::AddComponent() - { - auto returnValue = Plugin::UnityEngineGameObjectMethodAddComponentMyGameMonoBehavioursTestScript(Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return MyGame::MonoBehaviours::TestScript(Plugin::InternalUse::Only, returnValue); - } -} - -namespace UnityEngine -{ - Component::Component(std::nullptr_t n) - : Component(Plugin::InternalUse::Only, 0) - { - } - - Component::Component(Plugin::InternalUse iu, int32_t handle) - : UnityEngine::Object(iu, handle) - { - if (handle) - { - Plugin::ReferenceManagedClass(handle); - } - } - - Component::Component(const Component& other) - : Component(Plugin::InternalUse::Only, other.Handle) - { - } - - Component::Component(Component&& other) - : Component(Plugin::InternalUse::Only, other.Handle) - { - other.Handle = 0; - } - - Component::~Component() - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - } - - Component& Component::operator=(const Component& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedClass(this->Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedClass(this->Handle); - } - return *this; - } - - Component& Component::operator=(std::nullptr_t other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - return *this; - } - - Component& Component::operator=(Component&& other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - } - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool Component::operator==(const Component& other) const - { - return Handle == other.Handle; - } - - bool Component::operator!=(const Component& other) const - { - return Handle != other.Handle; - } - - UnityEngine::Transform Component::GetTransform() - { - auto returnValue = Plugin::UnityEngineComponentPropertyGetTransform(Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return UnityEngine::Transform(Plugin::InternalUse::Only, returnValue); - } -} - -namespace UnityEngine -{ - Transform::Transform(std::nullptr_t n) - : Transform(Plugin::InternalUse::Only, 0) - { - } - - Transform::Transform(Plugin::InternalUse iu, int32_t handle) - : UnityEngine::Component(iu, handle) - { - if (handle) - { - Plugin::ReferenceManagedClass(handle); - } - } - - Transform::Transform(const Transform& other) - : Transform(Plugin::InternalUse::Only, other.Handle) - { - } - - Transform::Transform(Transform&& other) - : Transform(Plugin::InternalUse::Only, other.Handle) - { - other.Handle = 0; - } - - Transform::~Transform() - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - } - - Transform& Transform::operator=(const Transform& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedClass(this->Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedClass(this->Handle); - } - return *this; - } - - Transform& Transform::operator=(std::nullptr_t other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - return *this; - } - - Transform& Transform::operator=(Transform&& other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - } - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool Transform::operator==(const Transform& other) const - { - return Handle == other.Handle; - } - - bool Transform::operator!=(const Transform& other) const - { - return Handle != other.Handle; - } - - UnityEngine::Vector3 Transform::GetPosition() - { - auto returnValue = Plugin::UnityEngineTransformPropertyGetPosition(Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnValue; - } - - void Transform::SetPosition(UnityEngine::Vector3& value) - { - Plugin::UnityEngineTransformPropertySetPosition(Handle, value); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } -} - -namespace UnityEngine -{ - Debug::Debug(std::nullptr_t n) - : Debug(Plugin::InternalUse::Only, 0) - { - } - - Debug::Debug(Plugin::InternalUse iu, int32_t handle) - : System::Object(iu, handle) - { - if (handle) - { - Plugin::ReferenceManagedClass(handle); - } - } - - Debug::Debug(const Debug& other) - : Debug(Plugin::InternalUse::Only, other.Handle) - { - } - - Debug::Debug(Debug&& other) - : Debug(Plugin::InternalUse::Only, other.Handle) - { - other.Handle = 0; - } - - Debug::~Debug() - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - } - - Debug& Debug::operator=(const Debug& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedClass(this->Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedClass(this->Handle); - } - return *this; - } - - Debug& Debug::operator=(std::nullptr_t other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - return *this; - } - - Debug& Debug::operator=(Debug&& other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - } - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool Debug::operator==(const Debug& other) const - { - return Handle == other.Handle; - } - - bool Debug::operator!=(const Debug& other) const - { - return Handle != other.Handle; - } - - void Debug::Log(System::Object message) - { - Plugin::UnityEngineDebugMethodLogSystemObject(message.Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } -} - -namespace UnityEngine -{ - namespace Assertions - { - System::Boolean Assert::GetRaiseExceptions() - { - auto returnValue = Plugin::UnityEngineAssertionsAssertFieldGetRaiseExceptions(); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnValue; - } - - void Assert::SetRaiseExceptions(System::Boolean value) - { - Plugin::UnityEngineAssertionsAssertFieldSetRaiseExceptions(value); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - template<> void Assert::AreEqual(System::String expected, System::String actual) - { - Plugin::UnityEngineAssertionsAssertMethodAreEqualSystemStringSystemString_SystemString(expected.Handle, actual.Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - template<> void Assert::AreEqual(UnityEngine::GameObject expected, UnityEngine::GameObject actual) - { - Plugin::UnityEngineAssertionsAssertMethodAreEqualUnityEngineGameObjectUnityEngineGameObject_UnityEngineGameObject(expected.Handle, actual.Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - } -} - -namespace UnityEngine -{ - Collision::Collision(std::nullptr_t n) - : Collision(Plugin::InternalUse::Only, 0) - { - } - - Collision::Collision(Plugin::InternalUse iu, int32_t handle) - : System::Object(iu, handle) - { - if (handle) - { - Plugin::ReferenceManagedClass(handle); - } - } - - Collision::Collision(const Collision& other) - : Collision(Plugin::InternalUse::Only, other.Handle) - { - } - - Collision::Collision(Collision&& other) - : Collision(Plugin::InternalUse::Only, other.Handle) - { - other.Handle = 0; - } - - Collision::~Collision() - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - } - - Collision& Collision::operator=(const Collision& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedClass(this->Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedClass(this->Handle); - } - return *this; - } - - Collision& Collision::operator=(std::nullptr_t other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - return *this; - } - - Collision& Collision::operator=(Collision&& other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - } - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool Collision::operator==(const Collision& other) const - { - return Handle == other.Handle; - } - - bool Collision::operator!=(const Collision& other) const - { - return Handle != other.Handle; - } -} - -namespace UnityEngine -{ - Behaviour::Behaviour(std::nullptr_t n) - : Behaviour(Plugin::InternalUse::Only, 0) - { - } - - Behaviour::Behaviour(Plugin::InternalUse iu, int32_t handle) - : UnityEngine::Component(iu, handle) - { - if (handle) - { - Plugin::ReferenceManagedClass(handle); - } - } - - Behaviour::Behaviour(const Behaviour& other) - : Behaviour(Plugin::InternalUse::Only, other.Handle) - { - } - - Behaviour::Behaviour(Behaviour&& other) - : Behaviour(Plugin::InternalUse::Only, other.Handle) - { - other.Handle = 0; - } - - Behaviour::~Behaviour() - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - } - - Behaviour& Behaviour::operator=(const Behaviour& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedClass(this->Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedClass(this->Handle); - } - return *this; - } - - Behaviour& Behaviour::operator=(std::nullptr_t other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - return *this; - } - - Behaviour& Behaviour::operator=(Behaviour&& other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - } - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool Behaviour::operator==(const Behaviour& other) const - { - return Handle == other.Handle; - } - - bool Behaviour::operator!=(const Behaviour& other) const - { - return Handle != other.Handle; - } -} - -namespace UnityEngine -{ - MonoBehaviour::MonoBehaviour(std::nullptr_t n) - : MonoBehaviour(Plugin::InternalUse::Only, 0) - { - } - - MonoBehaviour::MonoBehaviour(Plugin::InternalUse iu, int32_t handle) - : UnityEngine::Behaviour(iu, handle) - { - if (handle) - { - Plugin::ReferenceManagedClass(handle); - } - } - - MonoBehaviour::MonoBehaviour(const MonoBehaviour& other) - : MonoBehaviour(Plugin::InternalUse::Only, other.Handle) - { - } - - MonoBehaviour::MonoBehaviour(MonoBehaviour&& other) - : MonoBehaviour(Plugin::InternalUse::Only, other.Handle) - { - other.Handle = 0; - } - - MonoBehaviour::~MonoBehaviour() - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - } - - MonoBehaviour& MonoBehaviour::operator=(const MonoBehaviour& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedClass(this->Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedClass(this->Handle); - } - return *this; - } - - MonoBehaviour& MonoBehaviour::operator=(std::nullptr_t other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - return *this; - } - - MonoBehaviour& MonoBehaviour::operator=(MonoBehaviour&& other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - } - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool MonoBehaviour::operator==(const MonoBehaviour& other) const - { - return Handle == other.Handle; - } - - bool MonoBehaviour::operator!=(const MonoBehaviour& other) const - { - return Handle != other.Handle; - } -} - -namespace UnityEngine -{ - AudioSettings::AudioSettings(std::nullptr_t n) - : AudioSettings(Plugin::InternalUse::Only, 0) - { - } - - AudioSettings::AudioSettings(Plugin::InternalUse iu, int32_t handle) - : System::Object(iu, handle) - { - if (handle) - { - Plugin::ReferenceManagedClass(handle); - } - } - - AudioSettings::AudioSettings(const AudioSettings& other) - : AudioSettings(Plugin::InternalUse::Only, other.Handle) - { - } - - AudioSettings::AudioSettings(AudioSettings&& other) - : AudioSettings(Plugin::InternalUse::Only, other.Handle) - { - other.Handle = 0; - } - - AudioSettings::~AudioSettings() - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - } - - AudioSettings& AudioSettings::operator=(const AudioSettings& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedClass(this->Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedClass(this->Handle); - } - return *this; - } - - AudioSettings& AudioSettings::operator=(std::nullptr_t other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - return *this; - } - - AudioSettings& AudioSettings::operator=(AudioSettings&& other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - } - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool AudioSettings::operator==(const AudioSettings& other) const - { - return Handle == other.Handle; - } - - bool AudioSettings::operator!=(const AudioSettings& other) const - { - return Handle != other.Handle; - } - - void AudioSettings::GetDSPBufferSize(int32_t* bufferLength, int32_t* numBuffers) - { - Plugin::UnityEngineAudioSettingsMethodGetDSPBufferSizeSystemInt32_SystemInt32(bufferLength, numBuffers); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } -} - -namespace UnityEngine -{ - namespace Networking - { - NetworkTransport::NetworkTransport(std::nullptr_t n) - : NetworkTransport(Plugin::InternalUse::Only, 0) - { - } - - NetworkTransport::NetworkTransport(Plugin::InternalUse iu, int32_t handle) - : System::Object(iu, handle) - { - if (handle) - { - Plugin::ReferenceManagedClass(handle); - } - } - - NetworkTransport::NetworkTransport(const NetworkTransport& other) - : NetworkTransport(Plugin::InternalUse::Only, other.Handle) - { - } - - NetworkTransport::NetworkTransport(NetworkTransport&& other) - : NetworkTransport(Plugin::InternalUse::Only, other.Handle) - { - other.Handle = 0; - } - - NetworkTransport::~NetworkTransport() - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - } - - NetworkTransport& NetworkTransport::operator=(const NetworkTransport& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedClass(this->Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedClass(this->Handle); - } - return *this; - } - - NetworkTransport& NetworkTransport::operator=(std::nullptr_t other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - return *this; - } - - NetworkTransport& NetworkTransport::operator=(NetworkTransport&& other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - } - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool NetworkTransport::operator==(const NetworkTransport& other) const - { - return Handle == other.Handle; - } - - bool NetworkTransport::operator!=(const NetworkTransport& other) const - { - return Handle != other.Handle; - } - - void NetworkTransport::GetBroadcastConnectionInfo(int32_t hostId, System::String* address, int32_t* port, uint8_t* error) - { - int32_t addressHandle = address->Handle; - Plugin::UnityEngineNetworkingNetworkTransportMethodGetBroadcastConnectionInfoSystemInt32_SystemString_SystemInt32_SystemByte(hostId, &addressHandle, port, error); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - if (address->Handle) - { - Plugin::DereferenceManagedClass(address->Handle); - } - address->Handle = addressHandle; - if (address->Handle) - { - Plugin::ReferenceManagedClass(address->Handle); - } - } - - void NetworkTransport::Init() - { - Plugin::UnityEngineNetworkingNetworkTransportMethodInit(); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - } -} - -namespace UnityEngine -{ - Vector3::Vector3() - { - } - - Vector3::Vector3(float x, float y, float z) - { - auto returnValue = Plugin::UnityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingle(x, y, z); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - *this = returnValue; - } - - float Vector3::GetMagnitude() - { - auto returnValue = Plugin::UnityEngineVector3PropertyGetMagnitude(this); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnValue; - } - - void Vector3::Set(float newX, float newY, float newZ) - { - Plugin::UnityEngineVector3MethodSetSystemSingle_SystemSingle_SystemSingle(this, newX, newY, newZ); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - UnityEngine::Vector3 Vector3::operator+(UnityEngine::Vector3& a) - { - auto returnValue = Plugin::UnityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3(*this, a); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnValue; - } - - UnityEngine::Vector3 Vector3::operator-() - { - auto returnValue = Plugin::UnityEngineVector3Methodop_UnaryNegationUnityEngineVector3(*this); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnValue; - } -} - -namespace System -{ - Object::Object(UnityEngine::Vector3& val) - { - int32_t handle = Plugin::BoxVector3(val); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - if (handle) - { - Plugin::ReferenceManagedClass(handle); - Handle = handle; - } - } - - Object::operator UnityEngine::Vector3() - { - UnityEngine::Vector3 returnVal(Plugin::UnboxVector3(Handle)); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnVal; - } -} - -namespace UnityEngine -{ - Matrix4x4::Matrix4x4() - { - } - - float Matrix4x4::GetItem(int32_t row, int32_t column) - { - auto returnValue = Plugin::UnityEngineMatrix4x4PropertyGetItem(this, row, column); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnValue; - } - - void Matrix4x4::SetItem(int32_t row, int32_t column, float value) - { - Plugin::UnityEngineMatrix4x4PropertySetItem(this, row, column, value); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } -} - -namespace System -{ - Object::Object(UnityEngine::Matrix4x4& val) - { - int32_t handle = Plugin::BoxMatrix4x4(val); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - if (handle) - { - Plugin::ReferenceManagedClass(handle); - Handle = handle; - } - } - - Object::operator UnityEngine::Matrix4x4() - { - UnityEngine::Matrix4x4 returnVal(Plugin::UnboxMatrix4x4(Handle)); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnVal; - } -} - -namespace UnityEngine -{ - RaycastHit::RaycastHit(std::nullptr_t n) - : RaycastHit(Plugin::InternalUse::Only, 0) - { - } - - RaycastHit::RaycastHit(Plugin::InternalUse iu, int32_t handle) - : System::ValueType(iu, handle) - { - if (handle) - { - Plugin::ReferenceManagedUnityEngineRaycastHit(Handle); - } - } - - RaycastHit::RaycastHit(const RaycastHit& other) - : RaycastHit(Plugin::InternalUse::Only, other.Handle) - { - } - - RaycastHit::RaycastHit(RaycastHit&& other) - : RaycastHit(Plugin::InternalUse::Only, other.Handle) - { - other.Handle = 0; - } - - RaycastHit::~RaycastHit() - { - if (Handle) - { - Plugin::DereferenceManagedUnityEngineRaycastHit(Handle); - Handle = 0; - } - } - - RaycastHit& RaycastHit::operator=(const RaycastHit& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedUnityEngineRaycastHit(Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedUnityEngineRaycastHit(Handle); - } - return *this; - } - - RaycastHit& RaycastHit::operator=(std::nullptr_t other) - { - if (Handle) - { - Plugin::DereferenceManagedUnityEngineRaycastHit(Handle); - Handle = 0; - } - return *this; - } - - RaycastHit& RaycastHit::operator=(RaycastHit&& other) - { - if (Handle) - { - Plugin::DereferenceManagedUnityEngineRaycastHit(Handle); - } - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool RaycastHit::operator==(const RaycastHit& other) const - { - return Handle == other.Handle; - } - - bool RaycastHit::operator!=(const RaycastHit& other) const - { - return Handle != other.Handle; - } - - UnityEngine::Vector3 RaycastHit::GetPoint() - { - auto returnValue = Plugin::UnityEngineRaycastHitPropertyGetPoint(Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnValue; - } - - void RaycastHit::SetPoint(UnityEngine::Vector3& value) - { - Plugin::UnityEngineRaycastHitPropertySetPoint(Handle, value); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - UnityEngine::Transform RaycastHit::GetTransform() - { - auto returnValue = Plugin::UnityEngineRaycastHitPropertyGetTransform(Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return UnityEngine::Transform(Plugin::InternalUse::Only, returnValue); - } -} - -namespace System -{ - Object::Object(UnityEngine::RaycastHit val) - { - int32_t handle = Plugin::BoxRaycastHit(val.Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - if (handle) - { - Plugin::ReferenceManagedClass(handle); - Handle = handle; - } - } - - Object::operator UnityEngine::RaycastHit() - { - UnityEngine::RaycastHit returnVal(Plugin::InternalUse::Only, Plugin::UnboxRaycastHit(Handle)); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnVal; - } -} - -namespace System -{ - Object::Object(UnityEngine::QueryTriggerInteraction val) - { - int32_t handle = Plugin::BoxQueryTriggerInteraction(val); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - if (handle) - { - Plugin::ReferenceManagedClass(handle); - Handle = handle; - } - } - - Object::operator UnityEngine::QueryTriggerInteraction() - { - UnityEngine::QueryTriggerInteraction returnVal(Plugin::UnboxQueryTriggerInteraction(Handle)); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnVal; - } -} - -namespace System -{ - namespace Collections - { - namespace Generic - { - KeyValuePair::KeyValuePair(std::nullptr_t n) - : KeyValuePair(Plugin::InternalUse::Only, 0) - { - } - - KeyValuePair::KeyValuePair(Plugin::InternalUse iu, int32_t handle) - : System::ValueType(iu, handle) - { - if (handle) - { - Plugin::ReferenceManagedSystemCollectionsGenericKeyValuePairSystemString_SystemDouble(Handle); - } - } - - KeyValuePair::KeyValuePair(const KeyValuePair& other) - : KeyValuePair(Plugin::InternalUse::Only, other.Handle) - { - } - - KeyValuePair::KeyValuePair(KeyValuePair&& other) - : KeyValuePair(Plugin::InternalUse::Only, other.Handle) - { - other.Handle = 0; - } - - KeyValuePair::~KeyValuePair() - { - if (Handle) - { - Plugin::DereferenceManagedSystemCollectionsGenericKeyValuePairSystemString_SystemDouble(Handle); - Handle = 0; - } - } - - KeyValuePair& KeyValuePair::operator=(const KeyValuePair& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedSystemCollectionsGenericKeyValuePairSystemString_SystemDouble(Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedSystemCollectionsGenericKeyValuePairSystemString_SystemDouble(Handle); - } - return *this; - } - - KeyValuePair& KeyValuePair::operator=(std::nullptr_t other) - { - if (Handle) - { - Plugin::DereferenceManagedSystemCollectionsGenericKeyValuePairSystemString_SystemDouble(Handle); - Handle = 0; - } - return *this; - } - - KeyValuePair& KeyValuePair::operator=(KeyValuePair&& other) - { - if (Handle) - { - Plugin::DereferenceManagedSystemCollectionsGenericKeyValuePairSystemString_SystemDouble(Handle); - } - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool KeyValuePair::operator==(const KeyValuePair& other) const - { - return Handle == other.Handle; - } - - bool KeyValuePair::operator!=(const KeyValuePair& other) const - { - return Handle != other.Handle; - } - - KeyValuePair::KeyValuePair(System::String key, double value) - : System::ValueType(nullptr) - { - auto returnValue = Plugin::SystemCollectionsGenericKeyValuePairSystemString_SystemDoubleConstructorSystemString_SystemDouble(key.Handle, value); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - Handle = returnValue; - if (returnValue) - { - Plugin::ReferenceManagedSystemCollectionsGenericKeyValuePairSystemString_SystemDouble(Handle); - } - } - - System::String KeyValuePair::GetKey() - { - auto returnValue = Plugin::SystemCollectionsGenericKeyValuePairSystemString_SystemDoublePropertyGetKey(Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return System::String(Plugin::InternalUse::Only, returnValue); - } - - double KeyValuePair::GetValue() - { - auto returnValue = Plugin::SystemCollectionsGenericKeyValuePairSystemString_SystemDoublePropertyGetValue(Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnValue; - } - } - } -} - -namespace System -{ - Object::Object(System::Collections::Generic::KeyValuePair val) - { - int32_t handle = Plugin::BoxKeyValuePairSystemString_SystemDouble(val.Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - if (handle) - { - Plugin::ReferenceManagedClass(handle); - Handle = handle; - } - } - - Object::operator System::Collections::Generic::KeyValuePair() - { - System::Collections::Generic::KeyValuePair returnVal(Plugin::InternalUse::Only, Plugin::UnboxKeyValuePairSystemString_SystemDouble(Handle)); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnVal; - } -} - -namespace System -{ - namespace Collections - { - namespace Generic - { - List::List(std::nullptr_t n) - : List(Plugin::InternalUse::Only, 0) - { - } - - List::List(Plugin::InternalUse iu, int32_t handle) - : System::Object(iu, handle) - { - if (handle) - { - Plugin::ReferenceManagedClass(handle); - } - } - - List::List(const List& other) - : List(Plugin::InternalUse::Only, other.Handle) - { - } - - List::List(List&& other) - : List(Plugin::InternalUse::Only, other.Handle) - { - other.Handle = 0; - } - - List::~List() - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - } - - List& List::operator=(const List& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedClass(this->Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedClass(this->Handle); - } - return *this; - } - - List& List::operator=(std::nullptr_t other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - return *this; - } - - List& List::operator=(List&& other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - } - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool List::operator==(const List& other) const - { - return Handle == other.Handle; - } - - bool List::operator!=(const List& other) const - { - return Handle != other.Handle; - } - - List::List() - : System::Object(nullptr) - { - auto returnValue = Plugin::SystemCollectionsGenericListSystemStringConstructor(); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - Handle = returnValue; - if (returnValue) - { - Plugin::ReferenceManagedClass(returnValue); - } - } - - System::String List::GetItem(int32_t index) - { - auto returnValue = Plugin::SystemCollectionsGenericListSystemStringPropertyGetItem(Handle, index); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return System::String(Plugin::InternalUse::Only, returnValue); - } - - void List::SetItem(int32_t index, System::String value) - { - Plugin::SystemCollectionsGenericListSystemStringPropertySetItem(Handle, index, value.Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - void List::Add(System::String item) - { - Plugin::SystemCollectionsGenericListSystemStringMethodAddSystemString(Handle, item.Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - } - } -} - -namespace System -{ - namespace Collections - { - namespace Generic - { - LinkedListNode::LinkedListNode(std::nullptr_t n) - : LinkedListNode(Plugin::InternalUse::Only, 0) - { - } - - LinkedListNode::LinkedListNode(Plugin::InternalUse iu, int32_t handle) - : System::Object(iu, handle) - { - if (handle) - { - Plugin::ReferenceManagedClass(handle); - } - } - - LinkedListNode::LinkedListNode(const LinkedListNode& other) - : LinkedListNode(Plugin::InternalUse::Only, other.Handle) - { - } - - LinkedListNode::LinkedListNode(LinkedListNode&& other) - : LinkedListNode(Plugin::InternalUse::Only, other.Handle) - { - other.Handle = 0; - } - - LinkedListNode::~LinkedListNode() - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - } - - LinkedListNode& LinkedListNode::operator=(const LinkedListNode& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedClass(this->Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedClass(this->Handle); - } - return *this; - } - - LinkedListNode& LinkedListNode::operator=(std::nullptr_t other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - return *this; - } - - LinkedListNode& LinkedListNode::operator=(LinkedListNode&& other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - } - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool LinkedListNode::operator==(const LinkedListNode& other) const - { - return Handle == other.Handle; - } - - bool LinkedListNode::operator!=(const LinkedListNode& other) const - { - return Handle != other.Handle; - } - - LinkedListNode::LinkedListNode(System::String value) - : System::Object(nullptr) - { - auto returnValue = Plugin::SystemCollectionsGenericLinkedListNodeSystemStringConstructorSystemString(value.Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - Handle = returnValue; - if (returnValue) - { - Plugin::ReferenceManagedClass(returnValue); - } - } - - System::String LinkedListNode::GetValue() - { - auto returnValue = Plugin::SystemCollectionsGenericLinkedListNodeSystemStringPropertyGetValue(Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return System::String(Plugin::InternalUse::Only, returnValue); - } - - void LinkedListNode::SetValue(System::String value) - { - Plugin::SystemCollectionsGenericLinkedListNodeSystemStringPropertySetValue(Handle, value.Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - } - } -} - -namespace System -{ - namespace Runtime - { - namespace CompilerServices - { - StrongBox::StrongBox(std::nullptr_t n) - : StrongBox(Plugin::InternalUse::Only, 0) - { - } - - StrongBox::StrongBox(Plugin::InternalUse iu, int32_t handle) - : System::Object(iu, handle) - { - if (handle) - { - Plugin::ReferenceManagedClass(handle); - } - } - - StrongBox::StrongBox(const StrongBox& other) - : StrongBox(Plugin::InternalUse::Only, other.Handle) - { - } - - StrongBox::StrongBox(StrongBox&& other) - : StrongBox(Plugin::InternalUse::Only, other.Handle) - { - other.Handle = 0; - } - - StrongBox::~StrongBox() - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - } - - StrongBox& StrongBox::operator=(const StrongBox& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedClass(this->Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedClass(this->Handle); - } - return *this; - } - - StrongBox& StrongBox::operator=(std::nullptr_t other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - return *this; - } - - StrongBox& StrongBox::operator=(StrongBox&& other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - } - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool StrongBox::operator==(const StrongBox& other) const - { - return Handle == other.Handle; - } - - bool StrongBox::operator!=(const StrongBox& other) const - { - return Handle != other.Handle; - } - - StrongBox::StrongBox(System::String value) - : System::Object(nullptr) - { - auto returnValue = Plugin::SystemRuntimeCompilerServicesStrongBoxSystemStringConstructorSystemString(value.Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - Handle = returnValue; - if (returnValue) - { - Plugin::ReferenceManagedClass(returnValue); - } - } - - System::String StrongBox::GetValue() - { - auto returnValue = Plugin::SystemRuntimeCompilerServicesStrongBoxSystemStringFieldGetValue(Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return System::String(Plugin::InternalUse::Only, returnValue); - } - - void StrongBox::SetValue(System::String value) - { - Plugin::SystemRuntimeCompilerServicesStrongBoxSystemStringFieldSetValue(Handle, value.Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - } - } -} - -namespace System -{ - namespace Collections - { - namespace ObjectModel - { - Collection::Collection(std::nullptr_t n) - : Collection(Plugin::InternalUse::Only, 0) - { - } - - Collection::Collection(Plugin::InternalUse iu, int32_t handle) - : System::Object(iu, handle) - { - if (handle) - { - Plugin::ReferenceManagedClass(handle); - } - } - - Collection::Collection(const Collection& other) - : Collection(Plugin::InternalUse::Only, other.Handle) - { - } - - Collection::Collection(Collection&& other) - : Collection(Plugin::InternalUse::Only, other.Handle) - { - other.Handle = 0; - } - - Collection::~Collection() - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - } - - Collection& Collection::operator=(const Collection& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedClass(this->Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedClass(this->Handle); - } - return *this; - } - - Collection& Collection::operator=(std::nullptr_t other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - return *this; - } - - Collection& Collection::operator=(Collection&& other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - } - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool Collection::operator==(const Collection& other) const - { - return Handle == other.Handle; - } - - bool Collection::operator!=(const Collection& other) const - { - return Handle != other.Handle; - } - } - } -} - -namespace System -{ - namespace Collections - { - namespace ObjectModel - { - KeyedCollection::KeyedCollection(std::nullptr_t n) - : KeyedCollection(Plugin::InternalUse::Only, 0) - { - } - - KeyedCollection::KeyedCollection(Plugin::InternalUse iu, int32_t handle) - : System::Collections::ObjectModel::Collection(iu, handle) - { - if (handle) - { - Plugin::ReferenceManagedClass(handle); - } - } - - KeyedCollection::KeyedCollection(const KeyedCollection& other) - : KeyedCollection(Plugin::InternalUse::Only, other.Handle) - { - } - - KeyedCollection::KeyedCollection(KeyedCollection&& other) - : KeyedCollection(Plugin::InternalUse::Only, other.Handle) - { - other.Handle = 0; - } - - KeyedCollection::~KeyedCollection() - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - } - - KeyedCollection& KeyedCollection::operator=(const KeyedCollection& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedClass(this->Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedClass(this->Handle); - } - return *this; - } - - KeyedCollection& KeyedCollection::operator=(std::nullptr_t other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - return *this; - } - - KeyedCollection& KeyedCollection::operator=(KeyedCollection&& other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - } - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool KeyedCollection::operator==(const KeyedCollection& other) const - { - return Handle == other.Handle; - } - - bool KeyedCollection::operator!=(const KeyedCollection& other) const - { - return Handle != other.Handle; - } - } - } -} - -namespace System -{ - Exception::Exception(std::nullptr_t n) - : Exception(Plugin::InternalUse::Only, 0) - { - } - - Exception::Exception(Plugin::InternalUse iu, int32_t handle) - : System::Object(iu, handle) - { - if (handle) - { - Plugin::ReferenceManagedClass(handle); - } - } - - Exception::Exception(const Exception& other) - : Exception(Plugin::InternalUse::Only, other.Handle) - { - } - - Exception::Exception(Exception&& other) - : Exception(Plugin::InternalUse::Only, other.Handle) - { - other.Handle = 0; - } - - Exception::~Exception() - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - } - - Exception& Exception::operator=(const Exception& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedClass(this->Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedClass(this->Handle); - } - return *this; - } - - Exception& Exception::operator=(std::nullptr_t other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - return *this; - } - - Exception& Exception::operator=(Exception&& other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - } - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool Exception::operator==(const Exception& other) const - { - return Handle == other.Handle; - } - - bool Exception::operator!=(const Exception& other) const - { - return Handle != other.Handle; - } - - Exception::Exception(System::String message) - : System::Object(nullptr) - { - auto returnValue = Plugin::SystemExceptionConstructorSystemString(message.Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - Handle = returnValue; - if (returnValue) - { - Plugin::ReferenceManagedClass(returnValue); - } - } -} - -namespace System -{ - SystemException::SystemException(std::nullptr_t n) - : SystemException(Plugin::InternalUse::Only, 0) - { - } - - SystemException::SystemException(Plugin::InternalUse iu, int32_t handle) - : System::Exception(iu, handle) - { - if (handle) - { - Plugin::ReferenceManagedClass(handle); - } - } - - SystemException::SystemException(const SystemException& other) - : SystemException(Plugin::InternalUse::Only, other.Handle) - { - } - - SystemException::SystemException(SystemException&& other) - : SystemException(Plugin::InternalUse::Only, other.Handle) - { - other.Handle = 0; - } - - SystemException::~SystemException() - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - } - - SystemException& SystemException::operator=(const SystemException& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedClass(this->Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedClass(this->Handle); - } - return *this; - } - - SystemException& SystemException::operator=(std::nullptr_t other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - return *this; - } - - SystemException& SystemException::operator=(SystemException&& other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - } - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool SystemException::operator==(const SystemException& other) const - { - return Handle == other.Handle; - } - - bool SystemException::operator!=(const SystemException& other) const - { - return Handle != other.Handle; - } -} - -namespace System -{ - NullReferenceException::NullReferenceException(std::nullptr_t n) - : NullReferenceException(Plugin::InternalUse::Only, 0) - { - } - - NullReferenceException::NullReferenceException(Plugin::InternalUse iu, int32_t handle) - : System::SystemException(iu, handle) - { - if (handle) - { - Plugin::ReferenceManagedClass(handle); - } - } - - NullReferenceException::NullReferenceException(const NullReferenceException& other) - : NullReferenceException(Plugin::InternalUse::Only, other.Handle) - { - } - - NullReferenceException::NullReferenceException(NullReferenceException&& other) - : NullReferenceException(Plugin::InternalUse::Only, other.Handle) - { - other.Handle = 0; - } - - NullReferenceException::~NullReferenceException() - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - } - - NullReferenceException& NullReferenceException::operator=(const NullReferenceException& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedClass(this->Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedClass(this->Handle); - } - return *this; - } - - NullReferenceException& NullReferenceException::operator=(std::nullptr_t other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - return *this; - } - - NullReferenceException& NullReferenceException::operator=(NullReferenceException&& other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - } - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool NullReferenceException::operator==(const NullReferenceException& other) const - { - return Handle == other.Handle; - } - - bool NullReferenceException::operator!=(const NullReferenceException& other) const - { - return Handle != other.Handle; - } -} - -namespace UnityEngine -{ - Resolution::Resolution() - { - } - - int32_t Resolution::GetWidth() - { - auto returnValue = Plugin::UnityEngineResolutionPropertyGetWidth(this); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnValue; - } - - void Resolution::SetWidth(int32_t value) - { - Plugin::UnityEngineResolutionPropertySetWidth(this, value); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - int32_t Resolution::GetHeight() - { - auto returnValue = Plugin::UnityEngineResolutionPropertyGetHeight(this); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnValue; - } - - void Resolution::SetHeight(int32_t value) - { - Plugin::UnityEngineResolutionPropertySetHeight(this, value); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - int32_t Resolution::GetRefreshRate() - { - auto returnValue = Plugin::UnityEngineResolutionPropertyGetRefreshRate(this); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnValue; - } - - void Resolution::SetRefreshRate(int32_t value) - { - Plugin::UnityEngineResolutionPropertySetRefreshRate(this, value); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } -} - -namespace System -{ - Object::Object(UnityEngine::Resolution& val) - { - int32_t handle = Plugin::BoxResolution(val); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - if (handle) - { - Plugin::ReferenceManagedClass(handle); - Handle = handle; - } - } - - Object::operator UnityEngine::Resolution() - { - UnityEngine::Resolution returnVal(Plugin::UnboxResolution(Handle)); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnVal; - } -} - -namespace UnityEngine -{ - Screen::Screen(std::nullptr_t n) - : Screen(Plugin::InternalUse::Only, 0) - { - } - - Screen::Screen(Plugin::InternalUse iu, int32_t handle) - : System::Object(iu, handle) - { - if (handle) - { - Plugin::ReferenceManagedClass(handle); - } - } - - Screen::Screen(const Screen& other) - : Screen(Plugin::InternalUse::Only, other.Handle) - { - } - - Screen::Screen(Screen&& other) - : Screen(Plugin::InternalUse::Only, other.Handle) - { - other.Handle = 0; - } - - Screen::~Screen() - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - } - - Screen& Screen::operator=(const Screen& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedClass(this->Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedClass(this->Handle); - } - return *this; - } - - Screen& Screen::operator=(std::nullptr_t other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - return *this; - } - - Screen& Screen::operator=(Screen&& other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - } - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool Screen::operator==(const Screen& other) const - { - return Handle == other.Handle; - } - - bool Screen::operator!=(const Screen& other) const - { - return Handle != other.Handle; - } - - System::Array1 Screen::GetResolutions() - { - auto returnValue = Plugin::UnityEngineScreenPropertyGetResolutions(); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return System::Array1(Plugin::InternalUse::Only, returnValue); - } -} - -namespace UnityEngine -{ - Ray::Ray() - { - } - - Ray::Ray(UnityEngine::Vector3& origin, UnityEngine::Vector3& direction) - { - auto returnValue = Plugin::UnityEngineRayConstructorUnityEngineVector3_UnityEngineVector3(origin, direction); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - *this = returnValue; - } -} - -namespace System -{ - Object::Object(UnityEngine::Ray& val) - { - int32_t handle = Plugin::BoxRay(val); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - if (handle) - { - Plugin::ReferenceManagedClass(handle); - Handle = handle; - } - } - - Object::operator UnityEngine::Ray() - { - UnityEngine::Ray returnVal(Plugin::UnboxRay(Handle)); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnVal; - } -} - -namespace UnityEngine -{ - Physics::Physics(std::nullptr_t n) - : Physics(Plugin::InternalUse::Only, 0) - { - } - - Physics::Physics(Plugin::InternalUse iu, int32_t handle) - : System::Object(iu, handle) - { - if (handle) - { - Plugin::ReferenceManagedClass(handle); - } - } - - Physics::Physics(const Physics& other) - : Physics(Plugin::InternalUse::Only, other.Handle) - { - } - - Physics::Physics(Physics&& other) - : Physics(Plugin::InternalUse::Only, other.Handle) - { - other.Handle = 0; - } - - Physics::~Physics() - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - } - - Physics& Physics::operator=(const Physics& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedClass(this->Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedClass(this->Handle); - } - return *this; - } - - Physics& Physics::operator=(std::nullptr_t other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - return *this; - } - - Physics& Physics::operator=(Physics&& other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - } - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool Physics::operator==(const Physics& other) const - { - return Handle == other.Handle; - } - - bool Physics::operator!=(const Physics& other) const - { - return Handle != other.Handle; - } - - int32_t Physics::RaycastNonAlloc(UnityEngine::Ray& ray, System::Array1 results) - { - auto returnValue = Plugin::UnityEnginePhysicsMethodRaycastNonAllocUnityEngineRay_UnityEngineRaycastHit(ray, results.Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnValue; - } - - System::Array1 Physics::RaycastAll(UnityEngine::Ray& ray) - { - auto returnValue = Plugin::UnityEnginePhysicsMethodRaycastAllUnityEngineRay(ray); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return System::Array1(Plugin::InternalUse::Only, returnValue); - } -} - -namespace UnityEngine -{ - Color::Color() - { - } -} - -namespace System -{ - Object::Object(UnityEngine::Color& val) - { - int32_t handle = Plugin::BoxColor(val); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - if (handle) - { - Plugin::ReferenceManagedClass(handle); - Handle = handle; - } - } - - Object::operator UnityEngine::Color() - { - UnityEngine::Color returnVal(Plugin::UnboxColor(Handle)); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnVal; - } -} - -namespace UnityEngine -{ - GradientColorKey::GradientColorKey() - { - } -} - -namespace System -{ - Object::Object(UnityEngine::GradientColorKey& val) - { - int32_t handle = Plugin::BoxGradientColorKey(val); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - if (handle) - { - Plugin::ReferenceManagedClass(handle); - Handle = handle; - } - } - - Object::operator UnityEngine::GradientColorKey() - { - UnityEngine::GradientColorKey returnVal(Plugin::UnboxGradientColorKey(Handle)); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnVal; - } -} - -namespace UnityEngine -{ - Gradient::Gradient(std::nullptr_t n) - : Gradient(Plugin::InternalUse::Only, 0) - { - } - - Gradient::Gradient(Plugin::InternalUse iu, int32_t handle) - : System::Object(iu, handle) - { - if (handle) - { - Plugin::ReferenceManagedClass(handle); - } - } - - Gradient::Gradient(const Gradient& other) - : Gradient(Plugin::InternalUse::Only, other.Handle) - { - } - - Gradient::Gradient(Gradient&& other) - : Gradient(Plugin::InternalUse::Only, other.Handle) - { - other.Handle = 0; - } - - Gradient::~Gradient() - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - } - - Gradient& Gradient::operator=(const Gradient& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedClass(this->Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedClass(this->Handle); - } - return *this; - } - - Gradient& Gradient::operator=(std::nullptr_t other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - return *this; - } - - Gradient& Gradient::operator=(Gradient&& other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - } - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool Gradient::operator==(const Gradient& other) const - { - return Handle == other.Handle; - } - - bool Gradient::operator!=(const Gradient& other) const - { - return Handle != other.Handle; - } - - Gradient::Gradient() - : System::Object(nullptr) - { - auto returnValue = Plugin::UnityEngineGradientConstructor(); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - Handle = returnValue; - if (returnValue) - { - Plugin::ReferenceManagedClass(returnValue); - } - } - - System::Array1 Gradient::GetColorKeys() - { - auto returnValue = Plugin::UnityEngineGradientPropertyGetColorKeys(Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return System::Array1(Plugin::InternalUse::Only, returnValue); - } - - void Gradient::SetColorKeys(System::Array1 value) - { - Plugin::UnityEngineGradientPropertySetColorKeys(Handle, value.Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } -} - -namespace System -{ - AppDomainSetup::AppDomainSetup(std::nullptr_t n) - : AppDomainSetup(Plugin::InternalUse::Only, 0) - { - } - - AppDomainSetup::AppDomainSetup(Plugin::InternalUse iu, int32_t handle) - : System::Object(iu, handle) - { - if (handle) - { - Plugin::ReferenceManagedClass(handle); - } - } - - AppDomainSetup::AppDomainSetup(const AppDomainSetup& other) - : AppDomainSetup(Plugin::InternalUse::Only, other.Handle) - { - } - - AppDomainSetup::AppDomainSetup(AppDomainSetup&& other) - : AppDomainSetup(Plugin::InternalUse::Only, other.Handle) - { - other.Handle = 0; - } - - AppDomainSetup::~AppDomainSetup() - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - } - - AppDomainSetup& AppDomainSetup::operator=(const AppDomainSetup& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedClass(this->Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedClass(this->Handle); - } - return *this; - } - - AppDomainSetup& AppDomainSetup::operator=(std::nullptr_t other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - return *this; - } - - AppDomainSetup& AppDomainSetup::operator=(AppDomainSetup&& other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - } - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool AppDomainSetup::operator==(const AppDomainSetup& other) const - { - return Handle == other.Handle; - } - - bool AppDomainSetup::operator!=(const AppDomainSetup& other) const - { - return Handle != other.Handle; - } - - AppDomainSetup::AppDomainSetup() - : System::Object(nullptr) - { - auto returnValue = Plugin::SystemAppDomainSetupConstructor(); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - Handle = returnValue; - if (returnValue) - { - Plugin::ReferenceManagedClass(returnValue); - } - } - - System::AppDomainInitializer AppDomainSetup::GetAppDomainInitializer() - { - auto returnValue = Plugin::SystemAppDomainSetupPropertyGetAppDomainInitializer(Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return System::AppDomainInitializer(Plugin::InternalUse::Only, returnValue); - } - - void AppDomainSetup::SetAppDomainInitializer(System::AppDomainInitializer value) - { - Plugin::SystemAppDomainSetupPropertySetAppDomainInitializer(Handle, value.Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } -} - -namespace UnityEngine -{ - Application::Application(std::nullptr_t n) - : Application(Plugin::InternalUse::Only, 0) - { - } - - Application::Application(Plugin::InternalUse iu, int32_t handle) - : System::Object(iu, handle) - { - if (handle) - { - Plugin::ReferenceManagedClass(handle); - } - } - - Application::Application(const Application& other) - : Application(Plugin::InternalUse::Only, other.Handle) - { - } - - Application::Application(Application&& other) - : Application(Plugin::InternalUse::Only, other.Handle) - { - other.Handle = 0; - } - - Application::~Application() - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - } - - Application& Application::operator=(const Application& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedClass(this->Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedClass(this->Handle); - } - return *this; - } - - Application& Application::operator=(std::nullptr_t other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - return *this; - } - - Application& Application::operator=(Application&& other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - } - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool Application::operator==(const Application& other) const - { - return Handle == other.Handle; - } - - bool Application::operator!=(const Application& other) const - { - return Handle != other.Handle; - } - - void Application::AddOnBeforeRender(UnityEngine::Events::UnityAction del) - { - Plugin::UnityEngineApplicationAddEventOnBeforeRender(del.Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - void Application::RemoveOnBeforeRender(UnityEngine::Events::UnityAction del) - { - Plugin::UnityEngineApplicationRemoveEventOnBeforeRender(del.Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } -} - -namespace UnityEngine -{ - namespace SceneManagement - { - SceneManager::SceneManager(std::nullptr_t n) - : SceneManager(Plugin::InternalUse::Only, 0) - { - } - - SceneManager::SceneManager(Plugin::InternalUse iu, int32_t handle) - : System::Object(iu, handle) - { - if (handle) - { - Plugin::ReferenceManagedClass(handle); - } - } - - SceneManager::SceneManager(const SceneManager& other) - : SceneManager(Plugin::InternalUse::Only, other.Handle) - { - } - - SceneManager::SceneManager(SceneManager&& other) - : SceneManager(Plugin::InternalUse::Only, other.Handle) - { - other.Handle = 0; - } - - SceneManager::~SceneManager() - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - } - - SceneManager& SceneManager::operator=(const SceneManager& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedClass(this->Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedClass(this->Handle); - } - return *this; - } - - SceneManager& SceneManager::operator=(std::nullptr_t other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - return *this; - } - - SceneManager& SceneManager::operator=(SceneManager&& other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - } - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool SceneManager::operator==(const SceneManager& other) const - { - return Handle == other.Handle; - } - - bool SceneManager::operator!=(const SceneManager& other) const - { - return Handle != other.Handle; - } - - void SceneManager::AddSceneLoaded(UnityEngine::Events::UnityAction2 del) - { - Plugin::UnityEngineSceneManagementSceneManagerAddEventSceneLoaded(del.Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - void SceneManager::RemoveSceneLoaded(UnityEngine::Events::UnityAction2 del) - { - Plugin::UnityEngineSceneManagementSceneManagerRemoveEventSceneLoaded(del.Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - } -} - -namespace UnityEngine -{ - namespace SceneManagement - { - Scene::Scene() - { - } - } -} - -namespace System -{ - Object::Object(UnityEngine::SceneManagement::Scene& val) - { - int32_t handle = Plugin::BoxScene(val); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - if (handle) - { - Plugin::ReferenceManagedClass(handle); - Handle = handle; - } - } - - Object::operator UnityEngine::SceneManagement::Scene() - { - UnityEngine::SceneManagement::Scene returnVal(Plugin::UnboxScene(Handle)); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnVal; - } -} - -namespace System -{ - Object::Object(UnityEngine::SceneManagement::LoadSceneMode val) - { - int32_t handle = Plugin::BoxLoadSceneMode(val); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - if (handle) - { - Plugin::ReferenceManagedClass(handle); - Handle = handle; - } - } - - Object::operator UnityEngine::SceneManagement::LoadSceneMode() - { - UnityEngine::SceneManagement::LoadSceneMode returnVal(Plugin::UnboxLoadSceneMode(Handle)); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnVal; - } -} - -namespace System -{ - Object::Object(System::Boolean val) - { - int32_t handle = Plugin::BoxBoolean(val); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - if (handle) - { - Plugin::ReferenceManagedClass(handle); - Handle = handle; - } - } - - Object::operator System::Boolean() - { - System::Boolean returnVal(Plugin::UnboxBoolean(Handle)); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnVal; - } -} - -namespace System -{ - Object::Object(int8_t val) - { - int32_t handle = Plugin::BoxSByte(val); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - if (handle) - { - Plugin::ReferenceManagedClass(handle); - Handle = handle; - } - } - - Object::operator int8_t() - { - int8_t returnVal(Plugin::UnboxSByte(Handle)); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnVal; - } -} - -namespace System -{ - Object::Object(uint8_t val) - { - int32_t handle = Plugin::BoxByte(val); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - if (handle) - { - Plugin::ReferenceManagedClass(handle); - Handle = handle; - } - } - - Object::operator uint8_t() - { - uint8_t returnVal(Plugin::UnboxByte(Handle)); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnVal; - } -} - -namespace System -{ - Object::Object(int16_t val) - { - int32_t handle = Plugin::BoxInt16(val); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - if (handle) - { - Plugin::ReferenceManagedClass(handle); - Handle = handle; - } - } - - Object::operator int16_t() - { - int16_t returnVal(Plugin::UnboxInt16(Handle)); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnVal; - } -} - -namespace System -{ - Object::Object(uint16_t val) - { - int32_t handle = Plugin::BoxUInt16(val); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - if (handle) - { - Plugin::ReferenceManagedClass(handle); - Handle = handle; - } - } - - Object::operator uint16_t() - { - uint16_t returnVal(Plugin::UnboxUInt16(Handle)); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnVal; - } -} - -namespace System -{ - Object::Object(int32_t val) - { - int32_t handle = Plugin::BoxInt32(val); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - if (handle) - { - Plugin::ReferenceManagedClass(handle); - Handle = handle; - } - } - - Object::operator int32_t() - { - int32_t returnVal(Plugin::UnboxInt32(Handle)); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnVal; - } -} - -namespace System -{ - Object::Object(uint32_t val) - { - int32_t handle = Plugin::BoxUInt32(val); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - if (handle) - { - Plugin::ReferenceManagedClass(handle); - Handle = handle; - } - } - - Object::operator uint32_t() - { - uint32_t returnVal(Plugin::UnboxUInt32(Handle)); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnVal; - } -} - -namespace System -{ - Object::Object(int64_t val) - { - int32_t handle = Plugin::BoxInt64(val); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - if (handle) - { - Plugin::ReferenceManagedClass(handle); - Handle = handle; - } - } - - Object::operator int64_t() - { - int64_t returnVal(Plugin::UnboxInt64(Handle)); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnVal; - } -} - -namespace System -{ - Object::Object(uint64_t val) - { - int32_t handle = Plugin::BoxUInt64(val); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - if (handle) - { - Plugin::ReferenceManagedClass(handle); - Handle = handle; - } - } - - Object::operator uint64_t() - { - uint64_t returnVal(Plugin::UnboxUInt64(Handle)); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnVal; - } -} - -namespace System -{ - Object::Object(System::Char val) - { - int32_t handle = Plugin::BoxChar(val); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - if (handle) - { - Plugin::ReferenceManagedClass(handle); - Handle = handle; - } - } - - Object::operator System::Char() - { - System::Char returnVal(Plugin::UnboxChar(Handle)); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnVal; - } -} - -namespace System -{ - Object::Object(float val) - { - int32_t handle = Plugin::BoxSingle(val); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - if (handle) - { - Plugin::ReferenceManagedClass(handle); - Handle = handle; - } - } - - Object::operator float() - { - float returnVal(Plugin::UnboxSingle(Handle)); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnVal; - } -} - -namespace System -{ - Object::Object(double val) - { - int32_t handle = Plugin::BoxDouble(val); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - if (handle) - { - Plugin::ReferenceManagedClass(handle); - Handle = handle; - } - } - - Object::operator double() - { - double returnVal(Plugin::UnboxDouble(Handle)); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnVal; - } -} - -namespace MyGame -{ - namespace MonoBehaviours - { - TestScript::TestScript(std::nullptr_t n) - : TestScript(Plugin::InternalUse::Only, 0) - { - } - - TestScript::TestScript(Plugin::InternalUse iu, int32_t handle) - : UnityEngine::MonoBehaviour(iu, handle) - { - if (handle) - { - Plugin::ReferenceManagedClass(handle); - } - } - - TestScript::TestScript(const TestScript& other) - : TestScript(Plugin::InternalUse::Only, other.Handle) - { - } - - TestScript::TestScript(TestScript&& other) - : TestScript(Plugin::InternalUse::Only, other.Handle) - { - other.Handle = 0; - } - - TestScript::~TestScript() - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - } - - TestScript& TestScript::operator=(const TestScript& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedClass(this->Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedClass(this->Handle); - } - return *this; - } - - TestScript& TestScript::operator=(std::nullptr_t other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - return *this; - } - - TestScript& TestScript::operator=(TestScript&& other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - } - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool TestScript::operator==(const TestScript& other) const - { - return Handle == other.Handle; - } - - bool TestScript::operator!=(const TestScript& other) const - { - return Handle != other.Handle; - } - } -} - -namespace Plugin -{ - ArrayElementProxy1_1::ArrayElementProxy1_1(Plugin::InternalUse iu, int32_t handle, int32_t index0) - { - Handle = handle; - Index0 = index0; - } - - void ArrayElementProxy1_1::operator=(int32_t item) - { - Plugin::SystemInt32Array1SetItem1(Handle, Index0, item); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - ArrayElementProxy1_1::operator int32_t() - { - auto returnValue = Plugin::SystemInt32Array1GetItem1(Handle, Index0); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnValue; - } -} - -namespace System -{ - Array1::Array1(std::nullptr_t n) - : Array1(Plugin::InternalUse::Only, 0) - { - } - - Array1::Array1(Plugin::InternalUse iu, int32_t handle) - : System::Array(iu, handle) - { - if (handle) - { - Plugin::ReferenceManagedClass(handle); - } - } - - Array1::Array1(const Array1& other) - : Array1(Plugin::InternalUse::Only, other.Handle) - { - } - - Array1::Array1(Array1&& other) - : Array1(Plugin::InternalUse::Only, other.Handle) - { - other.Handle = 0; - } - - Array1::~Array1() - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - } - - Array1& Array1::operator=(const Array1& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedClass(this->Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedClass(this->Handle); - } - return *this; - } - - Array1& Array1::operator=(std::nullptr_t other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - return *this; - } - - Array1& Array1::operator=(Array1&& other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - } - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool Array1::operator==(const Array1& other) const - { - return Handle == other.Handle; - } - - bool Array1::operator!=(const Array1& other) const - { - return Handle != other.Handle; - } - - Array1::Array1(int32_t length0) - : System::Array(nullptr) - { - auto returnValue = Plugin::SystemSystemInt32Array1Constructor1(length0); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - Handle = returnValue; - if (returnValue) - { - Plugin::ReferenceManagedClass(returnValue); - } - } - - int32_t Array1::GetLength() - { - return Array::GetLength(); - } - - int32_t Array1::GetRank() - { - return Array::GetRank(); - } - - Plugin::ArrayElementProxy1_1 System::Array1::operator[](int32_t index) - { - return Plugin::ArrayElementProxy1_1(Plugin::InternalUse::Only, Handle, index); - } -} - -namespace Plugin -{ - ArrayElementProxy1_1::ArrayElementProxy1_1(Plugin::InternalUse iu, int32_t handle, int32_t index0) - { - Handle = handle; - Index0 = index0; - } - - void ArrayElementProxy1_1::operator=(float item) - { - Plugin::SystemSingleArray1SetItem1(Handle, Index0, item); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - ArrayElementProxy1_1::operator float() - { - auto returnValue = Plugin::SystemSingleArray1GetItem1(Handle, Index0); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnValue; - } -} - -namespace Plugin -{ - ArrayElementProxy1_2::ArrayElementProxy1_2(Plugin::InternalUse iu, int32_t handle, int32_t index0) - { - Handle = handle; - Index0 = index0; - } - - Plugin::ArrayElementProxy2_2 Plugin::ArrayElementProxy1_2::operator[](int32_t index) - { - return Plugin::ArrayElementProxy2_2(Plugin::InternalUse::Only, Handle, Index0, index); - } -} - -namespace Plugin -{ - ArrayElementProxy2_2::ArrayElementProxy2_2(Plugin::InternalUse iu, int32_t handle, int32_t index0, int32_t index1) - { - Handle = handle; - Index0 = index0; - Index1 = index1; - } - - void ArrayElementProxy2_2::operator=(float item) - { - Plugin::SystemSingleArray2SetItem2(Handle, Index0, Index1, item); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - ArrayElementProxy2_2::operator float() - { - auto returnValue = Plugin::SystemSingleArray2GetItem2(Handle, Index0, Index1); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnValue; - } -} - -namespace Plugin -{ - ArrayElementProxy1_3::ArrayElementProxy1_3(Plugin::InternalUse iu, int32_t handle, int32_t index0) - { - Handle = handle; - Index0 = index0; - } - - Plugin::ArrayElementProxy2_3 Plugin::ArrayElementProxy1_3::operator[](int32_t index) - { - return Plugin::ArrayElementProxy2_3(Plugin::InternalUse::Only, Handle, Index0, index); - } -} - -namespace Plugin -{ - ArrayElementProxy2_3::ArrayElementProxy2_3(Plugin::InternalUse iu, int32_t handle, int32_t index0, int32_t index1) - { - Handle = handle; - Index0 = index0; - Index1 = index1; - } - - Plugin::ArrayElementProxy3_3 Plugin::ArrayElementProxy2_3::operator[](int32_t index) - { - return Plugin::ArrayElementProxy3_3(Plugin::InternalUse::Only, Handle, Index0, Index1, index); - } -} - -namespace Plugin -{ - ArrayElementProxy3_3::ArrayElementProxy3_3(Plugin::InternalUse iu, int32_t handle, int32_t index0, int32_t index1, int32_t index2) - { - Handle = handle; - Index0 = index0; - Index1 = index1; - Index2 = index2; - } - - void ArrayElementProxy3_3::operator=(float item) - { - Plugin::SystemSingleArray3SetItem3(Handle, Index0, Index1, Index2, item); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - ArrayElementProxy3_3::operator float() - { - auto returnValue = Plugin::SystemSingleArray3GetItem3(Handle, Index0, Index1, Index2); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnValue; - } -} - -namespace System -{ - Array1::Array1(std::nullptr_t n) - : Array1(Plugin::InternalUse::Only, 0) - { - } - - Array1::Array1(Plugin::InternalUse iu, int32_t handle) - : System::Array(iu, handle) - { - if (handle) - { - Plugin::ReferenceManagedClass(handle); - } - } - - Array1::Array1(const Array1& other) - : Array1(Plugin::InternalUse::Only, other.Handle) - { - } - - Array1::Array1(Array1&& other) - : Array1(Plugin::InternalUse::Only, other.Handle) - { - other.Handle = 0; - } - - Array1::~Array1() - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - } - - Array1& Array1::operator=(const Array1& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedClass(this->Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedClass(this->Handle); - } - return *this; - } - - Array1& Array1::operator=(std::nullptr_t other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - return *this; - } - - Array1& Array1::operator=(Array1&& other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - } - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool Array1::operator==(const Array1& other) const - { - return Handle == other.Handle; - } - - bool Array1::operator!=(const Array1& other) const - { - return Handle != other.Handle; - } - - Array1::Array1(int32_t length0) - : System::Array(nullptr) - { - auto returnValue = Plugin::SystemSystemSingleArray1Constructor1(length0); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - Handle = returnValue; - if (returnValue) - { - Plugin::ReferenceManagedClass(returnValue); - } - } - - int32_t Array1::GetLength() - { - return Array::GetLength(); - } - - int32_t Array1::GetRank() - { - return Array::GetRank(); - } - - Plugin::ArrayElementProxy1_1 System::Array1::operator[](int32_t index) - { - return Plugin::ArrayElementProxy1_1(Plugin::InternalUse::Only, Handle, index); - } -} - -namespace System -{ - Array2::Array2(std::nullptr_t n) - : Array2(Plugin::InternalUse::Only, 0) - { - } - - Array2::Array2(Plugin::InternalUse iu, int32_t handle) - : System::Array(iu, handle) - { - if (handle) - { - Plugin::ReferenceManagedClass(handle); - } - } - - Array2::Array2(const Array2& other) - : Array2(Plugin::InternalUse::Only, other.Handle) - { - } - - Array2::Array2(Array2&& other) - : Array2(Plugin::InternalUse::Only, other.Handle) - { - other.Handle = 0; - } - - Array2::~Array2() - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - } - - Array2& Array2::operator=(const Array2& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedClass(this->Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedClass(this->Handle); - } - return *this; - } - - Array2& Array2::operator=(std::nullptr_t other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - return *this; - } - - Array2& Array2::operator=(Array2&& other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - } - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool Array2::operator==(const Array2& other) const - { - return Handle == other.Handle; - } - - bool Array2::operator!=(const Array2& other) const - { - return Handle != other.Handle; - } - - Array2::Array2(int32_t length0, int32_t length1) - : System::Array(nullptr) - { - auto returnValue = Plugin::SystemSystemSingleArray2Constructor2(length0, length1); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - Handle = returnValue; - if (returnValue) - { - Plugin::ReferenceManagedClass(returnValue); - } - } - - int32_t Array2::GetLength() - { - return Array::GetLength(); - } - - int32_t Array2::GetLength(int32_t dimension) - { - auto returnValue = Plugin::SystemSystemSingleArray2GetLength2(Handle, dimension); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnValue; - } - - int32_t Array2::GetRank() - { - return Array::GetRank(); - } - - Plugin::ArrayElementProxy1_2 System::Array2::operator[](int32_t index) - { - return Plugin::ArrayElementProxy1_2(Plugin::InternalUse::Only, Handle, index); - } -} - -namespace System -{ - Array3::Array3(std::nullptr_t n) - : Array3(Plugin::InternalUse::Only, 0) - { - } - - Array3::Array3(Plugin::InternalUse iu, int32_t handle) - : System::Array(iu, handle) - { - if (handle) - { - Plugin::ReferenceManagedClass(handle); - } - } - - Array3::Array3(const Array3& other) - : Array3(Plugin::InternalUse::Only, other.Handle) - { - } - - Array3::Array3(Array3&& other) - : Array3(Plugin::InternalUse::Only, other.Handle) - { - other.Handle = 0; - } - - Array3::~Array3() - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - } - - Array3& Array3::operator=(const Array3& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedClass(this->Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedClass(this->Handle); - } - return *this; - } - - Array3& Array3::operator=(std::nullptr_t other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - return *this; - } - - Array3& Array3::operator=(Array3&& other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - } - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool Array3::operator==(const Array3& other) const - { - return Handle == other.Handle; - } - - bool Array3::operator!=(const Array3& other) const - { - return Handle != other.Handle; - } - - Array3::Array3(int32_t length0, int32_t length1, int32_t length2) - : System::Array(nullptr) - { - auto returnValue = Plugin::SystemSystemSingleArray3Constructor3(length0, length1, length2); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - Handle = returnValue; - if (returnValue) - { - Plugin::ReferenceManagedClass(returnValue); - } - } - - int32_t Array3::GetLength() - { - return Array::GetLength(); - } - - int32_t Array3::GetLength(int32_t dimension) - { - auto returnValue = Plugin::SystemSystemSingleArray3GetLength3(Handle, dimension); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnValue; - } - - int32_t Array3::GetRank() - { - return Array::GetRank(); - } - - Plugin::ArrayElementProxy1_3 System::Array3::operator[](int32_t index) - { - return Plugin::ArrayElementProxy1_3(Plugin::InternalUse::Only, Handle, index); - } -} - -namespace Plugin -{ - ArrayElementProxy1_1::ArrayElementProxy1_1(Plugin::InternalUse iu, int32_t handle, int32_t index0) - { - Handle = handle; - Index0 = index0; - } - - void ArrayElementProxy1_1::operator=(System::String item) - { - Plugin::SystemStringArray1SetItem1(Handle, Index0, item.Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - ArrayElementProxy1_1::operator System::String() - { - auto returnValue = Plugin::SystemStringArray1GetItem1(Handle, Index0); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return System::String(Plugin::InternalUse::Only, returnValue); - } -} - -namespace System -{ - Array1::Array1(std::nullptr_t n) - : Array1(Plugin::InternalUse::Only, 0) - { - } - - Array1::Array1(Plugin::InternalUse iu, int32_t handle) - : System::Array(iu, handle) - { - if (handle) - { - Plugin::ReferenceManagedClass(handle); - } - } - - Array1::Array1(const Array1& other) - : Array1(Plugin::InternalUse::Only, other.Handle) - { - } - - Array1::Array1(Array1&& other) - : Array1(Plugin::InternalUse::Only, other.Handle) - { - other.Handle = 0; - } - - Array1::~Array1() - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - } - - Array1& Array1::operator=(const Array1& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedClass(this->Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedClass(this->Handle); - } - return *this; - } - - Array1& Array1::operator=(std::nullptr_t other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - return *this; - } - - Array1& Array1::operator=(Array1&& other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - } - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool Array1::operator==(const Array1& other) const - { - return Handle == other.Handle; - } - - bool Array1::operator!=(const Array1& other) const - { - return Handle != other.Handle; - } - - Array1::Array1(int32_t length0) - : System::Array(nullptr) - { - auto returnValue = Plugin::SystemSystemStringArray1Constructor1(length0); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - Handle = returnValue; - if (returnValue) - { - Plugin::ReferenceManagedClass(returnValue); - } - } - - int32_t Array1::GetLength() - { - return Array::GetLength(); - } - - int32_t Array1::GetRank() - { - return Array::GetRank(); - } - - Plugin::ArrayElementProxy1_1 System::Array1::operator[](int32_t index) - { - return Plugin::ArrayElementProxy1_1(Plugin::InternalUse::Only, Handle, index); - } -} - -namespace Plugin -{ - ArrayElementProxy1_1::ArrayElementProxy1_1(Plugin::InternalUse iu, int32_t handle, int32_t index0) - { - Handle = handle; - Index0 = index0; - } - - void ArrayElementProxy1_1::operator=(UnityEngine::Resolution item) - { - Plugin::UnityEngineResolutionArray1SetItem1(Handle, Index0, item); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - ArrayElementProxy1_1::operator UnityEngine::Resolution() - { - auto returnValue = Plugin::UnityEngineResolutionArray1GetItem1(Handle, Index0); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnValue; - } -} - -namespace System -{ - Array1::Array1(std::nullptr_t n) - : Array1(Plugin::InternalUse::Only, 0) - { - } - - Array1::Array1(Plugin::InternalUse iu, int32_t handle) - : System::Array(iu, handle) - { - if (handle) - { - Plugin::ReferenceManagedClass(handle); - } - } - - Array1::Array1(const Array1& other) - : Array1(Plugin::InternalUse::Only, other.Handle) - { - } - - Array1::Array1(Array1&& other) - : Array1(Plugin::InternalUse::Only, other.Handle) - { - other.Handle = 0; - } - - Array1::~Array1() - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - } - - Array1& Array1::operator=(const Array1& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedClass(this->Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedClass(this->Handle); - } - return *this; - } - - Array1& Array1::operator=(std::nullptr_t other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - return *this; - } - - Array1& Array1::operator=(Array1&& other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - } - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool Array1::operator==(const Array1& other) const - { - return Handle == other.Handle; - } - - bool Array1::operator!=(const Array1& other) const - { - return Handle != other.Handle; - } - - Array1::Array1(int32_t length0) - : System::Array(nullptr) - { - auto returnValue = Plugin::UnityEngineUnityEngineResolutionArray1Constructor1(length0); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - Handle = returnValue; - if (returnValue) - { - Plugin::ReferenceManagedClass(returnValue); - } - } - - int32_t Array1::GetLength() - { - return Array::GetLength(); - } - - int32_t Array1::GetRank() - { - return Array::GetRank(); - } - - Plugin::ArrayElementProxy1_1 System::Array1::operator[](int32_t index) - { - return Plugin::ArrayElementProxy1_1(Plugin::InternalUse::Only, Handle, index); - } -} - -namespace Plugin -{ - ArrayElementProxy1_1::ArrayElementProxy1_1(Plugin::InternalUse iu, int32_t handle, int32_t index0) - { - Handle = handle; - Index0 = index0; - } - - void ArrayElementProxy1_1::operator=(UnityEngine::RaycastHit item) - { - Plugin::UnityEngineRaycastHitArray1SetItem1(Handle, Index0, item.Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - ArrayElementProxy1_1::operator UnityEngine::RaycastHit() - { - auto returnValue = Plugin::UnityEngineRaycastHitArray1GetItem1(Handle, Index0); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return UnityEngine::RaycastHit(Plugin::InternalUse::Only, returnValue); - } -} - -namespace System -{ - Array1::Array1(std::nullptr_t n) - : Array1(Plugin::InternalUse::Only, 0) - { - } - - Array1::Array1(Plugin::InternalUse iu, int32_t handle) - : System::Array(iu, handle) - { - if (handle) - { - Plugin::ReferenceManagedClass(handle); - } - } - - Array1::Array1(const Array1& other) - : Array1(Plugin::InternalUse::Only, other.Handle) - { - } - - Array1::Array1(Array1&& other) - : Array1(Plugin::InternalUse::Only, other.Handle) - { - other.Handle = 0; - } - - Array1::~Array1() - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - } - - Array1& Array1::operator=(const Array1& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedClass(this->Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedClass(this->Handle); - } - return *this; - } - - Array1& Array1::operator=(std::nullptr_t other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - return *this; - } - - Array1& Array1::operator=(Array1&& other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - } - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool Array1::operator==(const Array1& other) const - { - return Handle == other.Handle; - } - - bool Array1::operator!=(const Array1& other) const - { - return Handle != other.Handle; - } - - Array1::Array1(int32_t length0) - : System::Array(nullptr) - { - auto returnValue = Plugin::UnityEngineUnityEngineRaycastHitArray1Constructor1(length0); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - Handle = returnValue; - if (returnValue) - { - Plugin::ReferenceManagedClass(returnValue); - } - } - - int32_t Array1::GetLength() - { - return Array::GetLength(); - } - - int32_t Array1::GetRank() - { - return Array::GetRank(); - } - - Plugin::ArrayElementProxy1_1 System::Array1::operator[](int32_t index) - { - return Plugin::ArrayElementProxy1_1(Plugin::InternalUse::Only, Handle, index); - } -} - -namespace Plugin -{ - ArrayElementProxy1_1::ArrayElementProxy1_1(Plugin::InternalUse iu, int32_t handle, int32_t index0) - { - Handle = handle; - Index0 = index0; - } - - void ArrayElementProxy1_1::operator=(UnityEngine::GradientColorKey item) - { - Plugin::UnityEngineGradientColorKeyArray1SetItem1(Handle, Index0, item); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - ArrayElementProxy1_1::operator UnityEngine::GradientColorKey() - { - auto returnValue = Plugin::UnityEngineGradientColorKeyArray1GetItem1(Handle, Index0); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnValue; - } -} - -namespace System -{ - Array1::Array1(std::nullptr_t n) - : Array1(Plugin::InternalUse::Only, 0) - { - } - - Array1::Array1(Plugin::InternalUse iu, int32_t handle) - : System::Array(iu, handle) - { - if (handle) - { - Plugin::ReferenceManagedClass(handle); - } - } - - Array1::Array1(const Array1& other) - : Array1(Plugin::InternalUse::Only, other.Handle) - { - } - - Array1::Array1(Array1&& other) - : Array1(Plugin::InternalUse::Only, other.Handle) - { - other.Handle = 0; - } - - Array1::~Array1() - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - } - - Array1& Array1::operator=(const Array1& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedClass(this->Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedClass(this->Handle); - } - return *this; - } - - Array1& Array1::operator=(std::nullptr_t other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - Handle = 0; - } - return *this; - } - - Array1& Array1::operator=(Array1&& other) - { - if (Handle) - { - Plugin::DereferenceManagedClass(Handle); - } - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool Array1::operator==(const Array1& other) const - { - return Handle == other.Handle; - } - - bool Array1::operator!=(const Array1& other) const - { - return Handle != other.Handle; - } - - Array1::Array1(int32_t length0) - : System::Array(nullptr) - { - auto returnValue = Plugin::UnityEngineUnityEngineGradientColorKeyArray1Constructor1(length0); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - Handle = returnValue; - if (returnValue) - { - Plugin::ReferenceManagedClass(returnValue); - } - } - - int32_t Array1::GetLength() - { - return Array::GetLength(); - } - - int32_t Array1::GetRank() - { - return Array::GetRank(); - } - - Plugin::ArrayElementProxy1_1 System::Array1::operator[](int32_t index) - { - return Plugin::ArrayElementProxy1_1(Plugin::InternalUse::Only, Handle, index); - } -} - -namespace System -{ - Action::Action() - : System::Object(nullptr) - { - CppHandle = Plugin::StoreSystemAction(this); - Plugin::SystemActionConstructor(CppHandle, &Handle, &ClassHandle); - if (Handle) - { - Plugin::ReferenceManagedClass(Handle); - } - else - { - Plugin::RemoveSystemAction(CppHandle); - ClassHandle = 0; - CppHandle = 0; - } - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - Action::Action(std::nullptr_t n) - : System::Object(Plugin::InternalUse::Only, 0) - { - CppHandle = Plugin::StoreSystemAction(this); - ClassHandle = 0; - } - - Action::Action(const Action& other) - : System::Object(Plugin::InternalUse::Only, other.Handle) - { - CppHandle = Plugin::StoreSystemAction(this); - if (Handle) - { - Plugin::ReferenceManagedClass(Handle); - } - ClassHandle = other.ClassHandle; - } - - Action::Action(Action&& other) - : System::Object(Plugin::InternalUse::Only, other.Handle) - { - CppHandle = other.CppHandle; - ClassHandle = other.ClassHandle; - other.Handle = 0; - other.CppHandle = 0; - other.ClassHandle = 0; - } - - Action::Action(Plugin::InternalUse iu, int32_t handle) - : System::Object(iu, handle) - { - CppHandle = Plugin::StoreSystemAction(this); - if (Handle) - { - Plugin::ReferenceManagedClass(Handle); - } - ClassHandle = 0; - } - - Action::~Action() - { - Plugin::RemoveSystemAction(CppHandle); - CppHandle = 0; - if (Handle) - { - int32_t handle = Handle; - int32_t classHandle = ClassHandle; - Handle = 0; - ClassHandle = 0; - if (Plugin::DereferenceManagedClassNoRelease(handle)) - { - Plugin::ReleaseSystemAction(handle, classHandle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - } - } - - Action& Action::operator=(const Action& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedClass(this->Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedClass(this->Handle); - } - ClassHandle = other.ClassHandle; - return *this; - } - - Action& Action::operator=(std::nullptr_t other) - { - if (Handle) - { - int32_t handle = Handle; - int32_t classHandle = ClassHandle; - Handle = 0; - ClassHandle = 0; - if (Plugin::DereferenceManagedClassNoRelease(handle)) - { - Plugin::ReleaseSystemAction(handle, classHandle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - } - ClassHandle = 0; - Handle = 0; - return *this; - } - - Action& Action::operator=(Action&& other) - { - Plugin::RemoveSystemAction(CppHandle); - CppHandle = 0; - if (Handle) - { - int32_t handle = Handle; - int32_t classHandle = ClassHandle; - Handle = 0; - ClassHandle = 0; - if (Plugin::DereferenceManagedClassNoRelease(handle)) - { - Plugin::ReleaseSystemAction(handle, classHandle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - } - ClassHandle = other.ClassHandle; - other.ClassHandle = 0; - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool Action::operator==(const Action& other) const - { - return Handle == other.Handle; - } - - bool Action::operator!=(const Action& other) const - { - return Handle != other.Handle; - } - - void Action::operator()() - { - } - - void Action::Invoke() - { - Plugin::SystemActionInvoke(Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - void Action::operator+=(System::Action& del) - { - Plugin::SystemActionAdd(Handle, del.Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - void Action::operator-=(System::Action& del) - { - Plugin::SystemActionRemove(Handle, del.Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - DLLEXPORT void SystemActionCppInvoke(int32_t cppHandle) - { - try - { - (*Plugin::GetSystemAction(cppHandle))(); - } - catch (System::Exception ex) - { - Plugin::SetException(ex.Handle); - } - catch (...) - { - System::String msg = "Unhandled exception invoking System::Action"; - System::Exception ex(msg); - Plugin::SetException(ex.Handle); - } - } -} - -namespace System -{ - Action1::Action1() - : System::Object(nullptr) - { - CppHandle = Plugin::StoreSystemActionSystemSingle(this); - Plugin::SystemActionSystemSingleConstructor(CppHandle, &Handle, &ClassHandle); - if (Handle) - { - Plugin::ReferenceManagedClass(Handle); - } - else - { - Plugin::RemoveSystemActionSystemSingle(CppHandle); - ClassHandle = 0; - CppHandle = 0; - } - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - Action1::Action1(std::nullptr_t n) - : System::Object(Plugin::InternalUse::Only, 0) - { - CppHandle = Plugin::StoreSystemActionSystemSingle(this); - ClassHandle = 0; - } - - Action1::Action1(const Action1& other) - : System::Object(Plugin::InternalUse::Only, other.Handle) - { - CppHandle = Plugin::StoreSystemActionSystemSingle(this); - if (Handle) - { - Plugin::ReferenceManagedClass(Handle); - } - ClassHandle = other.ClassHandle; - } - - Action1::Action1(Action1&& other) - : System::Object(Plugin::InternalUse::Only, other.Handle) - { - CppHandle = other.CppHandle; - ClassHandle = other.ClassHandle; - other.Handle = 0; - other.CppHandle = 0; - other.ClassHandle = 0; - } - - Action1::Action1(Plugin::InternalUse iu, int32_t handle) - : System::Object(iu, handle) - { - CppHandle = Plugin::StoreSystemActionSystemSingle(this); - if (Handle) - { - Plugin::ReferenceManagedClass(Handle); - } - ClassHandle = 0; - } - - Action1::~Action1() - { - Plugin::RemoveSystemActionSystemSingle(CppHandle); - CppHandle = 0; - if (Handle) - { - int32_t handle = Handle; - int32_t classHandle = ClassHandle; - Handle = 0; - ClassHandle = 0; - if (Plugin::DereferenceManagedClassNoRelease(handle)) - { - Plugin::ReleaseSystemActionSystemSingle(handle, classHandle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - } - } - - Action1& Action1::operator=(const Action1& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedClass(this->Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedClass(this->Handle); - } - ClassHandle = other.ClassHandle; - return *this; - } - - Action1& Action1::operator=(std::nullptr_t other) - { - if (Handle) - { - int32_t handle = Handle; - int32_t classHandle = ClassHandle; - Handle = 0; - ClassHandle = 0; - if (Plugin::DereferenceManagedClassNoRelease(handle)) - { - Plugin::ReleaseSystemActionSystemSingle(handle, classHandle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - } - ClassHandle = 0; - Handle = 0; - return *this; - } - - Action1& Action1::operator=(Action1&& other) - { - Plugin::RemoveSystemActionSystemSingle(CppHandle); - CppHandle = 0; - if (Handle) - { - int32_t handle = Handle; - int32_t classHandle = ClassHandle; - Handle = 0; - ClassHandle = 0; - if (Plugin::DereferenceManagedClassNoRelease(handle)) - { - Plugin::ReleaseSystemActionSystemSingle(handle, classHandle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - } - ClassHandle = other.ClassHandle; - other.ClassHandle = 0; - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool Action1::operator==(const Action1& other) const - { - return Handle == other.Handle; - } - - bool Action1::operator!=(const Action1& other) const - { - return Handle != other.Handle; - } - - void Action1::operator()(float obj) - { - } - - void Action1::Invoke(float obj) - { - Plugin::SystemActionSystemSingleInvoke(Handle, obj); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - void Action1::operator+=(System::Action1& del) - { - Plugin::SystemActionSystemSingleAdd(Handle, del.Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - void Action1::operator-=(System::Action1& del) - { - Plugin::SystemActionSystemSingleRemove(Handle, del.Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - DLLEXPORT void SystemActionSystemSingleCppInvoke(int32_t cppHandle, float obj) - { - try - { - (*Plugin::GetSystemActionSystemSingle(cppHandle))(obj); - } - catch (System::Exception ex) - { - Plugin::SetException(ex.Handle); - } - catch (...) - { - System::String msg = "Unhandled exception invoking System::Action1"; - System::Exception ex(msg); - Plugin::SetException(ex.Handle); - } - } -} - -namespace System -{ - Action2::Action2() - : System::Object(nullptr) - { - CppHandle = Plugin::StoreSystemActionSystemSingle_SystemSingle(this); - Plugin::SystemActionSystemSingle_SystemSingleConstructor(CppHandle, &Handle, &ClassHandle); - if (Handle) - { - Plugin::ReferenceManagedClass(Handle); - } - else - { - Plugin::RemoveSystemActionSystemSingle_SystemSingle(CppHandle); - ClassHandle = 0; - CppHandle = 0; - } - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - Action2::Action2(std::nullptr_t n) - : System::Object(Plugin::InternalUse::Only, 0) - { - CppHandle = Plugin::StoreSystemActionSystemSingle_SystemSingle(this); - ClassHandle = 0; - } - - Action2::Action2(const Action2& other) - : System::Object(Plugin::InternalUse::Only, other.Handle) - { - CppHandle = Plugin::StoreSystemActionSystemSingle_SystemSingle(this); - if (Handle) - { - Plugin::ReferenceManagedClass(Handle); - } - ClassHandle = other.ClassHandle; - } - - Action2::Action2(Action2&& other) - : System::Object(Plugin::InternalUse::Only, other.Handle) - { - CppHandle = other.CppHandle; - ClassHandle = other.ClassHandle; - other.Handle = 0; - other.CppHandle = 0; - other.ClassHandle = 0; - } - - Action2::Action2(Plugin::InternalUse iu, int32_t handle) - : System::Object(iu, handle) - { - CppHandle = Plugin::StoreSystemActionSystemSingle_SystemSingle(this); - if (Handle) - { - Plugin::ReferenceManagedClass(Handle); - } - ClassHandle = 0; - } - - Action2::~Action2() - { - Plugin::RemoveSystemActionSystemSingle_SystemSingle(CppHandle); - CppHandle = 0; - if (Handle) - { - int32_t handle = Handle; - int32_t classHandle = ClassHandle; - Handle = 0; - ClassHandle = 0; - if (Plugin::DereferenceManagedClassNoRelease(handle)) - { - Plugin::ReleaseSystemActionSystemSingle_SystemSingle(handle, classHandle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - } - } - - Action2& Action2::operator=(const Action2& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedClass(this->Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedClass(this->Handle); - } - ClassHandle = other.ClassHandle; - return *this; - } - - Action2& Action2::operator=(std::nullptr_t other) - { - if (Handle) - { - int32_t handle = Handle; - int32_t classHandle = ClassHandle; - Handle = 0; - ClassHandle = 0; - if (Plugin::DereferenceManagedClassNoRelease(handle)) - { - Plugin::ReleaseSystemActionSystemSingle_SystemSingle(handle, classHandle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - } - ClassHandle = 0; - Handle = 0; - return *this; - } - - Action2& Action2::operator=(Action2&& other) - { - Plugin::RemoveSystemActionSystemSingle_SystemSingle(CppHandle); - CppHandle = 0; - if (Handle) - { - int32_t handle = Handle; - int32_t classHandle = ClassHandle; - Handle = 0; - ClassHandle = 0; - if (Plugin::DereferenceManagedClassNoRelease(handle)) - { - Plugin::ReleaseSystemActionSystemSingle_SystemSingle(handle, classHandle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - } - ClassHandle = other.ClassHandle; - other.ClassHandle = 0; - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool Action2::operator==(const Action2& other) const - { - return Handle == other.Handle; - } - - bool Action2::operator!=(const Action2& other) const - { - return Handle != other.Handle; - } - - void Action2::operator()(float arg1, float arg2) - { - } - - void Action2::Invoke(float arg1, float arg2) - { - Plugin::SystemActionSystemSingle_SystemSingleInvoke(Handle, arg1, arg2); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - void Action2::operator+=(System::Action2& del) - { - Plugin::SystemActionSystemSingle_SystemSingleAdd(Handle, del.Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - void Action2::operator-=(System::Action2& del) - { - Plugin::SystemActionSystemSingle_SystemSingleRemove(Handle, del.Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - DLLEXPORT void SystemActionSystemSingle_SystemSingleCppInvoke(int32_t cppHandle, float arg1, float arg2) - { - try - { - (*Plugin::GetSystemActionSystemSingle_SystemSingle(cppHandle))(arg1, arg2); - } - catch (System::Exception ex) - { - Plugin::SetException(ex.Handle); - } - catch (...) - { - System::String msg = "Unhandled exception invoking System::Action2"; - System::Exception ex(msg); - Plugin::SetException(ex.Handle); - } - } -} - -namespace System -{ - Func3::Func3() - : System::Object(nullptr) - { - CppHandle = Plugin::StoreSystemFuncSystemInt32_SystemSingle_SystemDouble(this); - Plugin::SystemFuncSystemInt32_SystemSingle_SystemDoubleConstructor(CppHandle, &Handle, &ClassHandle); - if (Handle) - { - Plugin::ReferenceManagedClass(Handle); - } - else - { - Plugin::RemoveSystemFuncSystemInt32_SystemSingle_SystemDouble(CppHandle); - ClassHandle = 0; - CppHandle = 0; - } - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - Func3::Func3(std::nullptr_t n) - : System::Object(Plugin::InternalUse::Only, 0) - { - CppHandle = Plugin::StoreSystemFuncSystemInt32_SystemSingle_SystemDouble(this); - ClassHandle = 0; - } - - Func3::Func3(const Func3& other) - : System::Object(Plugin::InternalUse::Only, other.Handle) - { - CppHandle = Plugin::StoreSystemFuncSystemInt32_SystemSingle_SystemDouble(this); - if (Handle) - { - Plugin::ReferenceManagedClass(Handle); - } - ClassHandle = other.ClassHandle; - } - - Func3::Func3(Func3&& other) - : System::Object(Plugin::InternalUse::Only, other.Handle) - { - CppHandle = other.CppHandle; - ClassHandle = other.ClassHandle; - other.Handle = 0; - other.CppHandle = 0; - other.ClassHandle = 0; - } - - Func3::Func3(Plugin::InternalUse iu, int32_t handle) - : System::Object(iu, handle) - { - CppHandle = Plugin::StoreSystemFuncSystemInt32_SystemSingle_SystemDouble(this); - if (Handle) - { - Plugin::ReferenceManagedClass(Handle); - } - ClassHandle = 0; - } - - Func3::~Func3() - { - Plugin::RemoveSystemFuncSystemInt32_SystemSingle_SystemDouble(CppHandle); - CppHandle = 0; - if (Handle) - { - int32_t handle = Handle; - int32_t classHandle = ClassHandle; - Handle = 0; - ClassHandle = 0; - if (Plugin::DereferenceManagedClassNoRelease(handle)) - { - Plugin::ReleaseSystemFuncSystemInt32_SystemSingle_SystemDouble(handle, classHandle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - } - } - - Func3& Func3::operator=(const Func3& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedClass(this->Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedClass(this->Handle); - } - ClassHandle = other.ClassHandle; - return *this; - } - - Func3& Func3::operator=(std::nullptr_t other) - { - if (Handle) - { - int32_t handle = Handle; - int32_t classHandle = ClassHandle; - Handle = 0; - ClassHandle = 0; - if (Plugin::DereferenceManagedClassNoRelease(handle)) - { - Plugin::ReleaseSystemFuncSystemInt32_SystemSingle_SystemDouble(handle, classHandle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - } - ClassHandle = 0; - Handle = 0; - return *this; - } - - Func3& Func3::operator=(Func3&& other) - { - Plugin::RemoveSystemFuncSystemInt32_SystemSingle_SystemDouble(CppHandle); - CppHandle = 0; - if (Handle) - { - int32_t handle = Handle; - int32_t classHandle = ClassHandle; - Handle = 0; - ClassHandle = 0; - if (Plugin::DereferenceManagedClassNoRelease(handle)) - { - Plugin::ReleaseSystemFuncSystemInt32_SystemSingle_SystemDouble(handle, classHandle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - } - ClassHandle = other.ClassHandle; - other.ClassHandle = 0; - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool Func3::operator==(const Func3& other) const - { - return Handle == other.Handle; - } - - bool Func3::operator!=(const Func3& other) const - { - return Handle != other.Handle; - } - - double Func3::operator()(int32_t arg1, float arg2) - { - return {}; - } - - double Func3::Invoke(int32_t arg1, float arg2) - { - auto returnValue = Plugin::SystemFuncSystemInt32_SystemSingle_SystemDoubleInvoke(Handle, arg1, arg2); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return returnValue; - } - - void Func3::operator+=(System::Func3& del) - { - Plugin::SystemFuncSystemInt32_SystemSingle_SystemDoubleAdd(Handle, del.Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - void Func3::operator-=(System::Func3& del) - { - Plugin::SystemFuncSystemInt32_SystemSingle_SystemDoubleRemove(Handle, del.Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - DLLEXPORT double SystemFuncSystemInt32_SystemSingle_SystemDoubleCppInvoke(int32_t cppHandle, int32_t arg1, float arg2) - { - try - { - return (*Plugin::GetSystemFuncSystemInt32_SystemSingle_SystemDouble(cppHandle))(arg1, arg2); - } - catch (System::Exception ex) - { - Plugin::SetException(ex.Handle); - return {}; - } - catch (...) - { - System::String msg = "Unhandled exception invoking System::Func3"; - System::Exception ex(msg); - Plugin::SetException(ex.Handle); - return {}; - } - } -} - -namespace System -{ - Func3::Func3() - : System::Object(nullptr) - { - CppHandle = Plugin::StoreSystemFuncSystemInt16_SystemInt32_SystemString(this); - Plugin::SystemFuncSystemInt16_SystemInt32_SystemStringConstructor(CppHandle, &Handle, &ClassHandle); - if (Handle) - { - Plugin::ReferenceManagedClass(Handle); - } - else - { - Plugin::RemoveSystemFuncSystemInt16_SystemInt32_SystemString(CppHandle); - ClassHandle = 0; - CppHandle = 0; - } - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - Func3::Func3(std::nullptr_t n) - : System::Object(Plugin::InternalUse::Only, 0) - { - CppHandle = Plugin::StoreSystemFuncSystemInt16_SystemInt32_SystemString(this); - ClassHandle = 0; - } - - Func3::Func3(const Func3& other) - : System::Object(Plugin::InternalUse::Only, other.Handle) - { - CppHandle = Plugin::StoreSystemFuncSystemInt16_SystemInt32_SystemString(this); - if (Handle) - { - Plugin::ReferenceManagedClass(Handle); - } - ClassHandle = other.ClassHandle; - } - - Func3::Func3(Func3&& other) - : System::Object(Plugin::InternalUse::Only, other.Handle) - { - CppHandle = other.CppHandle; - ClassHandle = other.ClassHandle; - other.Handle = 0; - other.CppHandle = 0; - other.ClassHandle = 0; - } - - Func3::Func3(Plugin::InternalUse iu, int32_t handle) - : System::Object(iu, handle) - { - CppHandle = Plugin::StoreSystemFuncSystemInt16_SystemInt32_SystemString(this); - if (Handle) - { - Plugin::ReferenceManagedClass(Handle); - } - ClassHandle = 0; - } - - Func3::~Func3() - { - Plugin::RemoveSystemFuncSystemInt16_SystemInt32_SystemString(CppHandle); - CppHandle = 0; - if (Handle) - { - int32_t handle = Handle; - int32_t classHandle = ClassHandle; - Handle = 0; - ClassHandle = 0; - if (Plugin::DereferenceManagedClassNoRelease(handle)) - { - Plugin::ReleaseSystemFuncSystemInt16_SystemInt32_SystemString(handle, classHandle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - } - } - - Func3& Func3::operator=(const Func3& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedClass(this->Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedClass(this->Handle); - } - ClassHandle = other.ClassHandle; - return *this; - } - - Func3& Func3::operator=(std::nullptr_t other) - { - if (Handle) - { - int32_t handle = Handle; - int32_t classHandle = ClassHandle; - Handle = 0; - ClassHandle = 0; - if (Plugin::DereferenceManagedClassNoRelease(handle)) - { - Plugin::ReleaseSystemFuncSystemInt16_SystemInt32_SystemString(handle, classHandle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - } - ClassHandle = 0; - Handle = 0; - return *this; - } - - Func3& Func3::operator=(Func3&& other) - { - Plugin::RemoveSystemFuncSystemInt16_SystemInt32_SystemString(CppHandle); - CppHandle = 0; - if (Handle) - { - int32_t handle = Handle; - int32_t classHandle = ClassHandle; - Handle = 0; - ClassHandle = 0; - if (Plugin::DereferenceManagedClassNoRelease(handle)) - { - Plugin::ReleaseSystemFuncSystemInt16_SystemInt32_SystemString(handle, classHandle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - } - ClassHandle = other.ClassHandle; - other.ClassHandle = 0; - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool Func3::operator==(const Func3& other) const - { - return Handle == other.Handle; - } - - bool Func3::operator!=(const Func3& other) const - { - return Handle != other.Handle; - } - - System::String Func3::operator()(int16_t arg1, int32_t arg2) - { - return {}; - } - - System::String Func3::Invoke(int16_t arg1, int32_t arg2) - { - auto returnValue = Plugin::SystemFuncSystemInt16_SystemInt32_SystemStringInvoke(Handle, arg1, arg2); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - return System::String(Plugin::InternalUse::Only, returnValue); - } - - void Func3::operator+=(System::Func3& del) - { - Plugin::SystemFuncSystemInt16_SystemInt32_SystemStringAdd(Handle, del.Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - void Func3::operator-=(System::Func3& del) - { - Plugin::SystemFuncSystemInt16_SystemInt32_SystemStringRemove(Handle, del.Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - DLLEXPORT int32_t SystemFuncSystemInt16_SystemInt32_SystemStringCppInvoke(int32_t cppHandle, int16_t arg1, int32_t arg2) - { - try - { - return (*Plugin::GetSystemFuncSystemInt16_SystemInt32_SystemString(cppHandle))(arg1, arg2).Handle; - } - catch (System::Exception ex) - { - Plugin::SetException(ex.Handle); - return {}; - } - catch (...) - { - System::String msg = "Unhandled exception invoking System::Func3"; - System::Exception ex(msg); - Plugin::SetException(ex.Handle); - return {}; - } - } -} - -namespace System -{ - AppDomainInitializer::AppDomainInitializer() - : System::Object(nullptr) - { - CppHandle = Plugin::StoreSystemAppDomainInitializer(this); - Plugin::SystemAppDomainInitializerConstructor(CppHandle, &Handle, &ClassHandle); - if (Handle) - { - Plugin::ReferenceManagedClass(Handle); - } - else - { - Plugin::RemoveSystemAppDomainInitializer(CppHandle); - ClassHandle = 0; - CppHandle = 0; - } - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - AppDomainInitializer::AppDomainInitializer(std::nullptr_t n) - : System::Object(Plugin::InternalUse::Only, 0) - { - CppHandle = Plugin::StoreSystemAppDomainInitializer(this); - ClassHandle = 0; - } - - AppDomainInitializer::AppDomainInitializer(const AppDomainInitializer& other) - : System::Object(Plugin::InternalUse::Only, other.Handle) - { - CppHandle = Plugin::StoreSystemAppDomainInitializer(this); - if (Handle) - { - Plugin::ReferenceManagedClass(Handle); - } - ClassHandle = other.ClassHandle; - } - - AppDomainInitializer::AppDomainInitializer(AppDomainInitializer&& other) - : System::Object(Plugin::InternalUse::Only, other.Handle) - { - CppHandle = other.CppHandle; - ClassHandle = other.ClassHandle; - other.Handle = 0; - other.CppHandle = 0; - other.ClassHandle = 0; - } - - AppDomainInitializer::AppDomainInitializer(Plugin::InternalUse iu, int32_t handle) - : System::Object(iu, handle) - { - CppHandle = Plugin::StoreSystemAppDomainInitializer(this); - if (Handle) - { - Plugin::ReferenceManagedClass(Handle); - } - ClassHandle = 0; - } - - AppDomainInitializer::~AppDomainInitializer() - { - Plugin::RemoveSystemAppDomainInitializer(CppHandle); - CppHandle = 0; - if (Handle) - { - int32_t handle = Handle; - int32_t classHandle = ClassHandle; - Handle = 0; - ClassHandle = 0; - if (Plugin::DereferenceManagedClassNoRelease(handle)) - { - Plugin::ReleaseSystemAppDomainInitializer(handle, classHandle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - } - } - - AppDomainInitializer& AppDomainInitializer::operator=(const AppDomainInitializer& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedClass(this->Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedClass(this->Handle); - } - ClassHandle = other.ClassHandle; - return *this; - } - - AppDomainInitializer& AppDomainInitializer::operator=(std::nullptr_t other) - { - if (Handle) - { - int32_t handle = Handle; - int32_t classHandle = ClassHandle; - Handle = 0; - ClassHandle = 0; - if (Plugin::DereferenceManagedClassNoRelease(handle)) - { - Plugin::ReleaseSystemAppDomainInitializer(handle, classHandle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - } - ClassHandle = 0; - Handle = 0; - return *this; - } - - AppDomainInitializer& AppDomainInitializer::operator=(AppDomainInitializer&& other) - { - Plugin::RemoveSystemAppDomainInitializer(CppHandle); - CppHandle = 0; - if (Handle) - { - int32_t handle = Handle; - int32_t classHandle = ClassHandle; - Handle = 0; - ClassHandle = 0; - if (Plugin::DereferenceManagedClassNoRelease(handle)) - { - Plugin::ReleaseSystemAppDomainInitializer(handle, classHandle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - } - ClassHandle = other.ClassHandle; - other.ClassHandle = 0; - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool AppDomainInitializer::operator==(const AppDomainInitializer& other) const - { - return Handle == other.Handle; - } - - bool AppDomainInitializer::operator!=(const AppDomainInitializer& other) const - { - return Handle != other.Handle; - } - - void AppDomainInitializer::operator()(System::Array1 args) - { - } - - void AppDomainInitializer::Invoke(System::Array1 args) - { - Plugin::SystemAppDomainInitializerInvoke(Handle, args.Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - void AppDomainInitializer::operator+=(System::AppDomainInitializer& del) - { - Plugin::SystemAppDomainInitializerAdd(Handle, del.Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - void AppDomainInitializer::operator-=(System::AppDomainInitializer& del) - { - Plugin::SystemAppDomainInitializerRemove(Handle, del.Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - DLLEXPORT void SystemAppDomainInitializerCppInvoke(int32_t cppHandle, int32_t argsHandle) - { - try - { - (*Plugin::GetSystemAppDomainInitializer(cppHandle))(System::Array1(Plugin::InternalUse::Only, argsHandle)); - } - catch (System::Exception ex) - { - Plugin::SetException(ex.Handle); - } - catch (...) - { - System::String msg = "Unhandled exception invoking System::AppDomainInitializer"; - System::Exception ex(msg); - Plugin::SetException(ex.Handle); - } - } -} - -namespace UnityEngine -{ - namespace Events - { - UnityAction::UnityAction() - : System::Object(nullptr) - { - CppHandle = Plugin::StoreUnityEngineEventsUnityAction(this); - Plugin::UnityEngineEventsUnityActionConstructor(CppHandle, &Handle, &ClassHandle); - if (Handle) - { - Plugin::ReferenceManagedClass(Handle); - } - else - { - Plugin::RemoveUnityEngineEventsUnityAction(CppHandle); - ClassHandle = 0; - CppHandle = 0; - } - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - UnityAction::UnityAction(std::nullptr_t n) - : System::Object(Plugin::InternalUse::Only, 0) - { - CppHandle = Plugin::StoreUnityEngineEventsUnityAction(this); - ClassHandle = 0; - } - - UnityAction::UnityAction(const UnityAction& other) - : System::Object(Plugin::InternalUse::Only, other.Handle) - { - CppHandle = Plugin::StoreUnityEngineEventsUnityAction(this); - if (Handle) - { - Plugin::ReferenceManagedClass(Handle); - } - ClassHandle = other.ClassHandle; - } - - UnityAction::UnityAction(UnityAction&& other) - : System::Object(Plugin::InternalUse::Only, other.Handle) - { - CppHandle = other.CppHandle; - ClassHandle = other.ClassHandle; - other.Handle = 0; - other.CppHandle = 0; - other.ClassHandle = 0; - } - - UnityAction::UnityAction(Plugin::InternalUse iu, int32_t handle) - : System::Object(iu, handle) - { - CppHandle = Plugin::StoreUnityEngineEventsUnityAction(this); - if (Handle) - { - Plugin::ReferenceManagedClass(Handle); - } - ClassHandle = 0; - } - - UnityAction::~UnityAction() - { - Plugin::RemoveUnityEngineEventsUnityAction(CppHandle); - CppHandle = 0; - if (Handle) - { - int32_t handle = Handle; - int32_t classHandle = ClassHandle; - Handle = 0; - ClassHandle = 0; - if (Plugin::DereferenceManagedClassNoRelease(handle)) - { - Plugin::ReleaseUnityEngineEventsUnityAction(handle, classHandle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - } - } - - UnityAction& UnityAction::operator=(const UnityAction& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedClass(this->Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedClass(this->Handle); - } - ClassHandle = other.ClassHandle; - return *this; - } - - UnityAction& UnityAction::operator=(std::nullptr_t other) - { - if (Handle) - { - int32_t handle = Handle; - int32_t classHandle = ClassHandle; - Handle = 0; - ClassHandle = 0; - if (Plugin::DereferenceManagedClassNoRelease(handle)) - { - Plugin::ReleaseUnityEngineEventsUnityAction(handle, classHandle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - } - ClassHandle = 0; - Handle = 0; - return *this; - } - - UnityAction& UnityAction::operator=(UnityAction&& other) - { - Plugin::RemoveUnityEngineEventsUnityAction(CppHandle); - CppHandle = 0; - if (Handle) - { - int32_t handle = Handle; - int32_t classHandle = ClassHandle; - Handle = 0; - ClassHandle = 0; - if (Plugin::DereferenceManagedClassNoRelease(handle)) - { - Plugin::ReleaseUnityEngineEventsUnityAction(handle, classHandle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - } - ClassHandle = other.ClassHandle; - other.ClassHandle = 0; - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool UnityAction::operator==(const UnityAction& other) const - { - return Handle == other.Handle; - } - - bool UnityAction::operator!=(const UnityAction& other) const - { - return Handle != other.Handle; - } - - void UnityAction::operator()() - { - } - - void UnityAction::Invoke() - { - Plugin::UnityEngineEventsUnityActionInvoke(Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - void UnityAction::operator+=(UnityEngine::Events::UnityAction& del) - { - Plugin::UnityEngineEventsUnityActionAdd(Handle, del.Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - void UnityAction::operator-=(UnityEngine::Events::UnityAction& del) - { - Plugin::UnityEngineEventsUnityActionRemove(Handle, del.Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - DLLEXPORT void UnityEngineEventsUnityActionCppInvoke(int32_t cppHandle) - { - try - { - (*Plugin::GetUnityEngineEventsUnityAction(cppHandle))(); - } - catch (System::Exception ex) - { - Plugin::SetException(ex.Handle); - } - catch (...) - { - System::String msg = "Unhandled exception invoking UnityEngine::Events::UnityAction"; - System::Exception ex(msg); - Plugin::SetException(ex.Handle); - } - } - } -} - -namespace UnityEngine -{ - namespace Events - { - UnityAction2::UnityAction2() - : System::Object(nullptr) - { - CppHandle = Plugin::StoreUnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneMode(this); - Plugin::UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeConstructor(CppHandle, &Handle, &ClassHandle); - if (Handle) - { - Plugin::ReferenceManagedClass(Handle); - } - else - { - Plugin::RemoveUnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneMode(CppHandle); - ClassHandle = 0; - CppHandle = 0; - } - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - UnityAction2::UnityAction2(std::nullptr_t n) - : System::Object(Plugin::InternalUse::Only, 0) - { - CppHandle = Plugin::StoreUnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneMode(this); - ClassHandle = 0; - } - - UnityAction2::UnityAction2(const UnityAction2& other) - : System::Object(Plugin::InternalUse::Only, other.Handle) - { - CppHandle = Plugin::StoreUnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneMode(this); - if (Handle) - { - Plugin::ReferenceManagedClass(Handle); - } - ClassHandle = other.ClassHandle; - } - - UnityAction2::UnityAction2(UnityAction2&& other) - : System::Object(Plugin::InternalUse::Only, other.Handle) - { - CppHandle = other.CppHandle; - ClassHandle = other.ClassHandle; - other.Handle = 0; - other.CppHandle = 0; - other.ClassHandle = 0; - } - - UnityAction2::UnityAction2(Plugin::InternalUse iu, int32_t handle) - : System::Object(iu, handle) - { - CppHandle = Plugin::StoreUnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneMode(this); - if (Handle) - { - Plugin::ReferenceManagedClass(Handle); - } - ClassHandle = 0; - } - - UnityAction2::~UnityAction2() - { - Plugin::RemoveUnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneMode(CppHandle); - CppHandle = 0; - if (Handle) - { - int32_t handle = Handle; - int32_t classHandle = ClassHandle; - Handle = 0; - ClassHandle = 0; - if (Plugin::DereferenceManagedClassNoRelease(handle)) - { - Plugin::ReleaseUnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneMode(handle, classHandle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - } - } - - UnityAction2& UnityAction2::operator=(const UnityAction2& other) - { - if (this->Handle) - { - Plugin::DereferenceManagedClass(this->Handle); - } - this->Handle = other.Handle; - if (this->Handle) - { - Plugin::ReferenceManagedClass(this->Handle); - } - ClassHandle = other.ClassHandle; - return *this; - } - - UnityAction2& UnityAction2::operator=(std::nullptr_t other) - { - if (Handle) - { - int32_t handle = Handle; - int32_t classHandle = ClassHandle; - Handle = 0; - ClassHandle = 0; - if (Plugin::DereferenceManagedClassNoRelease(handle)) - { - Plugin::ReleaseUnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneMode(handle, classHandle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - } - ClassHandle = 0; - Handle = 0; - return *this; - } - - UnityAction2& UnityAction2::operator=(UnityAction2&& other) - { - Plugin::RemoveUnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneMode(CppHandle); - CppHandle = 0; - if (Handle) - { - int32_t handle = Handle; - int32_t classHandle = ClassHandle; - Handle = 0; - ClassHandle = 0; - if (Plugin::DereferenceManagedClassNoRelease(handle)) - { - Plugin::ReleaseUnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneMode(handle, classHandle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - } - ClassHandle = other.ClassHandle; - other.ClassHandle = 0; - Handle = other.Handle; - other.Handle = 0; - return *this; - } - - bool UnityAction2::operator==(const UnityAction2& other) const - { - return Handle == other.Handle; - } - - bool UnityAction2::operator!=(const UnityAction2& other) const - { - return Handle != other.Handle; - } - - void UnityAction2::operator()(UnityEngine::SceneManagement::Scene& arg0, UnityEngine::SceneManagement::LoadSceneMode arg1) - { - } - - void UnityAction2::Invoke(UnityEngine::SceneManagement::Scene& arg0, UnityEngine::SceneManagement::LoadSceneMode arg1) - { - Plugin::UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeInvoke(Handle, arg0, arg1); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - void UnityAction2::operator+=(UnityEngine::Events::UnityAction2& del) - { - Plugin::UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeAdd(Handle, del.Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - void UnityAction2::operator-=(UnityEngine::Events::UnityAction2& del) - { - Plugin::UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeRemove(Handle, del.Handle); - if (Plugin::unhandledCsharpException) - { - System::Exception* ex = Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = nullptr; - ex->ThrowReferenceToThis(); - delete ex; - } - } - - DLLEXPORT void UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeCppInvoke(int32_t cppHandle, UnityEngine::SceneManagement::Scene arg0, UnityEngine::SceneManagement::LoadSceneMode arg1) - { - try - { - (*Plugin::GetUnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneMode(cppHandle))(arg0, arg1); - } - catch (System::Exception ex) - { - Plugin::SetException(ex.Handle); - } - catch (...) - { - System::String msg = "Unhandled exception invoking UnityEngine::Events::UnityAction2"; - System::Exception ex(msg); - Plugin::SetException(ex.Handle); - } - } - } -} - -namespace System -{ - struct NullReferenceExceptionThrower : System::NullReferenceException - { - NullReferenceExceptionThrower(int32_t handle) - : System::NullReferenceException(Plugin::InternalUse::Only, handle) - { - } - - virtual void ThrowReferenceToThis() - { - throw *this; - } - }; -} - -DLLEXPORT void SetCsharpExceptionSystemNullReferenceException(int32_t handle) -{ - delete Plugin::unhandledCsharpException; - Plugin::unhandledCsharpException = new System::NullReferenceExceptionThrower(handle); -} -/*END METHOD DEFINITIONS*/ - -//////////////////////////////////////////////////////////////// -// App-specific functions for this file to call -//////////////////////////////////////////////////////////////// - -// Called when the plugin is initialized -extern void PluginMain(); - -//////////////////////////////////////////////////////////////// -// C++ functions for C# to call -//////////////////////////////////////////////////////////////// - -// Init the plugin -DLLEXPORT void Init( - int32_t maxManagedObjects, - void (*releaseObject)(int32_t handle), - int32_t (*stringNew)(const char* chars), - void (*setException)(int32_t handle), - int32_t (*arrayGetLength)(int32_t handle), - int32_t (*arrayGetRank)(int32_t handle), - /*BEGIN INIT PARAMS*/ - int32_t (*systemDiagnosticsStopwatchConstructor)(), - int64_t (*systemDiagnosticsStopwatchPropertyGetElapsedMilliseconds)(int32_t thisHandle), - void (*systemDiagnosticsStopwatchMethodStart)(int32_t thisHandle), - void (*systemDiagnosticsStopwatchMethodReset)(int32_t thisHandle), - int32_t (*unityEngineObjectPropertyGetName)(int32_t thisHandle), - void (*unityEngineObjectPropertySetName)(int32_t thisHandle, int32_t valueHandle), - System::Boolean (*unityEngineObjectMethodop_EqualityUnityEngineObject_UnityEngineObject)(int32_t xHandle, int32_t yHandle), - System::Boolean (*unityEngineObjectMethodop_ImplicitUnityEngineObject)(int32_t existsHandle), - int32_t (*unityEngineGameObjectConstructor)(), - int32_t (*unityEngineGameObjectConstructorSystemString)(int32_t nameHandle), - int32_t (*unityEngineGameObjectPropertyGetTransform)(int32_t thisHandle), - int32_t (*unityEngineGameObjectMethodAddComponentMyGameMonoBehavioursTestScript)(int32_t thisHandle), - int32_t (*unityEngineComponentPropertyGetTransform)(int32_t thisHandle), - UnityEngine::Vector3 (*unityEngineTransformPropertyGetPosition)(int32_t thisHandle), - void (*unityEngineTransformPropertySetPosition)(int32_t thisHandle, UnityEngine::Vector3& value), - void (*unityEngineDebugMethodLogSystemObject)(int32_t messageHandle), - System::Boolean (*unityEngineAssertionsAssertFieldGetRaiseExceptions)(), - void (*unityEngineAssertionsAssertFieldSetRaiseExceptions)(System::Boolean value), - void (*unityEngineAssertionsAssertMethodAreEqualSystemStringSystemString_SystemString)(int32_t expectedHandle, int32_t actualHandle), - void (*unityEngineAssertionsAssertMethodAreEqualUnityEngineGameObjectUnityEngineGameObject_UnityEngineGameObject)(int32_t expectedHandle, int32_t actualHandle), - void (*unityEngineAudioSettingsMethodGetDSPBufferSizeSystemInt32_SystemInt32)(int32_t* bufferLength, int32_t* numBuffers), - void (*unityEngineNetworkingNetworkTransportMethodGetBroadcastConnectionInfoSystemInt32_SystemString_SystemInt32_SystemByte)(int32_t hostId, int32_t* addressHandle, int32_t* port, uint8_t* error), - void (*unityEngineNetworkingNetworkTransportMethodInit)(), - UnityEngine::Vector3 (*unityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingle)(float x, float y, float z), - float (*unityEngineVector3PropertyGetMagnitude)(UnityEngine::Vector3* thiz), - void (*unityEngineVector3MethodSetSystemSingle_SystemSingle_SystemSingle)(UnityEngine::Vector3* thiz, float newX, float newY, float newZ), - UnityEngine::Vector3 (*unityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3)(UnityEngine::Vector3& a, UnityEngine::Vector3& b), - UnityEngine::Vector3 (*unityEngineVector3Methodop_UnaryNegationUnityEngineVector3)(UnityEngine::Vector3& a), - int32_t (*boxVector3)(UnityEngine::Vector3& val), - UnityEngine::Vector3 (*unboxVector3)(int32_t valHandle), - float (*unityEngineMatrix4x4PropertyGetItem)(UnityEngine::Matrix4x4* thiz, int32_t row, int32_t column), - void (*unityEngineMatrix4x4PropertySetItem)(UnityEngine::Matrix4x4* thiz, int32_t row, int32_t column, float value), - int32_t (*boxMatrix4x4)(UnityEngine::Matrix4x4& val), - UnityEngine::Matrix4x4 (*unboxMatrix4x4)(int32_t valHandle), - void (*releaseUnityEngineRaycastHit)(int32_t handle), - UnityEngine::Vector3 (*unityEngineRaycastHitPropertyGetPoint)(int32_t thisHandle), - void (*unityEngineRaycastHitPropertySetPoint)(int32_t thisHandle, UnityEngine::Vector3& value), - int32_t (*unityEngineRaycastHitPropertyGetTransform)(int32_t thisHandle), - int32_t (*boxRaycastHit)(int32_t valHandle), - int32_t (*unboxRaycastHit)(int32_t valHandle), - int32_t (*boxQueryTriggerInteraction)(UnityEngine::QueryTriggerInteraction val), - UnityEngine::QueryTriggerInteraction (*unboxQueryTriggerInteraction)(int32_t valHandle), - void (*releaseSystemCollectionsGenericKeyValuePairSystemString_SystemDouble)(int32_t handle), - int32_t (*systemCollectionsGenericKeyValuePairSystemString_SystemDoubleConstructorSystemString_SystemDouble)(int32_t keyHandle, double value), - int32_t (*systemCollectionsGenericKeyValuePairSystemString_SystemDoublePropertyGetKey)(int32_t thisHandle), - double (*systemCollectionsGenericKeyValuePairSystemString_SystemDoublePropertyGetValue)(int32_t thisHandle), - int32_t (*boxKeyValuePairSystemString_SystemDouble)(int32_t valHandle), - int32_t (*unboxKeyValuePairSystemString_SystemDouble)(int32_t valHandle), - int32_t (*systemCollectionsGenericListSystemStringConstructor)(), - int32_t (*systemCollectionsGenericListSystemStringPropertyGetItem)(int32_t thisHandle, int32_t index), - void (*systemCollectionsGenericListSystemStringPropertySetItem)(int32_t thisHandle, int32_t index, int32_t valueHandle), - void (*systemCollectionsGenericListSystemStringMethodAddSystemString)(int32_t thisHandle, int32_t itemHandle), - int32_t (*systemCollectionsGenericLinkedListNodeSystemStringConstructorSystemString)(int32_t valueHandle), - int32_t (*systemCollectionsGenericLinkedListNodeSystemStringPropertyGetValue)(int32_t thisHandle), - void (*systemCollectionsGenericLinkedListNodeSystemStringPropertySetValue)(int32_t thisHandle, int32_t valueHandle), - int32_t (*systemRuntimeCompilerServicesStrongBoxSystemStringConstructorSystemString)(int32_t valueHandle), - int32_t (*systemRuntimeCompilerServicesStrongBoxSystemStringFieldGetValue)(int32_t thisHandle), - void (*systemRuntimeCompilerServicesStrongBoxSystemStringFieldSetValue)(int32_t thisHandle, int32_t valueHandle), - int32_t (*systemExceptionConstructorSystemString)(int32_t messageHandle), - int32_t (*unityEngineResolutionPropertyGetWidth)(UnityEngine::Resolution* thiz), - void (*unityEngineResolutionPropertySetWidth)(UnityEngine::Resolution* thiz, int32_t value), - int32_t (*unityEngineResolutionPropertyGetHeight)(UnityEngine::Resolution* thiz), - void (*unityEngineResolutionPropertySetHeight)(UnityEngine::Resolution* thiz, int32_t value), - int32_t (*unityEngineResolutionPropertyGetRefreshRate)(UnityEngine::Resolution* thiz), - void (*unityEngineResolutionPropertySetRefreshRate)(UnityEngine::Resolution* thiz, int32_t value), - int32_t (*boxResolution)(UnityEngine::Resolution& val), - UnityEngine::Resolution (*unboxResolution)(int32_t valHandle), - int32_t (*unityEngineScreenPropertyGetResolutions)(), - UnityEngine::Ray (*unityEngineRayConstructorUnityEngineVector3_UnityEngineVector3)(UnityEngine::Vector3& origin, UnityEngine::Vector3& direction), - int32_t (*boxRay)(UnityEngine::Ray& val), - UnityEngine::Ray (*unboxRay)(int32_t valHandle), - int32_t (*unityEnginePhysicsMethodRaycastNonAllocUnityEngineRay_UnityEngineRaycastHit)(UnityEngine::Ray& ray, int32_t resultsHandle), - int32_t (*unityEnginePhysicsMethodRaycastAllUnityEngineRay)(UnityEngine::Ray& ray), - int32_t (*boxColor)(UnityEngine::Color& val), - UnityEngine::Color (*unboxColor)(int32_t valHandle), - int32_t (*boxGradientColorKey)(UnityEngine::GradientColorKey& val), - UnityEngine::GradientColorKey (*unboxGradientColorKey)(int32_t valHandle), - int32_t (*unityEngineGradientConstructor)(), - int32_t (*unityEngineGradientPropertyGetColorKeys)(int32_t thisHandle), - void (*unityEngineGradientPropertySetColorKeys)(int32_t thisHandle, int32_t valueHandle), - int32_t (*systemAppDomainSetupConstructor)(), - int32_t (*systemAppDomainSetupPropertyGetAppDomainInitializer)(int32_t thisHandle), - void (*systemAppDomainSetupPropertySetAppDomainInitializer)(int32_t thisHandle, int32_t valueHandle), - void (*unityEngineApplicationAddEventOnBeforeRender)(int32_t delHandle), - void (*unityEngineApplicationRemoveEventOnBeforeRender)(int32_t delHandle), - void (*unityEngineSceneManagementSceneManagerAddEventSceneLoaded)(int32_t delHandle), - void (*unityEngineSceneManagementSceneManagerRemoveEventSceneLoaded)(int32_t delHandle), - int32_t (*boxScene)(UnityEngine::SceneManagement::Scene& val), - UnityEngine::SceneManagement::Scene (*unboxScene)(int32_t valHandle), - int32_t (*boxLoadSceneMode)(UnityEngine::SceneManagement::LoadSceneMode val), - UnityEngine::SceneManagement::LoadSceneMode (*unboxLoadSceneMode)(int32_t valHandle), - int32_t (*boxBoolean)(System::Boolean val), - System::Boolean (*unboxBoolean)(int32_t valHandle), - int32_t (*boxSByte)(int8_t val), - int8_t (*unboxSByte)(int32_t valHandle), - int32_t (*boxByte)(uint8_t val), - uint8_t (*unboxByte)(int32_t valHandle), - int32_t (*boxInt16)(int16_t val), - int16_t (*unboxInt16)(int32_t valHandle), - int32_t (*boxUInt16)(uint16_t val), - uint16_t (*unboxUInt16)(int32_t valHandle), - int32_t (*boxInt32)(int32_t val), - int32_t (*unboxInt32)(int32_t valHandle), - int32_t (*boxUInt32)(uint32_t val), - uint32_t (*unboxUInt32)(int32_t valHandle), - int32_t (*boxInt64)(int64_t val), - int64_t (*unboxInt64)(int32_t valHandle), - int32_t (*boxUInt64)(uint64_t val), - uint64_t (*unboxUInt64)(int32_t valHandle), - int32_t (*boxChar)(System::Char val), - System::Char (*unboxChar)(int32_t valHandle), - int32_t (*boxSingle)(float val), - float (*unboxSingle)(int32_t valHandle), - int32_t (*boxDouble)(double val), - double (*unboxDouble)(int32_t valHandle), - int32_t (*systemSystemInt32Array1Constructor1)(int32_t length0), - int32_t (*systemInt32Array1GetItem1)(int32_t thisHandle, int32_t index0), - int32_t (*systemInt32Array1SetItem1)(int32_t thisHandle, int32_t index0, int32_t item), - int32_t (*systemSystemSingleArray1Constructor1)(int32_t length0), - float (*systemSingleArray1GetItem1)(int32_t thisHandle, int32_t index0), - int32_t (*systemSingleArray1SetItem1)(int32_t thisHandle, int32_t index0, float item), - int32_t (*systemSystemSingleArray2Constructor2)(int32_t length0, int32_t length1), - int32_t (*systemSystemSingleArray2GetLength2)(int32_t thisHandle, int32_t dimension), - float (*systemSingleArray2GetItem2)(int32_t thisHandle, int32_t index0, int32_t index1), - int32_t (*systemSingleArray2SetItem2)(int32_t thisHandle, int32_t index0, int32_t index1, float item), - int32_t (*systemSystemSingleArray3Constructor3)(int32_t length0, int32_t length1, int32_t length2), - int32_t (*systemSystemSingleArray3GetLength3)(int32_t thisHandle, int32_t dimension), - float (*systemSingleArray3GetItem3)(int32_t thisHandle, int32_t index0, int32_t index1, int32_t index2), - int32_t (*systemSingleArray3SetItem3)(int32_t thisHandle, int32_t index0, int32_t index1, int32_t index2, float item), - int32_t (*systemSystemStringArray1Constructor1)(int32_t length0), - int32_t (*systemStringArray1GetItem1)(int32_t thisHandle, int32_t index0), - int32_t (*systemStringArray1SetItem1)(int32_t thisHandle, int32_t index0, int32_t itemHandle), - int32_t (*unityEngineUnityEngineResolutionArray1Constructor1)(int32_t length0), - UnityEngine::Resolution (*unityEngineResolutionArray1GetItem1)(int32_t thisHandle, int32_t index0), - int32_t (*unityEngineResolutionArray1SetItem1)(int32_t thisHandle, int32_t index0, UnityEngine::Resolution& item), - int32_t (*unityEngineUnityEngineRaycastHitArray1Constructor1)(int32_t length0), - int32_t (*unityEngineRaycastHitArray1GetItem1)(int32_t thisHandle, int32_t index0), - int32_t (*unityEngineRaycastHitArray1SetItem1)(int32_t thisHandle, int32_t index0, int32_t itemHandle), - int32_t (*unityEngineUnityEngineGradientColorKeyArray1Constructor1)(int32_t length0), - UnityEngine::GradientColorKey (*unityEngineGradientColorKeyArray1GetItem1)(int32_t thisHandle, int32_t index0), - int32_t (*unityEngineGradientColorKeyArray1SetItem1)(int32_t thisHandle, int32_t index0, UnityEngine::GradientColorKey& item), - void (*releaseSystemAction)(int32_t handle, int32_t classHandle), - void (*systemActionConstructor)(int32_t cppHandle, int32_t* handle, int32_t* classHandle), - void (*systemActionInvoke)(int32_t thisHandle), - void (*systemActionAdd)(int32_t thisHandle, int32_t delHandle), - void (*systemActionRemove)(int32_t thisHandle, int32_t delHandle), - void (*releaseSystemActionSystemSingle)(int32_t handle, int32_t classHandle), - void (*systemActionSystemSingleConstructor)(int32_t cppHandle, int32_t* handle, int32_t* classHandle), - void (*systemActionSystemSingleInvoke)(int32_t thisHandle, float obj), - void (*systemActionSystemSingleAdd)(int32_t thisHandle, int32_t delHandle), - void (*systemActionSystemSingleRemove)(int32_t thisHandle, int32_t delHandle), - void (*releaseSystemActionSystemSingle_SystemSingle)(int32_t handle, int32_t classHandle), - void (*systemActionSystemSingle_SystemSingleConstructor)(int32_t cppHandle, int32_t* handle, int32_t* classHandle), - void (*systemActionSystemSingle_SystemSingleInvoke)(int32_t thisHandle, float arg1, float arg2), - void (*systemActionSystemSingle_SystemSingleAdd)(int32_t thisHandle, int32_t delHandle), - void (*systemActionSystemSingle_SystemSingleRemove)(int32_t thisHandle, int32_t delHandle), - void (*releaseSystemFuncSystemInt32_SystemSingle_SystemDouble)(int32_t handle, int32_t classHandle), - void (*systemFuncSystemInt32_SystemSingle_SystemDoubleConstructor)(int32_t cppHandle, int32_t* handle, int32_t* classHandle), - double (*systemFuncSystemInt32_SystemSingle_SystemDoubleInvoke)(int32_t thisHandle, int32_t arg1, float arg2), - void (*systemFuncSystemInt32_SystemSingle_SystemDoubleAdd)(int32_t thisHandle, int32_t delHandle), - void (*systemFuncSystemInt32_SystemSingle_SystemDoubleRemove)(int32_t thisHandle, int32_t delHandle), - void (*releaseSystemFuncSystemInt16_SystemInt32_SystemString)(int32_t handle, int32_t classHandle), - void (*systemFuncSystemInt16_SystemInt32_SystemStringConstructor)(int32_t cppHandle, int32_t* handle, int32_t* classHandle), - int32_t (*systemFuncSystemInt16_SystemInt32_SystemStringInvoke)(int32_t thisHandle, int16_t arg1, int32_t arg2), - void (*systemFuncSystemInt16_SystemInt32_SystemStringAdd)(int32_t thisHandle, int32_t delHandle), - void (*systemFuncSystemInt16_SystemInt32_SystemStringRemove)(int32_t thisHandle, int32_t delHandle), - void (*releaseSystemAppDomainInitializer)(int32_t handle, int32_t classHandle), - void (*systemAppDomainInitializerConstructor)(int32_t cppHandle, int32_t* handle, int32_t* classHandle), - void (*systemAppDomainInitializerInvoke)(int32_t thisHandle, int32_t argsHandle), - void (*systemAppDomainInitializerAdd)(int32_t thisHandle, int32_t delHandle), - void (*systemAppDomainInitializerRemove)(int32_t thisHandle, int32_t delHandle), - void (*releaseUnityEngineEventsUnityAction)(int32_t handle, int32_t classHandle), - void (*unityEngineEventsUnityActionConstructor)(int32_t cppHandle, int32_t* handle, int32_t* classHandle), - void (*unityEngineEventsUnityActionInvoke)(int32_t thisHandle), - void (*unityEngineEventsUnityActionAdd)(int32_t thisHandle, int32_t delHandle), - void (*unityEngineEventsUnityActionRemove)(int32_t thisHandle, int32_t delHandle), - void (*releaseUnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneMode)(int32_t handle, int32_t classHandle), - void (*unityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeConstructor)(int32_t cppHandle, int32_t* handle, int32_t* classHandle), - void (*unityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeInvoke)(int32_t thisHandle, UnityEngine::SceneManagement::Scene& arg0, UnityEngine::SceneManagement::LoadSceneMode arg1), - void (*unityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeAdd)(int32_t thisHandle, int32_t delHandle), - void (*unityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeRemove)(int32_t thisHandle, int32_t delHandle) - /*END INIT PARAMS*/) -{ - using namespace Plugin; - - // Init managed object ref counting - Plugin::RefCountsLenClass = maxManagedObjects; - Plugin::RefCountsClass = new int32_t[maxManagedObjects](); - - // Init pointers to C# functions - Plugin::StringNew = stringNew; - Plugin::ReleaseObject = releaseObject; - Plugin::SetException = setException; - Plugin::ArrayGetLength = arrayGetLength; - Plugin::ArrayGetRank = arrayGetRank; - /*BEGIN INIT BODY*/ - Plugin::SystemDiagnosticsStopwatchConstructor = systemDiagnosticsStopwatchConstructor; - Plugin::SystemDiagnosticsStopwatchPropertyGetElapsedMilliseconds = systemDiagnosticsStopwatchPropertyGetElapsedMilliseconds; - Plugin::SystemDiagnosticsStopwatchMethodStart = systemDiagnosticsStopwatchMethodStart; - Plugin::SystemDiagnosticsStopwatchMethodReset = systemDiagnosticsStopwatchMethodReset; - Plugin::UnityEngineObjectPropertyGetName = unityEngineObjectPropertyGetName; - Plugin::UnityEngineObjectPropertySetName = unityEngineObjectPropertySetName; - Plugin::UnityEngineObjectMethodop_EqualityUnityEngineObject_UnityEngineObject = unityEngineObjectMethodop_EqualityUnityEngineObject_UnityEngineObject; - Plugin::UnityEngineObjectMethodop_ImplicitUnityEngineObject = unityEngineObjectMethodop_ImplicitUnityEngineObject; - Plugin::UnityEngineGameObjectConstructor = unityEngineGameObjectConstructor; - Plugin::UnityEngineGameObjectConstructorSystemString = unityEngineGameObjectConstructorSystemString; - Plugin::UnityEngineGameObjectPropertyGetTransform = unityEngineGameObjectPropertyGetTransform; - Plugin::UnityEngineGameObjectMethodAddComponentMyGameMonoBehavioursTestScript = unityEngineGameObjectMethodAddComponentMyGameMonoBehavioursTestScript; - Plugin::UnityEngineComponentPropertyGetTransform = unityEngineComponentPropertyGetTransform; - Plugin::UnityEngineTransformPropertyGetPosition = unityEngineTransformPropertyGetPosition; - Plugin::UnityEngineTransformPropertySetPosition = unityEngineTransformPropertySetPosition; - Plugin::UnityEngineDebugMethodLogSystemObject = unityEngineDebugMethodLogSystemObject; - Plugin::UnityEngineAssertionsAssertFieldGetRaiseExceptions = unityEngineAssertionsAssertFieldGetRaiseExceptions; - Plugin::UnityEngineAssertionsAssertFieldSetRaiseExceptions = unityEngineAssertionsAssertFieldSetRaiseExceptions; - Plugin::UnityEngineAssertionsAssertMethodAreEqualSystemStringSystemString_SystemString = unityEngineAssertionsAssertMethodAreEqualSystemStringSystemString_SystemString; - Plugin::UnityEngineAssertionsAssertMethodAreEqualUnityEngineGameObjectUnityEngineGameObject_UnityEngineGameObject = unityEngineAssertionsAssertMethodAreEqualUnityEngineGameObjectUnityEngineGameObject_UnityEngineGameObject; - Plugin::UnityEngineAudioSettingsMethodGetDSPBufferSizeSystemInt32_SystemInt32 = unityEngineAudioSettingsMethodGetDSPBufferSizeSystemInt32_SystemInt32; - Plugin::UnityEngineNetworkingNetworkTransportMethodGetBroadcastConnectionInfoSystemInt32_SystemString_SystemInt32_SystemByte = unityEngineNetworkingNetworkTransportMethodGetBroadcastConnectionInfoSystemInt32_SystemString_SystemInt32_SystemByte; - Plugin::UnityEngineNetworkingNetworkTransportMethodInit = unityEngineNetworkingNetworkTransportMethodInit; - Plugin::UnityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingle = unityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingle; - Plugin::UnityEngineVector3PropertyGetMagnitude = unityEngineVector3PropertyGetMagnitude; - Plugin::UnityEngineVector3MethodSetSystemSingle_SystemSingle_SystemSingle = unityEngineVector3MethodSetSystemSingle_SystemSingle_SystemSingle; - Plugin::UnityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3 = unityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3; - Plugin::UnityEngineVector3Methodop_UnaryNegationUnityEngineVector3 = unityEngineVector3Methodop_UnaryNegationUnityEngineVector3; - Plugin::BoxVector3 = boxVector3; - Plugin::UnboxVector3 = unboxVector3; - Plugin::UnityEngineMatrix4x4PropertyGetItem = unityEngineMatrix4x4PropertyGetItem; - Plugin::UnityEngineMatrix4x4PropertySetItem = unityEngineMatrix4x4PropertySetItem; - Plugin::BoxMatrix4x4 = boxMatrix4x4; - Plugin::UnboxMatrix4x4 = unboxMatrix4x4; - Plugin::ReleaseUnityEngineRaycastHit = releaseUnityEngineRaycastHit; - Plugin::RefCountsUnityEngineRaycastHit = new int32_t[1000](); - Plugin::UnityEngineRaycastHitPropertyGetPoint = unityEngineRaycastHitPropertyGetPoint; - Plugin::UnityEngineRaycastHitPropertySetPoint = unityEngineRaycastHitPropertySetPoint; - Plugin::UnityEngineRaycastHitPropertyGetTransform = unityEngineRaycastHitPropertyGetTransform; - Plugin::BoxRaycastHit = boxRaycastHit; - Plugin::UnboxRaycastHit = unboxRaycastHit; - Plugin::BoxQueryTriggerInteraction = boxQueryTriggerInteraction; - Plugin::UnboxQueryTriggerInteraction = unboxQueryTriggerInteraction; - Plugin::ReleaseSystemCollectionsGenericKeyValuePairSystemString_SystemDouble = releaseSystemCollectionsGenericKeyValuePairSystemString_SystemDouble; - Plugin::RefCountsSystemCollectionsGenericKeyValuePairSystemString_SystemDouble = new int32_t[maxManagedObjects](); - Plugin::SystemCollectionsGenericKeyValuePairSystemString_SystemDoubleConstructorSystemString_SystemDouble = systemCollectionsGenericKeyValuePairSystemString_SystemDoubleConstructorSystemString_SystemDouble; - Plugin::SystemCollectionsGenericKeyValuePairSystemString_SystemDoublePropertyGetKey = systemCollectionsGenericKeyValuePairSystemString_SystemDoublePropertyGetKey; - Plugin::SystemCollectionsGenericKeyValuePairSystemString_SystemDoublePropertyGetValue = systemCollectionsGenericKeyValuePairSystemString_SystemDoublePropertyGetValue; - Plugin::BoxKeyValuePairSystemString_SystemDouble = boxKeyValuePairSystemString_SystemDouble; - Plugin::UnboxKeyValuePairSystemString_SystemDouble = unboxKeyValuePairSystemString_SystemDouble; - Plugin::SystemCollectionsGenericListSystemStringConstructor = systemCollectionsGenericListSystemStringConstructor; - Plugin::SystemCollectionsGenericListSystemStringPropertyGetItem = systemCollectionsGenericListSystemStringPropertyGetItem; - Plugin::SystemCollectionsGenericListSystemStringPropertySetItem = systemCollectionsGenericListSystemStringPropertySetItem; - Plugin::SystemCollectionsGenericListSystemStringMethodAddSystemString = systemCollectionsGenericListSystemStringMethodAddSystemString; - Plugin::SystemCollectionsGenericLinkedListNodeSystemStringConstructorSystemString = systemCollectionsGenericLinkedListNodeSystemStringConstructorSystemString; - Plugin::SystemCollectionsGenericLinkedListNodeSystemStringPropertyGetValue = systemCollectionsGenericLinkedListNodeSystemStringPropertyGetValue; - Plugin::SystemCollectionsGenericLinkedListNodeSystemStringPropertySetValue = systemCollectionsGenericLinkedListNodeSystemStringPropertySetValue; - Plugin::SystemRuntimeCompilerServicesStrongBoxSystemStringConstructorSystemString = systemRuntimeCompilerServicesStrongBoxSystemStringConstructorSystemString; - Plugin::SystemRuntimeCompilerServicesStrongBoxSystemStringFieldGetValue = systemRuntimeCompilerServicesStrongBoxSystemStringFieldGetValue; - Plugin::SystemRuntimeCompilerServicesStrongBoxSystemStringFieldSetValue = systemRuntimeCompilerServicesStrongBoxSystemStringFieldSetValue; - Plugin::SystemExceptionConstructorSystemString = systemExceptionConstructorSystemString; - Plugin::UnityEngineResolutionPropertyGetWidth = unityEngineResolutionPropertyGetWidth; - Plugin::UnityEngineResolutionPropertySetWidth = unityEngineResolutionPropertySetWidth; - Plugin::UnityEngineResolutionPropertyGetHeight = unityEngineResolutionPropertyGetHeight; - Plugin::UnityEngineResolutionPropertySetHeight = unityEngineResolutionPropertySetHeight; - Plugin::UnityEngineResolutionPropertyGetRefreshRate = unityEngineResolutionPropertyGetRefreshRate; - Plugin::UnityEngineResolutionPropertySetRefreshRate = unityEngineResolutionPropertySetRefreshRate; - Plugin::BoxResolution = boxResolution; - Plugin::UnboxResolution = unboxResolution; - Plugin::UnityEngineScreenPropertyGetResolutions = unityEngineScreenPropertyGetResolutions; - Plugin::UnityEngineRayConstructorUnityEngineVector3_UnityEngineVector3 = unityEngineRayConstructorUnityEngineVector3_UnityEngineVector3; - Plugin::BoxRay = boxRay; - Plugin::UnboxRay = unboxRay; - Plugin::UnityEnginePhysicsMethodRaycastNonAllocUnityEngineRay_UnityEngineRaycastHit = unityEnginePhysicsMethodRaycastNonAllocUnityEngineRay_UnityEngineRaycastHit; - Plugin::UnityEnginePhysicsMethodRaycastAllUnityEngineRay = unityEnginePhysicsMethodRaycastAllUnityEngineRay; - Plugin::BoxColor = boxColor; - Plugin::UnboxColor = unboxColor; - Plugin::BoxGradientColorKey = boxGradientColorKey; - Plugin::UnboxGradientColorKey = unboxGradientColorKey; - Plugin::UnityEngineGradientConstructor = unityEngineGradientConstructor; - Plugin::UnityEngineGradientPropertyGetColorKeys = unityEngineGradientPropertyGetColorKeys; - Plugin::UnityEngineGradientPropertySetColorKeys = unityEngineGradientPropertySetColorKeys; - Plugin::SystemAppDomainSetupConstructor = systemAppDomainSetupConstructor; - Plugin::SystemAppDomainSetupPropertyGetAppDomainInitializer = systemAppDomainSetupPropertyGetAppDomainInitializer; - Plugin::SystemAppDomainSetupPropertySetAppDomainInitializer = systemAppDomainSetupPropertySetAppDomainInitializer; - Plugin::UnityEngineApplicationAddEventOnBeforeRender = unityEngineApplicationAddEventOnBeforeRender; - Plugin::UnityEngineApplicationRemoveEventOnBeforeRender = unityEngineApplicationRemoveEventOnBeforeRender; - Plugin::UnityEngineSceneManagementSceneManagerAddEventSceneLoaded = unityEngineSceneManagementSceneManagerAddEventSceneLoaded; - Plugin::UnityEngineSceneManagementSceneManagerRemoveEventSceneLoaded = unityEngineSceneManagementSceneManagerRemoveEventSceneLoaded; - Plugin::BoxScene = boxScene; - Plugin::UnboxScene = unboxScene; - Plugin::BoxLoadSceneMode = boxLoadSceneMode; - Plugin::UnboxLoadSceneMode = unboxLoadSceneMode; - 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; - Plugin::SystemSystemInt32Array1Constructor1 = systemSystemInt32Array1Constructor1; - Plugin::SystemInt32Array1GetItem1 = systemInt32Array1GetItem1; - Plugin::SystemInt32Array1SetItem1 = systemInt32Array1SetItem1; - Plugin::SystemSystemSingleArray1Constructor1 = systemSystemSingleArray1Constructor1; - Plugin::SystemSingleArray1GetItem1 = systemSingleArray1GetItem1; - Plugin::SystemSingleArray1SetItem1 = systemSingleArray1SetItem1; - Plugin::SystemSystemSingleArray2Constructor2 = systemSystemSingleArray2Constructor2; - Plugin::SystemSystemSingleArray2GetLength2 = systemSystemSingleArray2GetLength2; - Plugin::SystemSingleArray2GetItem2 = systemSingleArray2GetItem2; - Plugin::SystemSingleArray2SetItem2 = systemSingleArray2SetItem2; - Plugin::SystemSystemSingleArray3Constructor3 = systemSystemSingleArray3Constructor3; - Plugin::SystemSystemSingleArray3GetLength3 = systemSystemSingleArray3GetLength3; - Plugin::SystemSingleArray3GetItem3 = systemSingleArray3GetItem3; - Plugin::SystemSingleArray3SetItem3 = systemSingleArray3SetItem3; - Plugin::SystemSystemStringArray1Constructor1 = systemSystemStringArray1Constructor1; - Plugin::SystemStringArray1GetItem1 = systemStringArray1GetItem1; - Plugin::SystemStringArray1SetItem1 = systemStringArray1SetItem1; - Plugin::UnityEngineUnityEngineResolutionArray1Constructor1 = unityEngineUnityEngineResolutionArray1Constructor1; - Plugin::UnityEngineResolutionArray1GetItem1 = unityEngineResolutionArray1GetItem1; - Plugin::UnityEngineResolutionArray1SetItem1 = unityEngineResolutionArray1SetItem1; - Plugin::UnityEngineUnityEngineRaycastHitArray1Constructor1 = unityEngineUnityEngineRaycastHitArray1Constructor1; - Plugin::UnityEngineRaycastHitArray1GetItem1 = unityEngineRaycastHitArray1GetItem1; - Plugin::UnityEngineRaycastHitArray1SetItem1 = unityEngineRaycastHitArray1SetItem1; - Plugin::UnityEngineUnityEngineGradientColorKeyArray1Constructor1 = unityEngineUnityEngineGradientColorKeyArray1Constructor1; - Plugin::UnityEngineGradientColorKeyArray1GetItem1 = unityEngineGradientColorKeyArray1GetItem1; - Plugin::UnityEngineGradientColorKeyArray1SetItem1 = unityEngineGradientColorKeyArray1SetItem1; - SystemActionFreeListSize = maxManagedObjects; - SystemActionFreeList = new System::Action*[SystemActionFreeListSize]; - for (int32_t i = 0, end = SystemActionFreeListSize - 1; i < end; ++i) - { - SystemActionFreeList[i] = (System::Action*)(SystemActionFreeList + i + 1); - } - SystemActionFreeList[SystemActionFreeListSize - 1] = nullptr; - NextFreeSystemAction = SystemActionFreeList + 1; - Plugin::ReleaseSystemAction = releaseSystemAction; - Plugin::SystemActionConstructor = systemActionConstructor; - Plugin::SystemActionInvoke = systemActionInvoke; - Plugin::SystemActionAdd = systemActionAdd; - Plugin::SystemActionRemove = systemActionRemove; - SystemActionSystemSingleFreeListSize = maxManagedObjects; - SystemActionSystemSingleFreeList = new System::Action1*[SystemActionSystemSingleFreeListSize]; - for (int32_t i = 0, end = SystemActionSystemSingleFreeListSize - 1; i < end; ++i) - { - SystemActionSystemSingleFreeList[i] = (System::Action1*)(SystemActionSystemSingleFreeList + i + 1); - } - SystemActionSystemSingleFreeList[SystemActionSystemSingleFreeListSize - 1] = nullptr; - NextFreeSystemActionSystemSingle = SystemActionSystemSingleFreeList + 1; - Plugin::ReleaseSystemActionSystemSingle = releaseSystemActionSystemSingle; - Plugin::SystemActionSystemSingleConstructor = systemActionSystemSingleConstructor; - Plugin::SystemActionSystemSingleInvoke = systemActionSystemSingleInvoke; - Plugin::SystemActionSystemSingleAdd = systemActionSystemSingleAdd; - Plugin::SystemActionSystemSingleRemove = systemActionSystemSingleRemove; - SystemActionSystemSingle_SystemSingleFreeListSize = 100; - SystemActionSystemSingle_SystemSingleFreeList = new System::Action2*[SystemActionSystemSingle_SystemSingleFreeListSize]; - for (int32_t i = 0, end = SystemActionSystemSingle_SystemSingleFreeListSize - 1; i < end; ++i) - { - SystemActionSystemSingle_SystemSingleFreeList[i] = (System::Action2*)(SystemActionSystemSingle_SystemSingleFreeList + i + 1); - } - SystemActionSystemSingle_SystemSingleFreeList[SystemActionSystemSingle_SystemSingleFreeListSize - 1] = nullptr; - NextFreeSystemActionSystemSingle_SystemSingle = SystemActionSystemSingle_SystemSingleFreeList + 1; - Plugin::ReleaseSystemActionSystemSingle_SystemSingle = releaseSystemActionSystemSingle_SystemSingle; - Plugin::SystemActionSystemSingle_SystemSingleConstructor = systemActionSystemSingle_SystemSingleConstructor; - Plugin::SystemActionSystemSingle_SystemSingleInvoke = systemActionSystemSingle_SystemSingleInvoke; - Plugin::SystemActionSystemSingle_SystemSingleAdd = systemActionSystemSingle_SystemSingleAdd; - Plugin::SystemActionSystemSingle_SystemSingleRemove = systemActionSystemSingle_SystemSingleRemove; - SystemFuncSystemInt32_SystemSingle_SystemDoubleFreeListSize = 50; - SystemFuncSystemInt32_SystemSingle_SystemDoubleFreeList = new System::Func3*[SystemFuncSystemInt32_SystemSingle_SystemDoubleFreeListSize]; - for (int32_t i = 0, end = SystemFuncSystemInt32_SystemSingle_SystemDoubleFreeListSize - 1; i < end; ++i) - { - SystemFuncSystemInt32_SystemSingle_SystemDoubleFreeList[i] = (System::Func3*)(SystemFuncSystemInt32_SystemSingle_SystemDoubleFreeList + i + 1); - } - SystemFuncSystemInt32_SystemSingle_SystemDoubleFreeList[SystemFuncSystemInt32_SystemSingle_SystemDoubleFreeListSize - 1] = nullptr; - NextFreeSystemFuncSystemInt32_SystemSingle_SystemDouble = SystemFuncSystemInt32_SystemSingle_SystemDoubleFreeList + 1; - Plugin::ReleaseSystemFuncSystemInt32_SystemSingle_SystemDouble = releaseSystemFuncSystemInt32_SystemSingle_SystemDouble; - Plugin::SystemFuncSystemInt32_SystemSingle_SystemDoubleConstructor = systemFuncSystemInt32_SystemSingle_SystemDoubleConstructor; - Plugin::SystemFuncSystemInt32_SystemSingle_SystemDoubleInvoke = systemFuncSystemInt32_SystemSingle_SystemDoubleInvoke; - Plugin::SystemFuncSystemInt32_SystemSingle_SystemDoubleAdd = systemFuncSystemInt32_SystemSingle_SystemDoubleAdd; - Plugin::SystemFuncSystemInt32_SystemSingle_SystemDoubleRemove = systemFuncSystemInt32_SystemSingle_SystemDoubleRemove; - SystemFuncSystemInt16_SystemInt32_SystemStringFreeListSize = 25; - SystemFuncSystemInt16_SystemInt32_SystemStringFreeList = new System::Func3*[SystemFuncSystemInt16_SystemInt32_SystemStringFreeListSize]; - for (int32_t i = 0, end = SystemFuncSystemInt16_SystemInt32_SystemStringFreeListSize - 1; i < end; ++i) - { - SystemFuncSystemInt16_SystemInt32_SystemStringFreeList[i] = (System::Func3*)(SystemFuncSystemInt16_SystemInt32_SystemStringFreeList + i + 1); - } - SystemFuncSystemInt16_SystemInt32_SystemStringFreeList[SystemFuncSystemInt16_SystemInt32_SystemStringFreeListSize - 1] = nullptr; - NextFreeSystemFuncSystemInt16_SystemInt32_SystemString = SystemFuncSystemInt16_SystemInt32_SystemStringFreeList + 1; - Plugin::ReleaseSystemFuncSystemInt16_SystemInt32_SystemString = releaseSystemFuncSystemInt16_SystemInt32_SystemString; - Plugin::SystemFuncSystemInt16_SystemInt32_SystemStringConstructor = systemFuncSystemInt16_SystemInt32_SystemStringConstructor; - Plugin::SystemFuncSystemInt16_SystemInt32_SystemStringInvoke = systemFuncSystemInt16_SystemInt32_SystemStringInvoke; - Plugin::SystemFuncSystemInt16_SystemInt32_SystemStringAdd = systemFuncSystemInt16_SystemInt32_SystemStringAdd; - Plugin::SystemFuncSystemInt16_SystemInt32_SystemStringRemove = systemFuncSystemInt16_SystemInt32_SystemStringRemove; - SystemAppDomainInitializerFreeListSize = maxManagedObjects; - SystemAppDomainInitializerFreeList = new System::AppDomainInitializer*[SystemAppDomainInitializerFreeListSize]; - for (int32_t i = 0, end = SystemAppDomainInitializerFreeListSize - 1; i < end; ++i) - { - SystemAppDomainInitializerFreeList[i] = (System::AppDomainInitializer*)(SystemAppDomainInitializerFreeList + i + 1); - } - SystemAppDomainInitializerFreeList[SystemAppDomainInitializerFreeListSize - 1] = nullptr; - NextFreeSystemAppDomainInitializer = SystemAppDomainInitializerFreeList + 1; - Plugin::ReleaseSystemAppDomainInitializer = releaseSystemAppDomainInitializer; - Plugin::SystemAppDomainInitializerConstructor = systemAppDomainInitializerConstructor; - Plugin::SystemAppDomainInitializerInvoke = systemAppDomainInitializerInvoke; - Plugin::SystemAppDomainInitializerAdd = systemAppDomainInitializerAdd; - Plugin::SystemAppDomainInitializerRemove = systemAppDomainInitializerRemove; - UnityEngineEventsUnityActionFreeListSize = maxManagedObjects; - UnityEngineEventsUnityActionFreeList = new UnityEngine::Events::UnityAction*[UnityEngineEventsUnityActionFreeListSize]; - for (int32_t i = 0, end = UnityEngineEventsUnityActionFreeListSize - 1; i < end; ++i) - { - UnityEngineEventsUnityActionFreeList[i] = (UnityEngine::Events::UnityAction*)(UnityEngineEventsUnityActionFreeList + i + 1); - } - UnityEngineEventsUnityActionFreeList[UnityEngineEventsUnityActionFreeListSize - 1] = nullptr; - NextFreeUnityEngineEventsUnityAction = UnityEngineEventsUnityActionFreeList + 1; - Plugin::ReleaseUnityEngineEventsUnityAction = releaseUnityEngineEventsUnityAction; - Plugin::UnityEngineEventsUnityActionConstructor = unityEngineEventsUnityActionConstructor; - Plugin::UnityEngineEventsUnityActionInvoke = unityEngineEventsUnityActionInvoke; - Plugin::UnityEngineEventsUnityActionAdd = unityEngineEventsUnityActionAdd; - Plugin::UnityEngineEventsUnityActionRemove = unityEngineEventsUnityActionRemove; - UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeFreeListSize = 10; - UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeFreeList = new UnityEngine::Events::UnityAction2*[UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeFreeListSize]; - for (int32_t i = 0, end = UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeFreeListSize - 1; i < end; ++i) - { - UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeFreeList[i] = (UnityEngine::Events::UnityAction2*)(UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeFreeList + i + 1); - } - UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeFreeList[UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeFreeListSize - 1] = nullptr; - NextFreeUnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneMode = UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeFreeList + 1; - Plugin::ReleaseUnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneMode = releaseUnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneMode; - Plugin::UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeConstructor = unityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeConstructor; - Plugin::UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeInvoke = unityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeInvoke; - Plugin::UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeAdd = unityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeAdd; - Plugin::UnityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeRemove = unityEngineEventsUnityActionUnityEngineSceneManagementScene_UnityEngineSceneManagementLoadSceneModeRemove; - /*END INIT BODY*/ - - try - { - PluginMain(); - } - catch (System::Exception ex) - { - Plugin::SetException(ex.Handle); - } - catch (...) - { - System::String msg = "Unhandled exception in PluginMain"; - System::Exception ex(msg); - Plugin::SetException(ex.Handle); - } -} - -// Receive an unhandled exception from C# -DLLEXPORT void SetCsharpException(int32_t handle) -{ - Plugin::unhandledCsharpException = new System::Exception( - Plugin::InternalUse::Only, - handle); -} - -/*BEGIN MONOBEHAVIOUR MESSAGES*/ -DLLEXPORT void MyGameMonoBehavioursTestScriptAwake(int32_t thisHandle) -{ - MyGame::MonoBehaviours::TestScript thiz(Plugin::InternalUse::Only, thisHandle); - try - { - thiz.Awake(); - } - catch (System::Exception ex) - { - Plugin::SetException(ex.Handle); - } - catch (...) - { - System::String msg = "Unhandled exception in MyGame::MonoBehaviours::TestScript::Awake"; - System::Exception ex(msg); - Plugin::SetException(ex.Handle); - } -} - - -DLLEXPORT void MyGameMonoBehavioursTestScriptOnAnimatorIK(int32_t thisHandle, int32_t param0) -{ - MyGame::MonoBehaviours::TestScript thiz(Plugin::InternalUse::Only, thisHandle); - try - { - thiz.OnAnimatorIK(param0); - } - catch (System::Exception ex) - { - Plugin::SetException(ex.Handle); - } - catch (...) - { - System::String msg = "Unhandled exception in MyGame::MonoBehaviours::TestScript::OnAnimatorIK"; - System::Exception ex(msg); - Plugin::SetException(ex.Handle); - } -} - - -DLLEXPORT void MyGameMonoBehavioursTestScriptOnCollisionEnter(int32_t thisHandle, int32_t param0Handle) -{ - MyGame::MonoBehaviours::TestScript thiz(Plugin::InternalUse::Only, thisHandle); - UnityEngine::Collision param0(Plugin::InternalUse::Only, param0Handle); - try - { - thiz.OnCollisionEnter(param0); - } - catch (System::Exception ex) - { - Plugin::SetException(ex.Handle); - } - catch (...) - { - System::String msg = "Unhandled exception in MyGame::MonoBehaviours::TestScript::OnCollisionEnter"; - System::Exception ex(msg); - Plugin::SetException(ex.Handle); - } -} - - -DLLEXPORT void MyGameMonoBehavioursTestScriptUpdate(int32_t thisHandle) -{ - MyGame::MonoBehaviours::TestScript thiz(Plugin::InternalUse::Only, thisHandle); - try - { - thiz.Update(); - } - catch (System::Exception ex) - { - Plugin::SetException(ex.Handle); - } - catch (...) - { - System::String msg = "Unhandled exception in MyGame::MonoBehaviours::TestScript::Update"; - System::Exception ex(msg); - Plugin::SetException(ex.Handle); - } -} -/*END MONOBEHAVIOUR MESSAGES*/ diff --git a/Unity/CppSource/NativeScript/Bindings.h b/Unity/CppSource/NativeScript/Bindings.h deleted file mode 100644 index e7989fe..0000000 --- a/Unity/CppSource/NativeScript/Bindings.h +++ /dev/null @@ -1,1972 +0,0 @@ -/// -/// Declaration of the various .NET types exposed to C++ -/// -/// -/// Jackson Dunstan, 2017, http://JacksonDunstan.com -/// -/// -/// MIT -/// - -#pragma once - -// For int32_t, etc. -#include - -// For nullptr_t -#include - -//////////////////////////////////////////////////////////////// -// Plugin internals -//////////////////////////////////////////////////////////////// - -namespace Plugin -{ - enum class InternalUse - { - Only - }; - - template struct ArrayElementProxy1_1; - - template struct ArrayElementProxy1_2; - template struct ArrayElementProxy2_2; - - template struct ArrayElementProxy1_3; - template struct ArrayElementProxy2_3; - template struct ArrayElementProxy3_3; - - template struct ArrayElementProxy1_4; - template struct ArrayElementProxy2_4; - template struct ArrayElementProxy3_4; - template struct ArrayElementProxy4_4; - - template struct ArrayElementProxy1_5; - template struct ArrayElementProxy2_5; - template struct ArrayElementProxy3_5; - template struct ArrayElementProxy4_5; - template struct ArrayElementProxy5_5; -} - -//////////////////////////////////////////////////////////////// -// C# struct types -//////////////////////////////////////////////////////////////// - -namespace System -{ - // .NET booleans are four bytes long - // This struct makes them feel like C++'s bool type - struct Boolean - { - int32_t Value; - - Boolean() - : Value(0) - { - } - - Boolean(const Boolean& other) - : Value(other.Value) - { - } - - Boolean(const Boolean&& other) - : Value(other.Value) - { - } - - Boolean(bool value) - : Value((int32_t)value) - { - } - - operator bool() const - { - return (bool)Value; - } - - bool operator==(const Boolean other) const - { - return Value == other.Value; - } - - bool operator!=(const Boolean other) const - { - return Value != other.Value; - } - - bool operator==(const bool other) const - { - return Value == other; - } - - bool operator!=(const bool other) const - { - return Value != other; - } - }; - - // .NET chars are two bytes long - // This struct helps them interoperate with C++'s char type - struct Char - { - int16_t Value; - - Char() - : Value(0) - { - } - - Char(const Char& other) - : Value(other.Value) - { - } - - Char(const Char&& other) - : Value(other.Value) - { - } - - Char(char value) - : Value(value) - { - } - - Char(int16_t value) - : Value(value) - { - } - - operator bool() const - { - return (bool)Value; - } - - bool operator==(const Char other) const - { - return Value == other.Value; - } - - bool operator!=(const Char other) const - { - return Value != other.Value; - } - - bool operator==(const char other) const - { - return Value == other; - } - - bool operator!=(const char other) const - { - return Value != other; - } - }; -} - -//////////////////////////////////////////////////////////////// -// C# type declarations -//////////////////////////////////////////////////////////////// - -namespace System -{ - struct Object; - struct ValueType; - struct String; - struct Array; - template struct Array1; - template struct Array2; - template struct Array3; - template struct Array4; - template struct Array5; -} - -/*BEGIN TYPE DECLARATIONS*/ -namespace System -{ - namespace Diagnostics - { - struct Stopwatch; - } -} - -namespace UnityEngine -{ - struct Object; -} - -namespace UnityEngine -{ - struct GameObject; -} - -namespace UnityEngine -{ - struct Component; -} - -namespace UnityEngine -{ - struct Transform; -} - -namespace UnityEngine -{ - struct Debug; -} - -namespace UnityEngine -{ - namespace Assertions - { - namespace Assert - { - } - } -} - -namespace UnityEngine -{ - struct Collision; -} - -namespace UnityEngine -{ - struct Behaviour; -} - -namespace UnityEngine -{ - struct MonoBehaviour; -} - -namespace UnityEngine -{ - struct AudioSettings; -} - -namespace UnityEngine -{ - namespace Networking - { - struct NetworkTransport; - } -} - -namespace UnityEngine -{ - struct Vector3; -} - -namespace UnityEngine -{ - struct Matrix4x4; -} - -namespace UnityEngine -{ - struct RaycastHit; -} - -namespace UnityEngine -{ - enum struct QueryTriggerInteraction : int32_t - { - UseGlobal = 0, - Ignore = 1, - Collide = 2 - }; -} - -namespace System -{ - namespace Collections - { - namespace Generic - { - template struct KeyValuePair; - } - } -} - -namespace System -{ - namespace Collections - { - namespace Generic - { - template<> struct KeyValuePair; - } - } -} - -namespace System -{ - namespace Collections - { - namespace Generic - { - template struct List; - } - } -} - -namespace System -{ - namespace Collections - { - namespace Generic - { - template<> struct List; - } - } -} - -namespace System -{ - namespace Collections - { - namespace Generic - { - template struct LinkedListNode; - } - } -} - -namespace System -{ - namespace Collections - { - namespace Generic - { - template<> struct LinkedListNode; - } - } -} - -namespace System -{ - namespace Runtime - { - namespace CompilerServices - { - template struct StrongBox; - } - } -} - -namespace System -{ - namespace Runtime - { - namespace CompilerServices - { - template<> struct StrongBox; - } - } -} - -namespace System -{ - namespace Collections - { - namespace ObjectModel - { - template struct Collection; - } - } -} - -namespace System -{ - namespace Collections - { - namespace ObjectModel - { - template<> struct Collection; - } - } -} - -namespace System -{ - namespace Collections - { - namespace ObjectModel - { - template struct KeyedCollection; - } - } -} - -namespace System -{ - namespace Collections - { - namespace ObjectModel - { - template<> struct KeyedCollection; - } - } -} - -namespace System -{ - struct Exception; -} - -namespace System -{ - struct SystemException; -} - -namespace System -{ - struct NullReferenceException; -} - -namespace UnityEngine -{ - struct Resolution; -} - -namespace UnityEngine -{ - struct Screen; -} - -namespace UnityEngine -{ - struct Ray; -} - -namespace UnityEngine -{ - struct Physics; -} - -namespace UnityEngine -{ - struct Color; -} - -namespace UnityEngine -{ - struct GradientColorKey; -} - -namespace UnityEngine -{ - struct Gradient; -} - -namespace System -{ - struct AppDomainSetup; -} - -namespace UnityEngine -{ - struct Application; -} - -namespace UnityEngine -{ - namespace SceneManagement - { - struct SceneManager; - } -} - -namespace UnityEngine -{ - namespace SceneManagement - { - struct Scene; - } -} - -namespace UnityEngine -{ - namespace SceneManagement - { - enum struct LoadSceneMode : int32_t - { - Single = 0, - Additive = 1 - }; - } -} - -namespace MyGame -{ - namespace MonoBehaviours - { - struct TestScript; - } -} - -namespace Plugin -{ - template<> struct ArrayElementProxy1_1; -} - -namespace System -{ - template<> struct Array1; -} - -namespace Plugin -{ - template<> struct ArrayElementProxy1_1; -} - -namespace Plugin -{ - template<> struct ArrayElementProxy1_2; -} - -namespace Plugin -{ - template<> struct ArrayElementProxy2_2; -} - -namespace Plugin -{ - template<> struct ArrayElementProxy1_3; -} - -namespace Plugin -{ - template<> struct ArrayElementProxy2_3; -} - -namespace Plugin -{ - template<> struct ArrayElementProxy3_3; -} - -namespace System -{ - template<> struct Array1; -} - -namespace System -{ - template<> struct Array2; -} - -namespace System -{ - template<> struct Array3; -} - -namespace Plugin -{ - template<> struct ArrayElementProxy1_1; -} - -namespace System -{ - template<> struct Array1; -} - -namespace Plugin -{ - template<> struct ArrayElementProxy1_1; -} - -namespace System -{ - template<> struct Array1; -} - -namespace Plugin -{ - template<> struct ArrayElementProxy1_1; -} - -namespace System -{ - template<> struct Array1; -} - -namespace Plugin -{ - template<> struct ArrayElementProxy1_1; -} - -namespace System -{ - template<> struct Array1; -} - -namespace System -{ - struct Action; -} - -namespace System -{ - template struct Action1; -} - -namespace System -{ - template<> struct Action1; -} - -namespace System -{ - template struct Action2; -} - -namespace System -{ - template<> struct Action2; -} - -namespace System -{ - template struct Func3; -} - -namespace System -{ - template struct Func3; -} - -namespace System -{ - template<> struct Func3; -} - -namespace System -{ - template<> struct Func3; -} - -namespace System -{ - struct AppDomainInitializer; -} - -namespace UnityEngine -{ - namespace Events - { - struct UnityAction; - } -} - -namespace UnityEngine -{ - namespace Events - { - template struct UnityAction2; - } -} - -namespace UnityEngine -{ - namespace Events - { - template<> struct UnityAction2; - } -} -/*END TYPE DECLARATIONS*/ - -//////////////////////////////////////////////////////////////// -// C# type definitions -//////////////////////////////////////////////////////////////// - -namespace System -{ - struct Object - { - int32_t Handle; - Object(Plugin::InternalUse iu, int32_t handle); - Object(std::nullptr_t n); - virtual ~Object() = default; - bool operator==(std::nullptr_t other) const; - bool operator!=(std::nullptr_t other) const; - virtual void ThrowReferenceToThis(); - - /*BEGIN BOXING METHOD DECLARATIONS*/ - Object(UnityEngine::Vector3& val); - explicit operator UnityEngine::Vector3(); - Object(UnityEngine::Matrix4x4& val); - explicit operator UnityEngine::Matrix4x4(); - Object(UnityEngine::RaycastHit val); - explicit operator UnityEngine::RaycastHit(); - Object(UnityEngine::QueryTriggerInteraction val); - explicit operator UnityEngine::QueryTriggerInteraction(); - Object(System::Collections::Generic::KeyValuePair val); - explicit operator System::Collections::Generic::KeyValuePair(); - Object(UnityEngine::Resolution& val); - explicit operator UnityEngine::Resolution(); - Object(UnityEngine::Ray& val); - explicit operator UnityEngine::Ray(); - Object(UnityEngine::Color& val); - explicit operator UnityEngine::Color(); - Object(UnityEngine::GradientColorKey& val); - explicit operator UnityEngine::GradientColorKey(); - Object(UnityEngine::SceneManagement::Scene& val); - explicit operator UnityEngine::SceneManagement::Scene(); - Object(UnityEngine::SceneManagement::LoadSceneMode val); - explicit operator UnityEngine::SceneManagement::LoadSceneMode(); - Object(System::Boolean val); - explicit operator System::Boolean(); - Object(int8_t val); - explicit operator int8_t(); - Object(uint8_t val); - explicit operator uint8_t(); - Object(int16_t val); - explicit operator int16_t(); - Object(uint16_t val); - explicit operator uint16_t(); - Object(int32_t val); - explicit operator int32_t(); - Object(uint32_t val); - explicit operator uint32_t(); - Object(int64_t val); - explicit operator int64_t(); - Object(uint64_t val); - explicit operator uint64_t(); - Object(System::Char val); - explicit operator System::Char(); - Object(float val); - explicit operator float(); - Object(double val); - explicit operator double(); - - /*END BOXING METHOD DECLARATIONS*/ - }; - - struct ValueType - { - int32_t Handle; - ValueType(Plugin::InternalUse iu, int32_t handle); - ValueType(std::nullptr_t n); - }; - - struct String : Object - { - String(Plugin::InternalUse iu, int32_t handle); - String(std::nullptr_t n); - String(const String& other); - String(String&& other); - virtual ~String(); - String& operator=(const String& other); - String& operator=(std::nullptr_t other); - String& operator=(String&& other); - String(); - String(const char* chars); - }; - - struct Array : Object - { - Array(Plugin::InternalUse iu, int32_t handle); - Array(std::nullptr_t n); - int32_t GetLength(); - int32_t GetRank(); - }; -} - -/*BEGIN TYPE DEFINITIONS*/ -namespace System -{ - namespace Diagnostics - { - struct Stopwatch : System::Object - { - Stopwatch(std::nullptr_t n); - Stopwatch(Plugin::InternalUse iu, int32_t handle); - Stopwatch(const Stopwatch& other); - Stopwatch(Stopwatch&& other); - virtual ~Stopwatch(); - Stopwatch& operator=(const Stopwatch& other); - Stopwatch& operator=(std::nullptr_t other); - Stopwatch& operator=(Stopwatch&& other); - bool operator==(const Stopwatch& other) const; - bool operator!=(const Stopwatch& other) const; - Stopwatch(); - int64_t GetElapsedMilliseconds(); - void Start(); - void Reset(); - }; - } -} - -namespace UnityEngine -{ - struct Object : System::Object - { - Object(std::nullptr_t n); - Object(Plugin::InternalUse iu, int32_t handle); - Object(const Object& other); - Object(Object&& other); - virtual ~Object(); - Object& operator=(const Object& other); - Object& operator=(std::nullptr_t other); - Object& operator=(Object&& other); - bool operator==(const Object& other) const; - bool operator!=(const Object& other) const; - System::String GetName(); - void SetName(System::String value); - System::Boolean operator==(UnityEngine::Object x); - operator System::Boolean(); - }; -} - -namespace UnityEngine -{ - struct GameObject : UnityEngine::Object - { - GameObject(std::nullptr_t n); - GameObject(Plugin::InternalUse iu, int32_t handle); - GameObject(const GameObject& other); - GameObject(GameObject&& other); - virtual ~GameObject(); - GameObject& operator=(const GameObject& other); - GameObject& operator=(std::nullptr_t other); - GameObject& operator=(GameObject&& other); - bool operator==(const GameObject& other) const; - bool operator!=(const GameObject& other) const; - GameObject(); - GameObject(System::String name); - UnityEngine::Transform GetTransform(); - template MyGame::MonoBehaviours::TestScript AddComponent(); - }; -} - -namespace UnityEngine -{ - struct Component : UnityEngine::Object - { - Component(std::nullptr_t n); - Component(Plugin::InternalUse iu, int32_t handle); - Component(const Component& other); - Component(Component&& other); - virtual ~Component(); - Component& operator=(const Component& other); - Component& operator=(std::nullptr_t other); - Component& operator=(Component&& other); - bool operator==(const Component& other) const; - bool operator!=(const Component& other) const; - UnityEngine::Transform GetTransform(); - }; -} - -namespace UnityEngine -{ - struct Transform : UnityEngine::Component - { - Transform(std::nullptr_t n); - Transform(Plugin::InternalUse iu, int32_t handle); - Transform(const Transform& other); - Transform(Transform&& other); - virtual ~Transform(); - Transform& operator=(const Transform& other); - Transform& operator=(std::nullptr_t other); - Transform& operator=(Transform&& other); - bool operator==(const Transform& other) const; - bool operator!=(const Transform& other) const; - UnityEngine::Vector3 GetPosition(); - void SetPosition(UnityEngine::Vector3& value); - }; -} - -namespace UnityEngine -{ - struct Debug : System::Object - { - Debug(std::nullptr_t n); - Debug(Plugin::InternalUse iu, int32_t handle); - Debug(const Debug& other); - Debug(Debug&& other); - virtual ~Debug(); - Debug& operator=(const Debug& other); - Debug& operator=(std::nullptr_t other); - Debug& operator=(Debug&& other); - bool operator==(const Debug& other) const; - bool operator!=(const Debug& other) const; - static void Log(System::Object message); - }; -} - -namespace UnityEngine -{ - namespace Assertions - { - namespace Assert - { - System::Boolean GetRaiseExceptions(); - void SetRaiseExceptions(System::Boolean value); - template void AreEqual(System::String expected, System::String actual); - template void AreEqual(UnityEngine::GameObject expected, UnityEngine::GameObject actual); - } - } -} - -namespace UnityEngine -{ - struct Collision : System::Object - { - Collision(std::nullptr_t n); - Collision(Plugin::InternalUse iu, int32_t handle); - Collision(const Collision& other); - Collision(Collision&& other); - virtual ~Collision(); - Collision& operator=(const Collision& other); - Collision& operator=(std::nullptr_t other); - Collision& operator=(Collision&& other); - bool operator==(const Collision& other) const; - bool operator!=(const Collision& other) const; - }; -} - -namespace UnityEngine -{ - struct Behaviour : UnityEngine::Component - { - Behaviour(std::nullptr_t n); - Behaviour(Plugin::InternalUse iu, int32_t handle); - Behaviour(const Behaviour& other); - Behaviour(Behaviour&& other); - virtual ~Behaviour(); - Behaviour& operator=(const Behaviour& other); - Behaviour& operator=(std::nullptr_t other); - Behaviour& operator=(Behaviour&& other); - bool operator==(const Behaviour& other) const; - bool operator!=(const Behaviour& other) const; - }; -} - -namespace UnityEngine -{ - struct MonoBehaviour : UnityEngine::Behaviour - { - MonoBehaviour(std::nullptr_t n); - MonoBehaviour(Plugin::InternalUse iu, int32_t handle); - MonoBehaviour(const MonoBehaviour& other); - MonoBehaviour(MonoBehaviour&& other); - virtual ~MonoBehaviour(); - MonoBehaviour& operator=(const MonoBehaviour& other); - MonoBehaviour& operator=(std::nullptr_t other); - MonoBehaviour& operator=(MonoBehaviour&& other); - bool operator==(const MonoBehaviour& other) const; - bool operator!=(const MonoBehaviour& other) const; - }; -} - -namespace UnityEngine -{ - struct AudioSettings : System::Object - { - AudioSettings(std::nullptr_t n); - AudioSettings(Plugin::InternalUse iu, int32_t handle); - AudioSettings(const AudioSettings& other); - AudioSettings(AudioSettings&& other); - virtual ~AudioSettings(); - AudioSettings& operator=(const AudioSettings& other); - AudioSettings& operator=(std::nullptr_t other); - AudioSettings& operator=(AudioSettings&& other); - bool operator==(const AudioSettings& other) const; - bool operator!=(const AudioSettings& other) const; - static void GetDSPBufferSize(int32_t* bufferLength, int32_t* numBuffers); - }; -} - -namespace UnityEngine -{ - namespace Networking - { - struct NetworkTransport : System::Object - { - NetworkTransport(std::nullptr_t n); - NetworkTransport(Plugin::InternalUse iu, int32_t handle); - NetworkTransport(const NetworkTransport& other); - NetworkTransport(NetworkTransport&& other); - virtual ~NetworkTransport(); - NetworkTransport& operator=(const NetworkTransport& other); - NetworkTransport& operator=(std::nullptr_t other); - NetworkTransport& operator=(NetworkTransport&& other); - bool operator==(const NetworkTransport& other) const; - bool operator!=(const NetworkTransport& other) const; - static void GetBroadcastConnectionInfo(int32_t hostId, System::String* address, int32_t* port, uint8_t* error); - static void Init(); - }; - } -} - -namespace UnityEngine -{ - struct Vector3 - { - Vector3(); - Vector3(float x, float y, float z); - float GetMagnitude(); - float x; - float y; - float z; - void Set(float newX, float newY, float newZ); - UnityEngine::Vector3 operator+(UnityEngine::Vector3& a); - UnityEngine::Vector3 operator-(); - }; -} - -namespace UnityEngine -{ - struct Matrix4x4 - { - Matrix4x4(); - float GetItem(int32_t row, int32_t column); - void SetItem(int32_t row, int32_t column, float value); - float m00; - float m10; - float m20; - float m30; - float m01; - float m11; - float m21; - float m31; - float m02; - float m12; - float m22; - float m32; - float m03; - float m13; - float m23; - float m33; - }; -} - -namespace UnityEngine -{ - struct RaycastHit : System::ValueType - { - RaycastHit(std::nullptr_t n); - RaycastHit(Plugin::InternalUse iu, int32_t handle); - RaycastHit(const RaycastHit& other); - RaycastHit(RaycastHit&& other); - virtual ~RaycastHit(); - RaycastHit& operator=(const RaycastHit& other); - RaycastHit& operator=(std::nullptr_t other); - RaycastHit& operator=(RaycastHit&& other); - bool operator==(const RaycastHit& other) const; - bool operator!=(const RaycastHit& other) const; - UnityEngine::Vector3 GetPoint(); - void SetPoint(UnityEngine::Vector3& value); - UnityEngine::Transform GetTransform(); - }; -} - -namespace System -{ - namespace Collections - { - namespace Generic - { - template<> struct KeyValuePair : System::ValueType - { - KeyValuePair(std::nullptr_t n); - KeyValuePair(Plugin::InternalUse iu, int32_t handle); - KeyValuePair(const KeyValuePair& other); - KeyValuePair(KeyValuePair&& other); - virtual ~KeyValuePair(); - KeyValuePair& operator=(const KeyValuePair& other); - KeyValuePair& operator=(std::nullptr_t other); - KeyValuePair& operator=(KeyValuePair&& other); - bool operator==(const KeyValuePair& other) const; - bool operator!=(const KeyValuePair& other) const; - KeyValuePair(System::String key, double value); - System::String GetKey(); - double GetValue(); - }; - } - } -} - -namespace System -{ - namespace Collections - { - namespace Generic - { - template<> struct List : System::Object - { - List(std::nullptr_t n); - List(Plugin::InternalUse iu, int32_t handle); - List(const List& other); - List(List&& other); - virtual ~List(); - List& operator=(const List& other); - List& operator=(std::nullptr_t other); - List& operator=(List&& other); - bool operator==(const List& other) const; - bool operator!=(const List& other) const; - List(); - System::String GetItem(int32_t index); - void SetItem(int32_t index, System::String value); - void Add(System::String item); - }; - } - } -} - -namespace System -{ - namespace Collections - { - namespace Generic - { - template<> struct LinkedListNode : System::Object - { - LinkedListNode(std::nullptr_t n); - LinkedListNode(Plugin::InternalUse iu, int32_t handle); - LinkedListNode(const LinkedListNode& other); - LinkedListNode(LinkedListNode&& other); - virtual ~LinkedListNode(); - LinkedListNode& operator=(const LinkedListNode& other); - LinkedListNode& operator=(std::nullptr_t other); - LinkedListNode& operator=(LinkedListNode&& other); - bool operator==(const LinkedListNode& other) const; - bool operator!=(const LinkedListNode& other) const; - LinkedListNode(System::String value); - System::String GetValue(); - void SetValue(System::String value); - }; - } - } -} - -namespace System -{ - namespace Runtime - { - namespace CompilerServices - { - template<> struct StrongBox : System::Object - { - StrongBox(std::nullptr_t n); - StrongBox(Plugin::InternalUse iu, int32_t handle); - StrongBox(const StrongBox& other); - StrongBox(StrongBox&& other); - virtual ~StrongBox(); - StrongBox& operator=(const StrongBox& other); - StrongBox& operator=(std::nullptr_t other); - StrongBox& operator=(StrongBox&& other); - bool operator==(const StrongBox& other) const; - bool operator!=(const StrongBox& other) const; - StrongBox(System::String value); - System::String GetValue(); - void SetValue(System::String value); - }; - } - } -} - -namespace System -{ - namespace Collections - { - namespace ObjectModel - { - template<> struct Collection : System::Object - { - Collection(std::nullptr_t n); - Collection(Plugin::InternalUse iu, int32_t handle); - Collection(const Collection& other); - Collection(Collection&& other); - virtual ~Collection(); - Collection& operator=(const Collection& other); - Collection& operator=(std::nullptr_t other); - Collection& operator=(Collection&& other); - bool operator==(const Collection& other) const; - bool operator!=(const Collection& other) const; - }; - } - } -} - -namespace System -{ - namespace Collections - { - namespace ObjectModel - { - template<> struct KeyedCollection : System::Collections::ObjectModel::Collection - { - KeyedCollection(std::nullptr_t n); - KeyedCollection(Plugin::InternalUse iu, int32_t handle); - KeyedCollection(const KeyedCollection& other); - KeyedCollection(KeyedCollection&& other); - virtual ~KeyedCollection(); - KeyedCollection& operator=(const KeyedCollection& other); - KeyedCollection& operator=(std::nullptr_t other); - KeyedCollection& operator=(KeyedCollection&& other); - bool operator==(const KeyedCollection& other) const; - bool operator!=(const KeyedCollection& other) const; - }; - } - } -} - -namespace System -{ - struct Exception : System::Object - { - Exception(std::nullptr_t n); - Exception(Plugin::InternalUse iu, int32_t handle); - Exception(const Exception& other); - Exception(Exception&& other); - virtual ~Exception(); - Exception& operator=(const Exception& other); - Exception& operator=(std::nullptr_t other); - Exception& operator=(Exception&& other); - bool operator==(const Exception& other) const; - bool operator!=(const Exception& other) const; - Exception(System::String message); - }; -} - -namespace System -{ - struct SystemException : System::Exception - { - SystemException(std::nullptr_t n); - SystemException(Plugin::InternalUse iu, int32_t handle); - SystemException(const SystemException& other); - SystemException(SystemException&& other); - virtual ~SystemException(); - SystemException& operator=(const SystemException& other); - SystemException& operator=(std::nullptr_t other); - SystemException& operator=(SystemException&& other); - bool operator==(const SystemException& other) const; - bool operator!=(const SystemException& other) const; - }; -} - -namespace System -{ - struct NullReferenceException : System::SystemException - { - NullReferenceException(std::nullptr_t n); - NullReferenceException(Plugin::InternalUse iu, int32_t handle); - NullReferenceException(const NullReferenceException& other); - NullReferenceException(NullReferenceException&& other); - virtual ~NullReferenceException(); - NullReferenceException& operator=(const NullReferenceException& other); - NullReferenceException& operator=(std::nullptr_t other); - NullReferenceException& operator=(NullReferenceException&& other); - bool operator==(const NullReferenceException& other) const; - bool operator!=(const NullReferenceException& other) const; - }; -} - -namespace UnityEngine -{ - struct Resolution - { - Resolution(); - int32_t GetWidth(); - void SetWidth(int32_t value); - int32_t GetHeight(); - void SetHeight(int32_t value); - int32_t GetRefreshRate(); - void SetRefreshRate(int32_t value); - int32_t m_Width; - int32_t m_Height; - int32_t m_RefreshRate; - }; -} - -namespace UnityEngine -{ - struct Screen : System::Object - { - Screen(std::nullptr_t n); - Screen(Plugin::InternalUse iu, int32_t handle); - Screen(const Screen& other); - Screen(Screen&& other); - virtual ~Screen(); - Screen& operator=(const Screen& other); - Screen& operator=(std::nullptr_t other); - Screen& operator=(Screen&& other); - bool operator==(const Screen& other) const; - bool operator!=(const Screen& other) const; - static System::Array1 GetResolutions(); - }; -} - -namespace UnityEngine -{ - struct Ray - { - Ray(); - Ray(UnityEngine::Vector3& origin, UnityEngine::Vector3& direction); - UnityEngine::Vector3 m_Origin; - UnityEngine::Vector3 m_Direction; - }; -} - -namespace UnityEngine -{ - struct Physics : System::Object - { - Physics(std::nullptr_t n); - Physics(Plugin::InternalUse iu, int32_t handle); - Physics(const Physics& other); - Physics(Physics&& other); - virtual ~Physics(); - Physics& operator=(const Physics& other); - Physics& operator=(std::nullptr_t other); - Physics& operator=(Physics&& other); - bool operator==(const Physics& other) const; - bool operator!=(const Physics& other) const; - static int32_t RaycastNonAlloc(UnityEngine::Ray& ray, System::Array1 results); - static System::Array1 RaycastAll(UnityEngine::Ray& ray); - }; -} - -namespace UnityEngine -{ - struct Color - { - Color(); - float r; - float g; - float b; - float a; - }; -} - -namespace UnityEngine -{ - struct GradientColorKey - { - GradientColorKey(); - UnityEngine::Color color; - float time; - }; -} - -namespace UnityEngine -{ - struct Gradient : System::Object - { - Gradient(std::nullptr_t n); - Gradient(Plugin::InternalUse iu, int32_t handle); - Gradient(const Gradient& other); - Gradient(Gradient&& other); - virtual ~Gradient(); - Gradient& operator=(const Gradient& other); - Gradient& operator=(std::nullptr_t other); - Gradient& operator=(Gradient&& other); - bool operator==(const Gradient& other) const; - bool operator!=(const Gradient& other) const; - Gradient(); - System::Array1 GetColorKeys(); - void SetColorKeys(System::Array1 value); - }; -} - -namespace System -{ - struct AppDomainSetup : System::Object - { - AppDomainSetup(std::nullptr_t n); - AppDomainSetup(Plugin::InternalUse iu, int32_t handle); - AppDomainSetup(const AppDomainSetup& other); - AppDomainSetup(AppDomainSetup&& other); - virtual ~AppDomainSetup(); - AppDomainSetup& operator=(const AppDomainSetup& other); - AppDomainSetup& operator=(std::nullptr_t other); - AppDomainSetup& operator=(AppDomainSetup&& other); - bool operator==(const AppDomainSetup& other) const; - bool operator!=(const AppDomainSetup& other) const; - AppDomainSetup(); - System::AppDomainInitializer GetAppDomainInitializer(); - void SetAppDomainInitializer(System::AppDomainInitializer value); - }; -} - -namespace UnityEngine -{ - struct Application : System::Object - { - Application(std::nullptr_t n); - Application(Plugin::InternalUse iu, int32_t handle); - Application(const Application& other); - Application(Application&& other); - virtual ~Application(); - Application& operator=(const Application& other); - Application& operator=(std::nullptr_t other); - Application& operator=(Application&& other); - bool operator==(const Application& other) const; - bool operator!=(const Application& other) const; - static void AddOnBeforeRender(UnityEngine::Events::UnityAction del); - static void RemoveOnBeforeRender(UnityEngine::Events::UnityAction del); - }; -} - -namespace UnityEngine -{ - namespace SceneManagement - { - struct SceneManager : System::Object - { - SceneManager(std::nullptr_t n); - SceneManager(Plugin::InternalUse iu, int32_t handle); - SceneManager(const SceneManager& other); - SceneManager(SceneManager&& other); - virtual ~SceneManager(); - SceneManager& operator=(const SceneManager& other); - SceneManager& operator=(std::nullptr_t other); - SceneManager& operator=(SceneManager&& other); - bool operator==(const SceneManager& other) const; - bool operator!=(const SceneManager& other) const; - static void AddSceneLoaded(UnityEngine::Events::UnityAction2 del); - static void RemoveSceneLoaded(UnityEngine::Events::UnityAction2 del); - }; - } -} - -namespace UnityEngine -{ - namespace SceneManagement - { - struct Scene - { - Scene(); - int32_t m_Handle; - }; - } -} - -namespace MyGame -{ - namespace MonoBehaviours - { - struct TestScript : UnityEngine::MonoBehaviour - { - TestScript(std::nullptr_t n); - TestScript(Plugin::InternalUse iu, int32_t handle); - TestScript(const TestScript& other); - TestScript(TestScript&& other); - virtual ~TestScript(); - TestScript& operator=(const TestScript& other); - TestScript& operator=(std::nullptr_t other); - TestScript& operator=(TestScript&& other); - bool operator==(const TestScript& other) const; - bool operator!=(const TestScript& other) const; - void Awake(); - void OnAnimatorIK(int32_t param0); - void OnCollisionEnter(UnityEngine::Collision param0); - void Update(); - }; - } -} - -namespace Plugin -{ - template<> struct ArrayElementProxy1_1 - { - int32_t Handle; - int32_t Index0; - ArrayElementProxy1_1(Plugin::InternalUse iu, int32_t handle, int32_t index0); - void operator=(int32_t item); - operator int32_t(); - }; -} - -namespace System -{ - template<> struct Array1 : System::Array - { - Array1(std::nullptr_t n); - Array1(Plugin::InternalUse iu, int32_t handle); - Array1(const Array1& other); - Array1(Array1&& other); - virtual ~Array1(); - Array1& operator=(const Array1& other); - Array1& operator=(std::nullptr_t other); - Array1& operator=(Array1&& other); - bool operator==(const Array1& other) const; - bool operator!=(const Array1& other) const; - Array1(int32_t length0); - int32_t GetLength(); - int32_t GetRank(); - Plugin::ArrayElementProxy1_1 operator[](int32_t index); - }; -} - -namespace Plugin -{ - template<> struct ArrayElementProxy1_1 - { - int32_t Handle; - int32_t Index0; - ArrayElementProxy1_1(Plugin::InternalUse iu, int32_t handle, int32_t index0); - void operator=(float item); - operator float(); - }; -} - -namespace Plugin -{ - template<> struct ArrayElementProxy1_2 - { - int32_t Handle; - int32_t Index0; - ArrayElementProxy1_2(Plugin::InternalUse iu, int32_t handle, int32_t index0); - Plugin::ArrayElementProxy2_2 operator[](int32_t index); - }; -} - -namespace Plugin -{ - template<> struct ArrayElementProxy2_2 - { - int32_t Handle; - int32_t Index0; - int32_t Index1; - ArrayElementProxy2_2(Plugin::InternalUse iu, int32_t handle, int32_t index0, int32_t index1); - void operator=(float item); - operator float(); - }; -} - -namespace Plugin -{ - template<> struct ArrayElementProxy1_3 - { - int32_t Handle; - int32_t Index0; - ArrayElementProxy1_3(Plugin::InternalUse iu, int32_t handle, int32_t index0); - Plugin::ArrayElementProxy2_3 operator[](int32_t index); - }; -} - -namespace Plugin -{ - template<> struct ArrayElementProxy2_3 - { - int32_t Handle; - int32_t Index0; - int32_t Index1; - ArrayElementProxy2_3(Plugin::InternalUse iu, int32_t handle, int32_t index0, int32_t index1); - Plugin::ArrayElementProxy3_3 operator[](int32_t index); - }; -} - -namespace Plugin -{ - template<> struct ArrayElementProxy3_3 - { - int32_t Handle; - int32_t Index0; - int32_t Index1; - int32_t Index2; - ArrayElementProxy3_3(Plugin::InternalUse iu, int32_t handle, int32_t index0, int32_t index1, int32_t index2); - void operator=(float item); - operator float(); - }; -} - -namespace System -{ - template<> struct Array1 : System::Array - { - Array1(std::nullptr_t n); - Array1(Plugin::InternalUse iu, int32_t handle); - Array1(const Array1& other); - Array1(Array1&& other); - virtual ~Array1(); - Array1& operator=(const Array1& other); - Array1& operator=(std::nullptr_t other); - Array1& operator=(Array1&& other); - bool operator==(const Array1& other) const; - bool operator!=(const Array1& other) const; - Array1(int32_t length0); - int32_t GetLength(); - int32_t GetRank(); - Plugin::ArrayElementProxy1_1 operator[](int32_t index); - }; -} - -namespace System -{ - template<> struct Array2 : System::Array - { - Array2(std::nullptr_t n); - Array2(Plugin::InternalUse iu, int32_t handle); - Array2(const Array2& other); - Array2(Array2&& other); - virtual ~Array2(); - Array2& operator=(const Array2& other); - Array2& operator=(std::nullptr_t other); - Array2& operator=(Array2&& other); - bool operator==(const Array2& other) const; - bool operator!=(const Array2& other) const; - Array2(int32_t length0, int32_t length1); - int32_t GetLength(); - int32_t GetLength(int32_t dimension); - int32_t GetRank(); - Plugin::ArrayElementProxy1_2 operator[](int32_t index); - }; -} - -namespace System -{ - template<> struct Array3 : System::Array - { - Array3(std::nullptr_t n); - Array3(Plugin::InternalUse iu, int32_t handle); - Array3(const Array3& other); - Array3(Array3&& other); - virtual ~Array3(); - Array3& operator=(const Array3& other); - Array3& operator=(std::nullptr_t other); - Array3& operator=(Array3&& other); - bool operator==(const Array3& other) const; - bool operator!=(const Array3& other) const; - Array3(int32_t length0, int32_t length1, int32_t length2); - int32_t GetLength(); - int32_t GetLength(int32_t dimension); - int32_t GetRank(); - Plugin::ArrayElementProxy1_3 operator[](int32_t index); - }; -} - -namespace Plugin -{ - template<> struct ArrayElementProxy1_1 - { - int32_t Handle; - int32_t Index0; - ArrayElementProxy1_1(Plugin::InternalUse iu, int32_t handle, int32_t index0); - void operator=(System::String item); - operator System::String(); - }; -} - -namespace System -{ - template<> struct Array1 : System::Array - { - Array1(std::nullptr_t n); - Array1(Plugin::InternalUse iu, int32_t handle); - Array1(const Array1& other); - Array1(Array1&& other); - virtual ~Array1(); - Array1& operator=(const Array1& other); - Array1& operator=(std::nullptr_t other); - Array1& operator=(Array1&& other); - bool operator==(const Array1& other) const; - bool operator!=(const Array1& other) const; - Array1(int32_t length0); - int32_t GetLength(); - int32_t GetRank(); - Plugin::ArrayElementProxy1_1 operator[](int32_t index); - }; -} - -namespace Plugin -{ - template<> struct ArrayElementProxy1_1 - { - int32_t Handle; - int32_t Index0; - ArrayElementProxy1_1(Plugin::InternalUse iu, int32_t handle, int32_t index0); - void operator=(UnityEngine::Resolution item); - operator UnityEngine::Resolution(); - }; -} - -namespace System -{ - template<> struct Array1 : System::Array - { - Array1(std::nullptr_t n); - Array1(Plugin::InternalUse iu, int32_t handle); - Array1(const Array1& other); - Array1(Array1&& other); - virtual ~Array1(); - Array1& operator=(const Array1& other); - Array1& operator=(std::nullptr_t other); - Array1& operator=(Array1&& other); - bool operator==(const Array1& other) const; - bool operator!=(const Array1& other) const; - Array1(int32_t length0); - int32_t GetLength(); - int32_t GetRank(); - Plugin::ArrayElementProxy1_1 operator[](int32_t index); - }; -} - -namespace Plugin -{ - template<> struct ArrayElementProxy1_1 - { - int32_t Handle; - int32_t Index0; - ArrayElementProxy1_1(Plugin::InternalUse iu, int32_t handle, int32_t index0); - void operator=(UnityEngine::RaycastHit item); - operator UnityEngine::RaycastHit(); - }; -} - -namespace System -{ - template<> struct Array1 : System::Array - { - Array1(std::nullptr_t n); - Array1(Plugin::InternalUse iu, int32_t handle); - Array1(const Array1& other); - Array1(Array1&& other); - virtual ~Array1(); - Array1& operator=(const Array1& other); - Array1& operator=(std::nullptr_t other); - Array1& operator=(Array1&& other); - bool operator==(const Array1& other) const; - bool operator!=(const Array1& other) const; - Array1(int32_t length0); - int32_t GetLength(); - int32_t GetRank(); - Plugin::ArrayElementProxy1_1 operator[](int32_t index); - }; -} - -namespace Plugin -{ - template<> struct ArrayElementProxy1_1 - { - int32_t Handle; - int32_t Index0; - ArrayElementProxy1_1(Plugin::InternalUse iu, int32_t handle, int32_t index0); - void operator=(UnityEngine::GradientColorKey item); - operator UnityEngine::GradientColorKey(); - }; -} - -namespace System -{ - template<> struct Array1 : System::Array - { - Array1(std::nullptr_t n); - Array1(Plugin::InternalUse iu, int32_t handle); - Array1(const Array1& other); - Array1(Array1&& other); - virtual ~Array1(); - Array1& operator=(const Array1& other); - Array1& operator=(std::nullptr_t other); - Array1& operator=(Array1&& other); - bool operator==(const Array1& other) const; - bool operator!=(const Array1& other) const; - Array1(int32_t length0); - int32_t GetLength(); - int32_t GetRank(); - Plugin::ArrayElementProxy1_1 operator[](int32_t index); - }; -} - -namespace System -{ - struct Action : System::Object - { - Action(std::nullptr_t n); - Action(Plugin::InternalUse iu, int32_t handle); - Action(const Action& other); - Action(Action&& other); - virtual ~Action(); - Action& operator=(const Action& other); - Action& operator=(std::nullptr_t other); - Action& operator=(Action&& other); - bool operator==(const Action& other) const; - bool operator!=(const Action& other) const; - int32_t CppHandle; - int32_t ClassHandle; - Action(); - void Invoke(); - virtual void operator()(); - void operator+=(System::Action& del); - void operator-=(System::Action& del); - }; -} - -namespace System -{ - template<> struct Action1 : System::Object - { - Action1(std::nullptr_t n); - Action1(Plugin::InternalUse iu, int32_t handle); - Action1(const Action1& other); - Action1(Action1&& other); - virtual ~Action1(); - Action1& operator=(const Action1& other); - Action1& operator=(std::nullptr_t other); - Action1& operator=(Action1&& other); - bool operator==(const Action1& other) const; - bool operator!=(const Action1& other) const; - int32_t CppHandle; - int32_t ClassHandle; - Action1(); - void Invoke(float obj); - virtual void operator()(float obj); - void operator+=(System::Action1& del); - void operator-=(System::Action1& del); - }; -} - -namespace System -{ - template<> struct Action2 : System::Object - { - Action2(std::nullptr_t n); - Action2(Plugin::InternalUse iu, int32_t handle); - Action2(const Action2& other); - Action2(Action2&& other); - virtual ~Action2(); - Action2& operator=(const Action2& other); - Action2& operator=(std::nullptr_t other); - Action2& operator=(Action2&& other); - bool operator==(const Action2& other) const; - bool operator!=(const Action2& other) const; - int32_t CppHandle; - int32_t ClassHandle; - Action2(); - void Invoke(float arg1, float arg2); - virtual void operator()(float arg1, float arg2); - void operator+=(System::Action2& del); - void operator-=(System::Action2& del); - }; -} - -namespace System -{ - template<> struct Func3 : System::Object - { - Func3(std::nullptr_t n); - Func3(Plugin::InternalUse iu, int32_t handle); - Func3(const Func3& other); - Func3(Func3&& other); - virtual ~Func3(); - Func3& operator=(const Func3& other); - Func3& operator=(std::nullptr_t other); - Func3& operator=(Func3&& other); - bool operator==(const Func3& other) const; - bool operator!=(const Func3& other) const; - int32_t CppHandle; - int32_t ClassHandle; - Func3(); - double Invoke(int32_t arg1, float arg2); - virtual double operator()(int32_t arg1, float arg2); - void operator+=(System::Func3& del); - void operator-=(System::Func3& del); - }; -} - -namespace System -{ - template<> struct Func3 : System::Object - { - Func3(std::nullptr_t n); - Func3(Plugin::InternalUse iu, int32_t handle); - Func3(const Func3& other); - Func3(Func3&& other); - virtual ~Func3(); - Func3& operator=(const Func3& other); - Func3& operator=(std::nullptr_t other); - Func3& operator=(Func3&& other); - bool operator==(const Func3& other) const; - bool operator!=(const Func3& other) const; - int32_t CppHandle; - int32_t ClassHandle; - Func3(); - System::String Invoke(int16_t arg1, int32_t arg2); - virtual System::String operator()(int16_t arg1, int32_t arg2); - void operator+=(System::Func3& del); - void operator-=(System::Func3& del); - }; -} - -namespace System -{ - struct AppDomainInitializer : System::Object - { - AppDomainInitializer(std::nullptr_t n); - AppDomainInitializer(Plugin::InternalUse iu, int32_t handle); - AppDomainInitializer(const AppDomainInitializer& other); - AppDomainInitializer(AppDomainInitializer&& other); - virtual ~AppDomainInitializer(); - AppDomainInitializer& operator=(const AppDomainInitializer& other); - AppDomainInitializer& operator=(std::nullptr_t other); - AppDomainInitializer& operator=(AppDomainInitializer&& other); - bool operator==(const AppDomainInitializer& other) const; - bool operator!=(const AppDomainInitializer& other) const; - int32_t CppHandle; - int32_t ClassHandle; - AppDomainInitializer(); - void Invoke(System::Array1 args); - virtual void operator()(System::Array1 args); - void operator+=(System::AppDomainInitializer& del); - void operator-=(System::AppDomainInitializer& del); - }; -} - -namespace UnityEngine -{ - namespace Events - { - struct UnityAction : System::Object - { - UnityAction(std::nullptr_t n); - UnityAction(Plugin::InternalUse iu, int32_t handle); - UnityAction(const UnityAction& other); - UnityAction(UnityAction&& other); - virtual ~UnityAction(); - UnityAction& operator=(const UnityAction& other); - UnityAction& operator=(std::nullptr_t other); - UnityAction& operator=(UnityAction&& other); - bool operator==(const UnityAction& other) const; - bool operator!=(const UnityAction& other) const; - int32_t CppHandle; - int32_t ClassHandle; - UnityAction(); - void Invoke(); - virtual void operator()(); - void operator+=(UnityEngine::Events::UnityAction& del); - void operator-=(UnityEngine::Events::UnityAction& del); - }; - } -} - -namespace UnityEngine -{ - namespace Events - { - template<> struct UnityAction2 : System::Object - { - UnityAction2(std::nullptr_t n); - UnityAction2(Plugin::InternalUse iu, int32_t handle); - UnityAction2(const UnityAction2& other); - UnityAction2(UnityAction2&& other); - virtual ~UnityAction2(); - UnityAction2& operator=(const UnityAction2& other); - UnityAction2& operator=(std::nullptr_t other); - UnityAction2& operator=(UnityAction2&& other); - bool operator==(const UnityAction2& other) const; - bool operator!=(const UnityAction2& other) const; - int32_t CppHandle; - int32_t ClassHandle; - UnityAction2(); - void Invoke(UnityEngine::SceneManagement::Scene& arg0, UnityEngine::SceneManagement::LoadSceneMode arg1); - virtual void operator()(UnityEngine::SceneManagement::Scene& arg0, UnityEngine::SceneManagement::LoadSceneMode arg1); - void operator+=(UnityEngine::Events::UnityAction2& del); - void operator-=(UnityEngine::Events::UnityAction2& del); - }; - } -} -/*END TYPE DEFINITIONS*/ 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/EditorBuildSettings.asset b/Unity/ProjectSettings/EditorBuildSettings.asset index 990bcc2..c813dae 100644 --- a/Unity/ProjectSettings/EditorBuildSettings.asset +++ b/Unity/ProjectSettings/EditorBuildSettings.asset @@ -5,6 +5,6 @@ EditorBuildSettings: m_ObjectHideFlags: 0 serializedVersion: 2 m_Scenes: - - enabled: 1 - path: Assets/TestScene.unity + - enabled: 0 + path: guid: 00000000000000000000000000000000 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 a847871..646b92e 100644 --- a/Unity/ProjectSettings/GraphicsSettings.asset +++ b/Unity/ProjectSettings/GraphicsSettings.asset @@ -36,6 +36,8 @@ GraphicsSettings: - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} - {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, 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 52eead6..8602e2b 100644 --- a/Unity/ProjectSettings/ProjectSettings.asset +++ b/Unity/ProjectSettings/ProjectSettings.asset @@ -3,15 +3,17 @@ --- !u!129 &1 PlayerSettings: m_ObjectHideFlags: 0 - serializedVersion: 12 + serializedVersion: 18 productGUID: 435980e4cf9ff4aa8b71e496e8163063 AndroidProfiler: 0 + AndroidFilterTouchesWhenObscured: 0 + AndroidEnableSustainedPerformanceMode: 0 defaultScreenOrientation: 4 targetDevice: 2 useOnDemandResources: 0 accelerometerFrequency: 60 - companyName: DefaultCompany - productName: UnityPlayground + companyName: JacksonDunstan + productName: UnityNativeScripting defaultCursor: {fileID: 0} cursorHotspot: {x: 0, y: 0} m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1} @@ -38,8 +40,6 @@ PlayerSettings: width: 1 height: 1 m_SplashScreenLogos: [] - m_SplashScreenBackgroundLandscape: {fileID: 0} - m_SplashScreenBackgroundPortrait: {fileID: 0} m_VirtualRealitySplashScreen: {fileID: 0} m_HolographicTrackingLossScreen: {fileID: 0} defaultScreenWidth: 1024 @@ -49,13 +49,11 @@ PlayerSettings: m_StereoRenderingPath: 0 m_ActiveColorSpace: 0 m_MTRendering: 1 - m_MobileMTRendering: 0 m_StackTraceTypes: 010000000100000001000000010000000100000001000000 iosShowActivityIndicatorOnLoading: -1 androidShowActivityIndicatorOnLoading: -1 - tizenShowActivityIndicatorOnLoading: -1 - iosAppInBackgroundBehavior: 0 displayResolutionDialog: 1 + iosUseCustomAppBackgroundBehavior: 0 iosAllowHTTPDownload: 1 allowedAutorotateToPortrait: 1 allowedAutorotateToPortraitUpsideDown: 1 @@ -63,18 +61,26 @@ PlayerSettings: allowedAutorotateToLandscapeLeft: 1 useOSAutorotation: 1 use32BitDisplayBuffer: 1 + preserveFramebufferAlpha: 0 disableDepthAndStencilBuffers: 0 - defaultIsFullScreen: 1 + androidStartInFullscreen: 1 + androidRenderOutsideSafeArea: 1 + androidUseSwappy: 0 + androidBlitType: 0 defaultIsNativeResolution: 1 + macRetinaSupport: 1 runInBackground: 0 captureSingleScreen: 0 muteOtherAudioSources: 0 Prepare IOS For Recording: 0 Force IOS Speakers When Recording: 0 + deferSystemGesturesMode: 0 + hideHomeButton: 0 submitAnalytics: 1 usePlayerLog: 1 bakeCollisionMeshes: 0 forceSingleInstance: 0 + useFlipModelSwapchain: 1 resizableWindow: 0 useMacAppStoreValidation: 0 macAppStoreCategory: public.app-category.games @@ -88,33 +94,26 @@ PlayerSettings: visibleInBackground: 0 allowFullscreenSwitch: 1 graphicsJobMode: 0 - macFullscreenMode: 2 - d3d9FullscreenMode: 1 - d3d11FullscreenMode: 1 + fullscreenMode: 1 xboxSpeechDB: 0 xboxEnableHeadOrientation: 0 xboxEnableGuest: 0 xboxEnablePIXSampling: 0 - n3dsDisableStereoscopicView: 0 - n3dsEnableSharedListOpt: 1 - n3dsEnableVSync: 0 - ignoreAlphaClear: 0 + metalFramebufferOnly: 0 xboxOneResolution: 0 + xboxOneSResolution: 0 + xboxOneXResolution: 3 xboxOneMonoLoggingLevel: 0 xboxOneLoggingLevel: 1 xboxOneDisableEsram: 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 + xboxOnePresentImmediateThreshold: 0 + switchQueueCommandMemory: 1048576 + switchQueueControlMemory: 16384 + switchQueueComputeMemory: 262144 + switchNVNShaderPoolsGranularity: 33554432 + switchNVNDefaultPoolsGranularity: 16777216 + switchNVNOtherPoolsGranularity: 16777216 + vulkanEnableSetSRGBWrite: 0 m_SupportedAspectRatios: 4:3: 1 5:4: 1 @@ -124,6 +123,7 @@ PlayerSettings: bundleVersion: 1.0 preloadedAssets: [] metroInputSource: 0 + wsaTransparentSwapchain: 0 m_HolographicPauseOnTrackingLoss: 1 xboxOneDisableKinectGpuReservation: 0 xboxOneEnable7thCore: 0 @@ -134,20 +134,41 @@ PlayerSettings: daydream: depthFormat: 0 useSustainedPerformanceMode: 0 + enableVideoLayer: 0 + useProtectedVideoMemory: 0 + minimumSupportedHeadTracking: 0 + maximumSupportedHeadTracking: 1 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 - targetPixelDensity: 0 + m_ColorGamuts: 00000000 + targetPixelDensity: 30 resolutionScalingMode: 0 + androidSupportedAspectRatio: 1 + androidMaxAspectRatio: 2.1 applicationIdentifier: 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 @@ -162,11 +183,9 @@ PlayerSettings: APKExpansionFiles: 0 keepLoadedShadersAlive: 0 StripUnusedMeshComponents: 0 - VertexChannelCompressionMask: - serializedVersion: 2 - m_Bits: 238 + VertexChannelCompressionMask: 214 iPhoneSdkVersion: 988 - iOSTargetOSVersionString: 6.0 + iOSTargetOSVersionString: 9.0 tvOSSdkVersion: 0 tvOSRequireExtendedGameController: 0 tvOSTargetOSVersionString: 9.0 @@ -182,15 +201,26 @@ PlayerSettings: iPhone47inSplashScreen: {fileID: 0} iPhone55inPortraitSplashScreen: {fileID: 0} iPhone55inLandscapeSplashScreen: {fileID: 0} + iPhone58inPortraitSplashScreen: {fileID: 0} + iPhone58inLandscapeSplashScreen: {fileID: 0} iPadPortraitSplashScreen: {fileID: 0} 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: [] + tvOSTopShelfImageWideLayers2x: [] iOSLaunchScreenType: 0 iOSLaunchScreenPortrait: {fileID: 0} iOSLaunchScreenLandscape: {fileID: 0} @@ -208,6 +238,8 @@ PlayerSettings: iOSLaunchScreeniPadFillPct: 100 iOSLaunchScreeniPadSize: 100 iOSLaunchScreeniPadCustomXibPath: + iOSUseLaunchScreenStoryboard: 0 + iOSLaunchScreenCustomStoryboardPath: iOSDeviceRequirements: [] iOSURLSchemes: [] iOSBackgroundModes: 0 @@ -218,20 +250,34 @@ PlayerSettings: appleDeveloperTeamID: iOSManualSigningProvisioningProfileID: tvOSManualSigningProvisioningProfileID: + iOSManualSigningProvisioningProfileType: 0 + tvOSManualSigningProvisioningProfileType: 0 appleEnableAutomaticSigning: 0 - AndroidTargetDevice: 3 + iOSRequireARKit: 0 + iOSAutomaticallyDetectAndAddCapabilities: 1 + appleEnableProMotion: 0 + clonedFromGUID: 00000000000000000000000000000000 + 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: @@ -240,6 +286,8 @@ PlayerSettings: m_Icon: {fileID: 0} m_Width: 128 m_Height: 128 + m_Kind: 0 + m_BuildTargetPlatformIcons: [] m_BuildTargetBatching: [] m_BuildTargetGraphicsAPIs: - m_BuildTarget: AndroidPlayer @@ -250,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 @@ -294,7 +342,7 @@ PlayerSettings: - m_BuildTarget: XboxOne m_Enabled: 0 m_Devices: [] - - m_BuildTarget: iOS + - m_BuildTarget: iPhone m_Enabled: 0 m_Devices: [] - m_BuildTarget: tvOS @@ -302,27 +350,23 @@ PlayerSettings: m_Devices: [] openGLRequireES31: 0 openGLRequireES31AEP: 0 - webPlayerTemplate: APPLICATION:Default + openGLRequireES32: 0 + vuforiaEnabled: 0 m_TemplateCustomTags: {} - 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: + mobileMTRendering: + Android: 1 + iPhone: 1 + tvOS: 1 + m_BuildTargetGroupLightmapEncodingQuality: + - m_BuildTarget: Standalone + m_EncodingQuality: 1 + - m_BuildTarget: XboxOne + m_EncodingQuality: 1 + - m_BuildTarget: PS4 + m_EncodingQuality: 1 + m_BuildTargetGroupLightmapSettings: [] playModeTestRunnerEnabled: 0 + runPlayModeTestAsEditModeTest: 0 actionOnDotNetUnhandledException: 1 enableInternalProfiler: 0 logObjCUncaughtExceptions: 1 @@ -350,6 +394,9 @@ PlayerSettings: switchTitleNames_9: switchTitleNames_10: switchTitleNames_11: + switchTitleNames_12: + switchTitleNames_13: + switchTitleNames_14: switchPublisherNames_0: switchPublisherNames_1: switchPublisherNames_2: @@ -362,6 +409,9 @@ PlayerSettings: switchPublisherNames_9: switchPublisherNames_10: switchPublisherNames_11: + switchPublisherNames_12: + switchPublisherNames_13: + switchPublisherNames_14: switchIcons_0: {fileID: 0} switchIcons_1: {fileID: 0} switchIcons_2: {fileID: 0} @@ -374,6 +424,9 @@ PlayerSettings: switchIcons_9: {fileID: 0} switchIcons_10: {fileID: 0} switchIcons_11: {fileID: 0} + switchIcons_12: {fileID: 0} + switchIcons_13: {fileID: 0} + switchIcons_14: {fileID: 0} switchSmallIcons_0: {fileID: 0} switchSmallIcons_1: {fileID: 0} switchSmallIcons_2: {fileID: 0} @@ -386,6 +439,9 @@ PlayerSettings: switchSmallIcons_9: {fileID: 0} switchSmallIcons_10: {fileID: 0} switchSmallIcons_11: {fileID: 0} + switchSmallIcons_12: {fileID: 0} + switchSmallIcons_13: {fileID: 0} + switchSmallIcons_14: {fileID: 0} switchManualHTML: switchAccessibleURLs: switchLegalInformation: @@ -427,8 +483,15 @@ PlayerSettings: switchLocalCommunicationIds_7: switchParentalControl: 0 switchAllowsScreenshot: 1 + switchAllowsVideoCapturing: 1 + switchAllowsRuntimeAddOnContentInstall: 0 switchDataLossConfirmation: 0 + switchUserAccountLockEnabled: 0 + switchSystemResourceMemory: 16777216 switchSupportedNpadStyles: 3 + switchNativeFsCacheSize: 32 + switchIsHoldTypeHorizontal: 0 + switchSupportedNpadCount: 8 switchSocketConfigEnabled: 0 switchTcpInitialSendBufferSize: 32 switchTcpInitialReceiveBufferSize: 64 @@ -437,6 +500,9 @@ PlayerSettings: switchUdpSendBufferSize: 9 switchUdpReceiveBufferSize: 42 switchSocketBufferEfficiency: 4 + switchSocketInitializeEnabled: 1 + switchNetworkInterfaceManagerInitializeEnabled: 1 + switchPlayerConnectionEnabled: 1 ps4NPAgeRating: 12 ps4NPTitleSecret: ps4NPTrophyPackPath: @@ -455,6 +521,8 @@ PlayerSettings: ps4PronunciationSIGPath: ps4BackgroundImagePath: ps4StartupImagePath: + ps4StartupImagesFolder: + ps4IconImagesFolder: ps4SaveDataImagePath: ps4SdkOverride: ps4BGMPath: @@ -473,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 @@ -502,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 @@ -563,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 @@ -591,46 +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 - stvDeviceAddress: - stvProductDescription: - stvProductAuthor: - stvProductAuthorEmail: - stvProductLink: - stvProductCategory: 0 XboxOneProductId: XboxOneUpdateKey: XboxOneSandboxId: @@ -640,6 +647,7 @@ PlayerSettings: XboxOneGameOsOverridePath: XboxOnePackagingOverridePath: XboxOneAppManifestOverridePath: + XboxOneVersion: 1.0.0.0 XboxOnePackageEncryption: 0 XboxOnePackageUpdateGranularity: 2 XboxOneDescription: @@ -653,7 +661,9 @@ PlayerSettings: XboxOneSplashScreen: {fileID: 0} XboxOneAllowedProductIds: [] XboxOnePersistentLocalStorageSize: 0 - xboxOneScriptCompiler: 0 + XboxOneXTitleMemory: 8 + xboxOneScriptCompiler: 1 + XboxOneOverrideIdentityName: vrEditorSettings: daydream: daydreamIconForeground: {fileID: 0} @@ -668,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 7a6fffb..7e64146 100644 --- a/Unity/ProjectSettings/ProjectVersion.txt +++ b/Unity/ProjectSettings/ProjectVersion.txt @@ -1 +1,2 @@ -m_EditorVersion: 2017.2.0f3 +m_EditorVersion: 2019.2.0f1 +m_EditorVersionWithRevision: 2019.2.0f1 (20c1667945cf) diff --git a/Unity/ProjectSettings/UnityAdsSettings.asset b/Unity/ProjectSettings/UnityAdsSettings.asset deleted file mode 100644 index e6070fc..0000000 Binary files a/Unity/ProjectSettings/UnityAdsSettings.asset and /dev/null differ 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": { - } -}