[njs] Refactored usage of njs_ret_t.

Dmitry Volyntsev xeioex at nginx.com
Tue Jul 30 18:12:26 UTC 2019


details:   https://hg.nginx.org/njs/rev/f4ac8168e856
branches:  
changeset: 1087:f4ac8168e856
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Tue Jul 30 21:12:08 2019 +0300
description:
Refactored usage of njs_ret_t.

Currently njs_ret_t is used in 2 different cases: as a jump offset for
bytecode and as a return value for ordinary functions. The second case
is quite similar with njs_int_t (and is often confused with).

1) Splitting this two cases into different types to avoid
confusion with njs_int_t.

2) Renaming njs_ret_t to njs_jump_off_t to better reflect its
purpose.

NO functional changes.

diffstat:

 nginx/ngx_http_js_module.c   |  132 ++++++++++++++--------------
 nginx/ngx_stream_js_module.c |   74 ++++++++--------
 src/njs.h                    |   31 +++---
 src/njs_array.c              |   92 +++++++++---------
 src/njs_array.h              |    8 +-
 src/njs_boolean.c            |    6 +-
 src/njs_boolean.h            |    2 +-
 src/njs_builtin.c            |   14 +-
 src/njs_crypto.c             |   26 ++--
 src/njs_crypto.h             |    4 +-
 src/njs_date.c               |   88 +++++++++---------
 src/njs_date.h               |    4 +-
 src/njs_error.c              |   30 +++---
 src/njs_error.h              |   20 ++--
 src/njs_extern.c             |    2 +-
 src/njs_fs.c                 |   44 ++++----
 src/njs_function.c           |   46 ++++----
 src/njs_function.h           |   26 ++--
 src/njs_generator.c          |   52 +++++-----
 src/njs_json.c               |   48 +++++-----
 src/njs_math.c               |   76 ++++++++--------
 src/njs_module.c             |    3 +-
 src/njs_module.h             |    2 +-
 src/njs_number.c             |   26 ++--
 src/njs_number.h             |   12 +-
 src/njs_object.c             |   84 +++++++++---------
 src/njs_object.h             |   24 ++--
 src/njs_object_property.c    |   50 +++++-----
 src/njs_parser.c             |   28 +++---
 src/njs_parser.h             |    2 +-
 src/njs_parser_terminal.c    |   12 +-
 src/njs_regexp.c             |   42 ++++----
 src/njs_regexp.h             |    8 +-
 src/njs_shell.c              |   22 ++--
 src/njs_string.c             |  198 +++++++++++++++++++++---------------------
 src/njs_string.h             |   32 +++---
 src/njs_timer.c              |   10 +-
 src/njs_timer.h              |    6 +-
 src/njs_value.c              |    4 +-
 src/njs_value.h              |   16 +-
 src/njs_variable.c           |   22 ++--
 src/njs_variable.h           |    8 +-
 src/njs_vm.c                 |   26 ++--
 src/njs_vm.h                 |    2 +-
 src/njs_vmcode.c             |  168 ++++++++++++++++++------------------
 src/njs_vmcode.h             |   27 +++--
 src/test/njs_unit_test.c     |   30 +++---
 47 files changed, 847 insertions(+), 842 deletions(-)

diffs (truncated from 6313 to 1000 lines):

diff -r 8b01e5bbbd16 -r f4ac8168e856 nginx/ngx_http_js_module.c
--- a/nginx/ngx_http_js_module.c	Tue Jul 30 20:11:46 2019 +0300
+++ b/nginx/ngx_http_js_module.c	Tue Jul 30 21:12:08 2019 +0300
@@ -60,76 +60,76 @@ static ngx_int_t ngx_http_js_init_vm(ngx
 static void ngx_http_js_cleanup_ctx(void *data);
 static void ngx_http_js_cleanup_vm(void *data);
 
-static njs_ret_t ngx_http_js_ext_get_string(njs_vm_t *vm, njs_value_t *value,
+static njs_int_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_foreach_header(njs_vm_t *vm, void *obj,
+static njs_int_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,
+static njs_int_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,
+static njs_int_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,
+static njs_int_t ngx_http_js_ext_set_header_out(njs_vm_t *vm, void *obj,
     uintptr_t data, njs_str_t *value);
-static njs_ret_t ngx_http_js_ext_delete_header_out(njs_vm_t *vm, void *obj,
+static njs_int_t ngx_http_js_ext_delete_header_out(njs_vm_t *vm, void *obj,
     uintptr_t data, njs_bool_t delete);
-static njs_ret_t ngx_http_js_ext_foreach_header_out(njs_vm_t *vm, void *obj,
+static njs_int_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,
+static njs_int_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,
+static njs_int_t ngx_http_js_ext_set_status(njs_vm_t *vm, void *obj,
     uintptr_t data, njs_str_t *value);
-static njs_ret_t ngx_http_js_ext_send_header(njs_vm_t *vm, njs_value_t *args,
+static njs_int_t ngx_http_js_ext_send_header(njs_vm_t *vm, njs_value_t *args,
     njs_uint_t nargs, njs_index_t unused);
-static njs_ret_t ngx_http_js_ext_send(njs_vm_t *vm, njs_value_t *args,
+static njs_int_t ngx_http_js_ext_send(njs_vm_t *vm, njs_value_t *args,
     njs_uint_t nargs, njs_index_t unused);
-static njs_ret_t ngx_http_js_ext_finish(njs_vm_t *vm, njs_value_t *args,
+static njs_int_t ngx_http_js_ext_finish(njs_vm_t *vm, njs_value_t *args,
     njs_uint_t nargs, njs_index_t unused);
-static njs_ret_t ngx_http_js_ext_return(njs_vm_t *vm, njs_value_t *args,
+static njs_int_t ngx_http_js_ext_return(njs_vm_t *vm, njs_value_t *args,
     njs_uint_t nargs, njs_index_t unused);
-static njs_ret_t ngx_http_js_ext_internal_redirect(njs_vm_t *vm,
+static njs_int_t ngx_http_js_ext_internal_redirect(njs_vm_t *vm,
     njs_value_t *args, njs_uint_t nargs, njs_index_t unused);
 
-static njs_ret_t ngx_http_js_ext_log(njs_vm_t *vm, njs_value_t *args,
+static njs_int_t ngx_http_js_ext_log(njs_vm_t *vm, njs_value_t *args,
     njs_uint_t nargs, njs_index_t unused);
-static njs_ret_t ngx_http_js_ext_warn(njs_vm_t *vm, njs_value_t *args,
+static njs_int_t ngx_http_js_ext_warn(njs_vm_t *vm, njs_value_t *args,
     njs_uint_t nargs, njs_index_t unused);
-static njs_ret_t ngx_http_js_ext_error(njs_vm_t *vm, njs_value_t *args,
+static njs_int_t ngx_http_js_ext_error(njs_vm_t *vm, njs_value_t *args,
     njs_uint_t nargs, njs_index_t unused);
-static njs_ret_t ngx_http_js_ext_log_core(njs_vm_t *vm, njs_value_t *args,
+static njs_int_t ngx_http_js_ext_log_core(njs_vm_t *vm, njs_value_t *args,
     njs_uint_t nargs, ngx_uint_t level);
 
-static njs_ret_t ngx_http_js_ext_get_http_version(njs_vm_t *vm,
+static njs_int_t ngx_http_js_ext_get_http_version(njs_vm_t *vm,
     njs_value_t *value, void *obj, uintptr_t data);
-static njs_ret_t ngx_http_js_ext_get_remote_address(njs_vm_t *vm,
+static njs_int_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_request_body(njs_vm_t *vm,
+static njs_int_t ngx_http_js_ext_get_request_body(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,
+static njs_int_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_foreach_header_in(njs_vm_t *vm, void *obj,
+static njs_int_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,
+static njs_int_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_foreach_arg(njs_vm_t *vm, void *obj,
+static njs_int_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,
+static njs_int_t ngx_http_js_ext_next_arg(njs_vm_t *vm, njs_value_t *value,
     void *obj, void *next);
-static njs_ret_t ngx_http_js_ext_get_variable(njs_vm_t *vm, njs_value_t *value,
+static njs_int_t ngx_http_js_ext_get_variable(njs_vm_t *vm, njs_value_t *value,
     void *obj, uintptr_t data);
-static njs_ret_t ngx_http_js_ext_set_variable(njs_vm_t *vm, void *obj,
+static njs_int_t ngx_http_js_ext_set_variable(njs_vm_t *vm, void *obj,
        uintptr_t data, njs_str_t *value);
-static njs_ret_t ngx_http_js_ext_subrequest(njs_vm_t *vm, njs_value_t *args,
+static njs_int_t ngx_http_js_ext_subrequest(njs_vm_t *vm, njs_value_t *args,
     njs_uint_t nargs, njs_index_t unused);
 static ngx_int_t ngx_http_js_subrequest(ngx_http_request_t *r,
     njs_str_t *uri_arg, njs_str_t *args_arg, njs_function_t *callback,
     ngx_http_request_t **sr);
 static ngx_int_t ngx_http_js_subrequest_done(ngx_http_request_t *r,
     void *data, ngx_int_t rc);
-static njs_ret_t ngx_http_js_ext_get_parent(njs_vm_t *vm, njs_value_t *value,
+static njs_int_t ngx_http_js_ext_get_parent(njs_vm_t *vm, njs_value_t *value,
     void *obj, uintptr_t data);
-static njs_ret_t ngx_http_js_ext_get_reply_body(njs_vm_t *vm,
+static njs_int_t ngx_http_js_ext_get_reply_body(njs_vm_t *vm,
     njs_value_t *value, void *obj, uintptr_t data);
 
 static njs_host_event_t ngx_http_js_set_timer(njs_external_ptr_t external,
@@ -139,7 +139,7 @@ static void ngx_http_js_clear_timer(njs_
 static void ngx_http_js_timer_handler(ngx_event_t *ev);
 static void ngx_http_js_handle_event(ngx_http_request_t *r,
     njs_vm_event_t vm_event, njs_value_t *args, njs_uint_t nargs);
-static njs_ret_t ngx_http_js_string(njs_vm_t *vm, const njs_value_t *value,
+static njs_int_t ngx_http_js_string(njs_vm_t *vm, const njs_value_t *value,
     njs_str_t *str);
 
 static char *ngx_http_js_include(ngx_conf_t *cf, ngx_command_t *cmd,
@@ -807,7 +807,7 @@ ngx_http_js_cleanup_vm(void *data)
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_http_js_ext_get_string(njs_vm_t *vm, njs_value_t *value, void *obj,
     uintptr_t data)
 {
@@ -821,7 +821,7 @@ ngx_http_js_ext_get_string(njs_vm_t *vm,
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_http_js_ext_foreach_header(njs_vm_t *vm, void *obj, void *next,
     uintptr_t data)
 {
@@ -850,7 +850,7 @@ ngx_http_js_ext_foreach_header(njs_vm_t 
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_http_js_ext_next_header(njs_vm_t *vm, njs_value_t *value, void *obj,
     void *next)
 {
@@ -918,7 +918,7 @@ ngx_http_js_get_header(ngx_list_part_t *
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_http_js_ext_get_header_out(njs_vm_t *vm, njs_value_t *value, void *obj,
     uintptr_t data)
 {
@@ -971,7 +971,7 @@ ngx_http_js_ext_get_header_out(njs_vm_t 
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_http_js_ext_set_header_out(njs_vm_t *vm, void *obj, uintptr_t data,
     njs_str_t *value)
 {
@@ -1065,7 +1065,7 @@ ngx_http_js_ext_set_header_out(njs_vm_t 
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_http_js_ext_delete_header_out(njs_vm_t *vm, void *obj, uintptr_t data,
     njs_bool_t unused)
 {
@@ -1077,7 +1077,7 @@ ngx_http_js_ext_delete_header_out(njs_vm
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_http_js_ext_foreach_header_out(njs_vm_t *vm, void *obj, void *next)
 {
     return ngx_http_js_ext_foreach_header(vm, obj, next,
@@ -1085,7 +1085,7 @@ ngx_http_js_ext_foreach_header_out(njs_v
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_http_js_ext_get_status(njs_vm_t *vm, njs_value_t *value, void *obj,
     uintptr_t data)
 {
@@ -1099,7 +1099,7 @@ ngx_http_js_ext_get_status(njs_vm_t *vm,
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_http_js_ext_set_status(njs_vm_t *vm, void *obj, uintptr_t data,
     njs_str_t *value)
 {
@@ -1119,7 +1119,7 @@ ngx_http_js_ext_set_status(njs_vm_t *vm,
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_http_js_ext_send_header(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
     njs_index_t unused)
 {
@@ -1142,7 +1142,7 @@ ngx_http_js_ext_send_header(njs_vm_t *vm
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_http_js_ext_send(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
     njs_index_t unused)
 {
@@ -1216,7 +1216,7 @@ ngx_http_js_ext_send(njs_vm_t *vm, njs_v
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_http_js_ext_finish(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
     njs_index_t unused)
 {
@@ -1240,7 +1240,7 @@ ngx_http_js_ext_finish(njs_vm_t *vm, njs
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_http_js_ext_return(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
     njs_index_t unused)
 {
@@ -1297,7 +1297,7 @@ ngx_http_js_ext_return(njs_vm_t *vm, njs
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_http_js_ext_internal_redirect(njs_vm_t *vm, njs_value_t *args,
     njs_uint_t nargs, njs_index_t unused)
 {
@@ -1331,7 +1331,7 @@ ngx_http_js_ext_internal_redirect(njs_vm
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_http_js_ext_log(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
     njs_index_t unused)
 {
@@ -1339,7 +1339,7 @@ ngx_http_js_ext_log(njs_vm_t *vm, njs_va
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_http_js_ext_warn(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
     njs_index_t unused)
 {
@@ -1347,7 +1347,7 @@ ngx_http_js_ext_warn(njs_vm_t *vm, njs_v
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_http_js_ext_error(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
     njs_index_t unused)
 {
@@ -1355,7 +1355,7 @@ ngx_http_js_ext_error(njs_vm_t *vm, njs_
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_http_js_ext_log_core(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
     ngx_uint_t level)
 {
@@ -1388,7 +1388,7 @@ ngx_http_js_ext_log_core(njs_vm_t *vm, n
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_http_js_ext_get_http_version(njs_vm_t *vm, njs_value_t *value, void *obj,
     uintptr_t data)
 {
@@ -1416,7 +1416,7 @@ ngx_http_js_ext_get_http_version(njs_vm_
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_http_js_ext_get_remote_address(njs_vm_t *vm, njs_value_t *value, void *obj,
     uintptr_t data)
 {
@@ -1431,14 +1431,14 @@ ngx_http_js_ext_get_remote_address(njs_v
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_http_js_ext_get_request_body(njs_vm_t *vm, njs_value_t *value, void *obj,
     uintptr_t data)
 {
     u_char              *p, *body;
     size_t               len;
     ngx_buf_t           *buf;
-    njs_ret_t            ret;
+    njs_int_t            ret;
     njs_value_t         *request_body;
     ngx_chain_t         *cl;
     ngx_http_js_ctx_t   *ctx;
@@ -1510,7 +1510,7 @@ done:
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_http_js_ext_get_header_in(njs_vm_t *vm, njs_value_t *value, void *obj,
     uintptr_t data)
 {
@@ -1532,14 +1532,14 @@ ngx_http_js_ext_get_header_in(njs_vm_t *
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_http_js_ext_foreach_header_in(njs_vm_t *vm, void *obj, void *next)
 {
     return ngx_http_js_ext_foreach_header(vm, obj, next,
                               offsetof(ngx_http_request_t, headers_in.headers));
 }
 
-static njs_ret_t
+static njs_int_t
 ngx_http_js_ext_get_arg(njs_vm_t *vm, njs_value_t *value, void *obj,
     uintptr_t data)
 {
@@ -1560,7 +1560,7 @@ ngx_http_js_ext_get_arg(njs_vm_t *vm, nj
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_http_js_ext_foreach_arg(njs_vm_t *vm, void *obj, void *next)
 {
     ngx_str_t           *entry, **e;
@@ -1582,7 +1582,7 @@ ngx_http_js_ext_foreach_arg(njs_vm_t *vm
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_http_js_ext_next_arg(njs_vm_t *vm, njs_value_t *value, void *obj,
     void *next)
 {
@@ -1625,7 +1625,7 @@ ngx_http_js_ext_next_arg(njs_vm_t *vm, n
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_http_js_ext_get_variable(njs_vm_t *vm, njs_value_t *value, void *obj,
     uintptr_t data)
 {
@@ -1653,7 +1653,7 @@ ngx_http_js_ext_get_variable(njs_vm_t *v
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_http_js_ext_set_variable(njs_vm_t *vm, void *obj, uintptr_t data,
     njs_str_t *value)
 {
@@ -1722,7 +1722,7 @@ ngx_http_js_ext_set_variable(njs_vm_t *v
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_http_js_ext_subrequest(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
     njs_index_t unused)
 {
@@ -2042,7 +2042,7 @@ ngx_http_js_subrequest_done(ngx_http_req
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_http_js_ext_get_parent(njs_vm_t *vm, njs_value_t *value, void *obj,
     uintptr_t data)
 {
@@ -2065,7 +2065,7 @@ ngx_http_js_ext_get_parent(njs_vm_t *vm,
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_http_js_ext_get_reply_body(njs_vm_t *vm, njs_value_t *value, void *obj,
     uintptr_t data)
 {
@@ -2161,7 +2161,7 @@ static void
 ngx_http_js_handle_event(ngx_http_request_t *r, njs_vm_event_t vm_event,
     njs_value_t *args, njs_uint_t nargs)
 {
-    njs_ret_t           rc;
+    njs_int_t           rc;
     njs_str_t           exception;
     ngx_http_js_ctx_t  *ctx;
 
@@ -2186,7 +2186,7 @@ ngx_http_js_handle_event(ngx_http_reques
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_http_js_string(njs_vm_t *vm, const njs_value_t *value, njs_str_t *str)
 {
     if (!njs_value_is_null_or_undefined(value)) {
diff -r 8b01e5bbbd16 -r f4ac8168e856 nginx/ngx_stream_js_module.c
--- a/nginx/ngx_stream_js_module.c	Tue Jul 30 20:11:46 2019 +0300
+++ b/nginx/ngx_stream_js_module.c	Tue Jul 30 21:12:08 2019 +0300
@@ -64,43 +64,43 @@ static ngx_int_t ngx_stream_js_variable(
 static ngx_int_t ngx_stream_js_init_vm(ngx_stream_session_t *s);
 static void ngx_stream_js_cleanup_ctx(void *data);
 static void ngx_stream_js_cleanup_vm(void *data);
-static njs_ret_t ngx_stream_js_buffer_arg(ngx_stream_session_t *s,
+static njs_int_t ngx_stream_js_buffer_arg(ngx_stream_session_t *s,
     njs_value_t *buffer);
-static njs_ret_t ngx_stream_js_flags_arg(ngx_stream_session_t *s,
+static njs_int_t ngx_stream_js_flags_arg(ngx_stream_session_t *s,
     njs_value_t *flags);
 static njs_vm_event_t *ngx_stream_js_event(ngx_stream_session_t *s,
     njs_str_t *event);
 
-static njs_ret_t ngx_stream_js_ext_get_remote_address(njs_vm_t *vm,
+static njs_int_t ngx_stream_js_ext_get_remote_address(njs_vm_t *vm,
     njs_value_t *value, void *obj, uintptr_t data);
 
-static njs_ret_t ngx_stream_js_ext_done(njs_vm_t *vm, njs_value_t *args,
+static njs_int_t ngx_stream_js_ext_done(njs_vm_t *vm, njs_value_t *args,
      njs_uint_t nargs, njs_index_t unused);
-static njs_ret_t ngx_stream_js_ext_deny(njs_vm_t *vm, njs_value_t *args,
+static njs_int_t ngx_stream_js_ext_deny(njs_vm_t *vm, njs_value_t *args,
      njs_uint_t nargs, njs_index_t unused);
-static njs_ret_t ngx_stream_js_ext_decline(njs_vm_t *vm, njs_value_t *args,
+static njs_int_t ngx_stream_js_ext_decline(njs_vm_t *vm, njs_value_t *args,
      njs_uint_t nargs, njs_index_t unused);
-static njs_ret_t ngx_stream_js_ext_set_status(njs_vm_t *vm, njs_value_t *args,
+static njs_int_t ngx_stream_js_ext_set_status(njs_vm_t *vm, njs_value_t *args,
     njs_uint_t nargs, ngx_int_t status);
 
-static njs_ret_t ngx_stream_js_ext_log(njs_vm_t *vm, njs_value_t *args,
+static njs_int_t ngx_stream_js_ext_log(njs_vm_t *vm, njs_value_t *args,
      njs_uint_t nargs, njs_index_t unused);
-static njs_ret_t ngx_stream_js_ext_warn(njs_vm_t *vm, njs_value_t *args,
+static njs_int_t ngx_stream_js_ext_warn(njs_vm_t *vm, njs_value_t *args,
      njs_uint_t nargs, njs_index_t unused);
-static njs_ret_t ngx_stream_js_ext_error(njs_vm_t *vm, njs_value_t *args,
+static njs_int_t ngx_stream_js_ext_error(njs_vm_t *vm, njs_value_t *args,
      njs_uint_t nargs, njs_index_t unused);
-static njs_ret_t ngx_stream_js_ext_log_core(njs_vm_t *vm, njs_value_t *args,
+static njs_int_t ngx_stream_js_ext_log_core(njs_vm_t *vm, njs_value_t *args,
     njs_uint_t nargs, ngx_uint_t level);
-static njs_ret_t ngx_stream_js_ext_on(njs_vm_t *vm, njs_value_t *args,
+static njs_int_t ngx_stream_js_ext_on(njs_vm_t *vm, njs_value_t *args,
      njs_uint_t nargs, njs_index_t unused);
-static njs_ret_t ngx_stream_js_ext_off(njs_vm_t *vm, njs_value_t *args,
+static njs_int_t ngx_stream_js_ext_off(njs_vm_t *vm, njs_value_t *args,
      njs_uint_t nargs, njs_index_t unused);
-static njs_ret_t ngx_stream_js_ext_send(njs_vm_t *vm, njs_value_t *args,
+static njs_int_t ngx_stream_js_ext_send(njs_vm_t *vm, njs_value_t *args,
      njs_uint_t nargs, njs_index_t unused);
 
-static njs_ret_t ngx_stream_js_ext_get_variable(njs_vm_t *vm,
+static njs_int_t ngx_stream_js_ext_get_variable(njs_vm_t *vm,
     njs_value_t *value, void *obj, uintptr_t data);
-static njs_ret_t ngx_stream_js_ext_set_variable(njs_vm_t *vm, void *obj,
+static njs_int_t ngx_stream_js_ext_set_variable(njs_vm_t *vm, void *obj,
     uintptr_t data, njs_str_t *value);
 
 static njs_host_event_t ngx_stream_js_set_timer(njs_external_ptr_t external,
@@ -110,7 +110,7 @@ static void ngx_stream_js_clear_timer(nj
 static void ngx_stream_js_timer_handler(ngx_event_t *ev);
 static void ngx_stream_js_handle_event(ngx_stream_session_t *s,
     njs_vm_event_t vm_event, njs_value_t *args, njs_uint_t nargs);
-static njs_ret_t ngx_stream_js_string(njs_vm_t *vm, const njs_value_t *value,
+static njs_int_t ngx_stream_js_string(njs_vm_t *vm, const njs_value_t *value,
     njs_str_t *str);
 
 static char *ngx_stream_js_include(ngx_conf_t *cf, ngx_command_t *cmd,
@@ -406,7 +406,7 @@ static ngx_int_t
 ngx_stream_js_phase_handler(ngx_stream_session_t *s, ngx_str_t *name)
 {
     njs_str_t             fname, exception;
-    njs_ret_t             ret;
+    njs_int_t             ret;
     ngx_int_t             rc;
     njs_function_t       *func;
     ngx_connection_t     *c;
@@ -507,7 +507,7 @@ ngx_stream_js_body_filter(ngx_stream_ses
     ngx_uint_t from_upstream)
 {
     njs_str_t                  name, exception;
-    njs_ret_t                  ret;
+    njs_int_t                  ret;
     ngx_int_t                  rc;
     ngx_chain_t               *out, *cl;
     njs_function_t            *func;
@@ -790,7 +790,7 @@ ngx_stream_js_cleanup_vm(void *data)
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_stream_js_buffer_arg(ngx_stream_session_t *s, njs_value_t *buffer)
 {
     size_t                 len;
@@ -820,7 +820,7 @@ ngx_stream_js_buffer_arg(ngx_stream_sess
 
 
 
-static njs_ret_t
+static njs_int_t
 ngx_stream_js_flags_arg(ngx_stream_session_t *s, njs_value_t *flags)
 {
     ngx_buf_t             *b;
@@ -886,7 +886,7 @@ ngx_stream_js_event(ngx_stream_session_t
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_stream_js_ext_get_remote_address(njs_vm_t *vm, njs_value_t *value,
     void *obj, uintptr_t data)
 {
@@ -901,7 +901,7 @@ ngx_stream_js_ext_get_remote_address(njs
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_stream_js_ext_done(njs_vm_t *vm, njs_value_t *args,
      njs_uint_t nargs, njs_index_t unused)
 {
@@ -909,7 +909,7 @@ ngx_stream_js_ext_done(njs_vm_t *vm, njs
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_stream_js_ext_deny(njs_vm_t *vm, njs_value_t *args,
      njs_uint_t nargs, njs_index_t unused)
 {
@@ -918,7 +918,7 @@ ngx_stream_js_ext_deny(njs_vm_t *vm, njs
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_stream_js_ext_decline(njs_vm_t *vm, njs_value_t *args,
      njs_uint_t nargs, njs_index_t unused)
 {
@@ -927,7 +927,7 @@ ngx_stream_js_ext_decline(njs_vm_t *vm, 
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_stream_js_ext_set_status(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
     ngx_int_t status)
 {
@@ -976,7 +976,7 @@ ngx_stream_js_ext_set_status(njs_vm_t *v
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_stream_js_ext_log(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
     njs_index_t unused)
 {
@@ -984,7 +984,7 @@ ngx_stream_js_ext_log(njs_vm_t *vm, njs_
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_stream_js_ext_warn(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
     njs_index_t unused)
 {
@@ -992,7 +992,7 @@ ngx_stream_js_ext_warn(njs_vm_t *vm, njs
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_stream_js_ext_error(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
     njs_index_t unused)
 {
@@ -1000,7 +1000,7 @@ ngx_stream_js_ext_error(njs_vm_t *vm, nj
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_stream_js_ext_log_core(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
     ngx_uint_t level)
 {
@@ -1033,7 +1033,7 @@ ngx_stream_js_ext_log_core(njs_vm_t *vm,
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_stream_js_ext_on(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
     njs_index_t unused)
 {
@@ -1080,7 +1080,7 @@ ngx_stream_js_ext_on(njs_vm_t *vm, njs_v
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_stream_js_ext_off(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
     njs_index_t unused)
 {
@@ -1113,7 +1113,7 @@ ngx_stream_js_ext_off(njs_vm_t *vm, njs_
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_stream_js_ext_send(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
     njs_index_t unused)
 {
@@ -1192,7 +1192,7 @@ ngx_stream_js_ext_send(njs_vm_t *vm, njs
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_stream_js_ext_get_variable(njs_vm_t *vm, njs_value_t *value, void *obj,
     uintptr_t data)
 {
@@ -1220,7 +1220,7 @@ ngx_stream_js_ext_get_variable(njs_vm_t 
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_stream_js_ext_set_variable(njs_vm_t *vm, void *obj, uintptr_t data,
     njs_str_t *value)
 {
@@ -1351,7 +1351,7 @@ static void
 ngx_stream_js_handle_event(ngx_stream_session_t *s, njs_vm_event_t vm_event,
     njs_value_t *args, njs_uint_t nargs)
 {
-    njs_ret_t            rc;
+    njs_int_t            rc;
     njs_str_t            exception;
     ngx_stream_js_ctx_t  *ctx;
 
@@ -1376,7 +1376,7 @@ ngx_stream_js_handle_event(ngx_stream_se
 }
 
 
-static njs_ret_t
+static njs_int_t
 ngx_stream_js_string(njs_vm_t *vm, const njs_value_t *value, njs_str_t *str)
 {
     if (!njs_value_is_null_or_undefined(value)) {
diff -r 8b01e5bbbd16 -r f4ac8168e856 src/njs.h
--- a/src/njs.h	Tue Jul 30 20:11:46 2019 +0300
+++ b/src/njs.h	Tue Jul 30 21:12:08 2019 +0300
@@ -22,7 +22,6 @@
 #include <njs_lvlhsh.h>
 
 
-typedef intptr_t                    njs_ret_t;
 typedef uintptr_t                   njs_index_t;
 typedef struct njs_vm_s             njs_vm_t;
 typedef union  njs_value_s          njs_value_t;
@@ -60,16 +59,16 @@ extern const njs_value_t            njs_
     njs_vm_value_error_set(vm, njs_vm_retval(vm), fmt, ##__VA_ARGS__)
 
 
-typedef njs_ret_t (*njs_extern_get_t)(njs_vm_t *vm, njs_value_t *value,
+typedef njs_int_t (*njs_extern_get_t)(njs_vm_t *vm, njs_value_t *value,
     void *obj, uintptr_t data);
-typedef njs_ret_t (*njs_extern_set_t)(njs_vm_t *vm, void *obj, uintptr_t data,
+typedef njs_int_t (*njs_extern_set_t)(njs_vm_t *vm, void *obj, uintptr_t data,
     njs_str_t *value);
-typedef njs_ret_t (*njs_extern_find_t)(njs_vm_t *vm, void *obj, uintptr_t data,
+typedef njs_int_t (*njs_extern_find_t)(njs_vm_t *vm, void *obj, uintptr_t data,
     njs_bool_t delete);
-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,
+typedef njs_int_t (*njs_extern_foreach_t)(njs_vm_t *vm, void *obj, void *next);
+typedef njs_int_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_value_t *args,
+typedef njs_int_t (*njs_extern_method_t)(njs_vm_t *vm, njs_value_t *args,
     njs_uint_t nargs, njs_index_t unused);
 
 
@@ -236,7 +235,7 @@ NJS_EXPORT void njs_vm_retval_set(njs_vm
  * Sets a byte string value.
  *   start data is not copied and should not be freed.
  */
-NJS_EXPORT njs_ret_t njs_vm_value_string_set(njs_vm_t *vm, njs_value_t *value,
+NJS_EXPORT njs_int_t njs_vm_value_string_set(njs_vm_t *vm, njs_value_t *value,
     const u_char *start, uint32_t size);
 NJS_EXPORT u_char *njs_vm_value_string_alloc(njs_vm_t *vm, njs_value_t *value,
     uint32_t size);
@@ -246,19 +245,19 @@ NJS_EXPORT njs_int_t njs_vm_value_string
 /*
  * Converts a value to string.
  */
-NJS_EXPORT njs_ret_t njs_vm_value_to_string(njs_vm_t *vm, njs_str_t *dst,
+NJS_EXPORT njs_int_t njs_vm_value_to_string(njs_vm_t *vm, njs_str_t *dst,
     const njs_value_t *src);
 
 /*
  * Calls njs_vm_value_to_string(), if exception was thrown adds backtrace.
  */
-NJS_EXPORT njs_ret_t njs_vm_value_string(njs_vm_t *vm, njs_str_t *dst,
+NJS_EXPORT njs_int_t njs_vm_value_string(njs_vm_t *vm, njs_str_t *dst,
     const njs_value_t *src);
-NJS_EXPORT njs_ret_t njs_vm_retval_string(njs_vm_t *vm, njs_str_t *dst);
+NJS_EXPORT njs_int_t njs_vm_retval_string(njs_vm_t *vm, njs_str_t *dst);
 
-NJS_EXPORT njs_ret_t njs_vm_value_dump(njs_vm_t *vm, njs_str_t *dst,
+NJS_EXPORT njs_int_t njs_vm_value_dump(njs_vm_t *vm, njs_str_t *dst,
     const njs_value_t *value, njs_uint_t console, njs_uint_t indent);
-NJS_EXPORT njs_ret_t njs_vm_retval_dump(njs_vm_t *vm, njs_str_t *dst,
+NJS_EXPORT njs_int_t njs_vm_retval_dump(njs_vm_t *vm, njs_str_t *dst,
     njs_uint_t indent);
 
 NJS_EXPORT void njs_vm_value_error_set(njs_vm_t *vm, njs_value_t *value,
@@ -285,14 +284,14 @@ NJS_EXPORT njs_int_t njs_value_is_string
 NJS_EXPORT njs_int_t njs_value_is_object(const njs_value_t *value);
 NJS_EXPORT njs_int_t njs_value_is_function(const njs_value_t *value);
 
-NJS_EXPORT njs_ret_t njs_vm_object_alloc(njs_vm_t *vm, njs_value_t *retval,
+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_prop(njs_vm_t *vm,
     const njs_value_t *value, const njs_str_t *key);
 
-NJS_EXPORT njs_ret_t njs_vm_json_parse(njs_vm_t *vm, njs_value_t *args,
+NJS_EXPORT njs_int_t njs_vm_json_parse(njs_vm_t *vm, njs_value_t *args,
     njs_uint_t nargs);
-NJS_EXPORT njs_ret_t njs_vm_json_stringify(njs_vm_t *vm, njs_value_t *args,
+NJS_EXPORT njs_int_t njs_vm_json_stringify(njs_vm_t *vm, njs_value_t *args,
     njs_uint_t nargs);
 
 extern const njs_mem_proto_t  njs_vm_mp_proto;
diff -r 8b01e5bbbd16 -r f4ac8168e856 src/njs_array.c
--- a/src/njs_array.c	Tue Jul 30 20:11:46 2019 +0300
+++ b/src/njs_array.c	Tue Jul 30 21:12:08 2019 +0300
@@ -9,7 +9,7 @@
 #include <stdint.h>
 
 
-static njs_ret_t njs_array_prototype_slice_copy(njs_vm_t *vm,
+static njs_int_t njs_array_prototype_slice_copy(njs_vm_t *vm,
     njs_value_t *this, int64_t start, int64_t length);
 static njs_value_t *njs_array_copy(njs_value_t *dst, njs_value_t *src);
 
@@ -67,10 +67,10 @@ overflow:
 }
 
 
-njs_ret_t
+njs_int_t
 njs_array_add(njs_vm_t *vm, njs_array_t *array, njs_value_t *value)
 {
-    njs_ret_t  ret;
+    njs_int_t  ret;
 
     ret = njs_array_expand(vm, array, 0, 1);
 
@@ -83,11 +83,11 @@ njs_array_add(njs_vm_t *vm, njs_array_t 
 }
 
 
-njs_ret_t
+njs_int_t
 njs_array_string_add(njs_vm_t *vm, njs_array_t *array, const u_char *start,
     size_t size, size_t length)
 {
-    njs_ret_t  ret;
+    njs_int_t  ret;
 
     ret = njs_array_expand(vm, array, 0, 1);
 
@@ -100,7 +100,7 @@ njs_array_string_add(njs_vm_t *vm, njs_a
 }
 
 
-njs_ret_t
+njs_int_t
 njs_array_expand(njs_vm_t *vm, njs_array_t *array, uint32_t prepend,
     uint32_t append)
 {
@@ -156,7 +156,7 @@ memory_error:
 }
 
 
-njs_ret_t
+njs_int_t
 njs_array_constructor(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
     njs_index_t unused)
 {
@@ -211,7 +211,7 @@ njs_array_constructor(njs_vm_t *vm, njs_
 }
 
 
-static njs_ret_t
+static njs_int_t
 njs_array_is_array(njs_vm_t *vm, njs_value_t *args,
     njs_uint_t nargs, njs_index_t unused)
 {
@@ -230,7 +230,7 @@ njs_array_is_array(njs_vm_t *vm, njs_val
 }
 
 
-static njs_ret_t
+static njs_int_t
 njs_array_of(njs_vm_t *vm, njs_value_t *args,
     njs_uint_t nargs, njs_index_t unused)
 {
@@ -307,14 +307,14 @@ const njs_object_init_t  njs_array_const
 };
 
 
-static njs_ret_t
+static njs_int_t
 njs_array_length(njs_vm_t *vm, njs_value_t *value, njs_value_t *setval,
     njs_value_t *retval)
 {
     double       num;
     int64_t      size;
     uint32_t     length;
-    njs_ret_t    ret;
+    njs_int_t    ret;
     njs_value_t  *val;
     njs_array_t  *array;
     njs_object_t *proto;
@@ -396,12 +396,12 @@ njs_array_length(njs_vm_t *vm, njs_value
  * JavaScript 1.2, ECMAScript 3.
  */
 
-static njs_ret_t
+static njs_int_t
 njs_array_prototype_slice(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
     njs_index_t unused)
 {
     int64_t      start, end, length;
-    njs_ret_t    ret;
+    njs_int_t    ret;
     njs_value_t  prop_length;
 
     static const njs_value_t  string_length = njs_string("length");
@@ -462,14 +462,14 @@ njs_array_prototype_slice(njs_vm_t *vm, 
 }
 
 
-static njs_ret_t
+static njs_int_t
 njs_array_prototype_slice_copy(njs_vm_t *vm, njs_value_t *this,
     int64_t start, int64_t length)
 {
     size_t             size;
     u_char             *dst;
     uint32_t           n;
-    njs_ret_t          ret;
+    njs_int_t          ret;
     njs_array_t        *array;
     njs_value_t        *value, name;
     const u_char       *src, *end;
@@ -566,11 +566,11 @@ njs_array_prototype_slice_copy(njs_vm_t 
 }
 
 
-static njs_ret_t
+static njs_int_t
 njs_array_prototype_push(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
     njs_index_t unused)
 {
-    njs_ret_t    ret;
+    njs_int_t    ret;
     njs_uint_t   i;
     njs_array_t  *array;
 
@@ -596,7 +596,7 @@ njs_array_prototype_push(njs_vm_t *vm, n
 }
 
 
-static njs_ret_t
+static njs_int_t
 njs_array_prototype_pop(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
     njs_index_t unused)
 {
@@ -624,11 +624,11 @@ njs_array_prototype_pop(njs_vm_t *vm, nj
 }
 
 
-static njs_ret_t
+static njs_int_t
 njs_array_prototype_unshift(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
     njs_index_t unused)
 {
-    njs_ret_t    ret;
+    njs_int_t    ret;
     njs_uint_t   n;
     njs_array_t  *array;
 
@@ -660,7 +660,7 @@ njs_array_prototype_unshift(njs_vm_t *vm
 }
 
 
-static njs_ret_t
+static njs_int_t
 njs_array_prototype_shift(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
     njs_index_t unused)
 {
@@ -690,11 +690,11 @@ njs_array_prototype_shift(njs_vm_t *vm, 
 }
 
 
-static njs_ret_t
+static njs_int_t
 njs_array_prototype_splice(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
     njs_index_t unused)
 {
-    njs_ret_t    ret;
+    njs_int_t    ret;
     njs_int_t    n, start, length, items, delta, delete;
     njs_uint_t   i;
     njs_array_t  *array, *deleted;
@@ -790,7 +790,7 @@ njs_array_prototype_splice(njs_vm_t *vm,
 }
 
 
-static njs_ret_t
+static njs_int_t
 njs_array_prototype_reverse(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
     njs_index_t unused)
 {
@@ -821,7 +821,7 @@ njs_array_prototype_reverse(njs_vm_t *vm
 }
 
 
-static njs_ret_t
+static njs_int_t
 njs_array_prototype_to_string(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
     njs_index_t unused)
 {
@@ -844,14 +844,14 @@ njs_array_prototype_to_string(njs_vm_t *
 }
 
 
-static njs_ret_t
+static njs_int_t
 njs_array_prototype_join(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
     njs_index_t unused)
 {
     u_char             *p;
     uint32_t           max;
     size_t             size, length, mask;
-    njs_ret_t          ret;
+    njs_int_t          ret;
     njs_uint_t         i, n;
     njs_array_t        *array;
     njs_value_t        *value, *values;
@@ -989,7 +989,7 @@ njs_array_prototype_join(njs_vm_t *vm, n
 }
 
 
-static njs_ret_t
+static njs_int_t
 njs_array_prototype_concat(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
     njs_index_t unused)
 {
@@ -1048,7 +1048,7 @@ njs_array_copy(njs_value_t *dst, njs_val
 }
 
 
-static njs_ret_t
+static njs_int_t
 njs_array_prototype_index_of(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
     njs_index_t unused)
 {
@@ -1108,7 +1108,7 @@ done:


More information about the nginx-devel mailing list