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)
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 4d1e188..1abdf8e 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
50 { 50 {
51 using attributes::regular_type_def; 51 using attributes::regular_type_def;
52 52
53 auto is_native_dir = marshall_direction::current_direction(*context) == marshall_direction::native_to_managed;
54
53 struct match 55 struct match
54 { 56 {
55 eina::optional<std::string> name; 57 eina::optional<std::string> name;
@@ -69,6 +71,12 @@ struct marshall_type_visitor_generate
69 { 71 {
70 regular_type_def r = regular; 72 regular_type_def r = regular;
71 r.base_qualifier.qualifier ^= qualifier_info::is_ref; 73 r.base_qualifier.qualifier ^= qualifier_info::is_ref;
74
75 // Non-owned strings returned will be manually handled
76 // due to lifetime issues.
77 if (is_native_dir && (is_out || is_return))
78 return replace_base_type(r, "System.IntPtr");
79
72 return replace_base_type(r, "System.String"); 80 return replace_base_type(r, "System.String");
73 }} 81 }}
74 , {"mstring", true, [&] 82 , {"mstring", true, [&]
@@ -81,6 +89,12 @@ struct marshall_type_visitor_generate
81 { 89 {
82 regular_type_def r = regular; 90 regular_type_def r = regular;
83 r.base_qualifier.qualifier ^= qualifier_info::is_ref; 91 r.base_qualifier.qualifier ^= qualifier_info::is_ref;
92
93 // Non-owned strings returned will be manually handled
94 // due to lifetime issues.
95 if (is_native_dir && (is_out || is_return))
96 return replace_base_type(r, "System.IntPtr");
97
84 return replace_base_type(r, "System.String"); 98 return replace_base_type(r, "System.String");
85 }} 99 }}
86 , {"stringshare", true, [&] 100 , {"stringshare", true, [&]
diff --git a/src/bin/eolian_mono/eolian/mono/parameter.hh b/src/bin/eolian_mono/eolian/mono/parameter.hh
index deb9a9e..84d22ed 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
834 834
835} const convert_out_variable {}; 835} const convert_out_variable {};
836 836
837// Generates intermediate @out variables for native method wrappers (wrappers that are called from C)
837struct native_convert_out_variable_generator 838struct native_convert_out_variable_generator
838{ 839{
839 template <typename OutputIterator, typename Context> 840 template <typename OutputIterator, typename Context>
@@ -850,13 +851,19 @@ struct native_convert_out_variable_generator
850 ).generate(sink, std::make_tuple(param, out_variable_name(param.param_name), param), context); 851 ).generate(sink, std::make_tuple(param, out_variable_name(param.param_name), param), context);
851 } 852 }
852 else if (helpers::need_struct_conversion(regular) 853 else if (helpers::need_struct_conversion(regular)
853 || param_is_acceptable(param, "const char *", !WANT_OWN, WANT_OUT)
854 || param_is_acceptable(param, "Eina_Stringshare *", !WANT_OWN, WANT_OUT)) 854 || param_is_acceptable(param, "Eina_Stringshare *", !WANT_OWN, WANT_OUT))
855 { 855 {
856 return as_generator( 856 return as_generator(
857 type << " " << string << " = default(" << type << ");\n" 857 type << " " << string << " = default(" << type << ");\n"
858 ).generate(sink, std::make_tuple(param, out_variable_name(param.param_name), param), context); 858 ).generate(sink, std::make_tuple(param, out_variable_name(param.param_name), param), context);
859 } 859 }
860 else if (param_is_acceptable(param, "const char *", !WANT_OWN, WANT_OUT))
861 {
862 // FIXME Replace with IntPtr interemediate variable
863 return as_generator(
864 type << " " << string << " = default(" << type << ");\n"
865 ).generate(sink, std::make_tuple(param, out_variable_name(param.param_name), param), context);
866 }
860 else if (param_is_acceptable(param, "Eina_Binbuf *", WANT_OWN, WANT_OUT) 867 else if (param_is_acceptable(param, "Eina_Binbuf *", WANT_OWN, WANT_OUT)
861 || param_is_acceptable(param, "Eina_Binbuf *", !WANT_OWN, WANT_OUT) 868 || param_is_acceptable(param, "Eina_Binbuf *", !WANT_OWN, WANT_OUT)
862 || param_is_acceptable(param, "const Eina_Binbuf *", WANT_OWN, WANT_OUT) 869 || param_is_acceptable(param, "const Eina_Binbuf *", WANT_OWN, WANT_OUT)