eolian: refactor doc ref resolution API

This commit is contained in:
Daniel Kolesa 2018-03-14 16:51:11 +01:00
parent 425a447379
commit 2d0a25c995
8 changed files with 17 additions and 18 deletions

View File

@ -461,7 +461,7 @@ ffi.cdef [[
void eolian_doc_token_init(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);
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")
@ -1735,9 +1735,9 @@ M.Eolian_Doc_Token = ffi.metatype("Eolian_Doc_Token", {
return ret
end,
ref_get = function(self, unit)
ref_resolve = function(self, unit)
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
if tp == reft.CLASS then
return tp, ffi.cast("const Eolian_Class *", stor[0])

View File

@ -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
* 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] unit the unit to look in
* @param[out] data the primary data
* @param[out] data2 the secondary data
* @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

View File

@ -35,7 +35,7 @@ _validate_docstr(const Eolian_Unit *src, Eina_Stringshare *str, const Eolian_Obj
eolian_doc_token_init(&tok);
while (ret && (doc = eolian_documentation_tokenize(doc, &tok)))
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);
_eolian_log_line(info->file, info->line, info->column,

View File

@ -410,8 +410,8 @@ _resolve_event(const Eolian_Unit *src, char *name, const Eolian_Object **data,
}
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)
eolian_doc_token_ref_resolve(const Eolian_Doc_Token *tok, const Eolian_Unit *unit,
const Eolian_Object **data, const Eolian_Object **data2)
{
if (tok->type != EOLIAN_DOC_TOKEN_REF)
return EOLIAN_OBJECT_UNKNOWN;

View File

@ -670,8 +670,7 @@ M.Type = Node:clone {
end,
class_get = function(self)
-- FIXME: unit
return self._obj:class_get(eos:unit_get())
return self._obj:class_get()
end,
is_owned = function(self)
@ -1347,9 +1346,9 @@ M.DocTokenizer = util.Object:clone {
return self.tok:type_get()
end,
ref_get = function(self, root)
ref_resolve = function(self, root)
-- 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 ret = {}
if tp == reft.CLASS or tp == reft.FUNC or tp == reft.EVENT then

View File

@ -345,7 +345,7 @@ writers["dokuwiki"] = util.Object:clone {
hasraw = true
end
if tp == tokp.REF then
local reft = tokp:ref_get(true)
local reft = tokp:ref_resolve(true)
local str = tokp:text_get()
if str:sub(1, 1) == "[" then
str = str:sub(2, #str - 1)

View File

@ -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.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);
# lib.eolian_doc_token_ref_get.argtypes = [c_void_p, c_void_p, ???, ???]
# lib.eolian_doc_token_ref_get.restype = c_int
# 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_resolve.argtypes = [c_void_p, c_void_p, ???, ???]
# lib.eolian_doc_token_ref_resolve.restype = c_int

View File

@ -1256,7 +1256,7 @@ START_TEST(eolian_docs)
fail_if(eolian_doc_token_type_get(&tok) != EOLIAN_DOC_TOKEN_REF);
txt = eolian_doc_token_text_get(&tok);
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);
tdoc = eolian_documentation_tokenize(tdoc, &tok);
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);
txt = eolian_doc_token_text_get(&tok);
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);
tdoc = eolian_documentation_tokenize(tdoc, &tok);
fail_if(eolian_doc_token_type_get(&tok) != EOLIAN_DOC_TOKEN_TEXT);