summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2017-12-06 18:37:48 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2017-12-06 19:10:40 -0300
commitc5ff7f0f4687ccbd670a8094288eae1d6c536809 (patch)
tree8ff28dfb4862e8b7a8912a1c6a55de9cfe4603e9 /src
parent33f285c063d040c568dd666a7b8710848f4f1a5b (diff)
eolian_cxx: Fix Eolian_Unit support
Summary: Unit is now stored in klass_def, parameter_def and function_def for future calls to the Eolian API. Reviewers: felipealmeida, jpeg Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D5613
Diffstat (limited to 'src')
-rw-r--r--src/lib/eolian_cxx/grammar/function_definition.hpp2
-rw-r--r--src/lib/eolian_cxx/grammar/klass_def.hpp46
2 files changed, 27 insertions, 21 deletions
diff --git a/src/lib/eolian_cxx/grammar/function_definition.hpp b/src/lib/eolian_cxx/grammar/function_definition.hpp
index 3161b76041..3c2eab5c74 100644
--- a/src/lib/eolian_cxx/grammar/function_definition.hpp
+++ b/src/lib/eolian_cxx/grammar/function_definition.hpp
@@ -113,7 +113,7 @@ struct function_definition_generator
113 if(!as_generator(scope_tab).generate(sink, attributes::unused, ctx)) return false; 113 if(!as_generator(scope_tab).generate(sink, attributes::unused, ctx)) return false;
114 114
115 if(f.return_type != attributes::void_ 115 if(f.return_type != attributes::void_
116 && !as_generator(attributes::c_type({attributes::parameter_direction::in, f.return_type, ""}) 116 && !as_generator(attributes::c_type({attributes::parameter_direction::in, f.return_type, "", f.unit})
117 << " __return_value = " 117 << " __return_value = "
118 ).generate(sink, attributes::unused, ctx)) return false; 118 ).generate(sink, attributes::unused, ctx)) return false;
119 119
diff --git a/src/lib/eolian_cxx/grammar/klass_def.hpp b/src/lib/eolian_cxx/grammar/klass_def.hpp
index 1cb5ecfba0..e7a32ad396 100644
--- a/src/lib/eolian_cxx/grammar/klass_def.hpp
+++ b/src/lib/eolian_cxx/grammar/klass_def.hpp
@@ -357,6 +357,7 @@ struct parameter_def
357 parameter_direction direction; 357 parameter_direction direction;
358 type_def type; 358 type_def type;
359 std::string param_name; 359 std::string param_name;
360 Eolian_Unit const* unit;
360 361
361 friend inline bool operator==(parameter_def const& lhs, parameter_def const& rhs) 362 friend inline bool operator==(parameter_def const& lhs, parameter_def const& rhs)
362 { 363 {
@@ -369,11 +370,11 @@ struct parameter_def
369 return !(lhs == rhs); 370 return !(lhs == rhs);
370 } 371 }
371 372
372 parameter_def(parameter_direction direction, type_def type, std::string param_name) 373 parameter_def(parameter_direction direction, type_def type, std::string param_name, Eolian_Unit const* unit)
373 : direction(std::move(direction)), type(std::move(type)), param_name(std::move(param_name)) {} 374 : direction(std::move(direction)), type(std::move(type)), param_name(std::move(param_name)), unit(unit) {}
374 parameter_def(Eolian_Function_Parameter const* param, Eolian_Unit const* unit) 375 parameter_def(Eolian_Function_Parameter const* param, Eolian_Unit const* unit)
375 : type( ::eolian_parameter_type_get(param), unit, EOLIAN_C_TYPE_PARAM) 376 : type( ::eolian_parameter_type_get(param), unit, EOLIAN_C_TYPE_PARAM)
376 , param_name( ::eolian_parameter_name_get(param)) 377 , param_name( ::eolian_parameter_name_get(param)), unit(unit)
377 { 378 {
378 Eolian_Parameter_Dir direction = ::eolian_parameter_direction_get(param); 379 Eolian_Parameter_Dir direction = ::eolian_parameter_direction_get(param);
379 switch(direction) 380 switch(direction)
@@ -440,6 +441,7 @@ struct function_def
440 bool is_protected; 441 bool is_protected;
441 bool is_function_pointer; 442 bool is_function_pointer;
442 bool is_static; 443 bool is_static;
444 Eolian_Unit const* unit;
443 445
444 friend inline bool operator==(function_def const& lhs, function_def const& rhs) 446 friend inline bool operator==(function_def const& lhs, function_def const& rhs)
445 { 447 {
@@ -464,13 +466,14 @@ struct function_def
464 std::string _filename, 466 std::string _filename,
465 bool _is_beta = false, 467 bool _is_beta = false,
466 bool _is_protected = false, 468 bool _is_protected = false,
467 bool _is_function_pointer = false) 469 bool _is_function_pointer = false,
470 Eolian_Unit const* unit = nullptr)
468 : return_type(_return_type), name(_name), parameters(_parameters), 471 : return_type(_return_type), name(_name), parameters(_parameters),
469 c_name(_c_name), filename(_filename), is_beta(_is_beta), is_protected(_is_protected), 472 c_name(_c_name), filename(_filename), is_beta(_is_beta), is_protected(_is_protected),
470 is_function_pointer(_is_function_pointer) {} 473 is_function_pointer(_is_function_pointer), unit(unit) {}
471 474
472 function_def( ::Eolian_Function const* function, Eolian_Function_Type type, Eolian_Unit const* unit) 475 function_def( ::Eolian_Function const* function, Eolian_Function_Type type, Eolian_Unit const* unit)
473 : return_type(void_) 476 : return_type(void_), unit(unit)
474 { 477 {
475 Eolian_Type const* r_type = ::eolian_function_return_type_get(function, type); 478 Eolian_Type const* r_type = ::eolian_function_return_type_get(function, type);
476 name = ::eolian_function_name_get(function); 479 name = ::eolian_function_name_get(function);
@@ -735,6 +738,7 @@ struct klass_def
735 std::vector<event_def> events; 738 std::vector<event_def> events;
736 std::set<klass_name, compare_klass_name_by_name> immediate_inherits; 739 std::set<klass_name, compare_klass_name_by_name> immediate_inherits;
737 std::set<part_def> parts; 740 std::set<part_def> parts;
741 Eolian_Unit const* unit;
738 742
739 friend inline bool operator==(klass_def const& lhs, klass_def const& rhs) 743 friend inline bool operator==(klass_def const& lhs, klass_def const& rhs)
740 { 744 {
@@ -775,12 +779,12 @@ struct klass_def
775 , std::vector<std::string> _namespaces 779 , std::vector<std::string> _namespaces
776 , std::vector<function_def> _functions 780 , std::vector<function_def> _functions
777 , std::set<klass_name, compare_klass_name_by_name> _inherits 781 , std::set<klass_name, compare_klass_name_by_name> _inherits
778 , class_type _type) 782 , class_type _type, Eolian_Unit const* unit)
779 : eolian_name(_eolian_name), cxx_name(_cxx_name) 783 : eolian_name(_eolian_name), cxx_name(_cxx_name)
780 , namespaces(_namespaces) 784 , namespaces(_namespaces)
781 , functions(_functions), inherits(_inherits), type(_type) 785 , functions(_functions), inherits(_inherits), type(_type), unit(unit)
782 {} 786 {}
783 klass_def(Eolian_Class const* klass, Eolian_Unit const* unit) 787 klass_def(Eolian_Class const* klass, Eolian_Unit const* unit) : unit(unit)
784 { 788 {
785 for(efl::eina::iterator<const char> namespace_iterator( ::eolian_class_namespaces_get(klass)) 789 for(efl::eina::iterator<const char> namespace_iterator( ::eolian_class_namespaces_get(klass))
786 , namespace_last; namespace_iterator != namespace_last; ++namespace_iterator) 790 , namespace_last; namespace_iterator != namespace_last; ++namespace_iterator)
@@ -885,7 +889,7 @@ struct klass_def
885 889
886 for (auto inherit : inherits) 890 for (auto inherit : inherits)
887 { 891 {
888 klass_def klass(get_klass(inherit, NULL), NULL); 892 klass_def klass(get_klass(inherit, unit), unit);
889 std::copy(klass.functions.cbegin(), klass.functions.cend(), 893 std::copy(klass.functions.cbegin(), klass.functions.cend(),
890 std::back_inserter(ret)); 894 std::back_inserter(ret));
891 } 895 }
@@ -916,12 +920,12 @@ struct enum_value_def
916 std::string name; 920 std::string name;
917 std::string c_name; 921 std::string c_name;
918 922
919 enum_value_def(Eolian_Enum_Type_Field const* enum_field) 923 enum_value_def(Eolian_Enum_Type_Field const* enum_field, Eolian_Unit const* unit)
920 { 924 {
921 name = eolian_typedecl_enum_field_name_get(enum_field); 925 name = eolian_typedecl_enum_field_name_get(enum_field);
922 c_name = eolian_typedecl_enum_field_c_name_get(enum_field); 926 c_name = eolian_typedecl_enum_field_c_name_get(enum_field);
923 auto exp = eolian_typedecl_enum_field_value_get(enum_field, EINA_TRUE); 927 auto exp = eolian_typedecl_enum_field_value_get(enum_field, EINA_TRUE);
924 value = eolian_expression_eval(NULL, exp, EOLIAN_MASK_INT); // FIXME hardcoded int 928 value = eolian_expression_eval(unit, exp, EOLIAN_MASK_INT); // FIXME hardcoded int
925 } 929 }
926}; 930};
927 931
@@ -932,7 +936,7 @@ struct enum_def
932 std::vector<std::string> namespaces; 936 std::vector<std::string> namespaces;
933 std::vector<enum_value_def> fields; 937 std::vector<enum_value_def> fields;
934 938
935 enum_def(Eolian_Typedecl const* enum_obj) 939 enum_def(Eolian_Typedecl const* enum_obj, Eolian_Unit const* unit)
936 { 940 {
937 for(efl::eina::iterator<const char> namespace_iterator( ::eolian_typedecl_namespaces_get(enum_obj)) 941 for(efl::eina::iterator<const char> namespace_iterator( ::eolian_typedecl_namespaces_get(enum_obj))
938 , namespace_last; namespace_iterator != namespace_last; ++namespace_iterator) 942 , namespace_last; namespace_iterator != namespace_last; ++namespace_iterator)
@@ -945,7 +949,8 @@ struct enum_def
945 , field_last; field_iterator != field_last; ++field_iterator) 949 , field_last; field_iterator != field_last; ++field_iterator)
946 { 950 {
947 // Fill the types 951 // Fill the types
948 this->fields.push_back(&*field_iterator); 952 enum_value_def field_def(&*field_iterator, unit);
953 this->fields.push_back(field_def);
949 } 954 }
950 } 955 }
951}; 956};
@@ -955,11 +960,11 @@ struct struct_field_def
955 type_def type; 960 type_def type;
956 std::string name; 961 std::string name;
957 962
958 struct_field_def(Eolian_Struct_Type_Field const* struct_field) 963 struct_field_def(Eolian_Struct_Type_Field const* struct_field, Eolian_Unit const* unit)
959 { 964 {
960 name = eolian_typedecl_struct_field_name_get(struct_field); 965 name = eolian_typedecl_struct_field_name_get(struct_field);
961 try { 966 try {
962 type.set(eolian_typedecl_struct_field_type_get(struct_field), NULL, EOLIAN_C_TYPE_DEFAULT); 967 type.set(eolian_typedecl_struct_field_type_get(struct_field), unit, EOLIAN_C_TYPE_DEFAULT);
963 } catch(std::runtime_error const&) { /* Silently skip pointer fields*/ } 968 } catch(std::runtime_error const&) { /* Silently skip pointer fields*/ }
964 } 969 }
965 970
@@ -972,7 +977,7 @@ struct struct_def
972 std::vector<std::string> namespaces; 977 std::vector<std::string> namespaces;
973 std::vector<struct_field_def> fields; 978 std::vector<struct_field_def> fields;
974 979
975 struct_def(Eolian_Typedecl const* struct_obj) 980 struct_def(Eolian_Typedecl const* struct_obj, Eolian_Unit const* unit)
976 { 981 {
977 for(efl::eina::iterator<const char> namespace_iterator( ::eolian_typedecl_namespaces_get(struct_obj)) 982 for(efl::eina::iterator<const char> namespace_iterator( ::eolian_typedecl_namespaces_get(struct_obj))
978 , namespace_last; namespace_iterator != namespace_last; ++namespace_iterator) 983 , namespace_last; namespace_iterator != namespace_last; ++namespace_iterator)
@@ -984,7 +989,8 @@ struct struct_def
984 for(efl::eina::iterator<const Eolian_Struct_Type_Field> field_iterator(::eolian_typedecl_struct_fields_get(struct_obj)) 989 for(efl::eina::iterator<const Eolian_Struct_Type_Field> field_iterator(::eolian_typedecl_struct_fields_get(struct_obj))
985 , field_last; field_iterator != field_last; ++field_iterator) 990 , field_last; field_iterator != field_last; ++field_iterator)
986 { 991 {
987 this->fields.push_back(&*field_iterator); 992 struct_field_def field_def(&*field_iterator, unit);
993 this->fields.push_back(field_def);
988 } 994 }
989 } 995 }
990}; 996};
@@ -1023,7 +1029,7 @@ inline bool has_events(klass_def const &klass)
1023 1029
1024 for (auto&& c : klass.inherits) 1030 for (auto&& c : klass.inherits)
1025 { 1031 {
1026 attributes::klass_def parent(get_klass(c, NULL), NULL); 1032 attributes::klass_def parent(get_klass(c, klass.unit), klass.unit);
1027 for (auto&& e : parent.events) 1033 for (auto&& e : parent.events)
1028 { 1034 {
1029 (void)e; 1035 (void)e;
@@ -1045,7 +1051,7 @@ inline bool has_type_return(klass_def const &klass, T visitor)
1045 1051
1046 for (auto&& c : klass.inherits) 1052 for (auto&& c : klass.inherits)
1047 { 1053 {
1048 attributes::klass_def parent(get_klass(c, NULL), NULL); 1054 attributes::klass_def parent(get_klass(c, klass.unit), klass.unit);
1049 if (has_type_return(parent, visitor)) 1055 if (has_type_return(parent, visitor))
1050 return true; 1056 return true;
1051 } 1057 }