summaryrefslogtreecommitdiff
path: root/src/bin/eolian_mono/eolian/mono/helpers.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/eolian_mono/eolian/mono/helpers.hh')
-rw-r--r--src/bin/eolian_mono/eolian/mono/helpers.hh62
1 files changed, 26 insertions, 36 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/helpers.hh b/src/bin/eolian_mono/eolian/mono/helpers.hh
index 7d013bd6f5..40a99915ab 100644
--- a/src/bin/eolian_mono/eolian/mono/helpers.hh
+++ b/src/bin/eolian_mono/eolian/mono/helpers.hh
@@ -2,55 +2,44 @@
#define EOLIAN_MONO_HELPERS_HH
#include "grammar/klass_def.hpp"
+#include "blacklist.hh"
+#include "name_helpers.hh"
namespace eolian_mono {
+namespace helpers {
+
+/* General helpers, not related directly with generating strings (those go in the name_helpers.hh). */
+
namespace attributes = efl::eolian::grammar::attributes;
-inline std::string type_full_name(attributes::regular_type_def const& type)
+inline bool need_struct_conversion(attributes::regular_type_def const* regular)
{
- std::string full_name;
- for (auto& name : type.namespaces)
- {
- full_name += name + ".";
- }
- full_name += type.base_type;
- return full_name;
+ return regular && regular->is_struct() && !blacklist::is_struct_blacklisted(*regular);
}
-inline std::string struct_full_name(attributes::struct_def const& struct_)
+inline bool need_struct_conversion(attributes::parameter_def const& param, attributes::regular_type_def const* regular)
{
- std::string full_name;
- for (auto& name : struct_.namespaces)
- {
- full_name += name + ".";
- }
- full_name += struct_.cxx_name;
- return full_name;
-}
+ if (param.direction == attributes::parameter_direction::in && param.type.has_own)
+ return false;
-// Blacklist structs that require some kind of manual binding.
-inline bool is_struct_blacklisted(std::string const& full_name)
-{
- return full_name == "Efl.Event.Description"
- || full_name == "Eina.Binbuf"
- || full_name == "Eina.Slice"
- || full_name == "Eina.Rw_Slice";
+ return need_struct_conversion(regular);
}
-inline bool is_struct_blacklisted(attributes::struct_def const& struct_)
+inline bool need_struct_conversion_in_return(attributes::type_def const& ret_type, attributes::parameter_direction const& direction)
{
- return is_struct_blacklisted(struct_full_name(struct_));
-}
+ auto regular = efl::eina::get<attributes::regular_type_def>(&ret_type.original_type);
-inline bool is_struct_blacklisted(attributes::regular_type_def const& struct_)
-{
- return is_struct_blacklisted(type_full_name(struct_));
-}
+ if (!regular->is_struct())
+ return false;
-inline bool need_struct_conversion(attributes::regular_type_def const* regular)
-{
- return regular && regular->is_struct() && !is_struct_blacklisted(*regular);
+ if (regular->is_struct() && (direction == attributes::parameter_direction::out || direction == attributes::parameter_direction::unknown))
+ return false;
+
+ if (ret_type.has_own)
+ return false;
+
+ return true;
}
inline bool need_pointer_conversion(attributes::regular_type_def const* regular)
@@ -59,7 +48,7 @@ inline bool need_pointer_conversion(attributes::regular_type_def const* regular)
return false;
if (regular->is_enum()
- || (regular->is_struct() && type_full_name(*regular) != "Eina.Binbuf")
+ || (regular->is_struct() && name_helpers::type_full_eolian_name(*regular) != "Eina.Binbuf")
)
return true;
@@ -76,7 +65,8 @@ inline bool need_pointer_conversion(attributes::regular_type_def const* regular)
return false;
}
+} // namespace helpers
-}
+} // namespace eolian_mono
#endif