Confirmed users
699
edits
m (→Basic messages) |
|||
| Line 290: | Line 290: | ||
// ----- file Plugin.ipdl | // ----- file Plugin.ipdl | ||
include protocol "PluginInstance.ipdl"; | '''include''' '''protocol''' "PluginInstance.ipdl"; | ||
sync protocol Plugin { | '''sync''' '''protocol''' Plugin { | ||
manages PluginInstance; | '''manages''' PluginInstance; | ||
child: | '''child''': | ||
sync Init() returns (int rv); | '''sync''' Init() '''returns''' (int rv); | ||
Deinit(); | Deinit(); | ||
sync PluginInstance(String type, StringArray args) returns (int rv); | '''sync''' PluginInstance(String type, StringArray args) '''returns''' (int rv); | ||
~PluginInstance(); | ~PluginInstance(); | ||
} | } | ||
| Line 313: | Line 313: | ||
//class PluginParent { ... | //class PluginParent { ... | ||
// NOTE: these two methods are basically the same for PluginParent and PluginChild | // NOTE: these two methods are basically the same for PluginParent and PluginChild | ||
virtual PluginInstanceParent* PluginInstanceConstructor( | '''virtual''' PluginInstanceParent* PluginInstanceConstructor( | ||
const String& type, | '''const''' String& type, | ||
const StringArray& args, int* rv) = 0; | '''const''' StringArray& args, | ||
virtual nsresult PluginInstanceDestructor(PluginInstanceParent* __a) = 0; | '''int'''* rv) = 0; | ||
'''virtual''' nsresult PluginInstanceDestructor(PluginInstanceParent* __a) = 0; | |||
// NOTE: PluginChild does not have "Recv*" analogues of these methods | // NOTE: PluginChild does not have "Recv*" analogues of these methods | ||
PluginInstanceParent* SendPluginInstanceConstructor( | PluginInstanceParent* SendPluginInstanceConstructor( | ||
const String& type, | '''const''' String& type, | ||
const StringArray& args, int* rv) | '''const''' StringArray& args, | ||
'''int'''* rv) | |||
{ /* boilerplate code */ } | { /* boilerplate code */ } | ||
nsresult SendPluginInstanceDestructor(PluginInstanceParent* __a) | nsresult SendPluginInstanceDestructor(PluginInstanceParent* __a) | ||
| Line 328: | Line 330: | ||
//class PluginChild {... | //class PluginChild {... | ||
// NOTE: these two methods are basically the same for PluginParent and PluginChild | // NOTE: these two methods are basically the same for PluginParent and PluginChild | ||
virtual PluginInstanceChild* PluginInstanceConstructor( | '''virtual''' PluginInstanceChild* PluginInstanceConstructor( | ||
const String& type, | '''const''' String& type, | ||
const StringArray& args, int* rv) = 0; | '''const''' StringArray& args, | ||
virtual nsresult PluginInstanceDestructor(PluginInstanceChild* __a) = 0; | '''int'''* rv) = 0; | ||
'''virtual''' nsresult PluginInstanceDestructor(PluginInstanceChild* __a) = 0; | |||
Let's break apart this example quickly. Both the PluginParent and PluginChild have to be able to allocate and deallocate raw PluginInstance's; IPDL requires your C++ code to do this by implementing the PluginInstanceConstructor/PluginInstanceDestructor interface. (Your code must do this, because IPDL has no idea what concrete classes you'll have implementing the PluginInstance abstract classes, and it's best that IPDL does not know this.) | Let's break apart this example quickly. Both the PluginParent and PluginChild have to be able to allocate and deallocate raw PluginInstance's; IPDL requires your C++ code to do this by implementing the PluginInstanceConstructor/PluginInstanceDestructor interface. (Your code must do this, because IPDL has no idea what concrete classes you'll have implementing the PluginInstance abstract classes, and it's best that IPDL does not know this.) | ||
| Line 340: | Line 343: | ||
// ----- file PluginInstance.ipdl | // ----- file PluginInstance.ipdl | ||
include "mozilla/plugins/PluginTypes.h" | '''include''' "mozilla/plugins/PluginTypes.h" | ||
using mozilla::plugins::PluginWindow; | '''using''' mozilla::plugins::PluginWindow; | ||
sync protocol PluginInstance { | '''sync''' '''protocol''' PluginInstance { | ||
manager Plugin; | '''manager''' Plugin; | ||
child: | '''child''': | ||
SetWindow(PluginWindow window); | SetWindow(PluginWindow window); | ||
Paint(); | Paint(); | ||
parent: | '''parent''': | ||
sync GetBrowserValue(String key) returns (String value); | '''sync''' GetBrowserValue(String key) '''returns''' (String value); | ||
}; | }; | ||