eolian: Skip @beta APIs for duplicate warnings

No warnings:
export EOLIAN_WARN_FUNC_DUPLICATES=0

No beta warnings:
export EOLIAN_WARN_FUNC_DUPLICATES=1

All warnings including beta:
export EOLIAN_WARN_FUNC_DUPLICATES=2

EOLIAN_WARN_FUNC_DUPLICATES is not an API and may change in the future
as we improve the tool :)
This commit is contained in:
Jean-Philippe Andre 2017-10-31 13:58:31 +09:00
parent 02206f252f
commit 1adb93b3e5
1 changed files with 12 additions and 4 deletions

View File

@ -290,14 +290,22 @@ _validate_function(Eolian_Function *func, Eina_Hash *nhash)
Eolian_Function_Parameter *param;
char buf[512];
static int _duplicates_warn = -1;
if (EINA_UNLIKELY(_duplicates_warn < 0))
{
const char *s = getenv("EOLIAN_WARN_FUNC_DUPLICATES");
if (!s) _duplicates_warn = 0;
else _duplicates_warn = atoi(s);
}
const Eolian_Function *ofunc = eina_hash_find(nhash, func->name);
if (ofunc)
if (EINA_UNLIKELY(ofunc && (_duplicates_warn > 0)))
{
snprintf(buf, sizeof(buf),
"function '%s' redefined (originally at %s:%d:%d)",
func->name, ofunc->base.file,
"%sfunction '%s' redefined (originally at %s:%d:%d)",
func->is_beta ? "beta " : "", func->name, ofunc->base.file,
ofunc->base.line, ofunc->base.column);
if (getenv("EOLIAN_WARN_FUNC_DUPLICATES"))
if (!func->is_beta || (_duplicates_warn > 1))
_obj_error(&func->base, buf);
}