This is no problem at all. I'm assuming that you're using npruntime
(NPObjects) for your interface... if you're using xpcom, you should
probably think about changing since support for it is being dropped
=] Also, I don't know how to do this with xpcom =]
In your NPObject's Get/SetProperty method (or invoke, for that
matter), you normally would use NPN_UTF8FromIdentifier to get the
function name; when you're using array access, you just use
NPN_GetIntIdentifier instead. You can even support both; just use
NPN_IdentifierIsString to see if it's a string or an int.
So, you could do (pseudo-code):
bool GetProperty(NPIdentifier propertyName, NPVariant *result)
{
if (NPN_IdentifierIsString(propertyName)) {
GetStringProperty(NPN_UTF8FromIdentifier(propertyName, result));
} else {
GetIntProperty(NPN_GetIntIdentifier(propertyName, result));
}
}
and then just implement GetStringProperty to handle property names
with strings, and GetIntProperty to handle integer indexes.
i.e.:
pluginObj.length would result in GetStringProperty("length", result),
and pluginObj[4] would result in GetIntProperty(4, result)
Hope that helps,
Richard Bateman
Thanks! Very helpful.