Eolian: clean API.

defines used as keys for internal hash tables are now replaced by
functions giving access to the internal data.
This commit is contained in:
Daniel Zaoui 2014-04-06 17:10:05 +03:00
parent 912409df3c
commit 1d89978c5b
5 changed files with 49 additions and 30 deletions

View File

@ -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"

View File

@ -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);

View File

@ -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);

View File

@ -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:

View File

@ -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,