forked from enlightenment/efl
eolian: refine the ref system to suit more cases
Now references are first class (but still restricted to one level). Unlike pointers they only mark the type instead of introducing a whole new type.
This commit is contained in:
parent
08e189805d
commit
b87c4f6de8
|
@ -133,34 +133,9 @@ _template_fill(Eina_Strbuf *buf, const char *templ, const Eolian_Class *class, c
|
||||||
const char *
|
const char *
|
||||||
_get_add_star(Eolian_Function_Type ftype, Eolian_Parameter_Dir pdir)
|
_get_add_star(Eolian_Function_Type ftype, Eolian_Parameter_Dir pdir)
|
||||||
{
|
{
|
||||||
switch (ftype)
|
if (ftype == EOLIAN_PROP_GET)
|
||||||
{
|
return "*";
|
||||||
case EOLIAN_PROP_GET:
|
if ((pdir == EOLIAN_OUT_PARAM) || (pdir == EOLIAN_INOUT_PARAM))
|
||||||
if (pdir == EOLIAN_REF_PARAM)
|
return "*";
|
||||||
return "**";
|
|
||||||
else
|
|
||||||
return "*";
|
|
||||||
case EOLIAN_PROP_SET:
|
|
||||||
if (pdir == EOLIAN_REF_PARAM)
|
|
||||||
return "*";
|
|
||||||
else
|
|
||||||
return "";
|
|
||||||
default:
|
|
||||||
if (pdir != EOLIAN_IN_PARAM)
|
|
||||||
return "*";
|
|
||||||
else
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
Eina_Stringshare *
|
|
||||||
_get_rettype(const Eolian_Type *tp, Eina_Bool add_star)
|
|
||||||
{
|
|
||||||
Eina_Stringshare *rtp = eolian_type_c_type_get(tp);
|
|
||||||
if (!add_star || !rtp) return rtp;
|
|
||||||
char buf[1024];
|
|
||||||
snprintf(buf, sizeof(buf), "%s%s", rtp, (rtp[strlen(rtp) - 1] == '*') ? "*" : " *");
|
|
||||||
eina_stringshare_del(rtp);
|
|
||||||
return eina_stringshare_add(buf);
|
|
||||||
}
|
|
||||||
|
|
|
@ -64,6 +64,5 @@ void _class_env_create(const Eolian_Class *class, const char *over_classname, _e
|
||||||
void _class_func_env_create(const Eolian_Class *class, const char *funcname, Eolian_Function_Type ftype EINA_UNUSED, _eolian_class_func_vars *env);
|
void _class_func_env_create(const Eolian_Class *class, const char *funcname, Eolian_Function_Type ftype EINA_UNUSED, _eolian_class_func_vars *env);
|
||||||
|
|
||||||
const char *_get_add_star(Eolian_Function_Type ftype, Eolian_Parameter_Dir pdir);
|
const char *_get_add_star(Eolian_Function_Type ftype, Eolian_Parameter_Dir pdir);
|
||||||
Eina_Stringshare *_get_rettype(const Eolian_Type *tp, Eina_Bool add_star);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -517,7 +517,6 @@ docs_generate_function(const Eolian_Function *fid, Eolian_Function_Type ftype,
|
||||||
switch (dir)
|
switch (dir)
|
||||||
{
|
{
|
||||||
case EOLIAN_IN_PARAM:
|
case EOLIAN_IN_PARAM:
|
||||||
case EOLIAN_REF_PARAM:
|
|
||||||
eina_strbuf_append(buf, " * @param[in] ");
|
eina_strbuf_append(buf, " * @param[in] ");
|
||||||
curl += sizeof(" * @param[in] ") - 1;
|
curl += sizeof(" * @param[in] ") - 1;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -71,7 +71,6 @@ eo_fundef_generate(const Eolian_Class *class, const Eolian_Function *func, Eolia
|
||||||
|
|
||||||
_class_func_env_create(class, eolian_function_name_get(func), ftype, &func_env);
|
_class_func_env_create(class, eolian_function_name_get(func), ftype, &func_env);
|
||||||
rettypet = eolian_function_return_type_get(func, ftype);
|
rettypet = eolian_function_return_type_get(func, ftype);
|
||||||
Eina_Bool add_rstar = eolian_function_return_is_ref(func, ftype);
|
|
||||||
if (ftype == EOLIAN_PROP_GET && !rettypet)
|
if (ftype == EOLIAN_PROP_GET && !rettypet)
|
||||||
{
|
{
|
||||||
itr = eolian_property_values_get(func, ftype);
|
itr = eolian_property_values_get(func, ftype);
|
||||||
|
@ -144,7 +143,7 @@ eo_fundef_generate(const Eolian_Class *class, const Eolian_Function *func, Eolia
|
||||||
eina_iterator_free(itr);
|
eina_iterator_free(itr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rettypet) rettype = _get_rettype(rettypet, add_rstar);
|
if (rettypet) rettype = eolian_type_c_type_get(rettypet);
|
||||||
|
|
||||||
eina_strbuf_replace_all(str_func, "@#rettype", rettype ? rettype : "void");
|
eina_strbuf_replace_all(str_func, "@#rettype", rettype ? rettype : "void");
|
||||||
if (!rettype || rettype[strlen(rettype) - 1] != '*')
|
if (!rettype || rettype[strlen(rettype) - 1] != '*')
|
||||||
|
@ -318,7 +317,6 @@ eo_bind_func_generate(const Eolian_Class *class, const Eolian_Function *funcid,
|
||||||
Eina_Strbuf *params_init = eina_strbuf_new(); /* init of variables to default */
|
Eina_Strbuf *params_init = eina_strbuf_new(); /* init of variables to default */
|
||||||
|
|
||||||
rettypet = eolian_function_return_type_get(funcid, ftype);
|
rettypet = eolian_function_return_type_get(funcid, ftype);
|
||||||
Eina_Bool add_rstar = eolian_function_return_is_ref(funcid, ftype);
|
|
||||||
if (rettypet)
|
if (rettypet)
|
||||||
{
|
{
|
||||||
is_auto = EINA_FALSE; /* We block auto when the function has to return something */
|
is_auto = EINA_FALSE; /* We block auto when the function has to return something */
|
||||||
|
@ -450,7 +448,7 @@ eo_bind_func_generate(const Eolian_Class *class, const Eolian_Function *funcid,
|
||||||
eina_iterator_free(itr);
|
eina_iterator_free(itr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rettypet) rettype = _get_rettype(rettypet, add_rstar);
|
if (rettypet) rettype = eolian_type_c_type_get(rettypet);
|
||||||
|
|
||||||
if (need_implementation)
|
if (need_implementation)
|
||||||
{
|
{
|
||||||
|
|
|
@ -140,7 +140,6 @@ _prototype_generate(const Eolian_Function *foo, Eolian_Function_Type ftype, Eina
|
||||||
|
|
||||||
printf("Generation of function %s\n", func_name);
|
printf("Generation of function %s\n", func_name);
|
||||||
const Eolian_Type *rettypet = eolian_function_return_type_get(foo, ftype);
|
const Eolian_Type *rettypet = eolian_function_return_type_get(foo, ftype);
|
||||||
Eina_Bool add_rstar = eolian_function_return_is_ref(foo, ftype);
|
|
||||||
if (ftype == EOLIAN_PROP_GET && !rettypet)
|
if (ftype == EOLIAN_PROP_GET && !rettypet)
|
||||||
{
|
{
|
||||||
Eina_Iterator *itr = eolian_property_values_get(foo, ftype);
|
Eina_Iterator *itr = eolian_property_values_get(foo, ftype);
|
||||||
|
@ -183,7 +182,7 @@ _prototype_generate(const Eolian_Function *foo, Eolian_Function_Type ftype, Eina
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *rettype = NULL;
|
const char *rettype = NULL;
|
||||||
if (rettypet) rettype = _get_rettype(rettypet, add_rstar);
|
if (rettypet) rettype = eolian_type_c_type_get(rettypet);
|
||||||
|
|
||||||
eina_strbuf_append_printf(buffer,
|
eina_strbuf_append_printf(buffer,
|
||||||
"EOLIAN static %s\n%s(%sEo *obj, %s *pd%s%s)\n{\n%s\n}\n\n",
|
"EOLIAN static %s\n%s(%sEo *obj, %s *pd%s%s)\n{\n%s\n}\n\n",
|
||||||
|
|
|
@ -55,7 +55,6 @@ _eapi_decl_func_generate(const Eolian_Class *class, const Eolian_Function *funci
|
||||||
|
|
||||||
_class_func_env_create(class, funcname, ftype, &func_env);
|
_class_func_env_create(class, funcname, ftype, &func_env);
|
||||||
rettypet = eolian_function_return_type_get(funcid, ftype);
|
rettypet = eolian_function_return_type_get(funcid, ftype);
|
||||||
Eina_Bool add_rstar = eolian_function_return_is_ref(funcid, ftype);
|
|
||||||
if (ftype == EOLIAN_PROP_GET)
|
if (ftype == EOLIAN_PROP_GET)
|
||||||
{
|
{
|
||||||
if (!rettypet)
|
if (!rettypet)
|
||||||
|
@ -150,7 +149,7 @@ _eapi_decl_func_generate(const Eolian_Class *class, const Eolian_Function *funci
|
||||||
if (!eina_strbuf_length_get(fparam)) eina_strbuf_append(fparam, "void");
|
if (!eina_strbuf_length_get(fparam)) eina_strbuf_append(fparam, "void");
|
||||||
if (flags) eina_strbuf_append_printf(flags, ")");
|
if (flags) eina_strbuf_append_printf(flags, ")");
|
||||||
|
|
||||||
if (rettypet) rettype = _get_rettype(rettypet, add_rstar);
|
if (rettypet) rettype = eolian_type_c_type_get(rettypet);
|
||||||
|
|
||||||
eina_strbuf_replace_all(fbody, "@#params", eina_strbuf_string_get(fparam));
|
eina_strbuf_replace_all(fbody, "@#params", eina_strbuf_string_get(fparam));
|
||||||
eina_strbuf_reset(fparam);
|
eina_strbuf_reset(fparam);
|
||||||
|
@ -198,8 +197,7 @@ _eapi_func_generate(const Eolian_Class *class, const Eolian_Function *funcid, Eo
|
||||||
|
|
||||||
_class_func_env_create(class, eolian_function_name_get(funcid), ftype, &func_env);
|
_class_func_env_create(class, eolian_function_name_get(funcid), ftype, &func_env);
|
||||||
rettypet = eolian_function_return_type_get(funcid, ftype);
|
rettypet = eolian_function_return_type_get(funcid, ftype);
|
||||||
Eina_Bool add_rstar = eolian_function_return_is_ref(funcid, ftype);
|
if (rettypet) rettype = eolian_type_c_type_get(rettypet);
|
||||||
if (rettypet) rettype = _get_rettype(rettypet, add_rstar);
|
|
||||||
if (rettype && !strcmp(rettype, "void")) ret_is_void = EINA_TRUE;
|
if (rettype && !strcmp(rettype, "void")) ret_is_void = EINA_TRUE;
|
||||||
retname = "ret";
|
retname = "ret";
|
||||||
if (ftype == EOLIAN_PROP_GET)
|
if (ftype == EOLIAN_PROP_GET)
|
||||||
|
@ -221,7 +219,7 @@ _eapi_func_generate(const Eolian_Class *class, const Eolian_Function *funcid, Eo
|
||||||
|
|
||||||
if (func_env.legacy_func[0] == '\0') goto end;
|
if (func_env.legacy_func[0] == '\0') goto end;
|
||||||
|
|
||||||
if (!rettype && rettypet) rettype = _get_rettype(rettypet, add_rstar);
|
if (!rettype && rettypet) rettype = eolian_type_c_type_get(rettypet);
|
||||||
|
|
||||||
if (rettype && (!ret_is_void))
|
if (rettype && (!ret_is_void))
|
||||||
eina_strbuf_append(fbody, tmpl_eapi_body);
|
eina_strbuf_append(fbody, tmpl_eapi_body);
|
||||||
|
|
|
@ -71,9 +71,8 @@ _type_generate(const Eolian_Typedecl *tp, Eina_Bool full, Eina_Bool use_legacy)
|
||||||
{
|
{
|
||||||
const Eolian_Type *type = eolian_typedecl_struct_field_type_get(member);
|
const Eolian_Type *type = eolian_typedecl_struct_field_type_get(member);
|
||||||
Eina_Stringshare *c_type = eolian_type_c_type_get(type);
|
Eina_Stringshare *c_type = eolian_type_c_type_get(type);
|
||||||
Eina_Bool is_ref = eolian_typedecl_struct_field_is_ref(member);
|
eina_strbuf_append_printf(buf, " %s%s%s;",
|
||||||
eina_strbuf_append_printf(buf, " %s%s%s%s;",
|
c_type, strchr(c_type, '*')?"":" ",
|
||||||
c_type, is_ref ? (strchr(c_type, '*') ? "*" : " *") : "", (is_ref || strchr(c_type, '*'))?"":" ",
|
|
||||||
eolian_typedecl_struct_field_name_get(member));
|
eolian_typedecl_struct_field_name_get(member));
|
||||||
const Eolian_Documentation *fdoc
|
const Eolian_Documentation *fdoc
|
||||||
= eolian_typedecl_struct_field_documentation_get(member);
|
= eolian_typedecl_struct_field_documentation_get(member);
|
||||||
|
|
|
@ -41,8 +41,7 @@ ffi.cdef [[
|
||||||
{
|
{
|
||||||
EOLIAN_IN_PARAM = 0,
|
EOLIAN_IN_PARAM = 0,
|
||||||
EOLIAN_OUT_PARAM,
|
EOLIAN_OUT_PARAM,
|
||||||
EOLIAN_INOUT_PARAM,
|
EOLIAN_INOUT_PARAM
|
||||||
EOLIAN_REF_PARAM
|
|
||||||
} Eolian_Parameter_Dir;
|
} Eolian_Parameter_Dir;
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
|
@ -281,7 +280,6 @@ ffi.cdef [[
|
||||||
const char *eolian_typedecl_struct_field_name_get(const Eolian_Struct_Type_Field *fl);
|
const char *eolian_typedecl_struct_field_name_get(const Eolian_Struct_Type_Field *fl);
|
||||||
const Eolian_Documentation *eolian_typedecl_struct_field_documentation_get(const Eolian_Struct_Type_Field *fl);
|
const Eolian_Documentation *eolian_typedecl_struct_field_documentation_get(const Eolian_Struct_Type_Field *fl);
|
||||||
const Eolian_Type *eolian_typedecl_struct_field_type_get(const Eolian_Struct_Type_Field *fl);
|
const Eolian_Type *eolian_typedecl_struct_field_type_get(const Eolian_Struct_Type_Field *fl);
|
||||||
Eina_Bool eolian_typedecl_struct_field_is_ref(const Eolian_Struct_Type_Field *fl);
|
|
||||||
Eina_Iterator *eolian_typedecl_enum_fields_get(const Eolian_Typedecl *tp);
|
Eina_Iterator *eolian_typedecl_enum_fields_get(const Eolian_Typedecl *tp);
|
||||||
const Eolian_Enum_Type_Field *eolian_typedecl_enum_field_get(const Eolian_Typedecl *tp, const char *field);
|
const Eolian_Enum_Type_Field *eolian_typedecl_enum_field_get(const Eolian_Typedecl *tp, const char *field);
|
||||||
const char *eolian_typedecl_enum_field_name_get(const Eolian_Enum_Type_Field *fl);
|
const char *eolian_typedecl_enum_field_name_get(const Eolian_Enum_Type_Field *fl);
|
||||||
|
@ -304,6 +302,7 @@ ffi.cdef [[
|
||||||
const Eolian_Class *eolian_type_class_get(const Eolian_Type *tp);
|
const Eolian_Class *eolian_type_class_get(const Eolian_Type *tp);
|
||||||
Eina_Bool eolian_type_is_own(const Eolian_Type *tp);
|
Eina_Bool eolian_type_is_own(const Eolian_Type *tp);
|
||||||
Eina_Bool eolian_type_is_const(const Eolian_Type *tp);
|
Eina_Bool eolian_type_is_const(const Eolian_Type *tp);
|
||||||
|
Eina_Bool eolian_type_is_ref(const Eolian_Type *tp);
|
||||||
|
|
||||||
Eina_Bool eolian_typedecl_is_extern(const Eolian_Typedecl *tp);
|
Eina_Bool eolian_typedecl_is_extern(const Eolian_Typedecl *tp);
|
||||||
|
|
||||||
|
@ -484,10 +483,6 @@ ffi.metatype("Eolian_Struct_Type_Field", {
|
||||||
local v = eolian.eolian_typedecl_struct_field_type_get(self)
|
local v = eolian.eolian_typedecl_struct_field_type_get(self)
|
||||||
if v == nil then return nil end
|
if v == nil then return nil end
|
||||||
return v
|
return v
|
||||||
end,
|
|
||||||
|
|
||||||
is_ref = function(self)
|
|
||||||
return eolian.eolian_typedecl_struct_field_is_ref(self) ~= 0
|
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -662,6 +657,10 @@ M.Type = ffi.metatype("Eolian_Type", {
|
||||||
return eolian.eolian_type_is_const(self) ~= 0
|
return eolian.eolian_type_is_const(self) ~= 0
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
is_ref = function(self)
|
||||||
|
return eolian.eolian_type_is_ref(self) ~= 0
|
||||||
|
end,
|
||||||
|
|
||||||
c_type_get = function(self)
|
c_type_get = function(self)
|
||||||
local v = eolian.eolian_type_c_type_get(self)
|
local v = eolian.eolian_type_c_type_get(self)
|
||||||
if v == nil then return nil end
|
if v == nil then return nil end
|
||||||
|
@ -806,8 +805,7 @@ M.Function = ffi.metatype("Eolian_Function", {
|
||||||
M.parameter_dir = {
|
M.parameter_dir = {
|
||||||
IN = 0,
|
IN = 0,
|
||||||
OUT = 1,
|
OUT = 1,
|
||||||
INOUT = 2,
|
INOUT = 2
|
||||||
REF = 3
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ffi.metatype("Eolian_Function_Parameter", {
|
ffi.metatype("Eolian_Function_Parameter", {
|
||||||
|
|
|
@ -184,8 +184,7 @@ typedef enum
|
||||||
{
|
{
|
||||||
EOLIAN_IN_PARAM = 0,
|
EOLIAN_IN_PARAM = 0,
|
||||||
EOLIAN_OUT_PARAM,
|
EOLIAN_OUT_PARAM,
|
||||||
EOLIAN_INOUT_PARAM,
|
EOLIAN_INOUT_PARAM
|
||||||
EOLIAN_REF_PARAM
|
|
||||||
} Eolian_Parameter_Dir;
|
} Eolian_Parameter_Dir;
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
|
@ -968,20 +967,6 @@ EAPI const Eolian_Documentation *eolian_function_return_documentation_get(const
|
||||||
*/
|
*/
|
||||||
EAPI Eina_Bool eolian_function_return_is_warn_unused(const Eolian_Function *foo_id, Eolian_Function_Type ftype);
|
EAPI Eina_Bool eolian_function_return_is_warn_unused(const Eolian_Function *foo_id, Eolian_Function_Type ftype);
|
||||||
|
|
||||||
/*
|
|
||||||
* @brief Indicates if a function returns a ref (pointer).
|
|
||||||
*
|
|
||||||
* @param[in] function_id id of the function
|
|
||||||
* @param[in] ftype type of the function
|
|
||||||
* @return EINA_TRUE is ref return, EINA_FALSE otherwise.
|
|
||||||
*
|
|
||||||
* The type of the function is needed because a given function can represent a
|
|
||||||
* property, that can be set and get functions.
|
|
||||||
*
|
|
||||||
* @ingroup Eolian
|
|
||||||
*/
|
|
||||||
EAPI Eina_Bool eolian_function_return_is_ref(const Eolian_Function *foo_id, Eolian_Function_Type ftype);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @brief Indicates if a function object is const.
|
* @brief Indicates if a function object is const.
|
||||||
*
|
*
|
||||||
|
@ -1463,16 +1448,6 @@ EAPI const Eolian_Documentation *eolian_typedecl_struct_field_documentation_get(
|
||||||
*/
|
*/
|
||||||
EAPI const Eolian_Type *eolian_typedecl_struct_field_type_get(const Eolian_Struct_Type_Field *fl);
|
EAPI const Eolian_Type *eolian_typedecl_struct_field_type_get(const Eolian_Struct_Type_Field *fl);
|
||||||
|
|
||||||
/*
|
|
||||||
* @brief Check if a struct field is a reference.
|
|
||||||
*
|
|
||||||
* @param[in] fl the field.
|
|
||||||
* @return EINA_TRUE if it is, EINA_FALSE otherwise.
|
|
||||||
*
|
|
||||||
* @ingroup Eolian
|
|
||||||
*/
|
|
||||||
EAPI Eina_Bool eolian_typedecl_struct_field_is_ref(const Eolian_Struct_Type_Field *fl);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @brief Get an iterator to all fields of an enum type.
|
* @brief Get an iterator to all fields of an enum type.
|
||||||
*
|
*
|
||||||
|
@ -1763,6 +1738,16 @@ EAPI Eina_Bool eolian_type_is_own(const Eolian_Type *tp);
|
||||||
*/
|
*/
|
||||||
EAPI Eina_Bool eolian_type_is_const(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_ref(const Eolian_Type *tp);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @brief Get the full C type name of the given type.
|
* @brief Get the full C type name of the given type.
|
||||||
*
|
*
|
||||||
|
|
|
@ -302,19 +302,6 @@ eolian_function_return_is_warn_unused(const Eolian_Function *fid,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI Eina_Bool
|
|
||||||
eolian_function_return_is_ref(const Eolian_Function *fid,
|
|
||||||
Eolian_Function_Type ftype)
|
|
||||||
{
|
|
||||||
EINA_SAFETY_ON_NULL_RETURN_VAL(fid, EINA_FALSE);
|
|
||||||
switch (ftype)
|
|
||||||
{
|
|
||||||
case EOLIAN_PROP_SET: return fid->set_return_is_ref;
|
|
||||||
case EOLIAN_UNRESOLVED: case EOLIAN_METHOD: case EOLIAN_PROPERTY: case EOLIAN_PROP_GET: return fid->get_return_is_ref;
|
|
||||||
default: return EINA_FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
EAPI Eina_Bool
|
EAPI Eina_Bool
|
||||||
eolian_function_object_is_const(const Eolian_Function *fid)
|
eolian_function_object_is_const(const Eolian_Function *fid)
|
||||||
{
|
{
|
||||||
|
|
|
@ -70,7 +70,7 @@ database_enum_add(Eolian_Typedecl *tp)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name, Eina_Bool is_ref)
|
database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name)
|
||||||
{
|
{
|
||||||
if ((tp->type == EOLIAN_TYPE_REGULAR
|
if ((tp->type == EOLIAN_TYPE_REGULAR
|
||||||
|| tp->type == EOLIAN_TYPE_COMPLEX
|
|| tp->type == EOLIAN_TYPE_COMPLEX
|
||||||
|
@ -104,7 +104,7 @@ database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Eolian_Type *btp = tp->base_type;
|
Eolian_Type *btp = tp->base_type;
|
||||||
database_type_to_str(tp->base_type, buf, NULL, EINA_FALSE);
|
database_type_to_str(tp->base_type, buf, NULL);
|
||||||
if (btp->type != EOLIAN_TYPE_POINTER || btp->is_const)
|
if (btp->type != EOLIAN_TYPE_POINTER || btp->is_const)
|
||||||
eina_strbuf_append_char(buf, ' ');
|
eina_strbuf_append_char(buf, ' ');
|
||||||
eina_strbuf_append_char(buf, '*');
|
eina_strbuf_append_char(buf, '*');
|
||||||
|
@ -112,7 +112,7 @@ database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name,
|
||||||
}
|
}
|
||||||
if (tp->type == EOLIAN_TYPE_COMPLEX || tp->type == EOLIAN_TYPE_CLASS)
|
if (tp->type == EOLIAN_TYPE_COMPLEX || tp->type == EOLIAN_TYPE_CLASS)
|
||||||
eina_strbuf_append(buf, " *");
|
eina_strbuf_append(buf, " *");
|
||||||
if (is_ref)
|
if (tp->is_ref)
|
||||||
{
|
{
|
||||||
if (eina_strbuf_string_get(buf)[eina_strbuf_length_get(buf) - 1] != '*')
|
if (eina_strbuf_string_get(buf)[eina_strbuf_length_get(buf) - 1] != '*')
|
||||||
eina_strbuf_append_char(buf, ' ');
|
eina_strbuf_append_char(buf, ' ');
|
||||||
|
@ -144,7 +144,7 @@ _stype_to_str(const Eolian_Typedecl *tp, Eina_Strbuf *buf)
|
||||||
eina_strbuf_append(buf, " { ");
|
eina_strbuf_append(buf, " { ");
|
||||||
EINA_LIST_FOREACH(tp->field_list, l, sf)
|
EINA_LIST_FOREACH(tp->field_list, l, sf)
|
||||||
{
|
{
|
||||||
database_type_to_str(sf->type, buf, sf->name, sf->is_ref);
|
database_type_to_str(sf->type, buf, sf->name);
|
||||||
eina_strbuf_append(buf, "; ");
|
eina_strbuf_append(buf, "; ");
|
||||||
}
|
}
|
||||||
eina_strbuf_append(buf, "}");
|
eina_strbuf_append(buf, "}");
|
||||||
|
@ -213,7 +213,7 @@ _atype_to_str(const Eolian_Typedecl *tp, Eina_Strbuf *buf)
|
||||||
|
|
||||||
Eina_Strbuf *fulln = eina_strbuf_new();
|
Eina_Strbuf *fulln = eina_strbuf_new();
|
||||||
_append_name(tp, fulln);
|
_append_name(tp, fulln);
|
||||||
database_type_to_str(tp->base_type, buf, eina_strbuf_string_get(fulln), EINA_FALSE);
|
database_type_to_str(tp->base_type, buf, eina_strbuf_string_get(fulln));
|
||||||
eina_strbuf_free(fulln);
|
eina_strbuf_free(fulln);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -158,13 +158,6 @@ eolian_typedecl_struct_field_type_get(const Eolian_Struct_Type_Field *fl)
|
||||||
return fl->type;
|
return fl->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI Eina_Bool
|
|
||||||
eolian_typedecl_struct_field_is_ref(const Eolian_Struct_Type_Field *fl)
|
|
||||||
{
|
|
||||||
EINA_SAFETY_ON_NULL_RETURN_VAL(fl, EINA_FALSE);
|
|
||||||
return fl->is_ref;
|
|
||||||
}
|
|
||||||
|
|
||||||
EAPI Eina_Iterator *
|
EAPI Eina_Iterator *
|
||||||
eolian_typedecl_enum_fields_get(const Eolian_Typedecl *tp)
|
eolian_typedecl_enum_fields_get(const Eolian_Typedecl *tp)
|
||||||
{
|
{
|
||||||
|
@ -338,6 +331,13 @@ eolian_type_is_const(const Eolian_Type *tp)
|
||||||
return tp->is_const;
|
return tp->is_const;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EAPI Eina_Bool
|
||||||
|
eolian_type_is_ref(const Eolian_Type *tp)
|
||||||
|
{
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(tp, EINA_FALSE);
|
||||||
|
return tp->is_ref;
|
||||||
|
}
|
||||||
|
|
||||||
EAPI Eina_Bool
|
EAPI Eina_Bool
|
||||||
eolian_typedecl_is_extern(const Eolian_Typedecl *tp)
|
eolian_typedecl_is_extern(const Eolian_Typedecl *tp)
|
||||||
{
|
{
|
||||||
|
@ -352,7 +352,7 @@ eolian_type_c_type_get(const Eolian_Type *tp)
|
||||||
Eina_Strbuf *buf;
|
Eina_Strbuf *buf;
|
||||||
EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
|
EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
|
||||||
buf = eina_strbuf_new();
|
buf = eina_strbuf_new();
|
||||||
database_type_to_str(tp, buf, NULL, EINA_FALSE);
|
database_type_to_str(tp, buf, NULL);
|
||||||
ret = eina_stringshare_add(eina_strbuf_string_get(buf));
|
ret = eina_stringshare_add(eina_strbuf_string_get(buf));
|
||||||
eina_strbuf_free(buf);
|
eina_strbuf_free(buf);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -27,12 +27,12 @@ enum Tokens
|
||||||
KW(abstract), KW(constructor), KW(constructors), KW(data), \
|
KW(abstract), KW(constructor), KW(constructors), KW(data), \
|
||||||
KW(destructor), KW(eo), KW(eo_prefix), KW(event_prefix), KW(events), KW(free), \
|
KW(destructor), KW(eo), KW(eo_prefix), KW(event_prefix), KW(events), KW(free), \
|
||||||
KW(get), KW(implements), KW(import), KW(interface), KW(keys), KW(legacy), \
|
KW(get), KW(implements), KW(import), KW(interface), KW(keys), KW(legacy), \
|
||||||
KW(legacy_prefix), KW(methods), KW(mixin), KW(own), KW(params), \
|
KW(legacy_prefix), KW(methods), KW(mixin), KW(own), KW(params), KW(ref), \
|
||||||
KW(set), KW(type), KW(values), KW(var), KWAT(auto), KWAT(beta), \
|
KW(set), KW(type), KW(values), KW(var), KWAT(auto), KWAT(beta), \
|
||||||
KWAT(c_only), KWAT(class), KWAT(const), KWAT(empty), KWAT(extern), \
|
KWAT(c_only), KWAT(class), KWAT(const), KWAT(empty), KWAT(extern), \
|
||||||
KWAT(free), KWAT(hot), KWAT(in), KWAT(inout), KWAT(nonull), KWAT(nullable), \
|
KWAT(free), KWAT(hot), KWAT(in), KWAT(inout), KWAT(nonull), KWAT(nullable), \
|
||||||
KWAT(optional), KWAT(out), KWAT(private), KWAT(property), \
|
KWAT(optional), KWAT(out), KWAT(private), KWAT(property), \
|
||||||
KWAT(protected), KWAT(ref), KWAT(restart), KWAT(virtual_pure), KWAT(warn_unused), \
|
KWAT(protected), KWAT(restart), KWAT(virtual_pure), KWAT(warn_unused), \
|
||||||
\
|
\
|
||||||
KW(byte), KW(ubyte), KW(char), KW(short), KW(ushort), KW(int), KW(uint), \
|
KW(byte), KW(ubyte), KW(char), KW(short), KW(ushort), KW(int), KW(uint), \
|
||||||
KW(long), KW(ulong), KW(llong), KW(ullong), \
|
KW(long), KW(ulong), KW(llong), KW(ullong), \
|
||||||
|
|
|
@ -458,14 +458,14 @@ parse_expr(Eo_Lexer *ls)
|
||||||
return parse_expr_bin(ls, 1);
|
return parse_expr_bin(ls, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Eolian_Type *parse_type_void(Eo_Lexer *ls);
|
static Eolian_Type *parse_type_void(Eo_Lexer *ls, Eina_Bool allow_ref);
|
||||||
|
|
||||||
static Eolian_Type *
|
static Eolian_Type *
|
||||||
parse_type(Eo_Lexer *ls)
|
parse_type(Eo_Lexer *ls, Eina_Bool allow_ref)
|
||||||
{
|
{
|
||||||
Eolian_Type *ret;
|
Eolian_Type *ret;
|
||||||
eo_lexer_context_push(ls);
|
eo_lexer_context_push(ls);
|
||||||
ret = parse_type_void(ls);
|
ret = parse_type_void(ls, allow_ref);
|
||||||
if (ret->type == EOLIAN_TYPE_VOID)
|
if (ret->type == EOLIAN_TYPE_VOID)
|
||||||
{
|
{
|
||||||
eo_lexer_context_restore(ls);
|
eo_lexer_context_restore(ls);
|
||||||
|
@ -502,15 +502,9 @@ parse_struct(Eo_Lexer *ls, const char *name, Eina_Bool is_extern,
|
||||||
while (ls->t.token != '}')
|
while (ls->t.token != '}')
|
||||||
{
|
{
|
||||||
const char *fname;
|
const char *fname;
|
||||||
Eina_Bool is_ref = EINA_FALSE;
|
|
||||||
Eolian_Struct_Type_Field *fdef;
|
Eolian_Struct_Type_Field *fdef;
|
||||||
Eolian_Type *tp;
|
Eolian_Type *tp;
|
||||||
int fline = ls->line_number, fcol = ls->column;
|
int fline = ls->line_number, fcol = ls->column;
|
||||||
if (ls->t.kw == KW_at_ref)
|
|
||||||
{
|
|
||||||
is_ref = EINA_TRUE;
|
|
||||||
eo_lexer_get(ls);
|
|
||||||
}
|
|
||||||
check(ls, TOK_VALUE);
|
check(ls, TOK_VALUE);
|
||||||
if (eina_hash_find(def->fields, ls->t.value.s))
|
if (eina_hash_find(def->fields, ls->t.value.s))
|
||||||
eo_lexer_syntax_error(ls, "double field definition");
|
eo_lexer_syntax_error(ls, "double field definition");
|
||||||
|
@ -520,11 +514,10 @@ parse_struct(Eo_Lexer *ls, const char *name, Eina_Bool is_extern,
|
||||||
def->field_list = eina_list_append(def->field_list, fdef);
|
def->field_list = eina_list_append(def->field_list, fdef);
|
||||||
eo_lexer_get(ls);
|
eo_lexer_get(ls);
|
||||||
check_next(ls, ':');
|
check_next(ls, ':');
|
||||||
tp = parse_type(ls);
|
tp = parse_type(ls, EINA_TRUE);
|
||||||
FILL_BASE(fdef->base, ls, fline, fcol);
|
FILL_BASE(fdef->base, ls, fline, fcol);
|
||||||
fdef->type = tp;
|
fdef->type = tp;
|
||||||
fdef->name = eina_stringshare_ref(fname);
|
fdef->name = eina_stringshare_ref(fname);
|
||||||
fdef->is_ref = is_ref;
|
|
||||||
pop_type(ls);
|
pop_type(ls);
|
||||||
check_next(ls, ';');
|
check_next(ls, ';');
|
||||||
FILL_DOC(ls, fdef, doc);
|
FILL_DOC(ls, fdef, doc);
|
||||||
|
@ -701,6 +694,8 @@ _parse_dep(Eo_Lexer *ls, const char *fname, const char *name)
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_type_is_ownable(Eolian_Type *tp)
|
_type_is_ownable(Eolian_Type *tp)
|
||||||
{
|
{
|
||||||
|
if (tp->is_ref)
|
||||||
|
return EINA_TRUE;
|
||||||
if (tp->type == EOLIAN_TYPE_REGULAR)
|
if (tp->type == EOLIAN_TYPE_REGULAR)
|
||||||
{
|
{
|
||||||
int kwid = eo_lexer_keyword_str_to_id(tp->name);
|
int kwid = eo_lexer_keyword_str_to_id(tp->name);
|
||||||
|
@ -715,7 +710,7 @@ _type_is_ownable(Eolian_Type *tp)
|
||||||
}
|
}
|
||||||
|
|
||||||
static Eolian_Type *
|
static Eolian_Type *
|
||||||
parse_type_void(Eo_Lexer *ls)
|
parse_type_void(Eo_Lexer *ls, Eina_Bool allow_ref)
|
||||||
{
|
{
|
||||||
Eolian_Type *def;
|
Eolian_Type *def;
|
||||||
Eina_Strbuf *buf;
|
Eina_Strbuf *buf;
|
||||||
|
@ -729,12 +724,25 @@ parse_type_void(Eo_Lexer *ls)
|
||||||
pline = ls->line_number;
|
pline = ls->line_number;
|
||||||
pcol = ls->column;
|
pcol = ls->column;
|
||||||
check_next(ls, '(');
|
check_next(ls, '(');
|
||||||
def = parse_type_void(ls);
|
def = parse_type_void(ls, allow_ref);
|
||||||
FILL_BASE(def->base, ls, line, col);
|
FILL_BASE(def->base, ls, line, col);
|
||||||
def->is_const = EINA_TRUE;
|
def->is_const = EINA_TRUE;
|
||||||
check_match(ls, ')', '(', pline, pcol);
|
check_match(ls, ')', '(', pline, pcol);
|
||||||
goto parse_ptr;
|
goto parse_ptr;
|
||||||
}
|
}
|
||||||
|
case KW_ref:
|
||||||
|
{
|
||||||
|
int pline, pcol;
|
||||||
|
eo_lexer_get(ls);
|
||||||
|
pline = ls->line_number;
|
||||||
|
pcol = ls->column;
|
||||||
|
check_next(ls, '(');
|
||||||
|
def = parse_type_void(ls, EINA_FALSE);
|
||||||
|
FILL_BASE(def->base, ls, line, col);
|
||||||
|
def->is_ref = EINA_TRUE;
|
||||||
|
check_match(ls, ')', '(', pline, pcol);
|
||||||
|
goto parse_ptr;
|
||||||
|
}
|
||||||
case KW_own:
|
case KW_own:
|
||||||
{
|
{
|
||||||
int pline, pcolumn;
|
int pline, pcolumn;
|
||||||
|
@ -743,7 +751,7 @@ parse_type_void(Eo_Lexer *ls)
|
||||||
pcolumn = ls->column;
|
pcolumn = ls->column;
|
||||||
check_next(ls, '(');
|
check_next(ls, '(');
|
||||||
eo_lexer_context_push(ls);
|
eo_lexer_context_push(ls);
|
||||||
def = parse_type_void(ls);
|
def = parse_type_void(ls, allow_ref);
|
||||||
if (!_type_is_ownable(def))
|
if (!_type_is_ownable(def))
|
||||||
{
|
{
|
||||||
eo_lexer_context_restore(ls);
|
eo_lexer_context_restore(ls);
|
||||||
|
@ -763,7 +771,7 @@ parse_type_void(Eo_Lexer *ls)
|
||||||
pcolumn = ls->column;
|
pcolumn = ls->column;
|
||||||
check_next(ls, '(');
|
check_next(ls, '(');
|
||||||
eo_lexer_context_push(ls);
|
eo_lexer_context_push(ls);
|
||||||
def = parse_type_void(ls);
|
def = parse_type_void(ls, allow_ref);
|
||||||
if (!_type_is_ownable(def))
|
if (!_type_is_ownable(def))
|
||||||
{
|
{
|
||||||
eo_lexer_context_restore(ls);
|
eo_lexer_context_restore(ls);
|
||||||
|
@ -809,19 +817,19 @@ parse_type_void(Eo_Lexer *ls)
|
||||||
def->type = EOLIAN_TYPE_COMPLEX;
|
def->type = EOLIAN_TYPE_COMPLEX;
|
||||||
check_next(ls, '<');
|
check_next(ls, '<');
|
||||||
def->subtypes = eina_list_append(def->subtypes,
|
def->subtypes = eina_list_append(def->subtypes,
|
||||||
parse_type(ls));
|
parse_type(ls, EINA_FALSE));
|
||||||
pop_type(ls);
|
pop_type(ls);
|
||||||
if (tpid == KW_hash)
|
if (tpid == KW_hash)
|
||||||
{
|
{
|
||||||
check_next(ls, ',');
|
check_next(ls, ',');
|
||||||
def->subtypes = eina_list_append(def->subtypes,
|
def->subtypes = eina_list_append(def->subtypes,
|
||||||
parse_type(ls));
|
parse_type(ls, EINA_FALSE));
|
||||||
pop_type(ls);
|
pop_type(ls);
|
||||||
}
|
}
|
||||||
else if(tpid == KW_promise && test_next(ls, ','))
|
else if(tpid == KW_promise && test_next(ls, ','))
|
||||||
{
|
{
|
||||||
def->subtypes = eina_list_append(def->subtypes,
|
def->subtypes = eina_list_append(def->subtypes,
|
||||||
parse_type(ls));
|
parse_type(ls, EINA_FALSE));
|
||||||
pop_type(ls);
|
pop_type(ls);
|
||||||
}
|
}
|
||||||
check_match(ls, '>', '<', bline, bcol);
|
check_match(ls, '>', '<', bline, bcol);
|
||||||
|
@ -913,7 +921,7 @@ parse_typedef(Eo_Lexer *ls)
|
||||||
}
|
}
|
||||||
eo_lexer_context_pop(ls);
|
eo_lexer_context_pop(ls);
|
||||||
check_next(ls, ':');
|
check_next(ls, ':');
|
||||||
def->base_type = parse_type(ls);
|
def->base_type = parse_type(ls, EINA_FALSE);
|
||||||
pop_type(ls);
|
pop_type(ls);
|
||||||
check_next(ls, ';');
|
check_next(ls, ';');
|
||||||
FILL_DOC(ls, def, doc);
|
FILL_DOC(ls, def, doc);
|
||||||
|
@ -952,7 +960,7 @@ parse_variable(Eo_Lexer *ls, Eina_Bool global)
|
||||||
}
|
}
|
||||||
eo_lexer_context_pop(ls);
|
eo_lexer_context_pop(ls);
|
||||||
check_next(ls, ':');
|
check_next(ls, ':');
|
||||||
def->base_type = parse_type(ls);
|
def->base_type = parse_type(ls, EINA_FALSE);
|
||||||
pop_type(ls);
|
pop_type(ls);
|
||||||
if ((ls->t.token == '=') && !has_extern)
|
if ((ls->t.token == '=') && !has_extern)
|
||||||
{
|
{
|
||||||
|
@ -973,7 +981,6 @@ typedef struct _Eo_Ret_Def
|
||||||
Eolian_Documentation *doc;
|
Eolian_Documentation *doc;
|
||||||
Eolian_Expression *default_ret_val;
|
Eolian_Expression *default_ret_val;
|
||||||
Eina_Bool warn_unused: 1;
|
Eina_Bool warn_unused: 1;
|
||||||
Eina_Bool is_ref: 1;
|
|
||||||
} Eo_Ret_Def;
|
} Eo_Ret_Def;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -982,13 +989,12 @@ parse_return(Eo_Lexer *ls, Eo_Ret_Def *ret, Eina_Bool allow_void)
|
||||||
eo_lexer_get(ls);
|
eo_lexer_get(ls);
|
||||||
check_next(ls, ':');
|
check_next(ls, ':');
|
||||||
if (allow_void)
|
if (allow_void)
|
||||||
ret->type = parse_type_void(ls);
|
ret->type = parse_type_void(ls, EINA_TRUE);
|
||||||
else
|
else
|
||||||
ret->type = parse_type(ls);
|
ret->type = parse_type(ls, EINA_TRUE);
|
||||||
ret->doc = NULL;
|
ret->doc = NULL;
|
||||||
ret->default_ret_val = NULL;
|
ret->default_ret_val = NULL;
|
||||||
ret->warn_unused = EINA_FALSE;
|
ret->warn_unused = EINA_FALSE;
|
||||||
ret->is_ref = EINA_FALSE;
|
|
||||||
if (ls->t.token == '(')
|
if (ls->t.token == '(')
|
||||||
{
|
{
|
||||||
int line = ls->line_number, col = ls->column;
|
int line = ls->line_number, col = ls->column;
|
||||||
|
@ -998,7 +1004,7 @@ parse_return(Eo_Lexer *ls, Eo_Ret_Def *ret, Eina_Bool allow_void)
|
||||||
ls->expr_mode = EINA_FALSE;
|
ls->expr_mode = EINA_FALSE;
|
||||||
check_match(ls, ')', '(', line, col);
|
check_match(ls, ')', '(', line, col);
|
||||||
}
|
}
|
||||||
Eina_Bool has_warn_unused = EINA_FALSE, has_ref = EINA_FALSE;
|
Eina_Bool has_warn_unused = EINA_FALSE;
|
||||||
for (;;) switch (ls->t.kw)
|
for (;;) switch (ls->t.kw)
|
||||||
{
|
{
|
||||||
case KW_at_warn_unused:
|
case KW_at_warn_unused:
|
||||||
|
@ -1006,11 +1012,6 @@ parse_return(Eo_Lexer *ls, Eo_Ret_Def *ret, Eina_Bool allow_void)
|
||||||
ret->warn_unused = EINA_TRUE;
|
ret->warn_unused = EINA_TRUE;
|
||||||
eo_lexer_get(ls);
|
eo_lexer_get(ls);
|
||||||
break;
|
break;
|
||||||
case KW_at_ref:
|
|
||||||
CASE_LOCK(ls, ref, "ref qualifier");
|
|
||||||
ret->is_ref = EINA_TRUE;
|
|
||||||
eo_lexer_get(ls);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
@ -1043,20 +1044,15 @@ parse_param(Eo_Lexer *ls, Eina_List **params, Eina_Bool allow_inout,
|
||||||
par->param_dir = EOLIAN_INOUT_PARAM;
|
par->param_dir = EOLIAN_INOUT_PARAM;
|
||||||
eo_lexer_get(ls);
|
eo_lexer_get(ls);
|
||||||
}
|
}
|
||||||
else if (ls->t.kw == KW_at_ref)
|
|
||||||
{
|
|
||||||
par->param_dir = EOLIAN_REF_PARAM;
|
|
||||||
eo_lexer_get(ls);
|
|
||||||
}
|
|
||||||
else par->param_dir = EOLIAN_IN_PARAM;
|
else par->param_dir = EOLIAN_IN_PARAM;
|
||||||
check(ls, TOK_VALUE);
|
check(ls, TOK_VALUE);
|
||||||
par->name = eina_stringshare_ref(ls->t.value.s);
|
par->name = eina_stringshare_ref(ls->t.value.s);
|
||||||
eo_lexer_get(ls);
|
eo_lexer_get(ls);
|
||||||
check_next(ls, ':');
|
check_next(ls, ':');
|
||||||
if (par->param_dir == EOLIAN_OUT_PARAM || par->param_dir == EOLIAN_INOUT_PARAM)
|
if (par->param_dir == EOLIAN_OUT_PARAM || par->param_dir == EOLIAN_INOUT_PARAM)
|
||||||
par->type = parse_type_void(ls);
|
par->type = parse_type_void(ls, EINA_TRUE);
|
||||||
else
|
else
|
||||||
par->type = parse_type(ls);
|
par->type = parse_type(ls, EINA_TRUE);
|
||||||
pop_type(ls);
|
pop_type(ls);
|
||||||
if ((is_vals || (par->param_dir == EOLIAN_OUT_PARAM)) && (ls->t.token == '('))
|
if ((is_vals || (par->param_dir == EOLIAN_OUT_PARAM)) && (ls->t.token == '('))
|
||||||
{
|
{
|
||||||
|
@ -1189,7 +1185,6 @@ parse_accessor(Eo_Lexer *ls, Eolian_Function *prop)
|
||||||
prop->get_return_doc = ret.doc;
|
prop->get_return_doc = ret.doc;
|
||||||
prop->get_ret_val = ret.default_ret_val;
|
prop->get_ret_val = ret.default_ret_val;
|
||||||
prop->get_return_warn_unused = ret.warn_unused;
|
prop->get_return_warn_unused = ret.warn_unused;
|
||||||
prop->get_return_is_ref = ret.is_ref;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1197,7 +1192,6 @@ parse_accessor(Eo_Lexer *ls, Eolian_Function *prop)
|
||||||
prop->set_return_doc = ret.doc;
|
prop->set_return_doc = ret.doc;
|
||||||
prop->set_ret_val = ret.default_ret_val;
|
prop->set_ret_val = ret.default_ret_val;
|
||||||
prop->set_return_warn_unused = ret.warn_unused;
|
prop->set_return_warn_unused = ret.warn_unused;
|
||||||
prop->set_return_is_ref = ret.is_ref;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case KW_legacy:
|
case KW_legacy:
|
||||||
|
@ -1404,7 +1398,6 @@ body:
|
||||||
meth->get_return_doc = ret.doc;
|
meth->get_return_doc = ret.doc;
|
||||||
meth->get_ret_val = ret.default_ret_val;
|
meth->get_ret_val = ret.default_ret_val;
|
||||||
meth->get_return_warn_unused = ret.warn_unused;
|
meth->get_return_warn_unused = ret.warn_unused;
|
||||||
meth->get_return_is_ref = ret.is_ref;
|
|
||||||
break;
|
break;
|
||||||
case KW_legacy:
|
case KW_legacy:
|
||||||
CASE_LOCK(ls, legacy, "legacy name")
|
CASE_LOCK(ls, legacy, "legacy name")
|
||||||
|
@ -1644,7 +1637,7 @@ end:
|
||||||
if (ls->t.token == ':')
|
if (ls->t.token == ':')
|
||||||
{
|
{
|
||||||
eo_lexer_get(ls);
|
eo_lexer_get(ls);
|
||||||
ev->type = parse_type(ls);
|
ev->type = parse_type(ls, EINA_TRUE);
|
||||||
pop_type(ls);
|
pop_type(ls);
|
||||||
}
|
}
|
||||||
check(ls, ';');
|
check(ls, ';');
|
||||||
|
|
|
@ -140,8 +140,6 @@ struct _Eolian_Function
|
||||||
Eina_Bool set_empty :1;
|
Eina_Bool set_empty :1;
|
||||||
Eina_Bool get_return_warn_unused :1; /* also used for methods */
|
Eina_Bool get_return_warn_unused :1; /* also used for methods */
|
||||||
Eina_Bool set_return_warn_unused :1;
|
Eina_Bool set_return_warn_unused :1;
|
||||||
Eina_Bool get_return_is_ref: 1;
|
|
||||||
Eina_Bool set_return_is_ref: 1;
|
|
||||||
Eina_Bool get_only_legacy: 1;
|
Eina_Bool get_only_legacy: 1;
|
||||||
Eina_Bool set_only_legacy: 1;
|
Eina_Bool set_only_legacy: 1;
|
||||||
Eina_Bool is_class :1;
|
Eina_Bool is_class :1;
|
||||||
|
@ -176,6 +174,7 @@ struct _Eolian_Type
|
||||||
Eina_Stringshare *freefunc;
|
Eina_Stringshare *freefunc;
|
||||||
Eina_Bool is_const :1;
|
Eina_Bool is_const :1;
|
||||||
Eina_Bool is_own :1;
|
Eina_Bool is_own :1;
|
||||||
|
Eina_Bool is_ref :1;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _Eolian_Typedecl
|
struct _Eolian_Typedecl
|
||||||
|
@ -234,7 +233,6 @@ struct _Eolian_Struct_Type_Field
|
||||||
Eolian_Object base;
|
Eolian_Object base;
|
||||||
Eolian_Type *type;
|
Eolian_Type *type;
|
||||||
Eolian_Documentation *doc;
|
Eolian_Documentation *doc;
|
||||||
Eina_Bool is_ref: 1;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _Eolian_Enum_Type_Field
|
struct _Eolian_Enum_Type_Field
|
||||||
|
@ -303,7 +301,7 @@ void database_enum_add(Eolian_Typedecl *tp);
|
||||||
void database_type_del(Eolian_Type *tp);
|
void database_type_del(Eolian_Type *tp);
|
||||||
void database_typedecl_del(Eolian_Typedecl *tp);
|
void database_typedecl_del(Eolian_Typedecl *tp);
|
||||||
|
|
||||||
void database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name, Eina_Bool is_ref);
|
void database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name);
|
||||||
void database_typedecl_to_str(const Eolian_Typedecl *tp, Eina_Strbuf *buf);
|
void database_typedecl_to_str(const Eolian_Typedecl *tp, Eina_Strbuf *buf);
|
||||||
|
|
||||||
/* expressions */
|
/* expressions */
|
||||||
|
|
|
@ -27,7 +27,7 @@ class Class_Simple {
|
||||||
@in a: int; [[a]]
|
@in a: int; [[a]]
|
||||||
@inout b: char;
|
@inout b: char;
|
||||||
@out c: double (1337.6);
|
@out c: double (1337.6);
|
||||||
@ref d: int;
|
@in d: ref(int);
|
||||||
}
|
}
|
||||||
return: char * (null); [[comment for method return]]
|
return: char * (null); [[comment for method return]]
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ class Class_Simple {
|
||||||
params {
|
params {
|
||||||
x: int;
|
x: int;
|
||||||
}
|
}
|
||||||
return: int @ref;
|
return: ref(int);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
struct Named {
|
struct Named {
|
||||||
@ref field: int;
|
field: ref(int);
|
||||||
something: string;
|
something: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -606,7 +606,7 @@ START_TEST(eolian_simple_parsing)
|
||||||
/* Method */
|
/* Method */
|
||||||
fail_if(!(fid = eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD)));
|
fail_if(!(fid = eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD)));
|
||||||
fail_if(!eolian_function_is_beta(fid));
|
fail_if(!eolian_function_is_beta(fid));
|
||||||
fail_if(eolian_function_return_is_ref(fid, EOLIAN_METHOD));
|
fail_if(eolian_type_is_ref(eolian_function_return_type_get(fid, EOLIAN_METHOD)));
|
||||||
/* Function return */
|
/* Function return */
|
||||||
tp = eolian_function_return_type_get(fid, EOLIAN_METHOD);
|
tp = eolian_function_return_type_get(fid, EOLIAN_METHOD);
|
||||||
fail_if(!tp);
|
fail_if(!tp);
|
||||||
|
@ -641,8 +641,9 @@ START_TEST(eolian_simple_parsing)
|
||||||
fail_if(v.type != EOLIAN_EXPR_DOUBLE);
|
fail_if(v.type != EOLIAN_EXPR_DOUBLE);
|
||||||
fail_if(v.value.d != 1337.6);
|
fail_if(v.value.d != 1337.6);
|
||||||
fail_if(!(eina_iterator_next(iter, (void**)¶m)));
|
fail_if(!(eina_iterator_next(iter, (void**)¶m)));
|
||||||
fail_if(eolian_parameter_direction_get(param) != EOLIAN_REF_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_name_get(eolian_parameter_type_get(param)), "int"));
|
||||||
|
fail_if(!eolian_type_is_ref(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));
|
||||||
eina_iterator_free(iter);
|
eina_iterator_free(iter);
|
||||||
|
@ -652,7 +653,7 @@ START_TEST(eolian_simple_parsing)
|
||||||
fail_if(!eolian_function_is_legacy_only(fid, EOLIAN_METHOD));
|
fail_if(!eolian_function_is_legacy_only(fid, EOLIAN_METHOD));
|
||||||
fail_if(!eolian_function_is_c_only(fid));
|
fail_if(!eolian_function_is_c_only(fid));
|
||||||
fail_if(eolian_function_is_beta(fid));
|
fail_if(eolian_function_is_beta(fid));
|
||||||
fail_if(!eolian_function_return_is_ref(fid, EOLIAN_METHOD));
|
fail_if(!eolian_type_is_ref(eolian_function_return_type_get(fid, EOLIAN_METHOD)));
|
||||||
|
|
||||||
eolian_shutdown();
|
eolian_shutdown();
|
||||||
}
|
}
|
||||||
|
@ -686,12 +687,12 @@ START_TEST(eolian_struct)
|
||||||
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(!eolian_typedecl_struct_field_is_ref(field));
|
fail_if(!eolian_type_is_ref(ftype));
|
||||||
fail_if(!(type_name = eolian_type_name_get(ftype)));
|
fail_if(!(type_name = eolian_type_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)));
|
||||||
fail_if(eolian_typedecl_struct_field_is_ref(field));
|
fail_if(eolian_type_is_ref(ftype));
|
||||||
fail_if(!(type_name = eolian_type_c_type_get(ftype)));
|
fail_if(!(type_name = eolian_type_c_type_get(ftype)));
|
||||||
fail_if(strcmp(type_name, "const char *"));
|
fail_if(strcmp(type_name, "const char *"));
|
||||||
eina_stringshare_del(type_name);
|
eina_stringshare_del(type_name);
|
||||||
|
|
Loading…
Reference in New Issue