map.h
Go to the documentation of this file.
1 #ifndef NVIM_MAP_H
2 #define NVIM_MAP_H
3 
4 #include <stdbool.h>
5 
6 #include "nvim/map_defs.h"
9 #include "nvim/bufhl_defs.h"
10 #include "nvim/highlight_defs.h"
11 
12 #if defined(__NetBSD__)
13 # undef uint64_t
14 # define uint64_t uint64_t
15 #endif
16 
17 #define MAP_DECLS(T, U) \
18  KHASH_DECLARE(T##_##U##_map, T, U) \
19  \
20  typedef struct { \
21  khash_t(T##_##U##_map) *table; \
22  } Map(T, U); \
23  \
24  Map(T, U) *map_##T##_##U##_new(void); \
25  void map_##T##_##U##_free(Map(T, U) *map); \
26  U map_##T##_##U##_get(Map(T, U) *map, T key); \
27  bool map_##T##_##U##_has(Map(T, U) *map, T key); \
28  U map_##T##_##U##_put(Map(T, U) *map, T key, U value); \
29  U *map_##T##_##U##_ref(Map(T, U) *map, T key, bool put); \
30  U map_##T##_##U##_del(Map(T, U) *map, T key); \
31  void map_##T##_##U##_clear(Map(T, U) *map);
32 
33 MAP_DECLS(int, int)
35 MAP_DECLS(ptr_t, ptr_t)
36 MAP_DECLS(uint64_t, ptr_t)
37 MAP_DECLS(handle_T, ptr_t)
39 MAP_DECLS(HlEntry, int)
40 MAP_DECLS(String, handle_T)
41 
42 #define map_new(T, U) map_##T##_##U##_new
43 #define map_free(T, U) map_##T##_##U##_free
44 #define map_get(T, U) map_##T##_##U##_get
45 #define map_has(T, U) map_##T##_##U##_has
46 #define map_put(T, U) map_##T##_##U##_put
47 #define map_ref(T, U) map_##T##_##U##_ref
48 #define map_del(T, U) map_##T##_##U##_del
49 #define map_clear(T, U) map_##T##_##U##_clear
50 
51 #define pmap_new(T) map_new(T, ptr_t)
52 #define pmap_free(T) map_free(T, ptr_t)
53 #define pmap_get(T) map_get(T, ptr_t)
54 #define pmap_has(T) map_has(T, ptr_t)
55 #define pmap_put(T) map_put(T, ptr_t)
56 #define pmap_del(T) map_del(T, ptr_t)
57 #define pmap_clear(T) map_clear(T, ptr_t)
58 
59 #define map_foreach(map, key, value, block) \
60  kh_foreach(map->table, key, value, block)
61 
62 #define map_foreach_value(map, value, block) \
63  kh_foreach_value(map->table, value, block)
64 
65 #endif // NVIM_MAP_H
Definition: defs.h:77
const char * cstr_t
Definition: map_defs.h:6
Definition: highlight_defs.h:165
int handle_T
Definition: types.h:17
#define MAP_DECLS(T, U)
Definition: map.h:17
void * ptr_t
Definition: map_defs.h:7
Definition: dispatch.h:12