aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-10-14 16:24:59 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-10-14 16:24:59 -0700
commit802a6731d59c447ae513131290990357e8d778c1 (patch)
treeee6cc019318d1c52cafaca1f151f96812e03e041
parent7f5eddc09668592c754d6aad12015b8144d15a76 (diff)
downloadbun-802a6731d59c447ae513131290990357e8d778c1.tar.gz
bun-802a6731d59c447ae513131290990357e8d778c1.tar.zst
bun-802a6731d59c447ae513131290990357e8d778c1.zip
wip
-rw-r--r--src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h4
-rw-r--r--src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h4
-rw-r--r--src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h8
-rw-r--r--src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h14
-rw-r--r--src/bun.js/bindings/ZigGeneratedClasses.cpp813
-rw-r--r--src/bun.js/bindings/ZigGeneratedClasses.h137
-rw-r--r--src/bun.js/bindings/generated_classes.zig191
-rw-r--r--src/sql/postgres.zig39
8 files changed, 1194 insertions, 16 deletions
diff --git a/src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h b/src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h
index cef5c512a..c5aed565e 100644
--- a/src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h
+++ b/src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h
@@ -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;
diff --git a/src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h b/src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h
index d06451eda..40a781f39 100644
--- a/src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h
+++ b/src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h
@@ -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;
diff --git a/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h b/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h
index 381378262..445e0167e 100644
--- a/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h
+++ b/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h
@@ -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); }
diff --git a/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h b/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h
index 84d3df7a0..94d43e760 100644
--- a/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h
+++ b/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h
@@ -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);
diff --git a/src/bun.js/bindings/ZigGeneratedClasses.cpp b/src/bun.js/bindings/ZigGeneratedClasses.cpp
index 6e3a2e1e5..0a5ec7170 100644
--- a/src/bun.js/bindings/ZigGeneratedClasses.cpp
+++ b/src/bun.js/bindings/ZigGeneratedClasses.cpp
@@ -17202,6 +17202,819 @@ 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)
+ {
+ 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)
+ {
+ 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__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 } },
+ { "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__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());
+}
+
+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());
+}
+
+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);
+}
+
+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;
diff --git a/src/bun.js/bindings/ZigGeneratedClasses.h b/src/bun.js/bindings/ZigGeneratedClasses.h
index 33aa58487..2fbb8fa01 100644
--- a/src/bun.js/bindings/ZigGeneratedClasses.h
+++ b/src/bun.js/bindings/ZigGeneratedClasses.h
@@ -1802,6 +1802,143 @@ 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;
+ }
+
+ void finishCreation(JSC::VM&);
+
+ DECLARE_VISIT_CHILDREN;
+ template<typename Visitor> void visitAdditionalChildren(Visitor&);
+ DECLARE_VISIT_OUTPUT_CONSTRAINTS;
+
+ mutable JSC::WriteBarrier<JSC::Unknown> m_pendingValue;
+};
+
class JSRequest final : public JSC::JSDestructibleObject {
public:
using Base = JSC::JSDestructibleObject;
diff --git a/src/bun.js/bindings/generated_classes.zig b/src/bun.js/bindings/generated_classes.zig
index c44d554fc..53e97c306 100644
--- a/src/bun.js/bindings/generated_classes.zig
+++ b/src/bun.js/bindings/generated_classes.zig
@@ -4324,6 +4324,195 @@ 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;
+ }
+
+ /// 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.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.doRun, .{ .name = "PostgresSQLQueryPrototype__doRun" });
+ @export(PostgresSQLQuery.estimatedSize, .{ .name = "PostgresSQLQuery__estimatedSize" });
+ @export(PostgresSQLQuery.finalize, .{ .name = "PostgresSQLQueryClass__finalize" });
+ }
+ }
+};
pub const JSRequest = struct {
const Request = Classes.Request;
const GetterType = fn (*Request, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
@@ -7120,6 +7309,8 @@ comptime {
_ = JSMD5;
_ = JSMatchedRoute;
_ = JSNodeJSFS;
+ _ = JSPostgresSQLConnection;
+ _ = JSPostgresSQLQuery;
_ = JSRequest;
_ = JSResolveMessage;
_ = JSResponse;
diff --git a/src/sql/postgres.zig b/src/sql/postgres.zig
index 452457826..383d89fe6 100644
--- a/src/sql/postgres.zig
+++ b/src/sql/postgres.zig
@@ -1367,6 +1367,8 @@ pub const PostgresSQLQuery = struct {
cursor_name: bun.String = bun.String.empty,
thisValue: JSC.JSValue = .undefined,
+ pub usingnamespace JSC.Codegen.JSPostgresSQLQuery;
+
pub fn constructor(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) ?*PostgresSQLQuery {
_ = globalThis;
const args_ = callframe.arguments(3);
@@ -1374,6 +1376,16 @@ pub const PostgresSQLQuery = struct {
_ = args;
}
+ pub fn push(this: *PostgresSQLQuery, globalThis: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ var pending_value = PostgresSQLQuery.pendingValueGetCached(this.thisValue);
+ if (pending_value.isEmptyOrUndefinedOrNull()) {
+ pending_value = JSC.JSValue.createEmptyArray(globalThis, 0);
+ PostgresSQLQuery.pendingValueSetCached(this.thisValue, globalThis, pending_value);
+ }
+
+ pending_value.push(globalThis, value);
+ }
+
pub fn doRun(this: *PostgresSQLQuery, globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSC.JSValue {
var arguments_ = callframe.arguments(3);
const arguments = arguments_.slice();
@@ -1734,9 +1746,9 @@ pub const PostgresSQLConnection = struct {
pub fn put(this: *const CellPutter, index_: i16, optional_bytes: ?*Data) anyerror!bool {
const index: u32 = @intCast(index_);
- const putDirectIndex = JSC.JSObject.putDirectIndex;
+ const putDirectOffset = JSC.JSObject.putDirectOffset;
var bytes_ = optional_bytes orelse {
- putDirectIndex(this.vm, this.object, index, JSC.JSValue.jsNull());
+ putDirectOffset(this.vm, this.object, index, JSC.JSValue.jsNull());
return true;
};
defer bytes_.deinit();
@@ -1746,40 +1758,40 @@ pub const PostgresSQLConnection = struct {
.number => {
switch (bytes.len) {
0 => {
- putDirectIndex(this.vm, index, JSC.JSValue.jsNull());
+ putDirectOffset(this.vm, index, JSC.JSValue.jsNull());
},
2 => {
- putDirectIndex(this.vm, index, JSC.JSValue.jsNumber(@bitCast(@as(i16, @bitCast(bytes[0..2])))));
+ putDirectOffset(this.vm, index, JSC.JSValue.jsNumber(@bitCast(@as(i16, @bitCast(bytes[0..2])))));
},
4 => {
- putDirectIndex(this.vm, index, JSC.JSValue.jsNumber(@bitCast(@as(i32, @bitCast(bytes[0..4])))));
+ putDirectOffset(this.vm, index, JSC.JSValue.jsNumber(@bitCast(@as(i32, @bitCast(bytes[0..4])))));
},
else => {
var eight: usize = 0;
@memcpy(@as(*[8]u8, @ptrCast(&eight))[0..bytes.len], bytes[0..@min(8, bytes.len)]);
eight = @byteSwap(eight);
- putDirectIndex(this.vm, index, JSC.JSValue.jsNumber(@bitCast(@as(f64, eight))));
+ putDirectOffset(this.vm, index, JSC.JSValue.jsNumber(@bitCast(@as(f64, eight))));
},
}
},
.json => {
var str = bun.String.fromUTF8(bytes.slice());
defer str.deref();
- putDirectIndex(this.vm, index, str.toJSForParseJSON(this.globalObject));
+ putDirectOffset(this.vm, index, str.toJSForParseJSON(this.globalObject));
},
.boolean => {
- putDirectIndex(this.vm, index, JSC.JSValue.jsBoolean(bytes.len > 0 and bytes[0] == 't'));
+ putDirectOffset(this.vm, index, JSC.JSValue.jsBoolean(bytes.len > 0 and bytes[0] == 't'));
},
.time, .datetime, .date => {
- putDirectIndex(this.vm, index, JSC.JSValue.fromDateString(bytes_.sliceZ()));
+ putDirectOffset(this.vm, index, JSC.JSValue.fromDateString(bytes_.sliceZ()));
},
.bytea => {
- putDirectIndex(this.vm, index, JSC.JSValue.createBuffer(this.globalObject, bytes, null));
+ putDirectOffset(this.vm, index, JSC.JSValue.createBuffer(this.globalObject, bytes, null));
},
else => {
var str = bun.String.fromUTF8(bytes.slice());
defer str.deref();
- putDirectIndex(this.vm, index, str.toJS(this.globalObject));
+ putDirectOffset(this.vm, index, str.toJS(this.globalObject));
},
}
return true;
@@ -1797,6 +1809,7 @@ pub const PostgresSQLConnection = struct {
std.debug.assert(!structure.isEmptyOrUndefinedOrNull());
var row = JSC.JSObject.uninitialized(structure.asCell(), this.globalObject);
+ row.ensureStillAlive();
var putter = CellPutter{
.object = row,
.vm = this.globalObject.vm(),
@@ -1811,9 +1824,7 @@ pub const PostgresSQLConnection = struct {
);
request.push(row);
},
- .CopyData => {
-
- },
+ .CopyData => {},
.ParameterStatus => {},
.ReadyForQuery => {},
.CommandComplete => {},