forked from enlightenment/efl
eolian: move base function doc API into implements
This allows us to unify retrieval of docs for both regular and overridden funcs without having two separate APIs. It's currently missing validation and docgen is still not adjusted properly for it either, but at least there's this. Enables retrieval of docs for overridden funcs by default as well.
This commit is contained in:
parent
67bbb685d4
commit
95181f2d36
|
@ -417,15 +417,17 @@ eo_gen_docs_func_gen(const Eolian_Function *fid, Eolian_Function_Type ftype,
|
||||||
|
|
||||||
const char *group = eolian_class_full_name_get(eolian_function_class_get(fid));
|
const char *group = eolian_class_full_name_get(eolian_function_class_get(fid));
|
||||||
|
|
||||||
|
const Eolian_Implement *fimp = eolian_function_implement_get(fid);
|
||||||
|
|
||||||
if (ftype == EOLIAN_METHOD)
|
if (ftype == EOLIAN_METHOD)
|
||||||
{
|
{
|
||||||
doc = eolian_function_documentation_get(fid, EOLIAN_METHOD);
|
doc = eolian_implement_documentation_get(fimp, EOLIAN_METHOD);
|
||||||
pdoc = NULL;
|
pdoc = NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
doc = eolian_function_documentation_get(fid, EOLIAN_PROPERTY);
|
doc = eolian_implement_documentation_get(fimp, EOLIAN_PROPERTY);
|
||||||
pdoc = eolian_function_documentation_get(fid, ftype);
|
pdoc = eolian_implement_documentation_get(fimp, ftype);
|
||||||
if (!doc && pdoc) doc = pdoc;
|
if (!doc && pdoc) doc = pdoc;
|
||||||
if (pdoc == doc) pdoc = NULL;
|
if (pdoc == doc) pdoc = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,9 +42,11 @@ _gen_func(const Eolian_Function *fid, Eolian_Function_Type ftype,
|
||||||
if (!legacy && (fsc == EOLIAN_SCOPE_PROTECTED))
|
if (!legacy && (fsc == EOLIAN_SCOPE_PROTECTED))
|
||||||
eina_strbuf_append_printf(buf, "#ifdef %s_PROTECTED\n", cnameu);
|
eina_strbuf_append_printf(buf, "#ifdef %s_PROTECTED\n", cnameu);
|
||||||
|
|
||||||
Eina_Bool hasdoc = !!eolian_function_documentation_get(fid, ftype);
|
const Eolian_Implement *fimp = eolian_function_implement_get(fid);
|
||||||
|
|
||||||
|
Eina_Bool hasdoc = !!eolian_implement_documentation_get(fimp, ftype);
|
||||||
if (!hasdoc && ((ftype == EOLIAN_PROP_GET) || (ftype == EOLIAN_PROP_SET)))
|
if (!hasdoc && ((ftype == EOLIAN_PROP_GET) || (ftype == EOLIAN_PROP_SET)))
|
||||||
hasdoc = !!eolian_function_documentation_get(fid, EOLIAN_PROPERTY);
|
hasdoc = !!eolian_implement_documentation_get(fimp, EOLIAN_PROPERTY);
|
||||||
if (hasdoc)
|
if (hasdoc)
|
||||||
{
|
{
|
||||||
Eina_Strbuf *dbuf = eo_gen_docs_func_gen(fid, ftype, 0, legacy);
|
Eina_Strbuf *dbuf = eo_gen_docs_func_gen(fid, ftype, 0, legacy);
|
||||||
|
|
|
@ -249,7 +249,6 @@ ffi.cdef [[
|
||||||
const char *eolian_function_full_c_name_get(const Eolian_Function *function_id, Eolian_Function_Type ftype, Eina_Bool use_legacy);
|
const char *eolian_function_full_c_name_get(const Eolian_Function *function_id, Eolian_Function_Type ftype, Eina_Bool use_legacy);
|
||||||
const Eolian_Function *eolian_class_function_get_by_name(const Eolian_Class *klass, const char *func_name, Eolian_Function_Type f_type);
|
const Eolian_Function *eolian_class_function_get_by_name(const Eolian_Class *klass, const char *func_name, Eolian_Function_Type f_type);
|
||||||
const char *eolian_function_legacy_get(const Eolian_Function *function_id, Eolian_Function_Type f_type);
|
const char *eolian_function_legacy_get(const Eolian_Function *function_id, Eolian_Function_Type f_type);
|
||||||
const Eolian_Documentation *eolian_function_documentation_get(const Eolian_Function *function_id, Eolian_Function_Type f_type);
|
|
||||||
const Eolian_Implement *eolian_function_implement_get(const Eolian_Function *function_id);
|
const Eolian_Implement *eolian_function_implement_get(const Eolian_Function *function_id);
|
||||||
Eina_Bool eolian_function_is_legacy_only(const Eolian_Function *function_id, Eolian_Function_Type ftype);
|
Eina_Bool eolian_function_is_legacy_only(const Eolian_Function *function_id, Eolian_Function_Type ftype);
|
||||||
Eina_Bool eolian_function_is_class(const Eolian_Function *function_id);
|
Eina_Bool eolian_function_is_class(const Eolian_Function *function_id);
|
||||||
|
@ -273,6 +272,7 @@ ffi.cdef [[
|
||||||
const char *eolian_implement_full_name_get(const Eolian_Implement *impl);
|
const char *eolian_implement_full_name_get(const Eolian_Implement *impl);
|
||||||
const Eolian_Class *eolian_implement_class_get(const Eolian_Implement *impl);
|
const Eolian_Class *eolian_implement_class_get(const Eolian_Implement *impl);
|
||||||
const Eolian_Function *eolian_implement_function_get(const Eolian_Implement *impl, Eolian_Function_Type *func_type);
|
const Eolian_Function *eolian_implement_function_get(const Eolian_Implement *impl, Eolian_Function_Type *func_type);
|
||||||
|
const Eolian_Documentation *eolian_implement_documentation_get(const Eolian_Implement *impl, Eolian_Function_Type f_type);
|
||||||
Eina_Bool eolian_implement_is_auto(const Eolian_Implement *impl, Eolian_Function_Type ftype);
|
Eina_Bool eolian_implement_is_auto(const Eolian_Implement *impl, Eolian_Function_Type ftype);
|
||||||
Eina_Bool eolian_implement_is_empty(const Eolian_Implement *impl, Eolian_Function_Type ftype);
|
Eina_Bool eolian_implement_is_empty(const Eolian_Implement *impl, Eolian_Function_Type ftype);
|
||||||
Eina_Bool eolian_implement_is_pure_virtual(const Eolian_Implement *impl, Eolian_Function_Type ftype);
|
Eina_Bool eolian_implement_is_pure_virtual(const Eolian_Implement *impl, Eolian_Function_Type ftype);
|
||||||
|
@ -775,12 +775,6 @@ M.Function = ffi.metatype("Eolian_Function", {
|
||||||
return ffi.string(v)
|
return ffi.string(v)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
documentation_get = function(self, ftype)
|
|
||||||
local v = eolian.eolian_function_documentation_get(self, ftype)
|
|
||||||
if v == nil then return nil end
|
|
||||||
return v
|
|
||||||
end,
|
|
||||||
|
|
||||||
implement_get = function(self)
|
implement_get = function(self)
|
||||||
local v = eolian.eolian_function_implement_get(self)
|
local v = eolian.eolian_function_implement_get(self)
|
||||||
if v == nil then return nil end
|
if v == nil then return nil end
|
||||||
|
@ -915,6 +909,12 @@ ffi.metatype("Eolian_Implement", {
|
||||||
return v, tp[0]
|
return v, tp[0]
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
documentation_get = function(self, ftype)
|
||||||
|
local v = eolian.eolian_implement_documentation_get(self, ftype)
|
||||||
|
if v == nil then return nil end
|
||||||
|
return v
|
||||||
|
end,
|
||||||
|
|
||||||
is_auto = function(self, ftype)
|
is_auto = function(self, ftype)
|
||||||
return eolian.eolian_implement_is_auto(self, ftype) ~= 0
|
return eolian.eolian_implement_is_auto(self, ftype) ~= 0
|
||||||
end,
|
end,
|
||||||
|
|
|
@ -747,19 +747,6 @@ EAPI const Eolian_Function *eolian_class_function_get_by_name(const Eolian_Class
|
||||||
*/
|
*/
|
||||||
EAPI Eina_Stringshare *eolian_function_legacy_get(const Eolian_Function *function_id, Eolian_Function_Type f_type);
|
EAPI Eina_Stringshare *eolian_function_legacy_get(const Eolian_Function *function_id, Eolian_Function_Type f_type);
|
||||||
|
|
||||||
/*
|
|
||||||
* @brief Returns a documentation for a function.
|
|
||||||
*
|
|
||||||
* @param[in] function_id Id of the function
|
|
||||||
* @param[in] f_type The function type, for property get/set distinction.
|
|
||||||
* @return the documentation or NULL.
|
|
||||||
*
|
|
||||||
* Acceptable input types are METHOD, PROP_GET and PROP_SET.
|
|
||||||
*
|
|
||||||
* @ingroup Eolian
|
|
||||||
*/
|
|
||||||
EAPI const Eolian_Documentation *eolian_function_documentation_get(const Eolian_Function *function_id, Eolian_Function_Type f_type);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @brief Returns the implement for a function.
|
* @brief Returns the implement for a function.
|
||||||
*
|
*
|
||||||
|
@ -1057,6 +1044,19 @@ EAPI const Eolian_Class *eolian_implement_class_get(const Eolian_Implement *impl
|
||||||
*/
|
*/
|
||||||
EAPI const Eolian_Function *eolian_implement_function_get(const Eolian_Implement *impl, Eolian_Function_Type *func_type);
|
EAPI const Eolian_Function *eolian_implement_function_get(const Eolian_Implement *impl, Eolian_Function_Type *func_type);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief Returns a documentation for an implement.
|
||||||
|
*
|
||||||
|
* @param[in] impl the handle of the implement
|
||||||
|
* @param[in] f_type The function type, for property get/set distinction.
|
||||||
|
* @return the documentation or NULL.
|
||||||
|
*
|
||||||
|
* Acceptable input types are METHOD, PROP_GET and PROP_SET.
|
||||||
|
*
|
||||||
|
* @ingroup Eolian
|
||||||
|
*/
|
||||||
|
EAPI const Eolian_Documentation *eolian_implement_documentation_get(const Eolian_Implement *impl, Eolian_Function_Type f_type);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @brief Get whether an implement is tagged with @auto.
|
* @brief Get whether an implement is tagged with @auto.
|
||||||
*
|
*
|
||||||
|
|
|
@ -27,9 +27,6 @@ database_function_del(Eolian_Function *fid)
|
||||||
database_expr_del(fid->set_ret_val);
|
database_expr_del(fid->set_ret_val);
|
||||||
if (fid->get_legacy) eina_stringshare_del(fid->get_legacy);
|
if (fid->get_legacy) eina_stringshare_del(fid->get_legacy);
|
||||||
if (fid->set_legacy) eina_stringshare_del(fid->set_legacy);
|
if (fid->set_legacy) eina_stringshare_del(fid->set_legacy);
|
||||||
database_doc_del(fid->common_doc);
|
|
||||||
database_doc_del(fid->get_doc);
|
|
||||||
database_doc_del(fid->set_doc);
|
|
||||||
database_doc_del(fid->get_return_doc);
|
database_doc_del(fid->get_return_doc);
|
||||||
database_doc_del(fid->set_return_doc);
|
database_doc_del(fid->set_return_doc);
|
||||||
free(fid);
|
free(fid);
|
||||||
|
|
|
@ -184,18 +184,6 @@ eolian_function_legacy_get(const Eolian_Function *fid, Eolian_Function_Type ftyp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI const Eolian_Documentation *
|
|
||||||
eolian_function_documentation_get(const Eolian_Function *fid, Eolian_Function_Type ftype)
|
|
||||||
{
|
|
||||||
EINA_SAFETY_ON_NULL_RETURN_VAL(fid, NULL);
|
|
||||||
switch (ftype)
|
|
||||||
{
|
|
||||||
case EOLIAN_PROP_GET: return fid->get_doc; break;
|
|
||||||
case EOLIAN_PROP_SET: return fid->set_doc; break;
|
|
||||||
default: return fid->common_doc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
EAPI const Eolian_Implement *
|
EAPI const Eolian_Implement *
|
||||||
eolian_function_implement_get(const Eolian_Function *fid)
|
eolian_function_implement_get(const Eolian_Function *fid)
|
||||||
{
|
{
|
||||||
|
|
|
@ -43,6 +43,19 @@ eolian_implement_function_get(const Eolian_Implement *impl,
|
||||||
return impl->foo_id;
|
return impl->foo_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EAPI const Eolian_Documentation *
|
||||||
|
eolian_implement_documentation_get(const Eolian_Implement *impl,
|
||||||
|
Eolian_Function_Type ftype)
|
||||||
|
{
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(impl, NULL);
|
||||||
|
switch (ftype)
|
||||||
|
{
|
||||||
|
case EOLIAN_PROP_GET: return impl->get_doc; break;
|
||||||
|
case EOLIAN_PROP_SET: return impl->set_doc; break;
|
||||||
|
default: return impl->common_doc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
EAPI Eina_Bool
|
EAPI Eina_Bool
|
||||||
eolian_implement_is_auto(const Eolian_Implement *impl, Eolian_Function_Type ftype)
|
eolian_implement_is_auto(const Eolian_Implement *impl, Eolian_Function_Type ftype)
|
||||||
{
|
{
|
||||||
|
|
|
@ -227,11 +227,12 @@ _validate_function(const Eolian_Function *func)
|
||||||
|
|
||||||
#undef EOLIAN_PARAMS_VALIDATE
|
#undef EOLIAN_PARAMS_VALIDATE
|
||||||
|
|
||||||
if (!_validate_doc(func->common_doc))
|
/* TODO: validate docs via impls to also validate overrides */
|
||||||
|
if (!_validate_doc(func->impl->common_doc))
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
if (!_validate_doc(func->get_doc))
|
if (!_validate_doc(func->impl->get_doc))
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
if (!_validate_doc(func->set_doc))
|
if (!_validate_doc(func->impl->set_doc))
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
if (!_validate_doc(func->get_return_doc))
|
if (!_validate_doc(func->get_return_doc))
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
|
|
|
@ -1208,7 +1208,7 @@ parse_accessor:
|
||||||
line = ls->line_number;
|
line = ls->line_number;
|
||||||
col = ls->column;
|
col = ls->column;
|
||||||
check_next(ls, '{');
|
check_next(ls, '{');
|
||||||
if ((ls->t.token == TOK_DOC) && !prop->common_doc)
|
if ((ls->t.token == TOK_DOC) && !prop->impl->common_doc)
|
||||||
{
|
{
|
||||||
if (getenv("EOLIAN_PROPERTY_DOC_WARN"))
|
if (getenv("EOLIAN_PROPERTY_DOC_WARN"))
|
||||||
{
|
{
|
||||||
|
@ -1220,11 +1220,11 @@ parse_accessor:
|
||||||
}
|
}
|
||||||
if (is_get)
|
if (is_get)
|
||||||
{
|
{
|
||||||
FILL_DOC(ls, prop, get_doc);
|
FILL_DOC(ls, prop->impl, get_doc);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FILL_DOC(ls, prop, set_doc);
|
FILL_DOC(ls, prop->impl, set_doc);
|
||||||
}
|
}
|
||||||
for (;;) switch (ls->t.kw)
|
for (;;) switch (ls->t.kw)
|
||||||
{
|
{
|
||||||
|
@ -1369,7 +1369,7 @@ body:
|
||||||
line = ls->line_number;
|
line = ls->line_number;
|
||||||
col = ls->column;
|
col = ls->column;
|
||||||
check_next(ls, '{');
|
check_next(ls, '{');
|
||||||
FILL_DOC(ls, prop, common_doc);
|
FILL_DOC(ls, prop->impl, common_doc);
|
||||||
for (;;) switch (ls->t.kw)
|
for (;;) switch (ls->t.kw)
|
||||||
{
|
{
|
||||||
case KW_get:
|
case KW_get:
|
||||||
|
@ -1473,7 +1473,7 @@ body:
|
||||||
line = ls->line_number;
|
line = ls->line_number;
|
||||||
col = ls->column;
|
col = ls->column;
|
||||||
check_next(ls, '{');
|
check_next(ls, '{');
|
||||||
FILL_DOC(ls, meth, common_doc);
|
FILL_DOC(ls, meth->impl, common_doc);
|
||||||
for (;;) switch (ls->t.kw)
|
for (;;) switch (ls->t.kw)
|
||||||
{
|
{
|
||||||
case KW_return:
|
case KW_return:
|
||||||
|
|
|
@ -126,9 +126,6 @@ struct _Eolian_Function
|
||||||
Eolian_Implement *impl;
|
Eolian_Implement *impl;
|
||||||
Eina_Stringshare *get_legacy;
|
Eina_Stringshare *get_legacy;
|
||||||
Eina_Stringshare *set_legacy;
|
Eina_Stringshare *set_legacy;
|
||||||
Eolian_Documentation *common_doc;
|
|
||||||
Eolian_Documentation *get_doc;
|
|
||||||
Eolian_Documentation *set_doc;
|
|
||||||
Eolian_Documentation *get_return_doc;
|
Eolian_Documentation *get_return_doc;
|
||||||
Eolian_Documentation *set_return_doc;
|
Eolian_Documentation *set_return_doc;
|
||||||
Eina_Bool obj_is_const :1; /* True if the object has to be const. Useful for a few methods. */
|
Eina_Bool obj_is_const :1; /* True if the object has to be const. Useful for a few methods. */
|
||||||
|
|
|
@ -305,7 +305,8 @@ M.Function = Node:clone {
|
||||||
end,
|
end,
|
||||||
|
|
||||||
doc_get = function(self, ft)
|
doc_get = function(self, ft)
|
||||||
return M.Doc(self.func:documentation_get(ft))
|
-- TODO: handle overridden docs sanely
|
||||||
|
return M.Doc(self.func:implement_get():documentation_get(ft))
|
||||||
end,
|
end,
|
||||||
|
|
||||||
fallback_doc_get = function(self, ft)
|
fallback_doc_get = function(self, ft)
|
||||||
|
|
|
@ -1300,7 +1300,8 @@ START_TEST(eolian_docs)
|
||||||
"@Docs.prop.get @Docs.prop.set @Foo.field1 @Bar.foo @Docs"));
|
"@Docs.prop.get @Docs.prop.set @Foo.field1 @Bar.foo @Docs"));
|
||||||
|
|
||||||
fail_if(!(fid = eolian_class_function_get_by_name(class, "meth", EOLIAN_METHOD)));
|
fail_if(!(fid = eolian_class_function_get_by_name(class, "meth", EOLIAN_METHOD)));
|
||||||
fail_if(!(doc = eolian_function_documentation_get(fid, EOLIAN_METHOD)));
|
const Eolian_Implement *fimp = eolian_function_implement_get(fid);
|
||||||
|
fail_if(!(doc = eolian_implement_documentation_get(fimp, EOLIAN_METHOD)));
|
||||||
fail_if(strcmp(eolian_documentation_summary_get(doc),
|
fail_if(strcmp(eolian_documentation_summary_get(doc),
|
||||||
"Method documentation."));
|
"Method documentation."));
|
||||||
fail_if(eolian_documentation_description_get(doc));
|
fail_if(eolian_documentation_description_get(doc));
|
||||||
|
@ -1331,17 +1332,18 @@ START_TEST(eolian_docs)
|
||||||
fail_if(eolian_documentation_description_get(doc));
|
fail_if(eolian_documentation_description_get(doc));
|
||||||
|
|
||||||
fail_if(!(fid = eolian_class_function_get_by_name(class, "prop", EOLIAN_PROPERTY)));
|
fail_if(!(fid = eolian_class_function_get_by_name(class, "prop", EOLIAN_PROPERTY)));
|
||||||
fail_if(!(doc = eolian_function_documentation_get(fid, EOLIAN_PROPERTY)));
|
fimp = eolian_function_implement_get(fid);
|
||||||
|
fail_if(!(doc = eolian_implement_documentation_get(fimp, EOLIAN_PROPERTY)));
|
||||||
fail_if(strcmp(eolian_documentation_summary_get(doc),
|
fail_if(strcmp(eolian_documentation_summary_get(doc),
|
||||||
"Property common documentation."));
|
"Property common documentation."));
|
||||||
fail_if(eolian_documentation_description_get(doc));
|
fail_if(eolian_documentation_description_get(doc));
|
||||||
fail_if(strcmp(eolian_documentation_since_get(doc),
|
fail_if(strcmp(eolian_documentation_since_get(doc),
|
||||||
"1.18"));
|
"1.18"));
|
||||||
fail_if(!(doc = eolian_function_documentation_get(fid, EOLIAN_PROP_GET)));
|
fail_if(!(doc = eolian_implement_documentation_get(fimp, EOLIAN_PROP_GET)));
|
||||||
fail_if(strcmp(eolian_documentation_summary_get(doc),
|
fail_if(strcmp(eolian_documentation_summary_get(doc),
|
||||||
"Get documentation."));
|
"Get documentation."));
|
||||||
fail_if(eolian_documentation_description_get(doc));
|
fail_if(eolian_documentation_description_get(doc));
|
||||||
fail_if(!(doc = eolian_function_documentation_get(fid, EOLIAN_PROP_SET)));
|
fail_if(!(doc = eolian_implement_documentation_get(fimp, EOLIAN_PROP_SET)));
|
||||||
fail_if(strcmp(eolian_documentation_summary_get(doc),
|
fail_if(strcmp(eolian_documentation_summary_get(doc),
|
||||||
"Set documentation."));
|
"Set documentation."));
|
||||||
fail_if(eolian_documentation_description_get(doc));
|
fail_if(eolian_documentation_description_get(doc));
|
||||||
|
|
Loading…
Reference in New Issue