mirror of
https://github.com/neovim/neovim.git
synced 2025-09-17 00:38:17 +00:00
gendispatch: warn for deprecated alias if the deprecated function has implemation
This commit is contained in:
@@ -46,8 +46,8 @@ grammar = Ct((c_proto + c_comment + c_preproc + ws) ^ 1)
|
|||||||
assert(#arg >= 3)
|
assert(#arg >= 3)
|
||||||
functions = {}
|
functions = {}
|
||||||
|
|
||||||
local scriptdir = arg[1]
|
local nvimsrcdir = arg[1]
|
||||||
package.path = scriptdir .. '/?.lua;' .. package.path
|
package.path = nvimsrcdir .. '/?.lua;' .. package.path
|
||||||
|
|
||||||
-- names of all headers relative to the source root (for inclusion in the
|
-- names of all headers relative to the source root (for inclusion in the
|
||||||
-- generated file)
|
-- generated file)
|
||||||
@@ -57,6 +57,9 @@ outputf = arg[#arg-1]
|
|||||||
-- output mpack file (metadata)
|
-- output mpack file (metadata)
|
||||||
mpack_outputf = arg[#arg]
|
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
|
-- read each input file, parse and append to the api metadata
|
||||||
for i = 2, #arg - 2 do
|
for i = 2, #arg - 2 do
|
||||||
local full_path = arg[i]
|
local full_path = arg[i]
|
||||||
@@ -72,6 +75,7 @@ for i = 2, #arg - 2 do
|
|||||||
local fn = tmp[i]
|
local fn = tmp[i]
|
||||||
if not fn.noexport then
|
if not fn.noexport then
|
||||||
functions[#functions + 1] = tmp[i]
|
functions[#functions + 1] = tmp[i]
|
||||||
|
function_names[fn.name] = true
|
||||||
if #fn.parameters ~= 0 and fn.parameters[1][2] == 'channel_id' then
|
if #fn.parameters ~= 0 and fn.parameters[1][2] == 'channel_id' then
|
||||||
-- this function should receive the channel id
|
-- this function should receive the channel id
|
||||||
fn.receives_channel_id = true
|
fn.receives_channel_id = true
|
||||||
@@ -104,7 +108,7 @@ end
|
|||||||
|
|
||||||
-- Export functions under older deprecated names.
|
-- Export functions under older deprecated names.
|
||||||
-- These will be removed eventually.
|
-- 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
|
for i,f in ipairs(shallowcopy(functions)) do
|
||||||
local ismethod = false
|
local ismethod = false
|
||||||
if startswith(f.name, "nvim_buf_") then
|
if startswith(f.name, "nvim_buf_") then
|
||||||
@@ -120,6 +124,13 @@ for i,f in ipairs(shallowcopy(functions)) do
|
|||||||
f.method = ismethod
|
f.method = ismethod
|
||||||
local newname = deprecated_aliases[f.name]
|
local newname = deprecated_aliases[f.name]
|
||||||
if newname ~= nil then
|
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)
|
local newf = shallowcopy(f)
|
||||||
newf.name = newname
|
newf.name = newname
|
||||||
newf.impl_name = f.name
|
newf.impl_name = f.name
|
||||||
|
@@ -204,11 +204,12 @@ add_custom_command(OUTPUT ${GENERATED_UNICODE_TABLES}
|
|||||||
)
|
)
|
||||||
|
|
||||||
add_custom_command(OUTPUT ${GENERATED_API_DISPATCH} ${API_METADATA}
|
add_custom_command(OUTPUT ${GENERATED_API_DISPATCH} ${API_METADATA}
|
||||||
COMMAND ${LUA_PRG} ${DISPATCH_GENERATOR} ${PROJECT_SOURCE_DIR}/scripts ${API_HEADERS} ${GENERATED_API_DISPATCH} ${API_METADATA}
|
COMMAND ${LUA_PRG} ${DISPATCH_GENERATOR} ${CMAKE_CURRENT_LIST_DIR} ${API_HEADERS} ${GENERATED_API_DISPATCH} ${API_METADATA}
|
||||||
DEPENDS
|
DEPENDS
|
||||||
${API_HEADERS}
|
${API_HEADERS}
|
||||||
${MSGPACK_RPC_HEADERS}
|
${MSGPACK_RPC_HEADERS}
|
||||||
${DISPATCH_GENERATOR}
|
${DISPATCH_GENERATOR}
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/api/dispatch_deprecated.lua
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND NEOVIM_GENERATED_SOURCES
|
list(APPEND NEOVIM_GENERATED_SOURCES
|
||||||
|
Reference in New Issue
Block a user