-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: remove RefBase (nodejs/node#53590) * export ReferenceOwnership as runtime value
- Loading branch information
1 parent
6ac98c3
commit 5ab92c7
Showing
19 changed files
with
307 additions
and
199 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,13 @@ | ||
declare const enum UnwrapAction { | ||
KeepWrap, | ||
RemoveWrap | ||
import type { ReferenceOwnership as RuntimeReferenceOwnership } from '@emnapi/runtime' | ||
|
||
declare global { | ||
export const enum UnwrapAction { | ||
KeepWrap, | ||
RemoveWrap | ||
} | ||
|
||
export const enum ReferenceOwnership { | ||
kRuntime = RuntimeReferenceOwnership.kRuntime, | ||
kUserland = RuntimeReferenceOwnership.kUserland | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,49 @@ | ||
import type { Env } from './env' | ||
|
||
export class Finalizer { | ||
private _makeDynCall_vppp: (cb: Ptr) => (a: Ptr, b: Ptr, c: Ptr) => void | ||
|
||
public constructor ( | ||
public envObject: Env, | ||
protected _finalizeCallback: napi_finalize = 0, | ||
protected _finalizeData: void_p = 0, | ||
protected _finalizeHint: void_p = 0 | ||
) {} | ||
private _finalizeCallback: napi_finalize = 0, | ||
private _finalizeData: void_p = 0, | ||
private _finalizeHint: void_p = 0 | ||
) { | ||
this._makeDynCall_vppp = envObject.makeDynCall_vppp | ||
} | ||
|
||
public callback (): napi_finalize { return this._finalizeCallback } | ||
public data (): void_p { return this._finalizeData } | ||
public hint (): void_p { return this._finalizeHint } | ||
|
||
public resetEnv (): void { | ||
this.envObject = undefined! | ||
} | ||
|
||
public resetFinalizer (): void { | ||
this._finalizeCallback = 0 | ||
this._finalizeData = 0 | ||
this._finalizeHint = 0 | ||
} | ||
|
||
public callFinalizer (): void { | ||
const finalize_callback = this._finalizeCallback | ||
const finalize_data = this._finalizeData | ||
const finalize_hint = this._finalizeHint | ||
this.resetFinalizer() | ||
|
||
if (!finalize_callback) return | ||
|
||
const fini = Number(finalize_callback) | ||
if (!this.envObject) { | ||
this._makeDynCall_vppp(fini)(0, finalize_data, finalize_hint) | ||
} else { | ||
this.envObject.callFinalizer(fini, finalize_data, finalize_hint) | ||
} | ||
} | ||
|
||
public dispose (): void { | ||
this.envObject = undefined! | ||
this._makeDynCall_vppp = undefined! | ||
} | ||
} |
Oops, something went wrong.