Skip to content

Commit

Permalink
NAPI fixes (oven-sh#7765)
Browse files Browse the repository at this point in the history
* napi fixes

* Make bcrypt work

* Always return this

* Fixes oven-sh#7685

* [autofix.ci] apply automated fixes

* Update napi.cpp

* Make it clearer what this is doing

---------

Co-authored-by: Jarred Sumner <[email protected]>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored and ryoppippi committed Feb 1, 2024
1 parent d2883e5 commit 932b99b
Show file tree
Hide file tree
Showing 11 changed files with 440 additions and 195 deletions.
7 changes: 7 additions & 0 deletions src/bun.js/bindings/ZigGlobalObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3069,6 +3069,12 @@ void GlobalObject::finishCreation(VM& vm)
Bun::NapiExternal::createStructure(init.vm, init.owner, init.owner->objectPrototype()));
});

m_NAPIFunctionStructure.initLater(
[](const JSC::LazyProperty<JSC::JSGlobalObject, Structure>::Initializer& init) {
init.set(
Zig::createNAPIFunctionStructure(init.vm, init.owner));
});

m_NapiPrototypeStructure.initLater(
[](const JSC::LazyProperty<JSC::JSGlobalObject, Structure>::Initializer& init) {
auto& global = *reinterpret_cast<Zig::GlobalObject*>(init.owner);
Expand Down Expand Up @@ -3949,6 +3955,7 @@ void GlobalObject::visitChildrenImpl(JSCell* cell, Visitor& visitor)
thisObject->m_cachedGlobalProxyStructure.visit(visitor);
thisObject->m_NapiExternalStructure.visit(visitor);
thisObject->m_NapiPrototypeStructure.visit(visitor);
thisObject->m_NAPIFunctionStructure.visit(visitor);

thisObject->mockModule.mockFunctionStructure.visit(visitor);
thisObject->mockModule.mockResultStructure.visit(visitor);
Expand Down
2 changes: 2 additions & 0 deletions src/bun.js/bindings/ZigGlobalObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ class GlobalObject : public JSC::JSGlobalObject {

Structure* NapiExternalStructure() { return m_NapiExternalStructure.getInitializedOnMainThread(this); }
Structure* NapiPrototypeStructure() { return m_NapiPrototypeStructure.getInitializedOnMainThread(this); }
Structure* NAPIFunctionStructure() { return m_NAPIFunctionStructure.getInitializedOnMainThread(this); }

bool hasProcessObject() const { return m_processObject.isInitialized(); }

Expand Down Expand Up @@ -521,6 +522,7 @@ class GlobalObject : public JSC::JSGlobalObject {
LazyProperty<JSGlobalObject, Structure> m_JSCryptoKey;
LazyProperty<JSGlobalObject, Structure> m_NapiExternalStructure;
LazyProperty<JSGlobalObject, Structure> m_NapiPrototypeStructure;
LazyProperty<JSGlobalObject, Structure> m_NAPIFunctionStructure;

LazyProperty<JSGlobalObject, JSObject> m_bunObject;
LazyProperty<JSGlobalObject, JSObject> m_cryptoObject;
Expand Down
Loading

0 comments on commit 932b99b

Please sign in to comment.