forked from enlightenment/efl
eolian: refactor doc ref resolution API
This commit is contained in:
parent
425a447379
commit
2d0a25c995
|
@ -461,7 +461,7 @@ ffi.cdef [[
|
||||||
void eolian_doc_token_init(Eolian_Doc_Token *tok);
|
void eolian_doc_token_init(Eolian_Doc_Token *tok);
|
||||||
Eolian_Doc_Token_Type eolian_doc_token_type_get(const Eolian_Doc_Token *tok);
|
Eolian_Doc_Token_Type eolian_doc_token_type_get(const Eolian_Doc_Token *tok);
|
||||||
char *eolian_doc_token_text_get(const Eolian_Doc_Token *tok);
|
char *eolian_doc_token_text_get(const Eolian_Doc_Token *tok);
|
||||||
Eolian_Object_Type eolian_doc_token_ref_get(const Eolian_Unit *unit, const Eolian_Doc_Token *tok, const Eolian_Object **data, const Eolian_Object **data2);
|
Eolian_Object_Type eolian_doc_token_ref_resolve(const Eolian_Doc_Token *tok, const Eolian_Unit *unit, const Eolian_Object **data, const Eolian_Object **data2);
|
||||||
]]
|
]]
|
||||||
|
|
||||||
local cutil = require("cutil")
|
local cutil = require("cutil")
|
||||||
|
@ -1735,9 +1735,9 @@ M.Eolian_Doc_Token = ffi.metatype("Eolian_Doc_Token", {
|
||||||
return ret
|
return ret
|
||||||
end,
|
end,
|
||||||
|
|
||||||
ref_get = function(self, unit)
|
ref_resolve = function(self, unit)
|
||||||
local stor = ffi.new("const Eolian_Object *[2]")
|
local stor = ffi.new("const Eolian_Object *[2]")
|
||||||
local tp = tonumber(eolian.eolian_doc_token_ref_get(unit, self, stor, stor + 1))
|
local tp = tonumber(eolian.eolian_doc_token_ref_resolve(self, unit, stor, stor + 1))
|
||||||
local reft = M.object_type
|
local reft = M.object_type
|
||||||
if tp == reft.CLASS then
|
if tp == reft.CLASS then
|
||||||
return tp, ffi.cast("const Eolian_Class *", stor[0])
|
return tp, ffi.cast("const Eolian_Class *", stor[0])
|
||||||
|
|
|
@ -2866,13 +2866,13 @@ EAPI char *eolian_doc_token_text_get(const Eolian_Doc_Token *tok);
|
||||||
* and the second data is the event, when it's a struct field or enum field
|
* and the second data is the event, when it's a struct field or enum field
|
||||||
* the first data is is the struct/enum and the second data is the field.
|
* the first data is is the struct/enum and the second data is the field.
|
||||||
*
|
*
|
||||||
* @param[in] unit the unit to look in
|
|
||||||
* @param[in] tok the token
|
* @param[in] tok the token
|
||||||
|
* @param[in] unit the unit to look in
|
||||||
* @param[out] data the primary data
|
* @param[out] data the primary data
|
||||||
* @param[out] data2 the secondary data
|
* @param[out] data2 the secondary data
|
||||||
* @return the kind of reference this is
|
* @return the kind of reference this is
|
||||||
*/
|
*/
|
||||||
EAPI Eolian_Object_Type eolian_doc_token_ref_get(const Eolian_Unit *unit, const Eolian_Doc_Token *tok, const Eolian_Object **data, const Eolian_Object **data2);
|
EAPI Eolian_Object_Type eolian_doc_token_ref_resolve(const Eolian_Doc_Token *tok, const Eolian_Unit *unit, const Eolian_Object **data, const Eolian_Object **data2);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ _validate_docstr(const Eolian_Unit *src, Eina_Stringshare *str, const Eolian_Obj
|
||||||
eolian_doc_token_init(&tok);
|
eolian_doc_token_init(&tok);
|
||||||
while (ret && (doc = eolian_documentation_tokenize(doc, &tok)))
|
while (ret && (doc = eolian_documentation_tokenize(doc, &tok)))
|
||||||
if (eolian_doc_token_type_get(&tok) == EOLIAN_DOC_TOKEN_REF)
|
if (eolian_doc_token_type_get(&tok) == EOLIAN_DOC_TOKEN_REF)
|
||||||
if (eolian_doc_token_ref_get(src, &tok, NULL, NULL) == EOLIAN_OBJECT_UNKNOWN)
|
if (eolian_doc_token_ref_resolve(&tok, src, NULL, NULL) == EOLIAN_OBJECT_UNKNOWN)
|
||||||
{
|
{
|
||||||
char *refn = eolian_doc_token_text_get(&tok);
|
char *refn = eolian_doc_token_text_get(&tok);
|
||||||
_eolian_log_line(info->file, info->line, info->column,
|
_eolian_log_line(info->file, info->line, info->column,
|
||||||
|
|
|
@ -410,8 +410,8 @@ _resolve_event(const Eolian_Unit *src, char *name, const Eolian_Object **data,
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI Eolian_Object_Type
|
EAPI Eolian_Object_Type
|
||||||
eolian_doc_token_ref_get(const Eolian_Unit *unit, const Eolian_Doc_Token *tok,
|
eolian_doc_token_ref_resolve(const Eolian_Doc_Token *tok, const Eolian_Unit *unit,
|
||||||
const Eolian_Object **data, const Eolian_Object **data2)
|
const Eolian_Object **data, const Eolian_Object **data2)
|
||||||
{
|
{
|
||||||
if (tok->type != EOLIAN_DOC_TOKEN_REF)
|
if (tok->type != EOLIAN_DOC_TOKEN_REF)
|
||||||
return EOLIAN_OBJECT_UNKNOWN;
|
return EOLIAN_OBJECT_UNKNOWN;
|
||||||
|
|
|
@ -670,8 +670,7 @@ M.Type = Node:clone {
|
||||||
end,
|
end,
|
||||||
|
|
||||||
class_get = function(self)
|
class_get = function(self)
|
||||||
-- FIXME: unit
|
return self._obj:class_get()
|
||||||
return self._obj:class_get(eos:unit_get())
|
|
||||||
end,
|
end,
|
||||||
|
|
||||||
is_owned = function(self)
|
is_owned = function(self)
|
||||||
|
@ -1347,9 +1346,9 @@ M.DocTokenizer = util.Object:clone {
|
||||||
return self.tok:type_get()
|
return self.tok:type_get()
|
||||||
end,
|
end,
|
||||||
|
|
||||||
ref_get = function(self, root)
|
ref_resolve = function(self, root)
|
||||||
-- FIXME: unit
|
-- FIXME: unit
|
||||||
local tp, d1, d2 = self.tok:ref_get(eos:unit_get())
|
local tp, d1, d2 = self.tok:ref_resolve(eos:unit_get())
|
||||||
local reft = eolian.doc_ref_type
|
local reft = eolian.doc_ref_type
|
||||||
local ret = {}
|
local ret = {}
|
||||||
if tp == reft.CLASS or tp == reft.FUNC or tp == reft.EVENT then
|
if tp == reft.CLASS or tp == reft.FUNC or tp == reft.EVENT then
|
||||||
|
|
|
@ -345,7 +345,7 @@ writers["dokuwiki"] = util.Object:clone {
|
||||||
hasraw = true
|
hasraw = true
|
||||||
end
|
end
|
||||||
if tp == tokp.REF then
|
if tp == tokp.REF then
|
||||||
local reft = tokp:ref_get(true)
|
local reft = tokp:ref_resolve(true)
|
||||||
local str = tokp:text_get()
|
local str = tokp:text_get()
|
||||||
if str:sub(1, 1) == "[" then
|
if str:sub(1, 1) == "[" then
|
||||||
str = str:sub(2, #str - 1)
|
str = str:sub(2, #str - 1)
|
||||||
|
|
|
@ -759,7 +759,7 @@ lib.eolian_doc_token_type_get.restype = c_int
|
||||||
lib.eolian_doc_token_text_get.argtypes = [c_void_p,]
|
lib.eolian_doc_token_text_get.argtypes = [c_void_p,]
|
||||||
lib.eolian_doc_token_text_get.restype = c_void_p # char* TO BE FREED
|
lib.eolian_doc_token_text_get.restype = c_void_p # char* TO BE FREED
|
||||||
|
|
||||||
# EAPI Eolian_Object_Type eolian_doc_token_ref_get(const Eolian_Unit *unit, const Eolian_Doc_Token *tok, const Eolian_Object **data, const Eolian_Object **data2);
|
# EAPI Eolian_Object_Type eolian_doc_token_ref_resolve(const Eolian_Doc_Token *tok, const Eolian_Unit *unit, const Eolian_Object **data, const Eolian_Object **data2);
|
||||||
# lib.eolian_doc_token_ref_get.argtypes = [c_void_p, c_void_p, ???, ???]
|
# lib.eolian_doc_token_ref_resolve.argtypes = [c_void_p, c_void_p, ???, ???]
|
||||||
# lib.eolian_doc_token_ref_get.restype = c_int
|
# lib.eolian_doc_token_ref_resolve.restype = c_int
|
||||||
|
|
||||||
|
|
|
@ -1256,7 +1256,7 @@ START_TEST(eolian_docs)
|
||||||
fail_if(eolian_doc_token_type_get(&tok) != EOLIAN_DOC_TOKEN_REF);
|
fail_if(eolian_doc_token_type_get(&tok) != EOLIAN_DOC_TOKEN_REF);
|
||||||
txt = eolian_doc_token_text_get(&tok);
|
txt = eolian_doc_token_text_get(&tok);
|
||||||
fail_if(strcmp(txt, "pants"));
|
fail_if(strcmp(txt, "pants"));
|
||||||
fail_if(eolian_doc_token_ref_get(unit, &tok, NULL, NULL) != EOLIAN_OBJECT_VARIABLE);
|
fail_if(eolian_doc_token_ref_resolve(&tok, unit, NULL, NULL) != EOLIAN_OBJECT_VARIABLE);
|
||||||
free(txt);
|
free(txt);
|
||||||
tdoc = eolian_documentation_tokenize(tdoc, &tok);
|
tdoc = eolian_documentation_tokenize(tdoc, &tok);
|
||||||
fail_if(eolian_doc_token_type_get(&tok) != EOLIAN_DOC_TOKEN_TEXT);
|
fail_if(eolian_doc_token_type_get(&tok) != EOLIAN_DOC_TOKEN_TEXT);
|
||||||
|
@ -1267,7 +1267,7 @@ START_TEST(eolian_docs)
|
||||||
fail_if(eolian_doc_token_type_get(&tok) != EOLIAN_DOC_TOKEN_REF);
|
fail_if(eolian_doc_token_type_get(&tok) != EOLIAN_DOC_TOKEN_REF);
|
||||||
txt = eolian_doc_token_text_get(&tok);
|
txt = eolian_doc_token_text_get(&tok);
|
||||||
fail_if(strcmp(txt, "Docs.meth"));
|
fail_if(strcmp(txt, "Docs.meth"));
|
||||||
fail_if(eolian_doc_token_ref_get(unit, &tok, NULL, NULL) != EOLIAN_OBJECT_FUNCTION);
|
fail_if(eolian_doc_token_ref_resolve(&tok, unit, NULL, NULL) != EOLIAN_OBJECT_FUNCTION);
|
||||||
free(txt);
|
free(txt);
|
||||||
tdoc = eolian_documentation_tokenize(tdoc, &tok);
|
tdoc = eolian_documentation_tokenize(tdoc, &tok);
|
||||||
fail_if(eolian_doc_token_type_get(&tok) != EOLIAN_DOC_TOKEN_TEXT);
|
fail_if(eolian_doc_token_type_get(&tok) != EOLIAN_DOC_TOKEN_TEXT);
|
||||||
|
|
Loading…
Reference in New Issue