forked from enlightenment/efl
eolian: pass unit to struct get by name
This commit is contained in:
parent
52a0255e38
commit
9c2dae3531
|
@ -39,7 +39,7 @@ _generate_ref(const Eolian_Unit *src, const char *refn, Eina_Strbuf *wbuf,
|
|||
|
||||
Eina_Stringshare *bname = eina_stringshare_add_length(refn, sfx - refn);
|
||||
|
||||
const Eolian_Typedecl *tp = eolian_typedecl_struct_get_by_name(bname);
|
||||
const Eolian_Typedecl *tp = eolian_typedecl_struct_get_by_name(src, bname);
|
||||
if (tp)
|
||||
{
|
||||
if (!eolian_typedecl_struct_field_get(tp, sfx + 1))
|
||||
|
|
|
@ -298,7 +298,7 @@ ffi.cdef [[
|
|||
Eina_Bool eolian_class_dtor_enable_get(const Eolian_Class *klass);
|
||||
const char *eolian_class_c_get_function_name_get(const Eolian_Class *klass);
|
||||
const Eolian_Typedecl *eolian_typedecl_alias_get_by_name(const Eolian_Unit *unit, const char *name);
|
||||
const Eolian_Typedecl *eolian_typedecl_struct_get_by_name(const char *name);
|
||||
const Eolian_Typedecl *eolian_typedecl_struct_get_by_name(const Eolian_Unit *unit, const char *name);
|
||||
const Eolian_Typedecl *eolian_typedecl_enum_get_by_name(const char *name);
|
||||
Eina_Iterator *eolian_typedecl_aliases_get_by_file(const char *fname);
|
||||
Eina_Iterator *eolian_typedecl_structs_get_by_file(const char *fname);
|
||||
|
@ -1148,8 +1148,8 @@ M.typedecl_alias_get_by_name = function(unit, name)
|
|||
return v
|
||||
end
|
||||
|
||||
M.typedecl_struct_get_by_name = function(name)
|
||||
local v = eolian.eolian_typedecl_struct_get_by_name(name)
|
||||
M.typedecl_struct_get_by_name = function(unit, name)
|
||||
local v = eolian.eolian_typedecl_struct_get_by_name(unit, name)
|
||||
if v == nil then return nil end
|
||||
return v
|
||||
end
|
||||
|
|
|
@ -1381,12 +1381,13 @@ EAPI const Eolian_Typedecl *eolian_typedecl_alias_get_by_name(const Eolian_Unit
|
|||
/*
|
||||
* @brief Get a struct declaration by name. Supports namespaces.
|
||||
*
|
||||
* @param[in] unit the unit to look in
|
||||
* @param[in] name the name of the struct
|
||||
* @return the struct or NULL
|
||||
*
|
||||
* @ingroup Eolian
|
||||
*/
|
||||
EAPI const Eolian_Typedecl *eolian_typedecl_struct_get_by_name(const char *name);
|
||||
EAPI const Eolian_Typedecl *eolian_typedecl_struct_get_by_name(const Eolian_Unit *unit, const char *name);
|
||||
|
||||
/*
|
||||
* @brief Get an enum declaration by name. Supports namespaces.
|
||||
|
|
|
@ -19,7 +19,8 @@ eolian_typedecl_alias_get_by_name(const Eolian_Unit *unit EINA_UNUSED,
|
|||
}
|
||||
|
||||
EAPI const Eolian_Typedecl *
|
||||
eolian_typedecl_struct_get_by_name(const char *name)
|
||||
eolian_typedecl_struct_get_by_name(const Eolian_Unit *unit EINA_UNUSED,
|
||||
const char *name)
|
||||
{
|
||||
if (!_structs) return NULL;
|
||||
Eina_Stringshare *shr = eina_stringshare_add(name);
|
||||
|
|
|
@ -539,7 +539,8 @@ eolian_doc_token_ref_get(const Eolian_Doc_Token *tok, const void **data,
|
|||
*suffix++ = '\0';
|
||||
|
||||
/* try a struct field */
|
||||
const Eolian_Typedecl *tpd = eolian_typedecl_struct_get_by_name(name);
|
||||
/* FIXME: pass unit properly */
|
||||
const Eolian_Typedecl *tpd = eolian_typedecl_struct_get_by_name(NULL, name);
|
||||
if (tpd)
|
||||
{
|
||||
const Eolian_Struct_Type_Field *fld = eolian_typedecl_struct_field_get(tpd, suffix);
|
||||
|
|
|
@ -662,7 +662,7 @@ START_TEST(eolian_struct)
|
|||
fail_if(!eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD));
|
||||
|
||||
/* named struct */
|
||||
fail_if(!(tdl = eolian_typedecl_struct_get_by_name("Named")));
|
||||
fail_if(!(tdl = eolian_typedecl_struct_get_by_name(unit, "Named")));
|
||||
fail_if(!(type_name = eolian_typedecl_name_get(tdl)));
|
||||
fail_if(!(file = eolian_typedecl_file_get(tdl)));
|
||||
fail_if(eolian_typedecl_type_get(tdl) != EOLIAN_TYPEDECL_STRUCT);
|
||||
|
@ -696,7 +696,7 @@ START_TEST(eolian_struct)
|
|||
eina_stringshare_del(type_name);
|
||||
|
||||
/* referencing */
|
||||
fail_if(!(tdl = eolian_typedecl_struct_get_by_name("Another")));
|
||||
fail_if(!(tdl = eolian_typedecl_struct_get_by_name(unit, "Another")));
|
||||
fail_if(!(type_name = eolian_typedecl_name_get(tdl)));
|
||||
fail_if(!(file = eolian_typedecl_file_get(tdl)));
|
||||
fail_if(eolian_typedecl_type_get(tdl) != EOLIAN_TYPEDECL_STRUCT);
|
||||
|
@ -711,7 +711,7 @@ START_TEST(eolian_struct)
|
|||
!= EOLIAN_TYPEDECL_STRUCT);
|
||||
|
||||
/* opaque struct */
|
||||
fail_if(!(tdl = eolian_typedecl_struct_get_by_name("Opaque")));
|
||||
fail_if(!(tdl = eolian_typedecl_struct_get_by_name(unit, "Opaque")));
|
||||
fail_if(eolian_typedecl_type_get(tdl) != EOLIAN_TYPEDECL_STRUCT_OPAQUE);
|
||||
|
||||
/* use in function */
|
||||
|
@ -750,11 +750,11 @@ START_TEST(eolian_extern)
|
|||
fail_if(!eolian_typedecl_is_extern(tdl));
|
||||
|
||||
/* regular struct */
|
||||
fail_if(!(tdl = eolian_typedecl_struct_get_by_name("X")));
|
||||
fail_if(!(tdl = eolian_typedecl_struct_get_by_name(unit, "X")));
|
||||
fail_if(eolian_typedecl_is_extern(tdl));
|
||||
|
||||
/* extern struct */
|
||||
fail_if(!(tdl = eolian_typedecl_struct_get_by_name("Y")));
|
||||
fail_if(!(tdl = eolian_typedecl_struct_get_by_name(unit, "Y")));
|
||||
fail_if(!eolian_typedecl_is_extern(tdl));
|
||||
|
||||
eolian_shutdown();
|
||||
|
@ -980,9 +980,9 @@ START_TEST(eolian_free_func)
|
|||
fail_if(!eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD));
|
||||
|
||||
/* regular struct */
|
||||
fail_if(!(tdl = eolian_typedecl_struct_get_by_name("Named1")));
|
||||
fail_if(!(tdl = eolian_typedecl_struct_get_by_name(unit, "Named1")));
|
||||
fail_if(eolian_typedecl_free_func_get(tdl));
|
||||
fail_if(!(tdl = eolian_typedecl_struct_get_by_name("Named2")));
|
||||
fail_if(!(tdl = eolian_typedecl_struct_get_by_name(unit, "Named2")));
|
||||
fail_if(strcmp(eolian_typedecl_free_func_get(tdl), "test_free"));
|
||||
|
||||
/* typedef */
|
||||
|
@ -992,9 +992,9 @@ START_TEST(eolian_free_func)
|
|||
fail_if(strcmp(eolian_typedecl_free_func_get(tdl), "def_free"));
|
||||
|
||||
/* opaque struct */
|
||||
fail_if(!(tdl = eolian_typedecl_struct_get_by_name("Opaque1")));
|
||||
fail_if(!(tdl = eolian_typedecl_struct_get_by_name(unit, "Opaque1")));
|
||||
fail_if(eolian_typedecl_free_func_get(tdl));
|
||||
fail_if(!(tdl = eolian_typedecl_struct_get_by_name("Opaque2")));
|
||||
fail_if(!(tdl = eolian_typedecl_struct_get_by_name(unit, "Opaque2")));
|
||||
fail_if(strcmp(eolian_typedecl_free_func_get(tdl), "opaque_free"));
|
||||
|
||||
/* pointer */
|
||||
|
@ -1074,7 +1074,7 @@ START_TEST(eolian_import)
|
|||
fail_if(!(tdl = eolian_typedecl_alias_get_by_name(unit, "Imported")));
|
||||
fail_if(strcmp(eolian_typedecl_file_get(tdl), "import_types.eot"));
|
||||
|
||||
fail_if(!(tdl = eolian_typedecl_struct_get_by_name("Imported_Struct")));
|
||||
fail_if(!(tdl = eolian_typedecl_struct_get_by_name(unit, "Imported_Struct")));
|
||||
fail_if(strcmp(eolian_typedecl_file_get(tdl), "import_types.eot"));
|
||||
|
||||
eolian_shutdown();
|
||||
|
@ -1163,7 +1163,7 @@ START_TEST(eolian_docs)
|
|||
|
||||
fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/docs.eo")));
|
||||
|
||||
fail_if(!(tdl = eolian_typedecl_struct_get_by_name("Foo")));
|
||||
fail_if(!(tdl = eolian_typedecl_struct_get_by_name(unit, "Foo")));
|
||||
fail_if(!(doc = eolian_typedecl_documentation_get(tdl)));
|
||||
fail_if(strcmp(eolian_documentation_summary_get(doc),
|
||||
"This is struct Foo. It does stuff."));
|
||||
|
@ -1302,7 +1302,7 @@ START_TEST(eolian_docs)
|
|||
"Docs for var."));
|
||||
fail_if(eolian_documentation_description_get(doc));
|
||||
|
||||
fail_if(!(tdl = eolian_typedecl_struct_get_by_name("Opaque")));
|
||||
fail_if(!(tdl = eolian_typedecl_struct_get_by_name(unit, "Opaque")));
|
||||
fail_if(!(doc = eolian_typedecl_documentation_get(tdl)));
|
||||
fail_if(strcmp(eolian_documentation_summary_get(doc),
|
||||
"Opaque struct docs. See @Foo for another struct."));
|
||||
|
|
Loading…
Reference in New Issue