Fixed <rdar://problem/
4098713> Scripting API is incompatible with Mozilla
We were incompatible with Mozilla's implementation of the scripting APIs in
two ways:
Their NPN_SetException has the following signature:
void NPN_SetException(NPObject *npobj, const NPUTF8 *message);
ours has:
void NPN_SetException (NPObject * npobj, const NPString *message);
Also, they expect the string returned from NPN_UTF8FromIdentifier() to be freed by caller.
We do not.
I changed both behaviors to match Mozilla.
Reviewed by Chris.
* bindings/NP_jsobject.cpp:
(_NPN_SetException):
* bindings/npruntime.cpp:
(_NPN_UTF8FromIdentifier):
(_NPN_IntFromIdentifier):
(_NPN_SetExceptionWithUTF8):
* bindings/npruntime.h:
* bindings/npruntime_impl.h:
WebKit:
Fixed <rdar://problem/
4098713> Scripting API is incompatible with Mozilla
Reviewed by Chris.
* Plugins.subproj/npfunctions.h:
* Plugins.subproj/npruntime.h:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@9061
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2005-04-26 Richard Williamson <rjw@apple.com>
+
+ Fixed <rdar://problem/4098713> Scripting API is incompatible with Mozilla
+
+ We were incompatible with Mozilla's implementation of the scripting APIs in
+ two ways:
+
+ Their NPN_SetException has the following signature:
+
+ void NPN_SetException(NPObject *npobj, const NPUTF8 *message);
+
+ ours has:
+
+ void NPN_SetException (NPObject * npobj, const NPString *message);
+
+ Also, they expect the string returned from NPN_UTF8FromIdentifier() to be freed by caller.
+ We do not.
+
+ I changed both behaviors to match Mozilla.
+
+ Reviewed by Chris.
+
+ * bindings/NP_jsobject.cpp:
+ (_NPN_SetException):
+ * bindings/npruntime.cpp:
+ (_NPN_UTF8FromIdentifier):
+ (_NPN_IntFromIdentifier):
+ (_NPN_SetExceptionWithUTF8):
+ * bindings/npruntime.h:
+ * bindings/npruntime_impl.h:
+
2005-04-26 Maciej Stachowiak <mjs@apple.com>
Reviewed by Chris.
return false;
}
-void _NPN_SetException (NPObject *o, NPString *message)
+void _NPN_SetException (NPObject *o, const NPUTF8 *message)
{
if (o->_class == NPScriptObjectClass) {
JavaScriptObject *obj = (JavaScriptObject *)o;
ExecState *exec = obj->executionContext->interpreter()->globalExec();
Interpreter::lock();
- char *msg = (char *)malloc (message->UTF8Length + 1);
- strncpy (msg, message->UTF8Characters, message->UTF8Length);
- msg[message->UTF8Length] = 0;
- Object err = Error::create(exec, GeneralError, msg);
- free (msg);
+ Object err = Error::create(exec, GeneralError, message);
exec->setException (err);
Interpreter::unlock();
}
NPUTF8 *_NPN_UTF8FromIdentifier (NPIdentifier identifier)
{
PrivateIdentifier *i = (PrivateIdentifier *)identifier;
- if (!i->isString)
+ if (!i->isString || !i->value.string)
return NULL;
- return (NPUTF8 *)i->value.string;
+ return (NPUTF8 *)strdup(i->value.string);
}
int32_t _NPN_IntFromIdentifier(NPIdentifier identifier)
{
- // FIXME: Implement!
- return 0;
+ PrivateIdentifier *i = (PrivateIdentifier *)identifier;
+ if (!i->isString)
+ return 0;
+ return i->value.number;
}
NPBool NPN_VariantIsVoid (const NPVariant *variant)
assert (message);
if (obj && message) {
- NPString string;
- string.UTF8Characters = message;
- string.UTF8Length = length;
- _NPN_SetException (obj, &string);
+ _NPN_SetException (obj, message);
}
}
NPN_SetException may be called to trigger a script exception upon return
from entry points into NPObjects.
*/
-void NPN_SetException (NPObject *obj, NPString *message);
+void NPN_SetException (NPObject *obj, const NPUTF8 *message);
#ifdef __cplusplus
}
extern bool _NPN_RemoveProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName);
extern bool _NPN_HasProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName);
extern bool _NPN_HasMethod(NPP npp, NPObject *npobj, NPIdentifier methodName);
-extern void _NPN_SetException(NPObject *obj, NPString *message);
+extern void _NPN_SetException(NPObject *obj, const NPUTF8 *message);
#ifdef __cplusplus
} /* end extern "C" */
+2005-04-26 Richard Williamson <rjw@apple.com>
+
+ Fixed <rdar://problem/4098713> Scripting API is incompatible with Mozilla
+
+ Reviewed by Chris.
+
+ * Plugins.subproj/npfunctions.h:
+ * Plugins.subproj/npruntime.h:
+
2005-04-26 Darin Adler <darin@apple.com>
Reviewed by John.
typedef bool (*NPN_HasPropertyProcPtr) (NPP, NPObject *npobj, NPIdentifier propertyName);
typedef bool (*NPN_HasMethodProcPtr) (NPP npp, NPObject *npobj, NPIdentifier methodName);
typedef bool (*NPN_RemovePropertyProcPtr) (NPP npp, NPObject *obj, NPIdentifier propertyName);
-typedef void (*NPN_SetExceptionProcPtr) (NPObject *obj, NPString *message);
+typedef void (*NPN_SetExceptionProcPtr) (NPObject *obj, const NPUTF8 *message);
typedef NPError (*NPP_NewProcPtr)(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved);
typedef NPError (*NPP_DestroyProcPtr)(NPP instance, NPSavedData** save);
NPN_SetException may be called to trigger a script exception upon return
from entry points into NPObjects.
*/
-void NPN_SetException (NPObject *obj, NPString *message);
+void NPN_SetException (NPObject *obj, const NPUTF8 *message);
#ifdef __cplusplus
}