summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorq66 <daniel@octaforge.org>2018-08-29 12:49:07 +0200
committerq66 <daniel@octaforge.org>2018-08-29 12:49:07 +0200
commit7f8e6528fe70e6a8c76989e1cba352956c493d09 (patch)
tree9ffee963dcad8c5933be26e3845f2eb11fb1372e
parent158f4cc690af89d7565d664fcfaaad0a0973937f (diff)
add a mode to list only-legacy namesHEADmaster
-rw-r--r--list_beta_c_names.lua13
-rw-r--r--utils/eolian_extras.lua37
2 files changed, 35 insertions, 15 deletions
diff --git a/list_beta_c_names.lua b/list_beta_c_names.lua
index 5f989eb..c74ee48 100644
--- a/list_beta_c_names.lua
+++ b/list_beta_c_names.lua
@@ -3,6 +3,7 @@ local getopt = require("getopt")
3local eou = require("utils.eolian_extras") 3local eou = require("utils.eolian_extras")
4 4
5local exit = false 5local exit = false
6local legacy = false
6local pargs 7local pargs
7 8
8getopt.parse { 9getopt.parse {
@@ -14,7 +15,8 @@ path. If no path is specified, system-wide eo files are used instead.]],
14 descs = { 15 descs = {
15 { "h", "help", false, help = "Show this message.", 16 { "h", "help", false, help = "Show this message.",
16 callback = getopt.help_cb(io.stdout) 17 callback = getopt.help_cb(io.stdout)
17 } 18 },
19 { "l", "legacy", false, help = "Print only legacy names intead." }
18 }, 20 },
19 error_cb = function(parser, msg) 21 error_cb = function(parser, msg)
20 io.stderr:write(msg, "\n") 22 io.stderr:write(msg, "\n")
@@ -25,6 +27,9 @@ path. If no path is specified, system-wide eo files are used instead.]],
25 if opts["h"] then 27 if opts["h"] then
26 exit = true 28 exit = true
27 end 29 end
30 if opts["l"] then
31 legacy = true
32 end
28 pargs = args 33 pargs = args
29 end 34 end
30} 35}
@@ -45,17 +50,17 @@ eos:all_eot_files_parse()
45eos:all_eo_files_parse() 50eos:all_eo_files_parse()
46 51
47print("API functions:\n") 52print("API functions:\n")
48for i, n in ipairs(eou.get_c_functions(eos)) do 53for i, n in ipairs(eou.get_c_functions(eos, legacy)) do
49 print(n) 54 print(n)
50end 55end
51 56
52print("\nEvents:\n") 57print("\nEvents:\n")
53for i, n in ipairs(eou.get_c_events(eos)) do 58for i, n in ipairs(eou.get_c_events(eos, legacy)) do
54 print(n) 59 print(n)
55end 60end
56 61
57print("\nFunction pointers:\n") 62print("\nFunction pointers:\n")
58for i, n in ipairs(eou.get_c_function_pointers(eos)) do 63for i, n in ipairs(eou.get_c_function_pointers(eos, legacy)) do
59 print(n) 64 print(n)
60end 65end
61 66
diff --git a/utils/eolian_extras.lua b/utils/eolian_extras.lua
index 35be202..f84e048 100644
--- a/utils/eolian_extras.lua
+++ b/utils/eolian_extras.lua
@@ -57,28 +57,43 @@ M.new = function()
57 return eolian.new() 57 return eolian.new()
58end 58end
59 59
60M.get_c_functions = function(eos) 60local f_is_beta = function(fn)
61 if legacy then
62 return false
63 end
64 return fn:is_beta()
65end
66
67M.get_c_functions = function(eos, only_legacy)
68 only_legacy = not not only_legacy
61 local ret = {} 69 local ret = {}
62 for cl in eos:classes_get() do 70 for cl in eos:classes_get() do
63 local fntp = eolian.function_type 71 local fntp = eolian.function_type
64 for fn in cl:functions_get(fntp.METHOD) do 72 for fn in cl:functions_get(fntp.METHOD) do
65 ret[#ret + 1] = fn:full_c_name_get(fntp.METHOD, false) 73 if not only_legacy or not f_is_beta(fn) then
74 ret[#ret + 1] = fn:full_c_name_get(fntp.METHOD, only_legacy)
75 end
66 end 76 end
67 for fn in cl:functions_get(fntp.PROPERTY) do 77 for fn in cl:functions_get(fntp.PROPERTY) do
68 local tp = fn:type_get() 78 if not only_legacy or not f_is_beta(fn) then
69 if tp == fntp.PROPERTY then 79 local tp = fn:type_get()
70 ret[#ret + 1] = fn:full_c_name_get(fntp.PROP_GET, false) 80 if tp == fntp.PROPERTY then
71 ret[#ret + 1] = fn:full_c_name_get(fntp.PROP_SET, false) 81 ret[#ret + 1] = fn:full_c_name_get(fntp.PROP_GET, only_legacy)
72 else 82 ret[#ret + 1] = fn:full_c_name_get(fntp.PROP_SET, only_legacy)
73 ret[#ret + 1] = fn:full_c_name_get(tp, false) 83 else
84 ret[#ret + 1] = fn:full_c_name_get(tp, only_legacy)
85 end
74 end 86 end
75 end 87 end
76 end 88 end
77 return ret 89 return ret
78end 90end
79 91
80M.get_c_events = function(eos) 92M.get_c_events = function(eos, only_legacy)
81 local ret = {} 93 local ret = {}
94 if only_legacy then
95 return ret
96 end
82 for cl in eos:classes_get() do 97 for cl in eos:classes_get() do
83 for ev in cl:events_get() do 98 for ev in cl:events_get() do
84 ret[#ret + 1] = ev:c_name_get() 99 ret[#ret + 1] = ev:c_name_get()
@@ -94,8 +109,8 @@ local full_name_get = function(obj)
94 return obj:name_get() 109 return obj:name_get()
95end 110end
96 111
97M.get_c_function_pointers = function(eos) 112M.get_c_function_pointers = function(eos, only_legacy)
98 if legacy then 113 if legacy or only_legacy then
99 -- no function pointer support in pre-state api 114 -- no function pointer support in pre-state api
100 return {} 115 return {}
101 end 116 end