eolian: refactoring: refactor eolian_database.h
This commit is contained in:
parent
441455259e
commit
7cff1fda3e
|
@ -2,10 +2,10 @@
|
|||
#include "eolian_database.h"
|
||||
|
||||
void
|
||||
database_class_del(Eolian_Class *class)
|
||||
database_class_del(Eolian_Class *cl)
|
||||
{
|
||||
Eina_Stringshare *inherit_name;
|
||||
Eina_List *inherits = class->inherits;
|
||||
Eina_List *inherits = cl->inherits;
|
||||
Eolian_Function *fid;
|
||||
Eolian_Event *ev;
|
||||
|
||||
|
@ -13,27 +13,27 @@ database_class_del(Eolian_Class *class)
|
|||
eina_stringshare_del(inherit_name);
|
||||
|
||||
Eolian_Implement *impl;
|
||||
Eina_List *implements = class->implements;
|
||||
Eina_List *implements = cl->implements;
|
||||
EINA_LIST_FREE(implements, impl)
|
||||
{
|
||||
eina_stringshare_del(impl->full_name);
|
||||
free(impl);
|
||||
}
|
||||
|
||||
EINA_LIST_FREE(class->constructors, fid) database_function_del(fid);
|
||||
EINA_LIST_FREE(class->methods, fid) database_function_del(fid);
|
||||
EINA_LIST_FREE(class->properties, fid) database_function_del(fid);
|
||||
EINA_LIST_FREE(class->events, ev) database_event_free(ev);
|
||||
EINA_LIST_FREE(cl->constructors, fid) database_function_del(fid);
|
||||
EINA_LIST_FREE(cl->methods, fid) database_function_del(fid);
|
||||
EINA_LIST_FREE(cl->properties, fid) database_function_del(fid);
|
||||
EINA_LIST_FREE(cl->events, ev) database_event_del(ev);
|
||||
|
||||
eina_stringshare_del(class->name);
|
||||
eina_stringshare_del(class->full_name);
|
||||
eina_stringshare_del(class->file);
|
||||
eina_stringshare_del(class->description);
|
||||
eina_stringshare_del(class->legacy_prefix);
|
||||
eina_stringshare_del(class->eo_prefix);
|
||||
eina_stringshare_del(class->data_type);
|
||||
eina_stringshare_del(cl->name);
|
||||
eina_stringshare_del(cl->full_name);
|
||||
eina_stringshare_del(cl->file);
|
||||
eina_stringshare_del(cl->description);
|
||||
eina_stringshare_del(cl->legacy_prefix);
|
||||
eina_stringshare_del(cl->eo_prefix);
|
||||
eina_stringshare_del(cl->data_type);
|
||||
|
||||
free(class);
|
||||
free(cl);
|
||||
}
|
||||
|
||||
Eolian_Class *
|
||||
|
@ -64,12 +64,11 @@ database_class_add(const char *class_name, Eolian_Class_Type type)
|
|||
return cl;
|
||||
}
|
||||
|
||||
Eina_Bool
|
||||
database_class_file_set(Eolian_Class *class, const char *file_name)
|
||||
void
|
||||
database_class_file_set(Eolian_Class *cl, const char *file_name)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(class, EINA_FALSE);
|
||||
class->file = eina_stringshare_add(file_name);
|
||||
return EINA_TRUE;
|
||||
EINA_SAFETY_ON_NULL_RETURN(cl);
|
||||
cl->file = eina_stringshare_add(file_name);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -77,13 +76,13 @@ database_class_file_set(Eolian_Class *class, const char *file_name)
|
|||
* ret true && class -> only one class corresponding
|
||||
* ret true && !class -> no class corresponding
|
||||
*/
|
||||
Eina_Bool database_class_name_validate(const char *class_name, const Eolian_Class **class)
|
||||
Eina_Bool database_class_name_validate(const char *class_name, const Eolian_Class **cl)
|
||||
{
|
||||
char *name = strdup(class_name);
|
||||
char *colon = name + 1;
|
||||
const Eolian_Class *found_class = NULL;
|
||||
const Eolian_Class *candidate;
|
||||
if (class) *class = NULL;
|
||||
if (cl) *cl = NULL;
|
||||
do
|
||||
{
|
||||
colon = strchr(colon, '.');
|
||||
|
@ -104,7 +103,7 @@ Eina_Bool database_class_name_validate(const char *class_name, const Eolian_Clas
|
|||
if (colon) *colon++ = '.';
|
||||
}
|
||||
while(colon);
|
||||
if (class) *class = found_class;
|
||||
if (cl) *cl = found_class;
|
||||
free(name);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ database_event_new(const char *event_name, const char *event_type, const char *e
|
|||
}
|
||||
|
||||
void
|
||||
database_event_free(Eolian_Event *event)
|
||||
database_event_del(Eolian_Event *event)
|
||||
{
|
||||
eina_stringshare_del(event->name);
|
||||
eina_stringshare_del(event->comment);
|
||||
|
|
|
@ -149,122 +149,73 @@ typedef struct _Eolian_Struct_Field
|
|||
int database_init();
|
||||
int database_shutdown();
|
||||
|
||||
/* Add a type in the database */
|
||||
/* types */
|
||||
|
||||
Eina_Bool database_type_add(const char *alias, Eolian_Type *type);
|
||||
|
||||
/* Add a struct in the database */
|
||||
Eina_Bool database_struct_add(Eolian_Type *type);
|
||||
|
||||
Eina_Bool database_class_name_validate(const char *class_name, const Eolian_Class **class);
|
||||
|
||||
/* Add a class in the database */
|
||||
Eolian_Class *database_class_add(const char *class_name, Eolian_Class_Type type);
|
||||
|
||||
/* Add a class from the database */
|
||||
void database_class_del(Eolian_Class *class);
|
||||
|
||||
Eolian_Function_Parameter *database_parameter_add(Eolian_Type *type, const char *name, const char *description);
|
||||
|
||||
void database_parameter_del(Eolian_Function_Parameter *pdesc);
|
||||
|
||||
/* Add an inherit class name to a class */
|
||||
Eina_Bool database_class_inherit_add(Eolian_Class *class, const char *inherit_class_name);
|
||||
|
||||
/* Set description of class. */
|
||||
void
|
||||
database_class_description_set(Eolian_Class *class, const char *description);
|
||||
|
||||
/* Set legacy of class. */
|
||||
void
|
||||
database_class_legacy_prefix_set(Eolian_Class *class, const char *legacy_prefix);
|
||||
|
||||
/* Set eo prefix of class. */
|
||||
void
|
||||
database_class_eo_prefix_set(Eolian_Class *class, const char *eo_prefix);
|
||||
|
||||
/* Set data of class. */
|
||||
void
|
||||
database_class_data_type_set(Eolian_Class *class, const char *data_type);
|
||||
|
||||
/* Set file of class */
|
||||
Eina_Bool
|
||||
database_class_file_set(Eolian_Class *class, const char *file_name);
|
||||
|
||||
/* Create a function */
|
||||
Eolian_Function *database_function_new(const char *function_name, Eolian_Function_Type foo_type);
|
||||
|
||||
void database_function_del(Eolian_Function *fid);
|
||||
|
||||
/* Set a type to a function */
|
||||
void database_function_type_set(Eolian_Function *function_id, Eolian_Function_Type foo_type);
|
||||
|
||||
/* Add a function to a class */
|
||||
Eina_Bool database_class_function_add(Eolian_Class *class, Eolian_Function *foo_id);
|
||||
|
||||
void database_function_data_set(Eolian_Function *function_id, const char *key, const char *description);
|
||||
|
||||
/* Add a description to a function */
|
||||
#define database_function_description_set(foo_id, key, desc) database_function_data_set((foo_id), (key), (desc))
|
||||
|
||||
/* Add a key to a property */
|
||||
Eolian_Function_Parameter *database_property_key_add(Eolian_Function *foo_id, Eolian_Type *type, const char *name, const char *description);
|
||||
|
||||
/* Add a value to a property */
|
||||
Eolian_Function_Parameter *database_property_value_add(Eolian_Function *foo_id, Eolian_Type *type, const char *name, const char *description);
|
||||
|
||||
/* Add a parameter to a method */
|
||||
Eolian_Function_Parameter *database_method_parameter_add(Eolian_Function *foo_id, Eolian_Parameter_Dir param_dir, Eolian_Type *type, const char *name, const char *description);
|
||||
|
||||
void database_type_del(Eolian_Type *type);
|
||||
|
||||
void database_parameter_const_attribute_set(Eolian_Function_Parameter *param, Eina_Bool is_get, Eina_Bool is_const);
|
||||
void database_type_print(Eolian_Type *type);
|
||||
void database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name);
|
||||
|
||||
void database_parameter_nonull_set(Eolian_Function_Parameter *param, Eina_Bool nonull);
|
||||
/* classes */
|
||||
|
||||
Eolian_Class *database_class_add(const char *class_name, Eolian_Class_Type type);
|
||||
void database_class_del(Eolian_Class *cl);
|
||||
|
||||
Eina_Bool database_class_inherit_add(Eolian_Class *cl, const char *inherit_class_name);
|
||||
Eina_Bool database_class_function_add(Eolian_Class *cl, Eolian_Function *foo_id);
|
||||
Eina_Bool database_class_implement_add(Eolian_Class *cl, Eolian_Implement *impl_id);
|
||||
Eina_Bool database_class_event_add(Eolian_Class *cl, Eolian_Event *event_desc);
|
||||
|
||||
void database_class_description_set(Eolian_Class *cl, const char *description);
|
||||
void database_class_legacy_prefix_set(Eolian_Class *cl, const char *legacy_prefix);
|
||||
void database_class_eo_prefix_set(Eolian_Class *cl, const char *eo_prefix);
|
||||
void database_class_data_type_set(Eolian_Class *cl, const char *data_type);
|
||||
void database_class_file_set(Eolian_Class *cl, const char *file_name);
|
||||
Eina_Bool database_class_ctor_enable_set(Eolian_Class *cl, Eina_Bool enable);
|
||||
Eina_Bool database_class_dtor_enable_set(Eolian_Class *cl, Eina_Bool enable);
|
||||
|
||||
Eina_Bool database_class_name_validate(const char *class_name, const Eolian_Class **cl);
|
||||
|
||||
/* functions */
|
||||
|
||||
Eolian_Function *database_function_new(const char *function_name, Eolian_Function_Type foo_type);
|
||||
void database_function_del(Eolian_Function *fid);
|
||||
|
||||
void database_function_type_set(Eolian_Function *function_id, Eolian_Function_Type foo_type);
|
||||
void database_function_data_set(Eolian_Function *function_id, const char *key, const char *description);
|
||||
#define database_function_description_set(foo_id, key, desc) database_function_data_set((foo_id), (key), (desc))
|
||||
|
||||
void database_function_return_type_set(Eolian_Function *foo_id, Eolian_Function_Type ftype, Eolian_Type *ret_type);
|
||||
|
||||
void database_function_return_comment_set(Eolian_Function *foo_id, Eolian_Function_Type ftype, const char *ret_comment);
|
||||
|
||||
void database_function_return_dflt_val_set(Eolian_Function *foo_id, Eolian_Function_Type ftype, const char *ret_dflt_value);
|
||||
|
||||
void database_function_return_flag_set_as_warn_unused(Eolian_Function *foo_id,
|
||||
Eolian_Function_Type ftype, Eina_Bool warn_unused);
|
||||
void database_function_return_flag_set_as_warn_unused(Eolian_Function *foo_id, Eolian_Function_Type ftype, Eina_Bool warn_unused);
|
||||
|
||||
void database_function_object_set_as_const(Eolian_Function *foo_id, Eina_Bool is_const);
|
||||
Eina_Bool database_function_set_as_virtual_pure(Eolian_Function *function_id, Eolian_Function_Type type);
|
||||
void database_function_scope_set(Eolian_Function *function_id, Eolian_Function_Scope scope);
|
||||
|
||||
Eina_Bool
|
||||
database_function_set_as_virtual_pure(Eolian_Function *function_id, Eolian_Function_Type type);
|
||||
Eolian_Function_Parameter *database_property_key_add(Eolian_Function *foo_id, Eolian_Type *type, const char *name, const char *description);
|
||||
Eolian_Function_Parameter *database_property_value_add(Eolian_Function *foo_id, Eolian_Type *type, const char *name, const char *description);
|
||||
Eolian_Function_Parameter *database_method_parameter_add(Eolian_Function *foo_id, Eolian_Parameter_Dir param_dir, Eolian_Type *type, const char *name, const char *description);
|
||||
|
||||
void
|
||||
database_function_scope_set(Eolian_Function *function_id, Eolian_Function_Scope scope);
|
||||
/* func parameters */
|
||||
|
||||
/* Need to add API for callbacks and implements */
|
||||
Eolian_Function_Parameter *database_parameter_add(Eolian_Type *type, const char *name, const char *description);
|
||||
void database_parameter_del(Eolian_Function_Parameter *pdesc);
|
||||
|
||||
Eolian_Implement *
|
||||
database_implement_new(const char *impl_name);
|
||||
void database_parameter_const_attribute_set(Eolian_Function_Parameter *param, Eina_Bool is_get, Eina_Bool is_const);
|
||||
void database_parameter_nonull_set(Eolian_Function_Parameter *param, Eina_Bool nonull);
|
||||
|
||||
Eina_Bool
|
||||
database_class_implement_add(Eolian_Class *class, Eolian_Implement *impl_id);
|
||||
/* implements */
|
||||
|
||||
Eina_Bool
|
||||
database_class_ctor_enable_set(Eolian_Class *class, Eina_Bool enable);
|
||||
Eolian_Implement *database_implement_new(const char *impl_name);
|
||||
|
||||
Eina_Bool
|
||||
database_class_dtor_enable_set(Eolian_Class *class, Eina_Bool enable);
|
||||
/* events */
|
||||
|
||||
Eolian_Event *
|
||||
database_event_new(const char *event_name, const char *event_type, const char *event_desc);
|
||||
Eolian_Event *database_event_new(const char *event_name, const char *event_type, const char *event_desc);
|
||||
void database_event_del(Eolian_Event *event);
|
||||
|
||||
void
|
||||
database_event_free(Eolian_Event *event);
|
||||
|
||||
Eina_Bool
|
||||
database_class_event_add(Eolian_Class *class, Eolian_Event *event_desc);
|
||||
|
||||
void
|
||||
database_type_print(Eolian_Type *type);
|
||||
|
||||
void
|
||||
database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue