summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2017-09-22 17:46:02 +0200
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2017-09-22 17:46:02 +0200
commit4bae2a7385626e649b635dc4577a193a7d49e8e5 (patch)
tree6a69dfbbd10dabeb48c3487e420b83445eeac005
parentf36e5bd543a1fed2bc93bc803e326684269e28d0 (diff)
eolian: merge REGULAR and COMPLEX types
-rw-r--r--src/bindings/luajit/eolian.lua10
-rw-r--r--src/lib/eolian/Eolian.h14
-rw-r--r--src/lib/eolian/database_expr_api.c5
-rw-r--r--src/lib/eolian/database_type.c10
-rw-r--r--src/lib/eolian/database_validate.c16
-rw-r--r--src/lib/eolian/eo_lexer.c5
-rw-r--r--src/lib/eolian/eo_parser.c1
-rw-r--r--src/lib/eolian_cxx/grammar/klass_def.hpp67
-rw-r--r--src/scripts/elua/apps/docgen/doctree.lua18
9 files changed, 69 insertions, 77 deletions
diff --git a/src/bindings/luajit/eolian.lua b/src/bindings/luajit/eolian.lua
index 9c6a2817e9..7deca59372 100644
--- a/src/bindings/luajit/eolian.lua
+++ b/src/bindings/luajit/eolian.lua
@@ -79,7 +79,6 @@ ffi.cdef [[
79 EOLIAN_TYPE_UNKNOWN_TYPE = 0, 79 EOLIAN_TYPE_UNKNOWN_TYPE = 0,
80 EOLIAN_TYPE_VOID, 80 EOLIAN_TYPE_VOID,
81 EOLIAN_TYPE_REGULAR, 81 EOLIAN_TYPE_REGULAR,
82 EOLIAN_TYPE_COMPLEX,
83 EOLIAN_TYPE_CLASS, 82 EOLIAN_TYPE_CLASS,
84 EOLIAN_TYPE_STATIC_ARRAY, 83 EOLIAN_TYPE_STATIC_ARRAY,
85 EOLIAN_TYPE_TERMINATED_ARRAY, 84 EOLIAN_TYPE_TERMINATED_ARRAY,
@@ -504,11 +503,10 @@ M.type_type = {
504 UNKNOWN = 0, 503 UNKNOWN = 0,
505 VOID = 1, 504 VOID = 1,
506 REGULAR = 2, 505 REGULAR = 2,
507 COMPLEX = 3, 506 CLASS = 3,
508 CLASS = 4, 507 STATIC_ARRAY = 4,
509 STATIC_ARRAY = 5, 508 TERMINATED_ARRAY = 5,
510 TERMINATED_ARRAY = 6, 509 UNDEFINED = 6
511 UNDEFINED = 7
512} 510}
513 511
514M.typedecl_type = { 512M.typedecl_type = {
diff --git a/src/lib/eolian/Eolian.h b/src/lib/eolian/Eolian.h
index fdf14b97fa..5ec4abba42 100644
--- a/src/lib/eolian/Eolian.h
+++ b/src/lib/eolian/Eolian.h
@@ -227,7 +227,6 @@ typedef enum
227 EOLIAN_TYPE_UNKNOWN_TYPE = 0, 227 EOLIAN_TYPE_UNKNOWN_TYPE = 0,
228 EOLIAN_TYPE_VOID, 228 EOLIAN_TYPE_VOID,
229 EOLIAN_TYPE_REGULAR, 229 EOLIAN_TYPE_REGULAR,
230 EOLIAN_TYPE_COMPLEX,
231 EOLIAN_TYPE_CLASS, 230 EOLIAN_TYPE_CLASS,
232 EOLIAN_TYPE_STATIC_ARRAY, 231 EOLIAN_TYPE_STATIC_ARRAY,
233 EOLIAN_TYPE_TERMINATED_ARRAY, 232 EOLIAN_TYPE_TERMINATED_ARRAY,
@@ -1761,8 +1760,8 @@ EAPI Eina_Stringshare *eolian_type_file_get(const Eolian_Type *tp);
1761/* 1760/*
1762 * @brief Get the base type of a type. 1761 * @brief Get the base type of a type.
1763 * 1762 *
1764 * For pointers, this is the type before the star and for complex types, 1763 * Only applies to "complex" ordinary types, i.e. this is the first inner
1765 * this is the first inner type. 1764 * type in <>.
1766 * 1765 *
1767 * @param[in] tp the type. 1766 * @param[in] tp the type.
1768 * @return the base type or NULL. 1767 * @return the base type or NULL.
@@ -1883,8 +1882,8 @@ EAPI Eina_Bool eolian_type_is_ptr(const Eolian_Type *tp);
1883EAPI Eina_Stringshare *eolian_type_c_type_get(const Eolian_Type *tp, Eolian_C_Type_Type ctype); 1882EAPI Eina_Stringshare *eolian_type_c_type_get(const Eolian_Type *tp, Eolian_C_Type_Type ctype);
1884 1883
1885/* 1884/*
1886 * @brief Get the name of the given type. For regular or complex types, this 1885 * @brief Get the name of the given type. For regular types, this is for
1887 * is for example "int". For EOLIAN_TYPE_CLASS, this can be "Button". Keep in 1886 * example "int". For EOLIAN_TYPE_CLASS, this can be "Button". Keep in
1888 * mind that the name doesn't include namespaces. 1887 * mind that the name doesn't include namespaces.
1889 * 1888 *
1890 * @param[in] tp the type. 1889 * @param[in] tp the type.
@@ -1920,8 +1919,9 @@ EAPI Eina_Iterator *eolian_type_namespaces_get(const Eolian_Type *tp);
1920 * @param[in] tp the type. 1919 * @param[in] tp the type.
1921 * @return the free func name. 1920 * @return the free func name.
1922 * 1921 *
1923 * For pointer, class and complex types, this returns name of the func used 1922 * For types that translate to C pointers, this is the function used to
1924 * to free the pointer. For other types, this returns NULL. 1923 * free them. For other types, this is the function to free a pointer to
1924 * those types.
1925 * 1925 *
1926 * @ingroup Eolian 1926 * @ingroup Eolian
1927 */ 1927 */
diff --git a/src/lib/eolian/database_expr_api.c b/src/lib/eolian/database_expr_api.c
index ab6d98efa4..50a0afab44 100644
--- a/src/lib/eolian/database_expr_api.c
+++ b/src/lib/eolian/database_expr_api.c
@@ -26,13 +26,12 @@ _eval_type(const Eolian_Unit *unit, const Eolian_Expression *expr,
26 switch (type->type) 26 switch (type->type)
27 { 27 {
28 case EOLIAN_TYPE_CLASS: 28 case EOLIAN_TYPE_CLASS:
29 case EOLIAN_TYPE_COMPLEX:
30 return database_expr_eval(unit, expr, EOLIAN_MASK_NULL); 29 return database_expr_eval(unit, expr, EOLIAN_MASK_NULL);
31 case EOLIAN_TYPE_REGULAR: 30 case EOLIAN_TYPE_REGULAR:
32 { 31 {
33 int kw = eo_lexer_keyword_str_to_id(type->name); 32 if (database_type_is_ownable(type, EINA_FALSE))
34 if (type->is_ptr)
35 return database_expr_eval(unit, expr, EOLIAN_MASK_NULL); 33 return database_expr_eval(unit, expr, EOLIAN_MASK_NULL);
34 int kw = eo_lexer_keyword_str_to_id(type->name);
36 if (!kw || kw < KW_byte || kw >= KW_void) 35 if (!kw || kw < KW_byte || kw >= KW_void)
37 { 36 {
38 const Eolian_Typedecl *base = eolian_type_typedecl_get(type); 37 const Eolian_Typedecl *base = eolian_type_typedecl_get(type);
diff --git a/src/lib/eolian/database_type.c b/src/lib/eolian/database_type.c
index a05fa25fa5..dda298fbe2 100644
--- a/src/lib/eolian/database_type.c
+++ b/src/lib/eolian/database_type.c
@@ -120,13 +120,8 @@ void
120database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name, 120database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name,
121 Eolian_C_Type_Type ctype) 121 Eolian_C_Type_Type ctype)
122{ 122{
123 if ((tp->type == EOLIAN_TYPE_COMPLEX
124 || tp->type == EOLIAN_TYPE_CLASS)
125 && tp->is_const)
126 {
127 eina_strbuf_append(buf, "const ");
128 }
129 if ((tp->type == EOLIAN_TYPE_REGULAR 123 if ((tp->type == EOLIAN_TYPE_REGULAR
124 || tp->type == EOLIAN_TYPE_CLASS
130 || tp->type == EOLIAN_TYPE_VOID) 125 || tp->type == EOLIAN_TYPE_VOID)
131 && tp->is_const 126 && tp->is_const
132 && ((ctype != EOLIAN_C_TYPE_RETURN) || database_type_is_ownable(tp, EINA_FALSE))) 127 && ((ctype != EOLIAN_C_TYPE_RETURN) || database_type_is_ownable(tp, EINA_FALSE)))
@@ -134,7 +129,6 @@ database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name,
134 eina_strbuf_append(buf, "const "); 129 eina_strbuf_append(buf, "const ");
135 } 130 }
136 if (tp->type == EOLIAN_TYPE_REGULAR 131 if (tp->type == EOLIAN_TYPE_REGULAR
137 || tp->type == EOLIAN_TYPE_COMPLEX
138 || tp->type == EOLIAN_TYPE_CLASS) 132 || tp->type == EOLIAN_TYPE_CLASS)
139 { 133 {
140 Eina_List *l; 134 Eina_List *l;
@@ -162,7 +156,7 @@ database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name,
162 if (tp->is_const && (ctype != EOLIAN_C_TYPE_RETURN)) 156 if (tp->is_const && (ctype != EOLIAN_C_TYPE_RETURN))
163 eina_strbuf_append(buf, " const"); 157 eina_strbuf_append(buf, " const");
164 } 158 }
165 if (tp->type == EOLIAN_TYPE_COMPLEX || tp->type == EOLIAN_TYPE_CLASS) 159 if (tp->type == EOLIAN_TYPE_CLASS)
166 _buf_add_suffix(buf, "*"); 160 _buf_add_suffix(buf, "*");
167 if (tp->is_ptr) 161 if (tp->is_ptr)
168 _buf_add_suffix(buf, "*"); 162 _buf_add_suffix(buf, "*");
diff --git a/src/lib/eolian/database_validate.c b/src/lib/eolian/database_validate.c
index b2df691ac4..980ec628bb 100644
--- a/src/lib/eolian/database_validate.c
+++ b/src/lib/eolian/database_validate.c
@@ -160,15 +160,17 @@ _validate_type(Eolian_Type *tp)
160 case EOLIAN_TYPE_VOID: 160 case EOLIAN_TYPE_VOID:
161 case EOLIAN_TYPE_UNDEFINED: 161 case EOLIAN_TYPE_UNDEFINED:
162 return EINA_TRUE; 162 return EINA_TRUE;
163 case EOLIAN_TYPE_COMPLEX:
164 if (!tp->freefunc)
165 {
166 tp->freefunc = eina_stringshare_add(eo_complex_frees[
167 eo_lexer_keyword_str_to_id(tp->full_name) - KW_accessor]);
168 }
169 return EINA_TRUE;
170 case EOLIAN_TYPE_REGULAR: 163 case EOLIAN_TYPE_REGULAR:
171 { 164 {
165 if (tp->base_type)
166 {
167 if (!tp->freefunc)
168 {
169 tp->freefunc = eina_stringshare_add(eo_complex_frees[
170 eo_lexer_keyword_str_to_id(tp->full_name) - KW_accessor]);
171 }
172 return EINA_TRUE;
173 }
172 Eolian_Typedecl *tpp; 174 Eolian_Typedecl *tpp;
173 /* builtins */ 175 /* builtins */
174 int id = eo_lexer_keyword_str_to_id(tp->full_name); 176 int id = eo_lexer_keyword_str_to_id(tp->full_name);
diff --git a/src/lib/eolian/eo_lexer.c b/src/lib/eolian/eo_lexer.c
index dc5d01fe3c..9318186b82 100644
--- a/src/lib/eolian/eo_lexer.c
+++ b/src/lib/eolian/eo_lexer.c
@@ -73,8 +73,9 @@ static const char * const ctypes[] =
73 73
74 NULL, NULL, /* array types */ 74 NULL, NULL, /* array types */
75 75
76 "Eina_Accessor", "Eina_Array", "Eina_Iterator", "Eina_Hash", "Eina_List", 76 "Eina_Accessor *", "Eina_Array *", "Eina_Iterator *", "Eina_Hash *",
77 "Efl_Future", 77 "Eina_List *",
78 "Efl_Future *",
78 "Eina_Value", "char *", "const char *", "Eina_Stringshare *", 79 "Eina_Value", "char *", "const char *", "Eina_Stringshare *",
79 80
80 "void *", 81 "void *",
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index a523d881a0..3095864c6f 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -806,7 +806,6 @@ parse_type_void(Eo_Lexer *ls, Eina_Bool allow_ref, Eina_Bool allow_sarray)
806 if (tpid >= KW_accessor && tpid <= KW_future) 806 if (tpid >= KW_accessor && tpid <= KW_future)
807 { 807 {
808 int bline = ls->line_number, bcol = ls->column; 808 int bline = ls->line_number, bcol = ls->column;
809 def->type = EOLIAN_TYPE_COMPLEX;
810 check_next(ls, '<'); 809 check_next(ls, '<');
811 if (tpid == KW_future) 810 if (tpid == KW_future)
812 def->base_type = parse_type_void(ls, EINA_FALSE, EINA_FALSE); 811 def->base_type = parse_type_void(ls, EINA_FALSE, EINA_FALSE);
diff --git a/src/lib/eolian_cxx/grammar/klass_def.hpp b/src/lib/eolian_cxx/grammar/klass_def.hpp
index 8bcbfc6b40..3de453eb87 100644
--- a/src/lib/eolian_cxx/grammar/klass_def.hpp
+++ b/src/lib/eolian_cxx/grammar/klass_def.hpp
@@ -253,33 +253,45 @@ inline void type_def::set(Eolian_Type const* eolian_type, Eolian_Unit const* uni
253{ 253{
254 c_type = ::eolian_type_c_type_get(eolian_type, ctype); 254 c_type = ::eolian_type_c_type_get(eolian_type, ctype);
255 // ::eina_stringshare_del(stringshare); // this crashes 255 // ::eina_stringshare_del(stringshare); // this crashes
256 Eolian_Type const* stp = eolian_type_base_type_get(eolian_type);
256 switch( ::eolian_type_type_get(eolian_type)) 257 switch( ::eolian_type_type_get(eolian_type))
257 { 258 {
258 case EOLIAN_TYPE_VOID: 259 case EOLIAN_TYPE_VOID:
259 original_type = attributes::regular_type_def{"void", {qualifiers(eolian_type), {}}, {}}; 260 original_type = attributes::regular_type_def{"void", {qualifiers(eolian_type), {}}, {}};
260 break; 261 break;
261 case EOLIAN_TYPE_REGULAR: 262 case EOLIAN_TYPE_REGULAR:
262 { 263 if (!stp)
263 bool is_undefined = false; 264 {
264 Eolian_Typedecl const* decl = eolian_type_typedecl_get(eolian_type); 265 bool is_undefined = false;
265 bool is_function_ptr = decl && eolian_typedecl_type_get(decl) == EOLIAN_TYPEDECL_FUNCTION_POINTER; 266 Eolian_Typedecl const* decl = eolian_type_typedecl_get(eolian_type);
266 if(decl && eolian_typedecl_type_get(decl) == EOLIAN_TYPEDECL_ALIAS) 267 bool is_function_ptr = decl && eolian_typedecl_type_get(decl) == EOLIAN_TYPEDECL_FUNCTION_POINTER;
267 { 268 if(decl && eolian_typedecl_type_get(decl) == EOLIAN_TYPEDECL_ALIAS)
268 Eolian_Type const* aliased = eolian_typedecl_base_type_get(decl); 269 {
269 if(aliased && eolian_type_type_get(aliased) == EOLIAN_TYPE_UNDEFINED) 270 Eolian_Type const* aliased = eolian_typedecl_base_type_get(decl);
270 { 271 if(aliased && eolian_type_type_get(aliased) == EOLIAN_TYPE_UNDEFINED)
271 is_undefined = true; 272 {
272 } 273 is_undefined = true;
273 } 274 }
274 275 }
275 if(c_type == "va_list *") 276 if(c_type == "va_list *")
276 throw std::runtime_error(""); 277 throw std::runtime_error("");
277 std::vector<std::string> namespaces; 278 std::vector<std::string> namespaces;
278 for(efl::eina::iterator<const char> namespace_iterator( ::eolian_type_namespaces_get(eolian_type)) 279 for(efl::eina::iterator<const char> namespace_iterator( ::eolian_type_namespaces_get(eolian_type))
279 , namespace_last; namespace_iterator != namespace_last; ++namespace_iterator) 280 , namespace_last; namespace_iterator != namespace_last; ++namespace_iterator)
280 namespaces.push_back(&*namespace_iterator); 281 namespaces.push_back(&*namespace_iterator);
281 original_type = {regular_type_def{ ::eolian_type_name_get(eolian_type), {qualifiers(eolian_type), {}}, namespaces, is_undefined, is_function_ptr}}; 282 original_type = {regular_type_def{ ::eolian_type_name_get(eolian_type), {qualifiers(eolian_type), {}}, namespaces, is_undefined, is_function_ptr}};
282 } 283 }
284 else
285 {
286 complex_type_def complex
287 {{::eolian_type_name_get(eolian_type), {qualifiers(eolian_type), {}}, {}}, {}};
288 while (stp)
289 {
290 complex.subtypes.push_back({stp, unit, EOLIAN_C_TYPE_DEFAULT});
291 stp = eolian_type_next_type_get(stp);
292 }
293 original_type = complex;
294 }
283 break; 295 break;
284 case EOLIAN_TYPE_CLASS: 296 case EOLIAN_TYPE_CLASS:
285 { 297 {
@@ -287,19 +299,6 @@ inline void type_def::set(Eolian_Type const* eolian_type, Eolian_Unit const* uni
287 original_type = klass_name(klass, {qualifiers(eolian_type), {}}); 299 original_type = klass_name(klass, {qualifiers(eolian_type), {}});
288 } 300 }
289 break; 301 break;
290 case EOLIAN_TYPE_COMPLEX:
291 {
292 complex_type_def complex
293 {{::eolian_type_name_get(eolian_type), {qualifiers(eolian_type), {}}, {}}, {}};
294 Eolian_Type const* stp = eolian_type_base_type_get(eolian_type);
295 while (stp)
296 {
297 complex.subtypes.push_back({stp, unit, EOLIAN_C_TYPE_DEFAULT});
298 stp = eolian_type_next_type_get(stp);
299 }
300 original_type = complex;
301 }
302 break;
303 default: 302 default:
304 throw std::runtime_error("Type not supported"); 303 throw std::runtime_error("Type not supported");
305 break; 304 break;
diff --git a/src/scripts/elua/apps/docgen/doctree.lua b/src/scripts/elua/apps/docgen/doctree.lua
index 5ff9d3421e..f3876829aa 100644
--- a/src/scripts/elua/apps/docgen/doctree.lua
+++ b/src/scripts/elua/apps/docgen/doctree.lua
@@ -666,7 +666,6 @@ M.Type = Node:clone {
666 UNKNOWN = eolian.type_type.UNKNOWN, 666 UNKNOWN = eolian.type_type.UNKNOWN,
667 VOID = eolian.type_type.VOID, 667 VOID = eolian.type_type.VOID,
668 REGULAR = eolian.type_type.REGULAR, 668 REGULAR = eolian.type_type.REGULAR,
669 COMPLEX = eolian.type_type.COMPLEX,
670 CLASS = eolian.type_type.CLASS, 669 CLASS = eolian.type_type.CLASS,
671 STATIC_ARRAY = eolian.type_type.STATIC_ARRAY, 670 STATIC_ARRAY = eolian.type_type.STATIC_ARRAY,
672 TERMINATED_ARRAY = eolian.type_type.TERMINATED_ARRAY, 671 TERMINATED_ARRAY = eolian.type_type.TERMINATED_ARRAY,
@@ -769,16 +768,17 @@ M.Type = Node:clone {
769 elseif tpt == self.UNDEFINED then 768 elseif tpt == self.UNDEFINED then
770 return wrap_type_attrs(self, "__undefined_type") 769 return wrap_type_attrs(self, "__undefined_type")
771 elseif tpt == self.REGULAR or tpt == self.CLASS then 770 elseif tpt == self.REGULAR or tpt == self.CLASS then
772 return wrap_type_attrs(self, self:full_name_get())
773 elseif tpt == self.COMPLEX then
774 local stypes = {}
775 local stp = self:base_type_get() 771 local stp = self:base_type_get()
776 while stp do 772 if stp then
777 stypes[#stypes + 1] = stp:serialize() 773 local stypes = {}
778 stp = stp:next_type_get() 774 while stp do
775 stypes[#stypes + 1] = stp:serialize()
776 stp = stp:next_type_get()
777 end
778 return wrap_type_attrs(self, self:full_name_get() .. "<"
779 .. table.concat(stypes, ", ") .. ">")
779 end 780 end
780 return wrap_type_attrs(self, self:full_name_get() .. "<" 781 return wrap_type_attrs(self, self:full_name_get())
781 .. table.concat(stypes, ", ") .. ">")
782 elseif tpt == self.STATIC_ARRAY then 782 elseif tpt == self.STATIC_ARRAY then
783 return wrap_type_attrs(self, "static_array<" 783 return wrap_type_attrs(self, "static_array<"
784 .. self:base_type_get():serialize() .. ", " 784 .. self:base_type_get():serialize() .. ", "