From: Dmitry Volyntsev Date: Mon, 11 Jan 2021 19:53:10 +0000 (+0000) Subject: Added njs_vm_object_keys(). X-Git-Tag: 0.5.1~12 X-Git-Url: http://www.kaiwu.me/postgresql/commit/static/gitweb.js?a=commitdiff_plain;h=300c8514379c4c2f062e5f3a09fe1ae553329165;p=njs.git Added njs_vm_object_keys(). --- diff --git a/src/njs.h b/src/njs.h index 1e4963f4..39b68fb2 100644 --- a/src/njs.h +++ b/src/njs.h @@ -402,6 +402,8 @@ NJS_EXPORT njs_int_t njs_value_is_buffer(const njs_value_t *value); 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 --git a/src/njs_vm.c b/src/njs_vm.c index 0277ff3a..bb6018ce 100644 --- a/src/njs_vm.c +++ b/src/njs_vm.c @@ -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) {