forked from enlightenment/efl
Eolian: Code review fixes
1) API defined under EFL_BETA_API_SUPPORT 2) Init counters for init and shutdown 3) void for no-parameters functions
This commit is contained in:
parent
4ec1ae2d0f
commit
17abdbdd43
|
@ -71,3 +71,41 @@ _template_fill(Eina_Strbuf *buf, const char* templ, const char* classname, const
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,4 +5,10 @@
|
|||
|
||||
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
|
||||
|
|
|
@ -108,19 +108,6 @@ _eo_obj_@#class_@#func(Eo *obj, void *_pd EINA_UNUSED, va_list *list@#list_unuse
|
|||
}\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)
|
||||
{
|
||||
|
|
|
@ -280,31 +280,6 @@ legacy_header_generate(const char *classname, int eo_version, Eina_Strbuf *buf)
|
|||
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)
|
||||
{
|
||||
|
@ -449,4 +424,3 @@ legacy_source_generate(const char *classname, Eina_Bool legacy, int eo_version,
|
|||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,10 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
#include <Eina.h>
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
|
||||
/* Function Id used to extract information on class functions
|
||||
*
|
||||
|
@ -84,6 +88,8 @@ typedef enum
|
|||
EOLIAN_CLASS_INTERFACE
|
||||
} Eolian_Class_Type;
|
||||
|
||||
#ifdef EFL_BETA_API_SUPPORT
|
||||
|
||||
/*
|
||||
* @brief Parse a given .eo file and fill the database.
|
||||
*
|
||||
|
@ -101,14 +107,14 @@ EAPI Eina_Bool eolian_eo_file_parse(const char *filename);
|
|||
*
|
||||
* @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.
|
||||
|
@ -140,7 +146,7 @@ EAPI Eolian_Class_Type eolian_class_type_get(const char *class_name);
|
|||
* @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.
|
||||
|
@ -404,6 +410,8 @@ EAPI const Eina_List *eolian_class_events_list_get(const char *class_name);
|
|||
*/
|
||||
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
|
||||
|
|
|
@ -2,18 +2,32 @@
|
|||
#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)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "eolian_database.h"
|
||||
|
||||
static Eina_Hash *_classes = NULL;
|
||||
static int _database_init_count = 0;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -122,21 +123,32 @@ _class_get(const char *class_name)
|
|||
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
|
||||
|
@ -186,7 +198,7 @@ static Eina_Bool _class_name_get(const Eina_Hash *hash EINA_UNUSED, const void *
|
|||
}
|
||||
|
||||
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);
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
#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);
|
||||
|
|
Loading…
Reference in New Issue