summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2014-12-03 14:59:24 +0000
committerDaniel Kolesa <d.kolesa@samsung.com>2014-12-03 14:59:24 +0000
commit49aebd063e9a9bebac9ff5d7a9e3ecf7a70712cd (patch)
treebd4e41b89f30ea4208615128ce941a6d7104fffd
parentecfcb59c44a9bc7dd2ce95493806f6ac107c0d46 (diff)
eolian: add eolian_function_is_c_only
This function allows us to mark functions that are not bindable. Also remove some obsolete code.
-rw-r--r--src/lib/eolian/Eolian.h10
-rw-r--r--src/lib/eolian/database_function_api.c7
-rw-r--r--src/lib/eolian/eo_lexer.h4
-rw-r--r--src/lib/eolian/eo_parser.c77
-rw-r--r--src/lib/eolian/eolian_database.h1
5 files changed, 54 insertions, 45 deletions
diff --git a/src/lib/eolian/Eolian.h b/src/lib/eolian/Eolian.h
index 42e41c7..9464cdf 100644
--- a/src/lib/eolian/Eolian.h
+++ b/src/lib/eolian/Eolian.h
@@ -874,6 +874,16 @@ EAPI Eina_Bool eolian_function_is_legacy_only(const Eolian_Function *function_id
874EAPI Eina_Bool eolian_function_is_class(const Eolian_Function *function_id); 874EAPI Eina_Bool eolian_function_is_class(const Eolian_Function *function_id);
875 875
876/* 876/*
877 * @brief Get whether a function is C only (i.e. not bindable).
878 *
879 * @param[in] function_id Id of the function
880 * @return EINA_TRUE and EINA_FALSE respectively
881 *
882 * @ingroup Eolian
883 */
884EAPI Eina_Bool eolian_function_is_c_only(const Eolian_Function *function_id);
885
886/*
877 * @brief Indicates if a function is a constructing function of a given class. 887 * @brief Indicates if a function is a constructing function of a given class.
878 * 888 *
879 * @param[in] klass the class 889 * @param[in] klass the class
diff --git a/src/lib/eolian/database_function_api.c b/src/lib/eolian/database_function_api.c
index 000dda6..266ae54 100644
--- a/src/lib/eolian/database_function_api.c
+++ b/src/lib/eolian/database_function_api.c
@@ -249,3 +249,10 @@ eolian_function_object_is_const(const Eolian_Function *fid)
249 EINA_SAFETY_ON_NULL_RETURN_VAL(fid, EINA_FALSE); 249 EINA_SAFETY_ON_NULL_RETURN_VAL(fid, EINA_FALSE);
250 return fid->obj_is_const; 250 return fid->obj_is_const;
251} 251}
252
253EAPI Eina_Bool
254eolian_function_is_c_only(const Eolian_Function *fid)
255{
256 EINA_SAFETY_ON_NULL_RETURN_VAL(fid, EINA_FALSE);
257 return fid->is_c_only;
258}
diff --git a/src/lib/eolian/eo_lexer.h b/src/lib/eolian/eo_lexer.h
index 120e97a..eb1ca97 100644
--- a/src/lib/eolian/eo_lexer.h
+++ b/src/lib/eolian/eo_lexer.h
@@ -29,8 +29,8 @@ enum Tokens
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), \
32 KWAT(class), KWAT(const), KWAT(const_get), KWAT(const_set), KWAT(empty), \ 32 KWAT(c_only), KWAT(class), KWAT(const), KWAT(const_get), KWAT(const_set), \
33 KWAT(extern), KWAT(free), KWAT(in), KWAT(inout), KWAT(nonull), \ 33 KWAT(empty), KWAT(extern), KWAT(free), KWAT(in), KWAT(inout), KWAT(nonull), \
34 KWAT(optional), KWAT(out), KWAT(private), KWAT(protected), KWAT(virtual), \ 34 KWAT(optional), KWAT(out), KWAT(private), KWAT(protected), KWAT(virtual), \
35 KWAT(warn_unused), \ 35 KWAT(warn_unused), \
36 \ 36 \
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index 0d45bd0..9673c03 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -1276,7 +1276,8 @@ parse_property(Eo_Lexer *ls)
1276 Eolian_Function *prop = NULL; 1276 Eolian_Function *prop = NULL;
1277 Eina_Bool has_get = EINA_FALSE, has_set = EINA_FALSE, 1277 Eina_Bool has_get = EINA_FALSE, has_set = EINA_FALSE,
1278 has_keys = EINA_FALSE, has_values = EINA_FALSE, 1278 has_keys = EINA_FALSE, has_values = EINA_FALSE,
1279 has_protected = EINA_FALSE, has_class = EINA_FALSE; 1279 has_protected = EINA_FALSE, has_class = EINA_FALSE,
1280 has_c_only = EINA_FALSE;
1280 prop = calloc(1, sizeof(Eolian_Function)); 1281 prop = calloc(1, sizeof(Eolian_Function));
1281 prop->klass = ls->tmp.kls; 1282 prop->klass = ls->tmp.kls;
1282 prop->type = EOLIAN_UNRESOLVED; 1283 prop->type = EOLIAN_UNRESOLVED;
@@ -1299,6 +1300,11 @@ parse_property(Eo_Lexer *ls)
1299 prop->is_class = EINA_TRUE; 1300 prop->is_class = EINA_TRUE;
1300 eo_lexer_get(ls); 1301 eo_lexer_get(ls);
1301 break; 1302 break;
1303 case KW_at_c_only:
1304 CASE_LOCK(ls, c_only, "c_only qualifier");
1305 prop->is_c_only = EINA_TRUE;
1306 eo_lexer_get(ls);
1307 break;
1302 default: 1308 default:
1303 goto body; 1309 goto body;
1304 } 1310 }
@@ -1340,14 +1346,14 @@ end:
1340} 1346}
1341 1347
1342static void 1348static void
1343parse_method(Eo_Lexer *ls, Eina_Bool ctor) 1349parse_method(Eo_Lexer *ls)
1344{ 1350{
1345 int line, col; 1351 int line, col;
1346 Eolian_Function *meth = NULL; 1352 Eolian_Function *meth = NULL;
1347 Eina_Bool has_const = EINA_FALSE, has_params = EINA_FALSE, 1353 Eina_Bool has_const = EINA_FALSE, has_params = EINA_FALSE,
1348 has_return = EINA_FALSE, has_legacy = EINA_FALSE, 1354 has_return = EINA_FALSE, has_legacy = EINA_FALSE,
1349 has_protected = EINA_FALSE, has_class = EINA_FALSE, 1355 has_protected = EINA_FALSE, has_class = EINA_FALSE,
1350 has_eo = EINA_FALSE; 1356 has_eo = EINA_FALSE, has_c_only = EINA_FALSE;
1351 meth = calloc(1, sizeof(Eolian_Function)); 1357 meth = calloc(1, sizeof(Eolian_Function));
1352 meth->klass = ls->tmp.kls; 1358 meth->klass = ls->tmp.kls;
1353 meth->type = EOLIAN_METHOD; 1359 meth->type = EOLIAN_METHOD;
@@ -1355,48 +1361,33 @@ parse_method(Eo_Lexer *ls, Eina_Bool ctor)
1355 meth->base.line = ls->line_number; 1361 meth->base.line = ls->line_number;
1356 meth->base.column = ls->column; 1362 meth->base.column = ls->column;
1357 ls->tmp.kls->methods = eina_list_append(ls->tmp.kls->methods, meth); 1363 ls->tmp.kls->methods = eina_list_append(ls->tmp.kls->methods, meth);
1358 if (ctor) 1364 check(ls, TOK_VALUE);
1365 meth->name = eina_stringshare_ref(ls->t.value.s);
1366 eo_lexer_get(ls);
1367 for (;;) switch (ls->t.kw)
1359 { 1368 {
1360 if (ls->t.token != TOK_VALUE) 1369 case KW_at_protected:
1361 eo_lexer_syntax_error(ls, "expected method name"); 1370 CASE_LOCK(ls, protected, "protected qualifier")
1362 meth->name = eina_stringshare_ref(ls->t.value.s); 1371 meth->scope = EOLIAN_SCOPE_PROTECTED;
1363 eo_lexer_get(ls); 1372 eo_lexer_get(ls);
1364 for (;;) switch (ls->t.kw) 1373 break;
1365 { 1374 case KW_at_const:
1366 case KW_at_protected: 1375 CASE_LOCK(ls, const, "const qualifier")
1367 CASE_LOCK(ls, protected, "protected qualifier") 1376 meth->obj_is_const = EINA_TRUE;
1368 meth->scope = EOLIAN_SCOPE_PROTECTED;
1369 eo_lexer_get(ls);
1370 break;
1371 default:
1372 goto body;
1373 }
1374 }
1375 else
1376 {
1377 check(ls, TOK_VALUE);
1378 meth->name = eina_stringshare_ref(ls->t.value.s);
1379 eo_lexer_get(ls); 1377 eo_lexer_get(ls);
1380 for (;;) switch (ls->t.kw) 1378 break;
1381 { 1379 case KW_at_class:
1382 case KW_at_protected: 1380 CASE_LOCK(ls, class, "class qualifier");
1383 CASE_LOCK(ls, protected, "protected qualifier") 1381 meth->is_class = EINA_TRUE;
1384 meth->scope = EOLIAN_SCOPE_PROTECTED; 1382 eo_lexer_get(ls);
1385 eo_lexer_get(ls); 1383 break;
1386 break; 1384 case KW_at_c_only:
1387 case KW_at_const: 1385 CASE_LOCK(ls, c_only, "c_only qualifier");
1388 CASE_LOCK(ls, const, "const qualifier") 1386 meth->is_c_only = EINA_TRUE;
1389 meth->obj_is_const = EINA_TRUE; 1387 eo_lexer_get(ls);
1390 eo_lexer_get(ls); 1388 break;
1391 break; 1389 default:
1392 case KW_at_class: 1390 goto body;
1393 CASE_LOCK(ls, class, "class qualifier");
1394 meth->is_class = EINA_TRUE;
1395 eo_lexer_get(ls);
1396 break;
1397 default:
1398 goto body;
1399 }
1400 } 1391 }
1401body: 1392body:
1402 line = ls->line_number; 1393 line = ls->line_number;
@@ -1671,7 +1662,7 @@ parse_methods(Eo_Lexer *ls)
1671 line = ls->line_number, col = ls->column; 1662 line = ls->line_number, col = ls->column;
1672 check_next(ls, '{'); 1663 check_next(ls, '{');
1673 while (ls->t.token != '}') 1664 while (ls->t.token != '}')
1674 parse_method(ls, EINA_FALSE); 1665 parse_method(ls);
1675 check_match(ls, '}', '{', line, col); 1666 check_match(ls, '}', '{', line, col);
1676} 1667}
1677 1668
diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h
index e011e11..b12e05a 100644
--- a/src/lib/eolian/eolian_database.h
+++ b/src/lib/eolian/eolian_database.h
@@ -118,6 +118,7 @@ struct _Eolian_Function
118 Eina_Bool get_only_legacy: 1; 118 Eina_Bool get_only_legacy: 1;
119 Eina_Bool set_only_legacy: 1; 119 Eina_Bool set_only_legacy: 1;
120 Eina_Bool is_class :1; 120 Eina_Bool is_class :1;
121 Eina_Bool is_c_only :1;
121 Eina_List *ctor_of; 122 Eina_List *ctor_of;
122 Eolian_Class *klass; 123 Eolian_Class *klass;
123}; 124};