summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2017-09-22 18:01:15 +0200
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2017-09-22 18:01:15 +0200
commit1577c576e6141eeb80f9e6c7018310690bb1d8bc (patch)
tree787ebb7cad35729ca10d844587d268d574c20972
parent4bae2a7385626e649b635dc4577a193a7d49e8e5 (diff)
eolian: remove static_array and terminated_array
These types are of questionable value and the API was not entirely thought out - remove for now, and if a legitimate use is found later, they may be readded (with a better API), but typically it seems best to redesign the bad APIs around safe containers...
-rw-r--r--src/bin/eolian/types.c20
-rw-r--r--src/bindings/luajit/eolian.lua11
-rw-r--r--src/lib/eolian/Eolian.h12
-rw-r--r--src/lib/eolian/database_type_api.c7
-rw-r--r--src/lib/eolian/database_validate.c11
-rw-r--r--src/lib/eolian/eo_lexer.c2
-rw-r--r--src/lib/eolian/eo_lexer.h2
-rw-r--r--src/lib/eolian/eo_parser.c42
-rw-r--r--src/lib/eolian/eolian_database.h1
-rw-r--r--src/scripts/elua/apps/docgen/doctree.lua13
-rw-r--r--src/tests/eolian/data/struct.eo2
-rw-r--r--src/tests/eolian/data/struct_ref.c2
-rw-r--r--src/tests/eolian/eolian_parsing.c15
13 files changed, 5 insertions, 135 deletions
diff --git a/src/bin/eolian/types.c b/src/bin/eolian/types.c
index ec06c81869..ae4cd72d63 100644
--- a/src/bin/eolian/types.c
+++ b/src/bin/eolian/types.c
@@ -41,22 +41,10 @@ _type_generate(const Eolian_Unit *src, const Eolian_Typedecl *tp,
41 { 41 {
42 const Eolian_Type *mtp = eolian_typedecl_struct_field_type_get(memb); 42 const Eolian_Type *mtp = eolian_typedecl_struct_field_type_get(memb);
43 Eina_Stringshare *ct = NULL; 43 Eina_Stringshare *ct = NULL;
44 if (eolian_type_type_get(mtp) == EOLIAN_TYPE_STATIC_ARRAY) 44 ct = eolian_type_c_type_get(mtp, EOLIAN_C_TYPE_DEFAULT);
45 { 45 eina_strbuf_append_printf(buf, " %s%s%s;",
46 ct = eolian_type_c_type_get(eolian_type_base_type_get(mtp), 46 ct, strchr(ct, '*') ? "" : " ",
47 EOLIAN_C_TYPE_DEFAULT); 47 eolian_typedecl_struct_field_name_get(memb));
48 eina_strbuf_append_printf(buf, " %s%s%s[%zu];",
49 ct, strchr(ct, '*') ? "" : " ",
50 eolian_typedecl_struct_field_name_get(memb),
51 eolian_type_array_size_get(mtp));
52 }
53 else
54 {
55 ct = eolian_type_c_type_get(mtp, EOLIAN_C_TYPE_DEFAULT);
56 eina_strbuf_append_printf(buf, " %s%s%s;",
57 ct, strchr(ct, '*') ? "" : " ",
58 eolian_typedecl_struct_field_name_get(memb));
59 }
60 eina_stringshare_del(ct); 48 eina_stringshare_del(ct);
61 const Eolian_Documentation *fdoc 49 const Eolian_Documentation *fdoc
62 = eolian_typedecl_struct_field_documentation_get(memb); 50 = eolian_typedecl_struct_field_documentation_get(memb);
diff --git a/src/bindings/luajit/eolian.lua b/src/bindings/luajit/eolian.lua
index 7deca59372..1f3c009682 100644
--- a/src/bindings/luajit/eolian.lua
+++ b/src/bindings/luajit/eolian.lua
@@ -80,8 +80,6 @@ ffi.cdef [[
80 EOLIAN_TYPE_VOID, 80 EOLIAN_TYPE_VOID,
81 EOLIAN_TYPE_REGULAR, 81 EOLIAN_TYPE_REGULAR,
82 EOLIAN_TYPE_CLASS, 82 EOLIAN_TYPE_CLASS,
83 EOLIAN_TYPE_STATIC_ARRAY,
84 EOLIAN_TYPE_TERMINATED_ARRAY,
85 EOLIAN_TYPE_UNDEFINED 83 EOLIAN_TYPE_UNDEFINED
86 } Eolian_Type_Type; 84 } Eolian_Type_Type;
87 85
@@ -342,7 +340,6 @@ ffi.cdef [[
342 const Eolian_Type *eolian_typedecl_aliased_base_get(const Eolian_Typedecl *tp); 340 const Eolian_Type *eolian_typedecl_aliased_base_get(const Eolian_Typedecl *tp);
343 341
344 const Eolian_Class *eolian_type_class_get(const Eolian_Unit *unit, const Eolian_Type *tp); 342 const Eolian_Class *eolian_type_class_get(const Eolian_Unit *unit, const Eolian_Type *tp);
345 size_t eolian_type_array_size_get(const Eolian_Type *tp);
346 Eina_Bool eolian_type_is_owned(const Eolian_Type *tp); 343 Eina_Bool eolian_type_is_owned(const Eolian_Type *tp);
347 Eina_Bool eolian_type_is_const(const Eolian_Type *tp); 344 Eina_Bool eolian_type_is_const(const Eolian_Type *tp);
348 Eina_Bool eolian_type_is_ptr(const Eolian_Type *tp); 345 Eina_Bool eolian_type_is_ptr(const Eolian_Type *tp);
@@ -504,9 +501,7 @@ M.type_type = {
504 VOID = 1, 501 VOID = 1,
505 REGULAR = 2, 502 REGULAR = 2,
506 CLASS = 3, 503 CLASS = 3,
507 STATIC_ARRAY = 4, 504 UNDEFINED = 4
508 TERMINATED_ARRAY = 5,
509 UNDEFINED = 6
510} 505}
511 506
512M.typedecl_type = { 507M.typedecl_type = {
@@ -715,10 +710,6 @@ M.Type = ffi.metatype("Eolian_Type", {
715 return v 710 return v
716 end, 711 end,
717 712
718 array_size_get = function(self)
719 return tonumber(eolian.eolian_type_array_size_get(self))
720 end,
721
722 is_owned = function(self) 713 is_owned = function(self)
723 return eolian.eolian_type_is_owned(self) ~= 0 714 return eolian.eolian_type_is_owned(self) ~= 0
724 end, 715 end,
diff --git a/src/lib/eolian/Eolian.h b/src/lib/eolian/Eolian.h
index 5ec4abba42..458a7343e6 100644
--- a/src/lib/eolian/Eolian.h
+++ b/src/lib/eolian/Eolian.h
@@ -228,8 +228,6 @@ typedef enum
228 EOLIAN_TYPE_VOID, 228 EOLIAN_TYPE_VOID,
229 EOLIAN_TYPE_REGULAR, 229 EOLIAN_TYPE_REGULAR,
230 EOLIAN_TYPE_CLASS, 230 EOLIAN_TYPE_CLASS,
231 EOLIAN_TYPE_STATIC_ARRAY,
232 EOLIAN_TYPE_TERMINATED_ARRAY,
233 EOLIAN_TYPE_UNDEFINED 231 EOLIAN_TYPE_UNDEFINED
234} Eolian_Type_Type; 232} Eolian_Type_Type;
235 233
@@ -1825,16 +1823,6 @@ EAPI const Eolian_Type *eolian_type_aliased_base_get(const Eolian_Type *tp);
1825EAPI const Eolian_Class *eolian_type_class_get(const Eolian_Unit *unit, const Eolian_Type *tp); 1823EAPI const Eolian_Class *eolian_type_class_get(const Eolian_Unit *unit, const Eolian_Type *tp);
1826 1824
1827/* 1825/*
1828 * @brief Get the size of an EOLIAN_TYPE_STATIC_ARRAY.
1829 *
1830 * @param[in] tp the type.
1831 * @return the size or 0.
1832 *
1833 * @ingroup Eolian
1834 */
1835EAPI size_t eolian_type_array_size_get(const Eolian_Type *tp);
1836
1837/*
1838 * @brief Get whether the given type is owned. 1826 * @brief Get whether the given type is owned.
1839 * 1827 *
1840 * This is true when a parameter, return or whatever is marked as @owned. 1828 * This is true when a parameter, return or whatever is marked as @owned.
diff --git a/src/lib/eolian/database_type_api.c b/src/lib/eolian/database_type_api.c
index 8d83a8f273..f1db367ec4 100644
--- a/src/lib/eolian/database_type_api.c
+++ b/src/lib/eolian/database_type_api.c
@@ -319,13 +319,6 @@ eolian_type_class_get(const Eolian_Unit *unit, const Eolian_Type *tp)
319 return eolian_class_get_by_name(unit, tp->full_name); 319 return eolian_class_get_by_name(unit, tp->full_name);
320} 320}
321 321
322EAPI size_t
323eolian_type_array_size_get(const Eolian_Type *tp)
324{
325 EINA_SAFETY_ON_NULL_RETURN_VAL(tp, 0);
326 return tp->static_size;
327}
328
329EAPI Eina_Bool 322EAPI Eina_Bool
330eolian_type_is_owned(const Eolian_Type *tp) 323eolian_type_is_owned(const Eolian_Type *tp)
331{ 324{
diff --git a/src/lib/eolian/database_validate.c b/src/lib/eolian/database_validate.c
index 980ec628bb..0a296224da 100644
--- a/src/lib/eolian/database_validate.c
+++ b/src/lib/eolian/database_validate.c
@@ -208,17 +208,6 @@ _validate_type(Eolian_Type *tp)
208 tp->freefunc = eina_stringshare_ref(tpp->freefunc); 208 tp->freefunc = eina_stringshare_ref(tpp->freefunc);
209 return EINA_TRUE; 209 return EINA_TRUE;
210 } 210 }
211 case EOLIAN_TYPE_TERMINATED_ARRAY:
212 if (!database_type_is_ownable(tp->base_type, EINA_TRUE))
213 {
214 snprintf(buf, sizeof(buf),
215 "invalid base type '%s' for terminated array",
216 tp->base_type->full_name);
217 return _type_error(tp, buf);
218 }
219 return _validate_type(tp->base_type);
220 case EOLIAN_TYPE_STATIC_ARRAY:
221 return _validate_type(tp->base_type);
222 case EOLIAN_TYPE_CLASS: 211 case EOLIAN_TYPE_CLASS:
223 { 212 {
224 /* FIXME: pass unit properly */ 213 /* FIXME: pass unit properly */
diff --git a/src/lib/eolian/eo_lexer.c b/src/lib/eolian/eo_lexer.c
index 9318186b82..188af3c20e 100644
--- a/src/lib/eolian/eo_lexer.c
+++ b/src/lib/eolian/eo_lexer.c
@@ -71,8 +71,6 @@ static const char * const ctypes[] =
71 71
72 "void", 72 "void",
73 73
74 NULL, NULL, /* array types */
75
76 "Eina_Accessor *", "Eina_Array *", "Eina_Iterator *", "Eina_Hash *", 74 "Eina_Accessor *", "Eina_Array *", "Eina_Iterator *", "Eina_Hash *",
77 "Eina_List *", 75 "Eina_List *",
78 "Efl_Future *", 76 "Efl_Future *",
diff --git a/src/lib/eolian/eo_lexer.h b/src/lib/eolian/eo_lexer.h
index 88e68a4690..849cc98efb 100644
--- a/src/lib/eolian/eo_lexer.h
+++ b/src/lib/eolian/eo_lexer.h
@@ -50,8 +50,6 @@ enum Tokens
50 \ 50 \
51 KW(void), \ 51 KW(void), \
52 \ 52 \
53 KW(static_array), KW(terminated_array), \
54 \
55 KW(accessor), KW(array), KW(iterator), KW(hash), KW(list), \ 53 KW(accessor), KW(array), KW(iterator), KW(hash), KW(list), \
56 KW(future), \ 54 KW(future), \
57 KW(generic_value), \ 55 KW(generic_value), \
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index 3095864c6f..a3bdc8c41c 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -751,48 +751,6 @@ parse_type_void(Eo_Lexer *ls, Eina_Bool allow_ref, Eina_Bool allow_sarray)
751 def->type = EOLIAN_TYPE_UNDEFINED; 751 def->type = EOLIAN_TYPE_UNDEFINED;
752 eo_lexer_get(ls); 752 eo_lexer_get(ls);
753 } 753 }
754 else if (ls->t.kw == KW_static_array)
755 {
756 if (!allow_sarray)
757 eo_lexer_syntax_error(ls, "static arrays not allowed in this context");
758 def->type = EOLIAN_TYPE_STATIC_ARRAY;
759 eo_lexer_get(ls);
760 check_next(ls, '<');
761 def->base_type = parse_type(ls, EINA_FALSE, EINA_FALSE);
762 pop_type(ls);
763 check_next(ls, ',');
764 check(ls, TOK_NUMBER);
765 eo_lexer_context_push(ls);
766 if (ls->t.kw == NUM_FLOAT || ls->t.kw == NUM_DOUBLE)
767 {
768 eo_lexer_context_restore(ls);
769 eo_lexer_syntax_error(ls, "integer expected");
770 }
771 eo_lexer_context_pop(ls);
772 switch (ls->t.kw)
773 {
774 case NUM_INT : def->static_size = ls->t.value.i; break;
775 case NUM_UINT : def->static_size = ls->t.value.u; break;
776 case NUM_LONG : def->static_size = ls->t.value.l; break;
777 case NUM_ULONG : def->static_size = ls->t.value.ul; break;
778 case NUM_LLONG : def->static_size = ls->t.value.ll; break;
779 case NUM_ULLONG: def->static_size = ls->t.value.ull; break;
780 default:
781 eo_lexer_syntax_error(ls, "wrong type, internal error");
782 break;
783 }
784 eo_lexer_get(ls);
785 check_next(ls, '>');
786 }
787 else if (ls->t.kw == KW_terminated_array)
788 {
789 def->type = EOLIAN_TYPE_TERMINATED_ARRAY;
790 eo_lexer_get(ls);
791 check_next(ls, '<');
792 def->base_type = parse_type(ls, EINA_FALSE, EINA_FALSE);
793 pop_type(ls);
794 check_next(ls, '>');
795 }
796 else 754 else
797 { 755 {
798 int tpid = ls->t.kw; 756 int tpid = ls->t.kw;
diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h
index d0118d0653..1a165a42e8 100644
--- a/src/lib/eolian/eolian_database.h
+++ b/src/lib/eolian/eolian_database.h
@@ -162,7 +162,6 @@ struct _Eolian_Type
162 Eina_Stringshare *full_name; 162 Eina_Stringshare *full_name;
163 Eina_List *namespaces; 163 Eina_List *namespaces;
164 Eina_Stringshare *freefunc; 164 Eina_Stringshare *freefunc;
165 size_t static_size;
166 Eina_Bool is_const :1; 165 Eina_Bool is_const :1;
167 Eina_Bool is_ptr :1; 166 Eina_Bool is_ptr :1;
168 Eina_Bool owned :1; 167 Eina_Bool owned :1;
diff --git a/src/scripts/elua/apps/docgen/doctree.lua b/src/scripts/elua/apps/docgen/doctree.lua
index f3876829aa..146479fa00 100644
--- a/src/scripts/elua/apps/docgen/doctree.lua
+++ b/src/scripts/elua/apps/docgen/doctree.lua
@@ -667,8 +667,6 @@ M.Type = Node:clone {
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 CLASS = eolian.type_type.CLASS, 669 CLASS = eolian.type_type.CLASS,
670 STATIC_ARRAY = eolian.type_type.STATIC_ARRAY,
671 TERMINATED_ARRAY = eolian.type_type.TERMINATED_ARRAY,
672 UNDEFINED = eolian.type_type.UNDEFINED, 670 UNDEFINED = eolian.type_type.UNDEFINED,
673 671
674 __ctor = function(self, tp) 672 __ctor = function(self, tp)
@@ -721,10 +719,6 @@ M.Type = Node:clone {
721 return self.type:class_get(nil) 719 return self.type:class_get(nil)
722 end, 720 end,
723 721
724 array_size_get = function(self)
725 return self.type_array_size_get()
726 end,
727
728 is_owned = function(self) 722 is_owned = function(self)
729 return self.type:is_owned() 723 return self.type:is_owned()
730 end, 724 end,
@@ -779,13 +773,6 @@ M.Type = Node:clone {
779 .. table.concat(stypes, ", ") .. ">") 773 .. table.concat(stypes, ", ") .. ">")
780 end 774 end
781 return wrap_type_attrs(self, self:full_name_get()) 775 return wrap_type_attrs(self, self:full_name_get())
782 elseif tpt == self.STATIC_ARRAY then
783 return wrap_type_attrs(self, "static_array<"
784 .. self:base_type_get():serialize() .. ", "
785 .. self:array_size_get() .. ">")
786 elseif tpt == self.TERMINATED_ARRAY then
787 return wrap_type_attrs(self, "terminated_array<"
788 .. self:base_type_get():serialize() .. ">")
789 end 776 end
790 error("unhandled type type: " .. tpt) 777 error("unhandled type type: " .. tpt)
791 end 778 end
diff --git a/src/tests/eolian/data/struct.eo b/src/tests/eolian/data/struct.eo
index cb664f366c..55e6c50f4c 100644
--- a/src/tests/eolian/data/struct.eo
+++ b/src/tests/eolian/data/struct.eo
@@ -1,8 +1,6 @@
1struct Named { 1struct Named {
2 field: ptr(int); 2 field: ptr(int);
3 something: string; 3 something: string;
4 arr: static_array<int, 16>;
5 tarr: terminated_array<string>;
6} 4}
7 5
8struct Another { 6struct Another {
diff --git a/src/tests/eolian/data/struct_ref.c b/src/tests/eolian/data/struct_ref.c
index cb64af6cb3..42f34a9be2 100644
--- a/src/tests/eolian/data/struct_ref.c
+++ b/src/tests/eolian/data/struct_ref.c
@@ -15,8 +15,6 @@ typedef struct _Named
15{ 15{
16 int *field; 16 int *field;
17 const char *something; 17 const char *something;
18 int arr[16];
19 const char **tarr;
20} Named; 18} Named;
21 19
22typedef struct _Another 20typedef struct _Another
diff --git a/src/tests/eolian/eolian_parsing.c b/src/tests/eolian/eolian_parsing.c
index 79fdb64bb4..9e2c0d9bfc 100644
--- a/src/tests/eolian/eolian_parsing.c
+++ b/src/tests/eolian/eolian_parsing.c
@@ -677,21 +677,6 @@ START_TEST(eolian_struct)
677 fail_if(!(type_name = eolian_type_c_type_get(ftype, EOLIAN_C_TYPE_DEFAULT))); 677 fail_if(!(type_name = eolian_type_c_type_get(ftype, EOLIAN_C_TYPE_DEFAULT)));
678 fail_if(strcmp(type_name, "const char *")); 678 fail_if(strcmp(type_name, "const char *"));
679 eina_stringshare_del(type_name); 679 eina_stringshare_del(type_name);
680 fail_if(!(field = eolian_typedecl_struct_field_get(tdl, "arr")));
681 fail_if(!(ftype = eolian_typedecl_struct_field_type_get(field)));
682 fail_if(eolian_type_is_ptr(ftype));
683 fail_if(eolian_type_array_size_get(ftype) != 16);
684 fail_if(eolian_type_type_get(ftype) != EOLIAN_TYPE_STATIC_ARRAY);
685 fail_if(!(type_name = eolian_type_c_type_get(ftype, EOLIAN_C_TYPE_DEFAULT)));
686 fail_if(strcmp(type_name, "int *"));
687 eina_stringshare_del(type_name);
688 fail_if(!(field = eolian_typedecl_struct_field_get(tdl, "tarr")));
689 fail_if(!(ftype = eolian_typedecl_struct_field_type_get(field)));
690 fail_if(eolian_type_is_ptr(ftype));
691 fail_if(!(type_name = eolian_type_c_type_get(ftype, EOLIAN_C_TYPE_DEFAULT)));
692 fail_if(eolian_type_type_get(ftype) != EOLIAN_TYPE_TERMINATED_ARRAY);
693 fail_if(strcmp(type_name, "const char **"));
694 eina_stringshare_del(type_name);
695 680
696 /* referencing */ 681 /* referencing */
697 fail_if(!(tdl = eolian_typedecl_struct_get_by_name(unit, "Another"))); 682 fail_if(!(tdl = eolian_typedecl_struct_get_by_name(unit, "Another")));