virtualx-engine/modules
Ignacio Roldán Etcheverry 124fbf95f8 C#: Move marshaling logic and generated glue to C#
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-08-22 03:35:59 +02:00
..
basis_universal Refactor module initialization 2022-05-04 17:34:51 +02:00
bmp Make "Godot source files" comment consistent in modules 2022-08-05 17:09:11 -05:00
camera Code quality: Fix header guards consistency 2022-07-25 11:17:40 +02:00
csg Rename the argument tag to param in XML documentation 2022-08-08 22:34:31 +03:00
cvtt fix 'Comparison result is always the same' warnings 2022-07-29 19:45:22 +02:00
dds Add static methods for creating Image and ImageTexture 2022-07-08 13:40:47 +02:00
denoise Rename OSX to macOS and iPhoneOS to iOS. 2022-07-21 09:37:52 +03:00
enet Rename the argument tag to param in XML documentation 2022-08-08 22:34:31 +03:00
etcpak Refactor module initialization 2022-05-04 17:34:51 +02:00
freetype Add Text Server related options to the build profiles editor. 2022-08-03 15:06:43 +03:00
gdscript Merge pull request #64170 from YuriSizov/docs-annotations-in-technicolor 2022-08-20 00:57:01 +02:00
glslang Adding Variable Rate Shading support to Godot 2022-07-17 15:42:24 +10:00
gltf Document GLTFLight and GLTFSpecGloss 2022-08-14 14:57:58 -05:00
gridmap Fix error when switching to another GridMap with an item with higher index selected 2022-08-09 19:05:02 -03:00
hdr Make "Godot source files" comment consistent in modules 2022-08-05 17:09:11 -05:00
jpg Code quality: Fix header guards consistency 2022-07-25 11:17:40 +02:00
jsonrpc Code quality: Fix header guards consistency 2022-07-25 11:17:40 +02:00
lightmapper_rd Fix some array size function definition mismatch. 2022-08-04 13:06:17 +02:00
mbedtls Code quality: Fix header guards consistency 2022-07-25 11:17:40 +02:00
meshoptimizer Code quality: Fix header guards consistency 2022-07-25 11:17:40 +02:00
minimp3 Make "Godot source files" comment consistent in modules 2022-08-05 17:09:11 -05:00
mobile_vr Implement Vector4, Vector4i, Projection 2022-07-23 14:00:01 +02:00
mono C#: Move marshaling logic and generated glue to C# 2022-08-22 03:35:59 +02:00
msdfgen [Scons] Implement module dependency sorting. 2022-08-04 20:00:19 +02:00
multiplayer Rename the argument tag to param in XML documentation 2022-08-08 22:34:31 +03:00
navigation Add NavigationMesh baking for HeightMapShape 2022-08-05 08:56:38 +02:00
noise Rename the argument tag to param in XML documentation 2022-08-08 22:34:31 +03:00
ogg Rename every instance of "OGG" to "Ogg" 2022-07-28 16:41:38 -03:00
openxr Improve the make_rst.py parser for BBCode tags 2022-08-15 17:45:10 +03:00
raycast Remove ThreadWorkPool, replace by WorkerThreadPool 2022-07-25 15:39:50 +02:00
regex Rename the argument tag to param in XML documentation 2022-08-08 22:34:31 +03:00
squish Refactor module initialization 2022-05-04 17:34:51 +02:00
svg round dimensions of svg 2022-07-21 20:11:29 -05:00
text_server_adv Allow MSDF rendering for system fonts, fix crash on loading damaged / unsupported font files. 2022-08-09 14:21:09 +03:00
text_server_fb Allow MSDF rendering for system fonts, fix crash on loading damaged / unsupported font files. 2022-08-09 14:21:09 +03:00
tga Make "Godot source files" comment consistent in modules 2022-08-05 17:09:11 -05:00
theora Rename the argument tag to param in XML documentation 2022-08-08 22:34:31 +03:00
tinyexr Code quality: Fix header guards consistency 2022-07-25 11:17:40 +02:00
upnp Rename the argument tag to param in XML documentation 2022-08-08 22:34:31 +03:00
vhacd Refactor module initialization 2022-05-04 17:34:51 +02:00
visual_script Make property_*_revert methods multilevel and expose them for scripting 2022-08-18 00:03:53 +03:00
vorbis [Scons] Implement module dependency sorting. 2022-08-04 20:00:19 +02:00
webp Swap arguments of ResourceSaver.save() 2022-07-29 19:53:09 +02:00
webrtc Rename the argument tag to param in XML documentation 2022-08-08 22:34:31 +03:00
websocket Rename the argument tag to param in XML documentation 2022-08-08 22:34:31 +03:00
webxr Rename the argument tag to param in XML documentation 2022-08-08 22:34:31 +03:00
xatlas_unwrap Refactor module initialization 2022-05-04 17:34:51 +02:00
modules_builders.py SCons: Improve logic to generate modules_tests.gen.h 2022-02-08 13:01:35 +01:00
register_module_types.h Refactor module initialization 2022-05-04 17:34:51 +02:00
SCsub SCons: Improve logic to generate modules_tests.gen.h 2022-02-08 13:01:35 +01:00