mirror of
https://github.com/neovim/neovim.git
synced 2025-10-09 19:36:40 +00:00
api: Allow blacklist functions that shouldn't be accesible from eval
Blacklist deprecated functions and functions depending on channel_id
This commit is contained in:
@@ -56,6 +56,7 @@ Integer buffer_line_count(Buffer buffer, Error *err)
|
||||
/// @param[out] err Details of an error that may have occurred
|
||||
/// @return The line string
|
||||
String buffer_get_line(Buffer buffer, Integer index, Error *err)
|
||||
FUNC_API_NOEVAL
|
||||
{
|
||||
String rv = { .size = 0 };
|
||||
|
||||
@@ -84,6 +85,7 @@ String buffer_get_line(Buffer buffer, Integer index, Error *err)
|
||||
/// @param line The new line.
|
||||
/// @param[out] err Details of an error that may have occurred
|
||||
void buffer_set_line(Buffer buffer, Integer index, String line, Error *err)
|
||||
FUNC_API_NOEVAL
|
||||
{
|
||||
Object l = STRING_OBJ(line);
|
||||
Array array = { .items = &l, .size = 1 };
|
||||
@@ -102,6 +104,7 @@ void buffer_set_line(Buffer buffer, Integer index, String line, Error *err)
|
||||
/// @param index The line index
|
||||
/// @param[out] err Details of an error that may have occurred
|
||||
void buffer_del_line(Buffer buffer, Integer index, Error *err)
|
||||
FUNC_API_NOEVAL
|
||||
{
|
||||
Array array = ARRAY_DICT_INIT;
|
||||
index = convert_index(index);
|
||||
@@ -122,11 +125,12 @@ void buffer_del_line(Buffer buffer, Integer index, Error *err)
|
||||
/// @param[out] err Details of an error that may have occurred
|
||||
/// @return An array of lines
|
||||
ArrayOf(String) buffer_get_line_slice(Buffer buffer,
|
||||
Integer start,
|
||||
Integer end,
|
||||
Boolean include_start,
|
||||
Boolean include_end,
|
||||
Error *err)
|
||||
Integer start,
|
||||
Integer end,
|
||||
Boolean include_start,
|
||||
Boolean include_end,
|
||||
Error *err)
|
||||
FUNC_API_NOEVAL
|
||||
{
|
||||
start = convert_index(start) + !include_start;
|
||||
end = convert_index(end) + include_end;
|
||||
@@ -229,12 +233,13 @@ end:
|
||||
// array will simply delete the line range)
|
||||
/// @param[out] err Details of an error that may have occurred
|
||||
void buffer_set_line_slice(Buffer buffer,
|
||||
Integer start,
|
||||
Integer end,
|
||||
Boolean include_start,
|
||||
Boolean include_end,
|
||||
ArrayOf(String) replacement,
|
||||
Error *err)
|
||||
Integer start,
|
||||
Integer end,
|
||||
Boolean include_start,
|
||||
Boolean include_end,
|
||||
ArrayOf(String) replacement,
|
||||
Error *err)
|
||||
FUNC_API_NOEVAL
|
||||
{
|
||||
start = convert_index(start) + !include_start;
|
||||
end = convert_index(end) + include_end;
|
||||
@@ -590,6 +595,7 @@ void buffer_insert(Buffer buffer,
|
||||
Integer lnum,
|
||||
ArrayOf(String) lines,
|
||||
Error *err)
|
||||
FUNC_API_NOEVAL
|
||||
{
|
||||
// "lnum" will be the index of the line after inserting,
|
||||
// no matter if it is negative or not
|
||||
|
@@ -48,6 +48,7 @@ void remote_ui_disconnect(uint64_t channel_id)
|
||||
|
||||
void nvim_ui_attach(uint64_t channel_id, Integer width, Integer height,
|
||||
Dictionary options, Error *err)
|
||||
FUNC_API_NOEVAL
|
||||
{
|
||||
if (pmap_has(uint64_t)(connected_uis, channel_id)) {
|
||||
api_set_error(err, Exception, _("UI already attached for channel"));
|
||||
@@ -117,6 +118,7 @@ void ui_attach(uint64_t channel_id, Integer width, Integer height,
|
||||
}
|
||||
|
||||
void nvim_ui_detach(uint64_t channel_id, Error *err)
|
||||
FUNC_API_NOEVAL
|
||||
{
|
||||
if (!pmap_has(uint64_t)(connected_uis, channel_id)) {
|
||||
api_set_error(err, Exception, _("UI is not attached for channel"));
|
||||
@@ -133,6 +135,7 @@ void ui_detach(uint64_t channel_id, Error *err)
|
||||
|
||||
void nvim_ui_try_resize(uint64_t channel_id, Integer width,
|
||||
Integer height, Error *err)
|
||||
FUNC_API_NOEVAL
|
||||
{
|
||||
if (!pmap_has(uint64_t)(connected_uis, channel_id)) {
|
||||
api_set_error(err, Exception, _("UI is not attached for channel"));
|
||||
@@ -159,7 +162,9 @@ void ui_try_resize(uint64_t channel_id, Integer width,
|
||||
}
|
||||
|
||||
void nvim_ui_set_option(uint64_t channel_id, String name,
|
||||
Object value, Error *error) {
|
||||
Object value, Error *error)
|
||||
FUNC_API_NOEVAL
|
||||
{
|
||||
if (!pmap_has(uint64_t)(connected_uis, channel_id)) {
|
||||
api_set_error(error, Exception, _("UI is not attached for channel"));
|
||||
return;
|
||||
|
@@ -583,6 +583,7 @@ void vim_set_current_tabpage(Tabpage tabpage, Error *err)
|
||||
/// @param channel_id The channel id (passed automatically by the dispatcher)
|
||||
/// @param event The event type string
|
||||
void vim_subscribe(uint64_t channel_id, String event)
|
||||
FUNC_API_NOEVAL
|
||||
{
|
||||
size_t length = (event.size < METHOD_MAXLEN ? event.size : METHOD_MAXLEN);
|
||||
char e[METHOD_MAXLEN + 1];
|
||||
@@ -596,6 +597,7 @@ void vim_subscribe(uint64_t channel_id, String event)
|
||||
/// @param channel_id The channel id (passed automatically by the dispatcher)
|
||||
/// @param event The event type string
|
||||
void vim_unsubscribe(uint64_t channel_id, String event)
|
||||
FUNC_API_NOEVAL
|
||||
{
|
||||
size_t length = (event.size < METHOD_MAXLEN ?
|
||||
event.size :
|
||||
@@ -624,7 +626,7 @@ Dictionary vim_get_color_map(void)
|
||||
|
||||
|
||||
Array vim_get_api_info(uint64_t channel_id)
|
||||
FUNC_API_ASYNC
|
||||
FUNC_API_ASYNC FUNC_API_NOEVAL
|
||||
{
|
||||
Array rv = ARRAY_DICT_INIT;
|
||||
|
||||
|
Reference in New Issue
Block a user