Data Structures | Macros | Functions
helpers.h File Reference
#include "nvim/api/private/defs.h"
#include "nvim/decoration.h"
#include "nvim/ex_eval.h"
#include "nvim/getchar.h"
#include "nvim/lib/kvec.h"
#include "nvim/memory.h"
#include "nvim/vim.h"

Go to the source code of this file.

Data Structures

struct  TryState
 

Macros

#define OBJECT_OBJ(o)   o
 
#define BOOLEAN_OBJ(b)
 
#define BOOL(b)   BOOLEAN_OBJ(b)
 
#define INTEGER_OBJ(i)
 
#define FLOAT_OBJ(f)
 
#define STRING_OBJ(s)
 
#define CSTR_TO_OBJ(s)   STRING_OBJ(cstr_to_string(s))
 
#define BUFFER_OBJ(s)
 
#define WINDOW_OBJ(s)
 
#define TABPAGE_OBJ(s)
 
#define ARRAY_OBJ(a)
 
#define DICTIONARY_OBJ(d)
 
#define LUAREF_OBJ(r)
 
#define NIL   ((Object)OBJECT_INIT)
 
#define NULL_STRING   ((String)STRING_INIT)
 
#define HAS_KEY(o)   ((o).type != kObjectTypeNil)
 
#define PUT(dict, k, v)   kv_push(dict, ((KeyValuePair) { .key = cstr_to_string(k), .value = v }))
 
#define PUT_BOOL(dict, name, condition)   PUT(dict, name, BOOLEAN_OBJ(condition));
 
#define ADD(array, item)   kv_push(array, item)
 
#define FIXED_TEMP_ARRAY(name, fixsize)
 
#define STATIC_CSTR_AS_STRING(s)   ((String) { .data = s, .size = sizeof(s) - 1 })
 
#define STATIC_CSTR_TO_STRING(s)
 
#define api_init_boolean
 
#define api_init_integer
 
#define api_init_float
 
#define api_init_string   = STRING_INIT
 
#define api_init_buffer
 
#define api_init_window
 
#define api_init_tabpage
 
#define api_init_object   = NIL
 
#define api_init_array   = ARRAY_DICT_INIT
 
#define api_init_dictionary   = ARRAY_DICT_INIT
 
#define api_free_boolean(value)
 
#define api_free_integer(value)
 
#define api_free_float(value)
 
#define api_free_buffer(value)
 
#define api_free_window(value)
 
#define api_free_tabpage(value)
 
#define handle_get_buffer(h)   pmap_get(handle_T)(&buffer_handles, (h))
 
#define handle_get_window(h)   pmap_get(handle_T)(&window_handles, (h))
 
#define handle_get_tabpage(h)   pmap_get(handle_T)(&tabpage_handles, (h))
 
#define TRY_WRAP(code)
 
#define FOREACH_ITEM(a, __foreach_item, code)
 
#define WITH_SCRIPT_CONTEXT(channel_id, code)
 

Functions

EXTERN PMap (handle_T) buffer_handles INIT( = MAP_INIT)
 

Macro Definition Documentation

◆ ADD

#define ADD (   array,
  item 
)    kv_push(array, item)

◆ api_free_boolean

#define api_free_boolean (   value)

◆ api_free_buffer

#define api_free_buffer (   value)

◆ api_free_float

#define api_free_float (   value)

◆ api_free_integer

#define api_free_integer (   value)

◆ api_free_tabpage

#define api_free_tabpage (   value)

◆ api_free_window

#define api_free_window (   value)

◆ api_init_array

#define api_init_array   = ARRAY_DICT_INIT

◆ api_init_boolean

#define api_init_boolean

◆ api_init_buffer

#define api_init_buffer

◆ api_init_dictionary

#define api_init_dictionary   = ARRAY_DICT_INIT

◆ api_init_float

#define api_init_float

◆ api_init_integer

#define api_init_integer

◆ api_init_object

#define api_init_object   = NIL

◆ api_init_string

#define api_init_string   = STRING_INIT

◆ api_init_tabpage

#define api_init_tabpage

◆ api_init_window

#define api_init_window

◆ ARRAY_OBJ

#define ARRAY_OBJ (   a)
Value:
((Object) { \
.type = kObjectTypeArray, \
.data.array = a })

◆ BOOL

#define BOOL (   b)    BOOLEAN_OBJ(b)

◆ BOOLEAN_OBJ

#define BOOLEAN_OBJ (   b)
Value:
((Object) { \
.type = kObjectTypeBoolean, \
.data.boolean = b })

◆ BUFFER_OBJ

#define BUFFER_OBJ (   s)
Value:
((Object) { \
.type = kObjectTypeBuffer, \
.data.integer = s })

◆ CSTR_TO_OBJ

#define CSTR_TO_OBJ (   s)    STRING_OBJ(cstr_to_string(s))

◆ DICTIONARY_OBJ

#define DICTIONARY_OBJ (   d)
Value:
((Object) { \
.data.dictionary = d })

◆ FIXED_TEMP_ARRAY

#define FIXED_TEMP_ARRAY (   name,
  fixsize 
)
Value:
Object name##__items[fixsize]; \
name.size = fixsize; \
name.items = name##__items; \

◆ FLOAT_OBJ

#define FLOAT_OBJ (   f)
Value:
((Object) { \
.type = kObjectTypeFloat, \
.data.floating = f })

◆ FOREACH_ITEM

#define FOREACH_ITEM (   a,
  __foreach_item,
  code 
)
Value:
for (size_t (__foreach_item##_index) = 0; (__foreach_item##_index) < (a).size; \
(__foreach_item##_index)++) { \
Object __foreach_item = (a).items[__foreach_item##_index]; \
code; \
}

◆ handle_get_buffer

#define handle_get_buffer (   h)    pmap_get(handle_T)(&buffer_handles, (h))

◆ handle_get_tabpage

#define handle_get_tabpage (   h)    pmap_get(handle_T)(&tabpage_handles, (h))

◆ handle_get_window

#define handle_get_window (   h)    pmap_get(handle_T)(&window_handles, (h))

◆ HAS_KEY

#define HAS_KEY (   o)    ((o).type != kObjectTypeNil)

◆ INTEGER_OBJ

#define INTEGER_OBJ (   i)
Value:
((Object) { \
.type = kObjectTypeInteger, \
.data.integer = i })

◆ LUAREF_OBJ

#define LUAREF_OBJ (   r)
Value:
((Object) { \
.type = kObjectTypeLuaRef, \
.data.luaref = r })

◆ NIL

#define NIL   ((Object)OBJECT_INIT)

◆ NULL_STRING

#define NULL_STRING   ((String)STRING_INIT)

◆ OBJECT_OBJ

#define OBJECT_OBJ (   o)    o

◆ PUT

#define PUT (   dict,
  k,
  v 
)    kv_push(dict, ((KeyValuePair) { .key = cstr_to_string(k), .value = v }))

◆ PUT_BOOL

#define PUT_BOOL (   dict,
  name,
  condition 
)    PUT(dict, name, BOOLEAN_OBJ(condition));

◆ STATIC_CSTR_AS_STRING

#define STATIC_CSTR_AS_STRING (   s)    ((String) { .data = s, .size = sizeof(s) - 1 })

◆ STATIC_CSTR_TO_STRING

#define STATIC_CSTR_TO_STRING (   s)
Value:
((String){ \
.data = xmemdupz(s, sizeof(s) - 1), \
.size = sizeof(s) - 1 })

Create a new String instance, putting data in allocated memory

Parameters
[in]sString to work with. Must be a string literal.

◆ STRING_OBJ

#define STRING_OBJ (   s)
Value:
((Object) { \
.type = kObjectTypeString, \
.data.string = s })

◆ TABPAGE_OBJ

#define TABPAGE_OBJ (   s)
Value:
((Object) { \
.type = kObjectTypeTabpage, \
.data.integer = s })

◆ TRY_WRAP

#define TRY_WRAP (   code)
Value:
do { \
struct msglist **saved_msg_list = msg_list; \
struct msglist *private_msg_list; \
msg_list = &private_msg_list; \
private_msg_list = NULL; \
code \
msg_list = saved_msg_list; /* Restore the exception context. */ \
} while (0)

◆ WINDOW_OBJ

#define WINDOW_OBJ (   s)
Value:
((Object) { \
.type = kObjectTypeWindow, \
.data.integer = s })

◆ WITH_SCRIPT_CONTEXT

#define WITH_SCRIPT_CONTEXT (   channel_id,
  code 
)
Value:
do { \
current_sctx.sc_sid = \
(channel_id) == LUA_INTERNAL_CALL ? SID_LUA : SID_API_CLIENT; \
current_sctx.sc_lnum = 0; \
current_channel_id = channel_id; \
code; \
current_sctx = save_current_sctx; \
} while (0);

Function Documentation

◆ PMap()

EXTERN PMap ( handle_T  ) = MAP_INIT)
current_sctx
current_sctx
Definition: userfunc.c:1094
i
static void int i
Definition: edit.c:3047
msglist
Definition: ex_eval.h:43
Array
Definition: defs.h:88
SID_API_CLIENT
#define SID_API_CLIENT
Definition: globals.h:340
sctx_T
Definition: typval.h:280
kObjectTypeLuaRef
@ kObjectTypeLuaRef
Definition: defs.h:108
kObjectTypeDictionary
@ kObjectTypeDictionary
Definition: defs.h:107
kObjectTypeBoolean
@ kObjectTypeBoolean
Definition: defs.h:102
kObjectTypeArray
@ kObjectTypeArray
Definition: defs.h:106
save_current_sctx
const sctx_T save_current_sctx
Definition: userfunc.c:1093
Object
struct object Object
Definition: defs.h:86
String
Definition: defs.h:77
kObjectTypeBuffer
@ kObjectTypeBuffer
Definition: defs.h:110
kObjectTypeFloat
@ kObjectTypeFloat
Definition: defs.h:104
s
char * s
Definition: eval.c:797
kObjectTypeString
@ kObjectTypeString
Definition: defs.h:105
kObjectTypeTabpage
@ kObjectTypeTabpage
Definition: defs.h:112
items
fuzzyItem_T *const items
Definition: search.c:5111
r
regsubs_T * r
Definition: regexp_nfa.c:5240
LUA_INTERNAL_CALL
#define LUA_INTERNAL_CALL
Internal call from lua code.
Definition: defs.h:47
name
char_u * name
Definition: userfunc.c:817
kObjectTypeInteger
@ kObjectTypeInteger
Definition: defs.h:103
xmemdupz
void * xmemdupz(const void *data, size_t len) FUNC_ATTR_MALLOC FUNC_ATTR_NONNULL_RET FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
Definition: memory.c:201
SID_LUA
#define SID_LUA
Definition: globals.h:339
NULL
return NULL
Definition: eval.c:9968
ARRAY_DICT_INIT
#define ARRAY_DICT_INIT
Definition: defs.h:11
kObjectTypeWindow
@ kObjectTypeWindow
Definition: defs.h:111