Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can't pass a C++ object to javascript; what you can do is pass an NPObject that is also a C++ object and exposes things through the NPRuntime interface.</p> <p>See <a href="http://npapi.com/tutorial3" rel="nofollow">http://npapi.com/tutorial3</a> for more information.</p> <p>You may also want to look at the <a href="http://www.firebreath.org" rel="nofollow">FireBreath</a> framework, which greatly simplifies things like this.</p> <p><strong>Edit</strong>: it seems I misunderstood your question. What you want is to be able to store data linked to a plugin instance. What you need is the NPP that is given to you when your plugin is created; the NPP has two members, ndata (netscape data) and pdata (plugin data). The pdata pointer is yours to control -- you can set it to point to any arbitrary value that you want, and then cast it back to the real type whenever you want to use it. Be sure to cast it back and delete it on NPP_Destroy, of course. I usually create a struct to keep a few pieces of information in it. FireBreath uses this and sends all plugin calls into a Plugin object instance so that you can act as though it were a normal object.</p> <p>Relevant code example from FireBreath: <a href="https://github.com/firebreath/FireBreath/blob/master/src/NpapiCore/NpapiPluginModule_NPP.cpp#L145" rel="nofollow">https://github.com/firebreath/FireBreath/blob/master/src/NpapiCore/NpapiPluginModule_NPP.cpp#L145</a> </p> <p>Pay particular attention to NPP_New and NPP_Destroy; also pay particular attention to how the pdata member of the NPP is used.</p> <p>This is also discussed in <a href="http://npapi.com/tutorial2" rel="nofollow">http://npapi.com/tutorial2</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload