summaryrefslogtreecommitdiff
path: root/modules/mono/glue/collections_glue.cpp
AgeCommit message (Collapse)Author
2022-08-22C#: Re-write Array, Dictionary, NodePath, String icalls as P/InvokeIgnacio Roldán Etcheverry
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-01-12Fix marshaling values of generic Godot DictionaryRaul Santos
2022-01-03Update copyright statements to 2022Rémi Verschelde
Happy new year to the wonderful Godot community!
2021-12-23Fix `KeyValuePairAt` memory leakRaul Santos
2021-11-23Rename `remove()` to `remove_at()` when removing by indexLightning_A
2021-08-05Reduce C# Dictionary internal callsRaul Santos
- Implements new `KeyValuePairs` and `KeyValuePairAt` internal calls to get the `key` and the `value` in one call. - Caches the `DictionaryEntry` to reuse properties without repeating internal calls.
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-14Mono: Make Godot provide its own WASM m2n trampolinesIgnacio Etcheverry
This depends on a custom Mono patch from this commit: godotengine/godot-mono-builds@0e312939bd0dc4b807cc15dbe76a7b65456ab928
2020-11-07Reorganized core/ directory, it was too fatty alreadyreduz
-Removed FuncRef, since Callable makes it obsolete -Removed int_types.h as its obsolete in c++11+ -Changed color names code
2020-11-07[Mono] Added Shuffle method to ArrayYuri Roubinsky
2020-09-12Add concatenation support and a new ctor to Godot.Collections.ArrayAaron Franke
2020-07-05Mono/C#: Fix several clang-tidy warnings and cleanupIgnacio Etcheverry
2020-04-02Replace NULL with nullptrlupoDharkael
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-12-04C#: Add Duplicate method to the Array and Dictionary bindingsIgnacio Etcheverry
2019-11-13Mono/C#: WebAssembly supportIgnacio Etcheverry
2019-07-03Mono: Fix Array IndexOutOfRangeException not being thrownIgnacio Etcheverry
2019-05-21Replace call to 'mono_runtime_object_init' with manual ctor invokingIgnacio Etcheverry
2019-04-18C#: Add missing ToString() override methodsIgnacio Etcheverry
Godot.Object, Array, Dictionary and RID were missing ToString() override methods
2019-04-06C#: Some important Array and Dictionary interface changesIgnacio Etcheverry
Array now implements IList instead of IList<object, object>. Dictionary now implements IDictionary instead of IDictionary<object, object>.
2019-03-29C#: Add DynamicGodotObject classIgnacio Etcheverry
Expands to Object.call, Object.set and Object.get for accessing members. This means it can also access members from scripts written in other languages, like GDScript.
2019-02-28Merge pull request #26411 from neikeq/issue-26195Ignacio Etcheverry
C#: Add Array.Resize(int) method
2019-02-28C#: Add Array.Resize(int) methodIgnacio Etcheverry
2019-02-27Fix -Wsign-compare warnings.marxin
I decided to modify code in a defensive way. Ideally functions like size() or length() should return an unsigned type.
2019-01-01Update copyright statements to 2019Rémi Verschelde
Happy new year to the wonderful Godot community!
2018-09-27Mono: Fix not creating generic Array or Dictionary where expectedIgnacio Etcheverry
2018-09-12Cleanup of c# api files and bindings generatorIgnacio Etcheverry
- We no longer generate RID and NodePath C# classes. Both will be maintained manually. - We no longer generate C# declarations and runtime registration of internal calls for the following classes: RID, NodePath, String, GD, SignalAwaiter and Godot.Object (partial base). - We no longer auto-generate the base members of Godot.Object. They will be maintained manually as a partial class. This makes it easier to maintain these C# classes and their internal calls, as well as the bindings generator which no longer generates C# classes that don't derive from Godot Object, and it no longer generates the Godot.Object base members (which where unreadable in the bindings generator code). - Added missing 'RID(Object from)' constructor to the RID C# class. - Replaced MONO_GLUE_DISABLED constant macro with MONO_GLUE_ENABLED. - Add sources in module/mono/glue even if glue is disabled, but surround glue files with ifdef MONO_GLUE_ENABLED.
2018-08-25Added Collections namespace to Array & Dictionaryexts
2018-08-14Dictionary: remove erase_checked(key), make erase(key) return boolIgnacio Etcheverry
2018-07-20Add Array and Dictionary wrapper classes to C#Ignacio Etcheverry