Age | Commit message (Collapse) | Author |
|
Add `readonly` to C# methods and types that don't mutate
|
|
|
|
Also removes a few unnecessary temp variables
|
|
Fix c# Array.Shuffle incorrect mono bindings
|
|
|
|
C#: Add implicit conversion from arrays to Variant
|
|
|
|
Adds an implicit conversion from supported array types (the ones that
are equivalent to `Packed*Array` types in Godot) to Variant.
|
|
|
|
Replace Quaternion Euler constructor with `from_euler` method
|
|
|
|
|
|
This allows using generic Godot collections as type arguments for other
generic Godot collections. This also allows generic Godot collections
as parameter or return type in dynamic Callable invocations.
|
|
We aim to make the C# API reflection-free, mainly for concerns about
performance, and to be able to target NativeAOT in refletion-free mode,
which reduces the binary size.
One of the main usages of reflection still left was the dynamic
invokation of callable delegates, and for some time I wasn't sure
I would find an alternative solution that I'd be happy with.
The new solution uses trampoline functions to invoke the delegates:
```
static void Trampoline(object delegateObj, NativeVariantPtrArgs args, out godot_variant ret)
{
if (args.Count != 1)
throw new ArgumentException($"Callable expected 1 arguments but received {args.Count}.");
string res = ((Func<int, string>)delegateObj)(
VariantConversionCallbacks.GetToManagedCallback<int>()(args[0])
);
ret = VariantConversionCallbacks.GetToVariantCallback<string>()(res);
}
Callable.CreateWithUnsafeTrampoline((int num) => "Foo" + num, &Trampoline);
```
Of course, this is too much boilerplate for user code. To improve this,
the `Callable.From` methods were added. These are overloads that take
`Action` and `Func` delegates, which covers the most common use cases:
lambdas and method groups:
```
// Lambda
Callable.From((int num) => "Foo" + num);
// Method group
string AppendNum(int num) => "Foo" + num;
Callable.From(AppendNum);
```
Unfortunately, due to limitations in the C# language, implicit
conversions from delegates to `Callable` are not supported.
`Callable.From` does not support custom delegates. These should be
uncommon, but the Godot C# API actually uses them for event signals.
As such, the bindings generator was updated to generate trampoline
functions for event signals. It was also optimized to use `Action`
instead of a custom delegate for parameterless signals, which removes
the need for the trampoline functions for those signals.
The change to reflection-free invokation removes one of the last needs
for `ConvertVariantToManagedObjectOfType`. The only remaining usage is
from calling script constructors with parameters from the engine
(`CreateManagedForGodotObjectScriptInstance`). Once that one is made
reflection-free, `ConvertVariantToManagedObjectOfType` can be removed.
|
|
|
|
delegates in C#
|
|
|
|
|
|
C#: Update Basis Euler angle code to match core
|
|
If the delegate target is an Object, the connected signal will be registered in that object instead of the middleman. So when that object is destroyed, the signal will be properly disconnected.
|
|
|
|
|
|
Replace AABB/Rect2/Rect2i has_no_* methods with has_* methods
|
|
|
|
Create script instance of reloaded scripts even if they're not tools
|
|
|
|
|
|
Scripts that are instantiated at some point will always be recreated
if they ever become placeholders to prevent non-tool scripts
instantiated manually by users to become placeholders, if they
do become placeholders due to errors that prevent instantiation
(such as a missing parameterless constructor) these scripts
will also be recreated replacing the temporary placeholder.
If a script is marked as a tool but becomes a non-tool script
in a rebuild, the script will become a placeholder and will
no longer be considered applicable to be replaced by an instance
since the user explicitly removed the Tool attribute.
|
|
|
|
|
|
Vector4 and Vector4i were implemented incorrectly in godot_variant.
They were also missing their respective Variant conversion callbacks
(used for generic collections).
Took the chance to remove unnecessary native calls for creating
Variant from Vector4, as now it can be done from C# (which is faster).
|
|
paulloz/dotnet/fix-godot_variants-with-empty-type-field
C#: Populate `Type` field on `godot_variant` created in managed
|
|
|
|
|
|
Add `dotnet format` to CI to check C# style
|
|
Fix various C# exceptions
|
|
C#: Fix byteCount in `NativeMemory.Alloc`
|
|
`NativeMemory.Alloc` takes the byte count as parameter, this is
calculated by multiplying the element size in bytes by the length
of the array.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
C#: Fix dictionary keys in Colors
|
|
|
|
|
|
Rename `str2var` to `str_to_var` and similar
|