]> git.kaiwu.me - njs.git/commitdiff
Property enumeration changes.
authorIgor Sysoev <igor@sysoev.ru>
Sat, 12 Dec 2015 21:00:30 +0000 (00:00 +0300)
committerIgor Sysoev <igor@sysoev.ru>
Sat, 12 Dec 2015 21:00:30 +0000 (00:00 +0300)
nginx/ngx_http_js_module.c
njs/njs_disassembler.c
njs/njs_extern.c
njs/njs_extern.h
njs/njs_generator.c
njs/njs_parser.c
njs/njs_parser.h
njs/njs_vm.c
njs/njs_vm.h
njs/njscript.h
njs/test/njs_unit_test.c

index bd5917f47c8a4dc18e131306c1be358aaf450664..237971d7a9c30713457a7d86e600e1902248d3f3 100644 (file)
@@ -58,18 +58,18 @@ static njs_ret_t ngx_http_js_ext_get_string(njs_vm_t *vm, njs_value_t *value,
     void *obj, uintptr_t data);
 static njs_ret_t ngx_http_js_ext_set_string(njs_vm_t *vm, void *obj,
     uintptr_t data, nxt_str_t *value);
-static njs_ret_t ngx_http_js_ext_each_header_start(njs_vm_t *vm, void *obj,
-    void *each, uintptr_t data);
-static njs_ret_t ngx_http_js_ext_each_header(njs_vm_t *vm, njs_value_t *value,
-    void *obj, void *each);
+static njs_ret_t ngx_http_js_ext_foreach_header(njs_vm_t *vm, void *obj,
+    void *next, uintptr_t data);
+static njs_ret_t ngx_http_js_ext_next_header(njs_vm_t *vm, njs_value_t *value,
+    void *obj, void *next);
 static ngx_table_elt_t *ngx_http_js_get_header(ngx_list_part_t *part,
     u_char *data, size_t len);
 static njs_ret_t ngx_http_js_ext_get_header_out(njs_vm_t *vm,
     njs_value_t *value, void *obj, uintptr_t data);
 static njs_ret_t ngx_http_js_ext_set_header_out(njs_vm_t *vm, void *obj,
     uintptr_t data, nxt_str_t *value);
-static njs_ret_t ngx_http_js_ext_each_header_out_start(njs_vm_t *vm, void *obj,
-    void *each); /*FIXME*/
+static njs_ret_t ngx_http_js_ext_foreach_header_out(njs_vm_t *vm, void *obj,
+    void *next); /*FIXME*/
 static njs_ret_t ngx_http_js_ext_get_status(njs_vm_t *vm, njs_value_t *value,
     void *obj, uintptr_t data);
 static njs_ret_t ngx_http_js_ext_set_status(njs_vm_t *vm, void *obj,
@@ -87,14 +87,14 @@ static njs_ret_t ngx_http_js_ext_get_remote_address(njs_vm_t *vm,
     njs_value_t *value, void *obj, uintptr_t data);
 static njs_ret_t ngx_http_js_ext_get_header_in(njs_vm_t *vm, njs_value_t *value,
     void *obj, uintptr_t data);
-static njs_ret_t ngx_http_js_ext_each_header_in_start(njs_vm_t *vm, void *obj,
-    void *each); /*FIXME*/
+static njs_ret_t ngx_http_js_ext_foreach_header_in(njs_vm_t *vm, void *obj,
+    void *next); /*FIXME*/
 static njs_ret_t ngx_http_js_ext_get_arg(njs_vm_t *vm, njs_value_t *value,
     void *obj, uintptr_t data);
-static njs_ret_t ngx_http_js_ext_each_arg_start(njs_vm_t *vm, void *obj,
-    void *each);
-static njs_ret_t ngx_http_js_ext_each_arg(njs_vm_t *vm, njs_value_t *value,
-    void *obj, void *each);
+static njs_ret_t ngx_http_js_ext_foreach_arg(njs_vm_t *vm, void *obj,
+    void *next);
+static njs_ret_t ngx_http_js_ext_next_arg(njs_vm_t *vm, njs_value_t *value,
+    void *obj, void *next);
 
 static char *ngx_http_js_run(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
 static char *ngx_http_js_set(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
@@ -175,8 +175,8 @@ static njs_external_t  ngx_http_js_ext_response[] = {
       ngx_http_js_ext_get_header_out,
       ngx_http_js_ext_set_header_out,
       NULL,
-      ngx_http_js_ext_each_header_out_start,
-      ngx_http_js_ext_each_header,
+      ngx_http_js_ext_foreach_header_out,
+      ngx_http_js_ext_next_header,
       NULL,
       0 },
 
@@ -323,8 +323,8 @@ static njs_external_t  ngx_http_js_ext_request[] = {
       ngx_http_js_ext_get_header_in,
       NULL,
       NULL,
-      ngx_http_js_ext_each_header_in_start,
-      ngx_http_js_ext_each_header,
+      ngx_http_js_ext_foreach_header_in,
+      ngx_http_js_ext_next_header,
       NULL,
       0 },
 
@@ -335,8 +335,8 @@ static njs_external_t  ngx_http_js_ext_request[] = {
       ngx_http_js_ext_get_arg,
       NULL,
       NULL,
-      ngx_http_js_ext_each_arg_start,
-      ngx_http_js_ext_each_arg,
+      ngx_http_js_ext_foreach_arg,
+      ngx_http_js_ext_next_arg,
       NULL,
       0 },
 };
@@ -549,7 +549,7 @@ ngx_http_js_ext_set_string(njs_vm_t *vm, void *obj, uintptr_t data,
 
 
 static njs_ret_t
-ngx_http_js_ext_each_header_start(njs_vm_t *vm, void *obj, void *each,
+ngx_http_js_ext_foreach_header(njs_vm_t *vm, void *obj, void *next,
     uintptr_t data)
 {
     char *p = obj;
@@ -570,7 +570,7 @@ ngx_http_js_ext_each_header_start(njs_vm_t *vm, void *obj, void *each,
     entry->part = &headers->part;
     entry->item = 0;
 
-    e = (ngx_http_js_table_entry_t **) each;
+    e = (ngx_http_js_table_entry_t **) next;
     *e = entry;
 
     return NJS_OK;
@@ -578,10 +578,10 @@ ngx_http_js_ext_each_header_start(njs_vm_t *vm, void *obj, void *each,
 
 
 static njs_ret_t
-ngx_http_js_ext_each_header(njs_vm_t *vm, njs_value_t *value, void *obj,
-    void *each)
+ngx_http_js_ext_next_header(njs_vm_t *vm, njs_value_t *value, void *obj,
+    void *next)
 {
-    ngx_http_js_table_entry_t **e = each;
+    ngx_http_js_table_entry_t **e = next;
 
     ngx_table_elt_t            *header, *h;
     ngx_http_js_table_entry_t  *entry;
@@ -709,9 +709,9 @@ ngx_http_js_ext_set_header_out(njs_vm_t *vm, void *obj, uintptr_t data,
 
 
 static njs_ret_t
-ngx_http_js_ext_each_header_out_start(njs_vm_t *vm, void *obj, void *each)
+ngx_http_js_ext_foreach_header_out(njs_vm_t *vm, void *obj, void *next)
 {
-    return ngx_http_js_ext_each_header_start(vm, obj, each,
+    return ngx_http_js_ext_foreach_header(vm, obj, next,
                              offsetof(ngx_http_request_t, headers_out.headers));
 }
 
@@ -963,9 +963,9 @@ ngx_http_js_ext_get_header_in(njs_vm_t *vm, njs_value_t *value, void *obj,
 
 
 static njs_ret_t
-ngx_http_js_ext_each_header_in_start(njs_vm_t *vm, void *obj, void *each)
+ngx_http_js_ext_foreach_header_in(njs_vm_t *vm, void *obj, void *next)
 {
-    return ngx_http_js_ext_each_header_start(vm, obj, each,
+    return ngx_http_js_ext_foreach_header(vm, obj, next,
                               offsetof(ngx_http_request_t, headers_in.headers));
 }
 
@@ -989,7 +989,7 @@ ngx_http_js_ext_get_arg(njs_vm_t *vm, njs_value_t *value, void *obj,
 
 
 static njs_ret_t
-ngx_http_js_ext_each_arg_start(njs_vm_t *vm, void *obj, void *each)
+ngx_http_js_ext_foreach_arg(njs_vm_t *vm, void *obj, void *next)
 {
     ngx_str_t           *entry, **e;
     ngx_http_request_t  *r;
@@ -1003,7 +1003,7 @@ ngx_http_js_ext_each_arg_start(njs_vm_t *vm, void *obj, void *each)
 
     *entry = r->args;
 
-    e = (ngx_str_t **) each;
+    e = (ngx_str_t **) next;
     *e = entry;
 
     return NJS_OK;
@@ -1011,10 +1011,10 @@ ngx_http_js_ext_each_arg_start(njs_vm_t *vm, void *obj, void *each)
 
 
 static njs_ret_t
-ngx_http_js_ext_each_arg(njs_vm_t *vm, njs_value_t *value, void *obj,
-    void *each)
+ngx_http_js_ext_next_arg(njs_vm_t *vm, njs_value_t *value, void *obj,
+    void *next)
 {
-    ngx_str_t **e = each;
+    ngx_str_t **e = next;
 
     size_t      len;
     u_char     *p, *start, *end;
index 2bfc9d824d3c135d0e55f6881fffd7924712a83c..d61645f48bc2482481ffcb881aec451628471c08 100644 (file)
@@ -179,8 +179,8 @@ njs_disassemble(u_char *start, u_char *end)
     njs_vmcode_try_start_t     *try_start;
     njs_vmcode_operation_t     operation;
     njs_vmcode_cond_jump_t     *cond_jump;
-    njs_vmcode_prop_each_t     *each;
-    njs_vmcode_prop_start_t    *prop_start;
+    njs_vmcode_prop_next_t     *prop_next;
+    njs_vmcode_prop_foreach_t  *prop_foreach;
     njs_vmcode_method_frame_t  *method;
 
     p = start;
@@ -240,22 +240,24 @@ njs_disassemble(u_char *start, u_char *end)
             continue;
         }
 
-        if (operation == njs_vmcode_property_each_start) {
-            prop_start = (njs_vmcode_prop_start_t *) p;
-            p += sizeof(njs_vmcode_prop_start_t);
+        if (operation == njs_vmcode_property_foreach) {
+            prop_foreach = (njs_vmcode_prop_foreach_t *) p;
+            p += sizeof(njs_vmcode_prop_foreach_t);
 
-            printf("PROPERTY START    %04lX %04lX +%ld\n",
-                   prop_start->each, prop_start->object, prop_start->offset);
+            printf("PROPERTY FOREACH  %04lX %04lX +%ld\n",
+                   prop_foreach->next, prop_foreach->object,
+                   prop_foreach->offset);
 
             continue;
         }
 
-        if (operation == njs_vmcode_property_each) {
-            each = (njs_vmcode_prop_each_t *) p;
-            p += sizeof(njs_vmcode_prop_each_t);
+        if (operation == njs_vmcode_property_next) {
+            prop_next = (njs_vmcode_prop_next_t *) p;
+            p += sizeof(njs_vmcode_prop_next_t);
 
-            printf("PROPERTY EACH     %04lX %04lX %04lX %ld\n",
-                   each->retval, each->object, each->each, each->offset);
+            printf("PROPERTY NEXT     %04lX %04lX %04lX %ld\n",
+                   prop_next->retval, prop_next->object,
+                   prop_next->next, prop_next->offset);
 
             continue;
         }
index 9b060b67e979760bb1b3a3ad005ac3f742f44130..a2ac7846c7e2542baed1471a9892bc55047dec86 100644 (file)
@@ -81,8 +81,8 @@ njs_add_external(nxt_lvlhsh_t *hash, nxt_mem_cache_pool_t *mcp, uintptr_t object
         ext->get = external->get;
         ext->set = external->set;
         ext->find = external->find;
-        ext->each_start = external->each_start;
-        ext->each = external->each;
+        ext->foreach = external->foreach;
+        ext->next = external->next;
         ext->method = external->method;
         ext->object = object;
         ext->data = external->data;
index fb512b3d70f0859471266ea7c45af01d92950682..b2a77a3ae62abdff2783a1debce106f9a3cf4014 100644 (file)
@@ -21,8 +21,8 @@ struct njs_extern_s {
     njs_extern_set_t             set;
     njs_extern_find_t            find;
 
-    njs_extern_each_start_t      each_start;
-    njs_extern_each_t            each;
+    njs_extern_foreach_t         foreach;
+    njs_extern_next_t            next;
 
     njs_extern_method_t          method;
 
index e6a5856012d9e081cb5161cd6838264228bec22b..8f9b05487a3539dea299661c29a491f96af0521f 100644 (file)
@@ -671,12 +671,12 @@ static nxt_int_t
 njs_generate_for_in_statement(njs_vm_t *vm, njs_parser_t *parser,
     njs_parser_node_t *node)
 {
-    u_char                   *loop;
-    nxt_int_t                ret;
-    njs_index_t              index;
-    njs_parser_node_t        *foreach;
-    njs_vmcode_prop_each_t   *prop_each;
-    njs_vmcode_prop_start_t  *start;
+    u_char                     *loop;
+    nxt_int_t                  ret;
+    njs_index_t                index;
+    njs_parser_node_t          *foreach;
+    njs_vmcode_prop_next_t     *prop_next;
+    njs_vmcode_prop_foreach_t  *prop_foreach;
 
     /* The object. */
 
@@ -687,14 +687,14 @@ njs_generate_for_in_statement(njs_vm_t *vm, njs_parser_t *parser,
         return ret;
     }
 
-    njs_generate_code(parser, njs_vmcode_prop_start_t, start);
-    start->code.operation = njs_vmcode_property_each_start;
-    start->code.operands = NJS_VMCODE_2OPERANDS;
-    start->code.retval = NJS_VMCODE_RETVAL;
-    start->object = foreach->right->index;
+    njs_generate_code(parser, njs_vmcode_prop_foreach_t, prop_foreach);
+    prop_foreach->code.operation = njs_vmcode_property_foreach;
+    prop_foreach->code.operands = NJS_VMCODE_2OPERANDS;
+    prop_foreach->code.retval = NJS_VMCODE_RETVAL;
+    prop_foreach->object = foreach->right->index;
 
     index = njs_generator_temp_index_get(parser);
-    start->each = index;
+    prop_foreach->next = index;
 
     /* The loop body. */
 
@@ -707,21 +707,21 @@ njs_generate_for_in_statement(njs_vm_t *vm, njs_parser_t *parser,
 
     /* The loop iterator. */
 
-    start->offset = parser->code_end - (u_char *) start;
+    prop_foreach->offset = parser->code_end - (u_char *) prop_foreach;
 
     ret = njs_generator(vm, parser, node->left->left);
     if (nxt_slow_path(ret != NXT_OK)) {
         return ret;
     }
 
-    njs_generate_code(parser, njs_vmcode_prop_each_t, prop_each);
-    prop_each->code.operation = njs_vmcode_property_each;
-    prop_each->code.operands = NJS_VMCODE_3OPERANDS;
-    prop_each->code.retval = NJS_VMCODE_RETVAL;
-    prop_each->retval = foreach->left->index;
-    prop_each->object = foreach->right->index;
-    prop_each->each = index;
-    prop_each->offset = loop - (u_char *) prop_each;
+    njs_generate_code(parser, njs_vmcode_prop_next_t, prop_next);
+    prop_next->code.operation = njs_vmcode_property_next;
+    prop_next->code.operands = NJS_VMCODE_3OPERANDS;
+    prop_next->code.retval = NJS_VMCODE_RETVAL;
+    prop_next->retval = foreach->left->index;
+    prop_next->object = foreach->right->index;
+    prop_next->next = index;
+    prop_next->offset = loop - (u_char *) prop_next;
 
     /*
      * Release object and iterator indexes: an object can be a function result
index 60ebd8d9661fb42f32143935f72a1cd230ad2e59..d2b407e9ddd760357a15ca9428c18dee5f75a9d8 100644 (file)
@@ -934,12 +934,13 @@ njs_parser_for_in_statement(njs_vm_t *vm, njs_parser_t *parser,
 {
     njs_parser_node_t  *node;
 
-    if (parser->node->left->token != NJS_TOKEN_NAME) {
+    node = parser->node->left;
+
+    if (node->token != NJS_TOKEN_NAME) {
         return NJS_TOKEN_ILLEGAL;
     }
 
-    parser->node->left->u.variable->state = NJS_VARIABLE_DECLARED;
-    parser->node->token = NJS_TOKEN_PROPERTY_EACH;
+    node->u.variable->state = NJS_VARIABLE_DECLARED;
 
     node = njs_parser_node_alloc(vm);
     if (nxt_slow_path(node == NULL)) {
@@ -961,8 +962,8 @@ njs_parser_for_in_statement(njs_vm_t *vm, njs_parser_t *parser,
 
     node->right = parser->node;
     parser->node = node;
-    parser->code_size += sizeof(njs_vmcode_prop_start_t)
-                         + sizeof(njs_vmcode_prop_each_t);
+    parser->code_size += sizeof(njs_vmcode_prop_foreach_t)
+                         + sizeof(njs_vmcode_prop_next_t);
     return token;
 }
 
index abb36793db2e166bd6bed3eddaf7b38fc68f16f3..ebb3270c9679a2e09218f8661f298d28e7e01268 100644 (file)
@@ -145,7 +145,6 @@ typedef enum {
     NJS_TOKEN_DO,
     NJS_TOKEN_FOR,
     NJS_TOKEN_FOR_IN,
-    NJS_TOKEN_PROPERTY_EACH,
     NJS_TOKEN_BREAK,
     NJS_TOKEN_CONTINUE,
     NJS_TOKEN_SWITCH,
index 7860520f6f17d9cef29b24c399ef5a9bba00bc09..3dfaf4c61f7caf94122ba672de3e24fb90d882ad 100644 (file)
@@ -54,10 +54,10 @@ typedef struct {
 } njs_property_query_t;
 
 
-typedef struct {
+struct njs_property_next_s {
     int32_t                        index;
     nxt_lvlhsh_each_t              lhe;
-} njs_property_each_t;
+};
 
 
 /*
@@ -1083,69 +1083,69 @@ njs_function_private_copy(njs_vm_t *vm, njs_property_query_t *pq)
 
 
 njs_ret_t
-njs_vmcode_property_each_start(njs_vm_t *vm, njs_value_t *object,
+njs_vmcode_property_foreach(njs_vm_t *vm, njs_value_t *object,
     njs_value_t *invld)
 {
-    njs_ret_t                ret;
-    njs_extern_t             *ext;
-    njs_property_each_t      *pe;
-    njs_vmcode_prop_start_t  *code;
+    njs_ret_t                  ret;
+    njs_extern_t               *ext;
+    njs_property_next_t        *next;
+    njs_vmcode_prop_foreach_t  *code;
 
     if (njs_is_object(object)) {
-        pe = nxt_mem_cache_alloc(vm->mem_cache_pool,
-                                 sizeof(njs_property_each_t));
-        if (nxt_slow_path(pe == NULL)) {
+        next = nxt_mem_cache_alloc(vm->mem_cache_pool,
+                                   sizeof(njs_property_next_t));
+        if (nxt_slow_path(next == NULL)) {
             return NXT_ERROR;
         }
 
-        vm->retval.data.u.data = pe;
+        vm->retval.data.u.next = next;
 
-        memset(&pe->lhe, 0, sizeof(nxt_lvlhsh_each_t));
-        pe->lhe.proto = &njs_object_hash_proto;
-        pe->index = -1;
+        memset(&next->lhe, 0, sizeof(nxt_lvlhsh_each_t));
+        next->lhe.proto = &njs_object_hash_proto;
+        next->index = -1;
 
         if (njs_is_array(object) && object->data.u.array->size != 0) {
-            pe->index = 0;
+            next->index = 0;
         }
 
     } else if (njs_is_external(object)) {
         ext = object->data.u.external;
 
-        if (ext->each_start != NULL) {
-            ret = ext->each_start(vm, vm->external[ext->object], &vm->retval);
+        if (ext->foreach != NULL) {
+            ret = ext->foreach(vm, vm->external[ext->object], &vm->retval);
             if (nxt_slow_path(ret != NXT_OK)) {
                 return ret;
             }
         }
     }
 
-    code = (njs_vmcode_prop_start_t *) vm->current;
+    code = (njs_vmcode_prop_foreach_t *) vm->current;
 
     return code->offset;
 }
 
 
 njs_ret_t
-njs_vmcode_property_each(njs_vm_t *vm, njs_value_t *object, njs_value_t *each)
+njs_vmcode_property_next(njs_vm_t *vm, njs_value_t *object, njs_value_t *value)
 {
     njs_ret_t               ret;
     nxt_uint_t              n;
     njs_array_t             *array;
     njs_extern_t            *ext;
     njs_object_prop_t       *prop;
-    njs_property_each_t     *pe;
-    njs_vmcode_prop_each_t  *code;
+    njs_property_next_t     *next;
+    njs_vmcode_prop_next_t  *code;
 
-    code = (njs_vmcode_prop_each_t *) vm->current;
+    code = (njs_vmcode_prop_next_t *) vm->current;
 
     if (njs_is_object(object)) {
-        pe = each->data.u.data;
+        next = value->data.u.next;
 
-        if (pe->index >= 0) {
+        if (next->index >= 0) {
             array = object->data.u.array;
 
-            while ((uint32_t) pe->index < array->size) {
-                n = pe->index++;
+            while ((uint32_t) next->index < array->size) {
+                n = next->index++;
 
                 if (njs_is_valid(&array->start[n])) {
                     njs_number_set(&vm->retval, n);
@@ -1154,10 +1154,10 @@ njs_vmcode_property_each(njs_vm_t *vm, njs_value_t *object, njs_value_t *each)
                 }
             }
 
-            pe->index = -1;
+            next->index = -1;
         }
 
-        prop = nxt_lvlhsh_each(&object->data.u.object->hash, &pe->lhe);
+        prop = nxt_lvlhsh_each(&object->data.u.object->hash, &next->lhe);
 
         if (prop != NULL) {
             vm->retval = prop->name;
@@ -1165,15 +1165,15 @@ njs_vmcode_property_each(njs_vm_t *vm, njs_value_t *object, njs_value_t *each)
             return code->offset;
         }
 
-        nxt_mem_cache_free(vm->mem_cache_pool, pe);
+        nxt_mem_cache_free(vm->mem_cache_pool, next);
 
         vm->retval = njs_value_void;
 
     } else if (njs_is_external(object)) {
         ext = object->data.u.external;
 
-        if (ext->each != NULL) {
-            ret = ext->each(vm, &vm->retval, vm->external[ext->object], each);
+        if (ext->next != NULL) {
+            ret = ext->next(vm, &vm->retval, vm->external[ext->object], value);
 
             if (ret == NXT_OK) {
                 return code->offset;
@@ -1187,7 +1187,7 @@ njs_vmcode_property_each(njs_vm_t *vm, njs_value_t *object, njs_value_t *each)
         }
     }
 
-    return sizeof(njs_vmcode_prop_each_t);
+    return sizeof(njs_vmcode_prop_next_t);
 }
 
 
index 75ff4238c49b51bdeed1780c63404078b2f70dc6..54cc27a8cad8d40c216caf927eb7d809e86a9196 100644 (file)
@@ -87,6 +87,7 @@ typedef struct njs_regexp_s           njs_regexp_t;
 typedef struct njs_regexp_pattern_s   njs_regexp_pattern_t;
 typedef struct njs_extern_s           njs_extern_t;
 typedef struct njs_native_frame_s     njs_native_frame_t;
+typedef struct njs_property_next_s    njs_property_next_t;
 
 
 typedef struct njs_object_s           njs_object_t;
@@ -172,6 +173,7 @@ union njs_value_s {
             njs_getter_t               getter;
             njs_extern_t               *external;
             njs_value_t                *value;
+            njs_property_next_t        *next;
             void                       *data;
         } u;
     } data;
@@ -473,19 +475,19 @@ typedef struct {
 
 typedef struct {
     njs_vmcode_t               code;
-    njs_index_t                each;
+    njs_index_t                next;
     njs_index_t                object;
     njs_ret_t                  offset;
-} njs_vmcode_prop_start_t;
+} njs_vmcode_prop_foreach_t;
 
 
 typedef struct {
     njs_vmcode_t               code;
     njs_index_t                retval;
     njs_index_t                object;
-    njs_index_t                each;
+    njs_index_t                next;
     njs_ret_t                  offset;
-} njs_vmcode_prop_each_t;
+} njs_vmcode_prop_next_t;
 
 
 typedef struct {
@@ -734,10 +736,10 @@ njs_ret_t njs_vmcode_property_in(njs_vm_t *vm, njs_value_t *property,
     njs_value_t *object);
 njs_ret_t njs_vmcode_property_delete(njs_vm_t *vm, njs_value_t *object,
     njs_value_t *property);
-njs_ret_t njs_vmcode_property_each_start(njs_vm_t *vm, njs_value_t *object,
+njs_ret_t njs_vmcode_property_foreach(njs_vm_t *vm, njs_value_t *object,
     njs_value_t *invld);
-njs_ret_t njs_vmcode_property_each(njs_vm_t *vm, njs_value_t *object,
-    njs_value_t *each);
+njs_ret_t njs_vmcode_property_next(njs_vm_t *vm, njs_value_t *object,
+    njs_value_t *value);
 njs_ret_t njs_vmcode_instance_of(njs_vm_t *vm, njs_value_t *object,
     njs_value_t *constructor);
 
index f412d2eb1bca8d357492f266077a1a87f571c059..e5ebe06ff6184caf12745cdaae8656ee9ea32b8e 100644 (file)
@@ -33,10 +33,9 @@ typedef njs_ret_t (*njs_extern_set_t)(njs_vm_t *vm, void *obj, uintptr_t data,
     nxt_str_t *value);
 typedef njs_ret_t (*njs_extern_find_t)(njs_vm_t *vm, void *obj, uintptr_t data,
     nxt_bool_t delete);
-typedef njs_ret_t (*njs_extern_each_start_t)(njs_vm_t *vm, void *obj,
-    void *each);
-typedef njs_ret_t (*njs_extern_each_t)(njs_vm_t *vm, njs_value_t *value,
-    void *obj, void *each);
+typedef njs_ret_t (*njs_extern_foreach_t)(njs_vm_t *vm, void *obj, void *next);
+typedef njs_ret_t (*njs_extern_next_t)(njs_vm_t *vm, njs_value_t *value,
+    void *obj, void *next);
 typedef njs_ret_t (*njs_extern_method_t)(njs_vm_t *vm, njs_param_t *param);
 
 
@@ -59,8 +58,8 @@ struct njs_external_s {
     njs_extern_set_t                set;
     njs_extern_find_t               find;
 
-    njs_extern_each_start_t         each_start;
-    njs_extern_each_t               each;
+    njs_extern_foreach_t            foreach;
+    njs_extern_next_t               next;
 
     njs_extern_method_t             method;
 
index 77de64fc64a56989f41284287af04296591b1d4e..9f6529057ff9adb6f5bf04e11bb82c9edca81a60 100644 (file)
@@ -3269,11 +3269,11 @@ njs_unit_test_header_external(njs_vm_t *vm, njs_value_t *value, void *obj,
 
 
 static njs_ret_t
-njs_unit_test_header_each_start_external(njs_vm_t *vm, void *obj, void *each)
+njs_unit_test_header_foreach_external(njs_vm_t *vm, void *obj, void *next)
 {
     u_char  *s;
 
-    s = each;
+    s = next;
     s[0] = '0';
     s[1] = '0';
 
@@ -3282,12 +3282,12 @@ njs_unit_test_header_each_start_external(njs_vm_t *vm, void *obj, void *each)
 
 
 static njs_ret_t
-njs_unit_test_header_each_external(njs_vm_t *vm, njs_value_t *value, void *obj,
-    void *each)
+njs_unit_test_header_next_external(njs_vm_t *vm, njs_value_t *value, void *obj,
+    void *next)
 {
     u_char  *s;
 
-    s = each;
+    s = next;
     s[1]++;
 
     if (s[1] == '4') {
@@ -3368,8 +3368,8 @@ static njs_external_t  njs_unit_test_r_external[] = {
       njs_unit_test_header_external,
       NULL,
       NULL,
-      njs_unit_test_header_each_start_external,
-      njs_unit_test_header_each_external,
+      njs_unit_test_header_foreach_external,
+      njs_unit_test_header_next_external,
       NULL,
       0 },