You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-12-06 17:25:19 +00:00
Add methods to get argument count of methods
Added to: * `Callable`s * `Object`s * `ClassDB` * `Script(Instance)`s
This commit is contained in:
@@ -12,6 +12,7 @@ namespace Godot.Bridge
|
||||
public delegate* unmanaged<IntPtr, void*, godot_variant**, int, godot_variant*, void> DelegateUtils_InvokeWithVariantArgs;
|
||||
public delegate* unmanaged<IntPtr, IntPtr, godot_bool> DelegateUtils_DelegateEquals;
|
||||
public delegate* unmanaged<IntPtr, int> DelegateUtils_DelegateHash;
|
||||
public delegate* unmanaged<IntPtr, godot_bool*, int> DelegateUtils_GetArgumentCount;
|
||||
public delegate* unmanaged<IntPtr, godot_array*, godot_bool> DelegateUtils_TrySerializeDelegateWithGCHandle;
|
||||
public delegate* unmanaged<godot_array*, IntPtr*, godot_bool> DelegateUtils_TryDeserializeDelegateWithGCHandle;
|
||||
public delegate* unmanaged<void> ScriptManagerBridge_FrameCallback;
|
||||
@@ -55,6 +56,7 @@ namespace Godot.Bridge
|
||||
DelegateUtils_InvokeWithVariantArgs = &DelegateUtils.InvokeWithVariantArgs,
|
||||
DelegateUtils_DelegateEquals = &DelegateUtils.DelegateEquals,
|
||||
DelegateUtils_DelegateHash = &DelegateUtils.DelegateHash,
|
||||
DelegateUtils_GetArgumentCount = &DelegateUtils.GetArgumentCount,
|
||||
DelegateUtils_TrySerializeDelegateWithGCHandle = &DelegateUtils.TrySerializeDelegateWithGCHandle,
|
||||
DelegateUtils_TryDeserializeDelegateWithGCHandle = &DelegateUtils.TryDeserializeDelegateWithGCHandle,
|
||||
ScriptManagerBridge_FrameCallback = &ScriptManagerBridge.FrameCallback,
|
||||
|
||||
@@ -45,6 +45,29 @@ namespace Godot
|
||||
}
|
||||
}
|
||||
|
||||
[UnmanagedCallersOnly]
|
||||
internal static unsafe int GetArgumentCount(IntPtr delegateGCHandle, godot_bool* outIsValid)
|
||||
{
|
||||
try
|
||||
{
|
||||
var @delegate = (Delegate?)GCHandle.FromIntPtr(delegateGCHandle).Target;
|
||||
int? argCount = @delegate?.Method?.GetParameters().Length;
|
||||
if (argCount is null)
|
||||
{
|
||||
*outIsValid = godot_bool.False;
|
||||
return 0;
|
||||
}
|
||||
*outIsValid = godot_bool.True;
|
||||
return argCount.Value;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
ExceptionUtils.LogException(e);
|
||||
*outIsValid = godot_bool.False;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
[UnmanagedCallersOnly]
|
||||
internal static unsafe void InvokeWithVariantArgs(IntPtr delegateGCHandle, void* trampoline,
|
||||
godot_variant** args, int argc, godot_variant* outRet)
|
||||
|
||||
Reference in New Issue
Block a user