NPAPI header updates - comments, cleanup, and webkit compat change. Part of the patch for 386676. r=smichaud sr=roc

This commit is contained in:
Josh Aas 2008-12-16 23:48:42 -05:00
parent 5f8aedcf13
commit 04359072f7
4 changed files with 37 additions and 31 deletions

View File

@ -58,6 +58,8 @@ typedef void (*NPP_StreamAsFileProcPtr)(NPP instance, NPStream* stream,
typedef void (*NPP_PrintProcPtr)(NPP instance, NPPrint* platformPrint);
typedef int16_t (*NPP_HandleEventProcPtr)(NPP instance, void* event);
typedef void (*NPP_URLNotifyProcPtr)(NPP instance, const char* url, NPReason reason, void* notifyData);
// Any NPObjects returned to the browser via NPP_GetValue should be retained
// by the plugin on the way out. The browser is responsible for releasing.
typedef NPError (*NPP_GetValueProcPtr)(NPP instance, NPPVariable variable, void *ret_value);
typedef NPError (*NPP_SetValueProcPtr)(NPP instance, NPNVariable variable, void *ret_value);
@ -72,6 +74,8 @@ typedef NPError (*NPN_NewStreamProcPtr)(NPP instance, NPMIMEType type, cons
typedef int32_t (*NPN_WriteProcPtr)(NPP instance, NPStream* stream, int32_t len, void* buffer);
typedef NPError (*NPN_DestroyStreamProcPtr)(NPP instance, NPStream* stream, NPReason reason);
typedef void (*NPN_StatusProcPtr)(NPP instance, const char* message);
// Browser manages the lifetime of the buffer returned by NPN_UserAgent, don't
// depend on it sticking around and don't free it.
typedef const char* (*NPN_UserAgentProcPtr)(NPP instance);
typedef void* (*NPN_MemAllocProcPtr)(uint32_t size);
typedef void (*NPN_MemFreeProcPtr)(void* ptr);
@ -241,7 +245,7 @@ typedef struct _NPPluginData { /* Alternate OS2 Plugin interface */
NPError OSCALL NP_GetPluginData(NPPluginData * pPluginData);
#endif
NPError OSCALL NP_GetEntryPoints(NPPluginFuncs* pFuncs);
NPError OSCALL NP_Initialize(NPNetscapeFuncs* pFuncs);
NPError OSCALL NP_Initialize(NPNetscapeFuncs* bFuncs);
NPError OSCALL NP_Shutdown();
char* NP_GetMIMEDescription();
#ifdef __cplusplus

View File

@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* Copyright © 2004, Apple Computer, Inc. and The Mozilla Foundation.
* Copyright (c) 2004, Apple Computer, Inc. and The Mozilla Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -115,8 +115,8 @@ typedef struct NPClass NPClass;
typedef char NPUTF8;
typedef struct _NPString {
const NPUTF8 *utf8characters;
uint32_t utf8length;
const NPUTF8 *UTF8Characters;
uint32_t UTF8Length;
} NPString;
typedef enum {
@ -218,25 +218,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;
@ -248,7 +248,9 @@ 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,

View File

@ -354,7 +354,7 @@ NPVariantToJSVal(NPP npp, JSContext *cx, const NPVariant *variant)
case NPVariantType_String :
{
const NPString *s = &NPVARIANT_TO_STRING(*variant);
NS_ConvertUTF8toUTF16 utf16String(s->utf8characters, s->utf8length);
NS_ConvertUTF8toUTF16 utf16String(s->UTF8Characters, s->UTF8Length);
JSString *str =
::JS_NewUCStringCopyN(cx, reinterpret_cast<const jschar*>

View File

@ -1523,14 +1523,14 @@ _evaluate(NPP npp, NPObject* npobj, NPString *script, NPVariant *result)
VOID_TO_NPVARIANT(*result);
}
if (!script || !script->utf8length || !script->utf8characters) {
if (!script || !script->UTF8Length || !script->UTF8Characters) {
// Nothing to evaluate.
return true;
}
NS_ConvertUTF8toUTF16 utf16script(script->utf8characters,
script->utf8length);
NS_ConvertUTF8toUTF16 utf16script(script->UTF8Characters,
script->UTF8Length);
nsCOMPtr<nsIScriptContext> scx = GetScriptContextFromJSContext(cx);
NS_ENSURE_TRUE(scx, false);
@ -1568,7 +1568,7 @@ _evaluate(NPP npp, NPObject* npobj, NPString *script, NPVariant *result)
NPN_PLUGIN_LOG(PLUGIN_LOG_NOISY,
("NPN_Evaluate(npp %p, npobj %p, script <<<%s>>>) called\n",
npp, npobj, script->utf8characters));
npp, npobj, script->UTF8Characters));
nsresult rv = scx->EvaluateStringWithValue(utf16script, obj, principal,
spec, 0, 0, rval, nsnull);
@ -1763,12 +1763,12 @@ _releasevariantvalue(NPVariant* variant)
{
const NPString *s = &NPVARIANT_TO_STRING(*variant);
if (s->utf8characters) {
if (s->UTF8Characters) {
#ifdef MOZ_MEMORY_WINDOWS
if (malloc_usable_size((void *)s->utf8characters) != 0) {
PR_Free((void *)s->utf8characters);
if (malloc_usable_size((void *)s->UTF8Characters) != 0) {
PR_Free((void *)s->UTF8Characters);
} else {
void *p = (void *)s->utf8characters;
void *p = (void *)s->UTF8Characters;
DWORD nheaps = 0;
nsAutoTArray<HANDLE, 50> heaps;
nheaps = GetProcessHeaps(0, heaps.Elements());
@ -1782,7 +1782,7 @@ _releasevariantvalue(NPVariant* variant)
}
}
#else
PR_Free((void *)s->utf8characters);
PR_Free((void *)s->UTF8Characters);
#endif
}
break;