summaryrefslogtreecommitdiff
path: root/src/lib/eolian_cxx/grammar/klass_def.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/eolian_cxx/grammar/klass_def.hpp')
-rw-r--r--src/lib/eolian_cxx/grammar/klass_def.hpp100
1 files changed, 58 insertions, 42 deletions
diff --git a/src/lib/eolian_cxx/grammar/klass_def.hpp b/src/lib/eolian_cxx/grammar/klass_def.hpp
index 0dd6779..d696931 100644
--- a/src/lib/eolian_cxx/grammar/klass_def.hpp
+++ b/src/lib/eolian_cxx/grammar/klass_def.hpp
@@ -1,3 +1,18 @@
1/*
2 * Copyright 2019 by its authors. See AUTHORS.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
1#ifndef EOLIAN_CXX_KLASS_DEF_HH 16#ifndef EOLIAN_CXX_KLASS_DEF_HH
2#define EOLIAN_CXX_KLASS_DEF_HH 17#define EOLIAN_CXX_KLASS_DEF_HH
3 18
@@ -763,16 +778,35 @@ enum class member_scope
763 778
764struct function_def 779struct function_def
765{ 780{
766 klass_name klass; // Klass information for function_def as method 781 // Klass information for function_def as method
767 type_def return_type; 782 klass_name klass;
783 // Eolian name of the function
768 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
769 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
770 std::string c_name; 801 std::string c_name;
771 std::string filename; 802 std::string filename;
772 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
773 documentation_def documentation; 806 documentation_def documentation;
774 documentation_def return_documentation; 807 documentation_def return_documentation;
775 documentation_def property_documentation; 808 documentation_def property_documentation;
809
776 function_type type; 810 function_type type;
777 member_scope scope; 811 member_scope scope;
778 bool is_beta; 812 bool is_beta;
@@ -786,6 +820,8 @@ struct function_def
786 && lhs.return_type == rhs.return_type 820 && lhs.return_type == rhs.return_type
787 && lhs.name == rhs.name 821 && lhs.name == rhs.name
788 && lhs.parameters == rhs.parameters 822 && lhs.parameters == rhs.parameters
823 && lhs.keys == rhs.keys
824 && lhs.values == rhs.values
789 && lhs.c_name == rhs.c_name 825 && lhs.c_name == rhs.c_name
790 && lhs.filename == rhs.filename 826 && lhs.filename == rhs.filename
791 && lhs.namespaces == rhs.namespaces 827 && lhs.namespaces == rhs.namespaces
@@ -803,46 +839,25 @@ struct function_def
803 return !(lhs == rhs); 839 return !(lhs == rhs);
804 } 840 }
805 function_def() = default; 841 function_def() = default;
806 function_def(klass_name _klass,
807 type_def _return_type, std::string const& _name,
808 std::vector<parameter_def> const& _parameters,
809 std::string const& _c_name,
810 std::string _filename,
811 std::vector<std::string> const& _namespaces,
812 documentation_def _documentation,
813 documentation_def _return_documentation,
814 documentation_def _property_documentation,
815 function_type _type,
816 member_scope _scope,
817 bool _is_beta = false,
818 bool _is_protected = false,
819 bool _is_static = false,
820 Eolian_Unit const* unit = nullptr)
821 : klass(_klass), return_type(_return_type), name(_name),
822 parameters(_parameters), c_name(_c_name), filename(_filename),
823 namespaces(_namespaces),
824 documentation(_documentation),
825 return_documentation(_return_documentation),
826 property_documentation(_property_documentation),
827 type(_type),
828 scope(_scope),
829 is_beta(_is_beta), is_protected(_is_protected),
830 is_static(_is_static),
831 unit(unit) {}
832 842
833 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)
834 : return_type(void_), unit(unit) 844 : return_type(void_), explicit_return_type(void_), unit(unit)
835 { 845 {
836 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);
837 name = ::eolian_function_name_get(function); 847 name = ::eolian_function_name_get(function);
838 return_documentation = eolian_function_return_documentation_get(function, type); 848 return_documentation = eolian_function_return_documentation_get(function, type);
839 scope = static_cast<member_scope>(eolian_function_scope_get(function, type)); 849 scope = static_cast<member_scope>(eolian_function_scope_get(function, type));
840 if(r_type) 850
841 return_type.set(r_type 851 if(r_type)
842 , unit 852 {
843 , eolian_function_return_c_type_get(function, type) 853 return_type.set(r_type
844 , eolian_function_return_is_move(function, type) 854 , unit
845 , 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
846 if(type == EOLIAN_METHOD || type == EOLIAN_FUNCTION_POINTER) 861 if(type == EOLIAN_METHOD || type == EOLIAN_FUNCTION_POINTER)
847 { 862 {
848 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))
@@ -861,9 +876,10 @@ struct function_def
861 ( ::eolian_property_keys_get(function, type)) 876 ( ::eolian_property_keys_get(function, type))
862 , param_last; param_iterator != param_last; ++param_iterator) 877 , param_last; param_iterator != param_last; ++param_iterator)
863 { 878 {
864 parameters.push_back({&*param_iterator, unit}); 879 parameter_def param = {&*param_iterator, unit};
880 parameters.push_back(param);
881 keys.push_back(param);
865 } 882 }
866 std::vector<parameter_def> values;
867 for(efl::eina::iterator<Eolian_Function_Parameter> param_iterator 883 for(efl::eina::iterator<Eolian_Function_Parameter> param_iterator
868 ( ::eolian_property_values_get(function, type)) 884 ( ::eolian_property_values_get(function, type))
869 , param_last; param_iterator != param_last; ++param_iterator) 885 , param_last; param_iterator != param_last; ++param_iterator)