summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgnacio Roldán Etcheverry <ignalfonsore@gmail.com>2022-08-05 03:32:59 +0200
committerIgnacio Roldán Etcheverry <ignalfonsore@gmail.com>2022-08-22 03:36:52 +0200
commit2c180f62d985194060f1a8d2070c130081177c90 (patch)
treeba2e1bed3d3c3138d9ed39b315786cb6e22a3ee5
parent186d7f6239144351ed9f60915796a7a224f4dfbf (diff)
C#: Replace P/Invoke with delegate pointers
- Moves interop functions to UnmanagedCallbacks struct that contains the function pointers and is passed to C#. - Implements UnmanagedCallbacksGenerator, a C# source generator that generates the UnmanagedCallbacks struct in C# and the body for the NativeFuncs methods (their implementation just calls the function pointer in the UnmanagedCallbacks). The generated methods are needed because .NET pins byref parameters of native calls, even if they are 'ref struct's, which don't need pinning. The generated methods use `Unsafe.AsPointer` so that we can benefit from byref parameters without suffering overhead of pinning. Co-authored-by: Raul Santos <raulsntos@gmail.com>
-rw-r--r--modules/mono/csharp_script.cpp19
-rw-r--r--modules/mono/editor/GodotTools/GodotTools.sln6
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs3
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj1
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs119
-rw-r--r--modules/mono/editor/editor_internal_calls.cpp79
-rw-r--r--modules/mono/editor/editor_internal_calls.h6
-rw-r--r--modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/CallbacksInfo.cs24
-rw-r--r--modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/Common.cs65
-rw-r--r--modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/ExtensionMethods.cs119
-rw-r--r--modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/GeneratorClasses.cs6
-rw-r--r--modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/Godot.SourceGenerators.Internal.csproj11
-rw-r--r--modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/UnmanagedCallbacksGenerator.cs463
-rw-r--r--modules/mono/glue/GodotSharp/GodotPlugins/Main.cs13
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp.sln6
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.cs599
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj3
-rw-r--r--modules/mono/glue/runtime_interop.cpp450
-rw-r--r--modules/mono/glue/runtime_interop.h40
-rw-r--r--modules/mono/mono_gd/gd_mono.cpp16
-rw-r--r--modules/mono/mono_gd/gd_mono.h2
21 files changed, 1312 insertions, 738 deletions
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp
index 5364f8ff79..8b135051c5 100644
--- a/modules/mono/csharp_script.cpp
+++ b/modules/mono/csharp_script.cpp
@@ -95,13 +95,6 @@ Error CSharpLanguage::execute_file(const String &p_path) {
return OK;
}
-extern void *godotsharp_pinvoke_funcs[186];
-[[maybe_unused]] volatile void **do_not_strip_godotsharp_pinvoke_funcs;
-#ifdef TOOLS_ENABLED
-extern void *godotsharp_editor_pinvoke_funcs[28];
-[[maybe_unused]] volatile void **do_not_strip_godotsharp_editor_pinvoke_funcs;
-#endif
-
void CSharpLanguage::init() {
#ifdef DEBUG_METHODS_ENABLED
if (OS::get_singleton()->get_cmdline_args().find("--class-db-json")) {
@@ -112,12 +105,6 @@ void CSharpLanguage::init() {
}
#endif
- // Hopefully this will be enough for all compilers. Otherwise we could use the printf on fake getenv trick.
- do_not_strip_godotsharp_pinvoke_funcs = (volatile void **)godotsharp_pinvoke_funcs;
-#ifdef TOOLS_ENABLED
- do_not_strip_godotsharp_editor_pinvoke_funcs = (volatile void **)godotsharp_editor_pinvoke_funcs;
-#endif
-
#if defined(TOOLS_ENABLED) && defined(DEBUG_METHODS_ENABLED)
// Generate the bindings here, before loading assemblies. The Godot assemblies
// may be missing if the glue wasn't generated yet in order to build them.
@@ -1094,8 +1081,12 @@ void CSharpLanguage::_on_scripts_domain_about_to_unload() {
void CSharpLanguage::_editor_init_callback() {
// Load GodotTools and initialize GodotSharpEditor
+ int32_t interop_funcs_size = 0;
+ const void **interop_funcs = godotsharp::get_editor_interop_funcs(interop_funcs_size);
+
Object *editor_plugin_obj = GDMono::get_singleton()->get_plugin_callbacks().LoadToolsAssemblyCallback(
- GodotSharpDirs::get_data_editor_tools_dir().plus_file("GodotTools.dll").utf16());
+ GodotSharpDirs::get_data_editor_tools_dir().plus_file("GodotTools.dll").utf16(),
+ interop_funcs, interop_funcs_size);
CRASH_COND(editor_plugin_obj == nullptr);
EditorPlugin *godotsharp_editor = Object::cast_to<EditorPlugin>(editor_plugin_obj);
diff --git a/modules/mono/editor/GodotTools/GodotTools.sln b/modules/mono/editor/GodotTools/GodotTools.sln
index f3d2f90f39..564775635d 100644
--- a/modules/mono/editor/GodotTools/GodotTools.sln
+++ b/modules/mono/editor/GodotTools/GodotTools.sln
@@ -17,6 +17,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GodotTools.Shared", "GodotT
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Godot.SourceGenerators", "..\Godot.NET.Sdk\Godot.SourceGenerators\Godot.SourceGenerators.csproj", "{D8C421B2-8911-41EB-B983-F675C7141EB7}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Godot.SourceGenerators.Internal", "..\..\glue\GodotSharp\Godot.SourceGenerators.Internal\Godot.SourceGenerators.Internal.csproj", "{55666071-BEC1-4A52-8A98-9A4A7A947DBF}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -55,5 +57,9 @@ Global
{D8C421B2-8911-41EB-B983-F675C7141EB7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D8C421B2-8911-41EB-B983-F675C7141EB7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D8C421B2-8911-41EB-B983-F675C7141EB7}.Release|Any CPU.Build.0 = Release|Any CPU
+ {55666071-BEC1-4A52-8A98-9A4A7A947DBF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {55666071-BEC1-4A52-8A98-9A4A7A947DBF}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {55666071-BEC1-4A52-8A98-9A4A7A947DBF}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {55666071-BEC1-4A52-8A98-9A4A7A947DBF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
diff --git a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs
index 45a29d89de..0aca60dad4 100644
--- a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs
@@ -547,8 +547,9 @@ namespace GodotTools
public static GodotSharpEditor Instance { get; private set; }
[UsedImplicitly]
- private static IntPtr InternalCreateInstance()
+ private static IntPtr InternalCreateInstance(IntPtr unmanagedCallbacks, int unmanagedCallbacksSize)
{
+ Internal.Initialize(unmanagedCallbacks, unmanagedCallbacksSize);
return new GodotSharpEditor().NativeInstance;
}
}
diff --git a/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj b/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj
index f5734e6e69..30525ba04a 100644
--- a/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj
+++ b/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj
@@ -43,6 +43,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Godot.NET.Sdk\Godot.SourceGenerators\Godot.SourceGenerators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
+ <ProjectReference Include="..\..\..\glue\GodotSharp\Godot.SourceGenerators.Internal\Godot.SourceGenerators.Internal.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\GodotTools.BuildLogger\GodotTools.BuildLogger.csproj" />
diff --git a/modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs b/modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs
index f0d2bed246..e3fe1622d0 100644
--- a/modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs
@@ -1,12 +1,16 @@
using System;
-using System.Runtime.InteropServices;
+using System.Diagnostics.CodeAnalysis;
+using System.Runtime.CompilerServices;
using Godot;
using Godot.NativeInterop;
+using Godot.SourceGenerators.Internal;
using GodotTools.IdeMessaging.Requests;
namespace GodotTools.Internals
{
- internal static class Internal
+ [SuppressMessage("ReSharper", "InconsistentNaming")]
+ [GenerateUnmanagedCallbacks(typeof(InternalUnmanagedCallbacks))]
+ internal static partial class Internal
{
public const string CSharpLanguageType = "CSharpScript";
public const string CSharpLanguageExtension = ".cs";
@@ -64,97 +68,94 @@ namespace GodotTools.Internals
#region Internal
- private const string GodotDllName = "__Internal";
+ private static bool initialized = false;
- [DllImport(GodotDllName)]
- public static extern void godot_icall_GodotSharpDirs_ResMetadataDir(out godot_string r_dest);
+ // ReSharper disable once ParameterOnlyUsedForPreconditionCheck.Global
+ internal static unsafe void Initialize(IntPtr unmanagedCallbacks, int unmanagedCallbacksSize)
+ {
+ if (initialized)
+ throw new InvalidOperationException("Already initialized");
+ initialized = true;
+
+ if (unmanagedCallbacksSize != sizeof(InternalUnmanagedCallbacks))
+ throw new ArgumentException("Unmanaged callbacks size mismatch");
+
+ _unmanagedCallbacks = Unsafe.AsRef<InternalUnmanagedCallbacks>((void*)unmanagedCallbacks);
+ }
+
+ private partial struct InternalUnmanagedCallbacks
+ {
+ }
+
+ /*
+ * IMPORTANT:
+ * The order of the methods defined in NativeFuncs must match the order
+ * in the array defined at the bottom of 'editor/editor_internal_calls.cpp'.
+ */
+
+ public static partial void godot_icall_GodotSharpDirs_ResMetadataDir(out godot_string r_dest);
- [DllImport(GodotDllName)]
- public static extern void godot_icall_GodotSharpDirs_MonoUserDir(out godot_string r_dest);
+ public static partial void godot_icall_GodotSharpDirs_MonoUserDir(out godot_string r_dest);
- [DllImport(GodotDllName)]
- public static extern void godot_icall_GodotSharpDirs_BuildLogsDirs(out godot_string r_dest);
+ public static partial void godot_icall_GodotSharpDirs_BuildLogsDirs(out godot_string r_dest);
- [DllImport(GodotDllName)]
- public static extern void godot_icall_GodotSharpDirs_DataEditorToolsDir(out godot_string r_dest);
+ public static partial void godot_icall_GodotSharpDirs_DataEditorToolsDir(out godot_string r_dest);
- [DllImport(GodotDllName)]
- public static extern void godot_icall_EditorProgress_Create(in godot_string task, in godot_string label,
+ public static partial void godot_icall_EditorProgress_Create(in godot_string task, in godot_string label,
int amount, bool canCancel);
- [DllImport(GodotDllName)]
- public static extern void godot_icall_EditorProgress_Dispose(in godot_string task);
+ public static partial void godot_icall_EditorProgress_Dispose(in godot_string task);
- [DllImport(GodotDllName)]
- public static extern bool godot_icall_EditorProgress_Step(in godot_string task, in godot_string state, int step,
+ public static partial bool godot_icall_EditorProgress_Step(in godot_string task, in godot_string state,
+ int step,
bool forceRefresh);
- [DllImport(GodotDllName)]
- private static extern void godot_icall_Internal_FullExportTemplatesDir(out godot_string dest);
+ private static partial void godot_icall_Internal_FullExportTemplatesDir(out godot_string dest);
- [DllImport(GodotDllName)]
- private static extern bool godot_icall_Internal_IsMacOSAppBundleInstalled(in godot_string bundleId);
+ private static partial bool godot_icall_Internal_IsMacOSAppBundleInstalled(in godot_string bundleId);
- [DllImport(GodotDllName)]
- private static extern bool godot_icall_Internal_GodotIs32Bits();
+ private static partial bool godot_icall_Internal_GodotIs32Bits();
- [DllImport(GodotDllName)]
- private static extern bool godot_icall_Internal_GodotIsRealTDouble();
+ private static partial bool godot_icall_Internal_GodotIsRealTDouble();
- [DllImport(GodotDllName)]
- private static extern void godot_icall_Internal_GodotMainIteration();
+ private static partial void godot_icall_Internal_GodotMainIteration();
- [DllImport(GodotDllName)]
- private static extern bool godot_icall_Internal_IsAssembliesReloadingNeeded();
+ private static partial bool godot_icall_Internal_IsAssembliesReloadingNeeded();
- [DllImport(GodotDllName)]
- private static extern void godot_icall_Internal_ReloadAssemblies(bool softReload);
+ private static partial void godot_icall_Internal_ReloadAssemblies(bool softReload);
- [DllImport(GodotDllName)]
- private static extern void godot_icall_Internal_EditorDebuggerNodeReloadScripts();
+ private static partial void godot_icall_Internal_EditorDebuggerNodeReloadScripts();
- [DllImport(GodotDllName)]
- private static extern bool godot_icall_Internal_ScriptEditorEdit(IntPtr resource, int line, int col,
+ private static partial bool godot_icall_Internal_ScriptEditorEdit(IntPtr resource, int line, int col,
bool grabFocus);
- [DllImport(GodotDllName)]
- private static extern void godot_icall_Internal_EditorNodeShowScriptScreen();
+ private static partial void godot_icall_Internal_EditorNodeShowScriptScreen();
- [DllImport(GodotDllName)]
- private static extern void godot_icall_Internal_EditorRunPlay();
+ private static partial void godot_icall_Internal_EditorRunPlay();
- [DllImport(GodotDllName)]
- private static extern void godot_icall_Internal_EditorRunStop();
+ private static partial void godot_icall_Internal_EditorRunStop();
- [DllImport(GodotDllName)]
- private static extern void godot_icall_Internal_ScriptEditorDebugger_ReloadScripts();
+ private static partial void godot_icall_Internal_ScriptEditorDebugger_ReloadScripts();
- [DllImport(GodotDllName)]
- private static extern void godot_icall_Internal_CodeCompletionRequest(int kind, in godot_string scriptFile,
+ private static partial void godot_icall_Internal_CodeCompletionRequest(int kind, in godot_string scriptFile,
out godot_packed_string_array res);
- [DllImport(GodotDllName)]
- public static extern float godot_icall_Globals_EditorScale();
+ public static partial float godot_icall_Globals_EditorScale();
- [DllImport(GodotDllName)]
- public static extern void godot_icall_Globals_GlobalDef(in godot_string setting, in godot_variant defaultValue,
+ public static partial void godot_icall_Globals_GlobalDef(in godot_string setting, in godot_variant defaultValue,
bool restartIfChanged, out godot_variant result);
- [DllImport(GodotDllName)]
- public static extern void godot_icall_Globals_EditorDef(in godot_string setting, in godot_variant defaultValue,
+ public static partial void godot_icall_Globals_EditorDef(in godot_string setting, in godot_variant defaultValue,
bool restartIfChanged, out godot_variant result);
- [DllImport(GodotDllName)]
- public static extern void godot_icall_Globals_EditorShortcut(in godot_string setting, out godot_variant result);
+ public static partial void
+ godot_icall_Globals_EditorShortcut(in godot_string setting, out godot_variant result);
- [DllImport(GodotDllName)]
- public static extern void godot_icall_Globals_TTR(in godot_string text, out godot_string dest);
+ public static partial void godot_icall_Globals_TTR(in godot_string text, out godot_string dest);
- [DllImport(GodotDllName)]
- public static extern void godot_icall_Utils_OS_GetPlatformName(out godot_string dest);
+ public static partial void godot_icall_Utils_OS_GetPlatformName(out godot_string dest);
- [DllImport(GodotDllName)]
- public static extern bool godot_icall_Utils_OS_UnixFileHasExecutableAccess(in godot_string filePath);
+ public static partial bool godot_icall_Utils_OS_UnixFileHasExecutableAccess(in godot_string filePath);
#endregion
}
diff --git a/modules/mono/editor/editor_internal_calls.cpp b/modules/mono/editor/editor_internal_calls.cpp
index bf0309126b..1ef78c3ac2 100644
--- a/modules/mono/editor/editor_internal_calls.cpp
+++ b/modules/mono/editor/editor_internal_calls.cpp
@@ -56,29 +56,15 @@
extern "C" {
#endif
-#ifdef __cplusplus
-#define MAYBE_UNUSED [[maybe_unused]]
-#else
-#define MAYBE_UNUSED
-#endif
-
-#ifdef __GNUC__
-#define GD_PINVOKE_EXPORT MAYBE_UNUSED __attribute__((visibility("default")))
-#elif defined(_WIN32)
-#define GD_PINVOKE_EXPORT MAYBE_UNUSED __declspec(dllexport)
-#else
-#define GD_PINVOKE_EXPORT MAYBE_UNUSED
-#endif
-
-GD_PINVOKE_EXPORT void godot_icall_GodotSharpDirs_ResMetadataDir(godot_string *r_dest) {
+void godot_icall_GodotSharpDirs_ResMetadataDir(godot_string *r_dest) {
memnew_placement(r_dest, String(GodotSharpDirs::get_res_metadata_dir()));
}
-GD_PINVOKE_EXPORT void godot_icall_GodotSharpDirs_MonoUserDir(godot_string *r_dest) {
+void godot_icall_GodotSharpDirs_MonoUserDir(godot_string *r_dest) {
memnew_placement(r_dest, String(GodotSharpDirs::get_mono_user_dir()));
}
-GD_PINVOKE_EXPORT void godot_icall_GodotSharpDirs_BuildLogsDirs(godot_string *r_dest) {
+void godot_icall_GodotSharpDirs_BuildLogsDirs(godot_string *r_dest) {
#ifdef TOOLS_ENABLED
memnew_placement(r_dest, String(GodotSharpDirs::get_build_logs_dir()));
#else
@@ -86,7 +72,7 @@ GD_PINVOKE_EXPORT void godot_icall_GodotSharpDirs_BuildLogsDirs(godot_string *r_
#endif
}
-GD_PINVOKE_EXPORT void godot_icall_GodotSharpDirs_DataEditorToolsDir(godot_string *r_dest) {
+void godot_icall_GodotSharpDirs_DataEditorToolsDir(godot_string *r_dest) {
#ifdef TOOLS_ENABLED
memnew_placement(r_dest, String(GodotSharpDirs::get_data_editor_tools_dir()));
#else
@@ -94,29 +80,29 @@ GD_PINVOKE_EXPORT void godot_icall_GodotSharpDirs_DataEditorToolsDir(godot_strin
#endif
}
-GD_PINVOKE_EXPORT void godot_icall_EditorProgress_Create(const godot_string *p_task, const godot_string *p_label, int32_t p_amount, bool p_can_cancel) {
+void godot_icall_EditorProgress_Create(const godot_string *p_task, const godot_string *p_label, int32_t p_amount, bool p_can_cancel) {
String task = *reinterpret_cast<const String *>(p_task);
String label = *reinterpret_cast<const String *>(p_label);
EditorNode::progress_add_task(task, label, p_amount, (bool)p_can_cancel);
}
-GD_PINVOKE_EXPORT void godot_icall_EditorProgress_Dispose(const godot_string *p_task) {
+void godot_icall_EditorProgress_Dispose(const godot_string *p_task) {
String task = *reinterpret_cast<const String *>(p_task);
EditorNode::progress_end_task(task);
}
-GD_PINVOKE_EXPORT bool godot_icall_EditorProgress_Step(const godot_string *p_task, const godot_string *p_state, int32_t p_step, bool p_force_refresh) {
+bool godot_icall_EditorProgress_Step(const godot_string *p_task, const godot_string *p_state, int32_t p_step, bool p_force_refresh) {
String task = *reinterpret_cast<const String *>(p_task);
String state = *reinterpret_cast<const String *>(p_state);
return EditorNode::progress_task_step(task, state, p_step, (bool)p_force_refresh);
}
-GD_PINVOKE_EXPORT void godot_icall_Internal_FullExportTemplatesDir(godot_string *r_dest) {
+void godot_icall_Internal_FullExportTemplatesDir(godot_string *r_dest) {
String full_templates_dir = EditorPaths::get_singleton()->get_export_templates_dir().plus_file(VERSION_FULL_CONFIG);
memnew_placement(r_dest, String(full_templates_dir));
}
-GD_PINVOKE_EXPORT bool godot_icall_Internal_IsMacOSAppBundleInstalled(const godot_string *p_bundle_id) {
+bool godot_icall_Internal_IsMacOSAppBundleInstalled(const godot_string *p_bundle_id) {
#ifdef MACOS_ENABLED
String bundle_id = *reinterpret_cast<const String *>(p_bundle_id);
return (bool)macos_is_app_bundle_installed(bundle_id);
@@ -126,11 +112,11 @@ GD_PINVOKE_EXPORT bool godot_icall_Internal_IsMacOSAppBundleInstalled(const godo
#endif
}
-GD_PINVOKE_EXPORT bool godot_icall_Internal_GodotIs32Bits() {
+bool godot_icall_Internal_GodotIs32Bits() {
return sizeof(void *) == 4;
}
-GD_PINVOKE_EXPORT bool godot_icall_Internal_GodotIsRealTDouble() {
+bool godot_icall_Internal_GodotIsRealTDouble() {
#ifdef REAL_T_IS_DOUBLE
return (bool)true;
#else
@@ -138,11 +124,11 @@ GD_PINVOKE_EXPORT bool godot_icall_Internal_GodotIsRealTDouble() {
#endif
}
-GD_PINVOKE_EXPORT void godot_icall_Internal_GodotMainIteration() {
+void godot_icall_Internal_GodotMainIteration() {
Main::iteration();
}
-GD_PINVOKE_EXPORT bool godot_icall_Internal_IsAssembliesReloadingNeeded() {
+bool godot_icall_Internal_IsAssembliesReloadingNeeded() {
#ifdef GD_MONO_HOT_RELOAD
return (bool)CSharpLanguage::get_singleton()->is_assembly_reloading_needed();
#else
@@ -150,81 +136,81 @@ GD_PINVOKE_EXPORT bool godot_icall_Internal_IsAssembliesReloadingNeeded() {
#endif
}
-GD_PINVOKE_EXPORT void godot_icall_Internal_ReloadAssemblies(bool p_soft_reload) {
+void godot_icall_Internal_ReloadAssemblies(bool p_soft_reload) {
#ifdef GD_MONO_HOT_RELOAD
mono_bind::GodotSharp::get_singleton()->call_deferred(SNAME("_reload_assemblies"), (bool)p_soft_reload);
#endif
}
-GD_PINVOKE_EXPORT void godot_icall_Internal_EditorDebuggerNodeReloadScripts() {
+void godot_icall_Internal_EditorDebuggerNodeReloadScripts() {
EditorDebuggerNode::get_singleton()->reload_scripts();
}
-GD_PINVOKE_EXPORT bool godot_icall_Internal_ScriptEditorEdit(Resource *p_resource, int32_t p_line, int32_t p_col, bool p_grab_focus) {
+bool godot_icall_Internal_ScriptEditorEdit(Resource *p_resource, int32_t p_line, int32_t p_col, bool p_grab_focus) {
Ref<Resource> resource = p_resource;
return (bool)ScriptEditor::get_singleton()->edit(resource, p_line, p_col, (bool)p_grab_focus);
}
-GD_PINVOKE_EXPORT void godot_icall_Internal_EditorNodeShowScriptScreen() {
+void godot_icall_Internal_EditorNodeShowScriptScreen() {
EditorNode::get_singleton()->call("_editor_select", EditorNode::EDITOR_SCRIPT);
}
-GD_PINVOKE_EXPORT void godot_icall_Internal_EditorRunPlay() {
+void godot_icall_Internal_EditorRunPlay() {
EditorNode::get_singleton()->run_play();
}
-GD_PINVOKE_EXPORT void godot_icall_Internal_EditorRunStop() {
+void godot_icall_Internal_EditorRunStop() {
EditorNode::get_singleton()->run_stop();
}
-GD_PINVOKE_EXPORT void godot_icall_Internal_ScriptEditorDebugger_ReloadScripts() {
+void godot_icall_Internal_ScriptEditorDebugger_ReloadScripts() {
EditorDebuggerNode *ed = EditorDebuggerNode::get_singleton();
if (ed) {
ed->reload_scripts();
}
}
-GD_PINVOKE_EXPORT void godot_icall_Internal_CodeCompletionRequest(int32_t p_kind, const godot_string *p_script_file, godot_packed_array *r_ret) {
+void godot_icall_Internal_CodeCompletionRequest(int32_t p_kind, const godot_string *p_script_file, godot_packed_array *r_ret) {
String script_file = *reinterpret_cast<const String *>(p_script_file);
PackedStringArray suggestions = gdmono::get_code_completion((gdmono::CompletionKind)p_kind, script_file);
memnew_placement(r_ret, PackedStringArray(suggestions));
}
-GD_PINVOKE_EXPORT float godot_icall_Globals_EditorScale() {
+float godot_icall_Globals_EditorScale() {
return EDSCALE;
}
-GD_PINVOKE_EXPORT void godot_icall_Globals_GlobalDef(const godot_string *p_setting, const godot_variant *p_default_value, bool p_restart_if_changed, godot_variant *r_result) {
+void godot_icall_Globals_GlobalDef(const godot_string *p_setting, const godot_variant *p_default_value, bool p_restart_if_changed, godot_variant *r_result) {
String setting = *reinterpret_cast<const String *>(p_setting);
Variant default_value = *reinterpret_cast<const Variant *>(p_default_value);
Variant result = _GLOBAL_DEF(setting, default_value, (bool)p_restart_if_changed);
memnew_placement(r_result, Variant(result));
}
-GD_PINVOKE_EXPORT void godot_icall_Globals_EditorDef(const godot_string *p_setting, const godot_variant *p_default_value, bool p_restart_if_changed, godot_variant *r_result) {
+void godot_icall_Globals_EditorDef(const godot_string *p_setting, const godot_variant *p_default_value, bool p_restart_if_changed, godot_variant *r_result) {
String setting = *reinterpret_cast<const String *>(p_setting);
Variant default_value = *reinterpret_cast<const Variant *>(p_default_value);
Variant result = _EDITOR_DEF(setting, default_value, (bool)p_restart_if_changed);
memnew_placement(r_result, Variant(result));
}
-GD_PINVOKE_EXPORT void godot_icall_Globals_EditorShortcut(const godot_string *p_setting, godot_variant *r_result) {
+void godot_icall_Globals_EditorShortcut(const godot_string *p_setting, godot_variant *r_result) {
String setting = *reinterpret_cast<const String *>(p_setting);
Ref<Shortcut> result = ED_GET_SHORTCUT(setting);
memnew_placement(r_result, Variant(result));
}
-GD_PINVOKE_EXPORT void godot_icall_Globals_TTR(const godot_string *p_text, godot_string *r_dest) {
+void godot_icall_Globals_TTR(const godot_string *p_text, godot_string *r_dest) {
String text = *reinterpret_cast<const String *>(p_text);
memnew_placement(r_dest, String(TTR(text)));
}
-GD_PINVOKE_EXPORT void godot_icall_Utils_OS_GetPlatformName(godot_string *r_dest) {
+void godot_icall_Utils_OS_GetPlatformName(godot_string *r_dest) {
String os_name = OS::get_singleton()->get_name();
memnew_placement(r_dest, String(os_name));
}
-GD_PINVOKE_EXPORT bool godot_icall_Utils_OS_UnixFileHasExecutableAccess(const godot_string *p_file_path) {
+bool godot_icall_Utils_OS_UnixFileHasExecutableAccess(const godot_string *p_file_path) {
#ifdef UNIX_ENABLED
String file_path = *reinterpret_cast<const String *>(p_file_path);
return access(file_path.utf8().get_data(), X_OK) == 0;
@@ -237,7 +223,9 @@ GD_PINVOKE_EXPORT bool godot_icall_Utils_OS_UnixFileHasExecutableAccess(const go
}
#endif
-void *godotsharp_editor_pinvoke_funcs[28] = {
+// The order in this array must match the declaration order of
+// the methods in 'GodotTools/Internals/Internal.cs'.
+static const void *unmanaged_callbacks[]{
(void *)godot_icall_GodotSharpDirs_ResMetadataDir,
(void *)godot_icall_GodotSharpDirs_MonoUserDir,
(void *)godot_icall_GodotSharpDirs_BuildLogsDirs,
@@ -267,3 +255,8 @@ void *godotsharp_editor_pinvoke_funcs[28] = {
(void *)godot_icall_Utils_OS_GetPlatformName,
(void *)godot_icall_Utils_OS_UnixFileHasExecutableAccess,
};
+
+const void **godotsharp::get_editor_interop_funcs(int32_t &r_size) {
+ r_size = sizeof(unmanaged_callbacks);
+ return unmanaged_callbacks;
+}
diff --git a/modules/mono/editor/editor_internal_calls.h b/modules/mono/editor/editor_internal_calls.h
index 8262ac211a..35391f1f04 100644
--- a/modules/mono/editor/editor_internal_calls.h
+++ b/modules/mono/editor/editor_internal_calls.h
@@ -31,6 +31,10 @@
#ifndef EDITOR_INTERNAL_CALLS_H
#define EDITOR_INTERNAL_CALLS_H
-void register_editor_internal_calls();
+#include "core/typedefs.h"
+
+namespace godotsharp {
+const void **get_editor_interop_funcs(int32_t &r_size);
+}
#endif // EDITOR_INTERNAL_CALLS_H
diff --git a/modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/CallbacksInfo.cs b/modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/CallbacksInfo.cs
new file mode 100644
index 0000000000..686023a077
--- /dev/null
+++ b/modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/CallbacksInfo.cs
@@ -0,0 +1,24 @@
+using System.Collections.Immutable;
+using System.Linq;
+using Microsoft.CodeAnalysis;
+
+namespace Godot.SourceGenerators.Internal;
+
+internal struct CallbacksData
+{
+ public CallbacksData(INamedTypeSymbol nativeTypeSymbol, INamedTypeSymbol funcStructSymbol)
+ {
+ NativeTypeSymbol = nativeTypeSymbol;
+ FuncStructSymbol = funcStructSymbol;
+ Methods = NativeTypeSymbol.GetMembers()
+ .Where(symbol => symbol is IMethodSymbol { IsPartialDefinition: true })
+ .Cast<IMethodSymbol>()
+ .ToImmutableArray();
+ }
+
+ public INamedTypeSymbol NativeTypeSymbol { get; }
+
+ public INamedTypeSymbol FuncStructSymbol { get; }
+
+ public ImmutableArray<IMethodSymbol> Methods { get; }
+}
diff --git a/modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/Common.cs b/modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/Common.cs
new file mode 100644
index 0000000000..16e96c725a
--- /dev/null
+++ b/modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/Common.cs
@@ -0,0 +1,65 @@
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.CSharp.Syntax;
+
+namespace Godot.SourceGenerators.Internal;
+
+internal static class Common
+{
+ public static void ReportNonPartialUnmanagedCallbacksClass(
+ GeneratorExecutionContext context,
+ ClassDeclarationSyntax cds, INamedTypeSymbol symbol
+ )
+ {
+ string message =
+ "Missing partial modifier on declaration of type '" +
+ $"{symbol.FullQualifiedName()}' which has attribute '{GeneratorClasses.GenerateUnmanagedCallbacksAttr}'";
+
+ string description = $"{message}. Classes with attribute '{GeneratorClasses.GenerateUnmanagedCallbacksAttr}' " +
+ "must be declared with the partial modifier.";
+
+ context.ReportDiagnostic(Diagnostic.Create(
+ new DiagnosticDescriptor(id: "GODOT-INTERNAL-G0001",
+ title: message,
+ messageFormat: message,
+ category: "Usage",
+ DiagnosticSeverity.Error,
+ isEnabledByDefault: true,
+ description),
+ cds.GetLocation(),
+ cds.SyntaxTree.FilePath));
+ }
+
+ public static void ReportNonPartialUnmanagedCallbacksOuterClass(
+ GeneratorExecutionContext context,
+ TypeDeclarationSyntax outerTypeDeclSyntax
+ )
+ {
+ var outerSymbol = context.Compilation
+ .GetSemanticModel(outerTypeDeclSyntax.SyntaxTree)
+ .GetDeclaredSymbol(outerTypeDeclSyntax);
+
+ string fullQualifiedName = outerSymbol is INamedTypeSymbol namedTypeSymbol ?
+ namedTypeSymbol.FullQualifiedName() :
+ "type not found";
+
+ string message =
+ $"Missing partial modifier on declaration of type '{fullQualifiedName}', " +
+ $"which contains one or more subclasses with attribute " +
+ $"'{GeneratorClasses.GenerateUnmanagedCallbacksAttr}'";
+
+ string description = $"{message}. Classes with attribute " +
+ $"'{GeneratorClasses.GenerateUnmanagedCallbacksAttr}' and their " +
+ "containing types must be declared with the partial modifier.";
+
+ context.ReportDiagnostic(Diagnostic.Create(
+ new DiagnosticDescriptor(id: "GODOT-INTERNAL-G0002",
+ title: message,
+ messageFormat: message,
+ category: "Usage",
+ DiagnosticSeverity.Error,
+ isEnabledByDefault: true,
+ description),
+ outerTypeDeclSyntax.GetLocation(),
+ outerTypeDeclSyntax.SyntaxTree.FilePath));
+ }
+}
diff --git a/modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/ExtensionMethods.cs b/modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/ExtensionMethods.cs
new file mode 100644
index 0000000000..fac362479a
--- /dev/null
+++ b/modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/ExtensionMethods.cs
@@ -0,0 +1,119 @@
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.CSharp;
+using Microsoft.CodeAnalysis.CSharp.Syntax;
+
+namespace Godot.SourceGenerators.Internal;
+
+internal static class ExtensionMethods
+{
+ public static AttributeData? GetGenerateUnmanagedCallbacksAttribute(this INamedTypeSymbol symbol)
+ => symbol.GetAttributes()
+ .FirstOrDefault(a => a.AttributeClass?.IsGenerateUnmanagedCallbacksAttribute() ?? false);
+
+ private static bool HasGenerateUnmanagedCallbacksAttribute(
+ this ClassDeclarationSyntax cds, Compilation compilation,
+ out INamedTypeSymbol? symbol
+ )
+ {
+ var sm = compilation.GetSemanticModel(cds.SyntaxTree);
+
+ var classTypeSymbol = sm.GetDeclaredSymbol(cds);
+ if (classTypeSymbol == null)
+ {
+ symbol = null;
+ return false;
+ }
+
+ if (!classTypeSymbol.GetAttributes()
+ .Any(a => a.AttributeClass?.IsGenerateUnmanagedCallbacksAttribute() ?? false))
+ {
+ symbol = null;
+ return false;
+ }
+
+ symbol = classTypeSymbol;
+ return true;
+ }
+
+ private static bool IsGenerateUnmanagedCallbacksAttribute(this INamedTypeSymbol symbol)
+ => symbol.ToString() == GeneratorClasses.GenerateUnmanagedCallbacksAttr;
+
+ public static IEnumerable<(ClassDeclarationSyntax cds, INamedTypeSymbol symbol)> SelectUnmanagedCallbacksClasses(
+ this IEnumerable<ClassDeclarationSyntax> source,
+ Compilation compilation
+ )
+ {
+ foreach (var cds in source)
+ {
+ if (cds.HasGenerateUnmanagedCallbacksAttribute(compilation, out var symbol))
+ yield return (cds, symbol!);
+ }
+ }
+
+ public static bool IsNested(this TypeDeclarationSyntax cds)
+ => cds.Parent is TypeDeclarationSyntax;
+
+ public static bool IsPartial(this TypeDeclarationSyntax cds)
+ => cds.Modifiers.Any(SyntaxKind.PartialKeyword);
+
+ public static bool AreAllOuterTypesPartial(
+ this TypeDeclarationSyntax cds,
+ out TypeDeclarationSyntax? typeMissingPartial
+ )
+ {
+ SyntaxNode? outerSyntaxNode = cds.Parent;
+
+ while (outerSyntaxNode is TypeDeclarationSyntax outerTypeDeclSyntax)
+ {
+ if (!outerTypeDeclSyntax.IsPartial())
+ {
+ typeMissingPartial = outerTypeDeclSyntax;
+ return false;
+ }
+
+ outerSyntaxNode = outerSyntaxNode.Parent;
+ }
+
+ typeMissingPartial = null;
+ return true;
+ }
+
+ public static string GetDeclarationKeyword(this INamedTypeSymbol namedTypeSymbol)
+ {
+ string? keyword = namedTypeSymbol.DeclaringSyntaxReferences
+ .OfType<TypeDeclarationSyntax>().FirstOrDefault()?
+ .Keyword.Text;
+
+ return keyword ?? namedTypeSymbol.TypeKind switch
+ {
+ TypeKind.Interface => "interface",
+ TypeKind.Struct => "struct",
+ _ => "class"
+ };
+ }
+
+ private static SymbolDisplayFormat FullyQualifiedFormatOmitGlobal { get; } =
+ SymbolDisplayFormat.FullyQualifiedFormat
+ .WithGlobalNamespaceStyle(SymbolDisplayGlobalNamespaceStyle.Omitted);
+
+ public static string FullQualifiedName(this ITypeSymbol symbol)
+ => symbol.ToDisplayString(NullableFlowState.NotNull, FullyQualifiedFormatOmitGlobal);
+
+ public static string NameWithTypeParameters(this INamedTypeSymbol symbol)
+ {
+ return symbol.IsGenericType ?
+ string.Concat(symbol.Name, "<", string.Join(", ", symbol.TypeParameters), ">") :
+ symbol.Name;
+ }
+
+ public static string FullQualifiedName(this INamespaceSymbol symbol)
+ => symbol.ToDisplayString(FullyQualifiedFormatOmitGlobal);
+
+ public static string SanitizeQualifiedNameForUniqueHint(this string qualifiedName)
+ => qualifiedName
+ // AddSource() doesn't support angle brackets
+ .Replace("<", "(Of ")
+ .Replace(">", ")");
+}
diff --git a/modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/GeneratorClasses.cs b/modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/GeneratorClasses.cs
new file mode 100644
index 0000000000..1bbb33f5a1
--- /dev/null
+++ b/modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/GeneratorClasses.cs
@@ -0,0 +1,6 @@
+namespace Godot.SourceGenerators.Internal;
+
+internal static class GeneratorClasses
+{
+ public const string GenerateUnmanagedCallbacksAttr = "Godot.SourceGenerators.Internal.GenerateUnmanagedCallbacksAttribute";
+}
diff --git a/modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/Godot.SourceGenerators.Internal.csproj b/modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/Godot.SourceGenerators.Internal.csproj
new file mode 100644
index 0000000000..4d1a5bb76c
--- /dev/null
+++ b/modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/Godot.SourceGenerators.Internal.csproj
@@ -0,0 +1,11 @@
+<Project Sdk="Microsoft.NET.Sdk">
+ <PropertyGroup>
+ <TargetFramework>netstandard2.0</TargetFramework>
+ <LangVersion>10</LangVersion>
+ <Nullable>enable</Nullable>
+ </PropertyGroup>
+ <ItemGroup>
+ <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.10.0" PrivateAssets="all" />
+ <PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3" PrivateAssets="all" />
+ </ItemGroup>
+</Project>
diff --git a/modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/UnmanagedCallbacksGenerator.cs b/modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/UnmanagedCallbacksGenerator.cs
new file mode 100644
index 0000000000..da578309bc
--- /dev/null
+++ b/modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/UnmanagedCallbacksGenerator.cs
@@ -0,0 +1,463 @@
+using System.Text;
+using System.Linq;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.Text;
+using Microsoft.CodeAnalysis.CSharp;
+using Microsoft.CodeAnalysis.CSharp.Syntax;
+
+namespace Godot.SourceGenerators.Internal;
+
+[Generator]
+public class UnmanagedCallbacksGenerator : ISourceGenerator
+{
+ public void Initialize(GeneratorInitializationContext context)
+ {
+ context.RegisterForPostInitialization(ctx => { GenerateAttribute(ctx); });
+ }
+
+ public void Execute(GeneratorExecutionContext context)
+ {
+ INamedTypeSymbol[] unmanagedCallbacksClasses = context
+ .Compilation.SyntaxTrees
+ .SelectMany(tree =>
+ tree.GetRoot().DescendantNodes()
+ .OfType<ClassDeclarationSyntax>()
+ .SelectUnmanagedCallbacksClasses(context.Compilation)
+ // Report and skip non-partial classes
+ .Where(x =>
+ {
+ if (x.cds.IsPartial())
+ {
+ if (x.cds.IsNested() && !x.cds.AreAllOuterTypesPartial(out var typeMissingPartial))
+ {
+ Common.ReportNonPartialUnmanagedCallbacksOuterClass(context, typeMissingPartial!);
+ return false;
+ }
+
+ return true;
+ }
+
+ Common.ReportNonPartialUnmanagedCallbacksClass(context, x.cds, x.symbol);
+ return false;
+ })
+ .Select(x => x.symbol)
+ )
+ .Distinct<INamedTypeSymbol>(SymbolEqualityComparer.Default)
+ .ToArray();
+
+ foreach (var symbol in unmanagedCallbacksClasses)
+ {
+ var attr = symbol.GetGenerateUnmanagedCallbacksAttribute();
+ if (attr == null || attr.ConstructorArguments.Length != 1)
+ {
+ // TODO: Report error or throw exception, this is an invalid case and should never be reached
+ System.Diagnostics.Debug.Fail("FAILED!");
+ continue;
+ }
+
+ var funcStructType = (INamedTypeSymbol?)attr.ConstructorArguments[0].Value;
+ if (funcStructType == null)
+ {
+ // TODO: Report error or throw exception, this is an invalid case and should never be reached
+ System.Diagnostics.Debug.Fail("FAILED!");
+ continue;
+ }
+
+ var data = new CallbacksData(symbol, funcStructType);
+ GenerateInteropMethodImplementations(context, data);
+ GenerateUnmanagedCallbacksStruct(context, data);
+ }
+ }
+
+ private void GenerateAttribute(GeneratorPostInitializationContext context)
+ {
+ string source = @"using System;
+
+namespace Godot.SourceGenerators.Internal
+{
+internal class GenerateUnmanagedCallbacksAttribute : Attribute
+{
+ public Type FuncStructType { get; }
+
+ public GenerateUnmanagedCallbacksAttribute(Type funcStructType)
+ {
+ FuncStructType = funcStructType;
+ }
+}
+}";
+
+ context.AddSource("GenerateUnmanagedCallbacksAttribute.generated",
+ SourceText.From(source, Encoding.UTF8));
+ }
+
+ private void GenerateInteropMethodImplementations(GeneratorExecutionContext context, CallbacksData data)
+ {
+ var symbol = data.NativeTypeSymbol;
+
+ INamespaceSymbol namespaceSymbol = symbol.ContainingNamespace;
+ string classNs = namespaceSymbol != null && !namespaceSymbol.IsGlobalNamespace ?
+ namespaceSymbol.FullQualifiedName() :
+ string.Empty;
+ bool hasNamespace = classNs.Length != 0;
+ bool isInnerClass = symbol.ContainingType != null;
+
+ var source = new StringBuilder();
+ var methodSource = new StringBuilder();
+ var methodCallArguments = new StringBuilder();
+ var methodSourceAfterCall = new StringBuilder();
+
+ source.Append(
+ @"using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using Godot.Bridge;
+using Godot.NativeInterop;
+
+#pragma warning disable CA1707 // Disable warning: Identifiers should not contain underscores
+
+");
+
+ if (hasNamespace)
+ {
+ source.Append("namespace ");
+ source.Append(classNs);
+ source.Append("\n{\n");
+ }
+
+ if (isInnerClass)
+ {
+ var containingType = symbol.ContainingType;
+
+ while (containingType != null)
+ {
+ source.Append("partial ");
+ source.Append(containingType.GetDeclarationKeyword());
+ source.Append(" ");
+ source.Append(containingType.NameWithTypeParameters());
+ source.Append("\n{\n");
+
+ containingType = containingType.ContainingType;
+ }
+ }
+
+ source.Append("[System.Runtime.CompilerServices.SkipLocalsInit]\n");
+ source.Append($"unsafe partial class {symbol.Name}\n");
+ source.Append("{\n");
+ source.Append($" private static {data.FuncStructSymbol.FullQualifiedName()} _unmanagedCallbacks;\n\n");
+
+ foreach (var callback in data.Methods)
+ {
+ methodSource.Clear();
+ methodCallArguments.Clear();
+ methodSourceAfterCall.Clear();
+
+ source.Append(" [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]\n");
+ source.Append($" {SyntaxFacts.GetText(callback.DeclaredAccessibility)} ");
+
+ if (callback.IsStatic)
+ source.Append("static ");
+
+ source.Append("partial ");
+ source.Append(callback.ReturnType.FullQualifiedName());
+ source.Append(' ');
+ source.Append(callback.Name);
+ source.Append('(');
+
+ for (int i = 0; i < callback.Parameters.Length; i++)
+ {
+ var parameter = callback.Parameters[i];
+
+ source.Append(parameter.ToDisplayString());
+ source.Append(' ');
+ source.Append(parameter.Name);
+
+ if (parameter.RefKind == RefKind.Out)
+ {
+ // Only assign default if the parameter won't be passed by-ref or copied later.
+ if (IsGodotInteropStruct(parameter.Type))
+ methodSource.Append($" {parameter.Name} = default;\n");
+ }
+
+ if (IsByRefParameter(parameter))
+ {
+ if (IsGodotInteropStruct(parameter.Type))
+ {
+ methodSource.Append(" ");
+ AppendCustomUnsafeAsPointer(methodSource, parameter, out string varName);
+ methodCallArguments.Append(varName);
+ }
+ else if (parameter.Type.IsValueType)
+ {
+ methodSource.Append(" ");
+ AppendCopyToStackAndGetPointer(methodSource, parameter, out string varName);
+ methodCallArguments.Append($"&{varName}");
+
+ if (parameter.RefKind is RefKind.Out or RefKind.Ref)
+ {
+ methodSourceAfterCall.Append($" {parameter.Name} = {varName};\n");
+ }
+ }
+ else
+ {
+ // If it's a by-ref param and we can't get the pointer
+ // just pass it by-ref and let it be pinned.
+ AppendRefKind(methodCallArguments, parameter.RefKind)
+ .Append(' ')
+ .Append(parameter.Name);
+ }
+ }
+ else
+ {
+ methodCallArguments.Append(parameter.Name);
+ }
+
+ if (i < callback.Parameters.Length - 1)
+ {
+ source.Append(", ");
+ methodCallArguments.Append(", ");
+ }
+ }
+
+ source.Append(")\n");
+ source.Append(" {\n");
+
+ source.Append(methodSource);
+ source.Append(" ");
+
+ if (!callback.ReturnsVoid)
+ {
+ if (methodSourceAfterCall.Length != 0)
+ source.Append($"{callback.ReturnType.FullQualifiedName()} ret = ");
+ else
+ source.Append("return ");
+ }
+
+ source.Append($"_unmanagedCallbacks.{callback.Name}(");
+ source.Append(methodCallArguments);
+ source.Append(");\n");
+
+ if (methodSourceAfterCall.Length != 0)
+ {
+ source.Append(methodSourceAfterCall);
+
+ if (!callback.ReturnsVoid)
+ source.Append(" return ret;\n");
+ }
+
+ source.Append(" }\n\n");
+ }
+
+ source.Append("}\n");
+
+ if (isInnerClass)
+ {
+ var containingType = symbol.ContainingType;
+
+ while (containingType != null)
+ {
+ source.Append("}\n"); // outer class
+
+ containingType = containingType.ContainingType;
+ }
+ }
+
+ if (hasNamespace)
+ source.Append("\n}");
+
+ source.Append("\n\n#pragma warning restore CA1707\n");
+
+ context.AddSource($"{data.NativeTypeSymbol.FullQualifiedName().SanitizeQualifiedNameForUniqueHint()}.generated",
+ SourceText.From(source.ToString(), Encoding.UTF8));
+ }
+
+ private void GenerateUnmanagedCallbacksStruct(GeneratorExecutionContext context, CallbacksData data)
+ {
+ var symbol = data.FuncStructSymbol;
+
+ INamespaceSymbol namespaceSymbol = symbol.ContainingNamespace;
+ string classNs = namespaceSymbol != null && !namespaceSymbol.IsGlobalNamespace ?
+ namespaceSymbol.FullQualifiedName() :
+ string.Empty;
+ bool hasNamespace = classNs.Length != 0;
+ bool isInnerClass = symbol.ContainingType != null;
+
+ var source = new StringBuilder();
+
+ source.Append(
+ @"using System.Runtime.InteropServices;
+using Godot.NativeInterop;
+
+#pragma warning disable CA1707 // Disable warning: Identifiers should not contain underscores
+
+");
+ if (hasNamespace)
+ {
+ source.Append("namespace ");
+ source.Append(classNs);
+ source.Append("\n{\n");
+ }
+
+ if (isInnerClass)
+ {
+ var containingType = symbol.ContainingType;
+
+ while (containingType != null)
+ {
+ source.Append("partial ");
+ source.Append(containingType.GetDeclarationKeyword());
+ source.Append(" ");
+ source.Append(containingType.NameWithTypeParameters());
+ source.Append("\n{\n");
+
+ containingType = containingType.ContainingType;
+ }
+ }
+
+ source.Append("[StructLayout(LayoutKind.Sequential)]\n");
+ source.Append($"unsafe partial struct {symbol.Name}\n{{\n");
+
+ foreach (var callback in data.Methods)
+ {
+ source.Append(" ");
+ source.Append(callback.DeclaredAccessibility == Accessibility.Public ? "public " : "internal ");
+
+ source.Append("delegate* unmanaged<");
+
+ foreach (var parameter in callback.Parameters)
+ {
+ if (IsByRefParameter(parameter))
+ {
+ if (IsGodotInteropStruct(parameter.Type) || parameter.Type.IsValueType)
+ {
+ AppendPointerType(source, parameter.Type);
+ }
+ else
+ {
+ // If it's a by-ref param and we can't get the pointer
+ // just pass it by-ref and let it be pinned.
+ AppendRefKind(source, parameter.RefKind)
+ .Append(' ')
+ .Append(parameter.Type.FullQualifiedName());
+ }
+ }
+ else
+ {
+ source.Append(parameter.Type.FullQualifiedName());
+ }
+
+ source.Append(", ");
+ }
+
+ source.Append(callback.ReturnType.FullQualifiedName());
+ source.Append($"> {callback.Name};\n");
+ }
+
+ source.Append("}\n");
+
+ if (isInnerClass)
+ {
+ var containingType = symbol.ContainingType;
+
+ while (containingType != null)
+ {
+ source.Append("}\n"); // outer class
+
+ containingType = containingType.ContainingType;
+ }
+ }
+
+ if (hasNamespace)
+ source.Append("}\n");
+
+ source.Append("\n#pragma warning restore CA1707\n");
+
+ context.AddSource($"{symbol.FullQualifiedName().SanitizeQualifiedNameForUniqueHint()}.generated",
+ SourceText.From(source.ToString(), Encoding.UTF8));
+ }
+
+ private static bool IsGodotInteropStruct(ITypeSymbol type) =>
+ GodotInteropStructs.Contains(type.FullQualifiedName());
+
+ private static bool IsByRefParameter(IParameterSymbol parameter) =>
+ parameter.RefKind is RefKind.In or RefKind.Out or RefKind.Ref;
+
+ private static StringBuilder AppendRefKind(StringBuilder source, RefKind refKind) =>
+ refKind switch
+ {
+ RefKind.In => source.Append("in"),
+ RefKind.Out => source.Append("out"),
+ RefKind.Ref => source.Append("ref"),
+ _ => source,
+ };
+
+ private static void AppendPointerType(StringBuilder source, ITypeSymbol type)
+ {
+ source.Append(type.FullQualifiedName());
+ source.Append('*');
+ }
+
+ private static void AppendCustomUnsafeAsPointer(StringBuilder source, IParameterSymbol parameter,
+ out string varName)
+ {
+ varName = $"{parameter.Name}_ptr";
+
+ AppendPointerType(source, parameter.Type);
+ source.Append(' ');
+ source.Append(varName);
+ source.Append(" = ");
+
+ source.Append('(');
+ AppendPointerType(source, parameter.Type);
+ source.Append(')');
+
+ if (parameter.RefKind == RefKind.In)
+ source.Append("CustomUnsafe.ReadOnlyRefAsPointer(in ");
+ else
+ source.Append("CustomUnsafe.AsPointer(ref ");
+
+ source.Append(parameter.Name);
+
+ source.Append(");\n");
+ }
+
+ private static void AppendCopyToStackAndGetPointer(StringBuilder source, IParameterSymbol parameter,
+ out string varName)
+ {
+ varName = $"{parameter.Name}_copy";
+
+ source.Append(parameter.Type.FullQualifiedName());
+ source.Append(' ');
+ source.Append(varName);
+ if (parameter.RefKind is RefKind.In or RefKind.Ref)
+ {
+ source.Append(" = ");
+ source.Append(parameter.Name);
+ }
+
+ source.Append(";\n");
+ }
+
+ private static readonly string[] GodotInteropStructs =
+ {
+ "Godot.NativeInterop.godot_ref",
+ "Godot.NativeInterop.godot_variant_call_error",
+ "Godot.NativeInterop.godot_variant",
+ "Godot.NativeInterop.godot_string",
+ "Godot.NativeInterop.godot_string_name",
+ "Godot.NativeInterop.godot_node_path",
+ "Godot.NativeInterop.godot_signal",
+ "Godot.NativeInterop.godot_callable",
+ "Godot.NativeInterop.godot_array",
+ "Godot.NativeInterop.godot_dictionary",
+ "Godot.NativeInterop.godot_packed_byte_array",
+ "Godot.NativeInterop.godot_packed_int32_array",
+ "Godot.NativeInterop.godot_packed_int64_array",
+ "Godot.NativeInterop.godot_packed_float32_array",
+ "Godot.NativeInterop.godot_packed_float64_array",
+ "Godot.NativeInterop.godot_packed_string_array",
+ "Godot.NativeInterop.godot_packed_vector2_array",
+ "Godot.NativeInterop.godot_packed_vector3_array",
+ "Godot.NativeInterop.godot_packed_color_array",
+ };
+}
diff --git a/modules/mono/glue/GodotSharp/GodotPlugins/Main.cs b/modules/mono/glue/GodotSharp/GodotPlugins/Main.cs
index 395cc9bf66..dad7464410 100644
--- a/modules/mono/glue/GodotSharp/GodotPlugins/Main.cs
+++ b/modules/mono/glue/GodotSharp/GodotPlugins/Main.cs
@@ -72,7 +72,8 @@ namespace GodotPlugins
[UnmanagedCallersOnly]
// ReSharper disable once UnusedMember.Local
private static unsafe godot_bool InitializeFromEngine(IntPtr godotDllHandle, godot_bool editorHint,
- PluginsCallbacks* pluginsCallbacks, ManagedCallbacks* managedCallbacks)
+ PluginsCallbacks* pluginsCallbacks, ManagedCallbacks* managedCallbacks,
+ IntPtr unmanagedCallbacks, int unmanagedCallbacksSize)
{
try
{
@@ -82,6 +83,7 @@ namespace GodotPlugins
NativeLibrary.SetDllImportResolver(CoreApiAssembly, _dllImportResolver);
AlcReloadCfg.Configure(alcReloadEnabled: editorHint.ToBool());
+ NativeFuncs.Initialize(unmanagedCallbacks, unmanagedCallbacksSize);
if (editorHint.ToBool())
{
@@ -112,7 +114,7 @@ namespace GodotPlugins
private struct PluginsCallbacks
{
public unsafe delegate* unmanaged<char*, godot_string*, godot_bool> LoadProjectAssemblyCallback;
- public unsafe delegate* unmanaged<char*, IntPtr> LoadToolsAssemblyCallback;
+ public unsafe delegate* unmanaged<char*, IntPtr, int, IntPtr> LoadToolsAssemblyCallback;
public unsafe delegate* unmanaged<godot_bool> UnloadProjectPluginCallback;
}
@@ -143,7 +145,8 @@ namespace GodotPlugins
}
[UnmanagedCallersOnly]
- private static unsafe IntPtr LoadToolsAssembly(char* nAssemblyPath)
+ private static unsafe IntPtr LoadToolsAssembly(char* nAssemblyPath,
+ IntPtr unmanagedCallbacks, int unmanagedCallbacksSize)
{
try
{
@@ -166,7 +169,9 @@ namespace GodotPlugins
"InternalCreateInstance");
}
- return (IntPtr?)method.Invoke(null, null) ?? IntPtr.Zero;
+ return (IntPtr?)method
+ .Invoke(null, new object[] { unmanagedCallbacks, unmanagedCallbacksSize })
+ ?? IntPtr.Zero;
}
catch (Exception e)
{
diff --git a/modules/mono/glue/GodotSharp/GodotSharp.sln b/modules/mono/glue/GodotSharp/GodotSharp.sln
index fc4e6e91f1..8db42c2d1a 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp.sln
+++ b/modules/mono/glue/GodotSharp/GodotSharp.sln
@@ -6,6 +6,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GodotSharpEditor", "GodotSh
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GodotPlugins", "GodotPlugins\GodotPlugins.csproj", "{944B77DB-497B-47F5-A1E3-81C35E3E9D4E}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Godot.SourceGenerators.Internal", "Godot.SourceGenerators.Internal\Godot.SourceGenerators.Internal.csproj", "{7749662B-E30C-419A-B745-13852573360A}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -24,5 +26,9 @@ Global
{944B77DB-497B-47F5-A1E3-81C35E3E9D4E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{944B77DB-497B-47F5-A1E3-81C35E3E9D4E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{944B77DB-497B-47F5-A1E3-81C35E3E9D4E}.Release|Any CPU.Build.0 = Release|Any CPU
+ {7749662B-E30C-419A-B745-13852573360A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {7749662B-E30C-419A-B745-13852573360A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {7749662B-E30C-419A-B745-13852573360A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {7749662B-E30C-419A-B745-13852573360A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.cs
index e56e4944b0..6d2534e6f7 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.cs
@@ -1,697 +1,522 @@
using System;
using System.Diagnostics.CodeAnalysis;
-using System.Runtime.InteropServices;
+using System.Runtime.CompilerServices;
+using Godot.SourceGenerators.Internal;
// ReSharper disable InconsistentNaming
namespace Godot.NativeInterop
{
/*
- * TODO:
- * P/Invoke pins by-ref parameters in case the managed memory is moved.
- * That's not needed here since we use "ref structs" which are stack-only.
- * Unfortunately, the runtime is not smart enough and pins them anyway.
- * We want to avoid pinning, so we must wrap these DllImports in methods
- * that reinterpret refs and pointers with CustomUnsafe.AsPointer/AsRef.
- * I wish such unnecessary boilerplate wasn't needed...
+ * IMPORTANT:
+ * The order of the methods defined in NativeFuncs must match the order
+ * in the array defined at the bottom of 'glue/runtime_interop.cpp'.
*/
- [SuppressMessage("Interoperability", "CA1401",
- MessageId = "P/Invokes should not be visible" /* Meh. What are you gonna do about it? */)]
+ [GenerateUnmanagedCallbacks(typeof(UnmanagedCallbacks))]
public static unsafe partial class NativeFuncs
{
- private const string GodotDllName = "__Internal";
+ private static bool initialized = false;
+
+ // ReSharper disable once ParameterOnlyUsedForPreconditionCheck.Global
+ public static void Initialize(IntPtr unmanagedCallbacks, int unmanagedCallbacksSize)
+ {
+ if (initialized)
+ throw new InvalidOperationException("Already initialized");
+ initialized = true;
+
+ if (unmanagedCallbacksSize != sizeof(UnmanagedCallbacks))
+ throw new ArgumentException("Unmanaged callbacks size mismatch");
+
+ _unmanagedCallbacks = Unsafe.AsRef<UnmanagedCallbacks>((void*)unmanagedCallbacks);
+ }
+
+ private partial struct UnmanagedCallbacks
+ {
+ }
// Custom functions
- [DllImport(GodotDllName)]
- public static extern IntPtr godotsharp_method_bind_get_method(in godot_string_name p_classname,
+ public static partial IntPtr godotsharp_method_bind_get_method(in godot_string_name p_classname,
in godot_string_name p_methodname);
- [DllImport(GodotDllName)]
- public static extern delegate* unmanaged<IntPtr> godotsharp_get_class_constructor(
+ public static partial delegate* unmanaged<IntPtr> godotsharp_get_class_constructor(
in godot_string_name p_classname);
- [DllImport(GodotDllName)]
- public static extern IntPtr godotsharp_engine_get_singleton(in godot_string p_name);
+ public static partial IntPtr godotsharp_engine_get_singleton(in godot_string p_name);
- [DllImport(GodotDllName)]
- internal static extern Error godotsharp_stack_info_vector_resize(
+ internal static partial Error godotsharp_stack_info_vector_resize(
ref DebuggingUtils.godot_stack_info_vector p_stack_info_vector, int p_size);
- [DllImport(GodotDllName)]
- internal static extern void godotsharp_stack_info_vector_destroy(
+ internal static partial void godotsharp_stack_info_vector_destroy(
ref DebuggingUtils.godot_stack_info_vector p_stack_info_vector);
- [DllImport(GodotDllName)]
- internal static extern void godotsharp_internal_script_debugger_send_error(in godot_string p_func,
+ internal static partial void godotsharp_internal_script_debugger_send_error(in godot_string p_func,
in godot_string p_file, int p_line, in godot_string p_err, in godot_string p_descr,
godot_bool p_warning, in DebuggingUtils.godot_stack_info_vector p_stack_info_vector);
- [DllImport(GodotDllName)]
- internal static extern bool godotsharp_internal_script_debugger_is_active();
+ internal static partial bool godotsharp_internal_script_debugger_is_active();
- [DllImport(GodotDllName)]
- internal static extern IntPtr godotsharp_internal_object_get_associated_gchandle(IntPtr ptr);
+ internal static partial IntPtr godotsharp_internal_object_get_associated_gchandle(IntPtr ptr);
- [DllImport(GodotDllName)]
- internal static extern void godotsharp_internal_object_disposed(IntPtr ptr, IntPtr gcHandleToFree);
+ internal static partial void godotsharp_internal_object_disposed(IntPtr ptr, IntPtr gcHandleToFree);
- [DllImport(GodotDllName)]
- internal static extern void godotsharp_internal_refcounted_disposed(IntPtr ptr, IntPtr gcHandleToFree,
+ internal static partial void godotsharp_internal_refcounted_disposed(IntPtr ptr, IntPtr gcHandleToFree,
godot_bool isFinalizer);
- [DllImport(GodotDllName)]
- internal static extern Error godotsharp_internal_signal_awaiter_connect(IntPtr source,
+ internal static partial Error godotsharp_internal_signal_awaiter_connect(IntPtr source,
in godot_string_name signal,
IntPtr target, IntPtr awaiterHandlePtr);
- [DllImport(GodotDllName)]
- internal static extern void godotsharp_internal_tie_native_managed_to_unmanaged(IntPtr gcHandleIntPtr,
+ internal static partial void godotsharp_internal_tie_native_managed_to_unmanaged(IntPtr gcHandleIntPtr,
IntPtr unmanaged, in godot_string_name nativeName, godot_bool refCounted);
- [DllImport(GodotDllName)]
- internal static extern void godotsharp_internal_tie_user_managed_to_unmanaged(IntPtr gcHandleIntPtr,
+ internal static partial void godotsharp_internal_tie_user_managed_to_unmanaged(IntPtr gcHandleIntPtr,
IntPtr unmanaged, godot_ref* scriptPtr, godot_bool refCounted);
- [DllImport(GodotDllName)]
- internal static extern void godotsharp_internal_tie_managed_to_unmanaged_with_pre_setup(
+ internal static partial void godotsharp_internal_tie_managed_to_unmanaged_with_pre_setup(
IntPtr gcHandleIntPtr, IntPtr unmanaged);
- [DllImport(GodotDllName)]
- internal static extern IntPtr godotsharp_internal_unmanaged_get_script_instance_managed(IntPtr p_unmanaged,
+ internal static partial IntPtr godotsharp_internal_unmanaged_get_script_instance_managed(IntPtr p_unmanaged,
out godot_bool r_has_cs_script_instance);
- [DllImport(GodotDllName)]
- internal static extern IntPtr godotsharp_internal_unmanaged_get_instance_binding_managed(IntPtr p_unmanaged);
+ internal static partial IntPtr godotsharp_internal_unmanaged_get_instance_binding_managed(IntPtr p_unmanaged);
- [DllImport(GodotDllName)]
- internal static extern IntPtr godotsharp_internal_unmanaged_instance_binding_create_managed(IntPtr p_unmanaged,
+ internal static partial IntPtr godotsharp_internal_unmanaged_instance_binding_create_managed(IntPtr p_unmanaged,
IntPtr oldGCHandlePtr);
- [DllImport(GodotDllName)]
- internal static extern void godotsharp_internal_new_csharp_script(godot_ref* r_dest);
+ internal static partial void godotsharp_internal_new_csharp_script(godot_ref* r_dest);
- [DllImport(GodotDllName)]
- internal static extern godot_bool godotsharp_internal_script_load(in godot_string p_path, godot_ref* r_dest);
+ internal static partial godot_bool godotsharp_internal_script_load(in godot_string p_path, godot_ref* r_dest);
- [DllImport(GodotDllName)]
- internal static extern void godotsharp_internal_reload_registered_script(IntPtr scriptPtr);
+ internal static partial void godotsharp_internal_reload_registered_script(IntPtr scriptPtr);
- [DllImport(GodotDllName)]
- internal static extern void godotsharp_array_filter_godot_objects_by_native(in godot_string_name p_native_name,
+ internal static partial void godotsharp_array_filter_godot_objects_by_native(in godot_string_name p_native_name,
in godot_array p_input, out godot_array r_output);
- [DllImport(GodotDllName)]
- internal static extern void godotsharp_array_filter_godot_objects_by_non_native(in godot_array p_input,
+ internal static partial void godotsharp_array_filter_godot_objects_by_non_native(in godot_array p_input,
out godot_array r_output);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_ref_new_from_ref_counted_ptr(out godot_ref r_dest,
+ public static partial void godotsharp_ref_new_from_ref_counted_ptr(out godot_ref r_dest,
IntPtr p_ref_counted_ptr);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_ref_destroy(ref godot_ref p_instance);
+ public static partial void godotsharp_ref_destroy(ref godot_ref p_instance);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_string_name_new_from_string(out godot_string_name r_dest,
+ public static partial void godotsharp_string_name_new_from_string(out godot_string_name r_dest,
in godot_string p_name);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_node_path_new_from_string(out godot_node_path r_dest,
+ public static partial void godotsharp_node_path_new_from_string(out godot_node_path r_dest,
in godot_string p_name);
- [DllImport(GodotDllName)]
- public static extern void
+ public static partial void
godotsharp_string_name_as_string(out godot_string r_dest, in godot_string_name p_name);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_node_path_as_string(out godot_string r_dest, in godot_node_path p_np);
+ public static partial void godotsharp_node_path_as_string(out godot_string r_dest, in godot_node_path p_np);
- [DllImport(GodotDllName)]
- public static extern godot_packed_byte_array godotsharp_packed_byte_array_new_mem_copy(byte* p_src,
+ public static partial godot_packed_byte_array godotsharp_packed_byte_array_new_mem_copy(byte* p_src,
int p_length);
- [DllImport(GodotDllName)]
- public static extern godot_packed_int32_array godotsharp_packed_int32_array_new_mem_copy(int* p_src,
+ public static partial godot_packed_int32_array godotsharp_packed_int32_array_new_mem_copy(int* p_src,
int p_length);
- [DllImport(GodotDllName)]
- public static extern godot_packed_int64_array godotsharp_packed_int64_array_new_mem_copy(long* p_src,
+ public static partial godot_packed_int64_array godotsharp_packed_int64_array_new_mem_copy(long* p_src,
int p_length);
- [DllImport(GodotDllName)]
- public static extern godot_packed_float32_array godotsharp_packed_float32_array_new_mem_copy(float* p_src,
+ public static partial godot_packed_float32_array godotsharp_packed_float32_array_new_mem_copy(float* p_src,
int p_length);
- [DllImport(GodotDllName)]
- public static extern godot_packed_float64_array godotsharp_packed_float64_array_new_mem_copy(double* p_src,
+ public static partial godot_packed_float64_array godotsharp_packed_float64_array_new_mem_copy(double* p_src,
int p_length);
- [DllImport(GodotDllName)]
- public static extern godot_packed_vector2_array godotsharp_packed_vector2_array_new_mem_copy(Vector2* p_src,
+ public static partial godot_packed_vector2_array godotsharp_packed_vector2_array_new_mem_copy(Vector2* p_src,
int p_length);
- [DllImport(GodotDllName)]
- public static extern godot_packed_vector3_array godotsharp_packed_vector3_array_new_mem_copy(Vector3* p_src,
+ public static partial godot_packed_vector3_array godotsharp_packed_vector3_array_new_mem_copy(Vector3* p_src,
int p_length);
- [DllImport(GodotDllName)]
- public static extern godot_packed_color_array godotsharp_packed_color_array_new_mem_copy(Color* p_src,
+ public static partial godot_packed_color_array godotsharp_packed_color_array_new_mem_copy(Color* p_src,
int p_length);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_packed_string_array_add(ref godot_packed_string_array r_dest,
+ public static partial void godotsharp_packed_string_array_add(ref godot_packed_string_array r_dest,
in godot_string p_element);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_callable_new_with_delegate(IntPtr p_delegate_handle,
+ public static partial void godotsharp_callable_new_with_delegate(IntPtr p_delegate_handle,
out godot_callable r_callable);
- [DllImport(GodotDllName)]
- internal static extern godot_bool godotsharp_callable_get_data_for_marshalling(in godot_callable p_callable,
+ internal static partial godot_bool godotsharp_callable_get_data_for_marshalling(in godot_callable p_callable,
out IntPtr r_delegate_handle, out IntPtr r_object, out godot_string_name r_name);
- [DllImport(GodotDllName)]
- internal static extern godot_variant godotsharp_callable_call(in godot_callable p_callable,
+ internal static partial godot_variant godotsharp_callable_call(in godot_callable p_callable,
godot_variant** p_args, int p_arg_count, out godot_variant_call_error p_call_error);
- [DllImport(GodotDllName)]
- internal static extern void godotsharp_callable_call_deferred(in godot_callable p_callable,
+ internal static partial void godotsharp_callable_call_deferred(in godot_callable p_callable,
godot_variant** p_args, int p_arg_count);
// GDNative functions
// gdnative.h
- [DllImport(GodotDllName)]
- public static extern void godotsharp_method_bind_ptrcall(IntPtr p_method_bind, IntPtr p_instance, void** p_args,
+ public static partial void godotsharp_method_bind_ptrcall(IntPtr p_method_bind, IntPtr p_instance, void** p_args,
void* p_ret);
- [DllImport(GodotDllName)]
- public static extern godot_variant godotsharp_method_bind_call(IntPtr p_method_bind, IntPtr p_instance,
+ public static partial godot_variant godotsharp_method_bind_call(IntPtr p_method_bind, IntPtr p_instance,
godot_variant** p_args, int p_arg_count, out godot_variant_call_error p_call_error);
// variant.h
- [DllImport(GodotDllName)]
- public static extern void
+ public static partial void
godotsharp_variant_new_string_name(out godot_variant r_dest, in godot_string_name p_s);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_variant_new_copy(out godot_variant r_dest, in godot_variant p_src);
+ public static partial void godotsharp_variant_new_copy(out godot_variant r_dest, in godot_variant p_src);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_variant_new_node_path(out godot_variant r_dest, in godot_node_path p_np);
+ public static partial void godotsharp_variant_new_node_path(out godot_variant r_dest, in godot_node_path p_np);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_variant_new_object(out godot_variant r_dest, IntPtr p_obj);
+ public static partial void godotsharp_variant_new_object(out godot_variant r_dest, IntPtr p_obj);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_variant_new_transform2d(out godot_variant r_dest, in Transform2D p_t2d);
+ public static partial void godotsharp_variant_new_transform2d(out godot_variant r_dest, in Transform2D p_t2d);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_variant_new_vector4(out godot_variant r_dest, in Vector4 p_vec4);
+ public static partial void godotsharp_variant_new_vector4(out godot_variant r_dest, in Vector4 p_vec4);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_variant_new_vector4i(out godot_variant r_dest, in Vector4i p_vec4i);
+ public static partial void godotsharp_variant_new_vector4i(out godot_variant r_dest, in Vector4i p_vec4i);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_variant_new_basis(out godot_variant r_dest, in Basis p_basis);
+ public static partial void godotsharp_variant_new_basis(out godot_variant r_dest, in Basis p_basis);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_variant_new_transform3d(out godot_variant r_dest, in Transform3D p_trans);
+ public static partial void godotsharp_variant_new_transform3d(out godot_variant r_dest, in Transform3D p_trans);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_variant_new_projection(out godot_variant r_dest, in Projection p_proj);
+ public static partial void godotsharp_variant_new_projection(out godot_variant r_dest, in Projection p_proj);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_variant_new_aabb(out godot_variant r_dest, in AABB p_aabb);
+ public static partial void godotsharp_variant_new_aabb(out godot_variant r_dest, in AABB p_aabb);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_variant_new_dictionary(out godot_variant r_dest,
+ public static partial void godotsharp_variant_new_dictionary(out godot_variant r_dest,
in godot_dictionary p_dict);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_variant_new_array(out godot_variant r_dest, in godot_array p_arr);
+ public static partial void godotsharp_variant_new_array(out godot_variant r_dest, in godot_array p_arr);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_variant_new_packed_byte_array(out godot_variant r_dest,
+ public static partial void godotsharp_variant_new_packed_byte_array(out godot_variant r_dest,
in godot_packed_byte_array p_pba);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_variant_new_packed_int32_array(out godot_variant r_dest,
+ public static partial void godotsharp_variant_new_packed_int32_array(out godot_variant r_dest,
in godot_packed_int32_array p_pia);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_variant_new_packed_int64_array(out godot_variant r_dest,
+ public static partial void godotsharp_variant_new_packed_int64_array(out godot_variant r_dest,
in godot_packed_int64_array p_pia);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_variant_new_packed_float32_array(out godot_variant r_dest,
+ public static partial void godotsharp_variant_new_packed_float32_array(out godot_variant r_dest,
in godot_packed_float32_array p_pra);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_variant_new_packed_float64_array(out godot_variant r_dest,
+ public static partial void godotsharp_variant_new_packed_float64_array(out godot_variant r_dest,
in godot_packed_float64_array p_pra);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_variant_new_packed_string_array(out godot_variant r_dest,
+ public static partial void godotsharp_variant_new_packed_string_array(out godot_variant r_dest,
in godot_packed_string_array p_psa);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_variant_new_packed_vector2_array(out godot_variant r_dest,
+ public static partial void godotsharp_variant_new_packed_vector2_array(out godot_variant r_dest,
in godot_packed_vector2_array p_pv2a);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_variant_new_packed_vector3_array(out godot_variant r_dest,
+ public static partial void godotsharp_variant_new_packed_vector3_array(out godot_variant r_dest,
in godot_packed_vector3_array p_pv3a);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_variant_new_packed_color_array(out godot_variant r_dest,
+ public static partial void godotsharp_variant_new_packed_color_array(out godot_variant r_dest,
in godot_packed_color_array p_pca);
- [DllImport(GodotDllName)]
- public static extern godot_bool godotsharp_variant_as_bool(in godot_variant p_self);
+ public static partial godot_bool godotsharp_variant_as_bool(in godot_variant p_self);
- [DllImport(GodotDllName)]
- public static extern Int64 godotsharp_variant_as_int(in godot_variant p_self);
+ public static partial Int64 godotsharp_variant_as_int(in godot_variant p_self);
- [DllImport(GodotDllName)]
- public static extern double godotsharp_variant_as_float(in godot_variant p_self);
+ public static partial double godotsharp_variant_as_float(in godot_variant p_self);
- [DllImport(GodotDllName)]
- public static extern godot_string godotsharp_variant_as_string(in godot_variant p_self);
+ public static partial godot_string godotsharp_variant_as_string(in godot_variant p_self);
- [DllImport(GodotDllName)]
- public static extern Vector2 godotsharp_variant_as_vector2(in godot_variant p_self);
+ public static partial Vector2 godotsharp_variant_as_vector2(in godot_variant p_self);
- [DllImport(GodotDllName)]
- public static extern Vector2i godotsharp_variant_as_vector2i(in godot_variant p_self);
+ public static partial Vector2i godotsharp_variant_as_vector2i(in godot_variant p_self);
- [DllImport(GodotDllName)]
- public static extern Rect2 godotsharp_variant_as_rect2(in godot_variant p_self);
+ public static partial Rect2 godotsharp_variant_as_rect2(in godot_variant p_self);
- [DllImport(GodotDllName)]
- public static extern Rect2i godotsharp_variant_as_rect2i(in godot_variant p_self);
+ public static partial Rect2i godotsharp_variant_as_rect2i(in godot_variant p_self);
- [DllImport(GodotDllName)]
- public static extern Vector3 godotsharp_variant_as_vector3(in godot_variant p_self);
+ public static partial Vector3 godotsharp_variant_as_vector3(in godot_variant p_self);
- [DllImport(GodotDllName)]
- public static extern Vector3i godotsharp_variant_as_vector3i(in godot_variant p_self);
+ public static partial Vector3i godotsharp_variant_as_vector3i(in godot_variant p_self);
- [DllImport(GodotDllName)]
- public static extern Transform2D godotsharp_variant_as_transform2d(in godot_variant p_self);
+ public static partial Transform2D godotsharp_variant_as_transform2d(in godot_variant p_self);
- [DllImport(GodotDllName)]
- public static extern Vector4 godotsharp_variant_as_vector4(in godot_variant p_self);
+ public static partial Vector4 godotsharp_variant_as_vector4(in godot_variant p_self);
- [DllImport(GodotDllName)]
- public static extern Vector4i godotsharp_variant_as_vector4i(in godot_variant p_self);
+ public static partial Vector4i godotsharp_variant_as_vector4i(in godot_variant p_self);
- [DllImport(GodotDllName)]
- public static extern Plane godotsharp_variant_as_plane(in godot_variant p_self);
+ public static partial Plane godotsharp_variant_as_plane(in godot_variant p_self);
- [DllImport(GodotDllName)]
- public static extern Quaternion godotsharp_variant_as_quaternion(in godot_variant p_self);
+ public static partial Quaternion godotsharp_variant_as_quaternion(in godot_variant p_self);
- [DllImport(GodotDllName)]
- public static extern AABB godotsharp_variant_as_aabb(in godot_variant p_self);
+ public static partial AABB godotsharp_variant_as_aabb(in godot_variant p_self);
- [DllImport(GodotDllName)]
- public static extern Basis godotsharp_variant_as_basis(in godot_variant p_self);
+ public static partial Basis godotsharp_variant_as_basis(in godot_variant p_self);
- [DllImport(GodotDllName)]
- public static extern Transform3D godotsharp_variant_as_transform3d(in godot_variant p_self);
+ public static partial Transform3D godotsharp_variant_as_transform3d(in godot_variant p_self);
- [DllImport(GodotDllName)]
- public static extern Projection godotsharp_variant_as_projection(in godot_variant p_self);
+ public static partial Projection godotsharp_variant_as_projection(in godot_variant p_self);
- [DllImport(GodotDllName)]
- public static extern Color godotsharp_variant_as_color(in godot_variant p_self);
+ public static partial Color godotsharp_variant_as_color(in godot_variant p_self);
- [DllImport(GodotDllName)]
- public static extern godot_string_name godotsharp_variant_as_string_name(in godot_variant p_self);
+ public static partial godot_string_name godotsharp_variant_as_string_name(in godot_variant p_self);
- [DllImport(GodotDllName)]
- public static extern godot_node_path godotsharp_variant_as_node_path(in godot_variant p_self);
+ public static partial godot_node_path godotsharp_variant_as_node_path(in godot_variant p_self);
- [DllImport(GodotDllName)]
- public static extern RID godotsharp_variant_as_rid(in godot_variant p_self);
+ public static partial RID godotsharp_variant_as_rid(in godot_variant p_self);
- [DllImport(GodotDllName)]
- public static extern godot_callable godotsharp_variant_as_callable(in godot_variant p_self);
+ public static partial godot_callable godotsharp_variant_as_callable(in godot_variant p_self);
- [DllImport(GodotDllName)]
- public static extern godot_signal godotsharp_variant_as_signal(in godot_variant p_self);
+ public static partial godot_signal godotsharp_variant_as_signal(in godot_variant p_self);
- [DllImport(GodotDllName)]
- public static extern godot_dictionary godotsharp_variant_as_dictionary(in godot_variant p_self);
+ public static partial godot_dictionary godotsharp_variant_as_dictionary(in godot_variant p_self);
- [DllImport(GodotDllName)]
- public static extern godot_array godotsharp_variant_as_array(in godot_variant p_self);
+ public static partial godot_array godotsharp_variant_as_array(in godot_variant p_self);
- [DllImport(GodotDllName)]
- public static extern godot_packed_byte_array godotsharp_variant_as_packed_byte_array(in godot_variant p_self);
+ public static partial godot_packed_byte_array godotsharp_variant_as_packed_byte_array(in godot_variant p_self);
- [DllImport(GodotDllName)]
- public static extern godot_packed_int32_array godotsharp_variant_as_packed_int32_array(in godot_variant p_self);
+ public static partial godot_packed_int32_array godotsharp_variant_as_packed_int32_array(in godot_variant p_self);
- [DllImport(GodotDllName)]
- public static extern godot_packed_int64_array godotsharp_variant_as_packed_int64_array(in godot_variant p_self);
+ public static partial godot_packed_int64_array godotsharp_variant_as_packed_int64_array(in godot_variant p_self);
- [DllImport(GodotDllName)]
- public static extern godot_packed_float32_array godotsharp_variant_as_packed_float32_array(
+ public static partial godot_packed_float32_array godotsharp_variant_as_packed_float32_array(
in godot_variant p_self);
- [DllImport(GodotDllName)]
- public static extern godot_packed_float64_array godotsharp_variant_as_packed_float64_array(
+ public static partial godot_packed_float64_array godotsharp_variant_as_packed_float64_array(
in godot_variant p_self);
- [DllImport(GodotDllName)]
- public static extern godot_packed_string_array godotsharp_variant_as_packed_string_array(
+ public static partial godot_packed_string_array godotsharp_variant_as_packed_string_array(
in godot_variant p_self);
- [DllImport(GodotDllName)]
- public static extern godot_packed_vector2_array godotsharp_variant_as_packed_vector2_array(
+ public static partial godot_packed_vector2_array godotsharp_variant_as_packed_vector2_array(
in godot_variant p_self);
- [DllImport(GodotDllName)]
- public static extern godot_packed_vector3_array godotsharp_variant_as_packed_vector3_array(
+ public static partial godot_packed_vector3_array godotsharp_variant_as_packed_vector3_array(
in godot_variant p_self);
- [DllImport(GodotDllName)]
- public static extern godot_packed_color_array godotsharp_variant_as_packed_color_array(in godot_variant p_self);
+ public static partial godot_packed_color_array godotsharp_variant_as_packed_color_array(in godot_variant p_self);
- [DllImport(GodotDllName)]
- public static extern godot_bool godotsharp_variant_equals(in godot_variant p_a, in godot_variant p_b);
+ public static partial godot_bool godotsharp_variant_equals(in godot_variant p_a, in godot_variant p_b);
// string.h
- [DllImport(GodotDllName)]
- public static extern void godotsharp_string_new_with_utf16_chars(out godot_string r_dest, char* p_contents);
+ public static partial void godotsharp_string_new_with_utf16_chars(out godot_string r_dest, char* p_contents);
// string_name.h
- [DllImport(GodotDllName)]
- public static extern void godotsharp_string_name_new_copy(out godot_string_name r_dest,
+ public static partial void godotsharp_string_name_new_copy(out godot_string_name r_dest,
in godot_string_name p_src);
// node_path.h
- [DllImport(GodotDllName)]
- public static extern void godotsharp_node_path_new_copy(out godot_node_path r_dest, in godot_node_path p_src);
+ public static partial void godotsharp_node_path_new_copy(out godot_node_path r_dest, in godot_node_path p_src);
// array.h
- [DllImport(GodotDllName)]
- public static extern void godotsharp_array_new(out godot_array r_dest);
+ public static partial void godotsharp_array_new(out godot_array r_dest);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_array_new_copy(out godot_array r_dest, in godot_array p_src);
+ public static partial void godotsharp_array_new_copy(out godot_array r_dest, in godot_array p_src);
- [DllImport(GodotDllName)]
- public static extern godot_variant* godotsharp_array_ptrw(ref godot_array p_self);
+ public static partial godot_variant* godotsharp_array_ptrw(ref godot_array p_self);
// dictionary.h
- [DllImport(GodotDllName)]
- public static extern void godotsharp_dictionary_new(out godot_dictionary r_dest);
+ public static partial void godotsharp_dictionary_new(out godot_dictionary r_dest);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_dictionary_new_copy(out godot_dictionary r_dest,
+ public static partial void godotsharp_dictionary_new_copy(out godot_dictionary r_dest,
in godot_dictionary p_src);
// destroy functions
- [DllImport(GodotDllName)]
- public static extern void godotsharp_packed_byte_array_destroy(ref godot_packed_byte_array p_self);
+ public static partial void godotsharp_packed_byte_array_destroy(ref godot_packed_byte_array p_self);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_packed_int32_array_destroy(ref godot_packed_int32_array p_self);
+ public static partial void godotsharp_packed_int32_array_destroy(ref godot_packed_int32_array p_self);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_packed_int64_array_destroy(ref godot_packed_int64_array p_self);
+ public static partial void godotsharp_packed_int64_array_destroy(ref godot_packed_int64_array p_self);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_packed_float32_array_destroy(ref godot_packed_float32_array p_self);
+ public static partial void godotsharp_packed_float32_array_destroy(ref godot_packed_float32_array p_self);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_packed_float64_array_destroy(ref godot_packed_float64_array p_self);
+ public static partial void godotsharp_packed_float64_array_destroy(ref godot_packed_float64_array p_self);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_packed_string_array_destroy(ref godot_packed_string_array p_self);
+ public static partial void godotsharp_packed_string_array_destroy(ref godot_packed_string_array p_self);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_packed_vector2_array_destroy(ref godot_packed_vector2_array p_self);
+ public static partial void godotsharp_packed_vector2_array_destroy(ref godot_packed_vector2_array p_self);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_packed_vector3_array_destroy(ref godot_packed_vector3_array p_self);
+ public static partial void godotsharp_packed_vector3_array_destroy(ref godot_packed_vector3_array p_self);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_packed_color_array_destroy(ref godot_packed_color_array p_self);
+ public static partial void godotsharp_packed_color_array_destroy(ref godot_packed_color_array p_self);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_variant_destroy(ref godot_variant p_self);
+ public static partial void godotsharp_variant_destroy(ref godot_variant p_self);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_string_destroy(ref godot_string p_self);
+ public static partial void godotsharp_string_destroy(ref godot_string p_self);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_string_name_destroy(ref godot_string_name p_self);
+ public static partial void godotsharp_string_name_destroy(ref godot_string_name p_self);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_node_path_destroy(ref godot_node_path p_self);
+ public static partial void godotsharp_node_path_destroy(ref godot_node_path p_self);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_signal_destroy(ref godot_signal p_self);
+ public static partial void godotsharp_signal_destroy(ref godot_signal p_self);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_callable_destroy(ref godot_callable p_self);
+ public static partial void godotsharp_callable_destroy(ref godot_callable p_self);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_array_destroy(ref godot_array p_self);
+ public static partial void godotsharp_array_destroy(ref godot_array p_self);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_dictionary_destroy(ref godot_dictionary p_self);
+ public static partial void godotsharp_dictionary_destroy(ref godot_dictionary p_self);
// Array
- [DllImport(GodotDllName)]
- public static extern int godotsharp_array_add(ref godot_array p_self, in godot_variant p_item);
+ public static partial int godotsharp_array_add(ref godot_array p_self, in godot_variant p_item);
- [DllImport(GodotDllName)]
- public static extern void
+ public static partial void
godotsharp_array_duplicate(ref godot_array p_self, godot_bool p_deep, out godot_array r_dest);
- [DllImport(GodotDllName)]
- public static extern int godotsharp_array_index_of(ref godot_array p_self, in godot_variant p_item);
+ public static partial int godotsharp_array_index_of(ref godot_array p_self, in godot_variant p_item);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_array_insert(ref godot_array p_self, int p_index, in godot_variant p_item);
+ public static partial void godotsharp_array_insert(ref godot_array p_self, int p_index, in godot_variant p_item);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_array_remove_at(ref godot_array p_self, int p_index);
+ public static partial void godotsharp_array_remove_at(ref godot_array p_self, int p_index);
- [DllImport(GodotDllName)]
- public static extern Error godotsharp_array_resize(ref godot_array p_self, int p_new_size);
+ public static partial Error godotsharp_array_resize(ref godot_array p_self, int p_new_size);
- [DllImport(GodotDllName)]
- public static extern Error godotsharp_array_shuffle(ref godot_array p_self);
+ public static partial Error godotsharp_array_shuffle(ref godot_array p_self);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_array_to_string(ref godot_array p_self, out godot_string r_str);
+ public static partial void godotsharp_array_to_string(ref godot_array p_self, out godot_string r_str);
// Dictionary
- [DllImport(GodotDllName)]
- public static extern godot_bool godotsharp_dictionary_try_get_value(ref godot_dictionary p_self,
+ public static partial godot_bool godotsharp_dictionary_try_get_value(ref godot_dictionary p_self,
in godot_variant p_key,
out godot_variant r_value);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_dictionary_set_value(ref godot_dictionary p_self, in godot_variant p_key,
+ public static partial void godotsharp_dictionary_set_value(ref godot_dictionary p_self, in godot_variant p_key,
in godot_variant p_value);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_dictionary_keys(ref godot_dictionary p_self, out godot_array r_dest);
+ public static partial void godotsharp_dictionary_keys(ref godot_dictionary p_self, out godot_array r_dest);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_dictionary_values(ref godot_dictionary p_self, out godot_array r_dest);
+ public static partial void godotsharp_dictionary_values(ref godot_dictionary p_self, out godot_array r_dest);
- [DllImport(GodotDllName)]
- public static extern int godotsharp_dictionary_count(ref godot_dictionary p_self);
+ public static partial int godotsharp_dictionary_count(ref godot_dictionary p_self);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_dictionary_key_value_pair_at(ref godot_dictionary p_self, int p_index,
+ public static partial void godotsharp_dictionary_key_value_pair_at(ref godot_dictionary p_self, int p_index,
out godot_variant r_key, out godot_variant r_value);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_dictionary_add(ref godot_dictionary p_self, in godot_variant p_key,
+ public static partial void godotsharp_dictionary_add(ref godot_dictionary p_self, in godot_variant p_key,
in godot_variant p_value);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_dictionary_clear(ref godot_dictionary p_self);
+ public static partial void godotsharp_dictionary_clear(ref godot_dictionary p_self);
- [DllImport(GodotDllName)]
- public static extern godot_bool godotsharp_dictionary_contains_key(ref godot_dictionary p_self,
+ public static partial godot_bool godotsharp_dictionary_contains_key(ref godot_dictionary p_self,
in godot_variant p_key);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_dictionary_duplicate(ref godot_dictionary p_self, godot_bool p_deep,
+ public static partial void godotsharp_dictionary_duplicate(ref godot_dictionary p_self, godot_bool p_deep,
out godot_dictionary r_dest);
- [DllImport(GodotDllName)]
- public static extern godot_bool godotsharp_dictionary_remove_key(ref godot_dictionary p_self,
+ public static partial godot_bool godotsharp_dictionary_remove_key(ref godot_dictionary p_self,
in godot_variant p_key);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_dictionary_to_string(ref godot_dictionary p_self, out godot_string r_str);
+ public static partial void godotsharp_dictionary_to_string(ref godot_dictionary p_self, out godot_string r_str);
// StringExtensions
- [DllImport(GodotDllName)]
- public static extern void godotsharp_string_md5_buffer(in godot_string p_self,
+ public static partial void godotsharp_string_md5_buffer(in godot_string p_self,
out godot_packed_byte_array r_md5_buffer);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_string_md5_text(in godot_string p_self, out godot_string r_md5_text);
+ public static partial void godotsharp_string_md5_text(in godot_string p_self, out godot_string r_md5_text);
- [DllImport(GodotDllName)]
- public static extern int godotsharp_string_rfind(in godot_string p_self, in godot_string p_what, int p_from);
+ public static partial int godotsharp_string_rfind(in godot_string p_self, in godot_string p_what, int p_from);
- [DllImport(GodotDllName)]
- public static extern int godotsharp_string_rfindn(in godot_string p_self, in godot_string p_what, int p_from);
+ public static partial int godotsharp_string_rfindn(in godot_string p_self, in godot_string p_what, int p_from);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_string_sha256_buffer(in godot_string p_self,
+ public static partial void godotsharp_string_sha256_buffer(in godot_string p_self,
out godot_packed_byte_array r_sha256_buffer);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_string_sha256_text(in godot_string p_self,
+ public static partial void godotsharp_string_sha256_text(in godot_string p_self,
out godot_string r_sha256_text);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_string_simplify_path(in godot_string p_self,
+ public static partial void godotsharp_string_simplify_path(in godot_string p_self,
out godot_string r_simplified_path);
// NodePath
- [DllImport(GodotDllName)]
- public static extern void godotsharp_node_path_get_as_property_path(in godot_node_path p_self,
+ public static partial void godotsharp_node_path_get_as_property_path(in godot_node_path p_self,
ref godot_node_path r_dest);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_node_path_get_concatenated_names(in godot_node_path p_self,
+ public static partial void godotsharp_node_path_get_concatenated_names(in godot_node_path p_self,
out godot_string r_names);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_node_path_get_concatenated_subnames(in godot_node_path p_self,
+ public static partial void godotsharp_node_path_get_concatenated_subnames(in godot_node_path p_self,
out godot_string r_subnames);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_node_path_get_name(in godot_node_path p_self, int p_idx,
+ public static partial void godotsharp_node_path_get_name(in godot_node_path p_self, int p_idx,
out godot_string r_name);
- [DllImport(GodotDllName)]
- public static extern int godotsharp_node_path_get_name_count(in godot_node_path p_self);
+ public static partial int godotsharp_node_path_get_name_count(in godot_node_path p_self);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_node_path_get_subname(in godot_node_path p_self, int p_idx,
+ public static partial void godotsharp_node_path_get_subname(in godot_node_path p_self, int p_idx,
out godot_string r_subname);
- [DllImport(GodotDllName)]
- public static extern int godotsharp_node_path_get_subname_count(in godot_node_path p_self);
+ public static partial int godotsharp_node_path_get_subname_count(in godot_node_path p_self);
- [DllImport(GodotDllName)]
- public static extern godot_bool godotsharp_node_path_is_absolute(in godot_node_path p_self);
+ public static partial godot_bool godotsharp_node_path_is_absolute(in godot_node_path p_self);
// GD, etc
- [DllImport(GodotDllName)]
- internal static extern void godotsharp_bytes2var(in godot_packed_byte_array p_bytes,
+ internal static partial void godotsharp_bytes2var(in godot_packed_byte_array p_bytes,
godot_bool p_allow_objects,
out godot_variant r_ret);
- [DllImport(GodotDllName)]
- internal static extern void godotsharp_convert(in godot_variant p_what, int p_type,
+ internal static partial void godotsharp_convert(in godot_variant p_what, int p_type,
out godot_variant r_ret);
- [DllImport(GodotDllName)]
- internal static extern int godotsharp_hash(in godot_variant p_var);
+ internal static partial int godotsharp_hash(in godot_variant p_var);
- [DllImport(GodotDllName)]
- internal static extern IntPtr godotsharp_instance_from_id(ulong p_instance_id);
+ internal static partial IntPtr godotsharp_instance_from_id(ulong p_instance_id);
- [DllImport(GodotDllName)]
- internal static extern void godotsharp_print(in godot_string p_what);
+ internal static partial void godotsharp_print(in godot_string p_what);
- [DllImport(GodotDllName)]
- public static extern void godotsharp_print_rich(in godot_string p_what);
+ public static partial void godotsharp_print_rich(in godot_string p_what);
- [DllImport(GodotDllName)]
- internal static extern void godotsharp_printerr(in godot_string p_what);
+ internal static partial void godotsharp_printerr(in godot_string p_what);
- [DllImport(GodotDllName)]
- internal static extern void godotsharp_printraw(in godot_string p_what);
+ internal static partial void godotsharp_printraw(in godot_string p_what);
- [DllImport(GodotDllName)]
- internal static extern void godotsharp_prints(in godot_string p_what);
+ internal static partial void godotsharp_prints(in godot_string p_what);
- [DllImport(GodotDllName)]
- internal static extern void godotsharp_printt(in godot_string p_what);
+ internal static partial void godotsharp_printt(in godot_string p_what);
- [DllImport(GodotDllName)]
- internal static extern float godotsharp_randf();
+ internal static partial float godotsharp_randf();
- [DllImport(GodotDllName)]
- internal static extern uint godotsharp_randi();
+ internal static partial uint godotsharp_randi();
- [DllImport(GodotDllName)]
- internal static extern void godotsharp_randomize();
+ internal static partial void godotsharp_randomize();
- [DllImport(GodotDllName)]
- internal static extern double godotsharp_randf_range(double from, double to);
+ internal static partial double godotsharp_randf_range(double from, double to);
- [DllImport(GodotDllName)]
- internal static extern double godotsharp_randfn(double mean, double deviation);
+ internal static partial double godotsharp_randfn(double mean, double deviation);
- [DllImport(GodotDllName)]
- internal static extern int godotsharp_randi_range(int from, int to);
+ internal static partial int godotsharp_randi_range(int from, int to);
- [DllImport(GodotDllName)]
- internal static extern uint godotsharp_rand_from_seed(ulong seed, out ulong newSeed);
+ internal static partial uint godotsharp_rand_from_seed(ulong seed, out ulong newSeed);
- [DllImport(GodotDllName)]
- internal static extern void godotsharp_seed(ulong seed);
+ internal static partial void godotsharp_seed(ulong seed);
- [DllImport(GodotDllName)]
- internal static extern void godotsharp_weakref(IntPtr p_obj, out godot_ref r_weak_ref);
+ internal static partial void godotsharp_weakref(IntPtr p_obj, out godot_ref r_weak_ref);
- [DllImport(GodotDllName)]
- internal static extern void godotsharp_str(in godot_array p_what, out godot_string r_ret);
+ internal static partial void godotsharp_str(in godot_array p_what, out godot_string r_ret);
- [DllImport(GodotDllName)]
- internal static extern void godotsharp_str2var(in godot_string p_str, out godot_variant r_ret);
+ internal static partial void godotsharp_str2var(in godot_string p_str, out godot_variant r_ret);
- [DllImport(GodotDllName)]
- internal static extern void godotsharp_var2bytes(in godot_variant p_what, godot_bool p_full_objects,
+ internal static partial void godotsharp_var2bytes(in godot_variant p_what, godot_bool p_full_objects,
out godot_packed_byte_array r_bytes);
- [DllImport(GodotDllName)]
- internal static extern void godotsharp_var2str(in godot_variant p_var, out godot_string r_ret);
+ internal static partial void godotsharp_var2str(in godot_variant p_var, out godot_string r_ret);
- [DllImport(GodotDllName)]
- internal static extern void godotsharp_pusherror(in godot_string p_str);
+ internal static partial void godotsharp_pusherror(in godot_string p_str);
- [DllImport(GodotDllName)]
- internal static extern void godotsharp_pushwarning(in godot_string p_str);
+ internal static partial void godotsharp_pushwarning(in godot_string p_str);
// Object
- [DllImport(GodotDllName)]
- public static extern void godotsharp_object_to_string(IntPtr ptr, out godot_string r_str);
+ public static partial void godotsharp_object_to_string(IntPtr ptr, out godot_string r_str);
}
}
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj b/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj
index 7022d96cfc..111920ecf6 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj
+++ b/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj
@@ -41,6 +41,9 @@
<PackageReference Include="ReflectionAnalyzers" Version="0.1.22-dev" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers" />
<!--PackageReference Include="IDisposableAnalyzers" Version="3.4.13" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers" /-->
</ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\Godot.SourceGenerators.Internal\Godot.SourceGenerators.Internal.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
+ </ItemGroup>
<!-- Sources -->
<ItemGroup>
<Compile Include="Core\AABB.cs" />
diff --git a/modules/mono/glue/runtime_interop.cpp b/modules/mono/glue/runtime_interop.cpp
index 751d4b1d23..13d4395a64 100644
--- a/modules/mono/glue/runtime_interop.cpp
+++ b/modules/mono/glue/runtime_interop.cpp
@@ -28,6 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#include "runtime_interop.h"
+
#include "core/config/engine.h"
#include "core/debugger/engine_debugger.h"
#include "core/debugger/script_debugger.h"
@@ -48,30 +50,16 @@
extern "C" {
#endif
-#ifdef __cplusplus
-#define MAYBE_UNUSED [[maybe_unused]]
-#else
-#define MAYBE_UNUSED
-#endif
-
-#ifdef __GNUC__
-#define GD_PINVOKE_EXPORT MAYBE_UNUSED __attribute__((visibility("default")))
-#elif defined(_WIN32)
-#define GD_PINVOKE_EXPORT MAYBE_UNUSED __declspec(dllexport)
-#else
-#define GD_PINVOKE_EXPORT MAYBE_UNUSED
-#endif
-
// For ArrayPrivate and DictionaryPrivate
static_assert(sizeof(SafeRefCount) == sizeof(uint32_t));
typedef Object *(*godotsharp_class_creation_func)();
-GD_PINVOKE_EXPORT MethodBind *godotsharp_method_bind_get_method(const StringName *p_classname, const StringName *p_methodname) {
+MethodBind *godotsharp_method_bind_get_method(const StringName *p_classname, const StringName *p_methodname) {
return ClassDB::get_method(*p_classname, *p_methodname);
}
-GD_PINVOKE_EXPORT godotsharp_class_creation_func godotsharp_get_class_constructor(const StringName *p_classname) {
+godotsharp_class_creation_func godotsharp_get_class_constructor(const StringName *p_classname) {
ClassDB::ClassInfo *class_info = ClassDB::classes.getptr(*p_classname);
if (class_info) {
return class_info->creation_func;
@@ -79,32 +67,32 @@ GD_PINVOKE_EXPORT godotsharp_class_creation_func godotsharp_get_class_constructo
return nullptr;
}
-GD_PINVOKE_EXPORT Object *godotsharp_engine_get_singleton(const String *p_name) {
+Object *godotsharp_engine_get_singleton(const String *p_name) {
return Engine::get_singleton()->get_singleton_object(*p_name);
}
-GD_PINVOKE_EXPORT int32_t godotsharp_stack_info_vector_resize(
+int32_t godotsharp_stack_info_vector_resize(
Vector<ScriptLanguage::StackInfo> *p_stack_info_vector, int p_size) {
return (int32_t)p_stack_info_vector->resize(p_size);
}
-GD_PINVOKE_EXPORT void godotsharp_stack_info_vector_destroy(
+void godotsharp_stack_info_vector_destroy(
Vector<ScriptLanguage::StackInfo> *p_stack_info_vector) {
p_stack_info_vector->~Vector();
}
-GD_PINVOKE_EXPORT void godotsharp_internal_script_debugger_send_error(const String *p_func,
+void godotsharp_internal_script_debugger_send_error(const String *p_func,
const String *p_file, int32_t p_line, const String *p_err, const String *p_descr,
bool p_warning, const Vector<ScriptLanguage::StackInfo> *p_stack_info_vector) {
EngineDebugger::get_script_debugger()->send_error(*p_func, *p_file, p_line, *p_err, *p_descr,
true, p_warning ? ERR_HANDLER_WARNING : ERR_HANDLER_ERROR, *p_stack_info_vector);
}
-GD_PINVOKE_EXPORT bool godotsharp_internal_script_debugger_is_active() {
+bool godotsharp_internal_script_debugger_is_active() {
return EngineDebugger::is_active();
}
-GD_PINVOKE_EXPORT GCHandleIntPtr godotsharp_internal_object_get_associated_gchandle(Object *p_ptr) {
+GCHandleIntPtr godotsharp_internal_object_get_associated_gchandle(Object *p_ptr) {
#ifdef DEBUG_ENABLED
CRASH_COND(p_ptr == nullptr);
#endif
@@ -132,7 +120,7 @@ GD_PINVOKE_EXPORT GCHandleIntPtr godotsharp_internal_object_get_associated_gchan
return { nullptr };
}
-GD_PINVOKE_EXPORT void godotsharp_internal_object_disposed(Object *p_ptr, GCHandleIntPtr p_gchandle_to_free) {
+void godotsharp_internal_object_disposed(Object *p_ptr, GCHandleIntPtr p_gchandle_to_free) {
#ifdef DEBUG_ENABLED
CRASH_COND(p_ptr == nullptr);
#endif
@@ -160,7 +148,7 @@ GD_PINVOKE_EXPORT void godotsharp_internal_object_disposed(Object *p_ptr, GCHand
}
}
-GD_PINVOKE_EXPORT void godotsharp_internal_refcounted_disposed(Object *p_ptr, GCHandleIntPtr p_gchandle_to_free, bool p_is_finalizer) {
+void godotsharp_internal_refcounted_disposed(Object *p_ptr, GCHandleIntPtr p_gchandle_to_free, bool p_is_finalizer) {
#ifdef DEBUG_ENABLED
CRASH_COND(p_ptr == nullptr);
// This is only called with RefCounted derived classes
@@ -208,12 +196,12 @@ GD_PINVOKE_EXPORT void godotsharp_internal_refcounted_disposed(Object *p_ptr, GC
}
}
-GD_PINVOKE_EXPORT int32_t godotsharp_internal_signal_awaiter_connect(Object *p_source, StringName *p_signal, Object *p_target, GCHandleIntPtr p_awaiter_handle_ptr) {
+int32_t godotsharp_internal_signal_awaiter_connect(Object *p_source, StringName *p_signal, Object *p_target, GCHandleIntPtr p_awaiter_handle_ptr) {
StringName signal = p_signal ? *p_signal : StringName();
return (int32_t)gd_mono_connect_signal_awaiter(p_source, signal, p_target, p_awaiter_handle_ptr);
}
-GD_PINVOKE_EXPORT GCHandleIntPtr godotsharp_internal_unmanaged_get_script_instance_managed(Object *p_unmanaged, bool *r_has_cs_script_instance) {
+GCHandleIntPtr godotsharp_internal_unmanaged_get_script_instance_managed(Object *p_unmanaged, bool *r_has_cs_script_instance) {
#ifdef DEBUG_ENABLED
CRASH_COND(!p_unmanaged);
CRASH_COND(!r_has_cs_script_instance);
@@ -232,7 +220,7 @@ GD_PINVOKE_EXPORT GCHandleIntPtr godotsharp_internal_unmanaged_get_script_instan
return { nullptr };
}
-GD_PINVOKE_EXPORT GCHandleIntPtr godotsharp_internal_unmanaged_get_instance_binding_managed(Object *p_unmanaged) {
+GCHandleIntPtr godotsharp_internal_unmanaged_get_instance_binding_managed(Object *p_unmanaged) {
#ifdef DEBUG_ENABLED
CRASH_COND(!p_unmanaged);
#endif
@@ -245,7 +233,7 @@ GD_PINVOKE_EXPORT GCHandleIntPtr godotsharp_internal_unmanaged_get_instance_bind
return script_binding.gchandle.get_intptr();
}
-GD_PINVOKE_EXPORT GCHandleIntPtr godotsharp_internal_unmanaged_instance_binding_create_managed(Object *p_unmanaged, GCHandleIntPtr p_old_gchandle) {
+GCHandleIntPtr godotsharp_internal_unmanaged_instance_binding_create_managed(Object *p_unmanaged, GCHandleIntPtr p_old_gchandle) {
#ifdef DEBUG_ENABLED
CRASH_COND(!p_unmanaged);
#endif
@@ -297,23 +285,23 @@ GD_PINVOKE_EXPORT GCHandleIntPtr godotsharp_internal_unmanaged_instance_binding_
return gchandle.get_intptr();
}
-GD_PINVOKE_EXPORT void godotsharp_internal_tie_native_managed_to_unmanaged(GCHandleIntPtr p_gchandle_intptr, Object *p_unmanaged, const StringName *p_native_name, bool p_ref_counted) {
+void godotsharp_internal_tie_native_managed_to_unmanaged(GCHandleIntPtr p_gchandle_intptr, Object *p_unmanaged, const StringName *p_native_name, bool p_ref_counted) {
CSharpLanguage::tie_native_managed_to_unmanaged(p_gchandle_intptr, p_unmanaged, p_native_name, p_ref_counted);
}
-GD_PINVOKE_EXPORT void godotsharp_internal_tie_user_managed_to_unmanaged(GCHandleIntPtr p_gchandle_intptr, Object *p_unmanaged, Ref<CSharpScript> *p_script, bool p_ref_counted) {
+void godotsharp_internal_tie_user_managed_to_unmanaged(GCHandleIntPtr p_gchandle_intptr, Object *p_unmanaged, Ref<CSharpScript> *p_script, bool p_ref_counted) {
CSharpLanguage::tie_user_managed_to_unmanaged(p_gchandle_intptr, p_unmanaged, p_script, p_ref_counted);
}
-GD_PINVOKE_EXPORT void godotsharp_internal_tie_managed_to_unmanaged_with_pre_setup(GCHandleIntPtr p_gchandle_intptr, Object *p_unmanaged) {
+void godotsharp_internal_tie_managed_to_unmanaged_with_pre_setup(GCHandleIntPtr p_gchandle_intptr, Object *p_unmanaged) {
CSharpLanguage::tie_managed_to_unmanaged_with_pre_setup(p_gchandle_intptr, p_unmanaged);
}
-GD_PINVOKE_EXPORT void godotsharp_internal_new_csharp_script(Ref<CSharpScript> *r_dest) {
+void godotsharp_internal_new_csharp_script(Ref<CSharpScript> *r_dest) {
memnew_placement(r_dest, Ref<CSharpScript>(memnew(CSharpScript)));
}
-GD_PINVOKE_EXPORT bool godotsharp_internal_script_load(const String *p_path, Ref<CSharpScript> *r_dest) {
+bool godotsharp_internal_script_load(const String *p_path, Ref<CSharpScript> *r_dest) {
Ref<Resource> res = ResourceLoader::load(*p_path);
if (res.is_valid()) {
memnew_placement(r_dest, Ref<CSharpScript>(res));
@@ -324,12 +312,12 @@ GD_PINVOKE_EXPORT bool godotsharp_internal_script_load(const String *p_path, Ref
}
}
-GD_PINVOKE_EXPORT void godotsharp_internal_reload_registered_script(CSharpScript *p_script) {
+void godotsharp_internal_reload_registered_script(CSharpScript *p_script) {
CRASH_COND(!p_script);
CSharpScript::reload_registered_script(Ref<CSharpScript>(p_script));
}
-GD_PINVOKE_EXPORT void godotsharp_array_filter_godot_objects_by_native(StringName *p_native_name, const Array *p_input, Array *r_output) {
+void godotsharp_array_filter_godot_objects_by_native(StringName *p_native_name, const Array *p_input, Array *r_output) {
memnew_placement(r_output, Array);
for (int i = 0; i < p_input->size(); ++i) {
@@ -339,7 +327,7 @@ GD_PINVOKE_EXPORT void godotsharp_array_filter_godot_objects_by_native(StringNam
}
}
-GD_PINVOKE_EXPORT void godotsharp_array_filter_godot_objects_by_non_native(const Array *p_input, Array *r_output) {
+void godotsharp_array_filter_godot_objects_by_non_native(const Array *p_input, Array *r_output) {
memnew_placement(r_output, Array);
for (int i = 0; i < p_input->size(); ++i) {
@@ -351,31 +339,31 @@ GD_PINVOKE_EXPORT void godotsharp_array_filter_godot_objects_by_non_native(const
}
}
-GD_PINVOKE_EXPORT void godotsharp_ref_new_from_ref_counted_ptr(Ref<RefCounted> *r_dest, RefCounted *p_ref_counted_ptr) {
+void godotsharp_ref_new_from_ref_counted_ptr(Ref<RefCounted> *r_dest, RefCounted *p_ref_counted_ptr) {
memnew_placement(r_dest, Ref<RefCounted>(p_ref_counted_ptr));
}
-GD_PINVOKE_EXPORT void godotsharp_ref_destroy(Ref<RefCounted> *p_instance) {
+void godotsharp_ref_destroy(Ref<RefCounted> *p_instance) {
p_instance->~Ref();
}
-GD_PINVOKE_EXPORT void godotsharp_string_name_new_from_string(StringName *r_dest, const String *p_name) {
+void godotsharp_string_name_new_from_string(StringName *r_dest, const String *p_name) {
memnew_placement(r_dest, StringName(*p_name));
}
-GD_PINVOKE_EXPORT void godotsharp_node_path_new_from_string(NodePath *r_dest, const String *p_name) {
+void godotsharp_node_path_new_from_string(NodePath *r_dest, const String *p_name) {
memnew_placement(r_dest, NodePath(*p_name));
}
-GD_PINVOKE_EXPORT void godotsharp_string_name_as_string(String *r_dest, const StringName *p_name) {
+void godotsharp_string_name_as_string(String *r_dest, const StringName *p_name) {
memnew_placement(r_dest, String(p_name->operator String()));
}
-GD_PINVOKE_EXPORT void godotsharp_node_path_as_string(String *r_dest, const NodePath *p_np) {
+void godotsharp_node_path_as_string(String *r_dest, const NodePath *p_np) {
memnew_placement(r_dest, String(p_np->operator String()));
}
-GD_PINVOKE_EXPORT godot_packed_array godotsharp_packed_byte_array_new_mem_copy(const uint8_t *p_src, int32_t p_length) {
+godot_packed_array godotsharp_packed_byte_array_new_mem_copy(const uint8_t *p_src, int32_t p_length) {
godot_packed_array ret;
memnew_placement(&ret, PackedByteArray);
PackedByteArray *array = reinterpret_cast<PackedByteArray *>(&ret);
@@ -385,7 +373,7 @@ GD_PINVOKE_EXPORT godot_packed_array godotsharp_packed_byte_array_new_mem_copy(c
return ret;
}
-GD_PINVOKE_EXPORT godot_packed_array godotsharp_packed_int32_array_new_mem_copy(const int32_t *p_src, int32_t p_length) {
+godot_packed_array godotsharp_packed_int32_array_new_mem_copy(const int32_t *p_src, int32_t p_length) {
godot_packed_array ret;
memnew_placement(&ret, PackedInt32Array);
PackedInt32Array *array = reinterpret_cast<PackedInt32Array *>(&ret);
@@ -395,7 +383,7 @@ GD_PINVOKE_EXPORT godot_packed_array godotsharp_packed_int32_array_new_mem_copy(
return ret;
}
-GD_PINVOKE_EXPORT godot_packed_array godotsharp_packed_int64_array_new_mem_copy(const int64_t *p_src, int32_t p_length) {
+godot_packed_array godotsharp_packed_int64_array_new_mem_copy(const int64_t *p_src, int32_t p_length) {
godot_packed_array ret;
memnew_placement(&ret, PackedInt64Array);
PackedInt64Array *array = reinterpret_cast<PackedInt64Array *>(&ret);
@@ -405,7 +393,7 @@ GD_PINVOKE_EXPORT godot_packed_array godotsharp_packed_int64_array_new_mem_copy(
return ret;
}
-GD_PINVOKE_EXPORT godot_packed_array godotsharp_packed_float32_array_new_mem_copy(const float *p_src, int32_t p_length) {
+godot_packed_array godotsharp_packed_float32_array_new_mem_copy(const float *p_src, int32_t p_length) {
godot_packed_array ret;
memnew_placement(&ret, PackedFloat32Array);
PackedFloat32Array *array = reinterpret_cast<PackedFloat32Array *>(&ret);
@@ -415,7 +403,7 @@ GD_PINVOKE_EXPORT godot_packed_array godotsharp_packed_float32_array_new_mem_cop
return ret;
}
-GD_PINVOKE_EXPORT godot_packed_array godotsharp_packed_float64_array_new_mem_copy(const double *p_src, int32_t p_length) {
+godot_packed_array godotsharp_packed_float64_array_new_mem_copy(const double *p_src, int32_t p_length) {
godot_packed_array ret;
memnew_placement(&ret, PackedFloat64Array);
PackedFloat64Array *array = reinterpret_cast<PackedFloat64Array *>(&ret);
@@ -425,7 +413,7 @@ GD_PINVOKE_EXPORT godot_packed_array godotsharp_packed_float64_array_new_mem_cop
return ret;
}
-GD_PINVOKE_EXPORT godot_packed_array godotsharp_packed_vector2_array_new_mem_copy(const Vector2 *p_src, int32_t p_length) {
+godot_packed_array godotsharp_packed_vector2_array_new_mem_copy(const Vector2 *p_src, int32_t p_length) {
godot_packed_array ret;
memnew_placement(&ret, PackedVector2Array);
PackedVector2Array *array = reinterpret_cast<PackedVector2Array *>(&ret);
@@ -435,7 +423,7 @@ GD_PINVOKE_EXPORT godot_packed_array godotsharp_packed_vector2_array_new_mem_cop
return ret;
}
-GD_PINVOKE_EXPORT godot_packed_array godotsharp_packed_vector3_array_new_mem_copy(const Vector3 *p_src, int32_t p_length) {
+godot_packed_array godotsharp_packed_vector3_array_new_mem_copy(const Vector3 *p_src, int32_t p_length) {
godot_packed_array ret;
memnew_placement(&ret, PackedVector3Array);
PackedVector3Array *array = reinterpret_cast<PackedVector3Array *>(&ret);
@@ -445,7 +433,7 @@ GD_PINVOKE_EXPORT godot_packed_array godotsharp_packed_vector3_array_new_mem_cop
return ret;
}
-GD_PINVOKE_EXPORT godot_packed_array godotsharp_packed_color_array_new_mem_copy(const Color *p_src, int32_t p_length) {
+godot_packed_array godotsharp_packed_color_array_new_mem_copy(const Color *p_src, int32_t p_length) {
godot_packed_array ret;
memnew_placement(&ret, PackedColorArray);
PackedColorArray *array = reinterpret_cast<PackedColorArray *>(&ret);
@@ -455,17 +443,17 @@ GD_PINVOKE_EXPORT godot_packed_array godotsharp_packed_color_array_new_mem_copy(
return ret;
}
-GD_PINVOKE_EXPORT void godotsharp_packed_string_array_add(PackedStringArray *r_dest, const String *p_element) {
+void godotsharp_packed_string_array_add(PackedStringArray *r_dest, const String *p_element) {
r_dest->append(*p_element);
}
-GD_PINVOKE_EXPORT void godotsharp_callable_new_with_delegate(GCHandleIntPtr p_delegate_handle, Callable *r_callable) {
+void godotsharp_callable_new_with_delegate(GCHandleIntPtr p_delegate_handle, Callable *r_callable) {
// TODO: Use pooling for ManagedCallable instances.
CallableCustom *managed_callable = memnew(ManagedCallable(p_delegate_handle));
memnew_placement(r_callable, Callable(managed_callable));
}
-GD_PINVOKE_EXPORT bool godotsharp_callable_get_data_for_marshalling(const Callable *p_callable,
+bool godotsharp_callable_get_data_for_marshalling(const Callable *p_callable,
GCHandleIntPtr *r_delegate_handle, Object **r_object, StringName *r_name) {
if (p_callable->is_custom()) {
CallableCustom *custom = p_callable->get_custom();
@@ -504,7 +492,7 @@ GD_PINVOKE_EXPORT bool godotsharp_callable_get_data_for_marshalling(const Callab
}
}
-GD_PINVOKE_EXPORT godot_variant godotsharp_callable_call(Callable *p_callable, const Variant **p_args, const int32_t p_arg_count, Callable::CallError *p_call_error) {
+godot_variant godotsharp_callable_call(Callable *p_callable, const Variant **p_args, const int32_t p_arg_count, Callable::CallError *p_call_error) {
godot_variant ret;
memnew_placement(&ret, Variant);
@@ -515,7 +503,7 @@ GD_PINVOKE_EXPORT godot_variant godotsharp_callable_call(Callable *p_callable, c
return ret;
}
-GD_PINVOKE_EXPORT void godotsharp_callable_call_deferred(Callable *p_callable, const Variant **p_args, const int32_t p_arg_count) {
+void godotsharp_callable_call_deferred(Callable *p_callable, const Variant **p_args, const int32_t p_arg_count) {
p_callable->call_deferredp(p_args, p_arg_count);
}
@@ -523,11 +511,11 @@ GD_PINVOKE_EXPORT void godotsharp_callable_call_deferred(Callable *p_callable, c
// gdnative.h
-GD_PINVOKE_EXPORT void godotsharp_method_bind_ptrcall(MethodBind *p_method_bind, Object *p_instance, const void **p_args, void *p_ret) {
+void godotsharp_method_bind_ptrcall(MethodBind *p_method_bind, Object *p_instance, const void **p_args, void *p_ret) {
p_method_bind->ptrcall(p_instance, p_args, p_ret);
}
-GD_PINVOKE_EXPORT godot_variant godotsharp_method_bind_call(MethodBind *p_method_bind, Object *p_instance, const godot_variant **p_args, const int32_t p_arg_count, Callable::CallError *p_call_error) {
+godot_variant godotsharp_method_bind_call(MethodBind *p_method_bind, Object *p_instance, const godot_variant **p_args, const int32_t p_arg_count, Callable::CallError *p_call_error) {
godot_variant ret;
memnew_placement(&ret, Variant());
@@ -540,488 +528,492 @@ GD_PINVOKE_EXPORT godot_variant godotsharp_method_bind_call(MethodBind *p_method
// variant.h
-GD_PINVOKE_EXPORT void godotsharp_variant_new_copy(godot_variant *r_dest, const Variant *p_src) {
+void godotsharp_variant_new_copy(godot_variant *r_dest, const Variant *p_src) {
memnew_placement(r_dest, Variant(*p_src));
}
-GD_PINVOKE_EXPORT void godotsharp_variant_new_string_name(godot_variant *r_dest, const StringName *p_s) {
+void godotsharp_variant_new_string_name(godot_variant *r_dest, const StringName *p_s) {
memnew_placement(r_dest, Variant(*p_s));
}
-GD_PINVOKE_EXPORT void godotsharp_variant_new_node_path(godot_variant *r_dest, const NodePath *p_np) {
+void godotsharp_variant_new_node_path(godot_variant *r_dest, const NodePath *p_np) {
memnew_placement(r_dest, Variant(*p_np));
}
-GD_PINVOKE_EXPORT void godotsharp_variant_new_object(godot_variant *r_dest, const Object *p_obj) {
+void godotsharp_variant_new_object(godot_variant *r_dest, const Object *p_obj) {
memnew_placement(r_dest, Variant(p_obj));
}
-GD_PINVOKE_EXPORT void godotsharp_variant_new_transform2d(godot_variant *r_dest, const Transform2D *p_t2d) {
+void godotsharp_variant_new_transform2d(godot_variant *r_dest, const Transform2D *p_t2d) {
memnew_placement(r_dest, Variant(*p_t2d));
}
-GD_PINVOKE_EXPORT void godotsharp_variant_new_vector4(godot_variant *r_dest, const Vector4 *p_vec4) {
+void godotsharp_variant_new_vector4(godot_variant *r_dest, const Vector4 *p_vec4) {
memnew_placement(r_dest, Variant(*p_vec4));
}
-GD_PINVOKE_EXPORT void godotsharp_variant_new_vector4i(godot_variant *r_dest, const Vector4i *p_vec4i) {
+void godotsharp_variant_new_vector4i(godot_variant *r_dest, const Vector4i *p_vec4i) {
memnew_placement(r_dest, Variant(*p_vec4i));
}
-GD_PINVOKE_EXPORT void godotsharp_variant_new_basis(godot_variant *r_dest, const Basis *p_basis) {
+void godotsharp_variant_new_basis(godot_variant *r_dest, const Basis *p_basis) {
memnew_placement(r_dest, Variant(*p_basis));
}
-GD_PINVOKE_EXPORT void godotsharp_variant_new_transform3d(godot_variant *r_dest, const Transform3D *p_trans) {
+void godotsharp_variant_new_transform3d(godot_variant *r_dest, const Transform3D *p_trans) {
memnew_placement(r_dest, Variant(*p_trans));
}
-GD_PINVOKE_EXPORT void godotsharp_variant_new_projection(godot_variant *r_dest, const Projection *p_proj) {
+void godotsharp_variant_new_projection(godot_variant *r_dest, const Projection *p_proj) {
memnew_placement(r_dest, Variant(*p_proj));
}
-GD_PINVOKE_EXPORT void godotsharp_variant_new_aabb(godot_variant *r_dest, const AABB *p_aabb) {
+void godotsharp_variant_new_aabb(godot_variant *r_dest, const AABB *p_aabb) {
memnew_placement(r_dest, Variant(*p_aabb));
}
-GD_PINVOKE_EXPORT void godotsharp_variant_new_dictionary(godot_variant *r_dest, const Dictionary *p_dict) {
+void godotsharp_variant_new_dictionary(godot_variant *r_dest, const Dictionary *p_dict) {
memnew_placement(r_dest, Variant(*p_dict));
}
-GD_PINVOKE_EXPORT void godotsharp_variant_new_array(godot_variant *r_dest, const Array *p_arr) {
+void godotsharp_variant_new_array(godot_variant *r_dest, const Array *p_arr) {
memnew_placement(r_dest, Variant(*p_arr));
}
-GD_PINVOKE_EXPORT void godotsharp_variant_new_packed_byte_array(godot_variant *r_dest, const PackedByteArray *p_pba) {
+void godotsharp_variant_new_packed_byte_array(godot_variant *r_dest, const PackedByteArray *p_pba) {
memnew_placement(r_dest, Variant(*p_pba));
}
-GD_PINVOKE_EXPORT void godotsharp_variant_new_packed_int32_array(godot_variant *r_dest, const PackedInt32Array *p_pia) {
+void godotsharp_variant_new_packed_int32_array(godot_variant *r_dest, const PackedInt32Array *p_pia) {
memnew_placement(r_dest, Variant(*p_pia));
}
-GD_PINVOKE_EXPORT void godotsharp_variant_new_packed_int64_array(godot_variant *r_dest, const PackedInt64Array *p_pia) {
+void godotsharp_variant_new_packed_int64_array(godot_variant *r_dest, const PackedInt64Array *p_pia) {
memnew_placement(r_dest, Variant(*p_pia));
}
-GD_PINVOKE_EXPORT void godotsharp_variant_new_packed_float32_array(godot_variant *r_dest, const PackedFloat32Array *p_pra) {
+void godotsharp_variant_new_packed_float32_array(godot_variant *r_dest, const PackedFloat32Array *p_pra) {
memnew_placement(r_dest, Variant(*p_pra));
}
-GD_PINVOKE_EXPORT void godotsharp_variant_new_packed_float64_array(godot_variant *r_dest, const PackedFloat64Array *p_pra) {
+void godotsharp_variant_new_packed_float64_array(godot_variant *r_dest, const PackedFloat64Array *p_pra) {
memnew_placement(r_dest, Variant(*p_pra));
}
-GD_PINVOKE_EXPORT void godotsharp_variant_new_packed_string_array(godot_variant *r_dest, const PackedStringArray *p_psa) {
+void godotsharp_variant_new_packed_string_array(godot_variant *r_dest, const PackedStringArray *p_psa) {
memnew_placement(r_dest, Variant(*p_psa));
}
-GD_PINVOKE_EXPORT void godotsharp_variant_new_packed_vector2_array(godot_variant *r_dest, const PackedVector2Array *p_pv2a) {
+void godotsharp_variant_new_packed_vector2_array(godot_variant *r_dest, const PackedVector2Array *p_pv2a) {
memnew_placement(r_dest, Variant(*p_pv2a));
}
-GD_PINVOKE_EXPORT void godotsharp_variant_new_packed_vector3_array(godot_variant *r_dest, const PackedVector3Array *p_pv3a) {
+void godotsharp_variant_new_packed_vector3_array(godot_variant *r_dest, const PackedVector3Array *p_pv3a) {
memnew_placement(r_dest, Variant(*p_pv3a));
}
-GD_PINVOKE_EXPORT void godotsharp_variant_new_packed_color_array(godot_variant *r_dest, const PackedColorArray *p_pca) {
+void godotsharp_variant_new_packed_color_array(godot_variant *r_dest, const PackedColorArray *p_pca) {
memnew_placement(r_dest, Variant(*p_pca));
}
-GD_PINVOKE_EXPORT bool godotsharp_variant_as_bool(const Variant *p_self) {
+bool godotsharp_variant_as_bool(const Variant *p_self) {
return p_self->operator bool();
}
-GD_PINVOKE_EXPORT int64_t godotsharp_variant_as_int(const Variant *p_self) {
+int64_t godotsharp_variant_as_int(const Variant *p_self) {
return p_self->operator int64_t();
}
-GD_PINVOKE_EXPORT double godotsharp_variant_as_float(const Variant *p_self) {
+double godotsharp_variant_as_float(const Variant *p_self) {
return p_self->operator double();
}
-GD_PINVOKE_EXPORT godot_string godotsharp_variant_as_string(const Variant *p_self) {
+godot_string godotsharp_variant_as_string(const Variant *p_self) {
godot_string raw_dest;
String *dest = (String *)&raw_dest;
memnew_placement(dest, String(p_self->operator String()));
return raw_dest;
}
-GD_PINVOKE_EXPORT godot_vector2 godotsharp_variant_as_vector2(const Variant *p_self) {
+godot_vector2 godotsharp_variant_as_vector2(const Variant *p_self) {
godot_vector2 raw_dest;
Vector2 *dest = (Vector2 *)&raw_dest;
memnew_placement(dest, Vector2(p_self->operator Vector2()));
return raw_dest;
}
-GD_PINVOKE_EXPORT godot_vector2i godotsharp_variant_as_vector2i(const Variant *p_self) {
+godot_vector2i godotsharp_variant_as_vector2i(const Variant *p_self) {
godot_vector2i raw_dest;
Vector2i *dest = (Vector2i *)&raw_dest;
memnew_placement(dest, Vector2i(p_self->operator Vector2i()));
return raw_dest;
}
-GD_PINVOKE_EXPORT godot_rect2 godotsharp_variant_as_rect2(const Variant *p_self) {
+godot_rect2 godotsharp_variant_as_rect2(const Variant *p_self) {
godot_rect2 raw_dest;
Rect2 *dest = (Rect2 *)&raw_dest;
memnew_placement(dest, Rect2(p_self->operator Rect2()));
return raw_dest;
}
-GD_PINVOKE_EXPORT godot_rect2i godotsharp_variant_as_rect2i(const Variant *p_self) {
+godot_rect2i godotsharp_variant_as_rect2i(const Variant *p_self) {
godot_rect2i raw_dest;
Rect2i *dest = (Rect2i *)&raw_dest;
memnew_placement(dest, Rect2i(p_self->operator Rect2i()));
return raw_dest;
}
-GD_PINVOKE_EXPORT godot_vector3 godotsharp_variant_as_vector3(const Variant *p_self) {
+godot_vector3 godotsharp_variant_as_vector3(const Variant *p_self) {
godot_vector3 raw_dest;
Vector3 *dest = (Vector3 *)&raw_dest;
memnew_placement(dest, Vector3(p_self->operator Vector3()));
return raw_dest;
}
-GD_PINVOKE_EXPORT godot_vector3i godotsharp_variant_as_vector3i(const Variant *p_self) {
+godot_vector3i godotsharp_variant_as_vector3i(const Variant *p_self) {
godot_vector3i raw_dest;
Vector3i *dest = (Vector3i *)&raw_dest;
memnew_placement(dest, Vector3i(p_self->operator Vector3i()));
return raw_dest;
}
-GD_PINVOKE_EXPORT godot_transform2d godotsharp_variant_as_transform2d(const Variant *p_self) {
+godot_transform2d godotsharp_variant_as_transform2d(const Variant *p_self) {
godot_transform2d raw_dest;
Transform2D *dest = (Transform2D *)&raw_dest;
memnew_placement(dest, Transform2D(p_self->operator Transform2D()));
return raw_dest;
}
-GD_PINVOKE_EXPORT godot_vector4 godotsharp_variant_as_vector4(const Variant *p_self) {
+godot_vector4 godotsharp_variant_as_vector4(const Variant *p_self) {
godot_vector4 raw_dest;
Vector4 *dest = (Vector4 *)&raw_dest;
memnew_placement(dest, Vector4(p_self->operator Vector4()));
return raw_dest;
}
-GD_PINVOKE_EXPORT godot_vector4i godotsharp_variant_as_vector4i(const Variant *p_self) {
+godot_vector4i godotsharp_variant_as_vector4i(const Variant *p_self) {
godot_vector4i raw_dest;
Vector4i *dest = (Vector4i *)&raw_dest;
memnew_placement(dest, Vector4i(p_self->operator Vector4i()));
return raw_dest;
}
-GD_PINVOKE_EXPORT godot_plane godotsharp_variant_as_plane(const Variant *p_self) {
+godot_plane godotsharp_variant_as_plane(const Variant *p_self) {
godot_plane raw_dest;
Plane *dest = (Plane *)&raw_dest;
memnew_placement(dest, Plane(p_self->operator Plane()));
return raw_dest;
}
-GD_PINVOKE_EXPORT godot_quaternion godotsharp_variant_as_quaternion(const Variant *p_self) {
+godot_quaternion godotsharp_variant_as_quaternion(const Variant *p_self) {
godot_quaternion raw_dest;
Quaternion *dest = (Quaternion *)&raw_dest;
memnew_placement(dest, Quaternion(p_self->operator Quaternion()));
return raw_dest;
}
-GD_PINVOKE_EXPORT godot_aabb godotsharp_variant_as_aabb(const Variant *p_self) {
+godot_aabb godotsharp_variant_as_aabb(const Variant *p_self) {
godot_aabb raw_dest;
AABB *dest = (AABB *)&raw_dest;
memnew_placement(dest, AABB(p_self->operator ::AABB()));
return raw_dest;
}
-GD_PINVOKE_EXPORT godot_basis godotsharp_variant_as_basis(const Variant *p_self) {
+godot_basis godotsharp_variant_as_basis(const Variant *p_self) {
godot_basis raw_dest;
Basis *dest = (Basis *)&raw_dest;
memnew_placement(dest, Basis(p_self->operator Basis()));
return raw_dest;
}
-GD_PINVOKE_EXPORT godot_transform3d godotsharp_variant_as_transform3d(const Variant *p_self) {
+godot_transform3d godotsharp_variant_as_transform3d(const Variant *p_self) {
godot_transform3d raw_dest;
Transform3D *dest = (Transform3D *)&raw_dest;
memnew_placement(dest, Transform3D(p_self->operator Transform3D()));
return raw_dest;
}
-GD_PINVOKE_EXPORT godot_projection godotsharp_variant_as_projection(const Variant *p_self) {
+godot_projection godotsharp_variant_as_projection(const Variant *p_self) {
godot_projection raw_dest;
Projection *dest = (Projection *)&raw_dest;
memnew_placement(dest, Projection(p_self->operator Projection()));
return raw_dest;
}
-GD_PINVOKE_EXPORT godot_color godotsharp_variant_as_color(const Variant *p_self) {
+godot_color godotsharp_variant_as_color(const Variant *p_self) {
godot_color raw_dest;
Color *dest = (Color *)&raw_dest;
memnew_placement(dest, Color(p_self->operator Color()));
return raw_dest;
}
-GD_PINVOKE_EXPORT godot_string_name godotsharp_variant_as_string_name(const Variant *p_self) {
+godot_string_name godotsharp_variant_as_string_name(const Variant *p_self) {
godot_string_name raw_dest;
StringName *dest = (StringName *)&raw_dest;
memnew_placement(dest, StringName(p_self->operator StringName()));
return raw_dest;
}
-GD_PINVOKE_EXPORT godot_node_path godotsharp_variant_as_node_path(const Variant *p_self) {
+godot_node_path godotsharp_variant_as_node_path(const Variant *p_self) {
godot_node_path raw_dest;
NodePath *dest = (NodePath *)&raw_dest;
memnew_placement(dest, NodePath(p_self->operator NodePath()));
return raw_dest;
}
-GD_PINVOKE_EXPORT godot_rid godotsharp_variant_as_rid(const Variant *p_self) {
+godot_rid godotsharp_variant_as_rid(const Variant *p_self) {
godot_rid raw_dest;
RID *dest = (RID *)&raw_dest;
memnew_placement(dest, RID(p_self->operator ::RID()));
return raw_dest;
}
-GD_PINVOKE_EXPORT godot_callable godotsharp_variant_as_callable(const Variant *p_self) {
+godot_callable godotsharp_variant_as_callable(const Variant *p_self) {
godot_callable raw_dest;
Callable *dest = (Callable *)&raw_dest;
memnew_placement(dest, Callable(p_self->operator Callable()));
return raw_dest;
}
-GD_PINVOKE_EXPORT godot_signal godotsharp_variant_as_signal(const Variant *p_self) {
+godot_signal godotsharp_variant_as_signal(const Variant *p_self) {
godot_signal raw_dest;
Signal *dest = (Signal *)&raw_dest;
memnew_placement(dest, Signal(p_self->operator Signal()));
return raw_dest;
}
-GD_PINVOKE_EXPORT godot_dictionary godotsharp_variant_as_dictionary(const Variant *p_self) {
+godot_dictionary godotsharp_variant_as_dictionary(const Variant *p_self) {
godot_dictionary raw_dest;
Dictionary *dest = (Dictionary *)&raw_dest;
memnew_placement(dest, Dictionary(p_self->operator Dictionary()));
return raw_dest;
}
-GD_PINVOKE_EXPORT godot_array godotsharp_variant_as_array(const Variant *p_self) {
+godot_array godotsharp_variant_as_array(const Variant *p_self) {
godot_array raw_dest;
Array *dest = (Array *)&raw_dest;
memnew_placement(dest, Array(p_self->operator Array()));
return raw_dest;
}
-GD_PINVOKE_EXPORT godot_packed_array godotsharp_variant_as_packed_byte_array(const Variant *p_self) {
+godot_packed_array godotsharp_variant_as_packed_byte_array(const Variant *p_self) {
godot_packed_array raw_dest;
PackedByteArray *dest = (PackedByteArray *)&raw_dest;
memnew_placement(dest, PackedByteArray(p_self->operator PackedByteArray()));
return raw_dest;
}
-GD_PINVOKE_EXPORT godot_packed_array godotsharp_variant_as_packed_int32_array(const Variant *p_self) {
+godot_packed_array godotsharp_variant_as_packed_int32_array(const Variant *p_self) {
godot_packed_array raw_dest;
PackedInt32Array *dest = (PackedInt32Array *)&raw_dest;
memnew_placement(dest, PackedInt32Array(p_self->operator PackedInt32Array()));
return raw_dest;
}
-GD_PINVOKE_EXPORT godot_packed_array godotsharp_variant_as_packed_int64_array(const Variant *p_self) {
+godot_packed_array godotsharp_variant_as_packed_int64_array(const Variant *p_self) {
godot_packed_array raw_dest;
PackedInt64Array *dest = (PackedInt64Array *)&raw_dest;
memnew_placement(dest, PackedInt64Array(p_self->operator PackedInt64Array()));
return raw_dest;
}
-GD_PINVOKE_EXPORT godot_packed_array godotsharp_variant_as_packed_float32_array(const Variant *p_self) {
+godot_packed_array godotsharp_variant_as_packed_float32_array(const Variant *p_self) {
godot_packed_array raw_dest;
PackedFloat32Array *dest = (PackedFloat32Array *)&raw_dest;
memnew_placement(dest, PackedFloat32Array(p_self->operator PackedFloat32Array()));
return raw_dest;
}
-GD_PINVOKE_EXPORT godot_packed_array godotsharp_variant_as_packed_float64_array(const Variant *p_self) {
+godot_packed_array godotsharp_variant_as_packed_float64_array(const Variant *p_self) {
godot_packed_array raw_dest;
PackedFloat64Array *dest = (PackedFloat64Array *)&raw_dest;
memnew_placement(dest, PackedFloat64Array(p_self->operator PackedFloat64Array()));
return raw_dest;
}
-GD_PINVOKE_EXPORT godot_packed_array godotsharp_variant_as_packed_string_array(const Variant *p_self) {
+godot_packed_array godotsharp_variant_as_packed_string_array(const Variant *p_self) {
godot_packed_array raw_dest;
PackedStringArray *dest = (PackedStringArray *)&raw_dest;
memnew_placement(dest, PackedStringArray(p_self->operator PackedStringArray()));
return raw_dest;
}
-GD_PINVOKE_EXPORT godot_packed_array godotsharp_variant_as_packed_vector2_array(const Variant *p_self) {
+godot_packed_array godotsharp_variant_as_packed_vector2_array(const Variant *p_self) {
godot_packed_array raw_dest;
PackedVector2Array *dest = (PackedVector2Array *)&raw_dest;
memnew_placement(dest, PackedVector2Array(p_self->operator PackedVector2Array()));
return raw_dest;
}
-GD_PINVOKE_EXPORT godot_packed_array godotsharp_variant_as_packed_vector3_array(const Variant *p_self) {
+godot_packed_array godotsharp_variant_as_packed_vector3_array(const Variant *p_self) {
godot_packed_array raw_dest;
PackedVector3Array *dest = (PackedVector3Array *)&raw_dest;
memnew_placement(dest, PackedVector3Array(p_self->operator PackedVector3Array()));
return raw_dest;
}
-GD_PINVOKE_EXPORT godot_packed_array godotsharp_variant_as_packed_color_array(const Variant *p_self) {
+godot_packed_array godotsharp_variant_as_packed_color_array(const Variant *p_self) {
godot_packed_array raw_dest;
PackedColorArray *dest = (PackedColorArray *)&raw_dest;
memnew_placement(dest, PackedColorArray(p_self->operator PackedColorArray()));
return raw_dest;
}
-GD_PINVOKE_EXPORT bool godotsharp_variant_equals(const godot_variant *p_a, const godot_variant *p_b) {
+bool godotsharp_variant_equals(const godot_variant *p_a, const godot_variant *p_b) {
return *reinterpret_cast<const Variant *>(p_a) == *reinterpret_cast<const Variant *>(p_b);
}
// string.h
-GD_PINVOKE_EXPORT void godotsharp_string_new_with_utf16_chars(String *r_dest, const char16_t *p_contents) {
+void godotsharp_string_new_with_utf16_chars(String *r_dest, const char16_t *p_contents) {
memnew_placement(r_dest, String());
r_dest->parse_utf16(p_contents);
}
// string_name.h
-GD_PINVOKE_EXPORT void godotsharp_string_name_new_copy(StringName *r_dest, const StringName *p_src) {
+void godotsharp_string_name_new_copy(StringName *r_dest, const StringName *p_src) {
memnew_placement(r_dest, StringName(*p_src));
}
// node_path.h
-GD_PINVOKE_EXPORT void godotsharp_node_path_new_copy(NodePath *r_dest, const NodePath *p_src) {
+void godotsharp_node_path_new_copy(NodePath *r_dest, const NodePath *p_src) {
memnew_placement(r_dest, NodePath(*p_src));
}
// array.h
-GD_PINVOKE_EXPORT void godotsharp_array_new(Array *r_dest) {
+void godotsharp_array_new(Array *r_dest) {
memnew_placement(r_dest, Array);
}
-GD_PINVOKE_EXPORT void godotsharp_array_new_copy(Array *r_dest, const Array *p_src) {
+void godotsharp_array_new_copy(Array *r_dest, const Array *p_src) {
memnew_placement(r_dest, Array(*p_src));
}
-GD_PINVOKE_EXPORT godot_variant *godotsharp_array_ptrw(godot_array *p_self) {
+godot_variant *godotsharp_array_ptrw(godot_array *p_self) {
return reinterpret_cast<godot_variant *>(&reinterpret_cast<Array *>(p_self)->operator[](0));
}
// dictionary.h
-GD_PINVOKE_EXPORT void godotsharp_dictionary_new(Dictionary *r_dest) {
+void godotsharp_dictionary_new(Dictionary *r_dest) {
memnew_placement(r_dest, Dictionary);
}
-GD_PINVOKE_EXPORT void godotsharp_dictionary_new_copy(Dictionary *r_dest, const Dictionary *p_src) {
+void godotsharp_dictionary_new_copy(Dictionary *r_dest, const Dictionary *p_src) {
memnew_placement(r_dest, Dictionary(*p_src));
}
// destroy functions
-GD_PINVOKE_EXPORT void godotsharp_packed_byte_array_destroy(PackedByteArray *p_self) {
+void godotsharp_packed_byte_array_destroy(PackedByteArray *p_self) {
p_self->~PackedByteArray();
}
-GD_PINVOKE_EXPORT void godotsharp_packed_int32_array_destroy(PackedInt32Array *p_self) {
+void godotsharp_packed_int32_array_destroy(PackedInt32Array *p_self) {
p_self->~PackedInt32Array();
}
-GD_PINVOKE_EXPORT void godotsharp_packed_int64_array_destroy(PackedInt64Array *p_self) {
+void godotsharp_packed_int64_array_destroy(PackedInt64Array *p_self) {
p_self->~PackedInt64Array();
}
-GD_PINVOKE_EXPORT void godotsharp_packed_float32_array_destroy(PackedFloat32Array *p_self) {
+void godotsharp_packed_float32_array_destroy(PackedFloat32Array *p_self) {
p_self->~PackedFloat32Array();
}
-GD_PINVOKE_EXPORT void godotsharp_packed_float64_array_destroy(PackedFloat64Array *p_self) {
+void godotsharp_packed_float64_array_destroy(PackedFloat64Array *p_self) {
p_self->~PackedFloat64Array();
}
-GD_PINVOKE_EXPORT void godotsharp_packed_string_array_destroy(PackedStringArray *p_self) {
+void godotsharp_packed_string_array_destroy(PackedStringArray *p_self) {
p_self->~PackedStringArray();
}
-GD_PINVOKE_EXPORT void godotsharp_packed_vector2_array_destroy(PackedVector2Array *p_self) {
+void godotsharp_packed_vector2_array_destroy(PackedVector2Array *p_self) {
p_self->~PackedVector2Array();
}
-GD_PINVOKE_EXPORT void godotsharp_packed_vector3_array_destroy(PackedVector3Array *p_self) {
+void godotsharp_packed_vector3_array_destroy(PackedVector3Array *p_self) {
p_self->~PackedVector3Array();
}
-GD_PINVOKE_EXPORT void godotsharp_packed_color_array_destroy(PackedColorArray *p_self) {
+void godotsharp_packed_color_array_destroy(PackedColorArray *p_self) {
p_self->~PackedColorArray();
}
-GD_PINVOKE_EXPORT void godotsharp_variant_destroy(Variant *p_self) {
+void godotsharp_variant_destroy(Variant *p_self) {
p_self->~Variant();
}
-GD_PINVOKE_EXPORT void godotsharp_string_destroy(String *p_self) {
+void godotsharp_string_destroy(String *p_self) {
p_self->~String();
}
-GD_PINVOKE_EXPORT void godotsharp_string_name_destroy(StringName *p_self) {
+void godotsharp_string_name_destroy(StringName *p_self) {
p_self->~StringName();
}
-GD_PINVOKE_EXPORT void godotsharp_node_path_destroy(NodePath *p_self) {
+void godotsharp_node_path_destroy(NodePath *p_self) {
p_self->~NodePath();
}
-GD_PINVOKE_EXPORT void godotsharp_signal_destroy(Signal *p_self) {
+void godotsharp_signal_destroy(Signal *p_self) {
p_self->~Signal();
}
-GD_PINVOKE_EXPORT void godotsharp_callable_destroy(Callable *p_self) {
+void godotsharp_callable_destroy(Callable *p_self) {
p_self->~Callable();
}
-GD_PINVOKE_EXPORT void godotsharp_array_destroy(Array *p_self) {
+void godotsharp_array_destroy(Array *p_self) {
p_self->~Array();
}
-GD_PINVOKE_EXPORT void godotsharp_dictionary_destroy(Dictionary *p_self) {
+void godotsharp_dictionary_destroy(Dictionary *p_self) {
p_self->~Dictionary();
}
// Array
-GD_PINVOKE_EXPORT int32_t godotsharp_array_add(Array *p_self, const Variant *p_item) {
+int32_t godotsharp_array_add(Array *p_self, const Variant *p_item) {
p_self->append(*p_item);
return p_self->size();
}
-GD_PINVOKE_EXPORT void godotsharp_array_duplicate(const Array *p_self, bool p_deep, Array *r_dest) {
+void godotsharp_array_duplicate(const Array *p_self, bool p_deep, Array *r_dest) {
memnew_placement(r_dest, Array(p_self->duplicate(p_deep)));
}
-GD_PINVOKE_EXPORT int32_t godotsharp_array_index_of(const Array *p_self, const Variant *p_item) {
+int32_t godotsharp_array_index_of(const Array *p_self, const Variant *p_item) {
return p_self->find(*p_item);
}
-GD_PINVOKE_EXPORT void godotsharp_array_insert(Array *p_self, int32_t p_index, const Variant *p_item) {
+void godotsharp_array_insert(Array *p_self, int32_t p_index, const Variant *p_item) {
p_self->insert(p_index, *p_item);
}
-GD_PINVOKE_EXPORT void godotsharp_array_remove_at(Array *p_self, int32_t p_index) {
+void godotsharp_array_remove_at(Array *p_self, int32_t p_index) {
p_self->remove_at(p_index);
}
-GD_PINVOKE_EXPORT int32_t godotsharp_array_resize(Array *p_self, int32_t p_new_size) {
+int32_t godotsharp_array_resize(Array *p_self, int32_t p_new_size) {
return (int32_t)p_self->resize(p_new_size);
}
-GD_PINVOKE_EXPORT void godotsharp_array_shuffle(Array *p_self) {
+void godotsharp_array_shuffle(Array *p_self) {
p_self->shuffle();
}
+void godotsharp_array_to_string(const Array *p_self, String *r_str) {
+ *r_str = Variant(*p_self).operator String();
+}
+
// Dictionary
-GD_PINVOKE_EXPORT bool godotsharp_dictionary_try_get_value(const Dictionary *p_self, const Variant *p_key, Variant *r_value) {
+bool godotsharp_dictionary_try_get_value(const Dictionary *p_self, const Variant *p_key, Variant *r_value) {
const Variant *ret = p_self->getptr(*p_key);
if (ret == nullptr) {
memnew_placement(r_value, Variant());
@@ -1031,142 +1023,146 @@ GD_PINVOKE_EXPORT bool godotsharp_dictionary_try_get_value(const Dictionary *p_s
return true;
}
-GD_PINVOKE_EXPORT void godotsharp_dictionary_set_value(Dictionary *p_self, const Variant *p_key, const Variant *p_value) {
+void godotsharp_dictionary_set_value(Dictionary *p_self, const Variant *p_key, const Variant *p_value) {
p_self->operator[](*p_key) = *p_value;
}
-GD_PINVOKE_EXPORT void godotsharp_dictionary_keys(const Dictionary *p_self, Array *r_dest) {
+void godotsharp_dictionary_keys(const Dictionary *p_self, Array *r_dest) {
memnew_placement(r_dest, Array(p_self->keys()));
}
-GD_PINVOKE_EXPORT void godotsharp_dictionary_values(const Dictionary *p_self, Array *r_dest) {
+void godotsharp_dictionary_values(const Dictionary *p_self, Array *r_dest) {
memnew_placement(r_dest, Array(p_self->values()));
}
-GD_PINVOKE_EXPORT int32_t godotsharp_dictionary_count(const Dictionary *p_self) {
+int32_t godotsharp_dictionary_count(const Dictionary *p_self) {
return p_self->size();
}
-GD_PINVOKE_EXPORT void godotsharp_dictionary_key_value_pair_at(const Dictionary *p_self, int32_t p_index, Variant *r_key, Variant *r_value) {
+void godotsharp_dictionary_key_value_pair_at(const Dictionary *p_self, int32_t p_index, Variant *r_key, Variant *r_value) {
memnew_placement(r_key, Variant(p_self->get_key_at_index(p_index)));
memnew_placement(r_value, Variant(p_self->get_value_at_index(p_index)));
}
-GD_PINVOKE_EXPORT void godotsharp_dictionary_add(Dictionary *p_self, const Variant *p_key, const Variant *p_value) {
+void godotsharp_dictionary_add(Dictionary *p_self, const Variant *p_key, const Variant *p_value) {
p_self->operator[](*p_key) = *p_value;
}
-GD_PINVOKE_EXPORT void godotsharp_dictionary_clear(Dictionary *p_self) {
+void godotsharp_dictionary_clear(Dictionary *p_self) {
p_self->clear();
}
-GD_PINVOKE_EXPORT bool godotsharp_dictionary_contains_key(const Dictionary *p_self, const Variant *p_key) {
+bool godotsharp_dictionary_contains_key(const Dictionary *p_self, const Variant *p_key) {
return p_self->has(*p_key);
}
-GD_PINVOKE_EXPORT void godotsharp_dictionary_duplicate(const Dictionary *p_self, bool p_deep, Dictionary *r_dest) {
+void godotsharp_dictionary_duplicate(const Dictionary *p_self, bool p_deep, Dictionary *r_dest) {
memnew_placement(r_dest, Dictionary(p_self->duplicate(p_deep)));
}
-GD_PINVOKE_EXPORT bool godotsharp_dictionary_remove_key(Dictionary *p_self, const Variant *p_key) {
+bool godotsharp_dictionary_remove_key(Dictionary *p_self, const Variant *p_key) {
return p_self->erase(*p_key);
}
-GD_PINVOKE_EXPORT void godotsharp_string_md5_buffer(const String *p_self, PackedByteArray *r_md5_buffer) {
+void godotsharp_dictionary_to_string(const Dictionary *p_self, String *r_str) {
+ *r_str = Variant(*p_self).operator String();
+}
+
+void godotsharp_string_md5_buffer(const String *p_self, PackedByteArray *r_md5_buffer) {
memnew_placement(r_md5_buffer, PackedByteArray(p_self->md5_buffer()));
}
-GD_PINVOKE_EXPORT void godotsharp_string_md5_text(const String *p_self, String *r_md5_text) {
+void godotsharp_string_md5_text(const String *p_self, String *r_md5_text) {
memnew_placement(r_md5_text, String(p_self->md5_text()));
}
-GD_PINVOKE_EXPORT int32_t godotsharp_string_rfind(const String *p_self, const String *p_what, int32_t p_from) {
+int32_t godotsharp_string_rfind(const String *p_self, const String *p_what, int32_t p_from) {
return p_self->rfind(*p_what, p_from);
}
-GD_PINVOKE_EXPORT int32_t godotsharp_string_rfindn(const String *p_self, const String *p_what, int32_t p_from) {
+int32_t godotsharp_string_rfindn(const String *p_self, const String *p_what, int32_t p_from) {
return p_self->rfindn(*p_what, p_from);
}
-GD_PINVOKE_EXPORT void godotsharp_string_sha256_buffer(const String *p_self, PackedByteArray *r_sha256_buffer) {
+void godotsharp_string_sha256_buffer(const String *p_self, PackedByteArray *r_sha256_buffer) {
memnew_placement(r_sha256_buffer, PackedByteArray(p_self->sha256_buffer()));
}
-GD_PINVOKE_EXPORT void godotsharp_string_sha256_text(const String *p_self, String *r_sha256_text) {
+void godotsharp_string_sha256_text(const String *p_self, String *r_sha256_text) {
memnew_placement(r_sha256_text, String(p_self->sha256_text()));
}
-GD_PINVOKE_EXPORT void godotsharp_string_simplify_path(const String *p_self, String *r_simplified_path) {
+void godotsharp_string_simplify_path(const String *p_self, String *r_simplified_path) {
memnew_placement(r_simplified_path, String(p_self->simplify_path()));
}
-GD_PINVOKE_EXPORT void godotsharp_node_path_get_as_property_path(const NodePath *p_ptr, NodePath *r_dest) {
+void godotsharp_node_path_get_as_property_path(const NodePath *p_ptr, NodePath *r_dest) {
memnew_placement(r_dest, NodePath(p_ptr->get_as_property_path()));
}
-GD_PINVOKE_EXPORT void godotsharp_node_path_get_concatenated_names(const NodePath *p_self, String *r_subnames) {
+void godotsharp_node_path_get_concatenated_names(const NodePath *p_self, String *r_subnames) {
memnew_placement(r_subnames, String(p_self->get_concatenated_names()));
}
-GD_PINVOKE_EXPORT void godotsharp_node_path_get_concatenated_subnames(const NodePath *p_self, String *r_subnames) {
+void godotsharp_node_path_get_concatenated_subnames(const NodePath *p_self, String *r_subnames) {
memnew_placement(r_subnames, String(p_self->get_concatenated_subnames()));
}
-GD_PINVOKE_EXPORT void godotsharp_node_path_get_name(const NodePath *p_self, uint32_t p_idx, String *r_name) {
+void godotsharp_node_path_get_name(const NodePath *p_self, uint32_t p_idx, String *r_name) {
memnew_placement(r_name, String(p_self->get_name(p_idx)));
}
-GD_PINVOKE_EXPORT int32_t godotsharp_node_path_get_name_count(const NodePath *p_self) {
+int32_t godotsharp_node_path_get_name_count(const NodePath *p_self) {
return p_self->get_name_count();
}
-GD_PINVOKE_EXPORT void godotsharp_node_path_get_subname(const NodePath *p_self, uint32_t p_idx, String *r_subname) {
+void godotsharp_node_path_get_subname(const NodePath *p_self, uint32_t p_idx, String *r_subname) {
memnew_placement(r_subname, String(p_self->get_subname(p_idx)));
}
-GD_PINVOKE_EXPORT int32_t godotsharp_node_path_get_subname_count(const NodePath *p_self) {
+int32_t godotsharp_node_path_get_subname_count(const NodePath *p_self) {
return p_self->get_subname_count();
}
-GD_PINVOKE_EXPORT bool godotsharp_node_path_is_absolute(const NodePath *p_self) {
+bool godotsharp_node_path_is_absolute(const NodePath *p_self) {
return p_self->is_absolute();
}
-GD_PINVOKE_EXPORT void godotsharp_randomize() {
+void godotsharp_randomize() {
Math::randomize();
}
-GD_PINVOKE_EXPORT uint32_t godotsharp_randi() {
+uint32_t godotsharp_randi() {
return Math::rand();
}
-GD_PINVOKE_EXPORT float godotsharp_randf() {
+float godotsharp_randf() {
return Math::randf();
}
-GD_PINVOKE_EXPORT int32_t godotsharp_randi_range(int32_t p_from, int32_t p_to) {
+int32_t godotsharp_randi_range(int32_t p_from, int32_t p_to) {
return Math::random(p_from, p_to);
}
-GD_PINVOKE_EXPORT double godotsharp_randf_range(double p_from, double p_to) {
+double godotsharp_randf_range(double p_from, double p_to) {
return Math::random(p_from, p_to);
}
-GD_PINVOKE_EXPORT double godotsharp_randfn(double p_mean, double p_deviation) {
+double godotsharp_randfn(double p_mean, double p_deviation) {
return Math::randfn(p_mean, p_deviation);
}
-GD_PINVOKE_EXPORT void godotsharp_seed(uint64_t p_seed) {
+void godotsharp_seed(uint64_t p_seed) {
Math::seed(p_seed);
}
-GD_PINVOKE_EXPORT uint32_t godotsharp_rand_from_seed(uint64_t p_seed, uint64_t *r_new_seed) {
+uint32_t godotsharp_rand_from_seed(uint64_t p_seed, uint64_t *r_new_seed) {
uint32_t ret = Math::rand_from_seed(&p_seed);
*r_new_seed = p_seed;
return ret;
}
-GD_PINVOKE_EXPORT void godotsharp_weakref(Object *p_ptr, Ref<RefCounted> *r_weak_ref) {
+void godotsharp_weakref(Object *p_ptr, Ref<RefCounted> *r_weak_ref) {
if (!p_ptr) {
return;
}
@@ -1190,7 +1186,7 @@ GD_PINVOKE_EXPORT void godotsharp_weakref(Object *p_ptr, Ref<RefCounted> *r_weak
memnew_placement(r_weak_ref, Ref<RefCounted>(wref));
}
-GD_PINVOKE_EXPORT void godotsharp_str(const godot_array *p_what, godot_string *r_ret) {
+void godotsharp_str(const godot_array *p_what, godot_string *r_ret) {
String &str = *memnew_placement(r_ret, String);
const Array &what = *reinterpret_cast<const Array *>(p_what);
@@ -1205,45 +1201,45 @@ GD_PINVOKE_EXPORT void godotsharp_str(const godot_array *p_what, godot_string *r
}
}
-GD_PINVOKE_EXPORT void godotsharp_print(const godot_string *p_what) {
+void godotsharp_print(const godot_string *p_what) {
print_line(*reinterpret_cast<const String *>(p_what));
}
-GD_PINVOKE_EXPORT void godotsharp_print_rich(const godot_string *p_what) {
+void godotsharp_print_rich(const godot_string *p_what) {
print_line_rich(*reinterpret_cast<const String *>(p_what));
}
-GD_PINVOKE_EXPORT void godotsharp_printerr(const godot_string *p_what) {
+void godotsharp_printerr(const godot_string *p_what) {
print_error(*reinterpret_cast<const String *>(p_what));
}
-GD_PINVOKE_EXPORT void godotsharp_printt(const godot_string *p_what) {
+void godotsharp_printt(const godot_string *p_what) {
print_line(*reinterpret_cast<const String *>(p_what));
}
-GD_PINVOKE_EXPORT void godotsharp_prints(const godot_string *p_what) {
+void godotsharp_prints(const godot_string *p_what) {
print_line(*reinterpret_cast<const String *>(p_what));
}
-GD_PINVOKE_EXPORT void godotsharp_printraw(const godot_string *p_what) {
+void godotsharp_printraw(const godot_string *p_what) {
OS::get_singleton()->print("%s", reinterpret_cast<const String *>(p_what)->utf8().get_data());
}
-GD_PINVOKE_EXPORT void godotsharp_pusherror(const godot_string *p_str) {
+void godotsharp_pusherror(const godot_string *p_str) {
ERR_PRINT(*reinterpret_cast<const String *>(p_str));
}
-GD_PINVOKE_EXPORT void godotsharp_pushwarning(const godot_string *p_str) {
+void godotsharp_pushwarning(const godot_string *p_str) {
WARN_PRINT(*reinterpret_cast<const String *>(p_str));
}
-GD_PINVOKE_EXPORT void godotsharp_var2str(const godot_variant *p_var, godot_string *r_ret) {
+void godotsharp_var2str(const godot_variant *p_var, godot_string *r_ret) {
const Variant &var = *reinterpret_cast<const Variant *>(p_var);
String &vars = *memnew_placement(r_ret, String);
VariantWriter::write_to_string(var, vars);
}
-GD_PINVOKE_EXPORT void godotsharp_str2var(const godot_string *p_str, godot_variant *r_ret) {
+void godotsharp_str2var(const godot_string *p_str, godot_variant *r_ret) {
Variant ret;
VariantParser::StreamString ss;
@@ -1260,7 +1256,7 @@ GD_PINVOKE_EXPORT void godotsharp_str2var(const godot_string *p_str, godot_varia
memnew_placement(r_ret, Variant(ret));
}
-GD_PINVOKE_EXPORT void godotsharp_var2bytes(const godot_variant *p_var, bool p_full_objects, godot_packed_array *r_bytes) {
+void godotsharp_var2bytes(const godot_variant *p_var, bool p_full_objects, godot_packed_array *r_bytes) {
const Variant &var = *reinterpret_cast<const Variant *>(p_var);
PackedByteArray &bytes = *memnew_placement(r_bytes, PackedByteArray);
@@ -1272,7 +1268,7 @@ GD_PINVOKE_EXPORT void godotsharp_var2bytes(const godot_variant *p_var, bool p_f
encode_variant(var, bytes.ptrw(), len, p_full_objects);
}
-GD_PINVOKE_EXPORT void godotsharp_bytes2var(const godot_packed_array *p_bytes, bool p_allow_objects, godot_variant *r_ret) {
+void godotsharp_bytes2var(const godot_packed_array *p_bytes, bool p_allow_objects, godot_variant *r_ret) {
const PackedByteArray *bytes = reinterpret_cast<const PackedByteArray *>(p_bytes);
Variant ret;
Error err = decode_variant(ret, bytes->ptr(), bytes->size(), nullptr, p_allow_objects);
@@ -1282,11 +1278,11 @@ GD_PINVOKE_EXPORT void godotsharp_bytes2var(const godot_packed_array *p_bytes, b
memnew_placement(r_ret, Variant(ret));
}
-GD_PINVOKE_EXPORT int godotsharp_hash(const godot_variant *p_var) {
+int godotsharp_hash(const godot_variant *p_var) {
return reinterpret_cast<const Variant *>(p_var)->hash();
}
-GD_PINVOKE_EXPORT void godotsharp_convert(const godot_variant *p_what, int32_t p_type, godot_variant *r_ret) {
+void godotsharp_convert(const godot_variant *p_what, int32_t p_type, godot_variant *r_ret) {
const Variant *args[1] = { reinterpret_cast<const Variant *>(p_what) };
Callable::CallError ce;
Variant ret;
@@ -1300,11 +1296,11 @@ GD_PINVOKE_EXPORT void godotsharp_convert(const godot_variant *p_what, int32_t p
memnew_placement(r_ret, Variant(ret));
}
-GD_PINVOKE_EXPORT Object *godotsharp_instance_from_id(uint64_t p_instance_id) {
+Object *godotsharp_instance_from_id(uint64_t p_instance_id) {
return ObjectDB::get_instance(ObjectID(p_instance_id));
}
-GD_PINVOKE_EXPORT void godotsharp_object_to_string(Object *p_ptr, godot_string *r_str) {
+void godotsharp_object_to_string(Object *p_ptr, godot_string *r_str) {
#ifdef DEBUG_ENABLED
// Cannot happen in C#; would get an ObjectDisposedException instead.
CRASH_COND(p_ptr == nullptr);
@@ -1318,8 +1314,9 @@ GD_PINVOKE_EXPORT void godotsharp_object_to_string(Object *p_ptr, godot_string *
}
#endif
-// We need this to prevent the functions from being stripped.
-void *godotsharp_pinvoke_funcs[186] = {
+// The order in this array must match the declaration order of
+// the methods in 'GodotSharp/Core/NativeInterop/NativeFuncs.cs'.
+static const void *unmanaged_callbacks[]{
(void *)godotsharp_method_bind_get_method,
(void *)godotsharp_get_class_constructor,
(void *)godotsharp_engine_get_singleton,
@@ -1331,12 +1328,12 @@ void *godotsharp_pinvoke_funcs[186] = {
(void *)godotsharp_internal_object_disposed,
(void *)godotsharp_internal_refcounted_disposed,
(void *)godotsharp_internal_signal_awaiter_connect,
- (void *)godotsharp_internal_unmanaged_get_script_instance_managed,
- (void *)godotsharp_internal_unmanaged_get_instance_binding_managed,
- (void *)godotsharp_internal_unmanaged_instance_binding_create_managed,
(void *)godotsharp_internal_tie_native_managed_to_unmanaged,
(void *)godotsharp_internal_tie_user_managed_to_unmanaged,
(void *)godotsharp_internal_tie_managed_to_unmanaged_with_pre_setup,
+ (void *)godotsharp_internal_unmanaged_get_script_instance_managed,
+ (void *)godotsharp_internal_unmanaged_get_instance_binding_managed,
+ (void *)godotsharp_internal_unmanaged_instance_binding_create_managed,
(void *)godotsharp_internal_new_csharp_script,
(void *)godotsharp_internal_script_load,
(void *)godotsharp_internal_reload_registered_script,
@@ -1363,8 +1360,8 @@ void *godotsharp_pinvoke_funcs[186] = {
(void *)godotsharp_callable_call_deferred,
(void *)godotsharp_method_bind_ptrcall,
(void *)godotsharp_method_bind_call,
- (void *)godotsharp_variant_new_copy,
(void *)godotsharp_variant_new_string_name,
+ (void *)godotsharp_variant_new_copy,
(void *)godotsharp_variant_new_node_path,
(void *)godotsharp_variant_new_object,
(void *)godotsharp_variant_new_transform2d,
@@ -1454,6 +1451,7 @@ void *godotsharp_pinvoke_funcs[186] = {
(void *)godotsharp_array_remove_at,
(void *)godotsharp_array_resize,
(void *)godotsharp_array_shuffle,
+ (void *)godotsharp_array_to_string,
(void *)godotsharp_dictionary_try_get_value,
(void *)godotsharp_dictionary_set_value,
(void *)godotsharp_dictionary_keys,
@@ -1465,6 +1463,7 @@ void *godotsharp_pinvoke_funcs[186] = {
(void *)godotsharp_dictionary_contains_key,
(void *)godotsharp_dictionary_duplicate,
(void *)godotsharp_dictionary_remove_key,
+ (void *)godotsharp_dictionary_to_string,
(void *)godotsharp_string_md5_buffer,
(void *)godotsharp_string_md5_text,
(void *)godotsharp_string_rfind,
@@ -1480,30 +1479,35 @@ void *godotsharp_pinvoke_funcs[186] = {
(void *)godotsharp_node_path_get_subname,
(void *)godotsharp_node_path_get_subname_count,
(void *)godotsharp_node_path_is_absolute,
- (void *)godotsharp_randomize,
- (void *)godotsharp_randi,
+ (void *)godotsharp_bytes2var,
+ (void *)godotsharp_convert,
+ (void *)godotsharp_hash,
+ (void *)godotsharp_instance_from_id,
+ (void *)godotsharp_print,
+ (void *)godotsharp_print_rich,
+ (void *)godotsharp_printerr,
+ (void *)godotsharp_printraw,
+ (void *)godotsharp_prints,
+ (void *)godotsharp_printt,
(void *)godotsharp_randf,
- (void *)godotsharp_randi_range,
+ (void *)godotsharp_randi,
+ (void *)godotsharp_randomize,
(void *)godotsharp_randf_range,
(void *)godotsharp_randfn,
- (void *)godotsharp_seed,
+ (void *)godotsharp_randi_range,
(void *)godotsharp_rand_from_seed,
+ (void *)godotsharp_seed,
(void *)godotsharp_weakref,
(void *)godotsharp_str,
- (void *)godotsharp_print,
- (void *)godotsharp_print_rich,
- (void *)godotsharp_printerr,
- (void *)godotsharp_printt,
- (void *)godotsharp_prints,
- (void *)godotsharp_printraw,
- (void *)godotsharp_pusherror,
- (void *)godotsharp_pushwarning,
- (void *)godotsharp_var2str,
(void *)godotsharp_str2var,
(void *)godotsharp_var2bytes,
- (void *)godotsharp_bytes2var,
- (void *)godotsharp_hash,
- (void *)godotsharp_convert,
- (void *)godotsharp_instance_from_id,
+ (void *)godotsharp_var2str,
+ (void *)godotsharp_pusherror,
+ (void *)godotsharp_pushwarning,
(void *)godotsharp_object_to_string,
};
+
+const void **godotsharp::get_runtime_interop_funcs(int32_t &r_size) {
+ r_size = sizeof(unmanaged_callbacks);
+ return unmanaged_callbacks;
+}
diff --git a/modules/mono/glue/runtime_interop.h b/modules/mono/glue/runtime_interop.h
new file mode 100644
index 0000000000..9725ced593
--- /dev/null
+++ b/modules/mono/glue/runtime_interop.h
@@ -0,0 +1,40 @@
+/*************************************************************************/
+/* runtime_interop.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef RUNTIME_INTEROP_H
+#define RUNTIME_INTEROP_H
+
+#include "core/typedefs.h"
+
+namespace godotsharp {
+const void **get_runtime_interop_funcs(int32_t &r_size);
+}
+
+#endif // RUNTIME_INTEROP_H
diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp
index 77c3f07009..f746d63ce5 100644
--- a/modules/mono/mono_gd/gd_mono.cpp
+++ b/modules/mono/mono_gd/gd_mono.cpp
@@ -38,6 +38,7 @@
#include "core/os/thread.h"
#include "../csharp_script.h"
+#include "../glue/runtime_interop.h"
#include "../godotsharp_dirs.h"
#include "../utils/path_utils.h"
#include "gd_mono_cache.h"
@@ -294,9 +295,9 @@ load_assembly_and_get_function_pointer_fn initialize_hostfxr_self_contained(
#endif
#ifdef TOOLS_ENABLED
-using godot_plugins_initialize_fn = bool (*)(void *, bool, gdmono::PluginCallbacks *, GDMonoCache::ManagedCallbacks *);
+using godot_plugins_initialize_fn = bool (*)(void *, bool, gdmono::PluginCallbacks *, GDMonoCache::ManagedCallbacks *, const void **, int32_t);
#else
-using godot_plugins_initialize_fn = bool (*)(void *, GDMonoCache::ManagedCallbacks *);
+using godot_plugins_initialize_fn = bool (*)(void *, GDMonoCache::ManagedCallbacks *, const void **, int32_t);
#endif
#ifdef TOOLS_ENABLED
@@ -443,7 +444,10 @@ void GDMono::initialize() {
ERR_FAIL_NULL(godot_plugins_initialize);
}
- GDMonoCache::ManagedCallbacks managed_callbacks;
+ int32_t interop_funcs_size = 0;
+ const void **interop_funcs = godotsharp::get_runtime_interop_funcs(interop_funcs_size);
+
+ GDMonoCache::ManagedCallbacks managed_callbacks{};
void *godot_dll_handle = nullptr;
@@ -456,12 +460,14 @@ void GDMono::initialize() {
gdmono::PluginCallbacks plugin_callbacks_res;
bool init_ok = godot_plugins_initialize(godot_dll_handle,
Engine::get_singleton()->is_editor_hint(),
- &plugin_callbacks_res, &managed_callbacks);
+ &plugin_callbacks_res, &managed_callbacks,
+ interop_funcs, interop_funcs_size);
ERR_FAIL_COND_MSG(!init_ok, ".NET: GodotPlugins initialization failed");
plugin_callbacks = plugin_callbacks_res;
#else
- bool init_ok = godot_plugins_initialize(godot_dll_handle, &managed_callbacks);
+ bool init_ok = godot_plugins_initialize(godot_dll_handle, &managed_callbacks,
+ interop_funcs, interop_funcs_size);
ERR_FAIL_COND_MSG(!init_ok, ".NET: GodotPlugins initialization failed");
#endif
diff --git a/modules/mono/mono_gd/gd_mono.h b/modules/mono/mono_gd/gd_mono.h
index 776399a544..43811a4325 100644
--- a/modules/mono/mono_gd/gd_mono.h
+++ b/modules/mono/mono_gd/gd_mono.h
@@ -46,7 +46,7 @@ namespace gdmono {
#ifdef TOOLS_ENABLED
struct PluginCallbacks {
using FuncLoadProjectAssemblyCallback = bool(GD_CLR_STDCALL *)(const char16_t *, String *);
- using FuncLoadToolsAssemblyCallback = Object *(GD_CLR_STDCALL *)(const char16_t *);
+ using FuncLoadToolsAssemblyCallback = Object *(GD_CLR_STDCALL *)(const char16_t *, const void **, int32_t);
using FuncUnloadProjectPluginCallback = bool(GD_CLR_STDCALL *)();
FuncLoadProjectAssemblyCallback LoadProjectAssemblyCallback = nullptr;
FuncLoadToolsAssemblyCallback LoadToolsAssemblyCallback = nullptr;