static njs_int_t
-njs_array_length(njs_vm_t *vm, njs_value_t *value, njs_value_t *setval,
- njs_value_t *retval)
+njs_array_length(njs_vm_t *vm,njs_object_prop_t *prop, njs_value_t *value,
+ njs_value_t *setval, njs_value_t *retval)
{
double num;
int64_t size;
static njs_int_t
-njs_process_object_argv(njs_vm_t *vm, njs_value_t *process,
- njs_value_t *unused, njs_value_t *retval)
+njs_process_object_argv(njs_vm_t *vm, njs_object_prop_t *pr,
+ njs_value_t *process, njs_value_t *unused, njs_value_t *retval)
{
char **arg;
njs_int_t ret;
static njs_int_t
-njs_process_object_env(njs_vm_t *vm, njs_value_t *process,
- njs_value_t *unused, njs_value_t *retval)
+njs_process_object_env(njs_vm_t *vm, njs_object_prop_t *pr,
+ njs_value_t *process, njs_value_t *unused, njs_value_t *retval)
{
njs_int_t ret;
njs_object_t *env;
static njs_int_t
-njs_process_object_pid(njs_vm_t *vm, njs_value_t *unused,
- njs_value_t *unused2, njs_value_t *retval)
+njs_process_object_pid(njs_vm_t *vm, njs_object_prop_t *prop,
+ njs_value_t *unused, njs_value_t *unused2, njs_value_t *retval)
{
njs_set_number(retval, getpid());
static njs_int_t
-njs_process_object_ppid(njs_vm_t *vm, njs_value_t *unused,
- njs_value_t *unused2, njs_value_t *retval)
+njs_process_object_ppid(njs_vm_t *vm, njs_object_prop_t *prop,
+ njs_value_t *unused, njs_value_t *unused2, njs_value_t *retval)
{
njs_set_number(retval, getppid());
static njs_int_t
-njs_memory_error_prototype_create(njs_vm_t *vm, njs_value_t *value,
- njs_value_t *setval, njs_value_t *retval)
+njs_memory_error_prototype_create(njs_vm_t *vm, njs_object_prop_t *prop,
+ njs_value_t *value, njs_value_t *setval, njs_value_t *retval)
{
int32_t index;
njs_function_t *function;
*/
njs_int_t
-njs_function_prototype_create(njs_vm_t *vm, njs_value_t *value,
- njs_value_t *setval, njs_value_t *retval)
+njs_function_prototype_create(njs_vm_t *vm, njs_object_prop_t *prop,
+ njs_value_t *value, njs_value_t *setval, njs_value_t *retval)
{
njs_value_t *proto, proto_value, *cons;
njs_object_t *prototype;
* the typical number of arguments expected by the function.
*/
static njs_int_t
-njs_function_instance_length(njs_vm_t *vm, njs_value_t *value,
- njs_value_t *setval, njs_value_t *retval)
+njs_function_instance_length(njs_vm_t *vm, njs_object_prop_t *prop,
+ njs_value_t *value, njs_value_t *setval, njs_value_t *retval)
{
njs_object_t *proto;
njs_function_t *function;
njs_native_frame_t *frame);
njs_int_t njs_function_rest_parameters_init(njs_vm_t *vm,
njs_native_frame_t *frame);
-njs_int_t njs_function_prototype_create(njs_vm_t *vm, njs_value_t *value,
- njs_value_t *setval, njs_value_t *retval);
+njs_int_t njs_function_prototype_create(njs_vm_t *vm, njs_object_prop_t *prop,
+ njs_value_t *value, njs_value_t *setval, njs_value_t *retval);
njs_int_t njs_function_constructor(njs_vm_t *vm, njs_value_t *args,
njs_uint_t nargs, njs_index_t unused);
njs_int_t njs_function_native_frame(njs_vm_t *vm, njs_function_t *function,
value = njs_arg(args, nargs, 1);
if (njs_is_object(value)) {
- njs_object_prototype_proto(vm, value, NULL, &vm->retval);
+ njs_object_prototype_proto(vm, NULL, value, NULL, &vm->retval);
return NJS_OK;
}
*/
njs_int_t
-njs_primitive_prototype_get_proto(njs_vm_t *vm, njs_value_t *value,
- njs_value_t *setval, njs_value_t *retval)
+njs_primitive_prototype_get_proto(njs_vm_t *vm, njs_object_prop_t *prop,
+ njs_value_t *value, njs_value_t *setval, njs_value_t *retval)
{
njs_uint_t index;
njs_object_t *proto;
*/
njs_int_t
-njs_object_prototype_create(njs_vm_t *vm, njs_value_t *value,
- njs_value_t *setval, njs_value_t *retval)
+njs_object_prototype_create(njs_vm_t *vm, njs_object_prop_t *prop,
+ njs_value_t *value, njs_value_t *setval, njs_value_t *retval)
{
int32_t index;
njs_function_t *function;
njs_int_t
-njs_object_prototype_proto(njs_vm_t *vm, njs_value_t *value,
- njs_value_t *setval, njs_value_t *retval)
+njs_object_prototype_proto(njs_vm_t *vm, njs_object_prop_t *prop,
+ njs_value_t *value, njs_value_t *setval, njs_value_t *retval)
{
njs_int_t ret;
njs_object_t *proto, *object;
*/
njs_int_t
-njs_object_prototype_create_constructor(njs_vm_t *vm, njs_value_t *value,
- njs_value_t *setval, njs_value_t *retval)
+njs_object_prototype_create_constructor(njs_vm_t *vm, njs_object_prop_t *prop,
+ njs_value_t *value, njs_value_t *setval, njs_value_t *retval)
{
int32_t index;
njs_value_t *cons;
const njs_object_prop_t *prop, njs_uint_t n);
njs_int_t njs_object_constructor(njs_vm_t *vm, njs_value_t *args,
njs_uint_t nargs, njs_index_t unused);
-njs_int_t njs_primitive_prototype_get_proto(njs_vm_t *vm, njs_value_t *value,
- njs_value_t *setval, njs_value_t *retval);
-njs_int_t njs_object_prototype_create(njs_vm_t *vm, njs_value_t *value,
- njs_value_t *setval, njs_value_t *retval);
+njs_int_t njs_primitive_prototype_get_proto(njs_vm_t *vm,
+ njs_object_prop_t *prop, njs_value_t *value, njs_value_t *setval,
+ njs_value_t *retval);
+njs_int_t njs_object_prototype_create(njs_vm_t *vm, njs_object_prop_t *prop,
+ njs_value_t *value, njs_value_t *setval, njs_value_t *retval);
njs_value_t *njs_property_prototype_create(njs_vm_t *vm, njs_lvlhsh_t *hash,
njs_object_t *prototype);
-njs_int_t njs_object_prototype_proto(njs_vm_t *vm, njs_value_t *value,
- njs_value_t *setval, njs_value_t *retval);
-njs_int_t njs_object_prototype_create_constructor(njs_vm_t *vm,
+njs_int_t njs_object_prototype_proto(njs_vm_t *vm, njs_object_prop_t *prop,
njs_value_t *value, njs_value_t *setval, njs_value_t *retval);
+njs_int_t njs_object_prototype_create_constructor(njs_vm_t *vm,
+ njs_object_prop_t *prop, njs_value_t *value, njs_value_t *setval,
+ njs_value_t *retval);
njs_value_t *njs_property_constructor_create(njs_vm_t *vm, njs_lvlhsh_t *hash,
njs_value_t *constructor);
njs_int_t njs_object_prototype_to_string(njs_vm_t *vm, njs_value_t *args,
if (njs_is_valid(&prop->value)) {
if (prev->type == NJS_PROPERTY_HANDLER) {
if (njs_is_data_descriptor(prev) && prev->writable) {
- ret = prev->value.data.u.prop_handler(vm, object, &prop->value,
+ ret = prev->value.data.u.prop_handler(vm, prev, object,
+ &prop->value,
&vm->retval);
if (njs_slow_path(ret == NJS_ERROR)) {
return ret;
case NJS_PROPERTY_HANDLER:
pq.scratch = *prop;
prop = &pq.scratch;
- ret = prop->value.data.u.prop_handler(vm, value, NULL,
+ ret = prop->value.data.u.prop_handler(vm, prop, value, NULL,
&prop->value);
if (njs_slow_path(ret == NJS_ERROR)) {
return ret;
static void njs_regexp_free(void *p, void *memory_data);
static njs_regexp_flags_t njs_regexp_flags(u_char **start, u_char *end,
njs_bool_t bound);
-static njs_int_t njs_regexp_prototype_source(njs_vm_t *vm, njs_value_t *value,
- njs_value_t *setval, njs_value_t *retval);
+static njs_int_t njs_regexp_prototype_source(njs_vm_t *vm,
+ njs_object_prop_t *prop, njs_value_t *value, njs_value_t *setval,
+ njs_value_t *retval);
static int njs_regexp_pattern_compile(njs_vm_t *vm, njs_regex_t *regex,
u_char *source, int options);
static u_char *njs_regexp_compile_trace_handler(njs_trace_t *trace,
re_flags = 0;
if (njs_is_regexp(pattern)) {
- ret = njs_regexp_prototype_source(vm, pattern, NULL, &source);
+ ret = njs_regexp_prototype_source(vm, NULL, pattern, NULL, &source);
if (njs_slow_path(ret != NJS_OK)) {
return ret;
}
static njs_int_t
-njs_regexp_prototype_last_index(njs_vm_t *vm, njs_value_t *value,
- njs_value_t *setval, njs_value_t *retval)
+njs_regexp_prototype_last_index(njs_vm_t *vm, njs_object_prop_t *prop,
+ njs_value_t *value, njs_value_t *setval, njs_value_t *retval)
{
uint32_t index;
njs_regexp_t *regexp;
static njs_int_t
-njs_regexp_prototype_global(njs_vm_t *vm, njs_value_t *value,
- njs_value_t *setval, njs_value_t *retval)
+njs_regexp_prototype_global(njs_vm_t *vm, njs_object_prop_t *prop,
+ njs_value_t *value, njs_value_t *setval, njs_value_t *retval)
{
njs_regexp_pattern_t *pattern;
static njs_int_t
-njs_regexp_prototype_ignore_case(njs_vm_t *vm, njs_value_t *value,
- njs_value_t *setval, njs_value_t *retval)
+njs_regexp_prototype_ignore_case(njs_vm_t *vm, njs_object_prop_t *prop,
+ njs_value_t *value, njs_value_t *setval, njs_value_t *retval)
{
njs_regexp_pattern_t *pattern;
static njs_int_t
-njs_regexp_prototype_multiline(njs_vm_t *vm, njs_value_t *value,
- njs_value_t *setval, njs_value_t *retval)
+njs_regexp_prototype_multiline(njs_vm_t *vm, njs_object_prop_t *prop,
+ njs_value_t *value, njs_value_t *setval, njs_value_t *retval)
{
njs_regexp_pattern_t *pattern;
static njs_int_t
-njs_regexp_prototype_source(njs_vm_t *vm, njs_value_t *value,
- njs_value_t *setval, njs_value_t *retval)
+njs_regexp_prototype_source(njs_vm_t *vm, njs_object_prop_t *prop,
+ njs_value_t *value, njs_value_t *setval, njs_value_t *retval)
{
u_char *source;
int32_t length;
static njs_int_t
-njs_string_instance_length(njs_vm_t *vm, njs_value_t *value,
- njs_value_t *setval, njs_value_t *retval)
+njs_string_instance_length(njs_vm_t *vm, njs_object_prop_t *prop,
+ njs_value_t *value, njs_value_t *setval, njs_value_t *retval)
{
size_t size;
uintptr_t length;
njs_property_query_t *pq, njs_value_t *object, uint32_t index);
static njs_int_t njs_external_property_query(njs_vm_t *vm,
njs_property_query_t *pq, njs_value_t *object);
-static njs_int_t njs_external_property_set(njs_vm_t *vm, njs_value_t *value,
- njs_value_t *setval, njs_value_t *retval);
-static njs_int_t njs_external_property_delete(njs_vm_t *vm, njs_value_t *value,
- njs_value_t *setval, njs_value_t *retval);
+static njs_int_t njs_external_property_set(njs_vm_t *vm,
+ njs_object_prop_t *prop, njs_value_t *value, njs_value_t *setval,
+ njs_value_t *retval);
+static njs_int_t njs_external_property_delete(njs_vm_t *vm,
+ njs_object_prop_t *prop, njs_value_t *value, njs_value_t *setval,
+ njs_value_t *retval);
const njs_value_t njs_value_null = njs_value(NJS_NULL, 0, 0.0);
static njs_int_t
-njs_external_property_set(njs_vm_t *vm, njs_value_t *value, njs_value_t *setval,
- njs_value_t *retval)
+njs_external_property_set(njs_vm_t *vm, njs_object_prop_t *prop,
+ njs_value_t *value, njs_value_t *setval, njs_value_t *retval)
{
void *obj;
njs_int_t ret;
static njs_int_t
-njs_external_property_delete(njs_vm_t *vm, njs_value_t *value,
- njs_value_t *unused, njs_value_t *unused2)
+njs_external_property_delete(njs_vm_t *vm, njs_object_prop_t *prop,
+ njs_value_t *value, njs_value_t *unused, njs_value_t *unused2)
{
void *obj;
njs_property_query_t *pq;
case NJS_PROPERTY_HANDLER:
pq.scratch = *prop;
prop = &pq.scratch;
- ret = prop->value.data.u.prop_handler(vm, value, NULL,
+ ret = prop->value.data.u.prop_handler(vm, prop, value, NULL,
&prop->value);
if (njs_slow_path(ret == NJS_ERROR)) {
}
if (prop->type == NJS_PROPERTY_HANDLER) {
- ret = prop->value.data.u.prop_handler(vm, value, setval,
+ ret = prop->value.data.u.prop_handler(vm, prop, value, setval,
&vm->retval);
if (njs_slow_path(ret != NJS_DECLINED)) {
return ret;
switch (prop->type) {
case NJS_PROPERTY_HANDLER:
if (njs_is_external(value)) {
- ret = prop->value.data.u.prop_handler(vm, value, NULL, NULL);
+ ret = prop->value.data.u.prop_handler(vm, prop, value, NULL, NULL);
if (njs_slow_path(ret != NJS_OK)) {
return NJS_ERROR;
}
} njs_value_type_t;
+typedef struct njs_object_prop_s njs_object_prop_t;
+typedef struct njs_string_s njs_string_t;
+typedef struct njs_object_s njs_object_t;
+typedef struct njs_object_value_s njs_object_value_t;
+typedef struct njs_function_lambda_s njs_function_lambda_t;
+typedef struct njs_regexp_pattern_s njs_regexp_pattern_t;
+typedef struct njs_array_s njs_array_t;
+typedef struct njs_regexp_s njs_regexp_t;
+typedef struct njs_date_s njs_date_t;
+typedef struct njs_property_next_s njs_property_next_t;
+typedef struct njs_object_init_s njs_object_init_t;
+
+
/*
* njs_prop_handler_t operates as a property getter and/or setter.
* The handler receives NULL setval if it is invoked in GET context and
* NJS_DECLINED - handler was applied to inappropriate object, vm->retval
* contains undefined value.
*/
-typedef njs_int_t (*njs_prop_handler_t) (njs_vm_t *vm, njs_value_t *value,
- njs_value_t *setval, njs_value_t *retval);
+typedef njs_int_t (*njs_prop_handler_t) (njs_vm_t *vm, njs_object_prop_t *prop,
+ njs_value_t *value, njs_value_t *setval, njs_value_t *retval);
typedef njs_int_t (*njs_function_native_t) (njs_vm_t *vm, njs_value_t *args,
njs_uint_t nargs, njs_index_t retval);
-
-typedef struct njs_string_s njs_string_t;
-typedef struct njs_object_s njs_object_t;
-typedef struct njs_object_value_s njs_object_value_t;
-typedef struct njs_function_lambda_s njs_function_lambda_t;
-typedef struct njs_regexp_pattern_s njs_regexp_pattern_t;
-typedef struct njs_array_s njs_array_t;
-typedef struct njs_regexp_s njs_regexp_t;
-typedef struct njs_date_s njs_date_t;
-typedef struct njs_property_next_s njs_property_next_t;
-typedef struct njs_object_init_s njs_object_init_t;
-
#if (!NJS_HAVE_GCC_ATTRIBUTE_ALIGNED)
#error "aligned attribute is required"
#endif
} njs_object_attribute_t;
-typedef struct {
+struct njs_object_prop_s {
/* Must be aligned to njs_value_t. */
njs_value_t value;
njs_value_t name;
njs_object_attribute_t writable:8; /* 2 bits */
njs_object_attribute_t enumerable:8; /* 2 bits */
njs_object_attribute_t configurable:8; /* 2 bits */
-} njs_object_prop_t;
+};
typedef struct {
goto fail;
}
- ret = prop->value.data.u.prop_handler(vm, value, init, &vm->retval);
+ ret = prop->value.data.u.prop_handler(vm, prop, value, init, &vm->retval);
if (njs_slow_path(ret != NJS_OK)) {
goto fail;
}