godot/modules
Ignacio Roldán Etcheverry 483071716e 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.
2021-08-20 10:24:56 +02:00
..
basis_universal Implement the ability to disable classes 2021-07-13 09:25:14 -03:00
bmp Rename instance()->instantiate() when it's a verb 2021-06-19 20:49:18 -06:00
bullet Fixes in Bullet body_test_motion 2021-08-18 13:18:19 -07:00
camera Fix various typos with codespell 2021-07-25 11:21:51 +02:00
csg Merge pull request #51532 from nekomatata/layer-mask-accessors 2021-08-12 17:55:11 +02:00
cvtt Modernize atomics 2021-02-18 17:12:46 +01:00
dds Rename instance()->instantiate() when it's a verb 2021-06-19 20:49:18 -06:00
denoise Fix some unnecessary includes 2021-08-13 00:27:38 -05:00
enet [Net] Fix ENetMultiplayerPeer status during connection. 2021-08-06 02:00:56 +02:00
etcpak Import: Cleanup and optimize etcpak compression method 2021-04-16 17:08:36 +02:00
fbx Namespaces instead of underscore prefix for binds 2021-08-17 16:10:09 +02:00
freetype HTML5: Fix warnings and re-enable werror=yes on CI 2021-08-06 12:12:37 +02:00
gdnative Remove underscore hacks 2021-08-17 16:10:28 +02:00
gdscript Remove underscore hacks 2021-08-17 16:10:28 +02:00
glslang Implement Binary Shader Compilation 2021-07-26 08:40:39 -03:00
gltf Continue when glTF2 lights fail to parse. 2021-08-09 00:09:19 -07:00
gridmap Uniformize layer names, script methods and documentation 2021-08-12 08:06:42 -07:00
hdr
jpg Rename instance()->instantiate() when it's a verb 2021-06-19 20:49:18 -06:00
jsonrpc Implement the ability to disable classes 2021-07-13 09:25:14 -03:00
lightmapper_rd Implement Binary Shader Compilation 2021-07-26 08:40:39 -03:00
mbedtls Misc cleanup of header includes 2021-07-15 00:46:43 +02:00
meshoptimizer Disable 3D-only modules when 3D is disabled 2021-06-03 17:45:28 -04:00
minimp3 Implement the ability to disable classes 2021-07-13 09:25:14 -03:00
mobile_vr Add constant to vector function parameters that don't actually modify their input. 2021-08-15 16:45:37 +02:00
mono C#: Move marshaling logic and generated glue to C# 2021-08-20 10:24:56 +02:00
navigation Make radius & height in CapsuleShape3D independent 2021-08-11 14:54:53 -07:00
ogg
opensimplex doc: Use self-closing tags for return and argument 2021-07-30 15:29:52 +02:00
opus
pvr Validate image formats, check if resize_to_po2 failed 2021-06-28 21:17:06 +02:00
raycast Rename Reference to RefCounted 2021-06-11 18:48:42 +02:00
regex doc: Use self-closing tags for return and argument 2021-07-30 15:29:52 +02:00
squish Import: Cleanup and optimize etcpak compression method 2021-04-16 17:08:36 +02:00
stb_vorbis Implement the ability to disable classes 2021-07-13 09:25:14 -03:00
svg Rename File::get_len() get_length() 2021-05-25 11:54:28 +01:00
text_server_adv Merge pull request #51178 from Geometror/layout-options-textline-textparagraph 2021-08-11 07:51:57 +02:00
text_server_fb Merge pull request #51178 from Geometror/layout-options-textline-textparagraph 2021-08-11 07:51:57 +02:00
tga Rename instance()->instantiate() when it's a verb 2021-06-19 20:49:18 -06:00
theora doc: Use self-closing tags for return and argument 2021-07-30 15:29:52 +02:00
tinyexr Rename File::get_len() get_length() 2021-05-25 11:54:28 +01:00
upnp doc: Use self-closing tags for return and argument 2021-07-30 15:29:52 +02:00
vhacd Some work on double support 2021-08-09 17:43:48 -05:00
visual_script Namespaces instead of underscore prefix for binds 2021-08-17 16:10:09 +02:00
vorbis
webm doc: Use self-closing tags for return and argument 2021-07-30 15:29:52 +02:00
webp Rename instance()->instantiate() when it's a verb 2021-06-19 20:49:18 -06:00
webrtc [Net] Implement RPC channels in MultiplayerAPI. 2021-07-30 17:29:50 +02:00
websocket HTML5: Fix warnings and re-enable werror=yes on CI 2021-08-06 12:12:37 +02:00
webxr doc: Use self-closing tags for return and argument 2021-07-30 15:29:52 +02:00
xatlas_unwrap Assorted fixes to UV unwrapping and GPU lightmapper 2021-05-03 18:10:34 +02:00
modules_builders.py
register_module_types.h
SCsub Add env.Depends to modules_enabled.gen.h generator 2021-05-05 11:44:29 +02:00