aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-02-22 15:51:41 -0800
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-02-22 15:51:41 -0800
commit27be64cf12b8a2096ebb464106d6cfa992c289cf (patch)
treeb74a53be64bceafb62749a496a88d24e8c2f0e8c
parent4dd647290825040b69742993955e7d2dcfea65ba (diff)
downloadbun-27be64cf12b8a2096ebb464106d6cfa992c289cf.tar.gz
bun-27be64cf12b8a2096ebb464106d6cfa992c289cf.tar.zst
bun-27be64cf12b8a2096ebb464106d6cfa992c289cf.zip
Make format consistent with WebKit
-rw-r--r--src/javascript/jsc/bindings/BunClientData.cpp18
-rw-r--r--src/javascript/jsc/bindings/BunClientData.h33
-rw-r--r--src/javascript/jsc/bindings/BunStream.cpp700
-rw-r--r--src/javascript/jsc/bindings/BunStream.h136
-rw-r--r--src/javascript/jsc/bindings/Path.cpp193
-rw-r--r--src/javascript/jsc/bindings/Path.h49
-rw-r--r--src/javascript/jsc/bindings/Process.cpp469
-rw-r--r--src/javascript/jsc/bindings/Process.h58
-rw-r--r--src/javascript/jsc/bindings/ZigConsoleClient.cpp189
-rw-r--r--src/javascript/jsc/bindings/ZigConsoleClient.h77
-rw-r--r--src/javascript/jsc/bindings/ZigGlobalObject.cpp921
-rw-r--r--src/javascript/jsc/bindings/ZigGlobalObject.h146
-rw-r--r--src/javascript/jsc/bindings/ZigSourceProvider.cpp257
-rw-r--r--src/javascript/jsc/bindings/ZigSourceProvider.h96
-rw-r--r--src/javascript/jsc/bindings/bindings.cpp3384
-rw-r--r--src/javascript/jsc/bindings/headers-handwritten.h170
-rw-r--r--src/javascript/jsc/bindings/headers.h491
-rw-r--r--src/javascript/jsc/bindings/helpers.h295
-rw-r--r--src/javascript/jsc/bindings/objects.h20
-rw-r--r--src/javascript/jsc/bindings/root.h4
20 files changed, 4110 insertions, 3596 deletions
diff --git a/src/javascript/jsc/bindings/BunClientData.cpp b/src/javascript/jsc/bindings/BunClientData.cpp
index a86720a85..21db7cb7f 100644
--- a/src/javascript/jsc/bindings/BunClientData.cpp
+++ b/src/javascript/jsc/bindings/BunClientData.cpp
@@ -16,18 +16,22 @@
namespace Bun {
using namespace JSC;
-JSVMClientData::JSVMClientData(VM &vm) : m_builtinNames(vm) {}
+JSVMClientData::JSVMClientData(VM& vm)
+ : m_builtinNames(vm)
+{
+}
JSVMClientData::~JSVMClientData() {}
-void JSVMClientData::create(VM *vm) {
- JSVMClientData *clientData = new JSVMClientData(*vm);
- vm->clientData = clientData; // ~VM deletes this pointer.
+void JSVMClientData::create(VM* vm)
+{
+ JSVMClientData* clientData = new JSVMClientData(*vm);
+ vm->clientData = clientData; // ~VM deletes this pointer.
- // vm->heap.addMarkingConstraint(makeUnique<BunGCOutputConstraint>(*vm, *clientData));
+ // vm->heap.addMarkingConstraint(makeUnique<BunGCOutputConstraint>(*vm, *clientData));
- // vm->m_typedArrayController = adoptRef(new WebCoreTypedArrayController(
- // type == WorkerThreadType::DedicatedWorker || type == WorkerThreadType::Worklet));
+ // vm->m_typedArrayController = adoptRef(new WebCoreTypedArrayController(
+ // type == WorkerThreadType::DedicatedWorker || type == WorkerThreadType::Worklet));
}
} // namespace Bun \ No newline at end of file
diff --git a/src/javascript/jsc/bindings/BunClientData.h b/src/javascript/jsc/bindings/BunClientData.h
index cd506365f..6e3747bb1 100644
--- a/src/javascript/jsc/bindings/BunClientData.h
+++ b/src/javascript/jsc/bindings/BunClientData.h
@@ -10,32 +10,33 @@ namespace Bun {
using namespace JSC;
class JSVMClientData : public JSC::VM::ClientData {
- WTF_MAKE_NONCOPYABLE(JSVMClientData);
- WTF_MAKE_FAST_ALLOCATED;
+ WTF_MAKE_NONCOPYABLE(JSVMClientData);
+ WTF_MAKE_FAST_ALLOCATED;
- public:
- explicit JSVMClientData(JSC::VM &);
+public:
+ explicit JSVMClientData(JSC::VM&);
- virtual ~JSVMClientData();
+ virtual ~JSVMClientData();
- static void create(JSC::VM *);
+ static void create(JSC::VM*);
- BunBuiltinNames &builtinNames() { return m_builtinNames; }
+ BunBuiltinNames& builtinNames() { return m_builtinNames; }
- // Vector<JSC::IsoSubspace *> &outputConstraintSpaces() { return m_outputConstraintSpaces; }
+ // Vector<JSC::IsoSubspace *> &outputConstraintSpaces() { return m_outputConstraintSpaces; }
- // template <typename Func> void forEachOutputConstraintSpace(const Func &func) {
- // for (auto *space : m_outputConstraintSpaces) func(*space);
- // }
+ // template <typename Func> void forEachOutputConstraintSpace(const Func &func) {
+ // for (auto *space : m_outputConstraintSpaces) func(*space);
+ // }
- private:
- BunBuiltinNames m_builtinNames;
+private:
+ BunBuiltinNames m_builtinNames;
- // Vector<JSC::IsoSubspace *> m_outputConstraintSpaces;
+ // Vector<JSC::IsoSubspace *> m_outputConstraintSpaces;
};
-static JSVMClientData *clientData(JSC::VM &vm) {
- return static_cast<Bun::JSVMClientData *>(vm.clientData);
+static JSVMClientData* clientData(JSC::VM& vm)
+{
+ return static_cast<Bun::JSVMClientData*>(vm.clientData);
}
} // namespace Bun
diff --git a/src/javascript/jsc/bindings/BunStream.cpp b/src/javascript/jsc/bindings/BunStream.cpp
index 8c45feb40..436c4d2dd 100644
--- a/src/javascript/jsc/bindings/BunStream.cpp
+++ b/src/javascript/jsc/bindings/BunStream.cpp
@@ -15,46 +15,48 @@ using JSObject = JSC::JSObject;
using JSNonFinalObject = JSC::JSNonFinalObject;
namespace JSCastingHelpers = JSC::JSCastingHelpers;
-static ReadableEvent getReadableEvent(const WTF::String &eventName);
-static ReadableEvent getReadableEvent(const WTF::String &eventName) {
- if (eventName == "close")
- return ReadableEvent__Close;
- else if (eventName == "data")
- return ReadableEvent__Data;
- else if (eventName == "end")
- return ReadableEvent__End;
- else if (eventName == "error")
- return ReadableEvent__Error;
- else if (eventName == "pause")
- return ReadableEvent__Pause;
- else if (eventName == "readable")
- return ReadableEvent__Readable;
- else if (eventName == "resume")
- return ReadableEvent__Resume;
- else if (eventName == "open")
- return ReadableEvent__Open;
- else
- return ReadableEventUser;
+static ReadableEvent getReadableEvent(const WTF::String& eventName);
+static ReadableEvent getReadableEvent(const WTF::String& eventName)
+{
+ if (eventName == "close")
+ return ReadableEvent__Close;
+ else if (eventName == "data")
+ return ReadableEvent__Data;
+ else if (eventName == "end")
+ return ReadableEvent__End;
+ else if (eventName == "error")
+ return ReadableEvent__Error;
+ else if (eventName == "pause")
+ return ReadableEvent__Pause;
+ else if (eventName == "readable")
+ return ReadableEvent__Readable;
+ else if (eventName == "resume")
+ return ReadableEvent__Resume;
+ else if (eventName == "open")
+ return ReadableEvent__Open;
+ else
+ return ReadableEventUser;
}
-static WritableEvent getWritableEvent(const WTF::String &eventName);
-static WritableEvent getWritableEvent(const WTF::String &eventName) {
- if (eventName == "close")
- return WritableEvent__Close;
- else if (eventName == "drain")
- return WritableEvent__Drain;
- else if (eventName == "error")
- return WritableEvent__Error;
- else if (eventName == "finish")
- return WritableEvent__Finish;
- else if (eventName == "pipe")
- return WritableEvent__Pipe;
- else if (eventName == "unpipe")
- return WritableEvent__Unpipe;
- else if (eventName == "open")
- return WritableEvent__Open;
- else
- return WritableEventUser;
+static WritableEvent getWritableEvent(const WTF::String& eventName);
+static WritableEvent getWritableEvent(const WTF::String& eventName)
+{
+ if (eventName == "close")
+ return WritableEvent__Close;
+ else if (eventName == "drain")
+ return WritableEvent__Drain;
+ else if (eventName == "error")
+ return WritableEvent__Error;
+ else if (eventName == "finish")
+ return WritableEvent__Finish;
+ else if (eventName == "pipe")
+ return WritableEvent__Pipe;
+ else if (eventName == "unpipe")
+ return WritableEvent__Unpipe;
+ else if (eventName == "open")
+ return WritableEvent__Open;
+ else
+ return WritableEventUser;
}
// clang-format off
@@ -116,211 +118,235 @@ static JSC_DECLARE_HOST_FUNCTION(Writable__uncork);
static JSC_DECLARE_HOST_FUNCTION(Writable__write);
static JSC_DEFINE_HOST_FUNCTION(Readable__on,
- (JSC::JSGlobalObject * globalObject, JSC::CallFrame *callFrame)) {
+ (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+
+ if (callFrame->argumentCount() < 2) {
+ return JSC::JSValue::encode(JSC::jsUndefined());
+ }
+ JSC::VM& vm = globalObject->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ auto thisObject = JSC::jsDynamicCast<Bun::Readable*>(vm, callFrame->thisValue());
+ if (UNLIKELY(!thisObject)) {
+ scope.release();
+ JSC::throwVMTypeError(globalObject, scope);
+ return JSC::JSValue::encode(JSC::jsUndefined());
+ }
+
+ auto eventName = callFrame->argument(0).toStringOrNull(globalObject);
+ if (UNLIKELY(!eventName)) {
+ scope.release();
+ return JSC::JSValue::encode(JSC::jsUndefined());
+ }
+
+ ReadableEvent event = getReadableEvent(eventName->value(globalObject));
+ if (event == ReadableEventUser) {
+ // TODO:
+ scope.release();
+ return JSC::JSValue::encode(JSC::jsUndefined());
+ }
+
+ auto listener = callFrame->argument(1);
+ JSC::JSObject* object = listener.getObject();
+ if (UNLIKELY(!object) || !listener.isCallable(vm)) {
+ scope.release();
+ return JSC::JSValue::encode(JSC::jsUndefined());
+ }
+
+ Bun__Readable__addEventListener(thisObject->state, globalObject, event,
+ JSC::JSValue::encode(listener), true);
- if (callFrame->argumentCount() < 2) { return JSC::JSValue::encode(JSC::jsUndefined()); }
- JSC::VM &vm = globalObject->vm();
- auto scope = DECLARE_THROW_SCOPE(vm);
-
- auto thisObject = JSC::jsDynamicCast<Bun::Readable *>(vm, callFrame->thisValue());
- if (UNLIKELY(!thisObject)) {
- scope.release();
- JSC::throwVMTypeError(globalObject, scope);
- return JSC::JSValue::encode(JSC::jsUndefined());
- }
-
- auto eventName = callFrame->argument(0).toStringOrNull(globalObject);
- if (UNLIKELY(!eventName)) {
- scope.release();
- return JSC::JSValue::encode(JSC::jsUndefined());
- }
-
- ReadableEvent event = getReadableEvent(eventName->value(globalObject));
- if (event == ReadableEventUser) {
- // TODO:
scope.release();
return JSC::JSValue::encode(JSC::jsUndefined());
- }
-
- auto listener = callFrame->argument(1);
- JSC::JSObject *object = listener.getObject();
- if (UNLIKELY(!object) || !listener.isCallable(vm)) {
- scope.release();
- return JSC::JSValue::encode(JSC::jsUndefined());
- }
-
- Bun__Readable__addEventListener(thisObject->state, globalObject, event,
- JSC::JSValue::encode(listener), true);
-
- scope.release();
- return JSC::JSValue::encode(JSC::jsUndefined());
}
-extern "C" Bun__Readable *JSC__JSValue__getReadableStreamState(JSC__JSValue value, JSC__VM *vm) {
- auto *thisObject = JSC::jsDynamicCast<Bun::Readable *>(*vm, JSC::JSValue::decode(value));
- if (UNLIKELY(!thisObject)) { return nullptr; }
- return thisObject->state;
+extern "C" Bun__Readable* JSC__JSValue__getReadableStreamState(JSC__JSValue value, JSC__VM* vm)
+{
+ auto* thisObject = JSC::jsDynamicCast<Bun::Readable*>(*vm, JSC::JSValue::decode(value));
+ if (UNLIKELY(!thisObject)) {
+ return nullptr;
+ }
+ return thisObject->state;
}
-extern "C" Bun__Writable *JSC__JSValue__getWritableStreamState(JSC__JSValue value, JSC__VM *vm) {
- auto *thisObject = JSC::jsDynamicCast<Bun::Writable *>(*vm, JSC::JSValue::decode(value));
- if (UNLIKELY(!thisObject)) { return nullptr; }
- return thisObject->state;
+extern "C" Bun__Writable* JSC__JSValue__getWritableStreamState(JSC__JSValue value, JSC__VM* vm)
+{
+ auto* thisObject = JSC::jsDynamicCast<Bun::Writable*>(*vm, JSC::JSValue::decode(value));
+ if (UNLIKELY(!thisObject)) {
+ return nullptr;
+ }
+ return thisObject->state;
}
-const JSC::ClassInfo Readable::s_info = {"Readable", &Base::s_info, nullptr, nullptr,
- CREATE_METHOD_TABLE(Readable)};
+const JSC::ClassInfo Readable::s_info = { "Readable", &Base::s_info, nullptr, nullptr,
+ CREATE_METHOD_TABLE(Readable) };
-const JSC::ClassInfo Writable::s_info = {"Writable", &Base::s_info, nullptr, nullptr,
- CREATE_METHOD_TABLE(Writable)};
+const JSC::ClassInfo Writable::s_info = { "Writable", &Base::s_info, nullptr, nullptr,
+ CREATE_METHOD_TABLE(Writable) };
static JSC_DEFINE_HOST_FUNCTION(Readable__once,
- (JSC::JSGlobalObject * globalObject, JSC::CallFrame *callFrame)) {
-
- if (callFrame->argumentCount() < 2) { return JSC::JSValue::encode(JSC::jsUndefined()); }
- JSC::VM &vm = globalObject->vm();
- auto scope = DECLARE_THROW_SCOPE(vm);
+ (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+
+ if (callFrame->argumentCount() < 2) {
+ return JSC::JSValue::encode(JSC::jsUndefined());
+ }
+ JSC::VM& vm = globalObject->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ auto thisObject = JSC::jsDynamicCast<Bun::Readable*>(vm, callFrame->thisValue());
+ if (UNLIKELY(!thisObject)) {
+ scope.release();
+ JSC::throwVMTypeError(globalObject, scope);
+ return JSC::JSValue::encode(JSC::jsUndefined());
+ }
+
+ auto eventName = callFrame->argument(0).toStringOrNull(globalObject);
+ if (UNLIKELY(!eventName)) {
+ scope.release();
+ return JSC::JSValue::encode(JSC::jsUndefined());
+ }
+
+ ReadableEvent event = getReadableEvent(eventName->value(globalObject));
+ if (event == ReadableEventUser) {
+ // TODO:
+ scope.release();
+ return JSC::JSValue::encode(JSC::jsUndefined());
+ }
+
+ auto listener = callFrame->argument(1);
+ JSC::JSObject* object = listener.getObject();
+ if (UNLIKELY(!object) || !listener.isCallable(vm)) {
+ scope.release();
+ return JSC::JSValue::encode(JSC::jsUndefined());
+ }
+
+ Bun__Readable__addEventListener(thisObject->state, globalObject, event,
+ JSC::JSValue::encode(listener), true);
- auto thisObject = JSC::jsDynamicCast<Bun::Readable *>(vm, callFrame->thisValue());
- if (UNLIKELY(!thisObject)) {
scope.release();
- JSC::throwVMTypeError(globalObject, scope);
return JSC::JSValue::encode(JSC::jsUndefined());
- }
-
- auto eventName = callFrame->argument(0).toStringOrNull(globalObject);
- if (UNLIKELY(!eventName)) {
- scope.release();
- return JSC::JSValue::encode(JSC::jsUndefined());
- }
-
- ReadableEvent event = getReadableEvent(eventName->value(globalObject));
- if (event == ReadableEventUser) {
- // TODO:
- scope.release();
- return JSC::JSValue::encode(JSC::jsUndefined());
- }
-
- auto listener = callFrame->argument(1);
- JSC::JSObject *object = listener.getObject();
- if (UNLIKELY(!object) || !listener.isCallable(vm)) {
- scope.release();
- return JSC::JSValue::encode(JSC::jsUndefined());
- }
-
- Bun__Readable__addEventListener(thisObject->state, globalObject, event,
- JSC::JSValue::encode(listener), true);
-
- scope.release();
- return JSC::JSValue::encode(JSC::jsUndefined());
}
static JSC_DEFINE_HOST_FUNCTION(Writable__on,
- (JSC::JSGlobalObject * globalObject, JSC::CallFrame *callFrame)) {
-
- if (callFrame->argumentCount() < 2) { return JSC::JSValue::encode(JSC::jsUndefined()); }
- JSC::VM &vm = globalObject->vm();
- auto scope = DECLARE_THROW_SCOPE(vm);
+ (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+
+ if (callFrame->argumentCount() < 2) {
+ return JSC::JSValue::encode(JSC::jsUndefined());
+ }
+ JSC::VM& vm = globalObject->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ auto thisObject = JSC::jsDynamicCast<Bun::Writable*>(vm, callFrame->thisValue());
+ if (UNLIKELY(!thisObject)) {
+ scope.release();
+ JSC::throwVMTypeError(globalObject, scope);
+ return JSC::JSValue::encode(JSC::jsUndefined());
+ }
+
+ auto eventName = callFrame->argument(0).toStringOrNull(globalObject);
+ if (UNLIKELY(!eventName)) {
+ scope.release();
+ return JSC::JSValue::encode(JSC::jsUndefined());
+ }
+
+ WritableEvent event = getWritableEvent(eventName->value(globalObject));
+ if (event == WritableEventUser) {
+ // TODO:
+ scope.release();
+ return JSC::JSValue::encode(JSC::jsUndefined());
+ }
+
+ auto listener = callFrame->argument(1);
+ JSC::JSObject* object = listener.getObject();
+ if (UNLIKELY(!object) || !listener.isCallable(vm)) {
+ scope.release();
+ return JSC::JSValue::encode(JSC::jsUndefined());
+ }
+
+ Bun__Writable__addEventListener(thisObject->state, globalObject, event,
+ JSC::JSValue::encode(listener), false);
- auto thisObject = JSC::jsDynamicCast<Bun::Writable *>(vm, callFrame->thisValue());
- if (UNLIKELY(!thisObject)) {
scope.release();
- JSC::throwVMTypeError(globalObject, scope);
return JSC::JSValue::encode(JSC::jsUndefined());
- }
-
- auto eventName = callFrame->argument(0).toStringOrNull(globalObject);
- if (UNLIKELY(!eventName)) {
- scope.release();
- return JSC::JSValue::encode(JSC::jsUndefined());
- }
-
- WritableEvent event = getWritableEvent(eventName->value(globalObject));
- if (event == WritableEventUser) {
- // TODO:
- scope.release();
- return JSC::JSValue::encode(JSC::jsUndefined());
- }
-
- auto listener = callFrame->argument(1);
- JSC::JSObject *object = listener.getObject();
- if (UNLIKELY(!object) || !listener.isCallable(vm)) {
- scope.release();
- return JSC::JSValue::encode(JSC::jsUndefined());
- }
-
- Bun__Writable__addEventListener(thisObject->state, globalObject, event,
- JSC::JSValue::encode(listener), false);
-
- scope.release();
- return JSC::JSValue::encode(JSC::jsUndefined());
}
static JSC_DEFINE_HOST_FUNCTION(Writable__once,
- (JSC::JSGlobalObject * globalObject, JSC::CallFrame *callFrame)) {
-
- if (callFrame->argumentCount() < 2) { return JSC::JSValue::encode(JSC::jsUndefined()); }
- JSC::VM &vm = globalObject->vm();
- auto scope = DECLARE_THROW_SCOPE(vm);
+ (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+
+ if (callFrame->argumentCount() < 2) {
+ return JSC::JSValue::encode(JSC::jsUndefined());
+ }
+ JSC::VM& vm = globalObject->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ auto thisObject = JSC::jsDynamicCast<Bun::Writable*>(vm, callFrame->thisValue());
+ if (UNLIKELY(!thisObject)) {
+ scope.release();
+ JSC::throwVMTypeError(globalObject, scope);
+ return JSC::JSValue::encode(JSC::jsUndefined());
+ }
+
+ auto eventName = callFrame->argument(0).toStringOrNull(globalObject);
+ if (UNLIKELY(!eventName)) {
+ scope.release();
+ return JSC::JSValue::encode(JSC::jsUndefined());
+ }
+
+ WritableEvent event = getWritableEvent(eventName->value(globalObject));
+ if (event == WritableEventUser) {
+ // TODO:
+ scope.release();
+ return JSC::JSValue::encode(JSC::jsUndefined());
+ }
+
+ auto listener = callFrame->argument(1);
+ JSC::JSObject* object = listener.getObject();
+ if (UNLIKELY(!object) || !listener.isCallable(vm)) {
+ scope.release();
+ return JSC::JSValue::encode(JSC::jsUndefined());
+ }
+
+ Bun__Writable__addEventListener(thisObject->state, globalObject, event,
+ JSC::JSValue::encode(listener), true);
- auto thisObject = JSC::jsDynamicCast<Bun::Writable *>(vm, callFrame->thisValue());
- if (UNLIKELY(!thisObject)) {
scope.release();
- JSC::throwVMTypeError(globalObject, scope);
return JSC::JSValue::encode(JSC::jsUndefined());
- }
-
- auto eventName = callFrame->argument(0).toStringOrNull(globalObject);
- if (UNLIKELY(!eventName)) {
- scope.release();
- return JSC::JSValue::encode(JSC::jsUndefined());
- }
-
- WritableEvent event = getWritableEvent(eventName->value(globalObject));
- if (event == WritableEventUser) {
- // TODO:
- scope.release();
- return JSC::JSValue::encode(JSC::jsUndefined());
- }
-
- auto listener = callFrame->argument(1);
- JSC::JSObject *object = listener.getObject();
- if (UNLIKELY(!object) || !listener.isCallable(vm)) {
- scope.release();
- return JSC::JSValue::encode(JSC::jsUndefined());
- }
-
- Bun__Writable__addEventListener(thisObject->state, globalObject, event,
- JSC::JSValue::encode(listener), true);
-
- scope.release();
- return JSC::JSValue::encode(JSC::jsUndefined());
}
static JSC_DEFINE_HOST_FUNCTION(Readable__read,
- (JSC::JSGlobalObject * globalObject, JSC::CallFrame *callFrame)) {
- DEFINE_CALLBACK_FUNCTION_BODY(Bun::Readable, Bun__Readable__read);
+ (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ DEFINE_CALLBACK_FUNCTION_BODY(Bun::Readable, Bun__Readable__read);
}
static JSC_DEFINE_HOST_FUNCTION(Readable__pipe,
- (JSC::JSGlobalObject * globalObject, JSC::CallFrame *callFrame)) {
- DEFINE_CALLBACK_FUNCTION_BODY(Bun::Readable, Bun__Readable__pipe);
+ (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ DEFINE_CALLBACK_FUNCTION_BODY(Bun::Readable, Bun__Readable__pipe);
}
static JSC_DEFINE_HOST_FUNCTION(Readable__resume,
- (JSC::JSGlobalObject * globalObject, JSC::CallFrame *callFrame)) {
- DEFINE_CALLBACK_FUNCTION_BODY(Bun::Readable, Bun__Readable__resume);
+ (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ DEFINE_CALLBACK_FUNCTION_BODY(Bun::Readable, Bun__Readable__resume);
}
static JSC_DEFINE_HOST_FUNCTION(Readable__unpipe,
- (JSC::JSGlobalObject * globalObject, JSC::CallFrame *callFrame)) {
- DEFINE_CALLBACK_FUNCTION_BODY(Bun::Readable, Bun__Readable__unpipe);
+ (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ DEFINE_CALLBACK_FUNCTION_BODY(Bun::Readable, Bun__Readable__unpipe);
}
static JSC_DEFINE_HOST_FUNCTION(Readable__pause,
- (JSC::JSGlobalObject * globalObject, JSC::CallFrame *callFrame)) {
- DEFINE_CALLBACK_FUNCTION_BODY(Bun::Readable, Bun__Readable__pause);
+ (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ DEFINE_CALLBACK_FUNCTION_BODY(Bun::Readable, Bun__Readable__pause);
}
static JSC_DEFINE_HOST_FUNCTION(Readable__unshift,
- (JSC::JSGlobalObject * globalObject, JSC::CallFrame *callFrame)) {
- DEFINE_CALLBACK_FUNCTION_BODY(Bun::Readable, Bun__Readable__unshift);
+ (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ DEFINE_CALLBACK_FUNCTION_BODY(Bun::Readable, Bun__Readable__unshift);
}
// static JSC_DECLARE_HOST_FUNCTION(Readable__isPaused);
@@ -330,156 +356,172 @@ static JSC_DEFINE_HOST_FUNCTION(Readable__unshift,
// Bun__Writable__setDefaultEncoding);
static JSC_DEFINE_HOST_FUNCTION(Writable__write,
- (JSC::JSGlobalObject * globalObject, JSC::CallFrame *callFrame)) {
- DEFINE_CALLBACK_FUNCTION_BODY(Bun::Writable, Bun__Writable__write);
+ (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ DEFINE_CALLBACK_FUNCTION_BODY(Bun::Writable, Bun__Writable__write);
}
static JSC_DEFINE_HOST_FUNCTION(Writable__end,
- (JSC::JSGlobalObject * globalObject, JSC::CallFrame *callFrame)) {
- DEFINE_CALLBACK_FUNCTION_BODY(Bun::Writable, Bun__Writable__end);
+ (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ DEFINE_CALLBACK_FUNCTION_BODY(Bun::Writable, Bun__Writable__end);
}
static JSC_DEFINE_HOST_FUNCTION(Writable__close,
- (JSC::JSGlobalObject * globalObject, JSC::CallFrame *callFrame)) {
- DEFINE_CALLBACK_FUNCTION_BODY(Bun::Writable, Bun__Writable__close);
+ (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ DEFINE_CALLBACK_FUNCTION_BODY(Bun::Writable, Bun__Writable__close);
}
static JSC_DEFINE_HOST_FUNCTION(Writable__destroy,
- (JSC::JSGlobalObject * globalObject, JSC::CallFrame *callFrame)) {
- DEFINE_CALLBACK_FUNCTION_BODY(Bun::Writable, Bun__Writable__destroy);
+ (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ DEFINE_CALLBACK_FUNCTION_BODY(Bun::Writable, Bun__Writable__destroy);
}
static JSC_DEFINE_HOST_FUNCTION(Writable__cork,
- (JSC::JSGlobalObject * globalObject, JSC::CallFrame *callFrame)) {
- DEFINE_CALLBACK_FUNCTION_BODY(Bun::Writable, Bun__Writable__cork);
+ (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ DEFINE_CALLBACK_FUNCTION_BODY(Bun::Writable, Bun__Writable__cork);
}
static JSC_DEFINE_HOST_FUNCTION(Writable__uncork,
- (JSC::JSGlobalObject * globalObject, JSC::CallFrame *callFrame)) {
- DEFINE_CALLBACK_FUNCTION_BODY(Bun::Writable, Bun__Writable__uncork);
+ (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ DEFINE_CALLBACK_FUNCTION_BODY(Bun::Writable, Bun__Writable__uncork);
}
-extern "C" JSC__JSValue Bun__Readable__create(Bun__Readable *state,
- JSC__JSGlobalObject *globalObject) {
- JSC::JSValue result = JSC::JSValue(Readable::create(
- globalObject->vm(), state,
- Readable::createStructure(globalObject->vm(), globalObject, globalObject->objectPrototype())));
+extern "C" JSC__JSValue Bun__Readable__create(Bun__Readable* state,
+ JSC__JSGlobalObject* globalObject)
+{
+ JSC::JSValue result = JSC::JSValue(Readable::create(
+ globalObject->vm(), state,
+ Readable::createStructure(globalObject->vm(), globalObject, globalObject->objectPrototype())));
- return JSC::JSValue::encode(result);
+ return JSC::JSValue::encode(result);
}
-extern "C" JSC__JSValue Bun__Writable__create(Bun__Writable *state,
- JSC__JSGlobalObject *globalObject) {
- JSC::JSValue result = JSC::JSValue(Writable::create(
- globalObject->vm(), state,
- Writable::createStructure(globalObject->vm(), globalObject, globalObject->objectPrototype())));
+extern "C" JSC__JSValue Bun__Writable__create(Bun__Writable* state,
+ JSC__JSGlobalObject* globalObject)
+{
+ JSC::JSValue result = JSC::JSValue(Writable::create(
+ globalObject->vm(), state,
+ Writable::createStructure(globalObject->vm(), globalObject, globalObject->objectPrototype())));
- return JSC::JSValue::encode(result);
+ return JSC::JSValue::encode(result);
}
-Readable::~Readable() {
- if (this->state) { Bun__Readable__deinit(this->state); }
+Readable::~Readable()
+{
+ if (this->state) {
+ Bun__Readable__deinit(this->state);
+ }
}
-Writable::~Writable() {
- if (this->state) { Bun__Writable__deinit(this->state); }
+Writable::~Writable()
+{
+ if (this->state) {
+ Bun__Writable__deinit(this->state);
+ }
}
-void Readable::finishCreation(JSC::VM &vm) {
- Base::finishCreation(vm);
- auto clientData = Bun::clientData(vm);
- auto *globalObject = this->globalObject();
-
- putDirect(vm, clientData->builtinNames().onPublicName(),
- JSFunction::create(vm, globalObject, 2,
- clientData->builtinNames().onPublicName().string(), Readable__on),
- 0);
- putDirect(vm, clientData->builtinNames().oncePublicName(),
- JSFunction::create(vm, globalObject, 2,
- clientData->builtinNames().oncePublicName().string(),
- Readable__once),
- 0);
- putDirect(vm, clientData->builtinNames().pausePublicName(),
- JSFunction::create(vm, globalObject, 2,
- clientData->builtinNames().pausePublicName().string(),
- Readable__pause),
- 0);
- putDirect(vm, clientData->builtinNames().pipePublicName(),
- JSFunction::create(vm, globalObject, 2,
- clientData->builtinNames().pipePublicName().string(),
- Readable__pipe),
- 0);
- putDirect(vm, clientData->builtinNames().readPublicName(),
- JSFunction::create(vm, globalObject, 2,
- clientData->builtinNames().readPublicName().string(),
- Readable__read),
- 0);
- putDirect(vm, clientData->builtinNames().resumePublicName(),
- JSFunction::create(vm, globalObject, 2,
- clientData->builtinNames().resumePublicName().string(),
- Readable__resume),
- 0);
- putDirect(vm, clientData->builtinNames().unpipePublicName(),
- JSFunction::create(vm, globalObject, 2,
- clientData->builtinNames().unpipePublicName().string(),
- Readable__unpipe),
- 0);
- putDirect(vm, clientData->builtinNames().unshiftPublicName(),
- JSFunction::create(vm, globalObject, 2,
- clientData->builtinNames().unshiftPublicName().string(),
- Readable__unshift),
- 0);
+void Readable::finishCreation(JSC::VM& vm)
+{
+ Base::finishCreation(vm);
+ auto clientData = Bun::clientData(vm);
+ auto* globalObject = this->globalObject();
+
+ putDirect(vm, clientData->builtinNames().onPublicName(),
+ JSFunction::create(vm, globalObject, 2,
+ clientData->builtinNames().onPublicName().string(), Readable__on),
+ 0);
+ putDirect(vm, clientData->builtinNames().oncePublicName(),
+ JSFunction::create(vm, globalObject, 2,
+ clientData->builtinNames().oncePublicName().string(),
+ Readable__once),
+ 0);
+ putDirect(vm, clientData->builtinNames().pausePublicName(),
+ JSFunction::create(vm, globalObject, 2,
+ clientData->builtinNames().pausePublicName().string(),
+ Readable__pause),
+ 0);
+ putDirect(vm, clientData->builtinNames().pipePublicName(),
+ JSFunction::create(vm, globalObject, 2,
+ clientData->builtinNames().pipePublicName().string(),
+ Readable__pipe),
+ 0);
+ putDirect(vm, clientData->builtinNames().readPublicName(),
+ JSFunction::create(vm, globalObject, 2,
+ clientData->builtinNames().readPublicName().string(),
+ Readable__read),
+ 0);
+ putDirect(vm, clientData->builtinNames().resumePublicName(),
+ JSFunction::create(vm, globalObject, 2,
+ clientData->builtinNames().resumePublicName().string(),
+ Readable__resume),
+ 0);
+ putDirect(vm, clientData->builtinNames().unpipePublicName(),
+ JSFunction::create(vm, globalObject, 2,
+ clientData->builtinNames().unpipePublicName().string(),
+ Readable__unpipe),
+ 0);
+ putDirect(vm, clientData->builtinNames().unshiftPublicName(),
+ JSFunction::create(vm, globalObject, 2,
+ clientData->builtinNames().unshiftPublicName().string(),
+ Readable__unshift),
+ 0);
}
-void Writable::finishCreation(JSC::VM &vm) {
- Base::finishCreation(vm);
- auto clientData = Bun::clientData(vm);
-
- auto *globalObject = this->globalObject();
-
- putDirect(vm, clientData->builtinNames().onPublicName(),
- JSFunction::create(vm, globalObject, 2,
- clientData->builtinNames().onPublicName().string(), Writable__on),
- 0);
-
- putDirect(vm, clientData->builtinNames().oncePublicName(),
- JSFunction::create(vm, globalObject, 2,
- clientData->builtinNames().oncePublicName().string(),
- Writable__once),
- 0);
-
- putDirect(vm, clientData->builtinNames().closePublicName(),
- JSFunction::create(vm, globalObject, 2,
- clientData->builtinNames().closePublicName().string(),
- Writable__close),
- 0);
- putDirect(vm, clientData->builtinNames().corkPublicName(),
- JSFunction::create(vm, globalObject, 2,
- clientData->builtinNames().corkPublicName().string(),
- Writable__cork),
- 0);
- putDirect(vm, clientData->builtinNames().destroyPublicName(),
- JSFunction::create(vm, globalObject, 2,
- clientData->builtinNames().destroyPublicName().string(),
- Writable__destroy),
- 0);
- putDirect(vm, clientData->builtinNames().endPublicName(),
- JSFunction::create(vm, globalObject, 2,
- clientData->builtinNames().endPublicName().string(), Writable__end),
- 0);
- putDirect(vm, clientData->builtinNames().onPublicName(),
- JSFunction::create(vm, globalObject, 2,
- clientData->builtinNames().onPublicName().string(), Writable__on),
- 0);
- putDirect(vm, clientData->builtinNames().oncePublicName(),
- JSFunction::create(vm, globalObject, 2,
- clientData->builtinNames().oncePublicName().string(),
- Writable__once),
- 0);
- putDirect(vm, clientData->builtinNames().uncorkPublicName(),
- JSFunction::create(vm, globalObject, 2,
- clientData->builtinNames().uncorkPublicName().string(),
- Writable__uncork),
- 0);
- putDirect(vm, clientData->builtinNames().writePublicName(),
- JSFunction::create(vm, globalObject, 2,
- clientData->builtinNames().writePublicName().string(),
- Writable__write),
- 0);
+void Writable::finishCreation(JSC::VM& vm)
+{
+ Base::finishCreation(vm);
+ auto clientData = Bun::clientData(vm);
+
+ auto* globalObject = this->globalObject();
+
+ putDirect(vm, clientData->builtinNames().onPublicName(),
+ JSFunction::create(vm, globalObject, 2,
+ clientData->builtinNames().onPublicName().string(), Writable__on),
+ 0);
+
+ putDirect(vm, clientData->builtinNames().oncePublicName(),
+ JSFunction::create(vm, globalObject, 2,
+ clientData->builtinNames().oncePublicName().string(),
+ Writable__once),
+ 0);
+
+ putDirect(vm, clientData->builtinNames().closePublicName(),
+ JSFunction::create(vm, globalObject, 2,
+ clientData->builtinNames().closePublicName().string(),
+ Writable__close),
+ 0);
+ putDirect(vm, clientData->builtinNames().corkPublicName(),
+ JSFunction::create(vm, globalObject, 2,
+ clientData->builtinNames().corkPublicName().string(),
+ Writable__cork),
+ 0);
+ putDirect(vm, clientData->builtinNames().destroyPublicName(),
+ JSFunction::create(vm, globalObject, 2,
+ clientData->builtinNames().destroyPublicName().string(),
+ Writable__destroy),
+ 0);
+ putDirect(vm, clientData->builtinNames().endPublicName(),
+ JSFunction::create(vm, globalObject, 2,
+ clientData->builtinNames().endPublicName().string(), Writable__end),
+ 0);
+ putDirect(vm, clientData->builtinNames().onPublicName(),
+ JSFunction::create(vm, globalObject, 2,
+ clientData->builtinNames().onPublicName().string(), Writable__on),
+ 0);
+ putDirect(vm, clientData->builtinNames().oncePublicName(),
+ JSFunction::create(vm, globalObject, 2,
+ clientData->builtinNames().oncePublicName().string(),
+ Writable__once),
+ 0);
+ putDirect(vm, clientData->builtinNames().uncorkPublicName(),
+ JSFunction::create(vm, globalObject, 2,
+ clientData->builtinNames().uncorkPublicName().string(),
+ Writable__uncork),
+ 0);
+ putDirect(vm, clientData->builtinNames().writePublicName(),
+ JSFunction::create(vm, globalObject, 2,
+ clientData->builtinNames().writePublicName().string(),
+ Writable__write),
+ 0);
}
} // namespace Bun \ No newline at end of file
diff --git a/src/javascript/jsc/bindings/BunStream.h b/src/javascript/jsc/bindings/BunStream.h
index 0fdf87beb..39d015558 100644
--- a/src/javascript/jsc/bindings/BunStream.h
+++ b/src/javascript/jsc/bindings/BunStream.h
@@ -9,73 +9,81 @@ namespace Bun {
using namespace JSC;
class Readable : public JSC::JSNonFinalObject {
- using Base = JSC::JSNonFinalObject;
-
- public:
- Bun__Readable *state;
- Readable(JSC::VM &vm, Bun__Readable *readable, JSC::Structure *structure) : Base(vm, structure) {
- state = readable;
- }
-
- ~Readable();
-
- DECLARE_INFO;
-
- static constexpr unsigned StructureFlags = Base::StructureFlags;
-
- template <typename CellType, SubspaceAccess> static GCClient::IsoSubspace *subspaceFor(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());
- }
-
- static Readable *create(JSC::VM &vm, Bun__Readable *state, JSC::Structure *structure) {
- Readable *accessor =
- new (NotNull, JSC::allocateCell<Bun::Readable>(vm)) Readable(vm, state, structure);
- accessor->finishCreation(vm);
- return accessor;
- }
-
- void finishCreation(JSC::VM &vm);
+ using Base = JSC::JSNonFinalObject;
+
+public:
+ Bun__Readable* state;
+ Readable(JSC::VM& vm, Bun__Readable* readable, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ state = readable;
+ }
+
+ ~Readable();
+
+ DECLARE_INFO;
+
+ static constexpr unsigned StructureFlags = Base::StructureFlags;
+
+ template<typename CellType, SubspaceAccess> static GCClient::IsoSubspace* subspaceFor(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());
+ }
+
+ static Readable* create(JSC::VM& vm, Bun__Readable* state, JSC::Structure* structure)
+ {
+ Readable* accessor = new (NotNull, JSC::allocateCell<Bun::Readable>(vm)) Readable(vm, state, structure);
+ accessor->finishCreation(vm);
+ return accessor;
+ }
+
+ void finishCreation(JSC::VM& vm);
};
class Writable : public JSC::JSNonFinalObject {
- using Base = JSC::JSNonFinalObject;
-
- public:
- Bun__Writable *state;
- Writable(JSC::VM &vm, Bun__Writable *writable, JSC::Structure *structure) : Base(vm, structure) {
- state = writable;
- }
-
- DECLARE_INFO;
-
- static constexpr unsigned StructureFlags = Base::StructureFlags;
-
- template <typename CellType, SubspaceAccess> static GCClient::IsoSubspace *subspaceFor(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());
- }
-
- static Writable *create(JSC::VM &vm, Bun__Writable *state, JSC::Structure *structure) {
-
- Writable *accessor =
- new (NotNull, JSC::allocateCell<Writable>(vm)) Writable(vm, state, structure);
- accessor->finishCreation(vm);
- return accessor;
- }
- ~Writable();
-
- void finishCreation(JSC::VM &vm);
+ using Base = JSC::JSNonFinalObject;
+
+public:
+ Bun__Writable* state;
+ Writable(JSC::VM& vm, Bun__Writable* writable, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ state = writable;
+ }
+
+ DECLARE_INFO;
+
+ static constexpr unsigned StructureFlags = Base::StructureFlags;
+
+ template<typename CellType, SubspaceAccess> static GCClient::IsoSubspace* subspaceFor(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());
+ }
+
+ static Writable* create(JSC::VM& vm, Bun__Writable* state, JSC::Structure* structure)
+ {
+
+ Writable* accessor = new (NotNull, JSC::allocateCell<Writable>(vm)) Writable(vm, state, structure);
+ accessor->finishCreation(vm);
+ return accessor;
+ }
+ ~Writable();
+
+ void finishCreation(JSC::VM& vm);
};
} // namespace Bun \ No newline at end of file
diff --git a/src/javascript/jsc/bindings/Path.cpp b/src/javascript/jsc/bindings/Path.cpp
index a158beaa8..4bb0f146c 100644
--- a/src/javascript/jsc/bindings/Path.cpp
+++ b/src/javascript/jsc/bindings/Path.cpp
@@ -4,11 +4,12 @@
#pragma mark - Node.js Path
-extern JSC__JSValue Bun__Path__create(JSC::JSGlobalObject *globalObject, bool isWindows) {
- JSC::VM &vm = globalObject->vm();
+extern JSC__JSValue Bun__Path__create(JSC::JSGlobalObject* globalObject, bool isWindows)
+{
+ JSC::VM& vm = globalObject->vm();
- return JSC::JSValue::encode(JSC::JSValue(Zig::Path::create(
- vm, isWindows, Zig::Path::createStructure(vm, globalObject, globalObject->objectPrototype()))));
+ return JSC::JSValue::encode(JSC::JSValue(Zig::Path::create(
+ vm, isWindows, Zig::Path::createStructure(vm, globalObject, globalObject->objectPrototype()))));
}
namespace Zig {
@@ -55,128 +56,140 @@ namespace JSCastingHelpers = JSC::JSCastingHelpers;
static JSC_DECLARE_HOST_FUNCTION(Path_functionBasename);
static JSC_DEFINE_HOST_FUNCTION(Path_functionBasename,
- (JSC::JSGlobalObject * globalObject, JSC::CallFrame *callFrame)) {
- DEFINE_CALLBACK_FUNCTION_BODY(Bun__Path__basename);
+ (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ DEFINE_CALLBACK_FUNCTION_BODY(Bun__Path__basename);
}
static JSC_DECLARE_HOST_FUNCTION(Path_functionDirname);
static JSC_DEFINE_HOST_FUNCTION(Path_functionDirname,
- (JSC::JSGlobalObject * globalObject, JSC::CallFrame *callFrame)) {
- DEFINE_CALLBACK_FUNCTION_BODY(Bun__Path__dirname);
+ (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ DEFINE_CALLBACK_FUNCTION_BODY(Bun__Path__dirname);
}
static JSC_DECLARE_HOST_FUNCTION(Path_functionExtname);
static JSC_DEFINE_HOST_FUNCTION(Path_functionExtname,
- (JSC::JSGlobalObject * globalObject, JSC::CallFrame *callFrame)) {
- DEFINE_CALLBACK_FUNCTION_BODY(Bun__Path__extname);
+ (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ DEFINE_CALLBACK_FUNCTION_BODY(Bun__Path__extname);
}
static JSC_DECLARE_HOST_FUNCTION(Path_functionFormat);
static JSC_DEFINE_HOST_FUNCTION(Path_functionFormat,
- (JSC::JSGlobalObject * globalObject, JSC::CallFrame *callFrame)) {
- DEFINE_CALLBACK_FUNCTION_BODY(Bun__Path__format);
+ (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ DEFINE_CALLBACK_FUNCTION_BODY(Bun__Path__format);
}
static JSC_DECLARE_HOST_FUNCTION(Path_functionIsAbsolute);
static JSC_DEFINE_HOST_FUNCTION(Path_functionIsAbsolute,
- (JSC::JSGlobalObject * globalObject, JSC::CallFrame *callFrame)) {
- DEFINE_CALLBACK_FUNCTION_BODY(Bun__Path__isAbsolute);
+ (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ DEFINE_CALLBACK_FUNCTION_BODY(Bun__Path__isAbsolute);
}
static JSC_DECLARE_HOST_FUNCTION(Path_functionJoin);
static JSC_DEFINE_HOST_FUNCTION(Path_functionJoin,
- (JSC::JSGlobalObject * globalObject, JSC::CallFrame *callFrame)) {
- DEFINE_CALLBACK_FUNCTION_BODY(Bun__Path__join);
+ (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ DEFINE_CALLBACK_FUNCTION_BODY(Bun__Path__join);
}
static JSC_DECLARE_HOST_FUNCTION(Path_functionNormalize);
static JSC_DEFINE_HOST_FUNCTION(Path_functionNormalize,
- (JSC::JSGlobalObject * globalObject, JSC::CallFrame *callFrame)) {
- DEFINE_CALLBACK_FUNCTION_BODY(Bun__Path__normalize);
+ (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ DEFINE_CALLBACK_FUNCTION_BODY(Bun__Path__normalize);
}
static JSC_DECLARE_HOST_FUNCTION(Path_functionParse);
static JSC_DEFINE_HOST_FUNCTION(Path_functionParse,
- (JSC::JSGlobalObject * globalObject, JSC::CallFrame *callFrame)) {
- DEFINE_CALLBACK_FUNCTION_BODY(Bun__Path__parse);
+ (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ DEFINE_CALLBACK_FUNCTION_BODY(Bun__Path__parse);
}
static JSC_DECLARE_HOST_FUNCTION(Path_functionRelative);
static JSC_DEFINE_HOST_FUNCTION(Path_functionRelative,
- (JSC::JSGlobalObject * globalObject, JSC::CallFrame *callFrame)) {
- DEFINE_CALLBACK_FUNCTION_BODY(Bun__Path__relative);
+ (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ DEFINE_CALLBACK_FUNCTION_BODY(Bun__Path__relative);
}
static JSC_DECLARE_HOST_FUNCTION(Path_functionResolve);
static JSC_DEFINE_HOST_FUNCTION(Path_functionResolve,
- (JSC::JSGlobalObject * globalObject, JSC::CallFrame *callFrame)) {
- DEFINE_CALLBACK_FUNCTION_BODY(Bun__Path__resolve);
+ (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ DEFINE_CALLBACK_FUNCTION_BODY(Bun__Path__resolve);
}
static JSC_DECLARE_HOST_FUNCTION(Path_functionToNamespacedPath);
static JSC_DEFINE_HOST_FUNCTION(Path_functionToNamespacedPath,
- (JSC::JSGlobalObject * globalObject, JSC::CallFrame *callFrame)) {
- auto argCount = static_cast<uint16_t>(callFrame->argumentCount());
- // TODO:
- return JSC::JSValue::encode(callFrame->argument(0));
+ (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ auto argCount = static_cast<uint16_t>(callFrame->argumentCount());
+ // TODO:
+ return JSC::JSValue::encode(callFrame->argument(0));
}
-void Path::finishCreation(JSC::VM &vm) {
- Base::finishCreation(vm);
- auto clientData = Bun::clientData(vm);
+void Path::finishCreation(JSC::VM& vm)
+{
+ Base::finishCreation(vm);
+ auto clientData = Bun::clientData(vm);
- JSC::JSGlobalObject *globalThis = globalObject();
- this->putDirect(vm, clientData->builtinNames().basenamePublicName(),
- JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject *>(globalThis), 0,
- WTF::String("basename"), Path_functionBasename),
- 0);
- this->putDirect(vm, clientData->builtinNames().dirnamePublicName(),
- JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject *>(globalThis), 0,
- WTF::String("dirname"), Path_functionDirname),
- 0);
- this->putDirect(vm, clientData->builtinNames().extnamePublicName(),
- JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject *>(globalThis), 0,
- WTF::String("extname"), Path_functionExtname),
- 0);
- this->putDirect(vm, clientData->builtinNames().formatPublicName(),
- JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject *>(globalThis), 0,
- WTF::String("format"), Path_functionFormat),
- 0);
- this->putDirect(vm, clientData->builtinNames().isAbsolutePublicName(),
- JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject *>(globalThis), 0,
- WTF::String("isAbsolute"), Path_functionIsAbsolute),
- 0);
- this->putDirect(vm, clientData->builtinNames().joinPublicName(),
- JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject *>(globalThis), 0,
- WTF::String("join"), Path_functionJoin),
- 0);
- this->putDirect(vm, clientData->builtinNames().normalizePublicName(),
- JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject *>(globalThis), 0,
- WTF::String("normalize"), Path_functionNormalize),
- 0);
- this->putDirect(vm, clientData->builtinNames().parsePublicName(),
- JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject *>(globalThis), 0,
- WTF::String("parse"), Path_functionParse),
- 0);
- this->putDirect(vm, clientData->builtinNames().relativePublicName(),
- JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject *>(globalThis), 0,
- WTF::String("relative"), Path_functionRelative),
- 0);
- this->putDirect(vm, clientData->builtinNames().resolvePublicName(),
- JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject *>(globalThis), 0,
- WTF::String("resolve"), Path_functionResolve),
- 0);
+ JSC::JSGlobalObject* globalThis = globalObject();
+ this->putDirect(vm, clientData->builtinNames().basenamePublicName(),
+ JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject*>(globalThis), 0,
+ WTF::String("basename"), Path_functionBasename),
+ 0);
+ this->putDirect(vm, clientData->builtinNames().dirnamePublicName(),
+ JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject*>(globalThis), 0,
+ WTF::String("dirname"), Path_functionDirname),
+ 0);
+ this->putDirect(vm, clientData->builtinNames().extnamePublicName(),
+ JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject*>(globalThis), 0,
+ WTF::String("extname"), Path_functionExtname),
+ 0);
+ this->putDirect(vm, clientData->builtinNames().formatPublicName(),
+ JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject*>(globalThis), 0,
+ WTF::String("format"), Path_functionFormat),
+ 0);
+ this->putDirect(vm, clientData->builtinNames().isAbsolutePublicName(),
+ JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject*>(globalThis), 0,
+ WTF::String("isAbsolute"), Path_functionIsAbsolute),
+ 0);
+ this->putDirect(vm, clientData->builtinNames().joinPublicName(),
+ JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject*>(globalThis), 0,
+ WTF::String("join"), Path_functionJoin),
+ 0);
+ this->putDirect(vm, clientData->builtinNames().normalizePublicName(),
+ JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject*>(globalThis), 0,
+ WTF::String("normalize"), Path_functionNormalize),
+ 0);
+ this->putDirect(vm, clientData->builtinNames().parsePublicName(),
+ JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject*>(globalThis), 0,
+ WTF::String("parse"), Path_functionParse),
+ 0);
+ this->putDirect(vm, clientData->builtinNames().relativePublicName(),
+ JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject*>(globalThis), 0,
+ WTF::String("relative"), Path_functionRelative),
+ 0);
+ this->putDirect(vm, clientData->builtinNames().resolvePublicName(),
+ JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject*>(globalThis), 0,
+ WTF::String("resolve"), Path_functionResolve),
+ 0);
- this->putDirect(vm, clientData->builtinNames().toNamespacedPathPublicName(),
- JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject *>(globalThis), 0,
- WTF::String("toNamespacedPath"),
- Path_functionToNamespacedPath),
- 0);
+ this->putDirect(vm, clientData->builtinNames().toNamespacedPathPublicName(),
+ JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject*>(globalThis), 0,
+ WTF::String("toNamespacedPath"),
+ Path_functionToNamespacedPath),
+ 0);
- if (isWindows) {
- this->putDirect(vm, clientData->builtinNames().sepPublicName(),
- JSC::jsString(vm, WTF::String("\\"_s)), 0);
- this->putDirect(vm, clientData->builtinNames().delimiterPublicName(),
- JSC::jsString(vm, WTF::String(";"_s)), 0);
- } else {
- this->putDirect(vm, clientData->builtinNames().sepPublicName(),
- JSC::jsString(vm, WTF::String("/"_s)), 0);
- this->putDirect(vm, clientData->builtinNames().delimiterPublicName(),
- JSC::jsString(vm, WTF::String(":"_s)), 0);
- }
+ if (isWindows) {
+ this->putDirect(vm, clientData->builtinNames().sepPublicName(),
+ JSC::jsString(vm, WTF::String("\\"_s)), 0);
+ this->putDirect(vm, clientData->builtinNames().delimiterPublicName(),
+ JSC::jsString(vm, WTF::String(";"_s)), 0);
+ } else {
+ this->putDirect(vm, clientData->builtinNames().sepPublicName(),
+ JSC::jsString(vm, WTF::String("/"_s)), 0);
+ this->putDirect(vm, clientData->builtinNames().delimiterPublicName(),
+ JSC::jsString(vm, WTF::String(":"_s)), 0);
+ }
}
-const JSC::ClassInfo Path::s_info = {"Path", &Base::s_info, nullptr, nullptr,
- CREATE_METHOD_TABLE(Path)};
+const JSC::ClassInfo Path::s_info = { "Path", &Base::s_info, nullptr, nullptr,
+ CREATE_METHOD_TABLE(Path) };
} // namespace Zig \ No newline at end of file
diff --git a/src/javascript/jsc/bindings/Path.h b/src/javascript/jsc/bindings/Path.h
index 1c1c7817b..d229fedc6 100644
--- a/src/javascript/jsc/bindings/Path.h
+++ b/src/javascript/jsc/bindings/Path.h
@@ -9,36 +9,41 @@ namespace Zig {
using namespace JSC;
class Path : public JSC::JSNonFinalObject {
- using Base = JSC::JSNonFinalObject;
+ using Base = JSC::JSNonFinalObject;
- public:
- Path(JSC::VM &vm, JSC::Structure *structure, bool isWindows_) : Base(vm, structure) {
- isWindows = isWindows_;
- }
+public:
+ Path(JSC::VM& vm, JSC::Structure* structure, bool isWindows_)
+ : Base(vm, structure)
+ {
+ isWindows = isWindows_;
+ }
- DECLARE_INFO;
+ DECLARE_INFO;
- static constexpr unsigned StructureFlags = Base::StructureFlags;
+ static constexpr unsigned StructureFlags = Base::StructureFlags;
- template <typename CellType, SubspaceAccess> static GCClient::IsoSubspace *subspaceFor(VM &vm) {
- return &vm.plainObjectSpace();
- }
+ template<typename CellType, SubspaceAccess> static GCClient::IsoSubspace* subspaceFor(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());
- }
+ 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());
+ }
- static Path *create(JSC::VM &vm, bool isWindows, JSC::Structure *structure) {
- Path *accessor = new (NotNull, JSC::allocateCell<Path>(vm)) Path(vm, structure, isWindows);
+ static Path* create(JSC::VM& vm, bool isWindows, JSC::Structure* structure)
+ {
+ Path* accessor = new (NotNull, JSC::allocateCell<Path>(vm)) Path(vm, structure, isWindows);
- accessor->finishCreation(vm);
- return accessor;
- }
- bool isWindows = false;
+ accessor->finishCreation(vm);
+ return accessor;
+ }
+ bool isWindows = false;
- void finishCreation(JSC::VM &vm);
+ void finishCreation(JSC::VM& vm);
};
} // namespace Zig \ No newline at end of file
diff --git a/src/javascript/jsc/bindings/Process.cpp b/src/javascript/jsc/bindings/Process.cpp
index 7a1b37167..a6de63f8c 100644
--- a/src/javascript/jsc/bindings/Process.cpp
+++ b/src/javascript/jsc/bindings/Process.cpp
@@ -32,310 +32,327 @@ static JSC_DECLARE_HOST_FUNCTION(Process_functionCwd);
static JSC_DECLARE_HOST_FUNCTION(Process_functionNextTick);
static JSC_DEFINE_HOST_FUNCTION(Process_functionNextTick,
- (JSC::JSGlobalObject * globalObject, JSC::CallFrame *callFrame)) {
- JSC::VM &vm = globalObject->vm();
- auto argCount = callFrame->argumentCount();
- if (argCount == 0) {
- auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
- JSC::throwTypeError(globalObject, scope, "nextTick requires 1 argument (a function)"_s);
- return JSC::JSValue::encode(JSC::JSValue{});
- }
+ (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ JSC::VM& vm = globalObject->vm();
+ auto argCount = callFrame->argumentCount();
+ if (argCount == 0) {
+ auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
+ JSC::throwTypeError(globalObject, scope, "nextTick requires 1 argument (a function)"_s);
+ return JSC::JSValue::encode(JSC::JSValue {});
+ }
- JSC::JSValue job = callFrame->uncheckedArgument(0);
+ JSC::JSValue job = callFrame->uncheckedArgument(0);
- if (!job.isObject() || !job.getObject()->isCallable(vm)) {
- auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
- JSC::throwTypeError(globalObject, scope, "nextTick expects a function"_s);
- return JSC::JSValue::encode(JSC::JSValue{});
- }
+ if (!job.isObject() || !job.getObject()->isCallable(vm)) {
+ auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
+ JSC::throwTypeError(globalObject, scope, "nextTick expects a function"_s);
+ return JSC::JSValue::encode(JSC::JSValue {});
+ }
- switch (argCount) {
+ switch (argCount) {
case 1: {
- // This is a JSC builtin function
- globalObject->queueMicrotask(JSC::createJSMicrotask(vm, job, JSC::JSValue{}, JSC::JSValue{},
- JSC::JSValue{}, JSC::JSValue{}));
- break;
+ // This is a JSC builtin function
+ globalObject->queueMicrotask(JSC::createJSMicrotask(vm, job, JSC::JSValue {}, JSC::JSValue {},
+ JSC::JSValue {}, JSC::JSValue {}));
+ break;
}
case 2:
case 3:
case 4:
case 5: {
- JSC::JSValue argument0 = callFrame->uncheckedArgument(1);
- JSC::JSValue argument1 = argCount > 2 ? callFrame->uncheckedArgument(2) : JSC::JSValue{};
- JSC::JSValue argument2 = argCount > 3 ? callFrame->uncheckedArgument(3) : JSC::JSValue{};
- JSC::JSValue argument3 = argCount > 4 ? callFrame->uncheckedArgument(4) : JSC::JSValue{};
- globalObject->queueMicrotask(
- JSC::createJSMicrotask(vm, job, argument0, argument1, argument2, argument3));
- break;
+ JSC::JSValue argument0 = callFrame->uncheckedArgument(1);
+ JSC::JSValue argument1 = argCount > 2 ? callFrame->uncheckedArgument(2) : JSC::JSValue {};
+ JSC::JSValue argument2 = argCount > 3 ? callFrame->uncheckedArgument(3) : JSC::JSValue {};
+ JSC::JSValue argument3 = argCount > 4 ? callFrame->uncheckedArgument(4) : JSC::JSValue {};
+ globalObject->queueMicrotask(
+ JSC::createJSMicrotask(vm, job, argument0, argument1, argument2, argument3));
+ break;
}
default: {
- auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
- JSC::throwTypeError(globalObject, scope,
- "nextTick doesn't support more than 4 arguments currently"_s);
- return JSC::JSValue::encode(JSC::JSValue{});
+ auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
+ JSC::throwTypeError(globalObject, scope,
+ "nextTick doesn't support more than 4 arguments currently"_s);
+ return JSC::JSValue::encode(JSC::JSValue {});
- break;
+ break;
}
- // JSC::MarkedArgumentBuffer args;
- // for (unsigned i = 1; i < callFrame->argumentCount(); i++) {
- // args.append(callFrame->uncheckedArgument(i));
- // }
+ // JSC::MarkedArgumentBuffer args;
+ // for (unsigned i = 1; i < callFrame->argumentCount(); i++) {
+ // args.append(callFrame->uncheckedArgument(i));
+ // }
- // JSC::ArgList argsList(args);
- // JSC::gcProtect(job);
- // JSC::JSFunction *callback = JSC::JSNativeStdFunction::create(
- // vm, globalObject, 0, String(),
- // [job, &argsList](JSC::JSGlobalObject *globalObject, JSC::CallFrame *callFrame) {
- // JSC::VM &vm = globalObject->vm();
- // auto callData = getCallData(vm, job);
+ // JSC::ArgList argsList(args);
+ // JSC::gcProtect(job);
+ // JSC::JSFunction *callback = JSC::JSNativeStdFunction::create(
+ // vm, globalObject, 0, String(),
+ // [job, &argsList](JSC::JSGlobalObject *globalObject, JSC::CallFrame *callFrame) {
+ // JSC::VM &vm = globalObject->vm();
+ // auto callData = getCallData(vm, job);
- // return JSC::JSValue::encode(JSC::call(globalObject, job, callData, job, argsList));
- // });
+ // return JSC::JSValue::encode(JSC::call(globalObject, job, callData, job, argsList));
+ // });
- // globalObject->queueMicrotask(JSC::createJSMicrotask(vm, JSC::JSValue(callback)));
- }
+ // globalObject->queueMicrotask(JSC::createJSMicrotask(vm, JSC::JSValue(callback)));
+ }
- return JSC::JSValue::encode(JSC::jsUndefined());
+ return JSC::JSValue::encode(JSC::jsUndefined());
}
static JSC_DECLARE_HOST_FUNCTION(Process_functionChdir);
static JSC_DEFINE_HOST_FUNCTION(Process_functionChdir,
- (JSC::JSGlobalObject * globalObject, JSC::CallFrame *callFrame)) {
+ (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
- auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
+ auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
- ZigString str = ZigString{nullptr, 0};
- if (callFrame->argumentCount() > 0) {
- str = Zig::toZigString(callFrame->uncheckedArgument(0).toWTFString(globalObject));
- }
+ ZigString str = ZigString { nullptr, 0 };
+ if (callFrame->argumentCount() > 0) {
+ str = Zig::toZigString(callFrame->uncheckedArgument(0).toWTFString(globalObject));
+ }
- JSC::JSValue result = JSC::JSValue::decode(Bun__Process__setCwd(globalObject, &str));
- JSC::JSObject *obj = result.getObject();
- if (UNLIKELY(obj != nullptr && obj->isErrorInstance())) {
- scope.throwException(globalObject, obj);
- return JSValue::encode(JSC::jsUndefined());
- }
+ JSC::JSValue result = JSC::JSValue::decode(Bun__Process__setCwd(globalObject, &str));
+ JSC::JSObject* obj = result.getObject();
+ if (UNLIKELY(obj != nullptr && obj->isErrorInstance())) {
+ scope.throwException(globalObject, obj);
+ return JSValue::encode(JSC::jsUndefined());
+ }
- return JSC::JSValue::encode(result);
+ return JSC::JSValue::encode(result);
}
-void Process::finishCreation(JSC::VM &vm) {
- Base::finishCreation(vm);
- auto clientData = Bun::clientData(vm);
-
- putDirectCustomAccessor(vm, clientData->builtinNames().pidPublicName(),
- JSC::CustomGetterSetter::create(vm, Process_getPID, nullptr),
- static_cast<unsigned>(JSC::PropertyAttribute::CustomValue));
-
- putDirectCustomAccessor(vm, clientData->builtinNames().ppidPublicName(),
- JSC::CustomGetterSetter::create(vm, Process_getPPID, nullptr),
- static_cast<unsigned>(JSC::PropertyAttribute::CustomValue));
-
- putDirectCustomAccessor(vm, clientData->builtinNames().titlePublicName(),
- JSC::CustomGetterSetter::create(vm, Process_getTitle, Process_setTitle),
- static_cast<unsigned>(JSC::PropertyAttribute::CustomValue));
-
- putDirectCustomAccessor(vm, clientData->builtinNames().argvPublicName(),
- JSC::CustomGetterSetter::create(vm, Process_getArgv, Process_setArgv),
- static_cast<unsigned>(JSC::PropertyAttribute::CustomValue));
-
- this->putDirect(vm, clientData->builtinNames().nextTickPublicName(),
- JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject *>(globalObject()), 0,
- WTF::String("nextTick"), Process_functionNextTick),
- 0);
-
- this->putDirect(vm, clientData->builtinNames().cwdPublicName(),
- JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject *>(globalObject()), 0,
- WTF::String("cwd"), Process_functionCwd),
- 0);
-
- this->putDirect(vm, clientData->builtinNames().chdirPublicName(),
- JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject *>(globalObject()), 0,
- WTF::String("chdir"), Process_functionChdir),
- 0);
-
- putDirectCustomAccessor(
- vm, clientData->builtinNames().versionsPublicName(),
- JSC::CustomGetterSetter::create(vm, Process_getVersionsLazy, Process_setVersionsLazy), 0);
- // this should be transpiled out, but just incase
- this->putDirect(this->vm(), JSC::Identifier::fromString(this->vm(), "browser"),
- JSC::JSValue(false));
-
- this->putDirect(this->vm(), clientData->builtinNames().versionPublicName(),
- JSC::jsString(this->vm(), WTF::String(Bun__version)));
-
- // this gives some way of identifying at runtime whether the SSR is happening in node or not.
- // this should probably be renamed to what the name of the bundler is, instead of "notNodeJS"
- // but it must be something that won't evaluate to truthy in Node.js
- this->putDirect(this->vm(), JSC::Identifier::fromString(this->vm(), "isBun"), JSC::JSValue(true));
+void Process::finishCreation(JSC::VM& vm)
+{
+ Base::finishCreation(vm);
+ auto clientData = Bun::clientData(vm);
+
+ putDirectCustomAccessor(vm, clientData->builtinNames().pidPublicName(),
+ JSC::CustomGetterSetter::create(vm, Process_getPID, nullptr),
+ static_cast<unsigned>(JSC::PropertyAttribute::CustomValue));
+
+ putDirectCustomAccessor(vm, clientData->builtinNames().ppidPublicName(),
+ JSC::CustomGetterSetter::create(vm, Process_getPPID, nullptr),
+ static_cast<unsigned>(JSC::PropertyAttribute::CustomValue));
+
+ putDirectCustomAccessor(vm, clientData->builtinNames().titlePublicName(),
+ JSC::CustomGetterSetter::create(vm, Process_getTitle, Process_setTitle),
+ static_cast<unsigned>(JSC::PropertyAttribute::CustomValue));
+
+ putDirectCustomAccessor(vm, clientData->builtinNames().argvPublicName(),
+ JSC::CustomGetterSetter::create(vm, Process_getArgv, Process_setArgv),
+ static_cast<unsigned>(JSC::PropertyAttribute::CustomValue));
+
+ this->putDirect(vm, clientData->builtinNames().nextTickPublicName(),
+ JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject*>(globalObject()), 0,
+ WTF::String("nextTick"), Process_functionNextTick),
+ 0);
+
+ this->putDirect(vm, clientData->builtinNames().cwdPublicName(),
+ JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject*>(globalObject()), 0,
+ WTF::String("cwd"), Process_functionCwd),
+ 0);
+
+ this->putDirect(vm, clientData->builtinNames().chdirPublicName(),
+ JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject*>(globalObject()), 0,
+ WTF::String("chdir"), Process_functionChdir),
+ 0);
+
+ putDirectCustomAccessor(
+ vm, clientData->builtinNames().versionsPublicName(),
+ JSC::CustomGetterSetter::create(vm, Process_getVersionsLazy, Process_setVersionsLazy), 0);
+ // this should be transpiled out, but just incase
+ this->putDirect(this->vm(), JSC::Identifier::fromString(this->vm(), "browser"),
+ JSC::JSValue(false));
+
+ this->putDirect(this->vm(), clientData->builtinNames().versionPublicName(),
+ JSC::jsString(this->vm(), WTF::String(Bun__version)));
+
+ // this gives some way of identifying at runtime whether the SSR is happening in node or not.
+ // this should probably be renamed to what the name of the bundler is, instead of "notNodeJS"
+ // but it must be something that won't evaluate to truthy in Node.js
+ this->putDirect(this->vm(), JSC::Identifier::fromString(this->vm(), "isBun"), JSC::JSValue(true));
#if defined(__APPLE__)
- this->putDirect(this->vm(), JSC::Identifier::fromString(this->vm(), "platform"),
- JSC::jsString(this->vm(), WTF::String("darwin")));
+ this->putDirect(this->vm(), JSC::Identifier::fromString(this->vm(), "platform"),
+ JSC::jsString(this->vm(), WTF::String("darwin")));
#else
- this->putDirect(this->vm(), JSC::Identifier::fromString(this->vm(), "platform"),
- JSC::jsString(this->vm(), WTF::String("linux")));
+ this->putDirect(this->vm(), JSC::Identifier::fromString(this->vm(), "platform"),
+ JSC::jsString(this->vm(), WTF::String("linux")));
#endif
#if defined(__x86_64__)
- this->putDirect(this->vm(), JSC::Identifier::fromString(this->vm(), "arch"),
- JSC::jsString(this->vm(), WTF::String("x64")));
+ this->putDirect(this->vm(), JSC::Identifier::fromString(this->vm(), "arch"),
+ JSC::jsString(this->vm(), WTF::String("x64")));
#elif defined(__i386__)
- this->putDirect(this->vm(), JSC::Identifier::fromString(this->vm(), "arch"),
- JSC::jsString(this->vm(), WTF::String("x86")));
+ this->putDirect(this->vm(), JSC::Identifier::fromString(this->vm(), "arch"),
+ JSC::jsString(this->vm(), WTF::String("x86")));
#elif defined(__arm__)
- this->putDirect(this->vm(), JSC::Identifier::fromString(this->vm(), "arch"),
- JSC::jsString(this->vm(), WTF::String("arm")));
+ this->putDirect(this->vm(), JSC::Identifier::fromString(this->vm(), "arch"),
+ JSC::jsString(this->vm(), WTF::String("arm")));
#elif defined(__aarch64__)
- this->putDirect(this->vm(), JSC::Identifier::fromString(this->vm(), "arch"),
- JSC::jsString(this->vm(), WTF::String("arm64")));
+ this->putDirect(this->vm(), JSC::Identifier::fromString(this->vm(), "arch"),
+ JSC::jsString(this->vm(), WTF::String("arm64")));
#endif
}
-const JSC::ClassInfo Process::s_info = {"Process", &Base::s_info, nullptr, nullptr,
- CREATE_METHOD_TABLE(Process)};
+const JSC::ClassInfo Process::s_info = { "Process", &Base::s_info, nullptr, nullptr,
+ CREATE_METHOD_TABLE(Process) };
-JSC_DEFINE_CUSTOM_GETTER(Process_getTitle, (JSC::JSGlobalObject * globalObject,
- JSC::EncodedJSValue thisValue, JSC::PropertyName)) {
- ZigString str;
- Bun__Process__getTitle(globalObject, &str);
- return JSValue::encode(Zig::toJSStringValue(str, globalObject));
+JSC_DEFINE_CUSTOM_GETTER(Process_getTitle, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName))
+{
+ ZigString str;
+ Bun__Process__getTitle(globalObject, &str);
+ return JSValue::encode(Zig::toJSStringValue(str, globalObject));
}
JSC_DEFINE_CUSTOM_SETTER(Process_setTitle,
- (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue,
- JSC::EncodedJSValue value, JSC::PropertyName)) {
- JSC::VM &vm = globalObject->vm();
-
- JSC::JSObject *thisObject = JSC::jsDynamicCast<JSC::JSObject *>(vm, JSValue::decode(thisValue));
- JSC::JSString *jsString = JSC::jsDynamicCast<JSC::JSString *>(vm, JSValue::decode(value));
- if (!thisObject || !jsString) { return false; }
+ (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue,
+ JSC::EncodedJSValue value, JSC::PropertyName))
+{
+ JSC::VM& vm = globalObject->vm();
+
+ JSC::JSObject* thisObject = JSC::jsDynamicCast<JSC::JSObject*>(vm, JSValue::decode(thisValue));
+ JSC::JSString* jsString = JSC::jsDynamicCast<JSC::JSString*>(vm, JSValue::decode(value));
+ if (!thisObject || !jsString) {
+ return false;
+ }
- ZigString str = Zig::toZigString(jsString, globalObject);
- Bun__Process__setTitle(globalObject, &str);
+ ZigString str = Zig::toZigString(jsString, globalObject);
+ Bun__Process__setTitle(globalObject, &str);
- return true;
+ return true;
}
-JSC_DEFINE_CUSTOM_GETTER(Process_getArgv, (JSC::JSGlobalObject * globalObject,
- JSC::EncodedJSValue thisValue, JSC::PropertyName)) {
- JSC::VM &vm = globalObject->vm();
+JSC_DEFINE_CUSTOM_GETTER(Process_getArgv, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName))
+{
+ JSC::VM& vm = globalObject->vm();
- Zig::Process *thisObject = JSC::jsDynamicCast<Zig::Process *>(vm, JSValue::decode(thisValue));
- if (!thisObject) { return JSValue::encode(JSC::jsUndefined()); }
- auto clientData = Bun::clientData(vm);
+ Zig::Process* thisObject = JSC::jsDynamicCast<Zig::Process*>(vm, JSValue::decode(thisValue));
+ if (!thisObject) {
+ return JSValue::encode(JSC::jsUndefined());
+ }
+ auto clientData = Bun::clientData(vm);
- if (JSC::JSValue argv = thisObject->getIfPropertyExists(
- globalObject, clientData->builtinNames().argvPrivateName())) {
- return JSValue::encode(argv);
- }
+ if (JSC::JSValue argv = thisObject->getIfPropertyExists(
+ globalObject, clientData->builtinNames().argvPrivateName())) {
+ return JSValue::encode(argv);
+ }
- JSC::EncodedJSValue argv_ = Bun__Process__getArgv(globalObject);
- thisObject->putDirect(vm, clientData->builtinNames().argvPrivateName(),
- JSC::JSValue::decode(argv_));
+ JSC::EncodedJSValue argv_ = Bun__Process__getArgv(globalObject);
+ thisObject->putDirect(vm, clientData->builtinNames().argvPrivateName(),
+ JSC::JSValue::decode(argv_));
- return argv_;
+ return argv_;
}
JSC_DEFINE_CUSTOM_SETTER(Process_setArgv,
- (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue,
- JSC::EncodedJSValue value, JSC::PropertyName)) {
- JSC::VM &vm = globalObject->vm();
-
- JSC::JSObject *thisObject = JSC::jsDynamicCast<JSC::JSObject *>(vm, JSValue::decode(thisValue));
- if (!thisObject) { return false; }
+ (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue,
+ JSC::EncodedJSValue value, JSC::PropertyName))
+{
+ JSC::VM& vm = globalObject->vm();
+
+ JSC::JSObject* thisObject = JSC::jsDynamicCast<JSC::JSObject*>(vm, JSValue::decode(thisValue));
+ if (!thisObject) {
+ return false;
+ }
- auto clientData = Bun::clientData(vm);
+ auto clientData = Bun::clientData(vm);
- return thisObject->putDirect(vm, clientData->builtinNames().argvPrivateName(),
- JSC::JSValue::decode(value));
+ return thisObject->putDirect(vm, clientData->builtinNames().argvPrivateName(),
+ JSC::JSValue::decode(value));
}
-JSC_DEFINE_CUSTOM_GETTER(Process_getPID, (JSC::JSGlobalObject * globalObject,
- JSC::EncodedJSValue thisValue, JSC::PropertyName)) {
- return JSC::JSValue::encode(JSC::JSValue(getpid()));
+JSC_DEFINE_CUSTOM_GETTER(Process_getPID, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName))
+{
+ return JSC::JSValue::encode(JSC::JSValue(getpid()));
}
-JSC_DEFINE_CUSTOM_GETTER(Process_getPPID, (JSC::JSGlobalObject * globalObject,
- JSC::EncodedJSValue thisValue, JSC::PropertyName)) {
- return JSC::JSValue::encode(JSC::JSValue(getppid()));
+JSC_DEFINE_CUSTOM_GETTER(Process_getPPID, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName))
+{
+ return JSC::JSValue::encode(JSC::JSValue(getppid()));
}
JSC_DEFINE_CUSTOM_GETTER(Process_getVersionsLazy,
- (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue,
- JSC::PropertyName)) {
- JSC::VM &vm = globalObject->vm();
- auto clientData = Bun::clientData(vm);
-
- Zig::Process *thisObject = JSC::jsDynamicCast<Zig::Process *>(vm, JSValue::decode(thisValue));
- if (!thisObject) { return JSValue::encode(JSC::jsUndefined()); }
-
- if (JSC::JSValue argv = thisObject->getIfPropertyExists(
- globalObject, clientData->builtinNames().versionsPrivateName())) {
- return JSValue::encode(argv);
- }
-
- JSC::JSObject *object =
- JSC::constructEmptyObject(globalObject, globalObject->objectPrototype(), 9);
-
- object->putDirect(vm, JSC::Identifier::fromString(vm, "node"),
- JSC::JSValue(JSC::jsString(vm, WTF::String("17.0.0"))));
- object->putDirect(
- vm, JSC::Identifier::fromString(vm, "bun"),
- JSC::JSValue(JSC::jsString(vm, WTF::String(Bun__version + 1 /* prefix with v */))));
- object->putDirect(vm, JSC::Identifier::fromString(vm, "webkit"),
- JSC::JSValue(JSC::jsString(vm, WTF::String(Bun__versions_webkit))));
- object->putDirect(vm, JSC::Identifier::fromString(vm, "mimalloc"),
- JSC::JSValue(JSC::jsString(vm, WTF::String(Bun__versions_mimalloc))));
- object->putDirect(vm, JSC::Identifier::fromString(vm, "libarchive"),
- JSC::JSValue(JSC::jsString(vm, WTF::String(Bun__versions_libarchive))));
- object->putDirect(vm, JSC::Identifier::fromString(vm, "picohttpparser"),
- JSC::JSValue(JSC::jsString(vm, WTF::String(Bun__versions_picohttpparser))));
- object->putDirect(vm, JSC::Identifier::fromString(vm, "boringssl"),
- JSC::JSValue(JSC::jsString(vm, WTF::String(Bun__versions_boringssl))));
- object->putDirect(vm, JSC::Identifier::fromString(vm, "zlib"),
- JSC::JSValue(JSC::jsString(vm, WTF::String(Bun__versions_zlib))));
- object->putDirect(vm, JSC::Identifier::fromString(vm, "zig"),
- JSC::JSValue(JSC::jsString(vm, WTF::String(Bun__versions_zig))));
-
- object->putDirect(vm, JSC::Identifier::fromString(vm, "modules"),
- JSC::JSValue(JSC::jsString(vm, WTF::String("67"))));
-
- thisObject->putDirect(vm, clientData->builtinNames().versionsPrivateName(), object);
- return JSC::JSValue::encode(object);
+ (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue,
+ JSC::PropertyName))
+{
+ JSC::VM& vm = globalObject->vm();
+ auto clientData = Bun::clientData(vm);
+
+ Zig::Process* thisObject = JSC::jsDynamicCast<Zig::Process*>(vm, JSValue::decode(thisValue));
+ if (!thisObject) {
+ return JSValue::encode(JSC::jsUndefined());
+ }
+
+ if (JSC::JSValue argv = thisObject->getIfPropertyExists(
+ globalObject, clientData->builtinNames().versionsPrivateName())) {
+ return JSValue::encode(argv);
+ }
+
+ JSC::JSObject* object = JSC::constructEmptyObject(globalObject, globalObject->objectPrototype(), 9);
+
+ object->putDirect(vm, JSC::Identifier::fromString(vm, "node"),
+ JSC::JSValue(JSC::jsString(vm, WTF::String("17.0.0"))));
+ object->putDirect(
+ vm, JSC::Identifier::fromString(vm, "bun"),
+ JSC::JSValue(JSC::jsString(vm, WTF::String(Bun__version + 1 /* prefix with v */))));
+ object->putDirect(vm, JSC::Identifier::fromString(vm, "webkit"),
+ JSC::JSValue(JSC::jsString(vm, WTF::String(Bun__versions_webkit))));
+ object->putDirect(vm, JSC::Identifier::fromString(vm, "mimalloc"),
+ JSC::JSValue(JSC::jsString(vm, WTF::String(Bun__versions_mimalloc))));
+ object->putDirect(vm, JSC::Identifier::fromString(vm, "libarchive"),
+ JSC::JSValue(JSC::jsString(vm, WTF::String(Bun__versions_libarchive))));
+ object->putDirect(vm, JSC::Identifier::fromString(vm, "picohttpparser"),
+ JSC::JSValue(JSC::jsString(vm, WTF::String(Bun__versions_picohttpparser))));
+ object->putDirect(vm, JSC::Identifier::fromString(vm, "boringssl"),
+ JSC::JSValue(JSC::jsString(vm, WTF::String(Bun__versions_boringssl))));
+ object->putDirect(vm, JSC::Identifier::fromString(vm, "zlib"),
+ JSC::JSValue(JSC::jsString(vm, WTF::String(Bun__versions_zlib))));
+ object->putDirect(vm, JSC::Identifier::fromString(vm, "zig"),
+ JSC::JSValue(JSC::jsString(vm, WTF::String(Bun__versions_zig))));
+
+ object->putDirect(vm, JSC::Identifier::fromString(vm, "modules"),
+ JSC::JSValue(JSC::jsString(vm, WTF::String("67"))));
+
+ thisObject->putDirect(vm, clientData->builtinNames().versionsPrivateName(), object);
+ return JSC::JSValue::encode(object);
}
JSC_DEFINE_CUSTOM_SETTER(Process_setVersionsLazy,
- (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue,
- JSC::EncodedJSValue value, JSC::PropertyName)) {
+ (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue,
+ JSC::EncodedJSValue value, JSC::PropertyName))
+{
- JSC::VM &vm = globalObject->vm();
- auto clientData = Bun::clientData(vm);
+ JSC::VM& vm = globalObject->vm();
+ auto clientData = Bun::clientData(vm);
- Zig::Process *thisObject = JSC::jsDynamicCast<Zig::Process *>(vm, JSValue::decode(thisValue));
- if (!thisObject) { return JSValue::encode(JSC::jsUndefined()); }
+ Zig::Process* thisObject = JSC::jsDynamicCast<Zig::Process*>(vm, JSValue::decode(thisValue));
+ if (!thisObject) {
+ return JSValue::encode(JSC::jsUndefined());
+ }
- thisObject->putDirect(vm, clientData->builtinNames().versionsPrivateName(),
- JSC::JSValue::decode(value));
+ thisObject->putDirect(vm, clientData->builtinNames().versionsPrivateName(),
+ JSC::JSValue::decode(value));
- return true;
+ return true;
}
static JSC_DEFINE_HOST_FUNCTION(Process_functionCwd,
- (JSC::JSGlobalObject * globalObject, JSC::CallFrame *callFrame)) {
+ (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
- auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
- JSC::JSValue result = JSC::JSValue::decode(Bun__Process__getCwd(globalObject));
- JSC::JSObject *obj = result.getObject();
- if (UNLIKELY(obj != nullptr && obj->isErrorInstance())) {
- scope.throwException(globalObject, obj);
- return JSValue::encode(JSC::jsUndefined());
- }
+ auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
+ JSC::JSValue result = JSC::JSValue::decode(Bun__Process__getCwd(globalObject));
+ JSC::JSObject* obj = result.getObject();
+ if (UNLIKELY(obj != nullptr && obj->isErrorInstance())) {
+ scope.throwException(globalObject, obj);
+ return JSValue::encode(JSC::jsUndefined());
+ }
- return JSC::JSValue::encode(result);
+ return JSC::JSValue::encode(result);
}
} // namespace Zig \ No newline at end of file
diff --git a/src/javascript/jsc/bindings/Process.h b/src/javascript/jsc/bindings/Process.h
index e6b391e8f..5a4e7ec00 100644
--- a/src/javascript/jsc/bindings/Process.h
+++ b/src/javascript/jsc/bindings/Process.h
@@ -9,32 +9,38 @@ namespace Zig {
using namespace JSC;
class Process : public JSC::JSNonFinalObject {
- using Base = JSC::JSNonFinalObject;
-
- public:
- Process(JSC::VM &vm, JSC::Structure *structure) : Base(vm, structure) {}
-
- DECLARE_INFO;
-
- static constexpr unsigned StructureFlags = Base::StructureFlags;
-
- template <typename CellType, SubspaceAccess> static GCClient::IsoSubspace *subspaceFor(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());
- }
-
- static Process *create(JSC::VM &vm, JSC::Structure *structure) {
- Process *accessor = new (NotNull, JSC::allocateCell<Process>(vm)) Process(vm, structure);
- accessor->finishCreation(vm);
- return accessor;
- }
-
- void finishCreation(JSC::VM &vm);
+ using Base = JSC::JSNonFinalObject;
+
+public:
+ Process(JSC::VM& vm, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ DECLARE_INFO;
+
+ static constexpr unsigned StructureFlags = Base::StructureFlags;
+
+ template<typename CellType, SubspaceAccess> static GCClient::IsoSubspace* subspaceFor(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());
+ }
+
+ static Process* create(JSC::VM& vm, JSC::Structure* structure)
+ {
+ Process* accessor = new (NotNull, JSC::allocateCell<Process>(vm)) Process(vm, structure);
+ accessor->finishCreation(vm);
+ return accessor;
+ }
+
+ void finishCreation(JSC::VM& vm);
};
} // namespace Zig \ No newline at end of file
diff --git a/src/javascript/jsc/bindings/ZigConsoleClient.cpp b/src/javascript/jsc/bindings/ZigConsoleClient.cpp
index 75d137e3c..466e38735 100644
--- a/src/javascript/jsc/bindings/ZigConsoleClient.cpp
+++ b/src/javascript/jsc/bindings/ZigConsoleClient.cpp
@@ -15,109 +15,132 @@ using String = WTF::String;
namespace JSC {
-ALWAYS_INLINE GCDeferralContext::GCDeferralContext(VM &vm) : m_vm(vm) {}
+ALWAYS_INLINE GCDeferralContext::GCDeferralContext(VM& vm)
+ : m_vm(vm)
+{
+}
-ALWAYS_INLINE GCDeferralContext::~GCDeferralContext() {
- if constexpr (validateDFGDoesGC) m_vm.verifyCanGC();
+ALWAYS_INLINE GCDeferralContext::~GCDeferralContext()
+{
+ if constexpr (validateDFGDoesGC)
+ m_vm.verifyCanGC();
- if (UNLIKELY(m_shouldGC)) m_vm.heap.collectIfNecessaryOrDefer();
+ if (UNLIKELY(m_shouldGC))
+ m_vm.heap.collectIfNecessaryOrDefer();
}
} // namespace JSC
extern "C" {
-JSC__JSValue Inspector__ScriptArguments__argumentAt(Inspector__ScriptArguments *arg0, size_t i) {
- return JSC::JSValue::encode(arg0->argumentAt(i));
+JSC__JSValue Inspector__ScriptArguments__argumentAt(Inspector__ScriptArguments* arg0, size_t i)
+{
+ return JSC::JSValue::encode(arg0->argumentAt(i));
}
-size_t Inspector__ScriptArguments__argumentCount(Inspector__ScriptArguments *arg0) {
- return arg0->argumentCount();
+size_t Inspector__ScriptArguments__argumentCount(Inspector__ScriptArguments* arg0)
+{
+ return arg0->argumentCount();
}
bWTF__String
-Inspector__ScriptArguments__getFirstArgumentAsString(Inspector__ScriptArguments *arg0) {
- auto scope = DECLARE_CATCH_SCOPE(arg0->globalObject()->vm());
- JSC::JSValue val0 = arg0->argumentAt(0);
- auto type = val0.asCell()->type();
- Wrap<WTF::String, bWTF__String> wrap;
- wrap.cpp = new (wrap.alignedBuffer()) WTF::String(val0.getString(arg0->globalObject()));
- scope.clearException();
- return wrap.result;
+Inspector__ScriptArguments__getFirstArgumentAsString(Inspector__ScriptArguments* arg0)
+{
+ auto scope = DECLARE_CATCH_SCOPE(arg0->globalObject()->vm());
+ JSC::JSValue val0 = arg0->argumentAt(0);
+ auto type = val0.asCell()->type();
+ Wrap<WTF::String, bWTF__String> wrap;
+ wrap.cpp = new (wrap.alignedBuffer()) WTF::String(val0.getString(arg0->globalObject()));
+ scope.clearException();
+ return wrap.result;
}
-bool Inspector__ScriptArguments__isEqual(Inspector__ScriptArguments *arg0,
- Inspector__ScriptArguments *arg1) {
- return arg0->isEqual(*arg1);
+bool Inspector__ScriptArguments__isEqual(Inspector__ScriptArguments* arg0,
+ Inspector__ScriptArguments* arg1)
+{
+ return arg0->isEqual(*arg1);
}
-void Inspector__ScriptArguments__release(Inspector__ScriptArguments *arg0) {
- auto count = arg0->argumentCount();
- for (int i = 0; i < count; i++) { JSC::gcUnprotect(arg0->argumentAt(i)); }
- arg0->deref();
+void Inspector__ScriptArguments__release(Inspector__ScriptArguments* arg0)
+{
+ auto count = arg0->argumentCount();
+ for (int i = 0; i < count; i++) {
+ JSC::gcUnprotect(arg0->argumentAt(i));
+ }
+ arg0->deref();
}
}
void Zig::ConsoleClient::messageWithTypeAndLevel(MessageType type, MessageLevel level,
- JSC::JSGlobalObject *globalObject,
- Ref<ScriptArguments> &&arguments) {
- JSC::VM &vm = globalObject->vm();
- JSC::GCDeferralContext deferralContext(vm);
- JSC::DisallowGC disallowGC;
- auto args = arguments.ptr();
- JSC__JSValue jsArgs[255];
+ JSC::JSGlobalObject* globalObject,
+ Ref<ScriptArguments>&& arguments)
+{
+ JSC::VM& vm = globalObject->vm();
+ JSC::GCDeferralContext deferralContext(vm);
+ JSC::DisallowGC disallowGC;
+ auto args = arguments.ptr();
+ JSC__JSValue jsArgs[255];
- auto count = std::min(args->argumentCount(), (size_t)255);
- for (size_t i = 0; i < count; i++) {
- auto val = args->argumentAt(i);
- // JSC::gcProtect(val);
- jsArgs[i] = JSC::JSValue::encode(val);
- }
+ auto count = std::min(args->argumentCount(), (size_t)255);
+ for (size_t i = 0; i < count; i++) {
+ auto val = args->argumentAt(i);
+ // JSC::gcProtect(val);
+ jsArgs[i] = JSC::JSValue::encode(val);
+ }
- auto scope = DECLARE_THROW_SCOPE(vm);
- Zig__ConsoleClient__messageWithTypeAndLevel(this->m_client, static_cast<uint32_t>(type),
- static_cast<uint32_t>(level), globalObject, jsArgs,
- count);
- scope.clearException();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+ Zig__ConsoleClient__messageWithTypeAndLevel(this->m_client, static_cast<uint32_t>(type),
+ static_cast<uint32_t>(level), globalObject, jsArgs,
+ count);
+ scope.clearException();
- // for (size_t i = 0; i < count; i++) {
- // JSC::gcUnprotect(JSC::JSValue::decode(jsArgs[i]));
- // }
+ // for (size_t i = 0; i < count; i++) {
+ // JSC::gcUnprotect(JSC::JSValue::decode(jsArgs[i]));
+ // }
}
-void Zig::ConsoleClient::count(JSGlobalObject *globalObject, const String &label) {
- auto ptr = label.characters8();
- Zig__ConsoleClient__count(this->m_client, globalObject, ptr, label.length());
+void Zig::ConsoleClient::count(JSGlobalObject* globalObject, const String& label)
+{
+ auto ptr = label.characters8();
+ Zig__ConsoleClient__count(this->m_client, globalObject, ptr, label.length());
}
-void Zig::ConsoleClient::countReset(JSGlobalObject *globalObject, const String &label) {
- auto ptr = label.characters8();
- Zig__ConsoleClient__countReset(this->m_client, globalObject, ptr, label.length());
-}
-void Zig::ConsoleClient::profile(JSC::JSGlobalObject *globalObject, const String &label) {
- auto ptr = label.characters8();
- Zig__ConsoleClient__profile(this->m_client, globalObject, ptr, label.length());
-}
-void Zig::ConsoleClient::profileEnd(JSC::JSGlobalObject *globalObject, const String &label) {
- auto ptr = label.characters8();
- Zig__ConsoleClient__profileEnd(this->m_client, globalObject, ptr, label.length());
-}
-void Zig::ConsoleClient::takeHeapSnapshot(JSC::JSGlobalObject *globalObject, const String &label) {
- auto ptr = label.characters8();
- Zig__ConsoleClient__takeHeapSnapshot(this->m_client, globalObject, ptr, label.length());
-}
-void Zig::ConsoleClient::time(JSGlobalObject *globalObject, const String &label) {
- auto ptr = label.characters8();
- Zig__ConsoleClient__time(this->m_client, globalObject, ptr, label.length());
-}
-void Zig::ConsoleClient::timeLog(JSGlobalObject *globalObject, const String &label,
- Ref<ScriptArguments> &&arguments) {
- auto ptr = label.characters8();
- Zig__ConsoleClient__timeLog(this->m_client, globalObject, ptr, label.length(), arguments.ptr());
-}
-void Zig::ConsoleClient::timeEnd(JSGlobalObject *globalObject, const String &label) {
- auto ptr = label.characters8();
- Zig__ConsoleClient__timeEnd(this->m_client, globalObject, ptr, label.length());
-}
-void Zig::ConsoleClient::timeStamp(JSGlobalObject *globalObject, Ref<ScriptArguments> &&args) {
- Zig__ConsoleClient__timeStamp(this->m_client, globalObject, args.ptr());
-}
-void Zig::ConsoleClient::record(JSGlobalObject *, Ref<ScriptArguments> &&) {}
-void Zig::ConsoleClient::recordEnd(JSGlobalObject *, Ref<ScriptArguments> &&) {}
-void Zig::ConsoleClient::screenshot(JSGlobalObject *, Ref<ScriptArguments> &&) {}
-void Zig::ConsoleClient::warnUnimplemented(const String &method) {} \ No newline at end of file
+void Zig::ConsoleClient::countReset(JSGlobalObject* globalObject, const String& label)
+{
+ auto ptr = label.characters8();
+ Zig__ConsoleClient__countReset(this->m_client, globalObject, ptr, label.length());
+}
+void Zig::ConsoleClient::profile(JSC::JSGlobalObject* globalObject, const String& label)
+{
+ auto ptr = label.characters8();
+ Zig__ConsoleClient__profile(this->m_client, globalObject, ptr, label.length());
+}
+void Zig::ConsoleClient::profileEnd(JSC::JSGlobalObject* globalObject, const String& label)
+{
+ auto ptr = label.characters8();
+ Zig__ConsoleClient__profileEnd(this->m_client, globalObject, ptr, label.length());
+}
+void Zig::ConsoleClient::takeHeapSnapshot(JSC::JSGlobalObject* globalObject, const String& label)
+{
+ auto ptr = label.characters8();
+ Zig__ConsoleClient__takeHeapSnapshot(this->m_client, globalObject, ptr, label.length());
+}
+void Zig::ConsoleClient::time(JSGlobalObject* globalObject, const String& label)
+{
+ auto ptr = label.characters8();
+ Zig__ConsoleClient__time(this->m_client, globalObject, ptr, label.length());
+}
+void Zig::ConsoleClient::timeLog(JSGlobalObject* globalObject, const String& label,
+ Ref<ScriptArguments>&& arguments)
+{
+ auto ptr = label.characters8();
+ Zig__ConsoleClient__timeLog(this->m_client, globalObject, ptr, label.length(), arguments.ptr());
+}
+void Zig::ConsoleClient::timeEnd(JSGlobalObject* globalObject, const String& label)
+{
+ auto ptr = label.characters8();
+ Zig__ConsoleClient__timeEnd(this->m_client, globalObject, ptr, label.length());
+}
+void Zig::ConsoleClient::timeStamp(JSGlobalObject* globalObject, Ref<ScriptArguments>&& args)
+{
+ Zig__ConsoleClient__timeStamp(this->m_client, globalObject, args.ptr());
+}
+void Zig::ConsoleClient::record(JSGlobalObject*, Ref<ScriptArguments>&&) {}
+void Zig::ConsoleClient::recordEnd(JSGlobalObject*, Ref<ScriptArguments>&&) {}
+void Zig::ConsoleClient::screenshot(JSGlobalObject*, Ref<ScriptArguments>&&) {}
+void Zig::ConsoleClient::warnUnimplemented(const String& method) {} \ No newline at end of file
diff --git a/src/javascript/jsc/bindings/ZigConsoleClient.h b/src/javascript/jsc/bindings/ZigConsoleClient.h
index 61a0cc542..f8c0731de 100644
--- a/src/javascript/jsc/bindings/ZigConsoleClient.h
+++ b/src/javascript/jsc/bindings/ZigConsoleClient.h
@@ -16,50 +16,55 @@ using InspectorScriptProfilerAgent = Inspector::InspectorScriptProfilerAgent;
using namespace JSC;
class ConsoleClient final : public JSC::ConsoleClient {
- WTF_MAKE_FAST_ALLOCATED;
+ WTF_MAKE_FAST_ALLOCATED;
- public:
- ~ConsoleClient() final {}
- ConsoleClient(void *client) : JSC::ConsoleClient() { m_client = client; }
+public:
+ ~ConsoleClient() final {}
+ ConsoleClient(void* client)
+ : JSC::ConsoleClient()
+ {
+ m_client = client;
+ }
- static bool logToSystemConsole();
- static void setLogToSystemConsole(bool);
+ static bool logToSystemConsole();
+ static void setLogToSystemConsole(bool);
- void setDebuggerAgent(InspectorDebuggerAgent *agent) { m_debuggerAgent = agent; }
- void setPersistentScriptProfilerAgent(InspectorScriptProfilerAgent *agent) {
- m_scriptProfilerAgent = agent;
- }
+ void setDebuggerAgent(InspectorDebuggerAgent* agent) { m_debuggerAgent = agent; }
+ void setPersistentScriptProfilerAgent(InspectorScriptProfilerAgent* agent)
+ {
+ m_scriptProfilerAgent = agent;
+ }
- void *m_client;
+ void* m_client;
- private:
- void messageWithTypeAndLevel(MessageType, MessageLevel, JSC::JSGlobalObject *,
- Ref<Inspector::ScriptArguments> &&);
- void count(JSC::JSGlobalObject *, const String &label);
- void countReset(JSC::JSGlobalObject *, const String &label);
- void profile(JSC::JSGlobalObject *, const String &title);
- void profileEnd(JSC::JSGlobalObject *, const String &title);
- void takeHeapSnapshot(JSC::JSGlobalObject *, const String &title);
- void time(JSC::JSGlobalObject *, const String &label);
- void timeLog(JSC::JSGlobalObject *, const String &label, Ref<Inspector::ScriptArguments> &&);
- void timeEnd(JSC::JSGlobalObject *, const String &label);
- void timeStamp(JSC::JSGlobalObject *, Ref<Inspector::ScriptArguments> &&);
- void record(JSC::JSGlobalObject *, Ref<Inspector::ScriptArguments> &&);
- void recordEnd(JSC::JSGlobalObject *, Ref<Inspector::ScriptArguments> &&);
- void screenshot(JSC::JSGlobalObject *, Ref<Inspector::ScriptArguments> &&);
+private:
+ void messageWithTypeAndLevel(MessageType, MessageLevel, JSC::JSGlobalObject*,
+ Ref<Inspector::ScriptArguments>&&);
+ void count(JSC::JSGlobalObject*, const String& label);
+ void countReset(JSC::JSGlobalObject*, const String& label);
+ void profile(JSC::JSGlobalObject*, const String& title);
+ void profileEnd(JSC::JSGlobalObject*, const String& title);
+ void takeHeapSnapshot(JSC::JSGlobalObject*, const String& title);
+ void time(JSC::JSGlobalObject*, const String& label);
+ void timeLog(JSC::JSGlobalObject*, const String& label, Ref<Inspector::ScriptArguments>&&);
+ void timeEnd(JSC::JSGlobalObject*, const String& label);
+ void timeStamp(JSC::JSGlobalObject*, Ref<Inspector::ScriptArguments>&&);
+ void record(JSC::JSGlobalObject*, Ref<Inspector::ScriptArguments>&&);
+ void recordEnd(JSC::JSGlobalObject*, Ref<Inspector::ScriptArguments>&&);
+ void screenshot(JSC::JSGlobalObject*, Ref<Inspector::ScriptArguments>&&);
- void warnUnimplemented(const String &method);
- void internalAddMessage(MessageType, MessageLevel, JSC::JSGlobalObject *,
- Ref<Inspector::ScriptArguments> &&);
+ void warnUnimplemented(const String& method);
+ void internalAddMessage(MessageType, MessageLevel, JSC::JSGlobalObject*,
+ Ref<Inspector::ScriptArguments>&&);
- void startConsoleProfile();
- void stopConsoleProfile();
+ void startConsoleProfile();
+ void stopConsoleProfile();
- Inspector::InspectorConsoleAgent *m_consoleAgent;
- Inspector::InspectorDebuggerAgent *m_debuggerAgent{nullptr};
- Inspector::InspectorScriptProfilerAgent *m_scriptProfilerAgent{nullptr};
- Vector<String> m_profiles;
- bool m_profileRestoreBreakpointActiveValue{false};
+ Inspector::InspectorConsoleAgent* m_consoleAgent;
+ Inspector::InspectorDebuggerAgent* m_debuggerAgent { nullptr };
+ Inspector::InspectorScriptProfilerAgent* m_scriptProfilerAgent { nullptr };
+ Vector<String> m_profiles;
+ bool m_profileRestoreBreakpointActiveValue { false };
};
} // namespace Zig
diff --git a/src/javascript/jsc/bindings/ZigGlobalObject.cpp b/src/javascript/jsc/bindings/ZigGlobalObject.cpp
index 8b0eebc63..3ab654dda 100644
--- a/src/javascript/jsc/bindings/ZigGlobalObject.cpp
+++ b/src/javascript/jsc/bindings/ZigGlobalObject.cpp
@@ -88,178 +88,186 @@ namespace JSCastingHelpers = JSC::JSCastingHelpers;
static bool has_loaded_jsc = false;
-extern "C" void JSCInitialize() {
- if (has_loaded_jsc) return;
- has_loaded_jsc = true;
-
- JSC::Options::useSourceProviderCache() = true;
- JSC::Options::useUnlinkedCodeBlockJettisoning() = false;
- JSC::Options::exposeInternalModuleLoader() = true;
- JSC::Options::useSharedArrayBuffer() = true;
- // JSC::Options::useAtMethod() = true;
- std::set_terminate([]() { Zig__GlobalObject__onCrash(); });
- WTF::initializeMainThread();
- JSC::initialize();
+extern "C" void JSCInitialize()
+{
+ if (has_loaded_jsc)
+ return;
+ has_loaded_jsc = true;
+
+ JSC::Options::useSourceProviderCache() = true;
+ JSC::Options::useUnlinkedCodeBlockJettisoning() = false;
+ JSC::Options::exposeInternalModuleLoader() = true;
+ JSC::Options::useSharedArrayBuffer() = true;
+ // JSC::Options::useAtMethod() = true;
+ std::set_terminate([]() { Zig__GlobalObject__onCrash(); });
+ WTF::initializeMainThread();
+ JSC::initialize();
}
-extern "C" JSC__JSGlobalObject *Zig__GlobalObject__create(JSClassRef *globalObjectClass, int count,
- void *console_client) {
- auto heapSize = JSC::HeapType::Large;
+extern "C" JSC__JSGlobalObject* Zig__GlobalObject__create(JSClassRef* globalObjectClass, int count,
+ void* console_client)
+{
+ auto heapSize = JSC::HeapType::Large;
- JSC::VM &vm = JSC::VM::create(heapSize).leakRef();
- Bun::JSVMClientData::create(&vm);
+ JSC::VM& vm = JSC::VM::create(heapSize).leakRef();
+ Bun::JSVMClientData::create(&vm);
- vm.heap.acquireAccess();
+ vm.heap.acquireAccess();
#if ENABLE(WEBASSEMBLY)
- JSC::Wasm::enableFastMemory();
+ JSC::Wasm::enableFastMemory();
#endif
- JSC::JSLockHolder locker(vm);
- Zig::GlobalObject *globalObject =
- Zig::GlobalObject::create(vm, Zig::GlobalObject::createStructure(vm, JSC::jsNull()));
- globalObject->setConsole(globalObject);
+ JSC::JSLockHolder locker(vm);
+ Zig::GlobalObject* globalObject = Zig::GlobalObject::create(vm, Zig::GlobalObject::createStructure(vm, JSC::jsNull()));
+ globalObject->setConsole(globalObject);
- if (count > 0) { globalObject->installAPIGlobals(globalObjectClass, count); }
+ if (count > 0) {
+ globalObject->installAPIGlobals(globalObjectClass, count);
+ }
- JSC::gcProtect(globalObject);
- vm.ref();
- return globalObject;
+ JSC::gcProtect(globalObject);
+ vm.ref();
+ return globalObject;
}
-extern "C" void *Zig__GlobalObject__getModuleRegistryMap(JSC__JSGlobalObject *arg0) {
- if (JSC::JSObject *loader =
- JSC::jsDynamicCast<JSC::JSObject *>(arg0->vm(), arg0->moduleLoader())) {
- JSC::JSMap *map = JSC::jsDynamicCast<JSC::JSMap *>(
- arg0->vm(),
- loader->getDirect(arg0->vm(), JSC::Identifier::fromString(arg0->vm(), "registry")));
+extern "C" void* Zig__GlobalObject__getModuleRegistryMap(JSC__JSGlobalObject* arg0)
+{
+ if (JSC::JSObject* loader = JSC::jsDynamicCast<JSC::JSObject*>(arg0->vm(), arg0->moduleLoader())) {
+ JSC::JSMap* map = JSC::jsDynamicCast<JSC::JSMap*>(
+ arg0->vm(),
+ loader->getDirect(arg0->vm(), JSC::Identifier::fromString(arg0->vm(), "registry")));
- JSC::JSMap *cloned = map->clone(arg0, arg0->vm(), arg0->mapStructure());
- JSC::gcProtect(cloned);
+ JSC::JSMap* cloned = map->clone(arg0, arg0->vm(), arg0->mapStructure());
+ JSC::gcProtect(cloned);
- return cloned;
- }
+ return cloned;
+ }
- return nullptr;
+ return nullptr;
}
-extern "C" bool Zig__GlobalObject__resetModuleRegistryMap(JSC__JSGlobalObject *globalObject,
- void *map_ptr) {
- if (map_ptr == nullptr) return false;
- JSC::JSMap *map = reinterpret_cast<JSC::JSMap *>(map_ptr);
- JSC::VM &vm = globalObject->vm();
- if (JSC::JSObject *obj =
- JSC::jsDynamicCast<JSC::JSObject *>(globalObject->vm(), globalObject->moduleLoader())) {
- auto identifier = JSC::Identifier::fromString(globalObject->vm(), "registry");
-
- if (JSC::JSMap *oldMap = JSC::jsDynamicCast<JSC::JSMap *>(
- globalObject->vm(), obj->getDirect(globalObject->vm(), identifier))) {
- oldMap->clear(globalObject);
- // vm.finalizeSynchronousJSExecution();
-
- obj->putDirect(globalObject->vm(), identifier,
- map->clone(globalObject, globalObject->vm(), globalObject->mapStructure()));
-
- // vm.deleteAllLinkedCode(JSC::DeleteAllCodeEffort::DeleteAllCodeIfNotCollecting);
- // JSC::Heap::PreventCollectionScope(vm.heap);
-
- // vm.heap.completeAllJITPlans();
-
- // vm.forEachScriptExecutableSpace([&](auto &spaceAndSet) {
- // JSC::HeapIterationScope heapIterationScope(vm.heap);
- // auto &set = spaceAndSet.set;
- // set.forEachLiveCell([&](JSC::HeapCell *cell, JSC::HeapCell::Kind) {
- // if (JSC::ModuleProgramExecutable *executable =
- // JSC::jsDynamicCast<JSC::ModuleProgramExecutable *>(cell)) {
- // executable->clearCode(set);
- // }
- // });
- // });
+extern "C" bool Zig__GlobalObject__resetModuleRegistryMap(JSC__JSGlobalObject* globalObject,
+ void* map_ptr)
+{
+ if (map_ptr == nullptr)
+ return false;
+ JSC::JSMap* map = reinterpret_cast<JSC::JSMap*>(map_ptr);
+ JSC::VM& vm = globalObject->vm();
+ if (JSC::JSObject* obj = JSC::jsDynamicCast<JSC::JSObject*>(globalObject->vm(), globalObject->moduleLoader())) {
+ auto identifier = JSC::Identifier::fromString(globalObject->vm(), "registry");
+
+ if (JSC::JSMap* oldMap = JSC::jsDynamicCast<JSC::JSMap*>(
+ globalObject->vm(), obj->getDirect(globalObject->vm(), identifier))) {
+ oldMap->clear(globalObject);
+ // vm.finalizeSynchronousJSExecution();
+
+ obj->putDirect(globalObject->vm(), identifier,
+ map->clone(globalObject, globalObject->vm(), globalObject->mapStructure()));
+
+ // vm.deleteAllLinkedCode(JSC::DeleteAllCodeEffort::DeleteAllCodeIfNotCollecting);
+ // JSC::Heap::PreventCollectionScope(vm.heap);
+
+ // vm.heap.completeAllJITPlans();
+
+ // vm.forEachScriptExecutableSpace([&](auto &spaceAndSet) {
+ // JSC::HeapIterationScope heapIterationScope(vm.heap);
+ // auto &set = spaceAndSet.set;
+ // set.forEachLiveCell([&](JSC::HeapCell *cell, JSC::HeapCell::Kind) {
+ // if (JSC::ModuleProgramExecutable *executable =
+ // JSC::jsDynamicCast<JSC::ModuleProgramExecutable *>(cell)) {
+ // executable->clearCode(set);
+ // }
+ // });
+ // });
+ }
+ // globalObject->vm().heap.deleteAllUnlinkedCodeBlocks(
+ // JSC::DeleteAllCodeEffort::PreventCollectionAndDeleteAllCode);
+ // vm.whenIdle([globalObject, oldMap, map]() {
+ // auto recordIdentifier = JSC::Identifier::fromString(globalObject->vm(), "module");
+
+ // JSC::JSModuleRecord *record;
+ // JSC::JSValue key;
+ // JSC::JSValue value;
+ // JSC::JSObject *mod;
+ // JSC::JSObject *nextObject;
+ // JSC::forEachInIterable(
+ // globalObject, oldMap,
+ // [&](JSC::VM &vm, JSC::JSGlobalObject *globalObject, JSC::JSValue nextValue) {
+ // nextObject = JSC::jsDynamicCast<JSC::JSObject *>(vm, nextValue);
+ // key = nextObject->getIndex(globalObject, static_cast<unsigned>(0));
+
+ // if (!map->has(globalObject, key)) {
+ // value = nextObject->getIndex(globalObject, static_cast<unsigned>(1));
+ // mod = JSC::jsDynamicCast<JSC::JSObject *>(vm, value);
+ // if (mod) {
+ // record = JSC::jsDynamicCast<JSC::JSModuleRecord *>(
+ // vm, mod->getDirect(vm, recordIdentifier));
+ // if (record) {
+ // auto code = &record->sourceCode();
+ // if (code) {
+
+ // Zig::SourceProvider *provider =
+ // reinterpret_cast<Zig::SourceProvider *>(code->provider());
+ // // code->~SourceCode();
+ // if (provider) { provider->freeSourceCode(); }
+ // }
+ // }
+ // }
+ // }
+ // });
+
+ // oldMap->clear(globalObject);
+ // }
+ // }
+ // map
}
- // globalObject->vm().heap.deleteAllUnlinkedCodeBlocks(
- // JSC::DeleteAllCodeEffort::PreventCollectionAndDeleteAllCode);
- // vm.whenIdle([globalObject, oldMap, map]() {
- // auto recordIdentifier = JSC::Identifier::fromString(globalObject->vm(), "module");
-
- // JSC::JSModuleRecord *record;
- // JSC::JSValue key;
- // JSC::JSValue value;
- // JSC::JSObject *mod;
- // JSC::JSObject *nextObject;
- // JSC::forEachInIterable(
- // globalObject, oldMap,
- // [&](JSC::VM &vm, JSC::JSGlobalObject *globalObject, JSC::JSValue nextValue) {
- // nextObject = JSC::jsDynamicCast<JSC::JSObject *>(vm, nextValue);
- // key = nextObject->getIndex(globalObject, static_cast<unsigned>(0));
-
- // if (!map->has(globalObject, key)) {
- // value = nextObject->getIndex(globalObject, static_cast<unsigned>(1));
- // mod = JSC::jsDynamicCast<JSC::JSObject *>(vm, value);
- // if (mod) {
- // record = JSC::jsDynamicCast<JSC::JSModuleRecord *>(
- // vm, mod->getDirect(vm, recordIdentifier));
- // if (record) {
- // auto code = &record->sourceCode();
- // if (code) {
-
- // Zig::SourceProvider *provider =
- // reinterpret_cast<Zig::SourceProvider *>(code->provider());
- // // code->~SourceCode();
- // if (provider) { provider->freeSourceCode(); }
- // }
- // }
- // }
- // }
- // });
-
- // oldMap->clear(globalObject);
- // }
- // }
- // map
- }
- return true;
+ return true;
}
namespace Zig {
-const JSC::ClassInfo GlobalObject::s_info = {"GlobalObject", &Base::s_info, nullptr, nullptr,
- CREATE_METHOD_TABLE(GlobalObject)};
+const JSC::ClassInfo GlobalObject::s_info = { "GlobalObject", &Base::s_info, nullptr, nullptr,
+ CREATE_METHOD_TABLE(GlobalObject) };
const JSC::GlobalObjectMethodTable GlobalObject::s_globalObjectMethodTable = {
- &supportsRichSourceInfo,
- &shouldInterruptScript,
- &javaScriptRuntimeFlags,
- &queueMicrotaskToEventLoop, // queueTaskToEventLoop
- nullptr, // &shouldInterruptScriptBeforeTimeout,
- &moduleLoaderImportModule, // moduleLoaderImportModule
- &moduleLoaderResolve, // moduleLoaderResolve
- &moduleLoaderFetch, // moduleLoaderFetch
- &moduleLoaderCreateImportMetaProperties, // moduleLoaderCreateImportMetaProperties
- &moduleLoaderEvaluate, // moduleLoaderEvaluate
- &promiseRejectionTracker, // promiseRejectionTracker
- &reportUncaughtExceptionAtEventLoop,
- &currentScriptExecutionOwner,
- &scriptExecutionStatus,
- nullptr, // defaultLanguage
- nullptr, // compileStreaming
- nullptr, // instantiateStreaming
+ &supportsRichSourceInfo,
+ &shouldInterruptScript,
+ &javaScriptRuntimeFlags,
+ &queueMicrotaskToEventLoop, // queueTaskToEventLoop
+ nullptr, // &shouldInterruptScriptBeforeTimeout,
+ &moduleLoaderImportModule, // moduleLoaderImportModule
+ &moduleLoaderResolve, // moduleLoaderResolve
+ &moduleLoaderFetch, // moduleLoaderFetch
+ &moduleLoaderCreateImportMetaProperties, // moduleLoaderCreateImportMetaProperties
+ &moduleLoaderEvaluate, // moduleLoaderEvaluate
+ &promiseRejectionTracker, // promiseRejectionTracker
+ &reportUncaughtExceptionAtEventLoop,
+ &currentScriptExecutionOwner,
+ &scriptExecutionStatus,
+ nullptr, // defaultLanguage
+ nullptr, // compileStreaming
+ nullptr, // instantiateStreaming
};
-void GlobalObject::reportUncaughtExceptionAtEventLoop(JSGlobalObject *globalObject,
- Exception *exception) {
- Zig__GlobalObject__reportUncaughtException(globalObject, exception);
+void GlobalObject::reportUncaughtExceptionAtEventLoop(JSGlobalObject* globalObject,
+ Exception* exception)
+{
+ Zig__GlobalObject__reportUncaughtException(globalObject, exception);
}
-void GlobalObject::promiseRejectionTracker(JSGlobalObject *obj, JSC::JSPromise *prom,
- JSC::JSPromiseRejectionOperation reject) {
- Zig__GlobalObject__promiseRejectionTracker(
- obj, prom, reject == JSC::JSPromiseRejectionOperation::Reject ? 0 : 1);
+void GlobalObject::promiseRejectionTracker(JSGlobalObject* obj, JSC::JSPromise* prom,
+ JSC::JSPromiseRejectionOperation reject)
+{
+ Zig__GlobalObject__promiseRejectionTracker(
+ obj, prom, reject == JSC::JSPromiseRejectionOperation::Reject ? 0 : 1);
}
-static Zig::ConsoleClient *m_console;
+static Zig::ConsoleClient* m_console;
-void GlobalObject::setConsole(void *console) {
- m_console = new Zig::ConsoleClient(console);
- this->setConsoleClient(m_console);
+void GlobalObject::setConsole(void* console)
+{
+ m_console = new Zig::ConsoleClient(console);
+ this->setConsoleClient(m_console);
}
#pragma mark - Globals
@@ -268,391 +276,404 @@ static JSC_DECLARE_CUSTOM_SETTER(property_lazyProcessSetter);
static JSC_DECLARE_CUSTOM_GETTER(property_lazyProcessGetter);
JSC_DEFINE_CUSTOM_SETTER(property_lazyProcessSetter,
- (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue,
- JSC::EncodedJSValue value, JSC::PropertyName)) {
- return false;
+ (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue,
+ JSC::EncodedJSValue value, JSC::PropertyName))
+{
+ return false;
}
static JSClassRef dot_env_class_ref;
JSC_DEFINE_CUSTOM_GETTER(property_lazyProcessGetter,
- (JSC::JSGlobalObject * _globalObject, JSC::EncodedJSValue thisValue,
- JSC::PropertyName)) {
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject *>(_globalObject);
- if (LIKELY(globalObject->m_process))
- return JSValue::encode(JSC::JSValue(globalObject->m_process));
+ (JSC::JSGlobalObject * _globalObject, JSC::EncodedJSValue thisValue,
+ JSC::PropertyName))
+{
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(_globalObject);
+ if (LIKELY(globalObject->m_process))
+ return JSValue::encode(JSC::JSValue(globalObject->m_process));
- JSC::VM &vm = globalObject->vm();
+ JSC::VM& vm = globalObject->vm();
- globalObject->m_process = Zig::Process::create(
- vm, Zig::Process::createStructure(vm, globalObject, globalObject->objectPrototype()));
+ globalObject->m_process = Zig::Process::create(
+ vm, Zig::Process::createStructure(vm, globalObject, globalObject->objectPrototype()));
- {
- auto jsClass = dot_env_class_ref;
+ {
+ auto jsClass = dot_env_class_ref;
- JSC::JSCallbackObject<JSNonFinalObject> *object =
- JSC::JSCallbackObject<JSNonFinalObject>::create(
- globalObject, globalObject->callbackObjectStructure(), jsClass, nullptr);
- if (JSObject *prototype = jsClass->prototype(globalObject))
- object->setPrototypeDirect(vm, prototype);
+ JSC::JSCallbackObject<JSNonFinalObject>* object = JSC::JSCallbackObject<JSNonFinalObject>::create(
+ globalObject, globalObject->callbackObjectStructure(), jsClass, nullptr);
+ if (JSObject* prototype = jsClass->prototype(globalObject))
+ object->setPrototypeDirect(vm, prototype);
- globalObject->m_process->putDirect(vm, JSC::Identifier::fromString(vm, "env"),
- JSC::JSValue(object),
- JSC::PropertyAttribute::DontDelete | 0);
- }
+ globalObject->m_process->putDirect(vm, JSC::Identifier::fromString(vm, "env"),
+ JSC::JSValue(object),
+ JSC::PropertyAttribute::DontDelete | 0);
+ }
- return JSC::JSValue::encode(JSC::JSValue(globalObject->m_process));
+ return JSC::JSValue::encode(JSC::JSValue(globalObject->m_process));
}
static JSC_DECLARE_HOST_FUNCTION(functionQueueMicrotask);
static JSC_DEFINE_HOST_FUNCTION(functionQueueMicrotask,
- (JSC::JSGlobalObject * globalObject, JSC::CallFrame *callFrame)) {
- JSC::VM &vm = globalObject->vm();
-
- if (callFrame->argumentCount() == 0) {
- auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
- JSC::throwTypeError(globalObject, scope, "queueMicrotask requires 1 argument (a function)"_s);
- return JSC::JSValue::encode(JSC::JSValue{});
- }
+ (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ JSC::VM& vm = globalObject->vm();
+
+ if (callFrame->argumentCount() == 0) {
+ auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
+ JSC::throwTypeError(globalObject, scope, "queueMicrotask requires 1 argument (a function)"_s);
+ return JSC::JSValue::encode(JSC::JSValue {});
+ }
- JSC::JSValue job = callFrame->argument(0);
+ JSC::JSValue job = callFrame->argument(0);
- if (!job.isObject() || !job.getObject()->isCallable(vm)) {
- auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
- JSC::throwTypeError(globalObject, scope, "queueMicrotask expects a function"_s);
- return JSC::JSValue::encode(JSC::JSValue{});
- }
+ if (!job.isObject() || !job.getObject()->isCallable(vm)) {
+ auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
+ JSC::throwTypeError(globalObject, scope, "queueMicrotask expects a function"_s);
+ return JSC::JSValue::encode(JSC::JSValue {});
+ }
- // This is a JSC builtin function
- globalObject->queueMicrotask(JSC::createJSMicrotask(vm, job, JSC::JSValue{}, JSC::JSValue{},
- JSC::JSValue{}, JSC::JSValue{}));
+ // This is a JSC builtin function
+ globalObject->queueMicrotask(JSC::createJSMicrotask(vm, job, JSC::JSValue {}, JSC::JSValue {},
+ JSC::JSValue {}, JSC::JSValue {}));
- return JSC::JSValue::encode(JSC::jsUndefined());
+ return JSC::JSValue::encode(JSC::jsUndefined());
}
static JSC_DECLARE_HOST_FUNCTION(functionSetTimeout);
static JSC_DEFINE_HOST_FUNCTION(functionSetTimeout,
- (JSC::JSGlobalObject * globalObject, JSC::CallFrame *callFrame)) {
- JSC::VM &vm = globalObject->vm();
-
- if (callFrame->argumentCount() == 0) {
- auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
- JSC::throwTypeError(globalObject, scope, "setTimeout requires 1 argument (a function)"_s);
- return JSC::JSValue::encode(JSC::JSValue{});
- }
-
- JSC::JSValue job = callFrame->argument(0);
-
- if (!job.isObject() || !job.getObject()->isCallable(vm)) {
- auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
- JSC::throwTypeError(globalObject, scope, "setTimeout expects a function"_s);
- return JSC::JSValue::encode(JSC::JSValue{});
- }
-
- if (callFrame->argumentCount() == 1) {
- globalObject->queueMicrotask(JSC::createJSMicrotask(vm, job, JSC::JSValue{}, JSC::JSValue{},
- JSC::JSValue{}, JSC::JSValue{}));
- return JSC::JSValue::encode(JSC::jsNumber(Bun__Timer__getNextID()));
- }
-
- JSC::JSValue num = callFrame->argument(1);
- return Bun__Timer__setTimeout(globalObject, JSC::JSValue::encode(job), JSC::JSValue::encode(num));
+ (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ JSC::VM& vm = globalObject->vm();
+
+ if (callFrame->argumentCount() == 0) {
+ auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
+ JSC::throwTypeError(globalObject, scope, "setTimeout requires 1 argument (a function)"_s);
+ return JSC::JSValue::encode(JSC::JSValue {});
+ }
+
+ JSC::JSValue job = callFrame->argument(0);
+
+ if (!job.isObject() || !job.getObject()->isCallable(vm)) {
+ auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
+ JSC::throwTypeError(globalObject, scope, "setTimeout expects a function"_s);
+ return JSC::JSValue::encode(JSC::JSValue {});
+ }
+
+ if (callFrame->argumentCount() == 1) {
+ globalObject->queueMicrotask(JSC::createJSMicrotask(vm, job, JSC::JSValue {}, JSC::JSValue {},
+ JSC::JSValue {}, JSC::JSValue {}));
+ return JSC::JSValue::encode(JSC::jsNumber(Bun__Timer__getNextID()));
+ }
+
+ JSC::JSValue num = callFrame->argument(1);
+ return Bun__Timer__setTimeout(globalObject, JSC::JSValue::encode(job), JSC::JSValue::encode(num));
}
static JSC_DECLARE_HOST_FUNCTION(functionSetInterval);
static JSC_DEFINE_HOST_FUNCTION(functionSetInterval,
- (JSC::JSGlobalObject * globalObject, JSC::CallFrame *callFrame)) {
- JSC::VM &vm = globalObject->vm();
-
- if (callFrame->argumentCount() == 0) {
- auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
- JSC::throwTypeError(globalObject, scope, "setInterval requires 2 arguments (a function)"_s);
- return JSC::JSValue::encode(JSC::JSValue{});
- }
-
- JSC::JSValue job = callFrame->argument(0);
-
- if (!job.isObject() || !job.getObject()->isCallable(vm)) {
- auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
- JSC::throwTypeError(globalObject, scope, "setInterval expects a function"_s);
- return JSC::JSValue::encode(JSC::JSValue{});
- }
-
- JSC::JSValue num = callFrame->argument(1);
- return Bun__Timer__setInterval(globalObject, JSC::JSValue::encode(job),
- JSC::JSValue::encode(num));
+ (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ JSC::VM& vm = globalObject->vm();
+
+ if (callFrame->argumentCount() == 0) {
+ auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
+ JSC::throwTypeError(globalObject, scope, "setInterval requires 2 arguments (a function)"_s);
+ return JSC::JSValue::encode(JSC::JSValue {});
+ }
+
+ JSC::JSValue job = callFrame->argument(0);
+
+ if (!job.isObject() || !job.getObject()->isCallable(vm)) {
+ auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
+ JSC::throwTypeError(globalObject, scope, "setInterval expects a function"_s);
+ return JSC::JSValue::encode(JSC::JSValue {});
+ }
+
+ JSC::JSValue num = callFrame->argument(1);
+ return Bun__Timer__setInterval(globalObject, JSC::JSValue::encode(job),
+ JSC::JSValue::encode(num));
}
static JSC_DECLARE_HOST_FUNCTION(functionClearInterval);
static JSC_DEFINE_HOST_FUNCTION(functionClearInterval,
- (JSC::JSGlobalObject * globalObject, JSC::CallFrame *callFrame)) {
- JSC::VM &vm = globalObject->vm();
-
- if (callFrame->argumentCount() == 0) {
- auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
- JSC::throwTypeError(globalObject, scope, "clearInterval requires 1 argument (a number)"_s);
- return JSC::JSValue::encode(JSC::JSValue{});
- }
+ (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ JSC::VM& vm = globalObject->vm();
+
+ if (callFrame->argumentCount() == 0) {
+ auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
+ JSC::throwTypeError(globalObject, scope, "clearInterval requires 1 argument (a number)"_s);
+ return JSC::JSValue::encode(JSC::JSValue {});
+ }
- JSC::JSValue num = callFrame->argument(0);
+ JSC::JSValue num = callFrame->argument(0);
- return Bun__Timer__clearInterval(globalObject, JSC::JSValue::encode(num));
+ return Bun__Timer__clearInterval(globalObject, JSC::JSValue::encode(num));
}
static JSC_DECLARE_HOST_FUNCTION(functionClearTimeout);
static JSC_DEFINE_HOST_FUNCTION(functionClearTimeout,
- (JSC::JSGlobalObject * globalObject, JSC::CallFrame *callFrame)) {
- JSC::VM &vm = globalObject->vm();
-
- if (callFrame->argumentCount() == 0) {
- auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
- JSC::throwTypeError(globalObject, scope, "clearTimeout requires 1 argument (a number)"_s);
- return JSC::JSValue::encode(JSC::JSValue{});
- }
+ (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ JSC::VM& vm = globalObject->vm();
+
+ if (callFrame->argumentCount() == 0) {
+ auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
+ JSC::throwTypeError(globalObject, scope, "clearTimeout requires 1 argument (a number)"_s);
+ return JSC::JSValue::encode(JSC::JSValue {});
+ }
- JSC::JSValue num = callFrame->argument(0);
+ JSC::JSValue num = callFrame->argument(0);
- return Bun__Timer__clearTimeout(globalObject, JSC::JSValue::encode(num));
+ return Bun__Timer__clearTimeout(globalObject, JSC::JSValue::encode(num));
}
// This is not a publicly exposed API currently.
// This is used by the bundler to make Response, Request, FetchEvent,
// and any other objects available globally.
-void GlobalObject::installAPIGlobals(JSClassRef *globals, int count) {
- WTF::Vector<GlobalPropertyInfo> extraStaticGlobals;
- extraStaticGlobals.reserveCapacity((size_t)count + 3 + 4);
+void GlobalObject::installAPIGlobals(JSClassRef* globals, int count)
+{
+ WTF::Vector<GlobalPropertyInfo> extraStaticGlobals;
+ extraStaticGlobals.reserveCapacity((size_t)count + 3 + 4);
+
+ int i = 0;
+ for (; i < count - 1; i++) {
+ auto jsClass = globals[i];
+
+ JSC::JSCallbackObject<JSNonFinalObject>* object = JSC::JSCallbackObject<JSNonFinalObject>::create(this, this->callbackObjectStructure(),
+ jsClass, nullptr);
+ if (JSObject* prototype = jsClass->prototype(this))
+ object->setPrototypeDirect(vm(), prototype);
+
+ extraStaticGlobals.uncheckedAppend(
+ GlobalPropertyInfo { JSC::Identifier::fromString(vm(), jsClass->className()),
+ JSC::JSValue(object), JSC::PropertyAttribute::DontDelete | 0 });
+ }
+
+ // The last one must be "process.env"
+ // Runtime-support is for if they change
+ dot_env_class_ref = globals[i];
- int i = 0;
- for (; i < count - 1; i++) {
- auto jsClass = globals[i];
+ // // The last one must be "process.env"
+ // // Runtime-support is for if they change
+ // {
+ // auto jsClass = globals[i];
- JSC::JSCallbackObject<JSNonFinalObject> *object =
- JSC::JSCallbackObject<JSNonFinalObject>::create(this, this->callbackObjectStructure(),
- jsClass, nullptr);
- if (JSObject *prototype = jsClass->prototype(this)) object->setPrototypeDirect(vm(), prototype);
+ // JSC::JSCallbackObject<JSNonFinalObject> *object =
+ // JSC::JSCallbackObject<JSNonFinalObject>::create(this, this->callbackObjectStructure(),
+ // jsClass, nullptr);
+ // if (JSObject *prototype = jsClass->prototype(this)) object->setPrototypeDirect(vm(),
+ // prototype);
+
+ // process->putDirect(this->vm(), JSC::Identifier::fromString(this->vm(), "env"),
+ // JSC::JSValue(object), JSC::PropertyAttribute::DontDelete | 0);
+ // }
+ JSC::Identifier queueMicrotaskIdentifier = JSC::Identifier::fromString(vm(), "queueMicrotask"_s);
extraStaticGlobals.uncheckedAppend(
- GlobalPropertyInfo{JSC::Identifier::fromString(vm(), jsClass->className()),
- JSC::JSValue(object), JSC::PropertyAttribute::DontDelete | 0});
- }
-
- // The last one must be "process.env"
- // Runtime-support is for if they change
- dot_env_class_ref = globals[i];
-
- // // The last one must be "process.env"
- // // Runtime-support is for if they change
- // {
- // auto jsClass = globals[i];
-
- // JSC::JSCallbackObject<JSNonFinalObject> *object =
- // JSC::JSCallbackObject<JSNonFinalObject>::create(this, this->callbackObjectStructure(),
- // jsClass, nullptr);
- // if (JSObject *prototype = jsClass->prototype(this)) object->setPrototypeDirect(vm(),
- // prototype);
-
- // process->putDirect(this->vm(), JSC::Identifier::fromString(this->vm(), "env"),
- // JSC::JSValue(object), JSC::PropertyAttribute::DontDelete | 0);
- // }
-
- JSC::Identifier queueMicrotaskIdentifier = JSC::Identifier::fromString(vm(), "queueMicrotask"_s);
- extraStaticGlobals.uncheckedAppend(
- GlobalPropertyInfo{queueMicrotaskIdentifier,
- JSC::JSFunction::create(vm(), JSC::jsCast<JSC::JSGlobalObject *>(this), 0,
- "queueMicrotask", functionQueueMicrotask),
- JSC::PropertyAttribute::DontDelete | 0});
-
- JSC::Identifier setTimeoutIdentifier = JSC::Identifier::fromString(vm(), "setTimeout"_s);
- extraStaticGlobals.uncheckedAppend(
- GlobalPropertyInfo{setTimeoutIdentifier,
- JSC::JSFunction::create(vm(), JSC::jsCast<JSC::JSGlobalObject *>(this), 0,
- "setTimeout", functionQueueMicrotask),
- JSC::PropertyAttribute::DontDelete | 0});
-
- JSC::Identifier clearTimeoutIdentifier = JSC::Identifier::fromString(vm(), "clearTimeout"_s);
- extraStaticGlobals.uncheckedAppend(
- GlobalPropertyInfo{clearTimeoutIdentifier,
- JSC::JSFunction::create(vm(), JSC::jsCast<JSC::JSGlobalObject *>(this), 0,
- "clearTimeout", functionQueueMicrotask),
- JSC::PropertyAttribute::DontDelete | 0});
-
- JSC::Identifier setIntervalIdentifier = JSC::Identifier::fromString(vm(), "setInterval"_s);
- extraStaticGlobals.uncheckedAppend(
- GlobalPropertyInfo{setIntervalIdentifier,
- JSC::JSFunction::create(vm(), JSC::jsCast<JSC::JSGlobalObject *>(this), 0,
- "setInterval", functionQueueMicrotask),
- JSC::PropertyAttribute::DontDelete | 0});
-
- JSC::Identifier clearIntervalIdentifier = JSC::Identifier::fromString(vm(), "clearInterval"_s);
- extraStaticGlobals.uncheckedAppend(
- GlobalPropertyInfo{clearIntervalIdentifier,
- JSC::JSFunction::create(vm(), JSC::jsCast<JSC::JSGlobalObject *>(this), 0,
- "clearInterval", functionQueueMicrotask),
- JSC::PropertyAttribute::DontDelete | 0});
-
- auto clientData = Bun::clientData(vm());
-
- this->addStaticGlobals(extraStaticGlobals.data(), extraStaticGlobals.size());
- putDirectCustomAccessor(
- vm(), clientData->builtinNames().processPublicName(),
- JSC::CustomGetterSetter::create(vm(), property_lazyProcessGetter, property_lazyProcessSetter),
- JSC::PropertyAttribute::CustomValue | 0);
-
- extraStaticGlobals.releaseBuffer();
-}
+ GlobalPropertyInfo { queueMicrotaskIdentifier,
+ JSC::JSFunction::create(vm(), JSC::jsCast<JSC::JSGlobalObject*>(this), 0,
+ "queueMicrotask", functionQueueMicrotask),
+ JSC::PropertyAttribute::DontDelete | 0 });
+
+ JSC::Identifier setTimeoutIdentifier = JSC::Identifier::fromString(vm(), "setTimeout"_s);
+ extraStaticGlobals.uncheckedAppend(
+ GlobalPropertyInfo { setTimeoutIdentifier,
+ JSC::JSFunction::create(vm(), JSC::jsCast<JSC::JSGlobalObject*>(this), 0,
+ "setTimeout", functionQueueMicrotask),
+ JSC::PropertyAttribute::DontDelete | 0 });
-JSC::Identifier GlobalObject::moduleLoaderResolve(JSGlobalObject *globalObject,
- JSModuleLoader *loader, JSValue key,
- JSValue referrer, JSValue origin) {
- ErrorableZigString res;
- res.success = false;
- ZigString keyZ = toZigString(key, globalObject);
- ZigString referrerZ = referrer.isString() ? toZigString(referrer, globalObject) : ZigStringEmpty;
- Zig__GlobalObject__resolve(&res, globalObject, &keyZ, &referrerZ);
-
- if (res.success) {
- return toIdentifier(res.result.value, globalObject);
- } else {
- auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
- throwException(scope, res.result.err, globalObject);
- return globalObject->vm().propertyNames->emptyIdentifier;
- }
+ JSC::Identifier clearTimeoutIdentifier = JSC::Identifier::fromString(vm(), "clearTimeout"_s);
+ extraStaticGlobals.uncheckedAppend(
+ GlobalPropertyInfo { clearTimeoutIdentifier,
+ JSC::JSFunction::create(vm(), JSC::jsCast<JSC::JSGlobalObject*>(this), 0,
+ "clearTimeout", functionQueueMicrotask),
+ JSC::PropertyAttribute::DontDelete | 0 });
+
+ JSC::Identifier setIntervalIdentifier = JSC::Identifier::fromString(vm(), "setInterval"_s);
+ extraStaticGlobals.uncheckedAppend(
+ GlobalPropertyInfo { setIntervalIdentifier,
+ JSC::JSFunction::create(vm(), JSC::jsCast<JSC::JSGlobalObject*>(this), 0,
+ "setInterval", functionQueueMicrotask),
+ JSC::PropertyAttribute::DontDelete | 0 });
+
+ JSC::Identifier clearIntervalIdentifier = JSC::Identifier::fromString(vm(), "clearInterval"_s);
+ extraStaticGlobals.uncheckedAppend(
+ GlobalPropertyInfo { clearIntervalIdentifier,
+ JSC::JSFunction::create(vm(), JSC::jsCast<JSC::JSGlobalObject*>(this), 0,
+ "clearInterval", functionQueueMicrotask),
+ JSC::PropertyAttribute::DontDelete | 0 });
+
+ auto clientData = Bun::clientData(vm());
+
+ this->addStaticGlobals(extraStaticGlobals.data(), extraStaticGlobals.size());
+ putDirectCustomAccessor(
+ vm(), clientData->builtinNames().processPublicName(),
+ JSC::CustomGetterSetter::create(vm(), property_lazyProcessGetter, property_lazyProcessSetter),
+ JSC::PropertyAttribute::CustomValue | 0);
+
+ extraStaticGlobals.releaseBuffer();
}
-JSC::JSInternalPromise *GlobalObject::moduleLoaderImportModule(JSGlobalObject *globalObject,
- JSModuleLoader *,
- JSString *moduleNameValue,
- JSValue parameters,
- const SourceOrigin &sourceOrigin) {
- JSC::VM &vm = globalObject->vm();
- auto scope = DECLARE_THROW_SCOPE(vm);
-
- auto *promise = JSC::JSInternalPromise::create(vm, globalObject->internalPromiseStructure());
- RETURN_IF_EXCEPTION(scope, promise->rejectWithCaughtException(globalObject, scope));
-
- auto sourceURL = sourceOrigin.url();
- ErrorableZigString resolved;
- auto moduleNameZ = toZigString(moduleNameValue, globalObject);
- auto sourceOriginZ = sourceURL.isEmpty() ? ZigStringCwd : toZigString(sourceURL.fileSystemPath());
- resolved.success = false;
- Zig__GlobalObject__resolve(&resolved, globalObject, &moduleNameZ, &sourceOriginZ);
- if (!resolved.success) {
- throwException(scope, resolved.result.err, globalObject);
- return promise->rejectWithCaughtException(globalObject, scope);
- }
-
- auto result = JSC::importModule(globalObject, toIdentifier(resolved.result.value, globalObject),
- parameters, JSC::jsUndefined());
- RETURN_IF_EXCEPTION(scope, promise->rejectWithCaughtException(globalObject, scope));
-
- return result;
+JSC::Identifier GlobalObject::moduleLoaderResolve(JSGlobalObject* globalObject,
+ JSModuleLoader* loader, JSValue key,
+ JSValue referrer, JSValue origin)
+{
+ ErrorableZigString res;
+ res.success = false;
+ ZigString keyZ = toZigString(key, globalObject);
+ ZigString referrerZ = referrer.isString() ? toZigString(referrer, globalObject) : ZigStringEmpty;
+ Zig__GlobalObject__resolve(&res, globalObject, &keyZ, &referrerZ);
+
+ if (res.success) {
+ return toIdentifier(res.result.value, globalObject);
+ } else {
+ auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
+ throwException(scope, res.result.err, globalObject);
+ return globalObject->vm().propertyNames->emptyIdentifier;
+ }
}
-JSC::JSInternalPromise *GlobalObject::moduleLoaderFetch(JSGlobalObject *globalObject,
- JSModuleLoader *loader, JSValue key,
- JSValue value1, JSValue value2) {
- JSC::VM &vm = globalObject->vm();
- JSC::JSInternalPromise *promise =
- JSC::JSInternalPromise::create(vm, globalObject->internalPromiseStructure());
+JSC::JSInternalPromise* GlobalObject::moduleLoaderImportModule(JSGlobalObject* globalObject,
+ JSModuleLoader*,
+ JSString* moduleNameValue,
+ JSValue parameters,
+ const SourceOrigin& sourceOrigin)
+{
+ JSC::VM& vm = globalObject->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
- auto scope = DECLARE_THROW_SCOPE(vm);
+ auto* promise = JSC::JSInternalPromise::create(vm, globalObject->internalPromiseStructure());
+ RETURN_IF_EXCEPTION(scope, promise->rejectWithCaughtException(globalObject, scope));
- auto rejectWithError = [&](JSC::JSValue error) {
- promise->reject(globalObject, error);
- return promise;
- };
+ auto sourceURL = sourceOrigin.url();
+ ErrorableZigString resolved;
+ auto moduleNameZ = toZigString(moduleNameValue, globalObject);
+ auto sourceOriginZ = sourceURL.isEmpty() ? ZigStringCwd : toZigString(sourceURL.fileSystemPath());
+ resolved.success = false;
+ Zig__GlobalObject__resolve(&resolved, globalObject, &moduleNameZ, &sourceOriginZ);
+ if (!resolved.success) {
+ throwException(scope, resolved.result.err, globalObject);
+ return promise->rejectWithCaughtException(globalObject, scope);
+ }
- auto moduleKey = key.toWTFString(globalObject);
- RETURN_IF_EXCEPTION(scope, promise->rejectWithCaughtException(globalObject, scope));
- auto moduleKeyZig = toZigString(moduleKey);
- auto source = Zig::toZigString(value1, globalObject);
- ErrorableResolvedSource res;
- res.success = false;
- res.result.err.code = 0;
- res.result.err.ptr = nullptr;
+ auto result = JSC::importModule(globalObject, toIdentifier(resolved.result.value, globalObject),
+ parameters, JSC::jsUndefined());
+ RETURN_IF_EXCEPTION(scope, promise->rejectWithCaughtException(globalObject, scope));
+
+ return result;
+}
- Zig__GlobalObject__fetch(&res, globalObject, &moduleKeyZig, &source);
+JSC::JSInternalPromise* GlobalObject::moduleLoaderFetch(JSGlobalObject* globalObject,
+ JSModuleLoader* loader, JSValue key,
+ JSValue value1, JSValue value2)
+{
+ JSC::VM& vm = globalObject->vm();
+ JSC::JSInternalPromise* promise = JSC::JSInternalPromise::create(vm, globalObject->internalPromiseStructure());
- if (!res.success) {
- throwException(scope, res.result.err, globalObject);
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ auto rejectWithError = [&](JSC::JSValue error) {
+ promise->reject(globalObject, error);
+ return promise;
+ };
+
+ auto moduleKey = key.toWTFString(globalObject);
RETURN_IF_EXCEPTION(scope, promise->rejectWithCaughtException(globalObject, scope));
- }
+ auto moduleKeyZig = toZigString(moduleKey);
+ auto source = Zig::toZigString(value1, globalObject);
+ ErrorableResolvedSource res;
+ res.success = false;
+ res.result.err.code = 0;
+ res.result.err.ptr = nullptr;
+
+ Zig__GlobalObject__fetch(&res, globalObject, &moduleKeyZig, &source);
+
+ if (!res.success) {
+ throwException(scope, res.result.err, globalObject);
+ RETURN_IF_EXCEPTION(scope, promise->rejectWithCaughtException(globalObject, scope));
+ }
- auto provider = Zig::SourceProvider::create(res.result.value);
+ auto provider = Zig::SourceProvider::create(res.result.value);
- auto jsSourceCode = JSC::JSSourceCode::create(vm, JSC::SourceCode(provider));
+ auto jsSourceCode = JSC::JSSourceCode::create(vm, JSC::SourceCode(provider));
- if (provider.ptr()->isBytecodeCacheEnabled()) {
- provider.ptr()->readOrGenerateByteCodeCache(vm, jsSourceCode->sourceCode());
- }
+ if (provider.ptr()->isBytecodeCacheEnabled()) {
+ provider.ptr()->readOrGenerateByteCodeCache(vm, jsSourceCode->sourceCode());
+ }
- scope.release();
+ scope.release();
- promise->resolve(globalObject, jsSourceCode);
- globalObject->vm().drainMicrotasks();
- return promise;
+ promise->resolve(globalObject, jsSourceCode);
+ globalObject->vm().drainMicrotasks();
+ return promise;
}
-JSC::JSObject *GlobalObject::moduleLoaderCreateImportMetaProperties(JSGlobalObject *globalObject,
- JSModuleLoader *loader,
- JSValue key,
- JSModuleRecord *record,
- JSValue val) {
-
- JSC::VM &vm = globalObject->vm();
- auto scope = DECLARE_THROW_SCOPE(vm);
-
- JSC::JSObject *metaProperties =
- JSC::constructEmptyObject(vm, globalObject->nullPrototypeObjectStructure());
- RETURN_IF_EXCEPTION(scope, nullptr);
-
- auto clientData = Bun::clientData(vm);
- JSString *keyString = key.toStringOrNull(globalObject);
- if (UNLIKELY(!keyString)) { return metaProperties; }
- auto view = keyString->value(globalObject);
- auto index = view.reverseFind('/', view.length());
- if (index != WTF::notFound) {
- metaProperties->putDirect(vm, clientData->builtinNames().dirPublicName(),
- JSC::jsSubstring(globalObject, keyString, 0, index));
- metaProperties->putDirect(
- vm, clientData->builtinNames().filePublicName(),
- JSC::jsSubstring(globalObject, keyString, index + 1, keyString->length() - index - 1));
- }
-
- metaProperties->putDirect(vm, clientData->builtinNames().pathPublicName(), key);
-
- RETURN_IF_EXCEPTION(scope, nullptr);
-
- // metaProperties->putDirect(vm, Identifier::fromString(vm, "resolve"),
- // globalObject->globalThis()
- // ->get(vm, Identifier::fromString("Bun"))
- // .getObject()
- // ->get(vm, Identifier::fromString("resolve"))); );
- // RETURN_IF_EXCEPTION(scope, nullptr);
-
- return metaProperties;
+JSC::JSObject* GlobalObject::moduleLoaderCreateImportMetaProperties(JSGlobalObject* globalObject,
+ JSModuleLoader* loader,
+ JSValue key,
+ JSModuleRecord* record,
+ JSValue val)
+{
+
+ JSC::VM& vm = globalObject->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ JSC::JSObject* metaProperties = JSC::constructEmptyObject(vm, globalObject->nullPrototypeObjectStructure());
+ RETURN_IF_EXCEPTION(scope, nullptr);
+
+ auto clientData = Bun::clientData(vm);
+ JSString* keyString = key.toStringOrNull(globalObject);
+ if (UNLIKELY(!keyString)) {
+ return metaProperties;
+ }
+ auto view = keyString->value(globalObject);
+ auto index = view.reverseFind('/', view.length());
+ if (index != WTF::notFound) {
+ metaProperties->putDirect(vm, clientData->builtinNames().dirPublicName(),
+ JSC::jsSubstring(globalObject, keyString, 0, index));
+ metaProperties->putDirect(
+ vm, clientData->builtinNames().filePublicName(),
+ JSC::jsSubstring(globalObject, keyString, index + 1, keyString->length() - index - 1));
+ }
+
+ metaProperties->putDirect(vm, clientData->builtinNames().pathPublicName(), key);
+
+ RETURN_IF_EXCEPTION(scope, nullptr);
+
+ // metaProperties->putDirect(vm, Identifier::fromString(vm, "resolve"),
+ // globalObject->globalThis()
+ // ->get(vm, Identifier::fromString("Bun"))
+ // .getObject()
+ // ->get(vm, Identifier::fromString("resolve"))); );
+ // RETURN_IF_EXCEPTION(scope, nullptr);
+
+ return metaProperties;
}
-JSC::JSValue GlobalObject::moduleLoaderEvaluate(JSGlobalObject *globalObject,
- JSModuleLoader *moduleLoader, JSValue key,
- JSValue moduleRecordValue, JSValue scriptFetcher,
- JSValue sentValue, JSValue resumeMode) {
+JSC::JSValue GlobalObject::moduleLoaderEvaluate(JSGlobalObject* globalObject,
+ JSModuleLoader* moduleLoader, JSValue key,
+ JSValue moduleRecordValue, JSValue scriptFetcher,
+ JSValue sentValue, JSValue resumeMode)
+{
- JSC::JSValue result = moduleLoader->evaluateNonVirtual(globalObject, key, moduleRecordValue,
- scriptFetcher, sentValue, resumeMode);
+ JSC::JSValue result = moduleLoader->evaluateNonVirtual(globalObject, key, moduleRecordValue,
+ scriptFetcher, sentValue, resumeMode);
- return result;
+ return result;
}
-void GlobalObject::queueMicrotaskToEventLoop(JSC::JSGlobalObject &global,
- Ref<JSC::Microtask> &&task) {
+void GlobalObject::queueMicrotaskToEventLoop(JSC::JSGlobalObject& global,
+ Ref<JSC::Microtask>&& task)
+{
- Zig__GlobalObject__queueMicrotaskToEventLoop(
- &global, &JSMicrotaskCallback::create(global, WTFMove(task)).leakRef());
+ Zig__GlobalObject__queueMicrotaskToEventLoop(
+ &global, &JSMicrotaskCallback::create(global, WTFMove(task)).leakRef());
}
} // namespace Zig \ No newline at end of file
diff --git a/src/javascript/jsc/bindings/ZigGlobalObject.h b/src/javascript/jsc/bindings/ZigGlobalObject.h
index 48f5a1a02..edc250ecb 100644
--- a/src/javascript/jsc/bindings/ZigGlobalObject.h
+++ b/src/javascript/jsc/bindings/ZigGlobalObject.h
@@ -19,77 +19,87 @@ class Identifier;
namespace Zig {
class GlobalObject : public JSC::JSGlobalObject {
- using Base = JSC::JSGlobalObject;
-
- public:
- DECLARE_EXPORT_INFO;
- static const JSC::GlobalObjectMethodTable s_globalObjectMethodTable;
- Zig::Process *m_process;
- static constexpr bool needsDestruction = true;
- template <typename CellType, JSC::SubspaceAccess mode>
- static GCClient::IsoSubspace *subspaceFor(VM &vm) {
- return vm.globalObjectSpace<mode>();
- }
-
- static GlobalObject *create(JSC::VM &vm, JSC::Structure *structure) {
- auto *object = new (NotNull, JSC::allocateCell<GlobalObject>(vm)) GlobalObject(vm, structure);
- object->finishCreation(vm);
- return object;
- }
-
- static JSC::Structure *createStructure(JSC::VM &vm, JSC::JSValue prototype) {
- auto *result = JSC::Structure::create(
- vm, nullptr, prototype, JSC::TypeInfo(JSC::GlobalObjectType, Base::StructureFlags), info());
- result->setTransitionWatchpointIsLikelyToBeFired(true);
- return result;
- }
-
- static void reportUncaughtExceptionAtEventLoop(JSGlobalObject *, JSC::Exception *);
-
- static void queueMicrotaskToEventLoop(JSC::JSGlobalObject &global, Ref<JSC::Microtask> &&task);
- static JSC::JSInternalPromise *moduleLoaderImportModule(JSGlobalObject *, JSC::JSModuleLoader *,
- JSC::JSString *moduleNameValue,
- JSC::JSValue parameters,
- const JSC::SourceOrigin &);
- static JSC::Identifier moduleLoaderResolve(JSGlobalObject *, JSC::JSModuleLoader *,
- JSC::JSValue keyValue, JSC::JSValue referrerValue,
- JSC::JSValue);
- static JSC::JSInternalPromise *moduleLoaderFetch(JSGlobalObject *, JSC::JSModuleLoader *,
- JSC::JSValue, JSC::JSValue, JSC::JSValue);
- static JSC::JSObject *moduleLoaderCreateImportMetaProperties(JSGlobalObject *,
- JSC::JSModuleLoader *, JSC::JSValue,
- JSC::JSModuleRecord *, JSC::JSValue);
- static JSC::JSValue moduleLoaderEvaluate(JSGlobalObject *, JSC::JSModuleLoader *, JSC::JSValue,
- JSC::JSValue, JSC::JSValue, JSC::JSValue, JSC::JSValue);
- static void promiseRejectionTracker(JSGlobalObject *, JSC::JSPromise *,
- JSC::JSPromiseRejectionOperation);
- void setConsole(void *console);
- void installAPIGlobals(JSClassRef *globals, int count);
-
- private:
- GlobalObject(JSC::VM &vm, JSC::Structure *structure)
- : JSC::JSGlobalObject(vm, structure, &s_globalObjectMethodTable) {}
+ using Base = JSC::JSGlobalObject;
+
+public:
+ DECLARE_EXPORT_INFO;
+ static const JSC::GlobalObjectMethodTable s_globalObjectMethodTable;
+ Zig::Process* m_process;
+ static constexpr bool needsDestruction = true;
+ template<typename CellType, JSC::SubspaceAccess mode>
+ static GCClient::IsoSubspace* subspaceFor(VM& vm)
+ {
+ return vm.globalObjectSpace<mode>();
+ }
+
+ static GlobalObject* create(JSC::VM& vm, JSC::Structure* structure)
+ {
+ auto* object = new (NotNull, JSC::allocateCell<GlobalObject>(vm)) GlobalObject(vm, structure);
+ object->finishCreation(vm);
+ return object;
+ }
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSValue prototype)
+ {
+ auto* result = JSC::Structure::create(
+ vm, nullptr, prototype, JSC::TypeInfo(JSC::GlobalObjectType, Base::StructureFlags), info());
+ result->setTransitionWatchpointIsLikelyToBeFired(true);
+ return result;
+ }
+
+ static void reportUncaughtExceptionAtEventLoop(JSGlobalObject*, JSC::Exception*);
+
+ static void queueMicrotaskToEventLoop(JSC::JSGlobalObject& global, Ref<JSC::Microtask>&& task);
+ static JSC::JSInternalPromise* moduleLoaderImportModule(JSGlobalObject*, JSC::JSModuleLoader*,
+ JSC::JSString* moduleNameValue,
+ JSC::JSValue parameters,
+ const JSC::SourceOrigin&);
+ static JSC::Identifier moduleLoaderResolve(JSGlobalObject*, JSC::JSModuleLoader*,
+ JSC::JSValue keyValue, JSC::JSValue referrerValue,
+ JSC::JSValue);
+ static JSC::JSInternalPromise* moduleLoaderFetch(JSGlobalObject*, JSC::JSModuleLoader*,
+ JSC::JSValue, JSC::JSValue, JSC::JSValue);
+ static JSC::JSObject* moduleLoaderCreateImportMetaProperties(JSGlobalObject*,
+ JSC::JSModuleLoader*, JSC::JSValue,
+ JSC::JSModuleRecord*, JSC::JSValue);
+ static JSC::JSValue moduleLoaderEvaluate(JSGlobalObject*, JSC::JSModuleLoader*, JSC::JSValue,
+ JSC::JSValue, JSC::JSValue, JSC::JSValue, JSC::JSValue);
+ static void promiseRejectionTracker(JSGlobalObject*, JSC::JSPromise*,
+ JSC::JSPromiseRejectionOperation);
+ void setConsole(void* console);
+ void installAPIGlobals(JSClassRef* globals, int count);
+
+private:
+ GlobalObject(JSC::VM& vm, JSC::Structure* structure)
+ : JSC::JSGlobalObject(vm, structure, &s_globalObjectMethodTable)
+ {
+ }
};
class JSMicrotaskCallback : public RefCounted<JSMicrotaskCallback> {
- public:
- static Ref<JSMicrotaskCallback> create(JSC::JSGlobalObject &globalObject,
- Ref<JSC::Microtask> &&task) {
- return adoptRef(*new JSMicrotaskCallback(globalObject, WTFMove(task).leakRef()));
- }
-
- void call() {
- JSC::VM &vm = m_globalObject->vm();
- auto task = &m_task.get();
- task->run(m_globalObject.get());
- }
-
- private:
- JSMicrotaskCallback(JSC::JSGlobalObject &globalObject, Ref<JSC::Microtask> &&task)
- : m_globalObject{globalObject.vm(), &globalObject}, m_task{WTFMove(task)} {}
-
- JSC::Strong<JSC::JSGlobalObject> m_globalObject;
- Ref<JSC::Microtask> m_task;
+public:
+ static Ref<JSMicrotaskCallback> create(JSC::JSGlobalObject& globalObject,
+ Ref<JSC::Microtask>&& task)
+ {
+ return adoptRef(*new JSMicrotaskCallback(globalObject, WTFMove(task).leakRef()));
+ }
+
+ void call()
+ {
+ JSC::VM& vm = m_globalObject->vm();
+ auto task = &m_task.get();
+ task->run(m_globalObject.get());
+ }
+
+private:
+ JSMicrotaskCallback(JSC::JSGlobalObject& globalObject, Ref<JSC::Microtask>&& task)
+ : m_globalObject { globalObject.vm(), &globalObject }
+ , m_task { WTFMove(task) }
+ {
+ }
+
+ JSC::Strong<JSC::JSGlobalObject> m_globalObject;
+ Ref<JSC::Microtask> m_task;
};
} // namespace Zig
diff --git a/src/javascript/jsc/bindings/ZigSourceProvider.cpp b/src/javascript/jsc/bindings/ZigSourceProvider.cpp
index 509732307..523adbee3 100644
--- a/src/javascript/jsc/bindings/ZigSourceProvider.cpp
+++ b/src/javascript/jsc/bindings/ZigSourceProvider.cpp
@@ -23,147 +23,168 @@ using SourceOrigin = JSC::SourceOrigin;
using String = WTF::String;
using SourceProviderSourceType = JSC::SourceProviderSourceType;
-Ref<SourceProvider> SourceProvider::create(ResolvedSource resolvedSource) {
- void *allocator = resolvedSource.allocator;
-
- WTF::StringImpl *stringImpl = nullptr;
- if (allocator) {
- Ref<WTF::ExternalStringImpl> stringImpl_ = WTF::ExternalStringImpl::create(
- resolvedSource.source_code.ptr, resolvedSource.source_code.len,
- [allocator](WTF::ExternalStringImpl *str, void *ptr, unsigned int len) {
- ZigString__free((const unsigned char *)ptr, len, allocator);
- });
- return adoptRef(*new SourceProvider(
- resolvedSource, reinterpret_cast<WTF::StringImpl *>(stringImpl_.ptr()),
- JSC::SourceOrigin(WTF::URL::fileURLWithFileSystemPath(toString(resolvedSource.source_url))),
- toStringNotConst(resolvedSource.source_url), TextPosition(),
- JSC::SourceProviderSourceType::Module));
-
- } else {
- Ref<WTF::ExternalStringImpl> stringImpl_ = WTF::ExternalStringImpl::createStatic(
- resolvedSource.source_code.ptr, resolvedSource.source_code.len);
- return adoptRef(*new SourceProvider(
- resolvedSource, reinterpret_cast<WTF::StringImpl *>(stringImpl_.ptr()),
- JSC::SourceOrigin(WTF::URL::fileURLWithFileSystemPath(toString(resolvedSource.source_url))),
- toStringNotConst(resolvedSource.source_url), TextPosition(),
- JSC::SourceProviderSourceType::Module));
- }
+Ref<SourceProvider> SourceProvider::create(ResolvedSource resolvedSource)
+{
+ void* allocator = resolvedSource.allocator;
+
+ WTF::StringImpl* stringImpl = nullptr;
+ if (allocator) {
+ Ref<WTF::ExternalStringImpl> stringImpl_ = WTF::ExternalStringImpl::create(
+ resolvedSource.source_code.ptr, resolvedSource.source_code.len,
+ [allocator](WTF::ExternalStringImpl* str, void* ptr, unsigned int len) {
+ ZigString__free((const unsigned char*)ptr, len, allocator);
+ });
+ return adoptRef(*new SourceProvider(
+ resolvedSource, reinterpret_cast<WTF::StringImpl*>(stringImpl_.ptr()),
+ JSC::SourceOrigin(WTF::URL::fileURLWithFileSystemPath(toString(resolvedSource.source_url))),
+ toStringNotConst(resolvedSource.source_url), TextPosition(),
+ JSC::SourceProviderSourceType::Module));
+
+ } else {
+ Ref<WTF::ExternalStringImpl> stringImpl_ = WTF::ExternalStringImpl::createStatic(
+ resolvedSource.source_code.ptr, resolvedSource.source_code.len);
+ return adoptRef(*new SourceProvider(
+ resolvedSource, reinterpret_cast<WTF::StringImpl*>(stringImpl_.ptr()),
+ JSC::SourceOrigin(WTF::URL::fileURLWithFileSystemPath(toString(resolvedSource.source_url))),
+ toStringNotConst(resolvedSource.source_url), TextPosition(),
+ JSC::SourceProviderSourceType::Module));
+ }
}
-unsigned SourceProvider::getHash() {
- if (m_hash) { return m_hash; }
+unsigned SourceProvider::getHash()
+{
+ if (m_hash) {
+ return m_hash;
+ }
- m_hash = WTF::StringHash::hash(m_source.get());
- return m_hash;
+ m_hash = WTF::StringHash::hash(m_source.get());
+ return m_hash;
}
-void SourceProvider::freeSourceCode() {
- if (did_free_source_code) { return; }
- did_free_source_code = true;
- if (m_resolvedSource.allocator != 0) { // // WTF::ExternalStringImpl::destroy(m_source.ptr());
- this->m_source = WTF::StringImpl::empty()->isolatedCopy();
- this->m_hash = 0;
- m_resolvedSource.allocator = 0;
- }
- // if (m_resolvedSource.allocator != 0) {
- // ZigString__free(m_resolvedSource.source_code.ptr, m_resolvedSource.source_code.len,
- // m_resolvedSource.allocator);
- // }
+void SourceProvider::freeSourceCode()
+{
+ if (did_free_source_code) {
+ return;
+ }
+ did_free_source_code = true;
+ if (m_resolvedSource.allocator != 0) { // // WTF::ExternalStringImpl::destroy(m_source.ptr());
+ this->m_source = WTF::StringImpl::empty()->isolatedCopy();
+ this->m_hash = 0;
+ m_resolvedSource.allocator = 0;
+ }
+ // if (m_resolvedSource.allocator != 0) {
+ // ZigString__free(m_resolvedSource.source_code.ptr, m_resolvedSource.source_code.len,
+ // m_resolvedSource.allocator);
+ // }
}
-void SourceProvider::updateCache(const UnlinkedFunctionExecutable *executable, const SourceCode &,
- CodeSpecializationKind kind,
- const UnlinkedFunctionCodeBlock *codeBlock) {
- if (!m_resolvedSource.bytecodecache_fd || !m_cachedBytecode) return;
-
- JSC::BytecodeCacheError error;
- RefPtr<JSC::CachedBytecode> cachedBytecode =
- JSC::encodeFunctionCodeBlock(executable->vm(), codeBlock, error);
- if (cachedBytecode && !error.isValid())
- m_cachedBytecode->addFunctionUpdate(executable, kind, *cachedBytecode);
+void SourceProvider::updateCache(const UnlinkedFunctionExecutable* executable, const SourceCode&,
+ CodeSpecializationKind kind,
+ const UnlinkedFunctionCodeBlock* codeBlock)
+{
+ if (!m_resolvedSource.bytecodecache_fd || !m_cachedBytecode)
+ return;
+
+ JSC::BytecodeCacheError error;
+ RefPtr<JSC::CachedBytecode> cachedBytecode = JSC::encodeFunctionCodeBlock(executable->vm(), codeBlock, error);
+ if (cachedBytecode && !error.isValid())
+ m_cachedBytecode->addFunctionUpdate(executable, kind, *cachedBytecode);
}
-void SourceProvider::cacheBytecode(const BytecodeCacheGenerator &generator) {
- if (!m_resolvedSource.bytecodecache_fd) return;
+void SourceProvider::cacheBytecode(const BytecodeCacheGenerator& generator)
+{
+ if (!m_resolvedSource.bytecodecache_fd)
+ return;
- if (!m_cachedBytecode) m_cachedBytecode = JSC::CachedBytecode::create();
- auto update = generator();
- if (update) m_cachedBytecode->addGlobalUpdate(*update);
+ if (!m_cachedBytecode)
+ m_cachedBytecode = JSC::CachedBytecode::create();
+ auto update = generator();
+ if (update)
+ m_cachedBytecode->addGlobalUpdate(*update);
}
-void SourceProvider::commitCachedBytecode() {
- if (!m_resolvedSource.bytecodecache_fd || !m_cachedBytecode || !m_cachedBytecode->hasUpdates())
- return;
-
- auto clearBytecode = WTF::makeScopeExit([&] { m_cachedBytecode = nullptr; });
- const auto fd = m_resolvedSource.bytecodecache_fd;
-
- auto fileSize = FileSystem::fileSize(fd);
- if (!fileSize) return;
-
- size_t cacheFileSize;
- if (!WTF::convertSafely(*fileSize, cacheFileSize) || cacheFileSize != m_cachedBytecode->size()) {
- // The bytecode cache has already been updated
- return;
- }
-
- if (!FileSystem::truncateFile(fd, m_cachedBytecode->sizeForUpdate())) return;
-
- m_cachedBytecode->commitUpdates([&](off_t offset, const void *data, size_t size) {
- long long result = FileSystem::seekFile(fd, offset, FileSystem::FileSeekOrigin::Beginning);
- ASSERT_UNUSED(result, result != -1);
- size_t bytesWritten = static_cast<size_t>(FileSystem::writeToFile(fd, data, size));
- ASSERT_UNUSED(bytesWritten, bytesWritten == size);
- });
+void SourceProvider::commitCachedBytecode()
+{
+ if (!m_resolvedSource.bytecodecache_fd || !m_cachedBytecode || !m_cachedBytecode->hasUpdates())
+ return;
+
+ auto clearBytecode = WTF::makeScopeExit([&] { m_cachedBytecode = nullptr; });
+ const auto fd = m_resolvedSource.bytecodecache_fd;
+
+ auto fileSize = FileSystem::fileSize(fd);
+ if (!fileSize)
+ return;
+
+ size_t cacheFileSize;
+ if (!WTF::convertSafely(*fileSize, cacheFileSize) || cacheFileSize != m_cachedBytecode->size()) {
+ // The bytecode cache has already been updated
+ return;
+ }
+
+ if (!FileSystem::truncateFile(fd, m_cachedBytecode->sizeForUpdate()))
+ return;
+
+ m_cachedBytecode->commitUpdates([&](off_t offset, const void* data, size_t size) {
+ long long result = FileSystem::seekFile(fd, offset, FileSystem::FileSeekOrigin::Beginning);
+ ASSERT_UNUSED(result, result != -1);
+ size_t bytesWritten = static_cast<size_t>(FileSystem::writeToFile(fd, data, size));
+ ASSERT_UNUSED(bytesWritten, bytesWritten == size);
+ });
}
-bool SourceProvider::isBytecodeCacheEnabled() const {
- return m_resolvedSource.bytecodecache_fd > 0;
+bool SourceProvider::isBytecodeCacheEnabled() const
+{
+ return m_resolvedSource.bytecodecache_fd > 0;
}
-void SourceProvider::readOrGenerateByteCodeCache(JSC::VM &vm, const JSC::SourceCode &sourceCode) {
- auto status = this->readCache(vm, sourceCode);
- switch (status) {
+void SourceProvider::readOrGenerateByteCodeCache(JSC::VM& vm, const JSC::SourceCode& sourceCode)
+{
+ auto status = this->readCache(vm, sourceCode);
+ switch (status) {
case -1: {
- m_resolvedSource.bytecodecache_fd = 0;
- break;
+ m_resolvedSource.bytecodecache_fd = 0;
+ break;
}
case 0: {
- JSC::BytecodeCacheError err;
- m_cachedBytecode =
- JSC::generateModuleBytecode(vm, sourceCode, m_resolvedSource.bytecodecache_fd, err);
+ JSC::BytecodeCacheError err;
+ m_cachedBytecode = JSC::generateModuleBytecode(vm, sourceCode, m_resolvedSource.bytecodecache_fd, err);
- if (err.isValid()) {
- m_resolvedSource.bytecodecache_fd = 0;
- m_cachedBytecode = JSC::CachedBytecode::create();
- }
+ if (err.isValid()) {
+ m_resolvedSource.bytecodecache_fd = 0;
+ m_cachedBytecode = JSC::CachedBytecode::create();
+ }
}
// TODO: read the bytecode into a JSC::SourceCode object here
case 1: {
}
- }
+ }
}
-int SourceProvider::readCache(JSC::VM &vm, const JSC::SourceCode &sourceCode) {
- if (m_resolvedSource.bytecodecache_fd == 0) return -1;
- if (!FileSystem::isHandleValid(m_resolvedSource.bytecodecache_fd)) return -1;
- const auto fd = m_resolvedSource.bytecodecache_fd;
-
- bool success;
- FileSystem::MappedFileData mappedFile(fd, FileSystem::MappedFileMode::Shared, success);
- if (!success) return -1;
-
- const uint8_t *fileData = reinterpret_cast<const uint8_t *>(mappedFile.data());
- unsigned fileTotalSize = mappedFile.size();
- if (fileTotalSize == 0) return 0;
-
- Ref<JSC::CachedBytecode> cachedBytecode = JSC::CachedBytecode::create(WTFMove(mappedFile));
- // auto key = JSC::sourceCodeKeyForSerializedModule(vm, sourceCode);
- // if (isCachedBytecodeStillValid(vm, cachedBytecode.copyRef(), key,
- // JSC::SourceCodeType::ModuleType)) {
- m_cachedBytecode = WTFMove(cachedBytecode);
- return 1;
- // } else {
- // FileSystem::truncateFile(fd, 0);
- // return 0;
- // }
+int SourceProvider::readCache(JSC::VM& vm, const JSC::SourceCode& sourceCode)
+{
+ if (m_resolvedSource.bytecodecache_fd == 0)
+ return -1;
+ if (!FileSystem::isHandleValid(m_resolvedSource.bytecodecache_fd))
+ return -1;
+ const auto fd = m_resolvedSource.bytecodecache_fd;
+
+ bool success;
+ FileSystem::MappedFileData mappedFile(fd, FileSystem::MappedFileMode::Shared, success);
+ if (!success)
+ return -1;
+
+ const uint8_t* fileData = reinterpret_cast<const uint8_t*>(mappedFile.data());
+ unsigned fileTotalSize = mappedFile.size();
+ if (fileTotalSize == 0)
+ return 0;
+
+ Ref<JSC::CachedBytecode> cachedBytecode = JSC::CachedBytecode::create(WTFMove(mappedFile));
+ // auto key = JSC::sourceCodeKeyForSerializedModule(vm, sourceCode);
+ // if (isCachedBytecodeStillValid(vm, cachedBytecode.copyRef(), key,
+ // JSC::SourceCodeType::ModuleType)) {
+ m_cachedBytecode = WTFMove(cachedBytecode);
+ return 1;
+ // } else {
+ // FileSystem::truncateFile(fd, 0);
+ // return 0;
+ // }
}
}; // namespace Zig \ No newline at end of file
diff --git a/src/javascript/jsc/bindings/ZigSourceProvider.h b/src/javascript/jsc/bindings/ZigSourceProvider.h
index 24ae82af8..3a1a73b8f 100644
--- a/src/javascript/jsc/bindings/ZigSourceProvider.h
+++ b/src/javascript/jsc/bindings/ZigSourceProvider.h
@@ -22,60 +22,66 @@ class SourceProvider;
namespace Zig {
class SourceProvider final : public JSC::SourceProvider {
- WTF_MAKE_FAST_ALLOCATED;
- using Base = JSC::SourceProvider;
- using BytecodeCacheGenerator = JSC::BytecodeCacheGenerator;
- using UnlinkedFunctionExecutable = JSC::UnlinkedFunctionExecutable;
- using CachedBytecode = JSC::CachedBytecode;
- using UnlinkedFunctionCodeBlock = JSC::UnlinkedFunctionCodeBlock;
- using SourceCode = JSC::SourceCode;
- using CodeSpecializationKind = JSC::CodeSpecializationKind;
- using SourceOrigin = JSC::SourceOrigin;
+ WTF_MAKE_FAST_ALLOCATED;
+ using Base = JSC::SourceProvider;
+ using BytecodeCacheGenerator = JSC::BytecodeCacheGenerator;
+ using UnlinkedFunctionExecutable = JSC::UnlinkedFunctionExecutable;
+ using CachedBytecode = JSC::CachedBytecode;
+ using UnlinkedFunctionCodeBlock = JSC::UnlinkedFunctionCodeBlock;
+ using SourceCode = JSC::SourceCode;
+ using CodeSpecializationKind = JSC::CodeSpecializationKind;
+ using SourceOrigin = JSC::SourceOrigin;
- public:
- static Ref<SourceProvider> create(ResolvedSource resolvedSource);
- ~SourceProvider() {
- freeSourceCode();
+public:
+ static Ref<SourceProvider> create(ResolvedSource resolvedSource);
+ ~SourceProvider()
+ {
+ freeSourceCode();
- commitCachedBytecode();
- }
+ commitCachedBytecode();
+ }
- unsigned hash() const { return m_hash; };
- StringView source() const { return StringView(m_source.get()); }
- RefPtr<JSC::CachedBytecode> cachedBytecode() {
- if (m_resolvedSource.bytecodecache_fd == 0) { return nullptr; }
+ unsigned hash() const { return m_hash; };
+ StringView source() const { return StringView(m_source.get()); }
+ RefPtr<JSC::CachedBytecode> cachedBytecode()
+ {
+ if (m_resolvedSource.bytecodecache_fd == 0) {
+ return nullptr;
+ }
- return m_cachedBytecode;
- };
+ return m_cachedBytecode;
+ };
- void updateCache(const UnlinkedFunctionExecutable *executable, const SourceCode &,
- CodeSpecializationKind kind, const UnlinkedFunctionCodeBlock *codeBlock);
- void cacheBytecode(const BytecodeCacheGenerator &generator);
- void commitCachedBytecode();
- bool isBytecodeCacheEnabled() const;
- void readOrGenerateByteCodeCache(JSC::VM &vm, const JSC::SourceCode &sourceCode);
- ResolvedSource m_resolvedSource;
- int readCache(JSC::VM &vm, const JSC::SourceCode &sourceCode);
- void freeSourceCode();
+ void updateCache(const UnlinkedFunctionExecutable* executable, const SourceCode&,
+ CodeSpecializationKind kind, const UnlinkedFunctionCodeBlock* codeBlock);
+ void cacheBytecode(const BytecodeCacheGenerator& generator);
+ void commitCachedBytecode();
+ bool isBytecodeCacheEnabled() const;
+ void readOrGenerateByteCodeCache(JSC::VM& vm, const JSC::SourceCode& sourceCode);
+ ResolvedSource m_resolvedSource;
+ int readCache(JSC::VM& vm, const JSC::SourceCode& sourceCode);
+ void freeSourceCode();
- private:
- SourceProvider(ResolvedSource resolvedSource, WTF::StringImpl *sourceImpl,
- const SourceOrigin &sourceOrigin, WTF::String &&sourceURL,
- const TextPosition &startPosition, JSC::SourceProviderSourceType sourceType)
- : Base(sourceOrigin, WTFMove(sourceURL), startPosition, sourceType), m_source(*sourceImpl) {
+private:
+ SourceProvider(ResolvedSource resolvedSource, WTF::StringImpl* sourceImpl,
+ const SourceOrigin& sourceOrigin, WTF::String&& sourceURL,
+ const TextPosition& startPosition, JSC::SourceProviderSourceType sourceType)
+ : Base(sourceOrigin, WTFMove(sourceURL), startPosition, sourceType)
+ , m_source(*sourceImpl)
+ {
- m_resolvedSource = resolvedSource;
+ m_resolvedSource = resolvedSource;
- m_hash = resolvedSource.hash;
- getHash();
- }
+ m_hash = resolvedSource.hash;
+ getHash();
+ }
- unsigned m_hash;
- unsigned getHash();
- RefPtr<JSC::CachedBytecode> m_cachedBytecode;
- Ref<WTF::StringImpl> m_source;
- bool did_free_source_code = false;
- // JSC::SourceCodeKey key;
+ unsigned m_hash;
+ unsigned getHash();
+ RefPtr<JSC::CachedBytecode> m_cachedBytecode;
+ Ref<WTF::StringImpl> m_source;
+ bool did_free_source_code = false;
+ // JSC::SourceCodeKey key;
};
} // namespace Zig \ No newline at end of file
diff --git a/src/javascript/jsc/bindings/bindings.cpp b/src/javascript/jsc/bindings/bindings.cpp
index ece7b448c..4a0b14737 100644
--- a/src/javascript/jsc/bindings/bindings.cpp
+++ b/src/javascript/jsc/bindings/bindings.cpp
@@ -45,322 +45,346 @@
extern "C" {
-JSC__JSValue SystemError__toErrorInstance(const SystemError *arg0,
- JSC__JSGlobalObject *globalObject) {
+JSC__JSValue SystemError__toErrorInstance(const SystemError* arg0,
+ JSC__JSGlobalObject* globalObject)
+{
- static const char *system_error_name = "SystemError";
- SystemError err = *arg0;
+ static const char* system_error_name = "SystemError";
+ SystemError err = *arg0;
- JSC::VM &vm = globalObject->vm();
+ JSC::VM& vm = globalObject->vm();
- auto scope = DECLARE_THROW_SCOPE(vm);
- JSC::JSValue message = JSC::jsUndefined();
- if (err.message.len > 0) { message = Zig::toJSString(err.message, globalObject); }
+ auto scope = DECLARE_THROW_SCOPE(vm);
+ JSC::JSValue message = JSC::jsUndefined();
+ if (err.message.len > 0) {
+ message = Zig::toJSString(err.message, globalObject);
+ }
- JSC::JSValue options = JSC::jsUndefined();
+ JSC::JSValue options = JSC::jsUndefined();
- JSC::Structure *errorStructure = globalObject->errorStructure();
- JSC::JSObject *result =
- JSC::ErrorInstance::create(globalObject, errorStructure, message, options);
+ JSC::Structure* errorStructure = globalObject->errorStructure();
+ JSC::JSObject* result = JSC::ErrorInstance::create(globalObject, errorStructure, message, options);
- auto clientData = Bun::clientData(vm);
+ auto clientData = Bun::clientData(vm);
- if (err.code.len > 0) {
- JSC::JSValue code = Zig::toJSString(err.code, globalObject);
- result->putDirect(vm, clientData->builtinNames().codePublicName(), code,
- JSC::PropertyAttribute::DontDelete | 0);
+ if (err.code.len > 0) {
+ JSC::JSValue code = Zig::toJSString(err.code, globalObject);
+ result->putDirect(vm, clientData->builtinNames().codePublicName(), code,
+ JSC::PropertyAttribute::DontDelete | 0);
- result->putDirect(vm, vm.propertyNames->name, code, JSC::PropertyAttribute::DontEnum | 0);
- } else {
+ result->putDirect(vm, vm.propertyNames->name, code, JSC::PropertyAttribute::DontEnum | 0);
+ } else {
- result->putDirect(
- vm, vm.propertyNames->name,
- JSC::JSValue(JSC::jsOwnedString(
- vm, WTF::String(WTF::StringImpl::createWithoutCopying(system_error_name, 11)))),
- JSC::PropertyAttribute::DontEnum | 0);
- }
+ result->putDirect(
+ vm, vm.propertyNames->name,
+ JSC::JSValue(JSC::jsOwnedString(
+ vm, WTF::String(WTF::StringImpl::createWithoutCopying(system_error_name, 11)))),
+ JSC::PropertyAttribute::DontEnum | 0);
+ }
- if (err.path.len > 0) {
- JSC::JSValue path = JSC::JSValue(Zig::toJSStringGC(err.path, globalObject));
- result->putDirect(vm, clientData->builtinNames().pathPublicName(), path,
- JSC::PropertyAttribute::DontDelete | 0);
- }
+ if (err.path.len > 0) {
+ JSC::JSValue path = JSC::JSValue(Zig::toJSStringGC(err.path, globalObject));
+ result->putDirect(vm, clientData->builtinNames().pathPublicName(), path,
+ JSC::PropertyAttribute::DontDelete | 0);
+ }
- if (err.syscall.len > 0) {
- JSC::JSValue syscall = JSC::JSValue(Zig::toJSString(err.syscall, globalObject));
- result->putDirect(vm, clientData->builtinNames().syscallPublicName(), syscall,
- JSC::PropertyAttribute::DontDelete | 0);
- }
+ if (err.syscall.len > 0) {
+ JSC::JSValue syscall = JSC::JSValue(Zig::toJSString(err.syscall, globalObject));
+ result->putDirect(vm, clientData->builtinNames().syscallPublicName(), syscall,
+ JSC::PropertyAttribute::DontDelete | 0);
+ }
- result->putDirect(vm, clientData->builtinNames().errnoPublicName(), JSC::JSValue(err.errno_),
- JSC::PropertyAttribute::DontDelete | 0);
+ result->putDirect(vm, clientData->builtinNames().errnoPublicName(), JSC::JSValue(err.errno_),
+ JSC::PropertyAttribute::DontDelete | 0);
- RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(JSC::JSValue()));
- scope.release();
+ RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(JSC::JSValue()));
+ scope.release();
- return JSC::JSValue::encode(JSC::JSValue(result));
+ return JSC::JSValue::encode(JSC::JSValue(result));
}
JSC__JSValue
-JSC__JSObject__create(JSC__JSGlobalObject *globalObject, size_t initialCapacity, void *arg2,
- void (*ArgFn3)(void *arg0, JSC__JSObject *arg1, JSC__JSGlobalObject *arg2)) {
- JSC::JSObject *object =
- JSC::constructEmptyObject(globalObject, globalObject->objectPrototype(), initialCapacity);
+JSC__JSObject__create(JSC__JSGlobalObject* globalObject, size_t initialCapacity, void* arg2,
+ void (*ArgFn3)(void* arg0, JSC__JSObject* arg1, JSC__JSGlobalObject* arg2))
+{
+ JSC::JSObject* object = JSC::constructEmptyObject(globalObject, globalObject->objectPrototype(), initialCapacity);
- ArgFn3(arg2, object, globalObject);
+ ArgFn3(arg2, object, globalObject);
- return JSC::JSValue::encode(object);
+ return JSC::JSValue::encode(object);
}
-JSC__JSValue JSC__JSValue__createEmptyObject(JSC__JSGlobalObject *globalObject,
- size_t initialCapacity) {
- return JSC::JSValue::encode(
- JSC::constructEmptyObject(globalObject, globalObject->objectPrototype(), initialCapacity));
+JSC__JSValue JSC__JSValue__createEmptyObject(JSC__JSGlobalObject* globalObject,
+ size_t initialCapacity)
+{
+ return JSC::JSValue::encode(
+ JSC::constructEmptyObject(globalObject, globalObject->objectPrototype(), initialCapacity));
}
-uint32_t JSC__JSValue__getLengthOfArray(JSC__JSValue value, JSC__JSGlobalObject *globalObject) {
- JSC::JSValue jsValue = JSC::JSValue::decode(value);
- JSC::JSObject *object = jsValue.toObject(globalObject);
- return JSC::toLength(globalObject, object);
+uint32_t JSC__JSValue__getLengthOfArray(JSC__JSValue value, JSC__JSGlobalObject* globalObject)
+{
+ JSC::JSValue jsValue = JSC::JSValue::decode(value);
+ JSC::JSObject* object = jsValue.toObject(globalObject);
+ return JSC::toLength(globalObject, object);
}
-void JSC__JSObject__putRecord(JSC__JSObject *object, JSC__JSGlobalObject *global, ZigString *key,
- ZigString *values, size_t valuesLen) {
- auto scope = DECLARE_THROW_SCOPE(global->vm());
- auto ident = Zig::toIdentifier(*key, global);
- JSC::PropertyDescriptor descriptor;
+void JSC__JSObject__putRecord(JSC__JSObject* object, JSC__JSGlobalObject* global, ZigString* key,
+ ZigString* values, size_t valuesLen)
+{
+ auto scope = DECLARE_THROW_SCOPE(global->vm());
+ auto ident = Zig::toIdentifier(*key, global);
+ JSC::PropertyDescriptor descriptor;
- descriptor.setEnumerable(1);
- descriptor.setConfigurable(1);
- descriptor.setWritable(1);
+ descriptor.setEnumerable(1);
+ descriptor.setConfigurable(1);
+ descriptor.setWritable(1);
- if (valuesLen == 1) {
- descriptor.setValue(JSC::jsString(global->vm(), Zig::toString(values[0])));
- } else {
+ if (valuesLen == 1) {
+ descriptor.setValue(JSC::jsString(global->vm(), Zig::toString(values[0])));
+ } else {
- JSC::JSArray *array = nullptr;
- {
- JSC::ObjectInitializationScope initializationScope(global->vm());
- if ((array = JSC::JSArray::tryCreateUninitializedRestricted(
- initializationScope, nullptr,
- global->arrayStructureForIndexingTypeDuringAllocation(JSC::ArrayWithContiguous),
- valuesLen))) {
-
- for (size_t i = 0; i < valuesLen; ++i) {
- array->initializeIndexWithoutBarrier(
- initializationScope, i, JSC::jsString(global->vm(), Zig::toString(values[i])));
+ JSC::JSArray* array = nullptr;
+ {
+ JSC::ObjectInitializationScope initializationScope(global->vm());
+ if ((array = JSC::JSArray::tryCreateUninitializedRestricted(
+ initializationScope, nullptr,
+ global->arrayStructureForIndexingTypeDuringAllocation(JSC::ArrayWithContiguous),
+ valuesLen))) {
+
+ for (size_t i = 0; i < valuesLen; ++i) {
+ array->initializeIndexWithoutBarrier(
+ initializationScope, i, JSC::jsString(global->vm(), Zig::toString(values[i])));
+ }
+ }
}
- }
- }
- if (!array) {
- JSC::throwOutOfMemoryError(global, scope);
- return;
- }
+ if (!array) {
+ JSC::throwOutOfMemoryError(global, scope);
+ return;
+ }
- descriptor.setValue(array);
- }
+ descriptor.setValue(array);
+ }
- object->methodTable(global->vm())->defineOwnProperty(object, global, ident, descriptor, true);
- object->putDirect(global->vm(), ident, descriptor.value());
- scope.release();
+ object->methodTable(global->vm())->defineOwnProperty(object, global, ident, descriptor, true);
+ object->putDirect(global->vm(), ident, descriptor.value());
+ scope.release();
}
-void JSC__JSValue__putRecord(JSC__JSValue objectValue, JSC__JSGlobalObject *global, ZigString *key,
- ZigString *values, size_t valuesLen) {
- JSC::JSValue objValue = JSC::JSValue::decode(objectValue);
- JSC::JSObject *object = objValue.asCell()->getObject();
- auto scope = DECLARE_THROW_SCOPE(global->vm());
- auto ident = Zig::toIdentifier(*key, global);
- JSC::PropertyDescriptor descriptor;
-
- descriptor.setEnumerable(1);
- descriptor.setConfigurable(1);
- descriptor.setWritable(1);
+void JSC__JSValue__putRecord(JSC__JSValue objectValue, JSC__JSGlobalObject* global, ZigString* key,
+ ZigString* values, size_t valuesLen)
+{
+ JSC::JSValue objValue = JSC::JSValue::decode(objectValue);
+ JSC::JSObject* object = objValue.asCell()->getObject();
+ auto scope = DECLARE_THROW_SCOPE(global->vm());
+ auto ident = Zig::toIdentifier(*key, global);
+ JSC::PropertyDescriptor descriptor;
+
+ descriptor.setEnumerable(1);
+ descriptor.setConfigurable(1);
+ descriptor.setWritable(1);
+
+ if (valuesLen == 1) {
+ descriptor.setValue(JSC::jsString(global->vm(), Zig::toString(values[0])));
+ } else {
- if (valuesLen == 1) {
- descriptor.setValue(JSC::jsString(global->vm(), Zig::toString(values[0])));
- } else {
+ JSC::JSArray* array = nullptr;
+ {
+ JSC::ObjectInitializationScope initializationScope(global->vm());
+ if ((array = JSC::JSArray::tryCreateUninitializedRestricted(
+ initializationScope, nullptr,
+ global->arrayStructureForIndexingTypeDuringAllocation(JSC::ArrayWithContiguous),
+ valuesLen))) {
+
+ for (size_t i = 0; i < valuesLen; ++i) {
+ array->initializeIndexWithoutBarrier(
+ initializationScope, i, JSC::jsString(global->vm(), Zig::toString(values[i])));
+ }
+ }
+ }
- JSC::JSArray *array = nullptr;
- {
- JSC::ObjectInitializationScope initializationScope(global->vm());
- if ((array = JSC::JSArray::tryCreateUninitializedRestricted(
- initializationScope, nullptr,
- global->arrayStructureForIndexingTypeDuringAllocation(JSC::ArrayWithContiguous),
- valuesLen))) {
-
- for (size_t i = 0; i < valuesLen; ++i) {
- array->initializeIndexWithoutBarrier(
- initializationScope, i, JSC::jsString(global->vm(), Zig::toString(values[i])));
+ if (!array) {
+ JSC::throwOutOfMemoryError(global, scope);
+ return;
}
- }
- }
- if (!array) {
- JSC::throwOutOfMemoryError(global, scope);
- return;
+ descriptor.setValue(array);
}
- descriptor.setValue(array);
- }
-
- object->methodTable(global->vm())->defineOwnProperty(object, global, ident, descriptor, true);
- object->putDirect(global->vm(), ident, descriptor.value());
- scope.release();
+ object->methodTable(global->vm())->defineOwnProperty(object, global, ident, descriptor, true);
+ object->putDirect(global->vm(), ident, descriptor.value());
+ scope.release();
}
-JSC__JSInternalPromise *JSC__JSValue__asInternalPromise(JSC__JSValue JSValue0) {
- JSC::JSValue value = JSC::JSValue::decode(JSValue0);
- return JSC::jsCast<JSC::JSInternalPromise *>(value);
+JSC__JSInternalPromise* JSC__JSValue__asInternalPromise(JSC__JSValue JSValue0)
+{
+ JSC::JSValue value = JSC::JSValue::decode(JSValue0);
+ return JSC::jsCast<JSC::JSInternalPromise*>(value);
}
-JSC__JSValue JSC__JSValue__createInternalPromise(JSC__JSGlobalObject *globalObject) {
- JSC::VM &vm = globalObject->vm();
- return JSC::JSValue::encode(
- JSC::JSValue(JSC::JSInternalPromise::create(vm, globalObject->internalPromiseStructure())));
+JSC__JSValue JSC__JSValue__createInternalPromise(JSC__JSGlobalObject* globalObject)
+{
+ JSC::VM& vm = globalObject->vm();
+ return JSC::JSValue::encode(
+ JSC::JSValue(JSC::JSInternalPromise::create(vm, globalObject->internalPromiseStructure())));
}
-void JSC__JSValue__jsonStringify(JSC__JSValue JSValue0, JSC__JSGlobalObject *arg1, uint32_t arg2,
- ZigString *arg3) {
- JSC::JSValue value = JSC::JSValue::decode(JSValue0);
- WTF::String str = JSC::JSONStringify(arg1, value, (unsigned)arg2);
- *arg3 = Zig::toZigString(str);
+void JSC__JSValue__jsonStringify(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, uint32_t arg2,
+ ZigString* arg3)
+{
+ JSC::JSValue value = JSC::JSValue::decode(JSValue0);
+ WTF::String str = JSC::JSONStringify(arg1, value, (unsigned)arg2);
+ *arg3 = Zig::toZigString(str);
}
-unsigned char JSC__JSValue__jsType(JSC__JSValue JSValue0) {
- JSC::JSValue jsValue = JSC::JSValue::decode(JSValue0);
- if (!jsValue.isCell()) return 0;
+unsigned char JSC__JSValue__jsType(JSC__JSValue JSValue0)
+{
+ JSC::JSValue jsValue = JSC::JSValue::decode(JSValue0);
+ if (!jsValue.isCell())
+ return 0;
- return jsValue.asCell()->type();
+ return jsValue.asCell()->type();
}
-void JSC__JSGlobalObject__deleteModuleRegistryEntry(JSC__JSGlobalObject *global, ZigString *arg1) {
- JSC::JSMap *map = JSC::jsDynamicCast<JSC::JSMap *>(
- global->vm(), global->moduleLoader()->getDirect(
- global->vm(), JSC::Identifier::fromString(global->vm(), "registry")));
- if (!map) return;
- const JSC::Identifier identifier = Zig::toIdentifier(*arg1, global);
- JSC::JSValue val = JSC::identifierToJSValue(global->vm(), identifier);
+void JSC__JSGlobalObject__deleteModuleRegistryEntry(JSC__JSGlobalObject* global, ZigString* arg1)
+{
+ JSC::JSMap* map = JSC::jsDynamicCast<JSC::JSMap*>(
+ global->vm(), global->moduleLoader()->getDirect(global->vm(), JSC::Identifier::fromString(global->vm(), "registry")));
+ if (!map)
+ return;
+ const JSC::Identifier identifier = Zig::toIdentifier(*arg1, global);
+ JSC::JSValue val = JSC::identifierToJSValue(global->vm(), identifier);
- map->remove(global, val);
+ map->remove(global, val);
}
// This is very naive!
-JSC__JSInternalPromise *JSC__VM__reloadModule(JSC__VM *vm, JSC__JSGlobalObject *arg1,
- ZigString arg2) {
- return nullptr;
- // JSC::JSMap *map = JSC::jsDynamicCast<JSC::JSMap *>(
- // arg1->vm(), arg1->moduleLoader()->getDirect(
- // arg1->vm(), JSC::Identifier::fromString(arg1->vm(), "registry")));
-
- // const JSC::Identifier identifier = Zig::toIdentifier(arg2, arg1);
- // JSC::JSValue val = JSC::identifierToJSValue(arg1->vm(), identifier);
-
- // if (!map->has(arg1, val)) return nullptr;
-
- // if (JSC::JSObject *registryEntry =
- // JSC::jsDynamicCast<JSC::JSObject *>(arg1->vm(), map->get(arg1, val))) {
- // auto moduleIdent = JSC::Identifier::fromString(arg1->vm(), "module");
- // if (JSC::JSModuleRecord *record = JSC::jsDynamicCast<JSC::JSModuleRecord *>(
- // arg1->vm(), registryEntry->getDirect(arg1->vm(), moduleIdent))) {
- // registryEntry->putDirect(arg1->vm(), moduleIdent, JSC::jsUndefined());
- // JSC::JSModuleRecord::destroy(static_cast<JSC::JSCell *>(record));
- // }
- // map->remove(arg1, val);
- // return JSC__JSModuleLoader__loadAndEvaluateModule(arg1, arg2);
- // }
-
- // return nullptr;
+JSC__JSInternalPromise* JSC__VM__reloadModule(JSC__VM* vm, JSC__JSGlobalObject* arg1,
+ ZigString arg2)
+{
+ return nullptr;
+ // JSC::JSMap *map = JSC::jsDynamicCast<JSC::JSMap *>(
+ // arg1->vm(), arg1->moduleLoader()->getDirect(
+ // arg1->vm(), JSC::Identifier::fromString(arg1->vm(), "registry")));
+
+ // const JSC::Identifier identifier = Zig::toIdentifier(arg2, arg1);
+ // JSC::JSValue val = JSC::identifierToJSValue(arg1->vm(), identifier);
+
+ // if (!map->has(arg1, val)) return nullptr;
+
+ // if (JSC::JSObject *registryEntry =
+ // JSC::jsDynamicCast<JSC::JSObject *>(arg1->vm(), map->get(arg1, val))) {
+ // auto moduleIdent = JSC::Identifier::fromString(arg1->vm(), "module");
+ // if (JSC::JSModuleRecord *record = JSC::jsDynamicCast<JSC::JSModuleRecord *>(
+ // arg1->vm(), registryEntry->getDirect(arg1->vm(), moduleIdent))) {
+ // registryEntry->putDirect(arg1->vm(), moduleIdent, JSC::jsUndefined());
+ // JSC::JSModuleRecord::destroy(static_cast<JSC::JSCell *>(record));
+ // }
+ // map->remove(arg1, val);
+ // return JSC__JSModuleLoader__loadAndEvaluateModule(arg1, arg2);
+ // }
+
+ // return nullptr;
}
bool JSC__JSValue__isSameValue(JSC__JSValue JSValue0, JSC__JSValue JSValue1,
- JSC__JSGlobalObject *globalObject) {
- return JSC::sameValue(globalObject, JSC::JSValue::decode(JSValue0),
- JSC::JSValue::decode(JSValue1));
+ JSC__JSGlobalObject* globalObject)
+{
+ return JSC::sameValue(globalObject, JSC::JSValue::decode(JSValue0),
+ JSC::JSValue::decode(JSValue1));
}
// This is the same as the C API version, except it returns a JSValue which may be a *Exception
// We want that so we can return stack traces.
JSC__JSValue JSObjectCallAsFunctionReturnValue(JSContextRef ctx, JSObjectRef object,
- JSObjectRef thisObject, size_t argumentCount,
- const JSValueRef *arguments);
+ JSObjectRef thisObject, size_t argumentCount,
+ const JSValueRef* arguments);
JSC__JSValue JSObjectCallAsFunctionReturnValue(JSContextRef ctx, JSObjectRef object,
- JSObjectRef thisObject, size_t argumentCount,
- const JSValueRef *arguments) {
- JSC::JSGlobalObject *globalObject = toJS(ctx);
- JSC::VM &vm = globalObject->vm();
+ JSObjectRef thisObject, size_t argumentCount,
+ const JSValueRef* arguments)
+{
+ JSC::JSGlobalObject* globalObject = toJS(ctx);
+ JSC::VM& vm = globalObject->vm();
- if (!object) return JSC::JSValue::encode(JSC::JSValue());
+ if (!object)
+ return JSC::JSValue::encode(JSC::JSValue());
- JSC::JSObject *jsObject = toJS(object);
- JSC::JSObject *jsThisObject = toJS(thisObject);
+ JSC::JSObject* jsObject = toJS(object);
+ JSC::JSObject* jsThisObject = toJS(thisObject);
- if (!jsThisObject) jsThisObject = globalObject->globalThis();
+ if (!jsThisObject)
+ jsThisObject = globalObject->globalThis();
- JSC::MarkedArgumentBuffer argList;
- for (size_t i = 0; i < argumentCount; i++) argList.append(toJS(globalObject, arguments[i]));
+ JSC::MarkedArgumentBuffer argList;
+ for (size_t i = 0; i < argumentCount; i++)
+ argList.append(toJS(globalObject, arguments[i]));
- auto callData = getCallData(vm, jsObject);
- if (callData.type == JSC::CallData::Type::None) return JSC::JSValue::encode(JSC::JSValue());
+ auto callData = getCallData(vm, jsObject);
+ if (callData.type == JSC::CallData::Type::None)
+ return JSC::JSValue::encode(JSC::JSValue());
- NakedPtr<JSC::Exception> returnedException = nullptr;
- auto result =
- JSC::call(globalObject, jsObject, callData, jsThisObject, argList, returnedException);
+ NakedPtr<JSC::Exception> returnedException = nullptr;
+ auto result = JSC::call(globalObject, jsObject, callData, jsThisObject, argList, returnedException);
- if (returnedException.get()) {
- return JSC::JSValue::encode(JSC::JSValue(returnedException.get()));
- }
+ if (returnedException.get()) {
+ return JSC::JSValue::encode(JSC::JSValue(returnedException.get()));
+ }
- return JSC::JSValue::encode(result);
+ return JSC::JSValue::encode(result);
}
JSC__JSValue JSObjectCallAsFunctionReturnValueHoldingAPILock(JSContextRef ctx, JSObjectRef object,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef *arguments);
+ JSObjectRef thisObject,
+ size_t argumentCount,
+ const JSValueRef* arguments);
JSC__JSValue JSObjectCallAsFunctionReturnValueHoldingAPILock(JSContextRef ctx, JSObjectRef object,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef *arguments) {
- JSC::JSGlobalObject *globalObject = toJS(ctx);
- JSC::VM &vm = globalObject->vm();
+ JSObjectRef thisObject,
+ size_t argumentCount,
+ const JSValueRef* arguments)
+{
+ JSC::JSGlobalObject* globalObject = toJS(ctx);
+ JSC::VM& vm = globalObject->vm();
- JSC::JSLockHolder lock(vm);
+ JSC::JSLockHolder lock(vm);
- if (!object) return JSC::JSValue::encode(JSC::JSValue());
+ if (!object)
+ return JSC::JSValue::encode(JSC::JSValue());
- JSC::JSObject *jsObject = toJS(object);
- JSC::JSObject *jsThisObject = toJS(thisObject);
+ JSC::JSObject* jsObject = toJS(object);
+ JSC::JSObject* jsThisObject = toJS(thisObject);
- if (!jsThisObject) jsThisObject = globalObject->globalThis();
+ if (!jsThisObject)
+ jsThisObject = globalObject->globalThis();
- JSC::MarkedArgumentBuffer argList;
- for (size_t i = 0; i < argumentCount; i++) argList.append(toJS(globalObject, arguments[i]));
+ JSC::MarkedArgumentBuffer argList;
+ for (size_t i = 0; i < argumentCount; i++)
+ argList.append(toJS(globalObject, arguments[i]));
- auto callData = getCallData(vm, jsObject);
- if (callData.type == JSC::CallData::Type::None) return JSC::JSValue::encode(JSC::JSValue());
+ auto callData = getCallData(vm, jsObject);
+ if (callData.type == JSC::CallData::Type::None)
+ return JSC::JSValue::encode(JSC::JSValue());
- NakedPtr<JSC::Exception> returnedException = nullptr;
- auto result =
- JSC::call(globalObject, jsObject, callData, jsThisObject, argList, returnedException);
+ NakedPtr<JSC::Exception> returnedException = nullptr;
+ auto result = JSC::call(globalObject, jsObject, callData, jsThisObject, argList, returnedException);
- if (returnedException.get()) {
- return JSC::JSValue::encode(JSC::JSValue(returnedException.get()));
- }
+ if (returnedException.get()) {
+ return JSC::JSValue::encode(JSC::JSValue(returnedException.get()));
+ }
- return JSC::JSValue::encode(result);
+ return JSC::JSValue::encode(result);
}
#pragma mark - JSC::Exception
-JSC__Exception *JSC__Exception__create(JSC__JSGlobalObject *arg0, JSC__JSObject *arg1,
- unsigned char StackCaptureAction2) {
- return JSC::Exception::create(arg0->vm(), JSC::JSValue(arg1),
- StackCaptureAction2 == 0
- ? JSC::Exception::StackCaptureAction::CaptureStack
- : JSC::Exception::StackCaptureAction::DoNotCaptureStack);
+JSC__Exception* JSC__Exception__create(JSC__JSGlobalObject* arg0, JSC__JSObject* arg1,
+ unsigned char StackCaptureAction2)
+{
+ return JSC::Exception::create(arg0->vm(), JSC::JSValue(arg1),
+ StackCaptureAction2 == 0
+ ? JSC::Exception::StackCaptureAction::CaptureStack
+ : JSC::Exception::StackCaptureAction::DoNotCaptureStack);
}
-JSC__JSValue JSC__Exception__value(JSC__Exception *arg0) {
- return JSC::JSValue::encode(arg0->value());
+JSC__JSValue JSC__Exception__value(JSC__Exception* arg0)
+{
+ return JSC::JSValue::encode(arg0->value());
}
// #pragma mark - JSC::PropertyNameArray
@@ -369,51 +393,63 @@ JSC__JSValue JSC__Exception__value(JSC__Exception *arg0) {
// CPP_DECL const JSC__PropertyName*
// JSC__PropertyNameArray__next(JSC__PropertyNameArray* arg0, size_t arg1);
// CPP_DECL void JSC__PropertyNameArray__release(JSC__PropertyNameArray* arg0);
-size_t JSC__JSObject__getArrayLength(JSC__JSObject *arg0) { return arg0->getArrayLength(); }
-JSC__JSValue JSC__JSObject__getIndex(JSC__JSValue jsValue, JSC__JSGlobalObject *arg1,
- uint32_t arg3) {
- return JSC::JSValue::encode(JSC::JSValue::decode(jsValue).toObject(arg1)->getIndex(arg1, arg3));
+size_t JSC__JSObject__getArrayLength(JSC__JSObject* arg0) { return arg0->getArrayLength(); }
+JSC__JSValue JSC__JSObject__getIndex(JSC__JSValue jsValue, JSC__JSGlobalObject* arg1,
+ uint32_t arg3)
+{
+ return JSC::JSValue::encode(JSC::JSValue::decode(jsValue).toObject(arg1)->getIndex(arg1, arg3));
}
-JSC__JSValue JSC__JSObject__getDirect(JSC__JSObject *arg0, JSC__JSGlobalObject *arg1,
- const ZigString *arg2) {
- return JSC::JSValue::encode(arg0->getDirect(arg1->vm(), Zig::toIdentifier(*arg2, arg1)));
+JSC__JSValue JSC__JSObject__getDirect(JSC__JSObject* arg0, JSC__JSGlobalObject* arg1,
+ const ZigString* arg2)
+{
+ return JSC::JSValue::encode(arg0->getDirect(arg1->vm(), Zig::toIdentifier(*arg2, arg1)));
}
-void JSC__JSObject__putDirect(JSC__JSObject *arg0, JSC__JSGlobalObject *arg1, const ZigString *key,
- JSC__JSValue value) {
- auto prop = Zig::toIdentifier(*key, arg1);
+void JSC__JSObject__putDirect(JSC__JSObject* arg0, JSC__JSGlobalObject* arg1, const ZigString* key,
+ JSC__JSValue value)
+{
+ auto prop = Zig::toIdentifier(*key, arg1);
- arg0->putDirect(arg1->vm(), prop, JSC::JSValue::decode(value));
+ arg0->putDirect(arg1->vm(), prop, JSC::JSValue::decode(value));
}
#pragma mark - JSC::JSCell
-JSC__JSObject *JSC__JSCell__getObject(JSC__JSCell *arg0) { return arg0->getObject(); }
-bWTF__String JSC__JSCell__getString(JSC__JSCell *arg0, JSC__JSGlobalObject *arg1) {
- return Wrap<WTF__String, bWTF__String>::wrap(arg0->getString(arg1));
+JSC__JSObject* JSC__JSCell__getObject(JSC__JSCell* arg0)
+{
+ return arg0->getObject();
}
-unsigned char JSC__JSCell__getType(JSC__JSCell *arg0) { return arg0->type(); }
+bWTF__String JSC__JSCell__getString(JSC__JSCell* arg0, JSC__JSGlobalObject* arg1)
+{
+ return Wrap<WTF__String, bWTF__String>::wrap(arg0->getString(arg1));
+}
+unsigned char JSC__JSCell__getType(JSC__JSCell* arg0) { return arg0->type(); }
#pragma mark - JSC::JSString
-JSC__JSString *JSC__JSString__createFromOwnedString(JSC__VM *arg0, const WTF__String *arg1) {
- return JSC::jsOwnedString(reinterpret_cast<JSC__VM &>(arg0),
- reinterpret_cast<const WTF__String &>(arg1));
+JSC__JSString* JSC__JSString__createFromOwnedString(JSC__VM* arg0, const WTF__String* arg1)
+{
+ return JSC::jsOwnedString(reinterpret_cast<JSC__VM&>(arg0),
+ reinterpret_cast<const WTF__String&>(arg1));
}
-JSC__JSString *JSC__JSString__createFromString(JSC__VM *arg0, const WTF__String *arg1) {
- return JSC::jsString(reinterpret_cast<JSC__VM &>(arg0),
- reinterpret_cast<const WTF__String &>(arg1));
+JSC__JSString* JSC__JSString__createFromString(JSC__VM* arg0, const WTF__String* arg1)
+{
+ return JSC::jsString(reinterpret_cast<JSC__VM&>(arg0),
+ reinterpret_cast<const WTF__String&>(arg1));
}
-bool JSC__JSString__eql(const JSC__JSString *arg0, JSC__JSGlobalObject *obj, JSC__JSString *arg2) {
- return arg0->equal(obj, arg2);
+bool JSC__JSString__eql(const JSC__JSString* arg0, JSC__JSGlobalObject* obj, JSC__JSString* arg2)
+{
+ return arg0->equal(obj, arg2);
}
-bool JSC__JSString__is8Bit(const JSC__JSString *arg0) { return arg0->is8Bit(); };
-size_t JSC__JSString__length(const JSC__JSString *arg0) { return arg0->length(); }
-JSC__JSObject *JSC__JSString__toObject(JSC__JSString *arg0, JSC__JSGlobalObject *arg1) {
- return arg0->toObject(arg1);
+bool JSC__JSString__is8Bit(const JSC__JSString* arg0) { return arg0->is8Bit(); };
+size_t JSC__JSString__length(const JSC__JSString* arg0) { return arg0->length(); }
+JSC__JSObject* JSC__JSString__toObject(JSC__JSString* arg0, JSC__JSGlobalObject* arg1)
+{
+ return arg0->toObject(arg1);
}
-bWTF__String JSC__JSString__value(JSC__JSString *arg0, JSC__JSGlobalObject *arg1) {
- return Wrap<WTF__String, bWTF__String>::wrap(arg0->value(arg1));
+bWTF__String JSC__JSString__value(JSC__JSString* arg0, JSC__JSGlobalObject* arg1)
+{
+ return Wrap<WTF__String, bWTF__String>::wrap(arg0->value(arg1));
}
#pragma mark - JSC::JSModuleLoader
@@ -424,448 +460,504 @@ bWTF__String JSC__JSString__value(JSC__JSString *arg0, JSC__JSGlobalObject *arg1
// arg2->depen
// }
-void Microtask__run(void *microtask, void *global) {
- reinterpret_cast<Zig::JSMicrotaskCallback *>(microtask)->call();
-}
-
-bool JSC__JSModuleLoader__checkSyntax(JSC__JSGlobalObject *arg0, const JSC__SourceCode *arg1,
- bool arg2) {
- JSC::ParserError error;
- bool result = false;
- if (arg2) {
- result = JSC::checkModuleSyntax(arg0, reinterpret_cast<const JSC::SourceCode &>(arg1), error);
- } else {
- result = JSC::checkSyntax(reinterpret_cast<JSC__VM &>(arg0->vm()),
- reinterpret_cast<const JSC::SourceCode &>(arg1), error);
- }
-
- return result;
+void Microtask__run(void* microtask, void* global)
+{
+ reinterpret_cast<Zig::JSMicrotaskCallback*>(microtask)->call();
}
-JSC__JSValue JSC__JSModuleLoader__evaluate(JSC__JSGlobalObject *arg0, const unsigned char *arg1,
- size_t arg2, const unsigned char *arg3, size_t arg4,
- JSC__JSValue JSValue5, JSC__JSValue *arg6) {
- WTF::String src = WTF::String(WTF::StringImpl::createWithoutCopying(arg1, arg2));
- WTF::URL origin = WTF::URL::fileURLWithFileSystemPath(WTF::StringView(arg3, arg4));
- JSC::VM &vm = arg0->vm();
- JSC::JSLockHolder locker(vm);
+bool JSC__JSModuleLoader__checkSyntax(JSC__JSGlobalObject* arg0, const JSC__SourceCode* arg1,
+ bool arg2)
+{
+ JSC::ParserError error;
+ bool result = false;
+ if (arg2) {
+ result = JSC::checkModuleSyntax(arg0, reinterpret_cast<const JSC::SourceCode&>(arg1), error);
+ } else {
+ result = JSC::checkSyntax(reinterpret_cast<JSC__VM&>(arg0->vm()),
+ reinterpret_cast<const JSC::SourceCode&>(arg1), error);
+ }
- JSC::SourceCode sourceCode = JSC::makeSource(
- src, JSC::SourceOrigin{origin}, origin.lastPathComponent().toStringWithoutCopying(),
- WTF::TextPosition(), JSC::SourceProviderSourceType::Module);
- WTF::NakedPtr<JSC::Exception> exception;
- auto val = JSC::evaluate(arg0, sourceCode, JSC::JSValue(), exception);
- if (exception.get()) { *arg6 = JSC::JSValue::encode(JSC::JSValue(exception.get())); }
+ return result;
+}
+JSC__JSValue JSC__JSModuleLoader__evaluate(JSC__JSGlobalObject* arg0, const unsigned char* arg1,
+ size_t arg2, const unsigned char* arg3, size_t arg4,
+ JSC__JSValue JSValue5, JSC__JSValue* arg6)
+{
+ WTF::String src = WTF::String(WTF::StringImpl::createWithoutCopying(arg1, arg2));
+ WTF::URL origin = WTF::URL::fileURLWithFileSystemPath(WTF::StringView(arg3, arg4));
+
+ JSC::VM& vm = arg0->vm();
+ JSC::JSLockHolder locker(vm);
+
+ JSC::SourceCode sourceCode = JSC::makeSource(
+ src, JSC::SourceOrigin { origin }, origin.lastPathComponent().toStringWithoutCopying(),
+ WTF::TextPosition(), JSC::SourceProviderSourceType::Module);
+ WTF::NakedPtr<JSC::Exception> exception;
+ auto val = JSC::evaluate(arg0, sourceCode, JSC::JSValue(), exception);
+ if (exception.get()) {
+ *arg6 = JSC::JSValue::encode(JSC::JSValue(exception.get()));
+ }
- vm.drainMicrotasks();
- return JSC::JSValue::encode(val);
+ vm.drainMicrotasks();
+ return JSC::JSValue::encode(val);
}
-JSC__JSInternalPromise *JSC__JSModuleLoader__importModule(JSC__JSGlobalObject *arg0,
- const JSC__Identifier *arg1) {
- return JSC::importModule(arg0, *arg1, JSC::JSValue{}, JSC::JSValue{});
+JSC__JSInternalPromise* JSC__JSModuleLoader__importModule(JSC__JSGlobalObject* arg0,
+ const JSC__Identifier* arg1)
+{
+ return JSC::importModule(arg0, *arg1, JSC::JSValue {}, JSC::JSValue {});
}
-JSC__JSValue JSC__JSModuleLoader__linkAndEvaluateModule(JSC__JSGlobalObject *arg0,
- const JSC__Identifier *arg1) {
- return JSC::JSValue::encode(JSC::linkAndEvaluateModule(arg0, *arg1, JSC::JSValue{}));
+JSC__JSValue JSC__JSModuleLoader__linkAndEvaluateModule(JSC__JSGlobalObject* arg0,
+ const JSC__Identifier* arg1)
+{
+ return JSC::JSValue::encode(JSC::linkAndEvaluateModule(arg0, *arg1, JSC::JSValue {}));
}
-static JSC::Identifier jsValueToModuleKey(JSC::JSGlobalObject *lexicalGlobalObject,
- JSC::JSValue value) {
- if (value.isSymbol())
- return JSC::Identifier::fromUid(JSC::jsCast<JSC::Symbol *>(value)->privateName());
- return JSC::asString(value)->toIdentifier(lexicalGlobalObject);
+static JSC::Identifier jsValueToModuleKey(JSC::JSGlobalObject* lexicalGlobalObject,
+ JSC::JSValue value)
+{
+ if (value.isSymbol())
+ return JSC::Identifier::fromUid(JSC::jsCast<JSC::Symbol*>(value)->privateName());
+ return JSC::asString(value)->toIdentifier(lexicalGlobalObject);
}
-static JSC::JSValue doLink(JSC__JSGlobalObject *globalObject, JSC::JSValue moduleKeyValue) {
- JSC::VM &vm = globalObject->vm();
- JSC::JSLockHolder lock{vm};
- if (!(moduleKeyValue.isString() || moduleKeyValue.isSymbol())) { return JSC::jsUndefined(); }
- auto scope = DECLARE_THROW_SCOPE(vm);
- JSC::Identifier moduleKey = jsValueToModuleKey(globalObject, moduleKeyValue);
- RETURN_IF_EXCEPTION(scope, {});
+static JSC::JSValue doLink(JSC__JSGlobalObject* globalObject, JSC::JSValue moduleKeyValue)
+{
+ JSC::VM& vm = globalObject->vm();
+ JSC::JSLockHolder lock { vm };
+ if (!(moduleKeyValue.isString() || moduleKeyValue.isSymbol())) {
+ return JSC::jsUndefined();
+ }
+ auto scope = DECLARE_THROW_SCOPE(vm);
+ JSC::Identifier moduleKey = jsValueToModuleKey(globalObject, moduleKeyValue);
+ RETURN_IF_EXCEPTION(scope, {});
+
+ return JSC::linkAndEvaluateModule(globalObject, moduleKey, JSC::JSValue());
+}
+
+JSC__JSValue JSC__JSValue__createRangeError(const ZigString* message, const ZigString* arg1,
+ JSC__JSGlobalObject* globalObject)
+{
+ JSC::VM& vm = globalObject->vm();
+ ZigString code = *arg1;
+ JSC::JSObject* rangeError = Zig::getErrorInstance(message, globalObject).asCell()->getObject();
+ static const char* range_error_name = "RangeError";
+
+ rangeError->putDirect(
+ vm, vm.propertyNames->name,
+ JSC::JSValue(JSC::jsOwnedString(
+ vm, WTF::String(WTF::StringImpl::createWithoutCopying(range_error_name, 10)))),
+ 0);
+
+ if (code.len > 0) {
+ auto clientData = Bun::clientData(vm);
+ JSC::JSValue codeValue = Zig::toJSStringValue(code, globalObject);
+ rangeError->putDirect(vm, clientData->builtinNames().codePublicName(), codeValue,
+ JSC::PropertyAttribute::ReadOnly | 0);
+ }
- return JSC::linkAndEvaluateModule(globalObject, moduleKey, JSC::JSValue());
-}
+ return JSC::JSValue::encode(rangeError);
+}
+JSC__JSValue JSC__JSValue__createTypeError(const ZigString* message, const ZigString* arg1,
+ JSC__JSGlobalObject* globalObject)
+{
+ JSC::VM& vm = globalObject->vm();
+ ZigString code = *arg1;
+ JSC::JSObject* typeError = Zig::getErrorInstance(message, globalObject).asCell()->getObject();
+ static const char* range_error_name = "TypeError";
+
+ typeError->putDirect(
+ vm, vm.propertyNames->name,
+ JSC::JSValue(JSC::jsOwnedString(
+ vm, WTF::String(WTF::StringImpl::createWithoutCopying(range_error_name, 10)))),
+ 0);
+
+ if (code.len > 0) {
+ auto clientData = Bun::clientData(vm);
+ JSC::JSValue codeValue = Zig::toJSStringValue(code, globalObject);
+ typeError->putDirect(vm, clientData->builtinNames().codePublicName(), codeValue, 0);
+ }
-JSC__JSValue JSC__JSValue__createRangeError(const ZigString *message, const ZigString *arg1,
- JSC__JSGlobalObject *globalObject) {
- JSC::VM &vm = globalObject->vm();
- ZigString code = *arg1;
- JSC::JSObject *rangeError = Zig::getErrorInstance(message, globalObject).asCell()->getObject();
- static const char *range_error_name = "RangeError";
+ return JSC::JSValue::encode(typeError);
+}
- rangeError->putDirect(
- vm, vm.propertyNames->name,
- JSC::JSValue(JSC::jsOwnedString(
- vm, WTF::String(WTF::StringImpl::createWithoutCopying(range_error_name, 10)))),
- 0);
+JSC__JSValue JSC__JSValue__fromEntries(JSC__JSGlobalObject* globalObject, ZigString* keys,
+ ZigString* values, size_t initialCapacity, bool clone)
+{
+ JSC::VM& vm = globalObject->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+ if (initialCapacity == 0) {
+ return JSC::JSValue::encode(JSC::constructEmptyObject(globalObject));
+ }
- if (code.len > 0) {
- auto clientData = Bun::clientData(vm);
- JSC::JSValue codeValue = Zig::toJSStringValue(code, globalObject);
- rangeError->putDirect(vm, clientData->builtinNames().codePublicName(), codeValue,
- JSC::PropertyAttribute::ReadOnly | 0);
- }
-
- return JSC::JSValue::encode(rangeError);
-}
-JSC__JSValue JSC__JSValue__createTypeError(const ZigString *message, const ZigString *arg1,
- JSC__JSGlobalObject *globalObject) {
- JSC::VM &vm = globalObject->vm();
- ZigString code = *arg1;
- JSC::JSObject *typeError = Zig::getErrorInstance(message, globalObject).asCell()->getObject();
- static const char *range_error_name = "TypeError";
-
- typeError->putDirect(
- vm, vm.propertyNames->name,
- JSC::JSValue(JSC::jsOwnedString(
- vm, WTF::String(WTF::StringImpl::createWithoutCopying(range_error_name, 10)))),
- 0);
-
- if (code.len > 0) {
- auto clientData = Bun::clientData(vm);
- JSC::JSValue codeValue = Zig::toJSStringValue(code, globalObject);
- typeError->putDirect(vm, clientData->builtinNames().codePublicName(), codeValue, 0);
- }
-
- return JSC::JSValue::encode(typeError);
-}
-
-JSC__JSValue JSC__JSValue__fromEntries(JSC__JSGlobalObject *globalObject, ZigString *keys,
- ZigString *values, size_t initialCapacity, bool clone) {
- JSC::VM &vm = globalObject->vm();
- auto scope = DECLARE_THROW_SCOPE(vm);
- if (initialCapacity == 0) {
- return JSC::JSValue::encode(JSC::constructEmptyObject(globalObject));
- }
-
- JSC::JSObject *object = nullptr;
- {
- JSC::ObjectInitializationScope initializationScope(vm);
- object =
- JSC::constructEmptyObject(globalObject, globalObject->objectPrototype(), initialCapacity);
-
- if (!clone) {
- for (size_t i = 0; i < initialCapacity; ++i) {
- object->putDirect(
- vm, JSC::PropertyName(JSC::Identifier::fromString(vm, Zig::toString(keys[i]))),
- Zig::toJSStringValueGC(values[i], globalObject), 0);
- }
- } else {
- for (size_t i = 0; i < initialCapacity; ++i) {
- object->putDirect(vm, JSC::PropertyName(Zig::toIdentifier(keys[i], globalObject)),
- Zig::toJSStringValueGC(values[i], globalObject), 0);
- }
+ JSC::JSObject* object = nullptr;
+ {
+ JSC::ObjectInitializationScope initializationScope(vm);
+ object = JSC::constructEmptyObject(globalObject, globalObject->objectPrototype(), initialCapacity);
+
+ if (!clone) {
+ for (size_t i = 0; i < initialCapacity; ++i) {
+ object->putDirect(
+ vm, JSC::PropertyName(JSC::Identifier::fromString(vm, Zig::toString(keys[i]))),
+ Zig::toJSStringValueGC(values[i], globalObject), 0);
+ }
+ } else {
+ for (size_t i = 0; i < initialCapacity; ++i) {
+ object->putDirect(vm, JSC::PropertyName(Zig::toIdentifier(keys[i], globalObject)),
+ Zig::toJSStringValueGC(values[i], globalObject), 0);
+ }
+ }
}
- }
- return JSC::JSValue::encode(object);
+ return JSC::JSValue::encode(object);
}
-bool JSC__JSValue__asArrayBuffer_(JSC__JSValue JSValue0, JSC__JSGlobalObject *arg1,
- Bun__ArrayBuffer *arg2) {
- JSC::VM &vm = arg1->vm();
+bool JSC__JSValue__asArrayBuffer_(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1,
+ Bun__ArrayBuffer* arg2)
+{
+ JSC::VM& vm = arg1->vm();
- JSC::JSValue value = JSC::JSValue::decode(JSValue0);
- if (!value.isObject()) { return false; }
+ JSC::JSValue value = JSC::JSValue::decode(JSValue0);
+ if (!value.isObject()) {
+ return false;
+ }
+
+ JSC::JSObject* object = value.getObject();
+
+ if (JSC::JSArrayBufferView* typedArray = JSC::jsDynamicCast<JSC::JSArrayBufferView*>(vm, object)) {
+ if (JSC::ArrayBuffer* buffer = typedArray->possiblySharedBuffer()) {
+ buffer->pinAndLock();
+ arg2->ptr = reinterpret_cast<char*>(buffer->data());
+ arg2->len = typedArray->length();
+ arg2->byte_len = buffer->byteLength();
+ arg2->offset = typedArray->byteOffset();
+ arg2->cell_type = typedArray->type();
+ return true;
+ }
+ }
- JSC::JSObject *object = value.getObject();
+ if (JSC::ArrayBuffer* buffer = JSC::toPossiblySharedArrayBuffer(vm, value)) {
+ buffer->pinAndLock();
+ arg2->ptr = reinterpret_cast<char*>(buffer->data());
+ arg2->len = buffer->byteLength();
+ arg2->byte_len = buffer->byteLength();
+ arg2->offset = 0;
+ arg2->cell_type = 40;
+ return true;
+ }
- if (JSC::JSArrayBufferView *typedArray =
- JSC::jsDynamicCast<JSC::JSArrayBufferView *>(vm, object)) {
- if (JSC::ArrayBuffer *buffer = typedArray->possiblySharedBuffer()) {
- buffer->pinAndLock();
- arg2->ptr = reinterpret_cast<char *>(buffer->data());
- arg2->len = typedArray->length();
- arg2->byte_len = buffer->byteLength();
- arg2->offset = typedArray->byteOffset();
- arg2->cell_type = typedArray->type();
- return true;
+ return false;
+}
+JSC__JSValue JSC__JSValue__createStringArray(JSC__JSGlobalObject* globalObject, ZigString* arg1,
+ size_t arg2, bool clone)
+{
+ JSC::VM& vm = globalObject->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+ if (arg2 == 0) {
+ return JSC::JSValue::encode(JSC::JSArray::create(vm, 0));
}
- }
-
- if (JSC::ArrayBuffer *buffer = JSC::toPossiblySharedArrayBuffer(vm, value)) {
- buffer->pinAndLock();
- arg2->ptr = reinterpret_cast<char *>(buffer->data());
- arg2->len = buffer->byteLength();
- arg2->byte_len = buffer->byteLength();
- arg2->offset = 0;
- arg2->cell_type = 40;
- return true;
- }
-
- return false;
-}
-JSC__JSValue JSC__JSValue__createStringArray(JSC__JSGlobalObject *globalObject, ZigString *arg1,
- size_t arg2, bool clone) {
- JSC::VM &vm = globalObject->vm();
- auto scope = DECLARE_THROW_SCOPE(vm);
- if (arg2 == 0) { return JSC::JSValue::encode(JSC::JSArray::create(vm, 0)); }
-
- JSC::JSArray *array = nullptr;
- {
- JSC::ObjectInitializationScope initializationScope(vm);
- if ((array = JSC::JSArray::tryCreateUninitializedRestricted(
- initializationScope, nullptr,
- globalObject->arrayStructureForIndexingTypeDuringAllocation(JSC::ArrayWithContiguous),
- arg2))) {
-
- if (!clone) {
- for (size_t i = 0; i < arg2; ++i) {
- array->putDirectIndex(globalObject, i, JSC::jsString(vm, Zig::toString(arg1[i])));
+
+ JSC::JSArray* array = nullptr;
+ {
+ JSC::ObjectInitializationScope initializationScope(vm);
+ if ((array = JSC::JSArray::tryCreateUninitializedRestricted(
+ initializationScope, nullptr,
+ globalObject->arrayStructureForIndexingTypeDuringAllocation(JSC::ArrayWithContiguous),
+ arg2))) {
+
+ if (!clone) {
+ for (size_t i = 0; i < arg2; ++i) {
+ array->putDirectIndex(globalObject, i, JSC::jsString(vm, Zig::toString(arg1[i])));
+ }
+ } else {
+ for (size_t i = 0; i < arg2; ++i) {
+ array->putDirectIndex(globalObject, i, JSC::jsString(vm, Zig::toStringCopy(arg1[i])));
+ }
+ }
}
- } else {
- for (size_t i = 0; i < arg2; ++i) {
- array->putDirectIndex(globalObject, i, JSC::jsString(vm, Zig::toStringCopy(arg1[i])));
+ }
+ if (!array) {
+ JSC::throwOutOfMemoryError(globalObject, scope);
+ return JSC::JSValue::encode(JSC::JSValue());
+ }
+
+ RELEASE_AND_RETURN(scope, JSC::JSValue::encode(JSC::JSValue(array)));
+}
+
+JSC__JSValue JSC__JSGlobalObject__createAggregateError(JSC__JSGlobalObject* globalObject,
+ void** errors, uint16_t errors_count,
+ const ZigString* arg3)
+{
+ JSC::VM& vm = globalObject->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ JSC::JSValue message = JSC::JSValue(JSC::jsOwnedString(vm, Zig::toString(*arg3)));
+ JSC::JSValue options = JSC::jsUndefined();
+ JSC::JSArray* array = nullptr;
+ {
+ JSC::ObjectInitializationScope initializationScope(vm);
+ if ((array = JSC::JSArray::tryCreateUninitializedRestricted(
+ initializationScope, nullptr,
+ globalObject->arrayStructureForIndexingTypeDuringAllocation(JSC::ArrayWithContiguous),
+ errors_count))) {
+
+ for (uint16_t i = 0; i < errors_count; ++i) {
+ array->initializeIndexWithoutBarrier(
+ initializationScope, i, JSC::JSValue(reinterpret_cast<JSC::JSCell*>(errors[i])));
+ }
}
- }
}
- }
- if (!array) {
- JSC::throwOutOfMemoryError(globalObject, scope);
- return JSC::JSValue::encode(JSC::JSValue());
- }
-
- RELEASE_AND_RETURN(scope, JSC::JSValue::encode(JSC::JSValue(array)));
-}
-
-JSC__JSValue JSC__JSGlobalObject__createAggregateError(JSC__JSGlobalObject *globalObject,
- void **errors, uint16_t errors_count,
- const ZigString *arg3) {
- JSC::VM &vm = globalObject->vm();
- auto scope = DECLARE_THROW_SCOPE(vm);
-
- JSC::JSValue message = JSC::JSValue(JSC::jsOwnedString(vm, Zig::toString(*arg3)));
- JSC::JSValue options = JSC::jsUndefined();
- JSC::JSArray *array = nullptr;
- {
- JSC::ObjectInitializationScope initializationScope(vm);
- if ((array = JSC::JSArray::tryCreateUninitializedRestricted(
- initializationScope, nullptr,
- globalObject->arrayStructureForIndexingTypeDuringAllocation(JSC::ArrayWithContiguous),
- errors_count))) {
-
- for (uint16_t i = 0; i < errors_count; ++i) {
- array->initializeIndexWithoutBarrier(
- initializationScope, i, JSC::JSValue(reinterpret_cast<JSC::JSCell *>(errors[i])));
- }
+ if (!array) {
+ JSC::throwOutOfMemoryError(globalObject, scope);
+ return JSC::JSValue::encode(JSC::JSValue());
}
- }
- if (!array) {
- JSC::throwOutOfMemoryError(globalObject, scope);
- return JSC::JSValue::encode(JSC::JSValue());
- }
- JSC::Structure *errorStructure = globalObject->errorStructure(JSC::ErrorType::AggregateError);
- scope.release();
+ JSC::Structure* errorStructure = globalObject->errorStructure(JSC::ErrorType::AggregateError);
+ scope.release();
- return JSC::JSValue::encode(JSC::createAggregateError(
- globalObject, vm, errorStructure, array, message, options, nullptr, JSC::TypeNothing, false));
+ return JSC::JSValue::encode(JSC::createAggregateError(
+ globalObject, vm, errorStructure, array, message, options, nullptr, JSC::TypeNothing, false));
}
// static JSC::JSNativeStdFunction* resolverFunction;
// static JSC::JSNativeStdFunction* rejecterFunction;
// static bool resolverFunctionInitialized = false;
-JSC__JSValue ZigString__toValue(const ZigString *arg0, JSC__JSGlobalObject *arg1) {
- return JSC::JSValue::encode(JSC::JSValue(JSC::jsOwnedString(arg1->vm(), Zig::toString(*arg0))));
+JSC__JSValue ZigString__toValue(const ZigString* arg0, JSC__JSGlobalObject* arg1)
+{
+ return JSC::JSValue::encode(JSC::JSValue(JSC::jsOwnedString(arg1->vm(), Zig::toString(*arg0))));
}
-JSC__JSValue ZigString__to16BitValue(const ZigString *arg0, JSC__JSGlobalObject *arg1) {
- auto str = WTF::String::fromUTF8(arg0->ptr, arg0->len);
- return JSC::JSValue::encode(JSC::JSValue(JSC::jsString(arg1->vm(), str)));
+JSC__JSValue ZigString__to16BitValue(const ZigString* arg0, JSC__JSGlobalObject* arg1)
+{
+ auto str = WTF::String::fromUTF8(arg0->ptr, arg0->len);
+ return JSC::JSValue::encode(JSC::JSValue(JSC::jsString(arg1->vm(), str)));
}
-JSC__JSValue ZigString__toValueGC(const ZigString *arg0, JSC__JSGlobalObject *arg1) {
- return JSC::JSValue::encode(JSC::JSValue(JSC::jsString(arg1->vm(), Zig::toStringCopy(*arg0))));
+JSC__JSValue ZigString__toValueGC(const ZigString* arg0, JSC__JSGlobalObject* arg1)
+{
+ return JSC::JSValue::encode(JSC::JSValue(JSC::jsString(arg1->vm(), Zig::toStringCopy(*arg0))));
}
-void JSC__JSValue__toZigString(JSC__JSValue JSValue0, ZigString *arg1, JSC__JSGlobalObject *arg2) {
- JSC::JSValue value = JSC::JSValue::decode(JSValue0);
+void JSC__JSValue__toZigString(JSC__JSValue JSValue0, ZigString* arg1, JSC__JSGlobalObject* arg2)
+{
+ JSC::JSValue value = JSC::JSValue::decode(JSValue0);
- // if (!value.isString()) {
- // arg1->len = 0;
- // arg1->ptr = nullptr;
- // return;
- // }
+ // if (!value.isString()) {
+ // arg1->len = 0;
+ // arg1->ptr = nullptr;
+ // return;
+ // }
- auto str = value.toWTFString(arg2);
+ auto str = value.toWTFString(arg2);
- if (str.is8Bit()) {
- arg1->ptr = str.characters8();
- } else {
- arg1->ptr = Zig::taggedUTF16Ptr(str.characters16());
- }
+ if (str.is8Bit()) {
+ arg1->ptr = str.characters8();
+ } else {
+ arg1->ptr = Zig::taggedUTF16Ptr(str.characters16());
+ }
- arg1->len = str.length();
+ arg1->len = str.length();
}
-JSC__JSValue ZigString__toErrorInstance(const ZigString *str, JSC__JSGlobalObject *globalObject) {
- return JSC::JSValue::encode(Zig::getErrorInstance(str, globalObject));
+JSC__JSValue ZigString__toErrorInstance(const ZigString* str, JSC__JSGlobalObject* globalObject)
+{
+ return JSC::JSValue::encode(Zig::getErrorInstance(str, globalObject));
}
-static JSC::EncodedJSValue resolverFunctionCallback(JSC::JSGlobalObject *globalObject,
- JSC::CallFrame *callFrame) {
- return JSC::JSValue::encode(doLink(globalObject, callFrame->argument(0)));
+static JSC::EncodedJSValue resolverFunctionCallback(JSC::JSGlobalObject* globalObject,
+ JSC::CallFrame* callFrame)
+{
+ return JSC::JSValue::encode(doLink(globalObject, callFrame->argument(0)));
}
-JSC__JSInternalPromise *
-JSC__JSModuleLoader__loadAndEvaluateModule(JSC__JSGlobalObject *globalObject,
- const ZigString *arg1) {
- globalObject->vm().drainMicrotasks();
- auto name = Zig::toString(*arg1);
- name.impl()->ref();
+JSC__JSInternalPromise*
+JSC__JSModuleLoader__loadAndEvaluateModule(JSC__JSGlobalObject* globalObject,
+ const ZigString* arg1)
+{
+ globalObject->vm().drainMicrotasks();
+ auto name = Zig::toString(*arg1);
+ name.impl()->ref();
- auto *promise =
- JSC::loadAndEvaluateModule(globalObject, name, JSC::jsUndefined(), JSC::jsUndefined());
+ auto* promise = JSC::loadAndEvaluateModule(globalObject, name, JSC::jsUndefined(), JSC::jsUndefined());
- JSC::JSNativeStdFunction *resolverFunction = JSC::JSNativeStdFunction::create(
- globalObject->vm(), globalObject, 1, String(), resolverFunctionCallback);
- JSC::JSNativeStdFunction *rejecterFunction = JSC::JSNativeStdFunction::create(
- globalObject->vm(), globalObject, 1, String(),
- [&arg1](JSC::JSGlobalObject *globalObject, JSC::CallFrame *callFrame) -> JSC::EncodedJSValue {
- return JSC::JSValue::encode(
- JSC::JSInternalPromise::rejectedPromise(globalObject, callFrame->argument(0)));
- });
+ JSC::JSNativeStdFunction* resolverFunction = JSC::JSNativeStdFunction::create(
+ globalObject->vm(), globalObject, 1, String(), resolverFunctionCallback);
+ JSC::JSNativeStdFunction* rejecterFunction = JSC::JSNativeStdFunction::create(
+ globalObject->vm(), globalObject, 1, String(),
+ [&arg1](JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame) -> JSC::EncodedJSValue {
+ return JSC::JSValue::encode(
+ JSC::JSInternalPromise::rejectedPromise(globalObject, callFrame->argument(0)));
+ });
- globalObject->vm().drainMicrotasks();
- auto result = promise->then(globalObject, resolverFunction, rejecterFunction);
- globalObject->vm().drainMicrotasks();
+ globalObject->vm().drainMicrotasks();
+ auto result = promise->then(globalObject, resolverFunction, rejecterFunction);
+ globalObject->vm().drainMicrotasks();
- // if (promise->status(globalObject->vm()) ==
- // JSC::JSPromise::Status::Fulfilled) {
- // return reinterpret_cast<JSC::JSInternalPromise*>(
- // JSC::JSInternalPromise::resolvedPromise(
- // globalObject,
- // doLink(globalObject, promise->result(globalObject->vm()))
- // )
- // );
- // }
+ // if (promise->status(globalObject->vm()) ==
+ // JSC::JSPromise::Status::Fulfilled) {
+ // return reinterpret_cast<JSC::JSInternalPromise*>(
+ // JSC::JSInternalPromise::resolvedPromise(
+ // globalObject,
+ // doLink(globalObject, promise->result(globalObject->vm()))
+ // )
+ // );
+ // }
- return result;
+ return result;
}
-JSC__JSInternalPromise *
-JSC__JSModuleLoader__loadAndEvaluateModuleEntryPoint(JSC__JSGlobalObject *arg0,
- const JSC__SourceCode *arg1) {
- return JSC::loadAndEvaluateModule(arg0, *arg1, JSC::JSValue{});
+JSC__JSInternalPromise*
+JSC__JSModuleLoader__loadAndEvaluateModuleEntryPoint(JSC__JSGlobalObject* arg0,
+ const JSC__SourceCode* arg1)
+{
+ return JSC::loadAndEvaluateModule(arg0, *arg1, JSC::JSValue {});
}
#pragma mark - JSC::JSModuleRecord
-bJSC__SourceCode JSC__JSModuleRecord__sourceCode(JSC__JSModuleRecord *arg0) {
- Wrap<JSC::SourceCode, bJSC__SourceCode> wrapped =
- Wrap<JSC::SourceCode, bJSC__SourceCode>(arg0->sourceCode());
- return wrapped.result;
+bJSC__SourceCode JSC__JSModuleRecord__sourceCode(JSC__JSModuleRecord* arg0)
+{
+ Wrap<JSC::SourceCode, bJSC__SourceCode> wrapped = Wrap<JSC::SourceCode, bJSC__SourceCode>(arg0->sourceCode());
+ return wrapped.result;
}
#pragma mark - JSC::JSPromise
-void JSC__JSPromise__reject(JSC__JSPromise *arg0, JSC__JSGlobalObject *arg1,
- JSC__JSValue JSValue2) {
- arg0->reject(arg1, JSC::JSValue::decode(JSValue2));
-}
-void JSC__JSPromise__rejectAsHandled(JSC__JSPromise *arg0, JSC__JSGlobalObject *arg1,
- JSC__JSValue JSValue2) {
- arg0->rejectAsHandled(arg1, JSC::JSValue::decode(JSValue2));
-}
-void JSC__JSPromise__rejectAsHandledException(JSC__JSPromise *arg0, JSC__JSGlobalObject *arg1,
- JSC__Exception *arg2) {
- arg0->rejectAsHandled(arg1, arg2);
-}
-JSC__JSPromise *JSC__JSPromise__rejectedPromise(JSC__JSGlobalObject *arg0, JSC__JSValue JSValue1) {
- return JSC::JSPromise::rejectedPromise(arg0, JSC::JSValue::decode(JSValue1));
-}
-
-void JSC__JSPromise__rejectWithCaughtException(JSC__JSPromise *arg0, JSC__JSGlobalObject *arg1,
- bJSC__ThrowScope arg2) {
- Wrap<JSC::ThrowScope, bJSC__ThrowScope> wrapped = Wrap<JSC::ThrowScope, bJSC__ThrowScope>(arg2);
-
- arg0->rejectWithCaughtException(arg1, *wrapped.cpp);
-}
-void JSC__JSPromise__resolve(JSC__JSPromise *arg0, JSC__JSGlobalObject *arg1,
- JSC__JSValue JSValue2) {
- arg0->resolve(arg1, JSC::JSValue::decode(JSValue2));
-}
-JSC__JSPromise *JSC__JSPromise__resolvedPromise(JSC__JSGlobalObject *arg0, JSC__JSValue JSValue1) {
- return JSC::JSPromise::resolvedPromise(arg0, JSC::JSValue::decode(JSValue1));
-}
-
-JSC__JSValue JSC__JSPromise__result(const JSC__JSPromise *arg0, JSC__VM *arg1) {
- return JSC::JSValue::encode(arg0->result(reinterpret_cast<JSC::VM &>(arg1)));
-}
-uint32_t JSC__JSPromise__status(const JSC__JSPromise *arg0, JSC__VM *arg1) {
- switch (arg0->status(reinterpret_cast<JSC::VM &>(arg1))) {
- case JSC::JSPromise::Status::Pending: return 0;
- case JSC::JSPromise::Status::Fulfilled: return 1;
- case JSC::JSPromise::Status::Rejected: return 2;
- default: return 255;
- }
+void JSC__JSPromise__reject(JSC__JSPromise* arg0, JSC__JSGlobalObject* arg1,
+ JSC__JSValue JSValue2)
+{
+ arg0->reject(arg1, JSC::JSValue::decode(JSValue2));
+}
+void JSC__JSPromise__rejectAsHandled(JSC__JSPromise* arg0, JSC__JSGlobalObject* arg1,
+ JSC__JSValue JSValue2)
+{
+ arg0->rejectAsHandled(arg1, JSC::JSValue::decode(JSValue2));
+}
+void JSC__JSPromise__rejectAsHandledException(JSC__JSPromise* arg0, JSC__JSGlobalObject* arg1,
+ JSC__Exception* arg2)
+{
+ arg0->rejectAsHandled(arg1, arg2);
+}
+JSC__JSPromise* JSC__JSPromise__rejectedPromise(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1)
+{
+ return JSC::JSPromise::rejectedPromise(arg0, JSC::JSValue::decode(JSValue1));
+}
+
+void JSC__JSPromise__rejectWithCaughtException(JSC__JSPromise* arg0, JSC__JSGlobalObject* arg1,
+ bJSC__ThrowScope arg2)
+{
+ Wrap<JSC::ThrowScope, bJSC__ThrowScope> wrapped = Wrap<JSC::ThrowScope, bJSC__ThrowScope>(arg2);
+
+ arg0->rejectWithCaughtException(arg1, *wrapped.cpp);
+}
+void JSC__JSPromise__resolve(JSC__JSPromise* arg0, JSC__JSGlobalObject* arg1,
+ JSC__JSValue JSValue2)
+{
+ arg0->resolve(arg1, JSC::JSValue::decode(JSValue2));
+}
+JSC__JSPromise* JSC__JSPromise__resolvedPromise(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1)
+{
+ return JSC::JSPromise::resolvedPromise(arg0, JSC::JSValue::decode(JSValue1));
+}
+
+JSC__JSValue JSC__JSPromise__result(const JSC__JSPromise* arg0, JSC__VM* arg1)
+{
+ return JSC::JSValue::encode(arg0->result(reinterpret_cast<JSC::VM&>(arg1)));
+}
+uint32_t JSC__JSPromise__status(const JSC__JSPromise* arg0, JSC__VM* arg1)
+{
+ switch (arg0->status(reinterpret_cast<JSC::VM&>(arg1))) {
+ case JSC::JSPromise::Status::Pending:
+ return 0;
+ case JSC::JSPromise::Status::Fulfilled:
+ return 1;
+ case JSC::JSPromise::Status::Rejected:
+ return 2;
+ default:
+ return 255;
+ }
}
-bool JSC__JSPromise__isHandled(const JSC__JSPromise *arg0, JSC__VM *arg1) {
- return arg0->isHandled(reinterpret_cast<JSC::VM &>(arg1));
+bool JSC__JSPromise__isHandled(const JSC__JSPromise* arg0, JSC__VM* arg1)
+{
+ return arg0->isHandled(reinterpret_cast<JSC::VM&>(arg1));
}
#pragma mark - JSC::JSInternalPromise
-JSC__JSInternalPromise *JSC__JSInternalPromise__create(JSC__JSGlobalObject *globalObject) {
- JSC::VM &vm = globalObject->vm();
- return JSC::JSInternalPromise::create(vm, globalObject->internalPromiseStructure());
-}
-
-void JSC__JSInternalPromise__reject(JSC__JSInternalPromise *arg0, JSC__JSGlobalObject *arg1,
- JSC__JSValue JSValue2) {
- arg0->reject(arg1, JSC::JSValue::decode(JSValue2));
-}
-void JSC__JSInternalPromise__rejectAsHandled(JSC__JSInternalPromise *arg0,
- JSC__JSGlobalObject *arg1, JSC__JSValue JSValue2) {
- arg0->rejectAsHandled(arg1, JSC::JSValue::decode(JSValue2));
-}
-void JSC__JSInternalPromise__rejectAsHandledException(JSC__JSInternalPromise *arg0,
- JSC__JSGlobalObject *arg1,
- JSC__Exception *arg2) {
- arg0->rejectAsHandled(arg1, arg2);
-}
-JSC__JSInternalPromise *JSC__JSInternalPromise__rejectedPromise(JSC__JSGlobalObject *arg0,
- JSC__JSValue JSValue1) {
- return reinterpret_cast<JSC::JSInternalPromise *>(
- JSC::JSInternalPromise::rejectedPromise(arg0, JSC::JSValue::decode(JSValue1)));
-}
-
-void JSC__JSInternalPromise__rejectWithCaughtException(JSC__JSInternalPromise *arg0,
- JSC__JSGlobalObject *arg1,
- bJSC__ThrowScope arg2) {
- Wrap<JSC::ThrowScope, bJSC__ThrowScope> wrapped = Wrap<JSC::ThrowScope, bJSC__ThrowScope>(arg2);
-
- arg0->rejectWithCaughtException(arg1, *wrapped.cpp);
-}
-void JSC__JSInternalPromise__resolve(JSC__JSInternalPromise *arg0, JSC__JSGlobalObject *arg1,
- JSC__JSValue JSValue2) {
- arg0->resolve(arg1, JSC::JSValue::decode(JSValue2));
-}
-JSC__JSInternalPromise *JSC__JSInternalPromise__resolvedPromise(JSC__JSGlobalObject *arg0,
- JSC__JSValue JSValue1) {
- return reinterpret_cast<JSC::JSInternalPromise *>(
- JSC::JSInternalPromise::resolvedPromise(arg0, JSC::JSValue::decode(JSValue1)));
-}
-
-JSC__JSValue JSC__JSInternalPromise__result(const JSC__JSInternalPromise *arg0, JSC__VM *arg1) {
- return JSC::JSValue::encode(arg0->result(reinterpret_cast<JSC::VM &>(arg1)));
-}
-uint32_t JSC__JSInternalPromise__status(const JSC__JSInternalPromise *arg0, JSC__VM *arg1) {
- switch (arg0->status(reinterpret_cast<JSC::VM &>(arg1))) {
- case JSC::JSInternalPromise::Status::Pending: return 0;
- case JSC::JSInternalPromise::Status::Fulfilled: return 1;
- case JSC::JSInternalPromise::Status::Rejected: return 2;
- default: return 255;
- }
+JSC__JSInternalPromise* JSC__JSInternalPromise__create(JSC__JSGlobalObject* globalObject)
+{
+ JSC::VM& vm = globalObject->vm();
+ return JSC::JSInternalPromise::create(vm, globalObject->internalPromiseStructure());
+}
+
+void JSC__JSInternalPromise__reject(JSC__JSInternalPromise* arg0, JSC__JSGlobalObject* arg1,
+ JSC__JSValue JSValue2)
+{
+ arg0->reject(arg1, JSC::JSValue::decode(JSValue2));
+}
+void JSC__JSInternalPromise__rejectAsHandled(JSC__JSInternalPromise* arg0,
+ JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2)
+{
+ arg0->rejectAsHandled(arg1, JSC::JSValue::decode(JSValue2));
+}
+void JSC__JSInternalPromise__rejectAsHandledException(JSC__JSInternalPromise* arg0,
+ JSC__JSGlobalObject* arg1,
+ JSC__Exception* arg2)
+{
+ arg0->rejectAsHandled(arg1, arg2);
+}
+JSC__JSInternalPromise* JSC__JSInternalPromise__rejectedPromise(JSC__JSGlobalObject* arg0,
+ JSC__JSValue JSValue1)
+{
+ return reinterpret_cast<JSC::JSInternalPromise*>(
+ JSC::JSInternalPromise::rejectedPromise(arg0, JSC::JSValue::decode(JSValue1)));
+}
+
+void JSC__JSInternalPromise__rejectWithCaughtException(JSC__JSInternalPromise* arg0,
+ JSC__JSGlobalObject* arg1,
+ bJSC__ThrowScope arg2)
+{
+ Wrap<JSC::ThrowScope, bJSC__ThrowScope> wrapped = Wrap<JSC::ThrowScope, bJSC__ThrowScope>(arg2);
+
+ arg0->rejectWithCaughtException(arg1, *wrapped.cpp);
+}
+void JSC__JSInternalPromise__resolve(JSC__JSInternalPromise* arg0, JSC__JSGlobalObject* arg1,
+ JSC__JSValue JSValue2)
+{
+ arg0->resolve(arg1, JSC::JSValue::decode(JSValue2));
+}
+JSC__JSInternalPromise* JSC__JSInternalPromise__resolvedPromise(JSC__JSGlobalObject* arg0,
+ JSC__JSValue JSValue1)
+{
+ return reinterpret_cast<JSC::JSInternalPromise*>(
+ JSC::JSInternalPromise::resolvedPromise(arg0, JSC::JSValue::decode(JSValue1)));
+}
+
+JSC__JSValue JSC__JSInternalPromise__result(const JSC__JSInternalPromise* arg0, JSC__VM* arg1)
+{
+ return JSC::JSValue::encode(arg0->result(reinterpret_cast<JSC::VM&>(arg1)));
+}
+uint32_t JSC__JSInternalPromise__status(const JSC__JSInternalPromise* arg0, JSC__VM* arg1)
+{
+ switch (arg0->status(reinterpret_cast<JSC::VM&>(arg1))) {
+ case JSC::JSInternalPromise::Status::Pending:
+ return 0;
+ case JSC::JSInternalPromise::Status::Fulfilled:
+ return 1;
+ case JSC::JSInternalPromise::Status::Rejected:
+ return 2;
+ default:
+ return 255;
+ }
}
-bool JSC__JSInternalPromise__isHandled(const JSC__JSInternalPromise *arg0, JSC__VM *arg1) {
- return arg0->isHandled(reinterpret_cast<JSC::VM &>(arg1));
+bool JSC__JSInternalPromise__isHandled(const JSC__JSInternalPromise* arg0, JSC__VM* arg1)
+{
+ return arg0->isHandled(reinterpret_cast<JSC::VM&>(arg1));
}
-JSC__JSInternalPromise *JSC__JSInternalPromise__then(JSC__JSInternalPromise *arg0,
- JSC__JSGlobalObject *arg1,
- JSC__JSFunction *arg2, JSC__JSFunction *arg3) {
- return arg0->then(arg1, arg2, arg3);
+JSC__JSInternalPromise* JSC__JSInternalPromise__then(JSC__JSInternalPromise* arg0,
+ JSC__JSGlobalObject* arg1,
+ JSC__JSFunction* arg2, JSC__JSFunction* arg3)
+{
+ return arg0->then(arg1, arg2, arg3);
}
// bool JSC__JSPromise__isInternal(JSC__JSPromise* arg0, JSC__VM* arg1) {
@@ -874,11 +966,12 @@ JSC__JSInternalPromise *JSC__JSInternalPromise__then(JSC__JSInternalPromise *arg
#pragma mark - JSC::SourceOrigin
-bJSC__SourceOrigin JSC__SourceOrigin__fromURL(const WTF__URL *arg0) {
+bJSC__SourceOrigin JSC__SourceOrigin__fromURL(const WTF__URL* arg0)
+{
- Wrap<JSC::SourceOrigin, bJSC__SourceOrigin> wrap;
- wrap.cpp = new (&wrap.result.bytes) JSC::SourceOrigin(WTF::URL(*arg0));
- return wrap.result;
+ Wrap<JSC::SourceOrigin, bJSC__SourceOrigin> wrap;
+ wrap.cpp = new (&wrap.result.bytes) JSC::SourceOrigin(WTF::URL(*arg0));
+ return wrap.result;
}
#pragma mark - JSC::SourceCode
@@ -911,83 +1004,92 @@ bJSC__SourceOrigin JSC__SourceOrigin__fromURL(const WTF__URL *arg0) {
// }
// };
-void JSC__SourceCode__fromString(JSC__SourceCode *arg0, const WTF__String *arg1,
- const JSC__SourceOrigin *arg2, WTF__String *arg3,
- unsigned char SourceType4) {}
+void JSC__SourceCode__fromString(JSC__SourceCode* arg0, const WTF__String* arg1,
+ const JSC__SourceOrigin* arg2, WTF__String* arg3,
+ unsigned char SourceType4) {}
#pragma mark - JSC::JSFunction
-JSC__JSValue JSC__JSFunction__callWithArguments(JSC__JSValue JSValue0, JSC__JSGlobalObject *arg1,
- JSC__JSValue *arg2, size_t arg3,
- JSC__Exception **arg4, const unsigned char *arg5) {
- auto args = makeArgs(arg2, arg3);
- return JSC::JSValue::encode(JSC::call(arg1, JSC::JSValue::decode(JSValue0),
- JSC::JSValue::decode(JSValue0), args, (const char *)arg5));
+JSC__JSValue JSC__JSFunction__callWithArguments(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1,
+ JSC__JSValue* arg2, size_t arg3,
+ JSC__Exception** arg4, const unsigned char* arg5)
+{
+ auto args = makeArgs(arg2, arg3);
+ return JSC::JSValue::encode(JSC::call(arg1, JSC::JSValue::decode(JSValue0),
+ JSC::JSValue::decode(JSValue0), args, (const char*)arg5));
}
JSC__JSValue JSC__JSFunction__callWithArgumentsAndThis(JSC__JSValue JSValue0, JSC__JSValue JSValue1,
- JSC__JSGlobalObject *arg2,
- JSC__JSValue *arg3, size_t arg4,
- JSC__Exception **arg5,
- const unsigned char *arg6) {
- auto args = makeArgs(arg3, arg4);
- return JSC::JSValue::encode(JSC::call(arg2, JSC::JSValue::decode(JSValue0),
- JSC::JSValue::decode(JSValue1), args, (const char *)arg6));
+ JSC__JSGlobalObject* arg2,
+ JSC__JSValue* arg3, size_t arg4,
+ JSC__Exception** arg5,
+ const unsigned char* arg6)
+{
+ auto args = makeArgs(arg3, arg4);
+ return JSC::JSValue::encode(JSC::call(arg2, JSC::JSValue::decode(JSValue0),
+ JSC::JSValue::decode(JSValue1), args, (const char*)arg6));
}
JSC__JSValue JSC__JSFunction__callWithoutAnyArgumentsOrThis(JSC__JSValue JSValue0,
- JSC__JSGlobalObject *arg1,
- JSC__Exception **arg2,
- const unsigned char *arg3) {
- return JSC::JSValue::encode(JSC::call(arg1, JSC::JSValue::decode(JSValue0),
- JSC::JSValue::decode(JSValue0), JSC::ArgList(),
- (const char *)arg3));
-}
-JSC__JSValue JSC__JSFunction__callWithThis(JSC__JSValue JSValue0, JSC__JSGlobalObject *arg1,
- JSC__JSValue JSValue2, JSC__Exception **arg3,
- const unsigned char *arg4) {
- return JSC::JSValue::encode(JSC::call(arg1, JSC::JSValue::decode(JSValue0),
- JSC::JSValue::decode(JSValue2), JSC::ArgList(),
- (const char *)arg4));
+ JSC__JSGlobalObject* arg1,
+ JSC__Exception** arg2,
+ const unsigned char* arg3)
+{
+ return JSC::JSValue::encode(JSC::call(arg1, JSC::JSValue::decode(JSValue0),
+ JSC::JSValue::decode(JSValue0), JSC::ArgList(),
+ (const char*)arg3));
+}
+JSC__JSValue JSC__JSFunction__callWithThis(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1,
+ JSC__JSValue JSValue2, JSC__Exception** arg3,
+ const unsigned char* arg4)
+{
+ return JSC::JSValue::encode(JSC::call(arg1, JSC::JSValue::decode(JSValue0),
+ JSC::JSValue::decode(JSValue2), JSC::ArgList(),
+ (const char*)arg4));
}
JSC__JSValue JSC__JSFunction__constructWithArguments(JSC__JSValue JSValue0,
- JSC__JSGlobalObject *arg1, JSC__JSValue *arg2,
- size_t arg3, JSC__Exception **arg4,
- const unsigned char *arg5) {
- auto args = makeArgs(arg2, arg3);
- return JSC::JSValue::encode(
- JSC::construct(arg1, JSC::JSValue::decode(JSValue0), args, (const char *)arg5));
+ JSC__JSGlobalObject* arg1, JSC__JSValue* arg2,
+ size_t arg3, JSC__Exception** arg4,
+ const unsigned char* arg5)
+{
+ auto args = makeArgs(arg2, arg3);
+ return JSC::JSValue::encode(
+ JSC::construct(arg1, JSC::JSValue::decode(JSValue0), args, (const char*)arg5));
}
JSC__JSValue JSC__JSFunction__constructWithArgumentsAndNewTarget(
- JSC__JSValue JSValue0, JSC__JSValue JSValue1, JSC__JSGlobalObject *arg2, JSC__JSValue *arg3,
- size_t arg4, JSC__Exception **arg5, const unsigned char *arg6) {
- auto args = makeArgs(arg3, arg4);
- return JSC::JSValue::encode(JSC::construct(arg2, JSC::JSValue::decode(JSValue0),
- JSC::JSValue::decode(JSValue0), args,
- (const char *)arg6));
+ JSC__JSValue JSValue0, JSC__JSValue JSValue1, JSC__JSGlobalObject* arg2, JSC__JSValue* arg3,
+ size_t arg4, JSC__Exception** arg5, const unsigned char* arg6)
+{
+ auto args = makeArgs(arg3, arg4);
+ return JSC::JSValue::encode(JSC::construct(arg2, JSC::JSValue::decode(JSValue0),
+ JSC::JSValue::decode(JSValue0), args,
+ (const char*)arg6));
}
JSC__JSValue JSC__JSFunction__constructWithNewTarget(JSC__JSValue JSValue0,
- JSC__JSGlobalObject *arg1,
- JSC__JSValue JSValue2, JSC__Exception **arg3,
- const unsigned char *arg4) {
- return JSC::JSValue::encode(JSC::construct(arg1, JSC::JSValue::decode(JSValue0),
- JSC::JSValue::decode(JSValue2), JSC::ArgList(),
- (const char *)arg4));
+ JSC__JSGlobalObject* arg1,
+ JSC__JSValue JSValue2, JSC__Exception** arg3,
+ const unsigned char* arg4)
+{
+ return JSC::JSValue::encode(JSC::construct(arg1, JSC::JSValue::decode(JSValue0),
+ JSC::JSValue::decode(JSValue2), JSC::ArgList(),
+ (const char*)arg4));
}
JSC__JSValue JSC__JSFunction__constructWithoutAnyArgumentsOrNewTarget(JSC__JSValue JSValue0,
- JSC__JSGlobalObject *arg1,
- JSC__Exception **arg2,
- const unsigned char *arg3) {
- return JSC::JSValue::encode(
- JSC::construct(arg1, JSC::JSValue::decode(JSValue0), JSC::ArgList(), (const char *)arg3));
-}
-
-JSC__JSFunction *JSC__JSFunction__createFromNative(JSC__JSGlobalObject *arg0, uint16_t arg1,
- const WTF__String *arg2, void *ctx,
- NativeCallbackFunction callback) {
- return JSC::JSNativeStdFunction::create(
- reinterpret_cast<JSC::VM &>(arg0->vm()), arg0, arg1, arg2 != nullptr ? *arg2 : WTF::String(),
- [ctx, callback](JSC::JSGlobalObject *globalObject, JSC::CallFrame *callFrame)
- -> JSC::EncodedJSValue { return callback(ctx, globalObject, callFrame); });
+ JSC__JSGlobalObject* arg1,
+ JSC__Exception** arg2,
+ const unsigned char* arg3)
+{
+ return JSC::JSValue::encode(
+ JSC::construct(arg1, JSC::JSValue::decode(JSValue0), JSC::ArgList(), (const char*)arg3));
+}
+
+JSC__JSFunction* JSC__JSFunction__createFromNative(JSC__JSGlobalObject* arg0, uint16_t arg1,
+ const WTF__String* arg2, void* ctx,
+ NativeCallbackFunction callback)
+{
+ return JSC::JSNativeStdFunction::create(
+ reinterpret_cast<JSC::VM&>(arg0->vm()), arg0, arg1, arg2 != nullptr ? *arg2 : WTF::String(),
+ [ctx, callback](JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame)
+ -> JSC::EncodedJSValue { return callback(ctx, globalObject, callFrame); });
}
// JSC__JSFunction* JSC__JSFunction__createFromSourceCode(
// JSC__JSGlobalObject* arg0,
@@ -1016,517 +1118,601 @@ JSC__JSFunction *JSC__JSFunction__createFromNative(JSC__JSGlobalObject *arg0, ui
// }
-bWTF__String JSC__JSFunction__displayName(JSC__JSFunction *arg0, JSC__VM *arg1) {
- auto wrap = Wrap<WTF::String, bWTF__String>(arg0->displayName(reinterpret_cast<JSC::VM &>(arg1)));
- return wrap.result;
+bWTF__String JSC__JSFunction__displayName(JSC__JSFunction* arg0, JSC__VM* arg1)
+{
+ auto wrap = Wrap<WTF::String, bWTF__String>(arg0->displayName(reinterpret_cast<JSC::VM&>(arg1)));
+ return wrap.result;
};
-bWTF__String JSC__JSFunction__getName(JSC__JSFunction *arg0, JSC__VM *arg1) {
- auto wrap = Wrap<WTF::String, bWTF__String>(arg0->name(reinterpret_cast<JSC::VM &>(arg1)));
- return wrap.result;
+bWTF__String JSC__JSFunction__getName(JSC__JSFunction* arg0, JSC__VM* arg1)
+{
+ auto wrap = Wrap<WTF::String, bWTF__String>(arg0->name(reinterpret_cast<JSC::VM&>(arg1)));
+ return wrap.result;
};
-bWTF__String JSC__JSFunction__calculatedDisplayName(JSC__JSFunction *arg0, JSC__VM *arg1) {
- auto wrap =
- Wrap<WTF::String, bWTF__String>(arg0->calculatedDisplayName(reinterpret_cast<JSC::VM &>(arg1)));
- return wrap.result;
+bWTF__String JSC__JSFunction__calculatedDisplayName(JSC__JSFunction* arg0, JSC__VM* arg1)
+{
+ auto wrap = Wrap<WTF::String, bWTF__String>(arg0->calculatedDisplayName(reinterpret_cast<JSC::VM&>(arg1)));
+ return wrap.result;
};
#pragma mark - JSC::JSGlobalObject
-JSC__JSValue JSC__JSGlobalObject__generateHeapSnapshot(JSC__JSGlobalObject *globalObject) {
- JSC::VM &vm = globalObject->vm();
+JSC__JSValue JSC__JSGlobalObject__generateHeapSnapshot(JSC__JSGlobalObject* globalObject)
+{
+ JSC::VM& vm = globalObject->vm();
- JSC::JSLockHolder lock(vm);
- // JSC::DeferTermination deferScope(vm);
- auto scope = DECLARE_THROW_SCOPE(vm);
+ JSC::JSLockHolder lock(vm);
+ // JSC::DeferTermination deferScope(vm);
+ auto scope = DECLARE_THROW_SCOPE(vm);
- JSC::HeapSnapshotBuilder snapshotBuilder(vm.ensureHeapProfiler());
- snapshotBuilder.buildSnapshot();
+ JSC::HeapSnapshotBuilder snapshotBuilder(vm.ensureHeapProfiler());
+ snapshotBuilder.buildSnapshot();
- WTF::String jsonString = snapshotBuilder.json();
- JSC::EncodedJSValue result = JSC::JSValue::encode(JSONParse(globalObject, jsonString));
- scope.releaseAssertNoException();
- return result;
+ WTF::String jsonString = snapshotBuilder.json();
+ JSC::EncodedJSValue result = JSC::JSValue::encode(JSONParse(globalObject, jsonString));
+ scope.releaseAssertNoException();
+ return result;
}
-JSC__ArrayIteratorPrototype *
-JSC__JSGlobalObject__arrayIteratorPrototype(JSC__JSGlobalObject *arg0) {
- return arg0->arrayIteratorPrototype();
-};
-JSC__ArrayPrototype *JSC__JSGlobalObject__arrayPrototype(JSC__JSGlobalObject *arg0) {
- return arg0->arrayPrototype();
+JSC__ArrayIteratorPrototype*
+JSC__JSGlobalObject__arrayIteratorPrototype(JSC__JSGlobalObject* arg0)
+{
+ return arg0->arrayIteratorPrototype();
};
-JSC__AsyncFunctionPrototype *
-JSC__JSGlobalObject__asyncFunctionPrototype(JSC__JSGlobalObject *arg0) {
- return arg0->asyncFunctionPrototype();
+JSC__ArrayPrototype* JSC__JSGlobalObject__arrayPrototype(JSC__JSGlobalObject* arg0)
+{
+ return arg0->arrayPrototype();
};
-JSC__AsyncGeneratorFunctionPrototype *
-JSC__JSGlobalObject__asyncGeneratorFunctionPrototype(JSC__JSGlobalObject *arg0) {
- return arg0->asyncGeneratorFunctionPrototype();
+JSC__AsyncFunctionPrototype*
+JSC__JSGlobalObject__asyncFunctionPrototype(JSC__JSGlobalObject* arg0)
+{
+ return arg0->asyncFunctionPrototype();
};
-JSC__AsyncGeneratorPrototype *
-JSC__JSGlobalObject__asyncGeneratorPrototype(JSC__JSGlobalObject *arg0) {
- return arg0->asyncGeneratorPrototype();
+JSC__AsyncGeneratorFunctionPrototype*
+JSC__JSGlobalObject__asyncGeneratorFunctionPrototype(JSC__JSGlobalObject* arg0)
+{
+ return arg0->asyncGeneratorFunctionPrototype();
};
-JSC__AsyncIteratorPrototype *
-JSC__JSGlobalObject__asyncIteratorPrototype(JSC__JSGlobalObject *arg0) {
- return arg0->asyncIteratorPrototype();
+JSC__AsyncGeneratorPrototype*
+JSC__JSGlobalObject__asyncGeneratorPrototype(JSC__JSGlobalObject* arg0)
+{
+ return arg0->asyncGeneratorPrototype();
};
-JSC__BigIntPrototype *JSC__JSGlobalObject__bigIntPrototype(JSC__JSGlobalObject *arg0) {
- return arg0->bigIntPrototype();
+JSC__AsyncIteratorPrototype*
+JSC__JSGlobalObject__asyncIteratorPrototype(JSC__JSGlobalObject* arg0)
+{
+ return arg0->asyncIteratorPrototype();
};
-JSC__JSObject *JSC__JSGlobalObject__booleanPrototype(JSC__JSGlobalObject *arg0) {
- return arg0->booleanPrototype();
+JSC__BigIntPrototype* JSC__JSGlobalObject__bigIntPrototype(JSC__JSGlobalObject* arg0)
+{
+ return arg0->bigIntPrototype();
};
-JSC__JSObject *JSC__JSGlobalObject__datePrototype(JSC__JSGlobalObject *arg0) {
- return arg0->datePrototype();
+JSC__JSObject* JSC__JSGlobalObject__booleanPrototype(JSC__JSGlobalObject* arg0)
+{
+ return arg0->booleanPrototype();
};
-JSC__JSObject *JSC__JSGlobalObject__errorPrototype(JSC__JSGlobalObject *arg0) {
- return arg0->errorPrototype();
+JSC__JSObject* JSC__JSGlobalObject__datePrototype(JSC__JSGlobalObject* arg0)
+{
+ return arg0->datePrototype();
};
-JSC__FunctionPrototype *JSC__JSGlobalObject__functionPrototype(JSC__JSGlobalObject *arg0) {
- return arg0->functionPrototype();
+JSC__JSObject* JSC__JSGlobalObject__errorPrototype(JSC__JSGlobalObject* arg0)
+{
+ return arg0->errorPrototype();
};
-JSC__GeneratorFunctionPrototype *
-JSC__JSGlobalObject__generatorFunctionPrototype(JSC__JSGlobalObject *arg0) {
- return arg0->generatorFunctionPrototype();
+JSC__FunctionPrototype* JSC__JSGlobalObject__functionPrototype(JSC__JSGlobalObject* arg0)
+{
+ return arg0->functionPrototype();
};
-JSC__GeneratorPrototype *JSC__JSGlobalObject__generatorPrototype(JSC__JSGlobalObject *arg0) {
- return arg0->generatorPrototype();
+JSC__GeneratorFunctionPrototype*
+JSC__JSGlobalObject__generatorFunctionPrototype(JSC__JSGlobalObject* arg0)
+{
+ return arg0->generatorFunctionPrototype();
};
-JSC__IteratorPrototype *JSC__JSGlobalObject__iteratorPrototype(JSC__JSGlobalObject *arg0) {
- return arg0->iteratorPrototype();
+JSC__GeneratorPrototype* JSC__JSGlobalObject__generatorPrototype(JSC__JSGlobalObject* arg0)
+{
+ return arg0->generatorPrototype();
};
-JSC__JSObject *JSC__JSGlobalObject__jsSetPrototype(JSC__JSGlobalObject *arg0) {
- return arg0->jsSetPrototype();
+JSC__IteratorPrototype* JSC__JSGlobalObject__iteratorPrototype(JSC__JSGlobalObject* arg0)
+{
+ return arg0->iteratorPrototype();
};
-JSC__MapIteratorPrototype *JSC__JSGlobalObject__mapIteratorPrototype(JSC__JSGlobalObject *arg0) {
- return arg0->mapIteratorPrototype();
+JSC__JSObject* JSC__JSGlobalObject__jsSetPrototype(JSC__JSGlobalObject* arg0)
+{
+ return arg0->jsSetPrototype();
};
-JSC__JSObject *JSC__JSGlobalObject__mapPrototype(JSC__JSGlobalObject *arg0) {
- return arg0->mapPrototype();
+JSC__MapIteratorPrototype* JSC__JSGlobalObject__mapIteratorPrototype(JSC__JSGlobalObject* arg0)
+{
+ return arg0->mapIteratorPrototype();
};
-JSC__JSObject *JSC__JSGlobalObject__numberPrototype(JSC__JSGlobalObject *arg0) {
- return arg0->numberPrototype();
+JSC__JSObject* JSC__JSGlobalObject__mapPrototype(JSC__JSGlobalObject* arg0)
+{
+ return arg0->mapPrototype();
};
-JSC__ObjectPrototype *JSC__JSGlobalObject__objectPrototype(JSC__JSGlobalObject *arg0) {
- return arg0->objectPrototype();
+JSC__JSObject* JSC__JSGlobalObject__numberPrototype(JSC__JSGlobalObject* arg0)
+{
+ return arg0->numberPrototype();
};
-JSC__JSPromisePrototype *JSC__JSGlobalObject__promisePrototype(JSC__JSGlobalObject *arg0) {
- return arg0->promisePrototype();
+JSC__ObjectPrototype* JSC__JSGlobalObject__objectPrototype(JSC__JSGlobalObject* arg0)
+{
+ return arg0->objectPrototype();
};
-JSC__RegExpPrototype *JSC__JSGlobalObject__regExpPrototype(JSC__JSGlobalObject *arg0) {
- return arg0->regExpPrototype();
+JSC__JSPromisePrototype* JSC__JSGlobalObject__promisePrototype(JSC__JSGlobalObject* arg0)
+{
+ return arg0->promisePrototype();
};
-JSC__SetIteratorPrototype *JSC__JSGlobalObject__setIteratorPrototype(JSC__JSGlobalObject *arg0) {
- return arg0->setIteratorPrototype();
+JSC__RegExpPrototype* JSC__JSGlobalObject__regExpPrototype(JSC__JSGlobalObject* arg0)
+{
+ return arg0->regExpPrototype();
};
-JSC__StringPrototype *JSC__JSGlobalObject__stringPrototype(JSC__JSGlobalObject *arg0) {
- return arg0->stringPrototype();
+JSC__SetIteratorPrototype* JSC__JSGlobalObject__setIteratorPrototype(JSC__JSGlobalObject* arg0)
+{
+ return arg0->setIteratorPrototype();
};
-JSC__JSObject *JSC__JSGlobalObject__symbolPrototype(JSC__JSGlobalObject *arg0) {
- return arg0->symbolPrototype();
+JSC__StringPrototype* JSC__JSGlobalObject__stringPrototype(JSC__JSGlobalObject* arg0)
+{
+ return arg0->stringPrototype();
+};
+JSC__JSObject* JSC__JSGlobalObject__symbolPrototype(JSC__JSGlobalObject* arg0)
+{
+ return arg0->symbolPrototype();
};
-JSC__VM *JSC__JSGlobalObject__vm(JSC__JSGlobalObject *arg0) { return &arg0->vm(); };
- // JSC__JSObject* JSC__JSGlobalObject__createError(JSC__JSGlobalObject* arg0,
- // unsigned char ErrorType1, WTF__String* arg2) {}; JSC__JSObject*
- // JSC__JSGlobalObject__throwError(JSC__JSGlobalObject* arg0, JSC__JSObject*
- // arg1) {};
+JSC__VM* JSC__JSGlobalObject__vm(JSC__JSGlobalObject* arg0) { return &arg0->vm(); };
+ // JSC__JSObject* JSC__JSGlobalObject__createError(JSC__JSGlobalObject* arg0,
+ // unsigned char ErrorType1, WTF__String* arg2) {}; JSC__JSObject*
+ // JSC__JSGlobalObject__throwError(JSC__JSGlobalObject* arg0, JSC__JSObject*
+ // arg1) {};
#pragma mark - JSC::JSValue
-JSC__JSCell *JSC__JSValue__asCell(JSC__JSValue JSValue0) {
- auto value = JSC::JSValue::decode(JSValue0);
- return value.asCell();
+JSC__JSCell* JSC__JSValue__asCell(JSC__JSValue JSValue0)
+{
+ auto value = JSC::JSValue::decode(JSValue0);
+ return value.asCell();
}
-double JSC__JSValue__asNumber(JSC__JSValue JSValue0) {
- auto value = JSC::JSValue::decode(JSValue0);
- return value.asNumber();
+double JSC__JSValue__asNumber(JSC__JSValue JSValue0)
+{
+ auto value = JSC::JSValue::decode(JSValue0);
+ return value.asNumber();
};
-bJSC__JSObject JSC__JSValue__asObject(JSC__JSValue JSValue0) {
- auto value = JSC::JSValue::decode(JSValue0);
- auto obj = JSC::asObject(value);
- return cast<bJSC__JSObject>(&obj);
+bJSC__JSObject JSC__JSValue__asObject(JSC__JSValue JSValue0)
+{
+ auto value = JSC::JSValue::decode(JSValue0);
+ auto obj = JSC::asObject(value);
+ return cast<bJSC__JSObject>(&obj);
};
-JSC__JSString *JSC__JSValue__asString(JSC__JSValue JSValue0) {
- auto value = JSC::JSValue::decode(JSValue0);
- return JSC::asString(value);
+JSC__JSString* JSC__JSValue__asString(JSC__JSValue JSValue0)
+{
+ auto value = JSC::JSValue::decode(JSValue0);
+ return JSC::asString(value);
};
// uint64_t JSC__JSValue__encode(JSC__JSValue JSValue0) {
// }
-bool JSC__JSValue__eqlCell(JSC__JSValue JSValue0, JSC__JSCell *arg1) {
- return JSC::JSValue::decode(JSValue0) == arg1;
+bool JSC__JSValue__eqlCell(JSC__JSValue JSValue0, JSC__JSCell* arg1)
+{
+ return JSC::JSValue::decode(JSValue0) == arg1;
};
-bool JSC__JSValue__eqlValue(JSC__JSValue JSValue0, JSC__JSValue JSValue1) {
- return JSC::JSValue::decode(JSValue0) == JSC::JSValue::decode(JSValue1);
+bool JSC__JSValue__eqlValue(JSC__JSValue JSValue0, JSC__JSValue JSValue1)
+{
+ return JSC::JSValue::decode(JSValue0) == JSC::JSValue::decode(JSValue1);
};
-JSC__JSValue JSC__JSValue__getPrototype(JSC__JSValue JSValue0, JSC__JSGlobalObject *arg1) {
- auto value = JSC::JSValue::decode(JSValue0);
- return JSC::JSValue::encode(value.getPrototype(arg1));
+JSC__JSValue JSC__JSValue__getPrototype(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1)
+{
+ auto value = JSC::JSValue::decode(JSValue0);
+ return JSC::JSValue::encode(value.getPrototype(arg1));
}
-bool JSC__JSValue__isException(JSC__JSValue JSValue0, JSC__VM *arg1) {
- return JSC::jsDynamicCast<JSC::Exception *>(*arg1, JSC::JSValue::decode(JSValue0)) != nullptr;
+bool JSC__JSValue__isException(JSC__JSValue JSValue0, JSC__VM* arg1)
+{
+ return JSC::jsDynamicCast<JSC::Exception*>(*arg1, JSC::JSValue::decode(JSValue0)) != nullptr;
}
-bool JSC__JSValue__isAnyInt(JSC__JSValue JSValue0) {
- return JSC::JSValue::decode(JSValue0).isAnyInt();
+bool JSC__JSValue__isAnyInt(JSC__JSValue JSValue0)
+{
+ return JSC::JSValue::decode(JSValue0).isAnyInt();
}
-bool JSC__JSValue__isBigInt(JSC__JSValue JSValue0) {
- return JSC::JSValue::decode(JSValue0).isBigInt();
+bool JSC__JSValue__isBigInt(JSC__JSValue JSValue0)
+{
+ return JSC::JSValue::decode(JSValue0).isBigInt();
}
-bool JSC__JSValue__isBigInt32(JSC__JSValue JSValue0) {
- return JSC::JSValue::decode(JSValue0).isBigInt32();
+bool JSC__JSValue__isBigInt32(JSC__JSValue JSValue0)
+{
+ return JSC::JSValue::decode(JSValue0).isBigInt32();
}
-bool JSC__JSValue__isBoolean(JSC__JSValue JSValue0) {
- return JSC::JSValue::decode(JSValue0).isBoolean();
+bool JSC__JSValue__isBoolean(JSC__JSValue JSValue0)
+{
+ return JSC::JSValue::decode(JSValue0).isBoolean();
}
-bool JSC__JSValue__isClass(JSC__JSValue JSValue0, JSC__JSGlobalObject *arg1) {
- JSC::JSValue value = JSC::JSValue::decode(JSValue0);
- return value.isConstructor(arg1->vm());
+bool JSC__JSValue__isClass(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1)
+{
+ JSC::JSValue value = JSC::JSValue::decode(JSValue0);
+ return value.isConstructor(arg1->vm());
}
bool JSC__JSValue__isCell(JSC__JSValue JSValue0) { return JSC::JSValue::decode(JSValue0).isCell(); }
-bool JSC__JSValue__isCustomGetterSetter(JSC__JSValue JSValue0) {
- return JSC::JSValue::decode(JSValue0).isCustomGetterSetter();
+bool JSC__JSValue__isCustomGetterSetter(JSC__JSValue JSValue0)
+{
+ return JSC::JSValue::decode(JSValue0).isCustomGetterSetter();
}
-bool JSC__JSValue__isError(JSC__JSValue JSValue0) {
- JSC::JSObject *obj = JSC::JSValue::decode(JSValue0).getObject();
- return obj != nullptr && obj->isErrorInstance();
+bool JSC__JSValue__isError(JSC__JSValue JSValue0)
+{
+ JSC::JSObject* obj = JSC::JSValue::decode(JSValue0).getObject();
+ return obj != nullptr && obj->isErrorInstance();
}
-bool JSC__JSValue__isAggregateError(JSC__JSValue JSValue0, JSC__JSGlobalObject *global) {
- JSC::JSObject *obj = JSC::JSValue::decode(JSValue0).getObject();
+bool JSC__JSValue__isAggregateError(JSC__JSValue JSValue0, JSC__JSGlobalObject* global)
+{
+ JSC::JSObject* obj = JSC::JSValue::decode(JSValue0).getObject();
- if (obj != nullptr) {
- if (JSC::ErrorInstance *err = JSC::jsDynamicCast<JSC::ErrorInstance *>(global->vm(), obj)) {
- return err->errorType() == JSC::ErrorType::AggregateError;
+ if (obj != nullptr) {
+ if (JSC::ErrorInstance* err = JSC::jsDynamicCast<JSC::ErrorInstance*>(global->vm(), obj)) {
+ return err->errorType() == JSC::ErrorType::AggregateError;
+ }
}
- }
- return false;
+ return false;
}
-bool JSC__JSValue__isIterable(JSC__JSValue JSValue, JSC__JSGlobalObject *global) {
- return JSC::hasIteratorMethod(global, JSC::JSValue::decode(JSValue));
+bool JSC__JSValue__isIterable(JSC__JSValue JSValue, JSC__JSGlobalObject* global)
+{
+ return JSC::hasIteratorMethod(global, JSC::JSValue::decode(JSValue));
}
-void JSC__JSValue__forEach(JSC__JSValue JSValue0, JSC__JSGlobalObject *arg1,
- void (*ArgFn2)(JSC__VM *arg0, JSC__JSGlobalObject *arg1,
- JSC__JSValue JSValue2)) {
- JSC::forEachInIterable(
- arg1, JSC::JSValue::decode(JSValue0),
- [ArgFn2](JSC::VM &vm, JSC::JSGlobalObject *global, JSC::JSValue value) -> void {
- ArgFn2(&vm, global, JSC::JSValue::encode(value));
- });
+void JSC__JSValue__forEach(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1,
+ void (*ArgFn2)(JSC__VM* arg0, JSC__JSGlobalObject* arg1,
+ JSC__JSValue JSValue2))
+{
+ JSC::forEachInIterable(
+ arg1, JSC::JSValue::decode(JSValue0),
+ [ArgFn2](JSC::VM& vm, JSC::JSGlobalObject* global, JSC::JSValue value) -> void {
+ ArgFn2(&vm, global, JSC::JSValue::encode(value));
+ });
}
-bool JSC__JSValue__isCallable(JSC__JSValue JSValue0, JSC__VM *arg1) {
- return JSC::JSValue::decode(JSValue0).isCallable(reinterpret_cast<JSC::VM &>(arg1));
+bool JSC__JSValue__isCallable(JSC__JSValue JSValue0, JSC__VM* arg1)
+{
+ return JSC::JSValue::decode(JSValue0).isCallable(reinterpret_cast<JSC::VM&>(arg1));
}
-bool JSC__JSValue__isGetterSetter(JSC__JSValue JSValue0) {
- return JSC::JSValue::decode(JSValue0).isGetterSetter();
+bool JSC__JSValue__isGetterSetter(JSC__JSValue JSValue0)
+{
+ return JSC::JSValue::decode(JSValue0).isGetterSetter();
}
-bool JSC__JSValue__isHeapBigInt(JSC__JSValue JSValue0) {
- return JSC::JSValue::decode(JSValue0).isHeapBigInt();
+bool JSC__JSValue__isHeapBigInt(JSC__JSValue JSValue0)
+{
+ return JSC::JSValue::decode(JSValue0).isHeapBigInt();
}
-bool JSC__JSValue__isInt32(JSC__JSValue JSValue0) {
- return JSC::JSValue::decode(JSValue0).isInt32();
+bool JSC__JSValue__isInt32(JSC__JSValue JSValue0)
+{
+ return JSC::JSValue::decode(JSValue0).isInt32();
}
-bool JSC__JSValue__isInt32AsAnyInt(JSC__JSValue JSValue0) {
- return JSC::JSValue::decode(JSValue0).isInt32AsAnyInt();
+bool JSC__JSValue__isInt32AsAnyInt(JSC__JSValue JSValue0)
+{
+ return JSC::JSValue::decode(JSValue0).isInt32AsAnyInt();
}
bool JSC__JSValue__isNull(JSC__JSValue JSValue0) { return JSC::JSValue::decode(JSValue0).isNull(); }
-bool JSC__JSValue__isNumber(JSC__JSValue JSValue0) {
- return JSC::JSValue::decode(JSValue0).isNumber();
+bool JSC__JSValue__isNumber(JSC__JSValue JSValue0)
+{
+ return JSC::JSValue::decode(JSValue0).isNumber();
}
-bool JSC__JSValue__isObject(JSC__JSValue JSValue0) {
- return JSC::JSValue::decode(JSValue0).isObject();
+bool JSC__JSValue__isObject(JSC__JSValue JSValue0)
+{
+ return JSC::JSValue::decode(JSValue0).isObject();
}
-bool JSC__JSValue__isPrimitive(JSC__JSValue JSValue0) {
- return JSC::JSValue::decode(JSValue0).isPrimitive();
+bool JSC__JSValue__isPrimitive(JSC__JSValue JSValue0)
+{
+ return JSC::JSValue::decode(JSValue0).isPrimitive();
}
-bool JSC__JSValue__isString(JSC__JSValue JSValue0) {
- return JSC::JSValue::decode(JSValue0).isString();
+bool JSC__JSValue__isString(JSC__JSValue JSValue0)
+{
+ return JSC::JSValue::decode(JSValue0).isString();
}
-bool JSC__JSValue__isSymbol(JSC__JSValue JSValue0) {
- return JSC::JSValue::decode(JSValue0).isSymbol();
+bool JSC__JSValue__isSymbol(JSC__JSValue JSValue0)
+{
+ return JSC::JSValue::decode(JSValue0).isSymbol();
}
-bool JSC__JSValue__isUInt32AsAnyInt(JSC__JSValue JSValue0) {
- return JSC::JSValue::decode(JSValue0).isUInt32AsAnyInt();
+bool JSC__JSValue__isUInt32AsAnyInt(JSC__JSValue JSValue0)
+{
+ return JSC::JSValue::decode(JSValue0).isUInt32AsAnyInt();
}
-bool JSC__JSValue__isUndefined(JSC__JSValue JSValue0) {
- return JSC::JSValue::decode(JSValue0).isUndefined();
+bool JSC__JSValue__isUndefined(JSC__JSValue JSValue0)
+{
+ return JSC::JSValue::decode(JSValue0).isUndefined();
}
-bool JSC__JSValue__isUndefinedOrNull(JSC__JSValue JSValue0) {
- return JSC::JSValue::decode(JSValue0).isUndefinedOrNull();
+bool JSC__JSValue__isUndefinedOrNull(JSC__JSValue JSValue0)
+{
+ return JSC::JSValue::decode(JSValue0).isUndefinedOrNull();
}
-JSC__JSValue JSC__JSValue__jsBoolean(bool arg0) {
- return JSC::JSValue::encode(JSC::jsBoolean(arg0));
+JSC__JSValue JSC__JSValue__jsBoolean(bool arg0)
+{
+ return JSC::JSValue::encode(JSC::jsBoolean(arg0));
};
-JSC__JSValue JSC__JSValue__jsDoubleNumber(double arg0) {
- return JSC::JSValue::encode(JSC::jsNumber(arg0));
+JSC__JSValue JSC__JSValue__jsDoubleNumber(double arg0)
+{
+ return JSC::JSValue::encode(JSC::jsNumber(arg0));
}
JSC__JSValue JSC__JSValue__jsNull() { return JSC::JSValue::encode(JSC::jsNull()); };
-JSC__JSValue JSC__JSValue__jsNumberFromChar(unsigned char arg0) {
- return JSC::JSValue::encode(JSC::jsNumber(arg0));
+JSC__JSValue JSC__JSValue__jsNumberFromChar(unsigned char arg0)
+{
+ return JSC::JSValue::encode(JSC::jsNumber(arg0));
};
-JSC__JSValue JSC__JSValue__jsNumberFromDouble(double arg0) {
- return JSC::JSValue::encode(JSC::jsNumber(arg0));
+JSC__JSValue JSC__JSValue__jsNumberFromDouble(double arg0)
+{
+ return JSC::JSValue::encode(JSC::jsNumber(arg0));
};
-JSC__JSValue JSC__JSValue__jsNumberFromInt32(int32_t arg0) {
- return JSC::JSValue::encode(JSC::jsNumber(arg0));
+JSC__JSValue JSC__JSValue__jsNumberFromInt32(int32_t arg0)
+{
+ return JSC::JSValue::encode(JSC::jsNumber(arg0));
};
-JSC__JSValue JSC__JSValue__jsNumberFromInt64(int64_t arg0) {
- return JSC::JSValue::encode(JSC::jsNumber(arg0));
+JSC__JSValue JSC__JSValue__jsNumberFromInt64(int64_t arg0)
+{
+ return JSC::JSValue::encode(JSC::jsNumber(arg0));
};
-JSC__JSValue JSC__JSValue__jsNumberFromU16(uint16_t arg0) {
- return JSC::JSValue::encode(JSC::jsNumber(arg0));
+JSC__JSValue JSC__JSValue__jsNumberFromU16(uint16_t arg0)
+{
+ return JSC::JSValue::encode(JSC::jsNumber(arg0));
};
-JSC__JSValue JSC__JSValue__jsNumberFromUint64(uint64_t arg0) {
- return JSC::JSValue::encode(JSC::jsNumber(arg0));
+JSC__JSValue JSC__JSValue__jsNumberFromUint64(uint64_t arg0)
+{
+ return JSC::JSValue::encode(JSC::jsNumber(arg0));
};
-JSC__JSValue JSC__JSValue__createObject2(JSC__JSGlobalObject *globalObject, const ZigString *arg1,
- const ZigString *arg2, JSC__JSValue JSValue3,
- JSC__JSValue JSValue4) {
- JSC::JSObject *object = JSC::constructEmptyObject(globalObject);
- auto key1 = Zig::toIdentifier(*arg1, globalObject);
- JSC::PropertyDescriptor descriptor1;
- JSC::PropertyDescriptor descriptor2;
+JSC__JSValue JSC__JSValue__createObject2(JSC__JSGlobalObject* globalObject, const ZigString* arg1,
+ const ZigString* arg2, JSC__JSValue JSValue3,
+ JSC__JSValue JSValue4)
+{
+ JSC::JSObject* object = JSC::constructEmptyObject(globalObject);
+ auto key1 = Zig::toIdentifier(*arg1, globalObject);
+ JSC::PropertyDescriptor descriptor1;
+ JSC::PropertyDescriptor descriptor2;
- descriptor1.setEnumerable(1);
- descriptor1.setConfigurable(1);
- descriptor1.setWritable(1);
- descriptor1.setValue(JSC::JSValue::decode(JSValue3));
+ descriptor1.setEnumerable(1);
+ descriptor1.setConfigurable(1);
+ descriptor1.setWritable(1);
+ descriptor1.setValue(JSC::JSValue::decode(JSValue3));
- auto key2 = Zig::toIdentifier(*arg2, globalObject);
+ auto key2 = Zig::toIdentifier(*arg2, globalObject);
- descriptor2.setEnumerable(1);
- descriptor2.setConfigurable(1);
- descriptor2.setWritable(1);
- descriptor2.setValue(JSC::JSValue::decode(JSValue4));
+ descriptor2.setEnumerable(1);
+ descriptor2.setConfigurable(1);
+ descriptor2.setWritable(1);
+ descriptor2.setValue(JSC::JSValue::decode(JSValue4));
- object->methodTable(globalObject->vm())
- ->defineOwnProperty(object, globalObject, key2, descriptor2, true);
- object->methodTable(globalObject->vm())
- ->defineOwnProperty(object, globalObject, key1, descriptor1, true);
+ object->methodTable(globalObject->vm())
+ ->defineOwnProperty(object, globalObject, key2, descriptor2, true);
+ object->methodTable(globalObject->vm())
+ ->defineOwnProperty(object, globalObject, key1, descriptor1, true);
- return JSC::JSValue::encode(object);
+ return JSC::JSValue::encode(object);
}
JSC__JSValue JSC__JSValue__getIfPropertyExistsImpl(JSC__JSValue JSValue0,
- JSC__JSGlobalObject *globalObject,
- const unsigned char *arg1, uint32_t arg2) {
+ JSC__JSGlobalObject* globalObject,
+ const unsigned char* arg1, uint32_t arg2)
+{
- JSC::VM &vm = globalObject->vm();
- JSC::JSObject *object = JSC::JSValue::decode(JSValue0).asCell()->getObject();
- auto propertyName = JSC::PropertyName(
- JSC::Identifier::fromString(vm, reinterpret_cast<const LChar *>(arg1), (int)arg2));
- return JSC::JSValue::encode(object->getIfPropertyExists(globalObject, propertyName));
+ JSC::VM& vm = globalObject->vm();
+ JSC::JSObject* object = JSC::JSValue::decode(JSValue0).asCell()->getObject();
+ auto propertyName = JSC::PropertyName(
+ JSC::Identifier::fromString(vm, reinterpret_cast<const LChar*>(arg1), (int)arg2));
+ return JSC::JSValue::encode(object->getIfPropertyExists(globalObject, propertyName));
}
-bool JSC__JSValue__toBoolean(JSC__JSValue JSValue0) {
- return JSC::JSValue::decode(JSValue0).asBoolean();
+bool JSC__JSValue__toBoolean(JSC__JSValue JSValue0)
+{
+ return JSC::JSValue::decode(JSValue0).asBoolean();
}
-int32_t JSC__JSValue__toInt32(JSC__JSValue JSValue0) {
- return JSC::JSValue::decode(JSValue0).asInt32();
+int32_t JSC__JSValue__toInt32(JSC__JSValue JSValue0)
+{
+ return JSC::JSValue::decode(JSValue0).asInt32();
}
-JSC__JSValue JSC__JSValue__getErrorsProperty(JSC__JSValue JSValue0, JSC__JSGlobalObject *global) {
- JSC::JSObject *obj = JSC::JSValue::decode(JSValue0).getObject();
- return JSC::JSValue::encode(obj->getDirect(global->vm(), global->vm().propertyNames->errors));
+JSC__JSValue JSC__JSValue__getErrorsProperty(JSC__JSValue JSValue0, JSC__JSGlobalObject* global)
+{
+ JSC::JSObject* obj = JSC::JSValue::decode(JSValue0).getObject();
+ return JSC::JSValue::encode(obj->getDirect(global->vm(), global->vm().propertyNames->errors));
}
JSC__JSValue JSC__JSValue__jsTDZValue() { return JSC::JSValue::encode(JSC::jsTDZValue()); };
JSC__JSValue JSC__JSValue__jsUndefined() { return JSC::JSValue::encode(JSC::jsUndefined()); };
-JSC__JSObject *JSC__JSValue__toObject(JSC__JSValue JSValue0, JSC__JSGlobalObject *arg1) {
- JSC::JSValue value = JSC::JSValue::decode(JSValue0);
- return value.toObject(arg1);
+JSC__JSObject* JSC__JSValue__toObject(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1)
+{
+ JSC::JSValue value = JSC::JSValue::decode(JSValue0);
+ return value.toObject(arg1);
}
-bJSC__Identifier JSC__JSValue__toPropertyKey(JSC__JSValue JSValue0, JSC__JSGlobalObject *arg1) {
- JSC::JSValue value = JSC::JSValue::decode(JSValue0);
- auto ident = value.toPropertyKey(arg1);
- return cast<bJSC__Identifier>(&ident);
+bJSC__Identifier JSC__JSValue__toPropertyKey(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1)
+{
+ JSC::JSValue value = JSC::JSValue::decode(JSValue0);
+ auto ident = value.toPropertyKey(arg1);
+ return cast<bJSC__Identifier>(&ident);
}
-JSC__JSValue JSC__JSValue__toPropertyKeyValue(JSC__JSValue JSValue0, JSC__JSGlobalObject *arg1) {
- JSC::JSValue value = JSC::JSValue::decode(JSValue0);
- return JSC::JSValue::encode(value.toPropertyKeyValue(arg1));
+JSC__JSValue JSC__JSValue__toPropertyKeyValue(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1)
+{
+ JSC::JSValue value = JSC::JSValue::decode(JSValue0);
+ return JSC::JSValue::encode(value.toPropertyKeyValue(arg1));
}
-JSC__JSString *JSC__JSValue__toString(JSC__JSValue JSValue0, JSC__JSGlobalObject *arg1) {
- JSC::JSValue value = JSC::JSValue::decode(JSValue0);
- return value.toString(arg1);
+JSC__JSString* JSC__JSValue__toString(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1)
+{
+ JSC::JSValue value = JSC::JSValue::decode(JSValue0);
+ return value.toString(arg1);
};
-JSC__JSString *JSC__JSValue__toStringOrNull(JSC__JSValue JSValue0, JSC__JSGlobalObject *arg1) {
- JSC::JSValue value = JSC::JSValue::decode(JSValue0);
- return value.toStringOrNull(arg1);
+JSC__JSString* JSC__JSValue__toStringOrNull(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1)
+{
+ JSC::JSValue value = JSC::JSValue::decode(JSValue0);
+ return value.toStringOrNull(arg1);
}
-bWTF__String JSC__JSValue__toWTFString(JSC__JSValue JSValue0, JSC__JSGlobalObject *arg1) {
- JSC::JSValue value = JSC::JSValue::decode(JSValue0);
- return Wrap<WTF::String, bWTF__String>::wrap(value.toWTFString(arg1));
+bWTF__String JSC__JSValue__toWTFString(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1)
+{
+ JSC::JSValue value = JSC::JSValue::decode(JSValue0);
+ return Wrap<WTF::String, bWTF__String>::wrap(value.toWTFString(arg1));
};
-static void populateStackFrameMetadata(const JSC::StackFrame *stackFrame, ZigStackFrame *frame) {
- frame->source_url = Zig::toZigString(stackFrame->sourceURL());
-
- if (stackFrame->isWasmFrame()) {
- frame->code_type = ZigStackFrameCodeWasm;
- return;
- }
+static void populateStackFrameMetadata(const JSC::StackFrame* stackFrame, ZigStackFrame* frame)
+{
+ frame->source_url = Zig::toZigString(stackFrame->sourceURL());
- auto m_codeBlock = stackFrame->codeBlock();
- if (m_codeBlock) {
- switch (m_codeBlock->codeType()) {
- case JSC::EvalCode: {
- frame->code_type = ZigStackFrameCodeEval;
- return;
- }
- case JSC::ModuleCode: {
- frame->code_type = ZigStackFrameCodeModule;
+ if (stackFrame->isWasmFrame()) {
+ frame->code_type = ZigStackFrameCodeWasm;
return;
- }
- case JSC::GlobalCode: {
- frame->code_type = ZigStackFrameCodeGlobal;
- return;
- }
- case JSC::FunctionCode: {
- frame->code_type =
- !m_codeBlock->isConstructor() ? ZigStackFrameCodeFunction : ZigStackFrameCodeConstructor;
- break;
- }
- default: ASSERT_NOT_REACHED();
}
- }
- auto calleeCell = stackFrame->callee();
- if (!calleeCell || !calleeCell->isObject()) return;
+ auto m_codeBlock = stackFrame->codeBlock();
+ if (m_codeBlock) {
+ switch (m_codeBlock->codeType()) {
+ case JSC::EvalCode: {
+ frame->code_type = ZigStackFrameCodeEval;
+ return;
+ }
+ case JSC::ModuleCode: {
+ frame->code_type = ZigStackFrameCodeModule;
+ return;
+ }
+ case JSC::GlobalCode: {
+ frame->code_type = ZigStackFrameCodeGlobal;
+ return;
+ }
+ case JSC::FunctionCode: {
+ frame->code_type = !m_codeBlock->isConstructor() ? ZigStackFrameCodeFunction : ZigStackFrameCodeConstructor;
+ break;
+ }
+ default:
+ ASSERT_NOT_REACHED();
+ }
+ }
- JSC::JSObject *callee = JSC::jsCast<JSC::JSObject *>(calleeCell);
- // Does the code block have a user-defined name property?
- JSC::JSValue name = callee->getDirect(m_codeBlock->vm(), m_codeBlock->vm().propertyNames->name);
- if (name && name.isString()) {
- auto str = name.toWTFString(m_codeBlock->globalObject());
- frame->function_name = Zig::toZigString(str);
- return;
- }
+ auto calleeCell = stackFrame->callee();
+ if (!calleeCell || !calleeCell->isObject())
+ return;
+
+ JSC::JSObject* callee = JSC::jsCast<JSC::JSObject*>(calleeCell);
+ // Does the code block have a user-defined name property?
+ JSC::JSValue name = callee->getDirect(m_codeBlock->vm(), m_codeBlock->vm().propertyNames->name);
+ if (name && name.isString()) {
+ auto str = name.toWTFString(m_codeBlock->globalObject());
+ frame->function_name = Zig::toZigString(str);
+ return;
+ }
- /* For functions (either JSFunction or InternalFunction), fallback to their "native" name
+ /* For functions (either JSFunction or InternalFunction), fallback to their "native" name
* property. Based on JSC::getCalculatedDisplayName, "inlining" the
* JSFunction::calculatedDisplayName\InternalFunction::calculatedDisplayName calls */
- if (JSC::JSFunction *function =
- JSC::jsDynamicCast<JSC::JSFunction *>(m_codeBlock->vm(), callee)) {
+ if (JSC::JSFunction* function = JSC::jsDynamicCast<JSC::JSFunction*>(m_codeBlock->vm(), callee)) {
- WTF::String actualName = function->name(m_codeBlock->vm());
- if (!actualName.isEmpty() || function->isHostOrBuiltinFunction()) {
- frame->function_name = Zig::toZigString(actualName);
- return;
- }
+ WTF::String actualName = function->name(m_codeBlock->vm());
+ if (!actualName.isEmpty() || function->isHostOrBuiltinFunction()) {
+ frame->function_name = Zig::toZigString(actualName);
+ return;
+ }
- auto inferred_name = function->jsExecutable()->name();
- frame->function_name = Zig::toZigString(inferred_name.string());
- }
+ auto inferred_name = function->jsExecutable()->name();
+ frame->function_name = Zig::toZigString(inferred_name.string());
+ }
- if (JSC::InternalFunction *function =
- JSC::jsDynamicCast<JSC::InternalFunction *>(m_codeBlock->vm(), callee)) {
- // Based on JSC::InternalFunction::calculatedDisplayName, skipping the "displayName" property
- frame->function_name = Zig::toZigString(function->name());
- }
+ if (JSC::InternalFunction* function = JSC::jsDynamicCast<JSC::InternalFunction*>(m_codeBlock->vm(), callee)) {
+ // Based on JSC::InternalFunction::calculatedDisplayName, skipping the "displayName" property
+ frame->function_name = Zig::toZigString(function->name());
+ }
}
// Based on
// https://github.com/mceSystems/node-jsc/blob/master/deps/jscshim/src/shim/JSCStackTrace.cpp#L298
-static void populateStackFramePosition(const JSC::StackFrame *stackFrame, ZigString *source_lines,
- int32_t *source_line_numbers, uint8_t source_lines_count,
- ZigStackFramePosition *position) {
- auto m_codeBlock = stackFrame->codeBlock();
- if (!m_codeBlock) return;
+static void populateStackFramePosition(const JSC::StackFrame* stackFrame, ZigString* source_lines,
+ int32_t* source_line_numbers, uint8_t source_lines_count,
+ ZigStackFramePosition* position)
+{
+ auto m_codeBlock = stackFrame->codeBlock();
+ if (!m_codeBlock)
+ return;
- JSC::BytecodeIndex bytecodeOffset =
- stackFrame->hasBytecodeIndex() ? stackFrame->bytecodeIndex() : JSC::BytecodeIndex();
+ JSC::BytecodeIndex bytecodeOffset = stackFrame->hasBytecodeIndex() ? stackFrame->bytecodeIndex() : JSC::BytecodeIndex();
- /* Get the "raw" position info.
+ /* Get the "raw" position info.
* Note that we're using m_codeBlock->unlinkedCodeBlock()->expressionRangeForBytecodeOffset
* rather than m_codeBlock->expressionRangeForBytecodeOffset in order get the "raw" offsets and
* avoid the CodeBlock's expressionRangeForBytecodeOffset modifications to the line and column
* numbers, (we don't need the column number from it, and we'll calculate the line "fixes"
* ourselves). */
- int startOffset = 0;
- int endOffset = 0;
- int divotPoint = 0;
- unsigned line = 0;
- unsigned unusedColumn = 0;
- m_codeBlock->unlinkedCodeBlock()->expressionRangeForBytecodeIndex(
- bytecodeOffset, divotPoint, startOffset, endOffset, line, unusedColumn);
- divotPoint += m_codeBlock->sourceOffset();
-
- // TODO: evaluate if using the API from UnlinkedCodeBlock can be used instead of iterating
- // through source text.
-
- /* On the first line of the source code, it seems that we need to "fix" the column with the
+ int startOffset = 0;
+ int endOffset = 0;
+ int divotPoint = 0;
+ unsigned line = 0;
+ unsigned unusedColumn = 0;
+ m_codeBlock->unlinkedCodeBlock()->expressionRangeForBytecodeIndex(
+ bytecodeOffset, divotPoint, startOffset, endOffset, line, unusedColumn);
+ divotPoint += m_codeBlock->sourceOffset();
+
+ // TODO: evaluate if using the API from UnlinkedCodeBlock can be used instead of iterating
+ // through source text.
+
+ /* On the first line of the source code, it seems that we need to "fix" the column with the
* starting offset. We currently use codeBlock->source()->startPosition().m_column.oneBasedInt()
* as the offset in the first line rather than codeBlock->firstLineColumnOffset(), which seems
* simpler (and what CodeBlock::expressionRangeForBytecodeOffset does). This is because
* firstLineColumnOffset values seems different from what we expect (according to v8's tests)
* and I haven't dove into the relevant parts in JSC (yet) to figure out why. */
- unsigned columnOffset = line ? 0 : m_codeBlock->source().startColumn().zeroBasedInt();
-
- // "Fix" the line number
- JSC::ScriptExecutable *executable = m_codeBlock->ownerExecutable();
- if (std::optional<int> overrideLine = executable->overrideLineNumber(m_codeBlock->vm())) {
- line = overrideLine.value();
- } else {
- line += executable->firstLine();
- }
-
- // Calculate the staring\ending offsets of the entire expression
- int expressionStart = divotPoint - startOffset;
- int expressionStop = divotPoint + endOffset;
-
- // Make sure the range is valid
- WTF::StringView sourceString = m_codeBlock->source().provider()->source();
- if (!expressionStop || expressionStart > static_cast<int>(sourceString.length())) { return; }
-
- // Search for the beginning of the line
- unsigned int lineStart = expressionStart;
- while ((lineStart > 0) && ('\n' != sourceString[lineStart - 1])) { lineStart--; }
- // Search for the end of the line
- unsigned int lineStop = expressionStop;
- unsigned int sourceLength = sourceString.length();
- while ((lineStop < sourceLength) && ('\n' != sourceString[lineStop])) { lineStop++; }
- if (source_lines_count > 1 && source_lines != nullptr) {
- auto chars = sourceString.characters8();
-
- // Most of the time, when you look at a stack trace, you want a couple lines above
-
- source_lines[0] = {&chars[lineStart], lineStop - lineStart};
- source_line_numbers[0] = line;
-
- if (lineStart > 0) {
- auto byte_offset_in_source_string = lineStart - 1;
- uint8_t source_line_i = 1;
- auto remaining_lines_to_grab = source_lines_count - 1;
-
- while (byte_offset_in_source_string > 0 && remaining_lines_to_grab > 0) {
- unsigned int end_of_line_offset = byte_offset_in_source_string;
-
- // This should probably be code points instead of newlines
- while (byte_offset_in_source_string > 0 && chars[byte_offset_in_source_string] != '\n') {
- byte_offset_in_source_string--;
- }
+ unsigned columnOffset = line ? 0 : m_codeBlock->source().startColumn().zeroBasedInt();
+
+ // "Fix" the line number
+ JSC::ScriptExecutable* executable = m_codeBlock->ownerExecutable();
+ if (std::optional<int> overrideLine = executable->overrideLineNumber(m_codeBlock->vm())) {
+ line = overrideLine.value();
+ } else {
+ line += executable->firstLine();
+ }
+
+ // Calculate the staring\ending offsets of the entire expression
+ int expressionStart = divotPoint - startOffset;
+ int expressionStop = divotPoint + endOffset;
+
+ // Make sure the range is valid
+ WTF::StringView sourceString = m_codeBlock->source().provider()->source();
+ if (!expressionStop || expressionStart > static_cast<int>(sourceString.length())) {
+ return;
+ }
+
+ // Search for the beginning of the line
+ unsigned int lineStart = expressionStart;
+ while ((lineStart > 0) && ('\n' != sourceString[lineStart - 1])) {
+ lineStart--;
+ }
+ // Search for the end of the line
+ unsigned int lineStop = expressionStop;
+ unsigned int sourceLength = sourceString.length();
+ while ((lineStop < sourceLength) && ('\n' != sourceString[lineStop])) {
+ lineStop++;
+ }
+ if (source_lines_count > 1 && source_lines != nullptr) {
+ auto chars = sourceString.characters8();
+
+ // Most of the time, when you look at a stack trace, you want a couple lines above
+
+ source_lines[0] = { &chars[lineStart], lineStop - lineStart };
+ source_line_numbers[0] = line;
+
+ if (lineStart > 0) {
+ auto byte_offset_in_source_string = lineStart - 1;
+ uint8_t source_line_i = 1;
+ auto remaining_lines_to_grab = source_lines_count - 1;
+
+ while (byte_offset_in_source_string > 0 && remaining_lines_to_grab > 0) {
+ unsigned int end_of_line_offset = byte_offset_in_source_string;
- // We are at the beginning of the line
- source_lines[source_line_i] = {&chars[byte_offset_in_source_string],
- end_of_line_offset - byte_offset_in_source_string + 1};
+ // This should probably be code points instead of newlines
+ while (byte_offset_in_source_string > 0 && chars[byte_offset_in_source_string] != '\n') {
+ byte_offset_in_source_string--;
+ }
- source_line_numbers[source_line_i] = line - source_line_i;
- source_line_i++;
+ // We are at the beginning of the line
+ source_lines[source_line_i] = { &chars[byte_offset_in_source_string],
+ end_of_line_offset - byte_offset_in_source_string + 1 };
- remaining_lines_to_grab--;
+ source_line_numbers[source_line_i] = line - source_line_i;
+ source_line_i++;
- byte_offset_in_source_string -= byte_offset_in_source_string > 0;
- }
+ remaining_lines_to_grab--;
+
+ byte_offset_in_source_string -= byte_offset_in_source_string > 0;
+ }
+ }
}
- }
- /* Finally, store the source "positions" info.
+ /* Finally, store the source "positions" info.
* Notes:
* - The retrieved column seem to point the "end column". To make sure we're current, we'll
*calculate the columns ourselves, since we've already found where the line starts. Note that in
@@ -1536,659 +1722,735 @@ static void populateStackFramePosition(const JSC::StackFrame *stackFrame, ZigStr
* TODO: If expressionStart == expressionStop, then m_endColumn will be equal to m_startColumn.
*Should we handle this case?
*/
- position->expression_start = expressionStart;
- position->expression_stop = expressionStop;
- position->line = WTF::OrdinalNumber::fromOneBasedInt(static_cast<int>(line)).zeroBasedInt();
- position->column_start = (expressionStart - lineStart) + columnOffset;
- position->column_stop = position->column_start + (expressionStop - expressionStart);
- position->line_start = lineStart;
- position->line_stop = lineStop;
-
- return;
-}
-static void populateStackFrame(ZigStackTrace *trace, const JSC::StackFrame *stackFrame,
- ZigStackFrame *frame, bool is_top) {
- populateStackFrameMetadata(stackFrame, frame);
- populateStackFramePosition(stackFrame, is_top ? trace->source_lines_ptr : nullptr,
- is_top ? trace->source_lines_numbers : nullptr,
- is_top ? trace->source_lines_to_collect : 0, &frame->position);
-}
-static void populateStackTrace(const WTF::Vector<JSC::StackFrame> &frames, ZigStackTrace *trace) {
- uint8_t frame_i = 0;
- size_t stack_frame_i = 0;
- const size_t total_frame_count = frames.size();
- const uint8_t frame_count =
- total_frame_count < trace->frames_len ? total_frame_count : trace->frames_len;
-
- while (frame_i < frame_count && stack_frame_i < total_frame_count) {
- // Skip native frames
- while (stack_frame_i < total_frame_count && !(&frames.at(stack_frame_i))->codeBlock() &&
- !(&frames.at(stack_frame_i))->isWasmFrame()) {
- stack_frame_i++;
+ position->expression_start = expressionStart;
+ position->expression_stop = expressionStop;
+ position->line = WTF::OrdinalNumber::fromOneBasedInt(static_cast<int>(line)).zeroBasedInt();
+ position->column_start = (expressionStart - lineStart) + columnOffset;
+ position->column_stop = position->column_start + (expressionStop - expressionStart);
+ position->line_start = lineStart;
+ position->line_stop = lineStop;
+
+ return;
+}
+static void populateStackFrame(ZigStackTrace* trace, const JSC::StackFrame* stackFrame,
+ ZigStackFrame* frame, bool is_top)
+{
+ populateStackFrameMetadata(stackFrame, frame);
+ populateStackFramePosition(stackFrame, is_top ? trace->source_lines_ptr : nullptr,
+ is_top ? trace->source_lines_numbers : nullptr,
+ is_top ? trace->source_lines_to_collect : 0, &frame->position);
+}
+static void populateStackTrace(const WTF::Vector<JSC::StackFrame>& frames, ZigStackTrace* trace)
+{
+ uint8_t frame_i = 0;
+ size_t stack_frame_i = 0;
+ const size_t total_frame_count = frames.size();
+ const uint8_t frame_count = total_frame_count < trace->frames_len ? total_frame_count : trace->frames_len;
+
+ while (frame_i < frame_count && stack_frame_i < total_frame_count) {
+ // Skip native frames
+ while (stack_frame_i < total_frame_count && !(&frames.at(stack_frame_i))->codeBlock() && !(&frames.at(stack_frame_i))->isWasmFrame()) {
+ stack_frame_i++;
+ }
+ if (stack_frame_i >= total_frame_count)
+ break;
+
+ ZigStackFrame* frame = &trace->frames_ptr[frame_i];
+ populateStackFrame(trace, &frames[stack_frame_i], frame, frame_i == 0);
+ stack_frame_i++;
+ frame_i++;
}
- if (stack_frame_i >= total_frame_count) break;
-
- ZigStackFrame *frame = &trace->frames_ptr[frame_i];
- populateStackFrame(trace, &frames[stack_frame_i], frame, frame_i == 0);
- stack_frame_i++;
- frame_i++;
- }
- trace->frames_len = frame_i;
-}
-static void fromErrorInstance(ZigException *except, JSC::JSGlobalObject *global,
- JSC::ErrorInstance *err, const Vector<JSC::StackFrame> *stackTrace,
- JSC::JSValue val) {
- JSC::JSObject *obj = JSC::jsDynamicCast<JSC::JSObject *>(global->vm(), val);
-
- bool getFromSourceURL = false;
- if (stackTrace != nullptr && stackTrace->size() > 0) {
- populateStackTrace(*stackTrace, &except->stack);
- } else if (err->stackTrace() != nullptr && err->stackTrace()->size() > 0) {
- populateStackTrace(*err->stackTrace(), &except->stack);
- } else {
- getFromSourceURL = true;
- }
- except->code = (unsigned char)err->errorType();
- if (err->isStackOverflowError()) { except->code = 253; }
- if (err->isOutOfMemoryError()) { except->code = 8; }
-
- if (JSC::JSValue message =
- obj->getIfPropertyExists(global, global->vm().propertyNames->message)) {
-
- except->message = Zig::toZigString(message, global);
-
- } else {
- except->message = Zig::toZigString(err->sanitizedMessageString(global));
- }
- except->name = Zig::toZigString(err->sanitizedNameString(global));
- except->runtime_type = err->runtimeTypeForCause();
-
- auto clientData = Bun::clientData(global->vm());
-
- if (JSC::JSValue syscall =
- obj->getIfPropertyExists(global, clientData->builtinNames().syscallPublicName())) {
- except->syscall = Zig::toZigString(syscall, global);
- }
-
- if (JSC::JSValue code =
- obj->getIfPropertyExists(global, clientData->builtinNames().codePublicName())) {
- except->code_ = Zig::toZigString(code, global);
- }
-
- if (JSC::JSValue path =
- obj->getIfPropertyExists(global, clientData->builtinNames().pathPublicName())) {
- except->path = Zig::toZigString(path, global);
- }
-
- if (JSC::JSValue errno_ =
- obj->getIfPropertyExists(global, clientData->builtinNames().errnoPublicName())) {
- except->errno_ = errno_.toInt32(global);
- }
-
- if (getFromSourceURL) {
- if (JSC::JSValue sourceURL =
- obj->getIfPropertyExists(global, global->vm().propertyNames->sourceURL)) {
- except->stack.frames_ptr[0].source_url = Zig::toZigString(sourceURL, global);
-
- if (JSC::JSValue line = obj->getIfPropertyExists(global, global->vm().propertyNames->line)) {
- except->stack.frames_ptr[0].position.line = line.toInt32(global);
- }
-
- if (JSC::JSValue column =
- obj->getIfPropertyExists(global, global->vm().propertyNames->column)) {
- except->stack.frames_ptr[0].position.column_start = column.toInt32(global);
- }
- except->stack.frames_len = 1;
+ trace->frames_len = frame_i;
+}
+static void fromErrorInstance(ZigException* except, JSC::JSGlobalObject* global,
+ JSC::ErrorInstance* err, const Vector<JSC::StackFrame>* stackTrace,
+ JSC::JSValue val)
+{
+ JSC::JSObject* obj = JSC::jsDynamicCast<JSC::JSObject*>(global->vm(), val);
+
+ bool getFromSourceURL = false;
+ if (stackTrace != nullptr && stackTrace->size() > 0) {
+ populateStackTrace(*stackTrace, &except->stack);
+ } else if (err->stackTrace() != nullptr && err->stackTrace()->size() > 0) {
+ populateStackTrace(*err->stackTrace(), &except->stack);
+ } else {
+ getFromSourceURL = true;
}
- }
-
- except->exception = err;
-}
-
-void exceptionFromString(ZigException *except, JSC::JSValue value, JSC::JSGlobalObject *global) {
- // Fallback case for when it's a user-defined ErrorLike-object that doesn't inherit from
- // ErrorInstance
- if (JSC::JSObject *obj = JSC::jsDynamicCast<JSC::JSObject *>(global->vm(), value)) {
- if (obj->hasProperty(global, global->vm().propertyNames->name)) {
- auto name_str =
- obj->getDirect(global->vm(), global->vm().propertyNames->name).toWTFString(global);
- except->name = Zig::toZigString(name_str);
- if (name_str == "Error"_s) {
- except->code = JSErrorCodeError;
- } else if (name_str == "EvalError"_s) {
- except->code = JSErrorCodeEvalError;
- } else if (name_str == "RangeError"_s) {
- except->code = JSErrorCodeRangeError;
- } else if (name_str == "ReferenceError"_s) {
- except->code = JSErrorCodeReferenceError;
- } else if (name_str == "SyntaxError"_s) {
- except->code = JSErrorCodeSyntaxError;
- } else if (name_str == "TypeError"_s) {
- except->code = JSErrorCodeTypeError;
- } else if (name_str == "URIError"_s) {
- except->code = JSErrorCodeURIError;
- } else if (name_str == "AggregateError"_s) {
- except->code = JSErrorCodeAggregateError;
- }
+ except->code = (unsigned char)err->errorType();
+ if (err->isStackOverflowError()) {
+ except->code = 253;
}
+ if (err->isOutOfMemoryError()) {
+ except->code = 8;
+ }
+
+ if (JSC::JSValue message = obj->getIfPropertyExists(global, global->vm().propertyNames->message)) {
- if (obj->hasProperty(global, global->vm().propertyNames->message)) {
- except->message = Zig::toZigString(
- obj->getDirect(global->vm(), global->vm().propertyNames->message).toWTFString(global));
+ except->message = Zig::toZigString(message, global);
+
+ } else {
+ except->message = Zig::toZigString(err->sanitizedMessageString(global));
}
+ except->name = Zig::toZigString(err->sanitizedNameString(global));
+ except->runtime_type = err->runtimeTypeForCause();
- if (obj->hasProperty(global, global->vm().propertyNames->sourceURL)) {
- except->stack.frames_ptr[0].source_url = Zig::toZigString(
- obj->getDirect(global->vm(), global->vm().propertyNames->sourceURL).toWTFString(global));
- except->stack.frames_len = 1;
+ auto clientData = Bun::clientData(global->vm());
+
+ if (JSC::JSValue syscall = obj->getIfPropertyExists(global, clientData->builtinNames().syscallPublicName())) {
+ except->syscall = Zig::toZigString(syscall, global);
}
- if (obj->hasProperty(global, global->vm().propertyNames->line)) {
- except->stack.frames_ptr[0].position.line =
- obj->getDirect(global->vm(), global->vm().propertyNames->line).toInt32(global);
- except->stack.frames_len = 1;
+ if (JSC::JSValue code = obj->getIfPropertyExists(global, clientData->builtinNames().codePublicName())) {
+ except->code_ = Zig::toZigString(code, global);
}
- return;
- }
- auto scope = DECLARE_THROW_SCOPE(global->vm());
- auto str = value.toWTFString(global);
- if (scope.exception()) {
- scope.clearException();
+ if (JSC::JSValue path = obj->getIfPropertyExists(global, clientData->builtinNames().pathPublicName())) {
+ except->path = Zig::toZigString(path, global);
+ }
+
+ if (JSC::JSValue errno_ = obj->getIfPropertyExists(global, clientData->builtinNames().errnoPublicName())) {
+ except->errno_ = errno_.toInt32(global);
+ }
+
+ if (getFromSourceURL) {
+ if (JSC::JSValue sourceURL = obj->getIfPropertyExists(global, global->vm().propertyNames->sourceURL)) {
+ except->stack.frames_ptr[0].source_url = Zig::toZigString(sourceURL, global);
+
+ if (JSC::JSValue line = obj->getIfPropertyExists(global, global->vm().propertyNames->line)) {
+ except->stack.frames_ptr[0].position.line = line.toInt32(global);
+ }
+
+ if (JSC::JSValue column = obj->getIfPropertyExists(global, global->vm().propertyNames->column)) {
+ except->stack.frames_ptr[0].position.column_start = column.toInt32(global);
+ }
+ except->stack.frames_len = 1;
+ }
+ }
+
+ except->exception = err;
+}
+
+void exceptionFromString(ZigException* except, JSC::JSValue value, JSC::JSGlobalObject* global)
+{
+ // Fallback case for when it's a user-defined ErrorLike-object that doesn't inherit from
+ // ErrorInstance
+ if (JSC::JSObject* obj = JSC::jsDynamicCast<JSC::JSObject*>(global->vm(), value)) {
+ if (obj->hasProperty(global, global->vm().propertyNames->name)) {
+ auto name_str = obj->getDirect(global->vm(), global->vm().propertyNames->name).toWTFString(global);
+ except->name = Zig::toZigString(name_str);
+ if (name_str == "Error"_s) {
+ except->code = JSErrorCodeError;
+ } else if (name_str == "EvalError"_s) {
+ except->code = JSErrorCodeEvalError;
+ } else if (name_str == "RangeError"_s) {
+ except->code = JSErrorCodeRangeError;
+ } else if (name_str == "ReferenceError"_s) {
+ except->code = JSErrorCodeReferenceError;
+ } else if (name_str == "SyntaxError"_s) {
+ except->code = JSErrorCodeSyntaxError;
+ } else if (name_str == "TypeError"_s) {
+ except->code = JSErrorCodeTypeError;
+ } else if (name_str == "URIError"_s) {
+ except->code = JSErrorCodeURIError;
+ } else if (name_str == "AggregateError"_s) {
+ except->code = JSErrorCodeAggregateError;
+ }
+ }
+
+ if (obj->hasProperty(global, global->vm().propertyNames->message)) {
+ except->message = Zig::toZigString(
+ obj->getDirect(global->vm(), global->vm().propertyNames->message).toWTFString(global));
+ }
+
+ if (obj->hasProperty(global, global->vm().propertyNames->sourceURL)) {
+ except->stack.frames_ptr[0].source_url = Zig::toZigString(
+ obj->getDirect(global->vm(), global->vm().propertyNames->sourceURL).toWTFString(global));
+ except->stack.frames_len = 1;
+ }
+
+ if (obj->hasProperty(global, global->vm().propertyNames->line)) {
+ except->stack.frames_ptr[0].position.line = obj->getDirect(global->vm(), global->vm().propertyNames->line).toInt32(global);
+ except->stack.frames_len = 1;
+ }
+
+ return;
+ }
+ auto scope = DECLARE_THROW_SCOPE(global->vm());
+ auto str = value.toWTFString(global);
+ if (scope.exception()) {
+ scope.clearException();
+ scope.release();
+ return;
+ }
scope.release();
- return;
- }
- scope.release();
- auto ref = OpaqueJSString::tryCreate(str);
- except->message = ZigString{ref->characters8(), ref->length()};
- ref->ref();
+ auto ref = OpaqueJSString::tryCreate(str);
+ except->message = ZigString { ref->characters8(), ref->length() };
+ ref->ref();
}
static WTF::StringView function_string_view = WTF::StringView("Function");
-void JSC__JSValue__getClassName(JSC__JSValue JSValue0, JSC__JSGlobalObject *arg1, ZigString *arg2) {
- JSC::JSCell *cell = JSC::JSValue::decode(JSValue0).asCell();
- if (cell == nullptr) {
- arg2->len = 0;
- return;
- }
+void JSC__JSValue__getClassName(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, ZigString* arg2)
+{
+ JSC::JSCell* cell = JSC::JSValue::decode(JSValue0).asCell();
+ if (cell == nullptr) {
+ arg2->len = 0;
+ return;
+ }
- const char *ptr = cell->className(arg1->vm());
- auto view = WTF::StringView(ptr);
+ const char* ptr = cell->className(arg1->vm());
+ auto view = WTF::StringView(ptr);
- // Fallback to .name if className is empty
- if (view.length() == 0 || view == function_string_view) {
- JSC__JSValue__getNameProperty(JSValue0, arg1, arg2);
- return;
- } else {
- *arg2 = Zig::toZigString(view);
- return;
- }
+ // Fallback to .name if className is empty
+ if (view.length() == 0 || view == function_string_view) {
+ JSC__JSValue__getNameProperty(JSValue0, arg1, arg2);
+ return;
+ } else {
+ *arg2 = Zig::toZigString(view);
+ return;
+ }
- arg2->len = 0;
+ arg2->len = 0;
}
-void JSC__JSValue__getNameProperty(JSC__JSValue JSValue0, JSC__JSGlobalObject *arg1,
- ZigString *arg2) {
+void JSC__JSValue__getNameProperty(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1,
+ ZigString* arg2)
+{
- JSC::JSObject *obj = JSC::JSValue::decode(JSValue0).getObject();
+ JSC::JSObject* obj = JSC::JSValue::decode(JSValue0).getObject();
- if (obj == nullptr) {
- arg2->len = 0;
- return;
- }
-
- JSC::JSValue name = obj->getDirect(arg1->vm(), arg1->vm().propertyNames->name);
- if (name && name.isString()) {
- auto str = name.toWTFString(arg1);
- if (!str.isEmpty()) {
- *arg2 = Zig::toZigString(str);
- return;
+ if (obj == nullptr) {
+ arg2->len = 0;
+ return;
}
- }
- if (JSC::JSFunction *function = JSC::jsDynamicCast<JSC::JSFunction *>(arg1->vm(), obj)) {
-
- WTF::String actualName = function->name(arg1->vm());
- if (!actualName.isEmpty() || function->isHostOrBuiltinFunction()) {
- *arg2 = Zig::toZigString(actualName);
- return;
+ JSC::JSValue name = obj->getDirect(arg1->vm(), arg1->vm().propertyNames->name);
+ if (name && name.isString()) {
+ auto str = name.toWTFString(arg1);
+ if (!str.isEmpty()) {
+ *arg2 = Zig::toZigString(str);
+ return;
+ }
}
- actualName = function->jsExecutable()->name().string();
+ if (JSC::JSFunction* function = JSC::jsDynamicCast<JSC::JSFunction*>(arg1->vm(), obj)) {
- *arg2 = Zig::toZigString(actualName);
- return;
- }
+ WTF::String actualName = function->name(arg1->vm());
+ if (!actualName.isEmpty() || function->isHostOrBuiltinFunction()) {
+ *arg2 = Zig::toZigString(actualName);
+ return;
+ }
- if (JSC::InternalFunction *function =
- JSC::jsDynamicCast<JSC::InternalFunction *>(arg1->vm(), obj)) {
- auto view = WTF::StringView(function->name());
- *arg2 = Zig::toZigString(view);
- return;
- }
+ actualName = function->jsExecutable()->name().string();
- arg2->len = 0;
+ *arg2 = Zig::toZigString(actualName);
+ return;
+ }
+
+ if (JSC::InternalFunction* function = JSC::jsDynamicCast<JSC::InternalFunction*>(arg1->vm(), obj)) {
+ auto view = WTF::StringView(function->name());
+ *arg2 = Zig::toZigString(view);
+ return;
+ }
+
+ arg2->len = 0;
}
-void JSC__JSValue__toZigException(JSC__JSValue JSValue0, JSC__JSGlobalObject *arg1,
- ZigException *exception) {
- JSC::JSValue value = JSC::JSValue::decode(JSValue0);
+void JSC__JSValue__toZigException(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1,
+ ZigException* exception)
+{
+ JSC::JSValue value = JSC::JSValue::decode(JSValue0);
- if (JSC::Exception *jscException = JSC::jsDynamicCast<JSC::Exception *>(arg1->vm(), value)) {
- if (JSC::ErrorInstance *error =
- JSC::jsDynamicCast<JSC::ErrorInstance *>(arg1->vm(), jscException->value())) {
- fromErrorInstance(exception, arg1, error, &jscException->stack(), value);
- return;
+ if (JSC::Exception* jscException = JSC::jsDynamicCast<JSC::Exception*>(arg1->vm(), value)) {
+ if (JSC::ErrorInstance* error = JSC::jsDynamicCast<JSC::ErrorInstance*>(arg1->vm(), jscException->value())) {
+ fromErrorInstance(exception, arg1, error, &jscException->stack(), value);
+ return;
+ }
}
- }
- if (JSC::ErrorInstance *error = JSC::jsDynamicCast<JSC::ErrorInstance *>(arg1->vm(), value)) {
- fromErrorInstance(exception, arg1, error, nullptr, value);
- return;
- }
+ if (JSC::ErrorInstance* error = JSC::jsDynamicCast<JSC::ErrorInstance*>(arg1->vm(), value)) {
+ fromErrorInstance(exception, arg1, error, nullptr, value);
+ return;
+ }
- exceptionFromString(exception, value, arg1);
+ exceptionFromString(exception, value, arg1);
}
-void JSC__Exception__getStackTrace(JSC__Exception *arg0, ZigStackTrace *trace) {
- populateStackTrace(arg0->stack(), trace);
+void JSC__Exception__getStackTrace(JSC__Exception* arg0, ZigStackTrace* trace)
+{
+ populateStackTrace(arg0->stack(), trace);
}
#pragma mark - JSC::PropertyName
-bool JSC__PropertyName__eqlToIdentifier(JSC__PropertyName *arg0, const JSC__Identifier *arg1) {
- return (*arg0) == (*arg1);
+bool JSC__PropertyName__eqlToIdentifier(JSC__PropertyName* arg0, const JSC__Identifier* arg1)
+{
+ return (*arg0) == (*arg1);
};
-bool JSC__PropertyName__eqlToPropertyName(JSC__PropertyName *arg0, const JSC__PropertyName *arg1) {
- return (*arg0) == (*arg1);
+bool JSC__PropertyName__eqlToPropertyName(JSC__PropertyName* arg0, const JSC__PropertyName* arg1)
+{
+ return (*arg0) == (*arg1);
};
-const WTF__StringImpl *JSC__PropertyName__publicName(JSC__PropertyName *arg0) {
- return arg0->publicName();
+const WTF__StringImpl* JSC__PropertyName__publicName(JSC__PropertyName* arg0)
+{
+ return arg0->publicName();
};
-const WTF__StringImpl *JSC__PropertyName__uid(JSC__PropertyName *arg0) { return arg0->uid(); };
+const WTF__StringImpl* JSC__PropertyName__uid(JSC__PropertyName* arg0) { return arg0->uid(); };
#pragma mark - JSC::VM
-JSC__JSValue JSC__VM__runGC(JSC__VM *vm, bool sync) {
- JSC::JSLockHolder lock(vm);
+JSC__JSValue JSC__VM__runGC(JSC__VM* vm, bool sync)
+{
+ JSC::JSLockHolder lock(vm);
- if (sync) {
- vm->heap.collectNow(JSC::Sync, JSC::CollectionScope::Full);
- } else {
- vm->heap.collectSync(JSC::CollectionScope::Full);
- }
+ if (sync) {
+ vm->heap.collectNow(JSC::Sync, JSC::CollectionScope::Full);
+ } else {
+ vm->heap.collectSync(JSC::CollectionScope::Full);
+ }
- return JSC::JSValue::encode(JSC::jsNumber(vm->heap.sizeAfterLastFullCollection()));
+ return JSC::JSValue::encode(JSC::jsNumber(vm->heap.sizeAfterLastFullCollection()));
}
bool JSC__VM__isJITEnabled() { return JSC::Options::useJIT(); }
-void JSC__VM__clearExecutionTimeLimit(JSC__VM *vm) {
- JSC::JSLockHolder locker(vm);
- if (vm->watchdog()) vm->watchdog()->setTimeLimit(JSC::Watchdog::noTimeLimit);
+void JSC__VM__clearExecutionTimeLimit(JSC__VM* vm)
+{
+ JSC::JSLockHolder locker(vm);
+ if (vm->watchdog())
+ vm->watchdog()->setTimeLimit(JSC::Watchdog::noTimeLimit);
}
-void JSC__VM__setExecutionTimeLimit(JSC__VM *vm, double limit) {
- JSC::JSLockHolder locker(vm);
- JSC::Watchdog &watchdog = vm->ensureWatchdog();
- watchdog.setTimeLimit(WTF::Seconds{limit});
+void JSC__VM__setExecutionTimeLimit(JSC__VM* vm, double limit)
+{
+ JSC::JSLockHolder locker(vm);
+ JSC::Watchdog& watchdog = vm->ensureWatchdog();
+ watchdog.setTimeLimit(WTF::Seconds { limit });
}
-bool JSC__JSValue__isTerminationException(JSC__JSValue JSValue0, JSC__VM *arg1) {
- JSC::Exception *exception =
- JSC::jsDynamicCast<JSC::Exception *>(*arg1, JSC::JSValue::decode(JSValue0));
- return exception != NULL && arg1->isTerminationException(exception);
+bool JSC__JSValue__isTerminationException(JSC__JSValue JSValue0, JSC__VM* arg1)
+{
+ JSC::Exception* exception = JSC::jsDynamicCast<JSC::Exception*>(*arg1, JSC::JSValue::decode(JSValue0));
+ return exception != NULL && arg1->isTerminationException(exception);
}
-void JSC__VM__shrinkFootprint(JSC__VM *arg0) { arg0->shrinkFootprintWhenIdle(); };
-void JSC__VM__whenIdle(JSC__VM *arg0, void (*ArgFn1)()) { arg0->whenIdle(ArgFn1); };
+void JSC__VM__shrinkFootprint(JSC__VM* arg0) { arg0->shrinkFootprintWhenIdle(); };
+void JSC__VM__whenIdle(JSC__VM* arg0, void (*ArgFn1)()) { arg0->whenIdle(ArgFn1); };
-thread_local JSC::VM *g_commonVMOrNull;
-JSC__VM *JSC__VM__create(unsigned char HeapType0) {
+thread_local JSC::VM* g_commonVMOrNull;
+JSC__VM* JSC__VM__create(unsigned char HeapType0)
+{
- auto &vm = JSC::VM::create(HeapType0 == 0 ? JSC::HeapType::Small : JSC::HeapType::Large, nullptr)
- .leakRef();
+ auto& vm = JSC::VM::create(HeapType0 == 0 ? JSC::HeapType::Small : JSC::HeapType::Large, nullptr)
+ .leakRef();
#if ENABLE(WEBASSEMBLY)
- JSC::Wasm::enableFastMemory();
+ JSC::Wasm::enableFastMemory();
#endif
- g_commonVMOrNull = &vm;
- vm.heap.acquireAccess(); // At any time, we may do things that affect the GC.
+ g_commonVMOrNull = &vm;
+ vm.heap.acquireAccess(); // At any time, we may do things that affect the GC.
- return g_commonVMOrNull;
+ return g_commonVMOrNull;
}
-void JSC__VM__holdAPILock(JSC__VM *arg0, void *ctx, void (*callback)(void *arg0)) {
- JSC::JSLockHolder locker(arg0);
- callback(ctx);
+void JSC__VM__holdAPILock(JSC__VM* arg0, void* ctx, void (*callback)(void* arg0))
+{
+ JSC::JSLockHolder locker(arg0);
+ callback(ctx);
}
-void JSC__VM__deleteAllCode(JSC__VM *arg1, JSC__JSGlobalObject *globalObject) {
- JSC::JSLockHolder locker(globalObject->vm());
+void JSC__VM__deleteAllCode(JSC__VM* arg1, JSC__JSGlobalObject* globalObject)
+{
+ JSC::JSLockHolder locker(globalObject->vm());
- arg1->drainMicrotasks();
- if (JSC::JSObject *obj =
- JSC::jsDynamicCast<JSC::JSObject *>(globalObject->vm(), globalObject->moduleLoader())) {
- auto id = JSC::Identifier::fromString(globalObject->vm(), "registry");
- JSC::JSMap *map =
- JSC::JSMap::create(globalObject, globalObject->vm(), globalObject->mapStructure());
- obj->putDirect(globalObject->vm(), id, map);
- }
- arg1->deleteAllCode(JSC::DeleteAllCodeEffort::PreventCollectionAndDeleteAllCode);
- arg1->heap.reportAbandonedObjectGraph();
+ arg1->drainMicrotasks();
+ if (JSC::JSObject* obj = JSC::jsDynamicCast<JSC::JSObject*>(globalObject->vm(), globalObject->moduleLoader())) {
+ auto id = JSC::Identifier::fromString(globalObject->vm(), "registry");
+ JSC::JSMap* map = JSC::JSMap::create(globalObject, globalObject->vm(), globalObject->mapStructure());
+ obj->putDirect(globalObject->vm(), id, map);
+ }
+ arg1->deleteAllCode(JSC::DeleteAllCodeEffort::PreventCollectionAndDeleteAllCode);
+ arg1->heap.reportAbandonedObjectGraph();
}
-void JSC__VM__deinit(JSC__VM *arg1, JSC__JSGlobalObject *globalObject) {}
-void JSC__VM__drainMicrotasks(JSC__VM *arg0) { arg0->drainMicrotasks(); }
+void JSC__VM__deinit(JSC__VM* arg1, JSC__JSGlobalObject* globalObject) {}
+void JSC__VM__drainMicrotasks(JSC__VM* arg0) { arg0->drainMicrotasks(); }
-bool JSC__VM__executionForbidden(JSC__VM *arg0) { return (*arg0).executionForbidden(); }
+bool JSC__VM__executionForbidden(JSC__VM* arg0) { return (*arg0).executionForbidden(); }
-bool JSC__VM__isEntered(JSC__VM *arg0) { return (*arg0).isEntered(); }
+bool JSC__VM__isEntered(JSC__VM* arg0) { return (*arg0).isEntered(); }
-void JSC__VM__setExecutionForbidden(JSC__VM *arg0, bool arg1) { (*arg0).setExecutionForbidden(); }
+void JSC__VM__setExecutionForbidden(JSC__VM* arg0, bool arg1) { (*arg0).setExecutionForbidden(); }
-bool JSC__VM__throwError(JSC__VM *arg0, JSC__JSGlobalObject *arg1, JSC__ThrowScope *arg2,
- const unsigned char *arg3, size_t arg4) {
- auto scope = arg2;
- auto global = arg1;
- const String &message = WTF::String(arg3, arg4);
- return JSC::throwException(global, (*scope), createError(global, message));
+bool JSC__VM__throwError(JSC__VM* arg0, JSC__JSGlobalObject* arg1, JSC__ThrowScope* arg2,
+ const unsigned char* arg3, size_t arg4)
+{
+ auto scope = arg2;
+ auto global = arg1;
+ const String& message = WTF::String(arg3, arg4);
+ return JSC::throwException(global, (*scope), createError(global, message));
}
#pragma mark - JSC::ThrowScope
-void JSC__ThrowScope__clearException(JSC__ThrowScope *arg0) { arg0->clearException(); };
-bJSC__ThrowScope JSC__ThrowScope__declare(JSC__VM *arg0, unsigned char *arg1, unsigned char *arg2,
- size_t arg3) {
- Wrap<JSC::ThrowScope, bJSC__ThrowScope> wrapped = Wrap<JSC::ThrowScope, bJSC__ThrowScope>();
- wrapped.cpp = new (wrapped.alignedBuffer()) JSC::ThrowScope(reinterpret_cast<JSC::VM &>(arg0));
- return wrapped.result;
+void JSC__ThrowScope__clearException(JSC__ThrowScope* arg0)
+{
+ arg0->clearException();
+};
+bJSC__ThrowScope JSC__ThrowScope__declare(JSC__VM* arg0, unsigned char* arg1, unsigned char* arg2,
+ size_t arg3)
+{
+ Wrap<JSC::ThrowScope, bJSC__ThrowScope> wrapped = Wrap<JSC::ThrowScope, bJSC__ThrowScope>();
+ wrapped.cpp = new (wrapped.alignedBuffer()) JSC::ThrowScope(reinterpret_cast<JSC::VM&>(arg0));
+ return wrapped.result;
};
-JSC__Exception *JSC__ThrowScope__exception(JSC__ThrowScope *arg0) { return arg0->exception(); }
-void JSC__ThrowScope__release(JSC__ThrowScope *arg0) { arg0->release(); }
+JSC__Exception* JSC__ThrowScope__exception(JSC__ThrowScope* arg0) { return arg0->exception(); }
+void JSC__ThrowScope__release(JSC__ThrowScope* arg0) { arg0->release(); }
#pragma mark - JSC::CatchScope
-void JSC__CatchScope__clearException(JSC__CatchScope *arg0) { arg0->clearException(); }
-bJSC__CatchScope JSC__CatchScope__declare(JSC__VM *arg0, unsigned char *arg1, unsigned char *arg2,
- size_t arg3) {
- JSC::CatchScope scope = JSC::CatchScope(reinterpret_cast<JSC::VM &>(arg0));
- return cast<bJSC__CatchScope>(&scope);
+void JSC__CatchScope__clearException(JSC__CatchScope* arg0)
+{
+ arg0->clearException();
}
-JSC__Exception *JSC__CatchScope__exception(JSC__CatchScope *arg0) { return arg0->exception(); }
+bJSC__CatchScope JSC__CatchScope__declare(JSC__VM* arg0, unsigned char* arg1, unsigned char* arg2,
+ size_t arg3)
+{
+ JSC::CatchScope scope = JSC::CatchScope(reinterpret_cast<JSC::VM&>(arg0));
+ return cast<bJSC__CatchScope>(&scope);
+}
+JSC__Exception* JSC__CatchScope__exception(JSC__CatchScope* arg0) { return arg0->exception(); }
#pragma mark - JSC::CallFrame
-JSC__JSValue JSC__CallFrame__argument(const JSC__CallFrame *arg0, uint16_t arg1) {
- return JSC::JSValue::encode(arg0->argument(arg1));
+JSC__JSValue JSC__CallFrame__argument(const JSC__CallFrame* arg0, uint16_t arg1)
+{
+ return JSC::JSValue::encode(arg0->argument(arg1));
};
-size_t JSC__CallFrame__argumentsCount(const JSC__CallFrame *arg0) { return arg0->argumentCount(); }
-JSC__JSObject *JSC__CallFrame__jsCallee(const JSC__CallFrame *arg0) { return arg0->jsCallee(); }
-JSC__JSValue JSC__CallFrame__newTarget(const JSC__CallFrame *arg0) {
- return JSC::JSValue::encode(arg0->newTarget());
+size_t JSC__CallFrame__argumentsCount(const JSC__CallFrame* arg0) { return arg0->argumentCount(); }
+JSC__JSObject* JSC__CallFrame__jsCallee(const JSC__CallFrame* arg0) { return arg0->jsCallee(); }
+JSC__JSValue JSC__CallFrame__newTarget(const JSC__CallFrame* arg0)
+{
+ return JSC::JSValue::encode(arg0->newTarget());
};
-JSC__JSValue JSC__CallFrame__thisValue(const JSC__CallFrame *arg0) {
- return JSC::JSValue::encode(arg0->thisValue());
+JSC__JSValue JSC__CallFrame__thisValue(const JSC__CallFrame* arg0)
+{
+ return JSC::JSValue::encode(arg0->thisValue());
}
-JSC__JSValue JSC__CallFrame__uncheckedArgument(const JSC__CallFrame *arg0, uint16_t arg1) {
- return JSC::JSValue::encode(arg0->uncheckedArgument(arg1));
+JSC__JSValue JSC__CallFrame__uncheckedArgument(const JSC__CallFrame* arg0, uint16_t arg1)
+{
+ return JSC::JSValue::encode(arg0->uncheckedArgument(arg1));
}
#pragma mark - JSC::Identifier
-void JSC__Identifier__deinit(const JSC__Identifier *arg0) {}
+void JSC__Identifier__deinit(const JSC__Identifier* arg0)
+{
+}
-bool JSC__Identifier__eqlIdent(const JSC__Identifier *arg0, const JSC__Identifier *arg1) {
- return arg0 == arg1;
+bool JSC__Identifier__eqlIdent(const JSC__Identifier* arg0, const JSC__Identifier* arg1)
+{
+ return arg0 == arg1;
};
-bool JSC__Identifier__eqlStringImpl(const JSC__Identifier *arg0, const WTF__StringImpl *arg1) {
- return JSC::Identifier::equal(arg0->string().impl(), arg1);
+bool JSC__Identifier__eqlStringImpl(const JSC__Identifier* arg0, const WTF__StringImpl* arg1)
+{
+ return JSC::Identifier::equal(arg0->string().impl(), arg1);
};
-bool JSC__Identifier__eqlUTF8(const JSC__Identifier *arg0, const unsigned char *arg1, size_t arg2) {
- return JSC::Identifier::equal(arg0->string().impl(), reinterpret_cast<const LChar *>(arg1), arg2);
+bool JSC__Identifier__eqlUTF8(const JSC__Identifier* arg0, const unsigned char* arg1, size_t arg2)
+{
+ return JSC::Identifier::equal(arg0->string().impl(), reinterpret_cast<const LChar*>(arg1), arg2);
};
-bool JSC__Identifier__neqlIdent(const JSC__Identifier *arg0, const JSC__Identifier *arg1) {
- return arg0 != arg1;
+bool JSC__Identifier__neqlIdent(const JSC__Identifier* arg0, const JSC__Identifier* arg1)
+{
+ return arg0 != arg1;
}
-bool JSC__Identifier__neqlStringImpl(const JSC__Identifier *arg0, const WTF__StringImpl *arg1) {
- return !JSC::Identifier::equal(arg0->string().impl(), arg1);
+bool JSC__Identifier__neqlStringImpl(const JSC__Identifier* arg0, const WTF__StringImpl* arg1)
+{
+ return !JSC::Identifier::equal(arg0->string().impl(), arg1);
};
-bJSC__Identifier JSC__Identifier__fromSlice(JSC__VM *arg0, const unsigned char *arg1, size_t arg2) {
- JSC::Identifier ident =
- JSC::Identifier::fromString(reinterpret_cast<JSC__VM &>(arg0),
- reinterpret_cast<const LChar *>(arg1), static_cast<int>(arg2));
- return cast<bJSC__Identifier>(&ident);
+bJSC__Identifier JSC__Identifier__fromSlice(JSC__VM* arg0, const unsigned char* arg1, size_t arg2)
+{
+ JSC::Identifier ident = JSC::Identifier::fromString(reinterpret_cast<JSC__VM&>(arg0),
+ reinterpret_cast<const LChar*>(arg1), static_cast<int>(arg2));
+ return cast<bJSC__Identifier>(&ident);
};
-bJSC__Identifier JSC__Identifier__fromString(JSC__VM *arg0, const WTF__String *arg1) {
- JSC::Identifier ident = JSC::Identifier::fromString(reinterpret_cast<JSC__VM &>(arg0),
- reinterpret_cast<const WTF__String &>(arg1));
- return cast<bJSC__Identifier>(&ident);
+bJSC__Identifier JSC__Identifier__fromString(JSC__VM* arg0, const WTF__String* arg1)
+{
+ JSC::Identifier ident = JSC::Identifier::fromString(reinterpret_cast<JSC__VM&>(arg0),
+ reinterpret_cast<const WTF__String&>(arg1));
+ return cast<bJSC__Identifier>(&ident);
};
// bJSC__Identifier JSC__Identifier__fromUid(JSC__VM* arg0, const
// WTF__StringImpl* arg1) {
// auto ident = JSC::Identifier::fromUid(&arg0, &arg1);
// return *cast<bJSC__Identifier>(&ident);
// };
-bool JSC__Identifier__isEmpty(const JSC__Identifier *arg0) { return arg0->isEmpty(); };
-bool JSC__Identifier__isNull(const JSC__Identifier *arg0) { return arg0->isNull(); };
-bool JSC__Identifier__isPrivateName(const JSC__Identifier *arg0) { return arg0->isPrivateName(); };
-bool JSC__Identifier__isSymbol(const JSC__Identifier *arg0) { return arg0->isSymbol(); };
-size_t JSC__Identifier__length(const JSC__Identifier *arg0) { return arg0->length(); };
+bool JSC__Identifier__isEmpty(const JSC__Identifier* arg0) { return arg0->isEmpty(); };
+bool JSC__Identifier__isNull(const JSC__Identifier* arg0) { return arg0->isNull(); };
+bool JSC__Identifier__isPrivateName(const JSC__Identifier* arg0) { return arg0->isPrivateName(); };
+bool JSC__Identifier__isSymbol(const JSC__Identifier* arg0) { return arg0->isSymbol(); };
+size_t JSC__Identifier__length(const JSC__Identifier* arg0) { return arg0->length(); };
-bWTF__String JSC__Identifier__toString(const JSC__Identifier *arg0) {
- auto string = arg0->string();
- return cast<bWTF__String>(&string);
+bWTF__String JSC__Identifier__toString(const JSC__Identifier* arg0)
+{
+ auto string = arg0->string();
+ return cast<bWTF__String>(&string);
};
#pragma mark - WTF::StringView
-const uint16_t *WTF__StringView__characters16(const WTF__StringView *arg0) {
- WTF::StringView *view = (WTF::StringView *)arg0;
- return reinterpret_cast<const uint16_t *>(view->characters16());
+const uint16_t* WTF__StringView__characters16(const WTF__StringView* arg0)
+{
+ WTF::StringView* view = (WTF::StringView*)arg0;
+ return reinterpret_cast<const uint16_t*>(view->characters16());
}
-const unsigned char *WTF__StringView__characters8(const WTF__StringView *arg0) {
- return reinterpret_cast<const unsigned char *>(arg0->characters8());
+const unsigned char* WTF__StringView__characters8(const WTF__StringView* arg0)
+{
+ return reinterpret_cast<const unsigned char*>(arg0->characters8());
};
-bool WTF__StringView__is16Bit(const WTF__StringView *arg0) { return !arg0->is8Bit(); };
-bool WTF__StringView__is8Bit(const WTF__StringView *arg0) { return arg0->is8Bit(); };
-bool WTF__StringView__isEmpty(const WTF__StringView *arg0) { return arg0->isEmpty(); };
-size_t WTF__StringView__length(const WTF__StringView *arg0) { return arg0->length(); };
+bool WTF__StringView__is16Bit(const WTF__StringView* arg0) { return !arg0->is8Bit(); };
+bool WTF__StringView__is8Bit(const WTF__StringView* arg0) { return arg0->is8Bit(); };
+bool WTF__StringView__isEmpty(const WTF__StringView* arg0) { return arg0->isEmpty(); };
+size_t WTF__StringView__length(const WTF__StringView* arg0) { return arg0->length(); };
#pragma mark - WTF::StringImpl
-const uint16_t *WTF__StringImpl__characters16(const WTF__StringImpl *arg0) {
- return reinterpret_cast<const uint16_t *>(arg0->characters16());
+const uint16_t* WTF__StringImpl__characters16(const WTF__StringImpl* arg0)
+{
+ return reinterpret_cast<const uint16_t*>(arg0->characters16());
}
-const unsigned char *WTF__StringImpl__characters8(const WTF__StringImpl *arg0) {
- return reinterpret_cast<const unsigned char *>(arg0->characters8());
+const unsigned char* WTF__StringImpl__characters8(const WTF__StringImpl* arg0)
+{
+ return reinterpret_cast<const unsigned char*>(arg0->characters8());
}
-void WTF__StringView__from8Bit(WTF__StringView *arg0, const unsigned char *arg1, size_t arg2) {
- *arg0 = WTF::StringView(arg1, arg2);
+void WTF__StringView__from8Bit(WTF__StringView* arg0, const unsigned char* arg1, size_t arg2)
+{
+ *arg0 = WTF::StringView(arg1, arg2);
}
-bool WTF__StringImpl__is16Bit(const WTF__StringImpl *arg0) { return !arg0->is8Bit(); }
-bool WTF__StringImpl__is8Bit(const WTF__StringImpl *arg0) { return arg0->is8Bit(); }
-bool WTF__StringImpl__isEmpty(const WTF__StringImpl *arg0) { return arg0->isEmpty(); }
-bool WTF__StringImpl__isExternal(const WTF__StringImpl *arg0) { return arg0->isExternal(); }
-bool WTF__StringImpl__isStatic(const WTF__StringImpl *arg0) { return arg0->isStatic(); }
-size_t WTF__StringImpl__length(const WTF__StringImpl *arg0) { return arg0->length(); }
+bool WTF__StringImpl__is16Bit(const WTF__StringImpl* arg0) { return !arg0->is8Bit(); }
+bool WTF__StringImpl__is8Bit(const WTF__StringImpl* arg0) { return arg0->is8Bit(); }
+bool WTF__StringImpl__isEmpty(const WTF__StringImpl* arg0) { return arg0->isEmpty(); }
+bool WTF__StringImpl__isExternal(const WTF__StringImpl* arg0) { return arg0->isExternal(); }
+bool WTF__StringImpl__isStatic(const WTF__StringImpl* arg0) { return arg0->isStatic(); }
+size_t WTF__StringImpl__length(const WTF__StringImpl* arg0) { return arg0->length(); }
#pragma mark - WTF::ExternalStringImpl
-const uint16_t *WTF__ExternalStringImpl__characters16(const WTF__ExternalStringImpl *arg0) {
- return reinterpret_cast<const uint16_t *>(arg0->characters16());
+const uint16_t* WTF__ExternalStringImpl__characters16(const WTF__ExternalStringImpl* arg0)
+{
+ return reinterpret_cast<const uint16_t*>(arg0->characters16());
}
-const unsigned char *WTF__ExternalStringImpl__characters8(const WTF__ExternalStringImpl *arg0) {
- return reinterpret_cast<const unsigned char *>(arg0->characters8());
+const unsigned char* WTF__ExternalStringImpl__characters8(const WTF__ExternalStringImpl* arg0)
+{
+ return reinterpret_cast<const unsigned char*>(arg0->characters8());
}
-bool WTF__ExternalStringImpl__is16Bit(const WTF__ExternalStringImpl *arg0) {
- return !arg0->is8Bit();
+bool WTF__ExternalStringImpl__is16Bit(const WTF__ExternalStringImpl* arg0)
+{
+ return !arg0->is8Bit();
}
-bool WTF__ExternalStringImpl__is8Bit(const WTF__ExternalStringImpl *arg0) { return arg0->is8Bit(); }
-bool WTF__ExternalStringImpl__isEmpty(const WTF__ExternalStringImpl *arg0) {
- return arg0->isEmpty();
+bool WTF__ExternalStringImpl__is8Bit(const WTF__ExternalStringImpl* arg0) { return arg0->is8Bit(); }
+bool WTF__ExternalStringImpl__isEmpty(const WTF__ExternalStringImpl* arg0)
+{
+ return arg0->isEmpty();
}
-bool WTF__ExternalStringImpl__isExternal(const WTF__ExternalStringImpl *arg0) {
- return arg0->isExternal();
+bool WTF__ExternalStringImpl__isExternal(const WTF__ExternalStringImpl* arg0)
+{
+ return arg0->isExternal();
}
-bool WTF__ExternalStringImpl__isStatic(const WTF__ExternalStringImpl *arg0) {
- return arg0->isStatic();
+bool WTF__ExternalStringImpl__isStatic(const WTF__ExternalStringImpl* arg0)
+{
+ return arg0->isStatic();
}
-size_t WTF__ExternalStringImpl__length(const WTF__ExternalStringImpl *arg0) {
- return arg0->length();
+size_t WTF__ExternalStringImpl__length(const WTF__ExternalStringImpl* arg0)
+{
+ return arg0->length();
}
#pragma mark - WTF::String
-const uint16_t *WTF__String__characters16(WTF__String *arg0) {
- return reinterpret_cast<const uint16_t *>(arg0->characters16());
+const uint16_t* WTF__String__characters16(WTF__String* arg0)
+{
+ return reinterpret_cast<const uint16_t*>(arg0->characters16());
};
-const unsigned char *WTF__String__characters8(WTF__String *arg0) {
- return reinterpret_cast<const unsigned char *>(arg0->characters8());
+const unsigned char* WTF__String__characters8(WTF__String* arg0)
+{
+ return reinterpret_cast<const unsigned char*>(arg0->characters8());
};
-bool WTF__String__eqlSlice(WTF__String *arg0, const unsigned char *arg1, size_t arg2) {
- return WTF::equal(arg0->impl(), reinterpret_cast<const LChar *>(arg1), arg2);
+bool WTF__String__eqlSlice(WTF__String* arg0, const unsigned char* arg1, size_t arg2)
+{
+ return WTF::equal(arg0->impl(), reinterpret_cast<const LChar*>(arg1), arg2);
}
-bool WTF__String__eqlString(WTF__String *arg0, const WTF__String *arg1) { return arg0 == arg1; }
-const WTF__StringImpl *WTF__String__impl(WTF__String *arg0) { return arg0->impl(); }
+bool WTF__String__eqlString(WTF__String* arg0, const WTF__String* arg1) { return arg0 == arg1; }
+const WTF__StringImpl* WTF__String__impl(WTF__String* arg0) { return arg0->impl(); }
-bool WTF__String__is16Bit(WTF__String *arg0) { return !arg0->is8Bit(); }
-bool WTF__String__is8Bit(WTF__String *arg0) { return arg0->is8Bit(); }
-bool WTF__String__isEmpty(WTF__String *arg0) { return arg0->isEmpty(); }
-bool WTF__String__isExternal(WTF__String *arg0) { return arg0->impl()->isExternal(); }
-bool WTF__String__isStatic(WTF__String *arg0) { return arg0->impl()->isStatic(); }
-size_t WTF__String__length(WTF__String *arg0) { return arg0->length(); }
+bool WTF__String__is16Bit(WTF__String* arg0) { return !arg0->is8Bit(); }
+bool WTF__String__is8Bit(WTF__String* arg0) { return arg0->is8Bit(); }
+bool WTF__String__isEmpty(WTF__String* arg0) { return arg0->isEmpty(); }
+bool WTF__String__isExternal(WTF__String* arg0) { return arg0->impl()->isExternal(); }
+bool WTF__String__isStatic(WTF__String* arg0) { return arg0->impl()->isStatic(); }
+size_t WTF__String__length(WTF__String* arg0) { return arg0->length(); }
-bWTF__String WTF__String__createFromExternalString(bWTF__ExternalStringImpl arg0) {
- auto external = Wrap<WTF::ExternalStringImpl, bWTF__ExternalStringImpl>(arg0);
- return Wrap<WTF::String, bWTF__String>(WTF::String(external.cpp)).result;
+bWTF__String WTF__String__createFromExternalString(bWTF__ExternalStringImpl arg0)
+{
+ auto external = Wrap<WTF::ExternalStringImpl, bWTF__ExternalStringImpl>(arg0);
+ return Wrap<WTF::String, bWTF__String>(WTF::String(external.cpp)).result;
};
-void WTF__String__createWithoutCopyingFromPtr(WTF__String *str, const unsigned char *arg0,
- size_t arg1) {
- auto new_str = new (reinterpret_cast<char *>(str)) WTF::String(arg0, arg1);
- new_str->impl()->ref();
+void WTF__String__createWithoutCopyingFromPtr(WTF__String* str, const unsigned char* arg0,
+ size_t arg1)
+{
+ auto new_str = new (reinterpret_cast<char*>(str)) WTF::String(arg0, arg1);
+ new_str->impl()->ref();
}
#pragma mark - WTF::URL
-bWTF__StringView WTF__URL__encodedPassword(WTF__URL *arg0) {
- auto result = arg0->encodedPassword();
- return cast<bWTF__StringView>(&result);
-};
-bWTF__StringView WTF__URL__encodedUser(WTF__URL *arg0) {
- auto result = arg0->encodedUser();
- return cast<bWTF__StringView>(&result);
-};
-bWTF__String WTF__URL__fileSystemPath(WTF__URL *arg0) {
- auto result = arg0->fileSystemPath();
- return cast<bWTF__String>(&result);
-};
-bWTF__StringView WTF__URL__fragmentIdentifier(WTF__URL *arg0) {
- auto result = arg0->fragmentIdentifier();
- return cast<bWTF__StringView>(&result);
-};
-bWTF__StringView WTF__URL__fragmentIdentifierWithLeadingNumberSign(WTF__URL *arg0) {
- auto result = arg0->fragmentIdentifierWithLeadingNumberSign();
- return cast<bWTF__StringView>(&result);
-};
-void WTF__URL__fromFileSystemPath(WTF::URL *result, bWTF__StringView arg0) {
- Wrap<WTF::StringView, bWTF__StringView> fsPath = Wrap<WTF::StringView, bWTF__StringView>(&arg0);
- *result = WTF::URL::fileURLWithFileSystemPath(*fsPath.cpp);
- result->string().impl()->ref();
-};
-bWTF__URL WTF__URL__fromString(bWTF__String arg0, bWTF__String arg1) {
- WTF::URL url = WTF::URL(WTF::URL(), cast<WTF::String>(&arg1));
- return cast<bWTF__URL>(&url);
-};
-bWTF__StringView WTF__URL__host(WTF__URL *arg0) {
- auto result = arg0->host();
- return cast<bWTF__StringView>(&result);
-};
-bWTF__String WTF__URL__hostAndPort(WTF__URL *arg0) {
- auto result = arg0->hostAndPort();
- return cast<bWTF__String>(&result);
-};
-bool WTF__URL__isEmpty(const WTF__URL *arg0) { return arg0->isEmpty(); };
-bool WTF__URL__isValid(const WTF__URL *arg0) { return arg0->isValid(); };
-bWTF__StringView WTF__URL__lastPathComponent(WTF__URL *arg0) {
- auto result = arg0->lastPathComponent();
- return cast<bWTF__StringView>(&result);
-};
-bWTF__String WTF__URL__password(WTF__URL *arg0) {
- auto result = arg0->password();
- return cast<bWTF__String>(&result);
-};
-bWTF__StringView WTF__URL__path(WTF__URL *arg0) {
- auto wrap = Wrap<WTF::StringView, bWTF__StringView>(arg0->path());
- return wrap.result;
-};
-bWTF__StringView WTF__URL__protocol(WTF__URL *arg0) {
- auto result = arg0->protocol();
- return cast<bWTF__StringView>(&result);
-};
-bWTF__String WTF__URL__protocolHostAndPort(WTF__URL *arg0) {
- auto result = arg0->protocolHostAndPort();
- return cast<bWTF__String>(&result);
-};
-bWTF__StringView WTF__URL__query(WTF__URL *arg0) {
- auto result = arg0->query();
- return cast<bWTF__StringView>(&result);
-};
-bWTF__StringView WTF__URL__queryWithLeadingQuestionMark(WTF__URL *arg0) {
- auto result = arg0->queryWithLeadingQuestionMark();
- return cast<bWTF__StringView>(&result);
-};
-bWTF__String WTF__URL__stringWithoutFragmentIdentifier(WTF__URL *arg0) {
- auto result = arg0->stringWithoutFragmentIdentifier();
- return cast<bWTF__String>(&result);
-};
-bWTF__StringView WTF__URL__stringWithoutQueryOrFragmentIdentifier(WTF__URL *arg0) {
- auto result = arg0->stringWithoutQueryOrFragmentIdentifier();
- return cast<bWTF__StringView>(&result);
-};
-bWTF__URL WTF__URL__truncatedForUseAsBase(WTF__URL *arg0) {
- auto result = arg0->truncatedForUseAsBase();
- return cast<bWTF__URL>(&result);
-};
-bWTF__String WTF__URL__user(WTF__URL *arg0) {
- auto result = arg0->user();
- return cast<bWTF__String>(&result);
-};
-
-void WTF__URL__setHost(WTF__URL *arg0, bWTF__StringView arg1) {
- arg0->setHost(*Wrap<WTF::StringView, bWTF__StringView>::unwrap(&arg1));
-};
-void WTF__URL__setHostAndPort(WTF__URL *arg0, bWTF__StringView arg1) {
- arg0->setHostAndPort(*Wrap<WTF::StringView, bWTF__StringView>::unwrap(&arg1));
-};
-void WTF__URL__setPassword(WTF__URL *arg0, bWTF__StringView arg1) {
- arg0->setPassword(*Wrap<WTF::StringView, bWTF__StringView>::unwrap(&arg1));
-};
-void WTF__URL__setPath(WTF__URL *arg0, bWTF__StringView arg1) {
- arg0->setPath(*Wrap<WTF::StringView, bWTF__StringView>::unwrap(&arg1));
-};
-void WTF__URL__setProtocol(WTF__URL *arg0, bWTF__StringView arg1) {
- arg0->setProtocol(*Wrap<WTF::StringView, bWTF__StringView>::unwrap(&arg1));
-};
-void WTF__URL__setQuery(WTF__URL *arg0, bWTF__StringView arg1) {
- arg0->setQuery(*Wrap<WTF::StringView, bWTF__StringView>::unwrap(&arg1));
-};
-void WTF__URL__setUser(WTF__URL *arg0, bWTF__StringView arg1) {
- arg0->setUser(*Wrap<WTF::StringView, bWTF__StringView>::unwrap(&arg1));
-};
-
-JSC__JSValue JSC__JSPromise__rejectedPromiseValue(JSC__JSGlobalObject *arg0,
- JSC__JSValue JSValue1) {
- return JSC::JSValue::encode(
- JSC::JSPromise::rejectedPromise(arg0, JSC::JSValue::decode(JSValue1)));
-}
-JSC__JSValue JSC__JSPromise__resolvedPromiseValue(JSC__JSGlobalObject *arg0,
- JSC__JSValue JSValue1) {
- return JSC::JSValue::encode(
- JSC::JSPromise::resolvedPromise(arg0, JSC::JSValue::decode(JSValue1)));
+bWTF__StringView WTF__URL__encodedPassword(WTF__URL* arg0)
+{
+ auto result = arg0->encodedPassword();
+ return cast<bWTF__StringView>(&result);
+};
+bWTF__StringView WTF__URL__encodedUser(WTF__URL* arg0)
+{
+ auto result = arg0->encodedUser();
+ return cast<bWTF__StringView>(&result);
+};
+bWTF__String WTF__URL__fileSystemPath(WTF__URL* arg0)
+{
+ auto result = arg0->fileSystemPath();
+ return cast<bWTF__String>(&result);
+};
+bWTF__StringView WTF__URL__fragmentIdentifier(WTF__URL* arg0)
+{
+ auto result = arg0->fragmentIdentifier();
+ return cast<bWTF__StringView>(&result);
+};
+bWTF__StringView WTF__URL__fragmentIdentifierWithLeadingNumberSign(WTF__URL* arg0)
+{
+ auto result = arg0->fragmentIdentifierWithLeadingNumberSign();
+ return cast<bWTF__StringView>(&result);
+};
+void WTF__URL__fromFileSystemPath(WTF::URL* result, bWTF__StringView arg0)
+{
+ Wrap<WTF::StringView, bWTF__StringView> fsPath = Wrap<WTF::StringView, bWTF__StringView>(&arg0);
+ *result = WTF::URL::fileURLWithFileSystemPath(*fsPath.cpp);
+ result->string().impl()->ref();
+};
+bWTF__URL WTF__URL__fromString(bWTF__String arg0, bWTF__String arg1)
+{
+ WTF::URL url = WTF::URL(WTF::URL(), cast<WTF::String>(&arg1));
+ return cast<bWTF__URL>(&url);
+};
+bWTF__StringView WTF__URL__host(WTF__URL* arg0)
+{
+ auto result = arg0->host();
+ return cast<bWTF__StringView>(&result);
+};
+bWTF__String WTF__URL__hostAndPort(WTF__URL* arg0)
+{
+ auto result = arg0->hostAndPort();
+ return cast<bWTF__String>(&result);
+};
+bool WTF__URL__isEmpty(const WTF__URL* arg0) { return arg0->isEmpty(); };
+bool WTF__URL__isValid(const WTF__URL* arg0) { return arg0->isValid(); };
+bWTF__StringView WTF__URL__lastPathComponent(WTF__URL* arg0)
+{
+ auto result = arg0->lastPathComponent();
+ return cast<bWTF__StringView>(&result);
+};
+bWTF__String WTF__URL__password(WTF__URL* arg0)
+{
+ auto result = arg0->password();
+ return cast<bWTF__String>(&result);
+};
+bWTF__StringView WTF__URL__path(WTF__URL* arg0)
+{
+ auto wrap = Wrap<WTF::StringView, bWTF__StringView>(arg0->path());
+ return wrap.result;
+};
+bWTF__StringView WTF__URL__protocol(WTF__URL* arg0)
+{
+ auto result = arg0->protocol();
+ return cast<bWTF__StringView>(&result);
+};
+bWTF__String WTF__URL__protocolHostAndPort(WTF__URL* arg0)
+{
+ auto result = arg0->protocolHostAndPort();
+ return cast<bWTF__String>(&result);
+};
+bWTF__StringView WTF__URL__query(WTF__URL* arg0)
+{
+ auto result = arg0->query();
+ return cast<bWTF__StringView>(&result);
+};
+bWTF__StringView WTF__URL__queryWithLeadingQuestionMark(WTF__URL* arg0)
+{
+ auto result = arg0->queryWithLeadingQuestionMark();
+ return cast<bWTF__StringView>(&result);
+};
+bWTF__String WTF__URL__stringWithoutFragmentIdentifier(WTF__URL* arg0)
+{
+ auto result = arg0->stringWithoutFragmentIdentifier();
+ return cast<bWTF__String>(&result);
+};
+bWTF__StringView WTF__URL__stringWithoutQueryOrFragmentIdentifier(WTF__URL* arg0)
+{
+ auto result = arg0->stringWithoutQueryOrFragmentIdentifier();
+ return cast<bWTF__StringView>(&result);
+};
+bWTF__URL WTF__URL__truncatedForUseAsBase(WTF__URL* arg0)
+{
+ auto result = arg0->truncatedForUseAsBase();
+ return cast<bWTF__URL>(&result);
+};
+bWTF__String WTF__URL__user(WTF__URL* arg0)
+{
+ auto result = arg0->user();
+ return cast<bWTF__String>(&result);
+};
+
+void WTF__URL__setHost(WTF__URL* arg0, bWTF__StringView arg1)
+{
+ arg0->setHost(*Wrap<WTF::StringView, bWTF__StringView>::unwrap(&arg1));
+};
+void WTF__URL__setHostAndPort(WTF__URL* arg0, bWTF__StringView arg1)
+{
+ arg0->setHostAndPort(*Wrap<WTF::StringView, bWTF__StringView>::unwrap(&arg1));
+};
+void WTF__URL__setPassword(WTF__URL* arg0, bWTF__StringView arg1)
+{
+ arg0->setPassword(*Wrap<WTF::StringView, bWTF__StringView>::unwrap(&arg1));
+};
+void WTF__URL__setPath(WTF__URL* arg0, bWTF__StringView arg1)
+{
+ arg0->setPath(*Wrap<WTF::StringView, bWTF__StringView>::unwrap(&arg1));
+};
+void WTF__URL__setProtocol(WTF__URL* arg0, bWTF__StringView arg1)
+{
+ arg0->setProtocol(*Wrap<WTF::StringView, bWTF__StringView>::unwrap(&arg1));
+};
+void WTF__URL__setQuery(WTF__URL* arg0, bWTF__StringView arg1)
+{
+ arg0->setQuery(*Wrap<WTF::StringView, bWTF__StringView>::unwrap(&arg1));
+};
+void WTF__URL__setUser(WTF__URL* arg0, bWTF__StringView arg1)
+{
+ arg0->setUser(*Wrap<WTF::StringView, bWTF__StringView>::unwrap(&arg1));
+};
+
+JSC__JSValue JSC__JSPromise__rejectedPromiseValue(JSC__JSGlobalObject* arg0,
+ JSC__JSValue JSValue1)
+{
+ return JSC::JSValue::encode(
+ JSC::JSPromise::rejectedPromise(arg0, JSC::JSValue::decode(JSValue1)));
+}
+JSC__JSValue JSC__JSPromise__resolvedPromiseValue(JSC__JSGlobalObject* arg0,
+ JSC__JSValue JSValue1)
+{
+ return JSC::JSValue::encode(
+ JSC::JSPromise::resolvedPromise(arg0, JSC::JSValue::decode(JSValue1)));
}
} \ No newline at end of file
diff --git a/src/javascript/jsc/bindings/headers-handwritten.h b/src/javascript/jsc/bindings/headers-handwritten.h
index ee038999f..26eee4407 100644
--- a/src/javascript/jsc/bindings/headers-handwritten.h
+++ b/src/javascript/jsc/bindings/headers-handwritten.h
@@ -3,44 +3,44 @@
typedef uint16_t ZigErrorCode;
typedef struct ZigString {
- const unsigned char *ptr;
- size_t len;
+ const unsigned char* ptr;
+ size_t len;
} ZigString;
typedef struct ZigErrorType {
- ZigErrorCode code;
- void *ptr;
+ ZigErrorCode code;
+ void* ptr;
} ZigErrorType;
typedef union ErrorableZigStringResult {
- ZigString value;
- ZigErrorType err;
+ ZigString value;
+ ZigErrorType err;
} ErrorableZigStringResult;
typedef struct ErrorableZigString {
- ErrorableZigStringResult result;
- bool success;
+ ErrorableZigStringResult result;
+ bool success;
} ErrorableZigString;
typedef struct ResolvedSource {
- ZigString specifier;
- ZigString source_code;
- ZigString source_url;
- uint32_t hash;
- void *allocator;
- uint64_t bytecodecache_fd;
+ ZigString specifier;
+ ZigString source_code;
+ ZigString source_url;
+ uint32_t hash;
+ void* allocator;
+ uint64_t bytecodecache_fd;
} ResolvedSource;
typedef union ErrorableResolvedSourceResult {
- ResolvedSource value;
- ZigErrorType err;
+ ResolvedSource value;
+ ZigErrorType err;
} ErrorableResolvedSourceResult;
typedef struct ErrorableResolvedSource {
- ErrorableResolvedSourceResult result;
- bool success;
+ ErrorableResolvedSourceResult result;
+ bool success;
} ErrorableResolvedSource;
typedef struct SystemError {
- int errno_;
- ZigString code;
- ZigString message;
- ZigString path;
- ZigString syscall;
+ int errno_;
+ ZigString code;
+ ZigString message;
+ ZigString path;
+ ZigString syscall;
} SystemError;
typedef uint8_t ZigStackFrameCode;
@@ -53,43 +53,43 @@ const ZigStackFrameCode ZigStackFrameCodeWasm = 5;
const ZigStackFrameCode ZigStackFrameCodeConstructor = 6;
typedef struct ZigStackFramePosition {
- int32_t source_offset;
- int32_t line;
- int32_t line_start;
- int32_t line_stop;
- int32_t column_start;
- int32_t column_stop;
- int32_t expression_start;
- int32_t expression_stop;
+ int32_t source_offset;
+ int32_t line;
+ int32_t line_start;
+ int32_t line_stop;
+ int32_t column_start;
+ int32_t column_stop;
+ int32_t expression_start;
+ int32_t expression_stop;
} ZigStackFramePosition;
typedef struct ZigStackFrame {
- ZigString function_name;
- ZigString source_url;
- ZigStackFramePosition position;
- ZigStackFrameCode code_type;
+ ZigString function_name;
+ ZigString source_url;
+ ZigStackFramePosition position;
+ ZigStackFrameCode code_type;
} ZigStackFrame;
typedef struct ZigStackTrace {
- ZigString *source_lines_ptr;
- int32_t *source_lines_numbers;
- uint8_t source_lines_len;
- uint8_t source_lines_to_collect;
- ZigStackFrame *frames_ptr;
- uint8_t frames_len;
+ ZigString* source_lines_ptr;
+ int32_t* source_lines_numbers;
+ uint8_t source_lines_len;
+ uint8_t source_lines_to_collect;
+ ZigStackFrame* frames_ptr;
+ uint8_t frames_len;
} ZigStackTrace;
typedef struct ZigException {
- unsigned char code;
- uint16_t runtime_type;
- int errno_;
- ZigString syscall;
- ZigString code_;
- ZigString path;
- ZigString name;
- ZigString message;
- ZigStackTrace stack;
- void *exception;
+ unsigned char code;
+ uint16_t runtime_type;
+ int errno_;
+ ZigString syscall;
+ ZigString code_;
+ ZigString path;
+ ZigString name;
+ ZigString message;
+ ZigStackTrace stack;
+ void* exception;
} ZigException;
typedef uint8_t JSErrorCode;
@@ -141,55 +141,55 @@ const ReadableEvent ReadableEvent__Open = 7;
const ReadableEvent ReadableEventUser = 254;
typedef struct {
- uint32_t highwater_mark;
- Encoding encoding;
- int32_t start;
- int32_t end;
- bool readable;
- bool aborted;
- bool did_read;
- bool ended;
- uint8_t flowing;
- bool emit_close;
- bool emit_end;
+ uint32_t highwater_mark;
+ Encoding encoding;
+ int32_t start;
+ int32_t end;
+ bool readable;
+ bool aborted;
+ bool did_read;
+ bool ended;
+ uint8_t flowing;
+ bool emit_close;
+ bool emit_end;
} Bun__Readable;
typedef struct {
- uint32_t highwater_mark;
- Encoding encoding;
- uint32_t start;
- bool destroyed;
- bool ended;
- bool corked;
- bool finished;
- bool emit_close;
+ uint32_t highwater_mark;
+ Encoding encoding;
+ uint32_t start;
+ bool destroyed;
+ bool ended;
+ bool corked;
+ bool finished;
+ bool emit_close;
} Bun__Writable;
typedef struct {
- char *ptr;
- uint32_t offset;
- uint32_t len;
- uint32_t byte_len;
- uint8_t cell_type;
+ char* ptr;
+ uint32_t offset;
+ uint32_t len;
+ uint32_t byte_len;
+ uint8_t cell_type;
} Bun__ArrayBuffer;
#ifdef __cplusplus
extern "C" ZigErrorCode Zig_ErrorCodeParserError;
-extern "C" void ZigString__free(const unsigned char *ptr, size_t len, void *allocator);
-extern "C" void Microtask__run(void *ptr, void *global);
+extern "C" void ZigString__free(const unsigned char* ptr, size_t len, void* allocator);
+extern "C" void Microtask__run(void* ptr, void* global);
// Used in process.version
-extern "C" const char *Bun__version;
+extern "C" const char* Bun__version;
// Used in process.versions
-extern "C" const char *Bun__versions_webkit;
-extern "C" const char *Bun__versions_mimalloc;
-extern "C" const char *Bun__versions_libarchive;
-extern "C" const char *Bun__versions_picohttpparser;
-extern "C" const char *Bun__versions_boringssl;
-extern "C" const char *Bun__versions_zlib;
-extern "C" const char *Bun__versions_zig;
+extern "C" const char* Bun__versions_webkit;
+extern "C" const char* Bun__versions_mimalloc;
+extern "C" const char* Bun__versions_libarchive;
+extern "C" const char* Bun__versions_picohttpparser;
+extern "C" const char* Bun__versions_boringssl;
+extern "C" const char* Bun__versions_zlib;
+extern "C" const char* Bun__versions_zig;
#endif
diff --git a/src/javascript/jsc/bindings/headers.h b/src/javascript/jsc/bindings/headers.h
index 2f50b5726..a742dba7d 100644
--- a/src/javascript/jsc/bindings/headers.h
+++ b/src/javascript/jsc/bindings/headers.h
@@ -2,16 +2,16 @@
//-- AUTOGENERATED FILE -- 1645447009
#pragma once
+#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
-#include <stdbool.h>
#ifdef __cplusplus
- #define AUTO_EXTERN_C extern "C"
- #define AUTO_EXTERN_C_ZIG extern "C" __attribute__((weak))
+#define AUTO_EXTERN_C extern "C"
+#define AUTO_EXTERN_C_ZIG extern "C" __attribute__((weak))
#else
- #define AUTO_EXTERN_C
- #define AUTO_EXTERN_C_ZIG __attribute__((weak))
+#define AUTO_EXTERN_C
+#define AUTO_EXTERN_C_ZIG __attribute__((weak))
#endif
#define ZIG_DECL AUTO_EXTERN_C_ZIG
#define CPP_DECL AUTO_EXTERN_C
@@ -26,227 +26,276 @@ typedef void* JSClassRef;
#include <JavaScriptCore/JSClassRef.h>
#endif
#include "headers-handwritten.h"
- typedef struct bJSC__JSModuleRecord { unsigned char bytes[216]; } bJSC__JSModuleRecord;
- typedef char* bJSC__JSModuleRecord_buf;
- typedef struct bJSC__ThrowScope { unsigned char bytes[8]; } bJSC__ThrowScope;
- typedef char* bJSC__ThrowScope_buf;
- typedef struct bJSC__CallFrame { unsigned char bytes[8]; } bJSC__CallFrame;
- typedef char* bJSC__CallFrame_buf;
- typedef struct bJSC__PropertyName { unsigned char bytes[8]; } bJSC__PropertyName;
- typedef char* bJSC__PropertyName_buf;
- typedef struct bJSC__CatchScope { unsigned char bytes[8]; } bJSC__CatchScope;
- typedef char* bJSC__CatchScope_buf;
- typedef struct bWTF__String { unsigned char bytes[8]; } bWTF__String;
- typedef char* bWTF__String_buf;
- typedef struct bWTF__StringView { unsigned char bytes[16]; } bWTF__StringView;
- typedef char* bWTF__StringView_buf;
- typedef struct bJSC__JSModuleLoader { unsigned char bytes[16]; } bJSC__JSModuleLoader;
- typedef char* bJSC__JSModuleLoader_buf;
- typedef struct bJSC__Exception { unsigned char bytes[40]; } bJSC__Exception;
- typedef char* bJSC__Exception_buf;
- typedef struct bJSC__VM { unsigned char bytes[48824]; } bJSC__VM;
- typedef char* bJSC__VM_buf;
- typedef struct bJSC__JSString { unsigned char bytes[16]; } bJSC__JSString;
- typedef char* bJSC__JSString_buf;
- typedef struct bJSC__SourceOrigin { unsigned char bytes[48]; } bJSC__SourceOrigin;
- typedef char* bJSC__SourceOrigin_buf;
- typedef struct bWTF__ExternalStringImpl { unsigned char bytes[32]; } bWTF__ExternalStringImpl;
- typedef char* bWTF__ExternalStringImpl_buf;
- typedef struct bWTF__StringImpl { unsigned char bytes[24]; } bWTF__StringImpl;
- typedef char* bWTF__StringImpl_buf;
- typedef struct bJSC__SourceCode { unsigned char bytes[24]; } bJSC__SourceCode;
- typedef char* bJSC__SourceCode_buf;
- typedef struct bJSC__JSPromise { unsigned char bytes[32]; } bJSC__JSPromise;
- typedef char* bJSC__JSPromise_buf;
- typedef struct bWTF__URL { unsigned char bytes[40]; } bWTF__URL;
- typedef char* bWTF__URL_buf;
- typedef struct bJSC__JSFunction { unsigned char bytes[32]; } bJSC__JSFunction;
- typedef char* bJSC__JSFunction_buf;
- typedef struct bJSC__JSGlobalObject { unsigned char bytes[2400]; } bJSC__JSGlobalObject;
- typedef char* bJSC__JSGlobalObject_buf;
- typedef struct bJSC__JSCell { unsigned char bytes[8]; } bJSC__JSCell;
- typedef char* bJSC__JSCell_buf;
- typedef struct bJSC__JSLock { unsigned char bytes[40]; } bJSC__JSLock;
- typedef char* bJSC__JSLock_buf;
- typedef struct bInspector__ScriptArguments { unsigned char bytes[32]; } bInspector__ScriptArguments;
- typedef char* bInspector__ScriptArguments_buf;
- typedef struct bJSC__JSInternalPromise { unsigned char bytes[32]; } bJSC__JSInternalPromise;
- typedef char* bJSC__JSInternalPromise_buf;
- typedef struct bJSC__JSObject { unsigned char bytes[16]; } bJSC__JSObject;
- typedef char* bJSC__JSObject_buf;
- typedef struct bJSC__Identifier { unsigned char bytes[8]; } bJSC__Identifier;
- typedef char* bJSC__Identifier_buf;
+typedef struct bJSC__JSModuleRecord {
+ unsigned char bytes[216];
+} bJSC__JSModuleRecord;
+typedef char* bJSC__JSModuleRecord_buf;
+typedef struct bJSC__ThrowScope {
+ unsigned char bytes[8];
+} bJSC__ThrowScope;
+typedef char* bJSC__ThrowScope_buf;
+typedef struct bJSC__CallFrame {
+ unsigned char bytes[8];
+} bJSC__CallFrame;
+typedef char* bJSC__CallFrame_buf;
+typedef struct bJSC__PropertyName {
+ unsigned char bytes[8];
+} bJSC__PropertyName;
+typedef char* bJSC__PropertyName_buf;
+typedef struct bJSC__CatchScope {
+ unsigned char bytes[8];
+} bJSC__CatchScope;
+typedef char* bJSC__CatchScope_buf;
+typedef struct bWTF__String {
+ unsigned char bytes[8];
+} bWTF__String;
+typedef char* bWTF__String_buf;
+typedef struct bWTF__StringView {
+ unsigned char bytes[16];
+} bWTF__StringView;
+typedef char* bWTF__StringView_buf;
+typedef struct bJSC__JSModuleLoader {
+ unsigned char bytes[16];
+} bJSC__JSModuleLoader;
+typedef char* bJSC__JSModuleLoader_buf;
+typedef struct bJSC__Exception {
+ unsigned char bytes[40];
+} bJSC__Exception;
+typedef char* bJSC__Exception_buf;
+typedef struct bJSC__VM {
+ unsigned char bytes[48824];
+} bJSC__VM;
+typedef char* bJSC__VM_buf;
+typedef struct bJSC__JSString {
+ unsigned char bytes[16];
+} bJSC__JSString;
+typedef char* bJSC__JSString_buf;
+typedef struct bJSC__SourceOrigin {
+ unsigned char bytes[48];
+} bJSC__SourceOrigin;
+typedef char* bJSC__SourceOrigin_buf;
+typedef struct bWTF__ExternalStringImpl {
+ unsigned char bytes[32];
+} bWTF__ExternalStringImpl;
+typedef char* bWTF__ExternalStringImpl_buf;
+typedef struct bWTF__StringImpl {
+ unsigned char bytes[24];
+} bWTF__StringImpl;
+typedef char* bWTF__StringImpl_buf;
+typedef struct bJSC__SourceCode {
+ unsigned char bytes[24];
+} bJSC__SourceCode;
+typedef char* bJSC__SourceCode_buf;
+typedef struct bJSC__JSPromise {
+ unsigned char bytes[32];
+} bJSC__JSPromise;
+typedef char* bJSC__JSPromise_buf;
+typedef struct bWTF__URL {
+ unsigned char bytes[40];
+} bWTF__URL;
+typedef char* bWTF__URL_buf;
+typedef struct bJSC__JSFunction {
+ unsigned char bytes[32];
+} bJSC__JSFunction;
+typedef char* bJSC__JSFunction_buf;
+typedef struct bJSC__JSGlobalObject {
+ unsigned char bytes[2400];
+} bJSC__JSGlobalObject;
+typedef char* bJSC__JSGlobalObject_buf;
+typedef struct bJSC__JSCell {
+ unsigned char bytes[8];
+} bJSC__JSCell;
+typedef char* bJSC__JSCell_buf;
+typedef struct bJSC__JSLock {
+ unsigned char bytes[40];
+} bJSC__JSLock;
+typedef char* bJSC__JSLock_buf;
+typedef struct bInspector__ScriptArguments {
+ unsigned char bytes[32];
+} bInspector__ScriptArguments;
+typedef char* bInspector__ScriptArguments_buf;
+typedef struct bJSC__JSInternalPromise {
+ unsigned char bytes[32];
+} bJSC__JSInternalPromise;
+typedef char* bJSC__JSInternalPromise_buf;
+typedef struct bJSC__JSObject {
+ unsigned char bytes[16];
+} bJSC__JSObject;
+typedef char* bJSC__JSObject_buf;
+typedef struct bJSC__Identifier {
+ unsigned char bytes[8];
+} bJSC__Identifier;
+typedef char* bJSC__Identifier_buf;
#ifndef __cplusplus
- typedef bJSC__CatchScope JSC__CatchScope; // JSC::CatchScope
- typedef struct JSC__GeneratorPrototype JSC__GeneratorPrototype; // JSC::GeneratorPrototype
- typedef struct JSC__ArrayIteratorPrototype JSC__ArrayIteratorPrototype; // JSC::ArrayIteratorPrototype
- typedef ErrorableResolvedSource ErrorableResolvedSource;
- typedef struct JSC__JSPromisePrototype JSC__JSPromisePrototype; // JSC::JSPromisePrototype
- typedef ErrorableZigString ErrorableZigString;
- typedef bJSC__PropertyName JSC__PropertyName; // JSC::PropertyName
- typedef bJSC__JSObject JSC__JSObject; // JSC::JSObject
- typedef bWTF__ExternalStringImpl WTF__ExternalStringImpl; // WTF::ExternalStringImpl
- typedef struct JSC__AsyncIteratorPrototype JSC__AsyncIteratorPrototype; // JSC::AsyncIteratorPrototype
- typedef bJSC__JSLock JSC__JSLock; // JSC::JSLock
- typedef bJSC__JSModuleLoader JSC__JSModuleLoader; // JSC::JSModuleLoader
- typedef struct JSC__AsyncGeneratorPrototype JSC__AsyncGeneratorPrototype; // JSC::AsyncGeneratorPrototype
- typedef struct JSC__AsyncGeneratorFunctionPrototype JSC__AsyncGeneratorFunctionPrototype; // JSC::AsyncGeneratorFunctionPrototype
- typedef bJSC__Identifier JSC__Identifier; // JSC::Identifier
- typedef struct JSC__ArrayPrototype JSC__ArrayPrototype; // JSC::ArrayPrototype
- typedef struct Zig__JSMicrotaskCallback Zig__JSMicrotaskCallback; // Zig::JSMicrotaskCallback
- typedef bJSC__JSPromise JSC__JSPromise; // JSC::JSPromise
- typedef struct JSC__SetIteratorPrototype JSC__SetIteratorPrototype; // JSC::SetIteratorPrototype
- typedef SystemError SystemError;
- typedef bJSC__JSCell JSC__JSCell; // JSC::JSCell
- typedef bJSC__SourceOrigin JSC__SourceOrigin; // JSC::SourceOrigin
- typedef bJSC__JSModuleRecord JSC__JSModuleRecord; // JSC::JSModuleRecord
- typedef bWTF__String WTF__String; // WTF::String
- typedef bWTF__URL WTF__URL; // WTF::URL
- typedef struct JSC__IteratorPrototype JSC__IteratorPrototype; // JSC::IteratorPrototype
- typedef Bun__Readable Bun__Readable;
- typedef bJSC__JSInternalPromise JSC__JSInternalPromise; // JSC::JSInternalPromise
- typedef Bun__Writable Bun__Writable;
- typedef struct JSC__RegExpPrototype JSC__RegExpPrototype; // JSC::RegExpPrototype
- typedef bJSC__CallFrame JSC__CallFrame; // JSC::CallFrame
- typedef struct JSC__MapIteratorPrototype JSC__MapIteratorPrototype; // JSC::MapIteratorPrototype
- typedef bWTF__StringView WTF__StringView; // WTF::StringView
- typedef bJSC__ThrowScope JSC__ThrowScope; // JSC::ThrowScope
- typedef bWTF__StringImpl WTF__StringImpl; // WTF::StringImpl
- typedef bJSC__VM JSC__VM; // JSC::VM
- typedef JSClassRef JSClassRef;
- typedef Bun__ArrayBuffer Bun__ArrayBuffer;
- typedef bJSC__JSGlobalObject JSC__JSGlobalObject; // JSC::JSGlobalObject
- typedef bJSC__JSFunction JSC__JSFunction; // JSC::JSFunction
- typedef struct JSC__AsyncFunctionPrototype JSC__AsyncFunctionPrototype; // JSC::AsyncFunctionPrototype
- typedef ZigException ZigException;
- typedef bJSC__SourceCode JSC__SourceCode; // JSC::SourceCode
- typedef struct JSC__BigIntPrototype JSC__BigIntPrototype; // JSC::BigIntPrototype
- typedef struct JSC__GeneratorFunctionPrototype JSC__GeneratorFunctionPrototype; // JSC::GeneratorFunctionPrototype
- typedef ZigString ZigString;
- typedef int64_t JSC__JSValue;
- typedef struct JSC__FunctionPrototype JSC__FunctionPrototype; // JSC::FunctionPrototype
- typedef bInspector__ScriptArguments Inspector__ScriptArguments; // Inspector::ScriptArguments
- typedef bJSC__Exception JSC__Exception; // JSC::Exception
- typedef bJSC__JSString JSC__JSString; // JSC::JSString
- typedef struct JSC__ObjectPrototype JSC__ObjectPrototype; // JSC::ObjectPrototype
- typedef struct JSC__StringPrototype JSC__StringPrototype; // JSC::StringPrototype
+typedef bJSC__CatchScope JSC__CatchScope; // JSC::CatchScope
+typedef struct JSC__GeneratorPrototype JSC__GeneratorPrototype; // JSC::GeneratorPrototype
+typedef struct JSC__ArrayIteratorPrototype JSC__ArrayIteratorPrototype; // JSC::ArrayIteratorPrototype
+typedef ErrorableResolvedSource ErrorableResolvedSource;
+typedef struct JSC__JSPromisePrototype JSC__JSPromisePrototype; // JSC::JSPromisePrototype
+typedef ErrorableZigString ErrorableZigString;
+typedef bJSC__PropertyName JSC__PropertyName; // JSC::PropertyName
+typedef bJSC__JSObject JSC__JSObject; // JSC::JSObject
+typedef bWTF__ExternalStringImpl WTF__ExternalStringImpl; // WTF::ExternalStringImpl
+typedef struct JSC__AsyncIteratorPrototype JSC__AsyncIteratorPrototype; // JSC::AsyncIteratorPrototype
+typedef bJSC__JSLock JSC__JSLock; // JSC::JSLock
+typedef bJSC__JSModuleLoader JSC__JSModuleLoader; // JSC::JSModuleLoader
+typedef struct JSC__AsyncGeneratorPrototype JSC__AsyncGeneratorPrototype; // JSC::AsyncGeneratorPrototype
+typedef struct JSC__AsyncGeneratorFunctionPrototype JSC__AsyncGeneratorFunctionPrototype; // JSC::AsyncGeneratorFunctionPrototype
+typedef bJSC__Identifier JSC__Identifier; // JSC::Identifier
+typedef struct JSC__ArrayPrototype JSC__ArrayPrototype; // JSC::ArrayPrototype
+typedef struct Zig__JSMicrotaskCallback Zig__JSMicrotaskCallback; // Zig::JSMicrotaskCallback
+typedef bJSC__JSPromise JSC__JSPromise; // JSC::JSPromise
+typedef struct JSC__SetIteratorPrototype JSC__SetIteratorPrototype; // JSC::SetIteratorPrototype
+typedef SystemError SystemError;
+typedef bJSC__JSCell JSC__JSCell; // JSC::JSCell
+typedef bJSC__SourceOrigin JSC__SourceOrigin; // JSC::SourceOrigin
+typedef bJSC__JSModuleRecord JSC__JSModuleRecord; // JSC::JSModuleRecord
+typedef bWTF__String WTF__String; // WTF::String
+typedef bWTF__URL WTF__URL; // WTF::URL
+typedef struct JSC__IteratorPrototype JSC__IteratorPrototype; // JSC::IteratorPrototype
+typedef Bun__Readable Bun__Readable;
+typedef bJSC__JSInternalPromise JSC__JSInternalPromise; // JSC::JSInternalPromise
+typedef Bun__Writable Bun__Writable;
+typedef struct JSC__RegExpPrototype JSC__RegExpPrototype; // JSC::RegExpPrototype
+typedef bJSC__CallFrame JSC__CallFrame; // JSC::CallFrame
+typedef struct JSC__MapIteratorPrototype JSC__MapIteratorPrototype; // JSC::MapIteratorPrototype
+typedef bWTF__StringView WTF__StringView; // WTF::StringView
+typedef bJSC__ThrowScope JSC__ThrowScope; // JSC::ThrowScope
+typedef bWTF__StringImpl WTF__StringImpl; // WTF::StringImpl
+typedef bJSC__VM JSC__VM; // JSC::VM
+typedef JSClassRef JSClassRef;
+typedef Bun__ArrayBuffer Bun__ArrayBuffer;
+typedef bJSC__JSGlobalObject JSC__JSGlobalObject; // JSC::JSGlobalObject
+typedef bJSC__JSFunction JSC__JSFunction; // JSC::JSFunction
+typedef struct JSC__AsyncFunctionPrototype JSC__AsyncFunctionPrototype; // JSC::AsyncFunctionPrototype
+typedef ZigException ZigException;
+typedef bJSC__SourceCode JSC__SourceCode; // JSC::SourceCode
+typedef struct JSC__BigIntPrototype JSC__BigIntPrototype; // JSC::BigIntPrototype
+typedef struct JSC__GeneratorFunctionPrototype JSC__GeneratorFunctionPrototype; // JSC::GeneratorFunctionPrototype
+typedef ZigString ZigString;
+typedef int64_t JSC__JSValue;
+typedef struct JSC__FunctionPrototype JSC__FunctionPrototype; // JSC::FunctionPrototype
+typedef bInspector__ScriptArguments Inspector__ScriptArguments; // Inspector::ScriptArguments
+typedef bJSC__Exception JSC__Exception; // JSC::Exception
+typedef bJSC__JSString JSC__JSString; // JSC::JSString
+typedef struct JSC__ObjectPrototype JSC__ObjectPrototype; // JSC::ObjectPrototype
+typedef struct JSC__StringPrototype JSC__StringPrototype; // JSC::StringPrototype
#endif
#ifdef __cplusplus
- namespace JSC {
- class JSCell;
- class Exception;
- class JSPromisePrototype;
- class StringPrototype;
- class GeneratorFunctionPrototype;
- class ArrayPrototype;
- class JSString;
- class JSObject;
- class AsyncIteratorPrototype;
- class AsyncGeneratorFunctionPrototype;
- class Identifier;
- class JSPromise;
- class RegExpPrototype;
- class AsyncFunctionPrototype;
- class CatchScope;
- class VM;
- class BigIntPrototype;
- class SourceOrigin;
- class ThrowScope;
- class SetIteratorPrototype;
- class AsyncGeneratorPrototype;
- class PropertyName;
- class MapIteratorPrototype;
- class JSModuleRecord;
- class JSInternalPromise;
- class ArrayIteratorPrototype;
- class JSFunction;
- class JSModuleLoader;
- class GeneratorPrototype;
- class JSGlobalObject;
- class SourceCode;
- class JSLock;
- class FunctionPrototype;
- class IteratorPrototype;
- class CallFrame;
- class ObjectPrototype;
- }
- namespace WTF {
- class URL;
- class StringImpl;
- class String;
- class StringView;
- class ExternalStringImpl;
- }
- namespace Zig {
- class JSMicrotaskCallback;
- }
- namespace Inspector {
- class ScriptArguments;
- }
-
- typedef ErrorableResolvedSource ErrorableResolvedSource;
- typedef ErrorableZigString ErrorableZigString;
- typedef SystemError SystemError;
- typedef Bun__Readable Bun__Readable;
- typedef Bun__Writable Bun__Writable;
- typedef JSClassRef JSClassRef;
- typedef Bun__ArrayBuffer Bun__ArrayBuffer;
- typedef ZigException ZigException;
- typedef ZigString ZigString;
- typedef int64_t JSC__JSValue;
- using JSC__JSCell = JSC::JSCell;
- using JSC__Exception = JSC::Exception;
- using JSC__JSPromisePrototype = JSC::JSPromisePrototype;
- using JSC__StringPrototype = JSC::StringPrototype;
- using JSC__GeneratorFunctionPrototype = JSC::GeneratorFunctionPrototype;
- using JSC__ArrayPrototype = JSC::ArrayPrototype;
- using JSC__JSString = JSC::JSString;
- using JSC__JSObject = JSC::JSObject;
- using JSC__AsyncIteratorPrototype = JSC::AsyncIteratorPrototype;
- using JSC__AsyncGeneratorFunctionPrototype = JSC::AsyncGeneratorFunctionPrototype;
- using JSC__Identifier = JSC::Identifier;
- using JSC__JSPromise = JSC::JSPromise;
- using JSC__RegExpPrototype = JSC::RegExpPrototype;
- using JSC__AsyncFunctionPrototype = JSC::AsyncFunctionPrototype;
- using JSC__CatchScope = JSC::CatchScope;
- using JSC__VM = JSC::VM;
- using JSC__BigIntPrototype = JSC::BigIntPrototype;
- using JSC__SourceOrigin = JSC::SourceOrigin;
- using JSC__ThrowScope = JSC::ThrowScope;
- using JSC__SetIteratorPrototype = JSC::SetIteratorPrototype;
- using JSC__AsyncGeneratorPrototype = JSC::AsyncGeneratorPrototype;
- using JSC__PropertyName = JSC::PropertyName;
- using JSC__MapIteratorPrototype = JSC::MapIteratorPrototype;
- using JSC__JSModuleRecord = JSC::JSModuleRecord;
- using JSC__JSInternalPromise = JSC::JSInternalPromise;
- using JSC__ArrayIteratorPrototype = JSC::ArrayIteratorPrototype;
- using JSC__JSFunction = JSC::JSFunction;
- using JSC__JSModuleLoader = JSC::JSModuleLoader;
- using JSC__GeneratorPrototype = JSC::GeneratorPrototype;
- using JSC__JSGlobalObject = JSC::JSGlobalObject;
- using JSC__SourceCode = JSC::SourceCode;
- using JSC__JSLock = JSC::JSLock;
- using JSC__FunctionPrototype = JSC::FunctionPrototype;
- using JSC__IteratorPrototype = JSC::IteratorPrototype;
- using JSC__CallFrame = JSC::CallFrame;
- using JSC__ObjectPrototype = JSC::ObjectPrototype;
- using WTF__URL = WTF::URL;
- using WTF__StringImpl = WTF::StringImpl;
- using WTF__String = WTF::String;
- using WTF__StringView = WTF::StringView;
- using WTF__ExternalStringImpl = WTF::ExternalStringImpl;
- using Zig__JSMicrotaskCallback = Zig::JSMicrotaskCallback;
- using Inspector__ScriptArguments = Inspector::ScriptArguments;
+namespace JSC {
+class JSCell;
+class Exception;
+class JSPromisePrototype;
+class StringPrototype;
+class GeneratorFunctionPrototype;
+class ArrayPrototype;
+class JSString;
+class JSObject;
+class AsyncIteratorPrototype;
+class AsyncGeneratorFunctionPrototype;
+class Identifier;
+class JSPromise;
+class RegExpPrototype;
+class AsyncFunctionPrototype;
+class CatchScope;
+class VM;
+class BigIntPrototype;
+class SourceOrigin;
+class ThrowScope;
+class SetIteratorPrototype;
+class AsyncGeneratorPrototype;
+class PropertyName;
+class MapIteratorPrototype;
+class JSModuleRecord;
+class JSInternalPromise;
+class ArrayIteratorPrototype;
+class JSFunction;
+class JSModuleLoader;
+class GeneratorPrototype;
+class JSGlobalObject;
+class SourceCode;
+class JSLock;
+class FunctionPrototype;
+class IteratorPrototype;
+class CallFrame;
+class ObjectPrototype;
+}
+namespace WTF {
+class URL;
+class StringImpl;
+class String;
+class StringView;
+class ExternalStringImpl;
+}
+namespace Zig {
+class JSMicrotaskCallback;
+}
+namespace Inspector {
+class ScriptArguments;
+}
+
+typedef ErrorableResolvedSource ErrorableResolvedSource;
+typedef ErrorableZigString ErrorableZigString;
+typedef SystemError SystemError;
+typedef Bun__Readable Bun__Readable;
+typedef Bun__Writable Bun__Writable;
+typedef JSClassRef JSClassRef;
+typedef Bun__ArrayBuffer Bun__ArrayBuffer;
+typedef ZigException ZigException;
+typedef ZigString ZigString;
+typedef int64_t JSC__JSValue;
+using JSC__JSCell = JSC::JSCell;
+using JSC__Exception = JSC::Exception;
+using JSC__JSPromisePrototype = JSC::JSPromisePrototype;
+using JSC__StringPrototype = JSC::StringPrototype;
+using JSC__GeneratorFunctionPrototype = JSC::GeneratorFunctionPrototype;
+using JSC__ArrayPrototype = JSC::ArrayPrototype;
+using JSC__JSString = JSC::JSString;
+using JSC__JSObject = JSC::JSObject;
+using JSC__AsyncIteratorPrototype = JSC::AsyncIteratorPrototype;
+using JSC__AsyncGeneratorFunctionPrototype = JSC::AsyncGeneratorFunctionPrototype;
+using JSC__Identifier = JSC::Identifier;
+using JSC__JSPromise = JSC::JSPromise;
+using JSC__RegExpPrototype = JSC::RegExpPrototype;
+using JSC__AsyncFunctionPrototype = JSC::AsyncFunctionPrototype;
+using JSC__CatchScope = JSC::CatchScope;
+using JSC__VM = JSC::VM;
+using JSC__BigIntPrototype = JSC::BigIntPrototype;
+using JSC__SourceOrigin = JSC::SourceOrigin;
+using JSC__ThrowScope = JSC::ThrowScope;
+using JSC__SetIteratorPrototype = JSC::SetIteratorPrototype;
+using JSC__AsyncGeneratorPrototype = JSC::AsyncGeneratorPrototype;
+using JSC__PropertyName = JSC::PropertyName;
+using JSC__MapIteratorPrototype = JSC::MapIteratorPrototype;
+using JSC__JSModuleRecord = JSC::JSModuleRecord;
+using JSC__JSInternalPromise = JSC::JSInternalPromise;
+using JSC__ArrayIteratorPrototype = JSC::ArrayIteratorPrototype;
+using JSC__JSFunction = JSC::JSFunction;
+using JSC__JSModuleLoader = JSC::JSModuleLoader;
+using JSC__GeneratorPrototype = JSC::GeneratorPrototype;
+using JSC__JSGlobalObject = JSC::JSGlobalObject;
+using JSC__SourceCode = JSC::SourceCode;
+using JSC__JSLock = JSC::JSLock;
+using JSC__FunctionPrototype = JSC::FunctionPrototype;
+using JSC__IteratorPrototype = JSC::IteratorPrototype;
+using JSC__CallFrame = JSC::CallFrame;
+using JSC__ObjectPrototype = JSC::ObjectPrototype;
+using WTF__URL = WTF::URL;
+using WTF__StringImpl = WTF::StringImpl;
+using WTF__String = WTF::String;
+using WTF__StringView = WTF::StringView;
+using WTF__ExternalStringImpl = WTF::ExternalStringImpl;
+using Zig__JSMicrotaskCallback = Zig::JSMicrotaskCallback;
+using Inspector__ScriptArguments = Inspector::ScriptArguments;
#endif
-
#pragma mark - JSC::JSObject
-CPP_DECL JSC__JSValue JSC__JSObject__create(JSC__JSGlobalObject* arg0, size_t arg1, void* arg2, void (* ArgFn3)(void* arg0, JSC__JSObject* arg1, JSC__JSGlobalObject* arg2));
+CPP_DECL JSC__JSValue JSC__JSObject__create(JSC__JSGlobalObject* arg0, size_t arg1, void* arg2, void (*ArgFn3)(void* arg0, JSC__JSObject* arg1, JSC__JSGlobalObject* arg2));
CPP_DECL size_t JSC__JSObject__getArrayLength(JSC__JSObject* arg0);
CPP_DECL JSC__JSValue JSC__JSObject__getDirect(JSC__JSObject* arg0, JSC__JSGlobalObject* arg1, const ZigString* arg2);
CPP_DECL JSC__JSValue JSC__JSObject__getIndex(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, uint32_t arg2);
@@ -343,7 +392,7 @@ CPP_DECL JSC__JSValue JSC__JSFunction__constructWithArguments(JSC__JSValue JSVal
CPP_DECL JSC__JSValue JSC__JSFunction__constructWithArgumentsAndNewTarget(JSC__JSValue JSValue0, JSC__JSValue JSValue1, JSC__JSGlobalObject* arg2, JSC__JSValue* arg3, size_t arg4, JSC__Exception** arg5, const unsigned char* arg6);
CPP_DECL JSC__JSValue JSC__JSFunction__constructWithNewTarget(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2, JSC__Exception** arg3, const unsigned char* arg4);
CPP_DECL JSC__JSValue JSC__JSFunction__constructWithoutAnyArgumentsOrNewTarget(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, JSC__Exception** arg2, const unsigned char* arg3);
-CPP_DECL JSC__JSFunction* JSC__JSFunction__createFromNative(JSC__JSGlobalObject* arg0, uint16_t arg1, const WTF__String* arg2, void* arg3, JSC__JSValue (* ArgFn4)(void* arg0, JSC__JSGlobalObject* arg1, JSC__CallFrame* arg2));
+CPP_DECL JSC__JSFunction* JSC__JSFunction__createFromNative(JSC__JSGlobalObject* arg0, uint16_t arg1, const WTF__String* arg2, void* arg3, JSC__JSValue (*ArgFn4)(void* arg0, JSC__JSGlobalObject* arg1, JSC__CallFrame* arg2));
CPP_DECL bWTF__String JSC__JSFunction__displayName(JSC__JSFunction* arg0, JSC__VM* arg1);
CPP_DECL bWTF__String JSC__JSFunction__getName(JSC__JSFunction* arg0, JSC__VM* arg1);
@@ -442,7 +491,7 @@ CPP_DECL JSC__JSValue JSC__JSValue__createStringArray(JSC__JSGlobalObject* arg0,
CPP_DECL JSC__JSValue JSC__JSValue__createTypeError(const ZigString* arg0, const ZigString* arg1, JSC__JSGlobalObject* arg2);
CPP_DECL bool JSC__JSValue__eqlCell(JSC__JSValue JSValue0, JSC__JSCell* arg1);
CPP_DECL bool JSC__JSValue__eqlValue(JSC__JSValue JSValue0, JSC__JSValue JSValue1);
-CPP_DECL void JSC__JSValue__forEach(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, void (* ArgFn2)(JSC__VM* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2));
+CPP_DECL void JSC__JSValue__forEach(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, void (*ArgFn2)(JSC__VM* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2));
CPP_DECL JSC__JSValue JSC__JSValue__fromEntries(JSC__JSGlobalObject* arg0, ZigString* arg1, ZigString* arg2, size_t arg3, bool arg4);
CPP_DECL void JSC__JSValue__getClassName(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, ZigString* arg2);
CPP_DECL JSC__JSValue JSC__JSValue__getErrorsProperty(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1);
@@ -527,7 +576,7 @@ CPP_DECL void JSC__VM__deinit(JSC__VM* arg0, JSC__JSGlobalObject* arg1);
CPP_DECL void JSC__VM__deleteAllCode(JSC__VM* arg0, JSC__JSGlobalObject* arg1);
CPP_DECL void JSC__VM__drainMicrotasks(JSC__VM* arg0);
CPP_DECL bool JSC__VM__executionForbidden(JSC__VM* arg0);
-CPP_DECL void JSC__VM__holdAPILock(JSC__VM* arg0, void* arg1, void (* ArgFn2)(void* arg0));
+CPP_DECL void JSC__VM__holdAPILock(JSC__VM* arg0, void* arg1, void (*ArgFn2)(void* arg0));
CPP_DECL bool JSC__VM__isEntered(JSC__VM* arg0);
CPP_DECL bool JSC__VM__isJITEnabled();
CPP_DECL JSC__JSValue JSC__VM__runGC(JSC__VM* arg0, bool arg1);
@@ -535,7 +584,7 @@ CPP_DECL void JSC__VM__setExecutionForbidden(JSC__VM* arg0, bool arg1);
CPP_DECL void JSC__VM__setExecutionTimeLimit(JSC__VM* arg0, double arg1);
CPP_DECL void JSC__VM__shrinkFootprint(JSC__VM* arg0);
CPP_DECL bool JSC__VM__throwError(JSC__VM* arg0, JSC__JSGlobalObject* arg1, JSC__ThrowScope* arg2, const unsigned char* arg3, size_t arg4);
-CPP_DECL void JSC__VM__whenIdle(JSC__VM* arg0, void (* ArgFn1)());
+CPP_DECL void JSC__VM__whenIdle(JSC__VM* arg0, void (*ArgFn1)());
#pragma mark - JSC::ThrowScope
@@ -593,7 +642,7 @@ CPP_DECL size_t WTF__StringImpl__length(const WTF__StringImpl* arg0);
CPP_DECL const uint16_t* WTF__ExternalStringImpl__characters16(const WTF__ExternalStringImpl* arg0);
CPP_DECL const unsigned char* WTF__ExternalStringImpl__characters8(const WTF__ExternalStringImpl* arg0);
-CPP_DECL bWTF__ExternalStringImpl WTF__ExternalStringImpl__create(const unsigned char* arg0, size_t arg1, void (* ArgFn2)(void* arg0, unsigned char* arg1, size_t arg2));
+CPP_DECL bWTF__ExternalStringImpl WTF__ExternalStringImpl__create(const unsigned char* arg0, size_t arg1, void (*ArgFn2)(void* arg0, unsigned char* arg1, size_t arg2));
CPP_DECL bool WTF__ExternalStringImpl__is16Bit(const WTF__ExternalStringImpl* arg0);
CPP_DECL bool WTF__ExternalStringImpl__is8Bit(const WTF__ExternalStringImpl* arg0);
CPP_DECL bool WTF__ExternalStringImpl__isEmpty(const WTF__ExternalStringImpl* arg0);
@@ -704,7 +753,6 @@ CPP_DECL ZigException ZigException__fromException(JSC__Exception* arg0);
#pragma mark - Zig::ConsoleClient
-
#ifdef __cplusplus
ZIG_DECL void Zig__ConsoleClient__count(void* arg0, JSC__JSGlobalObject* arg1, const unsigned char* arg2, size_t arg3);
@@ -725,7 +773,6 @@ ZIG_DECL void Zig__ConsoleClient__timeStamp(void* arg0, JSC__JSGlobalObject* arg
#pragma mark - Bun__Timer
-
#ifdef __cplusplus
ZIG_DECL JSC__JSValue Bun__Timer__clearInterval(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1);
diff --git a/src/javascript/jsc/bindings/helpers.h b/src/javascript/jsc/bindings/helpers.h
index cacdd624e..11d728ac5 100644
--- a/src/javascript/jsc/bindings/helpers.h
+++ b/src/javascript/jsc/bindings/helpers.h
@@ -12,56 +12,63 @@
#include <JavaScriptCore/ThrowScope.h>
#include <JavaScriptCore/VM.h>
-template <class CppType, typename ZigType> class Wrap {
- public:
- Wrap(){};
+template<class CppType, typename ZigType> class Wrap {
+public:
+ Wrap() {};
- Wrap(ZigType zig) {
- result = zig;
- cpp = static_cast<CppType *>(static_cast<void *>(&zig));
- };
+ Wrap(ZigType zig)
+ {
+ result = zig;
+ cpp = static_cast<CppType*>(static_cast<void*>(&zig));
+ };
- Wrap(ZigType *zig) { cpp = static_cast<CppType *>(static_cast<void *>(&zig)); };
+ Wrap(ZigType* zig) { cpp = static_cast<CppType*>(static_cast<void*>(&zig)); };
- Wrap(CppType _cpp) {
- auto buffer = alignedBuffer();
- cpp = new (buffer) CppType(_cpp);
- };
+ Wrap(CppType _cpp)
+ {
+ auto buffer = alignedBuffer();
+ cpp = new (buffer) CppType(_cpp);
+ };
- ~Wrap(){};
+ ~Wrap() {};
- unsigned char *alignedBuffer() {
- return result.bytes + alignof(CppType) -
- reinterpret_cast<intptr_t>(result.bytes) % alignof(CppType);
- }
+ unsigned char* alignedBuffer()
+ {
+ return result.bytes + alignof(CppType) - reinterpret_cast<intptr_t>(result.bytes) % alignof(CppType);
+ }
- ZigType result;
- CppType *cpp;
+ ZigType result;
+ CppType* cpp;
- static ZigType wrap(CppType obj) { return *static_cast<ZigType *>(static_cast<void *>(&obj)); }
+ static ZigType wrap(CppType obj) { return *static_cast<ZigType*>(static_cast<void*>(&obj)); }
- static CppType unwrap(ZigType obj) { return *static_cast<CppType *>(static_cast<void *>(&obj)); }
+ static CppType unwrap(ZigType obj) { return *static_cast<CppType*>(static_cast<void*>(&obj)); }
- static CppType *unwrap(ZigType *obj) { return static_cast<CppType *>(static_cast<void *>(obj)); }
+ static CppType* unwrap(ZigType* obj) { return static_cast<CppType*>(static_cast<void*>(obj)); }
};
-template <class To, class From> To cast(From v) {
- return *static_cast<To *>(static_cast<void *>(v));
+template<class To, class From> To cast(From v)
+{
+ return *static_cast<To*>(static_cast<void*>(v));
}
-template <class To, class From> To ccast(From v) {
- return *static_cast<const To *>(static_cast<const void *>(v));
+template<class To, class From> To ccast(From v)
+{
+ return *static_cast<const To*>(static_cast<const void*>(v));
}
-typedef JSC__JSValue (*NativeCallbackFunction)(void *arg0, JSC__JSGlobalObject *arg1,
- JSC__CallFrame *arg2);
+typedef JSC__JSValue (*NativeCallbackFunction)(void* arg0, JSC__JSGlobalObject* arg1,
+ JSC__CallFrame* arg2);
-static const JSC::ArgList makeArgs(JSC__JSValue *v, size_t count) {
- JSC::MarkedArgumentBuffer args = JSC::MarkedArgumentBuffer();
- args.ensureCapacity(count);
- for (size_t i = 0; i < count; ++i) { args.append(JSC::JSValue::decode(v[i])); }
+static const JSC::ArgList makeArgs(JSC__JSValue* v, size_t count)
+{
+ JSC::MarkedArgumentBuffer args = JSC::MarkedArgumentBuffer();
+ args.ensureCapacity(count);
+ for (size_t i = 0; i < count; ++i) {
+ args.append(JSC::JSValue::decode(v[i]));
+ }
- return JSC::ArgList(args);
+ return JSC::ArgList(args);
}
namespace Zig {
@@ -70,159 +77,189 @@ namespace Zig {
// we tag the final two bits
// so 56 bits are copied over
// rest we zero out for consistentcy
-static const unsigned char *untag(const unsigned char *ptr) {
- return reinterpret_cast<const unsigned char *>(
- ((reinterpret_cast<uintptr_t>(ptr) & ~(static_cast<uint64_t>(1) << 63) &
- ~(static_cast<uint64_t>(1) << 62)) &
- ~(static_cast<uint64_t>(1) << 61)));
+static const unsigned char* untag(const unsigned char* ptr)
+{
+ return reinterpret_cast<const unsigned char*>(
+ ((reinterpret_cast<uintptr_t>(ptr) & ~(static_cast<uint64_t>(1) << 63) & ~(static_cast<uint64_t>(1) << 62)) & ~(static_cast<uint64_t>(1) << 61)));
}
-static const JSC::Identifier toIdentifier(ZigString str, JSC::JSGlobalObject *global) {
- if (str.len == 0 || str.ptr == nullptr) { return JSC::Identifier::EmptyIdentifier; }
+static const JSC::Identifier toIdentifier(ZigString str, JSC::JSGlobalObject* global)
+{
+ if (str.len == 0 || str.ptr == nullptr) {
+ return JSC::Identifier::EmptyIdentifier;
+ }
- return JSC::Identifier::fromString(global->vm(), untag(str.ptr), str.len);
+ return JSC::Identifier::fromString(global->vm(), untag(str.ptr), str.len);
}
-static bool isTaggedUTF16Ptr(const unsigned char *ptr) {
- return (reinterpret_cast<uintptr_t>(ptr) & (static_cast<uint64_t>(1) << 63)) != 0;
+static bool isTaggedUTF16Ptr(const unsigned char* ptr)
+{
+ return (reinterpret_cast<uintptr_t>(ptr) & (static_cast<uint64_t>(1) << 63)) != 0;
}
// Do we need to convert the string from UTF-8 to UTF-16?
-static bool isTaggedUTF8Ptr(const unsigned char *ptr) {
- return (reinterpret_cast<uintptr_t>(ptr) & (static_cast<uint64_t>(1) << 61)) != 0;
+static bool isTaggedUTF8Ptr(const unsigned char* ptr)
+{
+ return (reinterpret_cast<uintptr_t>(ptr) & (static_cast<uint64_t>(1) << 61)) != 0;
}
-static bool isTaggedExternalPtr(const unsigned char *ptr) {
- return (reinterpret_cast<uintptr_t>(ptr) & (static_cast<uint64_t>(1) << 62)) != 0;
+static bool isTaggedExternalPtr(const unsigned char* ptr)
+{
+ return (reinterpret_cast<uintptr_t>(ptr) & (static_cast<uint64_t>(1) << 62)) != 0;
}
-static const WTF::String toString(ZigString str) {
- if (str.len == 0 || str.ptr == nullptr) { return WTF::String(); }
- if (UNLIKELY(isTaggedUTF8Ptr(str.ptr))) { return WTF::String::fromUTF8(untag(str.ptr), str.len); }
-
- return !isTaggedUTF16Ptr(str.ptr)
- ? WTF::String(WTF::StringImpl::createWithoutCopying(untag(str.ptr), str.len))
- : WTF::String(WTF::StringImpl::createWithoutCopying(
- reinterpret_cast<const UChar *>(untag(str.ptr)), str.len));
+static const WTF::String toString(ZigString str)
+{
+ if (str.len == 0 || str.ptr == nullptr) {
+ return WTF::String();
+ }
+ if (UNLIKELY(isTaggedUTF8Ptr(str.ptr))) {
+ return WTF::String::fromUTF8(untag(str.ptr), str.len);
+ }
+
+ return !isTaggedUTF16Ptr(str.ptr)
+ ? WTF::String(WTF::StringImpl::createWithoutCopying(untag(str.ptr), str.len))
+ : WTF::String(WTF::StringImpl::createWithoutCopying(
+ reinterpret_cast<const UChar*>(untag(str.ptr)), str.len));
}
-static const WTF::String toStringCopy(ZigString str) {
- if (str.len == 0 || str.ptr == nullptr) { return WTF::String(); }
- if (UNLIKELY(isTaggedUTF8Ptr(str.ptr))) { return WTF::String::fromUTF8(untag(str.ptr), str.len); }
-
- return !isTaggedUTF16Ptr(str.ptr) ? WTF::String(WTF::StringImpl::create(untag(str.ptr), str.len))
- : WTF::String(WTF::StringImpl::create(
- reinterpret_cast<const UChar *>(untag(str.ptr)), str.len));
+static const WTF::String toStringCopy(ZigString str)
+{
+ if (str.len == 0 || str.ptr == nullptr) {
+ return WTF::String();
+ }
+ if (UNLIKELY(isTaggedUTF8Ptr(str.ptr))) {
+ return WTF::String::fromUTF8(untag(str.ptr), str.len);
+ }
+
+ return !isTaggedUTF16Ptr(str.ptr) ? WTF::String(WTF::StringImpl::create(untag(str.ptr), str.len))
+ : WTF::String(WTF::StringImpl::create(
+ reinterpret_cast<const UChar*>(untag(str.ptr)), str.len));
}
static WTF::String toStringNotConst(ZigString str) { return toString(str); }
-static const JSC::JSString *toJSString(ZigString str, JSC::JSGlobalObject *global) {
- return JSC::jsOwnedString(global->vm(), toString(str));
+static const JSC::JSString* toJSString(ZigString str, JSC::JSGlobalObject* global)
+{
+ return JSC::jsOwnedString(global->vm(), toString(str));
}
-static const JSC::JSValue toJSStringValue(ZigString str, JSC::JSGlobalObject *global) {
- return JSC::JSValue(toJSString(str, global));
+static const JSC::JSValue toJSStringValue(ZigString str, JSC::JSGlobalObject* global)
+{
+ return JSC::JSValue(toJSString(str, global));
}
-static const JSC::JSString *toJSStringGC(ZigString str, JSC::JSGlobalObject *global) {
- return JSC::jsString(global->vm(), toStringCopy(str));
+static const JSC::JSString* toJSStringGC(ZigString str, JSC::JSGlobalObject* global)
+{
+ return JSC::jsString(global->vm(), toStringCopy(str));
}
-static const JSC::JSValue toJSStringValueGC(ZigString str, JSC::JSGlobalObject *global) {
- return JSC::JSValue(toJSString(str, global));
+static const JSC::JSValue toJSStringValueGC(ZigString str, JSC::JSGlobalObject* global)
+{
+ return JSC::JSValue(toJSString(str, global));
}
-static const ZigString ZigStringEmpty = ZigString{nullptr, 0};
+static const ZigString ZigStringEmpty = ZigString { nullptr, 0 };
static const unsigned char __dot_char = '.';
-static const ZigString ZigStringCwd = ZigString{&__dot_char, 1};
+static const ZigString ZigStringCwd = ZigString { &__dot_char, 1 };
-static const unsigned char *taggedUTF16Ptr(const UChar *ptr) {
- return reinterpret_cast<const unsigned char *>(reinterpret_cast<uintptr_t>(ptr) |
- (static_cast<uint64_t>(1) << 63));
+static const unsigned char* taggedUTF16Ptr(const UChar* ptr)
+{
+ return reinterpret_cast<const unsigned char*>(reinterpret_cast<uintptr_t>(ptr) | (static_cast<uint64_t>(1) << 63));
}
-static ZigString toZigString(WTF::String str) {
- return str.isEmpty()
- ? ZigStringEmpty
- : ZigString{str.is8Bit() ? str.characters8() : taggedUTF16Ptr(str.characters16()),
- str.length()};
+static ZigString toZigString(WTF::String str)
+{
+ return str.isEmpty()
+ ? ZigStringEmpty
+ : ZigString { str.is8Bit() ? str.characters8() : taggedUTF16Ptr(str.characters16()),
+ str.length() };
}
-static ZigString toZigString(WTF::String *str) {
- return str->isEmpty()
- ? ZigStringEmpty
- : ZigString{str->is8Bit() ? str->characters8() : taggedUTF16Ptr(str->characters16()),
- str->length()};
+static ZigString toZigString(WTF::String* str)
+{
+ return str->isEmpty()
+ ? ZigStringEmpty
+ : ZigString { str->is8Bit() ? str->characters8() : taggedUTF16Ptr(str->characters16()),
+ str->length() };
}
-static ZigString toZigString(WTF::StringImpl &str) {
- return str.isEmpty()
- ? ZigStringEmpty
- : ZigString{str.is8Bit() ? str.characters8() : taggedUTF16Ptr(str.characters16()),
- str.length()};
+static ZigString toZigString(WTF::StringImpl& str)
+{
+ return str.isEmpty()
+ ? ZigStringEmpty
+ : ZigString { str.is8Bit() ? str.characters8() : taggedUTF16Ptr(str.characters16()),
+ str.length() };
}
-static ZigString toZigString(WTF::StringView &str) {
- return str.isEmpty()
- ? ZigStringEmpty
- : ZigString{str.is8Bit() ? str.characters8() : taggedUTF16Ptr(str.characters16()),
- str.length()};
+static ZigString toZigString(WTF::StringView& str)
+{
+ return str.isEmpty()
+ ? ZigStringEmpty
+ : ZigString { str.is8Bit() ? str.characters8() : taggedUTF16Ptr(str.characters16()),
+ str.length() };
}
-static ZigString toZigString(JSC::JSString &str, JSC::JSGlobalObject *global) {
- return toZigString(str.value(global));
+static ZigString toZigString(JSC::JSString& str, JSC::JSGlobalObject* global)
+{
+ return toZigString(str.value(global));
}
-static ZigString toZigString(JSC::JSString *str, JSC::JSGlobalObject *global) {
- return toZigString(str->value(global));
+static ZigString toZigString(JSC::JSString* str, JSC::JSGlobalObject* global)
+{
+ return toZigString(str->value(global));
}
-static ZigString toZigString(JSC::Identifier &str, JSC::JSGlobalObject *global) {
- return toZigString(str.string());
+static ZigString toZigString(JSC::Identifier& str, JSC::JSGlobalObject* global)
+{
+ return toZigString(str.string());
}
-static ZigString toZigString(JSC::Identifier *str, JSC::JSGlobalObject *global) {
- return toZigString(str->string());
+static ZigString toZigString(JSC::Identifier* str, JSC::JSGlobalObject* global)
+{
+ return toZigString(str->string());
}
-static WTF::StringView toStringView(ZigString str) {
- return WTF::StringView(untag(str.ptr), str.len);
+static WTF::StringView toStringView(ZigString str)
+{
+ return WTF::StringView(untag(str.ptr), str.len);
}
-static void throwException(JSC::ThrowScope &scope, ZigErrorType err, JSC::JSGlobalObject *global) {
- scope.throwException(global,
- JSC::Exception::create(global->vm(), JSC::JSValue((JSC::JSCell *)err.ptr)));
+static void throwException(JSC::ThrowScope& scope, ZigErrorType err, JSC::JSGlobalObject* global)
+{
+ scope.throwException(global,
+ JSC::Exception::create(global->vm(), JSC::JSValue((JSC::JSCell*)err.ptr)));
}
-static ZigString toZigString(JSC::JSValue val, JSC::JSGlobalObject *global) {
- auto scope = DECLARE_THROW_SCOPE(global->vm());
- WTF::String str = val.toWTFString(global);
+static ZigString toZigString(JSC::JSValue val, JSC::JSGlobalObject* global)
+{
+ auto scope = DECLARE_THROW_SCOPE(global->vm());
+ WTF::String str = val.toWTFString(global);
- if (scope.exception()) {
- scope.clearException();
- scope.release();
- return ZigStringEmpty;
- }
+ if (scope.exception()) {
+ scope.clearException();
+ scope.release();
+ return ZigStringEmpty;
+ }
- scope.release();
+ scope.release();
- return toZigString(str);
+ return toZigString(str);
}
-static JSC::JSValue getErrorInstance(const ZigString *str, JSC__JSGlobalObject *globalObject) {
- JSC::VM &vm = globalObject->vm();
+static JSC::JSValue getErrorInstance(const ZigString* str, JSC__JSGlobalObject* globalObject)
+{
+ JSC::VM& vm = globalObject->vm();
- auto scope = DECLARE_THROW_SCOPE(vm);
- JSC::JSValue message = Zig::toJSString(*str, globalObject);
- JSC::JSValue options = JSC::jsUndefined();
- JSC::Structure *errorStructure = globalObject->errorStructure();
- JSC::JSObject *result =
- JSC::ErrorInstance::create(globalObject, errorStructure, message, options);
- RETURN_IF_EXCEPTION(scope, JSC::JSValue());
- scope.release();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+ JSC::JSValue message = Zig::toJSString(*str, globalObject);
+ JSC::JSValue options = JSC::jsUndefined();
+ JSC::Structure* errorStructure = globalObject->errorStructure();
+ JSC::JSObject* result = JSC::ErrorInstance::create(globalObject, errorStructure, message, options);
+ RETURN_IF_EXCEPTION(scope, JSC::JSValue());
+ scope.release();
- return JSC::JSValue(result);
+ return JSC::JSValue(result);
}
}; // namespace Zig
diff --git a/src/javascript/jsc/bindings/objects.h b/src/javascript/jsc/bindings/objects.h
index 083d6a9d8..9d4d6d38d 100644
--- a/src/javascript/jsc/bindings/objects.h
+++ b/src/javascript/jsc/bindings/objects.h
@@ -30,7 +30,6 @@
// return object;
// }
-
// static JSC::JSObject* createPrototype(JSC::VM&, JSC::JSGlobalObject&);
// static JSC::JSObject* prototype(JSC::VM&, JSC::JSGlobalObject&);
@@ -47,7 +46,7 @@
// };
// void finishCreation(JSC::VM&, JSC::JSGlobalObject*, void* zigBase);
// void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
-
+
// };
// class ModuleExportsMap final : public JSC::JSNonFinalObject {
@@ -71,7 +70,6 @@
// return object;
// }
-
// static JSC::JSObject* createPrototype(JSC::VM&, JSC::JSGlobalObject&);
// static JSC::JSObject* prototype(JSC::VM&, JSC::JSGlobalObject&);
@@ -88,14 +86,11 @@
// };
// void finishCreation(JSC::VM&, JSC::JSGlobalObject*, void* zigBase);
// void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
-
-// };
+// };
// }
-
-
// namespace Zig {
// class HeadersPrototype final : public JSC::JSNonFinalObject {
@@ -126,7 +121,6 @@
// return object;
// }
-
// JSC::JSValue get(JSC::JSGlobalObject&, JSC::JSValue);
// bool put(JSC::JSGlobalObject&, JSC::JSValue, JSC::JSValue);
// bool has(JSC::JSGlobalObject&, JSC::JSValue);
@@ -149,9 +143,8 @@
// };
// void finishCreation(JSC::VM&, JSC::JSGlobalObject*, void* zigBase);
// void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
-
-// };
+// };
// JSC_DECLARE_HOST_FUNCTION(headersFuncPrototypeGet);
// JSC_DECLARE_HOST_FUNCTION(headersFuncPrototypePut);
@@ -185,8 +178,6 @@
// JSC_DECLARE_HOST_FUNCTION(headersFuncConstructor);
-
-
// class RequestConstructor final : public JSC::InternalFunction {
// public:
// typedef InternalFunction Base;
@@ -257,10 +248,7 @@
// };
// void finishCreation(JSC::VM&, JSC::JSGlobalObject*, void* zigBase);
// void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
-
-// };
-
+// };
// }
-
diff --git a/src/javascript/jsc/bindings/root.h b/src/javascript/jsc/bindings/root.h
index 2ac4c15bc..7bbd8ec5f 100644
--- a/src/javascript/jsc/bindings/root.h
+++ b/src/javascript/jsc/bindings/root.h
@@ -46,7 +46,6 @@
#endif
-
#ifdef __cplusplus
#undef new
#undef delete
@@ -60,12 +59,11 @@
Make sure this warning does not turn into an error.
*/
#if COMPILER(MSVC)
-#pragma warning(disable:4206)
+#pragma warning(disable : 4206)
#endif
#ifdef USE_FOUNDATION
#include <CoreFoundation/CoreFoundation.h>
#endif
-
#include <JavaScriptCore/Heap.h> \ No newline at end of file