diff options
| author | Ignacio Etcheverry <ignalfonsore@gmail.com> | 2018-10-17 21:37:57 +0200 |
|---|---|---|
| committer | Ignacio Etcheverry <ignalfonsore@gmail.com> | 2018-10-17 22:36:26 +0200 |
| commit | 23ae64b15e14e868f3a152ca2745b2db764b12c2 (patch) | |
| tree | f3d68e5022b7ee59993d9106a17c91e6f15cb301 /modules/mono/editor/bindings_generator.h | |
| parent | eeaa9124af0cf6b66acd70f003482eecdd997a4a (diff) | |
| download | redot-engine-23ae64b15e14e868f3a152ca2745b2db764b12c2.tar.gz | |
C#: Optimize struct marshalling
- We no longer box struct to return them from internal calls.
- Use reinterpret_cast if the managed struct layout is the same as the native struct.
Diffstat (limited to 'modules/mono/editor/bindings_generator.h')
| -rw-r--r-- | modules/mono/editor/bindings_generator.h | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/modules/mono/editor/bindings_generator.h b/modules/mono/editor/bindings_generator.h index ad89255ba5..7ae52e180f 100644 --- a/modules/mono/editor/bindings_generator.h +++ b/modules/mono/editor/bindings_generator.h @@ -223,7 +223,7 @@ class BindingsGenerator { String c_in; /** - * Determines the name of the variable that will be passed as argument to a ptrcall. + * Determines the expression that will be passed as argument to ptrcall. * By default the value equals the name of the parameter, * this varies for types that require special manipulation via [c_in]. * Formatting elements: @@ -333,8 +333,6 @@ class BindingsGenerator { itype.proxy_name = itype.name; itype.c_type = itype.name; - itype.c_type_in = "void*"; - itype.c_type_out = "MonoObject*"; itype.cs_type = itype.proxy_name; itype.im_type_in = "ref " + itype.proxy_name; itype.im_type_out = itype.proxy_name; @@ -385,10 +383,19 @@ class BindingsGenerator { } static void postsetup_enum_type(TypeInterface &r_enum_itype) { - r_enum_itype.c_arg_in = "&%s"; - r_enum_itype.c_type = "int"; - r_enum_itype.c_type_in = "int"; - r_enum_itype.c_type_out = "int"; + // C interface is the same as that of 'int'. Remember to apply any + // changes done here to the 'int' type interface as well + + r_enum_itype.c_arg_in = "&%s_in"; + { + // The expected types for parameters and return value in ptrcall are 'int64_t' or 'uint64_t'. + r_enum_itype.c_in = "\t%0 %1_in = (%0)%1;\n"; + r_enum_itype.c_out = "\treturn (%0)%1;\n"; + r_enum_itype.c_type = "int64_t"; + } + r_enum_itype.c_type_in = "int32_t"; + r_enum_itype.c_type_out = r_enum_itype.c_type_in; + r_enum_itype.cs_type = r_enum_itype.proxy_name; r_enum_itype.cs_in = "(int)%s"; r_enum_itype.cs_out = "return (%1)%0;"; |
