Move dotnet7 native interop, wrappers and marshalers into FlaxEngine.Interop namespace

This commit is contained in:
Wojtek Figat
2023-03-28 13:20:18 +02:00
parent 6f7b138488
commit a25eae5d10
19 changed files with 291 additions and 191 deletions

View File

@@ -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
{

View File

@@ -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
{

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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
/// <summary>
/// Gets a value indicating whether this Editor is running a dev instance of the engine.
/// </summary>
[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();
/// <summary>
/// Gets a value indicating whether this Editor is running as official build (distributed via Flax services).
/// </summary>
[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

View File

@@ -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")]

View File

@@ -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);
}
}

View File

@@ -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()

View File

@@ -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<TInstance>
{
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<TInstance, T1>
{
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<T1>.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
if (param1Ptr != IntPtr.Zero)
MarshalHelper<T1>.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<T1>.ToNative(ref param1, param1Ptr);
if (param1Ptr != IntPtr.Zero && types[0].IsByRef)
MarshalHelper<T1>.ToNative(ref param1, param1Ptr);
return IntPtr.Zero;
}
@@ -271,6 +275,7 @@ namespace FlaxEngine
internal static class InvokerNoRet2<TInstance, T1, T2>
{
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<T1>.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
if (param2Ptr != IntPtr.Zero) MarshalHelper<T2>.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
if (param1Ptr != IntPtr.Zero)
MarshalHelper<T1>.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
if (param2Ptr != IntPtr.Zero)
MarshalHelper<T2>.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<T1>.ToNative(ref param1, param1Ptr);
if (param2Ptr != IntPtr.Zero && types[1].IsByRef) MarshalHelper<T2>.ToNative(ref param2, param2Ptr);
if (param1Ptr != IntPtr.Zero && types[0].IsByRef)
MarshalHelper<T1>.ToNative(ref param1, param1Ptr);
if (param2Ptr != IntPtr.Zero && types[1].IsByRef)
MarshalHelper<T2>.ToNative(ref param2, param2Ptr);
return IntPtr.Zero;
}
@@ -322,6 +331,7 @@ namespace FlaxEngine
internal static class InvokerNoRet3<TInstance, T1, T2, T3>
{
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<T1>.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
if (param2Ptr != IntPtr.Zero) MarshalHelper<T2>.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
if (param3Ptr != IntPtr.Zero) MarshalHelper<T3>.ToManaged(ref param3, param3Ptr, types[2].IsByRef);
if (param1Ptr != IntPtr.Zero)
MarshalHelper<T1>.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
if (param2Ptr != IntPtr.Zero)
MarshalHelper<T2>.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
if (param3Ptr != IntPtr.Zero)
MarshalHelper<T3>.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<T1>.ToNative(ref param1, param1Ptr);
if (param2Ptr != IntPtr.Zero && types[1].IsByRef) MarshalHelper<T2>.ToNative(ref param2, param2Ptr);
if (param3Ptr != IntPtr.Zero && types[2].IsByRef) MarshalHelper<T3>.ToNative(ref param3, param3Ptr);
if (param1Ptr != IntPtr.Zero && types[0].IsByRef)
MarshalHelper<T1>.ToNative(ref param1, param1Ptr);
if (param2Ptr != IntPtr.Zero && types[1].IsByRef)
MarshalHelper<T2>.ToNative(ref param2, param2Ptr);
if (param3Ptr != IntPtr.Zero && types[2].IsByRef)
MarshalHelper<T3>.ToNative(ref param3, param3Ptr);
return IntPtr.Zero;
}
@@ -378,6 +394,7 @@ namespace FlaxEngine
internal static class InvokerNoRet4<TInstance, T1, T2, T3, T4>
{
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<T1>.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
if (param2Ptr != IntPtr.Zero) MarshalHelper<T2>.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
if (param3Ptr != IntPtr.Zero) MarshalHelper<T3>.ToManaged(ref param3, param3Ptr, types[2].IsByRef);
if (param4Ptr != IntPtr.Zero) MarshalHelper<T4>.ToManaged(ref param4, param4Ptr, types[3].IsByRef);
if (param1Ptr != IntPtr.Zero)
MarshalHelper<T1>.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
if (param2Ptr != IntPtr.Zero)
MarshalHelper<T2>.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
if (param3Ptr != IntPtr.Zero)
MarshalHelper<T3>.ToManaged(ref param3, param3Ptr, types[2].IsByRef);
if (param4Ptr != IntPtr.Zero)
MarshalHelper<T4>.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<T1>.ToNative(ref param1, param1Ptr);
if (param2Ptr != IntPtr.Zero && types[1].IsByRef) MarshalHelper<T2>.ToNative(ref param2, param2Ptr);
if (param3Ptr != IntPtr.Zero && types[2].IsByRef) MarshalHelper<T3>.ToNative(ref param3, param3Ptr);
if (param4Ptr != IntPtr.Zero && types[3].IsByRef) MarshalHelper<T4>.ToNative(ref param4, param4Ptr);
if (param1Ptr != IntPtr.Zero && types[0].IsByRef)
MarshalHelper<T1>.ToNative(ref param1, param1Ptr);
if (param2Ptr != IntPtr.Zero && types[1].IsByRef)
MarshalHelper<T2>.ToNative(ref param2, param2Ptr);
if (param3Ptr != IntPtr.Zero && types[2].IsByRef)
MarshalHelper<T3>.ToNative(ref param3, param3Ptr);
if (param4Ptr != IntPtr.Zero && types[3].IsByRef)
MarshalHelper<T4>.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<T1>
{
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<T1>.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
if (param1Ptr != IntPtr.Zero)
MarshalHelper<T1>.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<T1>.ToNative(ref param1, param1Ptr);
if (param1Ptr != IntPtr.Zero && types[0].IsByRef)
MarshalHelper<T1>.ToNative(ref param1, param1Ptr);
return IntPtr.Zero;
}
@@ -521,6 +550,7 @@ namespace FlaxEngine
internal static class InvokerStaticNoRet2<T1, T2>
{
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<T1>.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
if (param2Ptr != IntPtr.Zero) MarshalHelper<T2>.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
if (param1Ptr != IntPtr.Zero)
MarshalHelper<T1>.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
if (param2Ptr != IntPtr.Zero)
MarshalHelper<T2>.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<T1>.ToNative(ref param1, param1Ptr);
if (param2Ptr != IntPtr.Zero && types[1].IsByRef) MarshalHelper<T2>.ToNative(ref param2, param2Ptr);
if (param1Ptr != IntPtr.Zero && types[0].IsByRef)
MarshalHelper<T1>.ToNative(ref param1, param1Ptr);
if (param2Ptr != IntPtr.Zero && types[1].IsByRef)
MarshalHelper<T2>.ToNative(ref param2, param2Ptr);
return IntPtr.Zero;
}
@@ -572,6 +606,7 @@ namespace FlaxEngine
internal static class InvokerStaticNoRet3<T1, T2, T3>
{
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<T1>.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
if (param2Ptr != IntPtr.Zero) MarshalHelper<T2>.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
if (param3Ptr != IntPtr.Zero) MarshalHelper<T3>.ToManaged(ref param3, param3Ptr, types[2].IsByRef);
if (param1Ptr != IntPtr.Zero)
MarshalHelper<T1>.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
if (param2Ptr != IntPtr.Zero)
MarshalHelper<T2>.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
if (param3Ptr != IntPtr.Zero)
MarshalHelper<T3>.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<T1>.ToNative(ref param1, param1Ptr);
if (param2Ptr != IntPtr.Zero && types[1].IsByRef) MarshalHelper<T2>.ToNative(ref param2, param2Ptr);
if (param3Ptr != IntPtr.Zero && types[2].IsByRef) MarshalHelper<T3>.ToNative(ref param3, param3Ptr);
if (param1Ptr != IntPtr.Zero && types[0].IsByRef)
MarshalHelper<T1>.ToNative(ref param1, param1Ptr);
if (param2Ptr != IntPtr.Zero && types[1].IsByRef)
MarshalHelper<T2>.ToNative(ref param2, param2Ptr);
if (param3Ptr != IntPtr.Zero && types[2].IsByRef)
MarshalHelper<T3>.ToNative(ref param3, param3Ptr);
return IntPtr.Zero;
}
@@ -628,6 +669,7 @@ namespace FlaxEngine
internal static class InvokerStaticNoRet4<T1, T2, T3, T4>
{
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<T1>.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
if (param2Ptr != IntPtr.Zero) MarshalHelper<T2>.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
if (param3Ptr != IntPtr.Zero) MarshalHelper<T3>.ToManaged(ref param3, param3Ptr, types[2].IsByRef);
if (param4Ptr != IntPtr.Zero) MarshalHelper<T4>.ToManaged(ref param4, param4Ptr, types[3].IsByRef);
if (param1Ptr != IntPtr.Zero)
MarshalHelper<T1>.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
if (param2Ptr != IntPtr.Zero)
MarshalHelper<T2>.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
if (param3Ptr != IntPtr.Zero)
MarshalHelper<T3>.ToManaged(ref param3, param3Ptr, types[2].IsByRef);
if (param4Ptr != IntPtr.Zero)
MarshalHelper<T4>.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<T1>.ToNative(ref param1, param1Ptr);
if (param2Ptr != IntPtr.Zero && types[1].IsByRef) MarshalHelper<T2>.ToNative(ref param2, param2Ptr);
if (param3Ptr != IntPtr.Zero && types[2].IsByRef) MarshalHelper<T3>.ToNative(ref param3, param3Ptr);
if (param4Ptr != IntPtr.Zero && types[3].IsByRef) MarshalHelper<T4>.ToNative(ref param4, param4Ptr);
if (param1Ptr != IntPtr.Zero && types[0].IsByRef)
MarshalHelper<T1>.ToNative(ref param1, param1Ptr);
if (param2Ptr != IntPtr.Zero && types[1].IsByRef)
MarshalHelper<T2>.ToNative(ref param2, param2Ptr);
if (param3Ptr != IntPtr.Zero && types[2].IsByRef)
MarshalHelper<T3>.ToNative(ref param3, param3Ptr);
if (param4Ptr != IntPtr.Zero && types[3].IsByRef)
MarshalHelper<T4>.ToNative(ref param4, param4Ptr);
return IntPtr.Zero;
}
@@ -689,6 +739,7 @@ namespace FlaxEngine
internal static class InvokerRet0<TInstance, TRet>
{
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<TInstance, TRet, T1>
{
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<T1>.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
if (param1Ptr != IntPtr.Zero)
MarshalHelper<T1>.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<T1>.ToNative(ref param1, param1Ptr);
if (param1Ptr != IntPtr.Zero && types[0].IsByRef)
MarshalHelper<T1>.ToNative(ref param1, param1Ptr);
return MarshalReturnValue(ref ret);
}
@@ -771,6 +825,7 @@ namespace FlaxEngine
internal static class InvokerRet2<TInstance, TRet, T1, T2>
{
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<T1>.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
if (param2Ptr != IntPtr.Zero) MarshalHelper<T2>.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
if (param1Ptr != IntPtr.Zero)
MarshalHelper<T1>.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
if (param2Ptr != IntPtr.Zero)
MarshalHelper<T2>.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<T1>.ToNative(ref param1, param1Ptr);
if (param2Ptr != IntPtr.Zero && types[1].IsByRef) MarshalHelper<T2>.ToNative(ref param2, param2Ptr);
if (param1Ptr != IntPtr.Zero && types[0].IsByRef)
MarshalHelper<T1>.ToNative(ref param1, param1Ptr);
if (param2Ptr != IntPtr.Zero && types[1].IsByRef)
MarshalHelper<T2>.ToNative(ref param2, param2Ptr);
return MarshalReturnValue(ref ret);
}
@@ -822,6 +881,7 @@ namespace FlaxEngine
internal static class InvokerRet3<TInstance, TRet, T1, T2, T3>
{
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<T1>.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
if (param2Ptr != IntPtr.Zero) MarshalHelper<T2>.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
if (param3Ptr != IntPtr.Zero) MarshalHelper<T3>.ToManaged(ref param3, param3Ptr, types[2].IsByRef);
if (param1Ptr != IntPtr.Zero)
MarshalHelper<T1>.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
if (param2Ptr != IntPtr.Zero)
MarshalHelper<T2>.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
if (param3Ptr != IntPtr.Zero)
MarshalHelper<T3>.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<T1>.ToNative(ref param1, param1Ptr);
if (param2Ptr != IntPtr.Zero && types[1].IsByRef) MarshalHelper<T2>.ToNative(ref param2, param2Ptr);
if (param3Ptr != IntPtr.Zero && types[2].IsByRef) MarshalHelper<T3>.ToNative(ref param3, param3Ptr);
if (param1Ptr != IntPtr.Zero && types[0].IsByRef)
MarshalHelper<T1>.ToNative(ref param1, param1Ptr);
if (param2Ptr != IntPtr.Zero && types[1].IsByRef)
MarshalHelper<T2>.ToNative(ref param2, param2Ptr);
if (param3Ptr != IntPtr.Zero && types[2].IsByRef)
MarshalHelper<T3>.ToNative(ref param3, param3Ptr);
return MarshalReturnValue(ref ret);
}
@@ -878,6 +944,7 @@ namespace FlaxEngine
internal static class InvokerRet4<TInstance, TRet, T1, T2, T3, T4>
{
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<T1>.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
if (param2Ptr != IntPtr.Zero) MarshalHelper<T2>.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
if (param3Ptr != IntPtr.Zero) MarshalHelper<T3>.ToManaged(ref param3, param3Ptr, types[2].IsByRef);
if (param4Ptr != IntPtr.Zero) MarshalHelper<T4>.ToManaged(ref param4, param4Ptr, types[3].IsByRef);
if (param1Ptr != IntPtr.Zero)
MarshalHelper<T1>.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
if (param2Ptr != IntPtr.Zero)
MarshalHelper<T2>.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
if (param3Ptr != IntPtr.Zero)
MarshalHelper<T3>.ToManaged(ref param3, param3Ptr, types[2].IsByRef);
if (param4Ptr != IntPtr.Zero)
MarshalHelper<T4>.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<T1>.ToNative(ref param1, param1Ptr);
if (param2Ptr != IntPtr.Zero && types[1].IsByRef) MarshalHelper<T2>.ToNative(ref param2, param2Ptr);
if (param3Ptr != IntPtr.Zero && types[2].IsByRef) MarshalHelper<T3>.ToNative(ref param3, param3Ptr);
if (param4Ptr != IntPtr.Zero && types[3].IsByRef) MarshalHelper<T4>.ToNative(ref param4, param4Ptr);
if (param1Ptr != IntPtr.Zero && types[0].IsByRef)
MarshalHelper<T1>.ToNative(ref param1, param1Ptr);
if (param2Ptr != IntPtr.Zero && types[1].IsByRef)
MarshalHelper<T2>.ToNative(ref param2, param2Ptr);
if (param3Ptr != IntPtr.Zero && types[2].IsByRef)
MarshalHelper<T3>.ToNative(ref param3, param3Ptr);
if (param4Ptr != IntPtr.Zero && types[3].IsByRef)
MarshalHelper<T4>.ToNative(ref param4, param4Ptr);
return MarshalReturnValue(ref ret);
}
@@ -939,6 +1014,7 @@ namespace FlaxEngine
internal static class InvokerStaticRet0<TRet>
{
internal delegate TRet InvokerDelegate();
internal delegate TRet ThunkInvokerDelegate();
internal static object CreateDelegate(MethodInfo method)
@@ -975,6 +1051,7 @@ namespace FlaxEngine
internal static class InvokerStaticRet1<TRet, T1>
{
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<T1>.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
if (param1Ptr != IntPtr.Zero)
MarshalHelper<T1>.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<T1>.ToNative(ref param1, param1Ptr);
if (param1Ptr != IntPtr.Zero && types[0].IsByRef)
MarshalHelper<T1>.ToNative(ref param1, param1Ptr);
return MarshalReturnValue(ref ret);
}
@@ -1021,6 +1100,7 @@ namespace FlaxEngine
internal static class InvokerStaticRet2<TRet, T1, T2>
{
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<T1>.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
if (param2Ptr != IntPtr.Zero) MarshalHelper<T2>.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
if (param1Ptr != IntPtr.Zero)
MarshalHelper<T1>.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
if (param2Ptr != IntPtr.Zero)
MarshalHelper<T2>.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<T1>.ToNative(ref param1, param1Ptr);
if (param2Ptr != IntPtr.Zero && types[1].IsByRef) MarshalHelper<T2>.ToNative(ref param2, param2Ptr);
if (param1Ptr != IntPtr.Zero && types[0].IsByRef)
MarshalHelper<T1>.ToNative(ref param1, param1Ptr);
if (param2Ptr != IntPtr.Zero && types[1].IsByRef)
MarshalHelper<T2>.ToNative(ref param2, param2Ptr);
return MarshalReturnValue(ref ret);
}
@@ -1072,6 +1156,7 @@ namespace FlaxEngine
internal static class InvokerStaticRet3<TRet, T1, T2, T3>
{
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<T1>.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
if (param2Ptr != IntPtr.Zero) MarshalHelper<T2>.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
if (param3Ptr != IntPtr.Zero) MarshalHelper<T3>.ToManaged(ref param3, param3Ptr, types[2].IsByRef);
if (param1Ptr != IntPtr.Zero)
MarshalHelper<T1>.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
if (param2Ptr != IntPtr.Zero)
MarshalHelper<T2>.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
if (param3Ptr != IntPtr.Zero)
MarshalHelper<T3>.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<T1>.ToNative(ref param1, param1Ptr);
if (param2Ptr != IntPtr.Zero && types[1].IsByRef) MarshalHelper<T2>.ToNative(ref param2, param2Ptr);
if (param3Ptr != IntPtr.Zero && types[2].IsByRef) MarshalHelper<T3>.ToNative(ref param3, param3Ptr);
if (param1Ptr != IntPtr.Zero && types[0].IsByRef)
MarshalHelper<T1>.ToNative(ref param1, param1Ptr);
if (param2Ptr != IntPtr.Zero && types[1].IsByRef)
MarshalHelper<T2>.ToNative(ref param2, param2Ptr);
if (param3Ptr != IntPtr.Zero && types[2].IsByRef)
MarshalHelper<T3>.ToNative(ref param3, param3Ptr);
return MarshalReturnValue(ref ret);
}
@@ -1128,6 +1219,7 @@ namespace FlaxEngine
internal static class InvokerStaticRet4<TRet, T1, T2, T3, T4>
{
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<T1>.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
if (param2Ptr != IntPtr.Zero) MarshalHelper<T2>.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
if (param3Ptr != IntPtr.Zero) MarshalHelper<T3>.ToManaged(ref param3, param3Ptr, types[2].IsByRef);
if (param4Ptr != IntPtr.Zero) MarshalHelper<T4>.ToManaged(ref param4, param4Ptr, types[3].IsByRef);
if (param1Ptr != IntPtr.Zero)
MarshalHelper<T1>.ToManaged(ref param1, param1Ptr, types[0].IsByRef);
if (param2Ptr != IntPtr.Zero)
MarshalHelper<T2>.ToManaged(ref param2, param2Ptr, types[1].IsByRef);
if (param3Ptr != IntPtr.Zero)
MarshalHelper<T3>.ToManaged(ref param3, param3Ptr, types[2].IsByRef);
if (param4Ptr != IntPtr.Zero)
MarshalHelper<T4>.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<T1>.ToNative(ref param1, param1Ptr);
if (param2Ptr != IntPtr.Zero && types[1].IsByRef) MarshalHelper<T2>.ToNative(ref param2, param2Ptr);
if (param3Ptr != IntPtr.Zero && types[2].IsByRef) MarshalHelper<T3>.ToNative(ref param3, param3Ptr);
if (param4Ptr != IntPtr.Zero && types[3].IsByRef) MarshalHelper<T4>.ToNative(ref param4, param4Ptr);
if (param1Ptr != IntPtr.Zero && types[0].IsByRef)
MarshalHelper<T1>.ToNative(ref param1, param1Ptr);
if (param2Ptr != IntPtr.Zero && types[1].IsByRef)
MarshalHelper<T2>.ToNative(ref param2, param2Ptr);
if (param3Ptr != IntPtr.Zero && types[2].IsByRef)
MarshalHelper<T3>.ToNative(ref param3, param3Ptr);
if (param4Ptr != IntPtr.Zero && types[3].IsByRef)
MarshalHelper<T4>.ToNative(ref param4, param4Ptr);
return MarshalReturnValue(ref ret);
}

View File

@@ -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
{
/// <summary>
/// Wrapper for managed arrays which are passed to unmanaged code.

View File

@@ -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))]

View File

@@ -13,7 +13,7 @@ using FlaxEngine.Utilities;
#pragma warning disable 1591
namespace FlaxEngine
namespace FlaxEngine.Interop
{
[StructLayout(LayoutKind.Sequential)]
internal struct NativeClassDefinitions

View File

@@ -15,7 +15,7 @@ using FlaxEngine.Assertions;
using System.Collections.Concurrent;
using System.Text;
namespace FlaxEngine
namespace FlaxEngine.Interop
{
/// <summary>
/// Provides a Mono-like API for native code to access managed runtime.

View File

@@ -15,7 +15,7 @@ namespace FlaxEngine
/// Base class for all objects Flax can reference. Every object has unique identifier.
/// </summary>
[Serializable]
[NativeMarshalling(typeof(ObjectMarshaller))]
[NativeMarshalling(typeof(Interop.ObjectMarshaller))]
public abstract partial class Object
{
/// <summary>
@@ -240,7 +240,7 @@ namespace FlaxEngine
/// </summary>
/// <param name="ptr">The pointer to the unmanaged (native) object.</param>
/// <returns>The object.</returns>
[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);
/// <inheritdoc />
@@ -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
}

View File

@@ -156,7 +156,7 @@ extern MDomain* MActiveDomain;
extern Array<MDomain*, FixedAllocation<4>> MDomains;
Dictionary<String, void*> 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<void*, MClass*> classHandles;
Dictionary<void*, MAssembly*> assemblyHandles;

View File

@@ -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.
/// </summary>
/// <returns>True if game scripts assembly is loaded, otherwise false.</returns>
[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.
/// </summary>
/// <returns>True if the type is from game assembly, otherwise false.</returns>
[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);
/// <summary>
/// Flushes the removed objects (disposed objects using Object.Destroy).
/// </summary>
[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.
/// </summary>
/// <param name="name">The name of the event.</param>
[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);
/// <summary>
/// Ends profiling an event.
/// </summary>
[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();
/// <summary>
/// Begins GPU profiling a piece of code with a custom label.
/// </summary>
/// <param name="name">The name of the event.</param>
[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);
/// <summary>
/// Ends GPU profiling an event.
/// </summary>
[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();
}
}

View File

@@ -12,13 +12,13 @@ namespace FlaxEngine.Tests
public class TestScripting
{
/// <summary>
/// Tests all <see cref="LibraryImportAttribute"/> usages in the engine to verify all bindigns are correct to work with P/Invoke.
/// Tests all <see cref="LibraryImportAttribute"/> usages in the engine to verify all bindings are correct to work with P/Invoke.
/// </summary>
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();

View File

@@ -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

View File

@@ -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;