[njs] Fixed using of internal NJS headers in nginx modules.

Dmitry Volyntsev xeioex at nginx.com
Mon Feb 12 12:15:01 UTC 2018


details:   http://hg.nginx.org/njs/rev/703cc218b93c
branches:  
changeset: 443:703cc218b93c
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Mon Feb 12 14:57:24 2018 +0300
description:
Fixed using of internal NJS headers in nginx modules.

Public API is rectified to make it easier to work with the private
structure njs_value_t from the outside:
    1) njs_vm_retval() is split into njs_vm_retval() which now returns
    the njs_value_t * as a return value and njs_vm_value_to_ext_string()
    which stringifies an njs_value_t * passed as an argument.

    2) njs_value_*_set() methods are added.
    3) Similar public methods are grouped together.

diffstat:

 nginx/ngx_http_js_module.c      |   13 +-
 nginx/ngx_stream_js_module.c    |   33 +++----
 njs/njs.c                       |    4 +-
 njs/njs_array.c                 |   22 ++--
 njs/njs_date.c                  |   64 +++++++-------
 njs/njs_math.c                  |   70 ++++++++--------
 njs/njs_number.c                |    4 +-
 njs/njs_regexp.c                |    4 +-
 njs/njs_string.c                |   14 +-
 njs/njs_string.h                |    2 -
 njs/njs_vm.c                    |  171 ++++++++++++++++++++++++++++++---------
 njs/njs_vm.h                    |    5 +-
 njs/njscript.c                  |   88 +-------------------
 njs/njscript.h                  |   28 ++++--
 njs/test/njs_benchmark.c        |    2 +-
 njs/test/njs_expect_test.exp    |    2 +-
 njs/test/njs_interactive_test.c |    4 +-
 njs/test/njs_unit_test.c        |    7 +-
 18 files changed, 276 insertions(+), 261 deletions(-)

diffs (truncated from 1697 to 1000 lines):

diff -r 0daf5a5cd37a -r 703cc218b93c nginx/ngx_http_js_module.c
--- a/nginx/ngx_http_js_module.c	Mon Feb 12 14:54:24 2018 +0300
+++ b/nginx/ngx_http_js_module.c	Mon Feb 12 14:57:24 2018 +0300
@@ -20,8 +20,6 @@
 #include <nxt_mem_cache_pool.h>
 
 #include <njscript.h>
-#include <njs_vm.h>
-#include <njs_string.h>
 
 
 #define NGX_HTTP_JS_MCP_CLUSTER_SIZE    (2 * ngx_pagesize)
@@ -445,7 +443,7 @@ ngx_http_js_handler(ngx_http_request_t *
     }
 
     if (njs_vm_call(ctx->vm, func, ctx->args, 2) != NJS_OK) {
-        njs_vm_retval(ctx->vm, &exception);
+        njs_vm_retval_to_ext_string(ctx->vm, &exception);
 
         ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
                       "js exception: %*s", exception.length, exception.start);
@@ -496,7 +494,7 @@ ngx_http_js_variable(ngx_http_request_t 
     }
 
     if (njs_vm_call(ctx->vm, func, ctx->args, 2) != NJS_OK) {
-        njs_vm_retval(ctx->vm, &exception);
+        njs_vm_retval_to_ext_string(ctx->vm, &exception);
 
         ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
                       "js exception: %*s", exception.length, exception.start);
@@ -505,7 +503,7 @@ ngx_http_js_variable(ngx_http_request_t 
         return NGX_OK;
     }
 
-    if (njs_vm_retval(ctx->vm, &value) != NJS_OK) {
+    if (njs_vm_retval_to_ext_string(ctx->vm, &value) != NJS_OK) {
         return NGX_ERROR;
     }
 
@@ -1024,7 +1022,8 @@ ngx_http_js_ext_log(njs_vm_t *vm, njs_va
     r = njs_value_data(njs_argument(args, 0));
     c = r->connection;
 
-    if (njs_value_to_ext_string(vm, &msg, njs_argument(args, 1)) == NJS_ERROR)
+    if (njs_vm_value_to_ext_string(vm, &msg, njs_argument(args, 1), 0)
+        == NJS_ERROR)
     {
         return NJS_ERROR;
     }
@@ -1334,7 +1333,7 @@ ngx_http_js_include(ngx_conf_t *cf, ngx_
     rc = njs_vm_compile(jlcf->vm, &start, end);
 
     if (rc != NJS_OK) {
-        njs_vm_retval(jlcf->vm, &text);
+        njs_vm_retval_to_ext_string(jlcf->vm, &text);
 
         ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
                            "%*s, included",
diff -r 0daf5a5cd37a -r 703cc218b93c nginx/ngx_stream_js_module.c
--- a/nginx/ngx_stream_js_module.c	Mon Feb 12 14:54:24 2018 +0300
+++ b/nginx/ngx_stream_js_module.c	Mon Feb 12 14:57:24 2018 +0300
@@ -20,8 +20,6 @@
 #include <nxt_mem_cache_pool.h>
 
 #include <njscript.h>
-#include <njs_vm.h>
-#include <njs_string.h>
 
 
 #define NGX_STREAM_JS_MCP_CLUSTER_SIZE    (2 * ngx_pagesize)
@@ -408,7 +406,7 @@ ngx_stream_js_phase_handler(ngx_stream_s
     }
 
     if (njs_vm_call(ctx->vm, func, ctx->arg, 1) != NJS_OK) {
-        njs_vm_retval(ctx->vm, &exception);
+        njs_vm_retval_to_ext_string(ctx->vm, &exception);
 
         ngx_log_error(NGX_LOG_ERR, c->log, 0, "js exception: %*s",
                       exception.length, exception.start);
@@ -416,11 +414,11 @@ ngx_stream_js_phase_handler(ngx_stream_s
         return NGX_ERROR;
     }
 
-    if (ctx->vm->retval.type == NJS_VOID) {
+    if (njs_value_is_void(njs_vm_retval(ctx->vm))) {
         return NGX_OK;
     }
 
-    if (njs_vm_retval(ctx->vm, &value) != NJS_OK) {
+    if (njs_vm_retval_to_ext_string(ctx->vm, &value) != NJS_OK) {
         return NGX_ERROR;
     }
 
@@ -495,7 +493,7 @@ ngx_stream_js_body_filter(ngx_stream_ses
         ctx->buf = in->buf;
 
         if (njs_vm_call(ctx->vm, func, ctx->arg, 1) != NJS_OK) {
-            njs_vm_retval(ctx->vm, &exception);
+            njs_vm_retval_to_ext_string(ctx->vm, &exception);
 
             ngx_log_error(NGX_LOG_ERR, c->log, 0, "js exception: %*s",
                           exception.length, exception.start);
@@ -503,8 +501,8 @@ ngx_stream_js_body_filter(ngx_stream_ses
             return NGX_ERROR;
         }
 
-        if (ctx->vm->retval.type != NJS_VOID) {
-            if (njs_vm_retval(ctx->vm, &value) != NJS_OK) {
+        if (!njs_value_is_void(njs_vm_retval(ctx->vm))) {
+            if (njs_vm_retval_to_ext_string(ctx->vm, &value) != NJS_OK) {
                 return NGX_ERROR;
             }
 
@@ -593,7 +591,7 @@ ngx_stream_js_variable(ngx_stream_sessio
     }
 
     if (njs_vm_call(ctx->vm, func, ctx->arg, 1) != NJS_OK) {
-        njs_vm_retval(ctx->vm, &exception);
+        njs_vm_retval_to_ext_string(ctx->vm, &exception);
 
         ngx_log_error(NGX_LOG_ERR, s->connection->log, 0,
                       "js exception: %*s", exception.length, exception.start);
@@ -602,7 +600,7 @@ ngx_stream_js_variable(ngx_stream_sessio
         return NGX_OK;
     }
 
-    if (njs_vm_retval(ctx->vm, &value) != NJS_OK) {
+    if (njs_vm_retval_to_ext_string(ctx->vm, &value) != NJS_OK) {
         return NGX_ERROR;
     }
 
@@ -746,7 +744,7 @@ ngx_stream_js_ext_get_eof(njs_vm_t *vm, 
 
     b = ctx->filter ? ctx->buf : c->buffer;
 
-    *value = (b && b->last_buf ? njs_value_true : njs_value_false);
+    njs_value_boolean_set(value, b && b->last_buf);
 
     return NJS_OK;
 }
@@ -762,7 +760,7 @@ ngx_stream_js_ext_get_from_upstream(njs_
     s = (ngx_stream_session_t *) obj;
     ctx = ngx_stream_get_module_ctx(s, ngx_stream_js_module);
 
-    *value = (ctx->from_upstream ? njs_value_true : njs_value_false);
+    njs_value_boolean_set(value, ctx->from_upstream);
 
     return NJS_OK;
 }
@@ -874,7 +872,9 @@ ngx_stream_js_ext_log(njs_vm_t *vm, njs_
     s = njs_value_data(njs_argument(args, 0));
     c = s->connection;
 
-    if (njs_value_to_ext_string(vm, &msg, njs_argument(args, 1)) == NJS_ERROR) {
+    if (njs_vm_value_to_ext_string(vm, &msg, njs_argument(args, 1), 0)
+        == NJS_ERROR)
+    {
         return NJS_ERROR;
     }
 
@@ -920,10 +920,7 @@ static njs_ret_t
 ngx_stream_js_ext_get_code(njs_vm_t *vm, njs_value_t *value, void *obj,
     uintptr_t data)
 {
-    ngx_memzero(value, sizeof(njs_value_t));
-
-    value->data.type = NJS_NUMBER;
-    value->data.u.number = data;
+    njs_value_number_set(value, (double) data);
 
     return NJS_OK;
 }
@@ -1044,7 +1041,7 @@ ngx_stream_js_include(ngx_conf_t *cf, ng
     rc = njs_vm_compile(jscf->vm, &start, end);
 
     if (rc != NJS_OK) {
-        njs_vm_retval(jscf->vm, &text);
+        njs_vm_retval_to_ext_string(jscf->vm, &text);
 
         ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
                            "%*s, included",
diff -r 0daf5a5cd37a -r 703cc218b93c njs/njs.c
--- a/njs/njs.c	Mon Feb 12 14:54:24 2018 +0300
+++ b/njs/njs.c	Mon Feb 12 14:57:24 2018 +0300
@@ -445,7 +445,7 @@ njs_process_script(njs_vm_t *vm, njs_opt
         }
     }
 
-    if (njs_vm_retval(vm, out) != NXT_OK) {
+    if (njs_vm_retval_to_ext_string(vm, out) != NXT_OK) {
         return NXT_ERROR;
     }
 
@@ -617,7 +617,7 @@ njs_ext_console_log(njs_vm_t *vm, njs_va
     msg.start = NULL;
 
     if (nargs >= 2
-        && njs_value_to_ext_string(vm, &msg, njs_argument(args, 1))
+        && njs_vm_value_to_ext_string(vm, &msg, njs_argument(args, 1), 0)
            == NJS_ERROR)
     {
 
diff -r 0daf5a5cd37a -r 703cc218b93c njs/njs_array.c
--- a/njs/njs_array.c	Mon Feb 12 14:54:24 2018 +0300
+++ b/njs/njs_array.c	Mon Feb 12 14:57:24 2018 +0300
@@ -383,7 +383,7 @@ const njs_object_init_t  njs_array_const
 static njs_ret_t
 njs_array_prototype_length(njs_vm_t *vm, njs_value_t *array)
 {
-    njs_number_set(&vm->retval, array->data.u.array->length);
+    njs_value_number_set(&vm->retval, array->data.u.array->length);
 
     njs_release(vm, array);
 
@@ -499,7 +499,7 @@ njs_array_prototype_push(njs_vm_t *vm, n
             }
         }
 
-        njs_number_set(&vm->retval, array->length);
+        njs_value_number_set(&vm->retval, array->length);
     }
 
     return NXT_OK;
@@ -565,7 +565,7 @@ njs_array_prototype_unshift(njs_vm_t *vm
             } while (n > 1);
         }
 
-        njs_number_set(&vm->retval, array->length);
+        njs_value_number_set(&vm->retval, array->length);
     }
 
     return NXT_OK;
@@ -1074,7 +1074,7 @@ njs_array_prototype_index_of(njs_vm_t *v
 
 done:
 
-    njs_number_set(&vm->retval, index);
+    njs_value_number_set(&vm->retval, index);
 
     return NXT_OK;
 }
@@ -1133,7 +1133,7 @@ njs_array_prototype_last_index_of(njs_vm
 
 done:
 
-    njs_number_set(&vm->retval, index);
+    njs_value_number_set(&vm->retval, index);
 
     return NXT_OK;
 }
@@ -1574,7 +1574,7 @@ njs_array_prototype_find_index_continuat
         index = -1;
     }
 
-    njs_number_set(&vm->retval, index);
+    njs_value_number_set(&vm->retval, index);
 
     return NXT_OK;
 }
@@ -1602,7 +1602,7 @@ njs_array_prototype_find_apply(njs_vm_t 
 
     arguments[1] = *value;
 
-    njs_number_set(&arguments[2], n);
+    njs_value_number_set(&arguments[2], n);
 
     arguments[3] = args[0];
 
@@ -1751,7 +1751,7 @@ njs_array_prototype_reduce_continuation(
 
     arguments[2] = array->start[n];
 
-    njs_number_set(&arguments[3], n);
+    njs_value_number_set(&arguments[3], n);
 
     arguments[4] = args[0];
 
@@ -1815,7 +1815,7 @@ njs_array_iterator_apply(njs_vm_t *vm, n
     n = iter->index;
     arguments[1] = args[0].data.u.array->start[n];
 
-    njs_number_set(&arguments[2], n);
+    njs_value_number_set(&arguments[2], n);
 
     arguments[3] = args[0];
 
@@ -1888,7 +1888,7 @@ njs_array_prototype_reduce_right_continu
 
     arguments[2] = array->start[n];
 
-    njs_number_set(&arguments[3], n);
+    njs_value_number_set(&arguments[3], n);
 
     arguments[4] = args[0];
 
@@ -1934,7 +1934,7 @@ njs_array_string_sort(njs_vm_t *vm, njs_
 
     ret = njs_string_cmp(&args[1], &args[2]);
 
-    njs_number_set(&vm->retval, ret);
+    njs_value_number_set(&vm->retval, ret);
 
     return NXT_OK;
 }
diff -r 0daf5a5cd37a -r 703cc218b93c njs/njs_date.c
--- a/njs/njs_date.c	Mon Feb 12 14:54:24 2018 +0300
+++ b/njs/njs_date.c	Mon Feb 12 14:57:24 2018 +0300
@@ -219,7 +219,7 @@ njs_date_utc(njs_vm_t *vm, njs_value_t *
 
 done:
 
-    njs_number_set(&vm->retval, time);
+    njs_value_number_set(&vm->retval, time);
 
     return NXT_OK;
 }
@@ -278,7 +278,7 @@ static njs_ret_t
 njs_date_now(njs_vm_t *vm, njs_value_t *args, nxt_uint_t nargs,
     njs_index_t unused)
 {
-    njs_number_set(&vm->retval, njs_gettime());
+    njs_value_number_set(&vm->retval, njs_gettime());
 
     return NXT_OK;
 }
@@ -297,7 +297,7 @@ njs_date_parse(njs_vm_t *vm, njs_value_t
         time = NAN;
     }
 
-    njs_number_set(&vm->retval, time);
+    njs_value_number_set(&vm->retval, time);
 
     return NXT_OK;
 }
@@ -942,7 +942,7 @@ static njs_ret_t
 njs_date_prototype_value_of(njs_vm_t *vm, njs_value_t *args, nxt_uint_t nargs,
     njs_index_t unused)
 {
-    njs_number_set(&vm->retval, args[0].data.u.date->time);
+    njs_value_number_set(&vm->retval, args[0].data.u.date->time);
 
     return NXT_OK;
 }
@@ -1086,7 +1086,7 @@ njs_date_prototype_get_full_year(njs_vm_
         value = tm.tm_year + 1900;
     }
 
-    njs_number_set(&vm->retval, value);
+    njs_value_number_set(&vm->retval, value);
 
     return NXT_OK;
 }
@@ -1109,7 +1109,7 @@ njs_date_prototype_get_utc_full_year(njs
         value = tm.tm_year + 1900;
     }
 
-    njs_number_set(&vm->retval, value);
+    njs_value_number_set(&vm->retval, value);
 
     return NXT_OK;
 }
@@ -1132,7 +1132,7 @@ njs_date_prototype_get_month(njs_vm_t *v
         value = tm.tm_mon;
     }
 
-    njs_number_set(&vm->retval, value);
+    njs_value_number_set(&vm->retval, value);
 
     return NXT_OK;
 }
@@ -1156,7 +1156,7 @@ njs_date_prototype_get_utc_month(njs_vm_
         value = tm.tm_mon;
     }
 
-    njs_number_set(&vm->retval, value);
+    njs_value_number_set(&vm->retval, value);
 
     return NXT_OK;
 }
@@ -1179,7 +1179,7 @@ njs_date_prototype_get_date(njs_vm_t *vm
         value = tm.tm_mday;
     }
 
-    njs_number_set(&vm->retval, value);
+    njs_value_number_set(&vm->retval, value);
 
     return NXT_OK;
 }
@@ -1202,7 +1202,7 @@ njs_date_prototype_get_utc_date(njs_vm_t
         value = tm.tm_mday;
     }
 
-    njs_number_set(&vm->retval, value);
+    njs_value_number_set(&vm->retval, value);
 
     return NXT_OK;
 }
@@ -1225,7 +1225,7 @@ njs_date_prototype_get_day(njs_vm_t *vm,
         value = tm.tm_wday;
     }
 
-    njs_number_set(&vm->retval, value);
+    njs_value_number_set(&vm->retval, value);
 
     return NXT_OK;
 }
@@ -1248,7 +1248,7 @@ njs_date_prototype_get_utc_day(njs_vm_t 
         value = tm.tm_wday;
     }
 
-    njs_number_set(&vm->retval, value);
+    njs_value_number_set(&vm->retval, value);
 
     return NXT_OK;
 }
@@ -1272,7 +1272,7 @@ njs_date_prototype_get_hours(njs_vm_t *v
         value = tm.tm_hour;
     }
 
-    njs_number_set(&vm->retval, value);
+    njs_value_number_set(&vm->retval, value);
 
     return NXT_OK;
 }
@@ -1295,7 +1295,7 @@ njs_date_prototype_get_utc_hours(njs_vm_
         value = tm.tm_hour;
     }
 
-    njs_number_set(&vm->retval, value);
+    njs_value_number_set(&vm->retval, value);
 
     return NXT_OK;
 }
@@ -1319,7 +1319,7 @@ njs_date_prototype_get_minutes(njs_vm_t 
         value = tm.tm_min;
     }
 
-    njs_number_set(&vm->retval, value);
+    njs_value_number_set(&vm->retval, value);
 
     return NXT_OK;
 }
@@ -1342,7 +1342,7 @@ njs_date_prototype_get_utc_minutes(njs_v
         value = tm.tm_min;
     }
 
-    njs_number_set(&vm->retval, value);
+    njs_value_number_set(&vm->retval, value);
 
     return NXT_OK;
 }
@@ -1360,7 +1360,7 @@ njs_date_prototype_get_seconds(njs_vm_t 
         value = (int64_t) (value / 1000) % 60;
     }
 
-    njs_number_set(&vm->retval, value);
+    njs_value_number_set(&vm->retval, value);
 
     return NXT_OK;
 }
@@ -1378,7 +1378,7 @@ njs_date_prototype_get_milliseconds(njs_
         value = (int64_t) value % 1000;
     }
 
-    njs_number_set(&vm->retval, value);
+    njs_value_number_set(&vm->retval, value);
 
     return NXT_OK;
 }
@@ -1401,7 +1401,7 @@ njs_date_prototype_get_timezone_offset(n
         value = - nxt_timezone(&tm) / 60;
     }
 
-    njs_number_set(&vm->retval, value);
+    njs_value_number_set(&vm->retval, value);
 
     return NXT_OK;
 }
@@ -1426,7 +1426,7 @@ njs_date_prototype_set_time(njs_vm_t *vm
     }
 
     args[0].data.u.date->time = time;
-    njs_number_set(&vm->retval, time);
+    njs_value_number_set(&vm->retval, time);
 
     return NXT_OK;
 }
@@ -1451,7 +1451,7 @@ njs_date_prototype_set_milliseconds(njs_
     }
 
     args[0].data.u.date->time = time;
-    njs_number_set(&vm->retval, time);
+    njs_value_number_set(&vm->retval, time);
 
     return NXT_OK;
 }
@@ -1480,7 +1480,7 @@ njs_date_prototype_set_seconds(njs_vm_t 
     }
 
     args[0].data.u.date->time = time;
-    njs_number_set(&vm->retval, time);
+    njs_value_number_set(&vm->retval, time);
 
     return NXT_OK;
 }
@@ -1519,7 +1519,7 @@ njs_date_prototype_set_minutes(njs_vm_t 
     }
 
     args[0].data.u.date->time = time;
-    njs_number_set(&vm->retval, time);
+    njs_value_number_set(&vm->retval, time);
 
     return NXT_OK;
 }
@@ -1554,7 +1554,7 @@ njs_date_prototype_set_utc_minutes(njs_v
     }
 
     args[0].data.u.date->time = time;
-    njs_number_set(&vm->retval, time);
+    njs_value_number_set(&vm->retval, time);
 
     return NXT_OK;
 }
@@ -1597,7 +1597,7 @@ njs_date_prototype_set_hours(njs_vm_t *v
     }
 
     args[0].data.u.date->time = time;
-    njs_number_set(&vm->retval, time);
+    njs_value_number_set(&vm->retval, time);
 
     return NXT_OK;
 }
@@ -1633,7 +1633,7 @@ njs_date_prototype_set_utc_hours(njs_vm_
     }
 
     args[0].data.u.date->time = time;
-    njs_number_set(&vm->retval, time);
+    njs_value_number_set(&vm->retval, time);
 
     return NXT_OK;
 }
@@ -1665,7 +1665,7 @@ njs_date_prototype_set_date(njs_vm_t *vm
     }
 
     args[0].data.u.date->time = time;
-    njs_number_set(&vm->retval, time);
+    njs_value_number_set(&vm->retval, time);
 
     return NXT_OK;
 }
@@ -1697,7 +1697,7 @@ njs_date_prototype_set_utc_date(njs_vm_t
     }
 
     args[0].data.u.date->time = time;
-    njs_number_set(&vm->retval, time);
+    njs_value_number_set(&vm->retval, time);
 
     return NXT_OK;
 }
@@ -1733,7 +1733,7 @@ njs_date_prototype_set_month(njs_vm_t *v
     }
 
     args[0].data.u.date->time = time;
-    njs_number_set(&vm->retval, time);
+    njs_value_number_set(&vm->retval, time);
 
     return NXT_OK;
 }
@@ -1769,7 +1769,7 @@ njs_date_prototype_set_utc_month(njs_vm_
     }
 
     args[0].data.u.date->time = time;
-    njs_number_set(&vm->retval, time);
+    njs_value_number_set(&vm->retval, time);
 
     return NXT_OK;
 }
@@ -1809,7 +1809,7 @@ njs_date_prototype_set_full_year(njs_vm_
     }
 
     args[0].data.u.date->time = time;
-    njs_number_set(&vm->retval, time);
+    njs_value_number_set(&vm->retval, time);
 
     return NXT_OK;
 }
@@ -1849,7 +1849,7 @@ njs_date_prototype_set_utc_full_year(njs
     }
 
     args[0].data.u.date->time = time;
-    njs_number_set(&vm->retval, time);
+    njs_value_number_set(&vm->retval, time);
 
     return NXT_OK;
 }
diff -r 0daf5a5cd37a -r 703cc218b93c njs/njs_math.c
--- a/njs/njs_math.c	Mon Feb 12 14:54:24 2018 +0300
+++ b/njs/njs_math.c	Mon Feb 12 14:57:24 2018 +0300
@@ -34,7 +34,7 @@ njs_object_math_abs(njs_vm_t *vm, njs_va
         num = NAN;
     }
 
-    njs_number_set(&vm->retval, num);
+    njs_value_number_set(&vm->retval, num);
 
     return NXT_OK;
 }
@@ -62,7 +62,7 @@ njs_object_math_acos(njs_vm_t *vm, njs_v
         num = NAN;
     }
 
-    njs_number_set(&vm->retval, num);
+    njs_value_number_set(&vm->retval, num);
 
     return NXT_OK;
 }
@@ -81,7 +81,7 @@ njs_object_math_acosh(njs_vm_t *vm, njs_
         num = NAN;
     }
 
-    njs_number_set(&vm->retval, num);
+    njs_value_number_set(&vm->retval, num);
 
     return NXT_OK;
 }
@@ -109,7 +109,7 @@ njs_object_math_asin(njs_vm_t *vm, njs_v
         num = NAN;
     }
 
-    njs_number_set(&vm->retval, num);
+    njs_value_number_set(&vm->retval, num);
 
     return NXT_OK;
 }
@@ -128,7 +128,7 @@ njs_object_math_asinh(njs_vm_t *vm, njs_
         num = NAN;
     }
 
-    njs_number_set(&vm->retval, num);
+    njs_value_number_set(&vm->retval, num);
 
     return NXT_OK;
 }
@@ -147,7 +147,7 @@ njs_object_math_atan(njs_vm_t *vm, njs_v
         num = NAN;
     }
 
-    njs_number_set(&vm->retval, num);
+    njs_value_number_set(&vm->retval, num);
 
     return NXT_OK;
 }
@@ -169,7 +169,7 @@ njs_object_math_atan2(njs_vm_t *vm, njs_
         num = NAN;
     }
 
-    njs_number_set(&vm->retval, num);
+    njs_value_number_set(&vm->retval, num);
 
     return NXT_OK;
 }
@@ -188,7 +188,7 @@ njs_object_math_atanh(njs_vm_t *vm, njs_
         num = NAN;
     }
 
-    njs_number_set(&vm->retval, num);
+    njs_value_number_set(&vm->retval, num);
 
     return NXT_OK;
 }
@@ -207,7 +207,7 @@ njs_object_math_cbrt(njs_vm_t *vm, njs_v
         num = NAN;
     }
 
-    njs_number_set(&vm->retval, num);
+    njs_value_number_set(&vm->retval, num);
 
     return NXT_OK;
 }
@@ -226,7 +226,7 @@ njs_object_math_ceil(njs_vm_t *vm, njs_v
         num = NAN;
     }
 
-    njs_number_set(&vm->retval, num);
+    njs_value_number_set(&vm->retval, num);
 
     return NXT_OK;
 }
@@ -247,7 +247,7 @@ njs_object_math_clz32(njs_vm_t *vm, njs_
         num = 32;
     }
 
-    njs_number_set(&vm->retval, num);
+    njs_value_number_set(&vm->retval, num);
 
     return NXT_OK;
 }
@@ -266,7 +266,7 @@ njs_object_math_cos(njs_vm_t *vm, njs_va
         num = NAN;
     }
 
-    njs_number_set(&vm->retval, num);
+    njs_value_number_set(&vm->retval, num);
 
     return NXT_OK;
 }
@@ -285,7 +285,7 @@ njs_object_math_cosh(njs_vm_t *vm, njs_v
         num = NAN;
     }
 
-    njs_number_set(&vm->retval, num);
+    njs_value_number_set(&vm->retval, num);
 
     return NXT_OK;
 }
@@ -304,7 +304,7 @@ njs_object_math_exp(njs_vm_t *vm, njs_va
         num = NAN;
     }
 
-    njs_number_set(&vm->retval, num);
+    njs_value_number_set(&vm->retval, num);
 
     return NXT_OK;
 }
@@ -323,7 +323,7 @@ njs_object_math_expm1(njs_vm_t *vm, njs_
         num = NAN;
     }
 
-    njs_number_set(&vm->retval, num);
+    njs_value_number_set(&vm->retval, num);
 
     return NXT_OK;
 }
@@ -342,7 +342,7 @@ njs_object_math_floor(njs_vm_t *vm, njs_
         num = NAN;
     }
 
-    njs_number_set(&vm->retval, num);
+    njs_value_number_set(&vm->retval, num);
 
     return NXT_OK;
 }
@@ -361,7 +361,7 @@ njs_object_math_fround(njs_vm_t *vm, njs
         num = NAN;
     }
 
-    njs_number_set(&vm->retval, num);
+    njs_value_number_set(&vm->retval, num);
 
     return NXT_OK;
 }
@@ -392,7 +392,7 @@ njs_object_math_hypot(njs_vm_t *vm, njs_
         }
     }
 
-    njs_number_set(&vm->retval, num);
+    njs_value_number_set(&vm->retval, num);
 
     return NXT_OK;
 }
@@ -415,7 +415,7 @@ njs_object_math_imul(njs_vm_t *vm, njs_v
         num = 0;
     }
 
-    njs_number_set(&vm->retval, num);
+    njs_value_number_set(&vm->retval, num);
 
     return NXT_OK;
 }
@@ -434,7 +434,7 @@ njs_object_math_log(njs_vm_t *vm, njs_va
         num = NAN;
     }
 
-    njs_number_set(&vm->retval, num);
+    njs_value_number_set(&vm->retval, num);
 
     return NXT_OK;
 }
@@ -453,7 +453,7 @@ njs_object_math_log10(njs_vm_t *vm, njs_
         num = NAN;
     }
 
-    njs_number_set(&vm->retval, num);
+    njs_value_number_set(&vm->retval, num);
 
     return NXT_OK;
 }
@@ -472,7 +472,7 @@ njs_object_math_log1p(njs_vm_t *vm, njs_
         num = NAN;
     }
 
-    njs_number_set(&vm->retval, num);
+    njs_value_number_set(&vm->retval, num);
 
     return NXT_OK;
 }
@@ -500,7 +500,7 @@ njs_object_math_log2(njs_vm_t *vm, njs_v
         num = NAN;
     }
 
-    njs_number_set(&vm->retval, num);
+    njs_value_number_set(&vm->retval, num);
 
     return NXT_OK;
 }
@@ -531,7 +531,7 @@ njs_object_math_max(njs_vm_t *vm, njs_va
         num = -INFINITY;
     }
 
-    njs_number_set(&vm->retval, num);
+    njs_value_number_set(&vm->retval, num);
 
     return NXT_OK;
 }
@@ -562,7 +562,7 @@ njs_object_math_min(njs_vm_t *vm, njs_va
         num = INFINITY;
     }
 
-    njs_number_set(&vm->retval, num);
+    njs_value_number_set(&vm->retval, num);
 
     return NXT_OK;
 }
@@ -595,7 +595,7 @@ njs_object_math_pow(njs_vm_t *vm, njs_va
         num = NAN;
     }
 
-    njs_number_set(&vm->retval, num);
+    njs_value_number_set(&vm->retval, num);
 
     return NXT_OK;
 }
@@ -609,7 +609,7 @@ njs_object_math_random(njs_vm_t *vm, njs
 
     num = nxt_random(&vm->random) / 4294967296.0;
 
-    njs_number_set(&vm->retval, num);
+    njs_value_number_set(&vm->retval, num);
 
     return NXT_OK;
 }
@@ -628,7 +628,7 @@ njs_object_math_round(njs_vm_t *vm, njs_
         num = NAN;
     }
 
-    njs_number_set(&vm->retval, num);
+    njs_value_number_set(&vm->retval, num);
 
     return NXT_OK;
 }
@@ -651,7 +651,7 @@ njs_object_math_sign(njs_vm_t *vm, njs_v
         num = NAN;
     }
 
-    njs_number_set(&vm->retval, num);
+    njs_value_number_set(&vm->retval, num);
 
     return NXT_OK;
 }
@@ -670,7 +670,7 @@ njs_object_math_sin(njs_vm_t *vm, njs_va
         num = NAN;
     }
 
-    njs_number_set(&vm->retval, num);
+    njs_value_number_set(&vm->retval, num);
 
     return NXT_OK;
 }
@@ -689,7 +689,7 @@ njs_object_math_sinh(njs_vm_t *vm, njs_v
         num = NAN;
     }
 
-    njs_number_set(&vm->retval, num);
+    njs_value_number_set(&vm->retval, num);
 
     return NXT_OK;
 }
@@ -708,7 +708,7 @@ njs_object_math_sqrt(njs_vm_t *vm, njs_v
         num = NAN;
     }
 
-    njs_number_set(&vm->retval, num);
+    njs_value_number_set(&vm->retval, num);
 
     return NXT_OK;
 }
@@ -727,7 +727,7 @@ njs_object_math_tan(njs_vm_t *vm, njs_va
         num = NAN;
     }
 
-    njs_number_set(&vm->retval, num);
+    njs_value_number_set(&vm->retval, num);
 
     return NXT_OK;
 }
@@ -746,7 +746,7 @@ njs_object_math_tanh(njs_vm_t *vm, njs_v
         num = NAN;
     }
 
-    njs_number_set(&vm->retval, num);
+    njs_value_number_set(&vm->retval, num);
 
     return NXT_OK;
 }
@@ -765,7 +765,7 @@ njs_object_math_trunc(njs_vm_t *vm, njs_
         num = NAN;
     }
 
-    njs_number_set(&vm->retval, num);
+    njs_value_number_set(&vm->retval, num);
 
     return NXT_OK;
 }
diff -r 0daf5a5cd37a -r 703cc218b93c njs/njs_number.c
--- a/njs/njs_number.c	Mon Feb 12 14:54:24 2018 +0300
+++ b/njs/njs_number.c	Mon Feb 12 14:57:24 2018 +0300
@@ -848,7 +848,7 @@ njs_number_parse_int(njs_vm_t *vm, njs_v
 
 done:
 
-    njs_number_set(&vm->retval, num);
+    njs_value_number_set(&vm->retval, num);
 
     return NXT_OK;
 }
@@ -866,7 +866,7 @@ njs_number_parse_float(njs_vm_t *vm, njs
         num = njs_string_to_number(&args[1], 1);
     }
 
-    njs_number_set(&vm->retval, num);
+    njs_value_number_set(&vm->retval, num);
 
     return NXT_OK;
 }
diff -r 0daf5a5cd37a -r 703cc218b93c njs/njs_regexp.c
--- a/njs/njs_regexp.c	Mon Feb 12 14:54:24 2018 +0300
+++ b/njs/njs_regexp.c	Mon Feb 12 14:57:24 2018 +0300
@@ -487,7 +487,7 @@ njs_regexp_prototype_last_index(njs_vm_t
     (void) njs_string_prop(&string, &regexp->string);
 
     index = njs_string_index(&string, regexp->last_index);
-    njs_number_set(&vm->retval, index);
+    njs_value_number_set(&vm->retval, index);
 
     return NXT_OK;
 }
@@ -752,7 +752,7 @@ njs_regexp_exec_result(njs_vm_t *vm, njs
 
     /* TODO: Non UTF-8 position */
 
-    njs_number_set(&prop->value, regexp->last_index + captures[0]);
+    njs_value_number_set(&prop->value, regexp->last_index + captures[0]);
 
     if (regexp->pattern->global) {
         regexp->last_index += captures[1];
diff -r 0daf5a5cd37a -r 703cc218b93c njs/njs_string.c
--- a/njs/njs_string.c	Mon Feb 12 14:54:24 2018 +0300
+++ b/njs/njs_string.c	Mon Feb 12 14:57:24 2018 +0300
@@ -461,7 +461,7 @@ njs_string_prototype_length(njs_vm_t *vm
         length = (length == 0) ? size : length;
     }
 
-    njs_number_set(&vm->retval, length);
+    njs_value_number_set(&vm->retval, length);
 
     njs_release(vm, value);
 
@@ -1117,7 +1117,7 @@ njs_string_prototype_char_code_at(njs_vm
 
 done:
 
-    njs_number_set(&vm->retval, num);
+    njs_value_number_set(&vm->retval, num);
 
     return NXT_OK;
 }
@@ -1240,7 +1240,7 @@ njs_string_prototype_index_of(njs_vm_t *
 
 done:
 
-    njs_number_set(&vm->retval, index);
+    njs_value_number_set(&vm->retval, index);
 
     return NXT_OK;
 }
@@ -1329,7 +1329,7 @@ njs_string_prototype_last_index_of(njs_v
 
 done:
 
-    njs_number_set(&vm->retval, index);
+    njs_value_number_set(&vm->retval, index);
 
     return NXT_OK;
 }
@@ -1931,7 +1931,7 @@ njs_string_prototype_search(njs_vm_t *vm
 
 done:
 
-    njs_number_set(&vm->retval, index);
+    njs_value_number_set(&vm->retval, index);


More information about the nginx-devel mailing list