summaryrefslogtreecommitdiff
path: root/src/lib/eolian_cxx/grammar/klass_def.hpp
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2019-09-24 17:06:24 +0200
committerDaniel Kolesa <d.kolesa@samsung.com>2019-09-24 18:27:37 +0200
commit92da64a532f8c1746d7bd06b66b7ff4409c2ff8c (patch)
tree02e05754553c64c119f2e78194f5527d5cf0ff1e /src/lib/eolian_cxx/grammar/klass_def.hpp
parent553ce69bade88ac675aa56fcb184240403a12bfc (diff)
eolian: remove support for globals
This was meant to happen but did not previously happen. It is not ideal to do it now but better do it while we still can. In short, this removes one half of the variables API (keeps constants as they are) and repurposes the API to be only for constants. This is also better for consistency to match errors.
Diffstat (limited to '')
-rw-r--r--src/lib/eolian_cxx/grammar/klass_def.hpp45
1 files changed, 16 insertions, 29 deletions
diff --git a/src/lib/eolian_cxx/grammar/klass_def.hpp b/src/lib/eolian_cxx/grammar/klass_def.hpp
index a7a01cc243..ce3053331c 100644
--- a/src/lib/eolian_cxx/grammar/klass_def.hpp
+++ b/src/lib/eolian_cxx/grammar/klass_def.hpp
@@ -113,13 +113,6 @@ inline typedecl_type typedecl_type_get(Eolian_Typedecl const* decl)
113 } 113 }
114} 114}
115 115
116enum class variable_type
117{
118 unknown,
119 constant,
120 global
121};
122
123 116
124struct type_def; 117struct type_def;
125bool operator==(type_def const& lhs, type_def const& rhs); 118bool operator==(type_def const& lhs, type_def const& rhs);
@@ -1070,63 +1063,57 @@ struct property_def
1070 } 1063 }
1071}; 1064};
1072 1065
1073struct variable_def 1066struct constant_def
1074{ 1067{
1075 std::string name; 1068 std::string name;
1076 std::string full_name; 1069 std::string full_name;
1077 type_def base_type; 1070 type_def base_type;
1078 documentation_def documentation; 1071 documentation_def documentation;
1079 variable_type type;
1080 std::vector<std::string> namespaces; 1072 std::vector<std::string> namespaces;
1081 Eolian_Value expression_value; 1073 Eolian_Value expression_value;
1082 bool is_extern : 1; 1074 bool is_extern : 1;
1083 1075
1084 friend inline bool operator==(variable_def const& lhs, variable_def const& rhs) 1076 friend inline bool operator==(constant_def const& lhs, constant_def const& rhs)
1085 { 1077 {
1086 return lhs.name == rhs.name 1078 return lhs.name == rhs.name
1087 && lhs.full_name == rhs.full_name 1079 && lhs.full_name == rhs.full_name
1088 && lhs.base_type == rhs.base_type 1080 && lhs.base_type == rhs.base_type
1089 && lhs.documentation == rhs.documentation 1081 && lhs.documentation == rhs.documentation
1090 && lhs.type == rhs.type
1091 && lhs.namespaces == rhs.namespaces 1082 && lhs.namespaces == rhs.namespaces
1092 && lhs.expression_value.type == rhs.expression_value.type 1083 && lhs.expression_value.type == rhs.expression_value.type
1093 && lhs.expression_value.value.ll == rhs.expression_value.value.ll 1084 && lhs.expression_value.value.ll == rhs.expression_value.value.ll
1094 && lhs.is_extern == rhs.is_extern; 1085 && lhs.is_extern == rhs.is_extern;
1095 } 1086 }
1096 1087
1097 friend inline bool operator!=(variable_def const& lhs, variable_def const& rhs) 1088 friend inline bool operator!=(constant_def const& lhs, constant_def const& rhs)
1098 { 1089 {
1099 return !(lhs == rhs); 1090 return !(lhs == rhs);
1100 } 1091 }
1101 1092
1102 variable_def() = default; 1093 constant_def() = default;
1103 variable_def(Eolian_Variable const* variable, Eolian_Unit const* unit) 1094 constant_def(Eolian_Constant const* constant, Eolian_Unit const* unit)
1104 : name(::eolian_variable_short_name_get(variable)) 1095 : name(::eolian_constant_short_name_get(constant))
1105 , full_name(::eolian_variable_name_get(variable)) 1096 , full_name(::eolian_constant_name_get(constant))
1106 , base_type(::eolian_variable_base_type_get(variable) 1097 , base_type(::eolian_constant_base_type_get(constant)
1107 , unit 1098 , unit
1108 , ::eolian_type_c_type_get(eolian_variable_base_type_get(variable)) 1099 , ::eolian_type_c_type_get(eolian_constant_base_type_get(constant))
1109 , value_ownership::unmoved 1100 , value_ownership::unmoved
1110 , is_by::value) 1101 , is_by::value)
1111 , documentation(::eolian_variable_documentation_get(variable)) 1102 , documentation(::eolian_constant_documentation_get(constant))
1112 , type(static_cast<variable_type>(::eolian_variable_type_get(variable)))
1113 , expression_value() 1103 , expression_value()
1114 , is_extern(::eolian_variable_is_extern(variable)) 1104 , is_extern(::eolian_constant_is_extern(constant))
1115 { 1105 {
1116 for(efl::eina::iterator<const char> namespace_iterator( ::eolian_variable_namespaces_get(variable)) 1106 for(efl::eina::iterator<const char> namespace_iterator( ::eolian_constant_namespaces_get(constant))
1117 , namespace_last; namespace_iterator != namespace_last; ++namespace_iterator) 1107 , namespace_last; namespace_iterator != namespace_last; ++namespace_iterator)
1118 { 1108 {
1119 this->namespaces.push_back((&*namespace_iterator)); 1109 this->namespaces.push_back((&*namespace_iterator));
1120 } 1110 }
1121 1111
1122 if (this->type == variable_type::constant) 1112 auto expr = ::eolian_constant_value_get(constant);
1123 { 1113 if (!expr)
1124 auto expr = ::eolian_variable_value_get(variable); 1114 throw std::runtime_error("Could not get constant variable value expression");
1125 if (!expr)
1126 throw std::runtime_error("Could not get constant variable value expression");
1127 1115
1128 this->expression_value = ::eolian_expression_eval(expr, ::EOLIAN_MASK_ALL); 1116 this->expression_value = ::eolian_expression_eval(expr, ::EOLIAN_MASK_ALL);
1129 }
1130 } 1117 }
1131}; 1118};
1132 1119