eolian: fix redefined function checks

For one, the hash has to be populated once per inheritance tree
and the skipping on already-validated funcs was interfering with
that as the function might have been validated in another
inheritance tree already.

Also, if a class appeared multiple times in an inheritance tree,
as is common with e.g. Efl.Object, it would get added into the
hash the first time and then checked against the second time,
which would result in a strange error message about the
function being redefined in its own class.

So now we prevent both cases from happening.
This commit is contained in:
Daniel Kolesa 2018-01-18 12:49:05 +01:00
parent c91ae98fd3
commit 1017f37de7
1 changed files with 7 additions and 2 deletions

View File

@ -333,7 +333,7 @@ _validate_function(const Eolian_Unit *src, Eolian_Function *func, Eina_Hash *nha
}
const Eolian_Function *ofunc = nhash ? eina_hash_find(nhash, func->name) : NULL;
if (EINA_UNLIKELY(ofunc && (_duplicates_warn > 0)))
if (EINA_UNLIKELY(ofunc && (ofunc != func) && (_duplicates_warn > 0)))
{
snprintf(buf, sizeof(buf),
"%sfunction '%s' redefined (originally at %s:%d:%d)",
@ -347,7 +347,12 @@ _validate_function(const Eolian_Unit *src, Eolian_Function *func, Eina_Hash *nha
* but duplicate checks need to be performed every time
*/
if (func->base.validated)
return EINA_TRUE;
{
/* it might be validated, but need to add it anyway */
if (!ofunc && nhash)
eina_hash_add(nhash, func->name, func);
return EINA_TRUE;
}
if (func->get_ret_type && !_validate_type(src, func->get_ret_type))
return EINA_FALSE;