0

I have my Plugin.cpp class in my NPAPI Plugin i want to pass this class object to javascript function as follows ::

function testData(){
 var obj = data.getObject();

//data is an object created in javascript, getObject is implemented in Plugin.cpp, in Invoke method, inside getObject i have to return the Plugin Class Object . obj i have to access Plugin methods.

  initFS(obj);

}

function initFS(obj) {
  obj.testFunc(); //testFunc method is in the Plugin
}

Thanks in advance !!

r_tex
  • 77
  • 9
  • Just to clarify, are you asking how you can return an additional object besides your core NPObject to javascript? – taxilian Sep 11 '12 at 05:01
  • Yes taxilian , it's right i want to return additional objects from the Plugin. This object i am getting from plugin via NPN_InvokeDefault but unable to access methods of plugin from javascript. Like obj.testFunc(); – r_tex Sep 11 '12 at 08:33

1 Answers1

1

You just need to create an additional NPObject and put it in the NPVariant that you send as a parameter to the InvokeDefault call.

Remember that when you call InvokeDefault and hand it off to Javascript the browser will retain the object if it needs to hold onto it so you'll need to do a Release when you are done with the object to avoid a memory leak.

See http://npapi.com/memory

See also http://npapi.com/tutorial3

taxilian
  • 14,229
  • 4
  • 34
  • 73