Welcome! Log In Create A New Profile

Advanced

[njs] Added njs_vm_object_keys().

Dmitry Volyntsev
January 11, 2021 02:56PM
details: https://hg.nginx.org/njs/rev/dc7d94c05669
branches:
changeset: 1592:dc7d94c05669
user: Dmitry Volyntsev <xeioex@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)
{
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Added njs_vm_object_keys().

Dmitry Volyntsev 36 January 11, 2021 02:56PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 56
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready