This needs only one enum and allows for better interop.
EOLIAN_DOC_TOKEN_MARKUP_MONOSPACE
} Eolian_Doc_Token_Type;
- typedef enum {
- EOLIAN_DOC_REF_INVALID = 0,
- EOLIAN_DOC_REF_CLASS,
- EOLIAN_DOC_REF_FUNC,
- EOLIAN_DOC_REF_EVENT,
- EOLIAN_DOC_REF_ALIAS,
- EOLIAN_DOC_REF_STRUCT,
- EOLIAN_DOC_REF_STRUCT_FIELD,
- EOLIAN_DOC_REF_ENUM,
- EOLIAN_DOC_REF_ENUM_FIELD,
- EOLIAN_DOC_REF_VAR
- } Eolian_Doc_Ref_Type;
-
typedef struct _Eolian_Doc_Token {
Eolian_Doc_Token_Type type;
const char *text, *text_end;
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_Doc_Ref_Type eolian_doc_token_ref_get(const Eolian_Unit *unit, const Eolian_Doc_Token *tok, const void **data, const void **data2);
+ Eolian_Object_Type eolian_doc_token_ref_get(const Eolian_Unit *unit, const Eolian_Doc_Token *tok, const void **data, const void **data2);
]]
local cutil = require("cutil")
MARKUP_MONOSPACE = 7
}
-M.doc_ref_type = {
- INVALID = 0,
- CLASS = 1,
- FUNC = 2,
- EVENT = 3,
- ALIAS = 4,
- STRUCT = 5,
- STRUCT_FIELD = 6,
- ENUM = 7,
- ENUM_FIELD = 8,
- VAR = 9
-}
-
M.documentation_string_split = function(str)
if not str then
return {}
ref_get = function(self, unit)
local stor = ffi.new("const void *[2]")
local tp = tonumber(eolian.eolian_doc_token_ref_get(unit, self, stor, stor + 1))
- local reft = M.doc_ref_type
+ local reft = M.object_type
if tp == reft.CLASS then
return tp, ffi.cast("const Eolian_Class *", stor[0])
elseif tp == reft.FUNC then
elseif tp == reft.VAR then
return tp, ffi.cast("const Eolian_Variable *", stor[0])
else
- return reft.INVALID
+ return reft.UNKNOWN
end
end
}
EOLIAN_DOC_TOKEN_MARKUP_MONOSPACE
} Eolian_Doc_Token_Type;
-typedef enum
-{
- EOLIAN_DOC_REF_INVALID = 0,
- EOLIAN_DOC_REF_CLASS,
- EOLIAN_DOC_REF_FUNC,
- EOLIAN_DOC_REF_EVENT,
- EOLIAN_DOC_REF_ALIAS,
- EOLIAN_DOC_REF_STRUCT,
- EOLIAN_DOC_REF_STRUCT_FIELD,
- EOLIAN_DOC_REF_ENUM,
- EOLIAN_DOC_REF_ENUM_FIELD,
- EOLIAN_DOC_REF_VAR
-} Eolian_Doc_Ref_Type;
-
typedef struct _Eolian_Doc_Token
{
Eolian_Doc_Token_Type type;
/*
* @brief Get the thing that a reference token references.
*
- * Returns EOLIAN_DOC_REF_INVALID on failure (when not ref token or
+ * Returns EOLIAN_OBJECT_UNKNOWN on failure (when not ref token or
* invalid ref, but invalid refs don't happen when database is valid).
*
* When the reference is a class, alias, struct, enum or var, the first data arg
* @param[out] data2 the secondary data
* @return the kind of reference this is
*/
-EAPI Eolian_Doc_Ref_Type eolian_doc_token_ref_get(const Eolian_Unit *unit, const Eolian_Doc_Token *tok, const void **data, const void **data2);
+EAPI Eolian_Object_Type eolian_doc_token_ref_get(const Eolian_Unit *unit, const Eolian_Doc_Token *tok, const void **data, const void **data2);
#endif
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_DOC_REF_INVALID)
+ if (eolian_doc_token_ref_get(src, &tok, NULL, NULL) == EOLIAN_OBJECT_UNKNOWN)
{
char *refn = eolian_doc_token_text_get(&tok);
_eolian_log_line(info->file, info->line, info->column,
return ptr;
}
-static Eolian_Doc_Ref_Type
+static Eolian_Object_Type
_resolve_event(const Eolian_Unit *src, char *name, const void **data,
const void **data2)
{
/* never trust the user */
if (name[0] == ',')
- return EOLIAN_DOC_REF_INVALID;
+ return EOLIAN_OBJECT_UNKNOWN;
char *evname = strrchr(name, '.');
if (!evname)
- return EOLIAN_DOC_REF_INVALID;
+ return EOLIAN_OBJECT_UNKNOWN;
*evname++ = '\0';
const Eolian_Class *cl = eolian_unit_class_by_name_get(src, name);
if (!cl)
- return EOLIAN_DOC_REF_INVALID;
+ return EOLIAN_OBJECT_UNKNOWN;
const Eolian_Event *ev = eolian_class_event_get_by_name(cl, evname);
if (!ev)
- return EOLIAN_DOC_REF_INVALID;
+ return EOLIAN_OBJECT_UNKNOWN;
if (data) *data = cl;
if (data2) *data2 = ev;
- return EOLIAN_DOC_REF_EVENT;
+ return EOLIAN_OBJECT_EVENT;
}
-EAPI Eolian_Doc_Ref_Type
+EAPI Eolian_Object_Type
eolian_doc_token_ref_get(const Eolian_Unit *unit, const Eolian_Doc_Token *tok,
const void **data, const void **data2)
{
if (tok->type != EOLIAN_DOC_TOKEN_REF)
- return EOLIAN_DOC_REF_INVALID;
+ return EOLIAN_OBJECT_UNKNOWN;
size_t nlen = tok->text_end - tok->text;
if (decl)
{
if (data) *data = decl;
- switch (eolian_object_type_get(decl))
+ Eolian_Object_Type tp = eolian_object_type_get(decl);
+ switch (tp)
{
case EOLIAN_OBJECT_CLASS:
- return EOLIAN_DOC_REF_CLASS;
case EOLIAN_OBJECT_TYPEDECL:
- switch (eolian_typedecl_type_get((Eolian_Typedecl *)decl))
- {
- case EOLIAN_TYPEDECL_ALIAS:
- return EOLIAN_DOC_REF_ALIAS;
- case EOLIAN_TYPEDECL_STRUCT:
- case EOLIAN_TYPEDECL_STRUCT_OPAQUE:
- return EOLIAN_DOC_REF_STRUCT;
- case EOLIAN_TYPEDECL_ENUM:
- return EOLIAN_DOC_REF_ENUM;
- default:
- return EOLIAN_DOC_REF_INVALID;
- }
case EOLIAN_OBJECT_VARIABLE:
- return EOLIAN_DOC_REF_VAR;
+ /* we only allow certain types to be referenced */
+ return tp;
default:
- return EOLIAN_DOC_REF_INVALID;
+ return EOLIAN_OBJECT_UNKNOWN;
}
}
char *suffix = strrchr(name, '.');
/* no suffix, therefore invalid */
if (!suffix)
- return EOLIAN_DOC_REF_INVALID;
+ return EOLIAN_OBJECT_UNKNOWN;
/* name will terminate before suffix, suffix will be standalone */
*suffix++ = '\0';
const Eolian_Struct_Type_Field *fld = eolian_typedecl_struct_field_get(tpd, suffix);
/* field itself is invalid */
if (!fld)
- return EOLIAN_DOC_REF_INVALID;
+ return EOLIAN_OBJECT_UNKNOWN;
if (data) *data = tpd;
if (data2) *data2 = fld;
- return EOLIAN_DOC_REF_STRUCT_FIELD;
+ return EOLIAN_OBJECT_STRUCT_FIELD;
}
/* try an enum field */
const Eolian_Enum_Type_Field *fld = eolian_typedecl_enum_field_get(tpd, suffix);
/* field itself is invalid */
if (!fld)
- return EOLIAN_DOC_REF_INVALID;
+ return EOLIAN_OBJECT_UNKNOWN;
if (data) *data = tpd;
if (data2) *data2 = fld;
- return EOLIAN_DOC_REF_ENUM_FIELD;
+ return EOLIAN_OBJECT_ENUM_FIELD;
}
/* now it can only be a function or invalid */
suffix = strrchr(name, '.');
/* wrong suffix, therefore invalid */
if (!suffix)
- return EOLIAN_DOC_REF_INVALID;
+ return EOLIAN_OBJECT_UNKNOWN;
/* re-terminate */
*suffix++ = '\0';
}
const Eolian_Class *cl = eolian_unit_class_by_name_get(unit, name);
if (!cl)
- return EOLIAN_DOC_REF_INVALID;
+ return EOLIAN_OBJECT_UNKNOWN;
const Eolian_Function *fid = eolian_class_function_get_by_name(cl, suffix, ftype);
if (!fid)
- return EOLIAN_DOC_REF_INVALID;
+ return EOLIAN_OBJECT_UNKNOWN;
/* got a func */
if (data) *data = cl;
if (data2) *data2 = fid;
- return EOLIAN_DOC_REF_FUNC;
+ return EOLIAN_OBJECT_FUNCTION;
}
void
MARK_TODO = 6
MARKUP_MONOSPACE = 7
-class Eolian_Doc_Ref_Type(IntEnum):
- INVALID = 0
- CLASS = 1
- FUNC = 2
- EVENT = 3
- ALIAS = 4
- STRUCT = 5
- STRUCT_FIELD = 6
- ENUM = 7
- ENUM_FIELD = 8
- VAR = 9
-
### internal Classes ########################################################
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_Doc_Ref_Type eolian_doc_token_ref_get(const Eolian_Unit *unit, const Eolian_Doc_Token *tok, const void **data, const void **data2);
+# EAPI Eolian_Object_Type eolian_doc_token_ref_get(const Eolian_Unit *unit, const Eolian_Doc_Token *tok, const void **data, const void **data2);
# lib.eolian_doc_token_ref_get.argtypes = [c_void_p, c_void_p, ???, ???]
# lib.eolian_doc_token_ref_get.restype = c_int
'Documentation': eolian.Documentation,
'Documentation_Token': eolian.Documentation_Token,
# Eolian Enums
+ 'Eolian_Object_Type': eolian.Eolian_Object_Type,
'Eolian_Function_Type': eolian.Eolian_Function_Type,
'Eolian_Parameter_Dir': eolian.Eolian_Parameter_Dir,
'Eolian_Class_Type': eolian.Eolian_Class_Type,
'Eolian_Variable_Type': eolian.Eolian_Variable_Type,
'Eolian_Binary_Operator': eolian.Eolian_Binary_Operator,
'Eolian_Unary_Operator': eolian.Eolian_Unary_Operator,
- 'Eolian_Declaration_Type': eolian.Eolian_Declaration_Type,
'Eolian_Doc_Token_Type': eolian.Eolian_Doc_Token_Type,
- 'Eolian_Doc_Ref_Type': eolian.Eolian_Doc_Ref_Type,
})
# Call the parent __init__ func
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_DOC_REF_VAR);
+ fail_if(eolian_doc_token_ref_get(unit, &tok, 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);
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_DOC_REF_FUNC);
+ fail_if(eolian_doc_token_ref_get(unit, &tok, 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);