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>
This commit is contained in:
parent
186d7f6239
commit
2c180f62d9
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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" />
|
||||
|
|
|
@ -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;
|
||||
|
||||
[DllImport(GodotDllName)]
|
||||
public static extern void godot_icall_GodotSharpDirs_MonoUserDir(out godot_string r_dest);
|
||||
if (unmanagedCallbacksSize != sizeof(InternalUnmanagedCallbacks))
|
||||
throw new ArgumentException("Unmanaged callbacks size mismatch");
|
||||
|
||||
[DllImport(GodotDllName)]
|
||||
public static extern void godot_icall_GodotSharpDirs_BuildLogsDirs(out godot_string r_dest);
|
||||
_unmanagedCallbacks = Unsafe.AsRef<InternalUnmanagedCallbacks>((void*)unmanagedCallbacks);
|
||||
}
|
||||
|
||||
[DllImport(GodotDllName)]
|
||||
public static extern void godot_icall_GodotSharpDirs_DataEditorToolsDir(out godot_string r_dest);
|
||||
private partial struct InternalUnmanagedCallbacks
|
||||
{
|
||||
}
|
||||
|
||||
[DllImport(GodotDllName)]
|
||||
public static extern void godot_icall_EditorProgress_Create(in godot_string task, in godot_string label,
|
||||
/*
|
||||
* 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);
|
||||
|
||||
public static partial void godot_icall_GodotSharpDirs_MonoUserDir(out godot_string r_dest);
|
||||
|
||||
public static partial void godot_icall_GodotSharpDirs_BuildLogsDirs(out godot_string r_dest);
|
||||
|
||||
public static partial void godot_icall_GodotSharpDirs_DataEditorToolsDir(out godot_string r_dest);
|
||||
|
||||
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
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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; }
|
||||
}
|
|
@ -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));
|
||||
}
|
||||
}
|
|
@ -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(">", ")");
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
namespace Godot.SourceGenerators.Internal;
|
||||
|
||||
internal static class GeneratorClasses
|
||||
{
|
||||
public const string GenerateUnmanagedCallbacksAttr = "Godot.SourceGenerators.Internal.GenerateUnmanagedCallbacksAttribute";
|
||||
}
|
|
@ -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>
|
|
@ -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",
|
||||
};
|
||||
}
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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" />
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue