aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/private
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/api/private')
-rw-r--r--src/nvim/api/private/defs.h18
-rw-r--r--src/nvim/api/private/helpers.c2
-rw-r--r--src/nvim/api/private/helpers.h51
3 files changed, 62 insertions, 9 deletions
diff --git a/src/nvim/api/private/defs.h b/src/nvim/api/private/defs.h
index ee0fc02c4d..b049412014 100644
--- a/src/nvim/api/private/defs.h
+++ b/src/nvim/api/private/defs.h
@@ -65,8 +65,16 @@ typedef enum {
kObjectTypeInteger,
kObjectTypeFloat,
kObjectTypeString,
+ kObjectTypeBuffer,
+ kObjectTypeWindow,
+ kObjectTypeTabpage,
kObjectTypeArray,
- kObjectTypeDictionary
+ kObjectTypeDictionary,
+ kObjectTypePosition,
+ kObjectTypeStringArray,
+ kObjectTypeBufferArray,
+ kObjectTypeWindowArray,
+ kObjectTypeTabpageArray,
} ObjectType;
struct object {
@@ -76,8 +84,16 @@ struct object {
Integer integer;
Float floating;
String string;
+ Buffer buffer;
+ Window window;
+ Tabpage tabpage;
Array array;
Dictionary dictionary;
+ Position position;
+ StringArray stringarray;
+ BufferArray bufferarray;
+ WindowArray windowarray;
+ TabpageArray tabpagearray;
} data;
};
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c
index d5ebc93f7c..024f0c2405 100644
--- a/src/nvim/api/private/helpers.c
+++ b/src/nvim/api/private/helpers.c
@@ -426,6 +426,8 @@ bool object_to_vim(Object obj, typval_T *tv, Error *err)
}
tv->vval.v_dict->dv_refcount++;
break;
+ default:
+ abort();
}
return true;
diff --git a/src/nvim/api/private/helpers.h b/src/nvim/api/private/helpers.h
index e1e1a35490..f1b9dc3bc8 100644
--- a/src/nvim/api/private/helpers.h
+++ b/src/nvim/api/private/helpers.h
@@ -14,7 +14,9 @@
err->set = true; \
} while (0)
-#define BOOL_OBJ(b) ((Object) { \
+#define OBJECT_OBJ(o) o
+
+#define BOOLEAN_OBJ(b) ((Object) { \
.type = kObjectTypeBoolean, \
.data.boolean = b \
})
@@ -26,26 +28,59 @@
#define STRING_OBJ(s) ((Object) { \
.type = kObjectTypeString, \
- .data.string = cstr_to_string(s) \
+ .data.string = s \
})
-#define STRINGL_OBJ(d, s) ((Object) { \
- .type = kObjectTypeString, \
- .data.string = (String) { \
- .size = s, \
- .data = xmemdup(d, s) \
- }})
+#define BUFFER_OBJ(s) ((Object) { \
+ .type = kObjectTypeBuffer, \
+ .data.buffer = s \
+ })
+
+#define WINDOW_OBJ(s) ((Object) { \
+ .type = kObjectTypeWindow, \
+ .data.window = s \
+ })
+
+#define TABPAGE_OBJ(s) ((Object) { \
+ .type = kObjectTypeTabpage, \
+ .data.tabpage = s \
+ })
#define ARRAY_OBJ(a) ((Object) { \
.type = kObjectTypeArray, \
.data.array = a \
})
+#define STRINGARRAY_OBJ(a) ((Object) { \
+ .type = kObjectTypeStringArray, \
+ .data.stringarray = a \
+ })
+
+#define BUFFERARRAY_OBJ(a) ((Object) { \
+ .type = kObjectTypeBufferArray, \
+ .data.bufferarray = a \
+ })
+
+#define WINDOWARRAY_OBJ(a) ((Object) { \
+ .type = kObjectTypeWindowArray, \
+ .data.windowarray = a \
+ })
+
+#define TABPAGEARRAY_OBJ(a) ((Object) { \
+ .type = kObjectTypeTabpageArray, \
+ .data.tabpagearray = a \
+ })
+
#define DICTIONARY_OBJ(d) ((Object) { \
.type = kObjectTypeDictionary, \
.data.dictionary = d \
})
+#define POSITION_OBJ(p) ((Object) { \
+ .type = kObjectTypePosition, \
+ .data.position = p \
+ })
+
#define NIL ((Object) {.type = kObjectTypeNil})
#define PUT(dict, k, v) \