Welcome! Log In Create A New Profile

Advanced

[njs] Modules: sorting external object property descriptors alphabetically.

Dmitry Volyntsev
August 24, 2022 09:12PM
details: https://hg.nginx.org/njs/rev/e023db05004f
branches:
changeset: 1934:e023db05004f
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Wed Aug 24 17:04:58 2022 -0700
description:
Modules: sorting external object property descriptors alphabetically.

diffstat:

nginx/ngx_http_js_module.c | 357 +++++++++++++++++++++---------------------
nginx/ngx_js.c | 63 +++---
nginx/ngx_stream_js_module.c | 166 +++++++++----------
3 files changed, 292 insertions(+), 294 deletions(-)

diffs (764 lines):

diff -r b33aae5e8dc6 -r e023db05004f nginx/ngx_http_js_module.c
--- a/nginx/ngx_http_js_module.c Tue Aug 23 19:36:16 2022 -0700
+++ b/nginx/ngx_http_js_module.c Wed Aug 24 17:04:58 2022 -0700
@@ -459,11 +459,100 @@ static njs_external_t ngx_http_js_ext_r

{
.flags = NJS_EXTERN_PROPERTY,
- .name.string = njs_str("uri"),
+ .name.string = njs_str("args"),
.enumerable = 1,
.u.property = {
- .handler = ngx_js_ext_string,
- .magic32 = offsetof(ngx_http_request_t, uri),
+ .handler = ngx_http_js_ext_get_args,
+ }
+ },
+
+ {
+ .flags = NJS_EXTERN_METHOD,
+ .name.string = njs_str("done"),
+ .writable = 1,
+ .configurable = 1,
+ .enumerable = 1,
+ .u.method = {
+ .native = ngx_http_js_ext_done,
+ }
+ },
+
+ {
+ .flags = NJS_EXTERN_METHOD,
+ .name.string = njs_str("error"),
+ .writable = 1,
+ .configurable = 1,
+ .enumerable = 1,
+ .u.method = {
+ .native = ngx_js_ext_log,
+ .magic8 = NGX_LOG_ERR,
+ }
+ },
+
+ {
+ .flags = NJS_EXTERN_METHOD,
+ .name.string = njs_str("finish"),
+ .writable = 1,
+ .configurable = 1,
+ .enumerable = 1,
+ .u.method = {
+ .native = ngx_http_js_ext_finish,
+ }
+ },
+
+ {
+ .flags = NJS_EXTERN_OBJECT,
+ .name.string = njs_str("headersIn"),
+ .enumerable = 1,
+ .u.object = {
+ .enumerable = 1,
+ .prop_handler = ngx_http_js_ext_header_in,
+ .keys = ngx_http_js_ext_keys_header_in,
+ }
+ },
+
+ {
+ .flags = NJS_EXTERN_OBJECT,
+ .name.string = njs_str("headersOut"),
+ .enumerable = 1,
+ .u.object = {
+ .writable = 1,
+ .configurable = 1,
+ .enumerable = 1,
+ .prop_handler = ngx_http_js_ext_header_out,
+ .keys = ngx_http_js_ext_keys_header_out,
+ }
+ },
+
+ {
+ .flags = NJS_EXTERN_PROPERTY,
+ .name.string = njs_str("httpVersion"),
+ .enumerable = 1,
+ .u.property = {
+ .handler = ngx_http_js_ext_get_http_version,
+ }
+ },
+
+ {
+ .flags = NJS_EXTERN_METHOD,
+ .name.string = njs_str("internalRedirect"),
+ .writable = 1,
+ .configurable = 1,
+ .enumerable = 1,
+ .u.method = {
+ .native = ngx_http_js_ext_internal_redirect,
+ }
+ },
+
+ {
+ .flags = NJS_EXTERN_METHOD,
+ .name.string = njs_str("log"),
+ .writable = 1,
+ .configurable = 1,
+ .enumerable = 1,
+ .u.method = {
+ .native = ngx_js_ext_log,
+ .magic8 = NGX_LOG_INFO,
}
},

@@ -479,10 +568,37 @@ static njs_external_t ngx_http_js_ext_r

{
.flags = NJS_EXTERN_PROPERTY,
- .name.string = njs_str("httpVersion"),
- .enumerable = 1,
+ .name.string = njs_str("parent"),
+ .u.property = {
+ .handler = ngx_http_js_ext_get_parent,
+ }
+ },
+
+ {
+ .flags = NJS_EXTERN_PROPERTY,
+ .name.string = njs_str("rawHeadersIn"),
.u.property = {
- .handler = ngx_http_js_ext_get_http_version,
+ .handler = ngx_http_js_ext_raw_header,
+ .magic32 = 0,
+ }
+ },
+
+ {
+ .flags = NJS_EXTERN_PROPERTY,
+ .name.string = njs_str("rawHeadersOut"),
+ .u.property = {
+ .handler = ngx_http_js_ext_raw_header,
+ .magic32 = 1,
+ }
+ },
+
+ {
+ .flags = NJS_EXTERN_OBJECT,
+ .name.string = njs_str("rawVariables"),
+ .u.object = {
+ .writable = 1,
+ .prop_handler = ngx_http_js_ext_variables,
+ .magic32 = NGX_JS_BUFFER,
}
},

@@ -506,6 +622,15 @@ static njs_external_t ngx_http_js_ext_r

{
.flags = NJS_EXTERN_PROPERTY,
+ .name.string = njs_str("requestBuffer"),
+ .u.property = {
+ .handler = ngx_http_js_ext_get_request_body,
+ .magic32 = NGX_JS_BUFFER,
+ }
+ },
+
+ {
+ .flags = NJS_EXTERN_PROPERTY,
.name.string = njs_str("requestText"),
.enumerable = 1,
.u.property = {
@@ -516,27 +641,19 @@ static njs_external_t ngx_http_js_ext_r

{
.flags = NJS_EXTERN_PROPERTY,
- .name.string = njs_str("requestBuffer"),
+ .name.string = njs_str("responseBody"),
.u.property = {
- .handler = ngx_http_js_ext_get_request_body,
- .magic32 = NGX_JS_BUFFER,
+ .handler = ngx_http_js_ext_get_response_body,
+ .magic32 = NGX_JS_STRING | NGX_JS_DEPRECATED,
}
},

{
.flags = NJS_EXTERN_PROPERTY,
- .name.string = njs_str("parent"),
- .u.property = {
- .handler = ngx_http_js_ext_get_parent,
- }
- },
-
- {
- .flags = NJS_EXTERN_PROPERTY,
- .name.string = njs_str("responseBody"),
+ .name.string = njs_str("responseBuffer"),
.u.property = {
.handler = ngx_http_js_ext_get_response_body,
- .magic32 = NGX_JS_STRING | NGX_JS_DEPRECATED,
+ .magic32 = NGX_JS_BUFFER,
}
},

@@ -551,150 +668,13 @@ static njs_external_t ngx_http_js_ext_r
},

{
- .flags = NJS_EXTERN_PROPERTY,
- .name.string = njs_str("responseBuffer"),
- .u.property = {
- .handler = ngx_http_js_ext_get_response_body,
- .magic32 = NGX_JS_BUFFER,
- }
- },
-
- {
- .flags = NJS_EXTERN_OBJECT,
- .name.string = njs_str("headersIn"),
- .enumerable = 1,
- .u.object = {
- .enumerable = 1,
- .prop_handler = ngx_http_js_ext_header_in,
- .keys = ngx_http_js_ext_keys_header_in,
- }
- },
-
- {
- .flags = NJS_EXTERN_PROPERTY,
- .name.string = njs_str("rawHeadersIn"),
- .u.property = {
- .handler = ngx_http_js_ext_raw_header,
- .magic32 = 0,
- }
- },
-
- {
- .flags = NJS_EXTERN_PROPERTY,
- .name.string = njs_str("args"),
- .enumerable = 1,
- .u.property = {
- .handler = ngx_http_js_ext_get_args,
- }
- },
-
- {
- .flags = NJS_EXTERN_OBJECT,
- .name.string = njs_str("variables"),
- .u.object = {
- .writable = 1,
- .prop_handler = ngx_http_js_ext_variables,
- .magic32 = NGX_JS_STRING,
- }
- },
-
- {
- .flags = NJS_EXTERN_OBJECT,
- .name.string = njs_str("rawVariables"),
- .u.object = {
- .writable = 1,
- .prop_handler = ngx_http_js_ext_variables,
- .magic32 = NGX_JS_BUFFER,
- }
- },
-
- {
- .flags = NJS_EXTERN_PROPERTY,
- .name.string = njs_str("status"),
- .writable = 1,
- .enumerable = 1,
- .u.property = {
- .handler = ngx_http_js_ext_status,
- }
- },
-
- {
- .flags = NJS_EXTERN_OBJECT,
- .name.string = njs_str("headersOut"),
- .enumerable = 1,
- .u.object = {
- .writable = 1,
- .configurable = 1,
- .enumerable = 1,
- .prop_handler = ngx_http_js_ext_header_out,
- .keys = ngx_http_js_ext_keys_header_out,
- }
- },
-
- {
- .flags = NJS_EXTERN_PROPERTY,
- .name.string = njs_str("rawHeadersOut"),
- .u.property = {
- .handler = ngx_http_js_ext_raw_header,
- .magic32 = 1,
- }
- },
-
- {
.flags = NJS_EXTERN_METHOD,
- .name.string = njs_str("subrequest"),
+ .name.string = njs_str("return"),
.writable = 1,
.configurable = 1,
.enumerable = 1,
.u.method = {
- .native = ngx_http_js_ext_subrequest,
- }
- },
-
- {
- .flags = NJS_EXTERN_METHOD,
- .name.string = njs_str("log"),
- .writable = 1,
- .configurable = 1,
- .enumerable = 1,
- .u.method = {
- .native = ngx_js_ext_log,
- .magic8 = NGX_LOG_INFO,
- }
- },
-
- {
- .flags = NJS_EXTERN_METHOD,
- .name.string = njs_str("warn"),
- .writable = 1,
- .configurable = 1,
- .enumerable = 1,
- .u.method = {
- .native = ngx_js_ext_log,
- .magic8 = NGX_LOG_WARN,
- }
- },
-
- {
- .flags = NJS_EXTERN_METHOD,
- .name.string = njs_str("error"),
- .writable = 1,
- .configurable = 1,
- .enumerable = 1,
- .u.method = {
- .native = ngx_js_ext_log,
- .magic8 = NGX_LOG_ERR,
- }
- },
-
- {
- .flags = NJS_EXTERN_METHOD,
- .name.string = njs_str("sendHeader"),
- .writable = 1,
- .configurable = 1,
- .enumerable = 1,
- .u.method = {
- .native = ngx_http_js_ext_send_header,
+ .native = ngx_http_js_ext_return,
}
},

@@ -722,6 +702,17 @@ static njs_external_t ngx_http_js_ext_r

{
.flags = NJS_EXTERN_METHOD,
+ .name.string = njs_str("sendHeader"),
+ .writable = 1,
+ .configurable = 1,
+ .enumerable = 1,
+ .u.method = {
+ .native = ngx_http_js_ext_send_header,
+ }
+ },
+
+ {
+ .flags = NJS_EXTERN_METHOD,
.name.string = njs_str("setReturnValue"),
.writable = 1,
.configurable = 1,
@@ -732,49 +723,57 @@ static njs_external_t ngx_http_js_ext_r
},

{
- .flags = NJS_EXTERN_METHOD,
- .name.string = njs_str("done"),
+ .flags = NJS_EXTERN_PROPERTY,
+ .name.string = njs_str("status"),
.writable = 1,
- .configurable = 1,
.enumerable = 1,
- .u.method = {
- .native = ngx_http_js_ext_done,
+ .u.property = {
+ .handler = ngx_http_js_ext_status,
}
},

{
.flags = NJS_EXTERN_METHOD,
- .name.string = njs_str("finish"),
+ .name.string = njs_str("subrequest"),
.writable = 1,
.configurable = 1,
.enumerable = 1,
.u.method = {
- .native = ngx_http_js_ext_finish,
+ .native = ngx_http_js_ext_subrequest,
+ }
+ },
+
+ {
+ .flags = NJS_EXTERN_PROPERTY,
+ .name.string = njs_str("uri"),
+ .enumerable = 1,
+ .u.property = {
+ .handler = ngx_js_ext_string,
+ .magic32 = offsetof(ngx_http_request_t, uri),
+ }
+ },
+
+ {
+ .flags = NJS_EXTERN_OBJECT,
+ .name.string = njs_str("variables"),
+ .u.object = {
+ .writable = 1,
+ .prop_handler = ngx_http_js_ext_variables,
+ .magic32 = NGX_JS_STRING,
}
},

{
.flags = NJS_EXTERN_METHOD,
- .name.string = njs_str("return"),
+ .name.string = njs_str("warn"),
.writable = 1,
.configurable = 1,
.enumerable = 1,
.u.method = {
- .native = ngx_http_js_ext_return,
+ .native = ngx_js_ext_log,
+ .magic8 = NGX_LOG_WARN,
}
},
-
- {
- .flags = NJS_EXTERN_METHOD,
- .name.string = njs_str("internalRedirect"),
- .writable = 1,
- .configurable = 1,
- .enumerable = 1,
- .u.method = {
- .native = ngx_http_js_ext_internal_redirect,
- }
- },
-
};


diff -r b33aae5e8dc6 -r e023db05004f nginx/ngx_js.c
--- a/nginx/ngx_js.c Tue Aug 23 19:36:16 2022 -0700
+++ b/nginx/ngx_js.c Wed Aug 24 17:04:58 2022 -0700
@@ -18,37 +18,6 @@ extern njs_module_t njs_webcrypto_modul
static njs_external_t ngx_js_ext_core[] = {

{
- .flags = NJS_EXTERN_METHOD,
- .name.string = njs_str("log"),
- .writable = 1,
- .configurable = 1,
- .enumerable = 1,
- .u.method = {
- .native = ngx_js_ext_log,
- }
- },
-
- {
- .flags = NJS_EXTERN_PROPERTY,
- .name.string = njs_str("INFO"),
- .u.property = {
- .handler = ngx_js_ext_constant,
- .magic32 = NGX_LOG_INFO,
- .magic16 = NGX_JS_NUMBER,
- }
- },
-
- {
- .flags = NJS_EXTERN_PROPERTY,
- .name.string = njs_str("WARN"),
- .u.property = {
- .handler = ngx_js_ext_constant,
- .magic32 = NGX_LOG_WARN,
- .magic16 = NGX_JS_NUMBER,
- }
- },
-
- {
.flags = NJS_EXTERN_PROPERTY,
.name.string = njs_str("ERR"),
.u.property = {
@@ -68,6 +37,38 @@ static njs_external_t ngx_js_ext_core[]
.native = ngx_js_ext_fetch,
}
},
+
+ {
+ .flags = NJS_EXTERN_PROPERTY,
+ .name.string = njs_str("INFO"),
+ .u.property = {
+ .handler = ngx_js_ext_constant,
+ .magic32 = NGX_LOG_INFO,
+ .magic16 = NGX_JS_NUMBER,
+ }
+ },
+
+ {
+ .flags = NJS_EXTERN_METHOD,
+ .name.string = njs_str("log"),
+ .writable = 1,
+ .configurable = 1,
+ .enumerable = 1,
+ .u.method = {
+ .native = ngx_js_ext_log,
+ }
+ },
+
+ {
+ .flags = NJS_EXTERN_PROPERTY,
+ .name.string = njs_str("WARN"),
+ .u.property = {
+ .handler = ngx_js_ext_constant,
+ .magic32 = NGX_LOG_WARN,
+ .magic16 = NGX_JS_NUMBER,
+ }
+ },
+
};


diff -r b33aae5e8dc6 -r e023db05004f nginx/ngx_stream_js_module.c
--- a/nginx/ngx_stream_js_module.c Tue Aug 23 19:36:16 2022 -0700
+++ b/nginx/ngx_stream_js_module.c Wed Aug 24 17:04:58 2022 -0700
@@ -326,45 +326,6 @@ static njs_external_t ngx_stream_js_ext
},

{
- .flags = NJS_EXTERN_PROPERTY,
- .name.string = njs_str("status"),
- .enumerable = 1,
- .u.property = {
- .handler = ngx_js_ext_uint,
- .magic32 = offsetof(ngx_stream_session_t, status),
- }
- },
-
- {
- .flags = NJS_EXTERN_PROPERTY,
- .name.string = njs_str("remoteAddress"),
- .enumerable = 1,
- .u.property = {
- .handler = ngx_stream_js_ext_get_remote_address,
- }
- },
-
- {
- .flags = NJS_EXTERN_OBJECT,
- .name.string = njs_str("variables"),
- .u.object = {
- .writable = 1,
- .prop_handler = ngx_stream_js_ext_variables,
- .magic32 = NGX_JS_STRING,
- }
- },
-
- {
- .flags = NJS_EXTERN_OBJECT,
- .name.string = njs_str("rawVariables"),
- .u.object = {
- .writable = 1,
- .prop_handler = ngx_stream_js_ext_variables,
- .magic32 = NGX_JS_BUFFER,
- }
- },
-
- {
.flags = NJS_EXTERN_METHOD,
.name.string = njs_str("allow"),
.writable = 1,
@@ -378,6 +339,18 @@ static njs_external_t ngx_stream_js_ext

{
.flags = NJS_EXTERN_METHOD,
+ .name.string = njs_str("decline"),
+ .writable = 1,
+ .configurable = 1,
+ .enumerable = 1,
+ .u.method = {
+ .native = ngx_stream_js_ext_done,
+ .magic8 = -NGX_DECLINED,
+ }
+ },
+
+ {
+ .flags = NJS_EXTERN_METHOD,
.name.string = njs_str("deny"),
.writable = 1,
.configurable = 1,
@@ -390,18 +363,6 @@ static njs_external_t ngx_stream_js_ext

{
.flags = NJS_EXTERN_METHOD,
- .name.string = njs_str("decline"),
- .writable = 1,
- .configurable = 1,
- .enumerable = 1,
- .u.method = {
- .native = ngx_stream_js_ext_done,
- .magic8 = -NGX_DECLINED,
- }
- },
-
- {
- .flags = NJS_EXTERN_METHOD,
.name.string = njs_str("done"),
.writable = 1,
.configurable = 1,
@@ -415,6 +376,18 @@ static njs_external_t ngx_stream_js_ext

{
.flags = NJS_EXTERN_METHOD,
+ .name.string = njs_str("error"),
+ .writable = 1,
+ .configurable = 1,
+ .enumerable = 1,
+ .u.method = {
+ .native = ngx_js_ext_log,
+ .magic8 = NGX_LOG_ERR,
+ }
+ },
+
+ {
+ .flags = NJS_EXTERN_METHOD,
.name.string = njs_str("log"),
.writable = 1,
.configurable = 1,
@@ -427,25 +400,12 @@ static njs_external_t ngx_stream_js_ext

{
.flags = NJS_EXTERN_METHOD,
- .name.string = njs_str("warn"),
+ .name.string = njs_str("off"),
.writable = 1,
.configurable = 1,
.enumerable = 1,
.u.method = {
- .native = ngx_js_ext_log,
- .magic8 = NGX_LOG_WARN,
- }
- },
-
- {
- .flags = NJS_EXTERN_METHOD,
- .name.string = njs_str("error"),
- .writable = 1,
- .configurable = 1,
- .enumerable = 1,
- .u.method = {
- .native = ngx_js_ext_log,
- .magic8 = NGX_LOG_ERR,
+ .native = ngx_stream_js_ext_off,
}
},

@@ -461,13 +421,21 @@ static njs_external_t ngx_stream_js_ext
},

{
- .flags = NJS_EXTERN_METHOD,
- .name.string = njs_str("off"),
- .writable = 1,
- .configurable = 1,
+ .flags = NJS_EXTERN_OBJECT,
+ .name.string = njs_str("rawVariables"),
+ .u.object = {
+ .writable = 1,
+ .prop_handler = ngx_stream_js_ext_variables,
+ .magic32 = NGX_JS_BUFFER,
+ }
+ },
+
+ {
+ .flags = NJS_EXTERN_PROPERTY,
+ .name.string = njs_str("remoteAddress"),
.enumerable = 1,
- .u.method = {
- .native = ngx_stream_js_ext_off,
+ .u.property = {
+ .handler = ngx_stream_js_ext_get_remote_address,
}
},

@@ -493,6 +461,37 @@ static njs_external_t ngx_stream_js_ext
}
},

+ {
+ .flags = NJS_EXTERN_PROPERTY,
+ .name.string = njs_str("status"),
+ .enumerable = 1,
+ .u.property = {
+ .handler = ngx_js_ext_uint,
+ .magic32 = offsetof(ngx_stream_session_t, status),
+ }
+ },
+
+ {
+ .flags = NJS_EXTERN_OBJECT,
+ .name.string = njs_str("variables"),
+ .u.object = {
+ .writable = 1,
+ .prop_handler = ngx_stream_js_ext_variables,
+ .magic32 = NGX_JS_STRING,
+ }
+ },
+
+ {
+ .flags = NJS_EXTERN_METHOD,
+ .name.string = njs_str("warn"),
+ .writable = 1,
+ .configurable = 1,
+ .enumerable = 1,
+ .u.method = {
+ .native = ngx_js_ext_log,
+ .magic8 = NGX_LOG_WARN,
+ }
+ },
};


@@ -508,6 +507,17 @@ static njs_external_t ngx_stream_js_ext

{
.flags = NJS_EXTERN_PROPERTY,
+ .name.string = njs_str("from_upstream"),
+ .enumerable = 1,
+ .u.property = {
+ .handler = ngx_js_ext_flags,
+ .magic16 = NGX_JS_BOOLEAN,
+ .magic32 = 0x00000002,
+ }
+ },
+
+ {
+ .flags = NJS_EXTERN_PROPERTY,
.name.string = njs_str("last"),
.enumerable = 1,
.u.property = {
@@ -516,18 +526,6 @@ static njs_external_t ngx_stream_js_ext
.magic32 = 0x00000001,
}
},
-
- {
- .flags = NJS_EXTERN_PROPERTY,
- .name.string = njs_str("from_upstream"),
- .enumerable = 1,
- .u.property = {
- .handler = ngx_js_ext_flags,
- .magic16 = NGX_JS_BOOLEAN,
- .magic32 = 0x00000002,
- }
- },
-
};


_______________________________________________
nginx-devel mailing list -- nginx-devel@nginx.org
To unsubscribe send an email to nginx-devel-leave@nginx.org
Subject Author Views Posted

[njs] Modules: sorting external object property descriptors alphabetically.

Dmitry Volyntsev 413 August 24, 2022 09:12PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 118
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready