aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/private/helpers.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/api/private/helpers.h')
-rw-r--r--src/nvim/api/private/helpers.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/nvim/api/private/helpers.h b/src/nvim/api/private/helpers.h
index 731f186ecc..a946e35149 100644
--- a/src/nvim/api/private/helpers.h
+++ b/src/nvim/api/private/helpers.h
@@ -27,6 +27,10 @@
.type = kObjectTypeInteger, \
.data.integer = i })
+#define FLOATING_OBJ(f) ((Object) { \
+ .type = kObjectTypeFloat, \
+ .data.floating = f })
+
#define STRING_OBJ(s) ((Object) { \
.type = kObjectTypeString, \
.data.string = s })
@@ -61,6 +65,13 @@
#define STATIC_CSTR_AS_STRING(s) ((String) {.data = s, .size = sizeof(s) - 1})
+/// Create a new String instance, putting data in allocated memory
+///
+/// @param[in] s String to work with. Must be a string literal.
+#define STATIC_CSTR_TO_STRING(s) ((String){ \
+ .data = xmemdupz(s, sizeof(s) - 1), \
+ .size = sizeof(s) - 1 })
+
// Helpers used by the generated msgpack-rpc api wrappers
#define api_init_boolean
#define api_init_integer