nxt_str_t *expression);
static nxt_array_t *njs_object_completions(njs_vm_t *vm, njs_object_t *object);
+const njs_object_init_t njs_njs_object_init;
const njs_object_init_t *njs_object_init[] = {
NULL, /* global this */
+ &njs_njs_object_init, /* global njs object */
&njs_math_object_init, /* Math */
&njs_json_object_init, /* JSON */
};
return NXT_DECLINED;
}
+
+
+static const njs_object_prop_t njs_njs_object_properties[] =
+{
+ {
+ .type = NJS_PROPERTY,
+ .name = njs_string("version"),
+ .value = njs_string(NJS_VERSION),
+ },
+};
+
+
+const njs_object_init_t njs_njs_object_init = {
+ nxt_string("njs"),
+ njs_njs_object_properties,
+ nxt_nitems(njs_njs_object_properties),
+};
return njs_generate_name(vm, parser, node);
case NJS_TOKEN_GLOBAL_THIS:
+ case NJS_TOKEN_NJS:
case NJS_TOKEN_MATH:
case NJS_TOKEN_JSON:
case NJS_TOKEN_EVAL:
/* Builtin objects. */
{ nxt_string("this"), NJS_TOKEN_THIS, 0 },
+ { nxt_string("njs"), NJS_TOKEN_NJS, 0 },
{ nxt_string("Math"), NJS_TOKEN_MATH, 0 },
{ nxt_string("JSON"), NJS_TOKEN_JSON, 0 },
/* Fall through. */
+ case NJS_TOKEN_NJS:
case NJS_TOKEN_MATH:
case NJS_TOKEN_JSON:
return njs_parser_builtin_object(vm, parser, node);
#define NJS_TOKEN_FIRST_OBJECT NJS_TOKEN_GLOBAL_THIS
NJS_TOKEN_GLOBAL_THIS,
+ NJS_TOKEN_NJS,
NJS_TOKEN_MATH,
NJS_TOKEN_JSON,
enum njs_object_e {
NJS_OBJECT_THIS = 0,
+ NJS_OBJECT_NJS,
NJS_OBJECT_MATH,
NJS_OBJECT_JSON,
#define NJS_OBJECT_MAX (NJS_OBJECT_JSON + 1)
expect eof
}
+njs_test {
+ {"njs.version\r\n"
+ "njs.version\r\n\*\.\*\.\*"}
+}
+
# simple multi line interation
njs_test {
{"var a = 1\r\n"
{ nxt_string("this"),
nxt_string("[object Object]") },
+ { nxt_string("njs"),
+ nxt_string("[object Object]") },
+
{ nxt_string("var o = Object(); o"),
nxt_string("[object Object]") },