aboutsummaryrefslogtreecommitdiff
path: root/scripts/gendispatch.lua
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2016-09-14 11:15:01 +0200
committerBjörn Linse <bjorn.linse@gmail.com>2016-09-15 10:44:38 +0200
commitc61bf43a90238f20716d48554ddc536b485ec1bf (patch)
treed814e411d697dd1b546702b3fb4040ac09d3f4f9 /scripts/gendispatch.lua
parentfee961c8ddda9de00db19895e189a174896d6534 (diff)
downloadrneovim-c61bf43a90238f20716d48554ddc536b485ec1bf.tar.gz
rneovim-c61bf43a90238f20716d48554ddc536b485ec1bf.tar.bz2
rneovim-c61bf43a90238f20716d48554ddc536b485ec1bf.zip
gendispatch: warn for deprecated alias if the deprecated function has implemation
Diffstat (limited to 'scripts/gendispatch.lua')
-rw-r--r--scripts/gendispatch.lua17
1 files changed, 14 insertions, 3 deletions
diff --git a/scripts/gendispatch.lua b/scripts/gendispatch.lua
index 96322ccf73..40507d0afe 100644
--- a/scripts/gendispatch.lua
+++ b/scripts/gendispatch.lua
@@ -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