aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/bindings
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-01-02 21:05:56 -0800
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-01-02 21:05:56 -0800
commitea2b65d4834d864029299809fb23f40ba2a56f90 (patch)
treeb178b1c6327ed9b450b8764b0c13dea63112ee55 /src/bun.js/bindings
parent80c2da73ef59f0170f1c92551c948a1b285da17c (diff)
downloadbun-jarred/pg.tar.gz
bun-jarred/pg.tar.zst
bun-jarred/pg.zip
Draw the owljarred/pg
Diffstat (limited to 'src/bun.js/bindings')
-rw-r--r--src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h1
-rw-r--r--src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h1
-rw-r--r--src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h6
-rw-r--r--src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h7
-rw-r--r--src/bun.js/bindings/ZigGeneratedClasses.cpp316
-rw-r--r--src/bun.js/bindings/ZigGeneratedClasses.h87
-rw-r--r--src/bun.js/bindings/ZigGlobalObject.cpp8
-rw-r--r--src/bun.js/bindings/bindings.zig16
-rw-r--r--src/bun.js/bindings/generated_classes.zig180
-rw-r--r--src/bun.js/bindings/generated_classes_list.zig1
10 files changed, 619 insertions, 4 deletions
diff --git a/src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h b/src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h
index f74d54b02..b7c50465d 100644
--- a/src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h
+++ b/src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h
@@ -14,6 +14,7 @@ std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForSHA512_256Constructor;
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForCryptoHasherConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForServerWebSocket;
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForServerWebSocketConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForFileSystemRouter;
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForFileSystemRouterConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForMatchedRoute;
+std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForPostgresSQLDatabase;
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForExpect;
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForExpectConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForTextDecoder;
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForTextDecoderConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForRequest;
diff --git a/src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h b/src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h
index cda555fa9..ea7457ed2 100644
--- a/src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h
+++ b/src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h
@@ -14,6 +14,7 @@ std::unique_ptr<IsoSubspace> m_subspaceForSHA512_256Constructor;std::unique_ptr<
std::unique_ptr<IsoSubspace> m_subspaceForCryptoHasherConstructor;std::unique_ptr<IsoSubspace> m_subspaceForServerWebSocket;
std::unique_ptr<IsoSubspace> m_subspaceForServerWebSocketConstructor;std::unique_ptr<IsoSubspace> m_subspaceForFileSystemRouter;
std::unique_ptr<IsoSubspace> m_subspaceForFileSystemRouterConstructor;std::unique_ptr<IsoSubspace> m_subspaceForMatchedRoute;
+std::unique_ptr<IsoSubspace> m_subspaceForPostgresSQLDatabase;
std::unique_ptr<IsoSubspace> m_subspaceForExpect;
std::unique_ptr<IsoSubspace> m_subspaceForExpectConstructor;std::unique_ptr<IsoSubspace> m_subspaceForTextDecoder;
std::unique_ptr<IsoSubspace> m_subspaceForTextDecoderConstructor;std::unique_ptr<IsoSubspace> m_subspaceForRequest;
diff --git a/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h b/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h
index 2c0cf9929..6cc13981f 100644
--- a/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h
+++ b/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h
@@ -94,6 +94,12 @@ JSC::Structure* JSMatchedRouteStructure() { return m_JSMatchedRoute.getInitializ
JSC::LazyClassStructure m_JSMatchedRoute;
bool hasJSMatchedRouteSetterValue { false };
mutable JSC::WriteBarrier<JSC::Unknown> m_JSMatchedRouteSetterValue;
+JSC::Structure* JSPostgresSQLDatabaseStructure() { return m_JSPostgresSQLDatabase.getInitializedOnMainThread(this); }
+ JSC::JSObject* JSPostgresSQLDatabaseConstructor() { return m_JSPostgresSQLDatabase.constructorInitializedOnMainThread(this); }
+ JSC::JSValue JSPostgresSQLDatabasePrototype() { return m_JSPostgresSQLDatabase.prototypeInitializedOnMainThread(this); }
+ JSC::LazyClassStructure m_JSPostgresSQLDatabase;
+ bool hasJSPostgresSQLDatabaseSetterValue { false };
+ mutable JSC::WriteBarrier<JSC::Unknown> m_JSPostgresSQLDatabaseSetterValue;
JSC::Structure* JSExpectStructure() { return m_JSExpect.getInitializedOnMainThread(this); }
JSC::JSObject* JSExpectConstructor() { return m_JSExpect.constructorInitializedOnMainThread(this); }
JSC::JSValue JSExpectPrototype() { return m_JSExpect.prototypeInitializedOnMainThread(this); }
diff --git a/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h b/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h
index 8b4240876..987b298a3 100644
--- a/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h
+++ b/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h
@@ -95,6 +95,12 @@ void GlobalObject::initGeneratedLazyClasses() {
init.setStructure(WebCore::JSMatchedRoute::createStructure(init.vm, init.global, init.prototype));
});
+ m_JSPostgresSQLDatabase.initLater(
+ [](LazyClassStructure::Initializer& init) {
+ init.setPrototype(WebCore::JSPostgresSQLDatabase::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global)));
+ init.setStructure(WebCore::JSPostgresSQLDatabase::createStructure(init.vm, init.global, init.prototype));
+
+ });
m_JSExpect.initLater(
[](LazyClassStructure::Initializer& init) {
init.setPrototype(WebCore::JSExpect::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global)));
@@ -157,6 +163,7 @@ void GlobalObject::visitGeneratedLazyClasses(GlobalObject *thisObject, Visitor&
thisObject->m_JSServerWebSocket.visit(visitor); visitor.append(thisObject->m_JSServerWebSocketSetterValue);
thisObject->m_JSFileSystemRouter.visit(visitor); visitor.append(thisObject->m_JSFileSystemRouterSetterValue);
thisObject->m_JSMatchedRoute.visit(visitor); visitor.append(thisObject->m_JSMatchedRouteSetterValue);
+ thisObject->m_JSPostgresSQLDatabase.visit(visitor); visitor.append(thisObject->m_JSPostgresSQLDatabaseSetterValue);
thisObject->m_JSExpect.visit(visitor); visitor.append(thisObject->m_JSExpectSetterValue);
thisObject->m_JSTextDecoder.visit(visitor); visitor.append(thisObject->m_JSTextDecoderSetterValue);
thisObject->m_JSRequest.visit(visitor); visitor.append(thisObject->m_JSRequestSetterValue);
diff --git a/src/bun.js/bindings/ZigGeneratedClasses.cpp b/src/bun.js/bindings/ZigGeneratedClasses.cpp
index b649229d4..cf7bb2603 100644
--- a/src/bun.js/bindings/ZigGeneratedClasses.cpp
+++ b/src/bun.js/bindings/ZigGeneratedClasses.cpp
@@ -6243,6 +6243,322 @@ void JSMatchedRoute::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
}
DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSMatchedRoute);
+class JSPostgresSQLDatabasePrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+
+ static JSPostgresSQLDatabasePrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSPostgresSQLDatabasePrototype* ptr = new (NotNull, JSC::allocateCell<JSPostgresSQLDatabasePrototype>(vm)) JSPostgresSQLDatabasePrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm, globalObject);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ 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:
+ JSPostgresSQLDatabasePrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
+};
+
+extern "C" void PostgresSQLDatabaseClass__finalize(void*);
+
+extern "C" EncodedJSValue PostgresSQLDatabasePrototype__close(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
+JSC_DECLARE_HOST_FUNCTION(PostgresSQLDatabasePrototype__closeCallback);
+
+extern "C" EncodedJSValue PostgresSQLDatabasePrototype__query(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
+JSC_DECLARE_HOST_FUNCTION(PostgresSQLDatabasePrototype__queryCallback);
+
+extern "C" EncodedJSValue PostgresSQLDatabasePrototype__ref(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
+JSC_DECLARE_HOST_FUNCTION(PostgresSQLDatabasePrototype__refCallback);
+
+extern "C" EncodedJSValue PostgresSQLDatabasePrototype__unref(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
+JSC_DECLARE_HOST_FUNCTION(PostgresSQLDatabasePrototype__unrefCallback);
+
+STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSPostgresSQLDatabasePrototype, JSPostgresSQLDatabasePrototype::Base);
+
+static const HashTableValue JSPostgresSQLDatabasePrototypeTableValues[] = {
+ { "close"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, PostgresSQLDatabasePrototype__closeCallback, 0 } },
+ { "query"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, PostgresSQLDatabasePrototype__queryCallback, 4 } },
+ { "ref"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, PostgresSQLDatabasePrototype__refCallback, 0 } },
+ { "unref"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, PostgresSQLDatabasePrototype__unrefCallback, 0 } }
+};
+
+const ClassInfo JSPostgresSQLDatabasePrototype::s_info = { "PostgresSQLDatabase"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSPostgresSQLDatabasePrototype) };
+
+JSC_DEFINE_HOST_FUNCTION(PostgresSQLDatabasePrototype__closeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
+
+ JSPostgresSQLDatabase* thisObject = jsDynamicCast<JSPostgresSQLDatabase*>(callFrame->thisValue());
+
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ }
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return PostgresSQLDatabasePrototype__close(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
+
+JSC_DEFINE_HOST_FUNCTION(PostgresSQLDatabasePrototype__queryCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
+
+ JSPostgresSQLDatabase* thisObject = jsDynamicCast<JSPostgresSQLDatabase*>(callFrame->thisValue());
+
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ }
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return PostgresSQLDatabasePrototype__query(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
+
+JSC_DEFINE_HOST_FUNCTION(PostgresSQLDatabasePrototype__refCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
+
+ JSPostgresSQLDatabase* thisObject = jsDynamicCast<JSPostgresSQLDatabase*>(callFrame->thisValue());
+
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ }
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return PostgresSQLDatabasePrototype__ref(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
+
+JSC_DEFINE_HOST_FUNCTION(PostgresSQLDatabasePrototype__unrefCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
+
+ JSPostgresSQLDatabase* thisObject = jsDynamicCast<JSPostgresSQLDatabase*>(callFrame->thisValue());
+
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ }
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return PostgresSQLDatabasePrototype__unref(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
+
+extern "C" void PostgresSQLDatabasePrototype__onCloseSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSPostgresSQLDatabase*>(JSValue::decode(thisValue));
+ thisObject->m_onClose.set(vm, thisObject, JSValue::decode(value));
+}
+
+extern "C" EncodedJSValue PostgresSQLDatabasePrototype__onCloseGetCachedValue(JSC::EncodedJSValue thisValue)
+{
+ auto* thisObject = jsCast<JSPostgresSQLDatabase*>(JSValue::decode(thisValue));
+ return JSValue::encode(thisObject->m_onClose.get());
+}
+
+extern "C" void PostgresSQLDatabasePrototype__onNoticeSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSPostgresSQLDatabase*>(JSValue::decode(thisValue));
+ thisObject->m_onNotice.set(vm, thisObject, JSValue::decode(value));
+}
+
+extern "C" EncodedJSValue PostgresSQLDatabasePrototype__onNoticeGetCachedValue(JSC::EncodedJSValue thisValue)
+{
+ auto* thisObject = jsCast<JSPostgresSQLDatabase*>(JSValue::decode(thisValue));
+ return JSValue::encode(thisObject->m_onNotice.get());
+}
+
+extern "C" void PostgresSQLDatabasePrototype__onOpenSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSPostgresSQLDatabase*>(JSValue::decode(thisValue));
+ thisObject->m_onOpen.set(vm, thisObject, JSValue::decode(value));
+}
+
+extern "C" EncodedJSValue PostgresSQLDatabasePrototype__onOpenGetCachedValue(JSC::EncodedJSValue thisValue)
+{
+ auto* thisObject = jsCast<JSPostgresSQLDatabase*>(JSValue::decode(thisValue));
+ return JSValue::encode(thisObject->m_onOpen.get());
+}
+
+extern "C" void PostgresSQLDatabasePrototype__onTimeoutSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSPostgresSQLDatabase*>(JSValue::decode(thisValue));
+ thisObject->m_onTimeout.set(vm, thisObject, JSValue::decode(value));
+}
+
+extern "C" EncodedJSValue PostgresSQLDatabasePrototype__onTimeoutGetCachedValue(JSC::EncodedJSValue thisValue)
+{
+ auto* thisObject = jsCast<JSPostgresSQLDatabase*>(JSValue::decode(thisValue));
+ return JSValue::encode(thisObject->m_onTimeout.get());
+}
+
+extern "C" void PostgresSQLDatabasePrototype__onDrainSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSPostgresSQLDatabase*>(JSValue::decode(thisValue));
+ thisObject->m_onDrain.set(vm, thisObject, JSValue::decode(value));
+}
+
+extern "C" EncodedJSValue PostgresSQLDatabasePrototype__onDrainGetCachedValue(JSC::EncodedJSValue thisValue)
+{
+ auto* thisObject = jsCast<JSPostgresSQLDatabase*>(JSValue::decode(thisValue));
+ return JSValue::encode(thisObject->m_onDrain.get());
+}
+
+void JSPostgresSQLDatabasePrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
+{
+ Base::finishCreation(vm);
+ reifyStaticProperties(vm, JSPostgresSQLDatabase::info(), JSPostgresSQLDatabasePrototypeTableValues, *this);
+ JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
+}
+
+extern "C" bool PostgresSQLDatabase__hasPendingActivity(void* ptr);
+bool JSPostgresSQLDatabase::hasPendingActivity(void* ctx)
+{
+ return PostgresSQLDatabase__hasPendingActivity(ctx);
+}
+
+JSPostgresSQLDatabase::~JSPostgresSQLDatabase()
+{
+ if (m_ctx) {
+ PostgresSQLDatabaseClass__finalize(m_ctx);
+ }
+}
+void JSPostgresSQLDatabase::destroy(JSCell* cell)
+{
+ static_cast<JSPostgresSQLDatabase*>(cell)->JSPostgresSQLDatabase::~JSPostgresSQLDatabase();
+}
+
+const ClassInfo JSPostgresSQLDatabase::s_info = { "PostgresSQLDatabase"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSPostgresSQLDatabase) };
+
+void JSPostgresSQLDatabase::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ ASSERT(inherits(info()));
+}
+
+JSPostgresSQLDatabase* JSPostgresSQLDatabase::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx)
+{
+ JSPostgresSQLDatabase* ptr = new (NotNull, JSC::allocateCell<JSPostgresSQLDatabase>(vm)) JSPostgresSQLDatabase(vm, structure, ctx);
+ ptr->finishCreation(vm);
+ return ptr;
+}
+
+extern "C" void* PostgresSQLDatabase__fromJS(JSC::EncodedJSValue value)
+{
+ JSC::JSValue decodedValue = JSC::JSValue::decode(value);
+ if (!decodedValue || decodedValue.isUndefinedOrNull())
+ return nullptr;
+
+ JSPostgresSQLDatabase* object = JSC::jsDynamicCast<JSPostgresSQLDatabase*>(decodedValue);
+
+ if (!object)
+ return nullptr;
+
+ return object->wrapped();
+}
+
+extern "C" bool PostgresSQLDatabase__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr)
+{
+ JSPostgresSQLDatabase* object = JSC::jsDynamicCast<JSPostgresSQLDatabase*>(JSValue::decode(value));
+ if (!object)
+ return false;
+
+ object->m_ctx = ptr;
+ return true;
+}
+
+extern "C" const size_t PostgresSQLDatabase__ptrOffset = JSPostgresSQLDatabase::offsetOfWrapped();
+
+void JSPostgresSQLDatabase::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
+{
+ auto* thisObject = jsCast<JSPostgresSQLDatabase*>(cell);
+ if (void* wrapped = thisObject->wrapped()) {
+ // if (thisObject->scriptExecutionContext())
+ // analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
+ }
+ Base::analyzeHeap(cell, analyzer);
+}
+
+JSObject* JSPostgresSQLDatabase::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
+{
+ return JSPostgresSQLDatabasePrototype::create(vm, globalObject, JSPostgresSQLDatabasePrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
+}
+
+extern "C" EncodedJSValue PostgresSQLDatabase__create(Zig::GlobalObject* globalObject, void* ptr)
+{
+ auto& vm = globalObject->vm();
+ JSC::Structure* structure = globalObject->JSPostgresSQLDatabaseStructure();
+ JSPostgresSQLDatabase* instance = JSPostgresSQLDatabase::create(vm, globalObject, structure, ptr);
+
+ return JSValue::encode(instance);
+}
+
+template<typename Visitor>
+void JSPostgresSQLDatabase::visitChildrenImpl(JSCell* cell, Visitor& visitor)
+{
+ JSPostgresSQLDatabase* thisObject = jsCast<JSPostgresSQLDatabase*>(cell);
+ ASSERT_GC_OBJECT_INHERITS(thisObject, info());
+ Base::visitChildren(thisObject, visitor);
+ visitor.append(thisObject->m_onClose);
+ visitor.append(thisObject->m_onNotice);
+ visitor.append(thisObject->m_onOpen);
+ visitor.append(thisObject->m_onTimeout);
+ visitor.append(thisObject->m_onDrain);
+
+ visitor.addOpaqueRoot(thisObject->wrapped());
+}
+
+DEFINE_VISIT_CHILDREN(JSPostgresSQLDatabase);
+
+template<typename Visitor>
+void JSPostgresSQLDatabase::visitAdditionalChildren(Visitor& visitor)
+{
+ JSPostgresSQLDatabase* thisObject = this;
+ ASSERT_GC_OBJECT_INHERITS(thisObject, info());
+ visitor.append(thisObject->m_onClose);
+ visitor.append(thisObject->m_onNotice);
+ visitor.append(thisObject->m_onOpen);
+ visitor.append(thisObject->m_onTimeout);
+ visitor.append(thisObject->m_onDrain);
+
+ visitor.addOpaqueRoot(this->wrapped());
+}
+
+DEFINE_VISIT_ADDITIONAL_CHILDREN(JSPostgresSQLDatabase);
+
+template<typename Visitor>
+void JSPostgresSQLDatabase::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
+{
+ JSPostgresSQLDatabase* thisObject = jsCast<JSPostgresSQLDatabase*>(cell);
+ ASSERT_GC_OBJECT_INHERITS(thisObject, info());
+ thisObject->visitAdditionalChildren<Visitor>(visitor);
+}
+
+DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSPostgresSQLDatabase);
class JSExpectPrototype final : public JSC::JSNonFinalObject {
public:
using Base = JSC::JSNonFinalObject;
diff --git a/src/bun.js/bindings/ZigGeneratedClasses.h b/src/bun.js/bindings/ZigGeneratedClasses.h
index aee32a315..2423c973a 100644
--- a/src/bun.js/bindings/ZigGeneratedClasses.h
+++ b/src/bun.js/bindings/ZigGeneratedClasses.h
@@ -959,6 +959,93 @@ public:
mutable JSC::WriteBarrier<JSC::Unknown> m_scriptSrc;
};
+class JSPostgresSQLDatabase final : public JSC::JSDestructibleObject {
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSPostgresSQLDatabase* 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<JSPostgresSQLDatabase, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForPostgresSQLDatabase.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForPostgresSQLDatabase = WTFMove(space); },
+ [](auto& spaces) { return spaces.m_subspaceForPostgresSQLDatabase.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForPostgresSQLDatabase = WTFMove(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);
+ ;
+
+ ~JSPostgresSQLDatabase();
+
+ void* wrapped() const { return m_ctx; }
+
+ void detach()
+ {
+ m_ctx = nullptr;
+ }
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+ static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSPostgresSQLDatabase, m_ctx); }
+
+ void* m_ctx { nullptr };
+
+ JSPostgresSQLDatabase(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_ctx = sinkPtr;
+ m_weakThis = JSC::Weak<JSPostgresSQLDatabase>(this, getOwner());
+ }
+
+ void finishCreation(JSC::VM&);
+
+ JSC::Weak<JSPostgresSQLDatabase> 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<JSPostgresSQLDatabase*>(handle.slot()->asCell());
+ if (JSPostgresSQLDatabase::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_onClose;
+ mutable JSC::WriteBarrier<JSC::Unknown> m_onNotice;
+ mutable JSC::WriteBarrier<JSC::Unknown> m_onOpen;
+ mutable JSC::WriteBarrier<JSC::Unknown> m_onTimeout;
+ mutable JSC::WriteBarrier<JSC::Unknown> m_onDrain;
+};
+
class JSExpect final : public JSC::JSDestructibleObject {
public:
using Base = JSC::JSDestructibleObject;
diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp
index d8593a9fa..e5b55f177 100644
--- a/src/bun.js/bindings/ZigGlobalObject.cpp
+++ b/src/bun.js/bindings/ZigGlobalObject.cpp
@@ -1080,6 +1080,8 @@ enum ReadableStreamTag : int32_t {
Bytes = 4,
};
+extern "C" EncodedJSValue Bun__PostgreSQL__connect(JSGlobalObject*, CallFrame*);
+
// we're trying out a new way to do this lazy loading
static JSC_DEFINE_HOST_FUNCTION(functionLazyLoad,
(JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
@@ -1099,6 +1101,7 @@ JSC:
static NeverDestroyed<const String> bunStreamString(MAKE_STATIC_STRING_IMPL("bun:stream"));
static NeverDestroyed<const String> noopString(MAKE_STATIC_STRING_IMPL("noop"));
static NeverDestroyed<const String> createImportMeta(MAKE_STATIC_STRING_IMPL("createImportMeta"));
+ static NeverDestroyed<const String> bunSql(MAKE_STATIC_STRING_IMPL("bun:sql"));
JSC::JSValue moduleName = callFrame->argument(0);
if (moduleName.isNumber()) {
@@ -1154,6 +1157,11 @@ JSC:
JSFunction::create(vm, globalObject, 1, fileURLToPathString, functionFileURLToPath, ImplementationVisibility::Public, NoIntrinsic));
}
+ if (string == bunSql) {
+ return JSC::JSValue::encode(
+ JSFunction::create(vm, globalObject, 1, bunSql, Bun__PostgreSQL__connect, ImplementationVisibility::Public, NoIntrinsic));
+ }
+
if (string == bunStreamString) {
auto* obj = constructEmptyObject(globalObject);
obj->putDirect(vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "BufferList"_s)), reinterpret_cast<Zig::GlobalObject*>(globalObject)->JSBufferList(), 0);
diff --git a/src/bun.js/bindings/bindings.zig b/src/bun.js/bindings/bindings.zig
index 942d4b4f1..d11e30498 100644
--- a/src/bun.js/bindings/bindings.zig
+++ b/src/bun.js/bindings/bindings.zig
@@ -2030,7 +2030,7 @@ pub const JSGlobalObject = extern struct {
}
pub fn createErrorInstance(this: *JSGlobalObject, comptime fmt: string, args: anytype) JSValue {
- if (comptime std.meta.fieldNames(@TypeOf(args)).len > 0) {
+ if (comptime std.meta.fields(@TypeOf(args)).len > 0) {
var stack_fallback = std.heap.stackFallback(1024 * 4, this.allocator());
var buf = bun.MutableString.init2048(stack_fallback.get()) catch unreachable;
defer buf.deinit();
@@ -2077,11 +2077,19 @@ pub const JSGlobalObject = extern struct {
err: anyerror,
comptime fmt: string,
) void {
- var str = ZigString.init(std.fmt.allocPrint(this.bunVM().allocator, "{s} " ++ fmt, .{@errorName(err)}) catch return);
+ this.vm().throwError(this, this.createError(err, fmt));
+ }
+
+ pub fn createError(
+ this: *JSGlobalObject,
+ err: anyerror,
+ comptime fmt: string,
+ ) JSValue {
+ var str = ZigString.init(std.fmt.allocPrint(this.bunVM().allocator, "{s} " ++ fmt, .{@errorName(err)}) catch return ZigString.static("error").toErrorInstance(this));
str.markUTF8();
- var err_value = str.toErrorInstance(this);
- this.vm().throwError(this, err_value);
+ const instance = str.toErrorInstance(this);
this.bunVM().allocator.free(ZigString.untagged(str.ptr)[0..str.len]);
+ return instance;
}
pub fn handleError(
diff --git a/src/bun.js/bindings/generated_classes.zig b/src/bun.js/bindings/generated_classes.zig
index c64acbef5..d2d61d549 100644
--- a/src/bun.js/bindings/generated_classes.zig
+++ b/src/bun.js/bindings/generated_classes.zig
@@ -1970,6 +1970,185 @@ pub const JSMatchedRoute = struct {
}
}
};
+pub const JSPostgresSQLDatabase = struct {
+ const PostgresSQLDatabase = Classes.PostgresSQLDatabase;
+ const GetterType = fn (*PostgresSQLDatabase, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const GetterTypeWithThisValue = fn (*PostgresSQLDatabase, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const SetterType = fn (*PostgresSQLDatabase, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const SetterTypeWithThisValue = fn (*PostgresSQLDatabase, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const CallbackType = fn (*PostgresSQLDatabase, *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) ?*PostgresSQLDatabase {
+ JSC.markBinding(@src());
+ return PostgresSQLDatabase__fromJS(value);
+ }
+
+ extern fn PostgresSQLDatabasePrototype__onCloseSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+
+ extern fn PostgresSQLDatabasePrototype__onCloseGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `PostgresSQLDatabase.onClose` setter
+ /// This value will be visited by the garbage collector.
+ pub fn onCloseSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ PostgresSQLDatabasePrototype__onCloseSetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `PostgresSQLDatabase.onClose` getter
+ /// This value will be visited by the garbage collector.
+ pub fn onCloseGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = PostgresSQLDatabasePrototype__onCloseGetCachedValue(thisValue);
+ if (result == .zero)
+ return null;
+
+ return result;
+ }
+
+ extern fn PostgresSQLDatabasePrototype__onNoticeSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+
+ extern fn PostgresSQLDatabasePrototype__onNoticeGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `PostgresSQLDatabase.onNotice` setter
+ /// This value will be visited by the garbage collector.
+ pub fn onNoticeSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ PostgresSQLDatabasePrototype__onNoticeSetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `PostgresSQLDatabase.onNotice` getter
+ /// This value will be visited by the garbage collector.
+ pub fn onNoticeGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = PostgresSQLDatabasePrototype__onNoticeGetCachedValue(thisValue);
+ if (result == .zero)
+ return null;
+
+ return result;
+ }
+
+ extern fn PostgresSQLDatabasePrototype__onOpenSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+
+ extern fn PostgresSQLDatabasePrototype__onOpenGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `PostgresSQLDatabase.onOpen` setter
+ /// This value will be visited by the garbage collector.
+ pub fn onOpenSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ PostgresSQLDatabasePrototype__onOpenSetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `PostgresSQLDatabase.onOpen` getter
+ /// This value will be visited by the garbage collector.
+ pub fn onOpenGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = PostgresSQLDatabasePrototype__onOpenGetCachedValue(thisValue);
+ if (result == .zero)
+ return null;
+
+ return result;
+ }
+
+ extern fn PostgresSQLDatabasePrototype__onTimeoutSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+
+ extern fn PostgresSQLDatabasePrototype__onTimeoutGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `PostgresSQLDatabase.onTimeout` setter
+ /// This value will be visited by the garbage collector.
+ pub fn onTimeoutSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ PostgresSQLDatabasePrototype__onTimeoutSetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `PostgresSQLDatabase.onTimeout` getter
+ /// This value will be visited by the garbage collector.
+ pub fn onTimeoutGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = PostgresSQLDatabasePrototype__onTimeoutGetCachedValue(thisValue);
+ if (result == .zero)
+ return null;
+
+ return result;
+ }
+
+ extern fn PostgresSQLDatabasePrototype__onDrainSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+
+ extern fn PostgresSQLDatabasePrototype__onDrainGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `PostgresSQLDatabase.onDrain` setter
+ /// This value will be visited by the garbage collector.
+ pub fn onDrainSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ PostgresSQLDatabasePrototype__onDrainSetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `PostgresSQLDatabase.onDrain` getter
+ /// This value will be visited by the garbage collector.
+ pub fn onDrainGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = PostgresSQLDatabasePrototype__onDrainGetCachedValue(thisValue);
+ if (result == .zero)
+ return null;
+
+ return result;
+ }
+
+ /// Create a new instance of PostgresSQLDatabase
+ pub fn toJS(this: *PostgresSQLDatabase, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
+ JSC.markBinding(@src());
+ if (comptime Environment.allow_assert) {
+ const value__ = PostgresSQLDatabase__create(globalObject, this);
+ std.debug.assert(value__.as(PostgresSQLDatabase).? == this); // If this fails, likely a C ABI issue.
+ return value__;
+ } else {
+ return PostgresSQLDatabase__create(globalObject, this);
+ }
+ }
+
+ /// Modify the internal ptr to point to a new instance of PostgresSQLDatabase.
+ pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*PostgresSQLDatabase) bool {
+ JSC.markBinding(@src());
+ return PostgresSQLDatabase__dangerouslySetPtr(value, ptr);
+ }
+
+ /// Detach the ptr from the thisValue
+ pub fn detachPtr(_: *PostgresSQLDatabase, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ std.debug.assert(PostgresSQLDatabase__dangerouslySetPtr(value, null));
+ }
+
+ extern fn PostgresSQLDatabase__fromJS(JSC.JSValue) ?*PostgresSQLDatabase;
+ extern fn PostgresSQLDatabase__getConstructor(*JSC.JSGlobalObject) JSC.JSValue;
+
+ extern fn PostgresSQLDatabase__create(globalObject: *JSC.JSGlobalObject, ptr: ?*PostgresSQLDatabase) JSC.JSValue;
+
+ extern fn PostgresSQLDatabase__dangerouslySetPtr(JSC.JSValue, ?*PostgresSQLDatabase) bool;
+
+ comptime {
+ if (@TypeOf(PostgresSQLDatabase.finalize) != (fn (*PostgresSQLDatabase) callconv(.C) void)) {
+ @compileLog("PostgresSQLDatabase.finalize is not a finalizer");
+ }
+
+ if (@TypeOf(PostgresSQLDatabase.close) != CallbackType)
+ @compileLog("Expected PostgresSQLDatabase.close to be a callback but received " ++ @typeName(@TypeOf(PostgresSQLDatabase.close)));
+ if (@TypeOf(PostgresSQLDatabase.query) != CallbackType)
+ @compileLog("Expected PostgresSQLDatabase.query to be a callback but received " ++ @typeName(@TypeOf(PostgresSQLDatabase.query)));
+ if (@TypeOf(PostgresSQLDatabase.ref) != CallbackType)
+ @compileLog("Expected PostgresSQLDatabase.ref to be a callback but received " ++ @typeName(@TypeOf(PostgresSQLDatabase.ref)));
+ if (@TypeOf(PostgresSQLDatabase.unref) != CallbackType)
+ @compileLog("Expected PostgresSQLDatabase.unref to be a callback but received " ++ @typeName(@TypeOf(PostgresSQLDatabase.unref)));
+ if (!JSC.is_bindgen) {
+ @export(PostgresSQLDatabase.close, .{ .name = "PostgresSQLDatabasePrototype__close" });
+ @export(PostgresSQLDatabase.finalize, .{ .name = "PostgresSQLDatabaseClass__finalize" });
+ @export(PostgresSQLDatabase.hasPendingActivity, .{ .name = "PostgresSQLDatabase__hasPendingActivity" });
+ @export(PostgresSQLDatabase.query, .{ .name = "PostgresSQLDatabasePrototype__query" });
+ @export(PostgresSQLDatabase.ref, .{ .name = "PostgresSQLDatabasePrototype__ref" });
+ @export(PostgresSQLDatabase.unref, .{ .name = "PostgresSQLDatabasePrototype__unref" });
+ }
+ }
+};
pub const JSExpect = struct {
const Expect = Classes.Expect;
const GetterType = fn (*Expect, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
@@ -3306,6 +3485,7 @@ comptime {
_ = JSServerWebSocket;
_ = JSFileSystemRouter;
_ = JSMatchedRoute;
+ _ = JSPostgresSQLDatabase;
_ = JSExpect;
_ = JSTextDecoder;
_ = JSRequest;
diff --git a/src/bun.js/bindings/generated_classes_list.zig b/src/bun.js/bindings/generated_classes_list.zig
index 2eaf30e04..f5ae68260 100644
--- a/src/bun.js/bindings/generated_classes_list.zig
+++ b/src/bun.js/bindings/generated_classes_list.zig
@@ -24,4 +24,5 @@ pub const Classes = struct {
pub const MatchedRoute = JSC.API.MatchedRoute;
pub const Dirent = JSC.Node.Dirent;
pub const NodeJSFS = JSC.Node.NodeJSFS;
+ pub const PostgresSQLDatabase = JSC.API.Bun.PostgresSQLDatabase;
};