aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/CMakeLists.txt3
-rw-r--r--src/nvim/api/private/helpers.c18
-rw-r--r--src/nvim/api/ui_events.in.h86
-rw-r--r--src/nvim/generators/gen_api_ui_events.lua26
4 files changed, 103 insertions, 30 deletions
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt
index 3e0dadaa81..a5d4170062 100644
--- a/src/nvim/CMakeLists.txt
+++ b/src/nvim/CMakeLists.txt
@@ -26,6 +26,7 @@ set(GENERATED_UI_EVENTS ${GENERATED_DIR}/ui_events.generated.h)
set(GENERATED_UI_EVENTS_CALL ${GENERATED_DIR}/ui_events_call.generated.h)
set(GENERATED_UI_EVENTS_REMOTE ${GENERATED_DIR}/ui_events_remote.generated.h)
set(GENERATED_UI_EVENTS_BRIDGE ${GENERATED_DIR}/ui_events_bridge.generated.h)
+set(GENERATED_UI_EVENTS_METADATA ${GENERATED_DIR}/api/private/ui_events_metadata.generated.h)
set(GENERATED_EX_CMDS_ENUM ${GENERATED_INCLUDES_DIR}/ex_cmds_enum.generated.h)
set(GENERATED_EX_CMDS_DEFS ${GENERATED_DIR}/ex_cmds_defs.generated.h)
set(GENERATED_FUNCS ${GENERATED_DIR}/funcs.generated.h)
@@ -269,12 +270,14 @@ add_custom_command(
${GENERATED_UI_EVENTS_CALL}
${GENERATED_UI_EVENTS_REMOTE}
${GENERATED_UI_EVENTS_BRIDGE}
+ ${GENERATED_UI_EVENTS_METADATA}
COMMAND ${LUA_PRG} ${API_UI_EVENTS_GENERATOR} ${CMAKE_CURRENT_LIST_DIR}
${CMAKE_CURRENT_LIST_DIR}/api/ui_events.in.h
${GENERATED_UI_EVENTS}
${GENERATED_UI_EVENTS_CALL}
${GENERATED_UI_EVENTS_REMOTE}
${GENERATED_UI_EVENTS_BRIDGE}
+ ${GENERATED_UI_EVENTS_METADATA}
DEPENDS
${API_UI_EVENTS_GENERATOR}
${CMAKE_CURRENT_LIST_DIR}/api/ui_events.in.h
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c
index 361570bff4..1d7b305da3 100644
--- a/src/nvim/api/private/helpers.c
+++ b/src/nvim/api/private/helpers.c
@@ -33,6 +33,7 @@ typedef struct {
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "api/private/helpers.c.generated.h"
# include "api/private/funcs_metadata.generated.h"
+# include "api/private/ui_events_metadata.generated.h"
#endif
/// Start block that may cause vimscript exceptions
@@ -820,6 +821,7 @@ Dictionary api_metadata(void)
if (!metadata.size) {
PUT(metadata, "version", DICTIONARY_OBJ(version_dict()));
init_function_metadata(&metadata);
+ init_ui_event_metadata(&metadata);
init_error_type_metadata(&metadata);
init_type_metadata(&metadata);
}
@@ -843,6 +845,22 @@ static void init_function_metadata(Dictionary *metadata)
PUT(*metadata, "functions", functions);
}
+static void init_ui_event_metadata(Dictionary *metadata)
+{
+ msgpack_unpacked unpacked;
+ msgpack_unpacked_init(&unpacked);
+ if (msgpack_unpack_next(&unpacked,
+ (const char *)ui_events_metadata,
+ sizeof(ui_events_metadata),
+ NULL) != MSGPACK_UNPACK_SUCCESS) {
+ abort();
+ }
+ Object ui_events;
+ msgpack_rpc_to_object(&unpacked.data, &ui_events);
+ msgpack_unpacked_destroy(&unpacked);
+ PUT(*metadata, "ui_events", ui_events);
+}
+
static void init_error_type_metadata(Dictionary *metadata)
{
Dictionary types = ARRAY_DICT_INIT;
diff --git a/src/nvim/api/ui_events.in.h b/src/nvim/api/ui_events.in.h
index 39d508452c..02c81e649b 100644
--- a/src/nvim/api/ui_events.in.h
+++ b/src/nvim/api/ui_events.in.h
@@ -3,41 +3,69 @@
// This file is not compiled, just parsed for definitons
#ifdef INCLUDE_GENERATED_DECLARATIONS
-#error "don't include this file, include nvim/ui.h"
+# error "don't include this file, include nvim/ui.h"
#endif
#include "nvim/api/private/defs.h"
#include "nvim/func_attr.h"
#include "nvim/ui.h"
-void resize(Integer rows, Integer columns);
-void clear(void);
-void eol_clear(void);
-void cursor_goto(Integer row, Integer col);
-void mode_info_set(Boolean enabled, Array cursor_styles);
-void update_menu(void);
-void busy_start(void);
-void busy_stop(void);
-void mouse_on(void);
-void mouse_off(void);
-void mode_change(String mode, Integer mode_idx);
-void set_scroll_region(Integer top, Integer bot, Integer left, Integer right);
-void scroll(Integer count);
-void highlight_set(HlAttrs attrs) REMOTE_IMPL BRIDGE_IMPL;
-void put(String str);
-void bell(void);
-void visual_bell(void);
-void flush(void) REMOTE_IMPL;
-void update_fg(Integer fg);
-void update_bg(Integer bg);
-void update_sp(Integer sp);
-void suspend(void) BRIDGE_IMPL;
-void set_title(String title);
-void set_icon(String icon);
+void resize(Integer rows, Integer columns)
+ FUNC_API_SINCE(3);
+void clear(void)
+ FUNC_API_SINCE(3);
+void eol_clear(void)
+ FUNC_API_SINCE(3);
+void cursor_goto(Integer row, Integer col)
+ FUNC_API_SINCE(3);
+void mode_info_set(Boolean enabled, Array cursor_styles)
+ FUNC_API_SINCE(3);
+void update_menu(void)
+ FUNC_API_SINCE(3);
+void busy_start(void)
+ FUNC_API_SINCE(3);
+void busy_stop(void)
+ FUNC_API_SINCE(3);
+void mouse_on(void)
+ FUNC_API_SINCE(3);
+void mouse_off(void)
+ FUNC_API_SINCE(3);
+void mode_change(String mode, Integer mode_idx)
+ FUNC_API_SINCE(3);
+void set_scroll_region(Integer top, Integer bot, Integer left, Integer right)
+ FUNC_API_SINCE(3);
+void scroll(Integer count)
+ FUNC_API_SINCE(3);
+void highlight_set(HlAttrs attrs)
+ FUNC_API_SINCE(3) REMOTE_IMPL BRIDGE_IMPL;
+void put(String str)
+ FUNC_API_SINCE(3);
+void bell(void)
+ FUNC_API_SINCE(3);
+void visual_bell(void)
+ FUNC_API_SINCE(3);
+void flush(void)
+ FUNC_API_SINCE(3) REMOTE_IMPL;
+void update_fg(Integer fg)
+ FUNC_API_SINCE(3);
+void update_bg(Integer bg)
+ FUNC_API_SINCE(3);
+void update_sp(Integer sp)
+ FUNC_API_SINCE(3);
+void suspend(void)
+ FUNC_API_SINCE(3) BRIDGE_IMPL;
+void set_title(String title)
+ FUNC_API_SINCE(3);
+void set_icon(String icon)
+ FUNC_API_SINCE(3);
-void popupmenu_show(Array items, Integer selected, Integer row, Integer col) REMOTE_ONLY;
-void popupmenu_hide(void) REMOTE_ONLY;
-void popupmenu_select(Integer selected) REMOTE_ONLY;
-void tabline_update(Tabpage current, Array tabs) REMOTE_ONLY;
+void popupmenu_show(Array items, Integer selected, Integer row, Integer col)
+ FUNC_API_SINCE(3) REMOTE_ONLY;
+void popupmenu_hide(void)
+ FUNC_API_SINCE(3) REMOTE_ONLY;
+void popupmenu_select(Integer selected)
+ FUNC_API_SINCE(3) REMOTE_ONLY;
+void tabline_update(Tabpage current, Array tabs)
+ FUNC_API_SINCE(3) REMOTE_ONLY;
#endif // NVIM_API_UI_EVENTS_IN_H
diff --git a/src/nvim/generators/gen_api_ui_events.lua b/src/nvim/generators/gen_api_ui_events.lua
index 28007d2266..6f76eb5aab 100644
--- a/src/nvim/generators/gen_api_ui_events.lua
+++ b/src/nvim/generators/gen_api_ui_events.lua
@@ -3,12 +3,13 @@ mpack = require('mpack')
local nvimdir = arg[1]
package.path = nvimdir .. '/?.lua;' .. package.path
-assert(#arg == 6)
+assert(#arg == 7)
input = io.open(arg[2], 'rb')
proto_output = io.open(arg[3], 'wb')
call_output = io.open(arg[4], 'wb')
remote_output = io.open(arg[5], 'wb')
bridge_output = io.open(arg[6], 'wb')
+metadata_output = io.open(arg[7], 'wb')
c_grammar = require('generators.c_grammar')
local events = c_grammar.grammar:match(input:read('*all'))
@@ -53,6 +54,12 @@ for i = 1, #events do
ev = events[i]
assert(ev.return_type == 'void')
+ if ev.since == nil then
+ print("Ui event "..ev.name.." lacks since field.\n")
+ os.exit(1)
+ end
+ ev.since = tonumber(ev.since)
+
if not ev.remote_only then
proto_output:write(' void (*'..ev.name..')')
write_signature(proto_output, ev, 'UI *ui')
@@ -134,3 +141,20 @@ end
proto_output:close()
call_output:close()
remote_output:close()
+
+-- don't expose internal attributes like "impl_name" in public metadata
+exported_attributes = {'name', 'parameters',
+ 'since', 'deprecated_since'}
+exported_events = {}
+for _,ev in ipairs(events) do
+ local f_exported = {}
+ for _,attr in ipairs(exported_attributes) do
+ f_exported[attr] = ev[attr]
+ end
+ exported_events[#exported_events+1] = f_exported
+end
+
+packed = mpack.pack(exported_events)
+dump_bin_array = require("generators.dump_bin_array")
+dump_bin_array(metadata_output, 'ui_events_metadata', packed)
+metadata_output:close()