From 97421db1ada4818fd8a496958125bbade14bc143 Mon Sep 17 00:00:00 2001 From: Jackson Dunstan Date: Tue, 1 May 2018 09:11:18 -0700 Subject: [PATCH 01/36] Fix compiler errors for non-editor builds (thanks, @hanbim520!) Upgrade to 2017.4.1f1 --- Unity/Assets/NativeScript/Bindings.cs | 26 +++--- .../NativeScript/Editor/GenerateBindings.cs | 19 +++-- Unity/Assets/NativeScriptConstants.cs | 5 ++ Unity/ProjectSettings/GraphicsSettings.asset | 3 +- Unity/ProjectSettings/ProjectSettings.asset | 84 +++++++++++++++---- Unity/ProjectSettings/ProjectVersion.txt | 2 +- 6 files changed, 105 insertions(+), 34 deletions(-) diff --git a/Unity/Assets/NativeScript/Bindings.cs b/Unity/Assets/NativeScript/Bindings.cs index 4d182da..286d480 100644 --- a/Unity/Assets/NativeScript/Bindings.cs +++ b/Unity/Assets/NativeScript/Bindings.cs @@ -491,11 +491,11 @@ static T GetDelegate( typeof(T)) as T; } #else - [DllImport(PluginName)] + [DllImport(NativeScriptConstants.PluginName)] static extern void Init( IntPtr memory, int memorySize, - initMode initMode, + InitMode initMode, IntPtr releaseObject, IntPtr stringNew, IntPtr setException, @@ -555,21 +555,21 @@ static extern void Init( IntPtr unboxDouble /*END INIT PARAMS*/); - [DllImport(PluginName)] + [DllImport(NativeScriptConstants.PluginName)] static extern void SetCsharpException(int handle); /*BEGIN IMPORTS*/ - [DllImport(Constants.PluginName)] - public static extern void NewBaseBallScript(int thisHandle, int param0); + [DllImport(NativeScriptConstants.PluginName)] + public static extern int NewBaseBallScript(int thisHandle); - [DllImport(Constants.PluginName)] - public static extern void DestroyBaseBallScript(int thisHandle, int param0); + [DllImport(NativeScriptConstants.PluginName)] + public static extern void DestroyBaseBallScript(int thisHandle); - [DllImport(Constants.PluginName)] + [DllImport(NativeScriptConstants.PluginName)] public static extern void MyGameAbstractBaseBallScriptUpdate(int thisHandle); - [DllImport(Constants.PluginName)] - public static extern void SetCsharpExceptionSystemNullReferenceException(int thisHandle, int param0); + [DllImport(NativeScriptConstants.PluginName)] + public static extern void SetCsharpExceptionSystemNullReferenceException(int thisHandle); /*END IMPORTS*/ #endif @@ -631,13 +631,15 @@ IntPtr unboxDouble delegate int BoxDoubleDelegate(double val); delegate double UnboxDoubleDelegate(int valHandle); /*END DELEGATE TYPES*/ - - private static readonly string pluginPath = Application.dataPath + PLUGIN_PATH; + #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; diff --git a/Unity/Assets/NativeScript/Editor/GenerateBindings.cs b/Unity/Assets/NativeScript/Editor/GenerateBindings.cs index 7bd5513..0b810fd 100644 --- a/Unity/Assets/NativeScript/Editor/GenerateBindings.cs +++ b/Unity/Assets/NativeScript/Editor/GenerateBindings.cs @@ -7550,7 +7550,8 @@ static void AppendBaseType( GetTypeName(string.Empty, string.Empty), null, cppDefaultConstructorBindingFunctionName, - cppDefaultConstructorBindingFunctionParams, + ConvertParameters(Type.EmptyTypes), + typeof(int), builders.CsharpImports); AppendCsharpGetDelegateCall( GetTypeName(string.Empty, string.Empty), @@ -7607,11 +7608,14 @@ static void AppendBaseType( typeof(void), TypeKind.None, builders.CsharpDelegates); + ParameterInfo[] cppDestroyImportFunctionParams = ConvertParameters( + new Type[0]); AppendCsharpImport( GetTypeName(string.Empty, string.Empty), null, cppDestroyBindingFunctionName, - cppDestroyBindingFunctionParams, + cppDestroyImportFunctionParams, + typeof(void), builders.CsharpImports); AppendCsharpGetDelegateCall( GetTypeName(string.Empty, string.Empty), @@ -8685,6 +8689,7 @@ static ParameterInfo[] AppendBaseTypeCppNativeInvokeCall( typeParams, funcName, invokeParams, + typeof(void), builders.CsharpImports); return invokeParams; @@ -10639,11 +10644,14 @@ static void AppendCsharpImport( 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.Append("\t\t[DllImport(NativeScriptConstants.PluginName)]\n"); + output.Append("\t\tpublic static extern "); + AppendCsharpTypeFullName(returnType, output); + output.Append(' '); AppendCsharpDelegateName( typeTypeName, typeParams, @@ -10857,7 +10865,8 @@ static void AppendExceptions( GetTypeName(string.Empty, string.Empty), null, funcName, - parameters, + ConvertParameters(Type.EmptyTypes), + typeof(void), builders.CsharpImports); // C# delegate diff --git a/Unity/Assets/NativeScriptConstants.cs b/Unity/Assets/NativeScriptConstants.cs index 54e6923..7e91c65 100644 --- a/Unity/Assets/NativeScriptConstants.cs +++ b/Unity/Assets/NativeScriptConstants.cs @@ -10,6 +10,11 @@ /// public static class NativeScriptConstants { + /// + /// Name of the plugin used by [DllImport] when running outside the editor + /// + public const string PluginName = "NativeScript"; + /// /// Path within the Unity project to the exposed types JSON file /// diff --git a/Unity/ProjectSettings/GraphicsSettings.asset b/Unity/ProjectSettings/GraphicsSettings.asset index a847871..d8b1468 100644 --- a/Unity/ProjectSettings/GraphicsSettings.asset +++ b/Unity/ProjectSettings/GraphicsSettings.asset @@ -36,7 +36,8 @@ GraphicsSettings: - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} - {fileID: 10782, guid: 0000000000000000f000000000000000, type: 0} - {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0} - - {fileID: 16002, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 16001, guid: 0000000000000000f000000000000000, type: 0} m_PreloadedShaders: [] m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} diff --git a/Unity/ProjectSettings/ProjectSettings.asset b/Unity/ProjectSettings/ProjectSettings.asset index 52eead6..2a82354 100644 --- a/Unity/ProjectSettings/ProjectSettings.asset +++ b/Unity/ProjectSettings/ProjectSettings.asset @@ -3,9 +3,10 @@ --- !u!129 &1 PlayerSettings: m_ObjectHideFlags: 0 - serializedVersion: 12 + serializedVersion: 14 productGUID: 435980e4cf9ff4aa8b71e496e8163063 AndroidProfiler: 0 + AndroidFilterTouchesWhenObscured: 0 defaultScreenOrientation: 4 targetDevice: 2 useOnDemandResources: 0 @@ -38,8 +39,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,7 +48,6 @@ PlayerSettings: m_StereoRenderingPath: 0 m_ActiveColorSpace: 0 m_MTRendering: 1 - m_MobileMTRendering: 0 m_StackTraceTypes: 010000000100000001000000010000000100000001000000 iosShowActivityIndicatorOnLoading: -1 androidShowActivityIndicatorOnLoading: -1 @@ -63,14 +61,19 @@ PlayerSettings: allowedAutorotateToLandscapeLeft: 1 useOSAutorotation: 1 use32BitDisplayBuffer: 1 + preserveFramebufferAlpha: 0 disableDepthAndStencilBuffers: 0 + androidBlitType: 0 defaultIsFullScreen: 1 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 @@ -89,20 +92,22 @@ PlayerSettings: allowFullscreenSwitch: 1 graphicsJobMode: 0 macFullscreenMode: 2 - d3d9FullscreenMode: 1 d3d11FullscreenMode: 1 xboxSpeechDB: 0 xboxEnableHeadOrientation: 0 xboxEnableGuest: 0 xboxEnablePIXSampling: 0 + metalFramebufferOnly: 0 n3dsDisableStereoscopicView: 0 n3dsEnableSharedListOpt: 1 n3dsEnableVSync: 0 - ignoreAlphaClear: 0 xboxOneResolution: 0 + xboxOneSResolution: 0 + xboxOneXResolution: 3 xboxOneMonoLoggingLevel: 0 xboxOneLoggingLevel: 1 xboxOneDisableEsram: 0 + xboxOnePresentImmediateThreshold: 0 videoMemoryForVertexBuffers: 0 psp2PowerMode: 0 psp2AcquireBGM: 1 @@ -124,6 +129,7 @@ PlayerSettings: bundleVersion: 1.0 preloadedAssets: [] metroInputSource: 0 + wsaTransparentSwapchain: 0 m_HolographicPauseOnTrackingLoss: 1 xboxOneDisableKinectGpuReservation: 0 xboxOneEnable7thCore: 0 @@ -134,12 +140,23 @@ PlayerSettings: daydream: depthFormat: 0 useSustainedPerformanceMode: 0 + enableVideoLayer: 0 + useProtectedVideoMemory: 0 + minimumSupportedHeadTracking: 0 + maximumSupportedHeadTracking: 1 hololens: depthFormat: 1 + depthBufferSharingEnabled: 0 + oculus: + sharedDepthBuffer: 0 + dashSupport: 0 protectGraphicsMemory: 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 @@ -166,7 +183,7 @@ PlayerSettings: serializedVersion: 2 m_Bits: 238 iPhoneSdkVersion: 988 - iOSTargetOSVersionString: 6.0 + iOSTargetOSVersionString: 7.0 tvOSSdkVersion: 0 tvOSRequireExtendedGameController: 0 tvOSTargetOSVersionString: 9.0 @@ -182,15 +199,21 @@ 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} appleTVSplashScreen: {fileID: 0} + appleTVSplashScreen2x: {fileID: 0} tvOSSmallIconLayers: [] + tvOSSmallIconLayers2x: [] tvOSLargeIconLayers: [] tvOSTopShelfImageLayers: [] + tvOSTopShelfImageLayers2x: [] tvOSTopShelfImageWideLayers: [] + tvOSTopShelfImageWideLayers2x: [] iOSLaunchScreenType: 0 iOSLaunchScreenPortrait: {fileID: 0} iOSLaunchScreenLandscape: {fileID: 0} @@ -208,6 +231,8 @@ PlayerSettings: iOSLaunchScreeniPadFillPct: 100 iOSLaunchScreeniPadSize: 100 iOSLaunchScreeniPadCustomXibPath: + iOSUseLaunchScreenStoryboard: 0 + iOSLaunchScreenCustomStoryboardPath: iOSDeviceRequirements: [] iOSURLSchemes: [] iOSBackgroundModes: 0 @@ -219,6 +244,7 @@ PlayerSettings: iOSManualSigningProvisioningProfileID: tvOSManualSigningProvisioningProfileID: appleEnableAutomaticSigning: 0 + clonedFromGUID: 00000000000000000000000000000000 AndroidTargetDevice: 3 AndroidSplashScreenScale: 0 androidSplashScreen: {fileID: 0} @@ -226,7 +252,9 @@ PlayerSettings: AndroidKeyaliasName: AndroidTVCompatibility: 1 AndroidIsGame: 1 + AndroidEnableTango: 0 androidEnableBanner: 1 + androidUseLowAccuracyLocation: 0 m_AndroidBanners: - width: 320 height: 180 @@ -240,6 +268,7 @@ PlayerSettings: m_Icon: {fileID: 0} m_Width: 128 m_Height: 128 + m_Kind: 0 m_BuildTargetBatching: [] m_BuildTargetGraphicsAPIs: - m_BuildTarget: AndroidPlayer @@ -300,10 +329,21 @@ PlayerSettings: - m_BuildTarget: tvOS m_Enabled: 0 m_Devices: [] + m_BuildTargetEnableVuforiaSettings: [] openGLRequireES31: 0 openGLRequireES31AEP: 0 - webPlayerTemplate: APPLICATION:Default m_TemplateCustomTags: {} + 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 wiiUTitleID: 0005000011000000 wiiUGroupID: 00010000 wiiUCommonSaveSize: 4096 @@ -350,6 +390,9 @@ PlayerSettings: switchTitleNames_9: switchTitleNames_10: switchTitleNames_11: + switchTitleNames_12: + switchTitleNames_13: + switchTitleNames_14: switchPublisherNames_0: switchPublisherNames_1: switchPublisherNames_2: @@ -362,6 +405,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 +420,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 +435,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,6 +479,8 @@ PlayerSettings: switchLocalCommunicationIds_7: switchParentalControl: 0 switchAllowsScreenshot: 1 + switchAllowsVideoCapturing: 1 + switchAllowsRuntimeAddOnContentInstall: 0 switchDataLossConfirmation: 0 switchSupportedNpadStyles: 3 switchSocketConfigEnabled: 0 @@ -437,6 +491,9 @@ PlayerSettings: switchUdpSendBufferSize: 9 switchUdpReceiveBufferSize: 42 switchSocketBufferEfficiency: 4 + switchSocketInitializeEnabled: 1 + switchNetworkInterfaceManagerInitializeEnabled: 1 + switchPlayerConnectionEnabled: 1 ps4NPAgeRating: 12 ps4NPTitleSecret: ps4NPTrophyPackPath: @@ -455,6 +512,8 @@ PlayerSettings: ps4PronunciationSIGPath: ps4BackgroundImagePath: ps4StartupImagePath: + ps4StartupImagesFolder: + ps4IconImagesFolder: ps4SaveDataImagePath: ps4SdkOverride: ps4BGMPath: @@ -625,12 +684,6 @@ PlayerSettings: n3dsTitle: GameName n3dsProductCode: n3dsApplicationId: 0xFF3FF - stvDeviceAddress: - stvProductDescription: - stvProductAuthor: - stvProductAuthorEmail: - stvProductLink: - stvProductCategory: 0 XboxOneProductId: XboxOneUpdateKey: XboxOneSandboxId: @@ -653,6 +706,7 @@ PlayerSettings: XboxOneSplashScreen: {fileID: 0} XboxOneAllowedProductIds: [] XboxOnePersistentLocalStorageSize: 0 + XboxOneXTitleMemory: 8 xboxOneScriptCompiler: 0 vrEditorSettings: daydream: diff --git a/Unity/ProjectSettings/ProjectVersion.txt b/Unity/ProjectSettings/ProjectVersion.txt index e6cd1f9..e3618f1 100644 --- a/Unity/ProjectSettings/ProjectVersion.txt +++ b/Unity/ProjectSettings/ProjectVersion.txt @@ -1 +1 @@ -m_EditorVersion: 2017.3.0f3 +m_EditorVersion: 2017.4.1f1 From 0f3e137a60dfd78f73894bc0170cfa9d288d9f4a Mon Sep 17 00:00:00 2001 From: Jackson Dunstan Date: Sat, 5 May 2018 10:23:59 -0700 Subject: [PATCH 02/36] Move CppSource into Assets Rename platform preprocessor symbols to TARGET_OS_NAME Disable bitcode in iOS builds Use static linking for iOS (i.e. [DllImport("__Internal")]) Build iOS into a hidden directory so it's ignored by Unity Remove NativeScriptConstants.PluginName Update Unity project and company name Update README.md Update .gitignore --- .gitignore | 6 +-- README.md | 2 +- Unity/Assets/CppSource.meta | 10 ++++ Unity/{ => Assets}/CppSource/CMakeLists.txt | 47 ++++++++++--------- Unity/Assets/CppSource/CMakeLists.txt.meta | 9 ++++ Unity/Assets/CppSource/Game.meta | 10 ++++ Unity/{ => Assets}/CppSource/Game/Game.cpp | 0 Unity/Assets/CppSource/Game/Game.cpp.meta | 26 ++++++++++ Unity/{ => Assets}/CppSource/Game/Game.h | 0 Unity/Assets/CppSource/Game/Game.h.meta | 26 ++++++++++ Unity/Assets/CppSource/NativeScript.meta | 10 ++++ .../CppSource/NativeScript/Bindings.cpp | 0 .../CppSource/NativeScript/Bindings.cpp.meta | 26 ++++++++++ .../CppSource/NativeScript/Bindings.h | 0 .../CppSource/NativeScript/Bindings.h.meta | 26 ++++++++++ Unity/{ => Assets}/CppSource/iOS.cmake | 0 Unity/Assets/CppSource/iOS.cmake.meta | 9 ++++ Unity/Assets/NativeScript/Bindings.cs | 16 ++++--- Unity/Assets/NativeScriptConstants.cs | 5 -- Unity/CppSource/Game.cpp.meta | 27 ----------- Unity/ProjectSettings/GraphicsSettings.asset | 1 - Unity/ProjectSettings/ProjectSettings.asset | 4 +- 22 files changed, 192 insertions(+), 68 deletions(-) create mode 100644 Unity/Assets/CppSource.meta rename Unity/{ => Assets}/CppSource/CMakeLists.txt (70%) create mode 100644 Unity/Assets/CppSource/CMakeLists.txt.meta create mode 100644 Unity/Assets/CppSource/Game.meta rename Unity/{ => Assets}/CppSource/Game/Game.cpp (100%) create mode 100644 Unity/Assets/CppSource/Game/Game.cpp.meta rename Unity/{ => Assets}/CppSource/Game/Game.h (100%) create mode 100644 Unity/Assets/CppSource/Game/Game.h.meta create mode 100644 Unity/Assets/CppSource/NativeScript.meta rename Unity/{ => Assets}/CppSource/NativeScript/Bindings.cpp (100%) create mode 100644 Unity/Assets/CppSource/NativeScript/Bindings.cpp.meta rename Unity/{ => Assets}/CppSource/NativeScript/Bindings.h (100%) create mode 100644 Unity/Assets/CppSource/NativeScript/Bindings.h.meta rename Unity/{ => Assets}/CppSource/iOS.cmake (100%) create mode 100644 Unity/Assets/CppSource/iOS.cmake.meta delete mode 100644 Unity/CppSource/Game.cpp.meta diff --git a/.gitignore b/.gitignore index aa955b9..7f3848a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,2 @@ -# Typical location for CMake build files and Visual Studio 2017 generated directories -/cmake -/NativeScript.dir -/x64 +# Rider IDE +.idea \ No newline at end of file diff --git a/README.md b/README.md index d07f917..6302ab5 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ C++ is the standard language for video games as well as many other fields. By pr 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 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 70% rename from Unity/CppSource/CMakeLists.txt rename to Unity/Assets/CppSource/CMakeLists.txt index 73a28d6..306ae25 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,9 @@ 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() # 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/CppSource/Game/Game.cpp b/Unity/Assets/CppSource/Game/Game.cpp similarity index 100% rename from Unity/CppSource/Game/Game.cpp rename to Unity/Assets/CppSource/Game/Game.cpp 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/CppSource/Game/Game.h b/Unity/Assets/CppSource/Game/Game.h similarity index 100% rename from Unity/CppSource/Game/Game.h rename to Unity/Assets/CppSource/Game/Game.h 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/CppSource/NativeScript/Bindings.cpp b/Unity/Assets/CppSource/NativeScript/Bindings.cpp similarity index 100% rename from Unity/CppSource/NativeScript/Bindings.cpp rename to Unity/Assets/CppSource/NativeScript/Bindings.cpp 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/CppSource/NativeScript/Bindings.h b/Unity/Assets/CppSource/NativeScript/Bindings.h similarity index 100% rename from Unity/CppSource/NativeScript/Bindings.h rename to Unity/Assets/CppSource/NativeScript/Bindings.h 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/NativeScript/Bindings.cs b/Unity/Assets/NativeScript/Bindings.cs index 286d480..248ee00 100644 --- a/Unity/Assets/NativeScript/Bindings.cs +++ b/Unity/Assets/NativeScript/Bindings.cs @@ -301,7 +301,11 @@ public DestroyEntry(DestroyFunction function, int cppHandle) } // Name of the plugin when using [DllImport] +#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 @@ -491,7 +495,7 @@ static T GetDelegate( typeof(T)) as T; } #else - [DllImport(NativeScriptConstants.PluginName)] + [DllImport(PLUGIN_NAME)] static extern void Init( IntPtr memory, int memorySize, @@ -555,20 +559,20 @@ static extern void Init( IntPtr unboxDouble /*END INIT PARAMS*/); - [DllImport(NativeScriptConstants.PluginName)] + [DllImport(PLUGIN_NAME)] static extern void SetCsharpException(int handle); /*BEGIN IMPORTS*/ - [DllImport(NativeScriptConstants.PluginName)] + [DllImport(PLUGIN_NAME)] public static extern int NewBaseBallScript(int thisHandle); - [DllImport(NativeScriptConstants.PluginName)] + [DllImport(PLUGIN_NAME)] public static extern void DestroyBaseBallScript(int thisHandle); - [DllImport(NativeScriptConstants.PluginName)] + [DllImport(PLUGIN_NAME)] public static extern void MyGameAbstractBaseBallScriptUpdate(int thisHandle); - [DllImport(NativeScriptConstants.PluginName)] + [DllImport(PLUGIN_NAME)] public static extern void SetCsharpExceptionSystemNullReferenceException(int thisHandle); /*END IMPORTS*/ #endif diff --git a/Unity/Assets/NativeScriptConstants.cs b/Unity/Assets/NativeScriptConstants.cs index 7e91c65..54e6923 100644 --- a/Unity/Assets/NativeScriptConstants.cs +++ b/Unity/Assets/NativeScriptConstants.cs @@ -10,11 +10,6 @@ /// public static class NativeScriptConstants { - /// - /// Name of the plugin used by [DllImport] when running outside the editor - /// - public const string PluginName = "NativeScript"; - /// /// Path within the Unity project to the exposed types JSON 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/ProjectSettings/GraphicsSettings.asset b/Unity/ProjectSettings/GraphicsSettings.asset index d8b1468..77bf2f1 100644 --- a/Unity/ProjectSettings/GraphicsSettings.asset +++ b/Unity/ProjectSettings/GraphicsSettings.asset @@ -37,7 +37,6 @@ GraphicsSettings: - {fileID: 10782, guid: 0000000000000000f000000000000000, type: 0} - {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0} - {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0} - - {fileID: 16001, guid: 0000000000000000f000000000000000, type: 0} m_PreloadedShaders: [] m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} diff --git a/Unity/ProjectSettings/ProjectSettings.asset b/Unity/ProjectSettings/ProjectSettings.asset index 2a82354..b6955bb 100644 --- a/Unity/ProjectSettings/ProjectSettings.asset +++ b/Unity/ProjectSettings/ProjectSettings.asset @@ -11,8 +11,8 @@ PlayerSettings: 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} From 6e23b68d36e415b9c48151f7fb570832e93d1e5d Mon Sep 17 00:00:00 2001 From: Jackson Dunstan Date: Sat, 5 May 2018 14:19:54 -0700 Subject: [PATCH 03/36] Updated README to use Android as a build time example --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6302ab5..ed009f0 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,9 @@ This project aims to give you a viable alternative to C#. Scripting in C++ isn't ## Fast Device Build Times -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++. +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. -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! +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! ## Fast Compile Times From 40b66d8e371d3fb3d6215338ba018ed6f81295c7 Mon Sep 17 00:00:00 2001 From: jb Date: Mon, 14 May 2018 19:21:55 +0200 Subject: [PATCH 04/36] Fix incorrect path when generating bindings. Fix broken pragma causing warnings --- Unity/Assets/NativeScript/Editor/GenerateBindings.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Unity/Assets/NativeScript/Editor/GenerateBindings.cs b/Unity/Assets/NativeScript/Editor/GenerateBindings.cs index 0b810fd..83d4726 100644 --- a/Unity/Assets/NativeScript/Editor/GenerateBindings.cs +++ b/Unity/Assets/NativeScript/Editor/GenerateBindings.cs @@ -24,7 +24,7 @@ public static class GenerateBindings { // Disable unused field types. JsonUtility actually uses them, but it // does so with reflection. - #pragma warning disable CS0649 + #pragma warning disable 649 [Serializable] class JsonConstructor @@ -289,7 +289,9 @@ struct TypeName static readonly string CppDirPath = Path.Combine( Path.Combine( - ProjectDirPath, + Path.Combine( + ProjectDirPath, + "Assets"), "CppSource"), "NativeScript"); static readonly string CsharpPath = Path.Combine( @@ -308,7 +310,7 @@ static readonly FieldOrderComparer DefaultFieldOrderComparer = new FieldOrderComparer(); // Restore unused field types - #pragma warning restore CS0649 + #pragma warning restore 649 public static void Generate() { From aae2a8320ead9cb7ffaa908801d97cd07c31afa4 Mon Sep 17 00:00:00 2001 From: jb Date: Mon, 14 May 2018 19:26:52 +0200 Subject: [PATCH 05/36] Update the readme to correct path to CppSource --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ed009f0..14f12cc 100644 --- a/README.md +++ b/README.md @@ -161,9 +161,8 @@ With C++, the workflow looks like this: 1. Download or clone this repo 2. Copy everything in `Unity/Assets` directory to your Unity project's `Assets` directory -3. Copy the `Unity/CppSource` directory to your Unity project directory -4. Edit `NativeScriptTypes.json` and specify what parts of the Unity, .NET, and custom DLL APIs you want access to from C++. -5. Edit `Unity/CppSource/Game/Game.cpp` and `Unity/CppSource/Game/Game.h` to create your game. Some example code is provided, but feel free to delete it. You can add more C++ source (`.cpp`) and header (`.h`) files here as your game grows. +3. Edit `NativeScriptTypes.json` and specify what parts of the Unity, .NET, and custom DLL APIs you want access to from C++. +4. Edit `Unity/Assets/CppSource/Game/Game.cpp` and `Unity/Assets/CppSource/Game/Game.h` to create your game. Some example code is provided, but feel free to delete it. You can add more C++ source (`.cpp`) and header (`.h`) files here as your game grows. # Building the C++ Plugin From 800e0cd027c57da62f04b5357436667b16414d65 Mon Sep 17 00:00:00 2001 From: Jackson Dunstan Date: Thu, 17 May 2018 08:54:33 -0700 Subject: [PATCH 06/36] Fix generated plugin name in some cases --- Unity/Assets/NativeScript/Editor/GenerateBindings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Unity/Assets/NativeScript/Editor/GenerateBindings.cs b/Unity/Assets/NativeScript/Editor/GenerateBindings.cs index 83d4726..9e04575 100644 --- a/Unity/Assets/NativeScript/Editor/GenerateBindings.cs +++ b/Unity/Assets/NativeScript/Editor/GenerateBindings.cs @@ -10650,7 +10650,7 @@ static void AppendCsharpImport( StringBuilder output ) { - output.Append("\t\t[DllImport(NativeScriptConstants.PluginName)]\n"); + output.Append("\t\t[DllImport(PLUGIN_NAME)]\n"); output.Append("\t\tpublic static extern "); AppendCsharpTypeFullName(returnType, output); output.Append(' '); From 2180b3edfea9d58da5242d9c5752b344d9a0b84c Mon Sep 17 00:00:00 2001 From: Jackson Dunstan Date: Thu, 7 Jun 2018 21:04:08 -0700 Subject: [PATCH 07/36] Generate correct return type for non-void base type methods. Thanks, @JmgrArt! --- Unity/Assets/NativeScript/Editor/GenerateBindings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Unity/Assets/NativeScript/Editor/GenerateBindings.cs b/Unity/Assets/NativeScript/Editor/GenerateBindings.cs index 9e04575..8d84312 100644 --- a/Unity/Assets/NativeScript/Editor/GenerateBindings.cs +++ b/Unity/Assets/NativeScript/Editor/GenerateBindings.cs @@ -8691,7 +8691,7 @@ static ParameterInfo[] AppendBaseTypeCppNativeInvokeCall( typeParams, funcName, invokeParams, - typeof(void), + invokeMethod.ReturnType, builders.CsharpImports); return invokeParams; From 60450d4a58f623bf39770cf9e70da6c9932dd78e Mon Sep 17 00:00:00 2001 From: Jackson Dunstan Date: Sun, 10 Jun 2018 22:43:59 -0700 Subject: [PATCH 08/36] Pass Init parameters in 'memory' Never release exposed function delegates Fix miscellaneous Rider warnings --- .../CppSource/NativeScript/Bindings.cpp | 241 ++--- Unity/Assets/NativeScript/Bindings.cs | 626 +++++++------ Unity/Assets/NativeScript/BootScene.unity | 14 +- .../Assets/NativeScript/Editor/EditorMenus.cs | 3 +- .../NativeScript/Editor/GenerateBindings.cs | 871 +++++++----------- .../manifest.json | 0 Unity/ProjectSettings/GraphicsSettings.asset | 1 + Unity/ProjectSettings/PresetManager.asset | 6 + Unity/ProjectSettings/ProjectVersion.txt | 2 +- 9 files changed, 769 insertions(+), 995 deletions(-) rename Unity/{UnityPackageManager => Packages}/manifest.json (100%) create mode 100644 Unity/ProjectSettings/PresetManager.asset diff --git a/Unity/Assets/CppSource/NativeScript/Bindings.cpp b/Unity/Assets/CppSource/NativeScript/Bindings.cpp index a828a47..8e36cbb 100644 --- a/Unity/Assets/CppSource/NativeScript/Bindings.cpp +++ b/Unity/Assets/CppSource/NativeScript/Bindings.cpp @@ -5951,142 +5951,146 @@ enum class InitMode : uint8_t DLLEXPORT void Init( uint8_t* memory, int32_t memorySize, - InitMode initMode, - void (*releaseObject)(int32_t handle), - int32_t (*stringNew)(const char* chars), - void (*setException)(int32_t handle), - int32_t (*arrayGetLength)(int32_t handle), - int32_t (*enumerableGetEnumerator)(int32_t handle), - /*BEGIN INIT PARAMS*/ - int32_t maxManagedObjects, - void (*releaseSystemDecimal)(int32_t handle), - int32_t (*systemDecimalConstructorSystemDouble)(double value), - int32_t (*systemDecimalConstructorSystemUInt64)(uint64_t value), - int32_t (*boxDecimal)(int32_t valHandle), - int32_t (*unboxDecimal)(int32_t valHandle), - UnityEngine::Vector3 (*unityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingle)(float x, float y, float z), - UnityEngine::Vector3 (*unityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3)(UnityEngine::Vector3& a, UnityEngine::Vector3& b), - int32_t (*boxVector3)(UnityEngine::Vector3& val), - UnityEngine::Vector3 (*unboxVector3)(int32_t valHandle), - int32_t (*unityEngineObjectPropertyGetName)(int32_t thisHandle), - void (*unityEngineObjectPropertySetName)(int32_t thisHandle, int32_t valueHandle), - int32_t (*unityEngineComponentPropertyGetTransform)(int32_t thisHandle), - UnityEngine::Vector3 (*unityEngineTransformPropertyGetPosition)(int32_t thisHandle), - void (*unityEngineTransformPropertySetPosition)(int32_t thisHandle, UnityEngine::Vector3& value), - int32_t (*systemCollectionsIEnumeratorPropertyGetCurrent)(int32_t thisHandle), - int32_t (*systemCollectionsIEnumeratorMethodMoveNext)(int32_t thisHandle), - int32_t (*unityEngineGameObjectMethodAddComponentMyGameBaseBallScript)(int32_t thisHandle), - int32_t (*unityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveType)(UnityEngine::PrimitiveType type), - void (*unityEngineDebugMethodLogSystemObject)(int32_t messageHandle), - int32_t (*unityEngineMonoBehaviourPropertyGetTransform)(int32_t thisHandle), - int32_t (*systemExceptionConstructorSystemString)(int32_t messageHandle), - int32_t (*boxPrimitiveType)(UnityEngine::PrimitiveType val), - UnityEngine::PrimitiveType (*unboxPrimitiveType)(int32_t valHandle), - System::Single (*unityEngineTimePropertyGetDeltaTime)(), - void (*releaseBaseBallScript)(int32_t handle), - void (*baseBallScriptConstructor)(int32_t cppHandle, int32_t* handle), - int32_t (*boxBoolean)(uint32_t val), - int32_t (*unboxBoolean)(int32_t valHandle), - int32_t (*boxSByte)(int8_t val), - System::SByte (*unboxSByte)(int32_t valHandle), - int32_t (*boxByte)(uint8_t val), - System::Byte (*unboxByte)(int32_t valHandle), - int32_t (*boxInt16)(int16_t val), - System::Int16 (*unboxInt16)(int32_t valHandle), - int32_t (*boxUInt16)(uint16_t val), - System::UInt16 (*unboxUInt16)(int32_t valHandle), - int32_t (*boxInt32)(int32_t val), - System::Int32 (*unboxInt32)(int32_t valHandle), - int32_t (*boxUInt32)(uint32_t val), - System::UInt32 (*unboxUInt32)(int32_t valHandle), - int32_t (*boxInt64)(int64_t val), - System::Int64 (*unboxInt64)(int32_t valHandle), - int32_t (*boxUInt64)(uint64_t val), - System::UInt64 (*unboxUInt64)(int32_t valHandle), - int32_t (*boxChar)(uint16_t val), - int16_t (*unboxChar)(int32_t valHandle), - int32_t (*boxSingle)(float val), - System::Single (*unboxSingle)(int32_t valHandle), - int32_t (*boxDouble)(double val), - System::Double (*unboxDouble)(int32_t valHandle) - /*END INIT PARAMS*/) + InitMode initMode) { uint8_t* curMemory = memory; + // Read fixed parameters + Plugin::ReleaseObject = *(void (**)(int32_t handle))curMemory; + curMemory += sizeof(Plugin::ReleaseObject); + Plugin::StringNew = *(int32_t (**)(const char*))curMemory; + curMemory += sizeof(Plugin::StringNew); + Plugin::SetException = *(void (**)(int32_t))curMemory; + curMemory += sizeof(Plugin::SetException); + Plugin::ArrayGetLength = *(int32_t (**)(int32_t))curMemory; + curMemory += sizeof(Plugin::ArrayGetLength); + Plugin::EnumerableGetEnumerator = *(int32_t (**)(int32_t))curMemory; + curMemory += sizeof(Plugin::EnumerableGetEnumerator); + + // Read generated parameters + int32_t maxManagedObjects = *(int32_t*)curMemory; + curMemory += sizeof(int32_t); + /*BEGIN INIT BODY PARAMETER READS*/ + Plugin::ReleaseSystemDecimal = *(void (**)(int32_t handle))curMemory; + curMemory += sizeof(Plugin::ReleaseSystemDecimal); + Plugin::SystemDecimalConstructorSystemDouble = *(int32_t (**)(double value))curMemory; + curMemory += sizeof(Plugin::SystemDecimalConstructorSystemDouble); + Plugin::SystemDecimalConstructorSystemUInt64 = *(int32_t (**)(uint64_t value))curMemory; + curMemory += sizeof(Plugin::SystemDecimalConstructorSystemUInt64); + Plugin::BoxDecimal = *(int32_t (**)(int32_t valHandle))curMemory; + curMemory += sizeof(Plugin::BoxDecimal); + Plugin::UnboxDecimal = *(int32_t (**)(int32_t valHandle))curMemory; + curMemory += sizeof(Plugin::UnboxDecimal); + Plugin::UnityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingle = *(UnityEngine::Vector3 (**)(float x, float y, float z))curMemory; + curMemory += sizeof(Plugin::UnityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingle); + Plugin::UnityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3 = *(UnityEngine::Vector3 (**)(UnityEngine::Vector3& a, UnityEngine::Vector3& b))curMemory; + curMemory += sizeof(Plugin::UnityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3); + Plugin::BoxVector3 = *(int32_t (**)(UnityEngine::Vector3& val))curMemory; + curMemory += sizeof(Plugin::BoxVector3); + Plugin::UnboxVector3 = *(UnityEngine::Vector3 (**)(int32_t valHandle))curMemory; + curMemory += sizeof(Plugin::UnboxVector3); + Plugin::UnityEngineObjectPropertyGetName = *(int32_t (**)(int32_t thisHandle))curMemory; + curMemory += sizeof(Plugin::UnityEngineObjectPropertyGetName); + Plugin::UnityEngineObjectPropertySetName = *(void (**)(int32_t thisHandle, int32_t valueHandle))curMemory; + curMemory += sizeof(Plugin::UnityEngineObjectPropertySetName); + Plugin::UnityEngineComponentPropertyGetTransform = *(int32_t (**)(int32_t thisHandle))curMemory; + curMemory += sizeof(Plugin::UnityEngineComponentPropertyGetTransform); + Plugin::UnityEngineTransformPropertyGetPosition = *(UnityEngine::Vector3 (**)(int32_t thisHandle))curMemory; + curMemory += sizeof(Plugin::UnityEngineTransformPropertyGetPosition); + Plugin::UnityEngineTransformPropertySetPosition = *(void (**)(int32_t thisHandle, UnityEngine::Vector3& value))curMemory; + curMemory += sizeof(Plugin::UnityEngineTransformPropertySetPosition); + Plugin::SystemCollectionsIEnumeratorPropertyGetCurrent = *(int32_t (**)(int32_t thisHandle))curMemory; + curMemory += sizeof(Plugin::SystemCollectionsIEnumeratorPropertyGetCurrent); + Plugin::SystemCollectionsIEnumeratorMethodMoveNext = *(int32_t (**)(int32_t thisHandle))curMemory; + curMemory += sizeof(Plugin::SystemCollectionsIEnumeratorMethodMoveNext); + Plugin::UnityEngineGameObjectMethodAddComponentMyGameBaseBallScript = *(int32_t (**)(int32_t thisHandle))curMemory; + curMemory += sizeof(Plugin::UnityEngineGameObjectMethodAddComponentMyGameBaseBallScript); + Plugin::UnityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveType = *(int32_t (**)(UnityEngine::PrimitiveType type))curMemory; + curMemory += sizeof(Plugin::UnityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveType); + Plugin::UnityEngineDebugMethodLogSystemObject = *(void (**)(int32_t messageHandle))curMemory; + curMemory += sizeof(Plugin::UnityEngineDebugMethodLogSystemObject); + Plugin::UnityEngineMonoBehaviourPropertyGetTransform = *(int32_t (**)(int32_t thisHandle))curMemory; + curMemory += sizeof(Plugin::UnityEngineMonoBehaviourPropertyGetTransform); + Plugin::SystemExceptionConstructorSystemString = *(int32_t (**)(int32_t messageHandle))curMemory; + curMemory += sizeof(Plugin::SystemExceptionConstructorSystemString); + Plugin::BoxPrimitiveType = *(int32_t (**)(UnityEngine::PrimitiveType val))curMemory; + curMemory += sizeof(Plugin::BoxPrimitiveType); + Plugin::UnboxPrimitiveType = *(UnityEngine::PrimitiveType (**)(int32_t valHandle))curMemory; + curMemory += sizeof(Plugin::UnboxPrimitiveType); + Plugin::UnityEngineTimePropertyGetDeltaTime = *(System::Single (**)())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 = *(System::SByte (**)(int32_t valHandle))curMemory; + curMemory += sizeof(Plugin::UnboxSByte); + Plugin::BoxByte = *(int32_t (**)(uint8_t val))curMemory; + curMemory += sizeof(Plugin::BoxByte); + Plugin::UnboxByte = *(System::Byte (**)(int32_t valHandle))curMemory; + curMemory += sizeof(Plugin::UnboxByte); + Plugin::BoxInt16 = *(int32_t (**)(int16_t val))curMemory; + curMemory += sizeof(Plugin::BoxInt16); + Plugin::UnboxInt16 = *(System::Int16 (**)(int32_t valHandle))curMemory; + curMemory += sizeof(Plugin::UnboxInt16); + Plugin::BoxUInt16 = *(int32_t (**)(uint16_t val))curMemory; + curMemory += sizeof(Plugin::BoxUInt16); + Plugin::UnboxUInt16 = *(System::UInt16 (**)(int32_t valHandle))curMemory; + curMemory += sizeof(Plugin::UnboxUInt16); + Plugin::BoxInt32 = *(int32_t (**)(int32_t val))curMemory; + curMemory += sizeof(Plugin::BoxInt32); + Plugin::UnboxInt32 = *(System::Int32 (**)(int32_t valHandle))curMemory; + curMemory += sizeof(Plugin::UnboxInt32); + Plugin::BoxUInt32 = *(int32_t (**)(uint32_t val))curMemory; + curMemory += sizeof(Plugin::BoxUInt32); + Plugin::UnboxUInt32 = *(System::UInt32 (**)(int32_t valHandle))curMemory; + curMemory += sizeof(Plugin::UnboxUInt32); + Plugin::BoxInt64 = *(int32_t (**)(int64_t val))curMemory; + curMemory += sizeof(Plugin::BoxInt64); + Plugin::UnboxInt64 = *(System::Int64 (**)(int32_t valHandle))curMemory; + curMemory += sizeof(Plugin::UnboxInt64); + Plugin::BoxUInt64 = *(int32_t (**)(uint64_t val))curMemory; + curMemory += sizeof(Plugin::BoxUInt64); + Plugin::UnboxUInt64 = *(System::UInt64 (**)(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 = *(System::Single (**)(int32_t valHandle))curMemory; + curMemory += sizeof(Plugin::UnboxSingle); + Plugin::BoxDouble = *(int32_t (**)(double val))curMemory; + curMemory += sizeof(Plugin::BoxDouble); + Plugin::UnboxDouble = *(System::Double (**)(int32_t valHandle))curMemory; + curMemory += sizeof(Plugin::UnboxDouble); + /*END INIT BODY PARAMETER READS*/ + // Init managed object ref counting Plugin::RefCountsLenClass = maxManagedObjects; Plugin::RefCountsClass = (int32_t*)curMemory; curMemory += maxManagedObjects * sizeof(int32_t); - // Init pointers to C# functions - Plugin::StringNew = stringNew; - Plugin::ReleaseObject = releaseObject; - Plugin::SetException = setException; - Plugin::ArrayGetLength = arrayGetLength; - Plugin::EnumerableGetEnumerator = enumerableGetEnumerator; - /*BEGIN INIT BODY*/ - Plugin::ReleaseSystemDecimal = releaseSystemDecimal; + /*BEGIN INIT BODY ARRAYS*/ Plugin::RefCountsSystemDecimal = (int32_t*)curMemory; curMemory += 1000 * sizeof(int32_t); Plugin::RefCountsLenSystemDecimal = 1000; - Plugin::SystemDecimalConstructorSystemDouble = systemDecimalConstructorSystemDouble; - Plugin::SystemDecimalConstructorSystemUInt64 = systemDecimalConstructorSystemUInt64; - Plugin::BoxDecimal = boxDecimal; - Plugin::UnboxDecimal = unboxDecimal; - Plugin::UnityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingle = unityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingle; - Plugin::UnityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3 = unityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3; - Plugin::BoxVector3 = boxVector3; - Plugin::UnboxVector3 = unboxVector3; - Plugin::UnityEngineObjectPropertyGetName = unityEngineObjectPropertyGetName; - Plugin::UnityEngineObjectPropertySetName = unityEngineObjectPropertySetName; - Plugin::UnityEngineComponentPropertyGetTransform = unityEngineComponentPropertyGetTransform; - Plugin::UnityEngineTransformPropertyGetPosition = unityEngineTransformPropertyGetPosition; - Plugin::UnityEngineTransformPropertySetPosition = unityEngineTransformPropertySetPosition; - Plugin::SystemCollectionsIEnumeratorPropertyGetCurrent = systemCollectionsIEnumeratorPropertyGetCurrent; - Plugin::SystemCollectionsIEnumeratorMethodMoveNext = systemCollectionsIEnumeratorMethodMoveNext; - Plugin::UnityEngineGameObjectMethodAddComponentMyGameBaseBallScript = unityEngineGameObjectMethodAddComponentMyGameBaseBallScript; - Plugin::UnityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveType = unityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveType; - Plugin::UnityEngineDebugMethodLogSystemObject = unityEngineDebugMethodLogSystemObject; - Plugin::UnityEngineMonoBehaviourPropertyGetTransform = unityEngineMonoBehaviourPropertyGetTransform; - Plugin::SystemExceptionConstructorSystemString = systemExceptionConstructorSystemString; - Plugin::BoxPrimitiveType = boxPrimitiveType; - Plugin::UnboxPrimitiveType = unboxPrimitiveType; - Plugin::UnityEngineTimePropertyGetDeltaTime = unityEngineTimePropertyGetDeltaTime; + Plugin::BaseBallScriptFreeListSize = 1000; Plugin::BaseBallScriptFreeList = (MyGame::BaseBallScript**)curMemory; curMemory += 1000 * sizeof(MyGame::BaseBallScript*); - Plugin::ReleaseBaseBallScript = releaseBaseBallScript; - Plugin::BaseBallScriptConstructor = baseBallScriptConstructor; Plugin::BaseBallScriptFreeWholeListSize = 1000; Plugin::BaseBallScriptFreeWholeList = (Plugin::BaseBallScriptFreeWholeListEntry*)curMemory; curMemory += 1000 * sizeof(Plugin::BaseBallScriptFreeWholeListEntry); - - Plugin::BoxBoolean = boxBoolean; - Plugin::UnboxBoolean = unboxBoolean; - Plugin::BoxSByte = boxSByte; - Plugin::UnboxSByte = unboxSByte; - Plugin::BoxByte = boxByte; - Plugin::UnboxByte = unboxByte; - Plugin::BoxInt16 = boxInt16; - Plugin::UnboxInt16 = unboxInt16; - Plugin::BoxUInt16 = boxUInt16; - Plugin::UnboxUInt16 = unboxUInt16; - Plugin::BoxInt32 = boxInt32; - Plugin::UnboxInt32 = unboxInt32; - Plugin::BoxUInt32 = boxUInt32; - Plugin::UnboxUInt32 = unboxUInt32; - Plugin::BoxInt64 = boxInt64; - Plugin::UnboxInt64 = unboxInt64; - Plugin::BoxUInt64 = boxUInt64; - Plugin::UnboxUInt64 = unboxUInt64; - Plugin::BoxChar = boxChar; - Plugin::UnboxChar = unboxChar; - Plugin::BoxSingle = boxSingle; - Plugin::UnboxSingle = unboxSingle; - Plugin::BoxDouble = boxDouble; - Plugin::UnboxDouble = unboxDouble; - /*END INIT BODY*/ + /*END INIT BODY ARRAYS*/ // Make sure there was enough memory int32_t usedMemory = (int32_t)(curMemory - (uint8_t*)memory); @@ -6100,6 +6104,7 @@ DLLEXPORT void Init( if (initMode == InitMode::FirstBoot) { + // Clear memory memset(memory, 0, memorySize); /*BEGIN INIT BODY FIRST BOOT*/ diff --git a/Unity/Assets/NativeScript/Bindings.cs b/Unity/Assets/NativeScript/Bindings.cs index 248ee00..c2a00a6 100644 --- a/Unity/Assets/NativeScript/Bindings.cs +++ b/Unity/Assets/NativeScript/Bindings.cs @@ -330,81 +330,23 @@ enum InitMode : byte delegate void InitDelegate( IntPtr memory, int memorySize, - InitMode initMode, - IntPtr releaseObject, - IntPtr stringNew, - IntPtr setException, - IntPtr arrayGetLength, - IntPtr enumerableGetEnumerator, - /*BEGIN INIT PARAMS*/ - int maxManagedObjects, - IntPtr releaseSystemDecimal, - IntPtr systemDecimalConstructorSystemDouble, - IntPtr systemDecimalConstructorSystemUInt64, - IntPtr boxDecimal, - IntPtr unboxDecimal, - IntPtr unityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingle, - IntPtr unityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3, - IntPtr boxVector3, - IntPtr unboxVector3, - IntPtr unityEngineObjectPropertyGetName, - IntPtr unityEngineObjectPropertySetName, - IntPtr unityEngineComponentPropertyGetTransform, - IntPtr unityEngineTransformPropertyGetPosition, - IntPtr unityEngineTransformPropertySetPosition, - IntPtr systemCollectionsIEnumeratorPropertyGetCurrent, - IntPtr systemCollectionsIEnumeratorMethodMoveNext, - IntPtr unityEngineGameObjectMethodAddComponentMyGameBaseBallScript, - IntPtr unityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveType, - IntPtr unityEngineDebugMethodLogSystemObject, - IntPtr unityEngineMonoBehaviourPropertyGetTransform, - IntPtr systemExceptionConstructorSystemString, - IntPtr boxPrimitiveType, - IntPtr unboxPrimitiveType, - IntPtr unityEngineTimePropertyGetDeltaTime, - IntPtr releaseBaseBallScript, - IntPtr baseBallScriptConstructor, - IntPtr boxBoolean, - IntPtr unboxBoolean, - IntPtr boxSByte, - IntPtr unboxSByte, - IntPtr boxByte, - IntPtr unboxByte, - IntPtr boxInt16, - IntPtr unboxInt16, - IntPtr boxUInt16, - IntPtr unboxUInt16, - IntPtr boxInt32, - IntPtr unboxInt32, - IntPtr boxUInt32, - IntPtr unboxUInt32, - IntPtr boxInt64, - IntPtr unboxInt64, - IntPtr boxUInt64, - IntPtr unboxUInt64, - IntPtr boxChar, - IntPtr unboxChar, - IntPtr boxSingle, - IntPtr unboxSingle, - IntPtr boxDouble, - IntPtr unboxDouble - /*END INIT PARAMS*/); + InitMode initMode); public delegate void SetCsharpExceptionDelegate(int handle); - /*BEGIN DELEGATES*/ - public delegate int NewBaseBallScriptDelegate(int param0); - public static NewBaseBallScriptDelegate NewBaseBallScript; + /*BEGIN CPP DELEGATES*/ + public delegate int NewBaseBallScriptDelegateType(int param0); + public static NewBaseBallScriptDelegateType NewBaseBallScript; - public delegate void DestroyBaseBallScriptDelegate(int param0); - public static DestroyBaseBallScriptDelegate DestroyBaseBallScript; + public delegate void DestroyBaseBallScriptDelegateType(int param0); + public static DestroyBaseBallScriptDelegateType DestroyBaseBallScript; - public delegate void MyGameAbstractBaseBallScriptUpdateDelegate(int thisHandle); - public static MyGameAbstractBaseBallScriptUpdateDelegate MyGameAbstractBaseBallScriptUpdate; + public delegate void MyGameAbstractBaseBallScriptUpdateDelegateType(int thisHandle); + public static MyGameAbstractBaseBallScriptUpdateDelegateType MyGameAbstractBaseBallScriptUpdate; - public delegate void SetCsharpExceptionSystemNullReferenceExceptionDelegate(int param0); - public static SetCsharpExceptionSystemNullReferenceExceptionDelegate SetCsharpExceptionSystemNullReferenceException; - /*END DELEGATES*/ + public delegate void SetCsharpExceptionSystemNullReferenceExceptionDelegateType(int param0); + public static SetCsharpExceptionSystemNullReferenceExceptionDelegateType SetCsharpExceptionSystemNullReferenceException; + /*END CPP DELEGATES*/ #endif #if UNITY_EDITOR_OSX || UNITY_EDITOR_LINUX @@ -499,65 +441,7 @@ static T GetDelegate( static extern void Init( IntPtr memory, int memorySize, - InitMode initMode, - IntPtr releaseObject, - IntPtr stringNew, - IntPtr setException, - IntPtr arrayGetLength, - IntPtr enumerableGetEnumerator, - /*BEGIN INIT PARAMS*/ - int maxManagedObjects, - IntPtr releaseSystemDecimal, - IntPtr systemDecimalConstructorSystemDouble, - IntPtr systemDecimalConstructorSystemUInt64, - IntPtr boxDecimal, - IntPtr unboxDecimal, - IntPtr unityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingle, - IntPtr unityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3, - IntPtr boxVector3, - IntPtr unboxVector3, - IntPtr unityEngineObjectPropertyGetName, - IntPtr unityEngineObjectPropertySetName, - IntPtr unityEngineComponentPropertyGetTransform, - IntPtr unityEngineTransformPropertyGetPosition, - IntPtr unityEngineTransformPropertySetPosition, - IntPtr systemCollectionsIEnumeratorPropertyGetCurrent, - IntPtr systemCollectionsIEnumeratorMethodMoveNext, - IntPtr unityEngineGameObjectMethodAddComponentMyGameBaseBallScript, - IntPtr unityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveType, - IntPtr unityEngineDebugMethodLogSystemObject, - IntPtr unityEngineMonoBehaviourPropertyGetTransform, - IntPtr systemExceptionConstructorSystemString, - IntPtr boxPrimitiveType, - IntPtr unboxPrimitiveType, - IntPtr unityEngineTimePropertyGetDeltaTime, - IntPtr releaseBaseBallScript, - IntPtr baseBallScriptConstructor, - IntPtr boxBoolean, - IntPtr unboxBoolean, - IntPtr boxSByte, - IntPtr unboxSByte, - IntPtr boxByte, - IntPtr unboxByte, - IntPtr boxInt16, - IntPtr unboxInt16, - IntPtr boxUInt16, - IntPtr unboxUInt16, - IntPtr boxInt32, - IntPtr unboxInt32, - IntPtr boxUInt32, - IntPtr unboxUInt32, - IntPtr boxInt64, - IntPtr unboxInt64, - IntPtr boxUInt64, - IntPtr unboxUInt64, - IntPtr boxChar, - IntPtr unboxChar, - IntPtr boxSingle, - IntPtr unboxSingle, - IntPtr boxDouble, - IntPtr unboxDouble - /*END INIT PARAMS*/); + InitMode initMode); [DllImport(PLUGIN_NAME)] static extern void SetCsharpException(int handle); @@ -577,63 +461,63 @@ IntPtr unboxDouble /*END IMPORTS*/ #endif - delegate void ReleaseObjectDelegate(int handle); - delegate int StringNewDelegate(string chars); - delegate void SetExceptionDelegate(int handle); - delegate int ArrayGetLengthDelegate(int handle); - delegate int EnumerableGetEnumeratorDelegate(int handle); + delegate void ReleaseObjectDelegateType(int handle); + delegate int StringNewDelegateType(string chars); + delegate void SetExceptionDelegateType(int handle); + delegate int ArrayGetLengthDelegateType(int handle); + delegate int EnumerableGetEnumeratorDelegateType(int handle); /*BEGIN DELEGATE TYPES*/ - delegate void ReleaseSystemDecimalDelegate(int handle); - delegate int SystemDecimalConstructorSystemDoubleDelegate(double value); - delegate int SystemDecimalConstructorSystemUInt64Delegate(ulong value); - delegate int BoxDecimalDelegate(int valHandle); - delegate int UnboxDecimalDelegate(int valHandle); - delegate UnityEngine.Vector3 UnityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingleDelegate(float x, float y, float z); - delegate UnityEngine.Vector3 UnityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3Delegate(ref UnityEngine.Vector3 a, ref UnityEngine.Vector3 b); - delegate int BoxVector3Delegate(ref UnityEngine.Vector3 val); - delegate UnityEngine.Vector3 UnboxVector3Delegate(int valHandle); - delegate int UnityEngineObjectPropertyGetNameDelegate(int thisHandle); - delegate void UnityEngineObjectPropertySetNameDelegate(int thisHandle, int valueHandle); - delegate int UnityEngineComponentPropertyGetTransformDelegate(int thisHandle); - delegate UnityEngine.Vector3 UnityEngineTransformPropertyGetPositionDelegate(int thisHandle); - delegate void UnityEngineTransformPropertySetPositionDelegate(int thisHandle, ref UnityEngine.Vector3 value); - delegate int SystemCollectionsIEnumeratorPropertyGetCurrentDelegate(int thisHandle); - delegate bool SystemCollectionsIEnumeratorMethodMoveNextDelegate(int thisHandle); - delegate int UnityEngineGameObjectMethodAddComponentMyGameBaseBallScriptDelegate(int thisHandle); - delegate int UnityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveTypeDelegate(UnityEngine.PrimitiveType type); - delegate void UnityEngineDebugMethodLogSystemObjectDelegate(int messageHandle); - delegate int UnityEngineMonoBehaviourPropertyGetTransformDelegate(int thisHandle); - delegate int SystemExceptionConstructorSystemStringDelegate(int messageHandle); - delegate int BoxPrimitiveTypeDelegate(UnityEngine.PrimitiveType val); - delegate UnityEngine.PrimitiveType UnboxPrimitiveTypeDelegate(int valHandle); - delegate float UnityEngineTimePropertyGetDeltaTimeDelegate(); - delegate void BaseBallScriptConstructorDelegate(int cppHandle, ref int handle); - delegate void ReleaseBaseBallScriptDelegate(int handle); - delegate int BoxBooleanDelegate(bool val); - delegate bool UnboxBooleanDelegate(int valHandle); - delegate int BoxSByteDelegate(sbyte val); - delegate sbyte UnboxSByteDelegate(int valHandle); - delegate int BoxByteDelegate(byte val); - delegate byte UnboxByteDelegate(int valHandle); - delegate int BoxInt16Delegate(short val); - delegate short UnboxInt16Delegate(int valHandle); - delegate int BoxUInt16Delegate(ushort val); - delegate ushort UnboxUInt16Delegate(int valHandle); - delegate int BoxInt32Delegate(int val); - delegate int UnboxInt32Delegate(int valHandle); - delegate int BoxUInt32Delegate(uint val); - delegate uint UnboxUInt32Delegate(int valHandle); - delegate int BoxInt64Delegate(long val); - delegate long UnboxInt64Delegate(int valHandle); - delegate int BoxUInt64Delegate(ulong val); - delegate ulong UnboxUInt64Delegate(int valHandle); - delegate int BoxCharDelegate(char val); - delegate char UnboxCharDelegate(int valHandle); - delegate int BoxSingleDelegate(float val); - delegate float UnboxSingleDelegate(int valHandle); - delegate int BoxDoubleDelegate(double val); - delegate double UnboxDoubleDelegate(int valHandle); + delegate void ReleaseSystemDecimalDelegateType(int handle); + delegate int SystemDecimalConstructorSystemDoubleDelegateType(double value); + delegate int SystemDecimalConstructorSystemUInt64DelegateType(ulong value); + delegate int BoxDecimalDelegateType(int valHandle); + delegate int UnboxDecimalDelegateType(int valHandle); + delegate UnityEngine.Vector3 UnityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingleDelegateType(float x, float y, float z); + delegate UnityEngine.Vector3 UnityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3DelegateType(ref UnityEngine.Vector3 a, ref UnityEngine.Vector3 b); + delegate int BoxVector3DelegateType(ref UnityEngine.Vector3 val); + delegate UnityEngine.Vector3 UnboxVector3DelegateType(int valHandle); + delegate int UnityEngineObjectPropertyGetNameDelegateType(int thisHandle); + delegate void UnityEngineObjectPropertySetNameDelegateType(int thisHandle, int valueHandle); + delegate int UnityEngineComponentPropertyGetTransformDelegateType(int thisHandle); + delegate UnityEngine.Vector3 UnityEngineTransformPropertyGetPositionDelegateType(int thisHandle); + delegate void UnityEngineTransformPropertySetPositionDelegateType(int thisHandle, ref UnityEngine.Vector3 value); + delegate int SystemCollectionsIEnumeratorPropertyGetCurrentDelegateType(int thisHandle); + delegate bool SystemCollectionsIEnumeratorMethodMoveNextDelegateType(int thisHandle); + delegate int UnityEngineGameObjectMethodAddComponentMyGameBaseBallScriptDelegateType(int thisHandle); + delegate int UnityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveTypeDelegateType(UnityEngine.PrimitiveType type); + delegate void UnityEngineDebugMethodLogSystemObjectDelegateType(int messageHandle); + delegate int UnityEngineMonoBehaviourPropertyGetTransformDelegateType(int thisHandle); + delegate int SystemExceptionConstructorSystemStringDelegateType(int messageHandle); + delegate int BoxPrimitiveTypeDelegateType(UnityEngine.PrimitiveType val); + delegate UnityEngine.PrimitiveType UnboxPrimitiveTypeDelegateType(int valHandle); + delegate float UnityEngineTimePropertyGetDeltaTimeDelegateType(); + delegate void BaseBallScriptConstructorDelegateType(int cppHandle, ref int handle); + delegate void ReleaseBaseBallScriptDelegateType(int handle); + delegate int BoxBooleanDelegateType(bool val); + delegate bool UnboxBooleanDelegateType(int valHandle); + delegate int BoxSByteDelegateType(sbyte val); + delegate sbyte UnboxSByteDelegateType(int valHandle); + delegate int BoxByteDelegateType(byte val); + delegate byte UnboxByteDelegateType(int valHandle); + delegate int BoxInt16DelegateType(short val); + delegate short UnboxInt16DelegateType(int valHandle); + delegate int BoxUInt16DelegateType(ushort val); + delegate ushort UnboxUInt16DelegateType(int valHandle); + delegate int BoxInt32DelegateType(int val); + delegate int UnboxInt32DelegateType(int valHandle); + delegate int BoxUInt32DelegateType(uint val); + delegate uint UnboxUInt32DelegateType(int valHandle); + delegate int BoxInt64DelegateType(long val); + delegate long UnboxInt64DelegateType(int valHandle); + delegate int BoxUInt64DelegateType(ulong val); + delegate ulong UnboxUInt64DelegateType(int valHandle); + delegate int BoxCharDelegateType(char val); + delegate char UnboxCharDelegateType(int valHandle); + delegate int BoxSingleDelegateType(float val); + delegate float UnboxSingleDelegateType(int valHandle); + delegate int BoxDoubleDelegateType(double val); + delegate double UnboxDoubleDelegateType(int valHandle); /*END DELEGATE TYPES*/ #if UNITY_EDITOR_WIN @@ -651,6 +535,67 @@ IntPtr unboxDouble static int destroyQueueCapacity; static object destroyQueueLockObj; + // Fixed delegates + static readonly ReleaseObjectDelegateType ReleaseObjectDelegate = new ReleaseObjectDelegateType(ReleaseObject); + static readonly StringNewDelegateType StringNewDelegate = new StringNewDelegateType(StringNew); + static readonly SetExceptionDelegateType SetExceptionDelegate = new SetExceptionDelegateType(SetException); + static readonly ArrayGetLengthDelegateType ArrayGetLengthDelegate = new ArrayGetLengthDelegateType(ArrayGetLength); + static readonly EnumerableGetEnumeratorDelegateType EnumerableGetEnumeratorDelegate = new EnumerableGetEnumeratorDelegateType(EnumerableGetEnumerator); + + // Generated delegates + /*BEGIN CSHARP DELEGATES*/ + static readonly ReleaseSystemDecimalDelegateType ReleaseSystemDecimalDelegate = new ReleaseSystemDecimalDelegateType(ReleaseSystemDecimal); + static readonly SystemDecimalConstructorSystemDoubleDelegateType SystemDecimalConstructorSystemDoubleDelegate = new SystemDecimalConstructorSystemDoubleDelegateType(SystemDecimalConstructorSystemDouble); + static readonly SystemDecimalConstructorSystemUInt64DelegateType SystemDecimalConstructorSystemUInt64Delegate = new SystemDecimalConstructorSystemUInt64DelegateType(SystemDecimalConstructorSystemUInt64); + static readonly BoxDecimalDelegateType BoxDecimalDelegate = new BoxDecimalDelegateType(BoxDecimal); + static readonly UnboxDecimalDelegateType UnboxDecimalDelegate = new UnboxDecimalDelegateType(UnboxDecimal); + static readonly UnityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingleDelegateType UnityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingleDelegate = new UnityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingleDelegateType(UnityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingle); + static readonly UnityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3DelegateType UnityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3Delegate = new UnityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3DelegateType(UnityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3); + static readonly BoxVector3DelegateType BoxVector3Delegate = new BoxVector3DelegateType(BoxVector3); + static readonly UnboxVector3DelegateType UnboxVector3Delegate = new UnboxVector3DelegateType(UnboxVector3); + static readonly UnityEngineObjectPropertyGetNameDelegateType UnityEngineObjectPropertyGetNameDelegate = new UnityEngineObjectPropertyGetNameDelegateType(UnityEngineObjectPropertyGetName); + static readonly UnityEngineObjectPropertySetNameDelegateType UnityEngineObjectPropertySetNameDelegate = new UnityEngineObjectPropertySetNameDelegateType(UnityEngineObjectPropertySetName); + static readonly UnityEngineComponentPropertyGetTransformDelegateType UnityEngineComponentPropertyGetTransformDelegate = new UnityEngineComponentPropertyGetTransformDelegateType(UnityEngineComponentPropertyGetTransform); + static readonly UnityEngineTransformPropertyGetPositionDelegateType UnityEngineTransformPropertyGetPositionDelegate = new UnityEngineTransformPropertyGetPositionDelegateType(UnityEngineTransformPropertyGetPosition); + static readonly UnityEngineTransformPropertySetPositionDelegateType UnityEngineTransformPropertySetPositionDelegate = new UnityEngineTransformPropertySetPositionDelegateType(UnityEngineTransformPropertySetPosition); + static readonly SystemCollectionsIEnumeratorPropertyGetCurrentDelegateType SystemCollectionsIEnumeratorPropertyGetCurrentDelegate = new SystemCollectionsIEnumeratorPropertyGetCurrentDelegateType(SystemCollectionsIEnumeratorPropertyGetCurrent); + static readonly SystemCollectionsIEnumeratorMethodMoveNextDelegateType SystemCollectionsIEnumeratorMethodMoveNextDelegate = new SystemCollectionsIEnumeratorMethodMoveNextDelegateType(SystemCollectionsIEnumeratorMethodMoveNext); + static readonly UnityEngineGameObjectMethodAddComponentMyGameBaseBallScriptDelegateType UnityEngineGameObjectMethodAddComponentMyGameBaseBallScriptDelegate = new UnityEngineGameObjectMethodAddComponentMyGameBaseBallScriptDelegateType(UnityEngineGameObjectMethodAddComponentMyGameBaseBallScript); + static readonly UnityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveTypeDelegateType UnityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveTypeDelegate = new UnityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveTypeDelegateType(UnityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveType); + static readonly UnityEngineDebugMethodLogSystemObjectDelegateType UnityEngineDebugMethodLogSystemObjectDelegate = new UnityEngineDebugMethodLogSystemObjectDelegateType(UnityEngineDebugMethodLogSystemObject); + static readonly UnityEngineMonoBehaviourPropertyGetTransformDelegateType UnityEngineMonoBehaviourPropertyGetTransformDelegate = new UnityEngineMonoBehaviourPropertyGetTransformDelegateType(UnityEngineMonoBehaviourPropertyGetTransform); + static readonly SystemExceptionConstructorSystemStringDelegateType SystemExceptionConstructorSystemStringDelegate = new SystemExceptionConstructorSystemStringDelegateType(SystemExceptionConstructorSystemString); + static readonly BoxPrimitiveTypeDelegateType BoxPrimitiveTypeDelegate = new BoxPrimitiveTypeDelegateType(BoxPrimitiveType); + static readonly UnboxPrimitiveTypeDelegateType UnboxPrimitiveTypeDelegate = new UnboxPrimitiveTypeDelegateType(UnboxPrimitiveType); + static readonly UnityEngineTimePropertyGetDeltaTimeDelegateType UnityEngineTimePropertyGetDeltaTimeDelegate = new UnityEngineTimePropertyGetDeltaTimeDelegateType(UnityEngineTimePropertyGetDeltaTime); + static readonly ReleaseBaseBallScriptDelegateType ReleaseBaseBallScriptDelegate = new ReleaseBaseBallScriptDelegateType(ReleaseBaseBallScript); + static readonly BaseBallScriptConstructorDelegateType BaseBallScriptConstructorDelegate = new BaseBallScriptConstructorDelegateType(BaseBallScriptConstructor); + static readonly BoxBooleanDelegateType BoxBooleanDelegate = new BoxBooleanDelegateType(BoxBoolean); + static readonly UnboxBooleanDelegateType UnboxBooleanDelegate = new UnboxBooleanDelegateType(UnboxBoolean); + static readonly BoxSByteDelegateType BoxSByteDelegate = new BoxSByteDelegateType(BoxSByte); + static readonly UnboxSByteDelegateType UnboxSByteDelegate = new UnboxSByteDelegateType(UnboxSByte); + static readonly BoxByteDelegateType BoxByteDelegate = new BoxByteDelegateType(BoxByte); + static readonly UnboxByteDelegateType UnboxByteDelegate = new UnboxByteDelegateType(UnboxByte); + static readonly BoxInt16DelegateType BoxInt16Delegate = new BoxInt16DelegateType(BoxInt16); + static readonly UnboxInt16DelegateType UnboxInt16Delegate = new UnboxInt16DelegateType(UnboxInt16); + static readonly BoxUInt16DelegateType BoxUInt16Delegate = new BoxUInt16DelegateType(BoxUInt16); + static readonly UnboxUInt16DelegateType UnboxUInt16Delegate = new UnboxUInt16DelegateType(UnboxUInt16); + static readonly BoxInt32DelegateType BoxInt32Delegate = new BoxInt32DelegateType(BoxInt32); + static readonly UnboxInt32DelegateType UnboxInt32Delegate = new UnboxInt32DelegateType(UnboxInt32); + static readonly BoxUInt32DelegateType BoxUInt32Delegate = new BoxUInt32DelegateType(BoxUInt32); + static readonly UnboxUInt32DelegateType UnboxUInt32Delegate = new UnboxUInt32DelegateType(UnboxUInt32); + static readonly BoxInt64DelegateType BoxInt64Delegate = new BoxInt64DelegateType(BoxInt64); + static readonly UnboxInt64DelegateType UnboxInt64Delegate = new UnboxInt64DelegateType(UnboxInt64); + static readonly BoxUInt64DelegateType BoxUInt64Delegate = new BoxUInt64DelegateType(BoxUInt64); + static readonly UnboxUInt64DelegateType UnboxUInt64Delegate = new UnboxUInt64DelegateType(UnboxUInt64); + static readonly BoxCharDelegateType BoxCharDelegate = new BoxCharDelegateType(BoxChar); + static readonly UnboxCharDelegateType UnboxCharDelegate = new UnboxCharDelegateType(UnboxChar); + static readonly BoxSingleDelegateType BoxSingleDelegate = new BoxSingleDelegateType(BoxSingle); + static readonly UnboxSingleDelegateType UnboxSingleDelegate = new UnboxSingleDelegateType(UnboxSingle); + static readonly BoxDoubleDelegateType BoxDoubleDelegate = new BoxDoubleDelegateType(BoxDouble); + static readonly UnboxDoubleDelegateType UnboxDoubleDelegate = new UnboxDoubleDelegateType(UnboxDouble); + /*END CSHARP DELEGATES*/ + /// /// Open the C++ plugin and call its PluginMain() /// @@ -748,76 +693,147 @@ private static void OpenPlugin(InitMode initMode) libraryHandle, "SetCsharpException"); /*BEGIN GETDELEGATE CALLS*/ - NewBaseBallScript = GetDelegate(libraryHandle, "NewBaseBallScript"); - DestroyBaseBallScript = GetDelegate(libraryHandle, "DestroyBaseBallScript"); - MyGameAbstractBaseBallScriptUpdate = GetDelegate(libraryHandle, "MyGameAbstractBaseBallScriptUpdate"); - SetCsharpExceptionSystemNullReferenceException = GetDelegate(libraryHandle, "SetCsharpExceptionSystemNullReferenceException"); + NewBaseBallScript = GetDelegate(libraryHandle, "NewBaseBallScript"); + DestroyBaseBallScript = GetDelegate(libraryHandle, "DestroyBaseBallScript"); + MyGameAbstractBaseBallScriptUpdate = GetDelegate(libraryHandle, "MyGameAbstractBaseBallScriptUpdate"); + SetCsharpExceptionSystemNullReferenceException = GetDelegate(libraryHandle, "SetCsharpExceptionSystemNullReferenceException"); /*END GETDELEGATE CALLS*/ #endif - // Init C++ library - Init( + // Pass parameters through 'memory' + int curMemory = 0; + Marshal.WriteIntPtr( + memory, + curMemory, + Marshal.GetFunctionPointerForDelegate(ReleaseObjectDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr( + memory, + curMemory, + Marshal.GetFunctionPointerForDelegate(StringNewDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr( + memory, + curMemory, + Marshal.GetFunctionPointerForDelegate(SetExceptionDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr( memory, - memorySize, - initMode, - Marshal.GetFunctionPointerForDelegate(new ReleaseObjectDelegate(ReleaseObject)), - Marshal.GetFunctionPointerForDelegate(new StringNewDelegate(StringNew)), - Marshal.GetFunctionPointerForDelegate(new SetExceptionDelegate(SetException)), - Marshal.GetFunctionPointerForDelegate(new ArrayGetLengthDelegate(ArrayGetLength)), - Marshal.GetFunctionPointerForDelegate(new EnumerableGetEnumeratorDelegate(EnumerableGetEnumerator)), - /*BEGIN INIT CALL*/ - 1000, - Marshal.GetFunctionPointerForDelegate(new ReleaseSystemDecimalDelegate(ReleaseSystemDecimal)), - Marshal.GetFunctionPointerForDelegate(new SystemDecimalConstructorSystemDoubleDelegate(SystemDecimalConstructorSystemDouble)), - Marshal.GetFunctionPointerForDelegate(new SystemDecimalConstructorSystemUInt64Delegate(SystemDecimalConstructorSystemUInt64)), - Marshal.GetFunctionPointerForDelegate(new BoxDecimalDelegate(BoxDecimal)), - Marshal.GetFunctionPointerForDelegate(new UnboxDecimalDelegate(UnboxDecimal)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingleDelegate(UnityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingle)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3Delegate(UnityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3)), - Marshal.GetFunctionPointerForDelegate(new BoxVector3Delegate(BoxVector3)), - Marshal.GetFunctionPointerForDelegate(new UnboxVector3Delegate(UnboxVector3)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineObjectPropertyGetNameDelegate(UnityEngineObjectPropertyGetName)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineObjectPropertySetNameDelegate(UnityEngineObjectPropertySetName)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineComponentPropertyGetTransformDelegate(UnityEngineComponentPropertyGetTransform)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineTransformPropertyGetPositionDelegate(UnityEngineTransformPropertyGetPosition)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineTransformPropertySetPositionDelegate(UnityEngineTransformPropertySetPosition)), - Marshal.GetFunctionPointerForDelegate(new SystemCollectionsIEnumeratorPropertyGetCurrentDelegate(SystemCollectionsIEnumeratorPropertyGetCurrent)), - Marshal.GetFunctionPointerForDelegate(new SystemCollectionsIEnumeratorMethodMoveNextDelegate(SystemCollectionsIEnumeratorMethodMoveNext)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineGameObjectMethodAddComponentMyGameBaseBallScriptDelegate(UnityEngineGameObjectMethodAddComponentMyGameBaseBallScript)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveTypeDelegate(UnityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveType)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineDebugMethodLogSystemObjectDelegate(UnityEngineDebugMethodLogSystemObject)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineMonoBehaviourPropertyGetTransformDelegate(UnityEngineMonoBehaviourPropertyGetTransform)), - Marshal.GetFunctionPointerForDelegate(new SystemExceptionConstructorSystemStringDelegate(SystemExceptionConstructorSystemString)), - Marshal.GetFunctionPointerForDelegate(new BoxPrimitiveTypeDelegate(BoxPrimitiveType)), - Marshal.GetFunctionPointerForDelegate(new UnboxPrimitiveTypeDelegate(UnboxPrimitiveType)), - Marshal.GetFunctionPointerForDelegate(new UnityEngineTimePropertyGetDeltaTimeDelegate(UnityEngineTimePropertyGetDeltaTime)), - Marshal.GetFunctionPointerForDelegate(new ReleaseBaseBallScriptDelegate(ReleaseBaseBallScript)), - Marshal.GetFunctionPointerForDelegate(new BaseBallScriptConstructorDelegate(BaseBallScriptConstructor)), - Marshal.GetFunctionPointerForDelegate(new BoxBooleanDelegate(BoxBoolean)), - Marshal.GetFunctionPointerForDelegate(new UnboxBooleanDelegate(UnboxBoolean)), - Marshal.GetFunctionPointerForDelegate(new BoxSByteDelegate(BoxSByte)), - Marshal.GetFunctionPointerForDelegate(new UnboxSByteDelegate(UnboxSByte)), - Marshal.GetFunctionPointerForDelegate(new BoxByteDelegate(BoxByte)), - Marshal.GetFunctionPointerForDelegate(new UnboxByteDelegate(UnboxByte)), - Marshal.GetFunctionPointerForDelegate(new BoxInt16Delegate(BoxInt16)), - Marshal.GetFunctionPointerForDelegate(new UnboxInt16Delegate(UnboxInt16)), - Marshal.GetFunctionPointerForDelegate(new BoxUInt16Delegate(BoxUInt16)), - Marshal.GetFunctionPointerForDelegate(new UnboxUInt16Delegate(UnboxUInt16)), - Marshal.GetFunctionPointerForDelegate(new BoxInt32Delegate(BoxInt32)), - Marshal.GetFunctionPointerForDelegate(new UnboxInt32Delegate(UnboxInt32)), - Marshal.GetFunctionPointerForDelegate(new BoxUInt32Delegate(BoxUInt32)), - Marshal.GetFunctionPointerForDelegate(new UnboxUInt32Delegate(UnboxUInt32)), - Marshal.GetFunctionPointerForDelegate(new BoxInt64Delegate(BoxInt64)), - Marshal.GetFunctionPointerForDelegate(new UnboxInt64Delegate(UnboxInt64)), - Marshal.GetFunctionPointerForDelegate(new BoxUInt64Delegate(BoxUInt64)), - Marshal.GetFunctionPointerForDelegate(new UnboxUInt64Delegate(UnboxUInt64)), - Marshal.GetFunctionPointerForDelegate(new BoxCharDelegate(BoxChar)), - Marshal.GetFunctionPointerForDelegate(new UnboxCharDelegate(UnboxChar)), - Marshal.GetFunctionPointerForDelegate(new BoxSingleDelegate(BoxSingle)), - Marshal.GetFunctionPointerForDelegate(new UnboxSingleDelegate(UnboxSingle)), - Marshal.GetFunctionPointerForDelegate(new BoxDoubleDelegate(BoxDouble)), - Marshal.GetFunctionPointerForDelegate(new UnboxDoubleDelegate(UnboxDouble)) - /*END INIT CALL*/ - ); + curMemory, + Marshal.GetFunctionPointerForDelegate(ArrayGetLengthDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr( + memory, + curMemory, + Marshal.GetFunctionPointerForDelegate(EnumerableGetEnumeratorDelegate)); + curMemory += IntPtr.Size; + + /*BEGIN INIT CALL*/ + Marshal.WriteInt32(memory, curMemory, 1000); // max managed objects + curMemory += sizeof(int); + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(ReleaseSystemDecimalDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(SystemDecimalConstructorSystemDoubleDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(SystemDecimalConstructorSystemUInt64Delegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(BoxDecimalDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnboxDecimalDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingleDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3Delegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(BoxVector3Delegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnboxVector3Delegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnityEngineObjectPropertyGetNameDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnityEngineObjectPropertySetNameDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnityEngineComponentPropertyGetTransformDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnityEngineTransformPropertyGetPositionDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnityEngineTransformPropertySetPositionDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(SystemCollectionsIEnumeratorPropertyGetCurrentDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(SystemCollectionsIEnumeratorMethodMoveNextDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnityEngineGameObjectMethodAddComponentMyGameBaseBallScriptDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveTypeDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnityEngineDebugMethodLogSystemObjectDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnityEngineMonoBehaviourPropertyGetTransformDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(SystemExceptionConstructorSystemStringDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(BoxPrimitiveTypeDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnboxPrimitiveTypeDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnityEngineTimePropertyGetDeltaTimeDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(ReleaseBaseBallScriptDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(BaseBallScriptConstructorDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(BoxBooleanDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnboxBooleanDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(BoxSByteDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnboxSByteDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(BoxByteDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnboxByteDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(BoxInt16Delegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnboxInt16Delegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(BoxUInt16Delegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnboxUInt16Delegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(BoxInt32Delegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnboxInt32Delegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(BoxUInt32Delegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnboxUInt32Delegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(BoxInt64Delegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnboxInt64Delegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(BoxUInt64Delegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnboxUInt64Delegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(BoxCharDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnboxCharDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(BoxSingleDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnboxSingleDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(BoxDoubleDelegate)); + curMemory += IntPtr.Size; + Marshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate(UnboxDoubleDelegate)); + curMemory += IntPtr.Size; + /*END INIT CALL*/ + + // Init C++ library + Init(memory, memorySize, initMode); if (UnhandledCppException != null) { Exception ex = UnhandledCppException; @@ -908,7 +924,7 @@ static void DestroyAll() // C# functions for C++ to call //////////////////////////////////////////////////////////////// - [MonoPInvokeCallback(typeof(ReleaseObjectDelegate))] + [MonoPInvokeCallback(typeof(ReleaseObjectDelegateType))] static void ReleaseObject( int handle) { @@ -918,7 +934,7 @@ static void ReleaseObject( } } - [MonoPInvokeCallback(typeof(StringNewDelegate))] + [MonoPInvokeCallback(typeof(StringNewDelegateType))] static int StringNew( string chars) { @@ -926,26 +942,26 @@ static int StringNew( return handle; } - [MonoPInvokeCallback(typeof(SetExceptionDelegate))] + [MonoPInvokeCallback(typeof(SetExceptionDelegateType))] static void SetException(int handle) { UnhandledCppException = ObjectStore.Get(handle) as Exception; } - [MonoPInvokeCallback(typeof(ArrayGetLengthDelegate))] + [MonoPInvokeCallback(typeof(ArrayGetLengthDelegateType))] static int ArrayGetLength(int handle) { return ((Array)ObjectStore.Get(handle)).Length; } - [MonoPInvokeCallback(typeof(EnumerableGetEnumeratorDelegate))] + [MonoPInvokeCallback(typeof(EnumerableGetEnumeratorDelegateType))] static int EnumerableGetEnumerator(int handle) { return ObjectStore.Store(((IEnumerable)ObjectStore.Get(handle)).GetEnumerator()); } /*BEGIN FUNCTIONS*/ - [MonoPInvokeCallback(typeof(ReleaseSystemDecimalDelegate))] + [MonoPInvokeCallback(typeof(ReleaseSystemDecimalDelegateType))] static void ReleaseSystemDecimal(int handle) { try @@ -967,7 +983,7 @@ static void ReleaseSystemDecimal(int handle) } } - [MonoPInvokeCallback(typeof(SystemDecimalConstructorSystemDoubleDelegate))] + [MonoPInvokeCallback(typeof(SystemDecimalConstructorSystemDoubleDelegateType))] static int SystemDecimalConstructorSystemDouble(double value) { try @@ -989,7 +1005,7 @@ static int SystemDecimalConstructorSystemDouble(double value) } } - [MonoPInvokeCallback(typeof(SystemDecimalConstructorSystemUInt64Delegate))] + [MonoPInvokeCallback(typeof(SystemDecimalConstructorSystemUInt64DelegateType))] static int SystemDecimalConstructorSystemUInt64(ulong value) { try @@ -1011,7 +1027,7 @@ static int SystemDecimalConstructorSystemUInt64(ulong value) } } - [MonoPInvokeCallback(typeof(BoxDecimalDelegate))] + [MonoPInvokeCallback(typeof(BoxDecimalDelegateType))] static int BoxDecimal(int valHandle) { try @@ -1034,7 +1050,7 @@ static int BoxDecimal(int valHandle) } } - [MonoPInvokeCallback(typeof(UnboxDecimalDelegate))] + [MonoPInvokeCallback(typeof(UnboxDecimalDelegateType))] static int UnboxDecimal(int valHandle) { try @@ -1057,7 +1073,7 @@ static int UnboxDecimal(int valHandle) } } - [MonoPInvokeCallback(typeof(UnityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingleDelegate))] + [MonoPInvokeCallback(typeof(UnityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingleDelegateType))] static UnityEngine.Vector3 UnityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingle(float x, float y, float z) { try @@ -1079,7 +1095,7 @@ static UnityEngine.Vector3 UnityEngineVector3ConstructorSystemSingle_SystemSingl } } - [MonoPInvokeCallback(typeof(UnityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3Delegate))] + [MonoPInvokeCallback(typeof(UnityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3DelegateType))] static UnityEngine.Vector3 UnityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3(ref UnityEngine.Vector3 a, ref UnityEngine.Vector3 b) { try @@ -1101,7 +1117,7 @@ static UnityEngine.Vector3 UnityEngineVector3Methodop_AdditionUnityEngineVector3 } } - [MonoPInvokeCallback(typeof(BoxVector3Delegate))] + [MonoPInvokeCallback(typeof(BoxVector3DelegateType))] static int BoxVector3(ref UnityEngine.Vector3 val) { try @@ -1123,7 +1139,7 @@ static int BoxVector3(ref UnityEngine.Vector3 val) } } - [MonoPInvokeCallback(typeof(UnboxVector3Delegate))] + [MonoPInvokeCallback(typeof(UnboxVector3DelegateType))] static UnityEngine.Vector3 UnboxVector3(int valHandle) { try @@ -1146,7 +1162,7 @@ static UnityEngine.Vector3 UnboxVector3(int valHandle) } } - [MonoPInvokeCallback(typeof(UnityEngineObjectPropertyGetNameDelegate))] + [MonoPInvokeCallback(typeof(UnityEngineObjectPropertyGetNameDelegateType))] static int UnityEngineObjectPropertyGetName(int thisHandle) { try @@ -1169,7 +1185,7 @@ static int UnityEngineObjectPropertyGetName(int thisHandle) } } - [MonoPInvokeCallback(typeof(UnityEngineObjectPropertySetNameDelegate))] + [MonoPInvokeCallback(typeof(UnityEngineObjectPropertySetNameDelegateType))] static void UnityEngineObjectPropertySetName(int thisHandle, int valueHandle) { try @@ -1190,7 +1206,7 @@ static void UnityEngineObjectPropertySetName(int thisHandle, int valueHandle) } } - [MonoPInvokeCallback(typeof(UnityEngineComponentPropertyGetTransformDelegate))] + [MonoPInvokeCallback(typeof(UnityEngineComponentPropertyGetTransformDelegateType))] static int UnityEngineComponentPropertyGetTransform(int thisHandle) { try @@ -1213,7 +1229,7 @@ static int UnityEngineComponentPropertyGetTransform(int thisHandle) } } - [MonoPInvokeCallback(typeof(UnityEngineTransformPropertyGetPositionDelegate))] + [MonoPInvokeCallback(typeof(UnityEngineTransformPropertyGetPositionDelegateType))] static UnityEngine.Vector3 UnityEngineTransformPropertyGetPosition(int thisHandle) { try @@ -1236,7 +1252,7 @@ static UnityEngine.Vector3 UnityEngineTransformPropertyGetPosition(int thisHandl } } - [MonoPInvokeCallback(typeof(UnityEngineTransformPropertySetPositionDelegate))] + [MonoPInvokeCallback(typeof(UnityEngineTransformPropertySetPositionDelegateType))] static void UnityEngineTransformPropertySetPosition(int thisHandle, ref UnityEngine.Vector3 value) { try @@ -1256,7 +1272,7 @@ static void UnityEngineTransformPropertySetPosition(int thisHandle, ref UnityEng } } - [MonoPInvokeCallback(typeof(SystemCollectionsIEnumeratorPropertyGetCurrentDelegate))] + [MonoPInvokeCallback(typeof(SystemCollectionsIEnumeratorPropertyGetCurrentDelegateType))] static int SystemCollectionsIEnumeratorPropertyGetCurrent(int thisHandle) { try @@ -1279,7 +1295,7 @@ static int SystemCollectionsIEnumeratorPropertyGetCurrent(int thisHandle) } } - [MonoPInvokeCallback(typeof(SystemCollectionsIEnumeratorMethodMoveNextDelegate))] + [MonoPInvokeCallback(typeof(SystemCollectionsIEnumeratorMethodMoveNextDelegateType))] static bool SystemCollectionsIEnumeratorMethodMoveNext(int thisHandle) { try @@ -1302,7 +1318,7 @@ static bool SystemCollectionsIEnumeratorMethodMoveNext(int thisHandle) } } - [MonoPInvokeCallback(typeof(UnityEngineGameObjectMethodAddComponentMyGameBaseBallScriptDelegate))] + [MonoPInvokeCallback(typeof(UnityEngineGameObjectMethodAddComponentMyGameBaseBallScriptDelegateType))] static int UnityEngineGameObjectMethodAddComponentMyGameBaseBallScript(int thisHandle) { try @@ -1325,7 +1341,7 @@ static int UnityEngineGameObjectMethodAddComponentMyGameBaseBallScript(int thisH } } - [MonoPInvokeCallback(typeof(UnityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveTypeDelegate))] + [MonoPInvokeCallback(typeof(UnityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveTypeDelegateType))] static int UnityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveType(UnityEngine.PrimitiveType type) { try @@ -1347,7 +1363,7 @@ static int UnityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveType(Un } } - [MonoPInvokeCallback(typeof(UnityEngineDebugMethodLogSystemObjectDelegate))] + [MonoPInvokeCallback(typeof(UnityEngineDebugMethodLogSystemObjectDelegateType))] static void UnityEngineDebugMethodLogSystemObject(int messageHandle) { try @@ -1367,7 +1383,7 @@ static void UnityEngineDebugMethodLogSystemObject(int messageHandle) } } - [MonoPInvokeCallback(typeof(UnityEngineMonoBehaviourPropertyGetTransformDelegate))] + [MonoPInvokeCallback(typeof(UnityEngineMonoBehaviourPropertyGetTransformDelegateType))] static int UnityEngineMonoBehaviourPropertyGetTransform(int thisHandle) { try @@ -1390,7 +1406,7 @@ static int UnityEngineMonoBehaviourPropertyGetTransform(int thisHandle) } } - [MonoPInvokeCallback(typeof(SystemExceptionConstructorSystemStringDelegate))] + [MonoPInvokeCallback(typeof(SystemExceptionConstructorSystemStringDelegateType))] static int SystemExceptionConstructorSystemString(int messageHandle) { try @@ -1413,7 +1429,7 @@ static int SystemExceptionConstructorSystemString(int messageHandle) } } - [MonoPInvokeCallback(typeof(BoxPrimitiveTypeDelegate))] + [MonoPInvokeCallback(typeof(BoxPrimitiveTypeDelegateType))] static int BoxPrimitiveType(UnityEngine.PrimitiveType val) { try @@ -1435,7 +1451,7 @@ static int BoxPrimitiveType(UnityEngine.PrimitiveType val) } } - [MonoPInvokeCallback(typeof(UnboxPrimitiveTypeDelegate))] + [MonoPInvokeCallback(typeof(UnboxPrimitiveTypeDelegateType))] static UnityEngine.PrimitiveType UnboxPrimitiveType(int valHandle) { try @@ -1458,7 +1474,7 @@ static UnityEngine.PrimitiveType UnboxPrimitiveType(int valHandle) } } - [MonoPInvokeCallback(typeof(UnityEngineTimePropertyGetDeltaTimeDelegate))] + [MonoPInvokeCallback(typeof(UnityEngineTimePropertyGetDeltaTimeDelegateType))] static float UnityEngineTimePropertyGetDeltaTime() { try @@ -1480,7 +1496,7 @@ static float UnityEngineTimePropertyGetDeltaTime() } } - [MonoPInvokeCallback(typeof(BaseBallScriptConstructorDelegate))] + [MonoPInvokeCallback(typeof(BaseBallScriptConstructorDelegateType))] static void BaseBallScriptConstructor(int cppHandle, ref int handle) { try @@ -1502,7 +1518,7 @@ static void BaseBallScriptConstructor(int cppHandle, ref int handle) } } - [MonoPInvokeCallback(typeof(ReleaseBaseBallScriptDelegate))] + [MonoPInvokeCallback(typeof(ReleaseBaseBallScriptDelegateType))] static void ReleaseBaseBallScript(int handle) { try @@ -1526,7 +1542,7 @@ static void ReleaseBaseBallScript(int handle) } } - [MonoPInvokeCallback(typeof(BoxBooleanDelegate))] + [MonoPInvokeCallback(typeof(BoxBooleanDelegateType))] static int BoxBoolean(bool val) { try @@ -1548,7 +1564,7 @@ static int BoxBoolean(bool val) } } - [MonoPInvokeCallback(typeof(UnboxBooleanDelegate))] + [MonoPInvokeCallback(typeof(UnboxBooleanDelegateType))] static bool UnboxBoolean(int valHandle) { try @@ -1571,7 +1587,7 @@ static bool UnboxBoolean(int valHandle) } } - [MonoPInvokeCallback(typeof(BoxSByteDelegate))] + [MonoPInvokeCallback(typeof(BoxSByteDelegateType))] static int BoxSByte(sbyte val) { try @@ -1593,7 +1609,7 @@ static int BoxSByte(sbyte val) } } - [MonoPInvokeCallback(typeof(UnboxSByteDelegate))] + [MonoPInvokeCallback(typeof(UnboxSByteDelegateType))] static sbyte UnboxSByte(int valHandle) { try @@ -1616,7 +1632,7 @@ static sbyte UnboxSByte(int valHandle) } } - [MonoPInvokeCallback(typeof(BoxByteDelegate))] + [MonoPInvokeCallback(typeof(BoxByteDelegateType))] static int BoxByte(byte val) { try @@ -1638,7 +1654,7 @@ static int BoxByte(byte val) } } - [MonoPInvokeCallback(typeof(UnboxByteDelegate))] + [MonoPInvokeCallback(typeof(UnboxByteDelegateType))] static byte UnboxByte(int valHandle) { try @@ -1661,7 +1677,7 @@ static byte UnboxByte(int valHandle) } } - [MonoPInvokeCallback(typeof(BoxInt16Delegate))] + [MonoPInvokeCallback(typeof(BoxInt16DelegateType))] static int BoxInt16(short val) { try @@ -1683,7 +1699,7 @@ static int BoxInt16(short val) } } - [MonoPInvokeCallback(typeof(UnboxInt16Delegate))] + [MonoPInvokeCallback(typeof(UnboxInt16DelegateType))] static short UnboxInt16(int valHandle) { try @@ -1706,7 +1722,7 @@ static short UnboxInt16(int valHandle) } } - [MonoPInvokeCallback(typeof(BoxUInt16Delegate))] + [MonoPInvokeCallback(typeof(BoxUInt16DelegateType))] static int BoxUInt16(ushort val) { try @@ -1728,7 +1744,7 @@ static int BoxUInt16(ushort val) } } - [MonoPInvokeCallback(typeof(UnboxUInt16Delegate))] + [MonoPInvokeCallback(typeof(UnboxUInt16DelegateType))] static ushort UnboxUInt16(int valHandle) { try @@ -1751,7 +1767,7 @@ static ushort UnboxUInt16(int valHandle) } } - [MonoPInvokeCallback(typeof(BoxInt32Delegate))] + [MonoPInvokeCallback(typeof(BoxInt32DelegateType))] static int BoxInt32(int val) { try @@ -1773,7 +1789,7 @@ static int BoxInt32(int val) } } - [MonoPInvokeCallback(typeof(UnboxInt32Delegate))] + [MonoPInvokeCallback(typeof(UnboxInt32DelegateType))] static int UnboxInt32(int valHandle) { try @@ -1796,7 +1812,7 @@ static int UnboxInt32(int valHandle) } } - [MonoPInvokeCallback(typeof(BoxUInt32Delegate))] + [MonoPInvokeCallback(typeof(BoxUInt32DelegateType))] static int BoxUInt32(uint val) { try @@ -1818,7 +1834,7 @@ static int BoxUInt32(uint val) } } - [MonoPInvokeCallback(typeof(UnboxUInt32Delegate))] + [MonoPInvokeCallback(typeof(UnboxUInt32DelegateType))] static uint UnboxUInt32(int valHandle) { try @@ -1841,7 +1857,7 @@ static uint UnboxUInt32(int valHandle) } } - [MonoPInvokeCallback(typeof(BoxInt64Delegate))] + [MonoPInvokeCallback(typeof(BoxInt64DelegateType))] static int BoxInt64(long val) { try @@ -1863,7 +1879,7 @@ static int BoxInt64(long val) } } - [MonoPInvokeCallback(typeof(UnboxInt64Delegate))] + [MonoPInvokeCallback(typeof(UnboxInt64DelegateType))] static long UnboxInt64(int valHandle) { try @@ -1886,7 +1902,7 @@ static long UnboxInt64(int valHandle) } } - [MonoPInvokeCallback(typeof(BoxUInt64Delegate))] + [MonoPInvokeCallback(typeof(BoxUInt64DelegateType))] static int BoxUInt64(ulong val) { try @@ -1908,7 +1924,7 @@ static int BoxUInt64(ulong val) } } - [MonoPInvokeCallback(typeof(UnboxUInt64Delegate))] + [MonoPInvokeCallback(typeof(UnboxUInt64DelegateType))] static ulong UnboxUInt64(int valHandle) { try @@ -1931,7 +1947,7 @@ static ulong UnboxUInt64(int valHandle) } } - [MonoPInvokeCallback(typeof(BoxCharDelegate))] + [MonoPInvokeCallback(typeof(BoxCharDelegateType))] static int BoxChar(char val) { try @@ -1953,7 +1969,7 @@ static int BoxChar(char val) } } - [MonoPInvokeCallback(typeof(UnboxCharDelegate))] + [MonoPInvokeCallback(typeof(UnboxCharDelegateType))] static char UnboxChar(int valHandle) { try @@ -1976,7 +1992,7 @@ static char UnboxChar(int valHandle) } } - [MonoPInvokeCallback(typeof(BoxSingleDelegate))] + [MonoPInvokeCallback(typeof(BoxSingleDelegateType))] static int BoxSingle(float val) { try @@ -1998,7 +2014,7 @@ static int BoxSingle(float val) } } - [MonoPInvokeCallback(typeof(UnboxSingleDelegate))] + [MonoPInvokeCallback(typeof(UnboxSingleDelegateType))] static float UnboxSingle(int valHandle) { try @@ -2021,7 +2037,7 @@ static float UnboxSingle(int valHandle) } } - [MonoPInvokeCallback(typeof(BoxDoubleDelegate))] + [MonoPInvokeCallback(typeof(BoxDoubleDelegateType))] static int BoxDouble(double val) { try @@ -2043,7 +2059,7 @@ static int BoxDouble(double val) } } - [MonoPInvokeCallback(typeof(UnboxDoubleDelegate))] + [MonoPInvokeCallback(typeof(UnboxDoubleDelegateType))] static double UnboxDouble(int valHandle) { try diff --git a/Unity/Assets/NativeScript/BootScene.unity b/Unity/Assets/NativeScript/BootScene.unity index 4c9bb79..8a205bf 100644 --- a/Unity/Assets/NativeScript/BootScene.unity +++ b/Unity/Assets/NativeScript/BootScene.unity @@ -13,7 +13,7 @@ OcclusionCullingSettings: --- !u!104 &2 RenderSettings: m_ObjectHideFlags: 0 - serializedVersion: 8 + serializedVersion: 9 m_Fog: 0 m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} m_FogMode: 3 @@ -38,7 +38,8 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0.37311992, g: 0.38074034, b: 0.35872716, a: 1} + m_IndirectSpecularColor: {r: 0.3731316, g: 0.38074902, b: 0.3587254, a: 1} + m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: m_ObjectHideFlags: 0 @@ -54,11 +55,10 @@ LightmapSettings: m_EnableBakedLightmaps: 1 m_EnableRealtimeLightmaps: 1 m_LightmapEditorSettings: - serializedVersion: 9 + serializedVersion: 10 m_Resolution: 2 m_BakeResolution: 40 - m_TextureWidth: 1024 - m_TextureHeight: 1024 + m_AtlasSize: 1024 m_AO: 0 m_AOMaxDistance: 1 m_CompAOExponent: 1 @@ -88,6 +88,7 @@ LightmapSettings: m_PVRFilteringAtrousPositionSigmaDirect: 0.5 m_PVRFilteringAtrousPositionSigmaIndirect: 2 m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ShowResolutionOverlay: 1 m_LightingDataAsset: {fileID: 0} m_UseShadowmask: 1 --- !u!196 &4 @@ -139,7 +140,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 6b5575a60b7c04c7a87ff4e161573c66, type: 3} m_Name: m_EditorClassIdentifier: - MemorySize: 16777216 + MemorySize: 1048576 AutoReload: 1 AutoReloadPollTime: 1 --- !u!4 &643357610 @@ -218,6 +219,7 @@ Camera: m_TargetEye: 3 m_HDR: 1 m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 m_ForceIntoRT: 0 m_OcclusionCulling: 1 m_StereoConvergence: 10 diff --git a/Unity/Assets/NativeScript/Editor/EditorMenus.cs b/Unity/Assets/NativeScript/Editor/EditorMenus.cs index 12866f1..a444732 100644 --- a/Unity/Assets/NativeScript/Editor/EditorMenus.cs +++ b/Unity/Assets/NativeScript/Editor/EditorMenus.cs @@ -1,7 +1,6 @@ -using UnityEngine; using UnityEditor; -namespace NativeScript +namespace NativeScript.Editor { /// /// Menus for the Unity Editor diff --git a/Unity/Assets/NativeScript/Editor/GenerateBindings.cs b/Unity/Assets/NativeScript/Editor/GenerateBindings.cs index 8d84312..013fa39 100644 --- a/Unity/Assets/NativeScript/Editor/GenerateBindings.cs +++ b/Unity/Assets/NativeScript/Editor/GenerateBindings.cs @@ -8,7 +8,7 @@ using UnityEditor; using UnityEngine; -namespace NativeScript +namespace NativeScript.Editor { /// /// Code generator that reads a JSON file and outputs C# and C++ code @@ -137,8 +137,6 @@ class JsonDocument class StringBuilders { - public readonly StringBuilder CsharpInitParams = - new StringBuilder(InitialStringBuilderCapacity); public readonly StringBuilder CsharpDelegateTypes = new StringBuilder(InitialStringBuilderCapacity); public readonly StringBuilder CsharpStoreInitCalls = @@ -149,7 +147,9 @@ class StringBuilders new StringBuilder(InitialStringBuilderCapacity); public readonly StringBuilder CsharpFunctions = new StringBuilder(InitialStringBuilderCapacity); - public readonly StringBuilder CsharpDelegates = + public readonly StringBuilder CsharpCppDelegates = + new StringBuilder(InitialStringBuilderCapacity); + public readonly StringBuilder CsharpCsharpDelegates = new StringBuilder(InitialStringBuilderCapacity); public readonly StringBuilder CsharpImports = new StringBuilder(InitialStringBuilderCapacity); @@ -171,9 +171,9 @@ class StringBuilders new StringBuilder(InitialStringBuilderCapacity); public readonly StringBuilder CppMethodDefinitions = new StringBuilder(InitialStringBuilderCapacity); - public readonly StringBuilder CppInitParams = + public readonly StringBuilder CppInitBodyParameterReads = new StringBuilder(InitialStringBuilderCapacity); - public readonly StringBuilder CppInitBody = + public readonly StringBuilder CppInitBodyArrays = new StringBuilder(InitialStringBuilderCapacity); public readonly StringBuilder CppInitBodyFirstBoot = new StringBuilder(InitialStringBuilderCapacity); @@ -240,11 +240,17 @@ int IComparer.Compare(object x, object y) { FieldInfo xField = (FieldInfo)x; FieldInfo yField = (FieldInfo)y; - return xField.MetadataToken < yField.MetadataToken - ? -1 - : xField.MetadataToken > yField.MetadataToken + return xField == null + ? yField == null + ? 0 + : -1 + : yField == null ? 1 - : 0; + : xField.MetadataToken < yField.MetadataToken + ? -1 + : xField.MetadataToken > yField.MetadataToken + ? 1 + : 0; } } @@ -255,10 +261,9 @@ struct TypeName public int NumTypeParams; } - const int DEFAULT_MAX_SIMULTANEOUS = 1000; - const int DEFAULT_MAX_SIMULTANEOUS_OBJECTS = 1000; - - static readonly Type[] PRIMITIVE_TYPES = { + const int BaseMaxSimultaneous = 1000; + + static readonly Type[] PrimitiveTypes = { typeof(bool), typeof(sbyte), typeof(byte), @@ -270,7 +275,7 @@ struct TypeName typeof(ulong), typeof(char), typeof(float), - typeof(double), + typeof(double) }; const string PostCompileWorkPref = "NativeScriptGenerateBindingsPostCompileWork"; @@ -282,10 +287,9 @@ struct TypeName new Uri(typeof(GameObject).Assembly.CodeBase).LocalPath ).DirectoryName; static readonly string AssetsDirPath = Application.dataPath; - static readonly string ProjectDirPath = - new DirectoryInfo(AssetsDirPath) - .Parent - .FullName; + private static readonly DirectoryInfo ProjectDir = + new DirectoryInfo(AssetsDirPath).Parent; + static readonly string ProjectDirPath = ProjectDir.FullName; static readonly string CppDirPath = Path.Combine( Path.Combine( @@ -308,7 +312,7 @@ struct TypeName static readonly FieldOrderComparer DefaultFieldOrderComparer = new FieldOrderComparer(); - + // Restore unused field types #pragma warning restore 649 @@ -343,7 +347,7 @@ public static void Generate() } } } - determinedNeedStubs:; + determinedNeedStubs: if (needStubs) { @@ -403,10 +407,6 @@ static void AppendStubs( } } } - - // Need at least one init param - builders.CsharpInitParams.Append("object stub"); - builders.CsharpInitCall.Append("null // stub"); } static void AppendStubBaseType( @@ -448,7 +448,7 @@ static void AppendStubBaseType( { output.Append('\n'); ConstructorInfo[] constructors = type.GetConstructors(); - if (constructors != null && constructors.Length > 0) + if (constructors.Length > 0) { foreach (ConstructorInfo ctor in constructors) { @@ -507,14 +507,14 @@ static void DoPostCompileWork(bool canRefreshAssetDb) // it's not specified for a specific type int defaultMaxSimultaneous = doc.DefaultMaxSimultaneous != 0 ? doc.DefaultMaxSimultaneous - : DEFAULT_MAX_SIMULTANEOUS; + : BaseMaxSimultaneous; // Init param for max managed Objects - builders.CppInitParams.Append("\tint32_t maxManagedObjects,\n"); - builders.CsharpInitParams.Append("\t\t\tint maxManagedObjects,\n"); - builders.CsharpInitCall.Append("\t\t\t\t"); + builders.CsharpInitCall.Append("\t\t\tMarshal.WriteInt32(memory, curMemory, "); builders.CsharpInitCall.Append(defaultMaxSimultaneous); - builders.CsharpInitCall.Append(",\n"); + builders.CsharpInitCall.Append("); // max managed objects\n"); + builders.CsharpInitCall.Append("\t\t\tcurMemory += sizeof(int);\n"); + builders.CsharpInitCall.Append(' '); // C# ObjectStore Init call builders.CsharpStoreInitCalls.Append( @@ -560,7 +560,7 @@ static void DoPostCompileWork(bool canRefreshAssetDb) } // Generate boxing and unboxing for primitive types - foreach (Type type in PRIMITIVE_TYPES) + foreach (Type type in PrimitiveTypes) { string dummyString; ParameterInfo[] dummyParams; @@ -685,38 +685,38 @@ static Assembly[] GetAssemblies(string[] assemblyNames) assemblies[8] = typeof(UnityEngine.AI.NavMesh).Assembly; // Unity AI module assemblies[9] = typeof(UnityEngine.Animations.AnimationClipPlayable).Assembly; // Unity animation module 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 + 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 assemblies[30] = typeof(UnityEngine.Experimental.UIElements.Button).Assembly; // Unity UI elements module - assemblies[31] = typeof(UnityEngine.Canvas).Assembly; // Unity UI module + assemblies[31] = typeof(Canvas).Assembly; // Unity UI module assemblies[32] = typeof(UnityEngine.Networking.NetworkTransport).Assembly; // Unity cloth module 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 + assemblies[38] = typeof(WWW).Assembly; // Unity web request WWW module + 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; } @@ -920,7 +920,11 @@ static Type[] GetDirectInterfaces(Type type) minimalInterfaces.Add(iType); } } - minimalInterfaces.Sort((x, y) => x.Name.CompareTo(y.Name)); + minimalInterfaces.Sort( + (x, y) => string.Compare( + x.Name, + y.Name, + StringComparison.InvariantCulture)); return minimalInterfaces.ToArray(); } @@ -960,16 +964,11 @@ static void AppendCppConstructorInitializerList( string newline = "\n") { string separator = ": "; - for (int i = 0; i < interfaceTypes.Length; ++i) + foreach (Type interfaceType in interfaceTypes) { - Type interfaceType = interfaceTypes[i]; - AppendIndent( - indent, - output); + AppendIndent(indent, output); output.Append(separator); - AppendCppTypeFullName( - interfaceType, - output); + AppendCppTypeFullName( interfaceType, output); output.Append("(nullptr)"); output.Append(newline); separator = ", "; @@ -1429,7 +1428,7 @@ static void AppendTypeNameWithoutSuffixes( } } - static int AppendType( + static void AppendType( JsonType jsonType, Type type, TypeKind typeKind, @@ -1447,11 +1446,9 @@ static int AppendType( typeKind, null, builders); - return 0; } else { - int totalMaxSimultaneous = 0; Type[] genericArgTypes = type.GetGenericArguments(); if (jsonType.GenericParams != null) { @@ -1474,7 +1471,6 @@ static int AppendType( : jsonType.MaxSimultaneous != 0 ? jsonType.MaxSimultaneous : defaultMaxSimultaneous; - totalMaxSimultaneous += maxSimultaneous; AppendType( jsonType, genericArgTypes, @@ -1499,7 +1495,6 @@ static int AppendType( int maxSimultaneous = jsonType.MaxSimultaneous != 0 ? jsonType.MaxSimultaneous : defaultMaxSimultaneous; - totalMaxSimultaneous += maxSimultaneous; AppendType( jsonType, genericArgTypes, @@ -1518,7 +1513,6 @@ static int AppendType( builders); } } - return totalMaxSimultaneous; } } @@ -1562,11 +1556,6 @@ static void AppendType( builders.TempStrBuilder); string funcName = builders.TempStrBuilder.ToString(); - // Build lowercase function name - builders.TempStrBuilder[0] = char.ToLower( - builders.TempStrBuilder[0]); - string funcNameLower = builders.TempStrBuilder.ToString(); - // Build ReleaseX parameters ParameterInfo paramInfo = new ParameterInfo(); paramInfo.Name = "handle"; @@ -1621,44 +1610,35 @@ static void AppendType( typeof(void), builders.CppFunctionPointers); - // C++ init param for ReleaseX - AppendCppInitParam( - funcNameLower, + // C++ init body for ReleaseX + AppendCppInitBodyFunctionPointerParameterRead( + funcName, true, default(TypeName), TypeKind.None, parameters, typeof(void), - builders.CppInitParams); - - // C++ init body for ReleaseX - AppendCppInitBody( - funcName, - funcNameLower, - builders.CppInitBody); - - // C# init param for ReleaseX - AppendCsharpInitParam( - funcNameLower, - builders.CsharpInitParams); + builders.CppInitBodyParameterReads); // C# init call arg for ReleaseX - AppendCsharpInitCallArg( + AppendCsharpCsharpDelegate( funcName, - builders.CsharpInitCall); + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); // C++ init body for handle array length - builders.CppInitBody.Append("\tPlugin::RefCounts"); - builders.CppInitBody.Append(funcNameSuffix); - builders.CppInitBody.Append(" = (int32_t*)curMemory;\n"); - builders.CppInitBody.Append("\tcurMemory += "); - builders.CppInitBody.Append(maxSimultaneous); - builders.CppInitBody.Append(" * sizeof(int32_t);\n"); - builders.CppInitBody.Append("\tPlugin::RefCountsLen"); - builders.CppInitBody.Append(funcNameSuffix); - builders.CppInitBody.Append(" = "); - builders.CppInitBody.Append(maxSimultaneous); - builders.CppInitBody.Append(";\n"); + builders.CppInitBodyArrays.Append("\tPlugin::RefCounts"); + builders.CppInitBodyArrays.Append(funcNameSuffix); + builders.CppInitBodyArrays.Append(" = (int32_t*)curMemory;\n"); + builders.CppInitBodyArrays.Append("\tcurMemory += "); + builders.CppInitBodyArrays.Append(maxSimultaneous); + builders.CppInitBodyArrays.Append(" * sizeof(int32_t);\n"); + builders.CppInitBodyArrays.Append("\tPlugin::RefCountsLen"); + builders.CppInitBodyArrays.Append(funcNameSuffix); + builders.CppInitBodyArrays.Append(" = "); + builders.CppInitBodyArrays.Append(maxSimultaneous); + builders.CppInitBodyArrays.Append(";\n"); + builders.CppInitBodyArrays.Append("\t\n"); // C++ ref count state and functions builders.CppGlobalStateAndFunctions.Append("\tint32_t RefCountsLen"); @@ -2044,9 +2024,8 @@ static void AppendEnum( FieldInfo[] fields = type.GetFields( BindingFlags.Static | BindingFlags.Public); - for (int i = 0; i < fields.Length; ++i) + foreach (FieldInfo field in fields) { - FieldInfo field = fields[i]; AppendIndent( indent + 1, builders.CppTypeDefinitions); @@ -2235,9 +2214,8 @@ static void AppendEnum( builders.CppTypeDefinitions.Append('\n'); // Static initialization - for (int i = 0; i < fields.Length; ++i) + foreach (FieldInfo field in fields) { - FieldInfo field = fields[i]; builders.CppMethodDefinitions.Append("const "); AppendCppTypeFullName( type, @@ -2345,10 +2323,6 @@ static void AppendBoxingBindings( builders.TempStrBuilder); boxFuncName = builders.TempStrBuilder.ToString(); - builders.TempStrBuilder[0] = char.ToLower( - builders.TempStrBuilder[0]); - string boxFuncNameLower = builders.TempStrBuilder.ToString(); - ParameterInfo[] boxParams = { new ParameterInfo { @@ -2363,11 +2337,6 @@ static void AppendBoxingBindings( boxCppParams = new ParameterInfo[0]; - // C# init params - AppendCsharpInitParam( - boxFuncNameLower, - builders.CsharpInitParams); - // C# delegate types AppendCsharpDelegateType( boxFuncName, @@ -2379,9 +2348,10 @@ static void AppendBoxingBindings( builders.CsharpDelegateTypes); // C# init call args - AppendCsharpInitCallArg( + AppendCsharpCsharpDelegate( boxFuncName, - builders.CsharpInitCall); + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); // C# box function AppendCsharpFunctionBeginning( @@ -2412,21 +2382,15 @@ static void AppendBoxingBindings( typeof(object), builders.CppFunctionPointers); - // C++ init params - AppendCppInitParam( - boxFuncNameLower, + // C++ init body + AppendCppInitBodyFunctionPointerParameterRead( + boxFuncName, true, GetTypeName(type), typeKind, boxParams, typeof(object), - builders.CppInitParams); - - // C++ init body - AppendCppInitBody( - boxFuncName, - boxFuncNameLower, - builders.CppInitBody); + builders.CppInitBodyParameterReads); } static void AppendUnboxing( @@ -2445,10 +2409,6 @@ static void AppendUnboxing( builders.TempStrBuilder); string unboxFuncName = builders.TempStrBuilder.ToString(); - builders.TempStrBuilder[0] = char.ToLower( - builders.TempStrBuilder[0]); - string unboxFuncNameLower = builders.TempStrBuilder.ToString(); - builders.TempStrBuilder.Length = 0; builders.TempStrBuilder.Append("operator "); AppendCppTypeFullName( @@ -2476,10 +2436,7 @@ static void AppendUnboxing( ParameterInfo[] unboxCppParams = new ParameterInfo[0]; // C# init params - AppendCsharpInitParam( - unboxFuncNameLower, - builders.CsharpInitParams); - + // C# delegate types AppendCsharpDelegateType( unboxFuncName, @@ -2491,9 +2448,10 @@ static void AppendUnboxing( builders.CsharpDelegateTypes); // C# init call args - AppendCsharpInitCallArg( + AppendCsharpCsharpDelegate( unboxFuncName, - builders.CsharpInitCall); + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); // C# unbox function AppendCsharpFunctionBeginning( @@ -2603,21 +2561,15 @@ static void AppendUnboxing( indent, builders.CppMethodDefinitions); - // C++ init params - AppendCppInitParam( - unboxFuncNameLower, + // C++ init body + AppendCppInitBodyFunctionPointerParameterRead( + unboxFuncName, true, GetTypeName(type), typeKind, unboxParams, type, - builders.CppInitParams); - - // C++ init body - AppendCppInitBody( - unboxFuncName, - unboxFuncNameLower, - builders.CppInitBody); + builders.CppInitBodyParameterReads); } static void AppendCppBoxingMethodNames( @@ -2830,11 +2782,6 @@ static void AppendConstructor( builders.TempStrBuilder); string funcName = builders.TempStrBuilder.ToString(); - // Build lowercase function name - builders.TempStrBuilder[0] = char.ToLower( - builders.TempStrBuilder[0]); - string funcNameLower = builders.TempStrBuilder.ToString(); - TypeName enclosingTypeTypeName = GetTypeName(enclosingType); // Build C++ constructor method name @@ -2845,9 +2792,6 @@ static void AppendConstructor( string cppMethodName = builders.TempStrBuilder.ToString(); // C# init param declaration - AppendCsharpInitParam( - funcNameLower, - builders.CsharpInitParams); // C# delegate type Type delegateReturnType; @@ -2869,7 +2813,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) @@ -3035,22 +2982,16 @@ static void AppendConstructor( indent, builders.CppMethodDefinitions); builders.CppMethodDefinitions.Append('\n'); - - // C++ init params - AppendCppInitParam( - funcNameLower, + + // C++ init body + AppendCppInitBodyFunctionPointerParameterRead( + funcName, true, GetTypeName(enclosingType), enclosingTypeKind, parameters, enclosingType, - builders.CppInitParams); - - // C++ init body - AppendCppInitBody( - funcName, - funcNameLower, - builders.CppInitBody); + builders.CppInitBodyParameterReads); } static void AppendProperty( @@ -3421,20 +3362,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, @@ -3446,9 +3380,10 @@ static void AppendEventAddRemoveMethod( builders.CsharpDelegateTypes); // C# init call arg - AppendCsharpInitCallArg( + AppendCsharpCsharpDelegate( funcName, - builders.CsharpInitCall); + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); // C# function AppendCsharpFunctionBeginning( @@ -3530,21 +3465,15 @@ static void AppendEventAddRemoveMethod( builders.CppMethodDefinitions); builders.CppMethodDefinitions.Append("}\n\t\n"); - // C++ init params - AppendCppInitParam( - funcNameLower, + // C++ init body + AppendCppInitBodyFunctionPointerParameterRead( + funcName, methodIsStatic, GetTypeName(enclosingType), enclosingTypeKind, methodParams, typeof(void), - builders.CppInitParams); - - // C++ init body - AppendCppInitBody( - funcName, - funcNameLower, - builders.CppInitBody); + builders.CppInitBodyParameterReads); } static MethodInfo GetMethod( @@ -3847,16 +3776,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, @@ -3868,9 +3789,10 @@ static void AppendMethod( builders.CsharpDelegateTypes); // C# init call param - AppendCsharpInitCallArg( + AppendCsharpCsharpDelegate( funcName, - builders.CsharpInitCall); + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); // C# function AppendCsharpFunctionBeginning( @@ -4247,27 +4169,20 @@ static void AppendMethod( builders.CppMethodDefinitions); builders.CppMethodDefinitions.Append("}\n\t\n"); - // C++ init params - AppendCppInitParam( - funcNameLower, + // C++ init body + AppendCppInitBodyFunctionPointerParameterRead( + funcName, methodIsStatic, GetTypeName(enclosingType), enclosingTypeKind, parameters, returnType, - builders.CppInitParams); - - // C++ init body - AppendCppInitBody( - funcName, - funcNameLower, - builders.CppInitBody); + builders.CppInitBodyParameterReads); } static void AppendCSharpTypeParameters( Type[] typeParams, - StringBuilder output - ) + StringBuilder output) { if (typeParams != null && typeParams.Length > 0) { @@ -4514,9 +4429,7 @@ static void AppendArray( GetTypeName(cppArrayTypeName, "System"), false, cppTypeParams, - cppTypeParams != null ? - builders.CppTemplateSpecializationDeclarations : - builders.CppTypeDeclarations); + builders.CppTemplateSpecializationDeclarations); // C++ type definition (beginning) Type[] interfaceTypes = GetDirectInterfaces(arrayType); @@ -4535,6 +4448,7 @@ static void AppendArray( Type[] cppCtorInitTypes = GetCppCtorInitTypes( arrayType, false); + int localRank = rank; int cppMethodDefinitionsIndent = AppendCppMethodDefinitionsBegin( GetTypeName(cppArrayTypeName, "System"), TypeKind.Class, @@ -4548,9 +4462,9 @@ static void AppendArray( builders.CppMethodDefinitions.Append(subject); builders.CppMethodDefinitions.Append( "InternalLength = 0;\n"); - if (rank > 1) + if (localRank > 1) { - for (int i = 0; i < rank; ++i) + for (int i = 0; i < localRank; ++i) { AppendIndent( extraIndent, @@ -4573,9 +4487,9 @@ static void AppendArray( builders.CppMethodDefinitions.Append(subject); builders.CppMethodDefinitions.Append( "InternalLength;\n"); - if (rank > 1) + if (localRank > 1) { - for (int i = 0; i < rank; ++i) + for (int i = 0; i < localRank; ++i) { AppendIndent( extraIndent, @@ -5538,10 +5452,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) { @@ -5570,15 +5480,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, @@ -5624,21 +5532,15 @@ static void AppendArrayConstructor( arrayType, builders.CppFunctionPointers); - // C++ init param - AppendCppInitParam( - funcNameLower, + // C++ init body + AppendCppInitBodyFunctionPointerParameterRead( + funcName, true, cppArrayTypeTypeName, TypeKind.Class, parameters, arrayType, - builders.CppInitParams); - - // C++ init body - AppendCppInitBody( - funcName, - funcNameLower, - builders.CppInitBody); + builders.CppInitBodyParameterReads); // C++ method declaration AppendIndent( @@ -5919,10 +5821,6 @@ static void AppendArrayMultidimensionalGetLength( builders.TempStrBuilder.Append(rank); string funcName = builders.TempStrBuilder.ToString(); - builders.TempStrBuilder[0] = char.ToLower( - builders.TempStrBuilder[0]); - string funcNameLower = builders.TempStrBuilder.ToString(); - ParameterInfo[] parameters = { new ParameterInfo { Name = "dimension", @@ -5949,15 +5847,13 @@ static void AppendArrayMultidimensionalGetLength( builders.CsharpDelegateTypes); // C# Init Call - AppendCsharpInitCallArg( + AppendCsharpCsharpDelegate( funcName, - builders.CsharpInitCall); + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); // C# Init Param - AppendCsharpInitParam( - funcNameLower, - builders.CsharpInitParams); - + // C# function AppendCsharpFunctionBeginning( arrayType, @@ -5987,21 +5883,15 @@ static void AppendArrayMultidimensionalGetLength( arrayType, builders.CppFunctionPointers); - // C++ init param - AppendCppInitParam( - funcNameLower, + // C++ init body + AppendCppInitBodyFunctionPointerParameterRead( + funcName, false, cppArrayTypeTypeName, TypeKind.Class, parameters, arrayType, - builders.CppInitParams); - - // C++ init body - AppendCppInitBody( - funcName, - funcNameLower, - builders.CppInitBody); + builders.CppInitBodyParameterReads); // C++ method declaration AppendIndent( @@ -6106,10 +5996,6 @@ static void AppendArrayGetItem( builders.TempStrBuilder); string funcName = builders.TempStrBuilder.ToString(); - builders.TempStrBuilder[0] = char.ToLower( - builders.TempStrBuilder[0]); - string funcNameLower = builders.TempStrBuilder.ToString(); - ParameterInfo[] parameters = BuildArrayGetItemsParams( rank, "index"); @@ -6125,15 +6011,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, @@ -6176,21 +6060,15 @@ static void AppendArrayGetItem( elementType, builders.CppFunctionPointers); - // C++ init param - AppendCppInitParam( - funcNameLower, + // C++ init body + AppendCppInitBodyFunctionPointerParameterRead( + funcName, false, cppArrayTypeTypeName, TypeKind.Class, parameters, elementType, - builders.CppInitParams); - - // C++ init body - AppendCppInitBody( - funcName, - funcNameLower, - builders.CppInitBody); + builders.CppInitBodyParameterReads); } static void AppendArraySetItem( @@ -6208,10 +6086,6 @@ static void AppendArraySetItem( builders.TempStrBuilder); string funcName = builders.TempStrBuilder.ToString(); - builders.TempStrBuilder[0] = char.ToLower( - builders.TempStrBuilder[0]); - string funcNameLower = builders.TempStrBuilder.ToString(); - // Build parameters as indexes then element ParameterInfo[] parameters = BuildArraySetItemsParams( rank, @@ -6229,15 +6103,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, @@ -6280,21 +6152,15 @@ static void AppendArraySetItem( arrayType, builders.CppFunctionPointers); - // C++ init param - AppendCppInitParam( - funcNameLower, + // C++ init body + AppendCppInitBodyFunctionPointerParameterRead( + funcName, false, cppArrayTypeTypeName, TypeKind.Class, parameters, arrayType, - builders.CppInitParams); - - // C++ init body - AppendCppInitBody( - funcName, - funcNameLower, - builders.CppInitBody); + builders.CppInitBodyParameterReads); } static void AppendDelegate( @@ -6308,15 +6174,14 @@ static void AppendDelegate( assemblies); if (jsonDelegate.GenericParams != null) { - foreach (JsonGenericParams jsonGenericParams - in jsonDelegate.GenericParams) + for (int i = 0; i < jsonDelegate.GenericParams.Length; ++i) { // C++ template declaration AppendCppTemplateDeclaration( GetTypeName(type), builders.CppTemplateDeclarations); } - + foreach (JsonGenericParams jsonGenericParams in jsonDelegate.GenericParams) { @@ -6389,37 +6254,21 @@ static void AppendDelegate( builders.TempStrBuilder.Append(bindingTypeName); string releaseFuncName = builders.TempStrBuilder.ToString(); - builders.TempStrBuilder[0] = char.ToLower( - builders.TempStrBuilder[0]); - string releaseFuncNameLower = builders.TempStrBuilder.ToString(); - builders.TempStrBuilder.Length = 0; builders.TempStrBuilder.Append(bindingTypeName); builders.TempStrBuilder.Append("Constructor"); string constructorFuncName = builders.TempStrBuilder.ToString(); - builders.TempStrBuilder[0] = char.ToLower( - builders.TempStrBuilder[0]); - string constructorFuncNameLower = builders.TempStrBuilder.ToString(); - builders.TempStrBuilder.Length = 0; builders.TempStrBuilder.Append(bindingTypeName); builders.TempStrBuilder.Append("Add"); string addFuncName = builders.TempStrBuilder.ToString(); - builders.TempStrBuilder[0] = char.ToLower( - builders.TempStrBuilder[0]); - string addFuncNameLower = builders.TempStrBuilder.ToString(); - builders.TempStrBuilder.Length = 0; builders.TempStrBuilder.Append(bindingTypeName); builders.TempStrBuilder.Append("Remove"); string removeFuncName = builders.TempStrBuilder.ToString(); - builders.TempStrBuilder[0] = char.ToLower( - builders.TempStrBuilder[0]); - string removeFuncNameLower = builders.TempStrBuilder.ToString(); - TypeName typeTypeName = GetTypeName(type); // C++ type declaration @@ -6503,7 +6352,7 @@ static void AppendDelegate( GetTypeName(cppTypeName, type.Namespace), maxSimultaneous, bindingTypeName, - builders.CppInitBody, + builders.CppInitBodyArrays, builders.CppInitBodyFirstBoot); // C++ type definition (begin) @@ -6600,81 +6449,55 @@ static void AppendDelegate( typeof(void), builders.CppFunctionPointers); - // C++ init params - AppendCppInitParam( - releaseFuncNameLower, + // C++ and C# init params + AppendCppInitBodyFunctionPointerParameterRead( + releaseFuncName, true, default(TypeName), TypeKind.None, releaseParams, typeof(void), - builders.CppInitParams); - AppendCppInitParam( - constructorFuncNameLower, + builders.CppInitBodyParameterReads); + AppendCppInitBodyFunctionPointerParameterRead( + constructorFuncName, true, default(TypeName), TypeKind.None, constructorParams, typeof(void), - builders.CppInitParams); - AppendCppInitParam( - addFuncNameLower, + builders.CppInitBodyParameterReads); + AppendCppInitBodyFunctionPointerParameterRead( + addFuncName, false, default(TypeName), TypeKind.None, addRemoveParams, typeof(void), - builders.CppInitParams); - AppendCppInitParam( - removeFuncNameLower, + builders.CppInitBodyParameterReads); + AppendCppInitBodyFunctionPointerParameterRead( + removeFuncName, false, default(TypeName), TypeKind.None, addRemoveParams, typeof(void), - builders.CppInitParams); - - // C++ and C# init params - AppendCppInitBody( - releaseFuncName, - releaseFuncNameLower, - builders.CppInitBody); - AppendCppInitBody( - constructorFuncName, - constructorFuncNameLower, - builders.CppInitBody); - AppendCppInitBody( - addFuncName, - addFuncNameLower, - builders.CppInitBody); - AppendCppInitBody( - removeFuncName, - removeFuncNameLower, - builders.CppInitBody); - AppendCsharpInitParam( - releaseFuncNameLower, - builders.CsharpInitParams); - AppendCsharpInitParam( - constructorFuncNameLower, - builders.CsharpInitParams); - AppendCsharpInitParam( - addFuncNameLower, - builders.CsharpInitParams); - AppendCsharpInitParam( - removeFuncNameLower, - builders.CsharpInitParams); - AppendCsharpInitCallArg( + builders.CppInitBodyParameterReads); + AppendCsharpCsharpDelegate( releaseFuncName, - builders.CsharpInitCall); - AppendCsharpInitCallArg( + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); + AppendCsharpCsharpDelegate( constructorFuncName, - builders.CsharpInitCall); - AppendCsharpInitCallArg( + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); + AppendCsharpCsharpDelegate( addFuncName, - builders.CsharpInitCall); - AppendCsharpInitCallArg( + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); + AppendCsharpCsharpDelegate( removeFuncName, - builders.CsharpInitCall); + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); // C++ method definitions (end) int cppMethodDefinitionsIndent = AppendNamespaceBeginning( @@ -7039,10 +6862,6 @@ static void AppendBaseType( builders.TempStrBuilder.Append(baseTypeTypeName.Name); string releaseFuncName = builders.TempStrBuilder.ToString(); - builders.TempStrBuilder[0] = char.ToLower( - builders.TempStrBuilder[0]); - string releaseFuncNameLower = builders.TempStrBuilder.ToString(); - builders.TempStrBuilder.Length = 0; AppendCppTypeName( baseTypeTypeName, @@ -7073,7 +6892,7 @@ static void AppendBaseType( throw new Exception(errorBuilder.ToString()); } - jsonConstructors = new JsonConstructor[] + jsonConstructors = new[] { new JsonConstructor { @@ -7155,7 +6974,7 @@ static void AppendBaseType( { cppBaseClass = typeof(object); cppBaseClassTypeParams = null; - cppInterfaceTypes = new Type[] { type }; + cppInterfaceTypes = new [] { type }; } else { @@ -7175,7 +6994,7 @@ static void AppendBaseType( baseTypeTypeName, maxSimultaneous, baseTypeTypeName.Name, - builders.CppInitBody, + builders.CppInitBodyArrays, builders.CppInitBodyFirstBoot); // C++ type declaration @@ -7324,52 +7143,34 @@ static void AppendBaseType( builders.CppFunctionPointers); } - // C++ init params - AppendCppInitParam( - releaseFuncNameLower, + // C++ and C# init params + AppendCppInitBodyFunctionPointerParameterRead( + releaseFuncName, true, default(TypeName), TypeKind.None, releaseParams, typeof(void), - builders.CppInitParams); + builders.CppInitBodyParameterReads); + AppendCsharpCsharpDelegate( + releaseFuncName, + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); for (int i = 0; i < numConstructors; ++i) { - AppendCppInitParam( - constructorFuncNameLowers[i], + string funcName = constructorFuncNames[i]; + AppendCppInitBodyFunctionPointerParameterRead( + funcName, true, default(TypeName), TypeKind.None, constructorParams[i], typeof(void), - builders.CppInitParams); - } - - // C++ and C# init params - AppendCppInitBody( - releaseFuncName, - releaseFuncNameLower, - builders.CppInitBody); - AppendCsharpInitParam( - releaseFuncNameLower, - builders.CsharpInitParams); - AppendCsharpInitCallArg( - releaseFuncName, - builders.CsharpInitCall); - for (int i = 0; i < numConstructors; ++i) - { - string funcName = constructorFuncNames[i]; - string funcNameLower = constructorFuncNameLowers[i]; - AppendCppInitBody( - funcName, - funcNameLower, - builders.CppInitBody); - AppendCsharpInitParam( - funcNameLower, - builders.CsharpInitParams); - AppendCsharpInitCallArg( + builders.CppInitBodyParameterReads); + AppendCsharpCsharpDelegate( funcName, - builders.CsharpInitCall); + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); } // C++ method definitions (end) @@ -7489,7 +7290,7 @@ static void AppendBaseType( AppendCppWholeObjectFreeListInit( maxSimultaneous, baseTypeTypeName.Name, - builders.CppInitBody, + builders.CppInitBodyArrays, builders.CppInitBodyFirstBoot); // C++ binding function to create the base class @@ -7538,7 +7339,7 @@ static void AppendBaseType( // C# usage of the C++ binding function to create from C# default constructor ParameterInfo[] cppDefaultConstructorBindingFunctionParams = ConvertParameters( - new Type[] { typeof(int) }); + new[] { typeof(int) }); AppendCsharpDelegate( true, GetTypeName(string.Empty, string.Empty), @@ -7547,7 +7348,7 @@ static void AppendBaseType( cppDefaultConstructorBindingFunctionParams, typeof(int), TypeKind.None, - builders.CsharpDelegates); + builders.CsharpCppDelegates); AppendCsharpImport( GetTypeName(string.Empty, string.Empty), null, @@ -7600,7 +7401,7 @@ static void AppendBaseType( // C# usage of the C++ binding function to destroy from C# default constructor ParameterInfo[] cppDestroyBindingFunctionParams = ConvertParameters( - new Type[] { typeof(int) }); + new [] { typeof(int) }); AppendCsharpDelegate( true, GetTypeName(string.Empty, string.Empty), @@ -7609,7 +7410,7 @@ static void AppendBaseType( cppDestroyBindingFunctionParams, typeof(void), TypeKind.None, - builders.CsharpDelegates); + builders.CsharpCppDelegates); ParameterInfo[] cppDestroyImportFunctionParams = ConvertParameters( new Type[0]); AppendCsharpImport( @@ -8383,10 +8184,6 @@ static void AppendBaseTypeMethodCallsCsharpMethod( builders.TempStrBuilder.Append(methodName); string funcName = builders.TempStrBuilder.ToString(); - builders.TempStrBuilder[0] = char.ToLower( - builders.TempStrBuilder[0]); - string funcNameLower = builders.TempStrBuilder.ToString(); - // C++ method declaration for the method ParameterInfo[] invokeParams = ConvertParameters( methodInfo.GetParameters()); @@ -8414,24 +8211,18 @@ static void AppendBaseTypeMethodCallsCsharpMethod( builders.CppFunctionPointers); // C++ and C# Init parameter and body for the C# binding function - AppendCppInitParam( - funcNameLower, + AppendCppInitBodyFunctionPointerParameterRead( + funcName, false, default(TypeName), TypeKind.None, invokeParams, methodInfo.ReturnType, - builders.CppInitParams); - AppendCppInitBody( + builders.CppInitBodyParameterReads); + AppendCsharpCsharpDelegate( funcName, - funcNameLower, - builders.CppInitBody); - AppendCsharpInitParam( - funcNameLower, - builders.CsharpInitParams); - AppendCsharpInitCallArg( - funcName, - builders.CsharpInitCall); + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); // C++ method definition for the method TypeKind returnTypeKind = GetTypeKind( @@ -8683,7 +8474,7 @@ static ParameterInfo[] AppendBaseTypeCppNativeInvokeCall( invokeParams, invokeMethod.ReturnType, invokeReturnTypeKind, - builders.CsharpDelegates); + builders.CsharpCppDelegates); // C# import for the C++ binding function AppendCsharpImport( @@ -9040,9 +8831,8 @@ static void AppendCppBaseTypeMethodInvokeBindingFunction( indent + 1, output); output.Append("{\n"); - for (int i = 0; i < methodParams.Length; ++i) + foreach (ParameterInfo parameter in methodParams) { - ParameterInfo parameter = methodParams[i]; if (parameter.Kind == TypeKind.Class || parameter.Kind == TypeKind.ManagedStruct) { @@ -10546,7 +10336,7 @@ static void AppendCsharpDelegate( typeParams, funcName, output); - output.Append("Delegate("); + output.Append("DelegateType("); if (!isStatic) { output.Append("int thisHandle"); @@ -10586,7 +10376,7 @@ static void AppendCsharpDelegate( typeParams, funcName, output); - output.Append("Delegate "); + output.Append("DelegateType "); AppendCsharpDelegateName( typeTypeName, typeParams, @@ -10632,7 +10422,7 @@ static void AppendCsharpGetDelegateCall( typeParams, funcName, output); - output.Append("Delegate>(libraryHandle, \""); + output.Append("DelegateType>(libraryHandle, \""); AppendCsharpDelegateName( typeTypeName, typeParams, @@ -10880,7 +10670,7 @@ static void AppendExceptions( parameters, typeof(void), TypeKind.None, - builders.CsharpDelegates + builders.CsharpCppDelegates ); // C# GetDelegate call @@ -10947,11 +10737,6 @@ static void AppendGetter( builders.TempStrBuilder); string funcName = builders.TempStrBuilder.ToString(); - // Build lowercase function name - builders.TempStrBuilder[0] = char.ToLower( - builders.TempStrBuilder[0]); - string funcNameLower = builders.TempStrBuilder.ToString(); - // Build method name builders.TempStrBuilder.Length = 0; builders.TempStrBuilder.Append("Get"); @@ -10959,9 +10744,6 @@ static void AppendGetter( string methodName = builders.TempStrBuilder.ToString(); // C# init param declaration - AppendCsharpInitParam( - funcNameLower, - builders.CsharpInitParams); // C# delegate type AppendCsharpDelegateType( @@ -10974,9 +10756,10 @@ static void AppendGetter( builders.CsharpDelegateTypes); // C# init call param - AppendCsharpInitCallArg( + AppendCsharpCsharpDelegate( funcName, - builders.CsharpInitCall); + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); // C# function AppendCsharpFunctionBeginning( @@ -11081,22 +10864,16 @@ static void AppendGetter( builders.CppMethodDefinitions.Append("}\n"); AppendIndent(indent, builders.CppMethodDefinitions); builders.CppMethodDefinitions.Append('\n'); - - // C++ init params - AppendCppInitParam( - funcNameLower, + + // C++ init body + AppendCppInitBodyFunctionPointerParameterRead( + funcName, methodIsStatic, GetTypeName(enclosingType), enclosingTypeKind, parameters, fieldType, - builders.CppInitParams); - - // C++ init body - AppendCppInitBody( - funcName, - funcNameLower, - builders.CppInitBody); + builders.CppInitBodyParameterReads); } static void AppendSetter( @@ -11135,11 +10912,6 @@ static void AppendSetter( builders.TempStrBuilder); string funcName = builders.TempStrBuilder.ToString(); - // Build lowercase function name - builders.TempStrBuilder[0] = char.ToLower( - builders.TempStrBuilder[0]); - string funcNameLower = builders.TempStrBuilder.ToString(); - // Build method name builders.TempStrBuilder.Length = 0; builders.TempStrBuilder.Append("Set"); @@ -11147,10 +10919,7 @@ static void AppendSetter( string methodName = builders.TempStrBuilder.ToString(); // C# init param declaration - AppendCsharpInitParam( - funcNameLower, - builders.CsharpInitParams); - + // C# delegate type AppendCsharpDelegateType( funcName, @@ -11162,9 +10931,10 @@ static void AppendSetter( builders.CsharpDelegateTypes); // C# init call param - AppendCsharpInitCallArg( + AppendCsharpCsharpDelegate( funcName, - builders.CsharpInitCall); + builders.CsharpInitCall, + builders.CsharpCsharpDelegates); // C# function AppendCsharpFunctionBeginning( @@ -11268,21 +11038,15 @@ static void AppendSetter( AppendIndent(indent, builders.CppMethodDefinitions); builders.CppMethodDefinitions.Append('\n'); - // C++ init params - AppendCppInitParam( - funcNameLower, + // C++ init body + AppendCppInitBodyFunctionPointerParameterRead( + funcName, methodIsStatic, enclosingTypeTypeName, enclosingTypeKind, parameters, typeof(void), - builders.CppInitParams); - - // C++ init body - AppendCppInitBody( - funcName, - funcNameLower, - builders.CppInitBody); + builders.CppInitBodyParameterReads); } static void AppendFieldPropertyFuncName( @@ -12175,26 +11939,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.Append("));\n"); + initCallOutput.Append("\t\t\tcurMemory += IntPtr.Size;\n"); + + 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.Append(");\n"); } static void AppendCsharpDelegateType( @@ -12222,7 +11988,7 @@ static void AppendCsharpDelegateType( output.Append(' '); output.Append(funcName); - output.Append("Delegate("); + output.Append("DelegateType("); if (!isStatic) { if (enclosingTypeKind == TypeKind.FullStruct) @@ -12259,7 +12025,7 @@ static void AppendCsharpFunctionBeginning( { output.Append("\t\t[MonoPInvokeCallback(typeof("); output.Append(funcName); - output.Append("Delegate))]\n\t\tstatic "); + output.Append("DelegateType))]\n\t\tstatic "); // Return type if (returnType != null) @@ -12781,30 +12547,32 @@ static void AppendCppParameterDeclaration( } } } - - static void AppendDefaultStringParamName( - string str, - StringBuilder output) - { - foreach (char c in str) - { - if (char.IsLetterOrDigit(c)) - { - output.Append(c); - } - } - } - static void AppendCppInitBody( + static void AppendCppInitBodyFunctionPointerParameterRead( string globalVariableName, - string paramName, + bool isStatic, + TypeName enclosingTypeTypeName, + TypeKind enclosingTypeKind, + ParameterInfo[] parameters, + Type returnType, StringBuilder output) { output.Append("\tPlugin::"); output.Append(globalVariableName); - output.Append(" = "); - output.Append(paramName); - output.Append(";\n"); + output.Append(" = *("); + AppendCppFunctionPointer( + string.Empty, // function name + isStatic, + enclosingTypeTypeName, + enclosingTypeKind, + parameters, + returnType, + 2, + output); + output.Append(")curMemory;\n"); + output.Append("\tcurMemory += sizeof(Plugin::"); + output.Append(globalVariableName); + output.Append(");\n"); } static void AppendCppMethodDefinitionBegin( @@ -13029,31 +12797,7 @@ static void AppendCppUnhandledExceptionHandling( AppendIndent(indent, output); output.Append("}\n"); } - - static void AppendCppInitParam( - string funcName, - bool isStatic, - TypeName enclosingTypeTypeName, - TypeKind enclosingTypeKind, - ParameterInfo[] parameters, - Type returnType, - StringBuilder output - ) - { - output.Append('\t'); - AppendCppFunctionPointer( - funcName, - isStatic, - enclosingTypeTypeName, - enclosingTypeKind, - parameters, - returnType, - ',', - output - ); - output.Append('\n'); - } - + static void AppendCppFunctionPointerDefinition( string funcName, bool isStatic, @@ -13072,9 +12816,10 @@ StringBuilder output enclosingTypeKind, parameters, returnType, - ';', + 1, output ); + output.Append(';'); output.Append('\n'); } @@ -13085,7 +12830,7 @@ static void AppendCppFunctionPointer( TypeKind enclosingTypeKind, ParameterInfo[] parameters, Type returnType, - char separator, + int numIndirectionLevels, StringBuilder output) { // Return type @@ -13108,7 +12853,8 @@ static void AppendCppFunctionPointer( output.Append("int32_t"); } - output.Append(" (*"); + output.Append(" ("); + output.Append('*', numIndirectionLevels); output.Append(funcName); output.Append(")("); if (!isStatic) @@ -13189,7 +12935,6 @@ static void AppendCppFunctionPointer( } } output.Append(')'); - output.Append(separator); } static void AppendCppTemplateTypenames( @@ -13568,13 +13313,13 @@ static void AppendCppPrimitiveTypeName( static void RemoveTrailingChars( StringBuilders builders) { - RemoveTrailingChars(builders.CsharpInitParams); RemoveTrailingChars(builders.CsharpDelegateTypes); RemoveTrailingChars(builders.CsharpStoreInitCalls); RemoveTrailingChars(builders.CsharpInitCall); RemoveTrailingChars(builders.CsharpBaseTypes); RemoveTrailingChars(builders.CsharpFunctions); - RemoveTrailingChars(builders.CsharpDelegates); + RemoveTrailingChars(builders.CsharpCppDelegates); + RemoveTrailingChars(builders.CsharpCsharpDelegates); RemoveTrailingChars(builders.CsharpImports); RemoveTrailingChars(builders.CsharpGetDelegateCalls); RemoveTrailingChars(builders.CsharpDestroyFunctionEnumerators); @@ -13585,8 +13330,8 @@ static void RemoveTrailingChars( RemoveTrailingChars(builders.CppTemplateSpecializationDeclarations); RemoveTrailingChars(builders.CppTypeDefinitions); RemoveTrailingChars(builders.CppMethodDefinitions); - RemoveTrailingChars(builders.CppInitParams); - RemoveTrailingChars(builders.CppInitBody); + RemoveTrailingChars(builders.CppInitBodyParameterReads); + RemoveTrailingChars(builders.CppInitBodyArrays); RemoveTrailingChars(builders.CppInitBodyFirstBoot); RemoveTrailingChars(builders.CppGlobalStateAndFunctions); RemoveTrailingChars(builders.CppUnboxingMethodDeclarations); @@ -13627,11 +13372,6 @@ static void InjectBuilders( string csharpContents = File.ReadAllText(CsharpPath); string cppHeaderContents = File.ReadAllText(CppHeaderPath); 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", @@ -13645,7 +13385,7 @@ static void InjectBuilders( csharpContents = InjectIntoString( csharpContents, "/*BEGIN INIT CALL*/\n", - "\n\t\t\t\t/*END INIT CALL*/", + "\n\t\t\t/*END INIT CALL*/", builders.CsharpInitCall.ToString()); csharpContents = InjectIntoString( csharpContents, @@ -13659,9 +13399,14 @@ static void InjectBuilders( builders.CsharpFunctions.ToString()); csharpContents = InjectIntoString( csharpContents, - "/*BEGIN DELEGATES*/\n", - "\n\t\t/*END DELEGATES*/", - builders.CsharpDelegates.ToString()); + "/*BEGIN CPP DELEGATES*/\n", + "\n\t\t/*END CPP DELEGATES*/", + builders.CsharpCppDelegates.ToString()); + csharpContents = InjectIntoString( + csharpContents, + "/*BEGIN CSHARP DELEGATES*/\n", + "\n\t\t/*END CSHARP DELEGATES*/", + builders.CsharpCsharpDelegates.ToString()); csharpContents = InjectIntoString( csharpContents, "/*BEGIN IMPORTS*/\n", @@ -13714,14 +13459,14 @@ static void InjectBuilders( builders.CppMethodDefinitions.ToString()); cppSourceContents = InjectIntoString( cppSourceContents, - "/*BEGIN INIT PARAMS*/\n", - "\n\t/*END INIT PARAMS*/", - builders.CppInitParams.ToString()); + "/*BEGIN INIT BODY PARAMETER READS*/\n", + "\n\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*/\n", + "\n\t/*END INIT BODY ARRAYS*/", + builders.CppInitBodyArrays.ToString()); cppSourceContents = InjectIntoString( cppSourceContents, "/*BEGIN INIT BODY FIRST BOOT*/\n", diff --git a/Unity/UnityPackageManager/manifest.json b/Unity/Packages/manifest.json similarity index 100% rename from Unity/UnityPackageManager/manifest.json rename to Unity/Packages/manifest.json diff --git a/Unity/ProjectSettings/GraphicsSettings.asset b/Unity/ProjectSettings/GraphicsSettings.asset index 77bf2f1..d8b1468 100644 --- a/Unity/ProjectSettings/GraphicsSettings.asset +++ b/Unity/ProjectSettings/GraphicsSettings.asset @@ -37,6 +37,7 @@ GraphicsSettings: - {fileID: 10782, guid: 0000000000000000f000000000000000, type: 0} - {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0} - {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 16001, guid: 0000000000000000f000000000000000, type: 0} m_PreloadedShaders: [] m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} diff --git a/Unity/ProjectSettings/PresetManager.asset b/Unity/ProjectSettings/PresetManager.asset new file mode 100644 index 0000000..636a595 --- /dev/null +++ b/Unity/ProjectSettings/PresetManager.asset @@ -0,0 +1,6 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1386491679 &1 +PresetManager: + m_ObjectHideFlags: 0 + m_DefaultList: [] diff --git a/Unity/ProjectSettings/ProjectVersion.txt b/Unity/ProjectSettings/ProjectVersion.txt index e3618f1..22977b3 100644 --- a/Unity/ProjectSettings/ProjectVersion.txt +++ b/Unity/ProjectSettings/ProjectVersion.txt @@ -1 +1 @@ -m_EditorVersion: 2017.4.1f1 +m_EditorVersion: 2018.1.0f2 From 1cb1135e19576bb3a01205b9c1bc61fd304db746 Mon Sep 17 00:00:00 2001 From: Jackson Dunstan Date: Sat, 28 Jul 2018 17:16:52 -0700 Subject: [PATCH 09/36] Fix GitHub Issue #19 regarding whole object free list initialization (thanks to JmgrArt!) Update Unity project to 2018.2.0f2 and fix an error by generating IEquatable --- .../CppSource/NativeScript/Bindings.cpp | 101 +++++++++++++++++- .../Assets/CppSource/NativeScript/Bindings.h | 23 ++++ .../NativeScript/Editor/GenerateBindings.cs | 2 +- Unity/Assets/NativeScriptTypes.json | 5 + Unity/Packages/manifest.json | 39 ++++++- Unity/ProjectSettings/ProjectVersion.txt | 2 +- 6 files changed, 167 insertions(+), 5 deletions(-) diff --git a/Unity/Assets/CppSource/NativeScript/Bindings.cpp b/Unity/Assets/CppSource/NativeScript/Bindings.cpp index 8e36cbb..0903692 100644 --- a/Unity/Assets/CppSource/NativeScript/Bindings.cpp +++ b/Unity/Assets/CppSource/NativeScript/Bindings.cpp @@ -2490,6 +2490,87 @@ namespace System } } +namespace System +{ + IEquatable_1::IEquatable_1(decltype(nullptr)) + { + } + + IEquatable_1::IEquatable_1(Plugin::InternalUse, int32_t handle) + { + Handle = handle; + if (handle) + { + Plugin::ReferenceManagedClass(handle); + } + } + + IEquatable_1::IEquatable_1(const IEquatable_1& other) + : IEquatable_1(Plugin::InternalUse::Only, other.Handle) + { + } + + IEquatable_1::IEquatable_1(IEquatable_1&& other) + : IEquatable_1(Plugin::InternalUse::Only, other.Handle) + { + other.Handle = 0; + } + + IEquatable_1::~IEquatable_1() + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + } + + IEquatable_1& IEquatable_1::operator=(const IEquatable_1& other) + { + if (this->Handle) + { + Plugin::DereferenceManagedClass(this->Handle); + } + this->Handle = other.Handle; + if (this->Handle) + { + Plugin::ReferenceManagedClass(this->Handle); + } + return *this; + } + + IEquatable_1& IEquatable_1::operator=(decltype(nullptr)) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + return *this; + } + + IEquatable_1& IEquatable_1::operator=(IEquatable_1&& other) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + } + Handle = other.Handle; + other.Handle = 0; + return *this; + } + + bool IEquatable_1::operator==(const IEquatable_1& other) const + { + return Handle == other.Handle; + } + + bool IEquatable_1::operator!=(const IEquatable_1& other) const + { + return Handle != other.Handle; + } +} + namespace System { IComparable_1::IComparable_1(decltype(nullptr)) @@ -3867,6 +3948,24 @@ namespace UnityEngine } return nullptr; } + + UnityEngine::Vector3::operator System::IEquatable_1() + { + int32_t handle = Plugin::BoxVector3(*this); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + if (handle) + { + Plugin::ReferenceManagedClass(handle); + return System::IEquatable_1(Plugin::InternalUse::Only, handle); + } + return nullptr; + } } namespace System @@ -6117,7 +6216,7 @@ DLLEXPORT void Init( for (int32_t i = 0, end = Plugin::BaseBallScriptFreeWholeListSize - 1; i < end; ++i) { - Plugin::BaseBallScriptFreeWholeList[i].Next = Plugin::BaseBallScriptFreeWholeList[i + 1].Next; + Plugin::BaseBallScriptFreeWholeList[i].Next = Plugin::BaseBallScriptFreeWholeList + i + 1; } Plugin::BaseBallScriptFreeWholeList[Plugin::BaseBallScriptFreeWholeListSize - 1].Next = nullptr; Plugin::NextFreeWholeBaseBallScript = Plugin::BaseBallScriptFreeWholeList + 1; diff --git a/Unity/Assets/CppSource/NativeScript/Bindings.h b/Unity/Assets/CppSource/NativeScript/Bindings.h index e7a25bb..13aa459 100644 --- a/Unity/Assets/CppSource/NativeScript/Bindings.h +++ b/Unity/Assets/CppSource/NativeScript/Bindings.h @@ -489,6 +489,11 @@ namespace System template<> struct IEquatable_1; } +namespace System +{ + template<> struct IEquatable_1; +} + namespace System { template<> struct IComparable_1; @@ -934,6 +939,23 @@ namespace System }; } +namespace System +{ + template<> struct IEquatable_1 : virtual System::Object + { + IEquatable_1(decltype(nullptr)); + IEquatable_1(Plugin::InternalUse, int32_t handle); + IEquatable_1(const IEquatable_1& other); + IEquatable_1(IEquatable_1&& other); + virtual ~IEquatable_1(); + IEquatable_1& operator=(const IEquatable_1& other); + IEquatable_1& operator=(decltype(nullptr)); + IEquatable_1& operator=(IEquatable_1&& other); + bool operator==(const IEquatable_1& other) const; + bool operator!=(const IEquatable_1& other) const; + }; +} + namespace System { template<> struct IComparable_1 : virtual System::Object @@ -1193,6 +1215,7 @@ namespace UnityEngine UnityEngine::Vector3 operator+(UnityEngine::Vector3& a); explicit operator System::ValueType(); explicit operator System::Object(); + explicit operator System::IEquatable_1(); }; } diff --git a/Unity/Assets/NativeScript/Editor/GenerateBindings.cs b/Unity/Assets/NativeScript/Editor/GenerateBindings.cs index 013fa39..9966308 100644 --- a/Unity/Assets/NativeScript/Editor/GenerateBindings.cs +++ b/Unity/Assets/NativeScript/Editor/GenerateBindings.cs @@ -10164,7 +10164,7 @@ static void AppendCppWholeObjectFreeListInit( outputFirstBoot.Append(bindingTypeName); outputFirstBoot.Append("FreeWholeList[i].Next = Plugin::"); outputFirstBoot.Append(bindingTypeName); - outputFirstBoot.Append("FreeWholeList[i + 1].Next;\n"); + outputFirstBoot.Append("FreeWholeList + i + 1;\n"); outputFirstBoot.Append("\t\t}\n"); outputFirstBoot.Append("\t\tPlugin::"); diff --git a/Unity/Assets/NativeScriptTypes.json b/Unity/Assets/NativeScriptTypes.json index 26511b8..b933795 100644 --- a/Unity/Assets/NativeScriptTypes.json +++ b/Unity/Assets/NativeScriptTypes.json @@ -78,6 +78,11 @@ "Types": [ "System.Decimal" ] + }, + { + "Types": [ + "UnityEngine.Vector3" + ] } ] }, diff --git a/Unity/Packages/manifest.json b/Unity/Packages/manifest.json index 526aca6..1342d0a 100644 --- a/Unity/Packages/manifest.json +++ b/Unity/Packages/manifest.json @@ -1,4 +1,39 @@ { - "dependencies": { - } + "dependencies": { + "com.unity.ads": "2.0.8", + "com.unity.analytics": "2.0.16", + "com.unity.package-manager-ui": "1.9.11", + "com.unity.purchasing": "2.0.3", + "com.unity.textmeshpro": "1.2.4", + "com.unity.modules.ai": "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/ProjectVersion.txt b/Unity/ProjectSettings/ProjectVersion.txt index 22977b3..0498f4d 100644 --- a/Unity/ProjectSettings/ProjectVersion.txt +++ b/Unity/ProjectSettings/ProjectVersion.txt @@ -1 +1 @@ -m_EditorVersion: 2018.1.0f2 +m_EditorVersion: 2018.2.0f2 From ba3cf0d3e1f3c3eb6e8c05dbe18318d4b0361168 Mon Sep 17 00:00:00 2001 From: Jackson Dunstan Date: Tue, 5 Mar 2019 22:17:47 -0800 Subject: [PATCH 10/36] Fix a bug generating the base type constructor function for delegates --- Unity/Assets/NativeScript/Editor/GenerateBindings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Unity/Assets/NativeScript/Editor/GenerateBindings.cs b/Unity/Assets/NativeScript/Editor/GenerateBindings.cs index 9966308..4e25e7a 100644 --- a/Unity/Assets/NativeScript/Editor/GenerateBindings.cs +++ b/Unity/Assets/NativeScript/Editor/GenerateBindings.cs @@ -6751,7 +6751,7 @@ static void AppendDelegate( AppendCsharpBaseTypeConstructorFunction( type, GetTypeName(bindingTypeName, string.Empty), - false, + true, constructorFuncName, constructorParams, new ParameterInfo[0], From 7b3d95ec3ca559a543262b2dcc36daf4808c113f Mon Sep 17 00:00:00 2001 From: Jackson Dunstan Date: Thu, 4 Jul 2019 10:39:27 -0700 Subject: [PATCH 11/36] Use non-experimental namespace for UI Elements in Unity 2019.1+ --- Unity/Assets/NativeScript/Editor/GenerateBindings.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Unity/Assets/NativeScript/Editor/GenerateBindings.cs b/Unity/Assets/NativeScript/Editor/GenerateBindings.cs index 4e25e7a..16da323 100644 --- a/Unity/Assets/NativeScript/Editor/GenerateBindings.cs +++ b/Unity/Assets/NativeScript/Editor/GenerateBindings.cs @@ -704,7 +704,11 @@ static Assembly[] GetAssemblies(string[] assemblyNames) 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 +#endif assemblies[31] = typeof(Canvas).Assembly; // Unity UI module assemblies[32] = typeof(UnityEngine.Networking.NetworkTransport).Assembly; // Unity cloth module assemblies[33] = typeof(UnityEngine.Analytics.Analytics).Assembly; // Unity analytics module From d67249bde28778803d894eb336cac50be9f40b87 Mon Sep 17 00:00:00 2001 From: Jackson Dunstan Date: Fri, 2 Aug 2019 17:36:29 -0700 Subject: [PATCH 12/36] Made BootScript only run on Start, not Awake, so that it can be disabled. --- Unity/Assets/NativeScript/BootScript.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Unity/Assets/NativeScript/BootScript.cs b/Unity/Assets/NativeScript/BootScript.cs index 1fe063f..9296ee7 100644 --- a/Unity/Assets/NativeScript/BootScript.cs +++ b/Unity/Assets/NativeScript/BootScript.cs @@ -27,7 +27,7 @@ public class BootScript : MonoBehaviour private Coroutine autoReloadCoroutine; #endif - void Awake() + void Start() { #if UNITY_EDITOR lastAutoReloadPollTime = AutoReloadPollTime; From 7107c69e0e0aad14ba22778b20c86ba0b7b32119 Mon Sep 17 00:00:00 2001 From: Jackson Dunstan Date: Tue, 6 Aug 2019 21:39:37 -0700 Subject: [PATCH 13/36] - Remove global placement new operator - Add macros for defining placement new within derived classes (and use them in the example) - Fix copy errors on Windows when the temp DLL existed - Fix Bindings.h being included by Bindings.cpp on behalf of Game.h - Git-ignore Unity upgrade logs - Upgrade project to Unity 2019.2.0f1 and change the JSON config to add a newly-required type --- .gitignore | 5 +- Unity/Assets/CppSource/Game/Game.h | 1 + .../CppSource/NativeScript/Bindings.cpp | 147 +++++++++--- .../Assets/CppSource/NativeScript/Bindings.h | 75 +++++- Unity/Assets/NativeScript/Bindings.cs | 2 +- .../NativeScript/Editor/GenerateBindings.cs | 85 ++++++- Unity/Assets/NativeScriptTypes.json | 3 + Unity/Packages/manifest.json | 20 +- Unity/ProjectSettings/EditorSettings.asset | 16 +- Unity/ProjectSettings/GraphicsSettings.asset | 1 + Unity/ProjectSettings/ProjectSettings.asset | 227 ++++++++---------- Unity/ProjectSettings/ProjectVersion.txt | 3 +- .../UnityConnectSettings.asset | 16 +- Unity/ProjectSettings/VFXManager.asset | 11 + Unity/ProjectSettings/XRSettings.asset | 10 + 15 files changed, 444 insertions(+), 178 deletions(-) create mode 100644 Unity/ProjectSettings/VFXManager.asset create mode 100644 Unity/ProjectSettings/XRSettings.asset diff --git a/.gitignore b/.gitignore index 7f3848a..eaec275 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ # Rider IDE -.idea \ No newline at end of file +.idea + +# Unity upgrade logs +Unity/Logs \ No newline at end of file diff --git a/Unity/Assets/CppSource/Game/Game.h b/Unity/Assets/CppSource/Game/Game.h index a8e6e5b..79d31ad 100644 --- a/Unity/Assets/CppSource/Game/Game.h +++ b/Unity/Assets/CppSource/Game/Game.h @@ -16,6 +16,7 @@ namespace MyGame { struct BallScript : MyGame::BaseBallScript { + MY_GAME_BALL_SCRIPT_DEFAULT_CONTENTS MY_GAME_BALL_SCRIPT_DEFAULT_CONSTRUCTOR void Update() override; }; diff --git a/Unity/Assets/CppSource/NativeScript/Bindings.cpp b/Unity/Assets/CppSource/NativeScript/Bindings.cpp index 0903692..b8246ad 100644 --- a/Unity/Assets/CppSource/NativeScript/Bindings.cpp +++ b/Unity/Assets/CppSource/NativeScript/Bindings.cpp @@ -9,30 +9,18 @@ /// MIT /// -// Type definitions -#include "Bindings.h" - // Game type definitions #include "Game.h" +// Type definitions +#include "Bindings.h" + // For assert() #include -// For int32_t, etc. -#include - -// For malloc(), etc. -#include - // For memset(), etc. #include -// Support placement new -void* operator new(size_t, void* p) -{ - return p; -} - // Macro to put before functions that need to be exposed to C# #ifdef _WIN32 #define DLLEXPORT extern "C" __declspec(dllexport) @@ -3624,6 +3612,93 @@ namespace System } } +namespace System +{ + namespace Runtime + { + namespace Serialization + { + IDeserializationCallback::IDeserializationCallback(decltype(nullptr)) + { + } + + IDeserializationCallback::IDeserializationCallback(Plugin::InternalUse, int32_t handle) + { + Handle = handle; + if (handle) + { + Plugin::ReferenceManagedClass(handle); + } + } + + IDeserializationCallback::IDeserializationCallback(const IDeserializationCallback& other) + : IDeserializationCallback(Plugin::InternalUse::Only, other.Handle) + { + } + + IDeserializationCallback::IDeserializationCallback(IDeserializationCallback&& other) + : IDeserializationCallback(Plugin::InternalUse::Only, other.Handle) + { + other.Handle = 0; + } + + IDeserializationCallback::~IDeserializationCallback() + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + } + + IDeserializationCallback& IDeserializationCallback::operator=(const IDeserializationCallback& other) + { + if (this->Handle) + { + Plugin::DereferenceManagedClass(this->Handle); + } + this->Handle = other.Handle; + if (this->Handle) + { + Plugin::ReferenceManagedClass(this->Handle); + } + return *this; + } + + IDeserializationCallback& IDeserializationCallback::operator=(decltype(nullptr)) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + Handle = 0; + } + return *this; + } + + IDeserializationCallback& IDeserializationCallback::operator=(IDeserializationCallback&& other) + { + if (Handle) + { + Plugin::DereferenceManagedClass(Handle); + } + Handle = other.Handle; + other.Handle = 0; + return *this; + } + + bool IDeserializationCallback::operator==(const IDeserializationCallback& other) const + { + return Handle == other.Handle; + } + + bool IDeserializationCallback::operator!=(const IDeserializationCallback& other) const + { + return Handle != other.Handle; + } + } + } +} + namespace System { Decimal::Decimal(decltype(nullptr)) @@ -3774,7 +3849,7 @@ namespace System return nullptr; } - System::Decimal::operator System::IFormattable() + System::Decimal::operator System::IComparable() { int32_t handle = Plugin::BoxDecimal(Handle); if (Plugin::unhandledCsharpException) @@ -3787,7 +3862,25 @@ namespace System if (handle) { Plugin::ReferenceManagedClass(handle); - return System::IFormattable(Plugin::InternalUse::Only, handle); + return System::IComparable(Plugin::InternalUse::Only, handle); + } + return nullptr; + } + + System::Decimal::operator System::IComparable_1() + { + int32_t handle = Plugin::BoxDecimal(Handle); + if (Plugin::unhandledCsharpException) + { + System::Exception* ex = Plugin::unhandledCsharpException; + Plugin::unhandledCsharpException = nullptr; + ex->ThrowReferenceToThis(); + delete ex; + } + if (handle) + { + Plugin::ReferenceManagedClass(handle); + return System::IComparable_1(Plugin::InternalUse::Only, handle); } return nullptr; } @@ -3810,7 +3903,7 @@ namespace System return nullptr; } - System::Decimal::operator System::IComparable() + System::Decimal::operator System::IEquatable_1() { int32_t handle = Plugin::BoxDecimal(Handle); if (Plugin::unhandledCsharpException) @@ -3823,12 +3916,12 @@ namespace System if (handle) { Plugin::ReferenceManagedClass(handle); - return System::IComparable(Plugin::InternalUse::Only, handle); + return System::IEquatable_1(Plugin::InternalUse::Only, handle); } return nullptr; } - System::Decimal::operator System::IComparable_1() + System::Decimal::operator System::Runtime::Serialization::IDeserializationCallback() { int32_t handle = Plugin::BoxDecimal(Handle); if (Plugin::unhandledCsharpException) @@ -3841,12 +3934,12 @@ namespace System if (handle) { Plugin::ReferenceManagedClass(handle); - return System::IComparable_1(Plugin::InternalUse::Only, handle); + return System::Runtime::Serialization::IDeserializationCallback(Plugin::InternalUse::Only, handle); } return nullptr; } - System::Decimal::operator System::IEquatable_1() + System::Decimal::operator System::IFormattable() { int32_t handle = Plugin::BoxDecimal(Handle); if (Plugin::unhandledCsharpException) @@ -3859,7 +3952,7 @@ namespace System if (handle) { Plugin::ReferenceManagedClass(handle); - return System::IEquatable_1(Plugin::InternalUse::Only, handle); + return System::IFormattable(Plugin::InternalUse::Only, handle); } return nullptr; } @@ -5325,7 +5418,7 @@ namespace UnityEngine return nullptr; } - UnityEngine::PrimitiveType::operator System::IFormattable() + UnityEngine::PrimitiveType::operator System::IComparable() { int32_t handle = Plugin::BoxPrimitiveType(*this); if (Plugin::unhandledCsharpException) @@ -5338,7 +5431,7 @@ namespace UnityEngine if (handle) { Plugin::ReferenceManagedClass(handle); - return System::IFormattable(Plugin::InternalUse::Only, handle); + return System::IComparable(Plugin::InternalUse::Only, handle); } return nullptr; } @@ -5361,7 +5454,7 @@ namespace UnityEngine return nullptr; } - UnityEngine::PrimitiveType::operator System::IComparable() + UnityEngine::PrimitiveType::operator System::IFormattable() { int32_t handle = Plugin::BoxPrimitiveType(*this); if (Plugin::unhandledCsharpException) @@ -5374,7 +5467,7 @@ namespace UnityEngine if (handle) { Plugin::ReferenceManagedClass(handle); - return System::IComparable(Plugin::InternalUse::Only, handle); + return System::IFormattable(Plugin::InternalUse::Only, handle); } return nullptr; } diff --git a/Unity/Assets/CppSource/NativeScript/Bindings.h b/Unity/Assets/CppSource/NativeScript/Bindings.h index 13aa459..6835b61 100644 --- a/Unity/Assets/CppSource/NativeScript/Bindings.h +++ b/Unity/Assets/CppSource/NativeScript/Bindings.h @@ -13,6 +13,9 @@ // For int32_t, etc. #include +// For size_t to support placement new and delete +#include + //////////////////////////////////////////////////////////////// // Plugin internals. Do not name these in game code as they may // change without warning. For example: @@ -312,6 +315,17 @@ namespace System struct IComparable; } +namespace System +{ + namespace Runtime + { + namespace Serialization + { + struct IDeserializationCallback; + } + } +} + namespace System { struct Decimal; @@ -1177,6 +1191,29 @@ namespace System }; } +namespace System +{ + namespace Runtime + { + namespace Serialization + { + struct IDeserializationCallback : virtual System::Object + { + IDeserializationCallback(decltype(nullptr)); + IDeserializationCallback(Plugin::InternalUse, int32_t handle); + IDeserializationCallback(const IDeserializationCallback& other); + IDeserializationCallback(IDeserializationCallback&& other); + virtual ~IDeserializationCallback(); + IDeserializationCallback& operator=(const IDeserializationCallback& other); + IDeserializationCallback& operator=(decltype(nullptr)); + IDeserializationCallback& operator=(IDeserializationCallback&& other); + bool operator==(const IDeserializationCallback& other) const; + bool operator!=(const IDeserializationCallback& other) const; + }; + } + } +} + namespace System { struct Decimal : Plugin::ManagedType @@ -1195,11 +1232,12 @@ namespace System Decimal(System::UInt64 value); explicit operator System::ValueType(); explicit operator System::Object(); - explicit operator System::IFormattable(); - explicit operator System::IConvertible(); explicit operator System::IComparable(); explicit operator System::IComparable_1(); + explicit operator System::IConvertible(); explicit operator System::IEquatable_1(); + explicit operator System::Runtime::Serialization::IDeserializationCallback(); + explicit operator System::IFormattable(); }; } @@ -1485,9 +1523,9 @@ namespace UnityEngine explicit operator System::Enum(); explicit operator System::ValueType(); explicit operator System::Object(); - explicit operator System::IFormattable(); - explicit operator System::IConvertible(); explicit operator System::IComparable(); + explicit operator System::IConvertible(); + explicit operator System::IFormattable(); }; } @@ -1550,7 +1588,7 @@ namespace MyGame /*BEGIN MACROS*/ #define MY_GAME_BALL_SCRIPT_DEFAULT_CONSTRUCTOR_DECLARATION \ BallScript(Plugin::InternalUse iu, int32_t handle); - + #define MY_GAME_BALL_SCRIPT_DEFAULT_CONSTRUCTOR_DEFINITION \ BallScript::BallScript(Plugin::InternalUse iu, int32_t handle) \ : UnityEngine::Object(nullptr) \ @@ -1558,7 +1596,10 @@ namespace MyGame , UnityEngine::Behaviour(nullptr) \ , UnityEngine::MonoBehaviour(nullptr) \ , MyGame::AbstractBaseBallScript(nullptr) \ - , MyGame::BaseBallScript(iu, handle) + , MyGame::BaseBallScript(iu, handle) \ + { \ + } + #define MY_GAME_BALL_SCRIPT_DEFAULT_CONSTRUCTOR \ BallScript(Plugin::InternalUse iu, int32_t handle) \ : UnityEngine::Object(nullptr) \ @@ -1568,7 +1609,29 @@ namespace MyGame , MyGame::AbstractBaseBallScript(nullptr) \ , MyGame::BaseBallScript(iu, handle) \ { \ + } + +#define MY_GAME_BALL_SCRIPT_DEFAULT_CONTENTS_DECLARATION \ + void* operator new(size_t, void* p) noexcept; \ + void operator delete(void*, size_t) noexcept; \ + +#define MY_GAME_BALL_SCRIPT_DEFAULT_CONTENTS_DEFINITION \ + void* BallScript::operator new(size_t, void* p) noexcept\ + { \ + return p; \ + } \ + void BallScript::operator delete(void*, size_t) noexcept \ + { \ + } + +#define MY_GAME_BALL_SCRIPT_DEFAULT_CONTENTS\ + void* operator new(size_t, void* p) noexcept \ + { \ + return p; \ } \ + void operator delete(void*, size_t) noexcept \ + { \ + } /*END MACROS*/ //////////////////////////////////////////////////////////////// diff --git a/Unity/Assets/NativeScript/Bindings.cs b/Unity/Assets/NativeScript/Bindings.cs index c2a00a6..bb6745d 100644 --- a/Unity/Assets/NativeScript/Bindings.cs +++ b/Unity/Assets/NativeScript/Bindings.cs @@ -679,7 +679,7 @@ private static void OpenPlugin(InitMode initMode) string loadPath; #if UNITY_EDITOR_WIN // Copy native library to temporary file - File.Copy(pluginPath, pluginTempPath); + File.Copy(pluginPath, pluginTempPath, true); loadPath = pluginTempPath; #else loadPath = pluginPath; diff --git a/Unity/Assets/NativeScript/Editor/GenerateBindings.cs b/Unity/Assets/NativeScript/Editor/GenerateBindings.cs index 16da323..0855981 100644 --- a/Unity/Assets/NativeScript/Editor/GenerateBindings.cs +++ b/Unity/Assets/NativeScript/Editor/GenerateBindings.cs @@ -7067,6 +7067,7 @@ static void AppendBaseType( AppendIndent(indent, builders.CppMacros); builders.CppMacros.Append(derivedTypeTypeName.Name); builders.CppMacros.Append("(Plugin::InternalUse iu, int32_t handle);\n"); + AppendIndent(indent, builders.CppMacros); builders.CppMacros.Append('\n'); // C++ constructor definition macro @@ -7094,7 +7095,13 @@ static void AppendBaseType( AppendCppTypeFullName( baseTypeTypeName, builders.CppMacros); - builders.CppMacros.Append("(iu, handle)\n"); + builders.CppMacros.Append("(iu, handle) \\\n"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.Append("{ \\\n"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.Append("}\n"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.Append('\n'); // C++ constructor inline definition macro builders.CppMacros.Append("#define "); @@ -7123,7 +7130,83 @@ static void AppendBaseType( AppendIndent(indent, builders.CppMacros); builders.CppMacros.Append("{ \\\n"); AppendIndent(indent, builders.CppMacros); + builders.CppMacros.Append("}\n"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.Append('\n'); + + // C++ default contents declaration macro + builders.CppMacros.Append("#define "); + AppendUppercaseWithUnderscores( + derivedTypeTypeName.Namespace, + builders.CppMacros); + builders.CppMacros.Append('_'); + AppendUppercaseWithUnderscores( + derivedTypeTypeName.Name, + builders.CppMacros); + builders.CppMacros.Append("_DEFAULT_CONTENTS_DECLARATION \\\n"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.Append("void* operator new(size_t, void* p) noexcept; \\\n"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.Append("void operator delete(void*, size_t) noexcept; \\\n"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.Append('\n'); + + // C++ default contents definition macro + builders.CppMacros.Append("#define "); + AppendUppercaseWithUnderscores( + derivedTypeTypeName.Namespace, + builders.CppMacros); + builders.CppMacros.Append('_'); + AppendUppercaseWithUnderscores( + derivedTypeTypeName.Name, + builders.CppMacros); + builders.CppMacros.Append("_DEFAULT_CONTENTS_DEFINITION \\\n"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.Append("void* "); + builders.CppMacros.Append(derivedTypeTypeName.Name); + builders.CppMacros.Append("::operator new(size_t, void* p) noexcept\\\n"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.Append("{ \\\n"); + AppendIndent(indent + 1, builders.CppMacros); + builders.CppMacros.Append("return p; \\\n"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.Append("} \\\n"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.Append("void "); + builders.CppMacros.Append(derivedTypeTypeName.Name); + builders.CppMacros.Append("::operator delete(void*, size_t) noexcept \\\n"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.Append("{ \\\n"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.Append("}\n"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.Append('\n'); + + // 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.Append("_DEFAULT_CONTENTS\\\n"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.Append("void* operator new(size_t, void* p) noexcept \\\n"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.Append("{ \\\n"); + AppendIndent(indent + 1, builders.CppMacros); + builders.CppMacros.Append("return p; \\\n"); + AppendIndent(indent, builders.CppMacros); builders.CppMacros.Append("} \\\n"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.Append("void operator delete(void*, size_t) noexcept \\\n"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.Append("{ \\\n"); + AppendIndent(indent, builders.CppMacros); + builders.CppMacros.Append("}\n"); + AppendIndent(indent, builders.CppMacros); builders.CppMacros.Append('\n'); // C++ function pointers diff --git a/Unity/Assets/NativeScriptTypes.json b/Unity/Assets/NativeScriptTypes.json index b933795..c507547 100644 --- a/Unity/Assets/NativeScriptTypes.json +++ b/Unity/Assets/NativeScriptTypes.json @@ -156,6 +156,9 @@ } ] }, + { + "Name": " System.Runtime.Serialization.IDeserializationCallback" + }, { "Name": "System.Decimal", "Constructors": [ diff --git a/Unity/Packages/manifest.json b/Unity/Packages/manifest.json index 1342d0a..bc19e66 100644 --- a/Unity/Packages/manifest.json +++ b/Unity/Packages/manifest.json @@ -1,11 +1,23 @@ { "dependencies": { + "com.unity.2d.sprite": "1.0.0", + "com.unity.2d.tilemap": "1.0.0", "com.unity.ads": "2.0.8", - "com.unity.analytics": "2.0.16", - "com.unity.package-manager-ui": "1.9.11", - "com.unity.purchasing": "2.0.3", - "com.unity.textmeshpro": "1.2.4", + "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", 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 d8b1468..646b92e 100644 --- a/Unity/ProjectSettings/GraphicsSettings.asset +++ b/Unity/ProjectSettings/GraphicsSettings.asset @@ -38,6 +38,7 @@ GraphicsSettings: - {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0} - {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0} - {fileID: 16001, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 16002, guid: 0000000000000000f000000000000000, type: 0} m_PreloadedShaders: [] m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} diff --git a/Unity/ProjectSettings/ProjectSettings.asset b/Unity/ProjectSettings/ProjectSettings.asset index b6955bb..d724f15 100644 --- a/Unity/ProjectSettings/ProjectSettings.asset +++ b/Unity/ProjectSettings/ProjectSettings.asset @@ -3,10 +3,11 @@ --- !u!129 &1 PlayerSettings: m_ObjectHideFlags: 0 - serializedVersion: 14 + serializedVersion: 18 productGUID: 435980e4cf9ff4aa8b71e496e8163063 AndroidProfiler: 0 AndroidFilterTouchesWhenObscured: 0 + AndroidEnableSustainedPerformanceMode: 0 defaultScreenOrientation: 4 targetDevice: 2 useOnDemandResources: 0 @@ -51,9 +52,8 @@ PlayerSettings: m_StackTraceTypes: 010000000100000001000000010000000100000001000000 iosShowActivityIndicatorOnLoading: -1 androidShowActivityIndicatorOnLoading: -1 - tizenShowActivityIndicatorOnLoading: -1 - iosAppInBackgroundBehavior: 0 displayResolutionDialog: 1 + iosUseCustomAppBackgroundBehavior: 0 iosAllowHTTPDownload: 1 allowedAutorotateToPortrait: 1 allowedAutorotateToPortraitUpsideDown: 1 @@ -63,8 +63,10 @@ PlayerSettings: use32BitDisplayBuffer: 1 preserveFramebufferAlpha: 0 disableDepthAndStencilBuffers: 0 + androidStartInFullscreen: 1 + androidRenderOutsideSafeArea: 1 + androidUseSwappy: 0 androidBlitType: 0 - defaultIsFullScreen: 1 defaultIsNativeResolution: 1 macRetinaSupport: 1 runInBackground: 0 @@ -78,6 +80,7 @@ PlayerSettings: usePlayerLog: 1 bakeCollisionMeshes: 0 forceSingleInstance: 0 + useFlipModelSwapchain: 1 resizableWindow: 0 useMacAppStoreValidation: 0 macAppStoreCategory: public.app-category.games @@ -91,16 +94,12 @@ PlayerSettings: visibleInBackground: 0 allowFullscreenSwitch: 1 graphicsJobMode: 0 - macFullscreenMode: 2 - d3d11FullscreenMode: 1 + fullscreenMode: 1 xboxSpeechDB: 0 xboxEnableHeadOrientation: 0 xboxEnableGuest: 0 xboxEnablePIXSampling: 0 metalFramebufferOnly: 0 - n3dsDisableStereoscopicView: 0 - n3dsEnableSharedListOpt: 1 - n3dsEnableVSync: 0 xboxOneResolution: 0 xboxOneSResolution: 0 xboxOneXResolution: 3 @@ -108,18 +107,13 @@ PlayerSettings: xboxOneLoggingLevel: 1 xboxOneDisableEsram: 0 xboxOnePresentImmediateThreshold: 0 - videoMemoryForVertexBuffers: 0 - psp2PowerMode: 0 - psp2AcquireBGM: 1 - wiiUTVResolution: 0 - wiiUGamePadMSAA: 1 - wiiUSupportsNunchuk: 0 - wiiUSupportsClassicController: 0 - wiiUSupportsBalanceBoard: 0 - wiiUSupportsMotionPlus: 0 - wiiUSupportsProController: 0 - wiiUAllowScreenCapture: 1 - wiiUControllerCount: 0 + switchQueueCommandMemory: 1048576 + switchQueueControlMemory: 16384 + switchQueueComputeMemory: 262144 + switchNVNShaderPoolsGranularity: 33554432 + switchNVNDefaultPoolsGranularity: 16777216 + switchNVNOtherPoolsGranularity: 16777216 + vulkanEnableSetSRGBWrite: 0 m_SupportedAspectRatios: 4:3: 1 5:4: 1 @@ -147,10 +141,20 @@ PlayerSettings: hololens: depthFormat: 1 depthBufferSharingEnabled: 0 + lumin: + depthFormat: 0 + frameTiming: 2 + enableGLCache: 0 + glCacheMaxBlobSize: 524288 + glCacheMaxFileSize: 8388608 oculus: sharedDepthBuffer: 0 dashSupport: 0 + lowOverheadMode: 0 + enable360StereoCapture: 0 + isWsaHolographicRemotingEnabled: 0 protectGraphicsMemory: 0 + enableFrameTimingStats: 0 useHDRDisplay: 0 m_ColorGamuts: 00000000 targetPixelDensity: 30 @@ -161,10 +165,10 @@ PlayerSettings: Android: com.jacksondunstan.unityplayground Standalone: unity.DefaultCompany.UnityPlayground Tizen: com.jacksondunstan.unityplayground - iOS: com.jacksondunstan.unityplayground + iPhone: com.jacksondunstan.unityplayground tvOS: com.jacksondunstan.unityplayground buildNumber: - iOS: 0 + iPhone: 0 AndroidBundleVersionCode: 1 AndroidMinSdkVersion: 16 AndroidTargetSdkVersion: 0 @@ -179,11 +183,9 @@ PlayerSettings: APKExpansionFiles: 0 keepLoadedShadersAlive: 0 StripUnusedMeshComponents: 0 - VertexChannelCompressionMask: - serializedVersion: 2 - m_Bits: 238 + VertexChannelCompressionMask: 214 iPhoneSdkVersion: 988 - iOSTargetOSVersionString: 7.0 + iOSTargetOSVersionString: 9.0 tvOSSdkVersion: 0 tvOSRequireExtendedGameController: 0 tvOSTargetOSVersionString: 9.0 @@ -205,11 +207,16 @@ PlayerSettings: iPadHighResPortraitSplashScreen: {fileID: 0} iPadLandscapeSplashScreen: {fileID: 0} iPadHighResLandscapeSplashScreen: {fileID: 0} + iPhone65inPortraitSplashScreen: {fileID: 0} + iPhone65inLandscapeSplashScreen: {fileID: 0} + iPhone61inPortraitSplashScreen: {fileID: 0} + iPhone61inLandscapeSplashScreen: {fileID: 0} appleTVSplashScreen: {fileID: 0} appleTVSplashScreen2x: {fileID: 0} tvOSSmallIconLayers: [] tvOSSmallIconLayers2x: [] tvOSLargeIconLayers: [] + tvOSLargeIconLayers2x: [] tvOSTopShelfImageLayers: [] tvOSTopShelfImageLayers2x: [] tvOSTopShelfImageWideLayers: [] @@ -243,23 +250,34 @@ PlayerSettings: appleDeveloperTeamID: iOSManualSigningProvisioningProfileID: tvOSManualSigningProvisioningProfileID: + iOSManualSigningProvisioningProfileType: 0 + tvOSManualSigningProvisioningProfileType: 0 appleEnableAutomaticSigning: 0 + iOSRequireARKit: 0 + iOSAutomaticallyDetectAndAddCapabilities: 1 + appleEnableProMotion: 0 clonedFromGUID: 00000000000000000000000000000000 - AndroidTargetDevice: 3 + templatePackageId: + templateDefaultScene: + AndroidTargetArchitectures: 1 AndroidSplashScreenScale: 0 androidSplashScreen: {fileID: 0} - AndroidKeystoreName: + AndroidKeystoreName: '{inproject}: ' AndroidKeyaliasName: + AndroidBuildApkPerCpuArchitecture: 0 AndroidTVCompatibility: 1 AndroidIsGame: 1 AndroidEnableTango: 0 androidEnableBanner: 1 androidUseLowAccuracyLocation: 0 + androidUseCustomKeystore: 0 m_AndroidBanners: - width: 320 height: 180 banner: {fileID: 0} androidGamepadSupportLevel: 0 + AndroidValidateAppBundleSize: 1 + AndroidAppBundleSizeToValidate: 150 resolutionDialogBanner: {fileID: 0} m_BuildTargetIcons: - m_BuildTarget: @@ -269,6 +287,7 @@ PlayerSettings: m_Width: 128 m_Height: 128 m_Kind: 0 + m_BuildTargetPlatformIcons: [] m_BuildTargetBatching: [] m_BuildTargetGraphicsAPIs: - m_BuildTarget: AndroidPlayer @@ -279,7 +298,7 @@ PlayerSettings: m_Enabled: 0 m_Devices: - Oculus - - m_BuildTarget: Metro + - m_BuildTarget: Windows Store Apps m_Enabled: 0 m_Devices: [] - m_BuildTarget: N3DS @@ -323,15 +342,16 @@ PlayerSettings: - m_BuildTarget: XboxOne m_Enabled: 0 m_Devices: [] - - m_BuildTarget: iOS + - m_BuildTarget: iPhone m_Enabled: 0 m_Devices: [] - m_BuildTarget: tvOS m_Enabled: 0 m_Devices: [] - m_BuildTargetEnableVuforiaSettings: [] openGLRequireES31: 0 openGLRequireES31AEP: 0 + openGLRequireES32: 0 + vuforiaEnabled: 0 m_TemplateCustomTags: {} mobileMTRendering: Android: 1 @@ -344,25 +364,9 @@ PlayerSettings: m_EncodingQuality: 1 - m_BuildTarget: PS4 m_EncodingQuality: 1 - wiiUTitleID: 0005000011000000 - wiiUGroupID: 00010000 - wiiUCommonSaveSize: 4096 - wiiUAccountSaveSize: 2048 - wiiUOlvAccessKey: 0 - wiiUTinCode: 0 - wiiUJoinGameId: 0 - wiiUJoinGameModeMask: 0000000000000000 - wiiUCommonBossSize: 0 - wiiUAccountBossSize: 0 - wiiUAddOnUniqueIDs: [] - wiiUMainThreadStackSize: 3072 - wiiULoaderThreadStackSize: 1024 - wiiUSystemHeapSize: 128 - wiiUTVStartupScreen: {fileID: 0} - wiiUGamePadStartupScreen: {fileID: 0} - wiiUDrcBufferDisabled: 0 - wiiUProfilerLibPath: + m_BuildTargetGroupLightmapSettings: [] playModeTestRunnerEnabled: 0 + runPlayModeTestAsEditModeTest: 0 actionOnDotNetUnhandledException: 1 enableInternalProfiler: 0 logObjCUncaughtExceptions: 1 @@ -482,7 +486,12 @@ PlayerSettings: switchAllowsVideoCapturing: 1 switchAllowsRuntimeAddOnContentInstall: 0 switchDataLossConfirmation: 0 + switchUserAccountLockEnabled: 0 + switchSystemResourceMemory: 16777216 switchSupportedNpadStyles: 3 + switchNativeFsCacheSize: 32 + switchIsHoldTypeHorizontal: 0 + switchSupportedNpadCount: 8 switchSocketConfigEnabled: 0 switchTcpInitialSendBufferSize: 32 switchTcpInitialReceiveBufferSize: 64 @@ -532,12 +541,15 @@ PlayerSettings: ps4DownloadDataSize: 0 ps4GarlicHeapSize: 2048 ps4ProGarlicHeapSize: 2560 + playerPrefsMaxSize: 32768 ps4Passcode: 5PN2qmWqBlQ9wQj99nsQzldVI5ZuGXbE ps4pnSessions: 1 ps4pnPresence: 1 ps4pnFriends: 1 ps4pnGameCustomData: 1 playerPrefsSupport: 0 + enableApplicationExit: 0 + resetTempFolder: 1 restrictedAudioUsageRights: 0 ps4UseResolutionFallback: 0 ps4ReprojectionSupport: 0 @@ -561,56 +573,9 @@ PlayerSettings: ps4attribEyeToEyeDistanceSettingVR: 0 ps4IncludedModules: [] monoEnv: - psp2Splashimage: {fileID: 0} - psp2NPTrophyPackPath: - psp2NPSupportGBMorGJP: 0 - psp2NPAgeRating: 12 - psp2NPTitleDatPath: - psp2NPCommsID: - psp2NPCommunicationsID: - psp2NPCommsPassphrase: - psp2NPCommsSig: - psp2ParamSfxPath: - psp2ManualPath: - psp2LiveAreaGatePath: - psp2LiveAreaBackroundPath: - psp2LiveAreaPath: - psp2LiveAreaTrialPath: - psp2PatchChangeInfoPath: - psp2PatchOriginalPackage: - psp2PackagePassword: 5PN2qmWqBlQ9wQj99nsQzldVI5ZuGXbE - psp2KeystoneFile: - psp2MemoryExpansionMode: 0 - psp2DRMType: 0 - psp2StorageType: 0 - psp2MediaCapacity: 0 - psp2DLCConfigPath: - psp2ThumbnailPath: - psp2BackgroundPath: - psp2SoundPath: - psp2TrophyCommId: - psp2TrophyPackagePath: - psp2PackagedResourcesPath: - psp2SaveDataQuota: 10240 - psp2ParentalLevel: 1 - psp2ShortTitle: Not Set - psp2ContentID: IV0000-ABCD12345_00-0123456789ABCDEF - psp2Category: 0 - psp2MasterVersion: 01.00 - psp2AppVersion: 01.00 - psp2TVBootMode: 0 - psp2EnterButtonAssignment: 2 - psp2TVDisableEmu: 0 - psp2AllowTwitterDialog: 1 - psp2Upgradable: 0 - psp2HealthWarning: 0 - psp2UseLibLocation: 0 - psp2InfoBarOnStartup: 0 - psp2InfoBarColor: 0 - psp2ScriptOptimizationLevel: 0 - psmSplashimage: {fileID: 0} splashScreenBackgroundSourceLandscape: {fileID: 0} splashScreenBackgroundSourcePortrait: {fileID: 0} + blurSplashScreenBackground: 1 spritePackerPolicy: webGLMemorySize: 256 webGLExceptionSupport: 0 @@ -622,21 +587,28 @@ PlayerSettings: webGLTemplate: APPLICATION:Default webGLAnalyzeBuildSize: 0 webGLUseEmbeddedResources: 0 - webGLUseWasm: 0 webGLCompressionFormat: 1 + webGLLinkerTarget: 1 + webGLThreadsSupport: 0 + webGLWasmStreaming: 0 scriptingDefineSymbols: 1: platformArchitecture: - iOS: 0 + iPhone: 0 scriptingBackend: Android: 1 Standalone: 0 WebGL: 1 - iOS: 1 + iPhone: 1 + il2cppCompilerConfiguration: {} + managedStrippingLevel: {} incrementalIl2cppBuild: - iOS: 0 + iPhone: 0 + allowUnsafeCode: 0 additionalIl2CppArgs: - scriptingRuntimeVersion: 0 + scriptingRuntimeVersion: 1 + gcIncremental: 0 + gcWBarrierValidation: 0 apiCompatibilityLevelPerPlatform: {} m_RenderingPath: 1 m_MobileRenderingPath: 1 @@ -650,40 +622,22 @@ PlayerSettings: metroApplicationDescription: UnityPlayground wsaImages: {} metroTileShortName: - metroCommandLineArgsFile: metroTileShowName: 0 metroMediumTileShowName: 0 metroLargeTileShowName: 0 metroWideTileShowName: 0 + metroSupportStreamingInstall: 0 + metroLastRequiredScene: 0 metroDefaultTileSize: 1 metroTileForegroundText: 1 metroTileBackgroundColor: {r: 0, g: 0, b: 0, a: 1} metroSplashScreenBackgroundColor: {r: 0, g: 0, b: 0, a: 1} metroSplashScreenUseBackgroundColor: 0 platformCapabilities: {} + metroTargetDeviceFamilies: {} metroFTAName: metroFTAFileTypes: [] metroProtocolName: - metroCompilationOverrides: 1 - tizenProductDescription: - tizenProductURL: - tizenSigningProfileName: - tizenGPSPermissions: 0 - tizenMicrophonePermissions: 0 - tizenDeploymentTarget: - tizenDeploymentTargetType: -1579033 - tizenMinOSVersion: 1 - n3dsUseExtSaveData: 0 - n3dsCompressStaticMem: 1 - n3dsExtSaveDataNumber: 0x12345 - n3dsStackSize: 131072 - n3dsTargetPlatform: 2 - n3dsRegion: 7 - n3dsMediaSize: 0 - n3dsLogoStyle: 3 - n3dsTitle: GameName - n3dsProductCode: - n3dsApplicationId: 0xFF3FF XboxOneProductId: XboxOneUpdateKey: XboxOneSandboxId: @@ -693,6 +647,7 @@ PlayerSettings: XboxOneGameOsOverridePath: XboxOnePackagingOverridePath: XboxOneAppManifestOverridePath: + XboxOneVersion: 1.0.0.0 XboxOnePackageEncryption: 0 XboxOnePackageUpdateGranularity: 2 XboxOneDescription: @@ -707,7 +662,8 @@ PlayerSettings: XboxOneAllowedProductIds: [] XboxOnePersistentLocalStorageSize: 0 XboxOneXTitleMemory: 8 - xboxOneScriptCompiler: 0 + xboxOneScriptCompiler: 1 + XboxOneOverrideIdentityName: vrEditorSettings: daydream: daydreamIconForeground: {fileID: 0} @@ -722,11 +678,30 @@ PlayerSettings: Purchasing: 0 UNet: 0 Unity_Ads: 0 + luminIcon: + m_Name: + m_ModelFolderPath: + m_PortalFolderPath: + luminCert: + m_CertPath: + m_SignPackage: 1 + luminIsChannelApp: 0 + luminVersion: + m_VersionCode: 1 + m_VersionName: facebookSdkVersion: 7.9.1 - apiCompatibilityLevel: 2 + facebookAppId: + facebookCookies: 1 + facebookLogging: 1 + facebookStatus: 1 + facebookXfbml: 0 + facebookFrictionlessRequests: 1 + apiCompatibilityLevel: 6 cloudProjectId: + framebufferDepthMemorylessMode: 0 projectName: organizationId: cloudEnabled: 0 enableNativePlatformBackendsForNewInputSystem: 0 disableOldInputManagerSupport: 0 + legacyClampBlendShapeWeights: 1 diff --git a/Unity/ProjectSettings/ProjectVersion.txt b/Unity/ProjectSettings/ProjectVersion.txt index 0498f4d..7e64146 100644 --- a/Unity/ProjectSettings/ProjectVersion.txt +++ b/Unity/ProjectSettings/ProjectVersion.txt @@ -1 +1,2 @@ -m_EditorVersion: 2018.2.0f2 +m_EditorVersion: 2019.2.0f1 +m_EditorVersionWithRevision: 2019.2.0f1 (20c1667945cf) diff --git a/Unity/ProjectSettings/UnityConnectSettings.asset b/Unity/ProjectSettings/UnityConnectSettings.asset index 1cc5485..c3ae9a0 100644 --- a/Unity/ProjectSettings/UnityConnectSettings.asset +++ b/Unity/ProjectSettings/UnityConnectSettings.asset @@ -3,29 +3,29 @@ --- !u!310 &1 UnityConnectSettings: m_ObjectHideFlags: 0 - m_Enabled: 0 + serializedVersion: 1 + m_Enabled: 1 m_TestMode: 0 - m_TestEventUrl: - m_TestConfigUrl: + m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events + m_EventUrl: https://cdp.cloud.unity3d.com/v1/events + m_ConfigUrl: https://config.uca.cloud.unity3d.com m_TestInitMode: 0 CrashReportingSettings: - m_EventUrl: https://perf-events.cloud.unity3d.com/api/events/crashes + m_EventUrl: https://perf-events.cloud.unity3d.com m_Enabled: 0 + m_LogBufferSize: 10 m_CaptureEditorExceptions: 1 UnityPurchasingSettings: m_Enabled: 0 m_TestMode: 0 UnityAnalyticsSettings: m_Enabled: 0 - m_InitializeOnStartup: 1 m_TestMode: 0 - m_TestEventUrl: - m_TestConfigUrl: + m_InitializeOnStartup: 1 UnityAdsSettings: m_Enabled: 0 m_InitializeOnStartup: 1 m_TestMode: 0 - m_EnabledPlatforms: 4294967295 m_IosGameId: m_AndroidGameId: m_GameIds: {} diff --git a/Unity/ProjectSettings/VFXManager.asset b/Unity/ProjectSettings/VFXManager.asset new file mode 100644 index 0000000..6e0eaca --- /dev/null +++ b/Unity/ProjectSettings/VFXManager.asset @@ -0,0 +1,11 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!937362698 &1 +VFXManager: + m_ObjectHideFlags: 0 + m_IndirectShader: {fileID: 0} + m_CopyBufferShader: {fileID: 0} + m_SortShader: {fileID: 0} + m_RenderPipeSettingsPath: + m_FixedTimeStep: 0.016666668 + m_MaxDeltaTime: 0.05 diff --git a/Unity/ProjectSettings/XRSettings.asset b/Unity/ProjectSettings/XRSettings.asset new file mode 100644 index 0000000..482590c --- /dev/null +++ b/Unity/ProjectSettings/XRSettings.asset @@ -0,0 +1,10 @@ +{ + "m_SettingKeys": [ + "VR Device Disabled", + "VR Device User Alert" + ], + "m_SettingValues": [ + "False", + "False" + ] +} \ No newline at end of file From 5785e672b7e39448cbef9abfa425919add6969d0 Mon Sep 17 00:00:00 2001 From: Jackson Dunstan Date: Thu, 8 Aug 2019 22:37:56 -0700 Subject: [PATCH 14/36] Use IL2CPP in standalone builds --- Unity/ProjectSettings/ProjectSettings.asset | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Unity/ProjectSettings/ProjectSettings.asset b/Unity/ProjectSettings/ProjectSettings.asset index d724f15..8602e2b 100644 --- a/Unity/ProjectSettings/ProjectSettings.asset +++ b/Unity/ProjectSettings/ProjectSettings.asset @@ -597,7 +597,7 @@ PlayerSettings: iPhone: 0 scriptingBackend: Android: 1 - Standalone: 0 + Standalone: 1 WebGL: 1 iPhone: 1 il2cppCompilerConfiguration: {} From 7f61e75a460358b0cfc1b7f1c931f45204a33697 Mon Sep 17 00:00:00 2001 From: Jackson Dunstan Date: Thu, 8 Aug 2019 22:39:19 -0700 Subject: [PATCH 15/36] Omit type parameters in C++ constructor and destructor declarations. --- .../Assets/CppSource/NativeScript/Bindings.h | 270 +++++++++--------- .../NativeScript/Editor/GenerateBindings.cs | 15 - 2 files changed, 135 insertions(+), 150 deletions(-) diff --git a/Unity/Assets/CppSource/NativeScript/Bindings.h b/Unity/Assets/CppSource/NativeScript/Bindings.h index 6835b61..093dc3b 100644 --- a/Unity/Assets/CppSource/NativeScript/Bindings.h +++ b/Unity/Assets/CppSource/NativeScript/Bindings.h @@ -736,11 +736,11 @@ namespace System { template<> struct IEquatable_1 : virtual System::Object { - IEquatable_1(decltype(nullptr)); - IEquatable_1(Plugin::InternalUse, int32_t handle); - IEquatable_1(const IEquatable_1& other); - IEquatable_1(IEquatable_1&& other); - virtual ~IEquatable_1(); + IEquatable_1(decltype(nullptr)); + IEquatable_1(Plugin::InternalUse, int32_t handle); + IEquatable_1(const IEquatable_1& other); + IEquatable_1(IEquatable_1&& other); + virtual ~IEquatable_1(); IEquatable_1& operator=(const IEquatable_1& other); IEquatable_1& operator=(decltype(nullptr)); IEquatable_1& operator=(IEquatable_1&& other); @@ -753,11 +753,11 @@ namespace System { template<> struct IEquatable_1 : virtual System::Object { - IEquatable_1(decltype(nullptr)); - IEquatable_1(Plugin::InternalUse, int32_t handle); - IEquatable_1(const IEquatable_1& other); - IEquatable_1(IEquatable_1&& other); - virtual ~IEquatable_1(); + IEquatable_1(decltype(nullptr)); + IEquatable_1(Plugin::InternalUse, int32_t handle); + IEquatable_1(const IEquatable_1& other); + IEquatable_1(IEquatable_1&& other); + virtual ~IEquatable_1(); IEquatable_1& operator=(const IEquatable_1& other); IEquatable_1& operator=(decltype(nullptr)); IEquatable_1& operator=(IEquatable_1&& other); @@ -770,11 +770,11 @@ namespace System { template<> struct IEquatable_1 : virtual System::Object { - IEquatable_1(decltype(nullptr)); - IEquatable_1(Plugin::InternalUse, int32_t handle); - IEquatable_1(const IEquatable_1& other); - IEquatable_1(IEquatable_1&& other); - virtual ~IEquatable_1(); + IEquatable_1(decltype(nullptr)); + IEquatable_1(Plugin::InternalUse, int32_t handle); + IEquatable_1(const IEquatable_1& other); + IEquatable_1(IEquatable_1&& other); + virtual ~IEquatable_1(); IEquatable_1& operator=(const IEquatable_1& other); IEquatable_1& operator=(decltype(nullptr)); IEquatable_1& operator=(IEquatable_1&& other); @@ -787,11 +787,11 @@ namespace System { template<> struct IEquatable_1 : virtual System::Object { - IEquatable_1(decltype(nullptr)); - IEquatable_1(Plugin::InternalUse, int32_t handle); - IEquatable_1(const IEquatable_1& other); - IEquatable_1(IEquatable_1&& other); - virtual ~IEquatable_1(); + IEquatable_1(decltype(nullptr)); + IEquatable_1(Plugin::InternalUse, int32_t handle); + IEquatable_1(const IEquatable_1& other); + IEquatable_1(IEquatable_1&& other); + virtual ~IEquatable_1(); IEquatable_1& operator=(const IEquatable_1& other); IEquatable_1& operator=(decltype(nullptr)); IEquatable_1& operator=(IEquatable_1&& other); @@ -804,11 +804,11 @@ namespace System { template<> struct IEquatable_1 : virtual System::Object { - IEquatable_1(decltype(nullptr)); - IEquatable_1(Plugin::InternalUse, int32_t handle); - IEquatable_1(const IEquatable_1& other); - IEquatable_1(IEquatable_1&& other); - virtual ~IEquatable_1(); + IEquatable_1(decltype(nullptr)); + IEquatable_1(Plugin::InternalUse, int32_t handle); + IEquatable_1(const IEquatable_1& other); + IEquatable_1(IEquatable_1&& other); + virtual ~IEquatable_1(); IEquatable_1& operator=(const IEquatable_1& other); IEquatable_1& operator=(decltype(nullptr)); IEquatable_1& operator=(IEquatable_1&& other); @@ -821,11 +821,11 @@ namespace System { template<> struct IEquatable_1 : virtual System::Object { - IEquatable_1(decltype(nullptr)); - IEquatable_1(Plugin::InternalUse, int32_t handle); - IEquatable_1(const IEquatable_1& other); - IEquatable_1(IEquatable_1&& other); - virtual ~IEquatable_1(); + IEquatable_1(decltype(nullptr)); + IEquatable_1(Plugin::InternalUse, int32_t handle); + IEquatable_1(const IEquatable_1& other); + IEquatable_1(IEquatable_1&& other); + virtual ~IEquatable_1(); IEquatable_1& operator=(const IEquatable_1& other); IEquatable_1& operator=(decltype(nullptr)); IEquatable_1& operator=(IEquatable_1&& other); @@ -838,11 +838,11 @@ namespace System { template<> struct IEquatable_1 : virtual System::Object { - IEquatable_1(decltype(nullptr)); - IEquatable_1(Plugin::InternalUse, int32_t handle); - IEquatable_1(const IEquatable_1& other); - IEquatable_1(IEquatable_1&& other); - virtual ~IEquatable_1(); + IEquatable_1(decltype(nullptr)); + IEquatable_1(Plugin::InternalUse, int32_t handle); + IEquatable_1(const IEquatable_1& other); + IEquatable_1(IEquatable_1&& other); + virtual ~IEquatable_1(); IEquatable_1& operator=(const IEquatable_1& other); IEquatable_1& operator=(decltype(nullptr)); IEquatable_1& operator=(IEquatable_1&& other); @@ -855,11 +855,11 @@ namespace System { template<> struct IEquatable_1 : virtual System::Object { - IEquatable_1(decltype(nullptr)); - IEquatable_1(Plugin::InternalUse, int32_t handle); - IEquatable_1(const IEquatable_1& other); - IEquatable_1(IEquatable_1&& other); - virtual ~IEquatable_1(); + IEquatable_1(decltype(nullptr)); + IEquatable_1(Plugin::InternalUse, int32_t handle); + IEquatable_1(const IEquatable_1& other); + IEquatable_1(IEquatable_1&& other); + virtual ~IEquatable_1(); IEquatable_1& operator=(const IEquatable_1& other); IEquatable_1& operator=(decltype(nullptr)); IEquatable_1& operator=(IEquatable_1&& other); @@ -872,11 +872,11 @@ namespace System { template<> struct IEquatable_1 : virtual System::Object { - IEquatable_1(decltype(nullptr)); - IEquatable_1(Plugin::InternalUse, int32_t handle); - IEquatable_1(const IEquatable_1& other); - IEquatable_1(IEquatable_1&& other); - virtual ~IEquatable_1(); + IEquatable_1(decltype(nullptr)); + IEquatable_1(Plugin::InternalUse, int32_t handle); + IEquatable_1(const IEquatable_1& other); + IEquatable_1(IEquatable_1&& other); + virtual ~IEquatable_1(); IEquatable_1& operator=(const IEquatable_1& other); IEquatable_1& operator=(decltype(nullptr)); IEquatable_1& operator=(IEquatable_1&& other); @@ -889,11 +889,11 @@ namespace System { template<> struct IEquatable_1 : virtual System::Object { - IEquatable_1(decltype(nullptr)); - IEquatable_1(Plugin::InternalUse, int32_t handle); - IEquatable_1(const IEquatable_1& other); - IEquatable_1(IEquatable_1&& other); - virtual ~IEquatable_1(); + IEquatable_1(decltype(nullptr)); + IEquatable_1(Plugin::InternalUse, int32_t handle); + IEquatable_1(const IEquatable_1& other); + IEquatable_1(IEquatable_1&& other); + virtual ~IEquatable_1(); IEquatable_1& operator=(const IEquatable_1& other); IEquatable_1& operator=(decltype(nullptr)); IEquatable_1& operator=(IEquatable_1&& other); @@ -906,11 +906,11 @@ namespace System { template<> struct IEquatable_1 : virtual System::Object { - IEquatable_1(decltype(nullptr)); - IEquatable_1(Plugin::InternalUse, int32_t handle); - IEquatable_1(const IEquatable_1& other); - IEquatable_1(IEquatable_1&& other); - virtual ~IEquatable_1(); + IEquatable_1(decltype(nullptr)); + IEquatable_1(Plugin::InternalUse, int32_t handle); + IEquatable_1(const IEquatable_1& other); + IEquatable_1(IEquatable_1&& other); + virtual ~IEquatable_1(); IEquatable_1& operator=(const IEquatable_1& other); IEquatable_1& operator=(decltype(nullptr)); IEquatable_1& operator=(IEquatable_1&& other); @@ -923,11 +923,11 @@ namespace System { template<> struct IEquatable_1 : virtual System::Object { - IEquatable_1(decltype(nullptr)); - IEquatable_1(Plugin::InternalUse, int32_t handle); - IEquatable_1(const IEquatable_1& other); - IEquatable_1(IEquatable_1&& other); - virtual ~IEquatable_1(); + IEquatable_1(decltype(nullptr)); + IEquatable_1(Plugin::InternalUse, int32_t handle); + IEquatable_1(const IEquatable_1& other); + IEquatable_1(IEquatable_1&& other); + virtual ~IEquatable_1(); IEquatable_1& operator=(const IEquatable_1& other); IEquatable_1& operator=(decltype(nullptr)); IEquatable_1& operator=(IEquatable_1&& other); @@ -940,11 +940,11 @@ namespace System { template<> struct IEquatable_1 : virtual System::Object { - IEquatable_1(decltype(nullptr)); - IEquatable_1(Plugin::InternalUse, int32_t handle); - IEquatable_1(const IEquatable_1& other); - IEquatable_1(IEquatable_1&& other); - virtual ~IEquatable_1(); + IEquatable_1(decltype(nullptr)); + IEquatable_1(Plugin::InternalUse, int32_t handle); + IEquatable_1(const IEquatable_1& other); + IEquatable_1(IEquatable_1&& other); + virtual ~IEquatable_1(); IEquatable_1& operator=(const IEquatable_1& other); IEquatable_1& operator=(decltype(nullptr)); IEquatable_1& operator=(IEquatable_1&& other); @@ -957,11 +957,11 @@ namespace System { template<> struct IEquatable_1 : virtual System::Object { - IEquatable_1(decltype(nullptr)); - IEquatable_1(Plugin::InternalUse, int32_t handle); - IEquatable_1(const IEquatable_1& other); - IEquatable_1(IEquatable_1&& other); - virtual ~IEquatable_1(); + IEquatable_1(decltype(nullptr)); + IEquatable_1(Plugin::InternalUse, int32_t handle); + IEquatable_1(const IEquatable_1& other); + IEquatable_1(IEquatable_1&& other); + virtual ~IEquatable_1(); IEquatable_1& operator=(const IEquatable_1& other); IEquatable_1& operator=(decltype(nullptr)); IEquatable_1& operator=(IEquatable_1&& other); @@ -974,11 +974,11 @@ namespace System { template<> struct IComparable_1 : virtual System::Object { - IComparable_1(decltype(nullptr)); - IComparable_1(Plugin::InternalUse, int32_t handle); - IComparable_1(const IComparable_1& other); - IComparable_1(IComparable_1&& other); - virtual ~IComparable_1(); + IComparable_1(decltype(nullptr)); + IComparable_1(Plugin::InternalUse, int32_t handle); + IComparable_1(const IComparable_1& other); + IComparable_1(IComparable_1&& other); + virtual ~IComparable_1(); IComparable_1& operator=(const IComparable_1& other); IComparable_1& operator=(decltype(nullptr)); IComparable_1& operator=(IComparable_1&& other); @@ -991,11 +991,11 @@ namespace System { template<> struct IComparable_1 : virtual System::Object { - IComparable_1(decltype(nullptr)); - IComparable_1(Plugin::InternalUse, int32_t handle); - IComparable_1(const IComparable_1& other); - IComparable_1(IComparable_1&& other); - virtual ~IComparable_1(); + IComparable_1(decltype(nullptr)); + IComparable_1(Plugin::InternalUse, int32_t handle); + IComparable_1(const IComparable_1& other); + IComparable_1(IComparable_1&& other); + virtual ~IComparable_1(); IComparable_1& operator=(const IComparable_1& other); IComparable_1& operator=(decltype(nullptr)); IComparable_1& operator=(IComparable_1&& other); @@ -1008,11 +1008,11 @@ namespace System { template<> struct IComparable_1 : virtual System::Object { - IComparable_1(decltype(nullptr)); - IComparable_1(Plugin::InternalUse, int32_t handle); - IComparable_1(const IComparable_1& other); - IComparable_1(IComparable_1&& other); - virtual ~IComparable_1(); + IComparable_1(decltype(nullptr)); + IComparable_1(Plugin::InternalUse, int32_t handle); + IComparable_1(const IComparable_1& other); + IComparable_1(IComparable_1&& other); + virtual ~IComparable_1(); IComparable_1& operator=(const IComparable_1& other); IComparable_1& operator=(decltype(nullptr)); IComparable_1& operator=(IComparable_1&& other); @@ -1025,11 +1025,11 @@ namespace System { template<> struct IComparable_1 : virtual System::Object { - IComparable_1(decltype(nullptr)); - IComparable_1(Plugin::InternalUse, int32_t handle); - IComparable_1(const IComparable_1& other); - IComparable_1(IComparable_1&& other); - virtual ~IComparable_1(); + IComparable_1(decltype(nullptr)); + IComparable_1(Plugin::InternalUse, int32_t handle); + IComparable_1(const IComparable_1& other); + IComparable_1(IComparable_1&& other); + virtual ~IComparable_1(); IComparable_1& operator=(const IComparable_1& other); IComparable_1& operator=(decltype(nullptr)); IComparable_1& operator=(IComparable_1&& other); @@ -1042,11 +1042,11 @@ namespace System { template<> struct IComparable_1 : virtual System::Object { - IComparable_1(decltype(nullptr)); - IComparable_1(Plugin::InternalUse, int32_t handle); - IComparable_1(const IComparable_1& other); - IComparable_1(IComparable_1&& other); - virtual ~IComparable_1(); + IComparable_1(decltype(nullptr)); + IComparable_1(Plugin::InternalUse, int32_t handle); + IComparable_1(const IComparable_1& other); + IComparable_1(IComparable_1&& other); + virtual ~IComparable_1(); IComparable_1& operator=(const IComparable_1& other); IComparable_1& operator=(decltype(nullptr)); IComparable_1& operator=(IComparable_1&& other); @@ -1059,11 +1059,11 @@ namespace System { template<> struct IComparable_1 : virtual System::Object { - IComparable_1(decltype(nullptr)); - IComparable_1(Plugin::InternalUse, int32_t handle); - IComparable_1(const IComparable_1& other); - IComparable_1(IComparable_1&& other); - virtual ~IComparable_1(); + IComparable_1(decltype(nullptr)); + IComparable_1(Plugin::InternalUse, int32_t handle); + IComparable_1(const IComparable_1& other); + IComparable_1(IComparable_1&& other); + virtual ~IComparable_1(); IComparable_1& operator=(const IComparable_1& other); IComparable_1& operator=(decltype(nullptr)); IComparable_1& operator=(IComparable_1&& other); @@ -1076,11 +1076,11 @@ namespace System { template<> struct IComparable_1 : virtual System::Object { - IComparable_1(decltype(nullptr)); - IComparable_1(Plugin::InternalUse, int32_t handle); - IComparable_1(const IComparable_1& other); - IComparable_1(IComparable_1&& other); - virtual ~IComparable_1(); + IComparable_1(decltype(nullptr)); + IComparable_1(Plugin::InternalUse, int32_t handle); + IComparable_1(const IComparable_1& other); + IComparable_1(IComparable_1&& other); + virtual ~IComparable_1(); IComparable_1& operator=(const IComparable_1& other); IComparable_1& operator=(decltype(nullptr)); IComparable_1& operator=(IComparable_1&& other); @@ -1093,11 +1093,11 @@ namespace System { template<> struct IComparable_1 : virtual System::Object { - IComparable_1(decltype(nullptr)); - IComparable_1(Plugin::InternalUse, int32_t handle); - IComparable_1(const IComparable_1& other); - IComparable_1(IComparable_1&& other); - virtual ~IComparable_1(); + IComparable_1(decltype(nullptr)); + IComparable_1(Plugin::InternalUse, int32_t handle); + IComparable_1(const IComparable_1& other); + IComparable_1(IComparable_1&& other); + virtual ~IComparable_1(); IComparable_1& operator=(const IComparable_1& other); IComparable_1& operator=(decltype(nullptr)); IComparable_1& operator=(IComparable_1&& other); @@ -1110,11 +1110,11 @@ namespace System { template<> struct IComparable_1 : virtual System::Object { - IComparable_1(decltype(nullptr)); - IComparable_1(Plugin::InternalUse, int32_t handle); - IComparable_1(const IComparable_1& other); - IComparable_1(IComparable_1&& other); - virtual ~IComparable_1(); + IComparable_1(decltype(nullptr)); + IComparable_1(Plugin::InternalUse, int32_t handle); + IComparable_1(const IComparable_1& other); + IComparable_1(IComparable_1&& other); + virtual ~IComparable_1(); IComparable_1& operator=(const IComparable_1& other); IComparable_1& operator=(decltype(nullptr)); IComparable_1& operator=(IComparable_1&& other); @@ -1127,11 +1127,11 @@ namespace System { template<> struct IComparable_1 : virtual System::Object { - IComparable_1(decltype(nullptr)); - IComparable_1(Plugin::InternalUse, int32_t handle); - IComparable_1(const IComparable_1& other); - IComparable_1(IComparable_1&& other); - virtual ~IComparable_1(); + IComparable_1(decltype(nullptr)); + IComparable_1(Plugin::InternalUse, int32_t handle); + IComparable_1(const IComparable_1& other); + IComparable_1(IComparable_1&& other); + virtual ~IComparable_1(); IComparable_1& operator=(const IComparable_1& other); IComparable_1& operator=(decltype(nullptr)); IComparable_1& operator=(IComparable_1&& other); @@ -1144,11 +1144,11 @@ namespace System { template<> struct IComparable_1 : virtual System::Object { - IComparable_1(decltype(nullptr)); - IComparable_1(Plugin::InternalUse, int32_t handle); - IComparable_1(const IComparable_1& other); - IComparable_1(IComparable_1&& other); - virtual ~IComparable_1(); + IComparable_1(decltype(nullptr)); + IComparable_1(Plugin::InternalUse, int32_t handle); + IComparable_1(const IComparable_1& other); + IComparable_1(IComparable_1&& other); + virtual ~IComparable_1(); IComparable_1& operator=(const IComparable_1& other); IComparable_1& operator=(decltype(nullptr)); IComparable_1& operator=(IComparable_1&& other); @@ -1161,11 +1161,11 @@ namespace System { template<> struct IComparable_1 : virtual System::Object { - IComparable_1(decltype(nullptr)); - IComparable_1(Plugin::InternalUse, int32_t handle); - IComparable_1(const IComparable_1& other); - IComparable_1(IComparable_1&& other); - virtual ~IComparable_1(); + IComparable_1(decltype(nullptr)); + IComparable_1(Plugin::InternalUse, int32_t handle); + IComparable_1(const IComparable_1& other); + IComparable_1(IComparable_1&& other); + virtual ~IComparable_1(); IComparable_1& operator=(const IComparable_1& other); IComparable_1& operator=(decltype(nullptr)); IComparable_1& operator=(IComparable_1&& other); @@ -1178,11 +1178,11 @@ namespace System { template<> struct IComparable_1 : virtual System::Object { - IComparable_1(decltype(nullptr)); - IComparable_1(Plugin::InternalUse, int32_t handle); - IComparable_1(const IComparable_1& other); - IComparable_1(IComparable_1&& other); - virtual ~IComparable_1(); + IComparable_1(decltype(nullptr)); + IComparable_1(Plugin::InternalUse, int32_t handle); + IComparable_1(const IComparable_1& other); + IComparable_1(IComparable_1&& other); + virtual ~IComparable_1(); IComparable_1& operator=(const IComparable_1& other); IComparable_1& operator=(decltype(nullptr)); IComparable_1& operator=(IComparable_1&& other); diff --git a/Unity/Assets/NativeScript/Editor/GenerateBindings.cs b/Unity/Assets/NativeScript/Editor/GenerateBindings.cs index 0855981..b3bdfd5 100644 --- a/Unity/Assets/NativeScript/Editor/GenerateBindings.cs +++ b/Unity/Assets/NativeScript/Editor/GenerateBindings.cs @@ -11327,9 +11327,6 @@ static void AppendCppTypeDefinitionBegin( AppendCppTypeName( typeTypeName, output); - AppendCppTypeParameters( - typeParams, - output); output.Append("(decltype(nullptr));\n"); // Constructor from handle @@ -11337,9 +11334,6 @@ static void AppendCppTypeDefinitionBegin( AppendCppTypeName( typeTypeName, output); - AppendCppTypeParameters( - typeParams, - output); output.Append( "(Plugin::InternalUse, int32_t handle);\n"); @@ -11348,9 +11342,6 @@ static void AppendCppTypeDefinitionBegin( AppendCppTypeName( typeTypeName, output); - AppendCppTypeParameters( - typeParams, - output); output.Append("(const "); AppendCppTypeName( typeTypeName, @@ -11365,9 +11356,6 @@ static void AppendCppTypeDefinitionBegin( AppendCppTypeName( typeTypeName, output); - AppendCppTypeParameters( - typeParams, - output); output.Append('('); AppendCppTypeName( typeTypeName, @@ -11383,9 +11371,6 @@ static void AppendCppTypeDefinitionBegin( AppendCppTypeName( typeTypeName, output); - AppendCppTypeParameters( - typeParams, - output); output.Append("();\n"); // Assignment operator to same type From efcc9491a1d9bf1296b315a2263eb8ddcade56f9 Mon Sep 17 00:00:00 2001 From: Jackson Dunstan Date: Thu, 8 Aug 2019 22:40:33 -0700 Subject: [PATCH 16/36] Use Cdecl calling convention for all [DllImport] Add [UnmanagedFunctionPointer] to all binding function delegates with Cdecl calling convention --- Unity/Assets/NativeScript/Bindings.cs | 89 ++++++++++++++++--- .../NativeScript/Editor/GenerateBindings.cs | 4 +- 2 files changed, 80 insertions(+), 13 deletions(-) diff --git a/Unity/Assets/NativeScript/Bindings.cs b/Unity/Assets/NativeScript/Bindings.cs index bb6745d..07fbb24 100644 --- a/Unity/Assets/NativeScript/Bindings.cs +++ b/Unity/Assets/NativeScript/Bindings.cs @@ -327,40 +327,46 @@ enum InitMode : byte // Handle to the C++ DLL static IntPtr libraryHandle; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] delegate void InitDelegate( IntPtr memory, int memorySize, InitMode initMode); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void SetCsharpExceptionDelegate(int handle); /*BEGIN CPP DELEGATES*/ + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate int NewBaseBallScriptDelegateType(int param0); public static NewBaseBallScriptDelegateType NewBaseBallScript; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void DestroyBaseBallScriptDelegateType(int param0); public static DestroyBaseBallScriptDelegateType DestroyBaseBallScript; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void MyGameAbstractBaseBallScriptUpdateDelegateType(int thisHandle); public static MyGameAbstractBaseBallScriptUpdateDelegateType MyGameAbstractBaseBallScriptUpdate; + [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); @@ -395,16 +401,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); @@ -437,86 +443,145 @@ static T GetDelegate( typeof(T)) as T; } #else - [DllImport(PLUGIN_NAME)] + [DllImport(PLUGIN_NAME, CallingConvention = CallingConvention.Cdecl)] static extern void Init( IntPtr memory, int memorySize, InitMode initMode); - [DllImport(PLUGIN_NAME)] + [DllImport(PLUGIN_NAME, CallingConvention = CallingConvention.Cdecl)] static extern void SetCsharpException(int handle); /*BEGIN IMPORTS*/ - [DllImport(PLUGIN_NAME)] + [DllImport(PLUGIN_NAME, CallingConvention = CallingConvention.Cdecl)] public static extern int NewBaseBallScript(int thisHandle); - [DllImport(PLUGIN_NAME)] + [DllImport(PLUGIN_NAME, CallingConvention = CallingConvention.Cdecl)] public static extern void DestroyBaseBallScript(int thisHandle); - [DllImport(PLUGIN_NAME)] + [DllImport(PLUGIN_NAME, CallingConvention = CallingConvention.Cdecl)] public static extern void MyGameAbstractBaseBallScriptUpdate(int thisHandle); - [DllImport(PLUGIN_NAME)] + [DllImport(PLUGIN_NAME, CallingConvention = CallingConvention.Cdecl)] public static extern void SetCsharpExceptionSystemNullReferenceException(int thisHandle); /*END IMPORTS*/ #endif + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] delegate void ReleaseObjectDelegateType(int handle); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] delegate int StringNewDelegateType(string chars); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] delegate void SetExceptionDelegateType(int handle); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] delegate int ArrayGetLengthDelegateType(int handle); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] delegate int EnumerableGetEnumeratorDelegateType(int handle); /*BEGIN DELEGATE TYPES*/ + [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*/ diff --git a/Unity/Assets/NativeScript/Editor/GenerateBindings.cs b/Unity/Assets/NativeScript/Editor/GenerateBindings.cs index b3bdfd5..bc971d4 100644 --- a/Unity/Assets/NativeScript/Editor/GenerateBindings.cs +++ b/Unity/Assets/NativeScript/Editor/GenerateBindings.cs @@ -10397,6 +10397,7 @@ static void AppendCsharpDelegate( TypeKind returnTypeKind, StringBuilder output) { + output.Append("\t\t[UnmanagedFunctionPointer(CallingConvention.Cdecl)]\n"); output.Append("\t\tpublic delegate "); if (returnType == typeof(void)) { @@ -10527,7 +10528,7 @@ static void AppendCsharpImport( StringBuilder output ) { - output.Append("\t\t[DllImport(PLUGIN_NAME)]\n"); + output.Append("\t\t[DllImport(PLUGIN_NAME, CallingConvention = CallingConvention.Cdecl)]\n"); output.Append("\t\tpublic static extern "); AppendCsharpTypeFullName(returnType, output); output.Append(' '); @@ -12044,6 +12045,7 @@ static void AppendCsharpDelegateType( ParameterInfo[] parameters, StringBuilder output) { + output.Append("\t\t[UnmanagedFunctionPointer(CallingConvention.Cdecl)]\n"); output.Append("\t\tdelegate "); // Return type From 74d7d4a93c1d63c029fdff3bb522da779a98e402 Mon Sep 17 00:00:00 2001 From: Jackson Dunstan Date: Sat, 10 Aug 2019 17:49:51 -0700 Subject: [PATCH 17/36] Close the native library when the editor state changes back to edit mode rather than in OnApplicationQuit, which can be called before other MonoBehaviour messages like OnDestroy. --- Unity/Assets/NativeScript/BootScript.cs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Unity/Assets/NativeScript/BootScript.cs b/Unity/Assets/NativeScript/BootScript.cs index 9296ee7..74c8268 100644 --- a/Unity/Assets/NativeScript/BootScript.cs +++ b/Unity/Assets/NativeScript/BootScript.cs @@ -1,3 +1,5 @@ +using System; +using UnityEditor; using UnityEngine; namespace NativeScript @@ -25,6 +27,7 @@ public class BootScript : MonoBehaviour public float AutoReloadPollTime = 1.0f; private float lastAutoReloadPollTime; private Coroutine autoReloadCoroutine; + private Action onPlayModeStateChange; #endif void Start() @@ -34,6 +37,10 @@ void Start() #endif DontDestroyOnLoad(gameObject); Bindings.Open(MemorySize); +#if UNITY_EDITOR + onPlayModeStateChange = OnEditorStateChanged; + EditorApplication.playModeStateChanged += onPlayModeStateChange; +#endif } #if UNITY_EDITOR @@ -74,11 +81,15 @@ void Update() } } } -#endif - - void OnApplicationQuit() + + private void OnEditorStateChanged(PlayModeStateChange state) { - Bindings.Close(); + if (state == PlayModeStateChange.EnteredEditMode) + { + EditorApplication.playModeStateChanged -= onPlayModeStateChange; + Bindings.Close(); + } } +#endif } } \ No newline at end of file From b508933669b0c6de493996bce9d52470ba5b699c Mon Sep 17 00:00:00 2001 From: Jackson Dunstan Date: Fri, 23 Aug 2019 18:54:33 -0700 Subject: [PATCH 18/36] Fix issue #29 by returning primitive types in binding functions rather than struct types (e.g. int32_t instead of System::Int32). --- .../CppSource/NativeScript/Bindings.cpp | 44 +++++++++---------- .../NativeScript/Editor/GenerateBindings.cs | 4 ++ 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/Unity/Assets/CppSource/NativeScript/Bindings.cpp b/Unity/Assets/CppSource/NativeScript/Bindings.cpp index b8246ad..cd62a88 100644 --- a/Unity/Assets/CppSource/NativeScript/Bindings.cpp +++ b/Unity/Assets/CppSource/NativeScript/Bindings.cpp @@ -64,33 +64,33 @@ namespace Plugin int32_t (*SystemExceptionConstructorSystemString)(int32_t messageHandle); int32_t (*BoxPrimitiveType)(UnityEngine::PrimitiveType val); UnityEngine::PrimitiveType (*UnboxPrimitiveType)(int32_t valHandle); - System::Single (*UnityEngineTimePropertyGetDeltaTime)(); + float (*UnityEngineTimePropertyGetDeltaTime)(); void (*ReleaseBaseBallScript)(int32_t handle); void (*BaseBallScriptConstructor)(int32_t cppHandle, int32_t* handle); int32_t (*BoxBoolean)(uint32_t val); int32_t (*UnboxBoolean)(int32_t valHandle); int32_t (*BoxSByte)(int8_t val); - System::SByte (*UnboxSByte)(int32_t valHandle); + int8_t (*UnboxSByte)(int32_t valHandle); int32_t (*BoxByte)(uint8_t val); - System::Byte (*UnboxByte)(int32_t valHandle); + uint8_t (*UnboxByte)(int32_t valHandle); int32_t (*BoxInt16)(int16_t val); - System::Int16 (*UnboxInt16)(int32_t valHandle); + int16_t (*UnboxInt16)(int32_t valHandle); int32_t (*BoxUInt16)(uint16_t val); - System::UInt16 (*UnboxUInt16)(int32_t valHandle); + uint16_t (*UnboxUInt16)(int32_t valHandle); int32_t (*BoxInt32)(int32_t val); - System::Int32 (*UnboxInt32)(int32_t valHandle); + int32_t (*UnboxInt32)(int32_t valHandle); int32_t (*BoxUInt32)(uint32_t val); - System::UInt32 (*UnboxUInt32)(int32_t valHandle); + uint32_t (*UnboxUInt32)(int32_t valHandle); int32_t (*BoxInt64)(int64_t val); - System::Int64 (*UnboxInt64)(int32_t valHandle); + int64_t (*UnboxInt64)(int32_t valHandle); int32_t (*BoxUInt64)(uint64_t val); - System::UInt64 (*UnboxUInt64)(int32_t valHandle); + uint64_t (*UnboxUInt64)(int32_t valHandle); int32_t (*BoxChar)(uint16_t val); int16_t (*UnboxChar)(int32_t valHandle); int32_t (*BoxSingle)(float val); - System::Single (*UnboxSingle)(int32_t valHandle); + float (*UnboxSingle)(int32_t valHandle); int32_t (*BoxDouble)(double val); - System::Double (*UnboxDouble)(int32_t valHandle); + double (*UnboxDouble)(int32_t valHandle); /*END FUNCTION POINTERS*/ } @@ -6209,7 +6209,7 @@ DLLEXPORT void Init( curMemory += sizeof(Plugin::BoxPrimitiveType); Plugin::UnboxPrimitiveType = *(UnityEngine::PrimitiveType (**)(int32_t valHandle))curMemory; curMemory += sizeof(Plugin::UnboxPrimitiveType); - Plugin::UnityEngineTimePropertyGetDeltaTime = *(System::Single (**)())curMemory; + Plugin::UnityEngineTimePropertyGetDeltaTime = *(float (**)())curMemory; curMemory += sizeof(Plugin::UnityEngineTimePropertyGetDeltaTime); Plugin::ReleaseBaseBallScript = *(void (**)(int32_t handle))curMemory; curMemory += sizeof(Plugin::ReleaseBaseBallScript); @@ -6221,35 +6221,35 @@ DLLEXPORT void Init( curMemory += sizeof(Plugin::UnboxBoolean); Plugin::BoxSByte = *(int32_t (**)(int8_t val))curMemory; curMemory += sizeof(Plugin::BoxSByte); - Plugin::UnboxSByte = *(System::SByte (**)(int32_t valHandle))curMemory; + 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 = *(System::Byte (**)(int32_t valHandle))curMemory; + 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 = *(System::Int16 (**)(int32_t valHandle))curMemory; + 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 = *(System::UInt16 (**)(int32_t valHandle))curMemory; + 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 = *(System::Int32 (**)(int32_t valHandle))curMemory; + 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 = *(System::UInt32 (**)(int32_t valHandle))curMemory; + 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 = *(System::Int64 (**)(int32_t valHandle))curMemory; + 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 = *(System::UInt64 (**)(int32_t valHandle))curMemory; + Plugin::UnboxUInt64 = *(uint64_t (**)(int32_t valHandle))curMemory; curMemory += sizeof(Plugin::UnboxUInt64); Plugin::BoxChar = *(int32_t (**)(uint16_t val))curMemory; curMemory += sizeof(Plugin::BoxChar); @@ -6257,11 +6257,11 @@ DLLEXPORT void Init( curMemory += sizeof(Plugin::UnboxChar); Plugin::BoxSingle = *(int32_t (**)(float val))curMemory; curMemory += sizeof(Plugin::BoxSingle); - Plugin::UnboxSingle = *(System::Single (**)(int32_t valHandle))curMemory; + Plugin::UnboxSingle = *(float (**)(int32_t valHandle))curMemory; curMemory += sizeof(Plugin::UnboxSingle); Plugin::BoxDouble = *(int32_t (**)(double val))curMemory; curMemory += sizeof(Plugin::BoxDouble); - Plugin::UnboxDouble = *(System::Double (**)(int32_t valHandle))curMemory; + Plugin::UnboxDouble = *(double (**)(int32_t valHandle))curMemory; curMemory += sizeof(Plugin::UnboxDouble); /*END INIT BODY PARAMETER READS*/ diff --git a/Unity/Assets/NativeScript/Editor/GenerateBindings.cs b/Unity/Assets/NativeScript/Editor/GenerateBindings.cs index bc971d4..7e56758 100644 --- a/Unity/Assets/NativeScript/Editor/GenerateBindings.cs +++ b/Unity/Assets/NativeScript/Editor/GenerateBindings.cs @@ -12918,6 +12918,10 @@ static void AppendCppFunctionPointer( // C linkage requires us to use primitive types output.Append("int16_t"); } + else if (returnType.IsPrimitive) + { + AppendCppPrimitiveTypeName(returnType, output); + } else if (IsFullValueType(returnType)) { AppendCppTypeFullName(returnType, output); From 2a28a2466ed7da1e5857959110d77eee89249a7b Mon Sep 17 00:00:00 2001 From: = Date: Mon, 13 Jan 2020 22:01:55 -0600 Subject: [PATCH 19/36] [#51] Fix performance issue with Object Store When BaseMaxSimultaneous was set to a large number the object-store was spending to much time finding the handle. This was fixed using a dictionary where the keys have the objects full hash. --- Unity/Assets/NativeScript/Bindings.cs | 85 +++++++-------------------- 1 file changed, 20 insertions(+), 65 deletions(-) diff --git a/Unity/Assets/NativeScript/Bindings.cs b/Unity/Assets/NativeScript/Bindings.cs index 07fbb24..4e694ee 100644 --- a/Unity/Assets/NativeScript/Bindings.cs +++ b/Unity/Assets/NativeScript/Bindings.cs @@ -4,6 +4,7 @@ using System.Collections; using System.IO; using System.Runtime.InteropServices; +using System.Collections.Generic; using UnityEngine; @@ -24,19 +25,13 @@ public static class Bindings // Holds objects and provides handles to them in the form of ints public static class ObjectStore { + static Dictionary handleLookupByHash; + static Dictionary hashLookupByHandle; + static Stack freeHandleStack; + // Stored objects. The first is never used so 0 can be "null". static object[] objects; - // 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; @@ -49,19 +44,13 @@ public static void Init(int maxObjects) objects = new object[maxObjects + 1]; // Initialize the handles stack as 1, 2, 3, ... - handles = new int[maxObjects]; for ( int i = 0, handle = maxObjects; i < maxObjects; ++i, --handle) { - handles[i] = handle; + freeHandleStack.Push(handle); } - nextHandleIndex = maxObjects - 1; - - // Initialize the hash table - keys = new object[maxObjects]; - values = new int[maxObjects]; } public static int Store(object obj) @@ -75,27 +64,15 @@ public static int Store(object obj) lock (objects) { // Pop a handle off the stack - int handle = handles[nextHandleIndex]; - nextHandleIndex--; + int handle = freeHandleStack.Pop(); // 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); + uint hash = (uint)obj.GetHashCode(); + handleLookupByHash.Add(hash, handle); + hashLookupByHandle.Add(handle, hash); return handle; } @@ -108,6 +85,7 @@ public static object Get(int handle) public static int GetHandle(object obj) { + // Null is always zero if (object.ReferenceEquals(obj, null)) { @@ -116,19 +94,12 @@ 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 + // Look up the handle in the hash table + uint hash = (uint)obj.GetHashCode(); + if (handleLookupByHash.ContainsKey(hash)) { - if (object.ReferenceEquals(keys[index], obj)) - { - return values[index]; - } - index = (index + 1) % maxObjects; + return handleLookupByHash[hash]; } - while (index != initialIndex); } // Object not found @@ -150,28 +121,12 @@ public static object Remove(int handle) objects[handle] = null; // Push the handle onto the stack - nextHandleIndex++; - handles[nextHandleIndex] = handle; + freeHandleStack.Push(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 hash dictionary's + var hash = hashLookupByHandle[handle]; + handleLookupByHash.Remove(hash); + hashLookupByHandle.Remove(handle); return obj; } From 42116abf8aac16be2df63c20f56aa0fb19a11b02 Mon Sep 17 00:00:00 2001 From: = Date: Tue, 14 Jan 2020 00:50:14 -0600 Subject: [PATCH 20/36] [#51] add cache construction in the init method --- Unity/Assets/NativeScript/Bindings.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Unity/Assets/NativeScript/Bindings.cs b/Unity/Assets/NativeScript/Bindings.cs index 4e694ee..8ea312b 100644 --- a/Unity/Assets/NativeScript/Bindings.cs +++ b/Unity/Assets/NativeScript/Bindings.cs @@ -38,6 +38,9 @@ public static class ObjectStore public static void Init(int maxObjects) { ObjectStore.maxObjects = maxObjects; + handleLookupByHash = new Dictionary (); + hashLookupByHandle = new Dictionary (); + freeHandleStack = new Stack (); // Initialize the objects as all null plus room for the // first to always be null. From afd3c8e2bdc992c4639eb42a475bf70aa95a6724 Mon Sep 17 00:00:00 2001 From: = Date: Tue, 14 Jan 2020 23:48:48 -0600 Subject: [PATCH 21/36] [#51] Add collision handling for object store --- Unity/Assets/NativeScript/Bindings.cs | 73 ++++++++++++++++++++------- 1 file changed, 54 insertions(+), 19 deletions(-) diff --git a/Unity/Assets/NativeScript/Bindings.cs b/Unity/Assets/NativeScript/Bindings.cs index 8ea312b..3310650 100644 --- a/Unity/Assets/NativeScript/Bindings.cs +++ b/Unity/Assets/NativeScript/Bindings.cs @@ -25,9 +25,10 @@ public static class Bindings // Holds objects and provides handles to them in the form of ints public static class ObjectStore { - static Dictionary handleLookupByHash; + static Dictionary> handleBucketByHash; static Dictionary hashLookupByHandle; - static Stack freeHandleStack; + static HashSet hash; + static Stack handles; // Stored objects. The first is never used so 0 can be "null". static object[] objects; @@ -38,9 +39,9 @@ public static class ObjectStore public static void Init(int maxObjects) { ObjectStore.maxObjects = maxObjects; - handleLookupByHash = new Dictionary (); + handleBucketByHash = new Dictionary> (); hashLookupByHandle = new Dictionary (); - freeHandleStack = new Stack (); + handles = new Stack (); // Initialize the objects as all null plus room for the // first to always be null. @@ -52,7 +53,7 @@ public static void Init(int maxObjects) i < maxObjects; ++i, --handle) { - freeHandleStack.Push(handle); + handles.Push(handle); } } @@ -66,16 +67,28 @@ public static int Store(object obj) lock (objects) { + // Get the hash of the object + uint hash = (uint)obj.GetHashCode(); + // Pop a handle off the stack - int handle = freeHandleStack.Pop(); + int handle = handles.Pop(); // Store the object objects[handle] = obj; - - // Insert into the hash table - uint hash = (uint)obj.GetHashCode(); - handleLookupByHash.Add(hash, handle); - hashLookupByHandle.Add(handle, hash); + + List handleBucket = null; + + // Create new handle bucket if it does not exist + if (!handleBucketByHash.TryGetValue(hash, out handleBucket)) + { + handleBucket = new List (); + handleBucketByHash[hash] = handleBucket; + } + + // Insert into hash table + handleBucket.Add(handle); + + hashLookupByHandle[handle] = hash; return handle; } @@ -88,7 +101,6 @@ public static object Get(int handle) public static int GetHandle(object obj) { - // Null is always zero if (object.ReferenceEquals(obj, null)) { @@ -99,9 +111,20 @@ public static int GetHandle(object obj) { // Look up the handle in the hash table uint hash = (uint)obj.GetHashCode(); - if (handleLookupByHash.ContainsKey(hash)) + List handleBucket = null; + + if (handleBucketByHash.TryGetValue(hash, out handleBucket)) { - return handleLookupByHash[hash]; + for (int i = 0; i < handleBucket.Count; i++) + { + int handleInBucket = handleBucket[i]; + object objectInBucket = objects[handleInBucket]; + + if (object.ReferenceEquals(objectInBucket, obj)) + { + return handleInBucket; + } + } } } @@ -124,12 +147,24 @@ public static object Remove(int handle) objects[handle] = null; // Push the handle onto the stack - freeHandleStack.Push(handle); - + handles.Push(handle); + + uint hash = hashLookupByHandle[handle]; + List handleBucket = null; + // Remove the object from the hash dictionary's - var hash = hashLookupByHandle[handle]; - handleLookupByHash.Remove(hash); - hashLookupByHandle.Remove(handle); + if (handleBucketByHash.TryGetValue(hash, out handleBucket)) + { + for (int i = 0; i < handleBucket.Count; i++) + { + int handleInBucket = handleBucket[i]; + if (handleInBucket == handle) + { + handleBucket.RemoveAt(i); + break; + } + } + } return obj; } From 3b519ac840c0a8eed9ca6acbc307d4cadb63ad08 Mon Sep 17 00:00:00 2001 From: = Date: Wed, 15 Jan 2020 19:32:32 -0600 Subject: [PATCH 22/36] [#51] change object-store to use a dictionary to cache objects Dictionary will take care of hashing/collisions for us. --- Unity/Assets/NativeScript/Bindings.cs | 67 ++++++--------------------- 1 file changed, 14 insertions(+), 53 deletions(-) diff --git a/Unity/Assets/NativeScript/Bindings.cs b/Unity/Assets/NativeScript/Bindings.cs index 3310650..3f83a8e 100644 --- a/Unity/Assets/NativeScript/Bindings.cs +++ b/Unity/Assets/NativeScript/Bindings.cs @@ -25,9 +25,10 @@ public static class Bindings // Holds objects and provides handles to them in the form of ints public static class ObjectStore { - static Dictionary> handleBucketByHash; - static Dictionary hashLookupByHandle; - static HashSet hash; + // Lookup handles by object. + static Dictionary objectHandleCache; + + // Stack of available handles. static Stack handles; // Stored objects. The first is never used so 0 can be "null". @@ -39,9 +40,8 @@ public static class ObjectStore public static void Init(int maxObjects) { ObjectStore.maxObjects = maxObjects; - handleBucketByHash = new Dictionary> (); - hashLookupByHandle = new Dictionary (); - handles = new Stack (); + objectHandleCache = new Dictionary (maxObjects); + handles = new Stack (maxObjects); // Initialize the objects as all null plus room for the // first to always be null. @@ -67,28 +67,12 @@ public static int Store(object obj) lock (objects) { - // Get the hash of the object - uint hash = (uint)obj.GetHashCode(); - // Pop a handle off the stack int handle = handles.Pop(); // Store the object objects[handle] = obj; - - List handleBucket = null; - - // Create new handle bucket if it does not exist - if (!handleBucketByHash.TryGetValue(hash, out handleBucket)) - { - handleBucket = new List (); - handleBucketByHash[hash] = handleBucket; - } - - // Insert into hash table - handleBucket.Add(handle); - - hashLookupByHandle[handle] = hash; + objectHandleCache.Add(obj, handle); return handle; } @@ -109,22 +93,13 @@ public static int GetHandle(object obj) lock (objects) { - // Look up the handle in the hash table - uint hash = (uint)obj.GetHashCode(); - List handleBucket = null; + // A handle with a value of 0 is NULL + int handle = 0; - if (handleBucketByHash.TryGetValue(hash, out handleBucket)) + // Get handle from object cache + if (objectHandleCache.TryGetValue(obj, out handle)) { - for (int i = 0; i < handleBucket.Count; i++) - { - int handleInBucket = handleBucket[i]; - object objectInBucket = objects[handleInBucket]; - - if (object.ReferenceEquals(objectInBucket, obj)) - { - return handleInBucket; - } - } + return handle; } } @@ -149,22 +124,8 @@ public static object Remove(int handle) // Push the handle onto the stack handles.Push(handle); - uint hash = hashLookupByHandle[handle]; - List handleBucket = null; - - // Remove the object from the hash dictionary's - if (handleBucketByHash.TryGetValue(hash, out handleBucket)) - { - for (int i = 0; i < handleBucket.Count; i++) - { - int handleInBucket = handleBucket[i]; - if (handleInBucket == handle) - { - handleBucket.RemoveAt(i); - break; - } - } - } + // Remove the object from the cache + objectHandleCache.Remove(obj); return obj; } From bfaf5ee167308ce330c6a72b7a3614f31666a7b6 Mon Sep 17 00:00:00 2001 From: = Date: Sat, 18 Jan 2020 16:05:23 -0600 Subject: [PATCH 23/36] [#51] fix formatting and remove unnecessary variable initialization --- Unity/Assets/NativeScript/Bindings.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Unity/Assets/NativeScript/Bindings.cs b/Unity/Assets/NativeScript/Bindings.cs index 3f83a8e..72a594a 100644 --- a/Unity/Assets/NativeScript/Bindings.cs +++ b/Unity/Assets/NativeScript/Bindings.cs @@ -40,7 +40,7 @@ public static class ObjectStore public static void Init(int maxObjects) { ObjectStore.maxObjects = maxObjects; - objectHandleCache = new Dictionary (maxObjects); + objectHandleCache = new Dictionary(maxObjects); handles = new Stack (maxObjects); // Initialize the objects as all null plus room for the @@ -93,8 +93,7 @@ public static int GetHandle(object obj) lock (objects) { - // A handle with a value of 0 is NULL - int handle = 0; + int handle; // Get handle from object cache if (objectHandleCache.TryGetValue(obj, out handle)) From 0a6bdb00f5d6cd5d42c9fcfbce758bc5fcdcab6d Mon Sep 17 00:00:00 2001 From: = Date: Sat, 18 Jan 2020 16:26:34 -0600 Subject: [PATCH 24/36] [#51] Revert ObjectStore handles code to original implementation --- Unity/Assets/NativeScript/Bindings.cs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Unity/Assets/NativeScript/Bindings.cs b/Unity/Assets/NativeScript/Bindings.cs index 72a594a..04aef29 100644 --- a/Unity/Assets/NativeScript/Bindings.cs +++ b/Unity/Assets/NativeScript/Bindings.cs @@ -28,11 +28,14 @@ public static class ObjectStore // Lookup handles by object. static Dictionary objectHandleCache; - // Stack of available handles. - static Stack handles; - // Stored objects. The first is never used so 0 can be "null". static object[] objects; + + // Stack of available handles. + static int[] handles; + + // Index of the next available handle + static int nextHandleIndex; // The maximum number of objects to store. Must be positive. static int maxObjects; @@ -41,20 +44,21 @@ public static void Init(int maxObjects) { ObjectStore.maxObjects = maxObjects; objectHandleCache = new Dictionary(maxObjects); - handles = new Stack (maxObjects); // Initialize the objects as all null plus room for the // first to always be null. objects = new object[maxObjects + 1]; // Initialize the handles stack as 1, 2, 3, ... + handles = new int[maxObjects]; for ( int i = 0, handle = maxObjects; i < maxObjects; ++i, --handle) { - handles.Push(handle); + handles[i] = handle; } + nextHandleIndex = maxObjects - 1; } public static int Store(object obj) @@ -68,7 +72,8 @@ public static int Store(object obj) lock (objects) { // Pop a handle off the stack - int handle = handles.Pop(); + int handle = handles[nextHandleIndex]; + nextHandleIndex--; // Store the object objects[handle] = obj; @@ -121,7 +126,8 @@ public static object Remove(int handle) objects[handle] = null; // Push the handle onto the stack - handles.Push(handle); + nextHandleIndex++; + handles[nextHandleIndex] = handle; // Remove the object from the cache objectHandleCache.Remove(obj); From 1c0b627801613a5ffc9c34d653ce5e9c43bfe802 Mon Sep 17 00:00:00 2001 From: = Date: Sat, 18 Jan 2020 16:28:55 -0600 Subject: [PATCH 25/36] [#51] fix minor formatting error --- Unity/Assets/NativeScript/Bindings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Unity/Assets/NativeScript/Bindings.cs b/Unity/Assets/NativeScript/Bindings.cs index 04aef29..72ac143 100644 --- a/Unity/Assets/NativeScript/Bindings.cs +++ b/Unity/Assets/NativeScript/Bindings.cs @@ -36,7 +36,7 @@ public static class ObjectStore // Index of the next available handle static int nextHandleIndex; - + // The maximum number of objects to store. Must be positive. static int maxObjects; From 5f0e56f7c48bdcc71f419740c22a744f0b4b7383 Mon Sep 17 00:00:00 2001 From: Jackson Dunstan Date: Sat, 25 Jan 2020 15:43:44 -0800 Subject: [PATCH 26/36] Fix opening the native library on Linux --- Unity/Assets/NativeScript/Bindings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Unity/Assets/NativeScript/Bindings.cs b/Unity/Assets/NativeScript/Bindings.cs index 72ac143..3ae570d 100644 --- a/Unity/Assets/NativeScript/Bindings.cs +++ b/Unity/Assets/NativeScript/Bindings.cs @@ -332,7 +332,7 @@ static extern int dlclose( 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); From 65e70add52952098c5496ce91c4ef85b00c3895d Mon Sep 17 00:00:00 2001 From: Jackson Dunstan Date: Tue, 11 Aug 2020 20:31:02 -0700 Subject: [PATCH 27/36] Fix generating wrong C++ type name for multi-dimensional arrays --- .../Assets/NativeScript/Editor/GenerateBindings.cs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/Unity/Assets/NativeScript/Editor/GenerateBindings.cs b/Unity/Assets/NativeScript/Editor/GenerateBindings.cs index 7e56758..c36c2e6 100644 --- a/Unity/Assets/NativeScript/Editor/GenerateBindings.cs +++ b/Unity/Assets/NativeScript/Editor/GenerateBindings.cs @@ -13267,16 +13267,9 @@ static void AppendCppTypeFullName( output.Append(rank); output.Append('<'); Type elementType = type.GetElementType(); - for (int i = 0; i < rank; ++i) - { - AppendCppTypeFullName( - elementType, - output); - if (i != rank -1) - { - output.Append(", "); - } - } + AppendCppTypeFullName( + elementType, + output); output.Append('>'); } else if (IsDelegate(type)) From 0bac628fcd93c3274bbde8f42577f554191bb578 Mon Sep 17 00:00:00 2001 From: Yevhenii Vitiuk Date: Thu, 10 Dec 2020 09:55:24 +0200 Subject: [PATCH 28/36] Removed prefix "lib" after build C++ library --- Unity/Assets/CppSource/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Unity/Assets/CppSource/CMakeLists.txt b/Unity/Assets/CppSource/CMakeLists.txt index 306ae25..d668cf5 100644 --- a/Unity/Assets/CppSource/CMakeLists.txt +++ b/Unity/Assets/CppSource/CMakeLists.txt @@ -33,7 +33,6 @@ if (ANDROID_NDK) set(ANDROID_ABI armeabi-v7a) set(CMAKE_TOOLCHAIN_FILE ${ANDROID_NDK}/build/cmake/android.toolchain.cmake) endif() - # Set output path if (ANDROID_NDK) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/../Plugins/Android) @@ -79,5 +78,6 @@ if (IOS) set_xcode_property(${PROJECT_NAME} ENABLE_BITCODE "NO") endif() +set_property(TARGET ${PROJECT_NAME} PROPERTY PREFIX "") # Enable C++11 set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) \ No newline at end of file From 79c7c70b765e1286490cf0bdc1769deee1211498 Mon Sep 17 00:00:00 2001 From: Yevhenii Vitiuk Date: Thu, 10 Dec 2020 10:36:58 +0200 Subject: [PATCH 29/36] Fixed index of tags with Environment.NewLine "\r\n" --- .../NativeScript/Editor/GenerateBindings.cs | 115 ++++++++++-------- 1 file changed, 64 insertions(+), 51 deletions(-) diff --git a/Unity/Assets/NativeScript/Editor/GenerateBindings.cs b/Unity/Assets/NativeScript/Editor/GenerateBindings.cs index c36c2e6..809d780 100644 --- a/Unity/Assets/NativeScript/Editor/GenerateBindings.cs +++ b/Unity/Assets/NativeScript/Editor/GenerateBindings.cs @@ -684,7 +684,12 @@ 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 +#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 @@ -710,13 +715,21 @@ static Assembly[] GetAssemblies(string[] assemblyNames) assemblies[30] = typeof(UnityEngine.Experimental.UIElements.Button).Assembly; // Unity UI elements module #endif assemblies[31] = typeof(Canvas).Assembly; // Unity UI module - assemblies[32] = typeof(UnityEngine.Networking.NetworkTransport).Assembly; // Unity cloth 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(RemoteSettings).Assembly; // Unity Unity connect module assemblies[35] = typeof(UnityEngine.Networking.DownloadHandlerAudioClip).Assembly; // Unity web request audio module assemblies[36] = typeof(WWWForm).Assembly; // Unity web request module assemblies[37] = typeof(UnityEngine.Networking.DownloadHandlerTexture).Assembly; // Unity web request texture 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 @@ -13445,123 +13458,123 @@ static void InjectBuilders( string cppSourceContents = File.ReadAllText(CppSourcePath); csharpContents = InjectIntoString( csharpContents, - "/*BEGIN DELEGATE TYPES*/\n", - "\n\t\t/*END DELEGATE TYPES*/", + "/*BEGIN DELEGATE TYPES*/"+Environment.NewLine, + Environment.NewLine+"\t\t/*END DELEGATE TYPES*/", builders.CsharpDelegateTypes.ToString()); csharpContents = InjectIntoString( csharpContents, - "/*BEGIN STORE INIT CALLS*/\n", - "\n\t\t\t/*END STORE INIT CALLS*/", + "/*BEGIN STORE INIT CALLS*/"+Environment.NewLine, + Environment.NewLine+"\t\t\t/*END STORE INIT CALLS*/", builders.CsharpStoreInitCalls.ToString()); csharpContents = InjectIntoString( csharpContents, - "/*BEGIN INIT CALL*/\n", - "\n\t\t\t/*END INIT CALL*/", + "/*BEGIN INIT CALL*/"+Environment.NewLine, + Environment.NewLine+"\t\t\t/*END INIT CALL*/", builders.CsharpInitCall.ToString()); csharpContents = InjectIntoString( csharpContents, - "/*BEGIN BASE TYPES*/\n", - "\n/*END BASE TYPES*/", + "/*BEGIN BASE TYPES*/"+Environment.NewLine, + Environment.NewLine+"/*END BASE TYPES*/", builders.CsharpBaseTypes.ToString()); csharpContents = InjectIntoString( csharpContents, - "/*BEGIN FUNCTIONS*/\n", - "\n\t\t/*END FUNCTIONS*/", + "/*BEGIN FUNCTIONS*/"+Environment.NewLine, + Environment.NewLine+"\t\t/*END FUNCTIONS*/", builders.CsharpFunctions.ToString()); csharpContents = InjectIntoString( csharpContents, - "/*BEGIN CPP DELEGATES*/\n", - "\n\t\t/*END CPP DELEGATES*/", + "/*BEGIN CPP DELEGATES*/"+Environment.NewLine, + Environment.NewLine+"\t\t/*END CPP DELEGATES*/", builders.CsharpCppDelegates.ToString()); csharpContents = InjectIntoString( csharpContents, - "/*BEGIN CSHARP DELEGATES*/\n", - "\n\t\t/*END CSHARP DELEGATES*/", + "/*BEGIN CSHARP DELEGATES*/"+Environment.NewLine, + Environment.NewLine+"\t\t/*END CSHARP DELEGATES*/", builders.CsharpCsharpDelegates.ToString()); csharpContents = InjectIntoString( csharpContents, - "/*BEGIN IMPORTS*/\n", - "\n\t\t/*END IMPORTS*/", + "/*BEGIN IMPORTS*/"+Environment.NewLine, + Environment.NewLine+"\t\t/*END IMPORTS*/", builders.CsharpImports.ToString()); csharpContents = InjectIntoString( csharpContents, - "/*BEGIN GETDELEGATE CALLS*/\n", - "\n\t\t\t/*END GETDELEGATE CALLS*/", + "/*BEGIN GETDELEGATE CALLS*/"+Environment.NewLine, + Environment.NewLine+"\t\t\t/*END GETDELEGATE CALLS*/", builders.CsharpGetDelegateCalls.ToString()); csharpContents = InjectIntoString( csharpContents, - "/*BEGIN DESTROY FUNCTION ENUMERATORS*/\n", - "\n\t\t\t/*END DESTROY FUNCTION ENUMERATORS*/", + "/*BEGIN DESTROY FUNCTION ENUMERATORS*/"+Environment.NewLine, + Environment.NewLine+"\t\t\t/*END DESTROY FUNCTION ENUMERATORS*/", builders.CsharpDestroyFunctionEnumerators.ToString()); csharpContents = InjectIntoString( csharpContents, - "/*BEGIN DESTROY QUEUE CASES*/\n", - "\n\t\t\t\t\t\t/*END DESTROY QUEUE CASES*/", + "/*BEGIN DESTROY QUEUE CASES*/"+Environment.NewLine, + Environment.NewLine+"\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*/"+Environment.NewLine, + Environment.NewLine+"\t/*END FUNCTION POINTERS*/", builders.CppFunctionPointers.ToString()); cppHeaderContents = InjectIntoString( cppHeaderContents, - "/*BEGIN TYPE DECLARATIONS*/\n", - "\n/*END TYPE DECLARATIONS*/", + "/*BEGIN TYPE DECLARATIONS*/"+Environment.NewLine, + Environment.NewLine+"/*END TYPE DECLARATIONS*/", builders.CppTypeDeclarations.ToString()); cppHeaderContents = InjectIntoString( cppHeaderContents, - "/*BEGIN TEMPLATE DECLARATIONS*/\n", - "\n/*END TEMPLATE DECLARATIONS*/", + "/*BEGIN TEMPLATE DECLARATIONS*/"+Environment.NewLine, + Environment.NewLine+"/*END TEMPLATE DECLARATIONS*/", builders.CppTemplateDeclarations.ToString()); cppHeaderContents = InjectIntoString( cppHeaderContents, - "/*BEGIN TEMPLATE SPECIALIZATION DECLARATIONS*/\n", - "\n/*END TEMPLATE SPECIALIZATION DECLARATIONS*/", + "/*BEGIN TEMPLATE SPECIALIZATION DECLARATIONS*/"+Environment.NewLine, + Environment.NewLine+"/*END TEMPLATE SPECIALIZATION DECLARATIONS*/", builders.CppTemplateSpecializationDeclarations.ToString()); cppHeaderContents = InjectIntoString( cppHeaderContents, - "/*BEGIN TYPE DEFINITIONS*/\n", - "\n/*END TYPE DEFINITIONS*/", + "/*BEGIN TYPE DEFINITIONS*/"+Environment.NewLine, + Environment.NewLine+"/*END TYPE DEFINITIONS*/", builders.CppTypeDefinitions.ToString()); cppSourceContents = InjectIntoString( cppSourceContents, - "/*BEGIN METHOD DEFINITIONS*/\n", - "\n/*END METHOD DEFINITIONS*/", + "/*BEGIN METHOD DEFINITIONS*/"+Environment.NewLine, + Environment.NewLine+"/*END METHOD DEFINITIONS*/", builders.CppMethodDefinitions.ToString()); cppSourceContents = InjectIntoString( cppSourceContents, - "/*BEGIN INIT BODY PARAMETER READS*/\n", - "\n\t/*END INIT BODY PARAMETER READS*/", + "/*BEGIN INIT BODY PARAMETER READS*/"+Environment.NewLine, + Environment.NewLine+"\t/*END INIT BODY PARAMETER READS*/", builders.CppInitBodyParameterReads.ToString()); cppSourceContents = InjectIntoString( cppSourceContents, - "/*BEGIN INIT BODY ARRAYS*/\n", - "\n\t/*END INIT BODY ARRAYS*/", + "/*BEGIN INIT BODY ARRAYS*/"+Environment.NewLine, + Environment.NewLine+"\t/*END INIT BODY ARRAYS*/", builders.CppInitBodyArrays.ToString()); cppSourceContents = InjectIntoString( cppSourceContents, - "/*BEGIN INIT BODY FIRST BOOT*/\n", - "\n\t\t/*END INIT BODY FIRST BOOT*/", + "/*BEGIN INIT BODY FIRST BOOT*/"+Environment.NewLine, + Environment.NewLine+"\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*/"+Environment.NewLine, + Environment.NewLine+"\t/*END GLOBAL STATE AND FUNCTIONS*/", builders.CppGlobalStateAndFunctions.ToString()); cppHeaderContents = InjectIntoString( cppHeaderContents, - "/*BEGIN UNBOXING METHOD DECLARATIONS*/\n", - "\n\t\t/*END UNBOXING METHOD DECLARATIONS*/", + "/*BEGIN UNBOXING METHOD DECLARATIONS*/"+Environment.NewLine, + Environment.NewLine+"\t\t/*END UNBOXING METHOD DECLARATIONS*/", builders.CppUnboxingMethodDeclarations.ToString()); cppHeaderContents = InjectIntoString( cppHeaderContents, - "/*BEGIN STRING DEFAULT PARAMETERS*/\n", - "\n\t/*END STRING DEFAULT PARAMETERS*/", + "/*BEGIN STRING DEFAULT PARAMETERS*/"+Environment.NewLine, + Environment.NewLine+"\t/*END STRING DEFAULT PARAMETERS*/", builders.CppStringDefaultParams.ToString()); cppHeaderContents = InjectIntoString( cppHeaderContents, - "/*BEGIN MACROS*/\n", - "\n/*END MACROS*/", + "/*BEGIN MACROS*/"+Environment.NewLine, + Environment.NewLine+"/*END MACROS*/", builders.CppMacros.ToString()); File.WriteAllText(CsharpPath, csharpContents); @@ -13577,13 +13590,13 @@ static string InjectIntoString( { for (int startIndex = 0; ; ) { - 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( From 7573b1a9d7dcf9916d15a0c25272c76c389b050d Mon Sep 17 00:00:00 2001 From: Yevhenii Vitiuk Date: Fri, 11 Dec 2020 12:32:27 +0200 Subject: [PATCH 30/36] Fix cmake lib prefix for mingw on win32 platform --- Unity/Assets/CppSource/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Unity/Assets/CppSource/CMakeLists.txt b/Unity/Assets/CppSource/CMakeLists.txt index d668cf5..2baa025 100644 --- a/Unity/Assets/CppSource/CMakeLists.txt +++ b/Unity/Assets/CppSource/CMakeLists.txt @@ -33,6 +33,7 @@ if (ANDROID_NDK) set(ANDROID_ABI armeabi-v7a) set(CMAKE_TOOLCHAIN_FILE ${ANDROID_NDK}/build/cmake/android.toolchain.cmake) endif() + # Set output path if (ANDROID_NDK) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/../Plugins/Android) @@ -78,6 +79,9 @@ if (IOS) set_xcode_property(${PROJECT_NAME} ENABLE_BITCODE "NO") endif() -set_property(TARGET ${PROJECT_NAME} PROPERTY PREFIX "") +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 From faa5558ac836543c37f116e5ec636dcaf924a803 Mon Sep 17 00:00:00 2001 From: Yevhenii Vitiuk Date: Fri, 11 Dec 2020 12:36:03 +0200 Subject: [PATCH 31/36] Replace all "\n" symbol by Environment.NewLine --- .../NativeScript/Editor/GenerateBindings.cs | 1987 +++++++++-------- 1 file changed, 1006 insertions(+), 981 deletions(-) diff --git a/Unity/Assets/NativeScript/Editor/GenerateBindings.cs b/Unity/Assets/NativeScript/Editor/GenerateBindings.cs index 809d780..29fe4c7 100644 --- a/Unity/Assets/NativeScript/Editor/GenerateBindings.cs +++ b/Unity/Assets/NativeScript/Editor/GenerateBindings.cs @@ -437,16 +437,16 @@ static void AppendStubBaseType( AppendCSharpTypeParameters( typeParams, output); - output.Append('\n'); + output.AppendLine(); AppendIndent(indent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent(indent + 1, output); output.Append("// Stub version. GenerateBindings is still in progress. "); output.Append(timestamp); - output.Append('\n'); + output.AppendLine(); if (type.IsClass) { - output.Append('\n'); + output.AppendLine(); ConstructorInfo[] constructors = type.GetConstructors(); if (constructors.Length > 0) { @@ -463,22 +463,22 @@ static void AppendStubBaseType( AppendCsharpParams( ctorParams, output); - output.Append(")\n"); + output.AppendLine(")"); output.Append("\t\t\t: base("); AppendCsharpFunctionCallParameters( ctorParams, output); - output.Append(")\n"); - output.Append("\t\t{\n"); - output.Append("\t\t}\n"); - output.Append("\t\t\n"); + output.AppendLine(")"); + output.AppendLine("\t\t{"); + output.AppendLine("\t\t}"); + output.AppendLine("\t\t"); break; } } } } AppendIndent(indent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendNamespaceEnding(indent, output); } @@ -512,15 +512,15 @@ static void DoPostCompileWork(bool canRefreshAssetDb) // Init param for max managed Objects builders.CsharpInitCall.Append("\t\t\tMarshal.WriteInt32(memory, curMemory, "); builders.CsharpInitCall.Append(defaultMaxSimultaneous); - builders.CsharpInitCall.Append("); // max managed objects\n"); - builders.CsharpInitCall.Append("\t\t\tcurMemory += sizeof(int);\n"); + builders.CsharpInitCall.AppendLine("); // max managed objects"); + builders.CsharpInitCall.AppendLine("\t\t\tcurMemory += sizeof(int);"); builders.CsharpInitCall.Append(' '); // C# ObjectStore Init call builders.CsharpStoreInitCalls.Append( "\t\t\tNativeScript.Bindings.ObjectStore.Init("); builders.CsharpStoreInitCalls.Append(defaultMaxSimultaneous); - builders.CsharpStoreInitCalls.Append(");\n"); + builders.CsharpStoreInitCalls.AppendLine(");"); // Generate types if (doc.Types != null) @@ -978,8 +978,13 @@ static void AppendCppConstructorInitializerList( Type[] interfaceTypes, int indent, StringBuilder output, - string newline = "\n") + string newline = null) { + if (string.IsNullOrWhiteSpace(newline)) + { + newline = Environment.NewLine; + } + string separator = ": "; foreach (Type interfaceType in interfaceTypes) { @@ -1554,7 +1559,7 @@ static void AppendType( builders.CsharpStoreInitCalls); builders.CsharpStoreInitCalls.Append(">.Init("); builders.CsharpStoreInitCalls.Append(maxSimultaneous); - builders.CsharpStoreInitCalls.Append(");\n"); + builders.CsharpStoreInitCalls.AppendLine(");"); // Build function name suffix builders.TempStrBuilder.Length = 0; @@ -1602,15 +1607,15 @@ static void AppendType( typeof(void), parameters, builders.CsharpFunctions); - builders.CsharpFunctions.Append( - "if (handle != 0)\n\t\t\t{\n"); + builders.CsharpFunctions.AppendLine("if (handle != 0)"); + builders.CsharpFunctions.AppendLine("\t\t\t{"); builders.CsharpFunctions.Append( "\t\t\t\tNativeScript.Bindings.StructStore<"); AppendCsharpTypeFullName( type, builders.CsharpFunctions); - builders.CsharpFunctions.Append( - ">.Remove(handle);\n\t\t\t}"); + builders.CsharpFunctions.AppendLine(">.Remove(handle);"); + builders.CsharpFunctions.Append("\t\t\t}"); AppendCsharpFunctionEnd( typeof(void), new Type[0], @@ -1646,57 +1651,61 @@ static void AppendType( // C++ init body for handle array length builders.CppInitBodyArrays.Append("\tPlugin::RefCounts"); builders.CppInitBodyArrays.Append(funcNameSuffix); - builders.CppInitBodyArrays.Append(" = (int32_t*)curMemory;\n"); + builders.CppInitBodyArrays.AppendLine(" = (int32_t*)curMemory;"); builders.CppInitBodyArrays.Append("\tcurMemory += "); builders.CppInitBodyArrays.Append(maxSimultaneous); - builders.CppInitBodyArrays.Append(" * sizeof(int32_t);\n"); + builders.CppInitBodyArrays.AppendLine(" * sizeof(int32_t);"); builders.CppInitBodyArrays.Append("\tPlugin::RefCountsLen"); builders.CppInitBodyArrays.Append(funcNameSuffix); builders.CppInitBodyArrays.Append(" = "); builders.CppInitBodyArrays.Append(maxSimultaneous); - builders.CppInitBodyArrays.Append(";\n"); - builders.CppInitBodyArrays.Append("\t\n"); + 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 @@ -2035,7 +2044,7 @@ static void AppendEnum( AppendCppPrimitiveTypeName( underlyingType, builders.CppTypeDefinitions); - builders.CppTypeDefinitions.Append(" Value;\n"); + builders.CppTypeDefinitions.AppendLine(" Value;"); // Enumerator fields FieldInfo[] fields = type.GetFields( @@ -2052,7 +2061,7 @@ static void AppendEnum( builders.CppTypeDefinitions); builders.CppTypeDefinitions.Append(' '); builders.CppTypeDefinitions.Append(field.Name); - builders.CppTypeDefinitions.Append(";\n"); + builders.CppTypeDefinitions.AppendLine(";"); } // Constructor from primitive type @@ -2065,7 +2074,7 @@ static void AppendEnum( AppendCppPrimitiveTypeName( underlyingType, builders.CppTypeDefinitions); - builders.CppTypeDefinitions.Append(" value);\n"); + builders.CppTypeDefinitions.AppendLine(" value);"); // Conversion operator to primitive type AppendIndent( @@ -2075,7 +2084,7 @@ static void AppendEnum( AppendCppPrimitiveTypeName( underlyingType, builders.CppTypeDefinitions); - builders.CppTypeDefinitions.Append("() const;\n"); + builders.CppTypeDefinitions.AppendLine("() const;"); // Equality operator AppendIndent( @@ -2083,7 +2092,7 @@ static void AppendEnum( builders.CppTypeDefinitions); builders.CppTypeDefinitions.Append("bool operator==("); builders.CppTypeDefinitions.Append(type.Name); - builders.CppTypeDefinitions.Append(" other);\n"); + builders.CppTypeDefinitions.AppendLine(" other);"); // Inequality operator AppendIndent( @@ -2091,7 +2100,7 @@ static void AppendEnum( builders.CppTypeDefinitions); builders.CppTypeDefinitions.Append("bool operator!=("); builders.CppTypeDefinitions.Append(type.Name); - builders.CppTypeDefinitions.Append(" other);\n"); + builders.CppTypeDefinitions.AppendLine(" other);"); AppendNamespaceBeginning( type.Namespace, @@ -2108,23 +2117,23 @@ static void AppendEnum( AppendCppPrimitiveTypeName( underlyingType, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append(" value)\n"); + builders.CppMethodDefinitions.AppendLine(" value)"); AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append(": Value(value)\n"); + builders.CppMethodDefinitions.AppendLine(": Value(value)"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.AppendLine("}"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); + builders.CppMethodDefinitions.AppendLine(); // Conversion operator to primitive type AppendIndent( @@ -2137,23 +2146,23 @@ static void AppendEnum( AppendCppPrimitiveTypeName( underlyingType, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("() const\n"); + builders.CppMethodDefinitions.AppendLine("() const"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("return Value;\n"); + builders.CppMethodDefinitions.AppendLine("return Value;"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.AppendLine("}"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); + builders.CppMethodDefinitions.AppendLine();; // Equality operator AppendIndent( @@ -2165,23 +2174,23 @@ static void AppendEnum( builders.CppMethodDefinitions); builders.CppMethodDefinitions.Append("::operator==("); builders.CppMethodDefinitions.Append(type.Name); - builders.CppMethodDefinitions.Append(" other)\n"); + builders.CppMethodDefinitions.AppendLine(" other)"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("return Value == other.Value;\n"); + builders.CppMethodDefinitions.AppendLine("return Value == other.Value;"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.AppendLine("}"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); + builders.CppMethodDefinitions.AppendLine();; // Inequality operator AppendIndent( @@ -2193,23 +2202,23 @@ static void AppendEnum( builders.CppMethodDefinitions); builders.CppMethodDefinitions.Append("::operator!=("); builders.CppMethodDefinitions.Append(type.Name); - builders.CppMethodDefinitions.Append(" other)\n"); + builders.CppMethodDefinitions.AppendLine(" other)"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("return Value != other.Value;\n"); + builders.CppMethodDefinitions.AppendLine("return Value != other.Value;"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.AppendLine("}"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); + builders.CppMethodDefinitions.AppendLine();; AppendBoxing( type, @@ -2224,11 +2233,11 @@ static void AppendEnum( AppendIndent( indent, builders.CppTypeDefinitions); - builders.CppTypeDefinitions.Append("};\n"); + builders.CppTypeDefinitions.AppendLine("};"); AppendNamespaceEnding( indent, builders.CppTypeDefinitions); - builders.CppTypeDefinitions.Append('\n'); + builders.CppTypeDefinitions.AppendLine();; // Static initialization foreach (FieldInfo field in fields) @@ -2246,9 +2255,9 @@ static void AppendEnum( builders.CppMethodDefinitions.Append('('); builders.CppMethodDefinitions.Append( field.GetRawConstantValue()); - builders.CppMethodDefinitions.Append(");\n"); + builders.CppMethodDefinitions.AppendLine(");"); } - builders.CppMethodDefinitions.Append('\n'); + builders.CppMethodDefinitions.AppendLine();; } static void AppendBoxing( @@ -2546,7 +2555,7 @@ static void AppendUnboxing( AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendIndent( indent + 1, builders.CppMethodDefinitions); @@ -2560,18 +2569,19 @@ static void AppendUnboxing( } builders.CppMethodDefinitions.Append("Plugin::"); builders.CppMethodDefinitions.Append(unboxFuncName); - builders.CppMethodDefinitions.Append("(Handle));\n"); + builders.CppMethodDefinitions.AppendLine("(Handle));"); AppendCppUnhandledExceptionHandling( indent + 1, builders.CppMethodDefinitions); AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("return returnVal;\n"); + builders.CppMethodDefinitions.AppendLine("return returnVal;"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n\t\n"); + builders.CppMethodDefinitions.AppendLine("}"); + builders.CppMethodDefinitions.AppendLine("\t"); // C++ method definitions (end) AppendCppMethodDefinitionsEnd( @@ -2651,7 +2661,7 @@ static void AppendCppBoxingMethodDefinition( AppendIndent( indent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( indent + 1, output); @@ -2666,20 +2676,20 @@ static void AppendCppBoxingMethodDefinition( { output.Append("*this"); } - output.Append(");\n"); + output.AppendLine(");"); AppendCppUnhandledExceptionHandling( indent + 1, output); AppendIndent( indent + 1, output); - output.Append( - "if (handle)\n"); + output.AppendLine( + "if (handle)"); AppendIndent( indent + 1, output); - output.Append( - "{\n"); + output.AppendLine( + "{"); AppendIndent( indent + 2, output); @@ -2689,7 +2699,7 @@ static void AppendCppBoxingMethodDefinition( null, "handle", output); - output.Append(";\n"); + output.AppendLine(";"); AppendIndent( indent + 2, output); @@ -2697,24 +2707,24 @@ static void AppendCppBoxingMethodDefinition( AppendCppTypeFullName( boxedType, output); - output.Append("(Plugin::InternalUse::Only, handle);\n"); + output.AppendLine("(Plugin::InternalUse::Only, handle);"); AppendIndent( indent + 1, output); - output.Append( - "}\n"); + output.AppendLine( + "}"); AppendIndent( indent + 1, output); - output.Append("return nullptr;\n"); + output.AppendLine("return nullptr;"); AppendIndent( indent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( indent, output); - output.Append('\n'); + output.AppendLine();; } static void AppendHandleStoreTypeName( @@ -2939,7 +2949,7 @@ static void AppendConstructor( AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendCppPluginFunctionCall( true, GetTypeName(enclosingType), @@ -2955,26 +2965,26 @@ static void AppendConstructor( AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "*this = returnValue;\n"); + builders.CppMethodDefinitions.AppendLine( + "*this = returnValue;"); } else { AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "Handle = returnValue;\n"); + builders.CppMethodDefinitions.AppendLine( + "Handle = returnValue;"); AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "if (returnValue)\n"); + builders.CppMethodDefinitions.AppendLine( + "if (returnValue)"); AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "{\n"); + builders.CppMethodDefinitions.AppendLine( + "{"); AppendIndent( indent + 2, builders.CppMethodDefinitions); @@ -2984,21 +2994,21 @@ static void AppendConstructor( enclosingTypeParams, "returnValue", builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append(";\n"); + builders.CppMethodDefinitions.AppendLine(";"); AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "}\n"); + builders.CppMethodDefinitions.AppendLine( + "}"); } AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.AppendLine("}"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); + builders.CppMethodDefinitions.AppendLine();; // C++ init body AppendCppInitBodyFunctionPointerParameterRead( @@ -3189,7 +3199,7 @@ static void AppendFullValueTypeDefaultConstructor( AppendTypeNameWithoutGenericSuffix( enclosingType.Name, builders.CppTypeDefinitions); - builders.CppTypeDefinitions.Append("();\n"); + builders.CppTypeDefinitions.AppendLine("();"); AppendIndent( indent, @@ -3201,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( @@ -3236,7 +3246,7 @@ static void AppendFullValueTypeFields( builders.CppTypeDefinitions); builders.CppTypeDefinitions.Append(' '); builders.CppTypeDefinitions.Append(field.Name); - builders.CppTypeDefinitions.Append(";\n"); + builders.CppTypeDefinitions.AppendLine(";"); } } @@ -3466,7 +3476,7 @@ static void AppendEventAddRemoveMethod( AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendCppPluginFunctionCall( methodIsStatic, GetTypeName(enclosingType), @@ -3480,7 +3490,8 @@ static void AppendEventAddRemoveMethod( AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n\t\n"); + builders.CppMethodDefinitions.AppendLine("}"); + builders.CppMethodDefinitions.AppendLine("\t"); // C++ init body AppendCppInitBodyFunctionPointerParameterRead( @@ -4165,7 +4176,7 @@ static void AppendMethod( AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendCppPluginFunctionCall( methodIsStatic, GetTypeName(enclosingType), @@ -4184,7 +4195,8 @@ static void AppendMethod( AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n\t\n"); + builders.CppMethodDefinitions.AppendLine("}"); + builders.CppMethodDefinitions.AppendLine("\t"); // C++ init body AppendCppInitBodyFunctionPointerParameterRead( @@ -4270,7 +4282,7 @@ static void AppendCppFunctionCall( } output.Append('('); output.Append(param.Name); - output.Append(");\n"); + output.AppendLine(");"); } } if (!enclosingTypeIsStatic) @@ -4278,8 +4290,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, @@ -4313,31 +4325,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( @@ -4477,8 +4489,8 @@ static void AppendArray( extraIndent, builders.CppMethodDefinitions); builders.CppMethodDefinitions.Append(subject); - builders.CppMethodDefinitions.Append( - "InternalLength = 0;\n"); + builders.CppMethodDefinitions.AppendLine( + "InternalLength = 0;"); if (localRank > 1) { for (int i = 0; i < localRank; ++i) @@ -4490,8 +4502,8 @@ static void AppendArray( builders.CppMethodDefinitions.Append( "InternalLengths["); builders.CppMethodDefinitions.Append(i); - builders.CppMethodDefinitions.Append( - "] = 0;\n"); + builders.CppMethodDefinitions.AppendLine( + "] = 0;"); } } }, @@ -4502,8 +4514,8 @@ static void AppendArray( builders.CppMethodDefinitions.Append( "InternalLength = "); builders.CppMethodDefinitions.Append(subject); - builders.CppMethodDefinitions.Append( - "InternalLength;\n"); + builders.CppMethodDefinitions.AppendLine( + "InternalLength;"); if (localRank > 1) { for (int i = 0; i < localRank; ++i) @@ -4520,8 +4532,8 @@ static void AppendArray( builders.CppMethodDefinitions.Append( "InternalLengths["); builders.CppMethodDefinitions.Append(i); - builders.CppMethodDefinitions.Append( - "];\n"); + builders.CppMethodDefinitions.AppendLine( + "];"); } } }, @@ -4532,8 +4544,8 @@ static void AppendArray( AppendIndent( indent + 1, builders.CppTypeDefinitions); - builders.CppTypeDefinitions.Append( - "int32_t InternalLength;\n"); + builders.CppTypeDefinitions.AppendLine( + "int32_t InternalLength;"); if (rank > 1) { AppendIndent( @@ -4542,7 +4554,7 @@ static void AppendArray( builders.CppTypeDefinitions.Append( "int32_t InternalLengths["); builders.CppTypeDefinitions.Append(rank); - builders.CppTypeDefinitions.Append("];\n"); + builders.CppTypeDefinitions.AppendLine("];"); } AppendArrayConstructor( @@ -4611,7 +4623,7 @@ static void AppendArray( AppendTypeNameWithoutGenericSuffix( "operator[]", builders.CppTypeDefinitions); - builders.CppTypeDefinitions.Append("(int32_t index);\n"); + builders.CppTypeDefinitions.AppendLine("(int32_t index);"); // C++ operator[] method definition AppendCppArrayIndexOperatorMethodDefinition( @@ -4652,88 +4664,88 @@ static void AppendArrayIterator( StringBuilder cppMethodDefinitions) { // Iterator type definition - cppTypeDefinitions.Append("namespace Plugin\n"); - cppTypeDefinitions.Append("{\n"); + cppTypeDefinitions.AppendLine("namespace Plugin"); + cppTypeDefinitions.AppendLine("{"); cppTypeDefinitions.Append("\tstruct "); cppTypeDefinitions.Append(bindingArrayTypeName); - cppTypeDefinitions.Append("Iterator\n"); - cppTypeDefinitions.Append("\t{\n"); + cppTypeDefinitions.AppendLine("Iterator"); + cppTypeDefinitions.AppendLine("\t{"); cppTypeDefinitions.Append("\t\tSystem::"); cppTypeDefinitions.Append(cppGenericArrayTypeName); - cppTypeDefinitions.Append("& array;\n"); - cppTypeDefinitions.Append("\t\tint index;\n"); + cppTypeDefinitions.AppendLine("& array;"); + cppTypeDefinitions.AppendLine("\t\tint index;"); cppTypeDefinitions.Append("\t\t"); cppTypeDefinitions.Append(bindingArrayTypeName); cppTypeDefinitions.Append("Iterator(System::"); cppTypeDefinitions.Append(cppGenericArrayTypeName); - cppTypeDefinitions.Append("& array, int32_t index);\n"); + cppTypeDefinitions.AppendLine("& array, int32_t index);"); cppTypeDefinitions.Append("\t\t"); cppTypeDefinitions.Append(bindingArrayTypeName); - cppTypeDefinitions.Append("Iterator& operator++();\n"); + cppTypeDefinitions.AppendLine("Iterator& operator++();"); cppTypeDefinitions.Append("\t\tbool operator!=(const "); cppTypeDefinitions.Append(bindingArrayTypeName); - cppTypeDefinitions.Append("Iterator& other);\n"); + cppTypeDefinitions.AppendLine("Iterator& other);"); cppTypeDefinitions.Append("\t\t"); AppendCppTypeFullName( elementType, cppTypeDefinitions); - cppTypeDefinitions.Append(" operator*();\n"); - cppTypeDefinitions.Append("\t};\n"); - cppTypeDefinitions.Append("}\n"); - cppTypeDefinitions.Append('\n'); + cppTypeDefinitions.AppendLine(" operator*();"); + cppTypeDefinitions.AppendLine("\t};"); + cppTypeDefinitions.AppendLine("}"); + cppTypeDefinitions.AppendLine();; // begin() and end() declarations - cppTypeDefinitions.Append("namespace System\n"); - cppTypeDefinitions.Append("{\n"); + cppTypeDefinitions.AppendLine("namespace System"); + cppTypeDefinitions.AppendLine("{"); cppTypeDefinitions.Append("\tPlugin::"); cppTypeDefinitions.Append(bindingArrayTypeName); cppTypeDefinitions.Append("Iterator begin(System::"); cppTypeDefinitions.Append(cppGenericArrayTypeName); - cppTypeDefinitions.Append("& array);\n"); + cppTypeDefinitions.AppendLine("& array);"); cppTypeDefinitions.Append("\tPlugin::"); cppTypeDefinitions.Append(bindingArrayTypeName); cppTypeDefinitions.Append("Iterator end(System::"); cppTypeDefinitions.Append(cppGenericArrayTypeName); - cppTypeDefinitions.Append("& array);\n"); - cppTypeDefinitions.Append("}\n"); - cppTypeDefinitions.Append('\n'); + cppTypeDefinitions.AppendLine("& array);"); + cppTypeDefinitions.AppendLine("}"); + cppTypeDefinitions.AppendLine();; // Iterator method definitions - cppMethodDefinitions.Append("namespace Plugin\n"); - cppMethodDefinitions.Append("{\n"); + cppMethodDefinitions.AppendLine("namespace Plugin"); + cppMethodDefinitions.AppendLine("{"); cppMethodDefinitions.Append('\t'); cppMethodDefinitions.Append(bindingArrayTypeName); cppMethodDefinitions.Append("Iterator::"); cppMethodDefinitions.Append(bindingArrayTypeName); cppMethodDefinitions.Append("Iterator(System::"); cppMethodDefinitions.Append(cppGenericArrayTypeName); - cppMethodDefinitions.Append("& array, int32_t index)\n"); - cppMethodDefinitions.Append("\t\t: array(array)\n"); - cppMethodDefinitions.Append("\t\t, index(index)\n"); - cppMethodDefinitions.Append("\t{\n"); - cppMethodDefinitions.Append("\t}\n"); - cppMethodDefinitions.Append("\t\n"); + cppMethodDefinitions.AppendLine("& array, int32_t index)"); + cppMethodDefinitions.AppendLine("\t\t: array(array)"); + cppMethodDefinitions.AppendLine("\t\t, index(index)"); + cppMethodDefinitions.AppendLine("\t{"); + cppMethodDefinitions.AppendLine("\t}"); + cppMethodDefinitions.AppendLine("\t"); cppMethodDefinitions.Append('\t'); cppMethodDefinitions.Append(bindingArrayTypeName); cppMethodDefinitions.Append("Iterator& "); cppMethodDefinitions.Append(bindingArrayTypeName); cppMethodDefinitions.Append("Iterator::"); - cppMethodDefinitions.Append("operator++()\n"); - cppMethodDefinitions.Append("\t{\n"); - cppMethodDefinitions.Append("\t\tindex++;\n"); - cppMethodDefinitions.Append("\t\treturn *this;\n"); - cppMethodDefinitions.Append("\t}\n"); - cppMethodDefinitions.Append("\t\n"); + cppMethodDefinitions.AppendLine("operator++()"); + cppMethodDefinitions.AppendLine("\t{"); + cppMethodDefinitions.AppendLine("\t\tindex++;"); + cppMethodDefinitions.AppendLine("\t\treturn *this;"); + cppMethodDefinitions.AppendLine("\t}"); + cppMethodDefinitions.AppendLine("\t"); cppMethodDefinitions.Append("\tbool "); cppMethodDefinitions.Append(bindingArrayTypeName); cppMethodDefinitions.Append("Iterator::"); cppMethodDefinitions.Append("operator!=(const "); cppMethodDefinitions.Append(bindingArrayTypeName); - cppMethodDefinitions.Append("Iterator& other)\n"); - cppMethodDefinitions.Append("\t{\n"); - cppMethodDefinitions.Append("\t\treturn index != other.index;\n"); - cppMethodDefinitions.Append("\t}\n"); - cppMethodDefinitions.Append("\t\n"); + cppMethodDefinitions.AppendLine("Iterator& other)"); + cppMethodDefinitions.AppendLine("\t{"); + cppMethodDefinitions.AppendLine("\t\treturn index != other.index;"); + cppMethodDefinitions.AppendLine("\t}"); + cppMethodDefinitions.AppendLine("\t"); cppMethodDefinitions.Append('\t'); AppendCppTypeFullName( elementType, @@ -4741,39 +4753,39 @@ static void AppendArrayIterator( cppMethodDefinitions.Append(' '); cppMethodDefinitions.Append(bindingArrayTypeName); cppMethodDefinitions.Append("Iterator::"); - cppMethodDefinitions.Append("operator*()\n"); - cppMethodDefinitions.Append("\t{\n"); - cppMethodDefinitions.Append("\t\treturn array[index];\n"); - cppMethodDefinitions.Append("\t}\n"); - cppMethodDefinitions.Append("}\n"); - cppMethodDefinitions.Append('\n'); + cppMethodDefinitions.AppendLine("operator*()"); + cppMethodDefinitions.AppendLine("\t{"); + cppMethodDefinitions.AppendLine("\t\treturn array[index];"); + cppMethodDefinitions.AppendLine("\t}"); + cppMethodDefinitions.AppendLine("}"); + cppMethodDefinitions.AppendLine();; // begin() and end() definitions - cppMethodDefinitions.Append("namespace System\n"); - cppMethodDefinitions.Append("{\n"); + cppMethodDefinitions.AppendLine("namespace System"); + cppMethodDefinitions.AppendLine("{"); cppMethodDefinitions.Append("\tPlugin::"); cppMethodDefinitions.Append(bindingArrayTypeName); cppMethodDefinitions.Append("Iterator begin(System::"); cppMethodDefinitions.Append(cppGenericArrayTypeName); - cppMethodDefinitions.Append("& array)\n"); - cppMethodDefinitions.Append("\t{\n"); + cppMethodDefinitions.AppendLine("& array)"); + cppMethodDefinitions.AppendLine("\t{"); cppMethodDefinitions.Append("\t\treturn Plugin::"); cppMethodDefinitions.Append(bindingArrayTypeName); - cppMethodDefinitions.Append("Iterator(array, 0);\n"); - cppMethodDefinitions.Append("\t}\n"); - cppMethodDefinitions.Append("\t\n"); + cppMethodDefinitions.AppendLine("Iterator(array, 0);"); + cppMethodDefinitions.AppendLine("\t}"); + cppMethodDefinitions.AppendLine("\t"); cppMethodDefinitions.Append("\tPlugin::"); cppMethodDefinitions.Append(bindingArrayTypeName); cppMethodDefinitions.Append("Iterator end(System::"); cppMethodDefinitions.Append(cppGenericArrayTypeName); - cppMethodDefinitions.Append("& array)\n"); - cppMethodDefinitions.Append("\t{\n"); + cppMethodDefinitions.AppendLine("& array)"); + cppMethodDefinitions.AppendLine("\t{"); cppMethodDefinitions.Append("\t\treturn Plugin::"); cppMethodDefinitions.Append(bindingArrayTypeName); - cppMethodDefinitions.Append("Iterator(array, array.GetLength() - 1);\n"); - cppMethodDefinitions.Append("\t}\n"); - cppMethodDefinitions.Append("}\n"); - cppMethodDefinitions.Append('\n'); + cppMethodDefinitions.AppendLine("Iterator(array, array.GetLength() - 1);"); + cppMethodDefinitions.AppendLine("\t}"); + cppMethodDefinitions.AppendLine("}"); + cppMethodDefinitions.AppendLine();; } static void AppendGenericEnumerableIterator( @@ -4785,45 +4797,45 @@ static void AppendGenericEnumerableIterator( StringBuilder cppMethodDefinitions) { // Iterator type definition - cppTypeDefinitions.Append("namespace Plugin\n"); - cppTypeDefinitions.Append("{\n"); + cppTypeDefinitions.AppendLine("namespace Plugin"); + cppTypeDefinitions.AppendLine("{"); cppTypeDefinitions.Append("\tstruct "); cppTypeDefinitions.Append(bindingEnumerableTypeName); - cppTypeDefinitions.Append("Iterator\n"); - cppTypeDefinitions.Append("\t{\n"); + cppTypeDefinitions.AppendLine("Iterator"); + cppTypeDefinitions.AppendLine("\t{"); cppTypeDefinitions.Append("\t\t"); AppendCppTypeFullName( enumeratorType, cppTypeDefinitions); - cppTypeDefinitions.Append(" enumerator;\n"); - cppTypeDefinitions.Append("\t\tbool hasMore;\n"); + cppTypeDefinitions.AppendLine(" enumerator;"); + cppTypeDefinitions.AppendLine("\t\tbool hasMore;"); cppTypeDefinitions.Append("\t\t"); cppTypeDefinitions.Append(bindingEnumerableTypeName); - cppTypeDefinitions.Append("Iterator(decltype(nullptr));\n"); + cppTypeDefinitions.AppendLine("Iterator(decltype(nullptr));"); cppTypeDefinitions.Append("\t\t"); cppTypeDefinitions.Append(bindingEnumerableTypeName); cppTypeDefinitions.Append("Iterator("); AppendCppTypeFullName( enumerableType, cppTypeDefinitions); - cppTypeDefinitions.Append("& enumerable);\n"); + cppTypeDefinitions.AppendLine("& enumerable);"); cppTypeDefinitions.Append("\t\t~"); cppTypeDefinitions.Append(bindingEnumerableTypeName); - cppTypeDefinitions.Append("Iterator();\n"); + cppTypeDefinitions.AppendLine("Iterator();"); cppTypeDefinitions.Append("\t\t"); cppTypeDefinitions.Append(bindingEnumerableTypeName); - cppTypeDefinitions.Append("Iterator& operator++();\n"); + cppTypeDefinitions.AppendLine("Iterator& operator++();"); cppTypeDefinitions.Append("\t\tbool operator!=(const "); cppTypeDefinitions.Append(bindingEnumerableTypeName); - cppTypeDefinitions.Append("Iterator& other);\n"); + cppTypeDefinitions.AppendLine("Iterator& other);"); cppTypeDefinitions.Append("\t\t"); AppendCppTypeFullName( elementType, cppTypeDefinitions); - cppTypeDefinitions.Append(" operator*();\n"); - cppTypeDefinitions.Append("\t};\n"); - cppTypeDefinitions.Append("}\n"); - cppTypeDefinitions.Append('\n'); + cppTypeDefinitions.AppendLine(" operator*();"); + cppTypeDefinitions.AppendLine("\t};"); + cppTypeDefinitions.AppendLine("}"); + cppTypeDefinitions.AppendLine();; // begin() and end() declarations int indent = AppendNamespaceBeginning( @@ -4838,7 +4850,7 @@ static void AppendGenericEnumerableIterator( AppendCppTypeFullName( enumerableType, cppTypeDefinitions); - cppTypeDefinitions.Append("& enumerable);\n"); + cppTypeDefinitions.AppendLine("& enumerable);"); AppendIndent( indent, cppTypeDefinitions); @@ -4848,25 +4860,25 @@ static void AppendGenericEnumerableIterator( AppendCppTypeFullName( enumerableType, cppTypeDefinitions); - cppTypeDefinitions.Append("& enumerable);\n"); + cppTypeDefinitions.AppendLine("& enumerable);"); AppendNamespaceEnding( indent, cppTypeDefinitions); - cppTypeDefinitions.Append('\n'); + cppTypeDefinitions.AppendLine();; // Iterator method definitions - cppMethodDefinitions.Append("namespace Plugin\n"); - cppMethodDefinitions.Append("{\n"); + cppMethodDefinitions.AppendLine("namespace Plugin"); + cppMethodDefinitions.AppendLine("{"); cppMethodDefinitions.Append('\t'); cppMethodDefinitions.Append(bindingEnumerableTypeName); cppMethodDefinitions.Append("Iterator::"); cppMethodDefinitions.Append(bindingEnumerableTypeName); - cppMethodDefinitions.Append("Iterator(decltype(nullptr))\n"); - cppMethodDefinitions.Append("\t\t: enumerator(nullptr)\n"); - cppMethodDefinitions.Append("\t\t, hasMore(false)\n"); - cppMethodDefinitions.Append("\t{\n"); - cppMethodDefinitions.Append("\t}\n"); - cppMethodDefinitions.Append("\t\n"); + cppMethodDefinitions.AppendLine("Iterator(decltype(nullptr))"); + cppMethodDefinitions.AppendLine("\t\t: enumerator(nullptr)"); + cppMethodDefinitions.AppendLine("\t\t, hasMore(false)"); + cppMethodDefinitions.AppendLine("\t{"); + cppMethodDefinitions.AppendLine("\t}"); + cppMethodDefinitions.AppendLine("\t"); cppMethodDefinitions.Append('\t'); cppMethodDefinitions.Append(bindingEnumerableTypeName); cppMethodDefinitions.Append("Iterator::"); @@ -4875,45 +4887,45 @@ static void AppendGenericEnumerableIterator( AppendCppTypeFullName( enumerableType, cppMethodDefinitions); - cppMethodDefinitions.Append("& enumerable)\n"); - cppMethodDefinitions.Append("\t\t: enumerator(enumerable.GetEnumerator())\n"); - cppMethodDefinitions.Append("\t{\n"); - cppMethodDefinitions.Append("\t\thasMore = enumerator.MoveNext();\n"); - cppMethodDefinitions.Append("\t}\n"); - cppMethodDefinitions.Append("\t\n"); + cppMethodDefinitions.AppendLine("& enumerable)"); + cppMethodDefinitions.AppendLine("\t\t: enumerator(enumerable.GetEnumerator())"); + cppMethodDefinitions.AppendLine("\t{"); + cppMethodDefinitions.AppendLine("\t\thasMore = enumerator.MoveNext();"); + cppMethodDefinitions.AppendLine("\t}"); + cppMethodDefinitions.AppendLine("\t"); cppMethodDefinitions.Append('\t'); cppMethodDefinitions.Append(bindingEnumerableTypeName); cppMethodDefinitions.Append("Iterator::~"); cppMethodDefinitions.Append(bindingEnumerableTypeName); - cppMethodDefinitions.Append("Iterator()\n"); - cppMethodDefinitions.Append("\t{\n"); - cppMethodDefinitions.Append("\t\tif (enumerator != nullptr)\n"); - cppMethodDefinitions.Append("\t\t{\n"); - cppMethodDefinitions.Append("\t\t\tenumerator.Dispose();\n"); - cppMethodDefinitions.Append("\t\t}\n"); - cppMethodDefinitions.Append("\t}\n"); - cppMethodDefinitions.Append("\t\n"); + cppMethodDefinitions.AppendLine("Iterator()"); + cppMethodDefinitions.AppendLine("\t{"); + cppMethodDefinitions.AppendLine("\t\tif (enumerator != nullptr)"); + cppMethodDefinitions.AppendLine("\t\t{"); + cppMethodDefinitions.AppendLine("\t\t\tenumerator.Dispose();"); + cppMethodDefinitions.AppendLine("\t\t}"); + cppMethodDefinitions.AppendLine("\t}"); + cppMethodDefinitions.AppendLine("\t"); cppMethodDefinitions.Append('\t'); cppMethodDefinitions.Append(bindingEnumerableTypeName); cppMethodDefinitions.Append("Iterator& "); cppMethodDefinitions.Append(bindingEnumerableTypeName); cppMethodDefinitions.Append("Iterator::"); - cppMethodDefinitions.Append("operator++()\n"); - cppMethodDefinitions.Append("\t{\n"); - cppMethodDefinitions.Append("\t\thasMore = enumerator.MoveNext();\n"); - cppMethodDefinitions.Append("\t\treturn *this;\n"); - cppMethodDefinitions.Append("\t}\n"); - cppMethodDefinitions.Append("\t\n"); + cppMethodDefinitions.AppendLine("operator++()"); + cppMethodDefinitions.AppendLine("\t{"); + cppMethodDefinitions.AppendLine("\t\thasMore = enumerator.MoveNext();"); + cppMethodDefinitions.AppendLine("\t\treturn *this;"); + cppMethodDefinitions.AppendLine("\t}"); + cppMethodDefinitions.AppendLine("\t"); cppMethodDefinitions.Append("\tbool "); cppMethodDefinitions.Append(bindingEnumerableTypeName); cppMethodDefinitions.Append("Iterator::"); cppMethodDefinitions.Append("operator!=(const "); cppMethodDefinitions.Append(bindingEnumerableTypeName); - cppMethodDefinitions.Append("Iterator& other)\n"); - cppMethodDefinitions.Append("\t{\n"); - cppMethodDefinitions.Append("\t\treturn hasMore;\n"); - cppMethodDefinitions.Append("\t}\n"); - cppMethodDefinitions.Append("\t\n"); + cppMethodDefinitions.AppendLine("Iterator& other)"); + cppMethodDefinitions.AppendLine("\t{"); + cppMethodDefinitions.AppendLine("\t\treturn hasMore;"); + cppMethodDefinitions.AppendLine("\t}"); + cppMethodDefinitions.AppendLine("\t"); cppMethodDefinitions.Append('\t'); AppendCppTypeFullName( elementType, @@ -4921,12 +4933,12 @@ static void AppendGenericEnumerableIterator( cppMethodDefinitions.Append(' '); cppMethodDefinitions.Append(bindingEnumerableTypeName); cppMethodDefinitions.Append("Iterator::"); - cppMethodDefinitions.Append("operator*()\n"); - cppMethodDefinitions.Append("\t{\n"); - cppMethodDefinitions.Append("\t\treturn enumerator.GetCurrent();\n"); - cppMethodDefinitions.Append("\t}\n"); - cppMethodDefinitions.Append("}\n"); - cppMethodDefinitions.Append('\n'); + cppMethodDefinitions.AppendLine("operator*()"); + cppMethodDefinitions.AppendLine("\t{"); + cppMethodDefinitions.AppendLine("\t\treturn enumerator.GetCurrent();"); + cppMethodDefinitions.AppendLine("\t}"); + cppMethodDefinitions.AppendLine("}"); + cppMethodDefinitions.AppendLine();; // begin() and end() definitions indent = AppendNamespaceBeginning( @@ -4941,25 +4953,25 @@ static void AppendGenericEnumerableIterator( AppendCppTypeFullName( enumerableType, cppMethodDefinitions); - cppMethodDefinitions.Append("& enumerable)\n"); + cppMethodDefinitions.AppendLine("& enumerable)"); AppendIndent( indent, cppMethodDefinitions); - cppMethodDefinitions.Append("{\n"); + cppMethodDefinitions.AppendLine("{"); AppendIndent( indent + 1, cppMethodDefinitions); cppMethodDefinitions.Append("return Plugin::"); cppMethodDefinitions.Append(bindingEnumerableTypeName); - cppMethodDefinitions.Append("Iterator(enumerable);\n"); + cppMethodDefinitions.AppendLine("Iterator(enumerable);"); AppendIndent( indent, cppMethodDefinitions); - cppMethodDefinitions.Append("}\n"); + cppMethodDefinitions.AppendLine("}"); AppendIndent( indent, cppMethodDefinitions); - cppMethodDefinitions.Append('\n'); + cppMethodDefinitions.AppendLine();; AppendIndent( indent, cppMethodDefinitions); @@ -4969,25 +4981,25 @@ static void AppendGenericEnumerableIterator( AppendCppTypeFullName( enumerableType, cppMethodDefinitions); - cppMethodDefinitions.Append("& enumerable)\n"); + cppMethodDefinitions.AppendLine("& enumerable)"); AppendIndent( indent, cppMethodDefinitions); - cppMethodDefinitions.Append("{\n"); + cppMethodDefinitions.AppendLine("{"); AppendIndent( indent + 1, cppMethodDefinitions); cppMethodDefinitions.Append("return Plugin::"); cppMethodDefinitions.Append(bindingEnumerableTypeName); - cppMethodDefinitions.Append("Iterator(nullptr);\n"); + cppMethodDefinitions.AppendLine("Iterator(nullptr);"); AppendIndent( indent, cppMethodDefinitions); - cppMethodDefinitions.Append("}\n"); + cppMethodDefinitions.AppendLine("}"); AppendNamespaceEnding( indent, cppMethodDefinitions); - cppMethodDefinitions.Append('\n'); + cppMethodDefinitions.AppendLine();; } static void AppendCppArrayIndexOperatorMethodDefinition( @@ -5009,11 +5021,11 @@ static void AppendCppArrayIndexOperatorMethodDefinition( AppendTypeNameWithoutGenericSuffix( enclosingTypeTypeName.Name, output); - output.Append("::operator[](int32_t index)\n"); + output.AppendLine("::operator[](int32_t index)"); AppendIndent( indent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( indent + 1, output); @@ -5026,15 +5038,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( @@ -5215,11 +5227,11 @@ static void AppendArrayElementProxy( AppendTypeNameWithoutGenericSuffix( cppElementProxyTypeName, builders.CppTemplateSpecializationDeclarations); - builders.CppTemplateSpecializationDeclarations.Append(";\n"); + builders.CppTemplateSpecializationDeclarations.AppendLine(";"); AppendNamespaceEnding( indent, builders.CppTemplateSpecializationDeclarations); - builders.CppTemplateSpecializationDeclarations.Append('\n'); + builders.CppTemplateSpecializationDeclarations.AppendLine();; // C++ element proxy type definition AppendNamespaceBeginning( @@ -5230,15 +5242,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( @@ -5246,7 +5258,7 @@ static void AppendArrayElementProxy( builders.CppTypeDefinitions); builders.CppTypeDefinitions.Append("int32_t Index"); builders.CppTypeDefinitions.Append(i); - builders.CppTypeDefinitions.Append(";\n"); + builders.CppTypeDefinitions.AppendLine(";"); } AppendIndent( indent + 1, @@ -5263,7 +5275,7 @@ static void AppendArrayElementProxy( builders.CppTypeDefinitions.Append(", "); } } - builders.CppTypeDefinitions.Append(");\n"); + builders.CppTypeDefinitions.AppendLine(");"); if (rank == maxRank) { AppendIndent( @@ -5273,7 +5285,7 @@ static void AppendArrayElementProxy( AppendCppTypeFullName( elementType, builders.CppTypeDefinitions); - builders.CppTypeDefinitions.Append(" item);\n"); + builders.CppTypeDefinitions.AppendLine(" item);"); AppendIndent( indent + 1, builders.CppTypeDefinitions); @@ -5281,7 +5293,7 @@ static void AppendArrayElementProxy( AppendCppTypeFullName( elementType, builders.CppTypeDefinitions); - builders.CppTypeDefinitions.Append("();\n"); + builders.CppTypeDefinitions.AppendLine("();"); } else { @@ -5295,14 +5307,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( @@ -5330,15 +5342,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( @@ -5348,16 +5360,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) { @@ -5372,11 +5384,11 @@ static void AppendArrayElementProxy( AppendCppTypeFullName( elementType, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append(" item)\n"); + builders.CppMethodDefinitions.AppendLine(" item)"); AppendIndent( cppMethodDefinitionsIndent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendCppPluginFunctionCall( false, GetTypeName(cppArrayTypeName, "System"), @@ -5390,11 +5402,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( @@ -5406,11 +5418,11 @@ static void AppendArrayElementProxy( AppendCppTypeFullName( elementType, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("()\n"); + builders.CppMethodDefinitions.AppendLine("()"); AppendIndent( cppMethodDefinitionsIndent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendCppPluginFunctionCall( false, GetTypeName(cppArrayTypeName, "System"), @@ -5429,7 +5441,7 @@ static void AppendArrayElementProxy( AppendIndent( cppMethodDefinitionsIndent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.AppendLine("}"); } else { @@ -5594,13 +5606,13 @@ static void AppendArrayConstructor( AppendCppTypeFullName( interfaceType, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("(nullptr)\n"); + builders.CppMethodDefinitions.AppendLine("(nullptr)"); separator = ", "; } AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendCppPluginFunctionCall( true, cppArrayTypeTypeName, @@ -5614,18 +5626,18 @@ static void AppendArrayConstructor( AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "Handle = returnValue;\n"); + builders.CppMethodDefinitions.AppendLine( + "Handle = returnValue;"); AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "if (returnValue)\n"); + builders.CppMethodDefinitions.AppendLine( + "if (returnValue)"); AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "{\n"); + builders.CppMethodDefinitions.AppendLine( + "{"); AppendIndent( indent + 2, builders.CppMethodDefinitions); @@ -5635,7 +5647,7 @@ static void AppendArrayConstructor( cppTypeParams, "returnValue", builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append(";\n"); + builders.CppMethodDefinitions.AppendLine(";"); if (rank > 1) { AppendIndent( @@ -5651,7 +5663,7 @@ static void AppendArrayConstructor( builders.CppMethodDefinitions.Append(" * "); } } - builders.CppMethodDefinitions.Append(";\n"); + builders.CppMethodDefinitions.AppendLine(";"); for (int i = 0; i < rank; ++i) { AppendIndent( @@ -5661,7 +5673,7 @@ static void AppendArrayConstructor( builders.CppMethodDefinitions.Append(i); builders.CppMethodDefinitions.Append("] = length"); builders.CppMethodDefinitions.Append(i); - builders.CppMethodDefinitions.Append(";\n"); + builders.CppMethodDefinitions.AppendLine(";"); } } else @@ -5669,22 +5681,22 @@ static void AppendArrayConstructor( AppendIndent( indent + 2, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "InternalLength = length0;\n"); + builders.CppMethodDefinitions.AppendLine( + "InternalLength = length0;"); } AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "}\n"); + builders.CppMethodDefinitions.AppendLine( + "}"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.AppendLine("}"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); + builders.CppMethodDefinitions.AppendLine();; } static void AppendArrayCppGetLengthFunction( @@ -5722,46 +5734,46 @@ static void AppendArrayCppGetLengthFunction( AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "int32_t returnVal = InternalLength;\n"); + builders.CppMethodDefinitions.AppendLine( + "int32_t returnVal = InternalLength;"); AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("if (returnVal == 0)\n"); + builders.CppMethodDefinitions.AppendLine("if (returnVal == 0)"); AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendIndent( indent + 2, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "returnVal = Array::GetLength();\n"); + builders.CppMethodDefinitions.AppendLine( + "returnVal = Array::GetLength();"); AppendIndent( indent + 2, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "InternalLength = returnVal;\n"); + builders.CppMethodDefinitions.AppendLine( + "InternalLength = returnVal;"); AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("};\n"); + builders.CppMethodDefinitions.AppendLine("};"); AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("return returnVal;\n"); + builders.CppMethodDefinitions.AppendLine("return returnVal;"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.AppendLine("}"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); + builders.CppMethodDefinitions.AppendLine();; } static void AppendArrayCppGetRankFunction( @@ -5800,21 +5812,21 @@ static void AppendArrayCppGetRankFunction( AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendIndent( indent + 1, builders.CppMethodDefinitions); builders.CppMethodDefinitions.Append("return "); builders.CppMethodDefinitions.Append(rank); - builders.CppMethodDefinitions.Append(";\n"); + builders.CppMethodDefinitions.AppendLine(";"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.AppendLine("}"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); + builders.CppMethodDefinitions.AppendLine();; } static void AppendArrayMultidimensionalGetLength( @@ -5938,35 +5950,35 @@ static void AppendArrayMultidimensionalGetLength( AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendIndent( indent + 1, builders.CppMethodDefinitions); builders.CppMethodDefinitions.Append( "assert(dimension >= 0 && dimension < "); builders.CppMethodDefinitions.Append(rank); - builders.CppMethodDefinitions.Append(");\n"); + builders.CppMethodDefinitions.AppendLine(");"); AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "int32_t length = InternalLengths[dimension];\n"); + builders.CppMethodDefinitions.AppendLine( + "int32_t length = InternalLengths[dimension];"); AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("if (length)\n"); + builders.CppMethodDefinitions.AppendLine("if (length)"); AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendIndent( indent + 2, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("return length;\n"); + builders.CppMethodDefinitions.AppendLine("return length;"); AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.AppendLine("}"); AppendCppPluginFunctionCall( false, GetTypeName(cppArrayTypeName, "System"), @@ -5980,8 +5992,8 @@ static void AppendArrayMultidimensionalGetLength( AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append( - "InternalLengths[dimension] = returnValue;\n"); + builders.CppMethodDefinitions.AppendLine( + "InternalLengths[dimension] = returnValue;"); AppendCppMethodReturn( typeof(int), TypeKind.Primitive, @@ -5990,11 +6002,11 @@ static void AppendArrayMultidimensionalGetLength( AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.AppendLine("}"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); + builders.CppMethodDefinitions.AppendLine();; } static void AppendArrayGetItem( @@ -6388,11 +6400,11 @@ static void AppendDelegate( AppendIndent( indent + 1, builders.CppTypeDefinitions); - builders.CppTypeDefinitions.Append("int32_t CppHandle;\n"); + builders.CppTypeDefinitions.AppendLine("int32_t CppHandle;"); AppendIndent( indent + 1, builders.CppTypeDefinitions); - builders.CppTypeDefinitions.Append("int32_t ClassHandle;\n"); + builders.CppTypeDefinitions.AppendLine("int32_t ClassHandle;"); // C++ method declarations AppendIndent( @@ -6632,24 +6644,24 @@ static void AppendDelegate( AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendIndent( indent + 1, builders.CppMethodDefinitions); builders.CppMethodDefinitions.Append("Plugin::"); builders.CppMethodDefinitions.Append(addFuncName); - builders.CppMethodDefinitions.Append("(Handle, del.Handle);\n"); + builders.CppMethodDefinitions.AppendLine("(Handle, del.Handle);"); AppendCppUnhandledExceptionHandling( indent + 1, builders.CppMethodDefinitions); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.AppendLine("}"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); + builders.CppMethodDefinitions.AppendLine();; // C++ remove AppendCppMethodDefinitionBegin( @@ -6664,24 +6676,24 @@ static void AppendDelegate( AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendIndent( indent + 1, builders.CppMethodDefinitions); builders.CppMethodDefinitions.Append("Plugin::"); builders.CppMethodDefinitions.Append(removeFuncName); - builders.CppMethodDefinitions.Append("(Handle, del.Handle);\n"); + builders.CppMethodDefinitions.AppendLine("(Handle, del.Handle);"); AppendCppUnhandledExceptionHandling( indent + 1, builders.CppMethodDefinitions); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.AppendLine("}"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); + builders.CppMethodDefinitions.AppendLine();; // C# GetDelegate call AppendCsharpGetDelegateCall( @@ -6693,27 +6705,27 @@ static void AppendDelegate( // C# class (beginning) builders.CsharpBaseTypes.Append("class "); builders.CsharpBaseTypes.Append(bindingTypeName); - builders.CsharpBaseTypes.Append('\n'); - builders.CsharpBaseTypes.Append("{\n"); + builders.CsharpBaseTypes.AppendLine();; + builders.CsharpBaseTypes.AppendLine("{"); // C# class fields - builders.CsharpBaseTypes.Append("\tpublic int CppHandle;\n"); + builders.CsharpBaseTypes.AppendLine("\tpublic int CppHandle;"); builders.CsharpBaseTypes.Append("\tpublic "); AppendCsharpTypeFullName( type, builders.CsharpBaseTypes); - builders.CsharpBaseTypes.Append(" Delegate;\n"); - builders.CsharpBaseTypes.Append("\t\n"); + builders.CsharpBaseTypes.AppendLine(" Delegate;"); + builders.CsharpBaseTypes.AppendLine("\t"); // C# class constructor builders.CsharpBaseTypes.Append("\tpublic "); builders.CsharpBaseTypes.Append(bindingTypeName); - builders.CsharpBaseTypes.Append("(int cppHandle)\n"); - builders.CsharpBaseTypes.Append("\t{\n"); - builders.CsharpBaseTypes.Append("\t\tCppHandle = cppHandle;\n"); - builders.CsharpBaseTypes.Append("\t\tDelegate = NativeInvoke;\n"); - builders.CsharpBaseTypes.Append("\t}\n"); - builders.CsharpBaseTypes.Append("\t\n"); + builders.CsharpBaseTypes.AppendLine("(int cppHandle)"); + builders.CsharpBaseTypes.AppendLine("\t{"); + builders.CsharpBaseTypes.AppendLine("\t\tCppHandle = cppHandle;"); + builders.CsharpBaseTypes.AppendLine("\t\tDelegate = NativeInvoke;"); + builders.CsharpBaseTypes.AppendLine("\t}"); + builders.CsharpBaseTypes.AppendLine("\t"); // Build the name of the C++ binding function that C# calls builders.TempStrBuilder.Length = 0; @@ -6741,8 +6753,8 @@ static void AppendDelegate( builders); // C# class (ending) - builders.CsharpBaseTypes.Append("}\n"); - builders.CsharpBaseTypes.Append('\n'); + builders.CsharpBaseTypes.AppendLine("}"); + builders.CsharpBaseTypes.AppendLine();; // Invoke() is how C++ invokes the delegate AppendBaseTypeMethodCallsCsharpMethod( @@ -7048,7 +7060,7 @@ static void AppendBaseType( AppendIndent( indent + 1, builders.CppTypeDefinitions); - builders.CppTypeDefinitions.Append("int32_t CppHandle;\n"); + builders.CppTypeDefinitions.AppendLine("int32_t CppHandle;"); // C++ constructor declarations for (int i = 0; i < numConstructors; ++i) @@ -7076,12 +7088,12 @@ static void AppendBaseType( AppendUppercaseWithUnderscores( derivedTypeTypeName.Name, builders.CppMacros); - builders.CppMacros.Append("_DEFAULT_CONSTRUCTOR_DECLARATION \\\n"); + builders.CppMacros.AppendLine("_DEFAULT_CONSTRUCTOR_DECLARATION \\"); AppendIndent(indent, builders.CppMacros); builders.CppMacros.Append(derivedTypeTypeName.Name); - builders.CppMacros.Append("(Plugin::InternalUse iu, int32_t handle);\n"); + builders.CppMacros.AppendLine("(Plugin::InternalUse iu, int32_t handle);"); AppendIndent(indent, builders.CppMacros); - builders.CppMacros.Append('\n'); + builders.CppMacros.AppendLine();; // C++ constructor definition macro builders.CppMacros.Append("#define "); @@ -7092,12 +7104,12 @@ static void AppendBaseType( AppendUppercaseWithUnderscores( derivedTypeTypeName.Name, builders.CppMacros); - builders.CppMacros.Append("_DEFAULT_CONSTRUCTOR_DEFINITION \\\n"); + builders.CppMacros.AppendLine("_DEFAULT_CONSTRUCTOR_DEFINITION \\"); AppendIndent(indent, builders.CppMacros); builders.CppMacros.Append(derivedTypeTypeName.Name); builders.CppMacros.Append("::"); builders.CppMacros.Append(derivedTypeTypeName.Name); - builders.CppMacros.Append("(Plugin::InternalUse iu, int32_t handle) \\\n"); + builders.CppMacros.AppendLine("(Plugin::InternalUse iu, int32_t handle) \\"); AppendCppConstructorInitializerList( cppCtorInitTypes, indent + 1, @@ -7108,13 +7120,13 @@ static void AppendBaseType( AppendCppTypeFullName( baseTypeTypeName, builders.CppMacros); - builders.CppMacros.Append("(iu, handle) \\\n"); + builders.CppMacros.AppendLine("(iu, handle) \\"); AppendIndent(indent, builders.CppMacros); - builders.CppMacros.Append("{ \\\n"); + builders.CppMacros.AppendLine("{ \\"); AppendIndent(indent, builders.CppMacros); - builders.CppMacros.Append("}\n"); + builders.CppMacros.AppendLine("}"); AppendIndent(indent, builders.CppMacros); - builders.CppMacros.Append('\n'); + builders.CppMacros.AppendLine();; // C++ constructor inline definition macro builders.CppMacros.Append("#define "); @@ -7125,10 +7137,10 @@ static void AppendBaseType( AppendUppercaseWithUnderscores( derivedTypeTypeName.Name, builders.CppMacros); - builders.CppMacros.Append("_DEFAULT_CONSTRUCTOR \\\n"); + builders.CppMacros.AppendLine("_DEFAULT_CONSTRUCTOR \\"); AppendIndent(indent, builders.CppMacros); builders.CppMacros.Append(derivedTypeTypeName.Name); - builders.CppMacros.Append("(Plugin::InternalUse iu, int32_t handle) \\\n"); + builders.CppMacros.AppendLine("(Plugin::InternalUse iu, int32_t handle) \\"); AppendCppConstructorInitializerList( cppCtorInitTypes, indent + 1, @@ -7139,13 +7151,13 @@ static void AppendBaseType( AppendCppTypeFullName( baseTypeTypeName, builders.CppMacros); - builders.CppMacros.Append("(iu, handle) \\\n"); + builders.CppMacros.AppendLine("(iu, handle) \\"); AppendIndent(indent, builders.CppMacros); - builders.CppMacros.Append("{ \\\n"); + builders.CppMacros.AppendLine("{ \\"); AppendIndent(indent, builders.CppMacros); - builders.CppMacros.Append("}\n"); + builders.CppMacros.AppendLine("}"); AppendIndent(indent, builders.CppMacros); - builders.CppMacros.Append('\n'); + builders.CppMacros.AppendLine();; // C++ default contents declaration macro builders.CppMacros.Append("#define "); @@ -7156,13 +7168,13 @@ static void AppendBaseType( AppendUppercaseWithUnderscores( derivedTypeTypeName.Name, builders.CppMacros); - builders.CppMacros.Append("_DEFAULT_CONTENTS_DECLARATION \\\n"); + builders.CppMacros.AppendLine("_DEFAULT_CONTENTS_DECLARATION \\"); AppendIndent(indent, builders.CppMacros); - builders.CppMacros.Append("void* operator new(size_t, void* p) noexcept; \\\n"); + builders.CppMacros.AppendLine("void* operator new(size_t, void* p) noexcept; \\"); AppendIndent(indent, builders.CppMacros); - builders.CppMacros.Append("void operator delete(void*, size_t) noexcept; \\\n"); + builders.CppMacros.AppendLine("void operator delete(void*, size_t) noexcept; \\"); AppendIndent(indent, builders.CppMacros); - builders.CppMacros.Append('\n'); + builders.CppMacros.AppendLine();; // C++ default contents definition macro builders.CppMacros.Append("#define "); @@ -7173,27 +7185,27 @@ static void AppendBaseType( AppendUppercaseWithUnderscores( derivedTypeTypeName.Name, builders.CppMacros); - builders.CppMacros.Append("_DEFAULT_CONTENTS_DEFINITION \\\n"); + builders.CppMacros.AppendLine("_DEFAULT_CONTENTS_DEFINITION \\"); AppendIndent(indent, builders.CppMacros); builders.CppMacros.Append("void* "); builders.CppMacros.Append(derivedTypeTypeName.Name); - builders.CppMacros.Append("::operator new(size_t, void* p) noexcept\\\n"); + builders.CppMacros.AppendLine("::operator new(size_t, void* p) noexcept\\"); AppendIndent(indent, builders.CppMacros); - builders.CppMacros.Append("{ \\\n"); + builders.CppMacros.AppendLine("{ \\"); AppendIndent(indent + 1, builders.CppMacros); - builders.CppMacros.Append("return p; \\\n"); + builders.CppMacros.AppendLine("return p; \\"); AppendIndent(indent, builders.CppMacros); - builders.CppMacros.Append("} \\\n"); + builders.CppMacros.AppendLine("} \\"); AppendIndent(indent, builders.CppMacros); builders.CppMacros.Append("void "); builders.CppMacros.Append(derivedTypeTypeName.Name); - builders.CppMacros.Append("::operator delete(void*, size_t) noexcept \\\n"); + builders.CppMacros.AppendLine("::operator delete(void*, size_t) noexcept \\"); AppendIndent(indent, builders.CppMacros); - builders.CppMacros.Append("{ \\\n"); + builders.CppMacros.AppendLine("{ \\"); AppendIndent(indent, builders.CppMacros); - builders.CppMacros.Append("}\n"); + builders.CppMacros.AppendLine("}"); AppendIndent(indent, builders.CppMacros); - builders.CppMacros.Append('\n'); + builders.CppMacros.AppendLine();; // C++ default contents inline definition macro builders.CppMacros.Append("#define "); @@ -7204,23 +7216,23 @@ static void AppendBaseType( AppendUppercaseWithUnderscores( derivedTypeTypeName.Name, builders.CppMacros); - builders.CppMacros.Append("_DEFAULT_CONTENTS\\\n"); + builders.CppMacros.AppendLine("_DEFAULT_CONTENTS\\"); AppendIndent(indent, builders.CppMacros); - builders.CppMacros.Append("void* operator new(size_t, void* p) noexcept \\\n"); + builders.CppMacros.AppendLine("void* operator new(size_t, void* p) noexcept \\"); AppendIndent(indent, builders.CppMacros); - builders.CppMacros.Append("{ \\\n"); + builders.CppMacros.AppendLine("{ \\"); AppendIndent(indent + 1, builders.CppMacros); - builders.CppMacros.Append("return p; \\\n"); + builders.CppMacros.AppendLine("return p; \\"); AppendIndent(indent, builders.CppMacros); - builders.CppMacros.Append("} \\\n"); + builders.CppMacros.AppendLine("} \\"); AppendIndent(indent, builders.CppMacros); - builders.CppMacros.Append("void operator delete(void*, size_t) noexcept \\\n"); + builders.CppMacros.AppendLine("void operator delete(void*, size_t) noexcept \\"); AppendIndent(indent, builders.CppMacros); - builders.CppMacros.Append("{ \\\n"); + builders.CppMacros.AppendLine("{ \\"); AppendIndent(indent, builders.CppMacros); - builders.CppMacros.Append("}\n"); + builders.CppMacros.AppendLine("}"); AppendIndent(indent, builders.CppMacros); - builders.CppMacros.Append('\n'); + builders.CppMacros.AppendLine();; // C++ function pointers AppendCppFunctionPointerDefinition( @@ -7403,11 +7415,11 @@ static void AppendBaseType( builders.CppMethodDefinitions); builders.CppMethodDefinitions.Append("DLLEXPORT int32_t "); builders.CppMethodDefinitions.Append(cppDefaultConstructorBindingFunctionName); - builders.CppMethodDefinitions.Append("(int32_t handle)\n"); + builders.CppMethodDefinitions.AppendLine("(int32_t handle)"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendIndent( indent + 1, builders.CppMethodDefinitions); @@ -7416,7 +7428,7 @@ static void AppendBaseType( builders.CppMethodDefinitions); builders.CppMethodDefinitions.Append("* memory = Plugin::StoreWhole"); builders.CppMethodDefinitions.Append(baseTypeTypeName.Name); - builders.CppMethodDefinitions.Append("();\n"); + builders.CppMethodDefinitions.AppendLine("();"); AppendIndent( indent + 1, builders.CppMethodDefinitions); @@ -7427,15 +7439,16 @@ static void AppendBaseType( AppendCppTypeFullName( derivedTypeTypeName, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("(Plugin::InternalUse::Only, handle);\n"); + builders.CppMethodDefinitions.AppendLine("(Plugin::InternalUse::Only, handle);"); AppendIndent( indent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("return thiz->CppHandle;\n"); + builders.CppMethodDefinitions.AppendLine("return thiz->CppHandle;"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n\n"); + builders.CppMethodDefinitions.AppendLine("}"); + builders.CppMethodDefinitions.AppendLine(); // C# usage of the C++ binding function to create from C# default constructor ParameterInfo[] cppDefaultConstructorBindingFunctionParams = ConvertParameters( @@ -7472,11 +7485,11 @@ static void AppendBaseType( builders.CppMethodDefinitions); builders.CppMethodDefinitions.Append("DLLEXPORT void "); builders.CppMethodDefinitions.Append(cppDestroyBindingFunctionName); - builders.CppMethodDefinitions.Append("(int32_t cppHandle)\n"); + builders.CppMethodDefinitions.AppendLine("(int32_t cppHandle)"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendIndent( indent + 1, builders.CppMethodDefinitions); @@ -7485,7 +7498,7 @@ static void AppendBaseType( builders.CppMethodDefinitions); builders.CppMethodDefinitions.Append("* instance = Plugin::Get"); builders.CppMethodDefinitions.Append(baseTypeTypeName.Name); - builders.CppMethodDefinitions.Append("(cppHandle);\n"); + builders.CppMethodDefinitions.AppendLine("(cppHandle);"); AppendIndent( indent + 1, builders.CppMethodDefinitions); @@ -7493,11 +7506,12 @@ static void AppendBaseType( AppendCppTypeName( baseTypeTypeName, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("();\n"); + builders.CppMethodDefinitions.AppendLine("();"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n\n"); + builders.CppMethodDefinitions.AppendLine("}"); + builders.CppMethodDefinitions.AppendLine(); // C# usage of the C++ binding function to destroy from C# default constructor ParameterInfo[] cppDestroyBindingFunctionParams = ConvertParameters( @@ -7529,23 +7543,23 @@ static void AppendBaseType( // C# DestroyFunction enumerator builders.CsharpDestroyFunctionEnumerators.Append("\t\t\t"); builders.CsharpDestroyFunctionEnumerators.Append(baseTypeTypeName.Name); - builders.CsharpDestroyFunctionEnumerators.Append(",\n"); + builders.CsharpDestroyFunctionEnumerators.AppendLine(","); // C# Destroy queue cases builders.CsharpDestroyQueueCases.Append("\t\t\t\t\t\tcase DestroyFunction."); builders.CsharpDestroyQueueCases.Append(baseTypeTypeName.Name); - builders.CsharpDestroyQueueCases.Append(":\n"); + builders.CsharpDestroyQueueCases.AppendLine(":"); builders.CsharpDestroyQueueCases.Append("\t\t\t\t\t\t\t"); builders.CsharpDestroyQueueCases.Append(cppDestroyBindingFunctionName); - builders.CsharpDestroyQueueCases.Append("(entry.CppHandle);\n"); - builders.CsharpDestroyQueueCases.Append("\t\t\t\t\t\t\tbreak;\n"); + builders.CsharpDestroyQueueCases.AppendLine("(entry.CppHandle);"); + builders.CsharpDestroyQueueCases.AppendLine("\t\t\t\t\t\t\tbreak;"); } // C# class (beginning) builders.CsharpBaseTypes.Append("namespace "); builders.CsharpBaseTypes.Append(baseTypeTypeName.Namespace); - builders.CsharpBaseTypes.Append('\n'); - builders.CsharpBaseTypes.Append("{\n"); + builders.CsharpBaseTypes.AppendLine();; + builders.CsharpBaseTypes.AppendLine("{"); builders.CsharpBaseTypes.Append("\tclass "); builders.CsharpBaseTypes.Append(baseTypeTypeName.Name); if (jsonBaseType != null) @@ -7555,12 +7569,12 @@ static void AppendBaseType( type, builders.CsharpBaseTypes); } - builders.CsharpBaseTypes.Append('\n'); - builders.CsharpBaseTypes.Append("\t{\n"); + builders.CsharpBaseTypes.AppendLine();; + builders.CsharpBaseTypes.AppendLine("\t{"); // C# class fields - builders.CsharpBaseTypes.Append("\t\tpublic int CppHandle;\n"); - builders.CsharpBaseTypes.Append("\t\t\n"); + builders.CsharpBaseTypes.AppendLine("\t\tpublic int CppHandle;"); + builders.CsharpBaseTypes.AppendLine("\t\t"); if (derivedTypeTypeName.Name != null) { @@ -7569,33 +7583,33 @@ static void AppendBaseType( { builders.CsharpBaseTypes.Append("\t\tpublic "); builders.CsharpBaseTypes.Append(baseTypeTypeName.Name); - builders.CsharpBaseTypes.Append("()\n"); - builders.CsharpBaseTypes.Append("\t\t{\n"); - builders.CsharpBaseTypes.Append( - "\t\t\tint handle = NativeScript.Bindings.ObjectStore.Store(this);\n"); + builders.CsharpBaseTypes.AppendLine("()"); + builders.CsharpBaseTypes.AppendLine("\t\t{"); + builders.CsharpBaseTypes.AppendLine( + "\t\t\tint handle = NativeScript.Bindings.ObjectStore.Store(this);"); builders.CsharpBaseTypes.Append( "\t\t\tCppHandle = NativeScript.Bindings.New"); builders.CsharpBaseTypes.Append(baseTypeTypeName.Name); - builders.CsharpBaseTypes.Append("(handle);\n"); - builders.CsharpBaseTypes.Append("\t\t}\n"); - builders.CsharpBaseTypes.Append("\t\t\n"); + builders.CsharpBaseTypes.AppendLine("(handle);"); + builders.CsharpBaseTypes.AppendLine("\t\t}"); + builders.CsharpBaseTypes.AppendLine("\t\t"); } // C# finalizer/destructor builders.CsharpBaseTypes.Append("\t\t~"); builders.CsharpBaseTypes.Append(baseTypeTypeName.Name); - builders.CsharpBaseTypes.Append("()\n"); - builders.CsharpBaseTypes.Append("\t\t{\n"); - builders.CsharpBaseTypes.Append("\t\t\tif (CppHandle != 0)\n"); - builders.CsharpBaseTypes.Append("\t\t\t{\n"); + builders.CsharpBaseTypes.AppendLine("()"); + builders.CsharpBaseTypes.AppendLine("\t\t{"); + builders.CsharpBaseTypes.AppendLine("\t\t\tif (CppHandle != 0)"); + builders.CsharpBaseTypes.AppendLine("\t\t\t{"); builders.CsharpBaseTypes.Append( "\t\t\t\tNativeScript.Bindings.QueueDestroy(NativeScript.Bindings.DestroyFunction."); builders.CsharpBaseTypes.Append(baseTypeTypeName.Name); - builders.CsharpBaseTypes.Append(", CppHandle);\n"); - builders.CsharpBaseTypes.Append("\t\t\t\tCppHandle = 0;\n"); - builders.CsharpBaseTypes.Append("\t\t\t}\n"); - builders.CsharpBaseTypes.Append("\t\t}\n"); - builders.CsharpBaseTypes.Append("\t\t\n"); + builders.CsharpBaseTypes.AppendLine(", CppHandle);"); + builders.CsharpBaseTypes.AppendLine("\t\t\t\tCppHandle = 0;"); + builders.CsharpBaseTypes.AppendLine("\t\t\t}"); + builders.CsharpBaseTypes.AppendLine("\t\t}"); + builders.CsharpBaseTypes.AppendLine("\t\t"); } // C# class constructors @@ -7612,16 +7626,16 @@ static void AppendBaseType( parameters, builders.CsharpBaseTypes); } - builders.CsharpBaseTypes.Append(")\n"); + builders.CsharpBaseTypes.AppendLine(")"); builders.CsharpBaseTypes.Append("\t\t\t: base("); AppendCsharpFunctionCallParameters( parameters, builders.CsharpBaseTypes); - builders.CsharpBaseTypes.Append(")\n"); - builders.CsharpBaseTypes.Append("\t\t{\n"); - builders.CsharpBaseTypes.Append("\t\t\tCppHandle = cppHandle;\n"); - builders.CsharpBaseTypes.Append("\t\t}\n"); - builders.CsharpBaseTypes.Append("\t\t\n"); + builders.CsharpBaseTypes.AppendLine(")"); + builders.CsharpBaseTypes.AppendLine("\t\t{"); + builders.CsharpBaseTypes.AppendLine("\t\t\tCppHandle = cppHandle;"); + builders.CsharpBaseTypes.AppendLine("\t\t}"); + builders.CsharpBaseTypes.AppendLine("\t\t"); } // C# constructor delegate type @@ -7975,9 +7989,9 @@ static void AppendBaseType( } // C# class (ending) - builders.CsharpBaseTypes.Append("\t}\n"); - builders.CsharpBaseTypes.Append("}\n"); - builders.CsharpBaseTypes.Append("\n"); + builders.CsharpBaseTypes.AppendLine("\t}"); + builders.CsharpBaseTypes.AppendLine("}"); + builders.CsharpBaseTypes.AppendLine(); // C++ method definitions (end) AppendCppMethodDefinitionsEnd( @@ -8077,8 +8091,8 @@ static void AppendBaseTypeProperty( builders.CsharpBaseTypes); builders.CsharpBaseTypes.Append(']'); } - builders.CsharpBaseTypes.Append('\n'); - builders.CsharpBaseTypes.Append("\t\t{\n"); + builders.CsharpBaseTypes.AppendLine();; + builders.CsharpBaseTypes.AppendLine("\t\t{"); TypeKind propertyTypeKind = GetTypeKind( propertyInfo.PropertyType); @@ -8115,8 +8129,8 @@ static void AppendBaseTypeProperty( builders); } - builders.CsharpBaseTypes.Append("\t\t}\n"); - builders.CsharpBaseTypes.Append("\t\t\n"); + builders.CsharpBaseTypes.AppendLine("\t\t}"); + builders.CsharpBaseTypes.AppendLine("\t\t"); } static void AppendBaseTypeEvent( @@ -8142,8 +8156,8 @@ static void AppendBaseTypeEvent( builders.CsharpBaseTypes); builders.CsharpBaseTypes.Append(' '); builders.CsharpBaseTypes.Append(eventInfo.Name); - builders.CsharpBaseTypes.Append('\n'); - builders.CsharpBaseTypes.Append("\t\t{\n"); + builders.CsharpBaseTypes.AppendLine();; + builders.CsharpBaseTypes.AppendLine("\t\t{"); TypeKind eventHandlerTypeKind = GetTypeKind( eventInfo.EventHandlerType); @@ -8180,8 +8194,8 @@ static void AppendBaseTypeEvent( builders); } - builders.CsharpBaseTypes.Append("\t\t\t}\n"); - builders.CsharpBaseTypes.Append("\t\t\t\n"); + builders.CsharpBaseTypes.AppendLine("\t\t\t}"); + builders.CsharpBaseTypes.AppendLine("\t\t\t"); } static void AppendBaseTypeNativePropertyOrEvent( @@ -8238,8 +8252,8 @@ static void AppendBaseTypeNativePropertyOrEvent( operationType, 1, operationType.Length - 1); - builders.CsharpBaseTypes.Append('\n'); - builders.CsharpBaseTypes.Append("\t\t\t{\n"); + builders.CsharpBaseTypes.AppendLine();; + builders.CsharpBaseTypes.AppendLine("\t\t\t{"); AppendCsharpBaseTypeCppMethodCallMethodBody( methodInfo, nativeInvokeFuncName, @@ -8247,7 +8261,7 @@ static void AppendBaseTypeNativePropertyOrEvent( propertyOrEventTypeKind, 4, builders.CsharpBaseTypes); - builders.CsharpBaseTypes.Append("\t\t\t}\n"); + builders.CsharpBaseTypes.AppendLine("\t\t\t}"); } static void AppendCsharpParams( @@ -8339,7 +8353,7 @@ static void AppendBaseTypeMethodCallsCsharpMethod( AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendCppPluginFunctionCall( false, GetTypeName(type), @@ -8358,11 +8372,11 @@ static void AppendBaseTypeMethodCallsCsharpMethod( AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.AppendLine("}"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); + builders.CppMethodDefinitions.AppendLine();; // C# delegate type for the binding function that C++ calls ParameterInfo[] invokeParamsWithThis = new ParameterInfo[ @@ -8524,7 +8538,7 @@ static ParameterInfo[] AppendBaseTypeCppNativeInvokeCall( AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); if (invokeMethod.ReturnType != typeof(void)) { TypeKind returnTypeKind = GetTypeKind(invokeMethod.ReturnType); @@ -8534,21 +8548,21 @@ static ParameterInfo[] AppendBaseTypeCppNativeInvokeCall( if (returnTypeKind == TypeKind.Class || returnTypeKind == TypeKind.ManagedStruct) { - builders.CppMethodDefinitions.Append("return nullptr;\n"); + builders.CppMethodDefinitions.AppendLine("return nullptr;"); } else { - builders.CppMethodDefinitions.Append("return {};\n"); + builders.CppMethodDefinitions.AppendLine("return {};"); } } AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.AppendLine("}"); AppendIndent( indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); + builders.CppMethodDefinitions.AppendLine();; // C++ binding function that C# calls. Calls the C++ method. TypeKind invokeReturnTypeKind = GetTypeKind( @@ -8630,20 +8644,20 @@ static void AppendCsharpBaseTypeReleaseFunction( AppendCsharpTypeFullName( bindingTypeTypeName, output); - output.Append(" thiz;\n"); + output.AppendLine(" thiz;"); } if (typeIsDelegate) { - output.Append("\t\t\t\tif (classHandle != 0)\n"); - output.Append("\t\t\t\t{\n"); + output.AppendLine("\t\t\t\tif (classHandle != 0)"); + output.AppendLine("\t\t\t\t{"); output.Append("\t\t\t\t\tthiz = ("); AppendCsharpTypeFullName( bindingTypeTypeName, output); - output.Append(")ObjectStore.Remove(classHandle);\n"); - output.Append("\t\t\t\t\tthiz.CppHandle = 0;\n"); - output.Append("\t\t\t\t}\n"); - output.Append("\t\t\t\t\n"); + output.AppendLine(")ObjectStore.Remove(classHandle);"); + output.AppendLine("\t\t\t\t\tthiz.CppHandle = 0;"); + output.AppendLine("\t\t\t\t}"); + output.AppendLine("\t\t\t\t"); } if (derivedName != null) { @@ -8651,12 +8665,12 @@ static void AppendCsharpBaseTypeReleaseFunction( AppendCsharpTypeFullName( bindingTypeTypeName, output); - output.Append(")ObjectStore.Get(handle);\n"); - output.Append("\t\t\t\tint cppHandle = thiz.CppHandle;\n"); - output.Append("\t\t\t\tthiz.CppHandle = 0;\n"); + output.AppendLine(")ObjectStore.Get(handle);"); + output.AppendLine("\t\t\t\tint cppHandle = thiz.CppHandle;"); + output.AppendLine("\t\t\t\tthiz.CppHandle = 0;"); output.Append("\t\t\t\tQueueDestroy(DestroyFunction."); output.Append(bindingTypeTypeName.Name); - output.Append(", cppHandle);\n"); + output.AppendLine(", cppHandle);"); } output.Append("\t\t\t\tObjectStore.Remove(handle);"); AppendCsharpFunctionReturn( @@ -8692,8 +8706,8 @@ static void AppendCsharpBaseTypeCppMethodCallMethod( AppendCsharpParams( invokeParams, output); - output.Append(")\n"); - output.Append("\t\t{\n"); + output.AppendLine(")"); + output.AppendLine("\t\t{"); AppendCsharpBaseTypeCppMethodCallMethodBody( invokeMethod, nativeInvokeFuncName, @@ -8701,8 +8715,8 @@ static void AppendCsharpBaseTypeCppMethodCallMethod( invokeReturnTypeKind, 3, output); - output.Append("\t\t}\n"); - output.Append("\t\n"); + output.AppendLine("\t\t}"); + output.AppendLine("\t"); } static void AppendCsharpBaseTypeCppMethodCallMethodBody( @@ -8716,15 +8730,15 @@ static void AppendCsharpBaseTypeCppMethodCallMethodBody( AppendIndent( indent, output); - output.Append("if (CppHandle != 0)\n"); + output.AppendLine("if (CppHandle != 0)"); AppendIndent( indent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( indent + 1, output); - output.Append("int thisHandle = CppHandle;\n"); + output.AppendLine("int thisHandle = CppHandle;"); AppendCppFunctionCall( nativeInvokeFuncName, invokeParamsWithThis, @@ -8753,17 +8767,17 @@ static void AppendCsharpBaseTypeCppMethodCallMethodBody( AppendHandleStoreTypeName( invokeMethod.ReturnType, output); - output.Append(".Get(returnVal);\n"); + output.AppendLine(".Get(returnVal);"); break; default: - output.Append("returnVal;\n"); + output.AppendLine("returnVal;"); break; } } AppendIndent( indent, output); - output.Append("}\n"); + output.AppendLine("}"); if (invokeMethod.ReturnType != typeof(void)) { AppendIndent( @@ -8773,7 +8787,7 @@ static void AppendCsharpBaseTypeCppMethodCallMethodBody( AppendCsharpTypeFullName( invokeMethod.ReturnType, output); - output.Append(");\n"); + output.AppendLine(");"); } } @@ -8804,11 +8818,11 @@ static void AppendCsharpBaseTypeConstructorFunction( cppConstructorParams, output); } - output.Append(");\n"); + output.AppendLine(");"); if (typeIsDelegate) { - output.Append( - "\t\t\t\tclassHandle = NativeScript.Bindings.ObjectStore.Store(thiz);\n"); + output.AppendLine( + "\t\t\t\tclassHandle = NativeScript.Bindings.ObjectStore.Store(thiz);"); output.Append( "\t\t\t\thandle = NativeScript.Bindings.ObjectStore.Store(thiz.Delegate);"); } @@ -8918,19 +8932,19 @@ static void AppendCppBaseTypeMethodInvokeBindingFunction( output.Append(", "); } } - output.Append(")\n"); + output.AppendLine(")"); AppendIndent( indent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( indent + 1, output); - output.Append("try\n"); + output.AppendLine("try"); AppendIndent( indent + 1, output); - output.Append("{\n"); + output.AppendLine("{"); foreach (ParameterInfo parameter in methodParams) { if (parameter.Kind == TypeKind.Class || @@ -8947,7 +8961,7 @@ static void AppendCppBaseTypeMethodInvokeBindingFunction( output); output.Append("(Plugin::InternalUse::Only, "); output.Append(parameter.Name); - output.Append("Handle);\n"); + output.AppendLine("Handle);"); } } AppendIndent( @@ -8987,45 +9001,45 @@ static void AppendCppBaseTypeMethodInvokeBindingFunction( { output.Append(".Handle"); } - output.Append(";\n"); + output.AppendLine(";"); AppendIndent( indent + 1, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( indent + 1, output); - output.Append( - "catch (System::Exception ex)\n"); + output.AppendLine( + "catch (System::Exception ex)"); AppendIndent( indent + 1, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( indent + 2, output); - output.Append( - "Plugin::SetException(ex.Handle);\n"); + output.AppendLine( + "Plugin::SetException(ex.Handle);"); if (method.ReturnType != typeof(void)) { AppendIndent( indent + 2, output); - output.Append( - "return {};\n"); + output.AppendLine( + "return {};"); } AppendIndent( indent + 1, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( indent + 1, output); - output.Append("catch (...)\n"); + output.AppendLine("catch (...)"); AppendIndent( indent + 1, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( indent + 2, output); @@ -9034,37 +9048,37 @@ static void AppendCppBaseTypeMethodInvokeBindingFunction( AppendCppTypeFullName( type, output); - output.Append("\";\n"); + output.AppendLine("\";"); AppendIndent( indent + 2, output); - output.Append( - "System::Exception ex(msg);\n"); + output.AppendLine( + "System::Exception ex(msg);"); AppendIndent( indent + 2, output); - output.Append( - "Plugin::SetException(ex.Handle);\n"); + output.AppendLine( + "Plugin::SetException(ex.Handle);"); if (method.ReturnType != typeof(void)) { AppendIndent( indent + 2, output); - output.Append( - "return {};\n"); + output.AppendLine( + "return {};"); } AppendIndent( indent + 1, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( indent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( indent, output); - output.Append('\n'); + output.AppendLine();; } static void AppendCppBaseTypeInequalityOperator( @@ -9091,24 +9105,24 @@ static void AppendCppBaseTypeInequalityOperator( AppendCppTypeParameters( typeIsDelegate ? typeParams : null, output); - output.Append("& other) const\n"); + output.AppendLine("& other) const"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append( - "return Handle != other.Handle;\n"); + output.AppendLine( + "return Handle != other.Handle;"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append('\n'); + output.AppendLine();; } static void AppendCppBaseTypeEqualityOperator( @@ -9135,24 +9149,24 @@ static void AppendCppBaseTypeEqualityOperator( AppendCppTypeParameters( typeIsDelegate ? typeParams : null, output); - output.Append("& other) const\n"); + output.AppendLine("& other) const"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append( - "return Handle == other.Handle;\n"); + output.AppendLine( + "return Handle == other.Handle;"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append('\n'); + output.AppendLine();; } static void AppendCppBaseTypeMoveAssignmentOperator( @@ -9187,60 +9201,60 @@ static void AppendCppBaseTypeMoveAssignmentOperator( AppendCppTypeParameters( typeIsDelegate ? typeParams : null, output); - output.Append("&& other)\n"); + output.AppendLine("&& other)"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 1, output); output.Append("Plugin::Remove"); output.Append(bindingTypeName); - output.Append("(CppHandle);\n"); + output.AppendLine("(CppHandle);"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("CppHandle = 0;\n"); + output.AppendLine("CppHandle = 0;"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("if (Handle)\n"); + output.AppendLine("if (Handle)"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append("int32_t handle = Handle;\n"); + output.AppendLine("int32_t handle = Handle;"); if (typeIsDelegate) { AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append("int32_t classHandle = ClassHandle;\n"); + output.AppendLine("int32_t classHandle = ClassHandle;"); } AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append("Handle = 0;\n"); + output.AppendLine("Handle = 0;"); if (typeIsDelegate) { AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append("ClassHandle = 0;\n"); + output.AppendLine("ClassHandle = 0;"); } AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append( - "if (Plugin::DereferenceManagedClassNoRelease(handle))\n"); + output.AppendLine( + "if (Plugin::DereferenceManagedClassNoRelease(handle))"); AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 3, output); @@ -9251,50 +9265,50 @@ static void AppendCppBaseTypeMoveAssignmentOperator( { output.Append(", classHandle"); } - output.Append(");\n"); + output.AppendLine(");"); AppendCppUnhandledExceptionHandling( cppMethodDefinitionsIndent + 3, output); AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("}\n"); + output.AppendLine("}"); if (typeIsDelegate) { AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append( - "ClassHandle = other.ClassHandle;\n"); + output.AppendLine( + "ClassHandle = other.ClassHandle;"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("other.ClassHandle = 0;\n"); + output.AppendLine("other.ClassHandle = 0;"); } AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("Handle = other.Handle;\n"); + output.AppendLine("Handle = other.Handle;"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("other.Handle = 0;\n"); + output.AppendLine("other.Handle = 0;"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("return *this;\n"); + output.AppendLine("return *this;"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append('\n'); + output.AppendLine();; } static void AppendCppBaseTypeAssignmentOperatorNullptr( @@ -9321,51 +9335,51 @@ static void AppendCppBaseTypeAssignmentOperatorNullptr( AppendCppTypeParameters( typeIsDelegate ? typeParams : null, output); - output.Append( - "::operator=(decltype(nullptr))\n"); + output.AppendLine( + "::operator=(decltype(nullptr))"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("if (Handle)\n"); + output.AppendLine("if (Handle)"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append("int32_t handle = Handle;\n"); + output.AppendLine("int32_t handle = Handle;"); if (typeIsDelegate) { AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append("int32_t classHandle = ClassHandle;\n"); + output.AppendLine("int32_t classHandle = ClassHandle;"); } AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append("Handle = 0;\n"); + output.AppendLine("Handle = 0;"); if (typeIsDelegate) { AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append("ClassHandle = 0;\n"); + output.AppendLine("ClassHandle = 0;"); } AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append( - "if (Plugin::DereferenceManagedClassNoRelease(handle))\n"); + output.AppendLine( + "if (Plugin::DereferenceManagedClassNoRelease(handle))"); AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 3, output); @@ -9376,41 +9390,41 @@ static void AppendCppBaseTypeAssignmentOperatorNullptr( { output.Append(", classHandle"); } - output.Append(");\n"); + output.AppendLine(");"); AppendCppUnhandledExceptionHandling( cppMethodDefinitionsIndent + 3, output); AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("}\n"); + output.AppendLine("}"); if (typeIsDelegate) { AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("ClassHandle = 0;\n"); + output.AppendLine("ClassHandle = 0;"); } AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("Handle = 0;\n"); + output.AppendLine("Handle = 0;"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("return *this;\n"); + output.AppendLine("return *this;"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append('\n'); + output.AppendLine();; } static void AppendCppBaseTypeAssignmentOperatorSameType( @@ -9443,11 +9457,11 @@ static void AppendCppBaseTypeAssignmentOperatorSameType( AppendCppTypeParameters( typeIsDelegate ? typeParams : null, output); - output.Append("& other)\n"); + output.AppendLine("& other)"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendSetHandle( typeTypeName, TypeKind.Class, @@ -9461,21 +9475,21 @@ static void AppendCppBaseTypeAssignmentOperatorSameType( AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append( - "ClassHandle = other.ClassHandle;\n"); + output.AppendLine( + "ClassHandle = other.ClassHandle;"); } AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("return *this;\n"); + output.AppendLine("return *this;"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append('\n'); + output.AppendLine();; } static void AppendCppBaseTypeDestructor( @@ -9505,11 +9519,11 @@ static void AppendCppBaseTypeDestructor( AppendCppTypeParameters( typeIsDelegate ? typeParams : null, output); - output.Append("()\n"); + output.AppendLine("()"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("{\n"); + output.AppendLine("{"); if (!string.IsNullOrEmpty(derivedTypeName)) { AppendIndent( @@ -9517,57 +9531,57 @@ static void AppendCppBaseTypeDestructor( output); output.Append("Plugin::RemoveWhole"); output.Append(bindingTypeName); - output.Append("(this);\n"); + output.AppendLine("(this);"); } AppendIndent( cppMethodDefinitionsIndent + 1, output); output.Append("Plugin::Remove"); output.Append(typeName); - output.Append("(CppHandle);\n"); + output.AppendLine("(CppHandle);"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("CppHandle = 0;\n"); + output.AppendLine("CppHandle = 0;"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("if (Handle)\n"); + output.AppendLine("if (Handle)"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append("int32_t handle = Handle;\n"); + output.AppendLine("int32_t handle = Handle;"); if (typeIsDelegate) { AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append("int32_t classHandle = ClassHandle;\n"); + output.AppendLine("int32_t classHandle = ClassHandle;"); } AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append("Handle = 0;\n"); + output.AppendLine("Handle = 0;"); if (typeIsDelegate) { AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append("ClassHandle = 0;\n"); + output.AppendLine("ClassHandle = 0;"); } AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append( - "if (Plugin::DereferenceManagedClassNoRelease(handle))\n"); + output.AppendLine( + "if (Plugin::DereferenceManagedClassNoRelease(handle))"); AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 3, output); @@ -9578,26 +9592,26 @@ static void AppendCppBaseTypeDestructor( { output.Append(", classHandle"); } - output.Append(");\n"); + output.AppendLine(");"); AppendCppUnhandledExceptionHandling( cppMethodDefinitionsIndent + 3, output); AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append('\n'); + output.AppendLine();; } static void AppendCppBaseTypeHandleConstructor( @@ -9622,8 +9636,8 @@ static void AppendCppBaseTypeHandleConstructor( AppendCppTypeName( typeTypeName, output); - output.Append( - "(Plugin::InternalUse, int32_t handle)\n"); + output.AppendLine( + "(Plugin::InternalUse, int32_t handle)"); AppendCppConstructorInitializerList( interfaceTypes, cppMethodDefinitionsIndent + 1, @@ -9631,50 +9645,50 @@ static void AppendCppBaseTypeHandleConstructor( AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("Handle = handle;\n"); + output.AppendLine("Handle = handle;"); AppendIndent( cppMethodDefinitionsIndent + 1, output); output.Append("CppHandle = Plugin::Store"); output.Append(bindingTypeName); - output.Append("(this);\n"); + output.AppendLine("(this);"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("if (Handle)\n"); + output.AppendLine("if (Handle)"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append( - "Plugin::ReferenceManagedClass(Handle);\n"); + output.AppendLine( + "Plugin::ReferenceManagedClass(Handle);"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("}\n"); + output.AppendLine("}"); if (typeIsDelegate) { AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append( - "ClassHandle = 0;\n"); + output.AppendLine( + "ClassHandle = 0;"); } AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append('\n'); + output.AppendLine();; } static void AppendCppBaseTypeMoveConstructor( @@ -9705,7 +9719,7 @@ static void AppendCppBaseTypeMoveConstructor( AppendCppTypeParameters( typeIsDelegate ? typeParams : null, output); - output.Append("&& other)\n"); + output.AppendLine("&& other)"); AppendCppConstructorInitializerList( interfaceTypes, cppMethodDefinitionsIndent + 1, @@ -9713,48 +9727,48 @@ static void AppendCppBaseTypeMoveConstructor( AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append( - "Handle = other.Handle;\n"); + output.AppendLine( + "Handle = other.Handle;"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append( - "CppHandle = other.CppHandle;\n"); + output.AppendLine( + "CppHandle = other.CppHandle;"); if (typeIsDelegate) { AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append( - "ClassHandle = other.ClassHandle;\n"); + output.AppendLine( + "ClassHandle = other.ClassHandle;"); } AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("other.Handle = 0;\n"); + output.AppendLine("other.Handle = 0;"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("other.CppHandle = 0;\n"); + output.AppendLine("other.CppHandle = 0;"); if (typeIsDelegate) { AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("other.ClassHandle = 0;\n"); + output.AppendLine("other.ClassHandle = 0;"); } AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append('\n'); + output.AppendLine();; } static void AppendCppBaseTypeCopyConstructor( @@ -9786,7 +9800,7 @@ static void AppendCppBaseTypeCopyConstructor( AppendCppTypeParameters( typeIsDelegate ? typeParams : null, output); - output.Append("& other)\n"); + output.AppendLine("& other)"); AppendCppConstructorInitializerList( interfaceTypes, cppMethodDefinitionsIndent + 1, @@ -9794,51 +9808,51 @@ static void AppendCppBaseTypeCopyConstructor( AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append( - "Handle = other.Handle;\n"); + output.AppendLine( + "Handle = other.Handle;"); AppendIndent( cppMethodDefinitionsIndent + 1, output); output.Append("CppHandle = Plugin::Store"); output.Append(typeName); - output.Append("(this);\n"); + output.AppendLine("(this);"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("if (Handle)\n"); + output.AppendLine("if (Handle)"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append( - "Plugin::ReferenceManagedClass(Handle);\n"); + output.AppendLine( + "Plugin::ReferenceManagedClass(Handle);"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("}\n"); + output.AppendLine("}"); if (typeIsDelegate) { AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append( - "ClassHandle = other.ClassHandle;\n"); + output.AppendLine( + "ClassHandle = other.ClassHandle;"); } AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append('\n'); + output.AppendLine();; } static void AppendCppBaseTypeNullptrConstructor( @@ -9863,7 +9877,7 @@ static void AppendCppBaseTypeNullptrConstructor( AppendCppTypeName( cppTypeTypeName, output); - output.Append("(decltype(nullptr))\n"); + output.AppendLine("(decltype(nullptr))"); AppendCppConstructorInitializerList( interfaceTypes, cppMethodDefinitionsIndent + 1, @@ -9871,28 +9885,28 @@ static void AppendCppBaseTypeNullptrConstructor( AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 1, output); output.Append("CppHandle = Plugin::Store"); output.Append(typeName); - output.Append("(this);\n"); + output.AppendLine("(this);"); if (typeIsDelegate) { AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("ClassHandle = 0;\n"); + output.AppendLine("ClassHandle = 0;"); } AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append('\n'); + output.AppendLine();; } static void AppendCppBaseTypeConstructor( @@ -9925,27 +9939,27 @@ static void AppendCppBaseTypeConstructor( AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 1, output); output.Append("CppHandle = Plugin::Store"); output.Append(bindingTypeName); - output.Append("(this);\n"); + output.AppendLine("(this);"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("System::Int32* handle = (System::Int32*)&Handle;\n"); + output.AppendLine("System::Int32* handle = (System::Int32*)&Handle;"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("int32_t cppHandle = CppHandle;\n"); + output.AppendLine("int32_t cppHandle = CppHandle;"); if (typeIsDelegate) { AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("System::Int32* classHandle = (System::Int32*)&ClassHandle;\n"); + output.AppendLine("System::Int32* classHandle = (System::Int32*)&ClassHandle;"); } AppendCppPluginFunctionCall( true, @@ -9960,60 +9974,60 @@ static void AppendCppBaseTypeConstructor( AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("if (Handle)\n"); + output.AppendLine("if (Handle)"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append( - "Plugin::ReferenceManagedClass(Handle);\n"); + output.AppendLine( + "Plugin::ReferenceManagedClass(Handle);"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("else\n"); + output.AppendLine("else"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent( cppMethodDefinitionsIndent + 2, output); output.Append("Plugin::Remove"); output.Append(bindingTypeName); - output.Append("(CppHandle);\n"); + output.AppendLine("(CppHandle);"); if (typeIsDelegate) { AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append("ClassHandle = 0;\n"); + output.AppendLine("ClassHandle = 0;"); } AppendIndent( cppMethodDefinitionsIndent + 2, output); - output.Append("CppHandle = 0;\n"); + output.AppendLine("CppHandle = 0;"); AppendIndent( cppMethodDefinitionsIndent + 1, output); - output.Append("}\n"); + output.AppendLine("}"); AppendCppUnhandledExceptionHandling( cppMethodDefinitionsIndent + 1, output); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent( cppMethodDefinitionsIndent, output); - output.Append('\n'); + output.AppendLine();; } static void AppendCppPointerFreeListInit( @@ -10028,7 +10042,7 @@ static void AppendCppPointerFreeListInit( output.Append(typeName); output.Append("FreeListSize = "); output.Append(maxSimultaneous); - output.Append(";\n"); + output.AppendLine(";"); output.Append("\tPlugin::"); output.Append(typeName); @@ -10039,7 +10053,7 @@ static void AppendCppPointerFreeListInit( AppendCppTypeParameters( typeParams, output); - output.Append("**)curMemory;\n"); + output.AppendLine("**)curMemory;"); output.Append("\tcurMemory += "); output.Append(maxSimultaneous); @@ -10050,14 +10064,14 @@ static void AppendCppPointerFreeListInit( AppendCppTypeParameters( typeParams, output); - output.Append("*);\n"); + output.AppendLine("*);"); - output.Append("\t\n"); + output.AppendLine("\t"); outputFirstBoot.Append("\t\tfor (int32_t i = 0, end = Plugin::"); outputFirstBoot.Append(typeName); - outputFirstBoot.Append("FreeListSize - 1; i < end; ++i)\n"); - outputFirstBoot.Append("\t\t{\n"); + outputFirstBoot.AppendLine("FreeListSize - 1; i < end; ++i)"); + outputFirstBoot.AppendLine("\t\t{"); outputFirstBoot.Append("\t\t\tPlugin::"); outputFirstBoot.Append(typeName); outputFirstBoot.Append("FreeList[i] = ("); @@ -10069,22 +10083,22 @@ static void AppendCppPointerFreeListInit( outputFirstBoot); outputFirstBoot.Append("*)(Plugin::"); outputFirstBoot.Append(typeName); - outputFirstBoot.Append("FreeList + i + 1);\n"); - outputFirstBoot.Append("\t\t}\n"); + outputFirstBoot.AppendLine("FreeList + i + 1);"); + outputFirstBoot.AppendLine("\t\t}"); outputFirstBoot.Append("\t\tPlugin::"); outputFirstBoot.Append(typeName); outputFirstBoot.Append("FreeList[Plugin::"); outputFirstBoot.Append(typeName); - outputFirstBoot.Append("FreeListSize - 1] = nullptr;\n"); + outputFirstBoot.AppendLine("FreeListSize - 1] = nullptr;"); outputFirstBoot.Append("\t\tPlugin::NextFree"); outputFirstBoot.Append(typeName); outputFirstBoot.Append(" = Plugin::"); outputFirstBoot.Append(typeName); - outputFirstBoot.Append("FreeList + 1;\n"); + outputFirstBoot.AppendLine("FreeList + 1;"); - outputFirstBoot.Append("\t\t\n"); + outputFirstBoot.AppendLine("\t\t"); } static void AppendCppPointerFreeListStateAndFunctions( @@ -10101,13 +10115,13 @@ static void AppendCppPointerFreeListStateAndFunctions( AppendCppTypeParameters( typeParams, output); - output.Append(" pointers\n"); - output.Append("\t\n"); + output.AppendLine(" pointers"); + output.AppendLine("\t"); // Size variable output.Append("\tint32_t "); output.Append(bindingTypeName); - output.Append("FreeListSize;\n"); + output.AppendLine("FreeListSize;"); // Free list variable output.Append('\t'); @@ -10119,7 +10133,7 @@ static void AppendCppPointerFreeListStateAndFunctions( output); output.Append("** "); output.Append(bindingTypeName); - output.Append("FreeList;\n"); + output.AppendLine("FreeList;"); // Next free variable output.Append('\t'); @@ -10131,8 +10145,8 @@ static void AppendCppPointerFreeListStateAndFunctions( output); output.Append("** NextFree"); output.Append(bindingTypeName); - output.Append(";\n"); - output.Append("\t\n"); + output.AppendLine(";"); + output.AppendLine("\t"); // Store function output.Append("\tint32_t Store"); @@ -10144,11 +10158,11 @@ static void AppendCppPointerFreeListStateAndFunctions( AppendCppTypeParameters( typeParams, output); - output.Append("* del)\n"); - output.Append("\t{\n"); + output.AppendLine("* del)"); + output.AppendLine("\t{"); output.Append("\t\tassert(NextFree"); output.Append(bindingTypeName); - output.Append(" != nullptr);\n"); + output.AppendLine(" != nullptr);"); output.Append("\t\t"); AppendCppTypeFullName( cppTypeTypeName, @@ -10158,7 +10172,7 @@ static void AppendCppPointerFreeListStateAndFunctions( output); output.Append("** pNext = NextFree"); output.Append(bindingTypeName); - output.Append(";\n"); + output.AppendLine(";"); output.Append("\t\tNextFree"); output.Append(bindingTypeName); output.Append(" = ("); @@ -10168,13 +10182,13 @@ static void AppendCppPointerFreeListStateAndFunctions( AppendCppTypeParameters( typeParams, output); - output.Append("**)*pNext;\n"); - output.Append("\t\t*pNext = del;\n"); + output.AppendLine("**)*pNext;"); + output.AppendLine("\t\t*pNext = del;"); output.Append("\t\treturn (int32_t)(pNext - "); output.Append(bindingTypeName); - output.Append("FreeList);\n"); - output.Append("\t}\n"); - output.Append("\t\n"); + output.AppendLine("FreeList);"); + output.AppendLine("\t}"); + output.AppendLine("\t"); // Get function output.Append('\t'); @@ -10186,23 +10200,23 @@ static void AppendCppPointerFreeListStateAndFunctions( output); output.Append("* Get"); output.Append(bindingTypeName); - output.Append("(int32_t handle)\n"); - output.Append("\t{\n"); + output.AppendLine("(int32_t handle)"); + output.AppendLine("\t{"); output.Append( "\t\tassert(handle >= 0 && handle < "); output.Append(bindingTypeName); - output.Append("FreeListSize);\n"); + output.AppendLine("FreeListSize);"); output.Append("\t\treturn "); output.Append(bindingTypeName); - output.Append("FreeList[handle];\n"); - output.Append("\t}\n"); - output.Append("\t\n"); + output.AppendLine("FreeList[handle];"); + output.AppendLine("\t}"); + output.AppendLine("\t"); // Remove function output.Append("\tvoid Remove"); output.Append(bindingTypeName); - output.Append("(int32_t handle)\n"); - output.Append("\t{\n"); + output.AppendLine("(int32_t handle)"); + output.AppendLine("\t{"); output.Append("\t\t"); AppendCppTypeFullName( cppTypeTypeName, @@ -10212,7 +10226,7 @@ static void AppendCppPointerFreeListStateAndFunctions( output); output.Append("** pRelease = "); output.Append(bindingTypeName); - output.Append("FreeList + handle;\n"); + output.AppendLine("FreeList + handle;"); output.Append("\t\t*pRelease = ("); AppendCppTypeFullName( cppTypeTypeName, @@ -10222,12 +10236,12 @@ static void AppendCppPointerFreeListStateAndFunctions( output); output.Append("*)NextFree"); output.Append(bindingTypeName); - output.Append(";\n"); + output.AppendLine(";"); output.Append("\t\tNextFree"); output.Append(bindingTypeName); - output.Append(" = pRelease;\n"); - output.Append("\t}\n"); - output.Append("\t\n"); + output.AppendLine(" = pRelease;"); + output.AppendLine("\t}"); + output.AppendLine("\t"); } static void AppendCppWholeObjectFreeListInit( @@ -10240,46 +10254,46 @@ static void AppendCppWholeObjectFreeListInit( output.Append(bindingTypeName); output.Append("FreeWholeListSize = "); output.Append(maxSimultaneous); - output.Append(";\n"); + output.AppendLine(";"); output.Append("\tPlugin::"); output.Append(bindingTypeName); output.Append("FreeWholeList = (Plugin::"); output.Append(bindingTypeName); - output.Append("FreeWholeListEntry*)curMemory;\n"); + output.AppendLine("FreeWholeListEntry*)curMemory;"); output.Append("\tcurMemory += "); output.Append(maxSimultaneous); output.Append(" * sizeof(Plugin::"); output.Append(bindingTypeName); - output.Append("FreeWholeListEntry);\n"); + output.AppendLine("FreeWholeListEntry);"); - output.Append("\t\n"); + output.AppendLine("\t"); outputFirstBoot.Append("\t\tfor (int32_t i = 0, end = Plugin::"); outputFirstBoot.Append(bindingTypeName); - outputFirstBoot.Append("FreeWholeListSize - 1; i < end; ++i)\n"); - outputFirstBoot.Append("\t\t{\n"); + outputFirstBoot.AppendLine("FreeWholeListSize - 1; i < end; ++i)"); + outputFirstBoot.AppendLine("\t\t{"); outputFirstBoot.Append("\t\t\tPlugin::"); outputFirstBoot.Append(bindingTypeName); outputFirstBoot.Append("FreeWholeList[i].Next = Plugin::"); outputFirstBoot.Append(bindingTypeName); - outputFirstBoot.Append("FreeWholeList + i + 1;\n"); - outputFirstBoot.Append("\t\t}\n"); + outputFirstBoot.AppendLine("FreeWholeList + i + 1;"); + outputFirstBoot.AppendLine("\t\t}"); outputFirstBoot.Append("\t\tPlugin::"); outputFirstBoot.Append(bindingTypeName); outputFirstBoot.Append("FreeWholeList[Plugin::"); outputFirstBoot.Append(bindingTypeName); - outputFirstBoot.Append("FreeWholeListSize - 1].Next = nullptr;\n"); + outputFirstBoot.AppendLine("FreeWholeListSize - 1].Next = nullptr;"); outputFirstBoot.Append("\t\tPlugin::NextFreeWhole"); outputFirstBoot.Append(bindingTypeName); outputFirstBoot.Append(" = Plugin::"); outputFirstBoot.Append(bindingTypeName); - outputFirstBoot.Append("FreeWholeList + 1;\n"); + outputFirstBoot.AppendLine("FreeWholeList + 1;"); - outputFirstBoot.Append("\t\t\n"); + outputFirstBoot.AppendLine("\t\t"); } static void AppendCppWholeObjectFreeListStateAndFunctions( @@ -10296,17 +10310,17 @@ static void AppendCppWholeObjectFreeListStateAndFunctions( AppendCppTypeParameters( typeParams, output); - output.Append(" objects\n"); - output.Append("\t\n"); + output.AppendLine(" objects"); + output.AppendLine("\t"); // Union with a pointer and a whole object output.Append("\tunion "); output.Append(bindingTypeName); - output.Append("FreeWholeListEntry\n"); - output.Append("\t{\n"); + output.AppendLine("FreeWholeListEntry"); + output.AppendLine("\t{"); output.Append("\t\t"); output.Append(bindingTypeName); - output.Append("FreeWholeListEntry* Next;\n"); + output.AppendLine("FreeWholeListEntry* Next;"); output.Append("\t\t"); AppendCppTypeFullName( cppTypeTypeName, @@ -10314,28 +10328,28 @@ static void AppendCppWholeObjectFreeListStateAndFunctions( AppendCppTypeParameters( typeParams, output); - output.Append(" Value;\n"); - output.Append("\t};\n"); + output.AppendLine(" Value;"); + output.AppendLine("\t};"); // Size output.Append("\tint32_t "); output.Append(bindingTypeName); - output.Append("FreeWholeListSize;\n"); + output.AppendLine("FreeWholeListSize;"); // Free list entries output.Append('\t'); output.Append(bindingTypeName); output.Append("FreeWholeListEntry* "); output.Append(bindingTypeName); - output.Append("FreeWholeList;\n"); + output.AppendLine("FreeWholeList;"); // Pointer to next free entry output.Append('\t'); output.Append(bindingTypeName); output.Append("FreeWholeListEntry* NextFreeWhole"); output.Append(bindingTypeName); - output.Append(";\n"); - output.Append("\t\n"); + output.AppendLine(";"); + output.AppendLine("\t"); // Store function output.Append('\t'); @@ -10347,22 +10361,22 @@ static void AppendCppWholeObjectFreeListStateAndFunctions( output); output.Append("* StoreWhole"); output.Append(bindingTypeName); - output.Append("()\n"); - output.Append("\t{\n"); + output.AppendLine("()"); + output.AppendLine("\t{"); output.Append("\t\tassert(NextFreeWhole"); output.Append(bindingTypeName); - output.Append(" != nullptr);\n"); + output.AppendLine(" != nullptr);"); output.Append("\t\t"); output.Append(bindingTypeName); output.Append("FreeWholeListEntry* pNext = NextFreeWhole"); output.Append(bindingTypeName); - output.Append(";\n"); + output.AppendLine(";"); output.Append("\t\tNextFreeWhole"); output.Append(bindingTypeName); - output.Append(" = pNext->Next;\n"); - output.Append("\t\treturn &pNext->Value;\n"); - output.Append("\t}\n"); - output.Append("\t\n"); + output.AppendLine(" = pNext->Next;"); + output.AppendLine("\t\treturn &pNext->Value;"); + output.AppendLine("\t}"); + output.AppendLine("\t"); // Remove function output.Append("\tvoid RemoveWhole"); @@ -10374,30 +10388,30 @@ static void AppendCppWholeObjectFreeListStateAndFunctions( AppendCppTypeParameters( typeParams, output); - output.Append("* instance)\n"); - output.Append("\t{\n"); + output.AppendLine("* instance)"); + output.AppendLine("\t{"); output.Append("\t\t"); output.Append(bindingTypeName); output.Append("FreeWholeListEntry* pRelease = ("); output.Append(bindingTypeName); - output.Append("FreeWholeListEntry*)instance;\n"); + output.AppendLine("FreeWholeListEntry*)instance;"); output.Append("\t\tif (pRelease >= "); output.Append(bindingTypeName); output.Append("FreeWholeList && pRelease < "); output.Append(bindingTypeName); output.Append("FreeWholeList + ("); output.Append(bindingTypeName); - output.Append("FreeWholeListSize - 1))\n"); - output.Append("\t\t{\n"); + output.AppendLine("FreeWholeListSize - 1))"); + output.AppendLine("\t\t{"); output.Append("\t\t\tpRelease->Next = NextFreeWhole"); output.Append(bindingTypeName); - output.Append(";\n"); + output.AppendLine(";"); output.Append("\t\t\tNextFreeWhole"); output.Append(bindingTypeName); - output.Append(" = pRelease->Next;\n"); - output.Append("\t\t}\n"); - output.Append("\t}\n"); - output.Append("\t\n"); + output.AppendLine(" = pRelease->Next;"); + output.AppendLine("\t\t}"); + output.AppendLine("\t}"); + output.AppendLine("\t"); } static void AppendCsharpDelegate( @@ -10410,7 +10424,7 @@ static void AppendCsharpDelegate( TypeKind returnTypeKind, StringBuilder output) { - output.Append("\t\t[UnmanagedFunctionPointer(CallingConvention.Cdecl)]\n"); + output.AppendLine("\t\t[UnmanagedFunctionPointer(CallingConvention.Cdecl)]"); output.Append("\t\tpublic delegate "); if (returnType == typeof(void)) { @@ -10470,7 +10484,7 @@ static void AppendCsharpDelegate( output.Append(", "); } } - output.Append(");\n"); + output.AppendLine(");"); output.Append("\t\tpublic static "); AppendCsharpDelegateName( typeTypeName, @@ -10483,7 +10497,8 @@ static void AppendCsharpDelegate( typeParams, funcName, output); - output.Append(";\n\t\t\n"); + output.AppendLine(";"); + output.AppendLine("\t\t"); } static void AppendCsharpDelegateName( @@ -10529,7 +10544,7 @@ static void AppendCsharpGetDelegateCall( typeParams, funcName, output); - output.Append("\");\n"); + output.AppendLine("\");"); } static void AppendCsharpImport( @@ -10541,7 +10556,7 @@ static void AppendCsharpImport( StringBuilder output ) { - output.Append("\t\t[DllImport(PLUGIN_NAME, CallingConvention = CallingConvention.Cdecl)]\n"); + output.AppendLine("\t\t[DllImport(PLUGIN_NAME, CallingConvention = CallingConvention.Cdecl)]"); output.Append("\t\tpublic static extern "); AppendCsharpTypeFullName(returnType, output); output.Append(' '); @@ -10576,7 +10591,8 @@ StringBuilder output output.Append(", "); } } - output.Append(");\n\t\t\n"); + output.AppendLine(");"); + output.AppendLine("\t\t"); } static void AppendExceptions( @@ -10665,32 +10681,32 @@ static void AppendExceptions( AppendCppTypeFullName( exceptionType, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); + builders.CppMethodDefinitions.AppendLine();; AppendIndent( throwerIndent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendIndent( throwerIndent + 1, builders.CppMethodDefinitions); builders.CppMethodDefinitions.Append(exceptionType.Name); - builders.CppMethodDefinitions.Append("Thrower(int32_t handle)\n"); + builders.CppMethodDefinitions.AppendLine("Thrower(int32_t handle)"); AppendIndent( throwerIndent + 2, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append(": System::Runtime::InteropServices::_Exception(nullptr)\n"); + builders.CppMethodDefinitions.AppendLine(": System::Runtime::InteropServices::_Exception(nullptr)"); AppendIndent( throwerIndent + 2, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append(", System::Runtime::Serialization::ISerializable(nullptr)\n"); + builders.CppMethodDefinitions.AppendLine(", System::Runtime::Serialization::ISerializable(nullptr)"); AppendIndent( throwerIndent + 2, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append(", System::Exception(nullptr)\n"); + builders.CppMethodDefinitions.AppendLine(", System::Exception(nullptr)"); AppendIndent( throwerIndent + 2, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append(", System::SystemException(nullptr)\n"); + builders.CppMethodDefinitions.AppendLine(", System::SystemException(nullptr)"); AppendIndent( throwerIndent + 2, builders.CppMethodDefinitions); @@ -10698,56 +10714,57 @@ static void AppendExceptions( AppendCppTypeFullName( exceptionType, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("(Plugin::InternalUse::Only, handle)\n"); + builders.CppMethodDefinitions.AppendLine("(Plugin::InternalUse::Only, handle)"); AppendIndent( throwerIndent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendIndent( throwerIndent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.AppendLine("}"); AppendIndent( throwerIndent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); + builders.CppMethodDefinitions.AppendLine();; AppendIndent( throwerIndent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("virtual void ThrowReferenceToThis()\n"); + builders.CppMethodDefinitions.AppendLine("virtual void ThrowReferenceToThis()"); AppendIndent( throwerIndent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendIndent( throwerIndent + 2, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("throw *this;\n"); + builders.CppMethodDefinitions.AppendLine("throw *this;"); AppendIndent( throwerIndent + 1, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("}\n"); + builders.CppMethodDefinitions.AppendLine("}"); AppendIndent( throwerIndent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("};\n"); + builders.CppMethodDefinitions.AppendLine("};"); AppendNamespaceEnding( throwerIndent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append('\n'); + builders.CppMethodDefinitions.AppendLine();; // C++ function builders.CppMethodDefinitions.Append("DLLEXPORT void "); builders.CppMethodDefinitions.Append(funcName); - builders.CppMethodDefinitions.Append("(int32_t handle)\n"); - builders.CppMethodDefinitions.Append("{\n"); - builders.CppMethodDefinitions.Append("\tdelete Plugin::unhandledCsharpException;\n"); + builders.CppMethodDefinitions.AppendLine("(int32_t handle)"); + builders.CppMethodDefinitions.AppendLine("{"); + builders.CppMethodDefinitions.AppendLine("\tdelete Plugin::unhandledCsharpException;"); builders.CppMethodDefinitions.Append("\tPlugin::unhandledCsharpException = new "); AppendCppTypeFullName( exceptionType, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("Thrower(handle);\n"); - builders.CppMethodDefinitions.Append("}\n\n"); + builders.CppMethodDefinitions.AppendLine("Thrower(handle);"); + builders.CppMethodDefinitions.AppendLine("}"); + builders.CppMethodDefinitions.AppendLine(); // Build parameters ParameterInfo[] parameters = ConvertParameters( @@ -10945,7 +10962,7 @@ static void AppendGetter( indent, builders.CppMethodDefinitions); AppendIndent(indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendCppPluginFunctionCall( methodIsStatic, GetTypeName(enclosingType), @@ -10962,9 +10979,9 @@ 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'); + builders.CppMethodDefinitions.AppendLine();; // C++ init body AppendCppInitBodyFunctionPointerParameterRead( @@ -11123,7 +11140,7 @@ static void AppendSetter( indent, builders.CppMethodDefinitions); AppendIndent(indent, builders.CppMethodDefinitions); - builders.CppMethodDefinitions.Append("{\n"); + builders.CppMethodDefinitions.AppendLine("{"); AppendCppPluginFunctionCall( methodIsStatic, enclosingTypeTypeName, @@ -11135,9 +11152,9 @@ 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 body AppendCppInitBodyFunctionPointerParameterRead( @@ -11193,11 +11210,11 @@ static void AppendCppTemplateDeclaration( typeTypeName, output); output.Append(";"); - output.Append('\n'); + output.AppendLine();; AppendNamespaceEnding( indent, output); - output.Append('\n'); + output.AppendLine();; } static int AppendCppTypeDeclaration( @@ -11216,9 +11233,9 @@ static int AppendCppTypeDeclaration( AppendTypeNameWithoutGenericSuffix( typeTypeName.Name, output); - output.Append('\n'); + output.AppendLine();; AppendIndent(indent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent(indent, output); output.Append('}'); } @@ -11237,11 +11254,11 @@ static int AppendCppTypeDeclaration( output); output.Append(";"); } - output.Append('\n'); + output.AppendLine();; AppendNamespaceEnding( indent, output); - output.Append('\n'); + output.AppendLine();; return indent; } @@ -11325,11 +11342,11 @@ static void AppendCppTypeDefinitionBegin( break; } } - output.Append('\n'); + output.AppendLine();; AppendIndent( indent, output); - output.Append("{\n"); + output.AppendLine("{"); if (!isStatic) { switch (typeKind) @@ -11341,15 +11358,15 @@ static void AppendCppTypeDefinitionBegin( AppendCppTypeName( typeTypeName, output); - output.Append("(decltype(nullptr));\n"); + output.AppendLine("(decltype(nullptr));"); // Constructor from handle AppendIndent(indent + 1, output); AppendCppTypeName( typeTypeName, output); - output.Append( - "(Plugin::InternalUse, int32_t handle);\n"); + output.AppendLine( + "(Plugin::InternalUse, int32_t handle);"); // Copy constructor AppendIndent(indent + 1, output); @@ -11363,7 +11380,7 @@ static void AppendCppTypeDefinitionBegin( AppendCppTypeParameters( typeParams, output); - output.Append("& other);\n"); + output.AppendLine("& other);"); // Move constructor AppendIndent(indent + 1, output); @@ -11377,7 +11394,7 @@ static void AppendCppTypeDefinitionBegin( AppendCppTypeParameters( typeParams, output); - output.Append("&& other);\n"); + output.AppendLine("&& other);"); // Destructor AppendIndent(indent + 1, output); @@ -11385,7 +11402,7 @@ static void AppendCppTypeDefinitionBegin( AppendCppTypeName( typeTypeName, output); - output.Append("();\n"); + output.AppendLine("();"); // Assignment operator to same type AppendIndent(indent + 1, output); @@ -11402,7 +11419,7 @@ static void AppendCppTypeDefinitionBegin( AppendCppTypeParameters( typeParams, output); - output.Append("& other);\n"); + output.AppendLine("& other);"); // Assignment operator to nullptr AppendIndent(indent + 1, output); @@ -11412,7 +11429,7 @@ static void AppendCppTypeDefinitionBegin( AppendCppTypeParameters( typeParams, output); - output.Append("& operator=(decltype(nullptr));\n"); + output.AppendLine("& operator=(decltype(nullptr));"); // Move assignment operator to same type AppendIndent(indent + 1, output); @@ -11429,7 +11446,7 @@ static void AppendCppTypeDefinitionBegin( AppendCppTypeParameters( typeParams, output); - output.Append("&& other);\n"); + output.AppendLine("&& other);"); // Equality operator with same type AppendIndent(indent + 1, output); @@ -11440,7 +11457,7 @@ static void AppendCppTypeDefinitionBegin( AppendCppTypeParameters( typeParams, output); - output.Append("& other) const;\n"); + output.AppendLine("& other) const;"); // Inequality operator with same type AppendIndent(indent + 1, output); @@ -11451,7 +11468,7 @@ static void AppendCppTypeDefinitionBegin( AppendCppTypeParameters( typeParams, output); - output.Append("& other) const;\n"); + output.AppendLine("& other) const;"); break; } } @@ -11470,11 +11487,11 @@ static void AppendCppTypeDefinitionEnd( { output.Append(';'); } - output.Append('\n'); + output.AppendLine();; AppendNamespaceEnding( indent, output); - output.Append('\n'); + output.AppendLine();; } static int AppendCppMethodDefinitionsBegin( @@ -11507,7 +11524,7 @@ static int AppendCppMethodDefinitionsBegin( AppendCppTypeName( enclosingTypeTypeName, output); - output.Append("(decltype(nullptr))\n"); + output.AppendLine("(decltype(nullptr))"); if (enclosingTypeKind == TypeKind.Class) { AppendCppConstructorInitializerList( @@ -11516,12 +11533,12 @@ static int AppendCppMethodDefinitionsBegin( output); } AppendIndent(indent, output); - output.Append("{\n"); + output.AppendLine("{"); extraDefault(indent + 1, "this->"); AppendIndent(indent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent(indent, output); - output.Append('\n'); + output.AppendLine();; // Handle constructor AppendIndent(indent, output); @@ -11535,7 +11552,7 @@ static int AppendCppMethodDefinitionsBegin( AppendCppTypeName( enclosingTypeTypeName, output); - output.Append("(Plugin::InternalUse, int32_t handle)\n"); + output.AppendLine("(Plugin::InternalUse, int32_t handle)"); if (enclosingTypeKind == TypeKind.Class) { AppendCppConstructorInitializerList( @@ -11544,13 +11561,13 @@ static int AppendCppMethodDefinitionsBegin( output); } AppendIndent(indent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent(indent + 1, output); - output.Append("Handle = handle;\n"); + output.AppendLine("Handle = handle;"); AppendIndent(indent + 1, output); - output.Append("if (handle)\n"); + output.AppendLine("if (handle)"); AppendIndent(indent + 1, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent(indent + 2, output); AppendReferenceManagedHandleFunctionCall( enclosingTypeTypeName, @@ -11558,14 +11575,14 @@ static int AppendCppMethodDefinitionsBegin( enclosingTypeParams, "handle", output); - output.Append(";\n"); + output.AppendLine(";"); AppendIndent(indent + 1, output); - output.Append("}\n"); + output.AppendLine("}"); extraDefault(indent + 1, "this->"); AppendIndent(indent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent(indent, output); - output.Append('\n'); + output.AppendLine();; // Copy constructor AppendIndent(indent, output); @@ -11586,20 +11603,20 @@ static int AppendCppMethodDefinitionsBegin( AppendCppTypeParameters( enclosingTypeParams, output); - output.Append("& other)\n"); + output.AppendLine("& other)"); AppendIndent(indent + 1, output); output.Append(": "); AppendCppTypeName( enclosingTypeTypeName, output); - output.Append("(Plugin::InternalUse::Only, other.Handle)\n"); + output.AppendLine("(Plugin::InternalUse::Only, other.Handle)"); AppendIndent(indent, output); - output.Append("{\n"); + output.AppendLine("{"); extraCopy(indent + 1, "other."); AppendIndent(indent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent(indent, output); - output.Append('\n'); + output.AppendLine();; // Move constructor AppendIndent(indent, output); @@ -11620,23 +11637,23 @@ static int AppendCppMethodDefinitionsBegin( AppendCppTypeParameters( enclosingTypeParams, output); - output.Append("&& other)\n"); + output.AppendLine("&& other)"); AppendIndent(indent, output); output.Append("\t: "); AppendCppTypeName( enclosingTypeTypeName, output); - output.Append("(Plugin::InternalUse::Only, other.Handle)\n"); + output.AppendLine("(Plugin::InternalUse::Only, other.Handle)"); AppendIndent(indent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent(indent + 1, output); - output.Append("other.Handle = 0;\n"); + output.AppendLine("other.Handle = 0;"); extraCopy(indent + 1, "other."); extraDefault(indent + 1, "other."); AppendIndent(indent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent(indent, output); - output.Append('\n'); + output.AppendLine();; // Destructor AppendIndent(indent, output); @@ -11653,13 +11670,13 @@ static int AppendCppMethodDefinitionsBegin( AppendCppTypeParameters( enclosingTypeParams, output); - output.Append("()\n"); + output.AppendLine("()"); AppendIndent(indent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent(indent + 1, output); - output.Append("if (Handle)\n"); + output.AppendLine("if (Handle)"); AppendIndent(indent + 1, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent(indent + 2, output); AppendDereferenceManagedHandleFunctionCall( enclosingTypeTypeName, @@ -11667,15 +11684,15 @@ static int AppendCppMethodDefinitionsBegin( enclosingTypeParams, "Handle", output); - output.Append(";\n"); + output.AppendLine(";"); AppendIndent(indent + 2, output); - output.Append("Handle = 0;\n"); + output.AppendLine("Handle = 0;"); AppendIndent(indent + 1, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent(indent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent(indent, output); - output.Append('\n'); + output.AppendLine();; // Assignment operator to same type AppendIndent(indent, output); @@ -11699,9 +11716,9 @@ static int AppendCppMethodDefinitionsBegin( AppendCppTypeParameters( enclosingTypeParams, output); - output.Append("& other)\n"); + output.AppendLine("& other)"); AppendIndent(indent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendSetHandle( enclosingTypeTypeName, enclosingTypeKind, @@ -11712,11 +11729,11 @@ static int AppendCppMethodDefinitionsBegin( output); extraCopy(indent + 1, "other."); AppendIndent(indent + 1, output); - output.Append("return *this;\n"); + output.AppendLine("return *this;"); AppendIndent(indent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent(indent, output); - output.Append('\n'); + output.AppendLine();; // Assignment operator to nullptr AppendIndent(indent, output); @@ -11733,13 +11750,13 @@ static int AppendCppMethodDefinitionsBegin( AppendCppTypeParameters( enclosingTypeParams, output); - output.Append("::operator=(decltype(nullptr))\n"); + output.AppendLine("::operator=(decltype(nullptr))"); AppendIndent(indent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent(indent + 1, output); - output.Append("if (Handle)\n"); + output.AppendLine("if (Handle)"); AppendIndent(indent + 1, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent(indent + 2, output); AppendDereferenceManagedHandleFunctionCall( enclosingTypeTypeName, @@ -11747,17 +11764,17 @@ static int AppendCppMethodDefinitionsBegin( enclosingTypeParams, "Handle", output); - output.Append(";\n"); + output.AppendLine(";"); AppendIndent(indent + 2, output); - output.Append("Handle = 0;\n"); + output.AppendLine("Handle = 0;"); AppendIndent(indent + 1, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent(indent + 1, output); - output.Append("return *this;\n"); + output.AppendLine("return *this;"); AppendIndent(indent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent(indent, output); - output.Append('\n'); + output.AppendLine();; // Move assignment operator to same type AppendIndent(indent, output); @@ -11781,13 +11798,13 @@ static int AppendCppMethodDefinitionsBegin( AppendCppTypeParameters( enclosingTypeParams, output); - output.Append("&& other)\n"); + output.AppendLine("&& other)"); AppendIndent(indent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent(indent + 1, output); - output.Append("if (Handle)\n"); + output.AppendLine("if (Handle)"); AppendIndent(indent + 1, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent(indent + 2, output); AppendDereferenceManagedHandleFunctionCall( enclosingTypeTypeName, @@ -11795,21 +11812,21 @@ static int AppendCppMethodDefinitionsBegin( enclosingTypeParams, "Handle", output); - output.Append(";\n"); + output.AppendLine(";"); AppendIndent(indent + 1, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent(indent + 1, output); - output.Append("Handle = other.Handle;\n"); + output.AppendLine("Handle = other.Handle;"); extraCopy(indent + 1, "other."); AppendIndent(indent + 1, output); - output.Append("other.Handle = 0;\n"); + output.AppendLine("other.Handle = 0;"); extraDefault(indent + 1, "other."); AppendIndent(indent + 1, output); - output.Append("return *this;\n"); + output.AppendLine("return *this;"); AppendIndent(indent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent(indent, output); - output.Append('\n'); + output.AppendLine();; // Equality operator with same type AppendIndent(indent, output); @@ -11827,15 +11844,15 @@ static int AppendCppMethodDefinitionsBegin( AppendCppTypeParameters( enclosingTypeParams, output); - output.Append("& other) const\n"); + output.AppendLine("& other) const"); AppendIndent(indent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent(indent + 1, output); - output.Append("return Handle == other.Handle;\n"); + output.AppendLine("return Handle == other.Handle;"); AppendIndent(indent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent(indent, output); - output.Append('\n'); + output.AppendLine();; // Inequality operator with same type AppendIndent(indent, output); @@ -11853,15 +11870,15 @@ static int AppendCppMethodDefinitionsBegin( AppendCppTypeParameters( enclosingTypeParams, output); - output.Append("& other) const\n"); + output.AppendLine("& other) const"); AppendIndent(indent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent(indent + 1, output); - output.Append("return Handle != other.Handle;\n"); + output.AppendLine("return Handle != other.Handle;"); AppendIndent(indent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent(indent, output); - output.Append('\n'); + output.AppendLine();; } return cppMethodDefinitionsIndent; } @@ -11879,9 +11896,9 @@ static void AppendSetHandle( AppendIndent(indent, output); output.Append("if ("); output.Append(thisHandleExpression); - output.Append(")\n"); + output.AppendLine(")"); AppendIndent(indent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent(indent + 1, output); AppendDereferenceManagedHandleFunctionCall( enclosingTypeTypeName, @@ -11889,20 +11906,20 @@ static void AppendSetHandle( enclosingTypeParams, thisHandleExpression, output); - output.Append(";\n"); + output.AppendLine(";"); AppendIndent(indent, output); - output.Append("}\n"); + output.AppendLine("}"); AppendIndent(indent, output); output.Append(thisHandleExpression); output.Append(" = "); output.Append(otherHandleExpression); - output.Append(";\n"); + output.AppendLine(";"); AppendIndent(indent, output); output.Append("if ("); output.Append(thisHandleExpression); - output.Append(")\n"); + output.AppendLine(")"); AppendIndent(indent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent(indent + 1, output); AppendReferenceManagedHandleFunctionCall( enclosingTypeTypeName, @@ -11910,9 +11927,9 @@ static void AppendSetHandle( enclosingTypeParams, thisHandleExpression, output); - output.Append(";\n"); + output.AppendLine(";"); AppendIndent(indent, output); - output.Append("}\n"); + output.AppendLine("}"); } static void AppendReferenceManagedHandleFunctionCall( @@ -11968,11 +11985,11 @@ static void AppendCppMethodDefinitionsEnd( StringBuilder output) { RemoveTrailingChars(output); - output.Append('\n'); + output.AppendLine();; AppendNamespaceEnding( indent, output); - output.Append('\n'); + output.AppendLine();; } static int AppendNamespaceBeginning( @@ -11993,9 +12010,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; @@ -12015,7 +12032,7 @@ static void AppendNamespaceEnding( for (; indent >= 0; --indent) { AppendIndent(indent, output); - output.Append("}\n"); + output.AppendLine("}"); } } @@ -12035,8 +12052,8 @@ static void AppendCsharpCsharpDelegate( "\t\t\tMarshal.WriteIntPtr(memory, curMemory, Marshal.GetFunctionPointerForDelegate("); initCallOutput.Append(funcName); initCallOutput.Append("Delegate"); - initCallOutput.Append("));\n"); - initCallOutput.Append("\t\t\tcurMemory += IntPtr.Size;\n"); + initCallOutput.AppendLine("));"); + initCallOutput.AppendLine("\t\t\tcurMemory += IntPtr.Size;"); delegateOutput.Append("\t\tstatic readonly "); delegateOutput.Append(funcName); @@ -12046,7 +12063,7 @@ static void AppendCsharpCsharpDelegate( delegateOutput.Append(funcName); delegateOutput.Append("DelegateType("); delegateOutput.Append(funcName); - delegateOutput.Append(");\n"); + delegateOutput.AppendLine(");"); } static void AppendCsharpDelegateType( @@ -12058,7 +12075,7 @@ static void AppendCsharpDelegateType( ParameterInfo[] parameters, StringBuilder output) { - output.Append("\t\t[UnmanagedFunctionPointer(CallingConvention.Cdecl)]\n"); + output.AppendLine("\t\t[UnmanagedFunctionPointer(CallingConvention.Cdecl)]"); output.Append("\t\tdelegate "); // Return type @@ -12098,7 +12115,7 @@ static void AppendCsharpDelegateType( AppendCsharpBindingParameterDeclaration( parameters, output); - output.Append(");\n"); + output.AppendLine(");"); } static void AppendCsharpFunctionBeginning( @@ -12112,7 +12129,8 @@ static void AppendCsharpFunctionBeginning( { output.Append("\t\t[MonoPInvokeCallback(typeof("); output.Append(funcName); - output.Append("DelegateType))]\n\t\tstatic "); + output.AppendLine("DelegateType))]"); + output.Append("\t\tstatic "); // Return type if (returnType != null) @@ -12157,10 +12175,14 @@ static void AppendCsharpFunctionBeginning( AppendCsharpBindingParameterDeclaration( parameters, output); - output.Append(")\n\t\t{\n\t\t\t"); + output.AppendLine(")"); + output.AppendLine("\t\t{"); + output.Append("\t\t\t"); // Start try/catch block - output.Append("try\n\t\t\t{\n\t\t\t\t"); + output.AppendLine("try"); + output.AppendLine("\t\t\t{"); + output.Append("\t\t\t\t"); // Get "this" if (!isStatic @@ -12174,8 +12196,10 @@ static void AppendCsharpFunctionBeginning( AppendHandleStoreTypeName( enclosingType, output); + output.AppendLine( + ".Get(thisHandle);"); output.Append( - ".Get(thisHandle);\n\t\t\t\t"); + "\t\t\t\t"); } // Get managed type params from ObjectStore @@ -12197,7 +12221,8 @@ static void AppendCsharpFunctionBeginning( AppendHandleStoreTypeName(paramType, output); output.Append(".Get("); output.Append(param.Name); - output.Append("Handle);\n\t\t\t\t"); + output.AppendLine("Handle);"); + output.Append("\t\t\t\t"); } } @@ -12254,7 +12279,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); @@ -12280,7 +12306,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( @@ -12297,7 +12324,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); @@ -12308,7 +12336,8 @@ static void AppendCsharpFunctionReturn( // Return if (returnType != typeof(void)) { - output.Append("\n\t\t\t\treturn "); + output.AppendLine(); + output.Append("\t\t\t\treturn "); if ( forceReturnReturnValue || returnTypeKind == TypeKind.Enum @@ -12350,8 +12379,8 @@ static void AppendCsharpFunctionEnd( ParameterInfo[] parameters, StringBuilder output) { - output.Append('\n'); - output.Append("\t\t\t}\n"); + output.AppendLine();; + output.AppendLine("\t\t\t}"); if (exceptionTypes == null || Array.IndexOf( exceptionTypes, @@ -12379,8 +12408,8 @@ static void AppendCsharpFunctionEnd( returnType, parameters, output); - output.Append("\t\t}\n"); - output.Append("\t\t\n"); + output.AppendLine("\t\t}"); + output.AppendLine("\t\t"); } static void AppendCsharpCatchException( @@ -12393,14 +12422,14 @@ static void AppendCsharpCatchException( AppendCsharpTypeFullName( exceptionType, output); - output.Append(" ex)\n"); - output.Append("\t\t\t{\n"); - output.Append("\t\t\t\tUnityEngine.Debug.LogException(ex);\n"); + output.AppendLine(" ex)"); + output.AppendLine("\t\t\t{"); + output.AppendLine("\t\t\t\tUnityEngine.Debug.LogException(ex);"); output.Append("\t\t\t\tNativeScript.Bindings."); AppendCsharpSetCsharpExceptionFunctionName( exceptionType, output); - output.Append("(NativeScript.Bindings.ObjectStore.Store(ex));\n"); + output.AppendLine("(NativeScript.Bindings.ObjectStore.Store(ex));"); foreach (ParameterInfo param in parameters) { if (param.IsOut) @@ -12410,7 +12439,7 @@ static void AppendCsharpCatchException( if (param.Kind == TypeKind.Class || param.Kind == TypeKind.ManagedStruct) { - output.Append("Handle = default(int);\n"); + output.AppendLine("Handle = default(int);"); } else { @@ -12418,7 +12447,7 @@ static void AppendCsharpCatchException( AppendCsharpTypeFullName( param.DereferencedParameterType, output); - output.Append(");\n"); + output.AppendLine(");"); } } } @@ -12435,9 +12464,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( @@ -12656,10 +12685,10 @@ static void AppendCppInitBodyFunctionPointerParameterRead( returnType, 2, output); - output.Append(")curMemory;\n"); + output.AppendLine(")curMemory;"); output.Append("\tcurMemory += sizeof(Plugin::"); output.Append(globalVariableName); - output.Append(");\n"); + output.AppendLine(");"); } static void AppendCppMethodDefinitionBegin( @@ -12718,7 +12747,7 @@ static void AppendCppMethodDefinitionBegin( null, // don't substitute method type params false, output); - output.Append(")\n"); + output.AppendLine(")"); } static void AppendCppMethodReturn( @@ -12745,7 +12774,7 @@ static void AppendCppMethodReturn( output.Append("(Plugin::InternalUse::Only, returnValue)"); break; } - output.Append(";\n"); + output.AppendLine(";"); } } @@ -12772,7 +12801,7 @@ static void AppendCppPluginFunctionCall( output.Append(param.Name); output.Append("Handle = "); output.Append(param.Name); - output.Append("->Handle;\n"); + output.AppendLine("->Handle;"); } } @@ -12840,7 +12869,7 @@ static void AppendCppPluginFunctionCall( output.Append(", "); } } - output.Append(");\n"); + output.AppendLine(");"); AppendCppUnhandledExceptionHandling( indent, @@ -12870,19 +12899,19 @@ static void AppendCppUnhandledExceptionHandling( StringBuilder output) { AppendIndent(indent, output); - output.Append("if (Plugin::unhandledCsharpException)\n"); + output.AppendLine("if (Plugin::unhandledCsharpException)"); AppendIndent(indent, output); - output.Append("{\n"); + output.AppendLine("{"); AppendIndent(indent + 1, output); - output.Append("System::Exception* ex = Plugin::unhandledCsharpException;\n"); + output.AppendLine("System::Exception* ex = Plugin::unhandledCsharpException;"); AppendIndent(indent + 1, output); - output.Append("Plugin::unhandledCsharpException = nullptr;\n"); + output.AppendLine("Plugin::unhandledCsharpException = nullptr;"); AppendIndent(indent + 1, output); - output.Append("ex->ThrowReferenceToThis();\n"); + output.AppendLine("ex->ThrowReferenceToThis();"); AppendIndent(indent + 1, output); - output.Append("delete ex;\n"); + output.AppendLine("delete ex;"); AppendIndent(indent, output); - output.Append("}\n"); + output.AppendLine("}"); } static void AppendCppFunctionPointerDefinition( @@ -12907,7 +12936,7 @@ StringBuilder output output ); output.Append(';'); - output.Append('\n'); + output.AppendLine();; } static void AppendCppFunctionPointer( @@ -13111,7 +13140,7 @@ static void AppendCppMethodDeclaration( output); output.Append(')'); - output.Append(";\n"); + output.AppendLine(";"); } static void AppendCsharpTypeFullName( @@ -13432,17 +13461,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); @@ -13458,123 +13482,123 @@ static void InjectBuilders( string cppSourceContents = File.ReadAllText(CppSourcePath); csharpContents = InjectIntoString( csharpContents, - "/*BEGIN DELEGATE TYPES*/"+Environment.NewLine, - Environment.NewLine+"\t\t/*END DELEGATE TYPES*/", + "/*BEGIN DELEGATE TYPES*/", + "\t\t/*END DELEGATE TYPES*/", builders.CsharpDelegateTypes.ToString()); csharpContents = InjectIntoString( csharpContents, - "/*BEGIN STORE INIT CALLS*/"+Environment.NewLine, - Environment.NewLine+"\t\t\t/*END STORE INIT CALLS*/", + "/*BEGIN STORE INIT CALLS*/", + "\t\t\t/*END STORE INIT CALLS*/", builders.CsharpStoreInitCalls.ToString()); csharpContents = InjectIntoString( csharpContents, - "/*BEGIN INIT CALL*/"+Environment.NewLine, - Environment.NewLine+"\t\t\t/*END INIT CALL*/", + "/*BEGIN INIT CALL*/", + "\t\t\t/*END INIT CALL*/", builders.CsharpInitCall.ToString()); csharpContents = InjectIntoString( csharpContents, - "/*BEGIN BASE TYPES*/"+Environment.NewLine, - Environment.NewLine+"/*END BASE TYPES*/", + "/*BEGIN BASE TYPES*/", + "/*END BASE TYPES*/", builders.CsharpBaseTypes.ToString()); csharpContents = InjectIntoString( csharpContents, - "/*BEGIN FUNCTIONS*/"+Environment.NewLine, - Environment.NewLine+"\t\t/*END FUNCTIONS*/", + "/*BEGIN FUNCTIONS*/", + "\t\t/*END FUNCTIONS*/", builders.CsharpFunctions.ToString()); csharpContents = InjectIntoString( csharpContents, - "/*BEGIN CPP DELEGATES*/"+Environment.NewLine, - Environment.NewLine+"\t\t/*END CPP DELEGATES*/", + "/*BEGIN CPP DELEGATES*/", + "\t\t/*END CPP DELEGATES*/", builders.CsharpCppDelegates.ToString()); csharpContents = InjectIntoString( csharpContents, - "/*BEGIN CSHARP DELEGATES*/"+Environment.NewLine, - Environment.NewLine+"\t\t/*END CSHARP DELEGATES*/", + "/*BEGIN CSHARP DELEGATES*/", + "\t\t/*END CSHARP DELEGATES*/", builders.CsharpCsharpDelegates.ToString()); csharpContents = InjectIntoString( csharpContents, - "/*BEGIN IMPORTS*/"+Environment.NewLine, - Environment.NewLine+"\t\t/*END IMPORTS*/", + "/*BEGIN IMPORTS*/", + "\t\t/*END IMPORTS*/", builders.CsharpImports.ToString()); csharpContents = InjectIntoString( csharpContents, - "/*BEGIN GETDELEGATE CALLS*/"+Environment.NewLine, - Environment.NewLine+"\t\t\t/*END GETDELEGATE CALLS*/", + "/*BEGIN GETDELEGATE CALLS*/", + "\t\t\t/*END GETDELEGATE CALLS*/", builders.CsharpGetDelegateCalls.ToString()); csharpContents = InjectIntoString( csharpContents, - "/*BEGIN DESTROY FUNCTION ENUMERATORS*/"+Environment.NewLine, - Environment.NewLine+"\t\t\t/*END DESTROY FUNCTION ENUMERATORS*/", + "/*BEGIN DESTROY FUNCTION ENUMERATORS*/", + "\t\t\t/*END DESTROY FUNCTION ENUMERATORS*/", builders.CsharpDestroyFunctionEnumerators.ToString()); csharpContents = InjectIntoString( csharpContents, - "/*BEGIN DESTROY QUEUE CASES*/"+Environment.NewLine, - Environment.NewLine+"\t\t\t\t\t\t/*END DESTROY QUEUE CASES*/", + "/*BEGIN DESTROY QUEUE CASES*/", + "\t\t\t\t\t\t/*END DESTROY QUEUE CASES*/", builders.CsharpDestroyQueueCases.ToString()); cppSourceContents = InjectIntoString( cppSourceContents, - "/*BEGIN FUNCTION POINTERS*/"+Environment.NewLine, - Environment.NewLine+"\t/*END FUNCTION POINTERS*/", + "/*BEGIN FUNCTION POINTERS*/", + "\t/*END FUNCTION POINTERS*/", builders.CppFunctionPointers.ToString()); cppHeaderContents = InjectIntoString( cppHeaderContents, - "/*BEGIN TYPE DECLARATIONS*/"+Environment.NewLine, - Environment.NewLine+"/*END TYPE DECLARATIONS*/", + "/*BEGIN TYPE DECLARATIONS*/", + "/*END TYPE DECLARATIONS*/", builders.CppTypeDeclarations.ToString()); cppHeaderContents = InjectIntoString( cppHeaderContents, - "/*BEGIN TEMPLATE DECLARATIONS*/"+Environment.NewLine, - Environment.NewLine+"/*END TEMPLATE DECLARATIONS*/", + "/*BEGIN TEMPLATE DECLARATIONS*/", + "/*END TEMPLATE DECLARATIONS*/", builders.CppTemplateDeclarations.ToString()); cppHeaderContents = InjectIntoString( cppHeaderContents, - "/*BEGIN TEMPLATE SPECIALIZATION DECLARATIONS*/"+Environment.NewLine, - Environment.NewLine+"/*END TEMPLATE SPECIALIZATION DECLARATIONS*/", + "/*BEGIN TEMPLATE SPECIALIZATION DECLARATIONS*/", + "/*END TEMPLATE SPECIALIZATION DECLARATIONS*/", builders.CppTemplateSpecializationDeclarations.ToString()); cppHeaderContents = InjectIntoString( cppHeaderContents, - "/*BEGIN TYPE DEFINITIONS*/"+Environment.NewLine, - Environment.NewLine+"/*END TYPE DEFINITIONS*/", + "/*BEGIN TYPE DEFINITIONS*/", + "/*END TYPE DEFINITIONS*/", builders.CppTypeDefinitions.ToString()); cppSourceContents = InjectIntoString( cppSourceContents, - "/*BEGIN METHOD DEFINITIONS*/"+Environment.NewLine, - Environment.NewLine+"/*END METHOD DEFINITIONS*/", + "/*BEGIN METHOD DEFINITIONS*/", + "/*END METHOD DEFINITIONS*/", builders.CppMethodDefinitions.ToString()); cppSourceContents = InjectIntoString( cppSourceContents, - "/*BEGIN INIT BODY PARAMETER READS*/"+Environment.NewLine, - Environment.NewLine+"\t/*END INIT BODY PARAMETER READS*/", + "/*BEGIN INIT BODY PARAMETER READS*/", + "\t/*END INIT BODY PARAMETER READS*/", builders.CppInitBodyParameterReads.ToString()); cppSourceContents = InjectIntoString( cppSourceContents, - "/*BEGIN INIT BODY ARRAYS*/"+Environment.NewLine, - Environment.NewLine+"\t/*END INIT BODY ARRAYS*/", + "/*BEGIN INIT BODY ARRAYS*/", + "\t/*END INIT BODY ARRAYS*/", builders.CppInitBodyArrays.ToString()); cppSourceContents = InjectIntoString( cppSourceContents, - "/*BEGIN INIT BODY FIRST BOOT*/"+Environment.NewLine, - Environment.NewLine+"\t\t/*END INIT BODY FIRST BOOT*/", + "/*BEGIN INIT BODY FIRST BOOT*/", + "\t\t/*END INIT BODY FIRST BOOT*/", builders.CppInitBodyFirstBoot.ToString()); cppSourceContents = InjectIntoString( cppSourceContents, - "/*BEGIN GLOBAL STATE AND FUNCTIONS*/"+Environment.NewLine, - Environment.NewLine+"\t/*END GLOBAL STATE AND FUNCTIONS*/", + "/*BEGIN GLOBAL STATE AND FUNCTIONS*/", + "\t/*END GLOBAL STATE AND FUNCTIONS*/", builders.CppGlobalStateAndFunctions.ToString()); cppHeaderContents = InjectIntoString( cppHeaderContents, - "/*BEGIN UNBOXING METHOD DECLARATIONS*/"+Environment.NewLine, - Environment.NewLine+"\t\t/*END UNBOXING METHOD DECLARATIONS*/", + "/*BEGIN UNBOXING METHOD DECLARATIONS*/", + "\t\t/*END UNBOXING METHOD DECLARATIONS*/", builders.CppUnboxingMethodDeclarations.ToString()); cppHeaderContents = InjectIntoString( cppHeaderContents, - "/*BEGIN STRING DEFAULT PARAMETERS*/"+Environment.NewLine, - Environment.NewLine+"\t/*END STRING DEFAULT PARAMETERS*/", + "/*BEGIN STRING DEFAULT PARAMETERS*/", + "\t/*END STRING DEFAULT PARAMETERS*/", builders.CppStringDefaultParams.ToString()); cppHeaderContents = InjectIntoString( cppHeaderContents, - "/*BEGIN MACROS*/"+Environment.NewLine, - Environment.NewLine+"/*END MACROS*/", + "/*BEGIN MACROS*/", + "/*END MACROS*/", builders.CppMacros.ToString()); File.WriteAllText(CsharpPath, csharpContents); @@ -13588,7 +13612,8 @@ static string InjectIntoString( string endMarker, string text) { - for (int startIndex = 0; ; ) + int startIndex = 0; + while(true) { int beginIndex = contents.IndexOf(beginMarker, startIndex, StringComparison.OrdinalIgnoreCase); if (beginIndex < 0) @@ -13609,7 +13634,7 @@ 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; } } From a2afdbbbd2fd0248b838533babf8e249963361b1 Mon Sep 17 00:00:00 2001 From: "Youngkyoung, Lee" Date: Tue, 9 Feb 2021 00:10:31 +0900 Subject: [PATCH 32/36] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 14f12cc..8b108f6 100644 --- a/README.md +++ b/README.md @@ -192,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`. From 00443ef39d5418f3c744654c0d3d4036c2a81634 Mon Sep 17 00:00:00 2001 From: Jackson Dunstan Date: Sun, 21 Feb 2021 17:15:26 -0800 Subject: [PATCH 33/36] Don't use "= default" on the System.Object destructor so its "noexcept" matches derived classes --- Unity/Assets/CppSource/NativeScript/Bindings.cpp | 4 ++++ Unity/Assets/CppSource/NativeScript/Bindings.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Unity/Assets/CppSource/NativeScript/Bindings.cpp b/Unity/Assets/CppSource/NativeScript/Bindings.cpp index cd62a88..8cb2e2e 100644 --- a/Unity/Assets/CppSource/NativeScript/Bindings.cpp +++ b/Unity/Assets/CppSource/NativeScript/Bindings.cpp @@ -966,6 +966,10 @@ namespace System : ManagedType(nullptr) { } + + Object::~Object() + { + } bool Object::operator==(decltype(nullptr)) const { diff --git a/Unity/Assets/CppSource/NativeScript/Bindings.h b/Unity/Assets/CppSource/NativeScript/Bindings.h index 093dc3b..4da12a4 100644 --- a/Unity/Assets/CppSource/NativeScript/Bindings.h +++ b/Unity/Assets/CppSource/NativeScript/Bindings.h @@ -585,7 +585,7 @@ namespace System Object(); Object(Plugin::InternalUse iu, int32_t handle); Object(decltype(nullptr)); - virtual ~Object() = default; + virtual ~Object(); bool operator==(decltype(nullptr)) const; bool operator!=(decltype(nullptr)) const; virtual void ThrowReferenceToThis(); From e8c9b6b414e9ee406596f9428fe2b1d5d6aeb439 Mon Sep 17 00:00:00 2001 From: philipcass <244523+philipcass@users.noreply.github.com> Date: Mon, 22 Feb 2021 15:36:28 +0000 Subject: [PATCH 34/36] Fix for standalone builds defaulting to int parameters There was a mis-match in how types were specified in editor/build delegates. Changed so they both now use the same switch statement --- .../NativeScript/Editor/GenerateBindings.cs | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/Unity/Assets/NativeScript/Editor/GenerateBindings.cs b/Unity/Assets/NativeScript/Editor/GenerateBindings.cs index 29fe4c7..3b1bc12 100644 --- a/Unity/Assets/NativeScript/Editor/GenerateBindings.cs +++ b/Unity/Assets/NativeScript/Editor/GenerateBindings.cs @@ -10573,18 +10573,21 @@ StringBuilder output for (int i = 0; i < parameters.Length; ++i) { ParameterInfo param = parameters[i]; - if (param.Kind == TypeKind.FullStruct) - { - AppendCsharpTypeFullName( - param.ParameterType, - output); - output.Append(" param"); - output.Append(i); - } - else + switch (param.Kind) { - output.Append("int param"); - output.Append(i); + case TypeKind.FullStruct: + case TypeKind.Primitive: + case TypeKind.Enum: + AppendCsharpTypeFullName( + param.ParameterType, + output); + output.Append(" param"); + output.Append(i); + break; + default: + output.Append("int param"); + output.Append(i); + break; } if (i != parameters.Length-1) { @@ -13639,4 +13642,4 @@ static string InjectIntoString( } } } -} \ No newline at end of file +} From c53adea79b78cdd6ba5fc5505f66eddab73596ea Mon Sep 17 00:00:00 2001 From: philipcass <244523+philipcass@users.noreply.github.com> Date: Mon, 1 Mar 2021 14:14:11 +0000 Subject: [PATCH 35/36] Fix CPP event accessors Added hacky fix to resolve event accessors both adding delegates --- Unity/Assets/NativeScript/Editor/GenerateBindings.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Unity/Assets/NativeScript/Editor/GenerateBindings.cs b/Unity/Assets/NativeScript/Editor/GenerateBindings.cs index 3b1bc12..61af988 100644 --- a/Unity/Assets/NativeScript/Editor/GenerateBindings.cs +++ b/Unity/Assets/NativeScript/Editor/GenerateBindings.cs @@ -3427,7 +3427,15 @@ static void AppendEventAddRemoveMethod( builders.CsharpFunctions); builders.CsharpFunctions.Append('.'); builders.CsharpFunctions.Append(eventName); - builders.CsharpFunctions.Append(" += del;"); + // TODO: More safely differenciate between add/removing event delegates + if (funcName.Contains("RemoveEvent")) + { + builders.CsharpFunctions.Append(" -= del;"); + } + else + { + builders.CsharpFunctions.Append(" += del;"); + } AppendCsharpFunctionEnd( typeof(void), null, From 2eb88245bec25c36fa83716f9016bd056cc33dff Mon Sep 17 00:00:00 2001 From: philipcass <244523+philipcass@users.noreply.github.com> Date: Mon, 1 Mar 2021 14:20:36 +0000 Subject: [PATCH 36/36] Set abstract base method declarations as virtual The codegen would set all abstract base methods to be non-virtual, this allows derived classes to cleanly override abstract function implementations --- Unity/Assets/NativeScript/Editor/GenerateBindings.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Unity/Assets/NativeScript/Editor/GenerateBindings.cs b/Unity/Assets/NativeScript/Editor/GenerateBindings.cs index 3b1bc12..f927d2e 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; @@ -4155,7 +4155,8 @@ static void AppendMethod( AppendCppMethodDeclaration( cppMethodName, enclosingTypeIsStatic, - false, + // Mark as virtual if method/class is not static or generic + cppMethodIsStatic || enclosingTypeIsStatic || methodTypeParams != null? false : true, cppMethodIsStatic, cppReturnType, methodTypeParams,