summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2017-12-03 21:18:20 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2017-12-05 16:41:42 +0100
commite83e0897652bda4ecde28b7eeed7236c2b07ad39 (patch)
tree6579353fac496bff94d7db141e2665fdb3062d98
parent53aa99550d5b3351d85f3031e6a5baa34be38756 (diff)
eolian: contain master state in a larger structure
-rw-r--r--src/lib/eolian/Eolian.h27
-rw-r--r--src/lib/eolian/eolian_database.c18
-rw-r--r--src/lib/eolian/eolian_database.h29
3 files changed, 45 insertions, 29 deletions
diff --git a/src/lib/eolian/Eolian.h b/src/lib/eolian/Eolian.h
index d11d4f3904..0e8b9d59c7 100644
--- a/src/lib/eolian/Eolian.h
+++ b/src/lib/eolian/Eolian.h
@@ -84,6 +84,12 @@ extern "C" {
84 84
85#ifdef EFL_BETA_API_SUPPORT 85#ifdef EFL_BETA_API_SUPPORT
86 86
87/* State information
88 *
89 * @ingroup Eolian
90 */
91typedef struct _Eolian Eolian;
92
87/* Class type used to extract information on classes 93/* Class type used to extract information on classes
88 * 94 *
89 * @ingroup Eolian 95 * @ingroup Eolian
@@ -523,30 +529,31 @@ EAPI int eolian_init(void);
523EAPI int eolian_shutdown(void); 529EAPI int eolian_shutdown(void);
524 530
525/* 531/*
526 * @brief Create a new primary unit for Eolian state. 532 * @brief Create a new Eolian state.
533 *
534 * This creates a new Eolian state that consists of a "master unit" with
535 * the same address (therefore, you can cast it to Eolian_Unit) plus extra
536 * state information.
527 * 537 *
528 * This creates a nameless "master unit" which holds all Eolian state.
529 * You need to free this with eolian_free once you're done. 538 * You need to free this with eolian_free once you're done.
530 * 539 *
531 * @return A new master unit (or NULL on failure). 540 * @return A new state (or NULL on failure).
532 * 541 *
533 * @ingroup Eolian 542 * @ingroup Eolian
534 */ 543 */
535EAPI Eolian_Unit *eolian_new(void); 544EAPI Eolian *eolian_new(void);
536 545
537/* 546/*
538 * @brief Free a master unit. 547 * @brief Free an Eolian state.
539 * 548 *
540 * You can use this to free an Eolian state. Do not EVER use this to free 549 * You can use this to free an Eolian state.
541 * any unit other than master unit, as these are managed by the master unit
542 * and freeing them would result in incorrect behavior.
543 * 550 *
544 * If the input is NULL, this function has no effect. 551 * If the input is NULL, this function has no effect.
545 * 552 *
546 * @param[in] unit the master unit to free 553 * @param[in] unit the state to free
547 * 554 *
548 */ 555 */
549EAPI void eolian_free(Eolian_Unit *unit); 556EAPI void eolian_free(Eolian *state);
550 557
551/* 558/*
552 * @brief Scan the given directory (recursively) and search for .eo and 559 * @brief Scan the given directory (recursively) and search for .eo and
diff --git a/src/lib/eolian/eolian_database.c b/src/lib/eolian/eolian_database.c
index 80af933947..d2ae6a784f 100644
--- a/src/lib/eolian/eolian_database.c
+++ b/src/lib/eolian/eolian_database.c
@@ -636,21 +636,25 @@ database_unit_del(Eolian_Unit *unit)
636 eina_hash_free(unit->enums); 636 eina_hash_free(unit->enums);
637} 637}
638 638
639EAPI Eolian_Unit * 639EAPI Eolian *
640eolian_new(void) 640eolian_new(void)
641{ 641{
642 Eolian_Unit *nunit = calloc(1, sizeof(Eolian_Unit)); 642 Eolian *state = calloc(1, sizeof(Eolian));
643 if (!nunit) 643 if (!state)
644 return NULL; 644 return NULL;
645 645
646 database_unit_init(nunit, NULL); 646 database_unit_init(&state->unit, NULL);
647 return nunit; 647 return state;
648} 648}
649 649
650EAPI void 650EAPI void
651eolian_free(Eolian_Unit *unit) 651eolian_free(Eolian *state)
652{ 652{
653 database_unit_del(unit); 653 if (!state)
654 return;
655
656 database_unit_del(&state->unit);
657 free(state);
654} 658}
655 659
656#define EO_SUFFIX ".eo" 660#define EO_SUFFIX ".eo"
diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h
index 1ab61b0b66..e92cebdc3c 100644
--- a/src/lib/eolian/eolian_database.h
+++ b/src/lib/eolian/eolian_database.h
@@ -59,6 +59,23 @@ extern Eina_Hash *_parsingeos;
59/* for deferred dependency parsing */ 59/* for deferred dependency parsing */
60extern Eina_Hash *_defereos; 60extern Eina_Hash *_defereos;
61 61
62struct _Eolian_Unit
63{
64 Eolian_Unit *parent;
65 Eina_Hash *children;
66 Eina_Hash *classes;
67 Eina_Hash *globals;
68 Eina_Hash *constants;
69 Eina_Hash *aliases;
70 Eina_Hash *structs;
71 Eina_Hash *enums;
72};
73
74struct _Eolian
75{
76 Eolian_Unit unit;
77};
78
62typedef struct _Eolian_Object 79typedef struct _Eolian_Object
63{ 80{
64 const char *file; 81 const char *file;
@@ -294,18 +311,6 @@ struct _Eolian_Variable
294 Eina_Bool is_extern :1; 311 Eina_Bool is_extern :1;
295}; 312};
296 313
297struct _Eolian_Unit
298{
299 Eolian_Unit *parent;
300 Eina_Hash *children;
301 Eina_Hash *classes;
302 Eina_Hash *globals;
303 Eina_Hash *constants;
304 Eina_Hash *aliases;
305 Eina_Hash *structs;
306 Eina_Hash *enums;
307};
308
309int database_init(void); 314int database_init(void);
310int database_shutdown(void); 315int database_shutdown(void);
311 316