0

I write a plugin for android browser and follow the npruntime rule to let it support JavaScript method. However, after I call the function of my plugin in JavaScript, I get different identifier number in NPAPI's pluginHasMethod() function. I am sure there is no typo error in my JavaScript code. Is there any idea to debug this situation?

Thanks in advance.

Sean
  • 25
  • 1
  • 7
  • Are you testing with the standard browser or an embedded component? Different identifier number than what? You mean different `NPIdentifier`s on successive calls for the same function name? `NPIdentifier`s are supposed to be the same given the same string or integer. Maybe test your assumptions by [converting to a string](https://developer.mozilla.org/en-US/docs/NPN_UTF8FromIdentifier)? – Georg Fritzsche Aug 07 '12 at 13:26
  • I am testing with Android ICS default (webkit based) browser. Your understanding is right. NPIdentifier s should be the same because I write the same method name in JavaScript and C. Thanks for your suggestion. I have tested NPN_UTF8FromIdentifier, but I get a linking error: undefined reference to `NPN_UTF8FromIdentifier'. I am looking for the solution for this linking error, too. – Sean Aug 08 '12 at 02:02

1 Answers1

0

NPN_UTF8fromIdentifier is a function you have to provide yourself to call the correct function on the NPNFuncs that you were given when the plugin initialized.

The NPIdentifier is only guaranteed to be the same during the same browser instance; if you quit the browser and start a new one, it may change.

All NPN_* functions are not real functions; those are the "typical" names that you might use for them, but in actuality you are given a structure of function pointers of type NPNFuncs that will have a function pointer for each of the NPN_* functions; if you want those to actually work you need to create the NPN_UTF8FromIdentifier function, etc, and have it call the correct function pointer.

For more info see http://npapi.com/tutorial and http://npapi.com/tutorial2

taxilian
  • 14,229
  • 4
  • 34
  • 73
  • 1
    Thank you for your suggestion. I solve the linking error. The root cause is that I have to call function pointer from NPNetscapeFuncs. However, after I print out the method name, it is not the called method in my JavaScript. Do you have any suggestion about this situation? – Sean Aug 10 '12 at 03:41
  • Sorry, I use an undefined variable to call this method in my JavaScript. Your answer is correct. Thank you for your help. – Sean Aug 10 '12 at 06:34