diff options
author | Thiago de Arruda <tpadilha84@gmail.com> | 2014-05-30 18:41:57 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-05-30 20:42:19 -0300 |
commit | 82e3e7047f500b7523a2f36e76171a0e9fdee328 (patch) | |
tree | 51d95a2128560429ef291d485abef5e6d66dabe4 /src/nvim/api/private/helpers.c | |
parent | a581173e715af4f7ef4e6be232ed828bd7dea9b8 (diff) | |
download | rneovim-82e3e7047f500b7523a2f36e76171a0e9fdee328.tar.gz rneovim-82e3e7047f500b7523a2f36e76171a0e9fdee328.tar.bz2 rneovim-82e3e7047f500b7523a2f36e76171a0e9fdee328.zip |
Refactor: Redefine `Map(T)` as a more generic `Map(T, U)` macro
To replace `Map(T)`, a new macro `PMap(T)` was defined as `Map(T, ptr_t)` for
writing maps that store pointers with less boilerplate
Diffstat (limited to 'src/nvim/api/private/helpers.c')
-rw-r--r-- | src/nvim/api/private/helpers.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index 861ac8cc1b..705e16b13f 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -21,7 +21,7 @@ /// @param obj The source object /// @param lookup Lookup table containing pointers to all processed objects /// @return The converted value -static Object vim_to_object_rec(typval_T *obj, Map(ptr_t) *lookup); +static Object vim_to_object_rec(typval_T *obj, PMap(ptr_t) *lookup); static bool object_to_vim(Object obj, typval_T *tv, Error *err); @@ -278,10 +278,10 @@ Object vim_to_object(typval_T *obj) { Object rv; // We use a lookup table to break out of cyclic references - Map(ptr_t) *lookup = map_new(ptr_t)(); + PMap(ptr_t) *lookup = pmap_new(ptr_t)(); rv = vim_to_object_rec(obj, lookup); // Free the table - map_free(ptr_t)(lookup); + pmap_free(ptr_t)(lookup); return rv; } @@ -422,18 +422,18 @@ static bool object_to_vim(Object obj, typval_T *tv, Error *err) return true; } -static Object vim_to_object_rec(typval_T *obj, Map(ptr_t) *lookup) +static Object vim_to_object_rec(typval_T *obj, PMap(ptr_t) *lookup) { Object rv = {.type = kObjectTypeNil}; if (obj->v_type == VAR_LIST || obj->v_type == VAR_DICT) { // Container object, add it to the lookup table - if (map_has(ptr_t)(lookup, obj)) { + if (pmap_has(ptr_t)(lookup, obj)) { // It's already present, meaning we alredy processed it so just return // nil instead. return rv; } - map_put(ptr_t)(lookup, obj, NULL); + pmap_put(ptr_t)(lookup, obj, NULL); } switch (obj->v_type) { |