eolian: expose most API as stable

There is still some TODO with builtin types, parameter
directions and prefixes, which will be resolved in the
next commits.
This commit is contained in:
Daniel Kolesa 2019-09-25 18:17:48 +02:00
parent 883cb445c6
commit 71cd89c580
12 changed files with 75 additions and 110 deletions

View File

@ -339,7 +339,7 @@ ffi.cdef [[
Eolian_Class_Type eolian_class_type_get(const Eolian_Class *klass);
const Eolian_Documentation *eolian_class_documentation_get(const Eolian_Class *klass);
const char *eolian_class_eo_prefix_get(const Eolian_Class *klass);
const char *eolian_class_c_prefix_get(const Eolian_Class *klass);
const char *eolian_class_event_prefix_get(const Eolian_Class *klass);
const char *eolian_class_data_type_get(const Eolian_Class *klass);
const Eolian_Class *eolian_class_parent_get(const Eolian_Class *klass);
@ -454,7 +454,7 @@ ffi.cdef [[
const Eolian_Expression *eolian_expression_unary_expression_get(const Eolian_Expression *expr);
Eolian_Value_t eolian_expression_value_get(const Eolian_Expression *expr);
const Eolian_Documentation *eolian_constant_documentation_get(const Eolian_Constant *var);
const Eolian_Type *eolian_constant_base_type_get(const Eolian_Constant *var);
const Eolian_Type *eolian_constant_type_get(const Eolian_Constant *var);
const Eolian_Expression *eolian_constant_value_get(const Eolian_Constant *var);
Eina_Bool eolian_constant_is_extern(const Eolian_Constant *var);
const char *eolian_documentation_summary_get(const Eolian_Documentation *doc);
@ -1435,8 +1435,8 @@ M.Class = ffi.metatype("Eolian_Class", {
return v
end,
eo_prefix_get = function(self)
local v = eolian.eolian_class_eo_prefix_get(self)
c_prefix_get = function(self)
local v = eolian.eolian_class_c_prefix_get(self)
if v == nil then
local buf = self:namespaces_get()
buf[#buf + 1] = self:short_name_get()
@ -1448,7 +1448,7 @@ M.Class = ffi.metatype("Eolian_Class", {
event_prefix_get = function(self)
local v = eolian.eolian_class_event_prefix_get(self)
if v == nil then
return self:eo_prefix_get()
return self:c_prefix_get()
end
return ffi.string(v)
end,
@ -1713,8 +1713,8 @@ M.Constant = ffi.metatype("Eolian_Constant", {
return v
end,
base_type_get = function(self)
local v = eolian.eolian_constant_base_type_get(self)
type_get = function(self)
local v = eolian.eolian_constant_type_get(self)
if v == nil then return nil end
return v
end,

View File

@ -34,7 +34,7 @@ extern "C" {
#include <Eina.h>
/**
* @page eolian_main Eolian (BETA)
* @page eolian_main Eolian
*
* @date 2014 (created)
*
@ -82,8 +82,6 @@ extern "C" {
* @{
*/
#ifdef EFL_BETA_API_SUPPORT
/* The maximum format version supported by this version of Eolian */
#define EOLIAN_FILE_FORMAT_VERSION 1
@ -284,7 +282,9 @@ typedef enum
EOLIAN_TYPE_REGULAR,
EOLIAN_TYPE_CLASS,
EOLIAN_TYPE_ERROR,
#ifdef EFL_BETA_API_SUPPORT
EOLIAN_TYPE_UNDEFINED
#endif
} Eolian_Type_Type;
typedef enum
@ -336,7 +336,7 @@ typedef enum
EOLIAN_TYPE_BUILTIN_ARRAY,
EOLIAN_TYPE_BUILTIN_FUTURE,
EOLIAN_TYPE_BUILTIN_ITERATOR,
EOLIAN_TYPE_BUILTIN_HASH,
EOLIAN_TYPE_BUILTIN_HASH, /* FIXME: beta */
EOLIAN_TYPE_BUILTIN_LIST,
EOLIAN_TYPE_BUILTIN_ANY_VALUE,
@ -348,7 +348,9 @@ typedef enum
EOLIAN_TYPE_BUILTIN_STRINGSHARE,
EOLIAN_TYPE_BUILTIN_STRBUF,
#ifdef EOLIAN_BETA_API_SUPPORT
EOLIAN_TYPE_BUILTIN_VOID_PTR
#endif
} Eolian_Type_Builtin_Type;
typedef enum
@ -1498,14 +1500,14 @@ EAPI Eolian_Class_Type eolian_class_type_get(const Eolian_Class *klass);
EAPI const Eolian_Documentation *eolian_class_documentation_get(const Eolian_Class *klass);
/*
* @brief Returns the eo prefix of a class
* @brief Returns the C function prefix of a class
*
* @param[in] klass the class
* @return the eo prefix
*
* @ingroup Eolian
*/
EAPI Eina_Stringshare* eolian_class_eo_prefix_get(const Eolian_Class *klass);
EAPI Eina_Stringshare* eolian_class_c_prefix_get(const Eolian_Class *klass);
/*
* @brief Returns the event prefix of a class
@ -1701,16 +1703,6 @@ eolian_function_is_beta(const Eolian_Function *function_id)
*/
EAPI Eina_Bool eolian_function_is_constructor(const Eolian_Function *function_id, const Eolian_Class *klass);
/*
* @brief Get whether a function is a function pointer.
*
* @param[in] function_id Id of the function
* @return EINA_TRUE and EINA_FALSE respectively
*
* @ingroup Eolian
*/
EAPI Eina_Bool eolian_function_is_function_pointer(const Eolian_Function *function_id);
/*
* @brief Returns an iterator to the parameter handles for a method/ctor/dtor.
*
@ -2612,17 +2604,6 @@ EAPI const Eolian_Documentation *eolian_typedecl_enum_field_documentation_get(co
*/
EAPI const Eolian_Expression *eolian_typedecl_enum_field_value_get(const Eolian_Enum_Type_Field *fl, Eina_Bool force);
/*
* @brief Get the legacy prefix of enum field names. When not specified,
* enum name is used.
*
* @param[in] tp the type declaration.
* @return the legacy prefix or NULL.
*
* @ingroup Eolian
*/
EAPI Eina_Stringshare *eolian_typedecl_enum_legacy_prefix_get(const Eolian_Typedecl *tp);
/*
* @brief Get the documentation of a struct/alias type.
*
@ -2866,18 +2847,6 @@ EAPI const Eolian_Class *eolian_type_class_get(const Eolian_Type *tp);
*/
EAPI const Eolian_Error *eolian_type_error_get(const Eolian_Type *tp);
/*
* @brief Get whether the given type is owned.
*
* This is true when a parameter, return or whatever is marked as @owned.
*
* @param[in] tp the type.
* @return EINA_TRUE when the type is marked owned, EINA_FALSE otherwise.
*
* @ingroup Eolian
*/
EAPI Eina_Bool eolian_type_is_owned(const Eolian_Type *tp);
/*
* @brief Get whether the given type is moved with its parent type.
*
@ -2903,16 +2872,6 @@ EAPI Eina_Bool eolian_type_is_move(const Eolian_Type *tp);
*/
EAPI Eina_Bool eolian_type_is_const(const Eolian_Type *tp);
/*
* @brief Get whether the given type is a reference.
*
* @param[in] tp the type.
* @return EINA_TRUE when the type is marked ref, EINA_FALSE otherwise.
*
* @ingroup Eolian
*/
EAPI Eina_Bool eolian_type_is_ptr(const Eolian_Type *tp);
/*
* @brief Get the full C type name of the given type.
*
@ -3133,7 +3092,7 @@ EAPI const Eolian_Documentation *eolian_constant_documentation_get(const Eolian_
*
* @ingroup Eolian
*/
EAPI const Eolian_Type *eolian_constant_base_type_get(const Eolian_Constant *var);
EAPI const Eolian_Type *eolian_constant_type_get(const Eolian_Constant *var);
/*
* @brief Get the value of a constant.
@ -3439,7 +3398,30 @@ EAPI char *eolian_doc_token_text_get(const Eolian_Doc_Token *tok);
*/
EAPI Eolian_Object_Type eolian_doc_token_ref_resolve(const Eolian_Doc_Token *tok, const Eolian_State *state, const Eolian_Object **data, const Eolian_Object **data2);
#endif
#ifdef EFL_BETA_API_SUPPORT
/*
* @brief Get the legacy prefix of enum field names. When not specified,
* enum name is used. (BETA)
*
* @param[in] tp the type declaration.
* @return the legacy prefix or NULL.
*
* @ingroup Eolian
*/
EAPI Eina_Stringshare *eolian_typedecl_enum_legacy_prefix_get(const Eolian_Typedecl *tp);
/*
* @brief Get whether the given type is a reference.
*
* @param[in] tp the type.
* @return EINA_TRUE when the type is marked ref, EINA_FALSE otherwise.
*
* @ingroup Eolian
*/
EAPI Eina_Bool eolian_type_is_ptr(const Eolian_Type *tp);
#endif /* EFL_BETA_API_SUPPORT */
/**
* @}

View File

@ -21,7 +21,7 @@ eolian_class_documentation_get(const Eolian_Class *cl)
}
EAPI Eina_Stringshare*
eolian_class_eo_prefix_get(const Eolian_Class *cl)
eolian_class_c_prefix_get(const Eolian_Class *cl)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(cl, NULL);
return cl->c_prefix;

View File

@ -231,13 +231,6 @@ eolian_type_error_get(const Eolian_Type *tp)
return tp->error;
}
EAPI Eina_Bool
eolian_type_is_owned(const Eolian_Type *tp)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(tp, EINA_FALSE);
return tp->owned;
}
EAPI Eina_Bool
eolian_type_is_move(const Eolian_Type *tp)
{

View File

@ -13,7 +13,7 @@ eolian_constant_documentation_get(const Eolian_Constant *var)
}
EAPI const Eolian_Type *
eolian_constant_base_type_get(const Eolian_Constant *var)
eolian_constant_type_get(const Eolian_Constant *var)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(var, NULL);
return var->base_type;

View File

@ -517,7 +517,7 @@ parse_struct(Eo_Lexer *ls, const char *name, Eina_Bool is_extern,
FILL_BASE(fdef->base, ls, fline, fcol, STRUCT_FIELD);
fdef->type = eo_lexer_type_release(ls, tp);
fdef->base.name = eina_stringshare_ref(fname);
Eina_Bool has_owned = EINA_FALSE, has_by_ref = EINA_FALSE;
Eina_Bool has_move = EINA_FALSE, has_by_ref = EINA_FALSE;
for (;;) switch (ls->t.kw)
{
case KW_at_by_ref:
@ -526,8 +526,8 @@ parse_struct(Eo_Lexer *ls, const char *name, Eina_Bool is_extern,
eo_lexer_get(ls);
break;
case KW_at_move:
CASE_LOCK(ls, owned, "owned qualifier");
fdef->type->owned = fdef->move = EINA_TRUE;
CASE_LOCK(ls, move, "move qualifier");
fdef->move = EINA_TRUE;
eo_lexer_get(ls);
break;
default:
@ -773,14 +773,14 @@ parse_type_void(Eo_Lexer *ls, Eina_Bool allow_ptr)
def->base_type = eo_lexer_type_release(ls, parse_type(ls, EINA_TRUE));
/* view-only types are not allowed to own the contents */
if (tpid == KW_array || tpid == KW_hash || tpid == KW_list || tpid == KW_future)
if ((def->base_type->owned = def->base_type->move = ls->t.kw == KW_at_move))
if ((def->base_type->move = ls->t.kw == KW_at_move))
eo_lexer_get(ls);
if (tpid == KW_hash)
{
check_next(ls, ',');
def->base_type->next_type =
eo_lexer_type_release(ls, parse_type(ls, EINA_TRUE));
if ((def->base_type->next_type->owned = def->base_type->next_type->move = ls->t.kw == KW_at_move))
if ((def->base_type->next_type->move = ls->t.kw == KW_at_move))
eo_lexer_get(ls);
}
check_match(ls, '>', '<', bline, bcol);
@ -1014,7 +1014,7 @@ typedef struct _Eo_Ret_Def
Eolian_Documentation *doc;
Eolian_Expression *default_ret_val;
Eina_Bool no_unused: 1;
Eina_Bool owned: 1;
Eina_Bool move: 1;
Eina_Bool by_ref: 1;
} Eo_Ret_Def;
@ -1031,7 +1031,7 @@ parse_return(Eo_Lexer *ls, Eo_Ret_Def *ret, Eina_Bool allow_void,
ret->doc = NULL;
ret->default_ret_val = NULL;
ret->no_unused = EINA_FALSE;
ret->owned = EINA_FALSE;
ret->move = EINA_FALSE;
ret->by_ref = EINA_FALSE;
if (allow_def && (ls->t.token == '('))
{
@ -1042,7 +1042,7 @@ parse_return(Eo_Lexer *ls, Eo_Ret_Def *ret, Eina_Bool allow_void,
ls->expr_mode = EINA_FALSE;
check_match(ls, ')', '(', line, col);
}
Eina_Bool has_no_unused = EINA_FALSE, has_owned = EINA_FALSE,
Eina_Bool has_no_unused = EINA_FALSE, has_move = EINA_FALSE,
has_by_ref = EINA_FALSE;
if (!is_funcptr) for (;;) switch (ls->t.kw)
{
@ -1052,8 +1052,8 @@ parse_return(Eo_Lexer *ls, Eo_Ret_Def *ret, Eina_Bool allow_void,
eo_lexer_get(ls);
break;
case KW_at_move:
CASE_LOCK(ls, owned, "owned qualifier");
ret->owned = EINA_TRUE;
CASE_LOCK(ls, move, "move qualifier");
ret->move = EINA_TRUE;
eo_lexer_get(ls);
break;
case KW_at_by_ref:
@ -1074,7 +1074,7 @@ parse_param(Eo_Lexer *ls, Eina_List **params, Eina_Bool allow_inout,
Eina_Bool is_vals, const Eolian_Function *func)
{
Eina_Bool has_optional = EINA_FALSE,
has_owned = EINA_FALSE,
has_move = EINA_FALSE,
has_by_ref = EINA_FALSE;
Eolian_Function_Parameter *par = calloc(1, sizeof(Eolian_Function_Parameter));
par->param_dir = EOLIAN_IN_PARAM;
@ -1130,8 +1130,8 @@ type_done:
eo_lexer_get(ls);
break;
case KW_at_move:
CASE_LOCK(ls, owned, "owned qualifier");
par->type->owned = par->move = EINA_TRUE;
CASE_LOCK(ls, move, "move qualifier");
par->move = EINA_TRUE;
eo_lexer_get(ls);
break;
case KW_at_by_ref:
@ -1252,7 +1252,7 @@ parse_accessor:
prop->get_ret_val = ret.default_ret_val;
prop->get_return_no_unused = ret.no_unused;
prop->get_return_by_ref = ret.by_ref;
prop->get_return_move = prop->get_ret_type->owned = ret.owned;
prop->get_return_move = ret.move;
}
else
{
@ -1261,7 +1261,7 @@ parse_accessor:
prop->set_ret_val = ret.default_ret_val;
prop->set_return_no_unused = ret.no_unused;
prop->set_return_by_ref = ret.by_ref;
prop->set_return_move = prop->set_ret_type->owned = ret.owned;
prop->set_return_move = ret.move;
}
break;
case KW_keys:
@ -1573,7 +1573,7 @@ body:
meth->get_ret_val = ret.default_ret_val;
meth->get_return_no_unused = ret.no_unused;
meth->get_return_by_ref = ret.by_ref;
meth->get_return_move = meth->get_ret_type->owned = ret.owned;
meth->get_return_move = ret.move;
break;
case KW_params:
CASE_LOCK(ls, params, "params definition")

View File

@ -284,7 +284,6 @@ struct _Eolian_Type
Eina_Bool is_const :1;
Eina_Bool is_ptr :1;
Eina_Bool move :1;
Eina_Bool owned :1;
Eina_Bool ownable :1;
};

View File

@ -1094,9 +1094,9 @@ struct constant_def
constant_def(Eolian_Constant const* constant, Eolian_Unit const* unit)
: name(::eolian_constant_short_name_get(constant))
, full_name(::eolian_constant_name_get(constant))
, base_type(::eolian_constant_base_type_get(constant)
, base_type(::eolian_constant_type_get(constant)
, unit
, ::eolian_type_c_type_get(eolian_constant_base_type_get(constant))
, ::eolian_type_c_type_get(eolian_constant_type_get(constant))
, value_ownership::unmoved
, is_by::value)
, documentation(::eolian_constant_documentation_get(constant))

View File

@ -645,8 +645,8 @@ class Class(Object):
return ret
@cached_property
def eo_prefix(self):
return _str_to_py(lib.eolian_class_eo_prefix_get(self))
def c_prefix(self):
return _str_to_py(lib.eolian_class_c_prefix_get(self))
@cached_property
def event_prefix(self):
@ -1062,10 +1062,6 @@ class Type(Object):
c_cls = lib.eolian_type_class_get(self)
return Class(c_cls) if c_cls else None
@cached_property
def is_owned(self):
return bool(lib.eolian_type_is_owned(self))
@cached_property
def is_const(self):
return bool(lib.eolian_type_is_const(self))
@ -1231,8 +1227,8 @@ class Constant(Object):
return Expression(c_expr) if c_expr else None
@cached_property
def base_type(self):
c_type = lib.eolian_constant_base_type_get(self)
def type(self):
c_type = lib.eolian_constant_type_get(self)
return Type(c_type) if c_type else None
@cached_property

View File

@ -234,9 +234,9 @@ lib.eolian_class_type_get.restype = c_int
lib.eolian_class_documentation_get.argtypes = (c_void_p,)
lib.eolian_class_documentation_get.restype = c_void_p
# EAPI Eina_Stringshare *eolian_class_eo_prefix_get(const Eolian_Class *klass);
lib.eolian_class_eo_prefix_get.argtypes = (c_void_p,)
lib.eolian_class_eo_prefix_get.restype = c_char_p
# EAPI Eina_Stringshare *eolian_class_c_prefix_get(const Eolian_Class *klass);
lib.eolian_class_c_prefix_get.argtypes = (c_void_p,)
lib.eolian_class_c_prefix_get.restype = c_char_p
# EAPI Eina_Stringshare* eolian_class_event_prefix_get(const Eolian_Class *klass);
lib.eolian_class_event_prefix_get.argtypes = (c_void_p,)
@ -579,10 +579,6 @@ lib.eolian_type_aliased_base_get.restype = c_void_p
lib.eolian_type_class_get.argtypes = (c_void_p,)
lib.eolian_type_class_get.restype = c_void_p
# EAPI Eina_Bool eolian_type_is_owned(const Eolian_Type *tp);
lib.eolian_type_is_owned.argtypes = (c_void_p,)
lib.eolian_type_is_owned.restype = c_bool
# EAPI Eina_Bool eolian_type_is_const(const Eolian_Type *tp);
lib.eolian_type_is_const.argtypes = (c_void_p,)
lib.eolian_type_is_const.restype = c_bool
@ -631,9 +627,9 @@ lib.eolian_expression_unary_expression_get.restype = c_void_p
lib.eolian_constant_documentation_get.argtypes = (c_void_p,)
lib.eolian_constant_documentation_get.restype = c_void_p
# EAPI const Eolian_Type *eolian_constant_base_type_get(const Eolian_Constant *var);
lib.eolian_constant_base_type_get.argtypes = (c_void_p,)
lib.eolian_constant_base_type_get.restype = c_void_p
# EAPI const Eolian_Type *eolian_constant_type_get(const Eolian_Constant *var);
lib.eolian_constant_type_get.argtypes = (c_void_p,)
lib.eolian_constant_type_get.restype = c_void_p
# EAPI const Eolian_Expression *eolian_constant_value_get(const Eolian_Constant *var);
lib.eolian_constant_value_get.argtypes = (c_void_p,)

View File

@ -333,7 +333,7 @@ class TestEolianClass(unittest.TestCase):
self.assertEqual(list(cls.namespaces), ['Efl'])
self.assertEqual(cls.type, eolian.Eolian_Class_Type.REGULAR)
self.assertIsInstance(cls.documentation, eolian.Documentation)
self.assertIsNone(cls.eo_prefix) # TODO fin a class with a value
self.assertIsNone(cls.c_prefix) # TODO fin a class with a value
self.assertIsNone(cls.event_prefix) # TODO same as above
self.assertIsNone(cls.data_type) # TODO same as above
self.assertEqual(cls.parent.name, 'Efl.Loop_Consumer')
@ -475,7 +475,7 @@ class TestEolianConstant(unittest.TestCase):
self.assertFalse(var.is_extern)
self.assertEqual(list(var.namespaces), ['Efl','Gfx'])
self.assertIsInstance(var.documentation, eolian.Documentation)
self.assertIsInstance(var.base_type, eolian.Type)
self.assertIsInstance(var.type, eolian.Type)
self.assertIsInstance(var.value, eolian.Expression)
self.assertEqual(float(var.value.serialize), +1.0)
@ -553,7 +553,6 @@ class TestEolianType(unittest.TestCase):
self.assertEqual(t.file, 'efl_loop_timer.eo') # TODO is this correct ?
self.assertIsNone(t.base_type) # TODO find a better test
self.assertIsNone(t.next_type) # TODO find a better test
self.assertFalse(t.is_owned)
self.assertFalse(t.is_const)
self.assertFalse(t.is_ptr)
self.assertEqual(list(t.namespaces), [])

View File

@ -554,7 +554,7 @@ EFL_START_TEST(eolian_simple_parsing)
fail_if(eolian_class_type_get(class) != EOLIAN_CLASS_REGULAR);
fail_if(eolian_class_parent_get(class) != NULL);
fail_if(eolian_class_extensions_get(class) != NULL);
fail_if(strcmp(eolian_class_eo_prefix_get(class), "efl_canvas_object_simple"));
fail_if(strcmp(eolian_class_c_prefix_get(class), "efl_canvas_object_simple"));
fail_if(strcmp(eolian_class_data_type_get(class), "Evas_Simple_Data"));
Eina_Stringshare *dt = eolian_class_c_data_type_get(class);
fail_if(strcmp(dt, "Evas_Simple_Data"));
@ -786,7 +786,7 @@ EFL_START_TEST(eolian_var)
/* regular constant */
fail_if(!(var = eolian_unit_constant_by_name_get(unit, "Foo")));
fail_if(eolian_constant_is_extern(var));
fail_if(!(type = eolian_constant_base_type_get(var)));
fail_if(!(type = eolian_constant_type_get(var)));
fail_if(!(name = eolian_type_short_name_get(type)));
fail_if(strcmp(name, "int"));
fail_if(!(exp = eolian_constant_value_get(var)));
@ -913,7 +913,7 @@ EFL_START_TEST(eolian_enum)
eina_stringshare_del(cname);
fail_if(!(var = eolian_unit_constant_by_name_get(unit, "Bah")));
fail_if(!(type = eolian_constant_base_type_get(var)));
fail_if(!(type = eolian_constant_type_get(var)));
fail_if(!(name = eolian_type_short_name_get(type)));
fail_if(strcmp(name, "Baz"));
fail_if(!(exp = eolian_constant_value_get(var)));