[njs] Added njs_vm_object_keys().
Dmitry Volyntsev
xeioex at nginx.com
Mon Jan 11 19:54:06 UTC 2021
details: https://hg.nginx.org/njs/rev/dc7d94c05669
branches:
changeset: 1592:dc7d94c05669
user: Dmitry Volyntsev <xeioex at nginx.com>
date: Mon Jan 11 19:53:10 2021 +0000
description:
Added njs_vm_object_keys().
diffstat:
src/njs.h | 2 ++
src/njs_vm.c | 17 +++++++++++++++++
2 files changed, 19 insertions(+), 0 deletions(-)
diffs (39 lines):
diff -r 1b99785e0711 -r dc7d94c05669 src/njs.h
--- a/src/njs.h Mon Jan 11 19:53:09 2021 +0000
+++ b/src/njs.h Mon Jan 11 19:53:10 2021 +0000
@@ -402,6 +402,8 @@ NJS_EXPORT njs_int_t njs_value_is_buffer
NJS_EXPORT njs_int_t njs_vm_object_alloc(njs_vm_t *vm, njs_value_t *retval,
...);
+NJS_EXPORT njs_value_t *njs_vm_object_keys(njs_vm_t *vm, njs_value_t *value,
+ njs_value_t *retval);
NJS_EXPORT njs_value_t *njs_vm_object_prop(njs_vm_t *vm,
njs_value_t *value, const njs_str_t *key, njs_opaque_value_t *retval);
diff -r 1b99785e0711 -r dc7d94c05669 src/njs_vm.c
--- a/src/njs_vm.c Mon Jan 11 19:53:09 2021 +0000
+++ b/src/njs_vm.c Mon Jan 11 19:53:10 2021 +0000
@@ -976,6 +976,23 @@ done:
}
+njs_value_t *
+njs_vm_object_keys(njs_vm_t *vm, njs_value_t *value, njs_value_t *retval)
+{
+ njs_array_t *keys;
+
+ keys = njs_value_own_enumerate(vm, value, NJS_ENUM_KEYS,
+ NJS_ENUM_STRING, 0);
+ if (njs_slow_path(keys == NULL)) {
+ return NULL;
+ }
+
+ njs_set_array(retval, keys);
+
+ return retval;
+}
+
+
njs_int_t
njs_vm_array_alloc(njs_vm_t *vm, njs_value_t *retval, uint32_t spare)
{
More information about the nginx-devel
mailing list