Skip to content
New issue

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

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

Already on GitHub? # to your account

Is there any way to use v8pp without v8::Isolate data slot? #26

Closed
ghost opened this issue Sep 29, 2016 · 3 comments
Closed

Is there any way to use v8pp without v8::Isolate data slot? #26

ghost opened this issue Sep 29, 2016 · 3 comments

Comments

@ghost
Copy link

ghost commented Sep 29, 2016

There is no available v8::Isolate data slot in Electron.
(All the slots are in use.)

// NodeDebugger is stored in Isolate's data, slots 0, 1, 3 have already been
// taken by gin, blink and node, using 2 is a safe option for now.
const int kIsolateSlot = 2;

https://github.com/electron/electron/blob/28e2058ff108a20dd395ebe5374403381b6d3ff2/atom/browser/node_debugger.cc#L23-L25

@pmed
Copy link
Owner

pmed commented Sep 29, 2016

Well, I was afraid this moment would come :-)

I use a data slot in V8 to store a pointer to a list of registered classes class_instances. This list should be global, especially when we have several shared libraries which use v8pp.

Consider a first.dll with a class Base exposed to V8, and second.dll with a class Derived which is inherited from Base. Both Base and Derived classes should be registered in the same class_instances list.

I need to think either how to store class_instances aside of V8 isolate data slot.

pmed added a commit that referenced this issue Oct 4, 2016
Storing a shared list of class singletons only when a preprocessor macro
`V8PP_ISOLATE_DATA_SLOT` is defined. Otherwise using the singletons list from
a static variable inside of `class_instances()` function.

It works this way in most cases for Node.js addons, since a native addon
depends on another native addon very rarely. In opposite case, developer
should define the `V8PP_ISOLATE_DATA_SLOT` macro with the same value in several
projects, which all register and use shared classes in v8pp.
@pmed
Copy link
Owner

pmed commented Oct 4, 2016

@h2so5 I've pushed changes as v1.2.0. Since this version v8pp doesn't use a data slot in v8::Isolate. To register shared classes in several projects which use v8pp, a macro V8PP_ISOLATE_DATA_SLOT should be defined in those projects.

@ghost
Copy link
Author

ghost commented Oct 4, 2016

@pmed Excellent! Thank you for your quick action 😺

@ghost ghost closed this as completed Oct 4, 2016
pmed added a commit that referenced this issue Oct 19, 2016
Store v8pp internal data in a V8 isolate data slot because the
test project runs console and file plugins in different shared
libraries.

Related to issue #26
This issue was closed.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant