IPDL/Five minute example: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
(Created page with 'This page walks you through the steps of creating an IPDL protocol and writing the C++ code that implements the required interfaces. This guide walks you through the steps taken...')
 
No edit summary
Line 19: Line 19:
       TellValues(StringArray keys, StringArray vals);
       TellValues(StringArray keys, StringArray vals);
    
    
   state START
   state START:
       recv Ping goto START;
       recv Ping goto START;
       send Ping goto START;
       send Ping goto START;
Line 25: Line 25:
       recv SetValue goto HAVE_VALUES;
       recv SetValue goto HAVE_VALUES;
    
    
   state HAVE_VALUES
   state HAVE_VALUES:
       recv Ping goto HAVE_VALUES;
       recv Ping goto HAVE_VALUES;
       send Ping goto HAVE_VALUES;
       send Ping goto HAVE_VALUES;
Line 34: Line 34:
       recv GetValues goto TELLING_VALUES;
       recv GetValues goto TELLING_VALUES;
    
    
   state TELLING_VALUE
   state TELLING_VALUE:
       send TellValue goto HAVE_VALUES;
       send TellValue goto HAVE_VALUES;
   state TELLING_VALUES
   state TELLING_VALUES:
       send TellValues goto HAVE_VALUES;
       send TellValues goto HAVE_VALUES;
   };
   };
== Hook the IPDL file into our build system ==
* Add <code>ipc/ipdl/test-harness</code> to the IPDLDIRS variable in <code>ipc/ipdl/Makefile.in</code>
* Create the file <code>ipc/ipdl/test-harness/ipdl.mk</code> and add the following text to it.
  IPDLSRCS = \
    Test.ipdl \
    $(NULL)

Revision as of 17:22, 13 July 2009

This page walks you through the steps of creating an IPDL protocol and writing the C++ code that implements the required interfaces. This guide walks you through the steps taken to implement the testing code in ipc/ipdl/test-harness. You are encouraged to follow this guide step-by-step and change the code in ipc/ipdl/test-harness as you follow along.

Write the IPDL specification

Put this in the file ipc/ipdl/test-harness/Test.ipdl.

 sync protocol Test
 {
 both:
     sync Ping() returns (int status);
 
 parent:
     GetValue(String key);
     GetValues(StringArray keys);
     sync SetValue(String key, String val) returns (bool ok);
 
 child:
     TellValue(String key, String val);
     TellValues(StringArray keys, StringArray vals);
 
 state START:
     recv Ping goto START;
     send Ping goto START;
 
     recv SetValue goto HAVE_VALUES;
 
 state HAVE_VALUES:
     recv Ping goto HAVE_VALUES;
     send Ping goto HAVE_VALUES;
 
     recv SetValue goto HAVE_VALUES;
 
     recv GetValue goto TELLING_VALUE;
     recv GetValues goto TELLING_VALUES;
 
 state TELLING_VALUE:
     send TellValue goto HAVE_VALUES;
 state TELLING_VALUES:
     send TellValues goto HAVE_VALUES;
 };

Hook the IPDL file into our build system

  • Add ipc/ipdl/test-harness to the IPDLDIRS variable in ipc/ipdl/Makefile.in
  • Create the file ipc/ipdl/test-harness/ipdl.mk and add the following text to it.
 IPDLSRCS = \
   Test.ipdl \
   $(NULL)