How to get the associated NPP instance from NPObject

Because My plugins need to interact with other plugin on the same page with JavaScript code: obj1.invokeWith(obj2)

In this method, an NPObject object of obj2 is passed to obj1. How can I get the NPP instance of obj2 from this NPObject in the method of obj1?

Answers


Short answer: you can't.

Longer answer that may actually help you do what you want to do, though in a different way:

You can't get that information in any "approved" way. You could probably find some way to pass the data across the barrier as a void* and dereference it or something, but that would be a very bad idea, IMO.

If you're trying to access data in another instance of your own plugin then just use a global std::map (or something similar) and have a NPObject method that gives you the key to access the correct value of the std::map. When I do this I just use a global/static int and increment it to give every instance a unique id, then I have a property or method on the NPObject that can be called from the other NPObject that returns that id. You take the id, look up the instance in the map, and off you go.

Many modern browsers actually wrap your NPObject in something else even when it's passed to another instance of your plugin so you can't get the original NPObject from the one you get, you can just make NPRuntime calls on it. We used to be able to do that with FireBreath, but it no longer works between different instances.


Need Your Help

How to force user agent on mobile browser

php http user-agent

Im integrating Magento and Expression Engine. EE is pulling header and footer from Magento. And Magento has a mobile theme for specific agents but EE does not. So I wanna force mobile users to load

Find phase difference between two (inharmonic) waves

python numpy neural-network physics scipy

I have two datasets listing the average voltage outputs of two assemblies of neural networks at times t, that look something like this: