aboutsummaryrefslogtreecommitdiff
path: root/src/javascript/jsc/bindings
diff options
context:
space:
mode:
Diffstat (limited to 'src/javascript/jsc/bindings')
-rw-r--r--src/javascript/jsc/bindings/bindings.cpp58
-rw-r--r--src/javascript/jsc/bindings/bindings.zig35
-rw-r--r--src/javascript/jsc/bindings/headers-cpp.h10
-rw-r--r--src/javascript/jsc/bindings/headers.h11
-rw-r--r--src/javascript/jsc/bindings/headers.zig6
-rw-r--r--src/javascript/jsc/bindings/webcore/FetchHeaders.h2
6 files changed, 60 insertions, 62 deletions
diff --git a/src/javascript/jsc/bindings/bindings.cpp b/src/javascript/jsc/bindings/bindings.cpp
index 9bb5b33f3..c3684e2bd 100644
--- a/src/javascript/jsc/bindings/bindings.cpp
+++ b/src/javascript/jsc/bindings/bindings.cpp
@@ -110,6 +110,11 @@ void WebCore__FetchHeaders__toUWSResponse(WebCore__FetchHeaders* arg0, bool is_s
}
}
+WebCore__FetchHeaders* WebCore__FetchHeaders__createEmpty()
+{
+ RefPtr<WebCore::FetchHeaders> headers = adoptRef(*new WebCore::FetchHeaders({ WebCore::FetchHeaders::Guard::None, {} }));
+ return headers.leakRef();
+}
void WebCore__FetchHeaders__append(WebCore__FetchHeaders* headers, const ZigString* arg1, const ZigString* arg2)
{
headers->append(Zig::toString(*arg1), Zig::toString(*arg2));
@@ -128,9 +133,10 @@ WebCore__FetchHeaders* WebCore__FetchHeaders__createFromJS(JSC__JSGlobalObject*
auto throwScope = DECLARE_THROW_SCOPE(lexicalGlobalObject->vm());
auto init = argument0.value().isUndefined() ? std::optional<Converter<IDLUnion<IDLSequence<IDLSequence<IDLByteString>>, IDLRecord<IDLByteString, IDLByteString>>>::ReturnType>() : std::optional<Converter<IDLUnion<IDLSequence<IDLSequence<IDLByteString>>, IDLRecord<IDLByteString, IDLByteString>>>::ReturnType>(convert<IDLUnion<IDLSequence<IDLSequence<IDLByteString>>, IDLRecord<IDLByteString, IDLByteString>>>(*lexicalGlobalObject, argument0.value()));
RETURN_IF_EXCEPTION(throwScope, nullptr);
- return WebCoreCast<WebCore::JSFetchHeaders, WebCore__FetchHeaders>(
- JSC::JSValue::encode(WebCore::toJSNewlyCreated(lexicalGlobalObject, globalObject, WebCore::FetchHeaders::create(WTFMove(init)).releaseReturnValue())),
- &lexicalGlobalObject->vm());
+ RefPtr<WebCore::FetchHeaders> headers = adoptRef(*new WebCore::FetchHeaders({ WebCore::FetchHeaders::Guard::None, {} }));
+ if (init)
+ headers->fill(WTFMove(init.value()));
+ return headers.leakRef();
}
JSC__JSValue WebCore__FetchHeaders__toJS(WebCore__FetchHeaders* headers, JSC__JSGlobalObject* lexicalGlobalObject)
@@ -143,24 +149,19 @@ JSC__JSValue WebCore__FetchHeaders__clone(WebCore__FetchHeaders* headers, JSC__J
{
Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(arg1);
auto clone = WebCore::FetchHeaders::create();
- if (headers->size() > 0) {
- auto iter = headers->createIterator();
- uint32_t i = 0;
- unsigned count = 0;
- for (auto pair = iter.next(); pair; pair = iter.next()) {
- auto name = pair->key;
- auto value = pair->value;
- clone->append(name.isolatedCopy(), value.isolatedCopy());
- }
- }
+ clone->fill(*headers);
return JSC::JSValue::encode(WebCore::toJSNewlyCreated(arg1, globalObject, WTFMove(clone)));
}
-// WebCore__FetchHeaders* WebCore__FetchHeaders__cloneThis(WebCore__FetchHeaders* headers)
-// {
+WebCore__FetchHeaders* WebCore__FetchHeaders__cloneThis(WebCore__FetchHeaders* headers)
+{
+ RefPtr<WebCore::FetchHeaders> clone = adoptRef(*new WebCore::FetchHeaders({ WebCore::FetchHeaders::Guard::None, {} }));
+ if (headers->size() > 0) {
+ clone->fill(*headers);
+ }
-// return JSC::JSValue::encode(WebCore::toJSNewlyCreated(globalObject, globalObject, WebCore::FetchHeaders::create(*headers)));
-// }
+ return clone.leakRef();
+}
void WebCore__FetchHeaders__copyTo(WebCore__FetchHeaders* headers, StringPointer* names, StringPointer* values, unsigned char* buf)
{
@@ -201,7 +202,7 @@ typedef struct PicoHTTPHeaders {
const PicoHTTPHeader* ptr;
size_t len;
} PicoHTTPHeaders;
-JSC__JSValue WebCore__FetchHeaders__createFromPicoHeaders_(JSC__JSGlobalObject* arg0, const void* arg1)
+WebCore::FetchHeaders* WebCore__FetchHeaders__createFromPicoHeaders_(JSC__JSGlobalObject* arg0, const void* arg1)
{
PicoHTTPHeaders pico_headers = *reinterpret_cast<const PicoHTTPHeaders*>(arg1);
Vector<KeyValuePair<String, String>> pairs;
@@ -212,12 +213,12 @@ JSC__JSValue WebCore__FetchHeaders__createFromPicoHeaders_(JSC__JSGlobalObject*
pairs.uncheckedAppend(KeyValuePair<String, String>(name, value));
}
- Ref<WebCore::FetchHeaders> headers = WebCore::FetchHeaders::create();
- headers->fill(WebCore::FetchHeaders::Init(pairs));
+ RefPtr<WebCore::FetchHeaders> headers = adoptRef(*new WebCore::FetchHeaders({ WebCore::FetchHeaders::Guard::None, {} }));
+ headers->fill(WebCore::FetchHeaders::Init(WTFMove(pairs)));
pairs.releaseBuffer();
- return JSC::JSValue::encode(WebCore::toJSNewlyCreated(arg0, reinterpret_cast<Zig::GlobalObject*>(arg0), WTFMove(headers)));
+ return headers.leakRef();
}
-JSC__JSValue WebCore__FetchHeaders__createFromUWS(JSC__JSGlobalObject* arg0, void* arg1)
+WebCore::FetchHeaders* WebCore__FetchHeaders__createFromUWS(JSC__JSGlobalObject* arg0, void* arg1)
{
uWS::HttpRequest req = *reinterpret_cast<uWS::HttpRequest*>(arg1);
Vector<KeyValuePair<String, String>> pairs;
@@ -228,14 +229,15 @@ JSC__JSValue WebCore__FetchHeaders__createFromUWS(JSC__JSGlobalObject* arg0, voi
pairs.uncheckedAppend(KeyValuePair<String, String>(name, value));
}
- Ref<WebCore::FetchHeaders> headers = WebCore::FetchHeaders::create();
- headers->fill(WebCore::FetchHeaders::Init(pairs));
+ RefPtr<WebCore::FetchHeaders> headers = adoptRef(*new WebCore::FetchHeaders({ WebCore::FetchHeaders::Guard::None, {} }));
+ headers->fill(WebCore::FetchHeaders::Init(WTFMove(pairs)));
pairs.releaseBuffer();
- return JSC::JSValue::encode(WebCore::toJS(arg0, reinterpret_cast<Zig::GlobalObject*>(arg0), headers));
+ return headers.leakRef();
}
void WebCore__FetchHeaders__deref(WebCore__FetchHeaders* arg0)
{
- arg0->deref();
+ RefPtr<WebCore::FetchHeaders> clone = arg0;
+ clone->deref();
}
JSC__JSValue WebCore__FetchHeaders__createValue(JSC__JSGlobalObject* arg0, StringPointer* arg1, StringPointer* arg2, const ZigString* arg3, uint32_t count)
@@ -250,9 +252,9 @@ JSC__JSValue WebCore__FetchHeaders__createValue(JSC__JSGlobalObject* arg0, Strin
}
Ref<WebCore::FetchHeaders> headers = WebCore::FetchHeaders::create();
- headers->fill(WebCore::FetchHeaders::Init(pairs));
+ headers->fill(WebCore::FetchHeaders::Init(WTFMove(pairs)));
pairs.releaseBuffer();
- return JSC::JSValue::encode(WebCore::toJS(arg0, reinterpret_cast<Zig::GlobalObject*>(arg0), headers));
+ return JSC::JSValue::encode(WebCore::toJSNewlyCreated(arg0, reinterpret_cast<Zig::GlobalObject*>(arg0), WTFMove(headers)));
}
void WebCore__FetchHeaders__get_(WebCore__FetchHeaders* headers, const ZigString* arg1, ZigString* arg2)
{
diff --git a/src/javascript/jsc/bindings/bindings.zig b/src/javascript/jsc/bindings/bindings.zig
index 0f8d5de00..8d916af11 100644
--- a/src/javascript/jsc/bindings/bindings.zig
+++ b/src/javascript/jsc/bindings/bindings.zig
@@ -435,8 +435,11 @@ const Api = @import("../../../api/schema.zig").Api;
pub const FetchHeaders = opaque {
pub const shim = Shimmer("WebCore", "FetchHeaders", @This());
- const cppFn = shim.cppFn;
pub const name = "WebCore::FetchHeaders";
+ pub const include = "FetchHeaders.h";
+ pub const namespace = "WebCore";
+
+ const cppFn = shim.cppFn;
pub fn createValue(
global: *JSGlobalObject,
@@ -491,7 +494,7 @@ pub const FetchHeaders = opaque {
pub fn createFromUWS(
global: *JSGlobalObject,
uws_request: *anyopaque,
- ) JSValue {
+ ) *FetchHeaders {
return shim.cppFn("createFromUWS", .{
global,
uws_request,
@@ -515,20 +518,14 @@ pub const FetchHeaders = opaque {
len: usize,
};
- pub fn createEmpty(
- global: *JSGlobalObject,
- ) JSValue {
- const pico_ = PicoHeaders{ .ptr = undefined, .len = 0 };
- return shim.cppFn("createFromPicoHeaders_", .{
- global,
- &pico_,
- });
+ pub fn createEmpty() *FetchHeaders {
+ return shim.cppFn("createEmpty", .{});
}
pub fn createFromPicoHeaders(
global: *JSGlobalObject,
pico_headers: anytype,
- ) JSValue {
+ ) *FetchHeaders {
const out = PicoHeaders{ .ptr = pico_headers.ptr, .len = pico_headers.len };
const result = shim.cppFn("createFromPicoHeaders_", .{
global,
@@ -540,7 +537,7 @@ pub const FetchHeaders = opaque {
pub fn createFromPicoHeaders_(
global: *JSGlobalObject,
pico_headers: *const anyopaque,
- ) JSValue {
+ ) *FetchHeaders {
return shim.cppFn("createFromPicoHeaders_", .{
global,
pico_headers,
@@ -696,6 +693,7 @@ pub const FetchHeaders = opaque {
"copyTo",
"count",
"createFromJS",
+ "createEmpty",
"createFromPicoHeaders_",
"createFromUWS",
"createValue",
@@ -1990,10 +1988,6 @@ pub const String = extern struct {
};
};
-pub const BuiltinName = enum(u8) {
- headers,
-};
-
pub const JSValue = enum(u64) {
_,
@@ -2586,10 +2580,6 @@ pub const JSValue = enum(u64) {
return cppFn("getIfPropertyExistsImpl", .{ this, global, ptr, len });
}
- pub fn getHiddenIfPropertyExistsImpl(this: JSValue, global: *JSGlobalObject, ptr: [*]const u8, len: u32) JSValue {
- return cppFn("getHiddenIfPropertyExistsImpl", .{ this, global, ptr, len });
- }
-
pub fn getSymbolDescription(this: JSValue, global: *JSGlobalObject, str: *ZigString) void {
cppFn("getSymbolDescription", .{ this, global, str });
}
@@ -2655,11 +2645,6 @@ pub const JSValue = enum(u64) {
return if (@enumToInt(value) != 0) value else return null;
}
- pub fn getHidden(this: JSValue, global: *JSGlobalObject, property: []const u8) ?JSValue {
- const value = getIfPropertyExistsImpl(this, global, property.ptr, @intCast(u32, property.len));
- return if (@enumToInt(value) != 0) value else return null;
- }
-
pub fn getTruthy(this: JSValue, global: *JSGlobalObject, property: []const u8) ?JSValue {
if (get(this, global, property)) |prop| {
if (@enumToInt(prop) == 0 or prop.isUndefinedOrNull()) return null;
diff --git a/src/javascript/jsc/bindings/headers-cpp.h b/src/javascript/jsc/bindings/headers-cpp.h
index 9d0ce2113..fa70542cd 100644
--- a/src/javascript/jsc/bindings/headers-cpp.h
+++ b/src/javascript/jsc/bindings/headers-cpp.h
@@ -1,4 +1,4 @@
-//-- AUTOGENERATED FILE -- 1648790662
+//-- AUTOGENERATED FILE -- 1648857986
// clang-format off
#pragma once
@@ -16,6 +16,14 @@
extern "C" const size_t JSC__JSObject_object_size_ = sizeof(JSC::JSObject);
extern "C" const size_t JSC__JSObject_object_align_ = alignof(JSC::JSObject);
+#ifndef INCLUDED_FetchHeaders_h
+#define INCLUDED_FetchHeaders_h
+#include FetchHeaders.h
+#endif
+
+extern "C" const size_t WebCore__FetchHeaders_object_size_ = sizeof(WebCore::FetchHeaders);
+extern "C" const size_t WebCore__FetchHeaders_object_align_ = alignof(WebCore::FetchHeaders);
+
#ifndef INCLUDED_JavaScriptCore_JSCell_h
#define INCLUDED_JavaScriptCore_JSCell_h
#include JavaScriptCore/JSCell.h
diff --git a/src/javascript/jsc/bindings/headers.h b/src/javascript/jsc/bindings/headers.h
index 9175274cb..a3a12d138 100644
--- a/src/javascript/jsc/bindings/headers.h
+++ b/src/javascript/jsc/bindings/headers.h
@@ -1,5 +1,5 @@
// clang-format: off
-//-- AUTOGENERATED FILE -- 1648790662
+//-- AUTOGENERATED FILE -- 1648857986
#pragma once
#include <stddef.h>
@@ -312,20 +312,23 @@ CPP_DECL JSC__JSValue ZigString__toValueGC(const ZigString* arg0, JSC__JSGlobalO
CPP_DECL WebCore__DOMURL* WebCore__DOMURL__cast_(JSC__JSValue JSValue0, JSC__VM* arg1);
CPP_DECL void WebCore__DOMURL__href_(WebCore__DOMURL* arg0, ZigString* arg1);
CPP_DECL void WebCore__DOMURL__pathname_(WebCore__DOMURL* arg0, ZigString* arg1);
+
+#pragma mark - WebCore::FetchHeaders
+
CPP_DECL void WebCore__FetchHeaders__append(WebCore__FetchHeaders* arg0, const ZigString* arg1, const ZigString* arg2);
CPP_DECL WebCore__FetchHeaders* WebCore__FetchHeaders__cast_(JSC__JSValue JSValue0, JSC__VM* arg1);
CPP_DECL JSC__JSValue WebCore__FetchHeaders__clone(WebCore__FetchHeaders* arg0, JSC__JSGlobalObject* arg1);
CPP_DECL WebCore__FetchHeaders* WebCore__FetchHeaders__cloneThis(WebCore__FetchHeaders* arg0);
CPP_DECL void WebCore__FetchHeaders__copyTo(WebCore__FetchHeaders* arg0, StringPointer* arg1, StringPointer* arg2, unsigned char* arg3);
CPP_DECL void WebCore__FetchHeaders__count(WebCore__FetchHeaders* arg0, uint32_t* arg1, uint32_t* arg2);
+CPP_DECL WebCore__FetchHeaders* WebCore__FetchHeaders__createEmpty();
CPP_DECL WebCore__FetchHeaders* WebCore__FetchHeaders__createFromJS(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1);
-CPP_DECL JSC__JSValue WebCore__FetchHeaders__createFromPicoHeaders_(JSC__JSGlobalObject* arg0, const void* arg1);
-CPP_DECL JSC__JSValue WebCore__FetchHeaders__createFromUWS(JSC__JSGlobalObject* arg0, void* arg1);
+CPP_DECL WebCore__FetchHeaders* WebCore__FetchHeaders__createFromPicoHeaders_(JSC__JSGlobalObject* arg0, const void* arg1);
+CPP_DECL WebCore__FetchHeaders* WebCore__FetchHeaders__createFromUWS(JSC__JSGlobalObject* arg0, void* arg1);
CPP_DECL JSC__JSValue WebCore__FetchHeaders__createValue(JSC__JSGlobalObject* arg0, StringPointer* arg1, StringPointer* arg2, const ZigString* arg3, uint32_t arg4);
CPP_DECL void WebCore__FetchHeaders__deref(WebCore__FetchHeaders* arg0);
CPP_DECL void WebCore__FetchHeaders__get_(WebCore__FetchHeaders* arg0, const ZigString* arg1, ZigString* arg2);
CPP_DECL bool WebCore__FetchHeaders__has(WebCore__FetchHeaders* arg0, const ZigString* arg1);
-CPP_DECL uint32_t WebCore__FetchHeaders__keyCount(WebCore__FetchHeaders* arg0);
CPP_DECL void WebCore__FetchHeaders__put_(WebCore__FetchHeaders* arg0, const ZigString* arg1, const ZigString* arg2);
CPP_DECL void WebCore__FetchHeaders__remove(WebCore__FetchHeaders* arg0, const ZigString* arg1);
CPP_DECL JSC__JSValue WebCore__FetchHeaders__toJS(WebCore__FetchHeaders* arg0, JSC__JSGlobalObject* arg1);
diff --git a/src/javascript/jsc/bindings/headers.zig b/src/javascript/jsc/bindings/headers.zig
index 2eb6ad46f..6fd6b644b 100644
--- a/src/javascript/jsc/bindings/headers.zig
+++ b/src/javascript/jsc/bindings/headers.zig
@@ -160,14 +160,14 @@ pub extern fn WebCore__FetchHeaders__clone(arg0: ?*WebCore__FetchHeaders, arg1:
pub extern fn WebCore__FetchHeaders__cloneThis(arg0: ?*WebCore__FetchHeaders) ?*WebCore__FetchHeaders;
pub extern fn WebCore__FetchHeaders__copyTo(arg0: ?*WebCore__FetchHeaders, arg1: [*c]StringPointer, arg2: [*c]StringPointer, arg3: [*c]u8) void;
pub extern fn WebCore__FetchHeaders__count(arg0: ?*WebCore__FetchHeaders, arg1: [*c]u32, arg2: [*c]u32) void;
+pub extern fn WebCore__FetchHeaders__createEmpty(...) ?*WebCore__FetchHeaders;
pub extern fn WebCore__FetchHeaders__createFromJS(arg0: [*c]JSC__JSGlobalObject, JSValue1: JSC__JSValue) ?*WebCore__FetchHeaders;
-pub extern fn WebCore__FetchHeaders__createFromPicoHeaders_(arg0: [*c]JSC__JSGlobalObject, arg1: ?*const anyopaque) JSC__JSValue;
-pub extern fn WebCore__FetchHeaders__createFromUWS(arg0: [*c]JSC__JSGlobalObject, arg1: ?*anyopaque) JSC__JSValue;
+pub extern fn WebCore__FetchHeaders__createFromPicoHeaders_(arg0: [*c]JSC__JSGlobalObject, arg1: ?*const anyopaque) ?*WebCore__FetchHeaders;
+pub extern fn WebCore__FetchHeaders__createFromUWS(arg0: [*c]JSC__JSGlobalObject, arg1: ?*anyopaque) ?*WebCore__FetchHeaders;
pub extern fn WebCore__FetchHeaders__createValue(arg0: [*c]JSC__JSGlobalObject, arg1: [*c]StringPointer, arg2: [*c]StringPointer, arg3: [*c]const ZigString, arg4: u32) JSC__JSValue;
pub extern fn WebCore__FetchHeaders__deref(arg0: ?*WebCore__FetchHeaders) void;
pub extern fn WebCore__FetchHeaders__get_(arg0: ?*WebCore__FetchHeaders, arg1: [*c]const ZigString, arg2: [*c]ZigString) void;
pub extern fn WebCore__FetchHeaders__has(arg0: ?*WebCore__FetchHeaders, arg1: [*c]const ZigString) bool;
-pub extern fn WebCore__FetchHeaders__keyCount(arg0: ?*WebCore__FetchHeaders) u32;
pub extern fn WebCore__FetchHeaders__put_(arg0: ?*WebCore__FetchHeaders, arg1: [*c]const ZigString, arg2: [*c]const ZigString) void;
pub extern fn WebCore__FetchHeaders__remove(arg0: ?*WebCore__FetchHeaders, arg1: [*c]const ZigString) void;
pub extern fn WebCore__FetchHeaders__toJS(arg0: ?*WebCore__FetchHeaders, arg1: [*c]JSC__JSGlobalObject) JSC__JSValue;
diff --git a/src/javascript/jsc/bindings/webcore/FetchHeaders.h b/src/javascript/jsc/bindings/webcore/FetchHeaders.h
index c6a74880f..b116cf978 100644
--- a/src/javascript/jsc/bindings/webcore/FetchHeaders.h
+++ b/src/javascript/jsc/bindings/webcore/FetchHeaders.h
@@ -89,10 +89,10 @@ public:
void setGuard(Guard);
Guard guard() const { return m_guard; }
-private:
FetchHeaders(Guard, HTTPHeaderMap&&);
explicit FetchHeaders(const FetchHeaders&);
+private:
Guard m_guard;
HTTPHeaderMap m_headers;
};