[njs] Removing console.help() from CLI as it not needed anymore.
Dmitry Volyntsev
xeioex at nginx.com
Thu Oct 31 15:18:03 UTC 2019
details: https://hg.nginx.org/njs/rev/ce17b8cd9630
branches:
changeset: 1213:ce17b8cd9630
user: Dmitry Volyntsev <xeioex at nginx.com>
date: Thu Oct 31 18:17:32 2019 +0300
description:
Removing console.help() from CLI as it not needed anymore.
Now all available objects are accessible through the global object.
diffstat:
src/njs_array.c | 3 ---
src/njs_boolean.c | 2 --
src/njs_builtin.c | 18 ++++++++++++++----
src/njs_crypto.c | 5 -----
src/njs_date.c | 2 --
src/njs_error.c | 17 -----------------
src/njs_fs.c | 1 -
src/njs_function.c | 6 ------
src/njs_json.c | 1 -
src/njs_math.c | 1 -
src/njs_number.c | 3 ---
src/njs_object.c | 2 --
src/njs_object.h | 1 -
src/njs_regexp.c | 2 --
src/njs_shell.c | 47 +----------------------------------------------
src/njs_string.c | 3 ---
test/njs_expect_test.exp | 3 ---
17 files changed, 15 insertions(+), 102 deletions(-)
diffs (592 lines):
diff -r 2868545c461b -r ce17b8cd9630 src/njs_array.c
--- a/src/njs_array.c Thu Oct 31 18:17:31 2019 +0300
+++ b/src/njs_array.c Thu Oct 31 18:17:32 2019 +0300
@@ -322,7 +322,6 @@ static const njs_object_prop_t njs_arra
const njs_object_init_t njs_array_constructor_init = {
- njs_str("Array"),
njs_array_constructor_properties,
njs_nitems(njs_array_constructor_properties),
};
@@ -2987,7 +2986,6 @@ static const njs_object_prop_t njs_arra
const njs_object_init_t njs_array_prototype_init = {
- njs_str("Array"),
njs_array_prototype_properties,
njs_nitems(njs_array_prototype_properties),
};
@@ -3005,7 +3003,6 @@ const njs_object_prop_t njs_array_insta
const njs_object_init_t njs_array_instance_init = {
- njs_str("Array instance"),
njs_array_instance_properties,
njs_nitems(njs_array_instance_properties),
};
diff -r 2868545c461b -r ce17b8cd9630 src/njs_boolean.c
--- a/src/njs_boolean.c Thu Oct 31 18:17:31 2019 +0300
+++ b/src/njs_boolean.c Thu Oct 31 18:17:32 2019 +0300
@@ -66,7 +66,6 @@ static const njs_object_prop_t njs_bool
const njs_object_init_t njs_boolean_constructor_init = {
- njs_str("Boolean"),
njs_boolean_constructor_properties,
njs_nitems(njs_boolean_constructor_properties),
};
@@ -161,7 +160,6 @@ static const njs_object_prop_t njs_bool
const njs_object_init_t njs_boolean_prototype_init = {
- njs_str("Boolean"),
njs_boolean_prototype_properties,
njs_nitems(njs_boolean_prototype_properties),
};
diff -r 2868545c461b -r ce17b8cd9630 src/njs_builtin.c
--- a/src/njs_builtin.c Thu Oct 31 18:17:31 2019 +0300
+++ b/src/njs_builtin.c Thu Oct 31 18:17:32 2019 +0300
@@ -199,10 +199,12 @@ njs_builtin_objects_create(njs_vm_t *vm)
njs_lvlhsh_query_t lhq;
njs_regexp_pattern_t *pattern;
njs_object_prototype_t *prototype;
+ const njs_object_prop_t *prop;
const njs_object_init_t *obj, **p;
const njs_function_init_t *f;
static const njs_str_t sandbox_key = njs_str("sandbox");
+ static const njs_str_t name_key = njs_str("name");
shared = njs_mp_zalloc(vm->mem_pool, sizeof(njs_vm_shared_t));
if (njs_slow_path(shared == NULL)) {
@@ -308,7 +310,18 @@ njs_builtin_objects_create(njs_vm_t *vm)
}
}
- module->name = obj->name;
+ lhq.key = name_key;
+ lhq.key_hash = njs_djb_hash(name_key.start, name_key.length);
+ lhq.proto = &njs_object_hash_proto;
+
+ ret = njs_lvlhsh_find(&module->object.shared_hash, &lhq);
+ if (njs_fast_path(ret != NJS_OK)) {
+ return NJS_ERROR;
+ }
+
+ prop = lhq.value;
+
+ njs_string_get(&prop->value, &module->name);
module->object.shared = 1;
lhq.key = module->name;
@@ -1463,7 +1476,6 @@ static const njs_object_prop_t njs_glob
const njs_object_init_t njs_global_this_init = {
- njs_str(""),
njs_global_this_object_properties,
njs_nitems(njs_global_this_object_properties)
};
@@ -1489,7 +1501,6 @@ static const njs_object_prop_t njs_njs_
const njs_object_init_t njs_njs_object_init = {
- njs_str("njs"),
njs_njs_object_properties,
njs_nitems(njs_njs_object_properties),
};
@@ -1698,7 +1709,6 @@ static const njs_object_prop_t njs_proc
const njs_object_init_t njs_process_object_init = {
- njs_str("process"),
njs_process_object_properties,
njs_nitems(njs_process_object_properties),
};
diff -r 2868545c461b -r ce17b8cd9630 src/njs_crypto.c
--- a/src/njs_crypto.c Thu Oct 31 18:17:31 2019 +0300
+++ b/src/njs_crypto.c Thu Oct 31 18:17:32 2019 +0300
@@ -347,7 +347,6 @@ static const njs_object_prop_t njs_hash
const njs_object_init_t njs_hash_prototype_init = {
- njs_str("Hash"),
njs_hash_prototype_properties,
njs_nitems(njs_hash_prototype_properties),
};
@@ -386,7 +385,6 @@ static const njs_object_prop_t njs_hash
const njs_object_init_t njs_hash_constructor_init = {
- njs_str("Hash"),
njs_hash_constructor_properties,
njs_nitems(njs_hash_constructor_properties),
};
@@ -631,7 +629,6 @@ static const njs_object_prop_t njs_hmac
const njs_object_init_t njs_hmac_prototype_init = {
- njs_str("Hmac"),
njs_hmac_prototype_properties,
njs_nitems(njs_hmac_prototype_properties),
};
@@ -670,7 +667,6 @@ static const njs_object_prop_t njs_hmac
const njs_object_init_t njs_hmac_constructor_init = {
- njs_str("Hmac"),
njs_hmac_constructor_properties,
njs_nitems(njs_hmac_constructor_properties),
};
@@ -711,7 +707,6 @@ static const njs_object_prop_t njs_cryp
const njs_object_init_t njs_crypto_object_init = {
- njs_str("crypto"),
njs_crypto_object_properties,
njs_nitems(njs_crypto_object_properties),
};
diff -r 2868545c461b -r ce17b8cd9630 src/njs_date.c
--- a/src/njs_date.c Thu Oct 31 18:17:31 2019 +0300
+++ b/src/njs_date.c Thu Oct 31 18:17:32 2019 +0300
@@ -1048,7 +1048,6 @@ static const njs_object_prop_t njs_date
const njs_object_init_t njs_date_constructor_init = {
- njs_str("Date"),
njs_date_constructor_properties,
njs_nitems(njs_date_constructor_properties),
};
@@ -2888,7 +2887,6 @@ static const njs_object_prop_t njs_date
const njs_object_init_t njs_date_prototype_init = {
- njs_str("Date"),
njs_date_prototype_properties,
njs_nitems(njs_date_prototype_properties),
};
diff -r 2868545c461b -r ce17b8cd9630 src/njs_error.c
--- a/src/njs_error.c Thu Oct 31 18:17:31 2019 +0300
+++ b/src/njs_error.c Thu Oct 31 18:17:32 2019 +0300
@@ -201,7 +201,6 @@ static const njs_object_prop_t njs_erro
const njs_object_init_t njs_error_constructor_init = {
- njs_str("Error"),
njs_error_constructor_properties,
njs_nitems(njs_error_constructor_properties),
};
@@ -243,7 +242,6 @@ static const njs_object_prop_t njs_eval
const njs_object_init_t njs_eval_error_constructor_init = {
- njs_str("EvalError"),
njs_eval_error_constructor_properties,
njs_nitems(njs_eval_error_constructor_properties),
};
@@ -285,7 +283,6 @@ static const njs_object_prop_t njs_inte
const njs_object_init_t njs_internal_error_constructor_init = {
- njs_str("InternalError"),
njs_internal_error_constructor_properties,
njs_nitems(njs_internal_error_constructor_properties),
};
@@ -327,7 +324,6 @@ static const njs_object_prop_t njs_rang
const njs_object_init_t njs_range_error_constructor_init = {
- njs_str("RangeError"),
njs_range_error_constructor_properties,
njs_nitems(njs_range_error_constructor_properties),
};
@@ -369,7 +365,6 @@ static const njs_object_prop_t njs_refe
const njs_object_init_t njs_reference_error_constructor_init = {
- njs_str("ReferenceError"),
njs_reference_error_constructor_properties,
njs_nitems(njs_reference_error_constructor_properties),
};
@@ -411,7 +406,6 @@ static const njs_object_prop_t njs_synt
const njs_object_init_t njs_syntax_error_constructor_init = {
- njs_str("SyntaxError"),
njs_syntax_error_constructor_properties,
njs_nitems(njs_syntax_error_constructor_properties),
};
@@ -453,7 +447,6 @@ static const njs_object_prop_t njs_type
const njs_object_init_t njs_type_error_constructor_init = {
- njs_str("TypeError"),
njs_type_error_constructor_properties,
njs_nitems(njs_type_error_constructor_properties),
};
@@ -495,7 +488,6 @@ static const njs_object_prop_t njs_uri_
const njs_object_init_t njs_uri_error_constructor_init = {
- njs_str("URIError"),
njs_uri_error_constructor_properties,
njs_nitems(njs_uri_error_constructor_properties),
};
@@ -597,7 +589,6 @@ static const njs_object_prop_t njs_memo
const njs_object_init_t njs_memory_error_constructor_init = {
- njs_str("MemoryError"),
njs_memory_error_constructor_properties,
njs_nitems(njs_memory_error_constructor_properties),
};
@@ -762,7 +753,6 @@ static const njs_object_prop_t njs_erro
const njs_object_init_t njs_error_prototype_init = {
- njs_str("Error"),
njs_error_prototype_properties,
njs_nitems(njs_error_prototype_properties),
};
@@ -797,7 +787,6 @@ static const njs_object_prop_t njs_eval
const njs_object_init_t njs_eval_error_prototype_init = {
- njs_str("EvalError"),
njs_eval_error_prototype_properties,
njs_nitems(njs_eval_error_prototype_properties),
};
@@ -852,7 +841,6 @@ static const njs_object_prop_t njs_inte
const njs_object_init_t njs_internal_error_prototype_init = {
- njs_str("InternalError"),
njs_internal_error_prototype_properties,
njs_nitems(njs_internal_error_prototype_properties),
};
@@ -887,7 +875,6 @@ static const njs_object_prop_t njs_rang
const njs_object_init_t njs_range_error_prototype_init = {
- njs_str("RangeError"),
njs_range_error_prototype_properties,
njs_nitems(njs_range_error_prototype_properties),
};
@@ -922,7 +909,6 @@ static const njs_object_prop_t njs_refe
const njs_object_init_t njs_reference_error_prototype_init = {
- njs_str("ReferenceError"),
njs_reference_error_prototype_properties,
njs_nitems(njs_reference_error_prototype_properties),
};
@@ -957,7 +943,6 @@ static const njs_object_prop_t njs_synt
const njs_object_init_t njs_syntax_error_prototype_init = {
- njs_str("SyntaxError"),
njs_syntax_error_prototype_properties,
njs_nitems(njs_syntax_error_prototype_properties),
};
@@ -992,7 +977,6 @@ static const njs_object_prop_t njs_type
const njs_object_init_t njs_type_error_prototype_init = {
- njs_str("TypeError"),
njs_type_error_prototype_properties,
njs_nitems(njs_type_error_prototype_properties),
};
@@ -1027,7 +1011,6 @@ static const njs_object_prop_t njs_uri_
const njs_object_init_t njs_uri_error_prototype_init = {
- njs_str("URIError"),
njs_uri_error_prototype_properties,
njs_nitems(njs_uri_error_prototype_properties),
};
diff -r 2868545c461b -r ce17b8cd9630 src/njs_fs.c
--- a/src/njs_fs.c Thu Oct 31 18:17:31 2019 +0300
+++ b/src/njs_fs.c Thu Oct 31 18:17:32 2019 +0300
@@ -1215,7 +1215,6 @@ static const njs_object_prop_t njs_fs_o
const njs_object_init_t njs_fs_object_init = {
- njs_str("fs"),
njs_fs_object_properties,
njs_nitems(njs_fs_object_properties),
};
diff -r 2868545c461b -r ce17b8cd9630 src/njs_function.c
--- a/src/njs_function.c Thu Oct 31 18:17:31 2019 +0300
+++ b/src/njs_function.c Thu Oct 31 18:17:32 2019 +0300
@@ -275,7 +275,6 @@ const njs_object_prop_t njs_arguments_o
const njs_object_init_t njs_arguments_object_instance_init = {
- njs_str("Argument object instance"),
njs_arguments_object_instance_properties,
njs_nitems(njs_arguments_object_instance_properties),
};
@@ -872,7 +871,6 @@ static const njs_object_prop_t njs_func
const njs_object_init_t njs_function_constructor_init = {
- njs_str("Function"),
njs_function_constructor_properties,
njs_nitems(njs_function_constructor_properties),
};
@@ -1157,7 +1155,6 @@ static const njs_object_prop_t njs_func
const njs_object_init_t njs_function_prototype_init = {
- njs_str("Function"),
njs_function_prototype_properties,
njs_nitems(njs_function_prototype_properties),
};
@@ -1182,7 +1179,6 @@ const njs_object_prop_t njs_function_in
const njs_object_init_t njs_function_instance_init = {
- njs_str("Function instance"),
njs_function_instance_properties,
njs_nitems(njs_function_instance_properties),
};
@@ -1200,7 +1196,6 @@ const njs_object_prop_t njs_arrow_insta
const njs_object_init_t njs_arrow_instance_init = {
- njs_str("Arrow instance"),
njs_arrow_instance_properties,
njs_nitems(njs_arrow_instance_properties),
};
@@ -1237,7 +1232,6 @@ static const njs_object_prop_t njs_eval
const njs_object_init_t njs_eval_function_init = {
- njs_str("eval"),
njs_eval_function_properties,
njs_nitems(njs_eval_function_properties),
};
diff -r 2868545c461b -r ce17b8cd9630 src/njs_json.c
--- a/src/njs_json.c Thu Oct 31 18:17:31 2019 +0300
+++ b/src/njs_json.c Thu Oct 31 18:17:32 2019 +0300
@@ -2122,7 +2122,6 @@ static const njs_object_prop_t njs_json
const njs_object_init_t njs_json_object_init = {
- njs_str("JSON"),
njs_json_object_properties,
njs_nitems(njs_json_object_properties),
};
diff -r 2868545c461b -r ce17b8cd9630 src/njs_math.c
--- a/src/njs_math.c Thu Oct 31 18:17:31 2019 +0300
+++ b/src/njs_math.c Thu Oct 31 18:17:32 2019 +0300
@@ -1321,7 +1321,6 @@ static const njs_object_prop_t njs_math
const njs_object_init_t njs_math_object_init = {
- njs_str("Math"),
njs_math_object_properties,
njs_nitems(njs_math_object_properties),
};
diff -r 2868545c461b -r ce17b8cd9630 src/njs_number.c
--- a/src/njs_number.c Thu Oct 31 18:17:31 2019 +0300
+++ b/src/njs_number.c Thu Oct 31 18:17:32 2019 +0300
@@ -499,7 +499,6 @@ static const njs_object_prop_t njs_numb
const njs_object_init_t njs_number_constructor_init = {
- njs_str("Number"),
njs_number_constructor_properties,
njs_nitems(njs_number_constructor_properties),
};
@@ -963,7 +962,6 @@ static const njs_object_prop_t njs_numb
const njs_object_init_t njs_number_prototype_init = {
- njs_str("Number"),
njs_number_prototype_properties,
njs_nitems(njs_number_prototype_properties),
};
@@ -1146,7 +1144,6 @@ static const njs_object_prop_t njs_is_f
const njs_object_init_t njs_is_finite_function_init = {
- njs_str("isFinite"),
njs_is_finite_function_properties,
njs_nitems(njs_is_finite_function_properties),
};
diff -r 2868545c461b -r ce17b8cd9630 src/njs_object.c
--- a/src/njs_object.c Thu Oct 31 18:17:31 2019 +0300
+++ b/src/njs_object.c Thu Oct 31 18:17:32 2019 +0300
@@ -1912,7 +1912,6 @@ static const njs_object_prop_t njs_obje
const njs_object_init_t njs_object_constructor_init = {
- njs_str("Object"),
njs_object_constructor_properties,
njs_nitems(njs_object_constructor_properties),
};
@@ -2368,7 +2367,6 @@ static const njs_object_prop_t njs_obje
const njs_object_init_t njs_object_prototype_init = {
- njs_str("Object"),
njs_object_prototype_properties,
njs_nitems(njs_object_prototype_properties),
};
diff -r 2868545c461b -r ce17b8cd9630 src/njs_object.h
--- a/src/njs_object.h Thu Oct 31 18:17:31 2019 +0300
+++ b/src/njs_object.h Thu Oct 31 18:17:32 2019 +0300
@@ -37,7 +37,6 @@ typedef enum {
struct njs_object_init_s {
- njs_str_t name;
const njs_object_prop_t *properties;
njs_uint_t items;
};
diff -r 2868545c461b -r ce17b8cd9630 src/njs_regexp.c
--- a/src/njs_regexp.c Thu Oct 31 18:17:31 2019 +0300
+++ b/src/njs_regexp.c Thu Oct 31 18:17:32 2019 +0300
@@ -1189,7 +1189,6 @@ static const njs_object_prop_t njs_rege
const njs_object_init_t njs_regexp_constructor_init = {
- njs_str("RegExp"),
njs_regexp_constructor_properties,
njs_nitems(njs_regexp_constructor_properties),
};
@@ -1266,7 +1265,6 @@ static const njs_object_prop_t njs_rege
const njs_object_init_t njs_regexp_prototype_init = {
- njs_str("RegExp"),
njs_regexp_prototype_properties,
njs_nitems(njs_regexp_prototype_properties),
};
diff -r 2868545c461b -r ce17b8cd9630 src/njs_shell.c
--- a/src/njs_shell.c Thu Oct 31 18:17:31 2019 +0300
+++ b/src/njs_shell.c Thu Oct 31 18:17:32 2019 +0300
@@ -85,8 +85,6 @@ static njs_int_t njs_ext_console_log(njs
njs_uint_t nargs, njs_index_t unused);
static njs_int_t njs_ext_console_dump(njs_vm_t *vm, njs_value_t *args,
njs_uint_t nargs, njs_index_t unused);
-static njs_int_t njs_ext_console_help(njs_vm_t *vm, njs_value_t *args,
- njs_uint_t nargs, njs_index_t unused);
static njs_int_t njs_ext_console_time(njs_vm_t *vm, njs_value_t *args,
njs_uint_t nargs, njs_index_t unused);
static njs_int_t njs_ext_console_time_end(njs_vm_t *vm, njs_value_t *args,
@@ -126,17 +124,6 @@ static njs_external_t njs_ext_console[]
njs_ext_console_dump,
0 },
- { njs_str("help"),
- NJS_EXTERN_METHOD,
- NULL,
- 0,
- NULL,
- NULL,
- NULL,
- NULL,
- njs_ext_console_help,
- 0 },
-
{ njs_str("time"),
NJS_EXTERN_METHOD,
NULL,
@@ -473,8 +460,7 @@ njs_interactive_shell(njs_opts_t *opts,
if (!opts->quiet) {
njs_printf("interactive njs %s\n\n", NJS_VERSION);
- njs_printf("v.<Tab> -> the properties and prototype methods of v.\n");
- njs_printf("type console.help() for more information\n\n");
+ njs_printf("v.<Tab> -> the properties and prototype methods of v.\n\n");
}
for ( ;; ) {
@@ -1025,37 +1011,6 @@ njs_ext_console_dump(njs_vm_t *vm, njs_v
static njs_int_t
-njs_ext_console_help(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
- njs_index_t unused)
-{
- const njs_object_init_t *obj, **objpp;
-
- njs_printf("VM built-in objects:\n");
-
- for (objpp = njs_constructor_init; *objpp != NULL; objpp++) {
- obj = *objpp;
-
- njs_printf(" %V\n", &obj->name);
- }
-
- for (objpp = njs_object_init; *objpp != NULL; objpp++) {
- obj = *objpp;
-
- njs_printf(" %V\n", &obj->name);
- }
-
- njs_printf("\nEmbedded objects:\n");
- njs_printf(" console\n");
-
- njs_printf("\n");
-
- njs_set_undefined(&vm->retval);
-
- return NJS_OK;
-}
-
-
-static njs_int_t
njs_ext_console_time(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
njs_index_t unused)
{
diff -r 2868545c461b -r ce17b8cd9630 src/njs_string.c
--- a/src/njs_string.c Thu Oct 31 18:17:31 2019 +0300
+++ b/src/njs_string.c Thu Oct 31 18:17:32 2019 +0300
@@ -630,7 +630,6 @@ static const njs_object_prop_t njs_stri
const njs_object_init_t njs_string_constructor_init = {
- njs_str("String"),
njs_string_constructor_properties,
njs_nitems(njs_string_constructor_properties),
};
@@ -4723,7 +4722,6 @@ static const njs_object_prop_t njs_stri
const njs_object_init_t njs_string_prototype_init = {
- njs_str("String"),
njs_string_prototype_properties,
njs_nitems(njs_string_prototype_properties),
};
@@ -4740,7 +4738,6 @@ const njs_object_prop_t njs_string_inst
const njs_object_init_t njs_string_instance_init = {
- njs_str("String instance"),
njs_string_instance_properties,
njs_nitems(njs_string_instance_properties),
};
diff -r 2868545c461b -r ce17b8cd9630 test/njs_expect_test.exp
--- a/test/njs_expect_test.exp Thu Oct 31 18:17:31 2019 +0300
+++ b/test/njs_expect_test.exp Thu Oct 31 18:17:32 2019 +0300
@@ -26,7 +26,6 @@ proc njs_test {body {opts ""}} {
expect -re "interactive njs \\d+\.\\d+\.\\d+\r\n\r"
expect "v.<Tab> -> the properties and prototype methods of v.\r
-type console.help() for more information\r
\r
>> "
@@ -220,8 +219,6 @@ njs_test {
"console.dump(1)\r\n1\r\nundefined\r\n>> "}
{"console.dump(1, 'a')\r\n"
"console.dump(1, 'a')\r\n1 a\r\nundefined\r\n>> "}
- {"console.help()\r\n"
- "console.help()\r\nVM built-in objects:"}
}
# console.time* functions
More information about the nginx-devel
mailing list