summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-12-10 18:29:26 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2019-12-11 00:20:44 -0300
commit23cf1162f2f36e45da06f1026497d465d0edc8b6 (patch)
treebf80f6474c92519a8fa84f05b7ea53c65f1d4400
parent590cd749060a1f2135fecf346fc120b2a0ce8a44 (diff)
downloadefl-devs/lauromoura/T8515-marshaler-review.tar.gz
WIP - Start changing the MarshalType for non-owned string returneddevs/lauromoura/T8515-marshaler-review
-rw-r--r--src/bin/eolian_mono/eolian/mono/marshall_type_impl.hh14
-rw-r--r--src/bin/eolian_mono/eolian/mono/parameter.hh9
2 files changed, 22 insertions, 1 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/marshall_type_impl.hh b/src/bin/eolian_mono/eolian/mono/marshall_type_impl.hh
index 4d1e188997..1abdf8e004 100644
--- a/src/bin/eolian_mono/eolian/mono/marshall_type_impl.hh
+++ b/src/bin/eolian_mono/eolian/mono/marshall_type_impl.hh
@@ -50,6 +50,8 @@ struct marshall_type_visitor_generate
{
using attributes::regular_type_def;
+ auto is_native_dir = marshall_direction::current_direction(*context) == marshall_direction::native_to_managed;
+
struct match
{
eina::optional<std::string> name;
@@ -69,6 +71,12 @@ struct marshall_type_visitor_generate
{
regular_type_def r = regular;
r.base_qualifier.qualifier ^= qualifier_info::is_ref;
+
+ // Non-owned strings returned will be manually handled
+ // due to lifetime issues.
+ if (is_native_dir && (is_out || is_return))
+ return replace_base_type(r, "System.IntPtr");
+
return replace_base_type(r, "System.String");
}}
, {"mstring", true, [&]
@@ -81,6 +89,12 @@ struct marshall_type_visitor_generate
{
regular_type_def r = regular;
r.base_qualifier.qualifier ^= qualifier_info::is_ref;
+
+ // Non-owned strings returned will be manually handled
+ // due to lifetime issues.
+ if (is_native_dir && (is_out || is_return))
+ return replace_base_type(r, "System.IntPtr");
+
return replace_base_type(r, "System.String");
}}
, {"stringshare", true, [&]
diff --git a/src/bin/eolian_mono/eolian/mono/parameter.hh b/src/bin/eolian_mono/eolian/mono/parameter.hh
index deb9a9e5a8..84d22ed89c 100644
--- a/src/bin/eolian_mono/eolian/mono/parameter.hh
+++ b/src/bin/eolian_mono/eolian/mono/parameter.hh
@@ -834,6 +834,7 @@ struct convert_out_variable_generator
} const convert_out_variable {};
+// Generates intermediate @out variables for native method wrappers (wrappers that are called from C)
struct native_convert_out_variable_generator
{
template <typename OutputIterator, typename Context>
@@ -850,13 +851,19 @@ struct native_convert_out_variable_generator
).generate(sink, std::make_tuple(param, out_variable_name(param.param_name), param), context);
}
else if (helpers::need_struct_conversion(regular)
- || param_is_acceptable(param, "const char *", !WANT_OWN, WANT_OUT)
|| param_is_acceptable(param, "Eina_Stringshare *", !WANT_OWN, WANT_OUT))
{
return as_generator(
type << " " << string << " = default(" << type << ");\n"
).generate(sink, std::make_tuple(param, out_variable_name(param.param_name), param), context);
}
+ else if (param_is_acceptable(param, "const char *", !WANT_OWN, WANT_OUT))
+ {
+ // FIXME Replace with IntPtr interemediate variable
+ return as_generator(
+ type << " " << string << " = default(" << type << ");\n"
+ ).generate(sink, std::make_tuple(param, out_variable_name(param.param_name), param), context);
+ }
else if (param_is_acceptable(param, "Eina_Binbuf *", WANT_OWN, WANT_OUT)
|| param_is_acceptable(param, "Eina_Binbuf *", !WANT_OWN, WANT_OUT)
|| param_is_acceptable(param, "const Eina_Binbuf *", WANT_OWN, WANT_OUT)