mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
fix(api): deprecate nvim_subscribe, nvim_unsubscribe #30456
Problem:
- nvim_subscribe, nvim_unsubscribe were deprecated in
aec4938a21
but this wasn't set in the
API metadata.
- The function annotations
```
FUNC_API_SINCE(1) FUNC_API_REMOTE_ONLY FUNC_API_DEPRECATED_SINCE(13)
```
cause this test to fail:
```
RUN T3 api metadata functions are compatible with old metadata or have new level: 3.00 ms ERR
test/functional/api/version_spec.lua:135: function vim_subscribe was removed but exists in level 0 which nvim should be compatible with
stack traceback:
test/functional/api/version_spec.lua:135: in function <test/functional/api/version_spec.lua:128>
```
Solution:
- Set the API metadata.
- Rearrange the annotations so that FUNC_API_DEPRECATED_SINCE is 2nd:
```
FUNC_API_SINCE(1) FUNC_API_DEPRECATED_SINCE(13) FUNC_API_REMOTE_ONLY
```
This commit is contained in:
parent
c1378413c1
commit
716adbcc45
@ -798,7 +798,8 @@ theend:
|
||||
/// @param channel_id Channel id (passed automatically by the dispatcher)
|
||||
/// @param event Event type string
|
||||
void nvim_subscribe(uint64_t channel_id, String event)
|
||||
FUNC_API_SINCE(1) FUNC_API_REMOTE_ONLY
|
||||
// XXX: c_grammar.lua is order-sensitive.
|
||||
FUNC_API_SINCE(1) FUNC_API_DEPRECATED_SINCE(13) FUNC_API_REMOTE_ONLY
|
||||
{
|
||||
// Does nothing. `rpcnotify(0,…)` broadcasts to all channels, there are no "subscriptions".
|
||||
}
|
||||
@ -808,7 +809,8 @@ void nvim_subscribe(uint64_t channel_id, String event)
|
||||
/// @param channel_id Channel id (passed automatically by the dispatcher)
|
||||
/// @param event Event type string
|
||||
void nvim_unsubscribe(uint64_t channel_id, String event)
|
||||
FUNC_API_SINCE(1) FUNC_API_REMOTE_ONLY
|
||||
// XXX: c_grammar.lua is order-sensitive.
|
||||
FUNC_API_SINCE(1) FUNC_API_DEPRECATED_SINCE(13) FUNC_API_REMOTE_ONLY
|
||||
{
|
||||
// Does nothing. `rpcnotify(0,…)` broadcasts to all channels, there are no "subscriptions".
|
||||
}
|
||||
|
@ -257,6 +257,11 @@ if arg[1] == '--test' then
|
||||
'char *xstpcpy(char *restrict dst, const char *restrict src) {}',
|
||||
'bool try_leave(const TryState *const tstate, Error *const err) {}',
|
||||
'void api_set_error(ErrorType errType) {}',
|
||||
{
|
||||
'void nvim_subscribe(uint64_t channel_id, String event)',
|
||||
'FUNC_API_SINCE(1) FUNC_API_DEPRECATED_SINCE(13) FUNC_API_REMOTE_ONLY',
|
||||
'{}',
|
||||
},
|
||||
|
||||
-- Do not consume leading preproc statements
|
||||
{
|
||||
|
@ -1,3 +1,10 @@
|
||||
-- Example (manual) invocation:
|
||||
--
|
||||
-- make
|
||||
-- cp build/nvim_version.lua src/nvim/
|
||||
-- cd src/nvim
|
||||
-- nvim -l generators/gen_api_dispatch.lua "../../build/src/nvim/auto/api/private/dispatch_wrappers.generated.h" "../../build/src/nvim/auto/api/private/api_metadata.generated.h" "../../build/funcs_metadata.mpack" "../../build/src/nvim/auto/lua_api_c_bindings.generated.h" "../../build/src/nvim/auto/keysets_defs.generated.h" "../../build/ui_metadata.mpack" "../../build/cmake.config/auto/versiondef_git.h" "./api/autocmd.h" "./api/buffer.h" "./api/command.h" "./api/deprecated.h" "./api/extmark.h" "./api/keysets_defs.h" "./api/options.h" "./api/tabpage.h" "./api/ui.h" "./api/vim.h" "./api/vimscript.h" "./api/win_config.h" "./api/window.h" "../../build/include/api/autocmd.h.generated.h" "../../build/include/api/buffer.h.generated.h" "../../build/include/api/command.h.generated.h" "../../build/include/api/deprecated.h.generated.h" "../../build/include/api/extmark.h.generated.h" "../../build/include/api/options.h.generated.h" "../../build/include/api/tabpage.h.generated.h" "../../build/include/api/ui.h.generated.h" "../../build/include/api/vim.h.generated.h" "../../build/include/api/vimscript.h.generated.h" "../../build/include/api/win_config.h.generated.h" "../../build/include/api/window.h.generated.h"
|
||||
|
||||
local mpack = vim.mpack
|
||||
|
||||
local hashy = require 'generators.hashy'
|
||||
@ -8,7 +15,7 @@ assert(#arg >= pre_args)
|
||||
local dispatch_outputf = arg[1]
|
||||
-- output h file with packed metadata (api_metadata.generated.h)
|
||||
local api_metadata_outputf = arg[2]
|
||||
-- output metadata mpack file, for use by other build scripts (api_metadata.mpack)
|
||||
-- output metadata mpack file, for use by other build scripts (funcs_metadata.mpack)
|
||||
local mpack_outputf = arg[3]
|
||||
local lua_c_bindings_outputf = arg[4] -- lua_api_c_bindings.generated.c
|
||||
local keysets_outputf = arg[5] -- keysets_defs.generated.h
|
||||
@ -235,7 +242,7 @@ for x in string.gmatch(ui_options_text, '"([a-z][a-z_]+)"') do
|
||||
table.insert(ui_options, x)
|
||||
end
|
||||
|
||||
local version = require 'nvim_version'
|
||||
local version = require 'nvim_version' -- `build/nvim_version.lua` file.
|
||||
local git_version = io.open(git_version_inputf):read '*a'
|
||||
local version_build = string.match(git_version, '#define NVIM_VERSION_BUILD "([^"]+)"') or vim.NIL
|
||||
|
||||
@ -266,10 +273,7 @@ fixdict(1 + #version)
|
||||
for _, item in ipairs(version) do
|
||||
-- NB: all items are mandatory. But any error will be less confusing
|
||||
-- with placeholder vim.NIL (than invalid mpack data)
|
||||
local val = item[2]
|
||||
if val == nil then
|
||||
val = vim.NIL
|
||||
end
|
||||
local val = item[2] == nil and vim.NIL or item[2]
|
||||
put(item[1], val)
|
||||
end
|
||||
put('build', version_build)
|
||||
|
@ -93,28 +93,28 @@ describe('api metadata', function()
|
||||
local function clean_level_0(metadata)
|
||||
for _, f in ipairs(metadata.functions) do
|
||||
f.can_fail = nil
|
||||
f.async = nil
|
||||
f.async = nil -- XXX: renamed to "fast".
|
||||
f.receives_channel_id = nil
|
||||
f.since = 0
|
||||
end
|
||||
end
|
||||
|
||||
local api_info, compat, stable, api_level
|
||||
local api_info --[[@type table]]
|
||||
local compat --[[@type integer]]
|
||||
local stable --[[@type integer]]
|
||||
local api_level --[[@type integer]]
|
||||
local old_api = {}
|
||||
setup(function()
|
||||
clear() -- Ensure a session before requesting api_info.
|
||||
--[[@type { version: {api_compatible: integer, api_level: integer, api_prerelease: boolean} }]]
|
||||
api_info = api.nvim_get_api_info()[2]
|
||||
compat = api_info.version.api_compatible
|
||||
api_level = api_info.version.api_level
|
||||
if api_info.version.api_prerelease then
|
||||
stable = api_level - 1
|
||||
else
|
||||
stable = api_level
|
||||
end
|
||||
stable = api_info.version.api_prerelease and api_level - 1 or api_level
|
||||
|
||||
for level = compat, stable do
|
||||
local path = ('test/functional/fixtures/api_level_' .. tostring(level) .. '.mpack')
|
||||
old_api[level] = read_mpack_file(path)
|
||||
old_api[level] = read_mpack_file(path) --[[@type table]]
|
||||
if old_api[level] == nil then
|
||||
local errstr = 'missing metadata fixture for stable level ' .. level .. '. '
|
||||
if level == api_level and not api_info.version.api_prerelease then
|
||||
|
Loading…
Reference in New Issue
Block a user