aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/bindings/generated_classes.zig
blob: 700d1e53dba84666b7975f6ad302b0735e17e6c5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297

const JSC = @import("javascript_core");
const Classes = @import("./generated_classes_list.zig").Classes;
const Environment = @import("../../env.zig");
const std = @import("std");

const StaticGetterType = fn(*JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
const StaticSetterType = fn(*JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
const StaticCallbackType = fn(*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;



pub const JSRequest = struct {
    const Request = Classes.Request;
    const GetterType = fn(*Request, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
    const SetterType = fn(*Request, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
    const CallbackType = fn(*Request, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;

    /// Return the pointer to the wrapped object.
    /// If the object does not match the type, return null.
    pub fn fromJS(value: JSC.JSValue) ?*Request {
        JSC.markBinding();
        return Request__fromJS(value);
    }

    /// Create a new instance of Request
    pub fn toJS(this: *Request, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
        JSC.markBinding();
        if (comptime Environment.allow_assert) {
            const value__ = Request__create(globalObject, this);
            std.debug.assert(value__.as(Request).? == this); // If this fails, likely a C ABI issue.
            return value__;
        } else {
            return Request__create(globalObject, this);
        }
    }

    /// Modify the internal ptr to point to a new instance of Request.
    pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*Request) bool {
      JSC.markBinding();
      return Request__dangerouslySetPtr(value, ptr);
    }

    extern fn Request__fromJS(JSC.JSValue) ?*Request;

    extern fn Request__create(globalObject: *JSC.JSGlobalObject, ptr: ?*Request) JSC.JSValue;

    extern fn Request__dangerouslySetPtr(JSC.JSValue, ?*Request) bool;

    comptime {
        
        if (@TypeOf(Request.constructor) != (fn(*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*Request)) {
           @compileLog("Request.constructor is not a constructor");
        }
      
        if (@TypeOf(Request.finalize) != (fn(*Request) callconv(.C) void)) {
           @compileLog("Request.finalize is not a finalizer");
        }
      
          if (@TypeOf(Request.getArrayBuffer) != CallbackType) 
            @compileLog(
              "Expected Request.getArrayBuffer to be a callback"
            );
          if (@TypeOf(Request.getBlob) != CallbackType) 
            @compileLog(
              "Expected Request.getBlob to be a callback"
            );
          if (@TypeOf(Request.getBodyUsed) != GetterType) 
            @compileLog(
              "Expected Request.getBodyUsed to be a getter"
            );

          if (@TypeOf(Request.getCache) != GetterType) 
            @compileLog(
              "Expected Request.getCache to be a getter"
            );

          if (@TypeOf(Request.doClone) != CallbackType) 
            @compileLog(
              "Expected Request.doClone to be a callback"
            );
          if (@TypeOf(Request.getCredentials) != GetterType) 
            @compileLog(
              "Expected Request.getCredentials to be a getter"
            );

          if (@TypeOf(Request.getDestination) != GetterType) 
            @compileLog(
              "Expected Request.getDestination to be a getter"
            );

          if (@TypeOf(Request.getHeaders) != GetterType) 
            @compileLog(
              "Expected Request.getHeaders to be a getter"
            );

          if (@TypeOf(Request.getIntegrity) != GetterType) 
            @compileLog(
              "Expected Request.getIntegrity to be a getter"
            );

          if (@TypeOf(Request.getJSON) != CallbackType) 
            @compileLog(
              "Expected Request.getJSON to be a callback"
            );
          if (@TypeOf(Request.getMethod) != GetterType) 
            @compileLog(
              "Expected Request.getMethod to be a getter"
            );

          if (@TypeOf(Request.getMode) != GetterType) 
            @compileLog(
              "Expected Request.getMode to be a getter"
            );

          if (@TypeOf(Request.getRedirect) != GetterType) 
            @compileLog(
              "Expected Request.getRedirect to be a getter"
            );

          if (@TypeOf(Request.getReferrer) != GetterType) 
            @compileLog(
              "Expected Request.getReferrer to be a getter"
            );

          if (@TypeOf(Request.getReferrerPolicy) != GetterType) 
            @compileLog(
              "Expected Request.getReferrerPolicy to be a getter"
            );

          if (@TypeOf(Request.getText) != CallbackType) 
            @compileLog(
              "Expected Request.getText to be a callback"
            );
          if (@TypeOf(Request.getUrl) != GetterType) 
            @compileLog(
              "Expected Request.getUrl to be a getter"
            );

        if (!JSC.is_bindgen) {
@export(Request.constructor, .{.name = "RequestClass__construct"});
          @export(Request.doClone, .{.name = "RequestPrototype__doClone"});
          @export(Request.finalize, .{.name = "RequestClass__finalize"});
          @export(Request.getArrayBuffer, .{.name = "RequestPrototype__getArrayBuffer"});
          @export(Request.getBlob, .{.name = "RequestPrototype__getBlob"});
          @export(Request.getBodyUsed, .{.name = "RequestPrototype__getBodyUsed"});
          @export(Request.getCache, .{.name = "RequestPrototype__getCache"});
          @export(Request.getCredentials, .{.name = "RequestPrototype__getCredentials"});
          @export(Request.getDestination, .{.name = "RequestPrototype__getDestination"});
          @export(Request.getHeaders, .{.name = "RequestPrototype__getHeaders"});
          @export(Request.getIntegrity, .{.name = "RequestPrototype__getIntegrity"});
          @export(Request.getJSON, .{.name = "RequestPrototype__getJSON"});
          @export(Request.getMethod, .{.name = "RequestPrototype__getMethod"});
          @export(Request.getMode, .{.name = "RequestPrototype__getMode"});
          @export(Request.getRedirect, .{.name = "RequestPrototype__getRedirect"});
          @export(Request.getReferrer, .{.name = "RequestPrototype__getReferrer"});
          @export(Request.getReferrerPolicy, .{.name = "RequestPrototype__getReferrerPolicy"});
          @export(Request.getText, .{.name = "RequestPrototype__getText"});
          @export(Request.getUrl, .{.name = "RequestPrototype__getUrl"});
        }
    }
};
pub const JSResponse = struct {
    const Response = Classes.Response;
    const GetterType = fn(*Response, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
    const SetterType = fn(*Response, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
    const CallbackType = fn(*Response, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;

    /// Return the pointer to the wrapped object.
    /// If the object does not match the type, return null.
    pub fn fromJS(value: JSC.JSValue) ?*Response {
        JSC.markBinding();
        return Response__fromJS(value);
    }

    /// Create a new instance of Response
    pub fn toJS(this: *Response, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
        JSC.markBinding();
        if (comptime Environment.allow_assert) {
            const value__ = Response__create(globalObject, this);
            std.debug.assert(value__.as(Response).? == this); // If this fails, likely a C ABI issue.
            return value__;
        } else {
            return Response__create(globalObject, this);
        }
    }

    /// Modify the internal ptr to point to a new instance of Response.
    pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*Response) bool {
      JSC.markBinding();
      return Response__dangerouslySetPtr(value, ptr);
    }

    extern fn Response__fromJS(JSC.JSValue) ?*Response;

    extern fn Response__create(globalObject: *JSC.JSGlobalObject, ptr: ?*Response) JSC.JSValue;

    extern fn Response__dangerouslySetPtr(JSC.JSValue, ?*Response) bool;

    comptime {
        
        if (@TypeOf(Response.constructor) != (fn(*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*Response)) {
           @compileLog("Response.constructor is not a constructor");
        }
      
        if (@TypeOf(Response.finalize) != (fn(*Response) callconv(.C) void)) {
           @compileLog("Response.finalize is not a finalizer");
        }
      
          if (@TypeOf(Response.getArrayBuffer) != CallbackType) 
            @compileLog(
              "Expected Response.getArrayBuffer to be a callback"
            );
          if (@TypeOf(Response.getBlob) != CallbackType) 
            @compileLog(
              "Expected Response.getBlob to be a callback"
            );
          if (@TypeOf(Response.getBodyUsed) != GetterType) 
            @compileLog(
              "Expected Response.getBodyUsed to be a getter"
            );

          if (@TypeOf(Response.doClone) != CallbackType) 
            @compileLog(
              "Expected Response.doClone to be a callback"
            );
          if (@TypeOf(Response.getHeaders) != GetterType) 
            @compileLog(
              "Expected Response.getHeaders to be a getter"
            );

          if (@TypeOf(Response.getJSON) != CallbackType) 
            @compileLog(
              "Expected Response.getJSON to be a callback"
            );
          if (@TypeOf(Response.getOK) != GetterType) 
            @compileLog(
              "Expected Response.getOK to be a getter"
            );

          if (@TypeOf(Response.getStatus) != GetterType) 
            @compileLog(
              "Expected Response.getStatus to be a getter"
            );

          if (@TypeOf(Response.getStatusText) != GetterType) 
            @compileLog(
              "Expected Response.getStatusText to be a getter"
            );

          if (@TypeOf(Response.getText) != CallbackType) 
            @compileLog(
              "Expected Response.getText to be a callback"
            );
          if (@TypeOf(Response.getResponseType) != GetterType) 
            @compileLog(
              "Expected Response.getResponseType to be a getter"
            );

          if (@TypeOf(Response.getURL) != GetterType) 
            @compileLog(
              "Expected Response.getURL to be a getter"
            );

          if (@TypeOf(Response.constructError) != StaticCallbackType) 
            @compileLog(
              "Expected Response.constructError to be a static callback"
            );
          if (@TypeOf(Response.constructJSON) != StaticCallbackType) 
            @compileLog(
              "Expected Response.constructJSON to be a static callback"
            );
          if (@TypeOf(Response.constructRedirect) != StaticCallbackType) 
            @compileLog(
              "Expected Response.constructRedirect to be a static callback"
            );
        if (!JSC.is_bindgen) {
@export(Response.constructError, .{.name = "ResponseClass__constructError"});
          @export(Response.constructJSON, .{.name = "ResponseClass__constructJSON"});
          @export(Response.constructor, .{.name = "ResponseClass__construct"});
          @export(Response.constructRedirect, .{.name = "ResponseClass__constructRedirect"});
          @export(Response.doClone, .{.name = "ResponsePrototype__doClone"});
          @export(Response.finalize, .{.name = "ResponseClass__finalize"});
          @export(Response.getArrayBuffer, .{.name = "ResponsePrototype__getArrayBuffer"});
          @export(Response.getBlob, .{.name = "ResponsePrototype__getBlob"});
          @export(Response.getBodyUsed, .{.name = "ResponsePrototype__getBodyUsed"});
          @export(Response.getHeaders, .{.name = "ResponsePrototype__getHeaders"});
          @export(Response.getJSON, .{.name = "ResponsePrototype__getJSON"});
          @export(Response.getOK, .{.name = "ResponsePrototype__getOK"});
          @export(Response.getResponseType, .{.name = "ResponsePrototype__getResponseType"});
          @export(Response.getStatus, .{.name = "ResponsePrototype__getStatus"});
          @export(Response.getStatusText, .{.name = "ResponsePrototype__getStatusText"});
          @export(Response.getText, .{.name = "ResponsePrototype__getText"});
          @export(Response.getURL, .{.name = "ResponsePrototype__getURL"});
        }
    }
};