From 1d89978c5bcf7de7a5867e42fe4bc5e1ca70dda3 Mon Sep 17 00:00:00 2001 From: Daniel Zaoui Date: Sun, 6 Apr 2014 17:10:05 +0300 Subject: [PATCH] Eolian: clean API. defines used as keys for internal hash tables are now replaced by functions giving access to the internal data. --- src/lib/eolian/Eolian.h | 6 ------ src/lib/eolian/eo_lexer.c | 23 ++++++++++++----------- src/lib/eolian/eo_lexer.rl | 23 ++++++++++++----------- src/lib/eolian/eolian_database.c | 25 +++++++++++++++++++++++-- src/lib/eolian/eolian_database.h | 2 ++ 5 files changed, 49 insertions(+), 30 deletions(-) diff --git a/src/lib/eolian/Eolian.h b/src/lib/eolian/Eolian.h index 49749a8d0e..45bdd25b63 100644 --- a/src/lib/eolian/Eolian.h +++ b/src/lib/eolian/Eolian.h @@ -74,12 +74,6 @@ typedef struct _Implement_Legacy_Param* Eolian_Implement_Legacy_Parameter; */ typedef struct _Event_Desc* Eolian_Event; -#define EOLIAN_METHOD_RETURN_TYPE "method_return_type" -#define EOLIAN_PROP_GET_RETURN_TYPE "property_get_return_type" -#define EOLIAN_PROP_SET_RETURN_TYPE "property_set_return_type" -#define EOLIAN_RETURN_COMMENT "method_return_comment" -#define EOLIAN_PROP_GET_RETURN_COMMENT "property_get_return_comment" -#define EOLIAN_PROP_SET_RETURN_COMMENT "property_set_return_comment" #define EOLIAN_LEGACY "legacy" #define EOLIAN_LEGACY_GET "legacy_get" #define EOLIAN_LEGACY_SET "legacy_set" diff --git a/src/lib/eolian/eo_lexer.c b/src/lib/eolian/eo_lexer.c index 2b407bb570..0acce194c8 100644 --- a/src/lib/eolian/eo_lexer.c +++ b/src/lib/eolian/eo_lexer.c @@ -4369,7 +4369,7 @@ eo_tokenizer_database_fill(const char *filename) { Eolian_Function foo_id = database_function_new(meth->name, EOLIAN_CTOR); database_class_function_add(kls->name, foo_id); - if (meth->ret) database_function_description_set(foo_id, EOLIAN_RETURN_COMMENT, meth->ret->comment); + if (meth->ret) database_function_return_comment_set(foo_id, EOLIAN_METHOD, meth->ret->comment); database_function_data_set(foo_id, EOLIAN_LEGACY, meth->legacy); EINA_LIST_FOREACH(meth->params, m, param) { @@ -4381,7 +4381,7 @@ eo_tokenizer_database_fill(const char *filename) { Eolian_Function foo_id = database_function_new(meth->name, EOLIAN_DTOR); database_class_function_add(kls->name, foo_id); - if (meth->ret) database_function_description_set(foo_id, EOLIAN_RETURN_COMMENT, meth->ret->comment); + if (meth->ret) database_function_return_comment_set(foo_id, EOLIAN_METHOD, meth->ret->comment); database_function_data_set(foo_id, EOLIAN_LEGACY, meth->legacy); EINA_LIST_FOREACH(meth->params, m, param) { @@ -4411,17 +4411,18 @@ eo_tokenizer_database_fill(const char *filename) database_function_type_set(foo_id, (accessor->type == SETTER?EOLIAN_PROP_SET:EOLIAN_PROP_GET)); if (accessor->ret && accessor->ret->type) { + Eolian_Function_Type ftype = + accessor->type == SETTER?EOLIAN_PROP_SET:EOLIAN_PROP_GET; database_function_return_type_set(foo_id, - accessor->type == SETTER?EOLIAN_PROP_SET:EOLIAN_PROP_GET, accessor->ret->type); - database_function_data_set(foo_id, - (accessor->type == SETTER?EOLIAN_PROP_SET_RETURN_COMMENT:EOLIAN_PROP_GET_RETURN_COMMENT), - accessor->ret->comment); + ftype, accessor->ret->type); + database_function_return_comment_set(foo_id, + ftype, accessor->ret->comment); database_function_return_flag_set_as_warn_unused(foo_id, - accessor->type == SETTER?EOLIAN_PROP_SET:EOLIAN_PROP_GET, accessor->ret->warn_unused); + ftype, accessor->ret->warn_unused); database_function_return_flag_set_own(foo_id, - accessor->type == SETTER?EOLIAN_PROP_SET:EOLIAN_PROP_GET, accessor->ret->own); + ftype, accessor->ret->own); database_function_return_dflt_val_set(foo_id, - accessor->type == SETTER?EOLIAN_PROP_SET:EOLIAN_PROP_GET, accessor->ret->dflt_ret_val); + ftype, accessor->ret->dflt_ret_val); } if (accessor->legacy) { @@ -4457,8 +4458,8 @@ eo_tokenizer_database_fill(const char *filename) database_class_function_add(kls->name, foo_id); if (meth->ret) { - database_function_data_set(foo_id, EOLIAN_METHOD_RETURN_TYPE, meth->ret->type); - database_function_description_set(foo_id, EOLIAN_RETURN_COMMENT, meth->ret->comment); + database_function_return_type_set(foo_id, EOLIAN_METHOD, meth->ret->type); + database_function_return_comment_set(foo_id, EOLIAN_METHOD, meth->ret->comment); database_function_return_flag_set_as_warn_unused(foo_id, EOLIAN_METHOD, meth->ret->warn_unused); database_function_return_flag_set_own(foo_id, EOLIAN_METHOD, meth->ret->own); diff --git a/src/lib/eolian/eo_lexer.rl b/src/lib/eolian/eo_lexer.rl index 5a26226891..a4f6c3687f 100644 --- a/src/lib/eolian/eo_lexer.rl +++ b/src/lib/eolian/eo_lexer.rl @@ -1351,7 +1351,7 @@ eo_tokenizer_database_fill(const char *filename) { Eolian_Function foo_id = database_function_new(meth->name, EOLIAN_CTOR); database_class_function_add(kls->name, foo_id); - if (meth->ret) database_function_description_set(foo_id, EOLIAN_RETURN_COMMENT, meth->ret->comment); + if (meth->ret) database_function_return_comment_set(foo_id, EOLIAN_METHOD, meth->ret->comment); database_function_data_set(foo_id, EOLIAN_LEGACY, meth->legacy); EINA_LIST_FOREACH(meth->params, m, param) { @@ -1363,7 +1363,7 @@ eo_tokenizer_database_fill(const char *filename) { Eolian_Function foo_id = database_function_new(meth->name, EOLIAN_DTOR); database_class_function_add(kls->name, foo_id); - if (meth->ret) database_function_description_set(foo_id, EOLIAN_RETURN_COMMENT, meth->ret->comment); + if (meth->ret) database_function_return_comment_set(foo_id, EOLIAN_METHOD, meth->ret->comment); database_function_data_set(foo_id, EOLIAN_LEGACY, meth->legacy); EINA_LIST_FOREACH(meth->params, m, param) { @@ -1393,17 +1393,18 @@ eo_tokenizer_database_fill(const char *filename) database_function_type_set(foo_id, (accessor->type == SETTER?EOLIAN_PROP_SET:EOLIAN_PROP_GET)); if (accessor->ret && accessor->ret->type) { + Eolian_Function_Type ftype = + accessor->type == SETTER?EOLIAN_PROP_SET:EOLIAN_PROP_GET; database_function_return_type_set(foo_id, - accessor->type == SETTER?EOLIAN_PROP_SET:EOLIAN_PROP_GET, accessor->ret->type); - database_function_data_set(foo_id, - (accessor->type == SETTER?EOLIAN_PROP_SET_RETURN_COMMENT:EOLIAN_PROP_GET_RETURN_COMMENT), - accessor->ret->comment); + ftype, accessor->ret->type); + database_function_return_comment_set(foo_id, + ftype, accessor->ret->comment); database_function_return_flag_set_as_warn_unused(foo_id, - accessor->type == SETTER?EOLIAN_PROP_SET:EOLIAN_PROP_GET, accessor->ret->warn_unused); + ftype, accessor->ret->warn_unused); database_function_return_flag_set_own(foo_id, - accessor->type == SETTER?EOLIAN_PROP_SET:EOLIAN_PROP_GET, accessor->ret->own); + ftype, accessor->ret->own); database_function_return_dflt_val_set(foo_id, - accessor->type == SETTER?EOLIAN_PROP_SET:EOLIAN_PROP_GET, accessor->ret->dflt_ret_val); + ftype, accessor->ret->dflt_ret_val); } if (accessor->legacy) { @@ -1439,8 +1440,8 @@ eo_tokenizer_database_fill(const char *filename) database_class_function_add(kls->name, foo_id); if (meth->ret) { - database_function_data_set(foo_id, EOLIAN_METHOD_RETURN_TYPE, meth->ret->type); - database_function_description_set(foo_id, EOLIAN_RETURN_COMMENT, meth->ret->comment); + database_function_return_type_set(foo_id, EOLIAN_METHOD, meth->ret->type); + database_function_return_comment_set(foo_id, EOLIAN_METHOD, meth->ret->comment); database_function_return_flag_set_as_warn_unused(foo_id, EOLIAN_METHOD, meth->ret->warn_unused); database_function_return_flag_set_own(foo_id, EOLIAN_METHOD, meth->ret->own); diff --git a/src/lib/eolian/eolian_database.c b/src/lib/eolian/eolian_database.c index 392dd65bdb..1dcebcb23a 100644 --- a/src/lib/eolian/eolian_database.c +++ b/src/lib/eolian/eolian_database.c @@ -5,6 +5,14 @@ #define PROP_SET_RETURN_DFLT_VAL "property_set_return_dflt_val" #define METHOD_RETURN_DFLT_VAL "method_return_dflt_val" +#define EOLIAN_METHOD_RETURN_TYPE "method_return_type" +#define EOLIAN_PROP_GET_RETURN_TYPE "property_get_return_type" +#define EOLIAN_PROP_SET_RETURN_TYPE "property_set_return_type" + +#define EOLIAN_METHOD_RETURN_COMMENT "method_return_comment" +#define EOLIAN_PROP_GET_RETURN_COMMENT "property_get_return_comment" +#define EOLIAN_PROP_SET_RETURN_COMMENT "property_set_return_comment" + static Eina_Hash *_classes = NULL; static int _database_init_count = 0; @@ -907,12 +915,25 @@ eolian_function_return_comment_get(Eolian_Function foo_id, Eolian_Function_Type { case EOLIAN_PROP_SET: key = EOLIAN_PROP_SET_RETURN_COMMENT; break; case EOLIAN_PROP_GET: key = EOLIAN_PROP_GET_RETURN_COMMENT; break; - case EOLIAN_UNRESOLVED: case EOLIAN_METHOD: key = EOLIAN_RETURN_COMMENT; break; + case EOLIAN_UNRESOLVED: case EOLIAN_METHOD: key = EOLIAN_METHOD_RETURN_COMMENT; break; default: return NULL; } return eolian_function_data_get(foo_id, key); } +void database_function_return_comment_set(Eolian_Function foo_id, Eolian_Function_Type ftype, const char *ret_comment) +{ + const char *key = NULL; + switch (ftype) + { + case EOLIAN_PROP_SET: key = EOLIAN_PROP_SET_RETURN_COMMENT; break; + case EOLIAN_PROP_GET: key = EOLIAN_PROP_GET_RETURN_COMMENT; break; + case EOLIAN_METHOD: key = EOLIAN_METHOD_RETURN_COMMENT; break; + default: return; + } + database_function_data_set(foo_id, key, ret_comment); +} + void database_function_return_flag_set_as_warn_unused(Eolian_Function foo_id, Eolian_Function_Type ftype, Eina_Bool warn_unused) { @@ -1125,7 +1146,7 @@ static Eina_Bool _function_print(const _Function_Id *fid, int nb_spaces) { Eolian_Function foo_id = (Eolian_Function) fid; EINA_SAFETY_ON_NULL_RETURN_VAL(fid, EINA_FALSE); - const char *ret_desc = eolian_function_description_get(foo_id, EOLIAN_RETURN_COMMENT); + const char *ret_desc = eolian_function_return_comment_get(foo_id, fid->type); switch (fid->type) { case EOLIAN_PROPERTY: diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h index 5a225880ae..30e15b4f3f 100644 --- a/src/lib/eolian/eolian_database.h +++ b/src/lib/eolian/eolian_database.h @@ -94,6 +94,8 @@ void database_parameter_own_set(Eolian_Function_Parameter, Eina_Bool own); void database_function_return_type_set(Eolian_Function foo_id, Eolian_Function_Type ftype, const char *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,