break;
}
case EOLIAN_TYPE_STRUCT:
+ case EOLIAN_TYPE_STRUCT_OPAQUE:
{
const char *member_name;
char *name = _concat_name(tp);
- if (in_typedef && name)
+ if ((in_typedef && name) || tp_type == EOLIAN_TYPE_STRUCT_OPAQUE)
{
eina_strbuf_append_printf(buf, "struct %s", name);
free(name);
EOLIAN_TYPE_POINTER,
EOLIAN_TYPE_FUNCTION,
EOLIAN_TYPE_STRUCT,
+ EOLIAN_TYPE_STRUCT_OPAQUE,
EOLIAN_TYPE_ENUM,
EOLIAN_TYPE_ALIAS,
EOLIAN_TYPE_CLASS
* @brief Get the description of a struct/alias type.
*
* @param[in] tp the type.
- * @return the description when @c tp is EOLIAN_TYPE_STRUCT, NULL otherwise.
+ * @return the description when @c tp is EOLIAN_TYPE_STRUCT or
+ * EOLIAN_TYPE_STRUCT_OPAQUE, NULL otherwise.
*
* @ingroup Eolian
*/
* @brief Get the filename of a struct/alias type.
*
* @param[in] tp the type.
- * @return the filename when @c tp is EOLIAN_TYPE_STRUCT, NULL otherwise.
+ * @return the filename.
*
* @ingroup Eolian
*/
/*
* @brief Get the name of the given type. You have to manually delete
* the stringshare. For EOLIAN_TYPE_REGULAR and EOLIAN_TYPE_REGULAR_STRUCT,
- * this is for example "int". For EOLIAN_TYPE_STRUCT and EOLIAN_TYPE_ALIAS,
- * this is the name of the alias or of the struct. For EOLIAN_TYPE_CLASS,
- * this can be "Button". Keep in mind that the name doesn't include
- * namespaces for structs and aliases.
+ * this is for example "int". For EOLIAN_TYPE_STRUCT, EOLIAN_TYPE_STRUCT_OPAQUE
+ * and EOLIAN_TYPE_ALIAS, this is the name of the alias or of the struct. For
+ * EOLIAN_TYPE_CLASS, this can be "Button". Keep in mind that the name doesn't
+ * include namespaces for structs and aliases.
*
* @param[in] tp the type.
* @return the name.
{
if (btp->type == EOLIAN_TYPE_ENUM)
tp->base_type = NULL;
- else if (btp->type == EOLIAN_TYPE_STRUCT && btp->name)
+ else if ((btp->type == EOLIAN_TYPE_STRUCT
+ || btp->type == EOLIAN_TYPE_STRUCT_OPAQUE) && btp->name)
tp->base_type = NULL;
}
database_type_del(tp);
eina_strbuf_append(buf, tp->name);
eina_strbuf_append_char(buf, ' ');
}
+ if (tp->type == EOLIAN_TYPE_STRUCT_OPAQUE)
+ goto append_name;
eina_strbuf_append(buf, "{ ");
EINA_LIST_FOREACH(tp->field_names, l, fname)
{
eina_strbuf_append(buf, "; ");
}
eina_strbuf_append(buf, "}");
+append_name:
if (name)
{
eina_strbuf_append_char(buf, ' ');
_ftype_to_str(tp, buf, name);
return;
}
- else if (tp->type == EOLIAN_TYPE_STRUCT)
+ else if (tp->type == EOLIAN_TYPE_STRUCT
+ || tp->type == EOLIAN_TYPE_STRUCT_OPAQUE)
{
_stype_to_str(tp, buf, name);
return;
printf("%s", tp->full_name);
else if (tp->type == EOLIAN_TYPE_VOID)
printf("void");
- else if (tp->type == EOLIAN_TYPE_REGULAR_STRUCT)
+ else if (tp->type == EOLIAN_TYPE_REGULAR_STRUCT
+ || tp->type == EOLIAN_TYPE_STRUCT_OPAQUE)
printf("struct %s", tp->full_name);
else if (tp->type == EOLIAN_TYPE_REGULAR_ENUM)
printf("enum %s", tp->full_name);
}
eo_lexer_context_pop(ls);
pop_strbuf(ls);
+ if (ls->t.token == ';')
+ {
+ Eolian_Type *def = push_type(ls);
+ def->is_extern = is_extern;
+ def->type = EOLIAN_TYPE_STRUCT_OPAQUE;
+ _fill_type_name(def, name);
+ eo_lexer_get(ls);
+ if (ls->t.token == TOK_COMMENT)
+ {
+ def->comment = eina_stringshare_ref(ls->t.value.s);
+ eo_lexer_get(ls);
+ }
+ def->base.file = eina_stringshare_ref(ls->filename);
+ def->base.line = line;
+ def->base.column = col;
+ database_struct_add(def);
+ pop_type(ls);
+ break;
+ }
if (is_enum)
parse_enum(ls, name, is_extern, line, col);
else
Eina_Bool is_const :1;
Eina_Bool is_own :1;
Eina_Bool is_extern :1;
+ Eina_Bool is_opaque :1;
};
struct _Eolian_Implement
b: struct _Foo;
};
+/* opaque struct */
+struct Opaque;
+
class Struct {
methods {
foo {
float another;
};
+struct Opaque;
+
#endif
#define STRUCT_CLASS struct_class_get()
fail_if(!!(type_name = eolian_type_name_get(type)));
fail_if(eolian_type_type_get(type) != EOLIAN_TYPE_STRUCT);
+ /* opaque struct */
+ fail_if(!(type = eolian_type_struct_get_by_name("Opaque")));
+ fail_if(eolian_type_type_get(type) != EOLIAN_TYPE_STRUCT_OPAQUE);
+
eolian_shutdown();
}
END_TEST