summaryrefslogtreecommitdiff
path: root/src/bindings
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2016-12-08 17:20:22 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2016-12-08 17:20:22 +0100
commite8d1ddd86ca6086525ed735023ed4e6ee4234d7d (patch)
treea26113738dede0403000fec4f94e9cb2343a5513 /src/bindings
parent0397769a65fe8735f841ddfbf846a32db1211555 (diff)
elua: add bindings to new Eolian APIs
Diffstat (limited to 'src/bindings')
-rw-r--r--src/bindings/luajit/eolian.lua143
1 files changed, 143 insertions, 0 deletions
diff --git a/src/bindings/luajit/eolian.lua b/src/bindings/luajit/eolian.lua
index 8511152..c5e2e79 100644
--- a/src/bindings/luajit/eolian.lua
+++ b/src/bindings/luajit/eolian.lua
@@ -6,6 +6,7 @@ local bit = require("bit")
6 6
7ffi.cdef [[ 7ffi.cdef [[
8 void eina_stringshare_del(const char *str); 8 void eina_stringshare_del(const char *str);
9 void free(void *ptr);
9]] 10]]
10 11
11ffi.cdef [[ 12ffi.cdef [[
@@ -184,6 +185,35 @@ ffi.cdef [[
184 EOLIAN_DECL_VAR 185 EOLIAN_DECL_VAR
185 } Eolian_Declaration_Type; 186 } Eolian_Declaration_Type;
186 187
188 typedef enum {
189 EOLIAN_DOC_TOKEN_UNKNOWN = -1,
190 EOLIAN_DOC_TOKEN_TEXT,
191 EOLIAN_DOC_TOKEN_REF,
192 EOLIAN_DOC_TOKEN_MARK_NOTE,
193 EOLIAN_DOC_TOKEN_MARK_WARNING,
194 EOLIAN_DOC_TOKEN_MARK_REMARK,
195 EOLIAN_DOC_TOKEN_MARK_TODO,
196 EOLIAN_DOC_TOKEN_MARKUP_MONOSPACE
197 } Eolian_Doc_Token_Type;
198
199 typedef enum {
200 EOLIAN_DOC_REF_INVALID = 0,
201 EOLIAN_DOC_REF_CLASS,
202 EOLIAN_DOC_REF_FUNC,
203 EOLIAN_DOC_REF_EVENT,
204 EOLIAN_DOC_REF_ALIAS,
205 EOLIAN_DOC_REF_STRUCT,
206 EOLIAN_DOC_REF_STRUCT_FIELD,
207 EOLIAN_DOC_REF_ENUM,
208 EOLIAN_DOC_REF_ENUM_FIELD,
209 EOLIAN_DOC_REF_VAR
210 } Eolian_Doc_Ref_Type;
211
212 typedef struct _Eolian_Doc_Token {
213 Eolian_Doc_Token_Type type;
214 const char *text, *text_end;
215 } Eolian_Doc_Token;
216
187 Eina_Bool eolian_file_parse(const char *filepath); 217 Eina_Bool eolian_file_parse(const char *filepath);
188 Eina_Iterator *eolian_all_eo_file_paths_get(void); 218 Eina_Iterator *eolian_all_eo_file_paths_get(void);
189 Eina_Iterator *eolian_all_eot_file_paths_get(void); 219 Eina_Iterator *eolian_all_eot_file_paths_get(void);
@@ -361,6 +391,12 @@ ffi.cdef [[
361 const char *eolian_documentation_summary_get(const Eolian_Documentation *doc); 391 const char *eolian_documentation_summary_get(const Eolian_Documentation *doc);
362 const char *eolian_documentation_description_get(const Eolian_Documentation *doc); 392 const char *eolian_documentation_description_get(const Eolian_Documentation *doc);
363 const char *eolian_documentation_since_get(const Eolian_Documentation *doc); 393 const char *eolian_documentation_since_get(const Eolian_Documentation *doc);
394
395 const char *eolian_documentation_tokenize(const char *doc, Eolian_Doc_Token *ret);
396 void eolian_doc_token_init(Eolian_Doc_Token *tok);
397 Eolian_Doc_Token_Type eolian_doc_token_type_get(const Eolian_Doc_Token *tok);
398 char *eolian_doc_token_text_get(const Eolian_Doc_Token *tok);
399 Eolian_Doc_Ref_Type eolian_doc_token_ref_get(const Eolian_Doc_Token *tok, const void **data, const void **data2);
364]] 400]]
365 401
366local cutil = require("cutil") 402local cutil = require("cutil")
@@ -1484,4 +1520,111 @@ M.Documentation = ffi.metatype("Eolian_Documentation", {
1484 } 1520 }
1485}) 1521})
1486 1522
1523M.doc_token_type = {
1524 UNKNOWN = -1,
1525 TEXT = 0,
1526 REF = 1,
1527 MARK_NOTE = 2,
1528 MARK_WARNING = 3,
1529 MARK_REMARK = 4,
1530 MARK_TODO = 5,
1531 MARKUP_MONOSPACE = 6
1532}
1533
1534M.doc_ref_type = {
1535 INVALID = 0,
1536 CLASS = 1,
1537 FUNC = 2,
1538 EVENT = 3,
1539 ALIAS = 4,
1540 STRUCT = 5,
1541 STRUCT_FIELD = 6,
1542 ENUM = 7,
1543 ENUM_FIELD = 8,
1544 VAR = 9
1545}
1546
1547M.documentation_string_split = function(str)
1548 if not str then
1549 return {}
1550 end
1551 local sep = str:find("\n\n", 1, true)
1552 local ret = {}
1553 while true do
1554 local pstr = (sep and str:sub(1, sep - 1) or pstr):match("^%s*(.-)%s*$")
1555 if #pstr > 0 then
1556 ret[#ret + 1] = pstr
1557 end
1558 if not sep then
1559 break
1560 end
1561 str = str:sub(sep + 2)
1562 sep = str:find("\n\n", 1, true)
1563 end
1564 return ret
1565end
1566
1567M.documentation_tokenize = function(doc, ret)
1568 local ret = eolian.eolian_documentation_tokenize(doc, ret)
1569 if ret == nil then
1570 return nil
1571 end
1572 return ffi.string(ret)
1573end
1574
1575M.doc_token_init = function()
1576 local ret = ffi.new("Eolian_Doc_Token")
1577 eolian.eolian_doc_token_init(ret)
1578 return ret
1579end
1580
1581M.Eolian_Doc_Token = ffi.metatype("Eolian_Doc_Token", {
1582 __index = {
1583 type_get = function(self)
1584 return tonumber(eolian.eolian_doc_token_type_get(self))
1585 end,
1586
1587 text_get = function(self)
1588 local str = eolian.eolian_doc_token_text_get(self)
1589 if str == nil then
1590 return nil
1591 end
1592 local ret = ffi.string(str)
1593 ffi.C.free(str)
1594 return ret
1595 end,
1596
1597 ref_get = function(self)
1598 local stor = ffi.new("const void *[2]")
1599 local tp = tonumber(eolian.eolian_doc_token_ref_get(self, stor, stor + 1))
1600 local reft = M.doc_ref_type
1601 if tp == reft.CLASS then
1602 return tp, ffi.cast("const Eolian_Class *", stor[0])
1603 elseif tp == reft.FUNC then
1604 return tp, ffi.cast("const Eolian_Class *", stor[0]),
1605 ffi.cast("const Eolian_Function *", stor[1])
1606 elseif tp == reft.EVENT then
1607 return tp, ffi.cast("const Eolian_Class *", stor[0]),
1608 ffi.cast("const Eolian_Event *", stor[1])
1609 elseif tp == reft.ALIAS then
1610 return tp, ffi.cast("const Eolian_Typedecl *", stor[0])
1611 elseif tp == reft.STRUCT then
1612 return tp, ffi.cast("const Eolian_Typedecl *", stor[0])
1613 elseif tp == reft.STRUCT_FIELD then
1614 return tp, ffi.cast("const Eolian_Typedecl *", stor[0]),
1615 ffi.cast("const Eolian_Struct_Type_Field *", stor[1])
1616 elseif tp == reft.ENUM then
1617 return tp, ffi.cast("const Eolian_Typedecl *", stor[0])
1618 elseif tp == reft.ENUM_FIELD then
1619 return tp, ffi.cast("const Eolian_Typedecl *", stor[0]),
1620 ffi.cast("const Eolian_Enum_Type_Field *", stor[1])
1621 elseif tp == reft.VAR then
1622 return tp, ffi.cast("const Eolian_Variable *", stor[0])
1623 else
1624 return reft.INVALID
1625 end
1626 end
1627 }
1628})
1629
1487return M 1630return M