]> git.saurik.com Git - wxWidgets.git/blob - utils/nplugin/src/npupp.h
some changes to make wxHtmlHelpController easier to subclass
[wxWidgets.git] / utils / nplugin / src / npupp.h
1 /*
2 * npupp.h $Revision$
3 * function call mecahnics needed by platform specific glue code.
4 */
5
6
7 #ifndef _NPUPP_H_
8 #define _NPUPP_H_
9
10 #ifndef GENERATINGCFM
11 #define GENERATINGCFM 0
12 #endif
13
14 #ifndef _NPAPI_H_
15 #include "npapi.h"
16 #endif
17
18 /******************************************************************************************
19 plug-in function table macros
20 for each function in and out of the plugin API we define
21 typedef NPP_FooUPP
22 #define NewNPP_FooProc
23 #define CallNPP_FooProc
24 for mac, define the UPP magic for PPC/68K calling
25 *******************************************************************************************/
26
27
28 /* NPP_Initialize */
29
30 #if GENERATINGCFM
31 typedef UniversalProcPtr NPP_InitializeUPP;
32
33 enum {
34 uppNPP_InitializeProcInfo = kThinkCStackBased
35 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(0))
36 | RESULT_SIZE(SIZE_CODE(0))
37 };
38
39 #define NewNPP_InitializeProc(FUNC) \
40 (NPP_InitializeUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPP_InitializeProcInfo, GetCurrentArchitecture())
41 #define CallNPP_InitializeProc(FUNC) \
42 (void)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPP_InitializeProcInfo)
43
44 #else
45
46 typedef void (*NPP_InitializeUPP)(void);
47 #define NewNPP_InitializeProc(FUNC) \
48 ((NPP_InitializeUPP) (FUNC))
49 #define CallNPP_InitializeProc(FUNC) \
50 (*(FUNC))()
51
52 #endif
53
54
55 /* NPP_Shutdown */
56
57 #if GENERATINGCFM
58 typedef UniversalProcPtr NPP_ShutdownUPP;
59
60 enum {
61 uppNPP_ShutdownProcInfo = kThinkCStackBased
62 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(0))
63 | RESULT_SIZE(SIZE_CODE(0))
64 };
65
66 #define NewNPP_ShutdownProc(FUNC) \
67 (NPP_ShutdownUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPP_ShutdownProcInfo, GetCurrentArchitecture())
68 #define CallNPP_ShutdownProc(FUNC) \
69 (void)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPP_ShutdownProcInfo)
70
71 #else
72
73 typedef void (*NPP_ShutdownUPP)(void);
74 #define NewNPP_ShutdownProc(FUNC) \
75 ((NPP_ShutdownUPP) (FUNC))
76 #define CallNPP_ShutdownProc(FUNC) \
77 (*(FUNC))()
78
79 #endif
80
81
82 /* NPP_New */
83
84 #if GENERATINGCFM
85 typedef UniversalProcPtr NPP_NewUPP;
86
87 enum {
88 uppNPP_NewProcInfo = kThinkCStackBased
89 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(NPMIMEType)))
90 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(NPP)))
91 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(uint16)))
92 | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(int16)))
93 | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(char **)))
94 | STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(char **)))
95 | STACK_ROUTINE_PARAMETER(7, SIZE_CODE(sizeof(NPSavedData *)))
96 | RESULT_SIZE(SIZE_CODE(sizeof(NPError)))
97 };
98
99 #define NewNPP_NewProc(FUNC) \
100 (NPP_NewUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPP_NewProcInfo, GetCurrentArchitecture())
101 #define CallNPP_NewProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7) \
102 (NPError)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPP_NewProcInfo, \
103 (ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6), (ARG7))
104 #else
105
106 typedef NPError (*NPP_NewUPP)(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved);
107 #define NewNPP_NewProc(FUNC) \
108 ((NPP_NewUPP) (FUNC))
109 #define CallNPP_NewProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7) \
110 (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6), (ARG7))
111
112 #endif
113
114
115 /* NPP_Destroy */
116
117 #if GENERATINGCFM
118
119 typedef UniversalProcPtr NPP_DestroyUPP;
120 enum {
121 uppNPP_DestroyProcInfo = kThinkCStackBased
122 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(NPP)))
123 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(NPSavedData **)))
124 | RESULT_SIZE(SIZE_CODE(sizeof(NPError)))
125 };
126 #define NewNPP_DestroyProc(FUNC) \
127 (NPP_DestroyUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPP_DestroyProcInfo, GetCurrentArchitecture())
128 #define CallNPP_DestroyProc(FUNC, ARG1, ARG2) \
129 (NPError)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPP_DestroyProcInfo, (ARG1), (ARG2))
130 #else
131
132 typedef NPError (*NPP_DestroyUPP)(NPP instance, NPSavedData** save);
133 #define NewNPP_DestroyProc(FUNC) \
134 ((NPP_DestroyUPP) (FUNC))
135 #define CallNPP_DestroyProc(FUNC, ARG1, ARG2) \
136 (*(FUNC))((ARG1), (ARG2))
137
138 #endif
139
140
141 /* NPP_SetWindow */
142
143 #if GENERATINGCFM
144
145 typedef UniversalProcPtr NPP_SetWindowUPP;
146 enum {
147 uppNPP_SetWindowProcInfo = kThinkCStackBased
148 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(NPP)))
149 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(NPWindow *)))
150 | RESULT_SIZE(SIZE_CODE(sizeof(NPError)))
151 };
152 #define NewNPP_SetWindowProc(FUNC) \
153 (NPP_SetWindowUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPP_SetWindowProcInfo, GetCurrentArchitecture())
154 #define CallNPP_SetWindowProc(FUNC, ARG1, ARG2) \
155 (NPError)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPP_SetWindowProcInfo, (ARG1), (ARG2))
156
157 #else
158
159 typedef NPError (*NPP_SetWindowUPP)(NPP instance, NPWindow* window);
160 #define NewNPP_SetWindowProc(FUNC) \
161 ((NPP_SetWindowUPP) (FUNC))
162 #define CallNPP_SetWindowProc(FUNC, ARG1, ARG2) \
163 (*(FUNC))((ARG1), (ARG2))
164
165 #endif
166
167
168 /* NPP_NewStream */
169
170 #if GENERATINGCFM
171
172 typedef UniversalProcPtr NPP_NewStreamUPP;
173 enum {
174 uppNPP_NewStreamProcInfo = kThinkCStackBased
175 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(NPP)))
176 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(NPMIMEType)))
177 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(NPStream *)))
178 | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(NPBool)))
179 | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(uint16 *)))
180 | RESULT_SIZE(SIZE_CODE(sizeof(NPError)))
181 };
182 #define NewNPP_NewStreamProc(FUNC) \
183 (NPP_NewStreamUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPP_NewStreamProcInfo, GetCurrentArchitecture())
184 #define CallNPP_NewStreamProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5) \
185 (NPError)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPP_NewStreamProcInfo, (ARG1), (ARG2), (ARG3), (ARG4), (ARG5))
186 #else
187
188 typedef NPError (*NPP_NewStreamUPP)(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype);
189 #define NewNPP_NewStreamProc(FUNC) \
190 ((NPP_NewStreamUPP) (FUNC))
191 #define CallNPP_NewStreamProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5) \
192 (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5))
193 #endif
194
195
196 /* NPP_DestroyStream */
197
198 #if GENERATINGCFM
199
200 typedef UniversalProcPtr NPP_DestroyStreamUPP;
201 enum {
202 uppNPP_DestroyStreamProcInfo = kThinkCStackBased
203 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(NPP)))
204 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(NPStream *)))
205 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(NPError)))
206 | RESULT_SIZE(SIZE_CODE(sizeof(NPError)))
207 };
208 #define NewNPP_DestroyStreamProc(FUNC) \
209 (NPP_DestroyStreamUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPP_DestroyStreamProcInfo, GetCurrentArchitecture())
210 #define CallNPP_DestroyStreamProc(FUNC, NPParg, NPStreamPtr, NPErrorArg) \
211 (NPError)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPP_DestroyStreamProcInfo, (NPParg), (NPStreamPtr), (NPErrorArg))
212
213 #else
214
215 typedef NPError (*NPP_DestroyStreamUPP)(NPP instance, NPStream* stream, NPError reason);
216 #define NewNPP_DestroyStreamProc(FUNC) \
217 ((NPP_DestroyStreamUPP) (FUNC))
218 #define CallNPP_DestroyStreamProc(FUNC, NPParg, NPStreamPtr, NPErrorArg) \
219 (*(FUNC))((NPParg), (NPStreamPtr), (NPErrorArg))
220
221 #endif
222
223
224 /* NPP_WriteReady */
225
226 #if GENERATINGCFM
227
228 typedef UniversalProcPtr NPP_WriteReadyUPP;
229 enum {
230 uppNPP_WriteReadyProcInfo = kThinkCStackBased
231 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(NPP)))
232 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(NPStream *)))
233 | RESULT_SIZE(SIZE_CODE(sizeof(int32)))
234 };
235 #define NewNPP_WriteReadyProc(FUNC) \
236 (NPP_WriteReadyUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPP_WriteReadyProcInfo, GetCurrentArchitecture())
237 #define CallNPP_WriteReadyProc(FUNC, NPParg, NPStreamPtr) \
238 (int32)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPP_WriteReadyProcInfo, (NPParg), (NPStreamPtr))
239
240 #else
241
242 typedef int32 (*NPP_WriteReadyUPP)(NPP instance, NPStream* stream);
243 #define NewNPP_WriteReadyProc(FUNC) \
244 ((NPP_WriteReadyUPP) (FUNC))
245 #define CallNPP_WriteReadyProc(FUNC, NPParg, NPStreamPtr) \
246 (*(FUNC))((NPParg), (NPStreamPtr))
247
248 #endif
249
250
251 /* NPP_Write */
252
253 #if GENERATINGCFM
254
255 typedef UniversalProcPtr NPP_WriteUPP;
256 enum {
257 uppNPP_WriteProcInfo = kThinkCStackBased
258 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(NPP)))
259 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(NPStream *)))
260 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(int32)))
261 | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(int32)))
262 | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(void*)))
263 | RESULT_SIZE(SIZE_CODE(sizeof(int32)))
264 };
265 #define NewNPP_WriteProc(FUNC) \
266 (NPP_WriteUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPP_WriteProcInfo, GetCurrentArchitecture())
267 #define CallNPP_WriteProc(FUNC, NPParg, NPStreamPtr, offsetArg, lenArg, bufferPtr) \
268 (int32)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPP_WriteProcInfo, (NPParg), (NPStreamPtr), (offsetArg), (lenArg), (bufferPtr))
269
270 #else
271
272 typedef int32 (*NPP_WriteUPP)(NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer);
273 #define NewNPP_WriteProc(FUNC) \
274 ((NPP_WriteUPP) (FUNC))
275 #define CallNPP_WriteProc(FUNC, NPParg, NPStreamPtr, offsetArg, lenArg, bufferPtr) \
276 (*(FUNC))((NPParg), (NPStreamPtr), (offsetArg), (lenArg), (bufferPtr))
277
278 #endif
279
280
281 /* NPP_StreamAsFile */
282
283 #if GENERATINGCFM
284
285 typedef UniversalProcPtr NPP_StreamAsFileUPP;
286 enum {
287 uppNPP_StreamAsFileProcInfo = kThinkCStackBased
288 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(NPP)))
289 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(NPStream *)))
290 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(const char *)))
291 | RESULT_SIZE(SIZE_CODE(0))
292 };
293 #define NewNPP_StreamAsFileProc(FUNC) \
294 (NPP_StreamAsFileUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPP_StreamAsFileProcInfo, GetCurrentArchitecture())
295 #define CallNPP_StreamAsFileProc(FUNC, ARG1, ARG2, ARG3) \
296 (void)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPP_StreamAsFileProcInfo, (ARG1), (ARG2), (ARG3))
297
298 #else
299
300 typedef void (*NPP_StreamAsFileUPP)(NPP instance, NPStream* stream, const char* fname);
301 #define NewNPP_StreamAsFileProc(FUNC) \
302 ((NPP_StreamAsFileUPP) (FUNC))
303 #define CallNPP_StreamAsFileProc(FUNC, ARG1, ARG2, ARG3) \
304 (*(FUNC))((ARG1), (ARG2), (ARG3))
305 #endif
306
307
308 /* NPP_Print */
309
310 #if GENERATINGCFM
311
312 typedef UniversalProcPtr NPP_PrintUPP;
313 enum {
314 uppNPP_PrintProcInfo = kThinkCStackBased
315 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(NPP)))
316 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(NPPrint *)))
317 | RESULT_SIZE(SIZE_CODE(0))
318 };
319 #define NewNPP_PrintProc(FUNC) \
320 (NPP_PrintUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPP_PrintProcInfo, GetCurrentArchitecture())
321 #define CallNPP_PrintProc(FUNC, NPParg, voidPtr) \
322 (void)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPP_PrintProcInfo, (NPParg), (voidPtr))
323
324 #else
325
326 typedef void (*NPP_PrintUPP)(NPP instance, NPPrint* platformPrint);
327 #define NewNPP_PrintProc(FUNC) \
328 ((NPP_PrintUPP) (FUNC))
329 #define CallNPP_PrintProc(FUNC, NPParg, NPPrintArg) \
330 (*(FUNC))((NPParg), (NPPrintArg))
331
332 #endif
333
334
335 /* NPP_HandleEvent */
336
337 #if GENERATINGCFM
338
339 typedef UniversalProcPtr NPP_HandleEventUPP;
340 enum {
341 uppNPP_HandleEventProcInfo = kThinkCStackBased
342 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(NPP)))
343 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(void *)))
344 | RESULT_SIZE(SIZE_CODE(sizeof(int16)))
345 };
346 #define NewNPP_HandleEventProc(FUNC) \
347 (NPP_HandleEventUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPP_HandleEventProcInfo, GetCurrentArchitecture())
348 #define CallNPP_HandleEventProc(FUNC, NPParg, voidPtr) \
349 (int16)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPP_HandleEventProcInfo, (NPParg), (voidPtr))
350
351 #else
352
353 typedef int16 (*NPP_HandleEventUPP)(NPP instance, void* event);
354 #define NewNPP_HandleEventProc(FUNC) \
355 ((NPP_HandleEventUPP) (FUNC))
356 #define CallNPP_HandleEventProc(FUNC, NPParg, voidPtr) \
357 (*(FUNC))((NPParg), (voidPtr))
358
359 #endif
360
361
362
363
364 /*
365 * Netscape entry points
366 */
367
368
369 /* NPN_GetUrl */
370
371 #if GENERATINGCFM
372
373 typedef UniversalProcPtr NPN_GetURLUPP;
374 enum {
375 uppNPN_GetURLProcInfo = kThinkCStackBased
376 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(NPP)))
377 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(const char*)))
378 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(const char*)))
379 | RESULT_SIZE(SIZE_CODE(sizeof(NPError)))
380 };
381 #define NewNPN_GetURLProc(FUNC) \
382 (NPN_GetURLUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPN_GetURLProcInfo, GetCurrentArchitecture())
383 #define CallNPN_GetURLProc(FUNC, ARG1, ARG2, ARG3) \
384 (NPError)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPN_GetURLProcInfo, (ARG1), (ARG2), (ARG3))
385 #else
386
387 typedef NPError (*NPN_GetURLUPP)(NPP instance, const char* url, const char* window);
388 #define NewNPN_GetURLProc(FUNC) \
389 ((NPN_GetURLUPP) (FUNC))
390 #define CallNPN_GetURLProc(FUNC, ARG1, ARG2, ARG3) \
391 (*(FUNC))((ARG1), (ARG2), (ARG3))
392 #endif
393
394
395 /* NPN_PostUrl */
396
397 #if GENERATINGCFM
398
399 typedef UniversalProcPtr NPN_PostURLUPP;
400 enum {
401 uppNPN_PostURLProcInfo = kThinkCStackBased
402 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(NPP)))
403 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(const char*)))
404 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(const char*)))
405 | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(uint32)))
406 | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(const char*)))
407 | STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(NPBool)))
408 | RESULT_SIZE(SIZE_CODE(sizeof(NPError)))
409 };
410 #define NewNPN_PostURLProc(FUNC) \
411 (NPN_PostURLUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPN_PostURLProcInfo, GetCurrentArchitecture())
412 #define CallNPN_PostURLProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6) \
413 (NPError)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPN_PostURLProcInfo, (ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6))
414 #else
415
416 typedef NPError (*NPN_PostURLUPP)(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file);
417 #define NewNPN_PostURLProc(FUNC) \
418 ((NPN_PostURLUPP) (FUNC))
419 #define CallNPN_PostURLProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6) \
420 (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6))
421 #endif
422
423
424 /* NPN_RequestRead */
425
426 #if GENERATINGCFM
427
428 typedef UniversalProcPtr NPN_RequestReadUPP;
429 enum {
430 uppNPN_RequestReadProcInfo = kThinkCStackBased
431 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(NPStream *)))
432 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(NPByteRange *)))
433 | RESULT_SIZE(SIZE_CODE(sizeof(NPError)))
434 };
435 #define NewNPN_RequestReadProc(FUNC) \
436 (NPN_RequestReadUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPN_RequestReadProcInfo, GetCurrentArchitecture())
437 #define CallNPN_RequestReadProc(FUNC, stream, range) \
438 (NPError)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPN_RequestReadProcInfo, (stream), (range))
439
440 #else
441
442 typedef NPError (*NPN_RequestReadUPP)(NPStream* stream, NPByteRange* rangeList);
443 #define NewNPN_RequestReadProc(FUNC) \
444 ((NPN_RequestReadUPP) (FUNC))
445 #define CallNPN_RequestReadProc(FUNC, stream, range) \
446 (*(FUNC))((stream), (range))
447
448 #endif
449
450
451 /* NPN_NewStream */
452
453 #if GENERATINGCFM
454
455 typedef UniversalProcPtr NPN_NewStreamUPP;
456 enum {
457 uppNPN_NewStreamProcInfo = kThinkCStackBased
458 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(NPP )))
459 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(NPMIMEType)))
460 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(NPStream *)))
461 | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(NPBool)))
462 | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(uint16*)))
463 | RESULT_SIZE(SIZE_CODE(sizeof(NPError)))
464 };
465 #define NewNPN_NewStreamProc(FUNC) \
466 (NPN_NewStreamUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPN_NewStreamProcInfo, GetCurrentArchitecture())
467 #define CallNPN_NewStreamProc(FUNC, npp, type, stream) \
468 (NPError)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPN_NewStreamProcInfo, (npp), (type), (stream))
469
470 #else
471
472 typedef NPError (*NPN_NewStreamUPP)(NPP instance, NPMIMEType type, NPStream* stream);
473 #define NewNPN_NewStreamProc(FUNC) \
474 ((NPN_NewStreamUPP) (FUNC))
475 #define CallNPN_NewStreamProc(FUNC, npp, type, stream) \
476 (*(FUNC))((npp), (type), (stream))
477
478 #endif
479
480
481 /* NPN_Write */
482
483 #if GENERATINGCFM
484
485 typedef UniversalProcPtr NPN_WriteUPP;
486 enum {
487 uppNPN_WriteProcInfo = kThinkCStackBased
488 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(NPP )))
489 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(NPStream *)))
490 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(int32)))
491 | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(void*)))
492 | RESULT_SIZE(SIZE_CODE(sizeof(int32)))
493 };
494 #define NewNPN_WriteProc(FUNC) \
495 (NPN_WriteUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPN_WriteProcInfo, GetCurrentArchitecture())
496 #define CallNPN_WriteProc(FUNC, npp, stream, len, buffer) \
497 (int32)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPN_WriteProcInfo, (npp), (stream), (len), (buffer))
498
499 #else
500
501 typedef int32 (*NPN_WriteUPP)(NPP instance, NPStream* stream, int32 len, void* buffer);
502 #define NewNPN_WriteProc(FUNC) \
503 ((NPN_WriteUPP) (FUNC))
504 #define CallNPN_WriteProc(FUNC, npp, stream, len, buffer) \
505 (*(FUNC))((npp), (stream), (len), (buffer))
506
507 #endif
508
509
510 /* NPN_DestroyStream */
511
512 #if GENERATINGCFM
513
514 typedef UniversalProcPtr NPN_DestroyStreamUPP;
515 enum {
516 uppNPN_DestroyStreamProcInfo = kThinkCStackBased
517 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(NPP )))
518 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(NPStream *)))
519 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(NPError)))
520 | RESULT_SIZE(SIZE_CODE(sizeof(NPError)))
521 };
522 #define NewNPN_DestroyStreamProc(FUNC) \
523 (NPN_DestroyStreamUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPN_DestroyStreamProcInfo, GetCurrentArchitecture())
524 #define CallNPN_DestroyStreamProc(FUNC, npp, stream, err) \
525 (NPError)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPN_DestroyStreamProcInfo, (npp), (stream), (err))
526
527 #else
528
529 typedef NPError (*NPN_DestroyStreamUPP)(NPP instance, NPStream* stream, NPError reason);
530 #define NewNPN_DestroyStreamProc(FUNC) \
531 ((NPN_DestroyStreamUPP) (FUNC))
532 #define CallNPN_DestroyStreamProc(FUNC, npp, stream, err) \
533 (*(FUNC))((npp), (stream), (err))
534
535 #endif
536
537
538 /* NPN_Status */
539
540 #if GENERATINGCFM
541
542 typedef UniversalProcPtr NPN_StatusUPP;
543 enum {
544 uppNPN_StatusProcInfo = kThinkCStackBased
545 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(NPP)))
546 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(char *)))
547 };
548
549 #define NewNPN_StatusProc(FUNC) \
550 (NPN_StatusUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPN_StatusProcInfo, GetCurrentArchitecture())
551 #define CallNPN_StatusProc(FUNC, npp, msg) \
552 (void)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPN_StatusProcInfo, (npp), (msg))
553
554 #else
555
556 typedef void (*NPN_StatusUPP)(NPP instance, const char* message);
557 #define NewNPN_StatusProc(FUNC) \
558 ((NPN_StatusUPP) (FUNC))
559 #define CallNPN_StatusProc(FUNC, npp, msg) \
560 (*(FUNC))((npp), (msg))
561
562 #endif
563
564
565 /* NPN_UserAgent */
566 #if GENERATINGCFM
567
568 typedef UniversalProcPtr NPN_UserAgentUPP;
569 enum {
570 uppNPN_UserAgentProcInfo = kThinkCStackBased
571 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(NPP)))
572 | RESULT_SIZE(SIZE_CODE(sizeof(const char *)))
573 };
574
575 #define NewNPN_UserAgentProc(FUNC) \
576 (NPN_UserAgentUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPN_UserAgentProcInfo, GetCurrentArchitecture())
577 #define CallNPN_UserAgentProc(FUNC, ARG1) \
578 (const char*)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPN_UserAgentProcInfo, (ARG1))
579
580 #else
581
582 typedef const char* (*NPN_UserAgentUPP)(NPP instance);
583 #define NewNPN_UserAgentProc(FUNC) \
584 ((NPN_UserAgentUPP) (FUNC))
585 #define CallNPN_UserAgentProc(FUNC, ARG1) \
586 (*(FUNC))((ARG1))
587
588 #endif
589
590
591 /* NPN_MemAlloc */
592 #if GENERATINGCFM
593
594 typedef UniversalProcPtr NPN_MemAllocUPP;
595 enum {
596 uppNPN_MemAllocProcInfo = kThinkCStackBased
597 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(uint32)))
598 | RESULT_SIZE(SIZE_CODE(sizeof(void *)))
599 };
600
601 #define NewNPN_MemAllocProc(FUNC) \
602 (NPN_MemAllocUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPN_MemAllocProcInfo, GetCurrentArchitecture())
603 #define CallNPN_MemAllocProc(FUNC, ARG1) \
604 (void*)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPN_MemAllocProcInfo, (ARG1))
605
606 #else
607
608 typedef void* (*NPN_MemAllocUPP)(uint32 size);
609 #define NewNPN_MemAllocProc(FUNC) \
610 ((NPN_MemAllocUPP) (FUNC))
611 #define CallNPN_MemAllocProc(FUNC, ARG1) \
612 (*(FUNC))((ARG1))
613
614 #endif
615
616
617 /* NPN__MemFree */
618
619 #if GENERATINGCFM
620
621 typedef UniversalProcPtr NPN_MemFreeUPP;
622 enum {
623 uppNPN_MemFreeProcInfo = kThinkCStackBased
624 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(void *)))
625 };
626
627 #define NewNPN_MemFreeProc(FUNC) \
628 (NPN_MemFreeUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPN_MemFreeProcInfo, GetCurrentArchitecture())
629 #define CallNPN_MemFreeProc(FUNC, ARG1) \
630 (void)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPN_MemFreeProcInfo, (ARG1))
631
632 #else
633
634 typedef void (*NPN_MemFreeUPP)(void* ptr);
635 #define NewNPN_MemFreeProc(FUNC) \
636 ((NPN_MemFreeUPP) (FUNC))
637 #define CallNPN_MemFreeProc(FUNC, ARG1) \
638 (*(FUNC))((ARG1))
639
640 #endif
641
642
643 /* NPN_MemFlush */
644
645 #if GENERATINGCFM
646
647 typedef UniversalProcPtr NPN_MemFlushUPP;
648 enum {
649 uppNPN_MemFlushProcInfo = kThinkCStackBased
650 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(uint32)))
651 | RESULT_SIZE(SIZE_CODE(sizeof(uint32)))
652 };
653
654 #define NewNPN_MemFlushProc(FUNC) \
655 (NPN_MemFlushUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPN_MemFlushProcInfo, GetCurrentArchitecture())
656 #define CallNPN_MemFlushProc(FUNC, ARG1) \
657 (uint32)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPN_MemFlushProcInfo, (ARG1))
658
659 #else
660
661 typedef uint32 (*NPN_MemFlushUPP)(uint32 size);
662 #define NewNPN_MemFlushProc(FUNC) \
663 ((NPN_MemFlushUPP) (FUNC))
664 #define CallNPN_MemFlushProc(FUNC, ARG1) \
665 (*(FUNC))((ARG1))
666
667 #endif
668
669
670
671 /* NPN_ReloadPlugins */
672
673 #if GENERATINGCFM
674
675 typedef UniversalProcPtr NPN_ReloadPluginsUPP;
676 enum {
677 uppNPN_ReloadPluginsProcInfo = kThinkCStackBased
678 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(NPBool)))
679 | RESULT_SIZE(SIZE_CODE(0))
680 };
681
682 #define NewNPN_ReloadPluginsProc(FUNC) \
683 (NPN_ReloadPluginsUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPN_ReloadPluginsProcInfo, GetCurrentArchitecture())
684 #define CallNPN_ReloadPluginsProc(FUNC, ARG1) \
685 (void)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPN_ReloadPluginsProcInfo, (ARG1))
686
687 #else
688
689 typedef void (*NPN_ReloadPluginsUPP)(NPBool reloadPages);
690 #define NewNPN_ReloadPluginsProc(FUNC) \
691 ((NPN_ReloadPluginsUPP) (FUNC))
692 #define CallNPN_ReloadPluginsProc(FUNC, ARG1) \
693 (*(FUNC))((ARG1))
694
695 #endif
696
697
698
699
700 /******************************************************************************************
701 * The actual plugin function table definitions
702 *******************************************************************************************/
703
704 typedef struct _NPPluginFuncs {
705 uint16 size;
706 uint16 version;
707 NPP_NewUPP newp;
708 NPP_DestroyUPP destroy;
709 NPP_SetWindowUPP setwindow;
710 NPP_NewStreamUPP newstream;
711 NPP_DestroyStreamUPP destroystream;
712 NPP_StreamAsFileUPP asfile;
713 NPP_WriteReadyUPP writeready;
714 NPP_WriteUPP write;
715 NPP_PrintUPP print;
716 NPP_HandleEventUPP event;
717 } NPPluginFuncs;
718
719 typedef struct _NPNetscapeFuncs {
720 uint16 size;
721 uint16 version;
722 NPN_GetURLUPP geturl;
723 NPN_PostURLUPP posturl;
724 NPN_RequestReadUPP requestread;
725 NPN_NewStreamUPP newstream;
726 NPN_WriteUPP write;
727 NPN_DestroyStreamUPP destroystream;
728 NPN_StatusUPP status;
729 NPN_UserAgentUPP uagent;
730 NPN_MemAllocUPP memalloc;
731 NPN_MemFreeUPP memfree;
732 NPN_MemFlushUPP memflush;
733 NPN_ReloadPluginsUPP reloadplugins;
734 } NPNetscapeFuncs;
735
736
737
738 #ifdef XP_MAC
739 /******************************************************************************************
740 * Mac platform-specific plugin glue stuff
741 *******************************************************************************************/
742
743 /*
744 * Main entry point of the plugin.
745 * This routine will be called when the plugin is loaded. The function
746 * tables are passed in and the plugin fills in the NPPluginFuncs table
747 * and NPPShutdownUPP for Netscape's use.
748 */
749
750 #if GENERATINGCFM
751
752 typedef UniversalProcPtr NPP_MainEntryUPP;
753 enum {
754 uppNPP_MainEntryProcInfo = kThinkCStackBased
755 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(NPNetscapeFuncs*)))
756 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(NPPluginFuncs*)))
757 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(NPP_ShutdownUPP*)))
758 | RESULT_SIZE(SIZE_CODE(sizeof(NPError)))
759 };
760 #define NewNPP_MainEntryProc(FUNC) \
761 (NPP_MainEntryUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPP_MainEntryProcInfo, GetCurrentArchitecture())
762 #define CallNPP_MainEntryProc(FUNC, netscapeFunc, pluginFunc, shutdownUPP) \
763 CallUniversalProc((UniversalProcPtr)(FUNC), (ProcInfoType)uppNPP_MainEntryProcInfo, (netscapeFunc), (pluginFunc), (shutdownUPP))
764
765 #else
766
767 typedef NPError (*NPP_MainEntryUPP)(NPNetscapeFuncs*, NPPluginFuncs*, NPP_ShutdownUPP*);
768 #define NewNPP_MainEntryProc(FUNC) \
769 ((NPP_MainEntryUPP) (FUNC))
770 #define CallNPP_MainEntryProc(FUNC, netscapeFunc, pluginFunc, shutdownUPP) \
771 (*(FUNC))((netscapeFunc), (pluginFunc), (shutdownUPP))
772
773 #endif
774 #endif /* MAC */
775
776
777 #ifdef _WINDOWS
778
779 #ifdef __cplusplus
780 extern "C" {
781 #endif
782
783 /* plugin meta member functions */
784
785 NPError WINAPI NP_GetEntryPoints(NPPluginFuncs* pFuncs);
786
787 NPError WINAPI NP_Initialize(NPNetscapeFuncs* pFuncs);
788
789 NPError WINAPI NP_Shutdown();
790
791 #ifdef __cplusplus
792 }
793 #endif
794
795 #endif /* _WINDOWS */
796
797
798 #endif /* _NPUPP_H_ */
799