diff --git a/Source/Editor/Content/Import/AudioImportSettings.cs b/Source/Editor/Content/Import/AudioImportSettings.cs
index 98c5324f7..2fc0a1795 100644
--- a/Source/Editor/Content/Import/AudioImportSettings.cs
+++ b/Source/Editor/Content/Import/AudioImportSettings.cs
@@ -2,10 +2,9 @@
using System.ComponentModel;
using System.Reflection;
-using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
-using System.Runtime.InteropServices.Marshalling;
using FlaxEngine;
+using FlaxEngine.Interop;
namespace FlaxEditor.Content.Import
{
diff --git a/Source/Editor/Content/Import/ModelImportEntry.cs b/Source/Editor/Content/Import/ModelImportEntry.cs
index 2174eebdc..8eb240093 100644
--- a/Source/Editor/Content/Import/ModelImportEntry.cs
+++ b/Source/Editor/Content/Import/ModelImportEntry.cs
@@ -2,10 +2,10 @@
using System;
using System.ComponentModel;
-using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.Marshalling;
using FlaxEngine;
+using FlaxEngine.Interop;
namespace FlaxEditor.Content.Import
{
diff --git a/Source/Editor/Content/Import/TextureImportEntry.cs b/Source/Editor/Content/Import/TextureImportEntry.cs
index c08ef6e8f..ed3216f6b 100644
--- a/Source/Editor/Content/Import/TextureImportEntry.cs
+++ b/Source/Editor/Content/Import/TextureImportEntry.cs
@@ -4,10 +4,10 @@ using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Reflection;
-using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.Marshalling;
using FlaxEngine;
+using FlaxEngine.Interop;
// ReSharper disable InconsistentNaming
@@ -591,7 +591,7 @@ namespace FlaxEditor.Content.Import
#region Internal Calls
- [LibraryImport("FlaxEngine", EntryPoint = "TextureImportEntryInternal_GetTextureImportOptions", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "TextureImportEntryInternal_GetTextureImportOptions", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
[return: MarshalAs(UnmanagedType.U1)]
internal static partial bool Internal_GetTextureImportOptions(string path, out TextureImportSettings.InternalOptions result);
diff --git a/Source/Editor/CustomEditors/CustomEditorsUtil.cs b/Source/Editor/CustomEditors/CustomEditorsUtil.cs
index d6769270b..4c664031f 100644
--- a/Source/Editor/CustomEditors/CustomEditorsUtil.cs
+++ b/Source/Editor/CustomEditors/CustomEditorsUtil.cs
@@ -3,12 +3,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.Marshalling;
using FlaxEditor.CustomEditors.Editors;
using FlaxEditor.Scripting;
using FlaxEngine;
+using FlaxEngine.Interop;
using FlaxEngine.Utilities;
namespace FlaxEditor.CustomEditors
@@ -126,7 +126,7 @@ namespace FlaxEditor.CustomEditors
return new GenericEditor();
}
- [LibraryImport("FlaxEngine", EntryPoint = "CustomEditorsUtilInternal_GetCustomEditor", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "CustomEditorsUtilInternal_GetCustomEditor", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
[return: MarshalUsing(typeof(SystemTypeMarshaller))]
internal static partial Type Internal_GetCustomEditor([MarshalUsing(typeof(SystemTypeMarshaller))] Type targetType);
}
diff --git a/Source/Editor/Editor.cs b/Source/Editor/Editor.cs
index 0f7ffcf32..f50e954ad 100644
--- a/Source/Editor/Editor.cs
+++ b/Source/Editor/Editor.cs
@@ -20,6 +20,7 @@ using FlaxEditor.Windows.Assets;
using FlaxEngine;
using FlaxEngine.Assertions;
using FlaxEngine.GUI;
+using FlaxEngine.Interop;
using FlaxEngine.Json;
#pragma warning disable CS1591
@@ -66,18 +67,18 @@ namespace FlaxEditor
///
/// Gets a value indicating whether this Editor is running a dev instance of the engine.
///
- [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_IsDevInstance", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_IsDevInstance", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
[return: MarshalAs(UnmanagedType.U1)]
internal static partial bool IsDevInstance();
///
/// Gets a value indicating whether this Editor is running as official build (distributed via Flax services).
///
- [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_IsOfficialBuild", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_IsOfficialBuild", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
[return: MarshalAs(UnmanagedType.U1)]
internal static partial bool IsOfficialBuild();
- [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_IsPlayMode", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_IsPlayMode", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
[return: MarshalAs(UnmanagedType.U1)]
internal static partial bool Internal_IsPlayMode();
@@ -1596,132 +1597,132 @@ namespace FlaxEditor
Instance.StateMachine.StateChanged += RequestStartPlayOnEditMode;
}
- [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_ReadOutputLogs", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
- internal static partial int Internal_ReadOutputLogs([MarshalUsing(typeof(FlaxEngine.ArrayMarshaller<,>), CountElementName = "outCapacity")] ref string[] outMessages, [MarshalUsing(typeof(FlaxEngine.ArrayMarshaller<,>), CountElementName = "outCapacity")] ref byte[] outLogTypes, [MarshalUsing(typeof(FlaxEngine.ArrayMarshaller<,>), CountElementName = "outCapacity")] ref long[] outLogTimes, int outCapacity);
+ [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_ReadOutputLogs", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.Interop.StringMarshaller))]
+ internal static partial int Internal_ReadOutputLogs([MarshalUsing(typeof(FlaxEngine.Interop.ArrayMarshaller<,>), CountElementName = "outCapacity")] ref string[] outMessages, [MarshalUsing(typeof(FlaxEngine.Interop.ArrayMarshaller<,>), CountElementName = "outCapacity")] ref byte[] outLogTypes, [MarshalUsing(typeof(FlaxEngine.Interop.ArrayMarshaller<,>), CountElementName = "outCapacity")] ref long[] outLogTimes, int outCapacity);
- [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_SetPlayMode", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_SetPlayMode", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.Interop.StringMarshaller))]
internal static partial void Internal_SetPlayMode([MarshalAs(UnmanagedType.U1)] bool value);
- [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_GetProjectPath", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_GetProjectPath", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
internal static partial string Internal_GetProjectPath();
- [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_CloneAssetFile", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_CloneAssetFile", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
[return: MarshalAs(UnmanagedType.U1)]
internal static partial bool Internal_CloneAssetFile(string dstPath, string srcPath, ref Guid dstId);
- [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_Import", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_Import", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
[return: MarshalAs(UnmanagedType.U1)]
internal static partial bool Internal_Import(string inputPath, string outputPath, IntPtr arg);
- [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_ImportTexture", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_ImportTexture", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
[return: MarshalAs(UnmanagedType.U1)]
internal static partial bool Internal_ImportTexture(string inputPath, string outputPath, ref TextureImportSettings.InternalOptions options);
- [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_ImportModel", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_ImportModel", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
[return: MarshalAs(UnmanagedType.U1)]
internal static partial bool Internal_ImportModel(string inputPath, string outputPath, ref ModelImportSettings.InternalOptions options);
- [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_ImportAudio", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_ImportAudio", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
[return: MarshalAs(UnmanagedType.U1)]
internal static partial bool Internal_ImportAudio(string inputPath, string outputPath, ref AudioImportSettings.InternalOptions options);
- [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_GetAudioClipMetadata", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_GetAudioClipMetadata", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
internal static partial void Internal_GetAudioClipMetadata(IntPtr obj, out int originalSize, out int importedSize);
- [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_SaveJsonAsset", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_SaveJsonAsset", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
[return: MarshalAs(UnmanagedType.U1)]
internal static partial bool Internal_SaveJsonAsset(string outputPath, string data, string typename);
- [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_CopyCache", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_CopyCache", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
internal static partial void Internal_CopyCache(ref Guid dstId, ref Guid srcId);
- [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_BakeLightmaps", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_BakeLightmaps", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
internal static partial void Internal_BakeLightmaps([MarshalAs(UnmanagedType.U1)] bool cancel);
- [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_GetShaderAssetSourceCode", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_GetShaderAssetSourceCode", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
internal static partial string Internal_GetShaderAssetSourceCode(IntPtr obj);
- [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_CookMeshCollision", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_CookMeshCollision", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
[return: MarshalAs(UnmanagedType.U1)]
internal static partial bool Internal_CookMeshCollision(string path, CollisionDataType type, IntPtr model, int modelLodIndex, uint materialSlotsMask, ConvexMeshGenerationFlags convexFlags, int convexVertexLimit);
- [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_GetCollisionWires", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
- internal static partial void Internal_GetCollisionWires(IntPtr collisionData, [MarshalUsing(typeof(FlaxEngine.ArrayMarshaller<,>), CountElementName = "trianglesCount")] out Float3[] triangles, [MarshalUsing(typeof(FlaxEngine.ArrayMarshaller<,>), CountElementName = "indicesCount")] out int[] indices, out int trianglesCount, out int indicesCount);
+ [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_GetCollisionWires", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
+ internal static partial void Internal_GetCollisionWires(IntPtr collisionData, [MarshalUsing(typeof(FlaxEngine.Interop.ArrayMarshaller<,>), CountElementName = "trianglesCount")] out Float3[] triangles, [MarshalUsing(typeof(FlaxEngine.Interop.ArrayMarshaller<,>), CountElementName = "indicesCount")] out int[] indices, out int trianglesCount, out int indicesCount);
- [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_GetEditorBoxWithChildren", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_GetEditorBoxWithChildren", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
internal static partial void Internal_GetEditorBoxWithChildren(IntPtr obj, out BoundingBox resultAsRef);
- [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_SetOptions", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_SetOptions", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
internal static partial void Internal_SetOptions(ref InternalOptions options);
- [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_DrawNavMesh", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_DrawNavMesh", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
internal static partial void Internal_DrawNavMesh();
- [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_CloseSplashScreen", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_CloseSplashScreen", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
internal static partial void Internal_CloseSplashScreen();
- [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_CreateAsset", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_CreateAsset", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
[return: MarshalAs(UnmanagedType.U1)]
internal static partial bool Internal_CreateAsset(NewAssetType type, string outputPath);
- [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_CreateVisualScript", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_CreateVisualScript", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
[return: MarshalAs(UnmanagedType.U1)]
internal static partial bool Internal_CreateVisualScript(string outputPath, string baseTypename);
- [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_CanImport", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_CanImport", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
internal static partial string Internal_CanImport(string extension);
- [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_CanExport", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_CanExport", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
[return: MarshalAs(UnmanagedType.U1)]
internal static partial bool Internal_CanExport(string path);
- [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_Export", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_Export", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
[return: MarshalAs(UnmanagedType.U1)]
internal static partial bool Internal_Export(string inputPath, string outputFolder);
- [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_GetIsEveryAssemblyLoaded", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_GetIsEveryAssemblyLoaded", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
[return: MarshalAs(UnmanagedType.U1)]
internal static partial bool Internal_GetIsEveryAssemblyLoaded();
- [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_GetLastProjectOpenedEngineBuild", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_GetLastProjectOpenedEngineBuild", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
internal static partial int Internal_GetLastProjectOpenedEngineBuild();
- [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_GetIsCSGActive", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_GetIsCSGActive", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
[return: MarshalAs(UnmanagedType.U1)]
internal static partial bool Internal_GetIsCSGActive();
- [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_RunVisualScriptBreakpointLoopTick", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_RunVisualScriptBreakpointLoopTick", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
internal static partial void Internal_RunVisualScriptBreakpointLoopTick(float deltaTime);
- [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_GetVisualScriptLocals", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
- [return: MarshalUsing(typeof(FlaxEngine.ArrayMarshaller<,>), CountElementName = "localsCount")]
+ [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_GetVisualScriptLocals", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
+ [return: MarshalUsing(typeof(FlaxEngine.Interop.ArrayMarshaller<,>), CountElementName = "localsCount")]
internal static partial VisualScriptLocal[] Internal_GetVisualScriptLocals(out int localsCount);
- [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_GetVisualScriptStackFrames", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
- [return: MarshalUsing(typeof(FlaxEngine.ArrayMarshaller<,>), CountElementName = "stackFrameCount")]
+ [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_GetVisualScriptStackFrames", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
+ [return: MarshalUsing(typeof(FlaxEngine.Interop.ArrayMarshaller<,>), CountElementName = "stackFrameCount")]
internal static partial VisualScriptStackFrame[] Internal_GetVisualScriptStackFrames(out int stackFrameCount);
- [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_GetVisualScriptPreviousScopeFrame", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_GetVisualScriptPreviousScopeFrame", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
internal static partial VisualScriptStackFrame Internal_GetVisualScriptPreviousScopeFrame();
- [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_EvaluateVisualScriptLocal", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_EvaluateVisualScriptLocal", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
[return: MarshalAs(UnmanagedType.U1)]
internal static partial bool Internal_EvaluateVisualScriptLocal(IntPtr script, ref VisualScriptLocal local);
- [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_DeserializeSceneObject", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_DeserializeSceneObject", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
internal static partial void Internal_DeserializeSceneObject(IntPtr sceneObject, string json);
- [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_LoadAsset", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_LoadAsset", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
internal static partial void Internal_LoadAsset(ref Guid id);
- [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_CanSetToRoot", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_CanSetToRoot", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
[return: MarshalAs(UnmanagedType.U1)]
internal static partial bool Internal_CanSetToRoot(IntPtr prefab, IntPtr newRoot);
- [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_GetAnimationTime", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_GetAnimationTime", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
internal static partial float Internal_GetAnimationTime(IntPtr animatedModel);
- [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_SetAnimationTime", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_SetAnimationTime", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
internal static partial void Internal_SetAnimationTime(IntPtr animatedModel, float time);
#endregion
diff --git a/Source/Engine/Animations/AnimationGraph.cs b/Source/Engine/Animations/AnimationGraph.cs
index 9bba0858b..7de45768e 100644
--- a/Source/Engine/Animations/AnimationGraph.cs
+++ b/Source/Engine/Animations/AnimationGraph.cs
@@ -265,7 +265,7 @@ namespace FlaxEngine
internal static partial bool Internal_HasConnection(ref AnimationGraph.CustomNode.Context context, int boxId);
[LibraryImport("FlaxEngine", EntryPoint = "AnimGraphInternal_GetInputValue")]
- [return: MarshalUsing(typeof(FlaxEngine.ManagedHandleMarshaller))]
+ [return: MarshalUsing(typeof(FlaxEngine.Interop.ManagedHandleMarshaller))]
internal static partial object Internal_GetInputValue(ref AnimationGraph.CustomNode.Context context, int boxId);
[LibraryImport("FlaxEngine", EntryPoint = "AnimGraphInternal_GetOutputImpulseData")]
diff --git a/Source/Engine/Core/Config/LayersAndTagsSettings.cs b/Source/Engine/Core/Config/LayersAndTagsSettings.cs
index c0f333548..008f70504 100644
--- a/Source/Engine/Core/Config/LayersAndTagsSettings.cs
+++ b/Source/Engine/Core/Config/LayersAndTagsSettings.cs
@@ -1,7 +1,6 @@
// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
using System.Collections.Generic;
-using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.Marshalling;
using FlaxEngine;
@@ -31,8 +30,8 @@ namespace FlaxEditor.Content.Settings
return GetCurrentLayers(out int _);
}
- [LibraryImport("FlaxEngine", EntryPoint = "LayersAndTagsSettingsInternal_GetCurrentLayers", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
- [return: MarshalUsing(typeof(FlaxEngine.ArrayMarshaller<,>), CountElementName = "layerCount")]
+ [LibraryImport("FlaxEngine", EntryPoint = "LayersAndTagsSettingsInternal_GetCurrentLayers", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.Interop.StringMarshaller))]
+ [return: MarshalUsing(typeof(FlaxEngine.Interop.ArrayMarshaller<,>), CountElementName = "layerCount")]
internal static partial string[] GetCurrentLayers(out int layerCount);
}
}
diff --git a/Source/Engine/Engine/DebugLogHandler.cs b/Source/Engine/Engine/DebugLogHandler.cs
index b9e69bd7f..d123cbe07 100644
--- a/Source/Engine/Engine/DebugLogHandler.cs
+++ b/Source/Engine/Engine/DebugLogHandler.cs
@@ -66,14 +66,14 @@ namespace FlaxEngine
Debug.Logger.LogException(exception);
}
- [LibraryImport("FlaxEngine", EntryPoint = "DebugLogHandlerInternal_LogWrite", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "DebugLogHandlerInternal_LogWrite", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(Interop.StringMarshaller))]
internal static partial void Internal_LogWrite(LogType level, string msg);
- [LibraryImport("FlaxEngine", EntryPoint = "DebugLogHandlerInternal_Log", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "DebugLogHandlerInternal_Log", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(Interop.StringMarshaller))]
internal static partial void Internal_Log(LogType level, string msg, IntPtr obj, string stackTrace);
- [LibraryImport("FlaxEngine", EntryPoint = "DebugLogHandlerInternal_LogException", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
- internal static partial void Internal_LogException([MarshalUsing(typeof(FlaxEngine.ExceptionMarshaller))] Exception exception, IntPtr obj);
+ [LibraryImport("FlaxEngine", EntryPoint = "DebugLogHandlerInternal_LogException", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(Interop.StringMarshaller))]
+ internal static partial void Internal_LogException([MarshalUsing(typeof(Interop.ExceptionMarshaller))] Exception exception, IntPtr obj);
[SecuritySafeCritical]
public static string Internal_GetStackTrace()
diff --git a/Source/Engine/Engine/NativeInterop.Invoker.cs b/Source/Engine/Engine/NativeInterop.Invoker.cs
index 4ee9e80a1..874ff77f1 100644
--- a/Source/Engine/Engine/NativeInterop.Invoker.cs
+++ b/Source/Engine/Engine/NativeInterop.Invoker.cs
@@ -9,7 +9,7 @@ using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Diagnostics;
-namespace FlaxEngine
+namespace FlaxEngine.Interop
{
unsafe partial class NativeInterop
{
@@ -189,6 +189,7 @@ namespace FlaxEngine
internal static class InvokerNoRet0
{
internal delegate void InvokerDelegate(object instance);
+
internal delegate void ThunkInvokerDelegate(object instance);
internal static object CreateDelegate(MethodInfo method)
@@ -225,6 +226,7 @@ namespace FlaxEngine
internal static class InvokerNoRet1
{
internal delegate void InvokerDelegate(object instance, ref T1 param1);
+
internal delegate void ThunkInvokerDelegate(object instance, T1 param1);
internal static object CreateDelegate(MethodInfo method)
@@ -245,12 +247,14 @@ namespace FlaxEngine
IntPtr param1Ptr = Marshal.ReadIntPtr(paramPtr);
T1 param1 = default;
- if (param1Ptr != IntPtr.Zero) MarshalHelper.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
+ if (param1Ptr != IntPtr.Zero)
+ MarshalHelper.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
deleg(instancePtr.Target, ref param1);
// Marshal reference parameters back to original unmanaged references
- if (param1Ptr != IntPtr.Zero && types[0].IsByRef) MarshalHelper.ToNative(ref param1, param1Ptr);
+ if (param1Ptr != IntPtr.Zero && types[0].IsByRef)
+ MarshalHelper.ToNative(ref param1, param1Ptr);
return IntPtr.Zero;
}
@@ -271,6 +275,7 @@ namespace FlaxEngine
internal static class InvokerNoRet2
{
internal delegate void InvokerDelegate(object instance, ref T1 param1, ref T2 param2);
+
internal delegate void ThunkInvokerDelegate(object instance, T1 param1, T2 param2);
internal static object CreateDelegate(MethodInfo method)
@@ -293,14 +298,18 @@ namespace FlaxEngine
T1 param1 = default;
T2 param2 = default;
- if (param1Ptr != IntPtr.Zero) MarshalHelper.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
- if (param2Ptr != IntPtr.Zero) MarshalHelper.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
+ if (param1Ptr != IntPtr.Zero)
+ MarshalHelper.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
+ if (param2Ptr != IntPtr.Zero)
+ MarshalHelper.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
deleg(instancePtr.Target, ref param1, ref param2);
// Marshal reference parameters back to original unmanaged references
- if (param1Ptr != IntPtr.Zero && types[0].IsByRef) MarshalHelper.ToNative(ref param1, param1Ptr);
- if (param2Ptr != IntPtr.Zero && types[1].IsByRef) MarshalHelper.ToNative(ref param2, param2Ptr);
+ if (param1Ptr != IntPtr.Zero && types[0].IsByRef)
+ MarshalHelper.ToNative(ref param1, param1Ptr);
+ if (param2Ptr != IntPtr.Zero && types[1].IsByRef)
+ MarshalHelper.ToNative(ref param2, param2Ptr);
return IntPtr.Zero;
}
@@ -322,6 +331,7 @@ namespace FlaxEngine
internal static class InvokerNoRet3
{
internal delegate void InvokerDelegate(object instance, ref T1 param1, ref T2 param2, ref T3 param3);
+
internal delegate void ThunkInvokerDelegate(object instance, T1 param1, T2 param2, T3 param3);
internal static object CreateDelegate(MethodInfo method)
@@ -346,16 +356,22 @@ namespace FlaxEngine
T1 param1 = default;
T2 param2 = default;
T3 param3 = default;
- if (param1Ptr != IntPtr.Zero) MarshalHelper.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
- if (param2Ptr != IntPtr.Zero) MarshalHelper.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
- if (param3Ptr != IntPtr.Zero) MarshalHelper.ToManaged(ref param3, param3Ptr, types[2].IsByRef);
+ if (param1Ptr != IntPtr.Zero)
+ MarshalHelper.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
+ if (param2Ptr != IntPtr.Zero)
+ MarshalHelper.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
+ if (param3Ptr != IntPtr.Zero)
+ MarshalHelper.ToManaged(ref param3, param3Ptr, types[2].IsByRef);
deleg(instancePtr.Target, ref param1, ref param2, ref param3);
// Marshal reference parameters back to original unmanaged references
- if (param1Ptr != IntPtr.Zero && types[0].IsByRef) MarshalHelper.ToNative(ref param1, param1Ptr);
- if (param2Ptr != IntPtr.Zero && types[1].IsByRef) MarshalHelper.ToNative(ref param2, param2Ptr);
- if (param3Ptr != IntPtr.Zero && types[2].IsByRef) MarshalHelper.ToNative(ref param3, param3Ptr);
+ if (param1Ptr != IntPtr.Zero && types[0].IsByRef)
+ MarshalHelper.ToNative(ref param1, param1Ptr);
+ if (param2Ptr != IntPtr.Zero && types[1].IsByRef)
+ MarshalHelper.ToNative(ref param2, param2Ptr);
+ if (param3Ptr != IntPtr.Zero && types[2].IsByRef)
+ MarshalHelper.ToNative(ref param3, param3Ptr);
return IntPtr.Zero;
}
@@ -378,6 +394,7 @@ namespace FlaxEngine
internal static class InvokerNoRet4
{
internal delegate void InvokerDelegate(object instance, ref T1 param1, ref T2 param2, ref T3 param3, ref T4 param4);
+
internal delegate void ThunkInvokerDelegate(object instance, T1 param1, T2 param2, T3 param3, T4 param4);
internal static object CreateDelegate(MethodInfo method)
@@ -404,18 +421,26 @@ namespace FlaxEngine
T2 param2 = default;
T3 param3 = default;
T4 param4 = default;
- if (param1Ptr != IntPtr.Zero) MarshalHelper.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
- if (param2Ptr != IntPtr.Zero) MarshalHelper.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
- if (param3Ptr != IntPtr.Zero) MarshalHelper.ToManaged(ref param3, param3Ptr, types[2].IsByRef);
- if (param4Ptr != IntPtr.Zero) MarshalHelper.ToManaged(ref param4, param4Ptr, types[3].IsByRef);
+ if (param1Ptr != IntPtr.Zero)
+ MarshalHelper.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
+ if (param2Ptr != IntPtr.Zero)
+ MarshalHelper.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
+ if (param3Ptr != IntPtr.Zero)
+ MarshalHelper.ToManaged(ref param3, param3Ptr, types[2].IsByRef);
+ if (param4Ptr != IntPtr.Zero)
+ MarshalHelper.ToManaged(ref param4, param4Ptr, types[3].IsByRef);
deleg(instancePtr.Target, ref param1, ref param2, ref param3, ref param4);
// Marshal reference parameters back to original unmanaged references
- if (param1Ptr != IntPtr.Zero && types[0].IsByRef) MarshalHelper.ToNative(ref param1, param1Ptr);
- if (param2Ptr != IntPtr.Zero && types[1].IsByRef) MarshalHelper.ToNative(ref param2, param2Ptr);
- if (param3Ptr != IntPtr.Zero && types[2].IsByRef) MarshalHelper.ToNative(ref param3, param3Ptr);
- if (param4Ptr != IntPtr.Zero && types[3].IsByRef) MarshalHelper.ToNative(ref param4, param4Ptr);
+ if (param1Ptr != IntPtr.Zero && types[0].IsByRef)
+ MarshalHelper.ToNative(ref param1, param1Ptr);
+ if (param2Ptr != IntPtr.Zero && types[1].IsByRef)
+ MarshalHelper.ToNative(ref param2, param2Ptr);
+ if (param3Ptr != IntPtr.Zero && types[2].IsByRef)
+ MarshalHelper.ToNative(ref param3, param3Ptr);
+ if (param4Ptr != IntPtr.Zero && types[3].IsByRef)
+ MarshalHelper.ToNative(ref param4, param4Ptr);
return IntPtr.Zero;
}
@@ -439,6 +464,7 @@ namespace FlaxEngine
internal static class InvokerStaticNoRet0
{
internal delegate void InvokerDelegate();
+
internal delegate void ThunkInvokerDelegate();
internal static object CreateDelegate(MethodInfo method)
@@ -475,6 +501,7 @@ namespace FlaxEngine
internal static class InvokerStaticNoRet1
{
internal delegate void InvokerDelegate(ref T1 param1);
+
internal delegate void ThunkInvokerDelegate(T1 param1);
internal static object CreateDelegate(MethodInfo method)
@@ -495,12 +522,14 @@ namespace FlaxEngine
IntPtr param1Ptr = Marshal.ReadIntPtr(paramPtr);
T1 param1 = default;
- if (param1Ptr != IntPtr.Zero) MarshalHelper.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
+ if (param1Ptr != IntPtr.Zero)
+ MarshalHelper.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
deleg(ref param1);
// Marshal reference parameters back to original unmanaged references
- if (param1Ptr != IntPtr.Zero && types[0].IsByRef) MarshalHelper.ToNative(ref param1, param1Ptr);
+ if (param1Ptr != IntPtr.Zero && types[0].IsByRef)
+ MarshalHelper.ToNative(ref param1, param1Ptr);
return IntPtr.Zero;
}
@@ -521,6 +550,7 @@ namespace FlaxEngine
internal static class InvokerStaticNoRet2
{
internal delegate void InvokerDelegate(ref T1 param1, ref T2 param2);
+
internal delegate void ThunkInvokerDelegate(T1 param1, T2 param2);
internal static object CreateDelegate(MethodInfo method)
@@ -543,14 +573,18 @@ namespace FlaxEngine
T1 param1 = default;
T2 param2 = default;
- if (param1Ptr != IntPtr.Zero) MarshalHelper.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
- if (param2Ptr != IntPtr.Zero) MarshalHelper.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
+ if (param1Ptr != IntPtr.Zero)
+ MarshalHelper.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
+ if (param2Ptr != IntPtr.Zero)
+ MarshalHelper.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
deleg(ref param1, ref param2);
// Marshal reference parameters back to original unmanaged references
- if (param1Ptr != IntPtr.Zero && types[0].IsByRef) MarshalHelper.ToNative(ref param1, param1Ptr);
- if (param2Ptr != IntPtr.Zero && types[1].IsByRef) MarshalHelper.ToNative(ref param2, param2Ptr);
+ if (param1Ptr != IntPtr.Zero && types[0].IsByRef)
+ MarshalHelper.ToNative(ref param1, param1Ptr);
+ if (param2Ptr != IntPtr.Zero && types[1].IsByRef)
+ MarshalHelper.ToNative(ref param2, param2Ptr);
return IntPtr.Zero;
}
@@ -572,6 +606,7 @@ namespace FlaxEngine
internal static class InvokerStaticNoRet3
{
internal delegate void InvokerDelegate(ref T1 param1, ref T2 param2, ref T3 param3);
+
internal delegate void ThunkInvokerDelegate(T1 param1, T2 param2, T3 param3);
internal static object CreateDelegate(MethodInfo method)
@@ -596,16 +631,22 @@ namespace FlaxEngine
T1 param1 = default;
T2 param2 = default;
T3 param3 = default;
- if (param1Ptr != IntPtr.Zero) MarshalHelper.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
- if (param2Ptr != IntPtr.Zero) MarshalHelper.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
- if (param3Ptr != IntPtr.Zero) MarshalHelper.ToManaged(ref param3, param3Ptr, types[2].IsByRef);
+ if (param1Ptr != IntPtr.Zero)
+ MarshalHelper.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
+ if (param2Ptr != IntPtr.Zero)
+ MarshalHelper.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
+ if (param3Ptr != IntPtr.Zero)
+ MarshalHelper.ToManaged(ref param3, param3Ptr, types[2].IsByRef);
deleg(ref param1, ref param2, ref param3);
// Marshal reference parameters back to original unmanaged references
- if (param1Ptr != IntPtr.Zero && types[0].IsByRef) MarshalHelper.ToNative(ref param1, param1Ptr);
- if (param2Ptr != IntPtr.Zero && types[1].IsByRef) MarshalHelper.ToNative(ref param2, param2Ptr);
- if (param3Ptr != IntPtr.Zero && types[2].IsByRef) MarshalHelper.ToNative(ref param3, param3Ptr);
+ if (param1Ptr != IntPtr.Zero && types[0].IsByRef)
+ MarshalHelper.ToNative(ref param1, param1Ptr);
+ if (param2Ptr != IntPtr.Zero && types[1].IsByRef)
+ MarshalHelper.ToNative(ref param2, param2Ptr);
+ if (param3Ptr != IntPtr.Zero && types[2].IsByRef)
+ MarshalHelper.ToNative(ref param3, param3Ptr);
return IntPtr.Zero;
}
@@ -628,6 +669,7 @@ namespace FlaxEngine
internal static class InvokerStaticNoRet4
{
internal delegate void InvokerDelegate(ref T1 param1, ref T2 param2, ref T3 param3, ref T4 param4);
+
internal delegate void ThunkInvokerDelegate(T1 param1, T2 param2, T3 param3, T4 param4);
internal static object CreateDelegate(MethodInfo method)
@@ -654,18 +696,26 @@ namespace FlaxEngine
T2 param2 = default;
T3 param3 = default;
T4 param4 = default;
- if (param1Ptr != IntPtr.Zero) MarshalHelper.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
- if (param2Ptr != IntPtr.Zero) MarshalHelper.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
- if (param3Ptr != IntPtr.Zero) MarshalHelper.ToManaged(ref param3, param3Ptr, types[2].IsByRef);
- if (param4Ptr != IntPtr.Zero) MarshalHelper.ToManaged(ref param4, param4Ptr, types[3].IsByRef);
+ if (param1Ptr != IntPtr.Zero)
+ MarshalHelper.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
+ if (param2Ptr != IntPtr.Zero)
+ MarshalHelper.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
+ if (param3Ptr != IntPtr.Zero)
+ MarshalHelper.ToManaged(ref param3, param3Ptr, types[2].IsByRef);
+ if (param4Ptr != IntPtr.Zero)
+ MarshalHelper.ToManaged(ref param4, param4Ptr, types[3].IsByRef);
deleg(ref param1, ref param2, ref param3, ref param4);
// Marshal reference parameters back to original unmanaged references
- if (param1Ptr != IntPtr.Zero && types[0].IsByRef) MarshalHelper.ToNative(ref param1, param1Ptr);
- if (param2Ptr != IntPtr.Zero && types[1].IsByRef) MarshalHelper.ToNative(ref param2, param2Ptr);
- if (param3Ptr != IntPtr.Zero && types[2].IsByRef) MarshalHelper.ToNative(ref param3, param3Ptr);
- if (param4Ptr != IntPtr.Zero && types[3].IsByRef) MarshalHelper.ToNative(ref param4, param4Ptr);
+ if (param1Ptr != IntPtr.Zero && types[0].IsByRef)
+ MarshalHelper.ToNative(ref param1, param1Ptr);
+ if (param2Ptr != IntPtr.Zero && types[1].IsByRef)
+ MarshalHelper.ToNative(ref param2, param2Ptr);
+ if (param3Ptr != IntPtr.Zero && types[2].IsByRef)
+ MarshalHelper.ToNative(ref param3, param3Ptr);
+ if (param4Ptr != IntPtr.Zero && types[3].IsByRef)
+ MarshalHelper.ToNative(ref param4, param4Ptr);
return IntPtr.Zero;
}
@@ -689,6 +739,7 @@ namespace FlaxEngine
internal static class InvokerRet0
{
internal delegate TRet InvokerDelegate(object instance);
+
internal delegate TRet ThunkInvokerDelegate(object instance);
internal static object CreateDelegate(MethodInfo method)
@@ -725,6 +776,7 @@ namespace FlaxEngine
internal static class InvokerRet1
{
internal delegate TRet InvokerDelegate(object instance, ref T1 param1);
+
internal delegate TRet ThunkInvokerDelegate(object instance, T1 param1);
internal static object CreateDelegate(MethodInfo method)
@@ -745,12 +797,14 @@ namespace FlaxEngine
IntPtr param1Ptr = Marshal.ReadIntPtr(paramPtr);
T1 param1 = default;
- if (param1Ptr != IntPtr.Zero) MarshalHelper.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
+ if (param1Ptr != IntPtr.Zero)
+ MarshalHelper.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
TRet ret = deleg(instancePtr.Target, ref param1);
// Marshal reference parameters back to original unmanaged references
- if (param1Ptr != IntPtr.Zero && types[0].IsByRef) MarshalHelper.ToNative(ref param1, param1Ptr);
+ if (param1Ptr != IntPtr.Zero && types[0].IsByRef)
+ MarshalHelper.ToNative(ref param1, param1Ptr);
return MarshalReturnValue(ref ret);
}
@@ -771,6 +825,7 @@ namespace FlaxEngine
internal static class InvokerRet2
{
internal delegate TRet InvokerDelegate(object instance, ref T1 param1, ref T2 param2);
+
internal delegate TRet ThunkInvokerDelegate(object instance, T1 param1, T2 param2);
internal static object CreateDelegate(MethodInfo method)
@@ -793,14 +848,18 @@ namespace FlaxEngine
T1 param1 = default;
T2 param2 = default;
- if (param1Ptr != IntPtr.Zero) MarshalHelper.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
- if (param2Ptr != IntPtr.Zero) MarshalHelper.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
+ if (param1Ptr != IntPtr.Zero)
+ MarshalHelper.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
+ if (param2Ptr != IntPtr.Zero)
+ MarshalHelper.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
TRet ret = deleg(instancePtr.Target, ref param1, ref param2);
// Marshal reference parameters back to original unmanaged references
- if (param1Ptr != IntPtr.Zero && types[0].IsByRef) MarshalHelper.ToNative(ref param1, param1Ptr);
- if (param2Ptr != IntPtr.Zero && types[1].IsByRef) MarshalHelper.ToNative(ref param2, param2Ptr);
+ if (param1Ptr != IntPtr.Zero && types[0].IsByRef)
+ MarshalHelper.ToNative(ref param1, param1Ptr);
+ if (param2Ptr != IntPtr.Zero && types[1].IsByRef)
+ MarshalHelper.ToNative(ref param2, param2Ptr);
return MarshalReturnValue(ref ret);
}
@@ -822,6 +881,7 @@ namespace FlaxEngine
internal static class InvokerRet3
{
internal delegate TRet InvokerDelegate(object instance, ref T1 param1, ref T2 param2, ref T3 param3);
+
internal delegate TRet ThunkInvokerDelegate(object instance, T1 param1, T2 param2, T3 param3);
internal static object CreateDelegate(MethodInfo method)
@@ -846,16 +906,22 @@ namespace FlaxEngine
T1 param1 = default;
T2 param2 = default;
T3 param3 = default;
- if (param1Ptr != IntPtr.Zero) MarshalHelper.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
- if (param2Ptr != IntPtr.Zero) MarshalHelper.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
- if (param3Ptr != IntPtr.Zero) MarshalHelper.ToManaged(ref param3, param3Ptr, types[2].IsByRef);
+ if (param1Ptr != IntPtr.Zero)
+ MarshalHelper.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
+ if (param2Ptr != IntPtr.Zero)
+ MarshalHelper.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
+ if (param3Ptr != IntPtr.Zero)
+ MarshalHelper.ToManaged(ref param3, param3Ptr, types[2].IsByRef);
TRet ret = deleg(instancePtr.Target, ref param1, ref param2, ref param3);
// Marshal reference parameters back to original unmanaged references
- if (param1Ptr != IntPtr.Zero && types[0].IsByRef) MarshalHelper.ToNative(ref param1, param1Ptr);
- if (param2Ptr != IntPtr.Zero && types[1].IsByRef) MarshalHelper.ToNative(ref param2, param2Ptr);
- if (param3Ptr != IntPtr.Zero && types[2].IsByRef) MarshalHelper.ToNative(ref param3, param3Ptr);
+ if (param1Ptr != IntPtr.Zero && types[0].IsByRef)
+ MarshalHelper.ToNative(ref param1, param1Ptr);
+ if (param2Ptr != IntPtr.Zero && types[1].IsByRef)
+ MarshalHelper.ToNative(ref param2, param2Ptr);
+ if (param3Ptr != IntPtr.Zero && types[2].IsByRef)
+ MarshalHelper.ToNative(ref param3, param3Ptr);
return MarshalReturnValue(ref ret);
}
@@ -878,6 +944,7 @@ namespace FlaxEngine
internal static class InvokerRet4
{
internal delegate TRet InvokerDelegate(object instance, ref T1 param1, ref T2 param2, ref T3 param3, ref T4 param4);
+
internal delegate TRet ThunkInvokerDelegate(object instance, T1 param1, T2 param2, T3 param3, T4 param4);
internal static object CreateDelegate(MethodInfo method)
@@ -904,18 +971,26 @@ namespace FlaxEngine
T2 param2 = default;
T3 param3 = default;
T4 param4 = default;
- if (param1Ptr != IntPtr.Zero) MarshalHelper.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
- if (param2Ptr != IntPtr.Zero) MarshalHelper.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
- if (param3Ptr != IntPtr.Zero) MarshalHelper.ToManaged(ref param3, param3Ptr, types[2].IsByRef);
- if (param4Ptr != IntPtr.Zero) MarshalHelper.ToManaged(ref param4, param4Ptr, types[3].IsByRef);
+ if (param1Ptr != IntPtr.Zero)
+ MarshalHelper.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
+ if (param2Ptr != IntPtr.Zero)
+ MarshalHelper.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
+ if (param3Ptr != IntPtr.Zero)
+ MarshalHelper.ToManaged(ref param3, param3Ptr, types[2].IsByRef);
+ if (param4Ptr != IntPtr.Zero)
+ MarshalHelper.ToManaged(ref param4, param4Ptr, types[3].IsByRef);
TRet ret = deleg(instancePtr.Target, ref param1, ref param2, ref param3, ref param4);
// Marshal reference parameters back to original unmanaged references
- if (param1Ptr != IntPtr.Zero && types[0].IsByRef) MarshalHelper.ToNative(ref param1, param1Ptr);
- if (param2Ptr != IntPtr.Zero && types[1].IsByRef) MarshalHelper.ToNative(ref param2, param2Ptr);
- if (param3Ptr != IntPtr.Zero && types[2].IsByRef) MarshalHelper.ToNative(ref param3, param3Ptr);
- if (param4Ptr != IntPtr.Zero && types[3].IsByRef) MarshalHelper.ToNative(ref param4, param4Ptr);
+ if (param1Ptr != IntPtr.Zero && types[0].IsByRef)
+ MarshalHelper.ToNative(ref param1, param1Ptr);
+ if (param2Ptr != IntPtr.Zero && types[1].IsByRef)
+ MarshalHelper.ToNative(ref param2, param2Ptr);
+ if (param3Ptr != IntPtr.Zero && types[2].IsByRef)
+ MarshalHelper.ToNative(ref param3, param3Ptr);
+ if (param4Ptr != IntPtr.Zero && types[3].IsByRef)
+ MarshalHelper.ToNative(ref param4, param4Ptr);
return MarshalReturnValue(ref ret);
}
@@ -939,6 +1014,7 @@ namespace FlaxEngine
internal static class InvokerStaticRet0
{
internal delegate TRet InvokerDelegate();
+
internal delegate TRet ThunkInvokerDelegate();
internal static object CreateDelegate(MethodInfo method)
@@ -975,6 +1051,7 @@ namespace FlaxEngine
internal static class InvokerStaticRet1
{
internal delegate TRet InvokerDelegate(ref T1 param1);
+
internal delegate TRet ThunkInvokerDelegate(T1 param1);
internal static object CreateDelegate(MethodInfo method)
@@ -995,12 +1072,14 @@ namespace FlaxEngine
IntPtr param1Ptr = Marshal.ReadIntPtr(paramPtr);
T1 param1 = default;
- if (param1Ptr != IntPtr.Zero) MarshalHelper.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
+ if (param1Ptr != IntPtr.Zero)
+ MarshalHelper.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
TRet ret = deleg(ref param1);
// Marshal reference parameters back to original unmanaged references
- if (param1Ptr != IntPtr.Zero && types[0].IsByRef) MarshalHelper.ToNative(ref param1, param1Ptr);
+ if (param1Ptr != IntPtr.Zero && types[0].IsByRef)
+ MarshalHelper.ToNative(ref param1, param1Ptr);
return MarshalReturnValue(ref ret);
}
@@ -1021,6 +1100,7 @@ namespace FlaxEngine
internal static class InvokerStaticRet2
{
internal delegate TRet InvokerDelegate(ref T1 param1, ref T2 param2);
+
internal delegate TRet ThunkInvokerDelegate(T1 param1, T2 param2);
internal static object CreateDelegate(MethodInfo method)
@@ -1043,14 +1123,18 @@ namespace FlaxEngine
T1 param1 = default;
T2 param2 = default;
- if (param1Ptr != IntPtr.Zero) MarshalHelper.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
- if (param2Ptr != IntPtr.Zero) MarshalHelper.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
+ if (param1Ptr != IntPtr.Zero)
+ MarshalHelper.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
+ if (param2Ptr != IntPtr.Zero)
+ MarshalHelper.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
TRet ret = deleg(ref param1, ref param2);
// Marshal reference parameters back to original unmanaged references
- if (param1Ptr != IntPtr.Zero && types[0].IsByRef) MarshalHelper.ToNative(ref param1, param1Ptr);
- if (param2Ptr != IntPtr.Zero && types[1].IsByRef) MarshalHelper.ToNative(ref param2, param2Ptr);
+ if (param1Ptr != IntPtr.Zero && types[0].IsByRef)
+ MarshalHelper.ToNative(ref param1, param1Ptr);
+ if (param2Ptr != IntPtr.Zero && types[1].IsByRef)
+ MarshalHelper.ToNative(ref param2, param2Ptr);
return MarshalReturnValue(ref ret);
}
@@ -1072,6 +1156,7 @@ namespace FlaxEngine
internal static class InvokerStaticRet3
{
internal delegate TRet InvokerDelegate(ref T1 param1, ref T2 param2, ref T3 param3);
+
internal delegate TRet ThunkInvokerDelegate(T1 param1, T2 param2, T3 param3);
internal static object CreateDelegate(MethodInfo method)
@@ -1096,16 +1181,22 @@ namespace FlaxEngine
T1 param1 = default;
T2 param2 = default;
T3 param3 = default;
- if (param1Ptr != IntPtr.Zero) MarshalHelper.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
- if (param2Ptr != IntPtr.Zero) MarshalHelper.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
- if (param3Ptr != IntPtr.Zero) MarshalHelper.ToManaged(ref param3, param3Ptr, types[2].IsByRef);
+ if (param1Ptr != IntPtr.Zero)
+ MarshalHelper.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
+ if (param2Ptr != IntPtr.Zero)
+ MarshalHelper.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
+ if (param3Ptr != IntPtr.Zero)
+ MarshalHelper.ToManaged(ref param3, param3Ptr, types[2].IsByRef);
TRet ret = deleg(ref param1, ref param2, ref param3);
// Marshal reference parameters back to original unmanaged references
- if (param1Ptr != IntPtr.Zero && types[0].IsByRef) MarshalHelper.ToNative(ref param1, param1Ptr);
- if (param2Ptr != IntPtr.Zero && types[1].IsByRef) MarshalHelper.ToNative(ref param2, param2Ptr);
- if (param3Ptr != IntPtr.Zero && types[2].IsByRef) MarshalHelper.ToNative(ref param3, param3Ptr);
+ if (param1Ptr != IntPtr.Zero && types[0].IsByRef)
+ MarshalHelper.ToNative(ref param1, param1Ptr);
+ if (param2Ptr != IntPtr.Zero && types[1].IsByRef)
+ MarshalHelper.ToNative(ref param2, param2Ptr);
+ if (param3Ptr != IntPtr.Zero && types[2].IsByRef)
+ MarshalHelper.ToNative(ref param3, param3Ptr);
return MarshalReturnValue(ref ret);
}
@@ -1128,6 +1219,7 @@ namespace FlaxEngine
internal static class InvokerStaticRet4
{
internal delegate TRet InvokerDelegate(ref T1 param1, ref T2 param2, ref T3 param3, ref T4 param4);
+
internal delegate TRet ThunkInvokerDelegate(T1 param1, T2 param2, T3 param3, T4 param4);
internal static object CreateDelegate(MethodInfo method)
@@ -1154,18 +1246,26 @@ namespace FlaxEngine
T2 param2 = default;
T3 param3 = default;
T4 param4 = default;
- if (param1Ptr != IntPtr.Zero) MarshalHelper.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
- if (param2Ptr != IntPtr.Zero) MarshalHelper.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
- if (param3Ptr != IntPtr.Zero) MarshalHelper.ToManaged(ref param3, param3Ptr, types[2].IsByRef);
- if (param4Ptr != IntPtr.Zero) MarshalHelper.ToManaged(ref param4, param4Ptr, types[3].IsByRef);
+ if (param1Ptr != IntPtr.Zero)
+ MarshalHelper.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
+ if (param2Ptr != IntPtr.Zero)
+ MarshalHelper.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
+ if (param3Ptr != IntPtr.Zero)
+ MarshalHelper.ToManaged(ref param3, param3Ptr, types[2].IsByRef);
+ if (param4Ptr != IntPtr.Zero)
+ MarshalHelper.ToManaged(ref param4, param4Ptr, types[3].IsByRef);
TRet ret = deleg(ref param1, ref param2, ref param3, ref param4);
// Marshal reference parameters back to original unmanaged references
- if (param1Ptr != IntPtr.Zero && types[0].IsByRef) MarshalHelper.ToNative(ref param1, param1Ptr);
- if (param2Ptr != IntPtr.Zero && types[1].IsByRef) MarshalHelper.ToNative(ref param2, param2Ptr);
- if (param3Ptr != IntPtr.Zero && types[2].IsByRef) MarshalHelper.ToNative(ref param3, param3Ptr);
- if (param4Ptr != IntPtr.Zero && types[3].IsByRef) MarshalHelper.ToNative(ref param4, param4Ptr);
+ if (param1Ptr != IntPtr.Zero && types[0].IsByRef)
+ MarshalHelper.ToNative(ref param1, param1Ptr);
+ if (param2Ptr != IntPtr.Zero && types[1].IsByRef)
+ MarshalHelper.ToNative(ref param2, param2Ptr);
+ if (param3Ptr != IntPtr.Zero && types[2].IsByRef)
+ MarshalHelper.ToNative(ref param3, param3Ptr);
+ if (param4Ptr != IntPtr.Zero && types[3].IsByRef)
+ MarshalHelper.ToNative(ref param4, param4Ptr);
return MarshalReturnValue(ref ret);
}
diff --git a/Source/Engine/Engine/NativeInterop.Managed.cs b/Source/Engine/Engine/NativeInterop.Managed.cs
index 77c3587a5..42fccf204 100644
--- a/Source/Engine/Engine/NativeInterop.Managed.cs
+++ b/Source/Engine/Engine/NativeInterop.Managed.cs
@@ -8,11 +8,10 @@ using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Threading;
using FlaxEngine.Assertions;
-using FlaxEngine.Utilities;
#pragma warning disable 1591
-namespace FlaxEngine
+namespace FlaxEngine.Interop
{
///
/// Wrapper for managed arrays which are passed to unmanaged code.
diff --git a/Source/Engine/Engine/NativeInterop.Marshallers.cs b/Source/Engine/Engine/NativeInterop.Marshallers.cs
index f6434c325..96ba7edf5 100644
--- a/Source/Engine/Engine/NativeInterop.Marshallers.cs
+++ b/Source/Engine/Engine/NativeInterop.Marshallers.cs
@@ -9,9 +9,8 @@ using System.Runtime.InteropServices.Marshalling;
#pragma warning disable 1591
-namespace FlaxEngine
+namespace FlaxEngine.Interop
{
-
[CustomMarshaller(typeof(object), MarshalMode.ManagedToUnmanagedIn, typeof(ManagedHandleMarshaller.ManagedToNative))]
[CustomMarshaller(typeof(object), MarshalMode.UnmanagedToManagedOut, typeof(ManagedHandleMarshaller.ManagedToNative))]
[CustomMarshaller(typeof(object), MarshalMode.ElementIn, typeof(ManagedHandleMarshaller.ManagedToNative))]
diff --git a/Source/Engine/Engine/NativeInterop.Unmanaged.cs b/Source/Engine/Engine/NativeInterop.Unmanaged.cs
index 6b3d5b47d..2a756a189 100644
--- a/Source/Engine/Engine/NativeInterop.Unmanaged.cs
+++ b/Source/Engine/Engine/NativeInterop.Unmanaged.cs
@@ -13,7 +13,7 @@ using FlaxEngine.Utilities;
#pragma warning disable 1591
-namespace FlaxEngine
+namespace FlaxEngine.Interop
{
[StructLayout(LayoutKind.Sequential)]
internal struct NativeClassDefinitions
diff --git a/Source/Engine/Engine/NativeInterop.cs b/Source/Engine/Engine/NativeInterop.cs
index b0686f2d1..418f2e13b 100644
--- a/Source/Engine/Engine/NativeInterop.cs
+++ b/Source/Engine/Engine/NativeInterop.cs
@@ -15,7 +15,7 @@ using FlaxEngine.Assertions;
using System.Collections.Concurrent;
using System.Text;
-namespace FlaxEngine
+namespace FlaxEngine.Interop
{
///
/// Provides a Mono-like API for native code to access managed runtime.
diff --git a/Source/Engine/Scripting/Object.cs b/Source/Engine/Scripting/Object.cs
index 21c68fcd2..1ddffaf66 100644
--- a/Source/Engine/Scripting/Object.cs
+++ b/Source/Engine/Scripting/Object.cs
@@ -15,7 +15,7 @@ namespace FlaxEngine
/// Base class for all objects Flax can reference. Every object has unique identifier.
///
[Serializable]
- [NativeMarshalling(typeof(ObjectMarshaller))]
+ [NativeMarshalling(typeof(Interop.ObjectMarshaller))]
public abstract partial class Object
{
///
@@ -240,7 +240,7 @@ namespace FlaxEngine
///
/// The pointer to the unmanaged (native) object.
/// The object.
- [LibraryImport("FlaxEngine", EntryPoint = "ObjectInternal_FromUnmanagedPtr", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "ObjectInternal_FromUnmanagedPtr", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(Interop.StringMarshaller))]
public static partial Object FromUnmanagedPtr(IntPtr ptr);
///
@@ -251,35 +251,35 @@ namespace FlaxEngine
#region Internal Calls
- [LibraryImport("FlaxEngine", EntryPoint = "ObjectInternal_Create1", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
- internal static partial Object Internal_Create1([MarshalUsing(typeof(SystemTypeMarshaller))] Type type);
+ [LibraryImport("FlaxEngine", EntryPoint = "ObjectInternal_Create1", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(Interop.StringMarshaller))]
+ internal static partial Object Internal_Create1([MarshalUsing(typeof(Interop.SystemTypeMarshaller))] Type type);
- [LibraryImport("FlaxEngine", EntryPoint = "ObjectInternal_Create2", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "ObjectInternal_Create2", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(Interop.StringMarshaller))]
internal static partial Object Internal_Create2(string typeName);
- [LibraryImport("FlaxEngine", EntryPoint = "ObjectInternal_ManagedInstanceCreated", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "ObjectInternal_ManagedInstanceCreated", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(Interop.StringMarshaller))]
internal static partial void Internal_ManagedInstanceCreated(Object managedInstance);
- [LibraryImport("FlaxEngine", EntryPoint = "ObjectInternal_ManagedInstanceDeleted", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "ObjectInternal_ManagedInstanceDeleted", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(Interop.StringMarshaller))]
internal static partial void Internal_ManagedInstanceDeleted(IntPtr nativeInstance);
- [LibraryImport("FlaxEngine", EntryPoint = "ObjectInternal_Destroy", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "ObjectInternal_Destroy", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(Interop.StringMarshaller))]
internal static partial void Internal_Destroy(IntPtr obj, float timeLeft);
- [LibraryImport("FlaxEngine", EntryPoint = "ObjectInternal_GetTypeName", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "ObjectInternal_GetTypeName", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(Interop.StringMarshaller))]
internal static partial string Internal_GetTypeName(IntPtr obj);
- [LibraryImport("FlaxEngine", EntryPoint = "ObjectInternal_FindObject", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
- internal static partial Object Internal_FindObject(ref Guid id, [MarshalUsing(typeof(SystemTypeMarshaller))] Type type);
+ [LibraryImport("FlaxEngine", EntryPoint = "ObjectInternal_FindObject", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(Interop.StringMarshaller))]
+ internal static partial Object Internal_FindObject(ref Guid id, [MarshalUsing(typeof(Interop.SystemTypeMarshaller))] Type type);
- [LibraryImport("FlaxEngine", EntryPoint = "ObjectInternal_TryFindObject", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
- internal static partial Object Internal_TryFindObject(ref Guid id, [MarshalUsing(typeof(SystemTypeMarshaller))] Type type);
+ [LibraryImport("FlaxEngine", EntryPoint = "ObjectInternal_TryFindObject", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(Interop.StringMarshaller))]
+ internal static partial Object Internal_TryFindObject(ref Guid id, [MarshalUsing(typeof(Interop.SystemTypeMarshaller))] Type type);
- [LibraryImport("FlaxEngine", EntryPoint = "ObjectInternal_ChangeID", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "ObjectInternal_ChangeID", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(Interop.StringMarshaller))]
internal static partial void Internal_ChangeID(IntPtr obj, ref Guid id);
- [LibraryImport("FlaxEngine", EntryPoint = "ObjectInternal_GetUnmanagedInterface", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
- internal static partial IntPtr Internal_GetUnmanagedInterface(IntPtr obj, [MarshalUsing(typeof(SystemTypeMarshaller))] Type type);
+ [LibraryImport("FlaxEngine", EntryPoint = "ObjectInternal_GetUnmanagedInterface", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(Interop.StringMarshaller))]
+ internal static partial IntPtr Internal_GetUnmanagedInterface(IntPtr obj, [MarshalUsing(typeof(Interop.SystemTypeMarshaller))] Type type);
#endregion
}
diff --git a/Source/Engine/Scripting/Runtime/DotNet.cpp b/Source/Engine/Scripting/Runtime/DotNet.cpp
index 65bbb9e7c..19f39e9c6 100644
--- a/Source/Engine/Scripting/Runtime/DotNet.cpp
+++ b/Source/Engine/Scripting/Runtime/DotNet.cpp
@@ -156,7 +156,7 @@ extern MDomain* MActiveDomain;
extern Array> MDomains;
Dictionary CachedFunctions;
-const char_t* NativeInteropTypeName = FLAX_CORECLR_TEXT("FlaxEngine.NativeInterop, FlaxEngine.CSharp");
+const char_t* NativeInteropTypeName = FLAX_CORECLR_TEXT("FlaxEngine.Interop.NativeInterop, FlaxEngine.CSharp");
Dictionary classHandles;
Dictionary assemblyHandles;
diff --git a/Source/Engine/Scripting/Scripting.cs b/Source/Engine/Scripting/Scripting.cs
index d5f2f7fb2..f4a01cadb 100644
--- a/Source/Engine/Scripting/Scripting.cs
+++ b/Source/Engine/Scripting/Scripting.cs
@@ -11,6 +11,7 @@ using System.Runtime.InteropServices.Marshalling;
using System.Threading;
using System.Threading.Tasks;
using FlaxEngine.GUI;
+using FlaxEngine.Interop;
namespace FlaxEngine
{
@@ -316,7 +317,7 @@ namespace FlaxEngine
/// Returns true if game scripts assembly has been loaded.
///
/// True if game scripts assembly is loaded, otherwise false.
- [LibraryImport("FlaxEngine", EntryPoint = "ScriptingInternal_HasGameModulesLoaded", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "ScriptingInternal_HasGameModulesLoaded", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
[return: MarshalAs(UnmanagedType.U1)]
public static partial bool HasGameModulesLoaded();
@@ -324,14 +325,14 @@ namespace FlaxEngine
/// Returns true if given type is from one of the game scripts assemblies.
///
/// True if the type is from game assembly, otherwise false.
- [LibraryImport("FlaxEngine", EntryPoint = "ScriptingInternal_IsTypeFromGameScripts", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "ScriptingInternal_IsTypeFromGameScripts", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
[return: MarshalAs(UnmanagedType.U1)]
public static partial bool IsTypeFromGameScripts([MarshalUsing(typeof(SystemTypeMarshaller))] Type type);
///
/// Flushes the removed objects (disposed objects using Object.Destroy).
///
- [LibraryImport("FlaxEngine", EntryPoint = "ScriptingInternal_FlushRemovedObjects", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "ScriptingInternal_FlushRemovedObjects", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
public static partial void FlushRemovedObjects();
}
@@ -347,26 +348,26 @@ namespace FlaxEngine
/// Begins profiling a piece of code with a custom label.
///
/// The name of the event.
- [LibraryImport("FlaxEngine", EntryPoint = "ProfilerInternal_BeginEvent", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "ProfilerInternal_BeginEvent", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
public static partial void BeginEvent(string name);
///
/// Ends profiling an event.
///
- [LibraryImport("FlaxEngine", EntryPoint = "ProfilerInternal_EndEvent", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "ProfilerInternal_EndEvent", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
public static partial void EndEvent();
///
/// Begins GPU profiling a piece of code with a custom label.
///
/// The name of the event.
- [LibraryImport("FlaxEngine", EntryPoint = "ProfilerInternal_BeginEventGPU", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "ProfilerInternal_BeginEventGPU", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
public static partial void BeginEventGPU(string name);
///
/// Ends GPU profiling an event.
///
- [LibraryImport("FlaxEngine", EntryPoint = "ProfilerInternal_EndEventGPU", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]
+ [LibraryImport("FlaxEngine", EntryPoint = "ProfilerInternal_EndEventGPU", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
public static partial void EndEventGPU();
}
}
diff --git a/Source/Engine/Tests/TestScripting.cs b/Source/Engine/Tests/TestScripting.cs
index 9d5d3ba83..48dae37e3 100644
--- a/Source/Engine/Tests/TestScripting.cs
+++ b/Source/Engine/Tests/TestScripting.cs
@@ -12,13 +12,13 @@ namespace FlaxEngine.Tests
public class TestScripting
{
///
- /// Tests all usages in the engine to verify all bindigns are correct to work with P/Invoke.
+ /// Tests all usages in the engine to verify all bindings are correct to work with P/Invoke.
///
public static int TestLibraryImports()
{
var result = 0;
var libraryName = "FlaxEngine";
- var library = NativeLibrary.Load(NativeInterop.nativeLibraryPaths[libraryName]);
+ var library = NativeLibrary.Load(Interop.NativeInterop.nativeLibraryPaths[libraryName]);
if (library == IntPtr.Zero)
return -1;
var types = typeof(FlaxEngine.Object).Assembly.GetTypes();
diff --git a/Source/Engine/Utilities/Utils.cs b/Source/Engine/Utilities/Utils.cs
index 905680420..5ac43ecd9 100644
--- a/Source/Engine/Utilities/Utils.cs
+++ b/Source/Engine/Utilities/Utils.cs
@@ -7,6 +7,7 @@ using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Runtime.Loader;
+using FlaxEngine.Interop;
namespace FlaxEngine
{
@@ -238,7 +239,7 @@ namespace FlaxEngine
var location = assembly.Location;
if (!string.IsNullOrEmpty(location))
return location;
- if (NativeInterop.AssemblyLocations.TryGetValue(assembly.FullName, out location))
+ if (Interop.NativeInterop.AssemblyLocations.TryGetValue(assembly.FullName, out location))
return location;
return null;
#else
diff --git a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs
index edfdbf3b3..842db783c 100644
--- a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs
+++ b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs
@@ -494,24 +494,24 @@ namespace Flax.Build.Bindings
if (returnValueType == "bool")
returnMarshalType = "MarshalAs(UnmanagedType.U1)";
else if (returnValueType == "System.Type")
- returnMarshalType = "MarshalUsing(typeof(FlaxEngine.SystemTypeMarshaller))";
+ returnMarshalType = "MarshalUsing(typeof(FlaxEngine.Interop.SystemTypeMarshaller))";
else if (returnValueType == "CultureInfo")
- returnMarshalType = "MarshalUsing(typeof(FlaxEngine.CultureInfoMarshaller))";
+ returnMarshalType = "MarshalUsing(typeof(FlaxEngine.Interop.CultureInfoMarshaller))";
else if (functionInfo.ReturnType.Type == "Variant")
- returnMarshalType = "MarshalUsing(typeof(FlaxEngine.ManagedHandleMarshaller))";
+ returnMarshalType = "MarshalUsing(typeof(FlaxEngine.Interop.ManagedHandleMarshaller))";
else if (FindApiTypeInfo(buildData, functionInfo.ReturnType, caller)?.IsInterface ?? false)
{
// Interfaces are not supported by NativeMarshallingAttribute, marshal the parameter
returnMarshalType = $"MarshalUsing(typeof({returnValueType}Marshaller))";
}
else if (functionInfo.ReturnType.Type == "MonoArray" || functionInfo.ReturnType.Type == "MArray")
- returnMarshalType = "MarshalUsing(typeof(FlaxEngine.SystemArrayMarshaller))";
+ returnMarshalType = "MarshalUsing(typeof(FlaxEngine.Interop.SystemArrayMarshaller))";
else if (functionInfo.ReturnType.Type == "Array" || functionInfo.ReturnType.Type == "Span" || functionInfo.ReturnType.Type == "DataContainer" || functionInfo.ReturnType.Type == "BytesContainer" || returnNativeType == "Array")
- returnMarshalType = $"MarshalUsing(typeof(FlaxEngine.ArrayMarshaller<,>), CountElementName = nameof(__returnCount))";
+ returnMarshalType = $"MarshalUsing(typeof(FlaxEngine.Interop.ArrayMarshaller<,>), CountElementName = nameof(__returnCount))";
else if (functionInfo.ReturnType.Type == "Dictionary")
- returnMarshalType = $"MarshalUsing(typeof(FlaxEngine.DictionaryMarshaller<,>), ConstantElementCount = 0)";
+ returnMarshalType = $"MarshalUsing(typeof(FlaxEngine.Interop.DictionaryMarshaller<,>), ConstantElementCount = 0)";
else if (returnValueType == "byte[]")
- returnMarshalType = $"MarshalUsing(typeof(FlaxEngine.ArrayMarshaller<,>), CountElementName = \"__returnCount\")";
+ returnMarshalType = $"MarshalUsing(typeof(FlaxEngine.Interop.ArrayMarshaller<,>), CountElementName = \"__returnCount\")";
else if (returnValueType == "bool[]")
{
// Boolean arrays does not support custom marshalling for some unknown reason
@@ -524,7 +524,7 @@ namespace Flax.Build.Bindings
#else
if (string.IsNullOrEmpty(functionInfo.Glue.LibraryEntryPoint))
throw new Exception($"Function {caller.FullNameNative}::{functionInfo.Name} has missing entry point for library import.");
- contents.AppendLine().Append(indent).Append($"[LibraryImport(\"{caller.ParentModule.Module.BinaryModuleName}\", EntryPoint = \"{functionInfo.Glue.LibraryEntryPoint}\", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]");
+ contents.AppendLine().Append(indent).Append($"[LibraryImport(\"{caller.ParentModule.Module.BinaryModuleName}\", EntryPoint = \"{functionInfo.Glue.LibraryEntryPoint}\", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.Interop.StringMarshaller))]");
if (!string.IsNullOrEmpty(returnMarshalType))
contents.AppendLine().Append(indent).Append($"[return: {returnMarshalType}]");
contents.AppendLine().Append(indent).Append("internal static partial ");
@@ -548,19 +548,19 @@ namespace Flax.Build.Bindings
#if USE_NETCORE
string parameterMarshalType = "";
if (nativeType == "System.Type")
- parameterMarshalType = "MarshalUsing(typeof(FlaxEngine.SystemTypeMarshaller))";
+ parameterMarshalType = "MarshalUsing(typeof(FlaxEngine.Interop.SystemTypeMarshaller))";
else if (parameterInfo.Type.Type == "CultureInfo")
- parameterMarshalType = "MarshalUsing(typeof(FlaxEngine.CultureInfoMarshaller))";
+ parameterMarshalType = "MarshalUsing(typeof(FlaxEngine.Interop.CultureInfoMarshaller))";
else if (parameterInfo.Type.Type == "Variant") // object
- parameterMarshalType = "MarshalUsing(typeof(FlaxEngine.ManagedHandleMarshaller))";
+ parameterMarshalType = "MarshalUsing(typeof(FlaxEngine.Interop.ManagedHandleMarshaller))";
else if (parameterInfo.Type.Type == "MonoArray" || parameterInfo.Type.Type == "MArray")
- parameterMarshalType = "MarshalUsing(typeof(FlaxEngine.SystemArrayMarshaller))";
+ parameterMarshalType = "MarshalUsing(typeof(FlaxEngine.Interop.SystemArrayMarshaller))";
else if (parameterInfo.Type.Type == "Array" && parameterInfo.Type.GenericArgs.Count > 0 && parameterInfo.Type.GenericArgs[0].Type == "bool")
parameterMarshalType = $"MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U1, SizeParamIndex = {(!functionInfo.IsStatic ? 1 : 0) + functionInfo.Parameters.Count + (functionInfo.Glue.CustomParameters.FindIndex(x => x.Name == $"__{parameterInfo.Name}Count"))})";
else if (parameterInfo.Type.Type == "Array" || parameterInfo.Type.Type == "Span" || parameterInfo.Type.Type == "DataContainer" || parameterInfo.Type.Type == "BytesContainer" || nativeType == "Array")
- parameterMarshalType = $"MarshalUsing(typeof(FlaxEngine.ArrayMarshaller<,>), CountElementName = \"__{parameterInfo.Name}Count\")";
+ parameterMarshalType = $"MarshalUsing(typeof(FlaxEngine.Interop.ArrayMarshaller<,>), CountElementName = \"__{parameterInfo.Name}Count\")";
else if (parameterInfo.Type.Type == "Dictionary")
- parameterMarshalType = $"MarshalUsing(typeof(FlaxEngine.DictionaryMarshaller<,>), ConstantElementCount = 0)";
+ parameterMarshalType = $"MarshalUsing(typeof(FlaxEngine.Interop.DictionaryMarshaller<,>), ConstantElementCount = 0)";
else if (nativeType == "bool")
parameterMarshalType = "MarshalAs(UnmanagedType.U1)";
else if (nativeType == "char")
@@ -597,12 +597,12 @@ namespace Flax.Build.Bindings
if (parameterInfo.IsOut && parameterInfo.DefaultValue == "var __resultAsRef")
{
if (parameterInfo.Type.Type == "Array" || parameterInfo.Type.Type == "Span" || parameterInfo.Type.Type == "DataContainer" || parameterInfo.Type.Type == "BytesContainer")
- parameterMarshalType = $"MarshalUsing(typeof(FlaxEngine.ArrayMarshaller<,>), CountElementName = \"{parameterInfo.Name}Count\")";
+ parameterMarshalType = $"MarshalUsing(typeof(FlaxEngine.Interop.ArrayMarshaller<,>), CountElementName = \"{parameterInfo.Name}Count\")";
else if (parameterInfo.Type.Type == "Dictionary")
- parameterMarshalType = $"MarshalUsing(typeof(FlaxEngine.DictionaryMarshaller<,>), ConstantElementCount = 0)";
+ parameterMarshalType = $"MarshalUsing(typeof(FlaxEngine.Interop.DictionaryMarshaller<,>), ConstantElementCount = 0)";
}
if (nativeType == "System.Type")
- parameterMarshalType = "MarshalUsing(typeof(FlaxEngine.SystemTypeMarshaller))";
+ parameterMarshalType = "MarshalUsing(typeof(FlaxEngine.Interop.SystemTypeMarshaller))";
if (!string.IsNullOrEmpty(parameterMarshalType))
contents.Append($"[{parameterMarshalType}] ");
@@ -1017,7 +1017,7 @@ namespace Flax.Build.Bindings
libraryEntryPoint = $"{classInfo.FullNameManaged}::Internal_{eventInfo.Name}_Bind"; // MSVC allows to override exported symbol name
else
libraryEntryPoint = CppNameMangling.MangleFunctionName(buildData, eventInfo.Name + "_ManagedBind", classInfo.FullNameNativeInternal + "Internal", CSharpEventBindReturn, eventInfo.IsStatic ? null : new TypeInfo(classInfo.FullNameNative) { IsPtr = true }, CSharpEventBindParams);
- contents.Append(indent).Append($"[LibraryImport(\"{classInfo.ParentModule.Module.BinaryModuleName}\", EntryPoint = \"{libraryEntryPoint}\", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.StringMarshaller))]").AppendLine();
+ contents.Append(indent).Append($"[LibraryImport(\"{classInfo.ParentModule.Module.BinaryModuleName}\", EntryPoint = \"{libraryEntryPoint}\", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.Interop.StringMarshaller))]").AppendLine();
contents.Append(indent).Append($"internal static partial void Internal_{eventInfo.Name}_Bind(");
if (!eventInfo.IsStatic)
contents.Append("IntPtr obj, ");
@@ -2028,6 +2028,7 @@ namespace Flax.Build.Bindings
CSharpUsedNamespaces.Add("System.Runtime.InteropServices.Marshalling");
#endif
CSharpUsedNamespaces.Add("FlaxEngine");
+ CSharpUsedNamespaces.Add("FlaxEngine.Interop");
// Process all API types from the file
var useBindings = false;