summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorq66 <daniel@octaforge.org>2018-08-01 14:16:23 +0200
committerq66 <daniel@octaforge.org>2018-08-01 14:16:34 +0200
commit8c8f1fc182ad72d4810fd9cb09bad952883787a9 (patch)
tree586e0538c8b16758f5691d31a328a3a6a747793b
parent3cf525bd219cee2b584a04c4686d772d5c507e9b (diff)
split off name retrieval into a module
-rw-r--r--list_beta_c_names.lua52
-rw-r--r--utils/eolian_extras.lua87
2 files changed, 105 insertions, 34 deletions
diff --git a/list_beta_c_names.lua b/list_beta_c_names.lua
index f036cd5..612baf1 100644
--- a/list_beta_c_names.lua
+++ b/list_beta_c_names.lua
@@ -1,6 +1,8 @@
1local eolian = require("eolian") 1local eolian = require("eolian")
2local getopt = require("getopt") 2local getopt = require("getopt")
3 3
4local eou = require("utils.eolian_extras")
5
4local exit = false 6local exit = false
5local pargs 7local pargs
6 8
@@ -44,61 +46,43 @@ eos:all_eot_files_parse()
44eos:all_eo_files_parse() 46eos:all_eo_files_parse()
45 47
46print("API functions:\n") 48print("API functions:\n")
47for cl in eos:classes_get() do 49for i, n in ipairs(eou.get_c_functions(eos)) do
48 local fntp = eolian.function_type 50 print(n)
49 for fn in cl:functions_get(fntp.METHOD) do
50 print(fn:full_c_name_get(fntp.METHOD, false))
51 end
52 for fn in cl:functions_get(fntp.PROPERTY) do
53 local tp = fn:type_get()
54 if tp == fntp.PROPERTY then
55 print(fn:full_c_name_get(fntp.PROP_GET, false))
56 print(fn:full_c_name_get(fntp.PROP_SET, false))
57 else
58 print(fn:full_c_name_get(tp, false))
59 end
60 end
61end 51end
62 52
63print("\nEvents:\n") 53print("\nEvents:\n")
64for cl in eos:classes_get() do 54for i, n in ipairs(eou.get_c_events(eos)) do
65 for ev in cl:events_get() do 55 print(n)
66 print(ev:c_name_get())
67 end
68end 56end
69 57
70print("\nFunction pointers:\n") 58print("\nFunction pointers:\n")
71for tp in eos:aliases_get() do 59for i, n in ipairs(eou.get_c_function_pointers(eos)) do
72 if tp:type_get() == eolian.typedecl_type.FUNCTION_POINTER then 60 print(n)
73 print((tp:name_get():gsub("%.", "_")))
74 end
75end 61end
76 62
77print("\nAliases:\n") 63print("\nAliases:\n")
78for tp in eos:aliases_get() do 64for i, n in ipairs(eou.get_c_aliases(eos)) do
79 if tp:type_get() ~= eolian.typedecl_type.FUNCTION_POINTER then 65 print(n)
80 print((tp:name_get():gsub("%.", "_")))
81 end
82end 66end
83 67
84print("\nStructs:\n") 68print("\nStructs:\n")
85for tp in eos:structs_get() do 69for i, n in ipairs(eou.get_c_structs(eos)) do
86 print((tp:name_get():gsub("%.", "_"))) 70 print(n)
87end 71end
88 72
89print("\nEnums:\n") 73print("\nEnums:\n")
90for tp in eos:enums_get() do 74for i, n in ipairs(eou.get_c_enums(eos)) do
91 print((tp:name_get():gsub("%.", "_"))) 75 print(n)
92end 76end
93 77
94print("\nGlobals:\n") 78print("\nGlobals:\n")
95for v in eos:globals_get() do 79for i, n in ipairs(eou.get_c_globals(eos)) do
96 print(v:name_get():gsub("%.", "_"):upper()) 80 print(n)
97end 81end
98 82
99print("\nConstants:\n") 83print("\nConstants:\n")
100for v in eos:constants_get() do 84for i, n in ipairs(eou.get_c_constants(eos)) do
101 print(v:name_get():gsub("%.", "_"):upper()) 85 print(n)
102end 86end
103 87
104return true 88return true
diff --git a/utils/eolian_extras.lua b/utils/eolian_extras.lua
new file mode 100644
index 0000000..130f7ee
--- /dev/null
+++ b/utils/eolian_extras.lua
@@ -0,0 +1,87 @@
1local eolian = require("eolian")
2
3local M = {}
4
5M.get_c_functions = function(eos)
6 local ret = {}
7 for cl in eos:classes_get() do
8 local fntp = eolian.function_type
9 for fn in cl:functions_get(fntp.METHOD) do
10 ret[#ret + 1] = fn:full_c_name_get(fntp.METHOD, false)
11 end
12 for fn in cl:functions_get(fntp.PROPERTY) do
13 local tp = fn:type_get()
14 if tp == fntp.PROPERTY then
15 ret[#ret + 1] = fn:full_c_name_get(fntp.PROP_GET, false)
16 ret[#ret + 1] = fn:full_c_name_get(fntp.PROP_SET, false)
17 else
18 ret[#ret + 1] = fn:full_c_name_get(tp, false)
19 end
20 end
21 end
22 return ret
23end
24
25M.get_c_events = function(eos)
26 local ret = {}
27 for cl in eos:classes_get() do
28 for ev in cl:events_get() do
29 ret[#ret + 1] = ev:c_name_get()
30 end
31 end
32 return ret
33end
34
35M.get_c_function_pointers = function(eos)
36 local ret = {}
37 for tp in eos:aliases_get() do
38 if tp:type_get() == eolian.typedecl_type.FUNCTION_POINTER then
39 ret[#ret + 1] = tp:name_get():gsub("%.", "_")
40 end
41 end
42 return ret
43end
44
45M.get_c_aliases = function(eos)
46 local ret = {}
47 for tp in eos:aliases_get() do
48 if tp:type_get() ~= eolian.typedecl_type.FUNCTION_POINTER then
49 ret[#ret + 1] = tp:name_get():gsub("%.", "_")
50 end
51 end
52 return ret
53end
54
55M.get_c_structs = function(eos)
56 local ret = {}
57 for tp in eos:structs_get() do
58 ret[#ret + 1] = tp:name_get():gsub("%.", "_")
59 end
60 return ret
61end
62
63M.get_c_enums = function(eos)
64 local ret = {}
65 for tp in eos:enums_get() do
66 ret[#ret + 1] = tp:name_get():gsub("%.", "_")
67 end
68 return ret
69end
70
71M.get_c_globals = function(eos)
72 local ret = {}
73 for v in eos:globals_get() do
74 ret[#ret + 1] = v:name_get():gsub("%.", "_"):upper()
75 end
76 return ret
77end
78
79M.get_c_constants = function(eos)
80 local ret = {}
81 for v in eos:constants_get() do
82 ret[#ret + 1] = v:name_get():gsub("%.", "_"):upper()
83 end
84 return ret
85end
86
87return M