mirror of
https://github.com/oven-sh/bun
synced 2026-02-03 07:28:53 +00:00
Compare commits
37 Commits
fix-format
...
jarred/pos
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c2ebd014fb | ||
|
|
1a0974693b | ||
|
|
8e1eae7dae | ||
|
|
d92f3b6610 | ||
|
|
e523dd1fc0 | ||
|
|
7dbe01b822 | ||
|
|
c900d08bea | ||
|
|
ff7881f2ea | ||
|
|
d2899f1367 | ||
|
|
d1a7feef0a | ||
|
|
8f1606adf0 | ||
|
|
8d0ebfbc95 | ||
|
|
e2198b95ef | ||
|
|
0cb4e9919b | ||
|
|
84336eef30 | ||
|
|
b7b773398a | ||
|
|
83c5461461 | ||
|
|
55fb29667a | ||
|
|
b8175ac13d | ||
|
|
9b6c84ef1e | ||
|
|
d26756e153 | ||
|
|
ab035d6e82 | ||
|
|
ad7e90ae1b | ||
|
|
c508640e2c | ||
|
|
0a149bdbbb | ||
|
|
93a7c97e94 | ||
|
|
ae881b14e9 | ||
|
|
802a6731d5 | ||
|
|
7f5eddc096 | ||
|
|
9bc76f6628 | ||
|
|
0a6ef179f8 | ||
|
|
71ddfcf7c1 | ||
|
|
3809d8f5a0 | ||
|
|
d1855492de | ||
|
|
40579bb3af | ||
|
|
847fc70a42 | ||
|
|
de0ff15ef4 |
199
src/bun.js/Weak.zig
Normal file
199
src/bun.js/Weak.zig
Normal file
@@ -0,0 +1,199 @@
|
||||
const bun = @import("root").bun;
|
||||
const JSC = bun.JSC;
|
||||
const std = @import("std");
|
||||
|
||||
/// This value must be kept in sync with Weak.cpp
|
||||
pub const WeakRefFinalizerTag = *const fn (*anyopaque) callconv(.C) void;
|
||||
|
||||
const WeakImpl = opaque {
|
||||
pub fn init(ptr: *anyopaque, comptime tag: ?WeakRefFinalizerTag, value: JSC.JSValue) *WeakImpl {
|
||||
JSC.markBinding(@src());
|
||||
return Bun__WeakRef__new(value, tag, ptr);
|
||||
}
|
||||
|
||||
pub fn get(this: *WeakImpl) JSC.JSValue {
|
||||
JSC.markBinding(@src());
|
||||
return Bun__WeakRef__get(this);
|
||||
}
|
||||
|
||||
pub fn set(this: *WeakImpl, ptr: *anyopaque, comptime tag: ?WeakRefFinalizerTag, value: JSC.JSValue) void {
|
||||
JSC.markBinding(@src());
|
||||
Bun__WeakRef__set(this, value, tag, ptr);
|
||||
}
|
||||
|
||||
pub fn clear(this: *WeakImpl) void {
|
||||
JSC.markBinding(@src());
|
||||
Bun__WeakRef__clear(this);
|
||||
}
|
||||
|
||||
pub fn deinit(
|
||||
this: *WeakImpl,
|
||||
) void {
|
||||
JSC.markBinding(@src());
|
||||
Bun__WeakRef__delete(this);
|
||||
}
|
||||
|
||||
extern fn Bun__WeakRef__delete(this: *WeakImpl) void;
|
||||
extern fn Bun__WeakRef__new(JSC.JSValue, ?WeakRefFinalizerTag, *anyopaque) *WeakImpl;
|
||||
extern fn Bun__WeakRef__get(this: *WeakImpl) JSC.JSValue;
|
||||
extern fn Bun__WeakRef__set(this: *WeakImpl, JSC.JSValue, ?WeakRefFinalizerTag, *anyopaque) void;
|
||||
extern fn Bun__WeakRef__clear(this: *WeakImpl) void;
|
||||
};
|
||||
|
||||
pub fn NewWeakFinalizer(comptime Context: type, comptime FinalizerFn: *const fn (*Context) callconv(.C) void) type {
|
||||
return struct {
|
||||
ref: ?*WeakImpl = null,
|
||||
|
||||
const finalizer: WeakRefFinalizerTag = @ptrCast(FinalizerFn);
|
||||
|
||||
pub const WeakFinalizer = @This();
|
||||
|
||||
pub fn init() WeakFinalizer {
|
||||
return .{};
|
||||
}
|
||||
|
||||
pub fn create(
|
||||
ptr: *Context,
|
||||
value: JSC.JSValue,
|
||||
) WeakFinalizer {
|
||||
if (value != .zero) {
|
||||
return .{ .ref = WeakImpl.init(
|
||||
ptr,
|
||||
finalizer,
|
||||
value,
|
||||
) };
|
||||
}
|
||||
|
||||
return .{};
|
||||
}
|
||||
|
||||
pub fn get(this: *WeakFinalizer) ?JSC.JSValue {
|
||||
var ref = this.ref orelse return null;
|
||||
const result = ref.get();
|
||||
if (result == .zero) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
pub fn swap(this: *WeakFinalizer) JSC.JSValue {
|
||||
var ref = this.ref orelse return .zero;
|
||||
const result = ref.get();
|
||||
if (result == .zero) {
|
||||
return .zero;
|
||||
}
|
||||
|
||||
ref.clear();
|
||||
return result;
|
||||
}
|
||||
|
||||
pub fn has(this: *WeakFinalizer) bool {
|
||||
var ref = this.ref orelse return false;
|
||||
return ref.get() != .zero;
|
||||
}
|
||||
|
||||
pub fn trySwap(this: *WeakFinalizer) ?JSC.JSValue {
|
||||
const result = this.swap();
|
||||
if (result == .zero) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
pub fn set(this: *WeakFinalizer, ptr: *Context, value: JSC.JSValue) void {
|
||||
var ref: *WeakImpl = this.ref orelse {
|
||||
if (value == .zero) return;
|
||||
this.ref = WeakImpl.init(ptr, finalizer, value);
|
||||
return;
|
||||
};
|
||||
ref.set(ptr, finalizer, value);
|
||||
}
|
||||
|
||||
pub fn clear(this: *WeakFinalizer) void {
|
||||
var ref: *WeakImpl = this.ref orelse return;
|
||||
ref.clear();
|
||||
}
|
||||
|
||||
pub fn deinit(this: *WeakFinalizer) void {
|
||||
var ref: *WeakImpl = this.ref orelse return;
|
||||
this.ref = null;
|
||||
ref.deinit();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
pub const Weak = struct {
|
||||
ref: ?*WeakImpl = null,
|
||||
|
||||
pub fn init() Weak {
|
||||
return .{};
|
||||
}
|
||||
|
||||
pub fn create(
|
||||
ptr: *anyopaque,
|
||||
value: JSC.JSValue,
|
||||
) Weak {
|
||||
if (value != .zero) {
|
||||
return .{ .ref = WeakImpl.init(ptr, value, null) };
|
||||
}
|
||||
|
||||
return .{};
|
||||
}
|
||||
|
||||
pub fn get(this: *Weak) ?JSC.JSValue {
|
||||
var ref = this.ref orelse return null;
|
||||
const result = ref.get();
|
||||
if (result == .zero) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
pub fn swap(this: *Weak) JSC.JSValue {
|
||||
var ref = this.ref orelse return .zero;
|
||||
const result = ref.get();
|
||||
if (result == .zero) {
|
||||
return .zero;
|
||||
}
|
||||
|
||||
ref.clear();
|
||||
return result;
|
||||
}
|
||||
|
||||
pub fn has(this: *Weak) bool {
|
||||
var ref = this.ref orelse return false;
|
||||
return ref.get() != .zero;
|
||||
}
|
||||
|
||||
pub fn trySwap(this: *Weak) ?JSC.JSValue {
|
||||
const result = this.swap();
|
||||
if (result == .zero) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
pub fn set(this: *Weak, ptr: *anyopaque, value: JSC.JSValue) void {
|
||||
var ref: *WeakImpl = this.ref orelse {
|
||||
if (value == .zero) return;
|
||||
this.ref = WeakImpl.init(ptr, null, value);
|
||||
return;
|
||||
};
|
||||
ref.set(ptr, null, value);
|
||||
}
|
||||
|
||||
pub fn clear(this: *Weak) void {
|
||||
var ref: *WeakImpl = this.ref orelse return;
|
||||
ref.clear();
|
||||
}
|
||||
|
||||
pub fn deinit(this: *Weak) void {
|
||||
var ref: *WeakImpl = this.ref orelse return;
|
||||
this.ref = null;
|
||||
ref.deinit();
|
||||
}
|
||||
};
|
||||
Submodule src/bun.js/WebKit updated: 1a49a1f94b...acc1e092b4
65
src/bun.js/api/postgres.classes.ts
Normal file
65
src/bun.js/api/postgres.classes.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
import { define } from "../scripts/class-definitions";
|
||||
|
||||
export default [
|
||||
define({
|
||||
name: "PostgresSQLConnection",
|
||||
construct: true,
|
||||
finalize: true,
|
||||
hasPendingActivity: true,
|
||||
configurable: false,
|
||||
klass: {
|
||||
// escapeString: {
|
||||
// fn: "escapeString",
|
||||
// },
|
||||
// escapeIdentifier: {
|
||||
// fn: "escapeIdentifier",
|
||||
// },
|
||||
},
|
||||
JSType: "0b11101110",
|
||||
proto: {
|
||||
close: {
|
||||
fn: "doClose",
|
||||
},
|
||||
flush: {
|
||||
fn: "doFlush",
|
||||
},
|
||||
connected: {
|
||||
getter: "getConnected",
|
||||
},
|
||||
ref: {
|
||||
fn: "doRef",
|
||||
},
|
||||
unref: {
|
||||
fn: "doUnref",
|
||||
},
|
||||
query: {
|
||||
fn: "createQuery",
|
||||
},
|
||||
},
|
||||
}),
|
||||
define({
|
||||
name: "PostgresSQLQuery",
|
||||
construct: true,
|
||||
finalize: true,
|
||||
configurable: false,
|
||||
hasPendingActivity: true,
|
||||
JSType: "0b11101110",
|
||||
klass: {},
|
||||
proto: {
|
||||
run: {
|
||||
fn: "doRun",
|
||||
length: 2,
|
||||
},
|
||||
cancel: {
|
||||
fn: "doCancel",
|
||||
length: 0,
|
||||
},
|
||||
done: {
|
||||
fn: "doDone",
|
||||
length: 0,
|
||||
},
|
||||
},
|
||||
values: ["pendingValue", "binding"],
|
||||
estimatedSize: true,
|
||||
}),
|
||||
];
|
||||
@@ -33,6 +33,14 @@ extern "C" bool BunString__fromJS(JSC::JSGlobalObject* globalObject, JSC::Encode
|
||||
return bunString->tag != BunStringTag::Dead;
|
||||
}
|
||||
|
||||
extern "C" bool BunString__fromJSRef(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue encodedValue, BunString* bunString)
|
||||
{
|
||||
|
||||
JSC::JSValue value = JSC::JSValue::decode(encodedValue);
|
||||
*bunString = Bun::toStringRef(globalObject, value);
|
||||
return bunString->tag != BunStringTag::Dead;
|
||||
}
|
||||
|
||||
extern "C" BunString BunString__createAtom(const char* bytes, size_t length)
|
||||
{
|
||||
if (simdutf::validate_ascii(bytes, length)) {
|
||||
|
||||
94
src/bun.js/bindings/Weak.cpp
Normal file
94
src/bun.js/bindings/Weak.cpp
Normal file
@@ -0,0 +1,94 @@
|
||||
#include "root.h"
|
||||
#include "BunClientData.h"
|
||||
#include <JavaScriptCore/Weak.h>
|
||||
#include <JavaScriptCore/WeakInlines.h>
|
||||
|
||||
namespace Bun {
|
||||
using WeakRefFinalizerTag = uintptr_t;
|
||||
|
||||
template<void (*finalizer)(void*)>
|
||||
class WeakRefFinalizerClass : public JSC::WeakHandleOwner {
|
||||
public:
|
||||
WeakRefFinalizerClass()
|
||||
: JSC::WeakHandleOwner()
|
||||
{
|
||||
}
|
||||
|
||||
void finalize(JSC::Handle<JSC::Unknown>, void* context)
|
||||
{
|
||||
finalizer(context);
|
||||
}
|
||||
|
||||
static WeakHandleOwner& singleton()
|
||||
{
|
||||
static NeverDestroyed<WeakRefFinalizerClass<finalizer>> s_singleton;
|
||||
return s_singleton;
|
||||
}
|
||||
};
|
||||
|
||||
extern "C" void Bun__PostgreSQLQueryClient__target_onFinalize(void*);
|
||||
|
||||
using PostgreSQLQueryClient__targetWeakRefFinalizer = WeakRefFinalizerClass<Bun__PostgreSQLQueryClient__target_onFinalize>;
|
||||
|
||||
static inline JSC::WeakHandleOwner* getOwner(WeakRefFinalizerTag tag)
|
||||
{
|
||||
if (tag == reinterpret_cast<uintptr_t>(Bun__PostgreSQLQueryClient__target_onFinalize))
|
||||
return &PostgreSQLQueryClient__targetWeakRefFinalizer::singleton();
|
||||
|
||||
if (tag == 0)
|
||||
return nullptr;
|
||||
|
||||
RELEASE_ASSERT_NOT_REACHED_WITH_MESSAGE("Unknown WeakRefFinalizerTag");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
class WeakRef {
|
||||
WTF_MAKE_ISO_ALLOCATED(WeakRef);
|
||||
|
||||
public:
|
||||
WeakRef()
|
||||
: m_weak()
|
||||
{
|
||||
}
|
||||
|
||||
static inline WeakRef* create(JSC::JSObject* value, WeakRefFinalizerTag tag, void* context)
|
||||
{
|
||||
return new WeakRef(value, tag, context);
|
||||
}
|
||||
|
||||
WeakRef(JSC::JSObject* value, WeakRefFinalizerTag tag, void* context)
|
||||
{
|
||||
m_weak = JSC::Weak<JSC::JSObject>(value, getOwner(tag), context);
|
||||
}
|
||||
|
||||
JSC::Weak<JSC::JSObject> m_weak;
|
||||
};
|
||||
|
||||
WTF_MAKE_ISO_ALLOCATED_IMPL(WeakRef);
|
||||
|
||||
extern "C" void Bun__WeakRef__delete(Bun::WeakRef* ref)
|
||||
{
|
||||
delete ref;
|
||||
}
|
||||
|
||||
extern "C" Bun::WeakRef* Bun__WeakRef__new(JSC::EncodedJSValue encodedValue, WeakRefFinalizerTag tag, void* context)
|
||||
{
|
||||
return Bun::WeakRef::create(JSC::JSValue::decode(encodedValue).getObject(), tag, context);
|
||||
}
|
||||
|
||||
extern "C" JSC::EncodedJSValue Bun__WeakRef__get(Bun::WeakRef* weakRef)
|
||||
{
|
||||
return JSC::JSValue::encode(weakRef->m_weak.get());
|
||||
}
|
||||
|
||||
extern "C" void Bun__WeakRef__set(Bun::WeakRef* weakRef, JSC::EncodedJSValue encodedValue, WeakRefFinalizerTag tag, void* context)
|
||||
{
|
||||
weakRef->m_weak = JSC::Weak<JSC::JSObject>(JSC::JSValue::decode(encodedValue).getObject(), getOwner(tag), context);
|
||||
}
|
||||
|
||||
extern "C" void Bun__WeakRef__clear(Bun::WeakRef* weakRef)
|
||||
{
|
||||
weakRef->m_weak.clear();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30,7 +30,9 @@ std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForMD4;
|
||||
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForMD4Constructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForMD5;
|
||||
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForMD5Constructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForMatchedRoute;
|
||||
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForNodeJSFS;
|
||||
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForNodeJSFSConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForRequest;
|
||||
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForNodeJSFSConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForPostgresSQLConnection;
|
||||
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForPostgresSQLConnectionConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForPostgresSQLQuery;
|
||||
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForPostgresSQLQueryConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForRequest;
|
||||
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForRequestConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForResolveMessage;
|
||||
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForResolveMessageConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForResponse;
|
||||
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForResponseConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForSHA1;
|
||||
|
||||
@@ -30,7 +30,9 @@ std::unique_ptr<IsoSubspace> m_subspaceForMD4;
|
||||
std::unique_ptr<IsoSubspace> m_subspaceForMD4Constructor;std::unique_ptr<IsoSubspace> m_subspaceForMD5;
|
||||
std::unique_ptr<IsoSubspace> m_subspaceForMD5Constructor;std::unique_ptr<IsoSubspace> m_subspaceForMatchedRoute;
|
||||
std::unique_ptr<IsoSubspace> m_subspaceForNodeJSFS;
|
||||
std::unique_ptr<IsoSubspace> m_subspaceForNodeJSFSConstructor;std::unique_ptr<IsoSubspace> m_subspaceForRequest;
|
||||
std::unique_ptr<IsoSubspace> m_subspaceForNodeJSFSConstructor;std::unique_ptr<IsoSubspace> m_subspaceForPostgresSQLConnection;
|
||||
std::unique_ptr<IsoSubspace> m_subspaceForPostgresSQLConnectionConstructor;std::unique_ptr<IsoSubspace> m_subspaceForPostgresSQLQuery;
|
||||
std::unique_ptr<IsoSubspace> m_subspaceForPostgresSQLQueryConstructor;std::unique_ptr<IsoSubspace> m_subspaceForRequest;
|
||||
std::unique_ptr<IsoSubspace> m_subspaceForRequestConstructor;std::unique_ptr<IsoSubspace> m_subspaceForResolveMessage;
|
||||
std::unique_ptr<IsoSubspace> m_subspaceForResolveMessageConstructor;std::unique_ptr<IsoSubspace> m_subspaceForResponse;
|
||||
std::unique_ptr<IsoSubspace> m_subspaceForResponseConstructor;std::unique_ptr<IsoSubspace> m_subspaceForSHA1;
|
||||
|
||||
@@ -126,6 +126,14 @@ JSC::Structure* JSNodeJSFSStructure() { return m_JSNodeJSFS.getInitializedOnMain
|
||||
JSC::JSObject* JSNodeJSFSConstructor() { return m_JSNodeJSFS.constructorInitializedOnMainThread(this); }
|
||||
JSC::JSValue JSNodeJSFSPrototype() { return m_JSNodeJSFS.prototypeInitializedOnMainThread(this); }
|
||||
JSC::LazyClassStructure m_JSNodeJSFS;
|
||||
JSC::Structure* JSPostgresSQLConnectionStructure() { return m_JSPostgresSQLConnection.getInitializedOnMainThread(this); }
|
||||
JSC::JSObject* JSPostgresSQLConnectionConstructor() { return m_JSPostgresSQLConnection.constructorInitializedOnMainThread(this); }
|
||||
JSC::JSValue JSPostgresSQLConnectionPrototype() { return m_JSPostgresSQLConnection.prototypeInitializedOnMainThread(this); }
|
||||
JSC::LazyClassStructure m_JSPostgresSQLConnection;
|
||||
JSC::Structure* JSPostgresSQLQueryStructure() { return m_JSPostgresSQLQuery.getInitializedOnMainThread(this); }
|
||||
JSC::JSObject* JSPostgresSQLQueryConstructor() { return m_JSPostgresSQLQuery.constructorInitializedOnMainThread(this); }
|
||||
JSC::JSValue JSPostgresSQLQueryPrototype() { return m_JSPostgresSQLQuery.prototypeInitializedOnMainThread(this); }
|
||||
JSC::LazyClassStructure m_JSPostgresSQLQuery;
|
||||
JSC::Structure* JSRequestStructure() { return m_JSRequest.getInitializedOnMainThread(this); }
|
||||
JSC::JSObject* JSRequestConstructor() { return m_JSRequest.constructorInitializedOnMainThread(this); }
|
||||
JSC::JSValue JSRequestPrototype() { return m_JSRequest.prototypeInitializedOnMainThread(this); }
|
||||
|
||||
@@ -191,6 +191,18 @@ ALWAYS_INLINE void GlobalObject::initGeneratedLazyClasses() {
|
||||
init.setStructure(WebCore::JSNodeJSFS::createStructure(init.vm, init.global, init.prototype));
|
||||
init.setConstructor(WebCore::JSNodeJSFS::createConstructor(init.vm, init.global, init.prototype));
|
||||
});
|
||||
m_JSPostgresSQLConnection.initLater(
|
||||
[](LazyClassStructure::Initializer& init) {
|
||||
init.setPrototype(WebCore::JSPostgresSQLConnection::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global)));
|
||||
init.setStructure(WebCore::JSPostgresSQLConnection::createStructure(init.vm, init.global, init.prototype));
|
||||
init.setConstructor(WebCore::JSPostgresSQLConnection::createConstructor(init.vm, init.global, init.prototype));
|
||||
});
|
||||
m_JSPostgresSQLQuery.initLater(
|
||||
[](LazyClassStructure::Initializer& init) {
|
||||
init.setPrototype(WebCore::JSPostgresSQLQuery::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global)));
|
||||
init.setStructure(WebCore::JSPostgresSQLQuery::createStructure(init.vm, init.global, init.prototype));
|
||||
init.setConstructor(WebCore::JSPostgresSQLQuery::createConstructor(init.vm, init.global, init.prototype));
|
||||
});
|
||||
m_JSRequest.initLater(
|
||||
[](LazyClassStructure::Initializer& init) {
|
||||
init.setPrototype(WebCore::JSRequest::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global)));
|
||||
@@ -341,6 +353,8 @@ void GlobalObject::visitGeneratedLazyClasses(GlobalObject *thisObject, Visitor&
|
||||
thisObject->m_JSMD5.visit(visitor);
|
||||
thisObject->m_JSMatchedRoute.visit(visitor);
|
||||
thisObject->m_JSNodeJSFS.visit(visitor);
|
||||
thisObject->m_JSPostgresSQLConnection.visit(visitor);
|
||||
thisObject->m_JSPostgresSQLQuery.visit(visitor);
|
||||
thisObject->m_JSRequest.visit(visitor);
|
||||
thisObject->m_JSResolveMessage.visit(visitor);
|
||||
thisObject->m_JSResponse.visit(visitor);
|
||||
|
||||
869
src/bun.js/bindings/ZigGeneratedClasses.cpp
generated
869
src/bun.js/bindings/ZigGeneratedClasses.cpp
generated
@@ -17378,6 +17378,875 @@ extern "C" EncodedJSValue NodeJSFS__create(Zig::GlobalObject* globalObject, void
|
||||
|
||||
return JSValue::encode(instance);
|
||||
}
|
||||
class JSPostgresSQLConnectionPrototype final : public JSC::JSNonFinalObject {
|
||||
public:
|
||||
using Base = JSC::JSNonFinalObject;
|
||||
|
||||
static JSPostgresSQLConnectionPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
|
||||
{
|
||||
JSPostgresSQLConnectionPrototype* ptr = new (NotNull, JSC::allocateCell<JSPostgresSQLConnectionPrototype>(vm)) JSPostgresSQLConnectionPrototype(vm, globalObject, structure);
|
||||
ptr->finishCreation(vm, globalObject);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
DECLARE_INFO;
|
||||
template<typename CellType, JSC::SubspaceAccess>
|
||||
static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
|
||||
{
|
||||
STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSPostgresSQLConnectionPrototype, Base);
|
||||
return &vm.plainObjectSpace();
|
||||
}
|
||||
static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
|
||||
{
|
||||
return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
|
||||
}
|
||||
|
||||
private:
|
||||
JSPostgresSQLConnectionPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
|
||||
: Base(vm, structure)
|
||||
{
|
||||
}
|
||||
|
||||
void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
|
||||
};
|
||||
|
||||
class JSPostgresSQLConnectionConstructor final : public JSC::InternalFunction {
|
||||
public:
|
||||
using Base = JSC::InternalFunction;
|
||||
static JSPostgresSQLConnectionConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSPostgresSQLConnectionPrototype* prototype);
|
||||
|
||||
static constexpr unsigned StructureFlags = Base::StructureFlags;
|
||||
static constexpr bool needsDestruction = false;
|
||||
|
||||
static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
|
||||
{
|
||||
return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
|
||||
}
|
||||
|
||||
template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
|
||||
{
|
||||
if constexpr (mode == JSC::SubspaceAccess::Concurrently)
|
||||
return nullptr;
|
||||
return WebCore::subspaceForImpl<JSPostgresSQLConnectionConstructor, WebCore::UseCustomHeapCellType::No>(
|
||||
vm,
|
||||
[](auto& spaces) { return spaces.m_clientSubspaceForPostgresSQLConnectionConstructor.get(); },
|
||||
[](auto& spaces, auto&& space) { spaces.m_clientSubspaceForPostgresSQLConnectionConstructor = std::forward<decltype(space)>(space); },
|
||||
[](auto& spaces) { return spaces.m_subspaceForPostgresSQLConnectionConstructor.get(); },
|
||||
[](auto& spaces, auto&& space) { spaces.m_subspaceForPostgresSQLConnectionConstructor = std::forward<decltype(space)>(space); });
|
||||
}
|
||||
|
||||
void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSPostgresSQLConnectionPrototype* prototype);
|
||||
|
||||
// Must be defined for each specialization class.
|
||||
static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
|
||||
|
||||
DECLARE_EXPORT_INFO;
|
||||
|
||||
private:
|
||||
JSPostgresSQLConnectionConstructor(JSC::VM& vm, JSC::Structure* structure);
|
||||
void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSPostgresSQLConnectionPrototype* prototype);
|
||||
};
|
||||
|
||||
extern "C" void* PostgresSQLConnectionClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*);
|
||||
JSC_DECLARE_CUSTOM_GETTER(jsPostgresSQLConnectionConstructor);
|
||||
|
||||
extern "C" void PostgresSQLConnectionClass__finalize(void*);
|
||||
|
||||
extern "C" EncodedJSValue PostgresSQLConnectionPrototype__doClose(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
|
||||
JSC_DECLARE_HOST_FUNCTION(PostgresSQLConnectionPrototype__closeCallback);
|
||||
|
||||
extern "C" JSC::EncodedJSValue PostgresSQLConnectionPrototype__getConnected(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
|
||||
JSC_DECLARE_CUSTOM_GETTER(PostgresSQLConnectionPrototype__connectedGetterWrap);
|
||||
|
||||
extern "C" EncodedJSValue PostgresSQLConnectionPrototype__doFlush(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
|
||||
JSC_DECLARE_HOST_FUNCTION(PostgresSQLConnectionPrototype__flushCallback);
|
||||
|
||||
extern "C" EncodedJSValue PostgresSQLConnectionPrototype__createQuery(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
|
||||
JSC_DECLARE_HOST_FUNCTION(PostgresSQLConnectionPrototype__queryCallback);
|
||||
|
||||
extern "C" EncodedJSValue PostgresSQLConnectionPrototype__doRef(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
|
||||
JSC_DECLARE_HOST_FUNCTION(PostgresSQLConnectionPrototype__refCallback);
|
||||
|
||||
extern "C" EncodedJSValue PostgresSQLConnectionPrototype__doUnref(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
|
||||
JSC_DECLARE_HOST_FUNCTION(PostgresSQLConnectionPrototype__unrefCallback);
|
||||
|
||||
STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSPostgresSQLConnectionPrototype, JSPostgresSQLConnectionPrototype::Base);
|
||||
|
||||
static const HashTableValue JSPostgresSQLConnectionPrototypeTableValues[] = {
|
||||
{ "close"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, PostgresSQLConnectionPrototype__closeCallback, 0 } },
|
||||
{ "connected"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, PostgresSQLConnectionPrototype__connectedGetterWrap, 0 } },
|
||||
{ "flush"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, PostgresSQLConnectionPrototype__flushCallback, 0 } },
|
||||
{ "query"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, PostgresSQLConnectionPrototype__queryCallback, 0 } },
|
||||
{ "ref"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, PostgresSQLConnectionPrototype__refCallback, 0 } },
|
||||
{ "unref"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, PostgresSQLConnectionPrototype__unrefCallback, 0 } }
|
||||
};
|
||||
|
||||
const ClassInfo JSPostgresSQLConnectionPrototype::s_info = { "PostgresSQLConnection"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSPostgresSQLConnectionPrototype) };
|
||||
|
||||
JSC_DEFINE_CUSTOM_GETTER(jsPostgresSQLConnectionConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
|
||||
{
|
||||
VM& vm = JSC::getVM(lexicalGlobalObject);
|
||||
auto throwScope = DECLARE_THROW_SCOPE(vm);
|
||||
auto* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
|
||||
auto* prototype = jsDynamicCast<JSPostgresSQLConnectionPrototype*>(JSValue::decode(thisValue));
|
||||
|
||||
if (UNLIKELY(!prototype))
|
||||
return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for PostgresSQLConnection"_s);
|
||||
return JSValue::encode(globalObject->JSPostgresSQLConnectionConstructor());
|
||||
}
|
||||
|
||||
JSC_DEFINE_HOST_FUNCTION(PostgresSQLConnectionPrototype__closeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
|
||||
{
|
||||
auto& vm = lexicalGlobalObject->vm();
|
||||
|
||||
JSPostgresSQLConnection* thisObject = jsDynamicCast<JSPostgresSQLConnection*>(callFrame->thisValue());
|
||||
|
||||
if (UNLIKELY(!thisObject)) {
|
||||
auto throwScope = DECLARE_THROW_SCOPE(vm);
|
||||
throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof PostgresSQLConnection"_s);
|
||||
return JSValue::encode({});
|
||||
}
|
||||
|
||||
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
|
||||
|
||||
#ifdef BUN_DEBUG
|
||||
/** View the file name of the JS file that called this function
|
||||
* from a debugger */
|
||||
SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm);
|
||||
const char* fileName = sourceOrigin.string().utf8().data();
|
||||
static const char* lastFileName = nullptr;
|
||||
if (lastFileName != fileName) {
|
||||
lastFileName = fileName;
|
||||
}
|
||||
#endif
|
||||
|
||||
return PostgresSQLConnectionPrototype__doClose(thisObject->wrapped(), lexicalGlobalObject, callFrame);
|
||||
}
|
||||
|
||||
JSC_DEFINE_CUSTOM_GETTER(PostgresSQLConnectionPrototype__connectedGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
|
||||
{
|
||||
auto& vm = lexicalGlobalObject->vm();
|
||||
Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
|
||||
auto throwScope = DECLARE_THROW_SCOPE(vm);
|
||||
JSPostgresSQLConnection* thisObject = jsCast<JSPostgresSQLConnection*>(JSValue::decode(thisValue));
|
||||
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
|
||||
JSC::EncodedJSValue result = PostgresSQLConnectionPrototype__getConnected(thisObject->wrapped(), globalObject);
|
||||
RETURN_IF_EXCEPTION(throwScope, {});
|
||||
RELEASE_AND_RETURN(throwScope, result);
|
||||
}
|
||||
|
||||
JSC_DEFINE_HOST_FUNCTION(PostgresSQLConnectionPrototype__flushCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
|
||||
{
|
||||
auto& vm = lexicalGlobalObject->vm();
|
||||
|
||||
JSPostgresSQLConnection* thisObject = jsDynamicCast<JSPostgresSQLConnection*>(callFrame->thisValue());
|
||||
|
||||
if (UNLIKELY(!thisObject)) {
|
||||
auto throwScope = DECLARE_THROW_SCOPE(vm);
|
||||
throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof PostgresSQLConnection"_s);
|
||||
return JSValue::encode({});
|
||||
}
|
||||
|
||||
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
|
||||
|
||||
#ifdef BUN_DEBUG
|
||||
/** View the file name of the JS file that called this function
|
||||
* from a debugger */
|
||||
SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm);
|
||||
const char* fileName = sourceOrigin.string().utf8().data();
|
||||
static const char* lastFileName = nullptr;
|
||||
if (lastFileName != fileName) {
|
||||
lastFileName = fileName;
|
||||
}
|
||||
#endif
|
||||
|
||||
return PostgresSQLConnectionPrototype__doFlush(thisObject->wrapped(), lexicalGlobalObject, callFrame);
|
||||
}
|
||||
|
||||
JSC_DEFINE_HOST_FUNCTION(PostgresSQLConnectionPrototype__queryCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
|
||||
{
|
||||
auto& vm = lexicalGlobalObject->vm();
|
||||
|
||||
JSPostgresSQLConnection* thisObject = jsDynamicCast<JSPostgresSQLConnection*>(callFrame->thisValue());
|
||||
|
||||
if (UNLIKELY(!thisObject)) {
|
||||
auto throwScope = DECLARE_THROW_SCOPE(vm);
|
||||
throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof PostgresSQLConnection"_s);
|
||||
return JSValue::encode({});
|
||||
}
|
||||
|
||||
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
|
||||
|
||||
#ifdef BUN_DEBUG
|
||||
/** View the file name of the JS file that called this function
|
||||
* from a debugger */
|
||||
SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm);
|
||||
const char* fileName = sourceOrigin.string().utf8().data();
|
||||
static const char* lastFileName = nullptr;
|
||||
if (lastFileName != fileName) {
|
||||
lastFileName = fileName;
|
||||
}
|
||||
#endif
|
||||
|
||||
return PostgresSQLConnectionPrototype__createQuery(thisObject->wrapped(), lexicalGlobalObject, callFrame);
|
||||
}
|
||||
|
||||
JSC_DEFINE_HOST_FUNCTION(PostgresSQLConnectionPrototype__refCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
|
||||
{
|
||||
auto& vm = lexicalGlobalObject->vm();
|
||||
|
||||
JSPostgresSQLConnection* thisObject = jsDynamicCast<JSPostgresSQLConnection*>(callFrame->thisValue());
|
||||
|
||||
if (UNLIKELY(!thisObject)) {
|
||||
auto throwScope = DECLARE_THROW_SCOPE(vm);
|
||||
throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof PostgresSQLConnection"_s);
|
||||
return JSValue::encode({});
|
||||
}
|
||||
|
||||
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
|
||||
|
||||
#ifdef BUN_DEBUG
|
||||
/** View the file name of the JS file that called this function
|
||||
* from a debugger */
|
||||
SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm);
|
||||
const char* fileName = sourceOrigin.string().utf8().data();
|
||||
static const char* lastFileName = nullptr;
|
||||
if (lastFileName != fileName) {
|
||||
lastFileName = fileName;
|
||||
}
|
||||
#endif
|
||||
|
||||
return PostgresSQLConnectionPrototype__doRef(thisObject->wrapped(), lexicalGlobalObject, callFrame);
|
||||
}
|
||||
|
||||
JSC_DEFINE_HOST_FUNCTION(PostgresSQLConnectionPrototype__unrefCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
|
||||
{
|
||||
auto& vm = lexicalGlobalObject->vm();
|
||||
|
||||
JSPostgresSQLConnection* thisObject = jsDynamicCast<JSPostgresSQLConnection*>(callFrame->thisValue());
|
||||
|
||||
if (UNLIKELY(!thisObject)) {
|
||||
auto throwScope = DECLARE_THROW_SCOPE(vm);
|
||||
throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof PostgresSQLConnection"_s);
|
||||
return JSValue::encode({});
|
||||
}
|
||||
|
||||
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
|
||||
|
||||
#ifdef BUN_DEBUG
|
||||
/** View the file name of the JS file that called this function
|
||||
* from a debugger */
|
||||
SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm);
|
||||
const char* fileName = sourceOrigin.string().utf8().data();
|
||||
static const char* lastFileName = nullptr;
|
||||
if (lastFileName != fileName) {
|
||||
lastFileName = fileName;
|
||||
}
|
||||
#endif
|
||||
|
||||
return PostgresSQLConnectionPrototype__doUnref(thisObject->wrapped(), lexicalGlobalObject, callFrame);
|
||||
}
|
||||
|
||||
void JSPostgresSQLConnectionPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
|
||||
{
|
||||
Base::finishCreation(vm);
|
||||
reifyStaticProperties(vm, JSPostgresSQLConnection::info(), JSPostgresSQLConnectionPrototypeTableValues, *this);
|
||||
JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
|
||||
}
|
||||
|
||||
void JSPostgresSQLConnectionConstructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObject, JSPostgresSQLConnectionPrototype* prototype)
|
||||
{
|
||||
Base::finishCreation(vm, 0, "PostgresSQLConnection"_s, PropertyAdditionMode::WithoutStructureTransition);
|
||||
|
||||
putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly);
|
||||
ASSERT(inherits(info()));
|
||||
}
|
||||
|
||||
JSPostgresSQLConnectionConstructor::JSPostgresSQLConnectionConstructor(JSC::VM& vm, JSC::Structure* structure)
|
||||
: Base(vm, structure, construct, construct)
|
||||
{
|
||||
}
|
||||
|
||||
JSPostgresSQLConnectionConstructor* JSPostgresSQLConnectionConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSPostgresSQLConnectionPrototype* prototype)
|
||||
{
|
||||
JSPostgresSQLConnectionConstructor* ptr = new (NotNull, JSC::allocateCell<JSPostgresSQLConnectionConstructor>(vm)) JSPostgresSQLConnectionConstructor(vm, structure);
|
||||
ptr->finishCreation(vm, globalObject, prototype);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSPostgresSQLConnectionConstructor::construct(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame)
|
||||
{
|
||||
Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
|
||||
JSC::VM& vm = globalObject->vm();
|
||||
JSObject* newTarget = asObject(callFrame->newTarget());
|
||||
auto* constructor = globalObject->JSPostgresSQLConnectionConstructor();
|
||||
Structure* structure = globalObject->JSPostgresSQLConnectionStructure();
|
||||
if (constructor != newTarget) {
|
||||
auto scope = DECLARE_THROW_SCOPE(vm);
|
||||
|
||||
auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
|
||||
// ShadowRealm functions belong to a different global object.
|
||||
getFunctionRealm(globalObject, newTarget));
|
||||
RETURN_IF_EXCEPTION(scope, {});
|
||||
structure = InternalFunction::createSubclassStructure(
|
||||
globalObject,
|
||||
newTarget,
|
||||
functionGlobalObject->JSPostgresSQLConnectionStructure());
|
||||
}
|
||||
|
||||
void* ptr = PostgresSQLConnectionClass__construct(globalObject, callFrame);
|
||||
|
||||
if (UNLIKELY(!ptr)) {
|
||||
return JSValue::encode(JSC::jsUndefined());
|
||||
}
|
||||
|
||||
JSPostgresSQLConnection* instance = JSPostgresSQLConnection::create(vm, globalObject, structure, ptr);
|
||||
|
||||
return JSValue::encode(instance);
|
||||
}
|
||||
|
||||
void JSPostgresSQLConnectionConstructor::initializeProperties(VM& vm, JSC::JSGlobalObject* globalObject, JSPostgresSQLConnectionPrototype* prototype)
|
||||
{
|
||||
}
|
||||
|
||||
const ClassInfo JSPostgresSQLConnectionConstructor::s_info = { "Function"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSPostgresSQLConnectionConstructor) };
|
||||
|
||||
extern "C" EncodedJSValue PostgresSQLConnection__getConstructor(Zig::GlobalObject* globalObject)
|
||||
{
|
||||
return JSValue::encode(globalObject->JSPostgresSQLConnectionConstructor());
|
||||
}
|
||||
|
||||
extern "C" bool PostgresSQLConnection__hasPendingActivity(void* ptr);
|
||||
bool JSPostgresSQLConnection::hasPendingActivity(void* ctx)
|
||||
{
|
||||
return PostgresSQLConnection__hasPendingActivity(ctx);
|
||||
}
|
||||
|
||||
JSPostgresSQLConnection::~JSPostgresSQLConnection()
|
||||
{
|
||||
if (m_ctx) {
|
||||
PostgresSQLConnectionClass__finalize(m_ctx);
|
||||
}
|
||||
}
|
||||
void JSPostgresSQLConnection::destroy(JSCell* cell)
|
||||
{
|
||||
static_cast<JSPostgresSQLConnection*>(cell)->JSPostgresSQLConnection::~JSPostgresSQLConnection();
|
||||
}
|
||||
|
||||
const ClassInfo JSPostgresSQLConnection::s_info = { "PostgresSQLConnection"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSPostgresSQLConnection) };
|
||||
|
||||
void JSPostgresSQLConnection::finishCreation(VM& vm)
|
||||
{
|
||||
Base::finishCreation(vm);
|
||||
ASSERT(inherits(info()));
|
||||
}
|
||||
|
||||
JSPostgresSQLConnection* JSPostgresSQLConnection::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx)
|
||||
{
|
||||
JSPostgresSQLConnection* ptr = new (NotNull, JSC::allocateCell<JSPostgresSQLConnection>(vm)) JSPostgresSQLConnection(vm, structure, ctx);
|
||||
ptr->finishCreation(vm);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
extern "C" void* PostgresSQLConnection__fromJS(JSC::EncodedJSValue value)
|
||||
{
|
||||
JSC::JSValue decodedValue = JSC::JSValue::decode(value);
|
||||
if (decodedValue.isEmpty() || !decodedValue.isCell())
|
||||
return nullptr;
|
||||
|
||||
JSC::JSCell* cell = decodedValue.asCell();
|
||||
JSPostgresSQLConnection* object = JSC::jsDynamicCast<JSPostgresSQLConnection*>(cell);
|
||||
|
||||
if (!object)
|
||||
return nullptr;
|
||||
|
||||
return object->wrapped();
|
||||
}
|
||||
|
||||
extern "C" bool PostgresSQLConnection__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr)
|
||||
{
|
||||
JSPostgresSQLConnection* object = JSC::jsDynamicCast<JSPostgresSQLConnection*>(JSValue::decode(value));
|
||||
if (!object)
|
||||
return false;
|
||||
|
||||
object->m_ctx = ptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
extern "C" const size_t PostgresSQLConnection__ptrOffset = JSPostgresSQLConnection::offsetOfWrapped();
|
||||
|
||||
void JSPostgresSQLConnection::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
|
||||
{
|
||||
auto* thisObject = jsCast<JSPostgresSQLConnection*>(cell);
|
||||
if (void* wrapped = thisObject->wrapped()) {
|
||||
// if (thisObject->scriptExecutionContext())
|
||||
// analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
|
||||
}
|
||||
Base::analyzeHeap(cell, analyzer);
|
||||
}
|
||||
|
||||
JSObject* JSPostgresSQLConnection::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
|
||||
{
|
||||
return WebCore::JSPostgresSQLConnectionConstructor::create(vm, globalObject, WebCore::JSPostgresSQLConnectionConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSPostgresSQLConnectionPrototype*>(prototype));
|
||||
}
|
||||
|
||||
JSObject* JSPostgresSQLConnection::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
|
||||
{
|
||||
return JSPostgresSQLConnectionPrototype::create(vm, globalObject, JSPostgresSQLConnectionPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
|
||||
}
|
||||
|
||||
extern "C" EncodedJSValue PostgresSQLConnection__create(Zig::GlobalObject* globalObject, void* ptr)
|
||||
{
|
||||
auto& vm = globalObject->vm();
|
||||
JSC::Structure* structure = globalObject->JSPostgresSQLConnectionStructure();
|
||||
JSPostgresSQLConnection* instance = JSPostgresSQLConnection::create(vm, globalObject, structure, ptr);
|
||||
|
||||
return JSValue::encode(instance);
|
||||
}
|
||||
|
||||
template<typename Visitor>
|
||||
void JSPostgresSQLConnection::visitChildrenImpl(JSCell* cell, Visitor& visitor)
|
||||
{
|
||||
JSPostgresSQLConnection* thisObject = jsCast<JSPostgresSQLConnection*>(cell);
|
||||
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
|
||||
Base::visitChildren(thisObject, visitor);
|
||||
|
||||
thisObject->visitAdditionalChildren<Visitor>(visitor);
|
||||
}
|
||||
|
||||
DEFINE_VISIT_CHILDREN(JSPostgresSQLConnection);
|
||||
|
||||
template<typename Visitor>
|
||||
void JSPostgresSQLConnection::visitAdditionalChildren(Visitor& visitor)
|
||||
{
|
||||
JSPostgresSQLConnection* thisObject = this;
|
||||
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
|
||||
|
||||
visitor.addOpaqueRoot(this->wrapped());
|
||||
}
|
||||
|
||||
DEFINE_VISIT_ADDITIONAL_CHILDREN(JSPostgresSQLConnection);
|
||||
|
||||
template<typename Visitor>
|
||||
void JSPostgresSQLConnection::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
|
||||
{
|
||||
JSPostgresSQLConnection* thisObject = jsCast<JSPostgresSQLConnection*>(cell);
|
||||
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
|
||||
thisObject->visitAdditionalChildren<Visitor>(visitor);
|
||||
}
|
||||
|
||||
DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSPostgresSQLConnection);
|
||||
class JSPostgresSQLQueryPrototype final : public JSC::JSNonFinalObject {
|
||||
public:
|
||||
using Base = JSC::JSNonFinalObject;
|
||||
|
||||
static JSPostgresSQLQueryPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
|
||||
{
|
||||
JSPostgresSQLQueryPrototype* ptr = new (NotNull, JSC::allocateCell<JSPostgresSQLQueryPrototype>(vm)) JSPostgresSQLQueryPrototype(vm, globalObject, structure);
|
||||
ptr->finishCreation(vm, globalObject);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
DECLARE_INFO;
|
||||
template<typename CellType, JSC::SubspaceAccess>
|
||||
static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
|
||||
{
|
||||
STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSPostgresSQLQueryPrototype, Base);
|
||||
return &vm.plainObjectSpace();
|
||||
}
|
||||
static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
|
||||
{
|
||||
return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
|
||||
}
|
||||
|
||||
private:
|
||||
JSPostgresSQLQueryPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
|
||||
: Base(vm, structure)
|
||||
{
|
||||
}
|
||||
|
||||
void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
|
||||
};
|
||||
|
||||
class JSPostgresSQLQueryConstructor final : public JSC::InternalFunction {
|
||||
public:
|
||||
using Base = JSC::InternalFunction;
|
||||
static JSPostgresSQLQueryConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSPostgresSQLQueryPrototype* prototype);
|
||||
|
||||
static constexpr unsigned StructureFlags = Base::StructureFlags;
|
||||
static constexpr bool needsDestruction = false;
|
||||
|
||||
static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
|
||||
{
|
||||
return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
|
||||
}
|
||||
|
||||
template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
|
||||
{
|
||||
if constexpr (mode == JSC::SubspaceAccess::Concurrently)
|
||||
return nullptr;
|
||||
return WebCore::subspaceForImpl<JSPostgresSQLQueryConstructor, WebCore::UseCustomHeapCellType::No>(
|
||||
vm,
|
||||
[](auto& spaces) { return spaces.m_clientSubspaceForPostgresSQLQueryConstructor.get(); },
|
||||
[](auto& spaces, auto&& space) { spaces.m_clientSubspaceForPostgresSQLQueryConstructor = std::forward<decltype(space)>(space); },
|
||||
[](auto& spaces) { return spaces.m_subspaceForPostgresSQLQueryConstructor.get(); },
|
||||
[](auto& spaces, auto&& space) { spaces.m_subspaceForPostgresSQLQueryConstructor = std::forward<decltype(space)>(space); });
|
||||
}
|
||||
|
||||
void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSPostgresSQLQueryPrototype* prototype);
|
||||
|
||||
// Must be defined for each specialization class.
|
||||
static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
|
||||
|
||||
DECLARE_EXPORT_INFO;
|
||||
|
||||
private:
|
||||
JSPostgresSQLQueryConstructor(JSC::VM& vm, JSC::Structure* structure);
|
||||
void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSPostgresSQLQueryPrototype* prototype);
|
||||
};
|
||||
|
||||
extern "C" void* PostgresSQLQueryClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*);
|
||||
JSC_DECLARE_CUSTOM_GETTER(jsPostgresSQLQueryConstructor);
|
||||
|
||||
extern "C" void PostgresSQLQueryClass__finalize(void*);
|
||||
|
||||
extern "C" EncodedJSValue PostgresSQLQueryPrototype__doCancel(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
|
||||
JSC_DECLARE_HOST_FUNCTION(PostgresSQLQueryPrototype__cancelCallback);
|
||||
|
||||
extern "C" EncodedJSValue PostgresSQLQueryPrototype__doDone(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
|
||||
JSC_DECLARE_HOST_FUNCTION(PostgresSQLQueryPrototype__doneCallback);
|
||||
|
||||
extern "C" EncodedJSValue PostgresSQLQueryPrototype__doRun(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
|
||||
JSC_DECLARE_HOST_FUNCTION(PostgresSQLQueryPrototype__runCallback);
|
||||
|
||||
STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSPostgresSQLQueryPrototype, JSPostgresSQLQueryPrototype::Base);
|
||||
|
||||
static const HashTableValue JSPostgresSQLQueryPrototypeTableValues[] = {
|
||||
{ "cancel"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, PostgresSQLQueryPrototype__cancelCallback, 0 } },
|
||||
{ "done"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, PostgresSQLQueryPrototype__doneCallback, 0 } },
|
||||
{ "run"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, PostgresSQLQueryPrototype__runCallback, 2 } }
|
||||
};
|
||||
|
||||
const ClassInfo JSPostgresSQLQueryPrototype::s_info = { "PostgresSQLQuery"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSPostgresSQLQueryPrototype) };
|
||||
|
||||
JSC_DEFINE_CUSTOM_GETTER(jsPostgresSQLQueryConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
|
||||
{
|
||||
VM& vm = JSC::getVM(lexicalGlobalObject);
|
||||
auto throwScope = DECLARE_THROW_SCOPE(vm);
|
||||
auto* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
|
||||
auto* prototype = jsDynamicCast<JSPostgresSQLQueryPrototype*>(JSValue::decode(thisValue));
|
||||
|
||||
if (UNLIKELY(!prototype))
|
||||
return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for PostgresSQLQuery"_s);
|
||||
return JSValue::encode(globalObject->JSPostgresSQLQueryConstructor());
|
||||
}
|
||||
|
||||
JSC_DEFINE_HOST_FUNCTION(PostgresSQLQueryPrototype__cancelCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
|
||||
{
|
||||
auto& vm = lexicalGlobalObject->vm();
|
||||
|
||||
JSPostgresSQLQuery* thisObject = jsDynamicCast<JSPostgresSQLQuery*>(callFrame->thisValue());
|
||||
|
||||
if (UNLIKELY(!thisObject)) {
|
||||
auto throwScope = DECLARE_THROW_SCOPE(vm);
|
||||
throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof PostgresSQLQuery"_s);
|
||||
return JSValue::encode({});
|
||||
}
|
||||
|
||||
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
|
||||
|
||||
#ifdef BUN_DEBUG
|
||||
/** View the file name of the JS file that called this function
|
||||
* from a debugger */
|
||||
SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm);
|
||||
const char* fileName = sourceOrigin.string().utf8().data();
|
||||
static const char* lastFileName = nullptr;
|
||||
if (lastFileName != fileName) {
|
||||
lastFileName = fileName;
|
||||
}
|
||||
#endif
|
||||
|
||||
return PostgresSQLQueryPrototype__doCancel(thisObject->wrapped(), lexicalGlobalObject, callFrame);
|
||||
}
|
||||
|
||||
JSC_DEFINE_HOST_FUNCTION(PostgresSQLQueryPrototype__doneCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
|
||||
{
|
||||
auto& vm = lexicalGlobalObject->vm();
|
||||
|
||||
JSPostgresSQLQuery* thisObject = jsDynamicCast<JSPostgresSQLQuery*>(callFrame->thisValue());
|
||||
|
||||
if (UNLIKELY(!thisObject)) {
|
||||
auto throwScope = DECLARE_THROW_SCOPE(vm);
|
||||
throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof PostgresSQLQuery"_s);
|
||||
return JSValue::encode({});
|
||||
}
|
||||
|
||||
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
|
||||
|
||||
#ifdef BUN_DEBUG
|
||||
/** View the file name of the JS file that called this function
|
||||
* from a debugger */
|
||||
SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm);
|
||||
const char* fileName = sourceOrigin.string().utf8().data();
|
||||
static const char* lastFileName = nullptr;
|
||||
if (lastFileName != fileName) {
|
||||
lastFileName = fileName;
|
||||
}
|
||||
#endif
|
||||
|
||||
return PostgresSQLQueryPrototype__doDone(thisObject->wrapped(), lexicalGlobalObject, callFrame);
|
||||
}
|
||||
|
||||
JSC_DEFINE_HOST_FUNCTION(PostgresSQLQueryPrototype__runCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
|
||||
{
|
||||
auto& vm = lexicalGlobalObject->vm();
|
||||
|
||||
JSPostgresSQLQuery* thisObject = jsDynamicCast<JSPostgresSQLQuery*>(callFrame->thisValue());
|
||||
|
||||
if (UNLIKELY(!thisObject)) {
|
||||
auto throwScope = DECLARE_THROW_SCOPE(vm);
|
||||
throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof PostgresSQLQuery"_s);
|
||||
return JSValue::encode({});
|
||||
}
|
||||
|
||||
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
|
||||
|
||||
#ifdef BUN_DEBUG
|
||||
/** View the file name of the JS file that called this function
|
||||
* from a debugger */
|
||||
SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm);
|
||||
const char* fileName = sourceOrigin.string().utf8().data();
|
||||
static const char* lastFileName = nullptr;
|
||||
if (lastFileName != fileName) {
|
||||
lastFileName = fileName;
|
||||
}
|
||||
#endif
|
||||
|
||||
return PostgresSQLQueryPrototype__doRun(thisObject->wrapped(), lexicalGlobalObject, callFrame);
|
||||
}
|
||||
|
||||
extern "C" void PostgresSQLQueryPrototype__pendingValueSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
|
||||
{
|
||||
auto& vm = globalObject->vm();
|
||||
auto* thisObject = jsCast<JSPostgresSQLQuery*>(JSValue::decode(thisValue));
|
||||
thisObject->m_pendingValue.set(vm, thisObject, JSValue::decode(value));
|
||||
}
|
||||
|
||||
extern "C" EncodedJSValue PostgresSQLQueryPrototype__pendingValueGetCachedValue(JSC::EncodedJSValue thisValue)
|
||||
{
|
||||
auto* thisObject = jsCast<JSPostgresSQLQuery*>(JSValue::decode(thisValue));
|
||||
return JSValue::encode(thisObject->m_pendingValue.get());
|
||||
}
|
||||
|
||||
extern "C" void PostgresSQLQueryPrototype__bindingSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
|
||||
{
|
||||
auto& vm = globalObject->vm();
|
||||
auto* thisObject = jsCast<JSPostgresSQLQuery*>(JSValue::decode(thisValue));
|
||||
thisObject->m_binding.set(vm, thisObject, JSValue::decode(value));
|
||||
}
|
||||
|
||||
extern "C" EncodedJSValue PostgresSQLQueryPrototype__bindingGetCachedValue(JSC::EncodedJSValue thisValue)
|
||||
{
|
||||
auto* thisObject = jsCast<JSPostgresSQLQuery*>(JSValue::decode(thisValue));
|
||||
return JSValue::encode(thisObject->m_binding.get());
|
||||
}
|
||||
|
||||
void JSPostgresSQLQueryPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
|
||||
{
|
||||
Base::finishCreation(vm);
|
||||
reifyStaticProperties(vm, JSPostgresSQLQuery::info(), JSPostgresSQLQueryPrototypeTableValues, *this);
|
||||
JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
|
||||
}
|
||||
|
||||
extern "C" size_t PostgresSQLQuery__estimatedSize(void* ptr);
|
||||
|
||||
void JSPostgresSQLQueryConstructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObject, JSPostgresSQLQueryPrototype* prototype)
|
||||
{
|
||||
Base::finishCreation(vm, 0, "PostgresSQLQuery"_s, PropertyAdditionMode::WithoutStructureTransition);
|
||||
|
||||
putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly);
|
||||
ASSERT(inherits(info()));
|
||||
}
|
||||
|
||||
JSPostgresSQLQueryConstructor::JSPostgresSQLQueryConstructor(JSC::VM& vm, JSC::Structure* structure)
|
||||
: Base(vm, structure, construct, construct)
|
||||
{
|
||||
}
|
||||
|
||||
JSPostgresSQLQueryConstructor* JSPostgresSQLQueryConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSPostgresSQLQueryPrototype* prototype)
|
||||
{
|
||||
JSPostgresSQLQueryConstructor* ptr = new (NotNull, JSC::allocateCell<JSPostgresSQLQueryConstructor>(vm)) JSPostgresSQLQueryConstructor(vm, structure);
|
||||
ptr->finishCreation(vm, globalObject, prototype);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSPostgresSQLQueryConstructor::construct(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame)
|
||||
{
|
||||
Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
|
||||
JSC::VM& vm = globalObject->vm();
|
||||
JSObject* newTarget = asObject(callFrame->newTarget());
|
||||
auto* constructor = globalObject->JSPostgresSQLQueryConstructor();
|
||||
Structure* structure = globalObject->JSPostgresSQLQueryStructure();
|
||||
if (constructor != newTarget) {
|
||||
auto scope = DECLARE_THROW_SCOPE(vm);
|
||||
|
||||
auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
|
||||
// ShadowRealm functions belong to a different global object.
|
||||
getFunctionRealm(globalObject, newTarget));
|
||||
RETURN_IF_EXCEPTION(scope, {});
|
||||
structure = InternalFunction::createSubclassStructure(
|
||||
globalObject,
|
||||
newTarget,
|
||||
functionGlobalObject->JSPostgresSQLQueryStructure());
|
||||
}
|
||||
|
||||
void* ptr = PostgresSQLQueryClass__construct(globalObject, callFrame);
|
||||
|
||||
if (UNLIKELY(!ptr)) {
|
||||
return JSValue::encode(JSC::jsUndefined());
|
||||
}
|
||||
|
||||
JSPostgresSQLQuery* instance = JSPostgresSQLQuery::create(vm, globalObject, structure, ptr);
|
||||
vm.heap.reportExtraMemoryAllocated(instance, PostgresSQLQuery__estimatedSize(instance->wrapped()));
|
||||
|
||||
return JSValue::encode(instance);
|
||||
}
|
||||
|
||||
void JSPostgresSQLQueryConstructor::initializeProperties(VM& vm, JSC::JSGlobalObject* globalObject, JSPostgresSQLQueryPrototype* prototype)
|
||||
{
|
||||
}
|
||||
|
||||
const ClassInfo JSPostgresSQLQueryConstructor::s_info = { "Function"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSPostgresSQLQueryConstructor) };
|
||||
|
||||
extern "C" EncodedJSValue PostgresSQLQuery__getConstructor(Zig::GlobalObject* globalObject)
|
||||
{
|
||||
return JSValue::encode(globalObject->JSPostgresSQLQueryConstructor());
|
||||
}
|
||||
|
||||
extern "C" bool PostgresSQLQuery__hasPendingActivity(void* ptr);
|
||||
bool JSPostgresSQLQuery::hasPendingActivity(void* ctx)
|
||||
{
|
||||
return PostgresSQLQuery__hasPendingActivity(ctx);
|
||||
}
|
||||
|
||||
JSPostgresSQLQuery::~JSPostgresSQLQuery()
|
||||
{
|
||||
if (m_ctx) {
|
||||
PostgresSQLQueryClass__finalize(m_ctx);
|
||||
}
|
||||
}
|
||||
void JSPostgresSQLQuery::destroy(JSCell* cell)
|
||||
{
|
||||
static_cast<JSPostgresSQLQuery*>(cell)->JSPostgresSQLQuery::~JSPostgresSQLQuery();
|
||||
}
|
||||
|
||||
const ClassInfo JSPostgresSQLQuery::s_info = { "PostgresSQLQuery"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSPostgresSQLQuery) };
|
||||
|
||||
void JSPostgresSQLQuery::finishCreation(VM& vm)
|
||||
{
|
||||
Base::finishCreation(vm);
|
||||
ASSERT(inherits(info()));
|
||||
}
|
||||
|
||||
JSPostgresSQLQuery* JSPostgresSQLQuery::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx)
|
||||
{
|
||||
JSPostgresSQLQuery* ptr = new (NotNull, JSC::allocateCell<JSPostgresSQLQuery>(vm)) JSPostgresSQLQuery(vm, structure, ctx);
|
||||
ptr->finishCreation(vm);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
extern "C" void* PostgresSQLQuery__fromJS(JSC::EncodedJSValue value)
|
||||
{
|
||||
JSC::JSValue decodedValue = JSC::JSValue::decode(value);
|
||||
if (decodedValue.isEmpty() || !decodedValue.isCell())
|
||||
return nullptr;
|
||||
|
||||
JSC::JSCell* cell = decodedValue.asCell();
|
||||
JSPostgresSQLQuery* object = JSC::jsDynamicCast<JSPostgresSQLQuery*>(cell);
|
||||
|
||||
if (!object)
|
||||
return nullptr;
|
||||
|
||||
return object->wrapped();
|
||||
}
|
||||
|
||||
extern "C" bool PostgresSQLQuery__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr)
|
||||
{
|
||||
JSPostgresSQLQuery* object = JSC::jsDynamicCast<JSPostgresSQLQuery*>(JSValue::decode(value));
|
||||
if (!object)
|
||||
return false;
|
||||
|
||||
object->m_ctx = ptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
extern "C" const size_t PostgresSQLQuery__ptrOffset = JSPostgresSQLQuery::offsetOfWrapped();
|
||||
|
||||
void JSPostgresSQLQuery::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
|
||||
{
|
||||
auto* thisObject = jsCast<JSPostgresSQLQuery*>(cell);
|
||||
if (void* wrapped = thisObject->wrapped()) {
|
||||
// if (thisObject->scriptExecutionContext())
|
||||
// analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
|
||||
}
|
||||
Base::analyzeHeap(cell, analyzer);
|
||||
}
|
||||
|
||||
JSObject* JSPostgresSQLQuery::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
|
||||
{
|
||||
return WebCore::JSPostgresSQLQueryConstructor::create(vm, globalObject, WebCore::JSPostgresSQLQueryConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSPostgresSQLQueryPrototype*>(prototype));
|
||||
}
|
||||
|
||||
JSObject* JSPostgresSQLQuery::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
|
||||
{
|
||||
return JSPostgresSQLQueryPrototype::create(vm, globalObject, JSPostgresSQLQueryPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
|
||||
}
|
||||
|
||||
extern "C" EncodedJSValue PostgresSQLQuery__create(Zig::GlobalObject* globalObject, void* ptr)
|
||||
{
|
||||
auto& vm = globalObject->vm();
|
||||
JSC::Structure* structure = globalObject->JSPostgresSQLQueryStructure();
|
||||
JSPostgresSQLQuery* instance = JSPostgresSQLQuery::create(vm, globalObject, structure, ptr);
|
||||
vm.heap.reportExtraMemoryAllocated(instance, PostgresSQLQuery__estimatedSize(ptr));
|
||||
return JSValue::encode(instance);
|
||||
}
|
||||
|
||||
template<typename Visitor>
|
||||
void JSPostgresSQLQuery::visitChildrenImpl(JSCell* cell, Visitor& visitor)
|
||||
{
|
||||
JSPostgresSQLQuery* thisObject = jsCast<JSPostgresSQLQuery*>(cell);
|
||||
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
|
||||
Base::visitChildren(thisObject, visitor);
|
||||
if (auto* ptr = thisObject->wrapped()) {
|
||||
visitor.reportExtraMemoryVisited(PostgresSQLQuery__estimatedSize(ptr));
|
||||
}
|
||||
thisObject->visitAdditionalChildren<Visitor>(visitor);
|
||||
}
|
||||
|
||||
DEFINE_VISIT_CHILDREN(JSPostgresSQLQuery);
|
||||
|
||||
template<typename Visitor>
|
||||
void JSPostgresSQLQuery::visitAdditionalChildren(Visitor& visitor)
|
||||
{
|
||||
JSPostgresSQLQuery* thisObject = this;
|
||||
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
|
||||
visitor.append(thisObject->m_pendingValue);
|
||||
visitor.append(thisObject->m_binding);
|
||||
|
||||
visitor.addOpaqueRoot(this->wrapped());
|
||||
}
|
||||
|
||||
DEFINE_VISIT_ADDITIONAL_CHILDREN(JSPostgresSQLQuery);
|
||||
|
||||
template<typename Visitor>
|
||||
void JSPostgresSQLQuery::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
|
||||
{
|
||||
JSPostgresSQLQuery* thisObject = jsCast<JSPostgresSQLQuery*>(cell);
|
||||
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
|
||||
thisObject->visitAdditionalChildren<Visitor>(visitor);
|
||||
}
|
||||
|
||||
DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSPostgresSQLQuery);
|
||||
class JSRequestPrototype final : public JSC::JSNonFinalObject {
|
||||
public:
|
||||
using Base = JSC::JSNonFinalObject;
|
||||
|
||||
165
src/bun.js/bindings/ZigGeneratedClasses.h
generated
165
src/bun.js/bindings/ZigGeneratedClasses.h
generated
@@ -1806,6 +1806,171 @@ public:
|
||||
void finishCreation(JSC::VM&);
|
||||
};
|
||||
|
||||
class JSPostgresSQLConnection final : public JSC::JSDestructibleObject {
|
||||
public:
|
||||
using Base = JSC::JSDestructibleObject;
|
||||
static JSPostgresSQLConnection* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
|
||||
|
||||
DECLARE_EXPORT_INFO;
|
||||
template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
|
||||
{
|
||||
if constexpr (mode == JSC::SubspaceAccess::Concurrently)
|
||||
return nullptr;
|
||||
return WebCore::subspaceForImpl<JSPostgresSQLConnection, WebCore::UseCustomHeapCellType::No>(
|
||||
vm,
|
||||
[](auto& spaces) { return spaces.m_clientSubspaceForPostgresSQLConnection.get(); },
|
||||
[](auto& spaces, auto&& space) { spaces.m_clientSubspaceForPostgresSQLConnection = std::forward<decltype(space)>(space); },
|
||||
[](auto& spaces) { return spaces.m_subspaceForPostgresSQLConnection.get(); },
|
||||
[](auto& spaces, auto&& space) { spaces.m_subspaceForPostgresSQLConnection = std::forward<decltype(space)>(space); });
|
||||
}
|
||||
|
||||
static void destroy(JSC::JSCell*);
|
||||
static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
|
||||
{
|
||||
return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
|
||||
}
|
||||
|
||||
static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
|
||||
static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
|
||||
|
||||
~JSPostgresSQLConnection();
|
||||
|
||||
void* wrapped() const { return m_ctx; }
|
||||
|
||||
void detach()
|
||||
{
|
||||
m_ctx = nullptr;
|
||||
}
|
||||
|
||||
static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
|
||||
static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSPostgresSQLConnection, m_ctx); }
|
||||
|
||||
void* m_ctx { nullptr };
|
||||
|
||||
JSPostgresSQLConnection(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
|
||||
: Base(vm, structure)
|
||||
{
|
||||
m_ctx = sinkPtr;
|
||||
m_weakThis = JSC::Weak<JSPostgresSQLConnection>(this, getOwner());
|
||||
}
|
||||
|
||||
void finishCreation(JSC::VM&);
|
||||
|
||||
JSC::Weak<JSPostgresSQLConnection> m_weakThis;
|
||||
|
||||
static bool hasPendingActivity(void* ctx);
|
||||
|
||||
class Owner final : public JSC::WeakHandleOwner {
|
||||
public:
|
||||
bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void* context, JSC::AbstractSlotVisitor& visitor, const char** reason) final
|
||||
{
|
||||
auto* controller = JSC::jsCast<JSPostgresSQLConnection*>(handle.slot()->asCell());
|
||||
if (JSPostgresSQLConnection::hasPendingActivity(controller->wrapped())) {
|
||||
if (UNLIKELY(reason))
|
||||
*reason = "has pending activity";
|
||||
return true;
|
||||
}
|
||||
|
||||
return visitor.containsOpaqueRoot(context);
|
||||
}
|
||||
void finalize(JSC::Handle<JSC::Unknown>, void* context) final {}
|
||||
};
|
||||
|
||||
static JSC::WeakHandleOwner* getOwner()
|
||||
{
|
||||
static NeverDestroyed<Owner> m_owner;
|
||||
return &m_owner.get();
|
||||
}
|
||||
|
||||
DECLARE_VISIT_CHILDREN;
|
||||
template<typename Visitor> void visitAdditionalChildren(Visitor&);
|
||||
DECLARE_VISIT_OUTPUT_CONSTRAINTS;
|
||||
};
|
||||
|
||||
class JSPostgresSQLQuery final : public JSC::JSDestructibleObject {
|
||||
public:
|
||||
using Base = JSC::JSDestructibleObject;
|
||||
static JSPostgresSQLQuery* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
|
||||
|
||||
DECLARE_EXPORT_INFO;
|
||||
template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
|
||||
{
|
||||
if constexpr (mode == JSC::SubspaceAccess::Concurrently)
|
||||
return nullptr;
|
||||
return WebCore::subspaceForImpl<JSPostgresSQLQuery, WebCore::UseCustomHeapCellType::No>(
|
||||
vm,
|
||||
[](auto& spaces) { return spaces.m_clientSubspaceForPostgresSQLQuery.get(); },
|
||||
[](auto& spaces, auto&& space) { spaces.m_clientSubspaceForPostgresSQLQuery = std::forward<decltype(space)>(space); },
|
||||
[](auto& spaces) { return spaces.m_subspaceForPostgresSQLQuery.get(); },
|
||||
[](auto& spaces, auto&& space) { spaces.m_subspaceForPostgresSQLQuery = std::forward<decltype(space)>(space); });
|
||||
}
|
||||
|
||||
static void destroy(JSC::JSCell*);
|
||||
static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
|
||||
{
|
||||
return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
|
||||
}
|
||||
|
||||
static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
|
||||
static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
|
||||
|
||||
~JSPostgresSQLQuery();
|
||||
|
||||
void* wrapped() const { return m_ctx; }
|
||||
|
||||
void detach()
|
||||
{
|
||||
m_ctx = nullptr;
|
||||
}
|
||||
|
||||
static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
|
||||
static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSPostgresSQLQuery, m_ctx); }
|
||||
|
||||
void* m_ctx { nullptr };
|
||||
|
||||
JSPostgresSQLQuery(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
|
||||
: Base(vm, structure)
|
||||
{
|
||||
m_ctx = sinkPtr;
|
||||
m_weakThis = JSC::Weak<JSPostgresSQLQuery>(this, getOwner());
|
||||
}
|
||||
|
||||
void finishCreation(JSC::VM&);
|
||||
|
||||
JSC::Weak<JSPostgresSQLQuery> m_weakThis;
|
||||
|
||||
static bool hasPendingActivity(void* ctx);
|
||||
|
||||
class Owner final : public JSC::WeakHandleOwner {
|
||||
public:
|
||||
bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void* context, JSC::AbstractSlotVisitor& visitor, const char** reason) final
|
||||
{
|
||||
auto* controller = JSC::jsCast<JSPostgresSQLQuery*>(handle.slot()->asCell());
|
||||
if (JSPostgresSQLQuery::hasPendingActivity(controller->wrapped())) {
|
||||
if (UNLIKELY(reason))
|
||||
*reason = "has pending activity";
|
||||
return true;
|
||||
}
|
||||
|
||||
return visitor.containsOpaqueRoot(context);
|
||||
}
|
||||
void finalize(JSC::Handle<JSC::Unknown>, void* context) final {}
|
||||
};
|
||||
|
||||
static JSC::WeakHandleOwner* getOwner()
|
||||
{
|
||||
static NeverDestroyed<Owner> m_owner;
|
||||
return &m_owner.get();
|
||||
}
|
||||
|
||||
DECLARE_VISIT_CHILDREN;
|
||||
template<typename Visitor> void visitAdditionalChildren(Visitor&);
|
||||
DECLARE_VISIT_OUTPUT_CONSTRAINTS;
|
||||
|
||||
mutable JSC::WriteBarrier<JSC::Unknown> m_pendingValue;
|
||||
mutable JSC::WriteBarrier<JSC::Unknown> m_binding;
|
||||
};
|
||||
|
||||
class JSRequest final : public JSC::JSDestructibleObject {
|
||||
public:
|
||||
using Base = JSC::JSDestructibleObject;
|
||||
|
||||
@@ -107,7 +107,7 @@
|
||||
#include "JavaScriptCore/FunctionPrototype.h"
|
||||
#include "JavaScriptCore/GetterSetter.h"
|
||||
#include "napi.h"
|
||||
#include "JSSQLStatement.h"
|
||||
#include "JSSQLiteStatement.h"
|
||||
#include "ModuleLoader.h"
|
||||
#include "NodeVMScript.h"
|
||||
#include "ProcessIdentifier.h"
|
||||
@@ -1635,6 +1635,10 @@ JSC_DEFINE_HOST_FUNCTION(jsReceiveMessageOnPort, (JSGlobalObject * lexicalGlobal
|
||||
return JSC::JSValue::encode(jsUndefined());
|
||||
}
|
||||
|
||||
extern "C" JSC::EncodedJSValue PostgresSQLQuery__createInstance(JSC::JSGlobalObject*, JSC::CallFrame*);
|
||||
extern "C" JSC::EncodedJSValue PostgresSQLConnection__createInstance(JSC::JSGlobalObject*, JSC::CallFrame*);
|
||||
extern "C" JSC::EncodedJSValue PostgresSQLContext__init(JSC::JSGlobalObject*, JSC::CallFrame*);
|
||||
|
||||
// we're trying out a new way to do this lazy loading
|
||||
// this is $lazy() in js code
|
||||
JSC_DEFINE_HOST_FUNCTION(functionLazyLoad,
|
||||
@@ -1688,7 +1692,7 @@ JSC_DEFINE_HOST_FUNCTION(functionLazyLoad,
|
||||
}
|
||||
|
||||
if (string == "sqlite"_s) {
|
||||
return JSC::JSValue::encode(JSSQLStatementConstructor::create(vm, globalObject, JSSQLStatementConstructor::createStructure(vm, globalObject, globalObject->m_functionPrototype.get())));
|
||||
return JSC::JSValue::encode(JSSQLiteStatementConstructor::create(vm, globalObject, JSSQLiteStatementConstructor::createStructure(vm, globalObject, globalObject->m_functionPrototype.get())));
|
||||
}
|
||||
|
||||
if (string == "http"_s) {
|
||||
@@ -1869,6 +1873,28 @@ JSC_DEFINE_HOST_FUNCTION(functionLazyLoad,
|
||||
return JSValue::encode(obj);
|
||||
}
|
||||
|
||||
if (string == "bun:sql"_s) {
|
||||
auto* obj = constructEmptyObject(globalObject);
|
||||
|
||||
obj->putDirect(
|
||||
vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "createQuery"_s)),
|
||||
JSC::JSFunction::create(vm, globalObject, 0, "createQuery"_s, PostgresSQLQuery__createInstance, ImplementationVisibility::Public), 0);
|
||||
|
||||
obj->putDirect(
|
||||
vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "createConnection"_s)),
|
||||
JSC::JSFunction::create(vm, globalObject, 0, "createConnection"_s, PostgresSQLConnection__createInstance, ImplementationVisibility::Public), 0);
|
||||
|
||||
obj->putDirect(
|
||||
vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "init"_s)),
|
||||
JSC::JSFunction::create(vm, globalObject, 0, "init"_s, PostgresSQLContext__init, ImplementationVisibility::Public), 0);
|
||||
|
||||
obj->putDirect(
|
||||
vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "PostgresSQLConnection"_s)),
|
||||
globalObject->JSPostgresSQLConnectionConstructor(), 0);
|
||||
|
||||
return JSC::JSValue::encode(obj);
|
||||
}
|
||||
|
||||
if (UNLIKELY(string == "noop"_s)) {
|
||||
auto* obj = constructEmptyObject(globalObject);
|
||||
obj->putDirectCustomAccessor(vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "getterSetter"_s)), JSC::CustomGetterSetter::create(vm, noop_getter, noop_setter), 0);
|
||||
@@ -2486,7 +2512,11 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionPerformMicrotask, (JSGlobalObject * globalObj
|
||||
auto& vm = globalObject->vm();
|
||||
auto scope = DECLARE_CATCH_SCOPE(vm);
|
||||
|
||||
auto job = callframe->argument(0);
|
||||
JSValue job = callframe->argument(0);
|
||||
JSValue setAsyncContext = callframe->argument(1);
|
||||
JSValue arg1 = callframe->argument(2);
|
||||
JSValue arg2 = callframe->argument(3);
|
||||
|
||||
if (UNLIKELY(!job || job.isUndefinedOrNull())) {
|
||||
return JSValue::encode(jsUndefined());
|
||||
}
|
||||
@@ -2503,26 +2533,22 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionPerformMicrotask, (JSGlobalObject * globalObj
|
||||
|
||||
JSValue restoreAsyncContext = {};
|
||||
InternalFieldTuple* asyncContextData = nullptr;
|
||||
auto setAsyncContext = callframe->argument(1);
|
||||
if (!setAsyncContext.isUndefined()) {
|
||||
|
||||
if (setAsyncContext && !setAsyncContext.isUndefined()) {
|
||||
asyncContextData = globalObject->m_asyncContextData.get();
|
||||
restoreAsyncContext = asyncContextData->getInternalField(0);
|
||||
asyncContextData->putInternalField(vm, 0, setAsyncContext);
|
||||
}
|
||||
|
||||
size_t argCount = callframe->argumentCount();
|
||||
switch (argCount) {
|
||||
case 3: {
|
||||
arguments.append(callframe->uncheckedArgument(2));
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
arguments.append(callframe->uncheckedArgument(2));
|
||||
arguments.append(callframe->uncheckedArgument(3));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
|
||||
if (argCount > 2) {
|
||||
if (arg1) {
|
||||
arguments.append(arg1);
|
||||
if (arg2) {
|
||||
arguments.append(arg2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JSC::call(globalObject, job, callData, jsUndefined(), arguments, exceptionPtr);
|
||||
|
||||
@@ -97,6 +97,7 @@
|
||||
|
||||
#include "AsyncContextFrame.h"
|
||||
#include "JavaScriptCore/InternalFieldTuple.h"
|
||||
#include "JavaScriptCore/JSDateMath.h"
|
||||
|
||||
template<typename UWSResponse>
|
||||
static void copyToUWS(WebCore::FetchHeaders* headers, UWSResponse* res)
|
||||
@@ -3988,7 +3989,6 @@ void JSC__Exception__getStackTrace(JSC__Exception* arg0, ZigStackTrace* trace)
|
||||
JSC__JSValue JSC__VM__runGC(JSC__VM* vm, bool sync)
|
||||
{
|
||||
JSC::JSLockHolder lock(vm);
|
||||
|
||||
vm->finalizeSynchronousJSExecution();
|
||||
WTF::releaseFastMallocFreeMemory();
|
||||
|
||||
@@ -4561,14 +4561,20 @@ extern "C" size_t JSC__VM__externalMemorySize(JSC__VM* vm)
|
||||
|
||||
extern "C" void JSC__JSGlobalObject__queueMicrotaskJob(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1, JSC__JSValue JSValue3, JSC__JSValue JSValue4)
|
||||
{
|
||||
JSC::JSValue arg1 = JSC::JSValue::decode(JSValue1);
|
||||
JSC::JSValue arg3 = JSC::JSValue::decode(JSValue3);
|
||||
JSC::JSValue arg4 = JSC::JSValue::decode(JSValue4);
|
||||
|
||||
Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(arg0);
|
||||
JSC::VM& vm = globalObject->vm();
|
||||
StringBuilder builder;
|
||||
|
||||
globalObject->queueMicrotask(
|
||||
JSValue(globalObject->performMicrotaskFunction()),
|
||||
JSC::JSValue::decode(JSValue1),
|
||||
arg1,
|
||||
globalObject->m_asyncContextData.get()->getInternalField(0),
|
||||
JSC::JSValue::decode(JSValue3),
|
||||
JSC::JSValue::decode(JSValue4));
|
||||
arg3,
|
||||
arg4);
|
||||
}
|
||||
|
||||
extern "C" WebCore::AbortSignal* WebCore__AbortSignal__new(JSC__JSGlobalObject* globalObject)
|
||||
@@ -4711,6 +4717,57 @@ CPP_DECL double JSC__JSValue__getUnixTimestamp(JSC__JSValue timeValue)
|
||||
return date->internalNumber();
|
||||
}
|
||||
|
||||
extern "C" double Bun__parseDate(JSC::JSGlobalObject* globalObject, BunString* str)
|
||||
{
|
||||
auto& vm = globalObject->vm();
|
||||
return vm.dateCache.parseDate(globalObject, vm, Bun::toWTFString(*str));
|
||||
}
|
||||
|
||||
extern "C" EncodedJSValue JSC__JSValue__dateInstanceFromNullTerminatedString(JSC::JSGlobalObject* globalObject, const char* nullTerminatedChars)
|
||||
{
|
||||
double dateSeconds = WTF::parseDateFromNullTerminatedCharacters(nullTerminatedChars);
|
||||
JSC::DateInstance* date = JSC::DateInstance::create(globalObject->vm(), globalObject->dateStructure(), dateSeconds);
|
||||
|
||||
return JSValue::encode(date);
|
||||
}
|
||||
|
||||
// this is largely copied from dateProtoFuncToISOString
|
||||
extern "C" int JSC__JSValue__toISOString(JSC::JSGlobalObject* globalObject, EncodedJSValue dateValue, char* buf)
|
||||
{
|
||||
char buffer[28];
|
||||
JSC::DateInstance* thisDateObj = JSC::jsDynamicCast<JSC::DateInstance*>(JSC::JSValue::decode(dateValue));
|
||||
if (!thisDateObj)
|
||||
return -1;
|
||||
|
||||
if (!std::isfinite(thisDateObj->internalNumber()))
|
||||
return -1;
|
||||
|
||||
auto& vm = globalObject->vm();
|
||||
|
||||
const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTimeUTC(vm.dateCache);
|
||||
if (!gregorianDateTime)
|
||||
return -1;
|
||||
|
||||
// If the year is outside the bounds of 0 and 9999 inclusive we want to use the extended year format (ES 15.9.1.15.1).
|
||||
int ms = static_cast<int>(fmod(thisDateObj->internalNumber(), msPerSecond));
|
||||
if (ms < 0)
|
||||
ms += msPerSecond;
|
||||
|
||||
int charactersWritten;
|
||||
if (gregorianDateTime->year() > 9999 || gregorianDateTime->year() < 0)
|
||||
charactersWritten = snprintf(buffer, sizeof(buffer), "%+07d-%02d-%02dT%02d:%02d:%02d.%03dZ", gregorianDateTime->year(), gregorianDateTime->month() + 1, gregorianDateTime->monthDay(), gregorianDateTime->hour(), gregorianDateTime->minute(), gregorianDateTime->second(), ms);
|
||||
else
|
||||
charactersWritten = snprintf(buffer, sizeof(buffer), "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ", gregorianDateTime->year(), gregorianDateTime->month() + 1, gregorianDateTime->monthDay(), gregorianDateTime->hour(), gregorianDateTime->minute(), gregorianDateTime->second(), ms);
|
||||
|
||||
memcpy(buf, buffer, charactersWritten);
|
||||
|
||||
ASSERT(charactersWritten > 0 && static_cast<unsigned>(charactersWritten) < sizeof(buffer));
|
||||
if (static_cast<unsigned>(charactersWritten) >= sizeof(buffer))
|
||||
return -1;
|
||||
|
||||
return charactersWritten;
|
||||
}
|
||||
|
||||
#pragma mark - WebCore::DOMFormData
|
||||
|
||||
CPP_DECL void WebCore__DOMFormData__append(WebCore__DOMFormData* arg0, ZigString* arg1, ZigString* arg2)
|
||||
|
||||
@@ -45,6 +45,25 @@ pub const JSObject = extern struct {
|
||||
});
|
||||
}
|
||||
|
||||
extern fn JSC__createStructure(*JSC.JSGlobalObject, *JSC.JSCell, u32, names: [*]bun.String) JSC.JSValue;
|
||||
extern fn JSC__createEmptyObjectWithStructure(*JSC.JSGlobalObject, *anyopaque) JSC.JSValue;
|
||||
extern fn JSC__putDirectOffset(*JSC.VM, JSC.JSValue, offset: u32, JSC.JSValue) void;
|
||||
|
||||
pub fn createStructure(global: *JSGlobalObject, owner: JSC.JSValue, length: u32, names: [*]bun.String) JSValue {
|
||||
JSC.markBinding(@src());
|
||||
return JSC__createStructure(global, owner.asCell(), length, names);
|
||||
}
|
||||
|
||||
pub fn uninitialized(global: *JSGlobalObject, structure: JSC.JSValue) JSValue {
|
||||
JSC.markBinding(@src());
|
||||
return JSC__createEmptyObjectWithStructure(global, structure.asCell());
|
||||
}
|
||||
|
||||
pub fn putDirectOffset(this: JSValue, vm: *VM, offset: u32, value: JSValue) void {
|
||||
JSC.markBinding(@src());
|
||||
return JSC__putDirectOffset(vm, this, offset, value);
|
||||
}
|
||||
|
||||
pub fn Initializer(comptime Ctx: type, comptime func: fn (*Ctx, obj: *JSObject, global: *JSGlobalObject) void) type {
|
||||
return struct {
|
||||
pub fn call(this: ?*anyopaque, obj: [*c]JSObject, global: [*c]JSGlobalObject) callconv(.C) void {
|
||||
@@ -2774,7 +2793,7 @@ pub const JSGlobalObject = extern struct {
|
||||
pub fn queueMicrotask(
|
||||
this: *JSGlobalObject,
|
||||
function: JSValue,
|
||||
args: []JSC.JSValue,
|
||||
args: []const JSC.JSValue,
|
||||
) void {
|
||||
this.queueMicrotaskJob(
|
||||
function,
|
||||
@@ -3557,6 +3576,16 @@ pub const JSValue = enum(JSValueReprInt) {
|
||||
cppFn("push", .{ value, globalObject, out });
|
||||
}
|
||||
|
||||
extern fn JSC__JSValue__toISOString(*JSC.JSGlobalObject, JSC.JSValue, *[28]u8) c_int;
|
||||
pub fn toISOString(this: JSValue, globalObject: *JSC.JSGlobalObject, buf: *[28]u8) []const u8 {
|
||||
const count = JSC__JSValue__toISOString(globalObject, this, buf);
|
||||
if (count < 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return buf[0..@as(usize, @intCast(count))];
|
||||
}
|
||||
|
||||
pub fn as(value: JSValue, comptime ZigType: type) ?*ZigType {
|
||||
if (value.isEmptyOrUndefinedOrNull())
|
||||
return null;
|
||||
@@ -3588,6 +3617,12 @@ pub const JSValue = enum(JSValueReprInt) {
|
||||
return JSC.GetJSPrivateData(ZigType, value.asObjectRef());
|
||||
}
|
||||
|
||||
extern fn JSC__JSValue__dateInstanceFromNullTerminatedString(*JSGlobalObject, [*:0]const u8) JSValue;
|
||||
pub fn fromDateString(globalObject: *JSGlobalObject, str: [*:0]const u8) JSValue {
|
||||
JSC.markBinding(@src());
|
||||
return JSC__JSValue__dateInstanceFromNullTerminatedString(globalObject, str);
|
||||
}
|
||||
|
||||
extern fn JSBuffer__isBuffer(*JSGlobalObject, JSValue) bool;
|
||||
pub fn isBuffer(value: JSValue, global: *JSGlobalObject) bool {
|
||||
JSC.markBinding(@src());
|
||||
@@ -5068,6 +5103,13 @@ pub const VM = extern struct {
|
||||
cppFn("holdAPILock", .{ this, ctx, callback });
|
||||
}
|
||||
|
||||
extern fn JSC__runInDeferralContext(this: *VM, ctx: ?*anyopaque, callback: *const fn (ctx: ?*anyopaque) callconv(.C) void) void;
|
||||
|
||||
pub fn runInDeferralContext(this: *VM, ctx: ?*anyopaque, callback: *const fn (ctx: ?*anyopaque) callconv(.C) void) void {
|
||||
JSC.markBinding(@src());
|
||||
JSC__runInDeferralContext(this, ctx, callback);
|
||||
}
|
||||
|
||||
pub fn deferGC(this: *VM, ctx: ?*anyopaque, callback: *const fn (ctx: ?*anyopaque) callconv(.C) void) void {
|
||||
cppFn("deferGC", .{ this, ctx, callback });
|
||||
}
|
||||
@@ -5339,14 +5381,15 @@ pub const CallFrame = opaque {
|
||||
var ptr = self.argumentsPtr();
|
||||
return switch (@as(u4, @min(len, max))) {
|
||||
0 => .{ .ptr = undefined, .len = 0 },
|
||||
4 => Arguments(max).init(comptime @min(4, max), ptr),
|
||||
2 => Arguments(max).init(comptime @min(2, max), ptr),
|
||||
6 => Arguments(max).init(comptime @min(6, max), ptr),
|
||||
3 => Arguments(max).init(comptime @min(3, max), ptr),
|
||||
8 => Arguments(max).init(comptime @min(8, max), ptr),
|
||||
5 => Arguments(max).init(comptime @min(5, max), ptr),
|
||||
1 => Arguments(max).init(comptime @min(1, max), ptr),
|
||||
2 => Arguments(max).init(comptime @min(2, max), ptr),
|
||||
3 => Arguments(max).init(comptime @min(3, max), ptr),
|
||||
4 => Arguments(max).init(comptime @min(4, max), ptr),
|
||||
5 => Arguments(max).init(comptime @min(5, max), ptr),
|
||||
6 => Arguments(max).init(comptime @min(6, max), ptr),
|
||||
7 => Arguments(max).init(comptime @min(7, max), ptr),
|
||||
8 => Arguments(max).init(comptime @min(8, max), ptr),
|
||||
9 => Arguments(max).init(comptime @min(9, max), ptr),
|
||||
else => unreachable,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -4428,6 +4428,221 @@ pub const JSNodeJSFS = struct {
|
||||
}
|
||||
}
|
||||
};
|
||||
pub const JSPostgresSQLConnection = struct {
|
||||
const PostgresSQLConnection = Classes.PostgresSQLConnection;
|
||||
const GetterType = fn (*PostgresSQLConnection, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
|
||||
const GetterTypeWithThisValue = fn (*PostgresSQLConnection, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
|
||||
const SetterType = fn (*PostgresSQLConnection, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
|
||||
const SetterTypeWithThisValue = fn (*PostgresSQLConnection, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
|
||||
const CallbackType = fn (*PostgresSQLConnection, *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) ?*PostgresSQLConnection {
|
||||
JSC.markBinding(@src());
|
||||
return PostgresSQLConnection__fromJS(value);
|
||||
}
|
||||
|
||||
/// Get the PostgresSQLConnection constructor value.
|
||||
/// This loads lazily from the global object.
|
||||
pub fn getConstructor(globalObject: *JSC.JSGlobalObject) JSC.JSValue {
|
||||
JSC.markBinding(@src());
|
||||
return PostgresSQLConnection__getConstructor(globalObject);
|
||||
}
|
||||
|
||||
/// Create a new instance of PostgresSQLConnection
|
||||
pub fn toJS(this: *PostgresSQLConnection, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
|
||||
JSC.markBinding(@src());
|
||||
if (comptime Environment.allow_assert) {
|
||||
const value__ = PostgresSQLConnection__create(globalObject, this);
|
||||
std.debug.assert(value__.as(PostgresSQLConnection).? == this); // If this fails, likely a C ABI issue.
|
||||
return value__;
|
||||
} else {
|
||||
return PostgresSQLConnection__create(globalObject, this);
|
||||
}
|
||||
}
|
||||
|
||||
/// Modify the internal ptr to point to a new instance of PostgresSQLConnection.
|
||||
pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*PostgresSQLConnection) bool {
|
||||
JSC.markBinding(@src());
|
||||
return PostgresSQLConnection__dangerouslySetPtr(value, ptr);
|
||||
}
|
||||
|
||||
/// Detach the ptr from the thisValue
|
||||
pub fn detachPtr(_: *PostgresSQLConnection, value: JSC.JSValue) void {
|
||||
JSC.markBinding(@src());
|
||||
std.debug.assert(PostgresSQLConnection__dangerouslySetPtr(value, null));
|
||||
}
|
||||
|
||||
extern fn PostgresSQLConnection__fromJS(JSC.JSValue) ?*PostgresSQLConnection;
|
||||
extern fn PostgresSQLConnection__getConstructor(*JSC.JSGlobalObject) JSC.JSValue;
|
||||
|
||||
extern fn PostgresSQLConnection__create(globalObject: *JSC.JSGlobalObject, ptr: ?*PostgresSQLConnection) JSC.JSValue;
|
||||
|
||||
extern fn PostgresSQLConnection__dangerouslySetPtr(JSC.JSValue, ?*PostgresSQLConnection) bool;
|
||||
|
||||
comptime {
|
||||
if (@TypeOf(PostgresSQLConnection.constructor) != (fn (*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*PostgresSQLConnection)) {
|
||||
@compileLog("PostgresSQLConnection.constructor is not a constructor");
|
||||
}
|
||||
|
||||
if (@TypeOf(PostgresSQLConnection.finalize) != (fn (*PostgresSQLConnection) callconv(.C) void)) {
|
||||
@compileLog("PostgresSQLConnection.finalize is not a finalizer");
|
||||
}
|
||||
|
||||
if (@TypeOf(PostgresSQLConnection.doClose) != CallbackType)
|
||||
@compileLog("Expected PostgresSQLConnection.doClose to be a callback but received " ++ @typeName(@TypeOf(PostgresSQLConnection.doClose)));
|
||||
if (@TypeOf(PostgresSQLConnection.getConnected) != GetterType)
|
||||
@compileLog("Expected PostgresSQLConnection.getConnected to be a getter");
|
||||
|
||||
if (@TypeOf(PostgresSQLConnection.doFlush) != CallbackType)
|
||||
@compileLog("Expected PostgresSQLConnection.doFlush to be a callback but received " ++ @typeName(@TypeOf(PostgresSQLConnection.doFlush)));
|
||||
if (@TypeOf(PostgresSQLConnection.createQuery) != CallbackType)
|
||||
@compileLog("Expected PostgresSQLConnection.createQuery to be a callback but received " ++ @typeName(@TypeOf(PostgresSQLConnection.createQuery)));
|
||||
if (@TypeOf(PostgresSQLConnection.doRef) != CallbackType)
|
||||
@compileLog("Expected PostgresSQLConnection.doRef to be a callback but received " ++ @typeName(@TypeOf(PostgresSQLConnection.doRef)));
|
||||
if (@TypeOf(PostgresSQLConnection.doUnref) != CallbackType)
|
||||
@compileLog("Expected PostgresSQLConnection.doUnref to be a callback but received " ++ @typeName(@TypeOf(PostgresSQLConnection.doUnref)));
|
||||
if (!JSC.is_bindgen) {
|
||||
@export(PostgresSQLConnection.constructor, .{ .name = "PostgresSQLConnectionClass__construct" });
|
||||
@export(PostgresSQLConnection.createQuery, .{ .name = "PostgresSQLConnectionPrototype__createQuery" });
|
||||
@export(PostgresSQLConnection.doClose, .{ .name = "PostgresSQLConnectionPrototype__doClose" });
|
||||
@export(PostgresSQLConnection.doFlush, .{ .name = "PostgresSQLConnectionPrototype__doFlush" });
|
||||
@export(PostgresSQLConnection.doRef, .{ .name = "PostgresSQLConnectionPrototype__doRef" });
|
||||
@export(PostgresSQLConnection.doUnref, .{ .name = "PostgresSQLConnectionPrototype__doUnref" });
|
||||
@export(PostgresSQLConnection.finalize, .{ .name = "PostgresSQLConnectionClass__finalize" });
|
||||
@export(PostgresSQLConnection.getConnected, .{ .name = "PostgresSQLConnectionPrototype__getConnected" });
|
||||
@export(PostgresSQLConnection.hasPendingActivity, .{ .name = "PostgresSQLConnection__hasPendingActivity" });
|
||||
}
|
||||
}
|
||||
};
|
||||
pub const JSPostgresSQLQuery = struct {
|
||||
const PostgresSQLQuery = Classes.PostgresSQLQuery;
|
||||
const GetterType = fn (*PostgresSQLQuery, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
|
||||
const GetterTypeWithThisValue = fn (*PostgresSQLQuery, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
|
||||
const SetterType = fn (*PostgresSQLQuery, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
|
||||
const SetterTypeWithThisValue = fn (*PostgresSQLQuery, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
|
||||
const CallbackType = fn (*PostgresSQLQuery, *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) ?*PostgresSQLQuery {
|
||||
JSC.markBinding(@src());
|
||||
return PostgresSQLQuery__fromJS(value);
|
||||
}
|
||||
|
||||
extern fn PostgresSQLQueryPrototype__pendingValueSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
|
||||
|
||||
extern fn PostgresSQLQueryPrototype__pendingValueGetCachedValue(JSC.JSValue) JSC.JSValue;
|
||||
|
||||
/// `PostgresSQLQuery.pendingValue` setter
|
||||
/// This value will be visited by the garbage collector.
|
||||
pub fn pendingValueSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
|
||||
JSC.markBinding(@src());
|
||||
PostgresSQLQueryPrototype__pendingValueSetCachedValue(thisValue, globalObject, value);
|
||||
}
|
||||
|
||||
/// `PostgresSQLQuery.pendingValue` getter
|
||||
/// This value will be visited by the garbage collector.
|
||||
pub fn pendingValueGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
|
||||
JSC.markBinding(@src());
|
||||
const result = PostgresSQLQueryPrototype__pendingValueGetCachedValue(thisValue);
|
||||
if (result == .zero)
|
||||
return null;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
extern fn PostgresSQLQueryPrototype__bindingSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
|
||||
|
||||
extern fn PostgresSQLQueryPrototype__bindingGetCachedValue(JSC.JSValue) JSC.JSValue;
|
||||
|
||||
/// `PostgresSQLQuery.binding` setter
|
||||
/// This value will be visited by the garbage collector.
|
||||
pub fn bindingSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
|
||||
JSC.markBinding(@src());
|
||||
PostgresSQLQueryPrototype__bindingSetCachedValue(thisValue, globalObject, value);
|
||||
}
|
||||
|
||||
/// `PostgresSQLQuery.binding` getter
|
||||
/// This value will be visited by the garbage collector.
|
||||
pub fn bindingGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
|
||||
JSC.markBinding(@src());
|
||||
const result = PostgresSQLQueryPrototype__bindingGetCachedValue(thisValue);
|
||||
if (result == .zero)
|
||||
return null;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// Get the PostgresSQLQuery constructor value.
|
||||
/// This loads lazily from the global object.
|
||||
pub fn getConstructor(globalObject: *JSC.JSGlobalObject) JSC.JSValue {
|
||||
JSC.markBinding(@src());
|
||||
return PostgresSQLQuery__getConstructor(globalObject);
|
||||
}
|
||||
|
||||
/// Create a new instance of PostgresSQLQuery
|
||||
pub fn toJS(this: *PostgresSQLQuery, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
|
||||
JSC.markBinding(@src());
|
||||
if (comptime Environment.allow_assert) {
|
||||
const value__ = PostgresSQLQuery__create(globalObject, this);
|
||||
std.debug.assert(value__.as(PostgresSQLQuery).? == this); // If this fails, likely a C ABI issue.
|
||||
return value__;
|
||||
} else {
|
||||
return PostgresSQLQuery__create(globalObject, this);
|
||||
}
|
||||
}
|
||||
|
||||
/// Modify the internal ptr to point to a new instance of PostgresSQLQuery.
|
||||
pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*PostgresSQLQuery) bool {
|
||||
JSC.markBinding(@src());
|
||||
return PostgresSQLQuery__dangerouslySetPtr(value, ptr);
|
||||
}
|
||||
|
||||
/// Detach the ptr from the thisValue
|
||||
pub fn detachPtr(_: *PostgresSQLQuery, value: JSC.JSValue) void {
|
||||
JSC.markBinding(@src());
|
||||
std.debug.assert(PostgresSQLQuery__dangerouslySetPtr(value, null));
|
||||
}
|
||||
|
||||
extern fn PostgresSQLQuery__fromJS(JSC.JSValue) ?*PostgresSQLQuery;
|
||||
extern fn PostgresSQLQuery__getConstructor(*JSC.JSGlobalObject) JSC.JSValue;
|
||||
|
||||
extern fn PostgresSQLQuery__create(globalObject: *JSC.JSGlobalObject, ptr: ?*PostgresSQLQuery) JSC.JSValue;
|
||||
|
||||
extern fn PostgresSQLQuery__dangerouslySetPtr(JSC.JSValue, ?*PostgresSQLQuery) bool;
|
||||
|
||||
comptime {
|
||||
if (@TypeOf(PostgresSQLQuery.estimatedSize) != (fn (*PostgresSQLQuery) callconv(.C) usize)) {
|
||||
@compileLog("PostgresSQLQuery.estimatedSize is not a size function");
|
||||
}
|
||||
|
||||
if (@TypeOf(PostgresSQLQuery.constructor) != (fn (*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*PostgresSQLQuery)) {
|
||||
@compileLog("PostgresSQLQuery.constructor is not a constructor");
|
||||
}
|
||||
|
||||
if (@TypeOf(PostgresSQLQuery.finalize) != (fn (*PostgresSQLQuery) callconv(.C) void)) {
|
||||
@compileLog("PostgresSQLQuery.finalize is not a finalizer");
|
||||
}
|
||||
|
||||
if (@TypeOf(PostgresSQLQuery.doCancel) != CallbackType)
|
||||
@compileLog("Expected PostgresSQLQuery.doCancel to be a callback but received " ++ @typeName(@TypeOf(PostgresSQLQuery.doCancel)));
|
||||
if (@TypeOf(PostgresSQLQuery.doDone) != CallbackType)
|
||||
@compileLog("Expected PostgresSQLQuery.doDone to be a callback but received " ++ @typeName(@TypeOf(PostgresSQLQuery.doDone)));
|
||||
if (@TypeOf(PostgresSQLQuery.doRun) != CallbackType)
|
||||
@compileLog("Expected PostgresSQLQuery.doRun to be a callback but received " ++ @typeName(@TypeOf(PostgresSQLQuery.doRun)));
|
||||
if (!JSC.is_bindgen) {
|
||||
@export(PostgresSQLQuery.constructor, .{ .name = "PostgresSQLQueryClass__construct" });
|
||||
@export(PostgresSQLQuery.doCancel, .{ .name = "PostgresSQLQueryPrototype__doCancel" });
|
||||
@export(PostgresSQLQuery.doDone, .{ .name = "PostgresSQLQueryPrototype__doDone" });
|
||||
@export(PostgresSQLQuery.doRun, .{ .name = "PostgresSQLQueryPrototype__doRun" });
|
||||
@export(PostgresSQLQuery.estimatedSize, .{ .name = "PostgresSQLQuery__estimatedSize" });
|
||||
@export(PostgresSQLQuery.finalize, .{ .name = "PostgresSQLQueryClass__finalize" });
|
||||
@export(PostgresSQLQuery.hasPendingActivity, .{ .name = "PostgresSQLQuery__hasPendingActivity" });
|
||||
}
|
||||
}
|
||||
};
|
||||
pub const JSRequest = struct {
|
||||
const Request = Classes.Request;
|
||||
const GetterType = fn (*Request, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
|
||||
@@ -7224,6 +7439,8 @@ comptime {
|
||||
_ = JSMD5;
|
||||
_ = JSMatchedRoute;
|
||||
_ = JSNodeJSFS;
|
||||
_ = JSPostgresSQLConnection;
|
||||
_ = JSPostgresSQLQuery;
|
||||
_ = JSRequest;
|
||||
_ = JSResolveMessage;
|
||||
_ = JSResponse;
|
||||
|
||||
@@ -55,4 +55,6 @@ pub const Classes = struct {
|
||||
pub const DebugHTTPSServer = JSC.API.DebugHTTPSServer;
|
||||
pub const Crypto = JSC.WebCore.Crypto;
|
||||
pub const FFI = JSC.FFI;
|
||||
pub const PostgresSQLConnection = JSC.Postgres.PostgresSQLConnection;
|
||||
pub const PostgresSQLQuery = JSC.Postgres.PostgresSQLQuery;
|
||||
};
|
||||
|
||||
@@ -36,6 +36,7 @@ static constexpr ASCIILiteral builtinModuleNamesSortedLength[] = {
|
||||
"cluster"_s,
|
||||
"console"_s,
|
||||
"process"_s,
|
||||
"bun:sql"_s,
|
||||
"bun:wrap"_s,
|
||||
"punycode"_s,
|
||||
"bun:test"_s,
|
||||
@@ -83,16 +84,17 @@ static constexpr ASCIILiteral builtinModuleNamesSortedLength[] = {
|
||||
|
||||
namespace Bun {
|
||||
|
||||
bool isBuiltinModule(const String &namePossiblyWithNodePrefix) {
|
||||
String name = namePossiblyWithNodePrefix;
|
||||
if (name.startsWith("node:"_s))
|
||||
name = name.substringSharingImpl(5);
|
||||
bool isBuiltinModule(const String& namePossiblyWithNodePrefix)
|
||||
{
|
||||
String name = namePossiblyWithNodePrefix;
|
||||
if (name.startsWith("node:"_s))
|
||||
name = name.substringSharingImpl(5);
|
||||
|
||||
for (auto &builtinModule : builtinModuleNamesSortedLength) {
|
||||
if (name == builtinModule)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
for (auto& builtinModule : builtinModuleNamesSortedLength) {
|
||||
if (name == builtinModule)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace Bun
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "root.h"
|
||||
|
||||
#include "JSSQLStatement.h"
|
||||
#include "JSSQLiteStatement.h"
|
||||
#include "JavaScriptCore/JSObjectInlines.h"
|
||||
#include "wtf/text/ExternalStringImpl.h"
|
||||
|
||||
@@ -159,24 +159,24 @@ extern "C" void Bun__closeAllSQLiteDatabasesForTermination()
|
||||
namespace WebCore {
|
||||
using namespace JSC;
|
||||
|
||||
class JSSQLStatement : public JSC::JSNonFinalObject {
|
||||
class JSSQLiteStatement : public JSC::JSNonFinalObject {
|
||||
public:
|
||||
using Base = JSC::JSNonFinalObject;
|
||||
static JSSQLStatement* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, sqlite3_stmt* stmt, VersionSqlite3* version_db)
|
||||
static JSSQLiteStatement* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, sqlite3_stmt* stmt, VersionSqlite3* version_db)
|
||||
{
|
||||
JSSQLStatement* ptr = new (NotNull, JSC::allocateCell<JSSQLStatement>(globalObject->vm())) JSSQLStatement(structure, *globalObject, stmt, version_db);
|
||||
JSSQLiteStatement* ptr = new (NotNull, JSC::allocateCell<JSSQLiteStatement>(globalObject->vm())) JSSQLiteStatement(structure, *globalObject, stmt, version_db);
|
||||
ptr->finishCreation(globalObject->vm());
|
||||
return ptr;
|
||||
}
|
||||
static void destroy(JSC::JSCell*);
|
||||
template<typename, SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
|
||||
{
|
||||
return WebCore::subspaceForImpl<JSSQLStatement, UseCustomHeapCellType::No>(
|
||||
return WebCore::subspaceForImpl<JSSQLiteStatement, UseCustomHeapCellType::No>(
|
||||
vm,
|
||||
[](auto& spaces) { return spaces.m_clientSubspaceForJSSQLStatement.get(); },
|
||||
[](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSQLStatement = std::forward<decltype(space)>(space); },
|
||||
[](auto& spaces) { return spaces.m_subspaceForJSSQLStatement.get(); },
|
||||
[](auto& spaces, auto&& space) { spaces.m_subspaceForJSSQLStatement = std::forward<decltype(space)>(space); });
|
||||
[](auto& spaces) { return spaces.m_clientSubspaceForJSSQLiteStatement.get(); },
|
||||
[](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSQLiteStatement = std::forward<decltype(space)>(space); },
|
||||
[](auto& spaces) { return spaces.m_subspaceForJSSQLiteStatement.get(); },
|
||||
[](auto& spaces, auto&& space) { spaces.m_subspaceForJSSQLiteStatement = std::forward<decltype(space)>(space); });
|
||||
}
|
||||
DECLARE_VISIT_CHILDREN;
|
||||
DECLARE_EXPORT_INFO;
|
||||
@@ -194,7 +194,7 @@ public:
|
||||
bool need_update() { return version_db->version.load() != version; }
|
||||
void update_version() { version = version_db->version.load(); }
|
||||
|
||||
~JSSQLStatement();
|
||||
~JSSQLiteStatement();
|
||||
|
||||
sqlite3_stmt* stmt;
|
||||
VersionSqlite3* version_db;
|
||||
@@ -205,7 +205,7 @@ public:
|
||||
mutable WriteBarrier<JSC::Structure> _structure;
|
||||
|
||||
protected:
|
||||
JSSQLStatement(JSC::Structure* structure, JSDOMGlobalObject& globalObject, sqlite3_stmt* stmt, VersionSqlite3* version_db)
|
||||
JSSQLiteStatement(JSC::Structure* structure, JSDOMGlobalObject& globalObject, sqlite3_stmt* stmt, VersionSqlite3* version_db)
|
||||
: Base(globalObject.vm(), structure)
|
||||
, stmt(stmt)
|
||||
, version_db(version_db)
|
||||
@@ -218,7 +218,7 @@ protected:
|
||||
void finishCreation(JSC::VM&);
|
||||
};
|
||||
|
||||
static void initializeColumnNames(JSC::JSGlobalObject* lexicalGlobalObject, JSSQLStatement* castedThis)
|
||||
static void initializeColumnNames(JSC::JSGlobalObject* lexicalGlobalObject, JSSQLiteStatement* castedThis)
|
||||
{
|
||||
if (!castedThis->hasExecuted) {
|
||||
castedThis->hasExecuted = true;
|
||||
@@ -334,9 +334,9 @@ static void initializeColumnNames(JSC::JSGlobalObject* lexicalGlobalObject, JSSQ
|
||||
castedThis->_prototype.set(vm, castedThis, object);
|
||||
}
|
||||
|
||||
void JSSQLStatement::destroy(JSC::JSCell* cell)
|
||||
void JSSQLiteStatement::destroy(JSC::JSCell* cell)
|
||||
{
|
||||
JSSQLStatement* thisObject = static_cast<JSSQLStatement*>(cell);
|
||||
JSSQLiteStatement* thisObject = static_cast<JSSQLiteStatement*>(cell);
|
||||
sqlite3_finalize(thisObject->stmt);
|
||||
thisObject->stmt = nullptr;
|
||||
}
|
||||
@@ -495,7 +495,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementSetCustomSQLite, (JSC::JSGlobalObject * l
|
||||
auto scope = DECLARE_THROW_SCOPE(vm);
|
||||
|
||||
JSValue thisValue = callFrame->thisValue();
|
||||
JSSQLStatementConstructor* thisObject = jsDynamicCast<JSSQLStatementConstructor*>(thisValue.getObject());
|
||||
JSSQLiteStatementConstructor* thisObject = jsDynamicCast<JSSQLiteStatementConstructor*>(thisValue.getObject());
|
||||
if (UNLIKELY(!thisObject)) {
|
||||
throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Expected SQL"_s));
|
||||
return JSValue::encode(JSC::jsUndefined());
|
||||
@@ -536,7 +536,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementDeserialize, (JSC::JSGlobalObject * lexic
|
||||
auto scope = DECLARE_THROW_SCOPE(vm);
|
||||
|
||||
JSValue thisValue = callFrame->thisValue();
|
||||
JSSQLStatementConstructor* thisObject = jsDynamicCast<JSSQLStatementConstructor*>(thisValue.getObject());
|
||||
JSSQLiteStatementConstructor* thisObject = jsDynamicCast<JSSQLiteStatementConstructor*>(thisValue.getObject());
|
||||
JSC::JSArrayBufferView* array = jsDynamicCast<JSC::JSArrayBufferView*>(callFrame->argument(0));
|
||||
unsigned int flags = SQLITE_DESERIALIZE_FREEONCLOSE | SQLITE_DESERIALIZE_RESIZEABLE;
|
||||
JSC::EnsureStillAliveScope ensureAliveArray(array);
|
||||
@@ -623,7 +623,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementSerialize, (JSC::JSGlobalObject * lexical
|
||||
auto scope = DECLARE_THROW_SCOPE(vm);
|
||||
|
||||
JSValue thisValue = callFrame->thisValue();
|
||||
JSSQLStatementConstructor* thisObject = jsDynamicCast<JSSQLStatementConstructor*>(thisValue.getObject());
|
||||
JSSQLiteStatementConstructor* thisObject = jsDynamicCast<JSSQLiteStatementConstructor*>(thisValue.getObject());
|
||||
if (UNLIKELY(!thisObject)) {
|
||||
throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Expected SQL"_s));
|
||||
return JSValue::encode(JSC::jsUndefined());
|
||||
@@ -664,7 +664,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementLoadExtensionFunction, (JSC::JSGlobalObje
|
||||
auto scope = DECLARE_THROW_SCOPE(vm);
|
||||
|
||||
JSValue thisValue = callFrame->thisValue();
|
||||
JSSQLStatementConstructor* thisObject = jsDynamicCast<JSSQLStatementConstructor*>(thisValue.getObject());
|
||||
JSSQLiteStatementConstructor* thisObject = jsDynamicCast<JSSQLiteStatementConstructor*>(thisValue.getObject());
|
||||
if (UNLIKELY(!thisObject)) {
|
||||
throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Expected SQL"_s));
|
||||
return JSValue::encode(JSC::jsUndefined());
|
||||
@@ -719,7 +719,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementExecuteFunction, (JSC::JSGlobalObject * l
|
||||
auto scope = DECLARE_THROW_SCOPE(vm);
|
||||
|
||||
JSValue thisValue = callFrame->thisValue();
|
||||
JSSQLStatementConstructor* thisObject = jsDynamicCast<JSSQLStatementConstructor*>(thisValue.getObject());
|
||||
JSSQLiteStatementConstructor* thisObject = jsDynamicCast<JSSQLiteStatementConstructor*>(thisValue.getObject());
|
||||
if (UNLIKELY(!thisObject)) {
|
||||
throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Expected SQL"_s));
|
||||
return JSValue::encode(JSC::jsUndefined());
|
||||
@@ -820,7 +820,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementIsInTransactionFunction, (JSC::JSGlobalOb
|
||||
auto scope = DECLARE_THROW_SCOPE(vm);
|
||||
|
||||
JSValue thisValue = callFrame->thisValue();
|
||||
JSSQLStatementConstructor* thisObject = jsDynamicCast<JSSQLStatementConstructor*>(thisValue.getObject());
|
||||
JSSQLiteStatementConstructor* thisObject = jsDynamicCast<JSSQLiteStatementConstructor*>(thisValue.getObject());
|
||||
if (UNLIKELY(!thisObject)) {
|
||||
throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Expected SQLStatement"_s));
|
||||
return JSValue::encode(JSC::jsUndefined());
|
||||
@@ -856,7 +856,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementPrepareStatementFunction, (JSC::JSGlobalO
|
||||
auto scope = DECLARE_THROW_SCOPE(vm);
|
||||
|
||||
JSValue thisValue = callFrame->thisValue();
|
||||
JSSQLStatementConstructor* thisObject = jsDynamicCast<JSSQLStatementConstructor*>(thisValue.getObject());
|
||||
JSSQLiteStatementConstructor* thisObject = jsDynamicCast<JSSQLiteStatementConstructor*>(thisValue.getObject());
|
||||
if (UNLIKELY(!thisObject)) {
|
||||
throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Expected SQLStatement"_s));
|
||||
return JSValue::encode(JSC::jsUndefined());
|
||||
@@ -915,9 +915,9 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementPrepareStatementFunction, (JSC::JSGlobalO
|
||||
return JSValue::encode(JSC::jsUndefined());
|
||||
}
|
||||
|
||||
auto* structure = JSSQLStatement::createStructure(vm, lexicalGlobalObject, lexicalGlobalObject->objectPrototype());
|
||||
// auto* structure = JSSQLStatement::createStructure(vm, globalObject(), thisObject->getDirect(vm, vm.propertyNames->prototype));
|
||||
JSSQLStatement* sqlStatement = JSSQLStatement::create(
|
||||
auto* structure = JSSQLiteStatement::createStructure(vm, lexicalGlobalObject, lexicalGlobalObject->objectPrototype());
|
||||
// auto* structure = JSSQLiteStatement::createStructure(vm, globalObject(), thisObject->getDirect(vm, vm.propertyNames->prototype));
|
||||
JSSQLiteStatement* sqlStatement = JSSQLiteStatement::create(
|
||||
structure, reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject), statement, databases()[handle]);
|
||||
if (bindings.isObject()) {
|
||||
auto* castedThis = sqlStatement;
|
||||
@@ -926,10 +926,10 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementPrepareStatementFunction, (JSC::JSGlobalO
|
||||
return JSValue::encode(JSValue(sqlStatement));
|
||||
}
|
||||
|
||||
JSSQLStatementConstructor* JSSQLStatementConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
|
||||
JSSQLiteStatementConstructor* JSSQLiteStatementConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
|
||||
{
|
||||
NativeExecutable* executable = vm.getHostFunction(jsSQLStatementPrepareStatementFunction, ImplementationVisibility::Public, callHostFunctionAsConstructor, String("SQLStatement"_s));
|
||||
JSSQLStatementConstructor* ptr = new (NotNull, JSC::allocateCell<JSSQLStatementConstructor>(vm)) JSSQLStatementConstructor(vm, executable, globalObject, structure);
|
||||
JSSQLiteStatementConstructor* ptr = new (NotNull, JSC::allocateCell<JSSQLiteStatementConstructor>(vm)) JSSQLiteStatementConstructor(vm, executable, globalObject, structure);
|
||||
ptr->finishCreation(vm);
|
||||
|
||||
return ptr;
|
||||
@@ -941,7 +941,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementOpenStatementFunction, (JSC::JSGlobalObje
|
||||
auto scope = DECLARE_THROW_SCOPE(vm);
|
||||
|
||||
JSValue thisValue = callFrame->thisValue();
|
||||
JSSQLStatementConstructor* constructor = jsDynamicCast<JSSQLStatementConstructor*>(thisValue.getObject());
|
||||
JSSQLiteStatementConstructor* constructor = jsDynamicCast<JSSQLiteStatementConstructor*>(thisValue.getObject());
|
||||
if (!constructor) {
|
||||
throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Expected SQLStatement"_s));
|
||||
return JSValue::encode(jsUndefined());
|
||||
@@ -1006,7 +1006,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementCloseStatementFunction, (JSC::JSGlobalObj
|
||||
auto scope = DECLARE_THROW_SCOPE(vm);
|
||||
|
||||
JSValue thisValue = callFrame->thisValue();
|
||||
JSSQLStatementConstructor* constructor = jsDynamicCast<JSSQLStatementConstructor*>(thisValue.getObject());
|
||||
JSSQLiteStatementConstructor* constructor = jsDynamicCast<JSSQLiteStatementConstructor*>(thisValue.getObject());
|
||||
|
||||
if (!constructor) {
|
||||
throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Expected SQLStatement"_s));
|
||||
@@ -1048,7 +1048,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementCloseStatementFunction, (JSC::JSGlobalObj
|
||||
}
|
||||
|
||||
/* Hash table for constructor */
|
||||
static const HashTableValue JSSQLStatementConstructorTableValues[] = {
|
||||
static const HashTableValue JSSQLiteStatementConstructorTableValues[] = {
|
||||
{ "open"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsSQLStatementOpenStatementFunction, 2 } },
|
||||
{ "close"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsSQLStatementCloseStatementFunction, 1 } },
|
||||
{ "prepare"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsSQLStatementPrepareStatementFunction, 2 } },
|
||||
@@ -1060,21 +1060,21 @@ static const HashTableValue JSSQLStatementConstructorTableValues[] = {
|
||||
{ "deserialize"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsSQLStatementDeserialize, 2 } },
|
||||
};
|
||||
|
||||
const ClassInfo JSSQLStatementConstructor::s_info = { "SQLStatement"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSQLStatementConstructor) };
|
||||
const ClassInfo JSSQLiteStatementConstructor::s_info = { "SQLStatement"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSQLiteStatementConstructor) };
|
||||
|
||||
void JSSQLStatementConstructor::finishCreation(VM& vm)
|
||||
void JSSQLiteStatementConstructor::finishCreation(VM& vm)
|
||||
{
|
||||
Base::finishCreation(vm);
|
||||
auto* structure = JSSQLStatement::createStructure(vm, globalObject(), globalObject()->objectPrototype());
|
||||
auto* proto = JSSQLStatement::create(structure, reinterpret_cast<Zig::GlobalObject*>(globalObject()), nullptr, nullptr);
|
||||
auto* structure = JSSQLiteStatement::createStructure(vm, globalObject(), globalObject()->objectPrototype());
|
||||
auto* proto = JSSQLiteStatement::create(structure, reinterpret_cast<Zig::GlobalObject*>(globalObject()), nullptr, nullptr);
|
||||
this->putDirect(vm, vm.propertyNames->prototype, proto, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly);
|
||||
|
||||
reifyStaticProperties(vm, JSSQLStatementConstructor::info(), JSSQLStatementConstructorTableValues, *this);
|
||||
reifyStaticProperties(vm, JSSQLiteStatementConstructor::info(), JSSQLiteStatementConstructorTableValues, *this);
|
||||
JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
|
||||
}
|
||||
|
||||
static inline JSC::JSValue constructResultObject(JSC::JSGlobalObject* lexicalGlobalObject, JSSQLStatement* castedThis);
|
||||
static inline JSC::JSValue constructResultObject(JSC::JSGlobalObject* lexicalGlobalObject, JSSQLStatement* castedThis)
|
||||
static inline JSC::JSValue constructResultObject(JSC::JSGlobalObject* lexicalGlobalObject, JSSQLiteStatement* castedThis);
|
||||
static inline JSC::JSValue constructResultObject(JSC::JSGlobalObject* lexicalGlobalObject, JSSQLiteStatement* castedThis)
|
||||
{
|
||||
auto& columnNames = castedThis->columnNames->data()->propertyNameVector();
|
||||
int count = columnNames.size();
|
||||
@@ -1197,8 +1197,8 @@ static inline JSC::JSValue constructResultObject(JSC::JSGlobalObject* lexicalGlo
|
||||
return JSValue(result);
|
||||
}
|
||||
|
||||
static inline JSC::JSArray* constructResultRow(JSC::JSGlobalObject* lexicalGlobalObject, JSSQLStatement* castedThis, ObjectInitializationScope& scope, JSC::GCDeferralContext* deferralContext);
|
||||
static inline JSC::JSArray* constructResultRow(JSC::JSGlobalObject* lexicalGlobalObject, JSSQLStatement* castedThis, ObjectInitializationScope& scope, JSC::GCDeferralContext* deferralContext)
|
||||
static inline JSC::JSArray* constructResultRow(JSC::JSGlobalObject* lexicalGlobalObject, JSSQLiteStatement* castedThis, ObjectInitializationScope& scope, JSC::GCDeferralContext* deferralContext);
|
||||
static inline JSC::JSArray* constructResultRow(JSC::JSGlobalObject* lexicalGlobalObject, JSSQLiteStatement* castedThis, ObjectInitializationScope& scope, JSC::GCDeferralContext* deferralContext)
|
||||
{
|
||||
int count = castedThis->columnNames->size();
|
||||
auto& vm = lexicalGlobalObject->vm();
|
||||
@@ -1250,7 +1250,7 @@ static inline JSC::JSArray* constructResultRow(JSC::JSGlobalObject* lexicalGloba
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline JSC::JSArray* constructResultRow(JSC::JSGlobalObject* lexicalGlobalObject, JSSQLStatement* castedThis, ObjectInitializationScope& scope)
|
||||
static inline JSC::JSArray* constructResultRow(JSC::JSGlobalObject* lexicalGlobalObject, JSSQLiteStatement* castedThis, ObjectInitializationScope& scope)
|
||||
{
|
||||
return constructResultRow(lexicalGlobalObject, castedThis, scope, nullptr);
|
||||
}
|
||||
@@ -1259,7 +1259,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementExecuteStatementFunctionAll, (JSC::JSGlob
|
||||
{
|
||||
JSC::VM& vm = lexicalGlobalObject->vm();
|
||||
auto scope = DECLARE_THROW_SCOPE(vm);
|
||||
auto castedThis = jsDynamicCast<JSSQLStatement*>(callFrame->thisValue());
|
||||
auto castedThis = jsDynamicCast<JSSQLiteStatement*>(callFrame->thisValue());
|
||||
|
||||
CHECK_THIS
|
||||
|
||||
@@ -1326,7 +1326,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementExecuteStatementFunctionGet, (JSC::JSGlob
|
||||
|
||||
JSC::VM& vm = lexicalGlobalObject->vm();
|
||||
auto scope = DECLARE_THROW_SCOPE(vm);
|
||||
auto castedThis = jsDynamicCast<JSSQLStatement*>(callFrame->thisValue());
|
||||
auto castedThis = jsDynamicCast<JSSQLiteStatement*>(callFrame->thisValue());
|
||||
|
||||
CHECK_THIS
|
||||
|
||||
@@ -1371,10 +1371,10 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementExecuteStatementFunctionGet, (JSC::JSGlob
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
static JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(jsSQLStatementExecuteStatementFunctionGetWithoutTypeChecking, JSC::EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, JSSQLStatement* castedThis));
|
||||
static JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(jsSQLStatementExecuteStatementFunctionGetWithoutTypeChecking, JSC::EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, JSSQLiteStatement* castedThis));
|
||||
}
|
||||
|
||||
JSC_DEFINE_JIT_OPERATION(jsSQLStatementExecuteStatementFunctionGetWithoutTypeChecking, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, JSSQLStatement* castedThis))
|
||||
JSC_DEFINE_JIT_OPERATION(jsSQLStatementExecuteStatementFunctionGetWithoutTypeChecking, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, JSSQLiteStatement* castedThis))
|
||||
{
|
||||
VM& vm = JSC::getVM(lexicalGlobalObject);
|
||||
IGNORE_WARNINGS_BEGIN("frame-address")
|
||||
@@ -1423,7 +1423,7 @@ constexpr JSC::DFG::AbstractHeapKind writeKinds[4] = { JSC::DFG::SideState, JSC:
|
||||
|
||||
static const JSC::DOMJIT::Signature DOMJITSignatureForjsSQLStatementExecuteStatementFunctionGet(
|
||||
jsSQLStatementExecuteStatementFunctionGetWithoutTypeChecking,
|
||||
JSSQLStatement::info(),
|
||||
JSSQLiteStatement::info(),
|
||||
JSC::DOMJIT::Effect::forReadWriteKinds(readKinds, writeKinds),
|
||||
JSC::SpecOther);
|
||||
|
||||
@@ -1432,7 +1432,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementExecuteStatementFunctionRows, (JSC::JSGlo
|
||||
|
||||
JSC::VM& vm = lexicalGlobalObject->vm();
|
||||
auto scope = DECLARE_THROW_SCOPE(vm);
|
||||
auto castedThis = jsDynamicCast<JSSQLStatement*>(callFrame->thisValue());
|
||||
auto castedThis = jsDynamicCast<JSSQLiteStatement*>(callFrame->thisValue());
|
||||
|
||||
CHECK_THIS;
|
||||
|
||||
@@ -1508,7 +1508,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementExecuteStatementFunctionRun, (JSC::JSGlob
|
||||
|
||||
JSC::VM& vm = lexicalGlobalObject->vm();
|
||||
auto scope = DECLARE_THROW_SCOPE(vm);
|
||||
auto castedThis = jsDynamicCast<JSSQLStatement*>(callFrame->thisValue());
|
||||
auto castedThis = jsDynamicCast<JSSQLiteStatement*>(callFrame->thisValue());
|
||||
|
||||
CHECK_THIS
|
||||
|
||||
@@ -1551,7 +1551,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementExecuteStatementFunctionRun, (JSC::JSGlob
|
||||
JSC_DEFINE_HOST_FUNCTION(jsSQLStatementToStringFunction, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame))
|
||||
{
|
||||
JSC::VM& vm = lexicalGlobalObject->vm();
|
||||
JSSQLStatement* castedThis = jsDynamicCast<JSSQLStatement*>(callFrame->thisValue());
|
||||
JSSQLiteStatement* castedThis = jsDynamicCast<JSSQLiteStatement*>(callFrame->thisValue());
|
||||
auto scope = DECLARE_THROW_SCOPE(vm);
|
||||
|
||||
CHECK_THIS
|
||||
@@ -1570,7 +1570,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementToStringFunction, (JSC::JSGlobalObject *
|
||||
JSC_DEFINE_CUSTOM_GETTER(jsSqlStatementGetColumnNames, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
|
||||
{
|
||||
JSC::VM& vm = lexicalGlobalObject->vm();
|
||||
JSSQLStatement* castedThis = jsDynamicCast<JSSQLStatement*>(JSValue::decode(thisValue));
|
||||
JSSQLiteStatement* castedThis = jsDynamicCast<JSSQLiteStatement*>(JSValue::decode(thisValue));
|
||||
auto scope = DECLARE_THROW_SCOPE(vm);
|
||||
CHECK_THIS
|
||||
|
||||
@@ -1598,7 +1598,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsSqlStatementGetColumnNames, (JSGlobalObject * lexical
|
||||
JSC_DEFINE_CUSTOM_GETTER(jsSqlStatementGetColumnCount, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
|
||||
{
|
||||
JSC::VM& vm = lexicalGlobalObject->vm();
|
||||
JSSQLStatement* castedThis = jsDynamicCast<JSSQLStatement*>(JSValue::decode(thisValue));
|
||||
JSSQLiteStatement* castedThis = jsDynamicCast<JSSQLiteStatement*>(JSValue::decode(thisValue));
|
||||
auto scope = DECLARE_THROW_SCOPE(vm);
|
||||
CHECK_THIS
|
||||
CHECK_PREPARED
|
||||
@@ -1609,7 +1609,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsSqlStatementGetColumnCount, (JSGlobalObject * lexical
|
||||
JSC_DEFINE_CUSTOM_GETTER(jsSqlStatementGetParamCount, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
|
||||
{
|
||||
JSC::VM& vm = lexicalGlobalObject->vm();
|
||||
JSSQLStatement* castedThis = jsDynamicCast<JSSQLStatement*>(JSValue::decode(thisValue));
|
||||
JSSQLiteStatement* castedThis = jsDynamicCast<JSSQLiteStatement*>(JSValue::decode(thisValue));
|
||||
auto scope = DECLARE_THROW_SCOPE(vm);
|
||||
CHECK_THIS
|
||||
CHECK_PREPARED
|
||||
@@ -1620,7 +1620,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsSqlStatementGetParamCount, (JSGlobalObject * lexicalG
|
||||
JSC_DEFINE_HOST_FUNCTION(jsSQLStatementFunctionFinalize, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame))
|
||||
{
|
||||
JSC::VM& vm = lexicalGlobalObject->vm();
|
||||
JSSQLStatement* castedThis = jsDynamicCast<JSSQLStatement*>(callFrame->thisValue());
|
||||
JSSQLiteStatement* castedThis = jsDynamicCast<JSSQLiteStatement*>(callFrame->thisValue());
|
||||
auto scope = DECLARE_THROW_SCOPE(vm);
|
||||
CHECK_THIS
|
||||
|
||||
@@ -1632,10 +1632,10 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementFunctionFinalize, (JSC::JSGlobalObject *
|
||||
RELEASE_AND_RETURN(scope, JSValue::encode(jsUndefined()));
|
||||
}
|
||||
|
||||
const ClassInfo JSSQLStatement::s_info = { "SQLStatement"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSQLStatement) };
|
||||
const ClassInfo JSSQLiteStatement::s_info = { "SQLStatement"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSQLiteStatement) };
|
||||
|
||||
/* Hash table for prototype */
|
||||
static const HashTableValue JSSQLStatementTableValues[] = {
|
||||
static const HashTableValue JSSQLiteStatementTableValues[] = {
|
||||
{ "run"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsSQLStatementExecuteStatementFunctionRun, 1 } },
|
||||
{ "get"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction), NoIntrinsic, { HashTableValue::DOMJITFunctionType, jsSQLStatementExecuteStatementFunctionGet, &DOMJITSignatureForjsSQLStatementExecuteStatementFunctionGet } },
|
||||
{ "all"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsSQLStatementExecuteStatementFunctionAll, 1 } },
|
||||
@@ -1647,20 +1647,20 @@ static const HashTableValue JSSQLStatementTableValues[] = {
|
||||
{ "paramsCount"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor), NoIntrinsic, { HashTableValue::GetterSetterType, jsSqlStatementGetParamCount, 0 } },
|
||||
};
|
||||
|
||||
void JSSQLStatement::finishCreation(VM& vm)
|
||||
void JSSQLiteStatement::finishCreation(VM& vm)
|
||||
{
|
||||
Base::finishCreation(vm);
|
||||
reifyStaticProperties(vm, JSSQLStatement::info(), JSSQLStatementTableValues, *this);
|
||||
reifyStaticProperties(vm, JSSQLiteStatement::info(), JSSQLiteStatementTableValues, *this);
|
||||
}
|
||||
|
||||
JSSQLStatement::~JSSQLStatement()
|
||||
JSSQLiteStatement::~JSSQLiteStatement()
|
||||
{
|
||||
if (this->stmt) {
|
||||
sqlite3_finalize(this->stmt);
|
||||
}
|
||||
}
|
||||
|
||||
JSC::JSValue JSSQLStatement::rebind(JSC::JSGlobalObject* lexicalGlobalObject, JSC::JSValue values, bool clone)
|
||||
JSC::JSValue JSSQLiteStatement::rebind(JSC::JSGlobalObject* lexicalGlobalObject, JSC::JSValue values, bool clone)
|
||||
{
|
||||
JSC::VM& vm = lexicalGlobalObject->vm();
|
||||
auto scope = DECLARE_THROW_SCOPE(vm);
|
||||
@@ -1674,21 +1674,21 @@ JSC::JSValue JSSQLStatement::rebind(JSC::JSGlobalObject* lexicalGlobalObject, JS
|
||||
}
|
||||
|
||||
template<typename Visitor>
|
||||
void JSSQLStatement::visitChildrenImpl(JSCell* cell, Visitor& visitor)
|
||||
void JSSQLiteStatement::visitChildrenImpl(JSCell* cell, Visitor& visitor)
|
||||
{
|
||||
JSSQLStatement* thisObject = jsCast<JSSQLStatement*>(cell);
|
||||
JSSQLiteStatement* thisObject = jsCast<JSSQLiteStatement*>(cell);
|
||||
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
|
||||
Base::visitChildren(thisObject, visitor);
|
||||
visitor.append(thisObject->_structure);
|
||||
visitor.append(thisObject->_prototype);
|
||||
}
|
||||
|
||||
DEFINE_VISIT_CHILDREN(JSSQLStatement);
|
||||
DEFINE_VISIT_CHILDREN(JSSQLiteStatement);
|
||||
|
||||
template<typename Visitor>
|
||||
void JSSQLStatement::visitAdditionalChildren(Visitor& visitor)
|
||||
void JSSQLiteStatement::visitAdditionalChildren(Visitor& visitor)
|
||||
{
|
||||
JSSQLStatement* thisObject = this;
|
||||
JSSQLiteStatement* thisObject = this;
|
||||
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
|
||||
|
||||
visitor.append(thisObject->_structure);
|
||||
@@ -1696,14 +1696,14 @@ void JSSQLStatement::visitAdditionalChildren(Visitor& visitor)
|
||||
}
|
||||
|
||||
template<typename Visitor>
|
||||
void JSSQLStatement::visitOutputConstraints(JSCell* cell, Visitor& visitor)
|
||||
void JSSQLiteStatement::visitOutputConstraints(JSCell* cell, Visitor& visitor)
|
||||
{
|
||||
auto* thisObject = jsCast<JSSQLStatement*>(cell);
|
||||
auto* thisObject = jsCast<JSSQLiteStatement*>(cell);
|
||||
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
|
||||
Base::visitOutputConstraints(thisObject, visitor);
|
||||
thisObject->visitAdditionalChildren(visitor);
|
||||
}
|
||||
|
||||
template void JSSQLStatement::visitOutputConstraints(JSCell*, AbstractSlotVisitor&);
|
||||
template void JSSQLStatement::visitOutputConstraints(JSCell*, SlotVisitor&);
|
||||
template void JSSQLiteStatement::visitOutputConstraints(JSCell*, AbstractSlotVisitor&);
|
||||
template void JSSQLiteStatement::visitOutputConstraints(JSCell*, SlotVisitor&);
|
||||
}
|
||||
@@ -47,12 +47,12 @@
|
||||
|
||||
namespace WebCore {
|
||||
|
||||
class JSSQLStatementConstructor final : public JSC::JSFunction {
|
||||
class JSSQLiteStatementConstructor final : public JSC::JSFunction {
|
||||
public:
|
||||
using Base = JSC::JSFunction;
|
||||
static constexpr unsigned StructureFlags = Base::StructureFlags;
|
||||
|
||||
static JSSQLStatementConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure);
|
||||
static JSSQLiteStatementConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure);
|
||||
|
||||
DECLARE_INFO;
|
||||
|
||||
@@ -62,13 +62,13 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
JSSQLStatementConstructor(JSC::VM& vm, NativeExecutable* native, JSGlobalObject* globalObject, JSC::Structure* structure)
|
||||
JSSQLiteStatementConstructor(JSC::VM& vm, NativeExecutable* native, JSGlobalObject* globalObject, JSC::Structure* structure)
|
||||
: Base(vm, native, globalObject, structure)
|
||||
{
|
||||
}
|
||||
|
||||
void finishCreation(JSC::VM&);
|
||||
};
|
||||
static_assert(sizeof(JSSQLStatementConstructor) == sizeof(JSFunction), "Allocate JSSQLStatementConstructor in JSFunction IsoSubspace");
|
||||
static_assert(sizeof(JSSQLiteStatementConstructor) == sizeof(JSFunction), "Allocate JSSQLiteStatementConstructor in JSFunction IsoSubspace");
|
||||
|
||||
}
|
||||
167
src/bun.js/bindings/structure.cpp
Normal file
167
src/bun.js/bindings/structure.cpp
Normal file
@@ -0,0 +1,167 @@
|
||||
#include "root.h"
|
||||
#include <JavaScriptCore/StructureInlines.h>
|
||||
#include <JavaScriptCore/ObjectPrototype.h>
|
||||
#include "headers-handwritten.h"
|
||||
#include <JavaScriptCore/JSCJSValueInlines.h>
|
||||
#include <JavaScriptCore/ObjectConstructor.h>
|
||||
#include <JavaScriptCore/JSObjectInlines.h>
|
||||
#include <JavaScriptCore/JSBigInt.h>
|
||||
#include <JavaScriptCore/DateInstance.h>
|
||||
#include "ZigGlobalObject.h"
|
||||
#include <JavaScriptCore/JSONObject.h>
|
||||
#include <JavaScriptCore/GCDeferralContext.h>
|
||||
#include "GCDefferalContext.h"
|
||||
|
||||
namespace Bun {
|
||||
using namespace JSC;
|
||||
|
||||
typedef union DataCellValue {
|
||||
uint8_t null_value;
|
||||
WTF::StringImpl* string;
|
||||
double number;
|
||||
uint32_t integer;
|
||||
int64_t bigint;
|
||||
bool boolean;
|
||||
double date;
|
||||
size_t bytea[2];
|
||||
WTF::StringImpl* json;
|
||||
} DataCellValue;
|
||||
|
||||
enum class DataCellTag : uint8_t {
|
||||
Null = 0,
|
||||
String = 1,
|
||||
Double = 2,
|
||||
Integer = 3,
|
||||
Bigint = 4,
|
||||
Boolean = 5,
|
||||
Date = 6,
|
||||
Bytea = 7,
|
||||
Json = 8,
|
||||
};
|
||||
|
||||
typedef struct DataCell {
|
||||
DataCellTag tag;
|
||||
DataCellValue value;
|
||||
bool freeValue;
|
||||
} DataCell;
|
||||
|
||||
static JSC::JSValue toJS(JSC::Structure* structure, DataCell* cells, unsigned count, JSC::JSGlobalObject* globalObject)
|
||||
{
|
||||
auto& vm = globalObject->vm();
|
||||
auto* object = JSC::constructEmptyObject(vm, structure);
|
||||
|
||||
for (unsigned i = 0; i < count; i++) {
|
||||
auto& cell = cells[i];
|
||||
switch (cell.tag) {
|
||||
case DataCellTag::Null:
|
||||
object->putDirectOffset(vm, i, jsNull());
|
||||
break;
|
||||
case DataCellTag::String: {
|
||||
object->putDirectOffset(vm, i, jsString(vm, WTF::String(cell.value.string)));
|
||||
break;
|
||||
}
|
||||
case DataCellTag::Double:
|
||||
object->putDirectOffset(vm, i, jsDoubleNumber(cell.value.number));
|
||||
break;
|
||||
case DataCellTag::Integer:
|
||||
object->putDirectOffset(vm, i, jsNumber(cell.value.integer));
|
||||
break;
|
||||
case DataCellTag::Bigint:
|
||||
object->putDirectOffset(vm, i, JSC::JSBigInt::createFrom(globalObject, cell.value.bigint));
|
||||
break;
|
||||
case DataCellTag::Boolean:
|
||||
object->putDirectOffset(vm, i, jsBoolean(cell.value.boolean));
|
||||
break;
|
||||
case DataCellTag::Date:
|
||||
object->putDirectOffset(vm, i, JSC::DateInstance::create(vm, globalObject->dateStructure(), cell.value.date));
|
||||
break;
|
||||
case DataCellTag::Bytea: {
|
||||
Zig::GlobalObject* zigGlobal = jsCast<Zig::GlobalObject*>(globalObject);
|
||||
auto* subclassStructure = zigGlobal->JSBufferSubclassStructure();
|
||||
auto* uint8Array = JSC::JSUint8Array::createUninitialized(globalObject, subclassStructure, cell.value.bytea[1]);
|
||||
memcpy(uint8Array->vector(), reinterpret_cast<void*>(cell.value.bytea[0]), cell.value.bytea[1]);
|
||||
object->putDirectOffset(vm, i, uint8Array);
|
||||
break;
|
||||
}
|
||||
case DataCellTag::Json: {
|
||||
auto str = WTF::String(cell.value.string);
|
||||
JSC::JSValue json = JSC::JSONParse(globalObject, str);
|
||||
object->putDirectOffset(vm, i, json);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
RELEASE_ASSERT_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
static JSC::JSValue toJS(JSC::JSArray* array, JSC::Structure* structure, DataCell* cells, unsigned count, JSC::JSGlobalObject* globalObject)
|
||||
{
|
||||
auto& vm = globalObject->vm();
|
||||
|
||||
if (array) {
|
||||
array->push(globalObject, toJS(structure, cells, count, globalObject));
|
||||
return array;
|
||||
}
|
||||
|
||||
auto* newArray = JSC::constructEmptyArray(globalObject, nullptr);
|
||||
|
||||
newArray->putDirectIndex(globalObject, 0, toJS(structure, cells, count, globalObject));
|
||||
return newArray;
|
||||
}
|
||||
|
||||
extern "C" EncodedJSValue JSC__constructObjectFromDataCell(
|
||||
JSC::JSGlobalObject* globalObject,
|
||||
EncodedJSValue arrayValue,
|
||||
EncodedJSValue structureValue, DataCell* cells, unsigned count)
|
||||
{
|
||||
auto* array = arrayValue ? jsDynamicCast<JSC::JSArray*>(JSC::JSValue::decode(arrayValue)) : nullptr;
|
||||
auto* structure = jsDynamicCast<JSC::Structure*>(JSC::JSValue::decode(structureValue));
|
||||
|
||||
return JSValue::encode(toJS(array, structure, cells, count, globalObject));
|
||||
}
|
||||
|
||||
extern "C" EncodedJSValue JSC__createStructure(JSC::JSGlobalObject* globalObject, JSC::JSCell* owner, unsigned int inlineCapacity, BunString* names)
|
||||
{
|
||||
auto& vm = globalObject->vm();
|
||||
Structure* structure = globalObject->structureCache().emptyObjectStructureForPrototype(globalObject, globalObject->objectPrototype(), inlineCapacity);
|
||||
if (owner) {
|
||||
vm.writeBarrier(owner, structure);
|
||||
} else {
|
||||
vm.writeBarrier(structure);
|
||||
}
|
||||
ensureStillAliveHere(structure);
|
||||
|
||||
PropertyNameArray propertyNames(vm, PropertyNameMode::Strings, PrivateSymbolMode::Exclude);
|
||||
for (unsigned i = 0; i < inlineCapacity; i++) {
|
||||
propertyNames.add(Identifier::fromString(vm, Bun::toWTFString(names[i])));
|
||||
}
|
||||
|
||||
PropertyOffset offset = 0;
|
||||
for (unsigned i = 0; i < inlineCapacity; i++) {
|
||||
structure = structure->addPropertyTransition(vm, structure, propertyNames[i], 0, offset);
|
||||
}
|
||||
|
||||
return JSValue::encode(structure);
|
||||
}
|
||||
|
||||
extern "C" EncodedJSValue JSC__createEmptyObjectWithStructure(JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
|
||||
{
|
||||
auto& vm = globalObject->vm();
|
||||
auto* object = JSC::constructEmptyObject(vm, structure);
|
||||
|
||||
ensureStillAliveHere(object);
|
||||
vm.writeBarrier(object);
|
||||
|
||||
return JSValue::encode(object);
|
||||
}
|
||||
|
||||
extern "C" void JSC__putDirectOffset(JSC::VM* vm, JSC::EncodedJSValue object, unsigned int offset, JSC::EncodedJSValue value)
|
||||
{
|
||||
JSValue::decode(object).getObject()->putDirectOffset(*vm, offset, JSValue::decode(value));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,8 +20,8 @@ public:
|
||||
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForFFIFunction;
|
||||
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForNapiClass;
|
||||
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForNapiPrototype;
|
||||
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForJSSQLStatement;
|
||||
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForJSSQLStatementConstructor;
|
||||
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForJSSQLiteStatement;
|
||||
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForJSSQLiteStatementConstructor;
|
||||
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForJSSinkConstructor;
|
||||
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForJSSinkController;
|
||||
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForJSSink;
|
||||
|
||||
@@ -20,8 +20,8 @@ public:
|
||||
std::unique_ptr<IsoSubspace> m_subspaceForFFIFunction;
|
||||
std::unique_ptr<IsoSubspace> m_subspaceForNapiClass;
|
||||
std::unique_ptr<IsoSubspace> m_subspaceForNapiPrototype;
|
||||
std::unique_ptr<IsoSubspace> m_subspaceForJSSQLStatement;
|
||||
std::unique_ptr<IsoSubspace> m_subspaceForJSSQLStatementConstructor;
|
||||
std::unique_ptr<IsoSubspace> m_subspaceForJSSQLiteStatement;
|
||||
std::unique_ptr<IsoSubspace> m_subspaceForJSSQLiteStatementConstructor;
|
||||
std::unique_ptr<IsoSubspace> m_subspaceForJSSinkConstructor;
|
||||
std::unique_ptr<IsoSubspace> m_subspaceForJSSinkController;
|
||||
std::unique_ptr<IsoSubspace> m_subspaceForJSSink;
|
||||
|
||||
@@ -995,6 +995,8 @@ pub const ModuleLoader = struct {
|
||||
}
|
||||
log.deinit();
|
||||
|
||||
debug("fulfill: {any}", .{specifier});
|
||||
|
||||
Bun__onFulfillAsyncModule(
|
||||
promise,
|
||||
&errorable,
|
||||
@@ -2050,6 +2052,7 @@ pub const ModuleLoader = struct {
|
||||
|
||||
// These are defined in src/js/*
|
||||
.@"bun:ffi" => return jsSyntheticModule(.@"bun:ffi", specifier),
|
||||
.@"bun:sql" => return jsSyntheticModule(.@"bun:sql", specifier),
|
||||
.@"bun:sqlite" => return jsSyntheticModule(.@"bun:sqlite", specifier),
|
||||
.@"detect-libc" => return jsSyntheticModule(if (Environment.isLinux) .@"detect-libc/linux" else .@"detect-libc", specifier),
|
||||
.@"node:assert" => return jsSyntheticModule(.@"node:assert", specifier),
|
||||
@@ -2222,6 +2225,7 @@ pub const HardcodedModule = enum {
|
||||
@"bun:ffi",
|
||||
@"bun:jsc",
|
||||
@"bun:main",
|
||||
@"bun:sql",
|
||||
@"bun:sqlite",
|
||||
@"detect-libc",
|
||||
@"node:assert",
|
||||
@@ -2295,7 +2299,9 @@ pub const HardcodedModule = enum {
|
||||
.{ "bun:ffi", HardcodedModule.@"bun:ffi" },
|
||||
.{ "bun:jsc", HardcodedModule.@"bun:jsc" },
|
||||
.{ "bun:main", HardcodedModule.@"bun:main" },
|
||||
.{ "bun:sql", HardcodedModule.@"bun:sql" },
|
||||
.{ "bun:sqlite", HardcodedModule.@"bun:sqlite" },
|
||||
|
||||
.{ "detect-libc", HardcodedModule.@"detect-libc" },
|
||||
.{ "node-fetch", HardcodedModule.@"node-fetch" },
|
||||
.{ "isomorphic-fetch", HardcodedModule.@"isomorphic-fetch" },
|
||||
@@ -2506,6 +2512,7 @@ pub const HardcodedModule = enum {
|
||||
.{ "bun:ffi", .{ .path = "bun:ffi" } },
|
||||
.{ "bun:jsc", .{ .path = "bun:jsc" } },
|
||||
.{ "bun:sqlite", .{ .path = "bun:sqlite" } },
|
||||
.{ "bun:sql", .{ .path = "bun:sql" } },
|
||||
.{ "bun:wrap", .{ .path = "bun:wrap" } },
|
||||
.{ "ffi", .{ .path = "bun:ffi" } },
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ static constexpr ASCIILiteral builtinModuleNames[] = {
|
||||
"bun"_s,
|
||||
"bun:ffi"_s,
|
||||
"bun:jsc"_s,
|
||||
"bun:sql"_s,
|
||||
"bun:sqlite"_s,
|
||||
"bun:wrap"_s,
|
||||
"child_process"_s,
|
||||
|
||||
@@ -20,6 +20,8 @@ stderr_store: ?*Blob.Store = null,
|
||||
stdin_store: ?*Blob.Store = null,
|
||||
stdout_store: ?*Blob.Store = null,
|
||||
|
||||
postgresql_context: JSC.Postgres.PostgresSQLContext = .{},
|
||||
|
||||
entropy_cache: ?*EntropyCache = null,
|
||||
|
||||
hot_map: ?HotMap = null,
|
||||
|
||||
45
src/bun.zig
45
src/bun.zig
@@ -446,6 +446,51 @@ pub const StringHashMapUnowned = struct {
|
||||
};
|
||||
pub const BabyList = @import("./baby_list.zig").BabyList;
|
||||
pub const ByteList = BabyList(u8);
|
||||
pub const OffsetByteList = struct {
|
||||
head: u32 = 0,
|
||||
byte_list: ByteList = .{},
|
||||
|
||||
pub fn init(head: u32, byte_list: ByteList) OffsetByteList {
|
||||
return OffsetByteList{
|
||||
.head = head,
|
||||
.byte_list = byte_list,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn write(self: *OffsetByteList, allocator: std.mem.Allocator, bytes: []const u8) !void {
|
||||
_ = try self.byte_list.write(allocator, bytes);
|
||||
}
|
||||
|
||||
pub fn slice(this: *OffsetByteList) []u8 {
|
||||
return this.byte_list.slice()[0..this.head];
|
||||
}
|
||||
|
||||
pub fn remaining(this: *OffsetByteList) []u8 {
|
||||
return this.byte_list.slice()[this.head..];
|
||||
}
|
||||
|
||||
pub fn consume(self: *OffsetByteList, bytes: u32) void {
|
||||
self.head +|= bytes;
|
||||
if (self.head >= self.byte_list.len) {
|
||||
self.head = 0;
|
||||
self.byte_list.len = 0;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn len(self: *const OffsetByteList) u32 {
|
||||
return self.byte_list.len - self.head;
|
||||
}
|
||||
|
||||
pub fn clear(self: *OffsetByteList) void {
|
||||
self.head = 0;
|
||||
self.byte_list.len = 0;
|
||||
}
|
||||
|
||||
pub fn deinit(self: *OffsetByteList, allocator: std.mem.Allocator) void {
|
||||
self.byte_list.deinitWithAllocator(allocator);
|
||||
self.* = .{};
|
||||
}
|
||||
};
|
||||
|
||||
pub fn DebugOnly(comptime Type: type) type {
|
||||
if (comptime Environment.isDebug) {
|
||||
|
||||
118
src/deps/uws.zig
118
src/deps/uws.zig
@@ -731,6 +731,124 @@ pub fn NewSocketHandler(comptime is_ssl: bool) type {
|
||||
|
||||
pub const SocketTCP = NewSocketHandler(false);
|
||||
pub const SocketTLS = NewSocketHandler(true);
|
||||
pub const AnySocket = union(enum) {
|
||||
SocketTCP: SocketTCP,
|
||||
SocketTLS: SocketTLS,
|
||||
|
||||
pub fn setTimeout(this: AnySocket, seconds: c_uint) void {
|
||||
switch (this) {
|
||||
.SocketTCP => this.SocketTCP.setTimeout(seconds),
|
||||
.SocketTLS => this.SocketTLS.setTimeout(seconds),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn shutdown(this: AnySocket) void {
|
||||
debug("us_socket_shutdown({d})", .{@intFromPtr(this.socket())});
|
||||
return us_socket_shutdown(
|
||||
@intFromBool(this.isSSL()),
|
||||
this.socket(),
|
||||
);
|
||||
}
|
||||
pub fn shutdownRead(this: AnySocket) void {
|
||||
debug("us_socket_shutdown_read({d})", .{@intFromPtr(this.socket())});
|
||||
return us_socket_shutdown_read(
|
||||
@intFromBool(this.isSSL()),
|
||||
this.socket(),
|
||||
);
|
||||
}
|
||||
pub fn isShutdown(this: AnySocket) bool {
|
||||
return us_socket_is_shut_down(
|
||||
@intFromBool(this.isSSL()),
|
||||
this.socket(),
|
||||
) > 0;
|
||||
}
|
||||
pub fn isClosed(this: AnySocket) bool {
|
||||
return us_socket_is_closed(
|
||||
@intFromBool(this.isSSL()),
|
||||
this.socket(),
|
||||
) > 0;
|
||||
}
|
||||
pub fn close(this: AnySocket) void {
|
||||
debug("us_socket_close({d})", .{@intFromPtr(this.socket())});
|
||||
_ = us_socket_close(
|
||||
@intFromBool(this.isSSL()),
|
||||
this.socket(),
|
||||
0,
|
||||
null,
|
||||
);
|
||||
}
|
||||
|
||||
pub fn write(this: AnySocket, data: []const u8, msg_more: bool) i32 {
|
||||
const result = us_socket_write(
|
||||
@intFromBool(this.isSSL()),
|
||||
this.socket(),
|
||||
data.ptr,
|
||||
// truncate to 31 bits since sign bit exists
|
||||
@as(i32, @intCast(@as(u31, @truncate(data.len)))),
|
||||
@as(i32, @intFromBool(msg_more)),
|
||||
);
|
||||
|
||||
if (comptime Environment.allow_assert) {
|
||||
debug("us_socket_write({any}, {d}) = {d}", .{ this.getNativeHandle(), data.len, result });
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
pub fn getNativeHandle(this: AnySocket) ?*anyopaque {
|
||||
return us_socket_get_native_handle(
|
||||
@intFromBool(this.isSSL()),
|
||||
this.socket(),
|
||||
).?;
|
||||
}
|
||||
|
||||
pub fn rawWrite(this: AnySocket, data: []const u8, msg_more: bool) i32 {
|
||||
return us_socket_raw_write(
|
||||
@intFromBool(this.isSSL()),
|
||||
this.socket(),
|
||||
data.ptr,
|
||||
// truncate to 31 bits since sign bit exists
|
||||
@as(i32, @intCast(@as(u31, @truncate(data.len)))),
|
||||
@as(i32, @intFromBool(msg_more)),
|
||||
);
|
||||
}
|
||||
|
||||
pub fn localPort(this: AnySocket) i32 {
|
||||
return us_socket_local_port(
|
||||
@intFromBool(this.isSSL()),
|
||||
this.socket(),
|
||||
);
|
||||
}
|
||||
|
||||
pub fn isSSL(this: AnySocket) bool {
|
||||
return switch (this) {
|
||||
.SocketTCP => false,
|
||||
.SocketTLS => true,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn socket(this: AnySocket) *Socket {
|
||||
return switch (this) {
|
||||
.SocketTCP => this.SocketTCP.socket,
|
||||
.SocketTLS => this.SocketTLS.socket,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn ext(this: AnySocket, comptime ContextType: type) ?*ContextType {
|
||||
var ptr = us_socket_ext(
|
||||
this.isSSL(),
|
||||
this.socket(),
|
||||
) orelse return null;
|
||||
|
||||
return @ptrCast(@alignCast(ptr));
|
||||
}
|
||||
pub fn context(this: AnySocket) *SocketContext {
|
||||
return us_socket_context(
|
||||
this.isSSL(),
|
||||
this.socket(),
|
||||
).?;
|
||||
}
|
||||
};
|
||||
|
||||
pub const Timer = opaque {
|
||||
pub fn create(loop: *Loop, ptr: anytype) *Timer {
|
||||
|
||||
374
src/js/bun/sql.ts
Normal file
374
src/js/bun/sql.ts
Normal file
@@ -0,0 +1,374 @@
|
||||
const queryStatus_active = 1 << 1;
|
||||
const queryStatus_cancelled = 1 << 2;
|
||||
const queryStatus_error = 1 << 3;
|
||||
const queryStatus_executed = 1 << 4;
|
||||
|
||||
const rawMode_values = 1;
|
||||
const rawMode_objects = 2;
|
||||
|
||||
const _resolve = Symbol("resolve");
|
||||
const _reject = Symbol("reject");
|
||||
const _handle = Symbol("handle");
|
||||
const _run = Symbol("run");
|
||||
const _queryStatus = Symbol("status");
|
||||
const _handler = Symbol("handler");
|
||||
const PublicPromise = Promise;
|
||||
|
||||
const { createConnection: _createConnection, createQuery, PostgresSQLConnection, init } = $lazy("bun:sql");
|
||||
|
||||
class Query extends PublicPromise {
|
||||
[_resolve];
|
||||
[_reject];
|
||||
[_handle];
|
||||
[_handler];
|
||||
[_queryStatus] = 0;
|
||||
|
||||
constructor(handle, handler) {
|
||||
var resolve_, reject_;
|
||||
super((resolve, reject) => {
|
||||
resolve_ = resolve;
|
||||
reject_ = reject;
|
||||
});
|
||||
this[_resolve] = resolve_;
|
||||
this[_reject] = reject_;
|
||||
this[_handle] = handle;
|
||||
this[_handler] = handler;
|
||||
this[_queryStatus] = handle ? 0 : queryStatus_cancelled;
|
||||
}
|
||||
|
||||
async [_run]() {
|
||||
const { [_handle]: handle, [_handler]: handler, [_queryStatus]: status } = this;
|
||||
|
||||
if (status & (queryStatus_executed | queryStatus_cancelled)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this[_queryStatus] |= queryStatus_executed;
|
||||
await 1;
|
||||
return handler(this, handle);
|
||||
}
|
||||
|
||||
get active() {
|
||||
return (this[_queryStatus] & queryStatus_active) !== 0;
|
||||
}
|
||||
|
||||
set active(value) {
|
||||
const status = this[_queryStatus];
|
||||
if (status & (queryStatus_cancelled | queryStatus_error)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (value) {
|
||||
this[_queryStatus] |= queryStatus_active;
|
||||
} else {
|
||||
this[_queryStatus] &= ~queryStatus_active;
|
||||
}
|
||||
}
|
||||
|
||||
get cancelled() {
|
||||
return (this[_queryStatus] & queryStatus_cancelled) !== 0;
|
||||
}
|
||||
|
||||
resolve(x) {
|
||||
this[_queryStatus] &= ~queryStatus_active;
|
||||
this[_handle].done();
|
||||
return this[_resolve](x);
|
||||
}
|
||||
|
||||
reject(x) {
|
||||
this[_queryStatus] &= ~queryStatus_active;
|
||||
this[_queryStatus] |= queryStatus_error;
|
||||
this[_handle].done();
|
||||
|
||||
return this[_reject](x);
|
||||
}
|
||||
|
||||
cancel() {
|
||||
var status = this[_queryStatus];
|
||||
if (status & queryStatus_cancelled) {
|
||||
return this;
|
||||
}
|
||||
this[_queryStatus] |= queryStatus_cancelled;
|
||||
|
||||
if (status & queryStatus_executed) {
|
||||
this[_handle].cancel();
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
execute() {
|
||||
this[_run]();
|
||||
return this;
|
||||
}
|
||||
|
||||
raw() {
|
||||
this[_handle].raw = rawMode_objects;
|
||||
return this;
|
||||
}
|
||||
|
||||
values() {
|
||||
this[_handle].raw = rawMode_values;
|
||||
return this;
|
||||
}
|
||||
|
||||
then() {
|
||||
this[_run]();
|
||||
return super.$then.$apply(this, arguments);
|
||||
}
|
||||
|
||||
catch() {
|
||||
this[_run]();
|
||||
return super.$catch.$apply(this, arguments);
|
||||
}
|
||||
|
||||
finally() {
|
||||
this[_run]();
|
||||
return super.$finally.$apply(this, arguments);
|
||||
}
|
||||
}
|
||||
Object.defineProperty(Query, Symbol.species, { value: PublicPromise });
|
||||
Object.defineProperty(Query, Symbol.toStringTag, { value: "Query" });
|
||||
init(
|
||||
function (query, result) {
|
||||
try {
|
||||
query.resolve(result);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
},
|
||||
function (query, reject) {
|
||||
try {
|
||||
query.reject(reject);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
function createConnection({ hostname, port, username, password, tls, query, database }, onConnected, onClose) {
|
||||
return _createConnection(
|
||||
hostname,
|
||||
Number(port),
|
||||
username || "",
|
||||
password || "",
|
||||
database || "",
|
||||
tls || null,
|
||||
query || "",
|
||||
onConnected,
|
||||
onClose,
|
||||
);
|
||||
}
|
||||
|
||||
function normalizeStrings(strings) {
|
||||
if ($isJSArray(strings)) {
|
||||
const count = strings.length;
|
||||
if (count === 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
var out = strings[0];
|
||||
for (var i = 1; i < count; i++) {
|
||||
out += "$" + i;
|
||||
out += strings[i];
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
return strings + "";
|
||||
}
|
||||
|
||||
function loadOptions(o) {
|
||||
var hostname, port, username, password, database, tls, url, query, adapter;
|
||||
const env = Bun.env;
|
||||
|
||||
if (typeof o === "undefined" || (typeof o === "string" && o.length === 0)) {
|
||||
const urlString = env.POSTGRES_URL || env.DATABASE_URL || env.PGURL || env.PG_URL;
|
||||
if (urlString) {
|
||||
url = new URL(urlString);
|
||||
o = {};
|
||||
}
|
||||
} else if (o && typeof o === "object") {
|
||||
if (o instanceof URL) {
|
||||
url = o;
|
||||
} else if (o?.url) {
|
||||
const _url = o.url;
|
||||
if (typeof _url === "string") {
|
||||
url = new URL(_url);
|
||||
} else if (_url && typeof _url === "object" && _url instanceof URL) {
|
||||
url = _url;
|
||||
}
|
||||
}
|
||||
} else if (typeof o === "string") {
|
||||
url = new URL(o);
|
||||
}
|
||||
|
||||
if (url) {
|
||||
({ hostname, port, username, password, protocol: adapter } = o = url);
|
||||
if (adapter[adapter.length - 1] === ":") {
|
||||
adapter = adapter.slice(0, -1);
|
||||
}
|
||||
const queryObject = url.searchParams.toJSON();
|
||||
query = "";
|
||||
for (const key in queryObject) {
|
||||
query += `${encodeURIComponent(key)}=${encodeURIComponent(queryObject[key])} `;
|
||||
}
|
||||
query = query.trim();
|
||||
}
|
||||
|
||||
if (!o) {
|
||||
o = {};
|
||||
}
|
||||
|
||||
hostname ||= o.hostname || o.host || env.PGHOST || "localhost";
|
||||
port ||= Number(o.port || env.PGPORT || 5432);
|
||||
username ||= o.username || o.user || env.PGUSERNAME || env.PGUSER || env.USER || env.USERNAME || "postgres";
|
||||
database ||= o.database || o.db || (url?.pathname ?? "").slice(1) || env.PGDATABASE || username;
|
||||
password ||= o.password || o.pass || env.PGPASSWORD || "";
|
||||
tls ||= o.tls || o.ssl;
|
||||
adapter ||= o.adapter || "postgres";
|
||||
|
||||
port = Number(port);
|
||||
|
||||
if (!Number.isSafeInteger(port) || port < 1 || port > 65535) {
|
||||
throw new Error(`Invalid port: ${port}`);
|
||||
}
|
||||
|
||||
if (adapter && !(adapter === "postgres" || adapter === "postgresql")) {
|
||||
throw new Error(`Unsupported adapter: ${adapter}. Only \"postgres\" is supported for now`);
|
||||
}
|
||||
|
||||
return { hostname, port, username, password, database, tls, query };
|
||||
}
|
||||
|
||||
function SQL(o) {
|
||||
var connection,
|
||||
connected = false,
|
||||
connecting = false,
|
||||
closed = false,
|
||||
onConnect: any[] = [],
|
||||
connectionInfo = loadOptions(o);
|
||||
|
||||
function connectedHandler(query, handle, err) {
|
||||
if (err) {
|
||||
return query.reject(err);
|
||||
}
|
||||
|
||||
if (!connected) {
|
||||
return query.reject(new Error("Not connected"));
|
||||
}
|
||||
|
||||
if (query.cancelled) {
|
||||
return query.reject(new Error("Query cancelled"));
|
||||
}
|
||||
|
||||
handle.run(connection, query);
|
||||
}
|
||||
|
||||
function pendingConnectionHandler(query, handle) {
|
||||
onConnect.push(err => connectedHandler(query, handle, err));
|
||||
if (!connecting) {
|
||||
connecting = true;
|
||||
connection = createConnection(connectionInfo, onConnected, onClose);
|
||||
}
|
||||
}
|
||||
|
||||
function closedConnectionHandler(query, handle) {
|
||||
query.reject(new Error("Connection closed"));
|
||||
}
|
||||
|
||||
function onConnected(err, result) {
|
||||
connected = !err;
|
||||
for (const handler of onConnect) {
|
||||
handler(err);
|
||||
}
|
||||
onConnect = [];
|
||||
}
|
||||
|
||||
function onClose(err) {
|
||||
closed = true;
|
||||
onConnected(err, undefined);
|
||||
}
|
||||
|
||||
function connectedSQL(strings, values) {
|
||||
return new Query(createQuery(normalizeStrings(strings), values), connectedHandler);
|
||||
}
|
||||
|
||||
function closedSQL(strings, values) {
|
||||
return new Query(undefined, closedConnectionHandler);
|
||||
}
|
||||
|
||||
function pendingSQL(strings, values) {
|
||||
return new Query(createQuery(normalizeStrings(strings), values), pendingConnectionHandler);
|
||||
}
|
||||
|
||||
function sql(strings, ...values) {
|
||||
if (closed) {
|
||||
return closedSQL(strings, values);
|
||||
}
|
||||
|
||||
if (connected) {
|
||||
return connectedSQL(strings, values);
|
||||
}
|
||||
|
||||
return pendingSQL(strings, values);
|
||||
}
|
||||
|
||||
sql.connect = () => {
|
||||
if (closed) {
|
||||
return Promise.reject(new Error("Connection closed"));
|
||||
}
|
||||
|
||||
if (connected) {
|
||||
return Promise.resolve(sql);
|
||||
}
|
||||
|
||||
var { resolve, reject, promise } = Promise.withResolvers();
|
||||
onConnect.push(err => (err ? reject(err) : resolve(sql)));
|
||||
if (!connecting) {
|
||||
connecting = true;
|
||||
connection = createConnection(connectionInfo, onConnected, onClose);
|
||||
}
|
||||
|
||||
return promise;
|
||||
};
|
||||
|
||||
sql.close = () => {
|
||||
if (closed) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
var { resolve, promise } = Promise.withResolvers();
|
||||
onConnect.push(resolve);
|
||||
connection.close();
|
||||
return promise;
|
||||
};
|
||||
|
||||
sql.flush = () => {
|
||||
if (closed || !connected) {
|
||||
return;
|
||||
}
|
||||
|
||||
connection.flush();
|
||||
};
|
||||
return sql;
|
||||
}
|
||||
|
||||
var lazyDefaultSQL;
|
||||
var defaultSQLObject = function sql(strings, ...values) {
|
||||
if (!lazyDefaultSQL) {
|
||||
lazyDefaultSQL = SQL(undefined);
|
||||
Object.assign(defaultSQLObject, lazyDefaultSQL);
|
||||
exportsObject.default = exportsObject.sql = lazyDefaultSQL;
|
||||
}
|
||||
return lazyDefaultSQL(strings, ...values);
|
||||
};
|
||||
|
||||
var exportsObject = {
|
||||
sql: defaultSQLObject,
|
||||
default: defaultSQLObject,
|
||||
SQL,
|
||||
Query,
|
||||
};
|
||||
|
||||
export default exportsObject;
|
||||
@@ -6,6 +6,9 @@ JSValue InternalModuleRegistry::createInternalModuleById(JSGlobalObject* globalO
|
||||
case Field::BunFFI: {
|
||||
INTERNAL_MODULE_REGISTRY_GENERATE(globalObject, vm, "bun:ffi"_s, "bun/ffi.js"_s, InternalModuleRegistryConstants::BunFFICode, "builtin://bun/ffi"_s);
|
||||
}
|
||||
case Field::BunSql: {
|
||||
INTERNAL_MODULE_REGISTRY_GENERATE(globalObject, vm, "bun:sql"_s, "bun/sql.js"_s, InternalModuleRegistryConstants::BunSqlCode, "builtin://bun/sql"_s);
|
||||
}
|
||||
case Field::BunSqlite: {
|
||||
INTERNAL_MODULE_REGISTRY_GENERATE(globalObject, vm, "bun:sqlite"_s, "bun/sqlite.js"_s, InternalModuleRegistryConstants::BunSqliteCode, "builtin://bun/sqlite"_s);
|
||||
}
|
||||
|
||||
@@ -1,63 +1,64 @@
|
||||
BunFFI = 0,
|
||||
BunSqlite = 1,
|
||||
InternalDebugger = 2,
|
||||
InternalFSCpSync = 3,
|
||||
InternalFSCp = 4,
|
||||
InternalPrimordials = 5,
|
||||
InternalShared = 6,
|
||||
InternalUtilInspect = 7,
|
||||
NodeAssert = 8,
|
||||
NodeAssertStrict = 9,
|
||||
NodeAsyncHooks = 10,
|
||||
NodeChildProcess = 11,
|
||||
NodeCluster = 12,
|
||||
NodeConsole = 13,
|
||||
NodeCrypto = 14,
|
||||
NodeDgram = 15,
|
||||
NodeDiagnosticsChannel = 16,
|
||||
NodeDNS = 17,
|
||||
NodeDNSPromises = 18,
|
||||
NodeDomain = 19,
|
||||
NodeEvents = 20,
|
||||
NodeFS = 21,
|
||||
NodeFSPromises = 22,
|
||||
NodeHttp = 23,
|
||||
NodeHttp2 = 24,
|
||||
NodeHttps = 25,
|
||||
NodeInspector = 26,
|
||||
NodeNet = 27,
|
||||
NodeOS = 28,
|
||||
NodePathPosix = 29,
|
||||
NodePath = 30,
|
||||
NodePathWin32 = 31,
|
||||
NodePerfHooks = 32,
|
||||
NodePunycode = 33,
|
||||
NodeQuerystring = 34,
|
||||
NodeReadline = 35,
|
||||
NodeReadlinePromises = 36,
|
||||
NodeRepl = 37,
|
||||
NodeStreamConsumers = 38,
|
||||
NodeStream = 39,
|
||||
NodeStreamPromises = 40,
|
||||
NodeStreamWeb = 41,
|
||||
NodeTimers = 42,
|
||||
NodeTimersPromises = 43,
|
||||
NodeTLS = 44,
|
||||
NodeTraceEvents = 45,
|
||||
NodeTty = 46,
|
||||
NodeUrl = 47,
|
||||
NodeUtil = 48,
|
||||
NodeV8 = 49,
|
||||
NodeVM = 50,
|
||||
NodeWasi = 51,
|
||||
NodeWorkerThreads = 52,
|
||||
NodeZlib = 53,
|
||||
ThirdpartyDepd = 54,
|
||||
ThirdpartyDetectLibc = 55,
|
||||
ThirdpartyDetectLibcLinux = 56,
|
||||
ThirdpartyIsomorphicFetch = 57,
|
||||
ThirdpartyNodeFetch = 58,
|
||||
ThirdpartyUndici = 59,
|
||||
ThirdpartyVercelFetch = 60,
|
||||
ThirdpartyWS = 61,
|
||||
BunSql = 1,
|
||||
BunSqlite = 2,
|
||||
InternalDebugger = 3,
|
||||
InternalFSCpSync = 4,
|
||||
InternalFSCp = 5,
|
||||
InternalPrimordials = 6,
|
||||
InternalShared = 7,
|
||||
InternalUtilInspect = 8,
|
||||
NodeAssert = 9,
|
||||
NodeAssertStrict = 10,
|
||||
NodeAsyncHooks = 11,
|
||||
NodeChildProcess = 12,
|
||||
NodeCluster = 13,
|
||||
NodeConsole = 14,
|
||||
NodeCrypto = 15,
|
||||
NodeDgram = 16,
|
||||
NodeDiagnosticsChannel = 17,
|
||||
NodeDNS = 18,
|
||||
NodeDNSPromises = 19,
|
||||
NodeDomain = 20,
|
||||
NodeEvents = 21,
|
||||
NodeFS = 22,
|
||||
NodeFSPromises = 23,
|
||||
NodeHttp = 24,
|
||||
NodeHttp2 = 25,
|
||||
NodeHttps = 26,
|
||||
NodeInspector = 27,
|
||||
NodeNet = 28,
|
||||
NodeOS = 29,
|
||||
NodePathPosix = 30,
|
||||
NodePath = 31,
|
||||
NodePathWin32 = 32,
|
||||
NodePerfHooks = 33,
|
||||
NodePunycode = 34,
|
||||
NodeQuerystring = 35,
|
||||
NodeReadline = 36,
|
||||
NodeReadlinePromises = 37,
|
||||
NodeRepl = 38,
|
||||
NodeStreamConsumers = 39,
|
||||
NodeStream = 40,
|
||||
NodeStreamPromises = 41,
|
||||
NodeStreamWeb = 42,
|
||||
NodeTimers = 43,
|
||||
NodeTimersPromises = 44,
|
||||
NodeTLS = 45,
|
||||
NodeTraceEvents = 46,
|
||||
NodeTty = 47,
|
||||
NodeUrl = 48,
|
||||
NodeUtil = 49,
|
||||
NodeV8 = 50,
|
||||
NodeVM = 51,
|
||||
NodeWasi = 52,
|
||||
NodeWorkerThreads = 53,
|
||||
NodeZlib = 54,
|
||||
ThirdpartyDepd = 55,
|
||||
ThirdpartyDetectLibc = 56,
|
||||
ThirdpartyDetectLibcLinux = 57,
|
||||
ThirdpartyIsomorphicFetch = 58,
|
||||
ThirdpartyNodeFetch = 59,
|
||||
ThirdpartyUndici = 60,
|
||||
ThirdpartyVercelFetch = 61,
|
||||
ThirdpartyWS = 62,
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
#define BUN_INTERNAL_MODULE_COUNT 62
|
||||
#define BUN_INTERNAL_MODULE_COUNT 63
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -12,67 +12,68 @@ pub const ResolvedSourceTag = enum(u32) {
|
||||
// Built in modules are loaded through InternalModuleRegistry by numerical ID.
|
||||
// In this enum are represented as `(1 << 9) & id`
|
||||
@"bun:ffi" = 512,
|
||||
@"bun:sqlite" = 513,
|
||||
@"internal:debugger" = 514,
|
||||
@"internal:fs/cp-sync" = 515,
|
||||
@"internal:fs/cp" = 516,
|
||||
@"internal:primordials" = 517,
|
||||
@"internal:shared" = 518,
|
||||
@"internal:util/inspect" = 519,
|
||||
@"node:assert" = 520,
|
||||
@"node:assert/strict" = 521,
|
||||
@"node:async_hooks" = 522,
|
||||
@"node:child_process" = 523,
|
||||
@"node:cluster" = 524,
|
||||
@"node:console" = 525,
|
||||
@"node:crypto" = 526,
|
||||
@"node:dgram" = 527,
|
||||
@"node:diagnostics_channel" = 528,
|
||||
@"node:dns" = 529,
|
||||
@"node:dns/promises" = 530,
|
||||
@"node:domain" = 531,
|
||||
@"node:events" = 532,
|
||||
@"node:fs" = 533,
|
||||
@"node:fs/promises" = 534,
|
||||
@"node:http" = 535,
|
||||
@"node:http2" = 536,
|
||||
@"node:https" = 537,
|
||||
@"node:inspector" = 538,
|
||||
@"node:net" = 539,
|
||||
@"node:os" = 540,
|
||||
@"node:path/posix" = 541,
|
||||
@"node:path" = 542,
|
||||
@"node:path/win32" = 543,
|
||||
@"node:perf_hooks" = 544,
|
||||
@"node:punycode" = 545,
|
||||
@"node:querystring" = 546,
|
||||
@"node:readline" = 547,
|
||||
@"node:readline/promises" = 548,
|
||||
@"node:repl" = 549,
|
||||
@"node:stream/consumers" = 550,
|
||||
@"node:stream" = 551,
|
||||
@"node:stream/promises" = 552,
|
||||
@"node:stream/web" = 553,
|
||||
@"node:timers" = 554,
|
||||
@"node:timers/promises" = 555,
|
||||
@"node:tls" = 556,
|
||||
@"node:trace_events" = 557,
|
||||
@"node:tty" = 558,
|
||||
@"node:url" = 559,
|
||||
@"node:util" = 560,
|
||||
@"node:v8" = 561,
|
||||
@"node:vm" = 562,
|
||||
@"node:wasi" = 563,
|
||||
@"node:worker_threads" = 564,
|
||||
@"node:zlib" = 565,
|
||||
@"depd" = 566,
|
||||
@"detect-libc" = 567,
|
||||
@"detect-libc/linux" = 568,
|
||||
@"isomorphic-fetch" = 569,
|
||||
@"node-fetch" = 570,
|
||||
@"undici" = 571,
|
||||
@"vercel_fetch" = 572,
|
||||
@"ws" = 573,
|
||||
@"bun:sql" = 513,
|
||||
@"bun:sqlite" = 514,
|
||||
@"internal:debugger" = 515,
|
||||
@"internal:fs/cp-sync" = 516,
|
||||
@"internal:fs/cp" = 517,
|
||||
@"internal:primordials" = 518,
|
||||
@"internal:shared" = 519,
|
||||
@"internal:util/inspect" = 520,
|
||||
@"node:assert" = 521,
|
||||
@"node:assert/strict" = 522,
|
||||
@"node:async_hooks" = 523,
|
||||
@"node:child_process" = 524,
|
||||
@"node:cluster" = 525,
|
||||
@"node:console" = 526,
|
||||
@"node:crypto" = 527,
|
||||
@"node:dgram" = 528,
|
||||
@"node:diagnostics_channel" = 529,
|
||||
@"node:dns" = 530,
|
||||
@"node:dns/promises" = 531,
|
||||
@"node:domain" = 532,
|
||||
@"node:events" = 533,
|
||||
@"node:fs" = 534,
|
||||
@"node:fs/promises" = 535,
|
||||
@"node:http" = 536,
|
||||
@"node:http2" = 537,
|
||||
@"node:https" = 538,
|
||||
@"node:inspector" = 539,
|
||||
@"node:net" = 540,
|
||||
@"node:os" = 541,
|
||||
@"node:path/posix" = 542,
|
||||
@"node:path" = 543,
|
||||
@"node:path/win32" = 544,
|
||||
@"node:perf_hooks" = 545,
|
||||
@"node:punycode" = 546,
|
||||
@"node:querystring" = 547,
|
||||
@"node:readline" = 548,
|
||||
@"node:readline/promises" = 549,
|
||||
@"node:repl" = 550,
|
||||
@"node:stream/consumers" = 551,
|
||||
@"node:stream" = 552,
|
||||
@"node:stream/promises" = 553,
|
||||
@"node:stream/web" = 554,
|
||||
@"node:timers" = 555,
|
||||
@"node:timers/promises" = 556,
|
||||
@"node:tls" = 557,
|
||||
@"node:trace_events" = 558,
|
||||
@"node:tty" = 559,
|
||||
@"node:url" = 560,
|
||||
@"node:util" = 561,
|
||||
@"node:v8" = 562,
|
||||
@"node:vm" = 563,
|
||||
@"node:wasi" = 564,
|
||||
@"node:worker_threads" = 565,
|
||||
@"node:zlib" = 566,
|
||||
@"depd" = 567,
|
||||
@"detect-libc" = 568,
|
||||
@"detect-libc/linux" = 569,
|
||||
@"isomorphic-fetch" = 570,
|
||||
@"node-fetch" = 571,
|
||||
@"undici" = 572,
|
||||
@"vercel_fetch" = 573,
|
||||
@"ws" = 574,
|
||||
// Native modules run through a different system using ESM registry.
|
||||
@"bun" = 1024,
|
||||
@"bun:jsc" = 1025,
|
||||
|
||||
@@ -11,67 +11,68 @@ enum SyntheticModuleType : uint32_t {
|
||||
// In this enum are represented as `(1 << 9) & id`
|
||||
InternalModuleRegistryFlag = 1 << 9,
|
||||
BunFFI = 512,
|
||||
BunSqlite = 513,
|
||||
InternalDebugger = 514,
|
||||
InternalFSCpSync = 515,
|
||||
InternalFSCp = 516,
|
||||
InternalPrimordials = 517,
|
||||
InternalShared = 518,
|
||||
InternalUtilInspect = 519,
|
||||
NodeAssert = 520,
|
||||
NodeAssertStrict = 521,
|
||||
NodeAsyncHooks = 522,
|
||||
NodeChildProcess = 523,
|
||||
NodeCluster = 524,
|
||||
NodeConsole = 525,
|
||||
NodeCrypto = 526,
|
||||
NodeDgram = 527,
|
||||
NodeDiagnosticsChannel = 528,
|
||||
NodeDNS = 529,
|
||||
NodeDNSPromises = 530,
|
||||
NodeDomain = 531,
|
||||
NodeEvents = 532,
|
||||
NodeFS = 533,
|
||||
NodeFSPromises = 534,
|
||||
NodeHttp = 535,
|
||||
NodeHttp2 = 536,
|
||||
NodeHttps = 537,
|
||||
NodeInspector = 538,
|
||||
NodeNet = 539,
|
||||
NodeOS = 540,
|
||||
NodePathPosix = 541,
|
||||
NodePath = 542,
|
||||
NodePathWin32 = 543,
|
||||
NodePerfHooks = 544,
|
||||
NodePunycode = 545,
|
||||
NodeQuerystring = 546,
|
||||
NodeReadline = 547,
|
||||
NodeReadlinePromises = 548,
|
||||
NodeRepl = 549,
|
||||
NodeStreamConsumers = 550,
|
||||
NodeStream = 551,
|
||||
NodeStreamPromises = 552,
|
||||
NodeStreamWeb = 553,
|
||||
NodeTimers = 554,
|
||||
NodeTimersPromises = 555,
|
||||
NodeTLS = 556,
|
||||
NodeTraceEvents = 557,
|
||||
NodeTty = 558,
|
||||
NodeUrl = 559,
|
||||
NodeUtil = 560,
|
||||
NodeV8 = 561,
|
||||
NodeVM = 562,
|
||||
NodeWasi = 563,
|
||||
NodeWorkerThreads = 564,
|
||||
NodeZlib = 565,
|
||||
ThirdpartyDepd = 566,
|
||||
ThirdpartyDetectLibc = 567,
|
||||
ThirdpartyDetectLibcLinux = 568,
|
||||
ThirdpartyIsomorphicFetch = 569,
|
||||
ThirdpartyNodeFetch = 570,
|
||||
ThirdpartyUndici = 571,
|
||||
ThirdpartyVercelFetch = 572,
|
||||
ThirdpartyWS = 573,
|
||||
BunSql = 513,
|
||||
BunSqlite = 514,
|
||||
InternalDebugger = 515,
|
||||
InternalFSCpSync = 516,
|
||||
InternalFSCp = 517,
|
||||
InternalPrimordials = 518,
|
||||
InternalShared = 519,
|
||||
InternalUtilInspect = 520,
|
||||
NodeAssert = 521,
|
||||
NodeAssertStrict = 522,
|
||||
NodeAsyncHooks = 523,
|
||||
NodeChildProcess = 524,
|
||||
NodeCluster = 525,
|
||||
NodeConsole = 526,
|
||||
NodeCrypto = 527,
|
||||
NodeDgram = 528,
|
||||
NodeDiagnosticsChannel = 529,
|
||||
NodeDNS = 530,
|
||||
NodeDNSPromises = 531,
|
||||
NodeDomain = 532,
|
||||
NodeEvents = 533,
|
||||
NodeFS = 534,
|
||||
NodeFSPromises = 535,
|
||||
NodeHttp = 536,
|
||||
NodeHttp2 = 537,
|
||||
NodeHttps = 538,
|
||||
NodeInspector = 539,
|
||||
NodeNet = 540,
|
||||
NodeOS = 541,
|
||||
NodePathPosix = 542,
|
||||
NodePath = 543,
|
||||
NodePathWin32 = 544,
|
||||
NodePerfHooks = 545,
|
||||
NodePunycode = 546,
|
||||
NodeQuerystring = 547,
|
||||
NodeReadline = 548,
|
||||
NodeReadlinePromises = 549,
|
||||
NodeRepl = 550,
|
||||
NodeStreamConsumers = 551,
|
||||
NodeStream = 552,
|
||||
NodeStreamPromises = 553,
|
||||
NodeStreamWeb = 554,
|
||||
NodeTimers = 555,
|
||||
NodeTimersPromises = 556,
|
||||
NodeTLS = 557,
|
||||
NodeTraceEvents = 558,
|
||||
NodeTty = 559,
|
||||
NodeUrl = 560,
|
||||
NodeUtil = 561,
|
||||
NodeV8 = 562,
|
||||
NodeVM = 563,
|
||||
NodeWasi = 564,
|
||||
NodeWorkerThreads = 565,
|
||||
NodeZlib = 566,
|
||||
ThirdpartyDepd = 567,
|
||||
ThirdpartyDetectLibc = 568,
|
||||
ThirdpartyDetectLibcLinux = 569,
|
||||
ThirdpartyIsomorphicFetch = 570,
|
||||
ThirdpartyNodeFetch = 571,
|
||||
ThirdpartyUndici = 572,
|
||||
ThirdpartyVercelFetch = 573,
|
||||
ThirdpartyWS = 574,
|
||||
|
||||
// Native modules run through the same system, but with different underlying initializers.
|
||||
// They also have bit 10 set to differentiate them from JS builtins.
|
||||
|
||||
6
src/js/out/WebCoreJSBuiltins.cpp
generated
6
src/js/out/WebCoreJSBuiltins.cpp
generated
File diff suppressed because one or more lines are too long
1
src/js/private.d.ts
vendored
1
src/js/private.d.ts
vendored
@@ -172,6 +172,7 @@ interface BunLazyModules {
|
||||
ReadableState: Function;
|
||||
};
|
||||
sqlite: any;
|
||||
"bun:sql": any;
|
||||
"vm": {
|
||||
createContext: Function;
|
||||
isContext: Function;
|
||||
|
||||
@@ -46,6 +46,7 @@ pub const API = struct {
|
||||
pub const TLSSocket = @import("./bun.js/api/bun/socket.zig").TLSSocket;
|
||||
pub const Listener = @import("./bun.js/api/bun/socket.zig").Listener;
|
||||
};
|
||||
pub const Postgres = @import("./sql/postgres.zig");
|
||||
pub const DNS = @import("./bun.js/api/bun/dns_resolver.zig");
|
||||
pub const FFI = @import("./bun.js/api/ffi.zig").FFI;
|
||||
pub const Node = struct {
|
||||
@@ -86,3 +87,6 @@ pub const Subprocess = @import("./bun.js/api/bun.zig").Subprocess;
|
||||
/// 5. make clean-bindings && make bindings -j10
|
||||
///
|
||||
pub const Codegen = @import("./bun.js/bindings/generated_classes.zig");
|
||||
|
||||
pub const Weak = @import("./bun.js/Weak.zig").Weak;
|
||||
pub const NewWeakFinalizer = @import("./bun.js/Weak.zig").NewWeakFinalizer;
|
||||
|
||||
3328
src/sql/postgres.zig
Normal file
3328
src/sql/postgres.zig
Normal file
File diff suppressed because it is too large
Load Diff
@@ -487,6 +487,17 @@ pub const String = extern struct {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn fromJSRef(value: bun.JSC.JSValue, globalObject: *JSC.JSGlobalObject) String {
|
||||
JSC.markBinding(@src());
|
||||
|
||||
var out: String = String.dead;
|
||||
if (BunString__fromJSRef(globalObject, value, &out)) {
|
||||
return out;
|
||||
} else {
|
||||
return String.dead;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn tryFromJS(value: bun.JSC.JSValue, globalObject: *JSC.JSGlobalObject) ?String {
|
||||
JSC.markBinding(@src());
|
||||
|
||||
@@ -690,11 +701,18 @@ pub const String = extern struct {
|
||||
};
|
||||
}
|
||||
|
||||
extern fn Bun__parseDate(*JSC.JSGlobalObject, *String) f64;
|
||||
extern fn BunString__fromJS(globalObject: *JSC.JSGlobalObject, value: bun.JSC.JSValue, out: *String) bool;
|
||||
extern fn BunString__fromJSRef(globalObject: *JSC.JSGlobalObject, value: bun.JSC.JSValue, out: *String) bool;
|
||||
extern fn BunString__toJS(globalObject: *JSC.JSGlobalObject, in: *String) JSC.JSValue;
|
||||
extern fn BunString__toJSWithLength(globalObject: *JSC.JSGlobalObject, in: *String, usize) JSC.JSValue;
|
||||
extern fn BunString__toWTFString(this: *String) void;
|
||||
|
||||
pub fn parseDate(this: *String, globalObject: *JSC.JSGlobalObject) f64 {
|
||||
JSC.markBinding(@src());
|
||||
return Bun__parseDate(globalObject, this);
|
||||
}
|
||||
|
||||
pub fn ref(this: String) void {
|
||||
switch (this.tag) {
|
||||
.WTFStringImpl => this.value.WTFStringImpl.ref(),
|
||||
|
||||
34
test/js/sql/bootstrap.js
vendored
Normal file
34
test/js/sql/bootstrap.js
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
import { spawnSync } from "child_process";
|
||||
|
||||
exec("dropdb", ["bun_sql_test"]);
|
||||
|
||||
// Needs to have a server.crt file https://www.postgresql.org/docs/current/ssl-tcp.html#SSL-CERTIFICATE-CREATION
|
||||
// exec('psql', ['-c', 'alter system set ssl=on'])
|
||||
exec("psql", ["-c", "drop user bun_sql_test"]);
|
||||
exec("psql", ["-c", "create user bun_sql_test"]);
|
||||
exec("psql", ["-c", "alter system set password_encryption=md5"]);
|
||||
exec("psql", ["-c", "select pg_reload_conf()"]);
|
||||
exec("psql", ["-c", "drop user if exists bun_sql_test_md5"]);
|
||||
exec("psql", ["-c", "create user bun_sql_test_md5 with password 'bun_sql_test_md5'"]);
|
||||
exec("psql", ["-c", "alter system set password_encryption='scram-sha-256'"]);
|
||||
exec("psql", ["-c", "select pg_reload_conf()"]);
|
||||
exec("psql", ["-c", "drop user if exists bun_sql_test_scram"]);
|
||||
exec("psql", ["-c", "create user bun_sql_test_scram with password 'bun_sql_test_scram'"]);
|
||||
|
||||
exec("createdb", ["bun_sql_test"]);
|
||||
exec("psql", ["-c", "grant all on database bun_sql_test to bun_sql_test"]);
|
||||
exec("psql", ["-c", "alter database bun_sql_test owner to bun_sql_test"]);
|
||||
|
||||
export function exec(cmd, args) {
|
||||
const { stderr } = spawnSync(cmd, args, { stdio: "pipe", encoding: "utf8" });
|
||||
if (stderr && !stderr.includes("already exists") && !stderr.includes("does not exist")) throw stderr;
|
||||
}
|
||||
|
||||
async function execAsync(cmd, args) {
|
||||
// eslint-disable-line
|
||||
let stderr = "";
|
||||
const cp = await spawn(cmd, args, { stdio: "pipe", encoding: "utf8" }); // eslint-disable-line
|
||||
cp.stderr.on("data", x => (stderr += x));
|
||||
await new Promise(x => cp.on("exit", x));
|
||||
if (stderr && !stderr.includes("already exists") && !stderr.includes("does not exist")) throw new Error(stderr);
|
||||
}
|
||||
2525
test/js/sql/sql.test.ts
Normal file
2525
test/js/sql/sql.test.ts
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user