aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/bindings/JSMockFunction.h
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2023-06-21 19:54:00 -0700
committerGravatar GitHub <noreply@github.com> 2023-06-21 19:54:00 -0700
commit1f900cff453700b19bca2acadfe26da4468c1282 (patch)
tree4197fa9288b1f0522372a54211c14b3133c64019 /src/bun.js/bindings/JSMockFunction.h
parent522c9bbaaef5f40caca9e692abb15a238c8cd80b (diff)
parentbfb322d618a3f0e9618d311ae69016fe7a08e771 (diff)
downloadbun-1f900cff453700b19bca2acadfe26da4468c1282.tar.gz
bun-1f900cff453700b19bca2acadfe26da4468c1282.tar.zst
bun-1f900cff453700b19bca2acadfe26da4468c1282.zip
Merge branch 'main' into jarred/esm-conditions
Diffstat (limited to 'src/bun.js/bindings/JSMockFunction.h')
-rw-r--r--src/bun.js/bindings/JSMockFunction.h34
1 files changed, 33 insertions, 1 deletions
diff --git a/src/bun.js/bindings/JSMockFunction.h b/src/bun.js/bindings/JSMockFunction.h
index 288ca2e89..93c8bb015 100644
--- a/src/bun.js/bindings/JSMockFunction.h
+++ b/src/bun.js/bindings/JSMockFunction.h
@@ -16,15 +16,47 @@ class JSMockFunction;
class JSMockModule final {
public:
+ static uint64_t s_nextInvocationId;
+ static uint64_t nextInvocationId() { return ++s_nextInvocationId; }
+
LazyProperty<JSC::JSGlobalObject, Structure> mockFunctionStructure;
LazyProperty<JSC::JSGlobalObject, Structure> mockResultStructure;
LazyProperty<JSC::JSGlobalObject, Structure> mockImplementationStructure;
LazyProperty<JSC::JSGlobalObject, Structure> mockObjectStructure;
LazyProperty<JSC::JSGlobalObject, Structure> activeSpySetStructure;
+ LazyProperty<JSC::JSGlobalObject, JSFunction> withImplementationCleanupFunction;
+ LazyProperty<JSC::JSGlobalObject, JSC::Structure> mockWithImplementationCleanupDataStructure;
static JSMockModule create(JSC::JSGlobalObject*);
JSC::Strong<Unknown> activeSpies;
};
-} \ No newline at end of file
+class MockWithImplementationCleanupData : public JSC::JSInternalFieldObjectImpl<4> {
+public:
+ using Base = JSC::JSInternalFieldObjectImpl<4>;
+
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm);
+
+ JS_EXPORT_PRIVATE static MockWithImplementationCleanupData* create(VM&, Structure*);
+ static MockWithImplementationCleanupData* create(JSC::JSGlobalObject* globalObject, JSMockFunction* fn, JSValue impl, JSValue tail, JSValue fallback);
+ static MockWithImplementationCleanupData* createWithInitialValues(VM&, Structure*);
+ static Structure* createStructure(VM&, JSGlobalObject*, JSValue);
+
+ static std::array<JSValue, numberOfInternalFields> initialValues()
+ {
+ return { {
+ jsUndefined(),
+ jsUndefined(),
+ jsUndefined(),
+ jsUndefined(),
+ } };
+ }
+
+ DECLARE_EXPORT_INFO;
+ DECLARE_VISIT_CHILDREN;
+
+ MockWithImplementationCleanupData(JSC::VM&, JSC::Structure*);
+ void finishCreation(JSC::VM&, JSMockFunction* fn, JSValue impl, JSValue tail, JSValue fallback);
+};
+}