aboutsummaryrefslogtreecommitdiff
path: root/src/api/helpers.h
blob: ddb46eaad4bc1ce7560a9ff75a42ac77825bce0b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#ifndef NEOVIM_API_HELPERS_H
#define NEOVIM_API_HELPERS_H

#include <stdbool.h>

#include "api/defs.h"
#include "../vim.h"

#define set_api_error(message, err)                \
  do {                                             \
    strncpy(err->msg, message, sizeof(err->msg));  \
    err->set = true;                               \
  } while (0)

/// Start block that may cause vimscript exceptions
void try_start(void);

/// End try block, set the error message if any and return true if an error
/// occurred.
///
/// @param err Pointer to the stack-allocated error object
/// @return true if an error occurred
bool try_end(Error *err);

/// Convert a vim object to an `Object` instance, recursively expanding
/// Arrays/Dictionaries.
///
/// @param obj The source object
/// @return The converted value
Object vim_to_object(typval_T *obj);

#endif /* NEOVIM_API_HELPERS_H */