summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2019-01-26 21:11:14 +0900
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2019-01-31 16:16:00 +0900
commited9a9f1fb8bf6c4f578617d98b516dd4d27850ba (patch)
tree0d3f0b733b716e1b89a729249b8107d46e4a150b
parenta50b97da885b8a20798d8abbde5750ca85cef00d (diff)
downloadefl-ed9a9f1fb8bf6c4f578617d98b516dd4d27850ba.tar.gz
efl-mono: Use only one marshal_annotate
-rw-r--r--src/bin/eolian_mono/eolian/mono/function_definition.hh12
-rw-r--r--src/bin/eolian_mono/eolian/mono/function_pointer.hh8
-rw-r--r--src/bin/eolian_mono/eolian/mono/marshall_annotation.hh230
-rw-r--r--src/bin/eolian_mono/eolian/mono/marshall_type.hh80
4 files changed, 167 insertions, 163 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/function_definition.hh b/src/bin/eolian_mono/eolian/mono/function_definition.hh
index 915b12ea9e..77fda50dcc 100644
--- a/src/bin/eolian_mono/eolian/mono/function_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/function_definition.hh
@@ -41,7 +41,8 @@ struct native_function_definition_generator
{
if(!as_generator
("\n\n" << scope_tab
- << eolian_mono::marshall_native_annotation(true)
+ << eolian_mono::marshall_annotation(true)
+ // << eolian_mono::marshall_native_annotation(true)
<< " private delegate "
<< eolian_mono::marshall_type(true)
<< " "
@@ -49,14 +50,15 @@ struct native_function_definition_generator
<< "_delegate(System.IntPtr obj, System.IntPtr pd"
<< *grammar::attribute_reorder<-1, -1>
(
- (", " << marshall_native_annotation << " " << marshall_parameter)
+ (", " << marshall_annotation /*marshall_native_annotation*/ << " " << marshall_parameter)
)
<< ");\n")
.generate(sink, std::make_tuple(f.return_type, f.return_type, f.c_name, f.parameters), context))
return false;
if(!as_generator
("\n\n" << scope_tab
- << eolian_mono::marshall_native_annotation(true)
+ << eolian_mono::marshall_annotation(true)
+ // << eolian_mono::marshall_native_annotation(true)
<< " public delegate "
<< eolian_mono::marshall_type(true)
<< " "
@@ -64,7 +66,7 @@ struct native_function_definition_generator
<< "_api_delegate(System.IntPtr obj"
<< *grammar::attribute_reorder<-1, -1>
(
- (", " << marshall_native_annotation << " " << marshall_parameter)
+ (", " << marshall_annotation /*marshall_native_annotation*/ << " " << marshall_parameter)
)
<< ");\n")
.generate(sink, std::make_tuple(f.return_type, f.return_type, f.c_name, f.parameters), context))
@@ -131,7 +133,7 @@ struct native_function_definition_generator
// This is the delegate that will be passed to Eo to be called from C.
if(!as_generator(
- scope_tab << "private " << f.c_name << "_delegate " << f.c_name << "_static_delegate;\n"
+ scope_tab << "private static " << f.c_name << "_delegate " << f.c_name << "_static_delegate;\n"
).generate(sink, attributes::unused, context))
return false;
return true;
diff --git a/src/bin/eolian_mono/eolian/mono/function_pointer.hh b/src/bin/eolian_mono/eolian/mono/function_pointer.hh
index 2c62abeb12..4339600de8 100644
--- a/src/bin/eolian_mono/eolian/mono/function_pointer.hh
+++ b/src/bin/eolian_mono/eolian/mono/function_pointer.hh
@@ -47,9 +47,9 @@ struct function_pointer {
.generate(sink, std::make_tuple(f, f.return_type, f_name, f.parameters), funcptr_ctx))
return false;
// "Internal" delegate, 1-to-1 with the Unamaged function type
- if (!as_generator(marshall_native_annotation(true)
+ if (!as_generator(marshall_annotation(true) //marshall_native_annotation(true)
<< "public delegate " << marshall_type(true) << " " << string // public?
- << "Internal(IntPtr data" << *grammar::attribute_reorder<-1, -1>((", " << marshall_native_annotation << " " << marshall_parameter)) << ");\n")
+ << "Internal(IntPtr data" << *grammar::attribute_reorder<-1, -1>((", " << marshall_annotation /*marshall_native_annotation*/ << " " << marshall_parameter)) << ");\n")
.generate(sink, std::make_tuple(f.return_type, f.return_type, f_name, f.parameters), funcptr_ctx))
return false;
@@ -80,8 +80,8 @@ struct function_pointer {
<< scope_tab << "}\n\n"
- << scope_tab << marshall_native_annotation(true)
- << scope_tab << "internal static " << marshall_type(true) << " Cb(IntPtr cb_data" << *grammar::attribute_reorder<-1, -1>((", " << marshall_native_annotation << " " << marshall_parameter)) << ")\n"
+ << scope_tab << marshall_annotation(true) /*marshall_native_annotation(true)*/
+ << scope_tab << "internal static " << marshall_type(true) << " Cb(IntPtr cb_data" << *grammar::attribute_reorder<-1, -1>((", " << marshall_annotation /*marshall_native_annotation*/ << " " << marshall_parameter)) << ")\n"
<< scope_tab << "{\n"
<< scope_tab << scope_tab << "GCHandle handle = GCHandle.FromIntPtr(cb_data);\n"
<< scope_tab << scope_tab << string << " cb = (" << string << ")handle.Target;\n"
diff --git a/src/bin/eolian_mono/eolian/mono/marshall_annotation.hh b/src/bin/eolian_mono/eolian/mono/marshall_annotation.hh
index ee4c4747df..619efe2aa4 100644
--- a/src/bin/eolian_mono/eolian/mono/marshall_annotation.hh
+++ b/src/bin/eolian_mono/eolian/mono/marshall_annotation.hh
@@ -112,10 +112,10 @@ struct marshall_annotation_visitor_generate
return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Eina.ValueMarshaler))]";
}},
{"strbuf", true, [&] {
- return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufPassOwnershipMarshaler))]";
+ return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufPassOwnershipMarshaler))]";
}},
{"strbuf", false, [&] {
- return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufKeepOwnershipMarshaler))]";
+ return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufKeepOwnershipMarshaler))]";
}},
};
@@ -123,6 +123,8 @@ struct marshall_annotation_visitor_generate
((is_return ? return_match_table : parameter_match_table)
, [&] (match const& m)
{
+ if (is_return)
+ std::cout << "comparing return type " << (m.name ? *m.name : "unknown") << " with " << regular.base_type << std::endl;
return (!m.name || *m.name == regular.base_type)
&& (!m.has_own || *m.has_own == (bool)(regular.base_qualifier & qualifier_info::is_own))
;
@@ -160,121 +162,121 @@ struct marshall_annotation_visitor_generate
}
};
-template <typename OutputIterator, typename Context>
-struct marshall_native_annotation_visitor_generate
-{
- mutable OutputIterator sink;
- Context const* context;
- std::string c_type;
- bool is_out;
- bool is_return;
- bool is_ptr;
+// template <typename OutputIterator, typename Context>
+// struct marshall_native_annotation_visitor_generate
+// {
+// mutable OutputIterator sink;
+// Context const* context;
+// std::string c_type;
+// bool is_out;
+// bool is_return;
+// bool is_ptr;
- typedef marshall_type_visitor_generate<OutputIterator, Context> visitor_type;
- typedef bool result_type;
+// typedef marshall_type_visitor_generate<OutputIterator, Context> visitor_type;
+// typedef bool result_type;
- bool operator()(attributes::regular_type_def const& regular) const
- {
- using attributes::regular_type_def;
- struct match
- {
- eina::optional<std::string> name;
- eina::optional<bool> has_own;
- std::function<std::string()> function;
- };
- match const parameter_match_table[] =
- {
- // signed primitives
- {"bool", nullptr, [&] { return " [MarshalAs(UnmanagedType.U1)]"; }},
- {"string", true, [&] {
- return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringPassOwnershipMarshaler))]";
- }},
- {"string", false, [&] {
- if (is_out)
- return "";
- return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))]";
- }},
- {"stringshare", true, [&] {
- return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringsharePassOwnershipMarshaler))]";
- }},
- {"stringshare", false, [&] {
- if (is_out)
- return "";
- return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringshareKeepOwnershipMarshaler))]";
- }},
- {"strbuf", true, [&] {
- return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufPassOwnershipMarshaler))]";
- }},
- {"strbuf", false, [&] {
- return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufKeepOwnershipMarshaler))]";
- }},
- };
- match const return_match_table[] =
- {
- // signed primitives
- {"bool", nullptr, [&] { return " [return: MarshalAs(UnmanagedType.U1)]"; }},
- {"string", true, [&] {
- return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringPassOwnershipMarshaler))]";
- }},
- {"string", false, [&] {
- return ""; }},
- {"stringshare", true, [&] {
- return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringsharePassOwnershipMarshaler))]";
- }},
- {"stringshare", false, [&] { return "[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringshareKeepOwnershipMarshaler))]"; }},
- {"strbuf", true, [&] {
- return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufPassOwnershipMarshaler))]";
- }},
- {"strbuf", false, [&] {
- return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufKeepOwnershipMarshaler))]";
- }},
- };
+// bool operator()(attributes::regular_type_def const& regular) const
+// {
+// using attributes::regular_type_def;
+// struct match
+// {
+// eina::optional<std::string> name;
+// eina::optional<bool> has_own;
+// std::function<std::string()> function;
+// };
+// match const parameter_match_table[] =
+// {
+// // signed primitives
+// {"bool", nullptr, [&] { return " [MarshalAs(UnmanagedType.U1)]"; }},
+// {"string", true, [&] {
+// return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringPassOwnershipMarshaler))]";
+// }},
+// {"string", false, [&] {
+// if (is_out)
+// return "";
+// return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))]";
+// }},
+// {"stringshare", true, [&] {
+// return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringsharePassOwnershipMarshaler))]";
+// }},
+// {"stringshare", false, [&] {
+// if (is_out)
+// return "";
+// return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringshareKeepOwnershipMarshaler))]";
+// }},
+// {"strbuf", true, [&] {
+// return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufPassOwnershipMarshaler))]";
+// }},
+// {"strbuf", false, [&] {
+// return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufKeepOwnershipMarshaler))]";
+// }},
+// };
+// match const return_match_table[] =
+// {
+// // signed primitives
+// {"bool", nullptr, [&] { return " [return: MarshalAs(UnmanagedType.U1)]"; }},
+// {"string", true, [&] {
+// return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringPassOwnershipMarshaler))]";
+// }},
+// {"string", false, [&] {
+// return ""; }},
+// {"stringshare", true, [&] {
+// return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringsharePassOwnershipMarshaler))]";
+// }},
+// {"stringshare", false, [&] { return "[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringshareKeepOwnershipMarshaler))]"; }},
+// {"strbuf", true, [&] {
+// return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufPassOwnershipMarshaler))]";
+// }},
+// {"strbuf", false, [&] {
+// return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufKeepOwnershipMarshaler))]";
+// }},
+// };
- if(eina::optional<bool> b = call_annotation_match
- ((is_return ? return_match_table : parameter_match_table)
- , [&] (match const& m)
- {
- return (!m.name || *m.name == regular.base_type)
- && (!m.has_own || *m.has_own == static_cast<bool>(regular.base_qualifier & qualifier_info::is_own))
- ;
- }
- , [&] (std::string const& string)
- {
- if (is_return)
- {
- std::string comment = "// Passed through match table with type " + regular.base_type + " and string is size " + std::to_string(string.size()) + "\n";
- std::copy(comment.begin(), comment.end(), sink);
- }
- std::copy(string.begin(), string.end(), sink);
- return true;
- }))
- {
- return *b;
- }
- else
- {
- return true;
- }
- }
- bool operator()(attributes::klass_name const& klass_name) const
- {
- const char no_return_prefix[] = "[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Efl.Eo.MarshalTest<";
- const char return_prefix[] = "[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Efl.Eo.MarshalTest<";
- return as_generator
- ((is_return ? return_prefix : no_return_prefix)
- << string << ", Efl.Eo." << (klass_name.base_qualifier & qualifier_info::is_own ? "OwnTag" : "NonOwnTag") << ">))]"
- ).generate(sink, name_helpers::klass_full_concrete_name(klass_name), *context);
- }
- bool operator()(attributes::complex_type_def const& c) const
- {
- if (c.outer.base_type == "future")
- {
- std::string prefix = is_return ? "return: " : "";
- return as_generator("[" << prefix << "MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Eina.FutureMarshaler))]").generate(sink, nullptr, *context);
- }
- return true;
- }
-};
+// if(eina::optional<bool> b = call_annotation_match
+// ((is_return ? return_match_table : parameter_match_table)
+// , [&] (match const& m)
+// {
+// return (!m.name || *m.name == regular.base_type)
+// && (!m.has_own || *m.has_own == static_cast<bool>(regular.base_qualifier & qualifier_info::is_own))
+// ;
+// }
+// , [&] (std::string const& string)
+// {
+// if (is_return)
+// {
+// std::string comment = "// Passed through match table with type " + regular.base_type + " and string is size " + std::to_string(string.size()) + "\n";
+// std::copy(comment.begin(), comment.end(), sink);
+// }
+// std::copy(string.begin(), string.end(), sink);
+// return true;
+// }))
+// {
+// return *b;
+// }
+// else
+// {
+// return true;
+// }
+// }
+// bool operator()(attributes::klass_name const& klass_name) const
+// {
+// const char no_return_prefix[] = "[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Efl.Eo.MarshalTest<";
+// const char return_prefix[] = "[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Efl.Eo.MarshalTest<";
+// return as_generator
+// ((is_return ? return_prefix : no_return_prefix)
+// << string << ", Efl.Eo." << (klass_name.base_qualifier & qualifier_info::is_own ? "OwnTag" : "NonOwnTag") << ">))]"
+// ).generate(sink, name_helpers::klass_full_concrete_name(klass_name), *context);
+// }
+// bool operator()(attributes::complex_type_def const& c) const
+// {
+// if (c.outer.base_type == "future")
+// {
+// std::string prefix = is_return ? "return: " : "";
+// return as_generator("[" << prefix << "MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Eina.FutureMarshaler))]").generate(sink, nullptr, *context);
+// }
+// return true;
+// }
+// };
} }
diff --git a/src/bin/eolian_mono/eolian/mono/marshall_type.hh b/src/bin/eolian_mono/eolian/mono/marshall_type.hh
index add954ade2..0495a30a08 100644
--- a/src/bin/eolian_mono/eolian/mono/marshall_type.hh
+++ b/src/bin/eolian_mono/eolian/mono/marshall_type.hh
@@ -73,25 +73,25 @@ struct marshall_annotation_generator
bool is_return;
};
-struct marshall_native_annotation_generator
-{
- marshall_native_annotation_generator(bool is_return = false)
- : is_return(is_return) {}
-
- template <typename OutputIterator, typename Context>
- bool generate(OutputIterator sink, attributes::type_def const& type, Context const& context) const
- {
- return type.original_type.visit(detail::marshall_native_annotation_visitor_generate<OutputIterator, Context>{sink, &context, type.c_type, false, is_return, type.is_ptr});
- }
- template <typename OutputIterator, typename Context>
- bool generate(OutputIterator sink, attributes::parameter_def const& param, Context const& context) const
- {
- return param.type.original_type.visit(detail::marshall_native_annotation_visitor_generate<OutputIterator, Context>{sink, &context, param.type.c_type
- , param.direction != attributes::parameter_direction::in, false, param.type.is_ptr});
- }
-
- bool is_return;
-};
+// struct marshall_native_annotation_generator
+// {
+// marshall_native_annotation_generator(bool is_return = false)
+// : is_return(is_return) {}
+
+// template <typename OutputIterator, typename Context>
+// bool generate(OutputIterator sink, attributes::type_def const& type, Context const& context) const
+// {
+// return type.original_type.visit(detail::marshall_native_annotation_visitor_generate<OutputIterator, Context>{sink, &context, type.c_type, false, is_return, type.is_ptr});
+// }
+// template <typename OutputIterator, typename Context>
+// bool generate(OutputIterator sink, attributes::parameter_def const& param, Context const& context) const
+// {
+// return param.type.original_type.visit(detail::marshall_native_annotation_visitor_generate<OutputIterator, Context>{sink, &context, param.type.c_type
+// , param.direction != attributes::parameter_direction::in, false, param.type.is_ptr});
+// }
+
+// bool is_return;
+// };
struct marshall_type_terminal
{
@@ -120,18 +120,18 @@ marshall_annotation_generator const as_generator(marshall_annotation_terminal)
}
-struct marshall_native_annotation_terminal
-{
- marshall_native_annotation_generator const operator()(bool is_return) const
- {
- return marshall_native_annotation_generator(is_return);
- }
-} const marshall_native_annotation = {};
+// struct marshall_native_annotation_terminal
+// {
+// marshall_native_annotation_generator const operator()(bool is_return) const
+// {
+// return marshall_native_annotation_generator(is_return);
+// }
+// } const marshall_native_annotation = {};
-marshall_native_annotation_generator const as_generator(marshall_native_annotation_terminal)
-{
- return marshall_native_annotation_generator{};
-}
+// marshall_native_annotation_generator const as_generator(marshall_native_annotation_terminal)
+// {
+// return marshall_native_annotation_generator{};
+// }
}
@@ -158,12 +158,12 @@ struct is_generator< ::eolian_mono::marshall_annotation_generator> : std::true_t
template <>
struct is_generator< ::eolian_mono::marshall_annotation_terminal> : std::true_type {};
-template <>
-struct is_eager_generator< ::eolian_mono::marshall_native_annotation_generator> : std::true_type {};
-template <>
-struct is_generator< ::eolian_mono::marshall_native_annotation_generator> : std::true_type {};
-template <>
-struct is_generator< ::eolian_mono::marshall_native_annotation_terminal> : std::true_type {};
+// template <>
+// struct is_eager_generator< ::eolian_mono::marshall_native_annotation_generator> : std::true_type {};
+// template <>
+// struct is_generator< ::eolian_mono::marshall_native_annotation_generator> : std::true_type {};
+// template <>
+// struct is_generator< ::eolian_mono::marshall_native_annotation_terminal> : std::true_type {};
namespace type_traits {
template <>
@@ -171,10 +171,10 @@ struct attributes_needed< ::eolian_mono::marshall_annotation_generator> : std::i
template <>
struct attributes_needed< ::eolian_mono::marshall_annotation_terminal> : std::integral_constant<int, 1> {};
-template <>
-struct attributes_needed< ::eolian_mono::marshall_native_annotation_generator> : std::integral_constant<int, 1> {};
-template <>
-struct attributes_needed< ::eolian_mono::marshall_native_annotation_terminal> : std::integral_constant<int, 1> {};
+// template <>
+// struct attributes_needed< ::eolian_mono::marshall_native_annotation_generator> : std::integral_constant<int, 1> {};
+// template <>
+// struct attributes_needed< ::eolian_mono::marshall_native_annotation_terminal> : std::integral_constant<int, 1> {};
}
} } }