eolian: update type/var name APIs

This commit is contained in:
Daniel Kolesa 2018-03-12 16:28:28 +01:00
parent 35d9ef2dd2
commit 1f4d919cf9
10 changed files with 112 additions and 145 deletions

View File

@ -131,7 +131,7 @@ _append_defval(Eina_Strbuf *buf, const Eolian_Expression *exp, const Eolian_Type
const Eolian_Typedecl *tdcl = eolian_type_typedecl_get(btp); const Eolian_Typedecl *tdcl = eolian_type_typedecl_get(btp);
if (tdcl && (eolian_typedecl_type_get(tdcl) == EOLIAN_TYPEDECL_STRUCT)) if (tdcl && (eolian_typedecl_type_get(tdcl) == EOLIAN_TYPEDECL_STRUCT))
{ {
char *sn = eo_gen_c_full_name_get(eolian_typedecl_full_name_get(tdcl)); char *sn = eo_gen_c_full_name_get(eolian_typedecl_name_get(tdcl));
if (eina_streq(sn, "Eina_Rect")) if (eina_streq(sn, "Eina_Rect"))
eina_strbuf_append(buf, "(EINA_RECT_EMPTY())"); eina_strbuf_append(buf, "(EINA_RECT_EMPTY())");
else else
@ -156,7 +156,7 @@ _generate_normal_free(Eina_Strbuf **buf, const Eolian_Type *type, const Eina_Str
const char *free_func = eolian_type_free_func_get(type); const char *free_func = eolian_type_free_func_get(type);
if (!free_func) if (!free_func)
{ {
printf("No free type %s\n", eolian_type_name_get(type)); printf("No free type %s\n", eolian_type_short_name_get(type));
return; return;
} }

View File

@ -6,7 +6,7 @@ static Eina_Strbuf *
_type_generate(const Eolian_Unit *src, const Eolian_Typedecl *tp, _type_generate(const Eolian_Unit *src, const Eolian_Typedecl *tp,
Eina_Bool full, Eina_Bool legacy) Eina_Bool full, Eina_Bool legacy)
{ {
char *grp = strdup(eolian_typedecl_full_name_get(tp)); char *grp = strdup(eolian_typedecl_name_get(tp));
char *p = strrchr(grp, '.'); char *p = strrchr(grp, '.');
if (p) *p = '\0'; if (p) *p = '\0';
Eina_Strbuf *buf = eo_gen_docs_full_gen(src, eolian_typedecl_documentation_get(tp), Eina_Strbuf *buf = eo_gen_docs_full_gen(src, eolian_typedecl_documentation_get(tp),
@ -28,7 +28,7 @@ _type_generate(const Eolian_Unit *src, const Eolian_Typedecl *tp,
case EOLIAN_TYPEDECL_STRUCT_OPAQUE: case EOLIAN_TYPEDECL_STRUCT_OPAQUE:
{ {
const Eolian_Struct_Type_Field *memb; const Eolian_Struct_Type_Field *memb;
char *fn = eo_gen_c_full_name_get(eolian_typedecl_full_name_get(tp)); char *fn = eo_gen_c_full_name_get(eolian_typedecl_name_get(tp));
if (tpt == EOLIAN_TYPEDECL_STRUCT_OPAQUE || !full) if (tpt == EOLIAN_TYPEDECL_STRUCT_OPAQUE || !full)
{ {
eina_strbuf_append_printf(buf, "typedef struct _%s %s", fn, fn); eina_strbuf_append_printf(buf, "typedef struct _%s %s", fn, fn);
@ -118,7 +118,7 @@ _type_generate(const Eolian_Unit *src, const Eolian_Typedecl *tp,
eina_strbuf_append(buf, "\n"); eina_strbuf_append(buf, "\n");
} }
eina_iterator_free(membs); eina_iterator_free(membs);
char *fn = eo_gen_c_full_name_get(eolian_typedecl_full_name_get(tp)); char *fn = eo_gen_c_full_name_get(eolian_typedecl_name_get(tp));
eina_strbuf_append_printf(buf, "} %s", fn); eina_strbuf_append_printf(buf, "} %s", fn);
free(fn); free(fn);
break; break;
@ -140,7 +140,7 @@ _type_generate(const Eolian_Unit *src, const Eolian_Typedecl *tp,
} }
/* Function name */ /* Function name */
char *fn = eo_gen_c_full_name_get(eolian_typedecl_full_name_get(tp)); char *fn = eo_gen_c_full_name_get(eolian_typedecl_name_get(tp));
eina_strbuf_append_printf(buf, "(*%s)", fn); eina_strbuf_append_printf(buf, "(*%s)", fn);
free(fn); free(fn);
@ -162,7 +162,7 @@ _type_generate(const Eolian_Unit *src, const Eolian_Typedecl *tp,
static Eina_Strbuf * static Eina_Strbuf *
_var_generate(const Eolian_Unit *src, const Eolian_Variable *vr, Eina_Bool legacy) _var_generate(const Eolian_Unit *src, const Eolian_Variable *vr, Eina_Bool legacy)
{ {
char *fn = strdup(eolian_variable_full_name_get(vr)); char *fn = strdup(eolian_variable_name_get(vr));
char *p = strrchr(fn, '.'); char *p = strrchr(fn, '.');
if (p) *p = '\0'; if (p) *p = '\0';
Eina_Strbuf *buf = eo_gen_docs_full_gen(src, eolian_variable_documentation_get(vr), Eina_Strbuf *buf = eo_gen_docs_full_gen(src, eolian_variable_documentation_get(vr),
@ -280,7 +280,7 @@ void eo_gen_types_source_gen(Eina_Iterator *itr, Eina_Strbuf *buf)
if (!vv) if (!vv)
continue; continue;
char *fn = strdup(eolian_variable_full_name_get(vr)); char *fn = strdup(eolian_variable_name_get(vr));
for (char *p = strchr(fn, '.'); p; p = strchr(p, '.')) for (char *p = strchr(fn, '.'); p; p = strchr(p, '.'))
*p = '_'; *p = '_';
eina_str_toupper(&fn); eina_str_toupper(&fn);

View File

@ -248,7 +248,7 @@ types_generate(std::string const& fname, options_type const& opts,
if (!func) return false; if (!func) return false;
function_def def(func, EOLIAN_FUNCTION_POINTER, opts.unit); function_def def(func, EOLIAN_FUNCTION_POINTER, opts.unit);
def.c_name = eolian_typedecl_full_name_get(tp); def.c_name = eolian_typedecl_name_get(tp);
std::replace(def.c_name.begin(), def.c_name.end(), '.', '_'); std::replace(def.c_name.begin(), def.c_name.end(), '.', '_');
functions.push_back(std::move(def)); functions.push_back(std::move(def));
} }

View File

@ -59,7 +59,7 @@ inline std::string type_class_name(Eolian_Type const* tp)
auto tpd = eolian_type_typedecl_get(tp); auto tpd = eolian_type_typedecl_get(tp);
if (tpd && eolian_typedecl_type_get(tpd) == EOLIAN_TYPEDECL_STRUCT) if (tpd && eolian_typedecl_type_get(tpd) == EOLIAN_TYPEDECL_STRUCT)
{ {
auto struct_type_full_name = ::eolian_type_full_name_get(tp); auto struct_type_full_name = ::eolian_type_name_get(tp);
if (!struct_type_full_name) if (!struct_type_full_name)
throw std::runtime_error("Could not get struct name"); throw std::runtime_error("Could not get struct name");
return struct_type_full_name; return struct_type_full_name;

View File

@ -73,8 +73,8 @@ _final_type_and_type_type_get(Eolian_Type const* tp_in, Eolian_Type const*& tp_o
!eolian_typedecl_is_extern(tpd)) !eolian_typedecl_is_extern(tpd))
{ {
auto btp = eolian_typedecl_aliased_base_get(tpd); auto btp = eolian_typedecl_aliased_base_get(tpd);
if (btp && eolian_type_full_name_get(btp) && if (btp && eolian_type_name_get(btp) &&
strcmp(eolian_type_full_name_get(btp), "__undefined_type") != 0) strcmp(eolian_type_name_get(btp), "__undefined_type") != 0)
{ {
_final_type_and_type_type_get(btp, tp_out, tpt_out); _final_type_and_type_type_get(btp, tp_out, tpt_out);
} }
@ -200,7 +200,7 @@ _eolian_type_cpp_type_named_get(const Eolian_Type *tp, std::string const& caller
}; };
std::string type_name = eolian_type_name_get(tp); std::string type_name = eolian_type_short_name_get(tp);
auto it = type_map.find(type_name); auto it = type_map.find(type_name);
if (it != end(type_map)) if (it != end(type_map))
type_name = it->second; type_name = it->second;
@ -690,8 +690,8 @@ int main(int argc, char** argv)
if (!tpd || ::eolian_typedecl_type_get(tpd) == EOLIAN_TYPEDECL_STRUCT_OPAQUE) if (!tpd || ::eolian_typedecl_type_get(tpd) == EOLIAN_TYPEDECL_STRUCT_OPAQUE)
continue; continue;
auto struct_name = ::eolian_typedecl_name_get(tpd); auto struct_name = ::eolian_typedecl_short_name_get(tpd);
auto struct_type_full_name = ::eolian_typedecl_full_name_get(tpd); auto struct_type_full_name = ::eolian_typedecl_name_get(tpd);
if (!struct_name || !struct_type_full_name) if (!struct_name || !struct_type_full_name)
{ {
EINA_CXX_DOM_LOG_ERR(eolian::js::domain) << "Could not get struct type name"; EINA_CXX_DOM_LOG_ERR(eolian::js::domain) << "Could not get struct type name";
@ -1157,7 +1157,7 @@ int main(int argc, char** argv)
auto tpd = &*first; auto tpd = &*first;
if (::eolian_typedecl_is_extern(tpd)) if (::eolian_typedecl_is_extern(tpd))
continue; continue;
std::string enum_name = ::eolian_typedecl_name_get(tpd); std::string enum_name = ::eolian_typedecl_short_name_get(tpd);
os << " {\n"; os << " {\n";
os << " auto to_export = ::efl::eo::js::get_namespace({"; os << " auto to_export = ::efl::eo::js::get_namespace({";
bool comma = false; bool comma = false;

View File

@ -2264,35 +2264,43 @@ EAPI Eina_Bool eolian_typedecl_is_extern(const Eolian_Typedecl *tp);
EAPI Eina_Stringshare *eolian_typedecl_c_type_get(const Eolian_Typedecl *tp); EAPI Eina_Stringshare *eolian_typedecl_c_type_get(const Eolian_Typedecl *tp);
/* /*
* @brief Get the name of the given type declaration. Keep in mind that the * @brief A helper function to get the full name of a typedecl.
* name doesn't include namespaces.
* *
* @param[in] tp the type declaration. * @see eolian_object_name_get
* @return the name.
* *
* @ingroup Eolian * @ingroup Eolian
*/ */
EAPI Eina_Stringshare *eolian_typedecl_name_get(const Eolian_Typedecl *tp); static inline const char *
eolian_typedecl_name_get(const Eolian_Typedecl *tp)
{
return eolian_object_name_get(EOLIAN_OBJECT(tp));
}
/* /*
* @brief Get the full (namespaced) name of a type declaration. * @brief A helper function to get the short name of a typedecl.
* *
* @param[in] tp the type declaration. * @see eolian_object_short_name_get
* @return the name.
* *
* @ingroup Eolian * @ingroup Eolian
*/ */
EAPI Eina_Stringshare *eolian_typedecl_full_name_get(const Eolian_Typedecl *tp); static inline const char *
eolian_typedecl_short_name_get(const Eolian_Typedecl *tp)
{
return eolian_object_short_name_get(EOLIAN_OBJECT(tp));
}
/* /*
* @brief Get an iterator to the list of namespaces of the given type decl. * @brief A helper function to get the namespaces of a typedecl.
* *
* @param[in] tp the type declaration. * @see eolian_object_namespaces_get
* @return the iterator.
* *
* @ingroup Eolian * @ingroup Eolian
*/ */
EAPI Eina_Iterator *eolian_typedecl_namespaces_get(const Eolian_Typedecl *tp); static inline Eina_Iterator *
eolian_typedecl_namespaces_get(const Eolian_Typedecl *tp)
{
return eolian_object_namespaces_get(EOLIAN_OBJECT(tp));
}
/* /*
* @brief Get the name of the function used to free this type declaration. * @brief Get the name of the function used to free this type declaration.
@ -2451,36 +2459,43 @@ EAPI Eina_Bool eolian_type_is_ptr(const Eolian_Type *tp);
EAPI Eina_Stringshare *eolian_type_c_type_get(const Eolian_Type *tp, Eolian_C_Type_Type ctype); EAPI Eina_Stringshare *eolian_type_c_type_get(const Eolian_Type *tp, Eolian_C_Type_Type ctype);
/* /*
* @brief Get the name of the given type. For regular types, this is for * @brief A helper function to get the full name of a type.
* example "int". For EOLIAN_TYPE_CLASS, this can be "Button". Keep in
* mind that the name doesn't include namespaces.
* *
* @param[in] tp the type. * @see eolian_object_name_get
* @return the name.
* *
* @ingroup Eolian * @ingroup Eolian
*/ */
EAPI Eina_Stringshare *eolian_type_name_get(const Eolian_Type *tp); static inline const char *
eolian_type_name_get(const Eolian_Type *tp)
{
return eolian_object_name_get(EOLIAN_OBJECT(tp));
}
/* /*
* @brief Get the full (namespaced) name of a type. * @brief A helper function to get the short name of a type.
* *
* @param[in] tp the type. * @see eolian_object_short_name_get
* @return the name.
* *
* @ingroup Eolian * @ingroup Eolian
*/ */
EAPI Eina_Stringshare *eolian_type_full_name_get(const Eolian_Type *tp); static inline const char *
eolian_type_short_name_get(const Eolian_Type *tp)
{
return eolian_object_short_name_get(EOLIAN_OBJECT(tp));
}
/* /*
* @brief Get an iterator to the list of namespaces of the given type. * @brief A helper function to get the namespaces of a type.
* *
* @param[in] tp the type. * @see eolian_object_namespaces_get
* @return the iterator.
* *
* @ingroup Eolian * @ingroup Eolian
*/ */
EAPI Eina_Iterator *eolian_type_namespaces_get(const Eolian_Type *tp); static inline Eina_Iterator *
eolian_type_namespaces_get(const Eolian_Type *tp)
{
return eolian_object_namespaces_get(EOLIAN_OBJECT(tp));
}
/* /*
* @brief Get the name of the function used to free this type. * @brief Get the name of the function used to free this type.
@ -2687,34 +2702,43 @@ EAPI const Eolian_Type *eolian_variable_base_type_get(const Eolian_Variable *var
EAPI const Eolian_Expression *eolian_variable_value_get(const Eolian_Variable *var); EAPI const Eolian_Expression *eolian_variable_value_get(const Eolian_Variable *var);
/* /*
* @brief Get the name of the given variable (without namespaces). * @brief A helper function to get the full name of a variable.
* *
* @param[in] var the variable. * @see eolian_object_name_get
* @return the name.
* *
* @ingroup Eolian * @ingroup Eolian
*/ */
EAPI Eina_Stringshare *eolian_variable_name_get(const Eolian_Variable *var); static inline const char *
eolian_variable_name_get(const Eolian_Variable *tp)
{
return eolian_object_name_get(EOLIAN_OBJECT(tp));
}
/* /*
* @brief Get the name of the given variable (with namespaces). * @brief A helper function to get the short name of a variable.
* *
* @param[in] var the variable. * @see eolian_object_short_name_get
* @return the name.
* *
* @ingroup Eolian * @ingroup Eolian
*/ */
EAPI Eina_Stringshare *eolian_variable_full_name_get(const Eolian_Variable *var); static inline const char *
eolian_variable_short_name_get(const Eolian_Variable *tp)
{
return eolian_object_short_name_get(EOLIAN_OBJECT(tp));
}
/* /*
* @brief Get an iterator to the list of namespaces of the given variable. * @brief A helper function to get the namespaces of a variable.
* *
* @param[in] var the variable. * @see eolian_object_namespaces_get
* @return the iterator.
* *
* @ingroup Eolian * @ingroup Eolian
*/ */
EAPI Eina_Iterator *eolian_variable_namespaces_get(const Eolian_Variable *var); static inline Eina_Iterator *
eolian_variable_namespaces_get(const Eolian_Variable *tp)
{
return eolian_object_namespaces_get(EOLIAN_OBJECT(tp));
}
/* /*
* @brief Check if a variable is extern. * @brief Check if a variable is extern.

View File

@ -251,44 +251,6 @@ eolian_typedecl_c_type_get(const Eolian_Typedecl *tp)
return ret; return ret;
} }
EAPI Eina_Stringshare *
eolian_type_name_get(const Eolian_Type *tp)
{
return eolian_object_short_name_get((const Eolian_Object *)tp);
}
EAPI Eina_Stringshare *
eolian_typedecl_name_get(const Eolian_Typedecl *tp)
{
return eolian_object_short_name_get((const Eolian_Object *)tp);
}
EAPI Eina_Stringshare *
eolian_type_full_name_get(const Eolian_Type *tp)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
return tp->base.name;
}
EAPI Eina_Stringshare *
eolian_typedecl_full_name_get(const Eolian_Typedecl *tp)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
return tp->base.name;
}
EAPI Eina_Iterator *
eolian_type_namespaces_get(const Eolian_Type *tp)
{
return eolian_object_namespaces_get((const Eolian_Object *)tp);
}
EAPI Eina_Iterator *
eolian_typedecl_namespaces_get(const Eolian_Typedecl *tp)
{
return eolian_object_namespaces_get((const Eolian_Object *)tp);
}
EAPI Eina_Stringshare * EAPI Eina_Stringshare *
eolian_type_free_func_get(const Eolian_Type *tp) eolian_type_free_func_get(const Eolian_Type *tp)
{ {

View File

@ -33,25 +33,6 @@ eolian_variable_value_get(const Eolian_Variable *var)
return var->value; return var->value;
} }
EAPI Eina_Stringshare *
eolian_variable_name_get(const Eolian_Variable *var)
{
return eolian_object_short_name_get((const Eolian_Object *)var);
}
EAPI Eina_Stringshare *
eolian_variable_full_name_get(const Eolian_Variable *var)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(var, NULL);
return var->base.name;
}
EAPI Eina_Iterator *
eolian_variable_namespaces_get(const Eolian_Variable *var)
{
return eolian_object_namespaces_get((const Eolian_Object *)var);
}
EAPI Eina_Bool EAPI Eina_Bool
eolian_variable_is_extern(const Eolian_Variable *var) eolian_variable_is_extern(const Eolian_Variable *var)
{ {

View File

@ -369,12 +369,12 @@ inline void type_def::set(Eolian_Type const* eolian_type, Eolian_Unit const* uni
for(efl::eina::iterator<const char> namespace_iterator( ::eolian_type_namespaces_get(eolian_type)) for(efl::eina::iterator<const char> namespace_iterator( ::eolian_type_namespaces_get(eolian_type))
, namespace_last; namespace_iterator != namespace_last; ++namespace_iterator) , namespace_last; namespace_iterator != namespace_last; ++namespace_iterator)
namespaces.push_back(&*namespace_iterator); namespaces.push_back(&*namespace_iterator);
original_type = {regular_type_def{ ::eolian_type_name_get(eolian_type), {qualifiers(eolian_type), {}}, namespaces, type_type, is_undefined}}; original_type = {regular_type_def{ ::eolian_type_short_name_get(eolian_type), {qualifiers(eolian_type), {}}, namespaces, type_type, is_undefined}};
} }
else else
{ {
complex_type_def complex complex_type_def complex
{{::eolian_type_name_get(eolian_type), {qualifiers(eolian_type), {}}, {}}, {}}; {{::eolian_type_short_name_get(eolian_type), {qualifiers(eolian_type), {}}, {}}, {}};
while (stp) while (stp)
{ {
complex.subtypes.push_back({stp, unit, EOLIAN_C_TYPE_DEFAULT}); complex.subtypes.push_back({stp, unit, EOLIAN_C_TYPE_DEFAULT});
@ -1097,7 +1097,7 @@ struct enum_def
{ {
this->namespaces.push_back((&*namespace_iterator)); this->namespaces.push_back((&*namespace_iterator));
} }
cxx_name = eolian_name = eolian_typedecl_name_get(enum_obj); cxx_name = eolian_name = eolian_typedecl_short_name_get(enum_obj);
for (efl::eina::iterator<const Eolian_Enum_Type_Field> field_iterator(::eolian_typedecl_enum_fields_get(enum_obj)) for (efl::eina::iterator<const Eolian_Enum_Type_Field> field_iterator(::eolian_typedecl_enum_fields_get(enum_obj))
, field_last; field_iterator != field_last; ++field_iterator) , field_last; field_iterator != field_last; ++field_iterator)
@ -1143,7 +1143,7 @@ struct struct_def
{ {
this->namespaces.push_back((&*namespace_iterator)); this->namespaces.push_back((&*namespace_iterator));
} }
cxx_name = eolian_name = eolian_typedecl_name_get(struct_obj); cxx_name = eolian_name = eolian_typedecl_short_name_get(struct_obj);
for(efl::eina::iterator<const Eolian_Struct_Type_Field> field_iterator(::eolian_typedecl_struct_fields_get(struct_obj)) for(efl::eina::iterator<const Eolian_Struct_Type_Field> field_iterator(::eolian_typedecl_struct_fields_get(struct_obj))
, field_last; field_iterator != field_last; ++field_iterator) , field_last; field_iterator != field_last; ++field_iterator)

View File

@ -130,7 +130,7 @@ START_TEST(eolian_events)
fail_if(!(name = eolian_event_name_get(ev))); fail_if(!(name = eolian_event_name_get(ev)));
fail_if(!(type = eolian_event_type_get(ev))); fail_if(!(type = eolian_event_type_get(ev)));
fail_if(strcmp(name, "clicked,double")); fail_if(strcmp(name, "clicked,double"));
type_name = eolian_type_name_get(type); type_name = eolian_type_short_name_get(type);
fail_if(strcmp(type_name, "Evas_Event_Clicked_Double_Info")); fail_if(strcmp(type_name, "Evas_Event_Clicked_Double_Info"));
fail_if(eolian_event_is_beta(ev)); fail_if(eolian_event_is_beta(ev));
fail_if(eolian_event_is_hot(ev)); fail_if(eolian_event_is_hot(ev));
@ -346,13 +346,13 @@ START_TEST(eolian_typedef)
/* Basic type */ /* Basic type */
fail_if(!(tdl = eolian_unit_alias_by_name_get(unit, "Evas.Coord"))); fail_if(!(tdl = eolian_unit_alias_by_name_get(unit, "Evas.Coord")));
fail_if(eolian_typedecl_type_get(tdl) != EOLIAN_TYPEDECL_ALIAS); fail_if(eolian_typedecl_type_get(tdl) != EOLIAN_TYPEDECL_ALIAS);
fail_if(!(type_name = eolian_typedecl_name_get(tdl))); fail_if(!(type_name = eolian_typedecl_short_name_get(tdl)));
fail_if(strcmp(type_name, "Coord")); fail_if(strcmp(type_name, "Coord"));
fail_if(!(type_name = eolian_typedecl_c_type_get(tdl))); fail_if(!(type_name = eolian_typedecl_c_type_get(tdl)));
fail_if(strcmp(type_name, "typedef int Evas_Coord")); fail_if(strcmp(type_name, "typedef int Evas_Coord"));
eina_stringshare_del(type_name); eina_stringshare_del(type_name);
fail_if(!(type = eolian_typedecl_base_type_get(tdl))); fail_if(!(type = eolian_typedecl_base_type_get(tdl)));
fail_if(!(type_name = eolian_type_name_get(type))); fail_if(!(type_name = eolian_type_short_name_get(type)));
fail_if(eolian_type_is_owned(type)); fail_if(eolian_type_is_owned(type));
fail_if(eolian_type_is_const(type)); fail_if(eolian_type_is_const(type));
fail_if(eolian_type_base_type_get(type)); fail_if(eolian_type_base_type_get(type));
@ -365,11 +365,11 @@ START_TEST(eolian_typedef)
/* Lowest alias base */ /* Lowest alias base */
fail_if(!(tdl = eolian_unit_alias_by_name_get(unit, "Evas.Coord3"))); fail_if(!(tdl = eolian_unit_alias_by_name_get(unit, "Evas.Coord3")));
fail_if(!(type = eolian_typedecl_aliased_base_get(tdl))); fail_if(!(type = eolian_typedecl_aliased_base_get(tdl)));
fail_if(strcmp(eolian_type_name_get(type), "int")); fail_if(strcmp(eolian_type_short_name_get(type), "int"));
/* Complex type */ /* Complex type */
fail_if(!(tdl = eolian_unit_alias_by_name_get(unit, "List_Objects"))); fail_if(!(tdl = eolian_unit_alias_by_name_get(unit, "List_Objects")));
fail_if(!(type_name = eolian_typedecl_name_get(tdl))); fail_if(!(type_name = eolian_typedecl_short_name_get(tdl)));
fail_if(strcmp(type_name, "List_Objects")); fail_if(strcmp(type_name, "List_Objects"));
fail_if(!(type = eolian_typedecl_base_type_get(tdl))); fail_if(!(type = eolian_typedecl_base_type_get(tdl)));
fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_DEFAULT))); fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_DEFAULT)));
@ -386,10 +386,10 @@ START_TEST(eolian_typedef)
/* List */ /* List */
fail_if(!(iter = eolian_state_aliases_by_file_get(eos, "typedef.eo"))); fail_if(!(iter = eolian_state_aliases_by_file_get(eos, "typedef.eo")));
fail_if(!eina_iterator_next(iter, (void**)&tdl)); fail_if(!eina_iterator_next(iter, (void**)&tdl));
fail_if(!(type_name = eolian_typedecl_name_get(tdl))); fail_if(!(type_name = eolian_typedecl_short_name_get(tdl)));
fail_if(strcmp(type_name, "Coord")); fail_if(strcmp(type_name, "Coord"));
fail_if(!eina_iterator_next(iter, (void**)&tdl)); fail_if(!eina_iterator_next(iter, (void**)&tdl));
fail_if(!(type_name = eolian_typedecl_name_get(tdl))); fail_if(!(type_name = eolian_typedecl_short_name_get(tdl)));
fail_if(strcmp(type_name, "List_Objects")); fail_if(strcmp(type_name, "List_Objects"));
/* coord2 and coord3, skip */ /* coord2 and coord3, skip */
fail_if(!eina_iterator_next(iter, (void**)&tdl)); fail_if(!eina_iterator_next(iter, (void**)&tdl));
@ -584,7 +584,7 @@ START_TEST(eolian_simple_parsing)
fail_if(!tp); fail_if(!tp);
printf("BUILT %d\n", (int)eolian_type_builtin_type_get(tp)); printf("BUILT %d\n", (int)eolian_type_builtin_type_get(tp));
fail_if(eolian_type_builtin_type_get(tp) != EOLIAN_TYPE_BUILTIN_BOOL); fail_if(eolian_type_builtin_type_get(tp) != EOLIAN_TYPE_BUILTIN_BOOL);
fail_if(strcmp(eolian_type_name_get(tp), "bool")); fail_if(strcmp(eolian_type_short_name_get(tp), "bool"));
expr = eolian_function_return_default_value_get(fid, EOLIAN_PROP_SET); expr = eolian_function_return_default_value_get(fid, EOLIAN_PROP_SET);
fail_if(!expr); fail_if(!expr);
v = eolian_expression_eval(expr, EOLIAN_MASK_BOOL); v = eolian_expression_eval(expr, EOLIAN_MASK_BOOL);
@ -599,7 +599,7 @@ START_TEST(eolian_simple_parsing)
fail_if(!(eina_iterator_next(iter, (void**)&param))); fail_if(!(eina_iterator_next(iter, (void**)&param)));
fail_if(eina_iterator_next(iter, &dummy)); fail_if(eina_iterator_next(iter, &dummy));
eina_iterator_free(iter); eina_iterator_free(iter);
fail_if(strcmp(eolian_type_name_get(eolian_parameter_type_get(param)), "int")); fail_if(strcmp(eolian_type_short_name_get(eolian_parameter_type_get(param)), "int"));
fail_if(strcmp(eolian_parameter_name_get(param), "value")); fail_if(strcmp(eolian_parameter_name_get(param), "value"));
expr = eolian_parameter_default_value_get(param); expr = eolian_parameter_default_value_get(param);
fail_if(!expr); fail_if(!expr);
@ -635,17 +635,17 @@ START_TEST(eolian_simple_parsing)
fail_if(!(iter = eolian_function_parameters_get(fid))); fail_if(!(iter = eolian_function_parameters_get(fid)));
fail_if(!(eina_iterator_next(iter, (void**)&param))); fail_if(!(eina_iterator_next(iter, (void**)&param)));
fail_if(eolian_parameter_direction_get(param) != EOLIAN_IN_PARAM); fail_if(eolian_parameter_direction_get(param) != EOLIAN_IN_PARAM);
fail_if(strcmp(eolian_type_name_get(eolian_parameter_type_get(param)), "int")); fail_if(strcmp(eolian_type_short_name_get(eolian_parameter_type_get(param)), "int"));
fail_if(strcmp(eolian_parameter_name_get(param), "a")); fail_if(strcmp(eolian_parameter_name_get(param), "a"));
fail_if(!(eina_iterator_next(iter, (void**)&param))); fail_if(!(eina_iterator_next(iter, (void**)&param)));
fail_if(eolian_parameter_direction_get(param) != EOLIAN_INOUT_PARAM); fail_if(eolian_parameter_direction_get(param) != EOLIAN_INOUT_PARAM);
ptype = eolian_type_name_get(eolian_parameter_type_get(param)); ptype = eolian_type_short_name_get(eolian_parameter_type_get(param));
fail_if(strcmp(ptype, "char")); fail_if(strcmp(ptype, "char"));
fail_if(strcmp(eolian_parameter_name_get(param), "b")); fail_if(strcmp(eolian_parameter_name_get(param), "b"));
fail_if(!(eina_iterator_next(iter, (void**)&param))); fail_if(!(eina_iterator_next(iter, (void**)&param)));
fail_if(eolian_parameter_direction_get(param) != EOLIAN_OUT_PARAM); fail_if(eolian_parameter_direction_get(param) != EOLIAN_OUT_PARAM);
fail_if(eolian_type_builtin_type_get(eolian_parameter_type_get(param)) != EOLIAN_TYPE_BUILTIN_DOUBLE); fail_if(eolian_type_builtin_type_get(eolian_parameter_type_get(param)) != EOLIAN_TYPE_BUILTIN_DOUBLE);
fail_if(strcmp(eolian_type_name_get(eolian_parameter_type_get(param)), "double")); fail_if(strcmp(eolian_type_short_name_get(eolian_parameter_type_get(param)), "double"));
fail_if(strcmp(eolian_parameter_name_get(param), "c")); fail_if(strcmp(eolian_parameter_name_get(param), "c"));
expr = eolian_parameter_default_value_get(param); expr = eolian_parameter_default_value_get(param);
fail_if(!expr); fail_if(!expr);
@ -654,7 +654,7 @@ START_TEST(eolian_simple_parsing)
fail_if(v.value.d != 1337.6); fail_if(v.value.d != 1337.6);
fail_if(!(eina_iterator_next(iter, (void**)&param))); fail_if(!(eina_iterator_next(iter, (void**)&param)));
fail_if(eolian_parameter_direction_get(param) != EOLIAN_IN_PARAM); fail_if(eolian_parameter_direction_get(param) != EOLIAN_IN_PARAM);
fail_if(strcmp(eolian_type_name_get(eolian_parameter_type_get(param)), "int")); fail_if(strcmp(eolian_type_short_name_get(eolian_parameter_type_get(param)), "int"));
fail_if(!eolian_type_is_ptr(eolian_parameter_type_get(param))); fail_if(!eolian_type_is_ptr(eolian_parameter_type_get(param)));
fail_if(strcmp(eolian_parameter_name_get(param), "d")); fail_if(strcmp(eolian_parameter_name_get(param), "d"));
fail_if(eina_iterator_next(iter, &dummy)); fail_if(eina_iterator_next(iter, &dummy));
@ -695,7 +695,7 @@ START_TEST(eolian_struct)
/* named struct */ /* named struct */
fail_if(!(tdl = eolian_unit_struct_by_name_get(unit, "Named"))); fail_if(!(tdl = eolian_unit_struct_by_name_get(unit, "Named")));
fail_if(!(type_name = eolian_typedecl_name_get(tdl))); fail_if(!(type_name = eolian_typedecl_short_name_get(tdl)));
fail_if(!(file = eolian_object_file_get((const Eolian_Object *)tdl))); fail_if(!(file = eolian_object_file_get((const Eolian_Object *)tdl)));
fail_if(eolian_typedecl_type_get(tdl) != EOLIAN_TYPEDECL_STRUCT); fail_if(eolian_typedecl_type_get(tdl) != EOLIAN_TYPEDECL_STRUCT);
fail_if(strcmp(type_name, "Named")); fail_if(strcmp(type_name, "Named"));
@ -703,7 +703,7 @@ START_TEST(eolian_struct)
fail_if(!(field = eolian_typedecl_struct_field_get(tdl, "field"))); fail_if(!(field = eolian_typedecl_struct_field_get(tdl, "field")));
fail_if(!(ftype = eolian_typedecl_struct_field_type_get(field))); fail_if(!(ftype = eolian_typedecl_struct_field_type_get(field)));
fail_if(!eolian_type_is_ptr(ftype)); fail_if(!eolian_type_is_ptr(ftype));
fail_if(!(type_name = eolian_type_name_get(ftype))); fail_if(!(type_name = eolian_type_short_name_get(ftype)));
fail_if(strcmp(type_name, "int")); fail_if(strcmp(type_name, "int"));
fail_if(!(field = eolian_typedecl_struct_field_get(tdl, "something"))); fail_if(!(field = eolian_typedecl_struct_field_get(tdl, "something")));
fail_if(!(ftype = eolian_typedecl_struct_field_type_get(field))); fail_if(!(ftype = eolian_typedecl_struct_field_type_get(field)));
@ -714,14 +714,14 @@ START_TEST(eolian_struct)
/* referencing */ /* referencing */
fail_if(!(tdl = eolian_unit_struct_by_name_get(unit, "Another"))); fail_if(!(tdl = eolian_unit_struct_by_name_get(unit, "Another")));
fail_if(!(type_name = eolian_typedecl_name_get(tdl))); fail_if(!(type_name = eolian_typedecl_short_name_get(tdl)));
fail_if(!(file = eolian_object_file_get((const Eolian_Object *)tdl))); fail_if(!(file = eolian_object_file_get((const Eolian_Object *)tdl)));
fail_if(eolian_typedecl_type_get(tdl) != EOLIAN_TYPEDECL_STRUCT); fail_if(eolian_typedecl_type_get(tdl) != EOLIAN_TYPEDECL_STRUCT);
fail_if(strcmp(type_name, "Another")); fail_if(strcmp(type_name, "Another"));
fail_if(strcmp(file, "struct.eo")); fail_if(strcmp(file, "struct.eo"));
fail_if(!(field = eolian_typedecl_struct_field_get(tdl, "field"))); fail_if(!(field = eolian_typedecl_struct_field_get(tdl, "field")));
fail_if(!(ftype = eolian_typedecl_struct_field_type_get(field))); fail_if(!(ftype = eolian_typedecl_struct_field_type_get(field)));
fail_if(!(type_name = eolian_type_name_get(ftype))); fail_if(!(type_name = eolian_type_short_name_get(ftype)));
fail_if(strcmp(type_name, "Named")); fail_if(strcmp(type_name, "Named"));
fail_if(eolian_type_type_get(ftype) != EOLIAN_TYPE_REGULAR); fail_if(eolian_type_type_get(ftype) != EOLIAN_TYPE_REGULAR);
fail_if(eolian_typedecl_type_get(eolian_type_typedecl_get(ftype)) fail_if(eolian_typedecl_type_get(eolian_type_typedecl_get(ftype))
@ -808,7 +808,7 @@ START_TEST(eolian_var)
fail_if(eolian_variable_type_get(var) != EOLIAN_VAR_CONSTANT); fail_if(eolian_variable_type_get(var) != EOLIAN_VAR_CONSTANT);
fail_if(eolian_variable_is_extern(var)); fail_if(eolian_variable_is_extern(var));
fail_if(!(type = eolian_variable_base_type_get(var))); fail_if(!(type = eolian_variable_base_type_get(var)));
fail_if(!(name = eolian_type_name_get(type))); fail_if(!(name = eolian_type_short_name_get(type)));
fail_if(strcmp(name, "int")); fail_if(strcmp(name, "int"));
fail_if(!(exp = eolian_variable_value_get(var))); fail_if(!(exp = eolian_variable_value_get(var)));
v = eolian_expression_eval_type(exp, type); v = eolian_expression_eval_type(exp, type);
@ -820,7 +820,7 @@ START_TEST(eolian_var)
fail_if(eolian_variable_type_get(var) != EOLIAN_VAR_GLOBAL); fail_if(eolian_variable_type_get(var) != EOLIAN_VAR_GLOBAL);
fail_if(eolian_variable_is_extern(var)); fail_if(eolian_variable_is_extern(var));
fail_if(!(type = eolian_variable_base_type_get(var))); fail_if(!(type = eolian_variable_base_type_get(var)));
fail_if(!(name = eolian_type_name_get(type))); fail_if(!(name = eolian_type_short_name_get(type)));
fail_if(strcmp(name, "float")); fail_if(strcmp(name, "float"));
fail_if(!(exp = eolian_variable_value_get(var))); fail_if(!(exp = eolian_variable_value_get(var)));
v = eolian_expression_eval_type(exp, type); v = eolian_expression_eval_type(exp, type);
@ -832,7 +832,7 @@ START_TEST(eolian_var)
fail_if(eolian_variable_type_get(var) != EOLIAN_VAR_GLOBAL); fail_if(eolian_variable_type_get(var) != EOLIAN_VAR_GLOBAL);
fail_if(eolian_variable_is_extern(var)); fail_if(eolian_variable_is_extern(var));
fail_if(!(type = eolian_variable_base_type_get(var))); fail_if(!(type = eolian_variable_base_type_get(var)));
fail_if(!(name = eolian_type_name_get(type))); fail_if(!(name = eolian_type_short_name_get(type)));
fail_if(strcmp(name, "long")); fail_if(strcmp(name, "long"));
fail_if(eolian_variable_value_get(var)); fail_if(eolian_variable_value_get(var));
@ -841,7 +841,7 @@ START_TEST(eolian_var)
fail_if(eolian_variable_type_get(var) != EOLIAN_VAR_GLOBAL); fail_if(eolian_variable_type_get(var) != EOLIAN_VAR_GLOBAL);
fail_if(!eolian_variable_is_extern(var)); fail_if(!eolian_variable_is_extern(var));
fail_if(!(type = eolian_variable_base_type_get(var))); fail_if(!(type = eolian_variable_base_type_get(var)));
fail_if(!(name = eolian_type_name_get(type))); fail_if(!(name = eolian_type_short_name_get(type)));
fail_if(strcmp(name, "double")); fail_if(strcmp(name, "double"));
fail_if(eolian_variable_value_get(var)); fail_if(eolian_variable_value_get(var));
@ -935,7 +935,7 @@ START_TEST(eolian_enum)
fail_if(eolian_variable_type_get(var) != EOLIAN_VAR_CONSTANT); fail_if(eolian_variable_type_get(var) != EOLIAN_VAR_CONSTANT);
fail_if(eolian_variable_is_extern(var)); fail_if(eolian_variable_is_extern(var));
fail_if(!(type = eolian_variable_base_type_get(var))); fail_if(!(type = eolian_variable_base_type_get(var)));
fail_if(!(name = eolian_type_name_get(type))); fail_if(!(name = eolian_type_short_name_get(type)));
fail_if(strcmp(name, "Baz")); fail_if(strcmp(name, "Baz"));
fail_if(!(exp = eolian_variable_value_get(var))); fail_if(!(exp = eolian_variable_value_get(var)));
v = eolian_expression_eval(exp, EOLIAN_MASK_ALL); v = eolian_expression_eval(exp, EOLIAN_MASK_ALL);
@ -1142,27 +1142,27 @@ START_TEST(eolian_decl)
fail_if(strcmp(eolian_object_name_get(decl), "A")); fail_if(strcmp(eolian_object_name_get(decl), "A"));
tdl = (const Eolian_Typedecl *)decl; tdl = (const Eolian_Typedecl *)decl;
fail_if(eolian_typedecl_type_get(tdl) != EOLIAN_TYPEDECL_STRUCT); fail_if(eolian_typedecl_type_get(tdl) != EOLIAN_TYPEDECL_STRUCT);
fail_if(strcmp(eolian_typedecl_name_get(tdl), "A")); fail_if(strcmp(eolian_typedecl_short_name_get(tdl), "A"));
fail_if(!eina_iterator_next(itr, (void**)&decl)); fail_if(!eina_iterator_next(itr, (void**)&decl));
fail_if(eolian_object_type_get(decl) != EOLIAN_OBJECT_TYPEDECL); fail_if(eolian_object_type_get(decl) != EOLIAN_OBJECT_TYPEDECL);
fail_if(strcmp(eolian_object_name_get(decl), "B")); fail_if(strcmp(eolian_object_name_get(decl), "B"));
tdl = (const Eolian_Typedecl *)decl; tdl = (const Eolian_Typedecl *)decl;
fail_if(eolian_typedecl_type_get(tdl) != EOLIAN_TYPEDECL_ENUM); fail_if(eolian_typedecl_type_get(tdl) != EOLIAN_TYPEDECL_ENUM);
fail_if(strcmp(eolian_typedecl_name_get(tdl), "B")); fail_if(strcmp(eolian_typedecl_short_name_get(tdl), "B"));
fail_if(!eina_iterator_next(itr, (void**)&decl)); fail_if(!eina_iterator_next(itr, (void**)&decl));
fail_if(eolian_object_type_get(decl) != EOLIAN_OBJECT_TYPEDECL); fail_if(eolian_object_type_get(decl) != EOLIAN_OBJECT_TYPEDECL);
fail_if(strcmp(eolian_object_name_get(decl), "C")); fail_if(strcmp(eolian_object_name_get(decl), "C"));
tdl = (const Eolian_Typedecl *)decl; tdl = (const Eolian_Typedecl *)decl;
fail_if(eolian_typedecl_type_get(tdl) != EOLIAN_TYPEDECL_ALIAS); fail_if(eolian_typedecl_type_get(tdl) != EOLIAN_TYPEDECL_ALIAS);
fail_if(strcmp(eolian_typedecl_name_get(tdl), "C")); fail_if(strcmp(eolian_typedecl_short_name_get(tdl), "C"));
fail_if(!eina_iterator_next(itr, (void**)&decl)); fail_if(!eina_iterator_next(itr, (void**)&decl));
fail_if(eolian_object_type_get(decl) != EOLIAN_OBJECT_VARIABLE); fail_if(eolian_object_type_get(decl) != EOLIAN_OBJECT_VARIABLE);
fail_if(strcmp(eolian_object_name_get(decl), "pants")); fail_if(strcmp(eolian_object_name_get(decl), "pants"));
var = (const Eolian_Variable *)decl; var = (const Eolian_Variable *)decl;
fail_if(strcmp(eolian_variable_name_get(var), "pants")); fail_if(strcmp(eolian_variable_short_name_get(var), "pants"));
fail_if(!eina_iterator_next(itr, (void**)&decl)); fail_if(!eina_iterator_next(itr, (void**)&decl));
fail_if(eolian_object_type_get(decl) != EOLIAN_OBJECT_CLASS); fail_if(eolian_object_type_get(decl) != EOLIAN_OBJECT_CLASS);
@ -1532,7 +1532,7 @@ START_TEST(eolian_function_types)
fail_if(!(type = eolian_parameter_type_get(param))); fail_if(!(type = eolian_parameter_type_get(param)));
fail_if(eolian_parameter_direction_get(param) != EOLIAN_IN_PARAM); fail_if(eolian_parameter_direction_get(param) != EOLIAN_IN_PARAM);
fail_if(eolian_type_is_owned(type)); fail_if(eolian_type_is_owned(type));
fail_if(!(type_name = eolian_type_name_get(type))); fail_if(!(type_name = eolian_type_short_name_get(type)));
fail_if(strcmp(type_name, "VoidFunc")); fail_if(strcmp(type_name, "VoidFunc"));
fail_if(!(arg_decl = eolian_type_typedecl_get(type))); fail_if(!(arg_decl = eolian_type_typedecl_get(type)));
fail_if(eolian_typedecl_type_get(arg_decl) != EOLIAN_TYPEDECL_FUNCTION_POINTER); fail_if(eolian_typedecl_type_get(arg_decl) != EOLIAN_TYPEDECL_FUNCTION_POINTER);
@ -1543,7 +1543,7 @@ START_TEST(eolian_function_types)
fail_if(!(type = eolian_parameter_type_get(param))); fail_if(!(type = eolian_parameter_type_get(param)));
fail_if(eolian_type_is_owned(type)); fail_if(eolian_type_is_owned(type));
fail_if(eolian_type_type_get(type) != EOLIAN_TYPE_REGULAR); fail_if(eolian_type_type_get(type) != EOLIAN_TYPE_REGULAR);
fail_if(!(type_name = eolian_type_name_get(type))); fail_if(!(type_name = eolian_type_short_name_get(type)));
fail_if(strcmp(type_name, "SimpleFunc")); fail_if(strcmp(type_name, "SimpleFunc"));
fail_if(!(arg_decl = eolian_type_typedecl_get(type))); fail_if(!(arg_decl = eolian_type_typedecl_get(type)));
fail_if(eolian_typedecl_type_get(arg_decl) != EOLIAN_TYPEDECL_FUNCTION_POINTER); fail_if(eolian_typedecl_type_get(arg_decl) != EOLIAN_TYPEDECL_FUNCTION_POINTER);
@ -1585,7 +1585,7 @@ START_TEST(eolian_function_as_arguments)
fail_if(!(type = eolian_parameter_type_get(param))); fail_if(!(type = eolian_parameter_type_get(param)));
fail_if(eolian_parameter_direction_get(param) != EOLIAN_IN_PARAM); fail_if(eolian_parameter_direction_get(param) != EOLIAN_IN_PARAM);
fail_if(eolian_type_is_owned(type)); fail_if(eolian_type_is_owned(type));
fail_if(!(type_name = eolian_type_name_get(type))); fail_if(!(type_name = eolian_type_short_name_get(type)));
fail_if(strcmp(type_name, "SimpleFunc")); fail_if(strcmp(type_name, "SimpleFunc"));
fail_if(!(arg_decl = eolian_type_typedecl_get(type))); fail_if(!(arg_decl = eolian_type_typedecl_get(type)));
fail_if(eolian_typedecl_type_get(arg_decl) != EOLIAN_TYPEDECL_FUNCTION_POINTER); fail_if(eolian_typedecl_type_get(arg_decl) != EOLIAN_TYPEDECL_FUNCTION_POINTER);