Landing fix for bug 296159. Adding support for NPObject enumeration to npruntime. Patch by alfred.peng@sun.com, r=mrbkap@gmail.com, sr=jst@mozilla.org

git-svn-id: svn://10.0.0.236/trunk@191449 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
jst%mozilla.jstenback.com
2006-03-01 00:13:38 +00:00
parent f9659c1a5b
commit dc4b19a5f8
7 changed files with 251 additions and 14 deletions

View File

@@ -37,7 +37,7 @@
/*
* npapi.h $Revision: 3.41 $
* npapi.h $Revision: 3.42 $
* Netscape client plug-in API spec
*/
@@ -125,7 +125,7 @@
/*----------------------------------------------------------------------*/
#define NP_VERSION_MAJOR 0
#define NP_VERSION_MINOR 16
#define NP_VERSION_MINOR 17
/* The OS/2 version of Netscape uses RC_DATA to define the

View File

@@ -292,6 +292,8 @@ typedef bool (*NPSetPropertyFunctionPtr)(NPObject *npobj, NPIdentifier name,
const NPVariant *value);
typedef bool (*NPRemovePropertyFunctionPtr)(NPObject *npobj,
NPIdentifier name);
typedef bool (*NPEnumerationFunctionPtr)(NPObject *npobj, NPIdentifier **value,
uint32_t *count);
/*
NPObjects returned by create, retain, invoke, and getProperty pass
@@ -310,6 +312,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
{
@@ -324,9 +331,14 @@ struct NPClass
NPGetPropertyFunctionPtr getProperty;
NPSetPropertyFunctionPtr setProperty;
NPRemovePropertyFunctionPtr removeProperty;
NPEnumerationFunctionPtr enumerate;
};
#define NP_CLASS_STRUCT_VERSION 1
#define NP_CLASS_STRUCT_VERSION 2
#define NP_CLASS_STRUCT_VERSION_ENUM 2
#define NP_CLASS_STRUCT_VERSION_HAS_ENUM(npclass) \
((npclass)->structVersion >= NP_CLASS_STRUCT_VERSION_ENUM)
struct NPObject {
NPClass *_class;
@@ -381,6 +393,8 @@ 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,
uint32_t *count);
/*
NPN_SetException may be called to trigger a script exception upon

View File

@@ -37,7 +37,7 @@
/*
* npupp.h $Revision: 3.20 $
* npupp.h $Revision: 3.21 $
* function call mecahnics needed by platform specific glue code.
*/
@@ -1638,6 +1638,35 @@ typedef bool (* NP_LOADDS NPN_PopPopupsEnabledStateUPP)(NPP npp);
#endif
/* NPN_Enumerate */
#if _NPUPP_USE_UPP_
typedef UniversalProcPtr NPN_EnumerateUPP;
enum {
uppNPN_EnumerateProcInfo = kThinkCStackBased
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(NPP)))
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(NPObject*)))
| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(NPIdentifier**)))
| STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(uint32_t*)))
| RESULT_SIZE(SIZE_CODE(sizeof(bool)))
};
#define NewNPN_EnumerateProc(FUNC) \
(NPN_EnumerateUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPN_EnumerateProcInfo, GetCurrentArchitecture())
#define CallNPN_EnumerateProc(FUNC, ARG1, ARG2, ARG3, ARG4) \
(jref)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPN_EnumerateProcInfo, (ARG1), (ARG2), (ARG3), (ARG4))
#else
typedef bool (* NP_LOADDS NPN_EnumerateUPP)(NPP npp, NPObject *obj, NPIdentifier **identifier, uint32_t *count);
#define NewNPN_EnumerateProc(FUNC) \
((NPN_EnumerateUPP) (FUNC))
#define CallNPN_EnumerateProc(FUNC, ARG1, ARG2, ARG3, ARG4) \
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4))
#endif
/******************************************************************************************
@@ -1714,6 +1743,7 @@ typedef struct _NPNetscapeFuncs {
NPN_SetExceptionUPP setexception;
NPN_PushPopupsEnabledStateUPP pushpopupsenabledstate;
NPN_PopPopupsEnabledStateUPP poppopupsenabledstate;
NPN_EnumerateUPP enumerate;
} NPNetscapeFuncs;
#ifdef XP_MAC