forked from enlightenment/efl
eolian: remove type silencing stuff entirely
this was useful during transition, but not anymore
This commit is contained in:
parent
bbf189c993
commit
82ef73ca18
|
@ -43,7 +43,6 @@ _print_usage(const char *progn, FILE *outf)
|
|||
" -o type:name specify a particular output filename\n"
|
||||
" -h print this message and exit\n"
|
||||
" -v print version and exit\n"
|
||||
" -s silence type errors in validation\n"
|
||||
"\n"
|
||||
"Available types:\n"
|
||||
" h: C header file (.h)\n"
|
||||
|
@ -398,8 +397,7 @@ main(int argc, char **argv)
|
|||
char *outs[5] = { NULL, NULL, NULL, NULL, NULL };
|
||||
|
||||
int gen_what = 0;
|
||||
Eina_Bool silent_types = EINA_FALSE;
|
||||
for (int opt; (opt = getopt(argc, argv, "I:g:o:shv")) != -1;)
|
||||
for (int opt; (opt = getopt(argc, argv, "I:g:o:hv")) != -1;)
|
||||
switch (opt)
|
||||
{
|
||||
case 0:
|
||||
|
@ -451,9 +449,6 @@ main(int argc, char **argv)
|
|||
}
|
||||
else _fill_all_outs(outs, optarg);
|
||||
break;
|
||||
case 's':
|
||||
silent_types = EINA_TRUE;
|
||||
break;
|
||||
case 'h':
|
||||
_print_usage(argv[0], stdout);
|
||||
goto end;
|
||||
|
@ -485,7 +480,7 @@ main(int argc, char **argv)
|
|||
goto end;
|
||||
}
|
||||
|
||||
if (!eolian_database_validate(silent_types))
|
||||
if (!eolian_database_validate())
|
||||
{
|
||||
fprintf(stderr, "eolian: failed validating database\n");
|
||||
goto end;
|
||||
|
|
|
@ -252,7 +252,7 @@ database_load(options_type const& opts)
|
|||
<< "Failed parsing: " << opts.in_file << ".";
|
||||
assert(false && "Error parsing input file");
|
||||
}
|
||||
if (!::eolian_database_validate(EINA_FALSE))
|
||||
if (!::eolian_database_validate())
|
||||
{
|
||||
EINA_CXX_DOM_LOG_ERR(eolian_cxx::domain)
|
||||
<< "Eolian failed validating database.";
|
||||
|
|
|
@ -196,7 +196,7 @@ ffi.cdef [[
|
|||
Eina_Bool eolian_system_directory_scan();
|
||||
Eina_Bool eolian_all_eo_files_parse();
|
||||
Eina_Bool eolian_all_eot_files_parse();
|
||||
Eina_Bool eolian_database_validate(Eina_Bool silent_types);
|
||||
Eina_Bool eolian_database_validate();
|
||||
const Eolian_Class *eolian_class_get_by_name(const char *class_name);
|
||||
const Eolian_Class *eolian_class_get_by_file(const char *file_name);
|
||||
const char *eolian_class_file_get(const Eolian_Class *klass);
|
||||
|
@ -438,8 +438,8 @@ M.all_eot_files_get = function()
|
|||
return iterator.String_Iterator(eolian.eolian_all_eot_files_get())
|
||||
end
|
||||
|
||||
M.database_validate = function(silent)
|
||||
return eolian.eolian_database_validate((not not silent) or false) ~= 0
|
||||
M.database_validate = function()
|
||||
return eolian.eolian_database_validate() ~= 0
|
||||
end
|
||||
|
||||
M.declaration_type = {
|
||||
|
|
|
@ -466,14 +466,13 @@ EAPI Eina_Bool eolian_all_eot_files_parse(void);
|
|||
/*
|
||||
* @brief Validates the database, printing errors and warnings.
|
||||
*
|
||||
* @param[in] silent_types whether to silence type errors
|
||||
* @return EINA_TRUE on success, EINA_FALSE otherwise.
|
||||
*
|
||||
* Useful to catch type errors etc. early on.
|
||||
*
|
||||
* @ingroup Eolian
|
||||
*/
|
||||
EAPI Eina_Bool eolian_database_validate(Eina_Bool silent_types);
|
||||
EAPI Eina_Bool eolian_database_validate();
|
||||
|
||||
/*
|
||||
* @brief Gets a class by its name
|
||||
|
|
|
@ -6,18 +6,8 @@
|
|||
|
||||
#include "eo_lexer.h"
|
||||
|
||||
typedef struct _Validator {
|
||||
Eina_Bool silent_types;
|
||||
} Validator;
|
||||
|
||||
typedef struct _Val_Success {
|
||||
const Validator *vs;
|
||||
Eina_Bool success;
|
||||
} Val_Success;
|
||||
|
||||
static Eina_Bool
|
||||
_validate_ref(const Validator *vs EINA_UNUSED, const char *ref,
|
||||
const Eolian_Object *info)
|
||||
_validate_ref(const char *ref, const Eolian_Object *info)
|
||||
{
|
||||
if (eolian_declaration_get_by_name(ref))
|
||||
return EINA_TRUE;
|
||||
|
@ -88,8 +78,7 @@ failed:
|
|||
}
|
||||
|
||||
static Eina_Bool
|
||||
_validate_docstr(const Validator *vs, Eina_Stringshare *str,
|
||||
const Eolian_Object *info)
|
||||
_validate_docstr(Eina_Stringshare *str, const Eolian_Object *info)
|
||||
{
|
||||
if (!str) return EINA_TRUE;
|
||||
|
||||
|
@ -110,7 +99,7 @@ _validate_docstr(const Validator *vs, Eina_Stringshare *str,
|
|||
++p;
|
||||
if (*(p - 1) == '.') --p;
|
||||
Eina_Stringshare *refs = eina_stringshare_add_length(ref, (p - ref));
|
||||
if (!_validate_ref(vs, refs, info))
|
||||
if (!_validate_ref(refs, info))
|
||||
{
|
||||
eina_stringshare_del(refs);
|
||||
return EINA_FALSE;
|
||||
|
@ -122,92 +111,85 @@ _validate_docstr(const Validator *vs, Eina_Stringshare *str,
|
|||
}
|
||||
|
||||
static Eina_Bool
|
||||
_validate_doc(const Validator *vs, const Eolian_Documentation *doc)
|
||||
_validate_doc(const Eolian_Documentation *doc)
|
||||
{
|
||||
if (!doc) return EINA_TRUE;
|
||||
|
||||
if (!_validate_docstr(vs, doc->summary, &doc->base))
|
||||
if (!_validate_docstr(doc->summary, &doc->base))
|
||||
return EINA_FALSE;
|
||||
if (!_validate_docstr(vs, doc->description, &doc->base))
|
||||
if (!_validate_docstr(doc->description, &doc->base))
|
||||
return EINA_FALSE;
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Eina_Bool _validate_type(const Validator *vs, const Eolian_Type *tp);
|
||||
static Eina_Bool _validate_expr(const Validator *vs,
|
||||
const Eolian_Expression *expr,
|
||||
static Eina_Bool _validate_type(const Eolian_Type *tp);
|
||||
static Eina_Bool _validate_expr(const Eolian_Expression *expr,
|
||||
const Eolian_Type *tp,
|
||||
Eolian_Expression_Mask msk);
|
||||
|
||||
static Eina_Bool
|
||||
_sf_map_cb(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED,
|
||||
const Eolian_Struct_Type_Field *sf, Val_Success *sc)
|
||||
const Eolian_Struct_Type_Field *sf, Eina_Bool *sc)
|
||||
{
|
||||
sc->success = _validate_type(sc->vs, sf->type);
|
||||
*sc = _validate_type(sf->type);
|
||||
|
||||
if (!sc->success)
|
||||
if (!*sc)
|
||||
return EINA_FALSE;
|
||||
|
||||
sc->success = _validate_doc(sc->vs, sf->doc);
|
||||
*sc = _validate_doc(sf->doc);
|
||||
|
||||
return sc->success;
|
||||
return *sc;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_ef_map_cb(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED,
|
||||
const Eolian_Enum_Type_Field *ef, Val_Success *sc)
|
||||
const Eolian_Enum_Type_Field *ef, Eina_Bool *sc)
|
||||
{
|
||||
if (ef->value)
|
||||
sc->success = _validate_expr(sc->vs, ef->value, NULL, EOLIAN_MASK_INT);
|
||||
*sc = _validate_expr(ef->value, NULL, EOLIAN_MASK_INT);
|
||||
else
|
||||
sc->success = EINA_TRUE;
|
||||
*sc = EINA_TRUE;
|
||||
|
||||
if (!sc->success)
|
||||
if (!*sc)
|
||||
return EINA_FALSE;
|
||||
|
||||
sc->success = _validate_doc(sc->vs, ef->doc);
|
||||
*sc = _validate_doc(ef->doc);
|
||||
|
||||
return sc->success;
|
||||
return *sc;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_type_error(const Validator *vs, const Eolian_Type *tp, const char *msg)
|
||||
_type_error(const Eolian_Type *tp, const char *msg)
|
||||
{
|
||||
if (vs->silent_types)
|
||||
return EINA_FALSE;
|
||||
fprintf(stderr, "eolian:%s:%d:%d: %s\n", tp->base.file, tp->base.line,
|
||||
tp->base.column, msg);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_validate_typedecl(const Validator *vs, const Eolian_Typedecl *tp)
|
||||
_validate_typedecl(const Eolian_Typedecl *tp)
|
||||
{
|
||||
if (!_validate_doc(vs, tp->doc))
|
||||
if (!_validate_doc(tp->doc))
|
||||
return EINA_FALSE;
|
||||
|
||||
switch (tp->type)
|
||||
{
|
||||
case EOLIAN_TYPEDECL_ALIAS:
|
||||
return _validate_type(vs, tp->base_type);
|
||||
return _validate_type(tp->base_type);
|
||||
case EOLIAN_TYPEDECL_STRUCT:
|
||||
{
|
||||
Val_Success succ;
|
||||
succ.vs = vs;
|
||||
succ.success = EINA_TRUE;
|
||||
Eina_Bool succ = EINA_TRUE;
|
||||
eina_hash_foreach(tp->fields, (Eina_Hash_Foreach)_sf_map_cb, &succ);
|
||||
return succ.success;
|
||||
return succ;
|
||||
}
|
||||
case EOLIAN_TYPEDECL_STRUCT_OPAQUE:
|
||||
return EINA_TRUE;
|
||||
case EOLIAN_TYPEDECL_ENUM:
|
||||
{
|
||||
Val_Success succ;
|
||||
succ.vs = vs;
|
||||
succ.success = EINA_TRUE;
|
||||
Eina_Bool succ = EINA_TRUE;
|
||||
eina_hash_foreach(tp->fields, (Eina_Hash_Foreach)_ef_map_cb, &succ);
|
||||
return succ.success;
|
||||
return succ;
|
||||
}
|
||||
default:
|
||||
return EINA_FALSE;
|
||||
|
@ -216,7 +198,7 @@ _validate_typedecl(const Validator *vs, const Eolian_Typedecl *tp)
|
|||
}
|
||||
|
||||
static Eina_Bool
|
||||
_validate_type(const Validator *vs, const Eolian_Type *tp)
|
||||
_validate_type(const Eolian_Type *tp)
|
||||
{
|
||||
switch (tp->type)
|
||||
{
|
||||
|
@ -237,14 +219,14 @@ _validate_type(const Validator *vs, const Eolian_Type *tp)
|
|||
{
|
||||
char buf[256];
|
||||
snprintf(buf, sizeof(buf), "undefined type %s", tp->full_name);
|
||||
return _type_error(vs, tp, buf);
|
||||
return _type_error(tp, buf);
|
||||
}
|
||||
return _validate_typedecl(vs, tpp);
|
||||
return _validate_typedecl(tpp);
|
||||
}
|
||||
case EOLIAN_TYPE_POINTER:
|
||||
case EOLIAN_TYPE_STATIC_ARRAY:
|
||||
case EOLIAN_TYPE_TERMINATED_ARRAY:
|
||||
return _validate_type(vs, tp->base_type);
|
||||
return _validate_type(tp->base_type);
|
||||
case EOLIAN_TYPE_CLASS:
|
||||
{
|
||||
if (!eolian_type_class_get(tp))
|
||||
|
@ -253,7 +235,7 @@ _validate_type(const Validator *vs, const Eolian_Type *tp)
|
|||
char buf[256];
|
||||
snprintf(buf, sizeof(buf), "undefined class %s "
|
||||
"(likely wrong namespacing)", tp->full_name);
|
||||
return _type_error(vs, tp, buf);
|
||||
return _type_error(tp, buf);
|
||||
}
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
@ -264,7 +246,7 @@ _validate_type(const Validator *vs, const Eolian_Type *tp)
|
|||
}
|
||||
|
||||
static Eina_Bool
|
||||
_validate_expr(const Validator *vs EINA_UNUSED, const Eolian_Expression *expr,
|
||||
_validate_expr(const Eolian_Expression *expr,
|
||||
const Eolian_Type *tp, Eolian_Expression_Mask msk)
|
||||
{
|
||||
Eolian_Value val;
|
||||
|
@ -283,40 +265,40 @@ _validate_expr(const Validator *vs EINA_UNUSED, const Eolian_Expression *expr,
|
|||
}
|
||||
|
||||
static Eina_Bool
|
||||
_validate_param(const Validator *vs, const Eolian_Function_Parameter *param)
|
||||
_validate_param(const Eolian_Function_Parameter *param)
|
||||
{
|
||||
if (!_validate_type(vs, param->type))
|
||||
if (!_validate_type(param->type))
|
||||
return EINA_FALSE;
|
||||
|
||||
if (!_validate_doc(vs, param->doc))
|
||||
if (!_validate_doc(param->doc))
|
||||
return EINA_FALSE;
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_validate_function(const Validator *vs, const Eolian_Function *func)
|
||||
_validate_function(const Eolian_Function *func)
|
||||
{
|
||||
Eina_List *l;
|
||||
const Eolian_Function_Parameter *param;
|
||||
|
||||
if (func->get_ret_type && !_validate_type(vs, func->get_ret_type))
|
||||
if (func->get_ret_type && !_validate_type(func->get_ret_type))
|
||||
return EINA_FALSE;
|
||||
|
||||
if (func->set_ret_type && !_validate_type(vs, func->set_ret_type))
|
||||
if (func->set_ret_type && !_validate_type(func->set_ret_type))
|
||||
return EINA_FALSE;
|
||||
|
||||
if (func->get_ret_val && !_validate_expr(vs, func->get_ret_val,
|
||||
if (func->get_ret_val && !_validate_expr(func->get_ret_val,
|
||||
func->get_ret_type, 0))
|
||||
return EINA_FALSE;
|
||||
|
||||
if (func->set_ret_val && !_validate_expr(vs, func->set_ret_val,
|
||||
if (func->set_ret_val && !_validate_expr(func->set_ret_val,
|
||||
func->set_ret_type, 0))
|
||||
return EINA_FALSE;
|
||||
|
||||
#define EOLIAN_PARAMS_VALIDATE(params) \
|
||||
EINA_LIST_FOREACH(params, l, param) \
|
||||
if (!_validate_param(vs, param)) \
|
||||
if (!_validate_param(param)) \
|
||||
return EINA_FALSE;
|
||||
|
||||
EOLIAN_PARAMS_VALIDATE(func->prop_values);
|
||||
|
@ -328,67 +310,67 @@ _validate_function(const Validator *vs, const Eolian_Function *func)
|
|||
|
||||
#undef EOLIAN_PARAMS_VALIDATE
|
||||
|
||||
if (!_validate_doc(vs, func->common_doc))
|
||||
if (!_validate_doc(func->common_doc))
|
||||
return EINA_FALSE;
|
||||
if (!_validate_doc(vs, func->get_doc))
|
||||
if (!_validate_doc(func->get_doc))
|
||||
return EINA_FALSE;
|
||||
if (!_validate_doc(vs, func->set_doc))
|
||||
if (!_validate_doc(func->set_doc))
|
||||
return EINA_FALSE;
|
||||
if (!_validate_doc(vs, func->get_return_doc))
|
||||
if (!_validate_doc(func->get_return_doc))
|
||||
return EINA_FALSE;
|
||||
if (!_validate_doc(vs, func->set_return_doc))
|
||||
if (!_validate_doc(func->set_return_doc))
|
||||
return EINA_FALSE;
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_validate_event(const Validator *vs, const Eolian_Event *event)
|
||||
_validate_event(const Eolian_Event *event)
|
||||
{
|
||||
if (event->type && !_validate_type(vs, event->type))
|
||||
if (event->type && !_validate_type(event->type))
|
||||
return EINA_FALSE;
|
||||
|
||||
if (!_validate_doc(vs, event->doc))
|
||||
if (!_validate_doc(event->doc))
|
||||
return EINA_FALSE;
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_validate_class(const Validator *vs, const Eolian_Class *cl)
|
||||
_validate_class(const Eolian_Class *cl)
|
||||
{
|
||||
Eina_List *l;
|
||||
const Eolian_Function *func;
|
||||
const Eolian_Event *event;
|
||||
|
||||
EINA_LIST_FOREACH(cl->properties, l, func)
|
||||
if (!_validate_function(vs, func))
|
||||
if (!_validate_function(func))
|
||||
return EINA_FALSE;
|
||||
|
||||
EINA_LIST_FOREACH(cl->methods, l, func)
|
||||
if (!_validate_function(vs, func))
|
||||
if (!_validate_function(func))
|
||||
return EINA_FALSE;
|
||||
|
||||
EINA_LIST_FOREACH(cl->events, l, event)
|
||||
if (!_validate_event(vs, event))
|
||||
if (!_validate_event(event))
|
||||
return EINA_FALSE;
|
||||
|
||||
if (!_validate_doc(vs, cl->doc))
|
||||
if (!_validate_doc(cl->doc))
|
||||
return EINA_FALSE;
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_validate_variable(const Validator *vs, const Eolian_Variable *var)
|
||||
_validate_variable(const Eolian_Variable *var)
|
||||
{
|
||||
if (!_validate_type(vs, var->base_type))
|
||||
if (!_validate_type(var->base_type))
|
||||
return EINA_FALSE;
|
||||
|
||||
if (var->value && !_validate_expr(vs, var->value, var->base_type, 0))
|
||||
if (var->value && !_validate_expr(var->value, var->base_type, 0))
|
||||
return EINA_FALSE;
|
||||
|
||||
if (!_validate_doc(vs, var->doc))
|
||||
if (!_validate_doc(var->doc))
|
||||
return EINA_FALSE;
|
||||
|
||||
return EINA_TRUE;
|
||||
|
@ -396,59 +378,52 @@ _validate_variable(const Validator *vs, const Eolian_Variable *var)
|
|||
|
||||
static Eina_Bool
|
||||
_typedecl_map_cb(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED,
|
||||
const Eolian_Typedecl *tp, Val_Success *sc)
|
||||
const Eolian_Typedecl *tp, Eina_Bool *sc)
|
||||
{
|
||||
sc->success = _validate_typedecl(sc->vs, tp);
|
||||
return sc->success;
|
||||
return (*sc = _validate_typedecl(tp));
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_var_map_cb(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED,
|
||||
const Eolian_Variable *var, Val_Success *sc)
|
||||
const Eolian_Variable *var, Eina_Bool *sc)
|
||||
{
|
||||
sc->success = _validate_variable(sc->vs, var);
|
||||
return sc->success;
|
||||
return (*sc = _validate_variable(var));
|
||||
}
|
||||
|
||||
Eina_Bool
|
||||
database_validate(Eina_Bool silent_types)
|
||||
database_validate()
|
||||
{
|
||||
Validator vs;
|
||||
const Eolian_Class *cl;
|
||||
|
||||
vs.silent_types = silent_types;
|
||||
|
||||
Eina_Iterator *iter = eolian_all_classes_get();
|
||||
EINA_ITERATOR_FOREACH(iter, cl)
|
||||
if (!_validate_class(&vs, cl))
|
||||
if (!_validate_class(cl))
|
||||
{
|
||||
eina_iterator_free(iter);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
eina_iterator_free(iter);
|
||||
|
||||
Val_Success succ;
|
||||
succ.vs = &vs;
|
||||
succ.success = EINA_TRUE;
|
||||
Eina_Bool succ = EINA_TRUE;
|
||||
|
||||
eina_hash_foreach(_aliases, (Eina_Hash_Foreach)_typedecl_map_cb, &succ);
|
||||
if (!succ.success)
|
||||
if (!succ)
|
||||
return EINA_FALSE;
|
||||
|
||||
eina_hash_foreach(_structs, (Eina_Hash_Foreach)_typedecl_map_cb, &succ);
|
||||
if (!succ.success)
|
||||
if (!succ)
|
||||
return EINA_FALSE;
|
||||
|
||||
eina_hash_foreach(_enums, (Eina_Hash_Foreach)_typedecl_map_cb, &succ);
|
||||
if (!succ.success)
|
||||
if (!succ)
|
||||
return EINA_FALSE;
|
||||
|
||||
eina_hash_foreach(_globals, (Eina_Hash_Foreach)_var_map_cb, &succ);
|
||||
if (!succ.success)
|
||||
if (!succ)
|
||||
return EINA_FALSE;
|
||||
|
||||
eina_hash_foreach(_constants, (Eina_Hash_Foreach)_var_map_cb, &succ);
|
||||
if (!succ.success)
|
||||
if (!succ)
|
||||
return EINA_FALSE;
|
||||
|
||||
return EINA_TRUE;
|
||||
|
|
|
@ -372,12 +372,12 @@ eolian_all_eo_files_parse()
|
|||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
eolian_database_validate(Eina_Bool silent_types)
|
||||
eolian_database_validate()
|
||||
{
|
||||
if (_database_init_count <= 0)
|
||||
return EINA_FALSE;
|
||||
|
||||
return database_validate(silent_types);
|
||||
return database_validate();
|
||||
}
|
||||
|
||||
EAPI Eina_Iterator *
|
||||
|
|
|
@ -287,7 +287,7 @@ int database_init(void);
|
|||
int database_shutdown(void);
|
||||
|
||||
char *database_class_to_filename(const char *cname);
|
||||
Eina_Bool database_validate(Eina_Bool silent_types);
|
||||
Eina_Bool database_validate();
|
||||
const Eolian_Class *database_object_class_fill(const char *class_name, const Eolian_Class **cl);
|
||||
|
||||
void database_decl_add(Eina_Stringshare *name, Eolian_Declaration_Type type,
|
||||
|
|
Loading…
Reference in New Issue