aboutsummaryrefslogtreecommitdiffstats
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
parentadd a script to print all non-legacy C names in eo files (diff)
downloadeolian_tools-8c8f1fc182ad72d4810fd9cb09bad952883787a9.tar.gz
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 @@
local eolian = require("eolian")
local getopt = require("getopt")
+local eou = require("utils.eolian_extras")
+
local exit = false
local pargs
@@ -44,61 +46,43 @@ eos:all_eot_files_parse()
eos:all_eo_files_parse()
print("API functions:\n")
-for cl in eos:classes_get() do
- local fntp = eolian.function_type
- for fn in cl:functions_get(fntp.METHOD) do
- print(fn:full_c_name_get(fntp.METHOD, false))
- end
- for fn in cl:functions_get(fntp.PROPERTY) do
- local tp = fn:type_get()
- if tp == fntp.PROPERTY then
- print(fn:full_c_name_get(fntp.PROP_GET, false))
- print(fn:full_c_name_get(fntp.PROP_SET, false))
- else
- print(fn:full_c_name_get(tp, false))
- end
- end
+for i, n in ipairs(eou.get_c_functions(eos)) do
+ print(n)
end
print("\nEvents:\n")
-for cl in eos:classes_get() do
- for ev in cl:events_get() do
- print(ev:c_name_get())
- end
+for i, n in ipairs(eou.get_c_events(eos)) do
+ print(n)
end
print("\nFunction pointers:\n")
-for tp in eos:aliases_get() do
- if tp:type_get() == eolian.typedecl_type.FUNCTION_POINTER then
- print((tp:name_get():gsub("%.", "_")))
- end
+for i, n in ipairs(eou.get_c_function_pointers(eos)) do
+ print(n)
end
print("\nAliases:\n")
-for tp in eos:aliases_get() do
- if tp:type_get() ~= eolian.typedecl_type.FUNCTION_POINTER then
- print((tp:name_get():gsub("%.", "_")))
- end
+for i, n in ipairs(eou.get_c_aliases(eos)) do
+ print(n)
end
print("\nStructs:\n")
-for tp in eos:structs_get() do
- print((tp:name_get():gsub("%.", "_")))
+for i, n in ipairs(eou.get_c_structs(eos)) do
+ print(n)
end
print("\nEnums:\n")
-for tp in eos:enums_get() do
- print((tp:name_get():gsub("%.", "_")))
+for i, n in ipairs(eou.get_c_enums(eos)) do
+ print(n)
end
print("\nGlobals:\n")
-for v in eos:globals_get() do
- print(v:name_get():gsub("%.", "_"):upper())
+for i, n in ipairs(eou.get_c_globals(eos)) do
+ print(n)
end
print("\nConstants:\n")
-for v in eos:constants_get() do
- print(v:name_get():gsub("%.", "_"):upper())
+for i, n in ipairs(eou.get_c_constants(eos)) do
+ print(n)
end
return 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 @@
+local eolian = require("eolian")
+
+local M = {}
+
+M.get_c_functions = function(eos)
+ local ret = {}
+ for cl in eos:classes_get() do
+ local fntp = eolian.function_type
+ for fn in cl:functions_get(fntp.METHOD) do
+ ret[#ret + 1] = fn:full_c_name_get(fntp.METHOD, false)
+ end
+ for fn in cl:functions_get(fntp.PROPERTY) do
+ local tp = fn:type_get()
+ if tp == fntp.PROPERTY then
+ ret[#ret + 1] = fn:full_c_name_get(fntp.PROP_GET, false)
+ ret[#ret + 1] = fn:full_c_name_get(fntp.PROP_SET, false)
+ else
+ ret[#ret + 1] = fn:full_c_name_get(tp, false)
+ end
+ end
+ end
+ return ret
+end
+
+M.get_c_events = function(eos)
+ local ret = {}
+ for cl in eos:classes_get() do
+ for ev in cl:events_get() do
+ ret[#ret + 1] = ev:c_name_get()
+ end
+ end
+ return ret
+end
+
+M.get_c_function_pointers = function(eos)
+ local ret = {}
+ for tp in eos:aliases_get() do
+ if tp:type_get() == eolian.typedecl_type.FUNCTION_POINTER then
+ ret[#ret + 1] = tp:name_get():gsub("%.", "_")
+ end
+ end
+ return ret
+end
+
+M.get_c_aliases = function(eos)
+ local ret = {}
+ for tp in eos:aliases_get() do
+ if tp:type_get() ~= eolian.typedecl_type.FUNCTION_POINTER then
+ ret[#ret + 1] = tp:name_get():gsub("%.", "_")
+ end
+ end
+ return ret
+end
+
+M.get_c_structs = function(eos)
+ local ret = {}
+ for tp in eos:structs_get() do
+ ret[#ret + 1] = tp:name_get():gsub("%.", "_")
+ end
+ return ret
+end
+
+M.get_c_enums = function(eos)
+ local ret = {}
+ for tp in eos:enums_get() do
+ ret[#ret + 1] = tp:name_get():gsub("%.", "_")
+ end
+ return ret
+end
+
+M.get_c_globals = function(eos)
+ local ret = {}
+ for v in eos:globals_get() do
+ ret[#ret + 1] = v:name_get():gsub("%.", "_"):upper()
+ end
+ return ret
+end
+
+M.get_c_constants = function(eos)
+ local ret = {}
+ for v in eos:constants_get() do
+ ret[#ret + 1] = v:name_get():gsub("%.", "_"):upper()
+ end
+ return ret
+end
+
+return M