eina_strbuf_replace_all(buf, "@#eoprefix", eoprefix);
}
+char*
+_nextline(char *str, unsigned int lines)
+{
+ if (!str) return NULL;
+
+ char *ret = str;
+ while ((lines--) && *ret)
+ {
+ ret= strchr(ret, '\n');
+ if (ret) ret++;
+ }
+ return ret;
+}
+
+char*
+_startline(char *str, char *pos)
+{
+ if (!str || !pos) return NULL;
+
+ char *ret = pos;
+ while ((ret > str) && (*(ret-1)!='\n')) ret--;
+
+ return ret;
+}
+
+char*
+_first_line_get(const char *str)
+{
+ Eina_Strbuf *ret = eina_strbuf_new();
+ if (str)
+ {
+ const char *p = strchr(str, '\n');
+ size_t offs = (p) ? (size_t)(p - str) : strlen(str);
+ eina_strbuf_append_n(ret, str, offs);
+ }
+ return eina_strbuf_string_steal(ret);
+}
+
void _template_fill(Eina_Strbuf *buf, const char* templ, const char* classname, const char *funcname, Eina_Bool reset);
+char *_nextline(char *str, unsigned int lines);
+
+char *_startline(char *str, char *pos);
+
+char *_first_line_get(const char *str);
+
#endif
}\n\
";
-char *
-_first_line_get(const char *str)
-{
- Eina_Strbuf *ret = eina_strbuf_new();
- if (str)
- {
- const char *p = strchr(str, '\n');
- size_t offs = (p) ? (size_t)(p - str) : strlen(str);
- eina_strbuf_append_n(ret, str, offs);
- }
- return eina_strbuf_string_steal(ret);
-}
-
Eina_Bool
eo1_enum_append(const char *classname, const char *funcname, Eina_Strbuf *str)
{
return EINA_TRUE;
}
-static char*
-_nextline(char *str, unsigned int lines)
-{
- if (!str) return NULL;
-
- char *ret = str;
- while ((lines--) && *ret)
- {
- ret= strchr(ret, '\n');
- if (ret) ret++;
- }
- return ret;
-}
-
-static char*
-_startline(char *str, char *pos)
-{
- if (!str || !pos) return NULL;
-
- char *ret = pos;
- while ((ret > str) && (*(ret-1)!='\n')) ret--;
-
- return ret;
-}
-
Eina_Bool
legacy_header_append(const char *classname, int eo_version, Eina_Strbuf *header)
{
return EINA_TRUE;
}
-
#endif
#include <Eina.h>
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
/* Function Id used to extract information on class functions
*
EOLIAN_CLASS_INTERFACE
} Eolian_Class_Type;
+#ifdef EFL_BETA_API_SUPPORT
+
/*
* @brief Parse a given .eo file and fill the database.
*
*
* @ingroup Eolian
*/
-EAPI Eina_Bool eolian_init();
+EAPI int eolian_init(void);
/*
* @brief Shutdown Eolian.
*
* @ingroup Eolian
*/
-EAPI Eina_Bool eolian_shutdown();
+EAPI int eolian_shutdown(void);
/*
* @brief Show information about a given class.
* @ingroup Eolian
*/
/* Returns the list of class names of the database */
-EAPI const Eina_List *eolian_class_names_list_get();
+EAPI const Eina_List *eolian_class_names_list_get(void);
/*
* @brief Indicates if class exists in the database.
*/
EAPI Eina_Bool eolian_class_event_information_get(Eolian_Event event, const char **event_name, const char **event_desc);
+#endif
+
#ifdef __cplusplus
} // extern "C" {
#endif
#include "eolian_database.h"
#include "eo_lexer.h"
-EAPI Eina_Bool eolian_init()
+static int _eolian_init_counter = 0;
+
+EAPI int eolian_init(void)
{
+ if (_eolian_init_counter > 0) return ++_eolian_init_counter;
database_init();
eo_tokenizer_init();
- return EINA_TRUE;
+ return ++_eolian_init_counter;
}
-EAPI Eina_Bool eolian_shutdown()
+EAPI int eolian_shutdown(void)
{
- eo_tokenizer_shutdown();
- database_shutdown();
- return EINA_TRUE;
+ if (_eolian_init_counter <= 0)
+ {
+ EINA_LOG_ERR("Init count not greater than 0 in shutdown.");
+ return 0;
+ }
+ _eolian_init_counter--;
+
+ if (_eolian_init_counter == 0)
+ {
+ eo_tokenizer_shutdown();
+ database_shutdown();
+ }
+
+ return _eolian_init_counter;
}
EAPI Eina_Bool eolian_eo_file_parse(const char *filename)
#include "eolian_database.h"
static Eina_Hash *_classes = NULL;
+static int _database_init_count = 0;
typedef struct
{
return cl;
}
-Eina_Bool
+int
database_init()
{
+ if (_database_init_count > 0) return ++_database_init_count;
eina_init();
if (!_classes)
_classes = eina_hash_stringshared_new(_hash_free_cb);
- return EINA_TRUE;
+ return ++_database_init_count;
}
-Eina_Bool
+int
database_shutdown()
{
- eina_hash_free(_classes);
- eina_shutdown();
- return EINA_TRUE;
+ if (_database_init_count <= 0)
+ {
+ EINA_LOG_ERR("Init count not greater than 0 in shutdown.");
+ return 0;
+ }
+ _database_init_count--;
+
+ if (_database_init_count == 0)
+ {
+ eina_hash_free(_classes);
+ eina_shutdown();
+ }
+ return _database_init_count;
}
Eina_Bool
}
EAPI const Eina_List *
-eolian_class_names_list_get()
+eolian_class_names_list_get(void)
{
Eina_List *list = NULL;
eina_hash_foreach(_classes, _class_name_get, &list);
#include <Eolian.h>
-Eina_Bool database_init();
-Eina_Bool database_shutdown();
+int database_init();
+int database_shutdown();
/* Add a class in the database */
Eina_Bool database_class_add(const char *class_name, Eolian_Class_Type type);