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 "npapi.h"
|
|
|
|
#include "npruntime.h"
|
|
|
|
#include "pldhash.h"
|
|
|
|
|
|
|
|
class nsJSNPRuntime
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static void OnPluginDestroy(NPP npp);
|
2015-03-10 00:07:16 +03:00
|
|
|
static void OnPluginDestroyPending(NPP npp);
|
2004-07-12 19:53:22 +04:00
|
|
|
};
|
|
|
|
|
2004-07-30 08:00:05 +04:00
|
|
|
class nsJSObjWrapperKey
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsJSObjWrapperKey(JSObject *obj, NPP npp)
|
|
|
|
: mJSObj(obj), mNpp(npp)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-11-20 02:53:36 +04:00
|
|
|
bool operator==(const nsJSObjWrapperKey& other) const {
|
|
|
|
return mJSObj == other.mJSObj && mNpp == other.mNpp;
|
|
|
|
}
|
|
|
|
bool operator!=(const nsJSObjWrapperKey& other) const {
|
|
|
|
return !(*this == other);
|
|
|
|
}
|
2004-07-30 08:00:05 +04:00
|
|
|
|
2013-11-20 02:53:36 +04:00
|
|
|
JSObject * mJSObj;
|
2004-07-30 08:00:05 +04:00
|
|
|
const NPP mNpp;
|
|
|
|
};
|
|
|
|
|
2013-11-20 02:53:36 +04:00
|
|
|
class nsJSObjWrapper : public NPObject
|
2004-07-12 19:53:22 +04:00
|
|
|
{
|
|
|
|
public:
|
2014-11-05 19:37:16 +03:00
|
|
|
JS::Heap<JSObject *> mJSObj;
|
2013-11-20 02:53:36 +04:00
|
|
|
const NPP mNpp;
|
2015-03-10 00:07:16 +03:00
|
|
|
bool mDestroyPending;
|
2013-11-20 02:53:36 +04:00
|
|
|
|
2013-05-15 03:25:32 +04:00
|
|
|
static NPObject *GetNewOrUsed(NPP npp, JSContext *cx,
|
|
|
|
JS::Handle<JSObject*> obj);
|
2014-12-30 02:12:25 +03:00
|
|
|
static bool HasOwnProperty(NPObject* npobj, NPIdentifier npid);
|
2004-07-12 19:53:22 +04:00
|
|
|
|
|
|
|
protected:
|
2014-09-02 04:49:25 +04:00
|
|
|
explicit 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:
|
2014-11-05 19:37:16 +03:00
|
|
|
static bool IsWrapper(JSObject *obj);
|
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
|
2013-04-03 03:05:37 +04:00
|
|
|
JSValToNPVariant(NPP npp, JSContext *cx, JS::Value val, NPVariant *variant);
|
2004-07-12 19:53:22 +04:00
|
|
|
|
2005-07-14 06:36:41 +04:00
|
|
|
|
2009-03-18 00:20:02 +03:00
|
|
|
#endif // nsJSNPRuntime_h_
|