Merge in latest version from mozilla.org, and fix a signedness bug with types I introduced.

svn path=/trunk/KDE/kdebase/apps/; revision=1116074
This commit is contained in:
Maks Orlovich 2010-04-18 15:30:55 +00:00
parent 7f5e80a8d3
commit f440aeb6b7

View file

@ -117,8 +117,8 @@ typedef struct NPClass NPClass;
typedef char NPUTF8;
typedef struct _NPString {
const NPUTF8 *utf8characters;
quint32 utf8length;
const NPUTF8 *UTF8Characters;
quint32 UTF8Length;
} NPString;
typedef enum {
@ -135,7 +135,7 @@ typedef struct _NPVariant {
NPVariantType type;
union {
bool boolValue;
quint32 intValue;
qint32 intValue;
double doubleValue;
NPString stringValue;
NPObject *objectValue;
@ -220,25 +220,25 @@ NP_END_MACRO
/*
Type mappings (JavaScript types have been used for illustration
Type mappings (JavaScript types have been used for illustration
purposes):
JavaScript to C (NPVariant with type:)
undefined NPVariantType_Void
null NPVariantType_Null
Boolean NPVariantType_Bool
Number NPVariantType_Double or NPVariantType_Int32
String NPVariantType_String
Object NPVariantType_Object
JavaScript to C (NPVariant with type:)
undefined NPVariantType_Void
null NPVariantType_Null
Boolean NPVariantType_Bool
Number NPVariantType_Double or NPVariantType_Int32
String NPVariantType_String
Object NPVariantType_Object
C (NPVariant with type:) to JavaScript
NPVariantType_Void undefined
NPVariantType_Null null
NPVariantType_Bool Boolean
NPVariantType_Int32 Number
NPVariantType_Double Number
NPVariantType_String String
NPVariantType_Object Object
C (NPVariant with type:) to JavaScript
NPVariantType_Void undefined
NPVariantType_Null null
NPVariantType_Bool Boolean
NPVariantType_Int32 Number
NPVariantType_Double Number
NPVariantType_String String
NPVariantType_Object Object
*/
typedef void *NPIdentifier;
@ -250,12 +250,14 @@ typedef void *NPIdentifier;
methods and properties can be identified by either strings or
integers (i.e. foo["bar"] vs foo[1]). NPIdentifiers can be
compared using ==. In case of any errors, the requested
NPIdentifier(s) will be NULL.
NPIdentifier(s) will be NULL. NPIdentifier lifetime is controlled
by the browser. Plugins do not need to worry about memory management
with regards to NPIdentifiers.
*/
NPIdentifier NPN_GetStringIdentifier(const NPUTF8 *name);
void NPN_GetStringIdentifiers(const NPUTF8 **names, int32_t nameCount,
void NPN_GetStringIdentifiers(const NPUTF8 **names, qint32 nameCount,
NPIdentifier *identifiers);
NPIdentifier NPN_GetIntIdentifier(int32_t intid);
NPIdentifier NPN_GetIntIdentifier(qint32 intid);
bool NPN_IdentifierIsString(NPIdentifier identifier);
/*
@ -267,7 +269,7 @@ NPUTF8 *NPN_UTF8FromIdentifier(NPIdentifier identifier);
Get the integer represented by identifier. If identifier is not an
integer identifier, the behaviour is undefined.
*/
int32_t NPN_IntFromIdentifier(NPIdentifier identifier);
qint32 NPN_IntFromIdentifier(NPIdentifier identifier);
/*
NPObject behavior is implemented using the following set of
@ -294,6 +296,12 @@ typedef bool (*NPSetPropertyFunctionPtr)(NPObject *npobj, NPIdentifier name,
const NPVariant *value);
typedef bool (*NPRemovePropertyFunctionPtr)(NPObject *npobj,
NPIdentifier name);
typedef bool (*NPEnumerationFunctionPtr)(NPObject *npobj, NPIdentifier **value,
quint32 *count);
typedef bool (*NPConstructFunctionPtr)(NPObject *npobj,
const NPVariant *args,
quint32 argCount,
NPVariant *result);
/*
NPObjects returned by create, retain, invoke, and getProperty pass
@ -312,6 +320,11 @@ typedef bool (*NPRemovePropertyFunctionPtr)(NPObject *npobj,
will typically return immediately, with 0 or NULL, from an attempt
to dispatch to a NPObject, but this behavior should not be
depended upon.)
The NPEnumerationFunctionPtr function may pass an array of
NPIdentifiers back to the caller. The callee allocs the memory of
the array using NPN_MemAlloc(), and it's the caller's responsibility
to release it using NPN_MemFree().
*/
struct NPClass
{
@ -326,9 +339,20 @@ struct NPClass
NPGetPropertyFunctionPtr getProperty;
NPSetPropertyFunctionPtr setProperty;
NPRemovePropertyFunctionPtr removeProperty;
NPEnumerationFunctionPtr enumerate;
NPConstructFunctionPtr construct;
};
#define NP_CLASS_STRUCT_VERSION 1
#define NP_CLASS_STRUCT_VERSION 3
#define NP_CLASS_STRUCT_VERSION_ENUM 2
#define NP_CLASS_STRUCT_VERSION_CTOR 3
#define NP_CLASS_STRUCT_VERSION_HAS_ENUM(npclass) \
((npclass)->structVersion >= NP_CLASS_STRUCT_VERSION_ENUM)
#define NP_CLASS_STRUCT_VERSION_HAS_CTOR(npclass) \
((npclass)->structVersion >= NP_CLASS_STRUCT_VERSION_CTOR)
struct NPObject {
NPClass *_class;
@ -383,6 +407,10 @@ bool NPN_SetProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName,
bool NPN_RemoveProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName);
bool NPN_HasProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName);
bool NPN_HasMethod(NPP npp, NPObject *npobj, NPIdentifier methodName);
bool NPN_Enumerate(NPP npp, NPObject *npobj, NPIdentifier **identifier,
quint32 *count);
bool NPN_Construct(NPP npp, NPObject *npobj, const NPVariant *args,
quint32 argCount, NPVariant *result);
/*
NPN_SetException may be called to trigger a script exception upon