Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inheritance not yet implemented #1

Open
ApsarasX opened this issue Mar 31, 2021 · 5 comments
Open

Inheritance not yet implemented #1

ApsarasX opened this issue Mar 31, 2021 · 5 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@ApsarasX
Copy link
Owner

Due to the limitation of node-addon-api, this project has not implemented inheritance yet, so calling the method of superclass from subclass object will report an error, just like

TypeError: Illegal invocation

Related issues are discussed in the following two issues.

node-addon-api#229
node-addon-api#956

In order to temporarily solve this problem, I reexposed the superclass method that needs to be used on the subclass.

It is expected that node-addon-api can really support inheritance.

@ApsarasX ApsarasX added the bug Something isn't working label Mar 31, 2021
@ApsarasX ApsarasX added the help wanted Extra attention is needed label Oct 14, 2021
@lixiangsheng2018
Copy link

any plan for Inheritance ?

@ApsarasX
Copy link
Owner Author

ApsarasX commented Mar 1, 2022

any plan for Inheritance ?

Sorry, not yet, this requires node to provide inheritance support for the napi mechanism.

Please refer to nodejs/node#38038 for more details.

@ajihyf
Copy link

ajihyf commented Apr 27, 2022

Hi, I've managed to make inheritance work in my lib node-addon-api-helper. It's complex due to the nature napi designed doesn't match C++ inheritance property. We need hold a pointer to base class in ObjectWrap and static cast the pointer while calling methods. Hope it could help. :)

@ghost
Copy link

ghost commented Dec 27, 2022

Any update on this?

@ApsarasX
Copy link
Owner Author

ApsarasX commented Jan 4, 2023

Any update on this?

Sorry, not yet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants