|
1 The NPObject contains following important methods: |
|
2 -------------------------------------------------- |
|
3 |
|
4 /** |
|
5 * Creates object for NP plugin npp of NPClass aClass. |
|
6 */ |
|
7 NPObject* NPN_CreateObject(NPP npp, NPClass* class); |
|
8 |
|
9 /** |
|
10 * Increases reference count for object |
|
11 */ |
|
12 NPObject* NPN_RetainObject(NPObject* object); |
|
13 |
|
14 /** |
|
15 * Decreases reference count for object |
|
16 */ |
|
17 NPObject* NPN_RetainObject(NPObject* object); |
|
18 |
|
19 /** |
|
20 * Calls object method |
|
21 */ |
|
22 ... NPN_Invoke(...); |
|
23 |
|
24 |
|
25 NOTE: |
|
26 ----- |
|
27 |
|
28 - In the plugin architecture, objects have two forms |
|
29 - The NP 'wrapped' form of NPObject or e.g. CCPixNPSearcherObject |
|
30 - And the nonwrapped form e.g. CCPixNPSearcher or MCPixNPSearcher |
|
31 - Only the former form can be memory managed (Reference count set up and down) |
|
32 - This means that if object wishes to maintain references to an NP object, |
|
33 it needs to have access to the wrapped form. |
|
34 - Wrapped form vs. Nonwrapped form |
|
35 - Wrapped form is more powerful, holding pointer also to the NP side handle |
|
36 - Nonwrapped form is easier for the programmer |
|
37 -> Still - to avoid refactoring - wrapped form should always be used |
|
38 |
|
39 Open questions: |
|
40 --------------- |
|
41 |
|
42 - How to handle const safety with wrapper objects? |
|
43 |
|
44 Nontrivial things: |
|
45 ------------------ |
|
46 |
|
47 - Should the /inc/idc/* interfaces contain refernces to NPVariants |
|
48 - At least the example code contains |
|
49 - More difficult for the programmer |
|
50 - Who should create NP wrapping around objects? Interface or implementation class? |
|
51 E.g. Should CCPixNPPlugin or CCPixNPPluginInterface wrap searcher into |
|
52 CPixNPSearcherObject form |
|
53 - In CCPixNPPlugin case - it doesn't really matter. Ownership is given away in any |
|
54 case and the reference counting functionality is not needed in either side. |
|
55 - Generally the implementing class should hold responsibility |
|
56 - E.g. If CNPSearchDocument wishes to hold ownership to its fields it needs |
|
57 to be able to add references to the fields it creates. |
|
58 - Observers |