dom/plugins/base/nsJSNPRuntime.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/plugins/base/nsJSNPRuntime.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,89 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef nsJSNPRuntime_h_
    1.10 +#define nsJSNPRuntime_h_
    1.11 +
    1.12 +#include "nscore.h"
    1.13 +#include "npapi.h"
    1.14 +#include "npruntime.h"
    1.15 +#include "pldhash.h"
    1.16 +
    1.17 +class nsJSNPRuntime
    1.18 +{
    1.19 +public:
    1.20 +  static void OnPluginDestroy(NPP npp);
    1.21 +};
    1.22 +
    1.23 +class nsJSObjWrapperKey
    1.24 +{
    1.25 +public:
    1.26 +  nsJSObjWrapperKey(JSObject *obj, NPP npp)
    1.27 +    : mJSObj(obj), mNpp(npp)
    1.28 +  {
    1.29 +  }
    1.30 +
    1.31 +  bool operator==(const nsJSObjWrapperKey& other) const {
    1.32 +    return mJSObj == other.mJSObj && mNpp == other.mNpp;
    1.33 +  }
    1.34 +  bool operator!=(const nsJSObjWrapperKey& other) const {
    1.35 +    return !(*this == other);
    1.36 +  }
    1.37 +
    1.38 +  JSObject * mJSObj;
    1.39 +  const NPP mNpp;
    1.40 +};
    1.41 +
    1.42 +extern const JSClass sNPObjectJSWrapperClass;
    1.43 +
    1.44 +class nsJSObjWrapper : public NPObject
    1.45 +{
    1.46 +public:
    1.47 +  JS::PersistentRooted<JSObject *> mJSObj;
    1.48 +  const NPP mNpp;
    1.49 +
    1.50 +  static NPObject *GetNewOrUsed(NPP npp, JSContext *cx,
    1.51 +                                JS::Handle<JSObject*> obj);
    1.52 +
    1.53 +protected:
    1.54 +  nsJSObjWrapper(NPP npp);
    1.55 +  ~nsJSObjWrapper();
    1.56 +
    1.57 +  static NPObject * NP_Allocate(NPP npp, NPClass *aClass);
    1.58 +  static void NP_Deallocate(NPObject *obj);
    1.59 +  static void NP_Invalidate(NPObject *obj);
    1.60 +  static bool NP_HasMethod(NPObject *, NPIdentifier identifier);
    1.61 +  static bool NP_Invoke(NPObject *obj, NPIdentifier method,
    1.62 +                        const NPVariant *args, uint32_t argCount,
    1.63 +                        NPVariant *result);
    1.64 +  static bool NP_InvokeDefault(NPObject *obj, const NPVariant *args,
    1.65 +                               uint32_t argCount, NPVariant *result);
    1.66 +  static bool NP_HasProperty(NPObject * obj, NPIdentifier property);
    1.67 +  static bool NP_GetProperty(NPObject *obj, NPIdentifier property,
    1.68 +                             NPVariant *result);
    1.69 +  static bool NP_SetProperty(NPObject *obj, NPIdentifier property,
    1.70 +                             const NPVariant *value);
    1.71 +  static bool NP_RemoveProperty(NPObject *obj, NPIdentifier property);
    1.72 +  static bool NP_Enumerate(NPObject *npobj, NPIdentifier **identifier,
    1.73 +                           uint32_t *count);
    1.74 +  static bool NP_Construct(NPObject *obj, const NPVariant *args,
    1.75 +                           uint32_t argCount, NPVariant *result);
    1.76 +
    1.77 +public:
    1.78 +  static NPClass sJSObjWrapperNPClass;
    1.79 +};
    1.80 +
    1.81 +class nsNPObjWrapper
    1.82 +{
    1.83 +public:
    1.84 +  static void OnDestroy(NPObject *npobj);
    1.85 +  static JSObject *GetNewOrUsed(NPP npp, JSContext *cx, NPObject *npobj);
    1.86 +};
    1.87 +
    1.88 +bool
    1.89 +JSValToNPVariant(NPP npp, JSContext *cx, JS::Value val, NPVariant *variant);
    1.90 +
    1.91 +
    1.92 +#endif // nsJSNPRuntime_h_

mercurial