My NPAPI plugin receives a Javascript function as NPObject. Is there a way to get this function's signature, or at least, the number of parameters it requires?
Thank you.
My NPAPI plugin receives a Javascript function as NPObject. Is there a way to get this function's signature, or at least, the number of parameters it requires?
Thank you.
Unlike C++, JavaScript is dynamically typed: you just call the function and rely on it to handle what you pass in.
While there is Function.length
to get the number of named arguments, differing behavior based on this breaks approaches like:
arguments
array.You can get the number of arguments using such code:
function MyFunc(a, b, c) {
//some stuff here...
}
var num = MyFunc.length;
alert("number of arguments: " + num);
Other than that not much you can get outside the function itself, JavaScript does not have types so you can't know what type of arguments the function is expecting.