summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2014-11-27 17:20:21 +0000
committerDaniel Kolesa <d.kolesa@samsung.com>2014-11-27 17:20:21 +0000
commit5b9ece9c85b020d9d43274b3b245bcdcdf5b6502 (patch)
tree732d448479df5493557284539883c36977b46c43
parentb598aefa67148aaf7a49eb2b0e588d239039e4dc (diff)
eolian: remove support for function types
These won't be needed because of Eo callbacks. They're also difficult to handle in bindings, so this will relieve bindings of some effort.
-rw-r--r--src/lib/eolian/Eolian.h21
-rw-r--r--src/lib/eolian/database_type.c49
-rw-r--r--src/lib/eolian/database_type_api.c22
-rw-r--r--src/lib/eolian/database_validate.c11
-rw-r--r--src/lib/eolian/eo_lexer.h2
-rw-r--r--src/lib/eolian/eo_parser.c36
-rw-r--r--src/lib/eolian/eolian_database.h30
7 files changed, 11 insertions, 160 deletions
diff --git a/src/lib/eolian/Eolian.h b/src/lib/eolian/Eolian.h
index d2712d5..d810c78 100644
--- a/src/lib/eolian/Eolian.h
+++ b/src/lib/eolian/Eolian.h
@@ -195,7 +195,6 @@ typedef enum
195 EOLIAN_TYPE_REGULAR_ENUM, 195 EOLIAN_TYPE_REGULAR_ENUM,
196 EOLIAN_TYPE_COMPLEX, 196 EOLIAN_TYPE_COMPLEX,
197 EOLIAN_TYPE_POINTER, 197 EOLIAN_TYPE_POINTER,
198 EOLIAN_TYPE_FUNCTION,
199 EOLIAN_TYPE_STRUCT, 198 EOLIAN_TYPE_STRUCT,
200 EOLIAN_TYPE_STRUCT_OPAQUE, 199 EOLIAN_TYPE_STRUCT_OPAQUE,
201 EOLIAN_TYPE_ENUM, 200 EOLIAN_TYPE_ENUM,
@@ -1343,16 +1342,6 @@ EAPI Eina_Iterator *eolian_type_enums_get_by_file(const char *fname);
1343EAPI Eolian_Type_Type eolian_type_type_get(const Eolian_Type *tp); 1342EAPI Eolian_Type_Type eolian_type_type_get(const Eolian_Type *tp);
1344 1343
1345/* 1344/*
1346 * @brief Get an iterator to all arguments of a function type.
1347 *
1348 * @param[in] tp the type.
1349 * @return the iterator when @c tp is an EOLIAN_TYPE_FUNCTION, NULL otherwise.
1350 *
1351 * @ingroup Eolian
1352 */
1353EAPI Eina_Iterator *eolian_type_arguments_get(const Eolian_Type *tp);
1354
1355/*
1356 * @brief Get an iterator to all subtypes of a type. 1345 * @brief Get an iterator to all subtypes of a type.
1357 * 1346 *
1358 * @param[in] tp the type. 1347 * @param[in] tp the type.
@@ -1502,16 +1491,6 @@ EAPI Eina_Stringshare *eolian_type_description_get(const Eolian_Type *tp);
1502EAPI Eina_Stringshare *eolian_type_file_get(const Eolian_Type *tp); 1491EAPI Eina_Stringshare *eolian_type_file_get(const Eolian_Type *tp);
1503 1492
1504/* 1493/*
1505 * @brief Get the return type of a function type.
1506 *
1507 * @param[in] tp the type.
1508 * @return the return type when @c tp is an EOLIAN_TYPE_FUNCTION, NULL otherwise.
1509 *
1510 * @ingroup Eolian
1511 */
1512EAPI const Eolian_Type *eolian_type_return_type_get(const Eolian_Type *tp);
1513
1514/*
1515 * @brief Get the base type of a pointer or alias type. 1494 * @brief Get the base type of a pointer or alias type.
1516 * 1495 *
1517 * @param[in] tp the type. 1496 * @param[in] tp the type.
diff --git a/src/lib/eolian/database_type.c b/src/lib/eolian/database_type.c
index b83121d..23097c5 100644
--- a/src/lib/eolian/database_type.c
+++ b/src/lib/eolian/database_type.c
@@ -70,28 +70,6 @@ database_enum_add(Eolian_Type *tp)
70} 70}
71 71
72static void 72static void
73_ftype_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name)
74{
75 Eina_List *l;
76 Eolian_Type *stp;
77 Eina_Bool first = EINA_TRUE;
78 if (tp->ret_type)
79 database_type_to_str(tp->ret_type, buf, NULL);
80 else
81 eina_strbuf_append(buf, "void");
82 eina_strbuf_append(buf, " (*");
83 if (name) eina_strbuf_append(buf, name);
84 eina_strbuf_append(buf, ")(");
85 EINA_LIST_FOREACH(tp->arguments, l, stp)
86 {
87 if (!first) eina_strbuf_append(buf, ", ");
88 first = EINA_FALSE;
89 database_type_to_str(stp, buf, NULL);
90 }
91 eina_strbuf_append(buf, ")");
92}
93
94static void
95_stype_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name) 73_stype_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name)
96{ 74{
97 Eolian_Struct_Type_Field *sf; 75 Eolian_Struct_Type_Field *sf;
@@ -197,11 +175,6 @@ database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name)
197 _atype_to_str(tp, buf); 175 _atype_to_str(tp, buf);
198 return; 176 return;
199 } 177 }
200 else if (tp->type == EOLIAN_TYPE_FUNCTION)
201 {
202 _ftype_to_str(tp, buf, name);
203 return;
204 }
205 else if (tp->type == EOLIAN_TYPE_STRUCT 178 else if (tp->type == EOLIAN_TYPE_STRUCT
206 || tp->type == EOLIAN_TYPE_STRUCT_OPAQUE) 179 || tp->type == EOLIAN_TYPE_STRUCT_OPAQUE)
207 { 180 {
@@ -286,8 +259,6 @@ database_expr_print(Eolian_Expression *exp)
286void 259void
287database_type_print(Eolian_Type *tp) 260database_type_print(Eolian_Type *tp)
288{ 261{
289 Eina_List *l;
290 Eolian_Type *stp;
291 if (tp->type == EOLIAN_TYPE_ALIAS) 262 if (tp->type == EOLIAN_TYPE_ALIAS)
292 { 263 {
293 _typedef_print(tp); 264 _typedef_print(tp);
@@ -312,26 +283,6 @@ database_type_print(Eolian_Type *tp)
312 database_type_print(tp->base_type); 283 database_type_print(tp->base_type);
313 putchar('*'); 284 putchar('*');
314 } 285 }
315 else if (tp->type == EOLIAN_TYPE_FUNCTION)
316 {
317 Eina_Bool first = EINA_TRUE;
318 printf("func");
319 if (tp->ret_type)
320 {
321 putchar(' ');
322 database_type_print(tp->ret_type);
323 }
324 else
325 printf(" void");
326 printf(" (");
327 EINA_LIST_FOREACH(tp->arguments, l, stp)
328 {
329 if (!first) printf(", ");
330 first = EINA_FALSE;
331 database_type_print(stp);
332 }
333 putchar(')');
334 }
335 else if (tp->type == EOLIAN_TYPE_STRUCT) 286 else if (tp->type == EOLIAN_TYPE_STRUCT)
336 { 287 {
337 Eolian_Struct_Type_Field *sf; 288 Eolian_Struct_Type_Field *sf;
diff --git a/src/lib/eolian/database_type_api.c b/src/lib/eolian/database_type_api.c
index 433266a..b755471 100644
--- a/src/lib/eolian/database_type_api.c
+++ b/src/lib/eolian/database_type_api.c
@@ -76,15 +76,6 @@ eolian_type_type_get(const Eolian_Type *tp)
76} 76}
77 77
78EAPI Eina_Iterator * 78EAPI Eina_Iterator *
79eolian_type_arguments_get(const Eolian_Type *tp)
80{
81 EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
82 EINA_SAFETY_ON_FALSE_RETURN_VAL(eolian_type_type_get(tp) == EOLIAN_TYPE_FUNCTION, NULL);
83 if (!tp->arguments) return NULL;
84 return eina_list_iterator_new(tp->arguments);
85}
86
87EAPI Eina_Iterator *
88eolian_type_subtypes_get(const Eolian_Type *tp) 79eolian_type_subtypes_get(const Eolian_Type *tp)
89{ 80{
90 Eolian_Type_Type tpt; 81 Eolian_Type_Type tpt;
@@ -192,7 +183,6 @@ eolian_type_description_get(const Eolian_Type *tp)
192 EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL); 183 EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
193 tpp = eolian_type_type_get(tp); 184 tpp = eolian_type_type_get(tp);
194 EINA_SAFETY_ON_FALSE_RETURN_VAL(tpp != EOLIAN_TYPE_POINTER 185 EINA_SAFETY_ON_FALSE_RETURN_VAL(tpp != EOLIAN_TYPE_POINTER
195 && tpp != EOLIAN_TYPE_FUNCTION
196 && tpp != EOLIAN_TYPE_VOID, NULL); 186 && tpp != EOLIAN_TYPE_VOID, NULL);
197 return tp->comment; 187 return tp->comment;
198} 188}
@@ -204,20 +194,11 @@ eolian_type_file_get(const Eolian_Type *tp)
204 EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL); 194 EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
205 tpp = eolian_type_type_get(tp); 195 tpp = eolian_type_type_get(tp);
206 EINA_SAFETY_ON_FALSE_RETURN_VAL(tpp != EOLIAN_TYPE_POINTER 196 EINA_SAFETY_ON_FALSE_RETURN_VAL(tpp != EOLIAN_TYPE_POINTER
207 && tpp != EOLIAN_TYPE_FUNCTION
208 && tpp != EOLIAN_TYPE_VOID, NULL); 197 && tpp != EOLIAN_TYPE_VOID, NULL);
209 return tp->base.file; 198 return tp->base.file;
210} 199}
211 200
212EAPI const Eolian_Type * 201EAPI const Eolian_Type *
213eolian_type_return_type_get(const Eolian_Type *tp)
214{
215 EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
216 EINA_SAFETY_ON_FALSE_RETURN_VAL(eolian_type_type_get(tp) == EOLIAN_TYPE_FUNCTION, NULL);
217 return tp->ret_type;
218}
219
220EAPI const Eolian_Type *
221eolian_type_base_type_get(const Eolian_Type *tp) 202eolian_type_base_type_get(const Eolian_Type *tp)
222{ 203{
223 Eolian_Type_Type tpt; 204 Eolian_Type_Type tpt;
@@ -282,7 +263,6 @@ eolian_type_name_get(const Eolian_Type *tp)
282 EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL); 263 EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
283 tpp = eolian_type_type_get(tp); 264 tpp = eolian_type_type_get(tp);
284 EINA_SAFETY_ON_FALSE_RETURN_VAL(tpp != EOLIAN_TYPE_POINTER 265 EINA_SAFETY_ON_FALSE_RETURN_VAL(tpp != EOLIAN_TYPE_POINTER
285 && tpp != EOLIAN_TYPE_FUNCTION
286 && tpp != EOLIAN_TYPE_VOID, NULL); 266 && tpp != EOLIAN_TYPE_VOID, NULL);
287 return tp->name; 267 return tp->name;
288} 268}
@@ -294,7 +274,6 @@ eolian_type_full_name_get(const Eolian_Type *tp)
294 EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL); 274 EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
295 tpp = eolian_type_type_get(tp); 275 tpp = eolian_type_type_get(tp);
296 EINA_SAFETY_ON_FALSE_RETURN_VAL(tpp != EOLIAN_TYPE_POINTER 276 EINA_SAFETY_ON_FALSE_RETURN_VAL(tpp != EOLIAN_TYPE_POINTER
297 && tpp != EOLIAN_TYPE_FUNCTION
298 && tpp != EOLIAN_TYPE_VOID, NULL); 277 && tpp != EOLIAN_TYPE_VOID, NULL);
299 return tp->full_name; 278 return tp->full_name;
300} 279}
@@ -306,7 +285,6 @@ eolian_type_namespaces_get(const Eolian_Type *tp)
306 EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL); 285 EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
307 tpp = eolian_type_type_get(tp); 286 tpp = eolian_type_type_get(tp);
308 EINA_SAFETY_ON_FALSE_RETURN_VAL(tpp != EOLIAN_TYPE_POINTER 287 EINA_SAFETY_ON_FALSE_RETURN_VAL(tpp != EOLIAN_TYPE_POINTER
309 && tpp != EOLIAN_TYPE_FUNCTION
310 && tpp != EOLIAN_TYPE_VOID, NULL); 288 && tpp != EOLIAN_TYPE_VOID, NULL);
311 if (!tp->namespaces) return NULL; 289 if (!tp->namespaces) return NULL;
312 return eina_list_iterator_new(tp->namespaces); 290 return eina_list_iterator_new(tp->namespaces);
diff --git a/src/lib/eolian/database_validate.c b/src/lib/eolian/database_validate.c
index ca8546c..43b1c4a 100644
--- a/src/lib/eolian/database_validate.c
+++ b/src/lib/eolian/database_validate.c
@@ -91,17 +91,6 @@ _validate_type(const Eolian_Type *tp)
91 case EOLIAN_TYPE_POINTER: 91 case EOLIAN_TYPE_POINTER:
92 case EOLIAN_TYPE_ALIAS: 92 case EOLIAN_TYPE_ALIAS:
93 return _validate_type(tp->base_type); 93 return _validate_type(tp->base_type);
94 case EOLIAN_TYPE_FUNCTION:
95 {
96 Eina_List *l;
97 Eolian_Type *tpp;
98 if (tp->ret_type && !_validate_type(tp->ret_type))
99 return EINA_FALSE;
100 EINA_LIST_FOREACH(tp->arguments, l, tpp)
101 if (!_validate_type(tpp))
102 return EINA_FALSE;
103 return EINA_TRUE;
104 }
105 case EOLIAN_TYPE_STRUCT: 94 case EOLIAN_TYPE_STRUCT:
106 { 95 {
107 Eina_Bool succ = EINA_TRUE; 96 Eina_Bool succ = EINA_TRUE;
diff --git a/src/lib/eolian/eo_lexer.h b/src/lib/eolian/eo_lexer.h
index f140ba1..120e97a 100644
--- a/src/lib/eolian/eo_lexer.h
+++ b/src/lib/eolian/eo_lexer.h
@@ -25,7 +25,7 @@ enum Tokens
25#define KEYWORDS KW(class), KW(const), KW(enum), KW(return), KW(struct), \ 25#define KEYWORDS KW(class), KW(const), KW(enum), KW(return), KW(struct), \
26 \ 26 \
27 KW(abstract), KW(constructor), KW(constructors), KW(data), \ 27 KW(abstract), KW(constructor), KW(constructors), KW(data), \
28 KW(destructor), KW(eo), KW(eo_prefix), KW(events), KW(free), KW(func), \ 28 KW(destructor), KW(eo), KW(eo_prefix), KW(events), KW(free), \
29 KW(get), KW(implements), KW(interface), KW(keys), KW(legacy), \ 29 KW(get), KW(implements), KW(interface), KW(keys), KW(legacy), \
30 KW(legacy_prefix), KW(methods), KW(mixin), KW(own), KW(params), \ 30 KW(legacy_prefix), KW(methods), KW(mixin), KW(own), KW(params), \
31 KW(properties), KW(set), KW(type), KW(values), KW(var), KWAT(auto), \ 31 KW(properties), KW(set), KW(type), KW(values), KW(var), KWAT(auto), \
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index e343f73..0d45bd0 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -495,40 +495,6 @@ parse_type_named(Eo_Lexer *ls, Eina_Bool allow_named)
495 return ret; 495 return ret;
496} 496}
497 497
498static Eolian_Type *
499parse_function_type(Eo_Lexer *ls)
500{
501 int line, col;
502 Eolian_Type *def = push_type(ls);
503 def->type = EOLIAN_TYPE_FUNCTION;
504 def->base.file = eina_stringshare_ref(ls->filename);
505 def->base.line = ls->line_number;
506 def->base.column = ls->column;
507 eo_lexer_get(ls);
508 if (ls->t.kw == KW_void)
509 eo_lexer_get(ls);
510 else
511 {
512 def->ret_type = parse_type_void(ls);
513 pop_type(ls);
514 }
515 line = ls->line_number;
516 col = ls->column;
517 check_next(ls, '(');
518 if (ls->t.token != ')')
519 {
520 def->arguments = eina_list_append(def->arguments, parse_type(ls));
521 pop_type(ls);
522 while (test_next(ls, ','))
523 {
524 def->arguments = eina_list_append(def->arguments, parse_type(ls));
525 pop_type(ls);
526 }
527 }
528 check_match(ls, ')', '(', line, col);
529 return def;
530}
531
532static void 498static void
533_struct_field_free(Eolian_Struct_Type_Field *def) 499_struct_field_free(Eolian_Struct_Type_Field *def)
534{ 500{
@@ -875,8 +841,6 @@ parse_type_named_void(Eo_Lexer *ls, Eina_Bool allow_named)
875 _fill_name(sname, &def->full_name, &def->name, &def->namespaces); 841 _fill_name(sname, &def->full_name, &def->name, &def->namespaces);
876 goto parse_ptr; 842 goto parse_ptr;
877 } 843 }
878 case KW_func:
879 return parse_function_type(ls);
880 default: 844 default:
881 break; 845 break;
882 } 846 }
diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h
index c339076..e011e11 100644
--- a/src/lib/eolian/eolian_database.h
+++ b/src/lib/eolian/eolian_database.h
@@ -139,26 +139,16 @@ struct _Eolian_Type
139{ 139{
140 Eolian_Object base; 140 Eolian_Object base;
141 Eolian_Type_Type type; 141 Eolian_Type_Type type;
142 union { 142 Eina_List *subtypes;
143 /* functions */ 143 Eolian_Type *base_type;
144 struct { 144 Eina_Stringshare *name;
145 Eina_List *arguments; 145 Eina_Stringshare *full_name;
146 Eolian_Type *ret_type; 146 Eina_List *namespaces;
147 }; 147 Eina_Hash *fields;
148 /* everything else */ 148 Eina_List *field_list;
149 struct { 149 Eina_Stringshare *comment;
150 Eina_List *subtypes; 150 Eina_Stringshare *legacy;
151 Eolian_Type *base_type; 151 Eina_Stringshare *freefunc;
152 Eina_Stringshare *name;
153 Eina_Stringshare *full_name;
154 Eina_List *namespaces;
155 Eina_Hash *fields;
156 Eina_List *field_list;
157 Eina_Stringshare *comment;
158 Eina_Stringshare *legacy;
159 Eina_Stringshare *freefunc;
160 };
161 };
162 Eina_Bool is_const :1; 152 Eina_Bool is_const :1;
163 Eina_Bool is_own :1; 153 Eina_Bool is_own :1;
164 Eina_Bool is_extern :1; 154 Eina_Bool is_extern :1;