IPDL/Getting started: Difference between revisions

Line 166: Line 166:
=== Parameters ===
=== Parameters ===


Message declarations allow any number of ''parameters'', which are data serialized by the sender and deserialized by the receiver.  The following snippet of IPDL and generated code shows how parameters can be used in message declarations
Message declarations allow any number of ''parameters'', which are data serialized by the sender and deserialized by the receiver.  The following snippet of IPDL and generated code shows how parameters can be used in message declarations.


   // protocol Blah { ...
   // protocol Blah { ...
     out Foo(int parameter);
  child:
     Foo(int parameter);
    
    
   // class BlahProtocolParent { ...
   // class BlahProtocolParent { ...
Line 177: Line 178:
     virtual void RecvFoo(const int& paramter) = 0;
     virtual void RecvFoo(const int& paramter) = 0;


The IPDL compiler has a set of "builtin" types for which library code exists to serialize and deserialize parameters of that type.  These builtin types include the C/C++ integer types (char, int, ..., int8_t, uint16_t, ...), a string type (<code>String</code> in IPDL), and some array types (<code>StringArray</code>, for example).  These builtin types are in flux and will certainly be expanded.  The most up-to-date reference for builtins is the file <code>ipc/glue/MessageTypes.h</code>.
The IPDL compiler has a set of "builtin" types for which library code exists to serialize and deserialize parameters of that type.  These builtin types include the C/C++ integer types (bool, char, int, ..., int8_t, uint16_t, ...), a string type (<code>String</code> in IPDL), and some array types (<code>StringArray</code>, for example).  These builtin types are in flux and will certainly be expanded.  The most up-to-date reference for builtins is the file <code>ipc/glue/MessageTypes.h</code>.


The builtin types are insufficient for all protocols.  When you need to send data of type other than one built into IPDL, you can "import" the type into an IPDL specification, and in C++ define your own data serializer and deserializer.  This is beyond the scope of this document at the moment; see <code>dom/plugins/NPAPI.ipdl</code> and <code>dom/plugins/PluginMessageUtils.h</code> for examples of how this can be done.
The builtin types are insufficient for all protocols.  When you need to send data of type other than one built into IPDL, you can add a <code>'''using'''</code> declaration of the type in an IPDL specification, and in C++ define your own data serializer and deserializer.  The details of this are beyond the scope of this document; see <code>dom/plugins/NPAPI.ipdl</code> and <code>dom/plugins/PluginMessageUtils.h</code> for examples of how this is done.


=== Semantics ===
=== Semantics ===
Confirmed users
699

edits