-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathScriptablePluginObjectBase.h
More file actions
executable file
·84 lines (73 loc) · 3.34 KB
/
ScriptablePluginObjectBase.h
File metadata and controls
executable file
·84 lines (73 loc) · 3.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#ifndef _NPSOBJBASE_H_
#define _NPSOBJBASE_H_
#include "npapi.h"
#include "npruntime.h"
// Helper class that can be used to map calls to the NPObject hooks
// into virtual methods on instances of classes that derive from this
// class.
static NPObject *sWindowObj;
class ScriptablePluginObjectBase : public NPObject
{
public:
ScriptablePluginObjectBase(NPP npp)
: mNpp(npp)
{
}
virtual ~ScriptablePluginObjectBase()
{
}
// Virtual NPObject hooks called through this base class. Override
// as you see fit.
virtual void Invalidate();
virtual bool HasMethod(NPIdentifier name);
virtual bool Invoke(NPIdentifier name, const NPVariant *args,
uint32_t argCount, NPVariant *result);
virtual bool InvokeDefault(const NPVariant *args, uint32_t argCount,
NPVariant *result);
virtual bool HasProperty(NPIdentifier name);
virtual bool GetProperty(NPIdentifier name, NPVariant *result);
virtual bool SetProperty(NPIdentifier name, const NPVariant *value);
virtual bool RemoveProperty(NPIdentifier name);
virtual bool Enumerate(NPIdentifier **identifier, uint32_t *count);
virtual bool Construct(const NPVariant *args, uint32_t argCount,
NPVariant *result);
public:
static void _Deallocate(NPObject *npobj);
static void _Invalidate(NPObject *npobj);
static bool _HasMethod(NPObject *npobj, NPIdentifier name);
static bool _Invoke(NPObject *npobj, NPIdentifier name,
const NPVariant *args, uint32_t argCount,
NPVariant *result);
static bool _InvokeDefault(NPObject *npobj, const NPVariant *args,
uint32_t argCount, NPVariant *result);
static bool _HasProperty(NPObject * npobj, NPIdentifier name);
static bool _GetProperty(NPObject *npobj, NPIdentifier name,
NPVariant *result);
static bool _SetProperty(NPObject *npobj, NPIdentifier name,
const NPVariant *value);
static bool _RemoveProperty(NPObject *npobj, NPIdentifier name);
static bool _Enumerate(NPObject *npobj, NPIdentifier **identifier,
uint32_t *count);
static bool _Construct(NPObject *npobj, const NPVariant *args,
uint32_t argCount, NPVariant *result);
protected:
NPP mNpp;
};
#define DECLARE_NPOBJECT_CLASS_WITH_BASE(_class, ctor) \
static NPClass s##_class##_NPClass = { \
NP_CLASS_STRUCT_VERSION_CTOR, \
ctor, \
ScriptablePluginObjectBase::_Deallocate, \
ScriptablePluginObjectBase::_Invalidate, \
ScriptablePluginObjectBase::_HasMethod, \
ScriptablePluginObjectBase::_Invoke, \
ScriptablePluginObjectBase::_InvokeDefault, \
ScriptablePluginObjectBase::_HasProperty, \
ScriptablePluginObjectBase::_GetProperty, \
ScriptablePluginObjectBase::_SetProperty, \
ScriptablePluginObjectBase::_RemoveProperty, \
ScriptablePluginObjectBase::_Enumerate, \
ScriptablePluginObjectBase::_Construct \
}
#define GET_NPOBJECT_CLASS(_class) &s##_class##_NPClass
#endif