summaryrefslogtreecommitdiff
path: root/modules/mono/signal_awaiter_utils.cpp
AgeCommit message (Collapse)Author
2022-09-06Rename CONNECT_ONESHOT TO CONNECT_ONE_SHOTMicky
For consistency. Every other exposed `one_shot` is spaced out like this.
2022-08-22C#: Begin move to .NET CoreIgnacio Roldán Etcheverry
We're targeting .NET 5 for now to make development easier while .NET 6 is not yet released. TEMPORARY REGRESSIONS --------------------- Assembly unloading is not implemented yet. As such, many Godot resources are leaked at exit. This will be re-implemented later together with assembly hot-reloading.
2022-08-22C#: Restructure code prior move to .NET CoreIgnacio Roldán Etcheverry
The main focus here was to remove the majority of code that relied on Mono's embedding APIs, specially the reflection APIs. The embedding APIs we still use are the bare minimum we need for things to work. A lot of code was moved to C#. We no longer deal with any managed objects (`MonoObject*`, and such) in native code, and all marshaling is done in C#. The reason for restructuring the code and move away from embedding APIs is that once we move to .NET Core, we will be limited by the much more minimal .NET hosting. PERFORMANCE REGRESSIONS ----------------------- Some parts of the code were written with little to no concern about performance. This includes code that calls into script methods and accesses script fields, properties and events. The reason for this is that all of that will be moved to source generators, so any work prior to that would be a waste of time. DISABLED FEATURES ----------------- Some code was removed as it no longer makes sense (or won't make sense in the future). Other parts were commented out with `#if 0`s and TODO warnings because it doesn't make much sense to work on them yet as those parts will change heavily when we switch to .NET Core but also when we start introducing source generators. As such, the following features were disabled temporarily: - Assembly-reloading (will be done with ALCs in .NET Core). - Properties/fields exports and script method listing (will be handled by source generators in the future). - Exception logging in the editor and stack info for errors. - Exporting games. - Building of C# projects. We no longer copy the Godot API assemblies to the project directory, so MSBuild won't be able to find them. The idea is to turn them into NuGet packages in the future, which could also be obtained from local NuGet sources during development.
2022-08-22C#: Move marshaling logic and generated glue to C#Ignacio Roldán Etcheverry
We will be progressively moving most code to C#. The plan is to only use Mono's embedding APIs to set things at launch. This will make it much easier to later support CoreCLR too which doesn't have rich embedding APIs. Additionally the code in C# is more maintainable and makes it easier to implement new features, e.g.: runtime codegen which we could use to avoid using reflection for marshaling everytime a field, property or method is accessed. SOME NOTES ON INTEROP We make the same assumptions as GDNative about the size of the Godot structures we use. We take it a bit further by also assuming the layout of fields in some cases, which is riskier but let's us squeeze out some performance by avoiding unnecessary managed to native calls. Code that deals with native structs is less safe than before as there's no RAII and copy constructors in C#. It's like using the GDNative C API directly. One has to take special care to free values they own. Perhaps we could use roslyn analyzers to check this, but I don't know any that uses attributes to determine what's owned or borrowed. As to why we maily use pointers for native structs instead of ref/out: - AFAIK (and confirmed with a benchmark) ref/out are pinned during P/Invoke calls and that has a cost. - Native struct fields can't be ref/out in the first place. - A `using` local can't be passed as ref/out, only `in`. Calling a method or property on an `in` value makes a silent copy, so we want to avoid `in`. REGARDING THE BUILD SYSTEM There's no longer a `mono_glue=yes/no` SCons options. We no longer need to build with `mono_glue=no`, generate the glue and then build again with `mono_glue=yes`. We build only once and generate the glue (which is in C# now). However, SCons no longer builds the C# projects for us. Instead one must run `build_assemblies.py`, e.g.: ```sh %godot_src_root%/modules/mono/build_scripts/build_assemblies.py \ --godot-output-dir=%godot_src_root%/bin \ --godot-target=release_debug` ``` We could turn this into a custom build target, but I don't know how to do that with SCons (it's possible with Meson). OTHER NOTES Most of the moved code doesn't follow the C# naming convention and still has the word Mono in the names despite no longer dealing with Mono's embedding APIs. This is just temporary while transitioning, to make it easier to understand what was moved where.
2022-07-29Fix Callable calls in mono moduleRaul Santos
The `Callable::call` and `Callable::call_deferred` methods have been renamed to `Callable::callp` and `Callable::call_deferredp`.
2022-06-20Clean up Hash Functionsreduz
Clean up and do fixes to hash functions and newly introduced murmur3 hashes in #61934 * Clean up usage of murmur3 * Fixed usages of binary murmur3 on floats (this is invalid) * Changed DJB2 to use xor (which seems to be better)
2022-01-03Update copyright statements to 2022Rémi Verschelde
Happy new year to the wonderful Godot community!
2021-01-01Update copyright statements to 2021Rémi Verschelde
Happy new year to the wonderful Godot community! 2020 has been a tough year for most of us personally, but a good year for Godot development nonetheless with a huge amount of work done towards Godot 4.0 and great improvements backported to the long-lived 3.2 branch. We've had close to 400 contributors to engine code this year, authoring near 7,000 commit! (And that's only for the `master` branch and for the engine code, there's a lot more when counting docs, demos and other first-party repos.) Here's to a great year 2021 for all Godot users 🎆
2020-12-06Merge pull request #44106 from neikeq/mono-invoke-no-params-boxingRémi Verschelde
Don't box params on Native->C# calls with Variant params
2020-12-06Don't box params on Native->C# calls with Variant paramsIgnacio Etcheverry
Godot uses Variant parameters for calls to script methods. Up until now we were boxing such parameters when marshalling them for invokation, even if they were value types. Now Godot allocates the marshalled parameters on the stack, reducing the GC allocations resulted from boxing.
2020-12-05C#: Fix multiple awaits to same signal result in connect errorIgnacio Etcheverry
Multiple calls to the same `await ToSignal` were resulting in "signal already connected to slot" error because the custom callable comparer was wrong. Comparing only the signal awaiter handle is the correct way (it's unique for the target).
2020-07-05Mono/C#: Fix several clang-tidy warnings and cleanupIgnacio Etcheverry
2020-05-14Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocksRémi Verschelde
Which means that reduz' beloved style which we all became used to will now be changed automatically to remove the first empty line. This makes us lean closer to 1TBS (the one true brace style) instead of hybridating it with some Allman-inspired spacing. There's still the case of braces around single-statement blocks that needs to be addressed (but clang-format can't help with that, but clang-tidy may if we agree about it). Part of #33027.
2020-04-02Replace NULL with nullptrlupoDharkael
2020-03-17Mono/C#: Optimize the way we store GC handles for scriptsIgnacio Etcheverry
Don't store GC handles for C# script instances and instance bindings as 'Ref<MonoGCHandle>'; store the raw data instead. Initially this was not possible as we needed to store a Variant, but this had not been the case for a looong time yet the stored type was never updated.
2020-03-17Fix C# bindings after recent breaking changesIgnacio Etcheverry
Implementation for new Variant types Callable, Signal, StringName. Added support for PackedInt64Array and PackedFloat64Array. Add generation of signal members as events, as well as support for user created signals as events. NOTE: As of now, raising such events will not emit the signal. As such, one must use `EmitSignal` instead of raising the event directly. Removed old ThreadLocal fallback class. It's safe to use thread_local now since it's supported on all minimum versions of compilers we support.
2020-02-20Reworked signal connection system, added support for Callable and Signal ↵Juan Linietsky
objects and made them default.
2020-02-12Fix Mono and GDNative builds after changes to ObjectIDRémi Verschelde
Issues caused by cf8c679a23b21d6c6f29cba6a54eaa2eed88bf92. The Mono change is actually a bugfix (used the int instead of ObjectID by mistake). The GDNative change is a temporary revert until a more exhaustive approach is taken to make 'godot_int' 64-bit, is confirmed wanted by GDNative users.
2020-01-01Update copyright statements to 2020Rémi Verschelde
Happy new year to the wonderful Godot community! We're starting a new decade with a well-established, non-profit, free and open source game engine, and tons of further improvements in the pipeline from hundreds of contributors. Godot will keep getting better, and we're looking forward to all the games that the community will keep developing and releasing with it.
2019-11-13Mono/C#: WebAssembly supportIgnacio Etcheverry
2019-08-09Replace 'ERR_EXPLAIN' with 'ERR_FAIL_*_MSG' in 'modules/mono'Ignacio Etcheverry
And 'CRASH_*_MSG' as well. Also make error messages puntuation and quotation more consistent.
2019-07-05Re-write mono module editor code in C#Ignacio Etcheverry
Make the build system automatically build the C# Api assemblies to be shipped with the editor. Make the editor, editor player and debug export templates use Api assemblies built with debug symbols. Always run MSBuild to build the editor tools and Api assemblies when building Godot. Several bugs fixed related to assembly hot reloading and restoring state. Fix StringExtensions internal calls not being registered correctly, resulting in MissingMethodException.
2019-06-03Android build and export for the mono moduleIgnacio Etcheverry
2019-04-06C#: Add marshalling support for IEnumerable and IDictionaryIgnacio Etcheverry
Added constructor that takes IEnumerable for Array and IEnumerable<T> for Array<T>. Added constructor that takes IDictionary for Dictionary and IDictionary<TKey, TValue> for Dictionary<TKey, TValue>.
2019-01-01Update copyright statements to 2019Rémi Verschelde
Happy new year to the wonderful Godot community!
2018-11-30C#: Improve tool script support and fix reloading issuesIgnacio Etcheverry
2018-10-25Fix msvc warnings in mono moduleIgnacio Etcheverry
- `modules\mono\csharp_script.cpp(576): warning C4099: 'CSharpScriptDepSort': type name first seen using 'class' now seen using 'struct'` - `modules\mono\signal_awaiter_utils.cpp(144): warning C4003: not enough actual parameters for macro 'ERR_FAIL_V'` - `modules\mono\editor\net_solution.cpp(101): warning C4129: '%': unrecognized character escape sequence` - (several) `modules\mono\glue\cs_compressed.gen.h(222): warning C4129: 'E': unrecognized character escape sequence`
2018-09-12Fix/workaround for issue #21667Ignacio Etcheverry
When a Reference managed instance is garbage collected and its finalizer is called, it could happen that the native instance is referenced once again before the finalizer can unreference and memdelete it. The workaround is to create a new managed instance when this happens (at least for now).
2018-08-25Merge pull request #16927 from neikeq/rework-refcount-notifyJuan Linietsky
Notify instance binding data api of refcount increment/decrement
2018-08-23Notify instance binding data api of refcount increment/decrementIgnacio Etcheverry
2018-07-04Mono: Pending exceptions and cleanupIgnacio Etcheverry
2018-01-23SignalAwaiter::_signal_callback was calling the thunk with a wrong pointerPaul Joannon
2018-01-05Add missing copyright headers and fix formattingRémi Verschelde
Using `misc/scripts/fix_headers.py` on all Godot files. Some missing header guards were added, and the header inclusion order was fixed in the Bullet module.
2018-01-01Update copyright statements to 2018Rémi Verschelde
Happy new year to the wonderful Godot community!
2017-12-07Style: Apply new clang-format 5.0 style to all filesRémi Verschelde
2017-10-18Mono: Fix build with tools=no or target=releaseIgnacio Etcheverry
2017-10-16Re-write SignalAwaiter implementationIgnacio Etcheverry
Old implementation had issues where you could only await on the same signal of the same source once.
2017-10-03Added mono moduleIgnacio Etcheverry