summaryrefslogtreecommitdiff
path: root/src/lib/eolian_cxx
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2017-08-22 22:31:55 -0300
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2017-08-22 22:40:13 -0300
commita7649a7897218f3d66d72c15851aa566f00ca1f7 (patch)
treeac45179937f3a9cc1950616a8dbe3d6b666dd4ca /src/lib/eolian_cxx
parent2f53bdfe60c9730ad8274616d556ac408aaf149f (diff)
eolian-cxx: Add workaround for function pointer types
Diffstat (limited to 'src/lib/eolian_cxx')
-rw-r--r--src/lib/eolian_cxx/grammar/converting_argument.hpp31
-rw-r--r--src/lib/eolian_cxx/grammar/klass_def.hpp11
2 files changed, 36 insertions, 6 deletions
diff --git a/src/lib/eolian_cxx/grammar/converting_argument.hpp b/src/lib/eolian_cxx/grammar/converting_argument.hpp
index cb3f750544..07255800ca 100644
--- a/src/lib/eolian_cxx/grammar/converting_argument.hpp
+++ b/src/lib/eolian_cxx/grammar/converting_argument.hpp
@@ -19,11 +19,40 @@ namespace efl { namespace eolian { namespace grammar {
19 19
20struct converting_argument_generator 20struct converting_argument_generator
21{ 21{
22 struct
23 {
24 typedef bool result_type;
25 template <typename T>
26 bool operator()(T const&) const { return false;}
27 bool operator()(attributes::regular_type_def const& r) const
28 {
29 return r.is_function_ptr;
30 }
31 } static const is_function_ptr;
22 template <typename OutputIterator, typename Context> 32 template <typename OutputIterator, typename Context>
23 bool generate(OutputIterator sink, attributes::parameter_def const& param, Context const& ctx) const 33 bool generate(OutputIterator sink, attributes::parameter_def const& param, Context const& ctx) const
24 { 34 {
25 attributes::qualifier_def qualifier = param.type.original_type.visit(attributes::get_qualifier_visitor{}); 35 attributes::qualifier_def qualifier = param.type.original_type.visit(attributes::get_qualifier_visitor{});
26 return as_generator 36 bool is_function_ptr = param.type.original_type.visit(this->is_function_ptr);
37 if(is_function_ptr)
38 return as_generator
39 (
40 attribute_reorder<-1, -1, 2, -1, -1, -1, -1>
41 (
42 " ::efl::eolian::data_function_ptr_to_c<" << c_type
43 << ", " << parameter_type
44 << ">(" << string << ")"
45
46 ", ::efl::eolian::function_ptr_to_c<" << c_type
47 << ", " << parameter_type
48 << ">()"
49 ", ::efl::eolian::free_function_ptr_to_c<" << c_type
50 << ", " << parameter_type
51 << ">()"
52 )
53 ).generate(sink, param, ctx);
54 else
55 return as_generator
27 ( 56 (
28 attribute_reorder<-1, -1, 2> 57 attribute_reorder<-1, -1, 2>
29 ( 58 (
diff --git a/src/lib/eolian_cxx/grammar/klass_def.hpp b/src/lib/eolian_cxx/grammar/klass_def.hpp
index 63d876f491..8bcbfc6b40 100644
--- a/src/lib/eolian_cxx/grammar/klass_def.hpp
+++ b/src/lib/eolian_cxx/grammar/klass_def.hpp
@@ -171,16 +171,16 @@ get(klass_name const& klass)
171 171
172struct regular_type_def 172struct regular_type_def
173{ 173{
174 regular_type_def() : is_undefined(false) {} 174 regular_type_def() : is_undefined(false), is_function_ptr(false) {}
175 regular_type_def(std::string base_type, qualifier_def qual, std::vector<std::string> namespaces 175 regular_type_def(std::string base_type, qualifier_def qual, std::vector<std::string> namespaces
176 , bool is_undefined = false) 176 , bool is_undefined = false, bool is_function_ptr = false)
177 : base_type(std::move(base_type)), base_qualifier(qual), namespaces(std::move(namespaces)) 177 : base_type(std::move(base_type)), base_qualifier(qual), namespaces(std::move(namespaces))
178 , is_undefined(is_undefined) {} 178 , is_undefined(is_undefined), is_function_ptr(is_function_ptr) {}
179 179
180 std::string base_type; 180 std::string base_type;
181 qualifier_def base_qualifier; 181 qualifier_def base_qualifier;
182 std::vector<std::string> namespaces; 182 std::vector<std::string> namespaces;
183 bool is_undefined; 183 bool is_undefined, is_function_ptr;
184}; 184};
185 185
186inline bool operator==(regular_type_def const& rhs, regular_type_def const& lhs) 186inline bool operator==(regular_type_def const& rhs, regular_type_def const& lhs)
@@ -262,6 +262,7 @@ inline void type_def::set(Eolian_Type const* eolian_type, Eolian_Unit const* uni
262 { 262 {
263 bool is_undefined = false; 263 bool is_undefined = false;
264 Eolian_Typedecl const* decl = eolian_type_typedecl_get(eolian_type); 264 Eolian_Typedecl const* decl = eolian_type_typedecl_get(eolian_type);
265 bool is_function_ptr = decl && eolian_typedecl_type_get(decl) == EOLIAN_TYPEDECL_FUNCTION_POINTER;
265 if(decl && eolian_typedecl_type_get(decl) == EOLIAN_TYPEDECL_ALIAS) 266 if(decl && eolian_typedecl_type_get(decl) == EOLIAN_TYPEDECL_ALIAS)
266 { 267 {
267 Eolian_Type const* aliased = eolian_typedecl_base_type_get(decl); 268 Eolian_Type const* aliased = eolian_typedecl_base_type_get(decl);
@@ -277,7 +278,7 @@ inline void type_def::set(Eolian_Type const* eolian_type, Eolian_Unit const* uni
277 for(efl::eina::iterator<const char> namespace_iterator( ::eolian_type_namespaces_get(eolian_type)) 278 for(efl::eina::iterator<const char> namespace_iterator( ::eolian_type_namespaces_get(eolian_type))
278 , namespace_last; namespace_iterator != namespace_last; ++namespace_iterator) 279 , namespace_last; namespace_iterator != namespace_last; ++namespace_iterator)
279 namespaces.push_back(&*namespace_iterator); 280 namespaces.push_back(&*namespace_iterator);
280 original_type = {regular_type_def{ ::eolian_type_name_get(eolian_type), {qualifiers(eolian_type), {}}, namespaces, is_undefined}}; 281 original_type = {regular_type_def{ ::eolian_type_name_get(eolian_type), {qualifiers(eolian_type), {}}, namespaces, is_undefined, is_function_ptr}};
281 } 282 }
282 break; 283 break;
283 case EOLIAN_TYPE_CLASS: 284 case EOLIAN_TYPE_CLASS: