summaryrefslogtreecommitdiff
path: root/src/lib/eolian_cxx/grammar/klass_def.hpp
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-10-28 20:35:39 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2019-10-28 20:35:39 -0300
commit135c69b23c7d091bb114022f3eb0c1788758a67c (patch)
tree594c39baa3e7519fe0aa1d79ca63e2ab705c5bbc /src/lib/eolian_cxx/grammar/klass_def.hpp
parentba34325f430903c8b3c1695f611bc858ab7e71a7 (diff)
eolian_cxx: Add key/value to function_def
Summary: This commit adds explicit eolian key/value/return info to function_def. The original parameter/return types are kept for compatibility. parameter/return -> Mimics the behavior of the generated C API (i.e. single-valued getters have their lone value translated to be their return type) explicit_return -> The actual return value for that block in the EO file. keys/values -> The values for respectively key and values blocks. This should help working with properties in the generators instead of fumbling with paremeter/return directly Fixes T8431 Test Plan: extra tests in the diff Reviewers: felipealmeida, brunobelo, segfaultxavi, YOhoho Reviewed By: brunobelo Subscribers: cedric, #reviewers, #committers, woohyun Tags: #efl Maniphest Tasks: T8431 Differential Revision: https://phab.enlightenment.org/D10494
Diffstat (limited to '')
-rw-r--r--src/lib/eolian_cxx/grammar/klass_def.hpp85
1 files changed, 43 insertions, 42 deletions
diff --git a/src/lib/eolian_cxx/grammar/klass_def.hpp b/src/lib/eolian_cxx/grammar/klass_def.hpp
index 3356a6ff77..d6969315e7 100644
--- a/src/lib/eolian_cxx/grammar/klass_def.hpp
+++ b/src/lib/eolian_cxx/grammar/klass_def.hpp
@@ -778,16 +778,35 @@ enum class member_scope
778 778
779struct function_def 779struct function_def
780{ 780{
781 klass_name klass; // Klass information for function_def as method 781 // Klass information for function_def as method
782 type_def return_type; 782 klass_name klass;
783 // Eolian name of the function
783 std::string name; 784 std::string name;
785
786 // Actual return type as expected in the C version of this function.
787 // For property getters, this could be the type of the single
788 // value it holds
789 type_def return_type;
790 // Parameters of this function as the C implementation of it
784 std::vector<parameter_def> parameters; 791 std::vector<parameter_def> parameters;
792
793 // Original return type as declared in the Eo.
794 type_def explicit_return_type;
795 // Original Eolian keys of this function. Used only for properties
796 std::vector<parameter_def> keys;
797 // Original Eolian values of this function. Used only for properties
798 std::vector<parameter_def> values;
799
800 // Name of this function in the C api
785 std::string c_name; 801 std::string c_name;
786 std::string filename; 802 std::string filename;
787 std::vector<std::string> namespaces; // Namespaces for top-level function pointers 803 // Namespaces for top-level function pointers
804 std::vector<std::string> namespaces;
805
788 documentation_def documentation; 806 documentation_def documentation;
789 documentation_def return_documentation; 807 documentation_def return_documentation;
790 documentation_def property_documentation; 808 documentation_def property_documentation;
809
791 function_type type; 810 function_type type;
792 member_scope scope; 811 member_scope scope;
793 bool is_beta; 812 bool is_beta;
@@ -801,6 +820,8 @@ struct function_def
801 && lhs.return_type == rhs.return_type 820 && lhs.return_type == rhs.return_type
802 && lhs.name == rhs.name 821 && lhs.name == rhs.name
803 && lhs.parameters == rhs.parameters 822 && lhs.parameters == rhs.parameters
823 && lhs.keys == rhs.keys
824 && lhs.values == rhs.values
804 && lhs.c_name == rhs.c_name 825 && lhs.c_name == rhs.c_name
805 && lhs.filename == rhs.filename 826 && lhs.filename == rhs.filename
806 && lhs.namespaces == rhs.namespaces 827 && lhs.namespaces == rhs.namespaces
@@ -818,46 +839,25 @@ struct function_def
818 return !(lhs == rhs); 839 return !(lhs == rhs);
819 } 840 }
820 function_def() = default; 841 function_def() = default;
821 function_def(klass_name _klass,
822 type_def _return_type, std::string const& _name,
823 std::vector<parameter_def> const& _parameters,
824 std::string const& _c_name,
825 std::string _filename,
826 std::vector<std::string> const& _namespaces,
827 documentation_def _documentation,
828 documentation_def _return_documentation,
829 documentation_def _property_documentation,
830 function_type _type,
831 member_scope _scope,
832 bool _is_beta = false,
833 bool _is_protected = false,
834 bool _is_static = false,
835 Eolian_Unit const* unit = nullptr)
836 : klass(_klass), return_type(_return_type), name(_name),
837 parameters(_parameters), c_name(_c_name), filename(_filename),
838 namespaces(_namespaces),
839 documentation(_documentation),
840 return_documentation(_return_documentation),
841 property_documentation(_property_documentation),
842 type(_type),
843 scope(_scope),
844 is_beta(_is_beta), is_protected(_is_protected),
845 is_static(_is_static),
846 unit(unit) {}
847 842
848 function_def( ::Eolian_Function const* function, Eolian_Function_Type type, Eolian_Typedecl const* tp, Eolian_Unit const* unit) 843 function_def( ::Eolian_Function const* function, Eolian_Function_Type type, Eolian_Typedecl const* tp, Eolian_Unit const* unit)
849 : return_type(void_), unit(unit) 844 : return_type(void_), explicit_return_type(void_), unit(unit)
850 { 845 {
851 Eolian_Type const* r_type = ::eolian_function_return_type_get(function, type); 846 Eolian_Type const* r_type = ::eolian_function_return_type_get(function, type);
852 name = ::eolian_function_name_get(function); 847 name = ::eolian_function_name_get(function);
853 return_documentation = eolian_function_return_documentation_get(function, type); 848 return_documentation = eolian_function_return_documentation_get(function, type);
854 scope = static_cast<member_scope>(eolian_function_scope_get(function, type)); 849 scope = static_cast<member_scope>(eolian_function_scope_get(function, type));
855 if(r_type) 850
856 return_type.set(r_type 851 if(r_type)
857 , unit 852 {
858 , eolian_function_return_c_type_get(function, type) 853 return_type.set(r_type
859 , eolian_function_return_is_move(function, type) 854 , unit
860 , eolian_function_return_is_by_ref(function, type)); 855 , eolian_function_return_c_type_get(function, type)
856 , eolian_function_return_is_move(function, type)
857 , eolian_function_return_is_by_ref(function, type));
858 explicit_return_type = return_type;
859 }
860
861 if(type == EOLIAN_METHOD || type == EOLIAN_FUNCTION_POINTER) 861 if(type == EOLIAN_METHOD || type == EOLIAN_FUNCTION_POINTER)
862 { 862 {
863 for(efl::eina::iterator<Eolian_Function_Parameter> param_iterator ( ::eolian_function_parameters_get(function)) 863 for(efl::eina::iterator<Eolian_Function_Parameter> param_iterator ( ::eolian_function_parameters_get(function))
@@ -876,9 +876,10 @@ struct function_def
876 ( ::eolian_property_keys_get(function, type)) 876 ( ::eolian_property_keys_get(function, type))
877 , param_last; param_iterator != param_last; ++param_iterator) 877 , param_last; param_iterator != param_last; ++param_iterator)
878 { 878 {
879 parameters.push_back({&*param_iterator, unit}); 879 parameter_def param = {&*param_iterator, unit};
880 parameters.push_back(param);
881 keys.push_back(param);
880 } 882 }
881 std::vector<parameter_def> values;
882 for(efl::eina::iterator<Eolian_Function_Parameter> param_iterator 883 for(efl::eina::iterator<Eolian_Function_Parameter> param_iterator
883 ( ::eolian_property_values_get(function, type)) 884 ( ::eolian_property_values_get(function, type))
884 , param_last; param_iterator != param_last; ++param_iterator) 885 , param_last; param_iterator != param_last; ++param_iterator)