88#include "ngx_http_wasm_types.h"
99
1010
11- #define MAX_WASM_API_ARG 5
11+ #define MAX_WASM_API_ARG 8
1212
1313
1414#define DEFINE_WASM_API (NAME , ARG , ARG_CHECK ) \
5454 int32_t p5 = args[4].of.i32; \
5555 int32_t res = NAME(p1, p2, p3, p4, p5);
5656
57+ #define DEFINE_WASM_API_ARG_I32_I32_I32_I32_I32_I32_I32_I32 \
58+ int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t
59+
60+ #define DEFINE_WASM_API_ARG_CHECK_I32_I32_I32_I32_I32_I32_I32_I32 (NAME ) \
61+ int32_t p1 = args[0].of.i32; \
62+ int32_t p2 = args[1].of.i32; \
63+ int32_t p3 = args[2].of.i32; \
64+ int32_t p4 = args[3].of.i32; \
65+ int32_t p5 = args[4].of.i32; \
66+ int32_t p6 = args[5].of.i32; \
67+ int32_t p7 = args[6].of.i32; \
68+ int32_t p8 = args[7].of.i32; \
69+ int32_t res = NAME(p1, p2, p3, p4, p5, p6, p7, p8);
70+
71+
5772#define DEFINE_WASM_NAME (NAME , ARG ) \
5873 {ngx_string(#NAME), wasmtime_##NAME, ARG},
74+ #define DEFINE_WASM_NAME_ALIAS (NAME , ARG , ALIAS ) \
75+ {ngx_string(#NAME), wasmtime_##NAME, ARG}, \
76+ {ngx_string(#ALIAS), wasmtime_##NAME, ARG},
5977#define DEFINE_WASM_NAME_ARG_I32 \
6078 1, {WASM_I32}
6179#define DEFINE_WASM_NAME_ARG_I32_I32_I32 \
6280 3, {WASM_I32, WASM_I32, WASM_I32}
6381#define DEFINE_WASM_NAME_ARG_I32_I32_I32_I32_I32 \
6482 5, {WASM_I32, WASM_I32, WASM_I32, WASM_I32, WASM_I32}
83+ #define DEFINE_WASM_NAME_ARG_I32_I32_I32_I32_I32_I32_I32_I32 \
84+ 8, {WASM_I32, WASM_I32, WASM_I32, WASM_I32, WASM_I32, WASM_I32, WASM_I32, WASM_I32}
6585
6686
6787typedef struct {
@@ -81,12 +101,19 @@ DEFINE_WASM_API(proxy_log,
81101DEFINE_WASM_API (proxy_get_buffer_bytes ,
82102 DEFINE_WASM_API_ARG_I32_I32_I32_I32_I32 ,
83103 DEFINE_WASM_API_ARG_CHECK_I32_I32_I32_I32_I32 (proxy_get_buffer_bytes ))
104+ DEFINE_WASM_API (proxy_send_http_response ,
105+ DEFINE_WASM_API_ARG_I32_I32_I32_I32_I32_I32_I32_I32 ,
106+ DEFINE_WASM_API_ARG_CHECK_I32_I32_I32_I32_I32_I32_I32_I32 (
107+ proxy_send_http_response ))
84108
85109
86110static ngx_wasm_host_api_t host_apis [] = {
87111 DEFINE_WASM_NAME (proxy_set_effective_context , DEFINE_WASM_NAME_ARG_I32 )
88112 DEFINE_WASM_NAME (proxy_log , DEFINE_WASM_NAME_ARG_I32_I32_I32 )
89113 DEFINE_WASM_NAME (proxy_get_buffer_bytes , DEFINE_WASM_NAME_ARG_I32_I32_I32_I32_I32 )
114+ DEFINE_WASM_NAME_ALIAS (proxy_send_http_response ,
115+ DEFINE_WASM_NAME_ARG_I32_I32_I32_I32_I32_I32_I32_I32 ,
116+ proxy_send_local_response )
90117 { ngx_null_string , NULL , 0 , {} }
91118};
92119
0 commit comments