summaryrefslogtreecommitdiff
path: root/list_used_beta_api.lua
blob: 7c435889587782060860b21dc74dd71f2a86fef9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
local getopt = require("getopt")

local eou = require("utils.eolian_extras")

local exit = false
local pargs

getopt.parse {
    usage = "Usage: %prog [OPTIONS] path_to_project [path_to_eo_files]",
    args = arg,
    header = [[
Print all beta C names used in the given project. You can specify a custom
path to .eo files as the second argument. If you don't, system-wide eo files
will be used instead.]],
    descs = {
        { "h", "help", false, help = "Show this message.",
            callback = getopt.help_cb(io.stdout)
        }
    },
    error_cb = function(parser, msg)
        io.stderr:write(msg, "\n")
        getopt.help(parser, io.stderr)
        exit = true
    end,
    done_cb = function(parser, opts, args)
        if opts["h"] then
            exit = true
        end
        if #args == 0 then
            parser:error_cb("project path not specified")
            return
        end
        pargs = args
    end
}

if exit then
    return true
end

local eos = eou.new()

if #pargs > 1 then
    eos:directory_add(pargs[2])
else
    eos:system_directory_add()
end

-- find all source, header and inline files first, we don't have a reasonable
-- filesystem api available here so this hack is necessary, maybe replace later
local f = io.popen(("find '%s' -name '*.[chx]'"):format(
    pargs[1]:gsub("'", "\\'")))
if not f then
    error("could not find source files")
end

local srcs = {}

-- a list of hardcoded names not in .eo files that we know of
local syms = {
    efl_add = true,
    efl_add_ref = true,
    efl_callbacks_cmp = true,
    efl_cast = true,
    efl_class_functions_set = true,
    efl_class_get = true,
    efl_class_name_get = true,
    efl_class_new = true,
    efl_compatible = true,
    efl_data_ref = true,
    efl_data_scope_get = true,
    efl_data_scope_safe_get = true,
    efl_data_unref = true,
    efl_data_xref = true,
    efl_data_xunref = true,
    efl_dbg_info_free = true,
    efl_dbg_info_get = true,
    efl_debug_name_get = true,
    efl_del = true,
    efl_del_intercept_get = true,
    efl_del_intercept_set = true,
    efl_destructed_is = true,
    efl_domain_current_get = true,
    efl_domain_current_pop = true,
    efl_domain_current_push = true,
    efl_domain_current_set = true,
    efl_domain_data_adopt = true,
    efl_domain_data_get = true,
    efl_domain_data_return = true,
    efl_domain_get = true,
    efl_domain_switch = true,
    efl_event_callback_add = true,
    efl_event_callback_array_add = true,
    efl_event_callback_array_del = true,
    efl_event_callback_array_priority_add = true,
    efl_event_callback_call = true,
    efl_event_callback_del = true,
    efl_event_callback_legacy_call = true,
    efl_event_callback_priority_add = true,
    efl_future_Eina_FutureXXX_then = true,
    efl_future_cb = true,
    efl_future_cb_from_desc = true,
    efl_future_chain = true,
    efl_future_chain_array = true,
    efl_isa = true,
    efl_key_data_get = true,
    efl_key_data_set = true,
    efl_key_ref_get = true,
    efl_key_ref_set = true,
    efl_key_value_get = true,
    efl_key_value_set = true,
    efl_key_wref_get = true,
    efl_key_wref_set = true,
    efl_manual_free = true,
    efl_manual_free_set = true,
    efl_new = true,
    efl_object_init = true,
    efl_object_legacy_only_event_description_get = true,
    efl_object_override = true,
    efl_object_shutdown = true,
    efl_ref = true,
    efl_ref_count = true,
    efl_reuse = true,
    efl_super = true,
    efl_unref = true,
    efl_weak_ref = true,
    efl_weak_unref = true,
    efl_wref_add = true,
    efl_wref_del = true,
    efl_wref_del_safe = true,
    efl_xref = true,
    efl_xunref = true
}

-- collect source files
for fn in f:lines() do
    srcs[#srcs + 1] = fn
end
f:close()

-- collect names as a lookup table
eos:all_eot_files_parse()
eos:all_eo_files_parse()

local add_syms = function(fun)
    for i, n in ipairs(fun(eos)) do
        syms[n] = true
    end
end

add_syms(eou.get_c_functions)
add_syms(eou.get_c_events)
add_syms(eou.get_c_function_pointers)
--add_syms(eou.get_c_aliases)
--add_syms(eou.get_c_structs)
--add_syms(eou.get_c_enums)
add_syms(eou.get_c_globals)
add_syms(eou.get_c_constants)

-- match words in sources against names

local match_names = function(fn)
    local fs = io.open(fn)
    if not fs then
        return
    end
    local lnum = 1
    for l in fs:lines() do
        -- C names on thel ine
        for w in l:gmatch("[%a_][%w_]*") do
            if syms[w] then
                print(("%s:%d: used beta name '%s'"):format(fn, lnum, w))
            end
        end
        lnum = lnum + 1
    end
    fs:close()
end

for i, fn in ipairs(srcs) do
    match_names(fn)
end

return true