summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile_Eolian.am2
-rw-r--r--src/lib/eolian/Eolian.h42
-rw-r--r--src/lib/eolian/database_class_api.c7
-rw-r--r--src/lib/eolian/database_part_api.c27
-rw-r--r--src/tests/eolian/data/parts.eo7
-rw-r--r--src/tests/eolian/eolian_parsing.c46
6 files changed, 130 insertions, 1 deletions
diff --git a/src/Makefile_Eolian.am b/src/Makefile_Eolian.am
index 8126337..efad6a6 100644
--- a/src/Makefile_Eolian.am
+++ b/src/Makefile_Eolian.am
@@ -30,6 +30,7 @@ lib_eolian_libeolian_la_SOURCES = \
30 lib/eolian/database_event.c \ 30 lib/eolian/database_event.c \
31 lib/eolian/database_event_api.c \ 31 lib/eolian/database_event_api.c \
32 lib/eolian/database_part.c \ 32 lib/eolian/database_part.c \
33 lib/eolian/database_part_api.c \
33 lib/eolian/database_expr.c \ 34 lib/eolian/database_expr.c \
34 lib/eolian/database_expr_api.c \ 35 lib/eolian/database_expr_api.c \
35 lib/eolian/database_var.c \ 36 lib/eolian/database_var.c \
@@ -94,6 +95,7 @@ tests/eolian/data/object_impl.eo \
94tests/eolian/data/object_impl_add.eo \ 95tests/eolian/data/object_impl_add.eo \
95tests/eolian/data/override.eo \ 96tests/eolian/data/override.eo \
96tests/eolian/data/owning.eo \ 97tests/eolian/data/owning.eo \
98tests/eolian/data/parts.eo \
97tests/eolian/data/scope.eo \ 99tests/eolian/data/scope.eo \
98tests/eolian/data/struct.eo \ 100tests/eolian/data/struct.eo \
99tests/eolian/data/typedef.eo \ 101tests/eolian/data/typedef.eo \
diff --git a/src/lib/eolian/Eolian.h b/src/lib/eolian/Eolian.h
index b69f2c5..0bd3646 100644
--- a/src/lib/eolian/Eolian.h
+++ b/src/lib/eolian/Eolian.h
@@ -1253,7 +1253,7 @@ EAPI Eina_Iterator *eolian_class_constructors_get(const Eolian_Class *klass);
1253 * @brief Get an iterator to the events defined in a class. 1253 * @brief Get an iterator to the events defined in a class.
1254 * 1254 *
1255 * @param[in] klass the class. 1255 * @param[in] klass the class.
1256 * @return the iterator 1256 * @return an iterator over const Eolian_Event* objects
1257 * 1257 *
1258 * @ingroup Eolian 1258 * @ingroup Eolian
1259 */ 1259 */
@@ -1334,6 +1334,46 @@ EAPI Eina_Bool eolian_event_is_hot(const Eolian_Event *event);
1334EAPI Eina_Bool eolian_event_is_restart(const Eolian_Event *event); 1334EAPI Eina_Bool eolian_event_is_restart(const Eolian_Event *event);
1335 1335
1336/* 1336/*
1337 * @brief Get an iterator to the parts defined in a class.
1338 *
1339 * @param[in] klass the class.
1340 * @return an iterator over const Eolian_Part* objects
1341 *
1342 * @ingroup Eolian
1343 */
1344EAPI Eina_Iterator *eolian_class_parts_get(const Eolian_Class *klass);
1345
1346/*
1347 * @brief Get the name of a part.
1348 *
1349 * @param[in] part the part handle
1350 * @return the name or NULL
1351 *
1352 * @ingroup Eolian
1353 */
1354EAPI Eina_Stringshare *eolian_part_name_get(const Eolian_Part *part);
1355
1356/*
1357 * @brief Get the type of a part.
1358 *
1359 * @param[in] part the part handle
1360 * @return the type or NULL
1361 *
1362 * @ingroup Eolian
1363 */
1364EAPI const Eolian_Class *eolian_part_class_get(const Eolian_Part *part);
1365
1366/*
1367 * @brief Get the documentation of an part.
1368 *
1369 * @param[in] part the part handle
1370 * @return the documentation or NULL
1371 *
1372 * @ingroup Eolian
1373 */
1374EAPI const Eolian_Documentation *eolian_part_documentation_get(const Eolian_Part *part);
1375
1376/*
1337 * @brief Returns the C name of an event 1377 * @brief Returns the C name of an event
1338 * 1378 *
1339 * @param[in] event the event handle 1379 * @param[in] event the event handle
diff --git a/src/lib/eolian/database_class_api.c b/src/lib/eolian/database_class_api.c
index 963a874..10fb275 100644
--- a/src/lib/eolian/database_class_api.c
+++ b/src/lib/eolian/database_class_api.c
@@ -173,6 +173,13 @@ eolian_class_events_get(const Eolian_Class *cl)
173 return (cl->events ? eina_list_iterator_new(cl->events) : NULL); 173 return (cl->events ? eina_list_iterator_new(cl->events) : NULL);
174} 174}
175 175
176EAPI Eina_Iterator *
177eolian_class_parts_get(const Eolian_Class *cl)
178{
179 EINA_SAFETY_ON_NULL_RETURN_VAL(cl, NULL);
180 return (cl->parts ? eina_list_iterator_new(cl->parts) : NULL);
181}
182
176EAPI Eina_Bool 183EAPI Eina_Bool
177eolian_class_ctor_enable_get(const Eolian_Class *cl) 184eolian_class_ctor_enable_get(const Eolian_Class *cl)
178{ 185{
diff --git a/src/lib/eolian/database_part_api.c b/src/lib/eolian/database_part_api.c
new file mode 100644
index 0000000..a67b0d4
--- /dev/null
+++ b/src/lib/eolian/database_part_api.c
@@ -0,0 +1,27 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#include <Eina.h>
6#include "eolian_database.h"
7
8EAPI Eina_Stringshare *
9eolian_part_name_get(const Eolian_Part *part)
10{
11 EINA_SAFETY_ON_NULL_RETURN_VAL(part, NULL);
12 return part->name;
13}
14
15EAPI const Eolian_Class *
16eolian_part_class_get(const Eolian_Part *part)
17{
18 EINA_SAFETY_ON_NULL_RETURN_VAL(part, NULL);
19 return part->klass;
20}
21
22EAPI const Eolian_Documentation *
23eolian_part_documentation_get(const Eolian_Part *part)
24{
25 EINA_SAFETY_ON_NULL_RETURN_VAL(part, NULL);
26 return part->doc;
27}
diff --git a/src/tests/eolian/data/parts.eo b/src/tests/eolian/data/parts.eo
new file mode 100644
index 0000000..286d1e4
--- /dev/null
+++ b/src/tests/eolian/data/parts.eo
@@ -0,0 +1,7 @@
1class Parts (Override, Base) {
2 parts {
3 part1: Override; [[Part 1]]
4 part2: Base; [[Part 2]]
5 part3: Parts; [[Part 3]]
6 }
7}
diff --git a/src/tests/eolian/eolian_parsing.c b/src/tests/eolian/eolian_parsing.c
index 9297932..ce18e4e 100644
--- a/src/tests/eolian/eolian_parsing.c
+++ b/src/tests/eolian/eolian_parsing.c
@@ -1544,6 +1544,51 @@ START_TEST(eolian_function_as_arguments)
1544} 1544}
1545END_TEST 1545END_TEST
1546 1546
1547START_TEST(eolian_parts)
1548{
1549 const Eolian_Unit *unit;
1550 const Eolian_Class *cls;
1551 Eina_Iterator *iter;
1552 Eolian_Part *part;
1553 int i = 0;
1554
1555 static const char *part_classes[] = {
1556 "Override", "Base", "Parts"
1557 };
1558
1559 eolian_init();
1560
1561 fail_if(!eolian_directory_scan(PACKAGE_DATA_DIR"/data"));
1562
1563 fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/parts.eo")));
1564
1565 fail_if(!(cls = eolian_class_get_by_name(unit, "Parts")));
1566
1567 fail_if(!(iter = eolian_class_parts_get(cls)));
1568
1569 EINA_ITERATOR_FOREACH(iter, part)
1570 {
1571 const Eolian_Documentation *doc;
1572 const Eolian_Class *klass;
1573 char pattern[24];
1574
1575 sprintf(pattern, "part%d", i + 1);
1576 ck_assert_str_eq(pattern, eolian_part_name_get(part));
1577
1578 sprintf(pattern, "Part %d", i + 1);
1579 fail_if(!(doc = eolian_part_documentation_get(part)));
1580 ck_assert_str_eq(pattern, eolian_documentation_summary_get(doc));
1581
1582 fail_if(!(klass = eolian_part_class_get(part)));
1583 ck_assert_str_eq(part_classes[i], eolian_class_name_get(klass));
1584 i++;
1585 }
1586 eina_iterator_free(iter);
1587
1588 eolian_shutdown();
1589}
1590END_TEST
1591
1547void eolian_parsing_test(TCase *tc) 1592void eolian_parsing_test(TCase *tc)
1548{ 1593{
1549 tcase_add_test(tc, eolian_simple_parsing); 1594 tcase_add_test(tc, eolian_simple_parsing);
@@ -1567,4 +1612,5 @@ void eolian_parsing_test(TCase *tc)
1567 tcase_add_test(tc, eolian_docs); 1612 tcase_add_test(tc, eolian_docs);
1568 tcase_add_test(tc, eolian_function_types); 1613 tcase_add_test(tc, eolian_function_types);
1569 tcase_add_test(tc, eolian_function_as_arguments); 1614 tcase_add_test(tc, eolian_function_as_arguments);
1615 tcase_add_test(tc, eolian_parts);
1570} 1616}