2004-07-12 19:53:22 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2004-07-12 19:53:22 +04:00
|
|
|
|
2009-03-18 00:20:02 +03:00
|
|
|
#ifndef nsJSNPRuntime_h_
|
|
|
|
#define nsJSNPRuntime_h_
|
2004-07-12 19:53:22 +04:00
|
|
|
|
|
|
|
#include "nscore.h"
|
|
|
|
#include "jsapi.h"
|
|
|
|
#include "npapi.h"
|
|
|
|
#include "npruntime.h"
|
|
|
|
#include "pldhash.h"
|
|
|
|
|
|
|
|
class nsJSNPRuntime
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static void OnPluginDestroy(NPP npp);
|
|
|
|
};
|
|
|
|
|
2004-07-30 08:00:05 +04:00
|
|
|
class nsJSObjWrapperKey
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsJSObjWrapperKey(JSObject *obj, NPP npp)
|
|
|
|
: mJSObj(obj), mNpp(npp)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
JSObject *mJSObj;
|
|
|
|
|
|
|
|
const NPP mNpp;
|
|
|
|
};
|
|
|
|
|
|
|
|
class nsJSObjWrapper : public NPObject,
|
|
|
|
public nsJSObjWrapperKey
|
2004-07-12 19:53:22 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
static NPObject *GetNewOrUsed(NPP npp, JSContext *cx, JSObject *obj);
|
|
|
|
|
|
|
|
protected:
|
2004-07-30 08:00:05 +04:00
|
|
|
nsJSObjWrapper(NPP npp);
|
2004-07-12 19:53:22 +04:00
|
|
|
~nsJSObjWrapper();
|
|
|
|
|
2004-08-27 04:58:44 +04:00
|
|
|
static NPObject * NP_Allocate(NPP npp, NPClass *aClass);
|
2004-07-12 19:53:22 +04:00
|
|
|
static void NP_Deallocate(NPObject *obj);
|
|
|
|
static void NP_Invalidate(NPObject *obj);
|
|
|
|
static bool NP_HasMethod(NPObject *, NPIdentifier identifier);
|
|
|
|
static bool NP_Invoke(NPObject *obj, NPIdentifier method,
|
|
|
|
const NPVariant *args, uint32_t argCount,
|
|
|
|
NPVariant *result);
|
2004-08-30 08:31:16 +04:00
|
|
|
static bool NP_InvokeDefault(NPObject *obj, const NPVariant *args,
|
|
|
|
uint32_t argCount, NPVariant *result);
|
2004-07-12 19:53:22 +04:00
|
|
|
static bool NP_HasProperty(NPObject * obj, NPIdentifier property);
|
|
|
|
static bool NP_GetProperty(NPObject *obj, NPIdentifier property,
|
|
|
|
NPVariant *result);
|
|
|
|
static bool NP_SetProperty(NPObject *obj, NPIdentifier property,
|
|
|
|
const NPVariant *value);
|
|
|
|
static bool NP_RemoveProperty(NPObject *obj, NPIdentifier property);
|
2006-03-01 03:13:38 +03:00
|
|
|
static bool NP_Enumerate(NPObject *npobj, NPIdentifier **identifier,
|
|
|
|
uint32_t *count);
|
2007-10-10 05:24:28 +04:00
|
|
|
static bool NP_Construct(NPObject *obj, const NPVariant *args,
|
|
|
|
uint32_t argCount, NPVariant *result);
|
2004-07-12 19:53:22 +04:00
|
|
|
|
|
|
|
public:
|
|
|
|
static NPClass sJSObjWrapperNPClass;
|
|
|
|
};
|
|
|
|
|
|
|
|
class nsNPObjWrapper
|
|
|
|
{
|
|
|
|
public:
|
2007-08-10 02:22:26 +04:00
|
|
|
static void OnDestroy(NPObject *npobj);
|
2004-07-12 19:53:22 +04:00
|
|
|
static JSObject *GetNewOrUsed(NPP npp, JSContext *cx, NPObject *npobj);
|
|
|
|
};
|
|
|
|
|
|
|
|
bool
|
|
|
|
JSValToNPVariant(NPP npp, JSContext *cx, jsval val, NPVariant *variant);
|
|
|
|
|
2005-07-14 06:36:41 +04:00
|
|
|
|
2009-03-18 00:20:02 +03:00
|
|
|
#endif // nsJSNPRuntime_h_
|