gendispatch: warn for deprecated alias if the deprecated function has implemation

This commit is contained in:
Björn Linse
2016-09-14 11:15:01 +02:00
parent fee961c8dd
commit c61bf43a90
3 changed files with 16 additions and 4 deletions

View File

@@ -1,77 +0,0 @@
local deprecated_aliases = {
nvim_buf_line_count="buffer_line_count",
nvim_buf_get_lines="buffer_get_lines",
nvim_buf_set_lines="buffer_set_lines",
nvim_buf_get_var="buffer_get_var",
nvim_buf_set_var="buffer_set_var",
nvim_buf_del_var="buffer_del_var",
nvim_buf_get_option="buffer_get_option",
nvim_buf_set_option="buffer_set_option",
nvim_buf_get_number="buffer_get_number",
nvim_buf_get_name="buffer_get_name",
nvim_buf_set_name="buffer_set_name",
nvim_buf_is_valid="buffer_is_valid",
nvim_buf_get_mark="buffer_get_mark",
nvim_buf_add_highlight="buffer_add_highlight",
nvim_buf_clear_highlight="buffer_clear_highlight",
nvim_tabpage_get_windows="tabpage_get_windows",
nvim_tabpage_get_var="tabpage_get_var",
nvim_tabpage_set_var="tabpage_set_var",
nvim_tabpage_del_var="tabpage_del_var",
nvim_tabpage_get_window="tabpage_get_window",
nvim_tabpage_is_valid="tabpage_is_valid",
nvim_ui_detach="ui_detach",
nvim_ui_try_resize="ui_try_resize",
nvim_command="vim_command",
nvim_feedkeys="vim_feedkeys",
nvim_input="vim_input",
nvim_replace_termcodes="vim_replace_termcodes",
nvim_command_output="vim_command_output",
nvim_eval="vim_eval",
nvim_call_function="vim_call_function",
nvim_strwidth="vim_strwidth",
nvim_list_runtime_paths="vim_list_runtime_paths",
nvim_change_directory="vim_change_directory",
nvim_get_var="vim_get_var",
nvim_set_var="vim_set_var",
nvim_del_var="vim_del_var",
nvim_get_vvar="vim_get_vvar",
nvim_get_option="vim_get_option",
nvim_set_option="vim_set_option",
nvim_out_write="vim_out_write",
nvim_err_write="vim_err_write",
nvim_report_error="vim_report_error",
nvim_get_buffers="vim_get_buffers",
nvim_get_current_buffer="vim_get_current_buffer",
nvim_set_current_buffer="vim_set_current_buffer",
nvim_get_windows="vim_get_windows",
nvim_get_current_window="vim_get_current_window",
nvim_set_current_window="vim_set_current_window",
nvim_get_tabpages="vim_get_tabpages",
nvim_get_current_tabpage="vim_get_current_tabpage",
nvim_set_current_tabpage="vim_set_current_tabpage",
nvim_set_current_line="vim_set_current_line",
nvim_get_current_line="vim_get_current_line",
nvim_del_current_line="vim_del_current_line",
nvim_subscribe="vim_subscribe",
nvim_unsubscribe="vim_unsubscribe",
nvim_name_to_color="vim_name_to_color",
nvim_get_color_map="vim_get_color_map",
nvim_get_api_info="vim_get_api_info",
nvim_win_get_buffer="window_get_buffer",
nvim_win_get_cursor="window_get_cursor",
nvim_win_set_cursor="window_set_cursor",
nvim_win_get_height="window_get_height",
nvim_win_set_height="window_set_height",
nvim_win_get_width="window_get_width",
nvim_win_set_width="window_set_width",
nvim_win_get_var="window_get_var",
nvim_win_set_var="window_set_var",
nvim_win_del_var="window_del_var",
nvim_win_get_option="window_get_option",
nvim_win_set_option="window_set_option",
nvim_win_get_position="window_get_position",
nvim_win_get_tabpage="window_get_tabpage",
nvim_win_is_valid="window_is_valid"
}
return deprecated_aliases

View File

@@ -46,8 +46,8 @@ grammar = Ct((c_proto + c_comment + c_preproc + ws) ^ 1)
assert(#arg >= 3)
functions = {}
local scriptdir = arg[1]
package.path = scriptdir .. '/?.lua;' .. package.path
local nvimsrcdir = arg[1]
package.path = nvimsrcdir .. '/?.lua;' .. package.path
-- names of all headers relative to the source root (for inclusion in the
-- generated file)
@@ -57,6 +57,9 @@ outputf = arg[#arg-1]
-- output mpack file (metadata)
mpack_outputf = arg[#arg]
-- set of function names, used to detect duplicates
function_names = {}
-- read each input file, parse and append to the api metadata
for i = 2, #arg - 2 do
local full_path = arg[i]
@@ -72,6 +75,7 @@ for i = 2, #arg - 2 do
local fn = tmp[i]
if not fn.noexport then
functions[#functions + 1] = tmp[i]
function_names[fn.name] = true
if #fn.parameters ~= 0 and fn.parameters[1][2] == 'channel_id' then
-- this function should receive the channel id
fn.receives_channel_id = true
@@ -104,7 +108,7 @@ end
-- Export functions under older deprecated names.
-- These will be removed eventually.
local deprecated_aliases = require("dispatch_deprecated")
local deprecated_aliases = require("api.dispatch_deprecated")
for i,f in ipairs(shallowcopy(functions)) do
local ismethod = false
if startswith(f.name, "nvim_buf_") then
@@ -120,6 +124,13 @@ for i,f in ipairs(shallowcopy(functions)) do
f.method = ismethod
local newname = deprecated_aliases[f.name]
if newname ~= nil then
if function_names[newname] then
-- duplicate
print("Function "..f.name.." has deprecated alias\n"
..newname.." which has a separate implementation.\n"..
"Please remove it from src/nvim/api/dispatch_deprecated.lua")
os.exit(1)
end
local newf = shallowcopy(f)
newf.name = newname
newf.impl_name = f.name