source: trunk/icedtea-web/plugin/icedteanp/IcedTeaScriptablePluginObject.h@ 350

Last change on this file since 350 was 348, checked in by dmik, 13 years ago

vendor: Add icedtea-web v1.1.2 to current.

File size: 6.8 KB
Line 
1/* IcedTeaScriptablePluginObject.h
2
3 Copyright (C) 2009, 2010 Red Hat
4
5This file is part of IcedTea.
6
7IcedTea is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2, or (at your option)
10any later version.
11
12IcedTea is distributed in the hope that it will be useful, but
13WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with IcedTea; see the file COPYING. If not, write to the
19Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
2002110-1301 USA.
21
22Linking this library statically or dynamically with other modules is
23making a combined work based on this library. Thus, the terms and
24conditions of the GNU General Public License cover the whole
25combination.
26
27As a special exception, the copyright holders of this library give you
28permission to link this library with independent modules to produce an
29executable, regardless of the license terms of these independent
30modules, and to copy and distribute the resulting executable under
31terms of your choice, provided that you also meet, for each linked
32independent module, the terms and conditions of the license of that
33module. An independent module is a module which is not derived from
34or based on this library. If you modify this library, you may extend
35this exception to your version of the library, but you are not
36obligated to do so. If you do not wish to do so, delete this
37exception statement from your version. */
38
39#ifndef __ICEDTEASCRIPTABLEPLUGINOBJECT_H_
40#define __ICEDTEASCRIPTABLEPLUGINOBJECT_H_
41
42#if MOZILLA_VERSION_COLLAPSED < 1090100
43#include "npupp.h"
44#else
45#include <npapi.h>
46#include <npruntime.h>
47#endif
48
49#include "IcedTeaJavaRequestProcessor.h"
50#include "IcedTeaNPPlugin.h"
51
52/**
53 * IcedTeaScriptablePluginObject, an extended NPObject that implements
54 * static functions whose pointers are supplied to NPClass.
55 */
56
57class IcedTeaScriptablePluginObject: public NPObject
58{
59
60 private:
61 NPP instance;
62
63 public:
64 IcedTeaScriptablePluginObject(NPP instance);
65
66 static void deAllocate(NPObject *npobj);
67
68 static void invalidate(NPObject *npobj);
69
70 static bool hasMethod(NPObject *npobj, NPIdentifier name);
71
72 static bool invoke(NPObject *npobj, NPIdentifier name,
73 const NPVariant *args, uint32_t argCount, NPVariant *result);
74
75 static bool invokeDefault(NPObject *npobj, const NPVariant *args,
76 uint32_t argCount, NPVariant *result);
77
78 static bool hasProperty(NPObject *npobj, NPIdentifier name);
79
80 static bool getProperty(NPObject *npobj, NPIdentifier name,
81 NPVariant *result);
82
83 static bool setProperty(NPObject *npobj, NPIdentifier name,
84 const NPVariant *value);
85
86 static bool removeProperty(NPObject *npobj, NPIdentifier name);
87
88 static bool enumerate(NPObject *npobj, NPIdentifier **value,
89 uint32_t *count);
90
91 static bool construct(NPObject *npobj, const NPVariant *args,
92 uint32_t argCount, NPVariant *result);
93
94 static NPObject* get_scriptable_java_package_object(NPP instance, const NPUTF8* name);
95};
96
97NPObject* allocate_scriptable_jp_object(NPP npp, NPClass *aClass);
98
99class IcedTeaScriptableJavaPackageObject: public NPObject
100{
101
102 private:
103 NPP instance;
104 std::string* package_name;
105
106 public:
107 IcedTeaScriptableJavaPackageObject(NPP instance);
108
109 ~IcedTeaScriptableJavaPackageObject();
110
111 void setPackageName(const NPUTF8* name);
112
113 std::string getPackageName();
114
115 static void deAllocate(NPObject *npobj);
116
117 static void invalidate(NPObject *npobj);
118
119 static bool hasMethod(NPObject *npobj, NPIdentifier name);
120
121 static bool invoke(NPObject *npobj, NPIdentifier name,
122 const NPVariant *args, uint32_t argCount, NPVariant *result);
123
124 static bool invokeDefault(NPObject *npobj, const NPVariant *args,
125 uint32_t argCount, NPVariant *result);
126
127 static bool hasProperty(NPObject *npobj, NPIdentifier name);
128
129 static bool getProperty(NPObject *npobj, NPIdentifier name,
130 NPVariant *result);
131
132 static bool setProperty(NPObject *npobj, NPIdentifier name,
133 const NPVariant *value);
134
135 static bool removeProperty(NPObject *npobj, NPIdentifier name);
136
137 static bool enumerate(NPObject *npobj, NPIdentifier **value,
138 uint32_t *count);
139
140 static bool construct(NPObject *npobj, const NPVariant *args,
141 uint32_t argCount, NPVariant *result);
142
143 static NPObject* get_scriptable_java_object(NPP instance,
144 std::string class_id,
145 std::string instance_id,
146 bool isArray);
147
148 static bool is_valid_java_object(NPObject* object_ptr);
149};
150
151class IcedTeaScriptableJavaObject: public NPObject
152{
153
154 private:
155 NPP instance;
156 bool isObjectArray;
157 std::string* class_id;
158 std::string* instance_id;
159
160 public:
161 IcedTeaScriptableJavaObject(NPP instance);
162
163 ~IcedTeaScriptableJavaObject();
164
165 void setClassIdentifier(std::string class_id);
166
167 void setInstanceIdentifier(std::string instance_id);
168
169 void setIsArray(bool isArray);
170
171 std::string getClassID() { return *class_id; }
172
173 std::string getInstanceID() { return *instance_id; }
174
175 NPP getInstance() { return instance; }
176
177 bool isArray() { return isObjectArray; }
178
179 static void deAllocate(NPObject *npobj);
180
181 static void invalidate(NPObject *npobj);
182
183 static bool hasMethod(NPObject *npobj, NPIdentifier name);
184
185 static bool invoke(NPObject *npobj, NPIdentifier name,
186 const NPVariant *args, uint32_t argCount, NPVariant *result);
187
188 static bool invokeDefault(NPObject *npobj, const NPVariant *args,
189 uint32_t argCount, NPVariant *result);
190
191 static bool hasProperty(NPObject *npobj, NPIdentifier name);
192
193 static bool getProperty(NPObject *npobj, NPIdentifier name,
194 NPVariant *result);
195
196 static bool setProperty(NPObject *npobj, NPIdentifier name,
197 const NPVariant *value);
198
199 static bool removeProperty(NPObject *npobj, NPIdentifier name);
200
201 static bool enumerate(NPObject *npobj, NPIdentifier **value,
202 uint32_t *count);
203
204 static bool construct(NPObject *npobj, const NPVariant *args,
205 uint32_t argCount, NPVariant *result);
206};
207
208/* Creates and retains a scriptable java object (intended to be called asynch.) */
209
210void _createAndRetainJavaObject(void* data);
211
212#endif /* __ICEDTEASCRIPTABLEPLUGINOBJECT_H_ */
Note: See TracBrowser for help on using the repository browser.