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

Uncaught v8pp::class_<T, v8pp::shared_ptr_traits> is already registered in isolate XXX before of v8pp::class_<T v8pp::raw_ptr_traits> #132

Open
yonatan-mitmit opened this issue Dec 17, 2019 · 2 comments

Comments

@yonatan-mitmit
Copy link

This issue is more of a design question.
Why did you decide to have the ptr_traits separate in all but the v8pp::classes registry.
This means that if someone uses class_<X,shared_ptr_traits> and another class Y has an X*/X& inside, that X&/X* cannot be wrapped.

The check in classes::find explicitly validates the same traits are used, but this means that if X is wrapped with shared_ptr_traits it cannot be used as member in another wrapped class.

@pmed
Copy link
Owner

pmed commented Jan 21, 2023

If I understood question, design decision is simple: both X and Y wrapped classes shall use the same pointer traits.

@rubenlg
Copy link
Contributor

rubenlg commented Mar 8, 2023

This design is very limiting when using other smart pointer libraries. For example, I tried to wrap parts of the OpenSceneGraph library, which has its own osg::ref_ptr<X> pointer type (similar to std::shared_ptr, but with intrusive reference counting for better cache coherency), and it's really challenging, at least with pointer traits.

The reason is precisely the intrusive reference counting which forces every class that needs to be wrapped with osg::ref_ptr to extend osg::Referenced (that's where the counter resides). Only certain objects extend that class (those that need reference counting because they are nodes in the graph). As soon as I try to wrap any object that is not reference counted (e.g. an osg::Matrix), I can't compile the project, because it's not possible to construct a osg::ref_ptr around that object.

Ideally, v8pp would support different pointer traits for each wrapped object so that we can use it to wrap existing third-party libraries that weren't necessarily written with v8pp in mind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants