IPDL/Getting started: Difference between revisions

m
Line 371: Line 371:
The following example shows one such state machine for the Plugin protocol.
The following example shows one such state machine for the Plugin protocol.


  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();
   
   
  // NOTE: state machine follows
  // NOTE: state machine follows
  state START:
  '''state''' START:
   send Init goto IDLE;
   '''send''' Init '''goto''' IDLE;
   
   
  state IDLE:
  '''state''' IDLE:
   send PluginInstance goto ACTIVE;
   '''send''' PluginInstance '''goto''' ACTIVE;
   
   
  state ACTIVE:
  '''state''' ACTIVE:
   send PluginInstance goto ACTIVE;
   '''send''' PluginInstance '''goto''' ACTIVE;
   send ~PluginInstance goto ACTIVE;
   '''send''' ~PluginInstance '''goto''' ACTIVE;
   send Deinit goto DYING;
   '''send''' Deinit '''goto''' DYING;
   
   
  state DYING:
  '''state''' DYING:
   send ~PluginInstance goto DYING;
   '''send''' ~PluginInstance '''goto''' DYING;
  };
  };


Line 409: Line 409:
Another example state machine, for PluginInstance, follows.
Another example state machine, for PluginInstance, follows.


  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);
   
   
  state START:
  '''state''' START:
   send SetWindow goto SENT_WINDOW;
   '''send''' SetWindow '''goto''' SENT_WINDOW;
   recv GetBrowserValue goto START;
   '''recv''' GetBrowserValue '''goto''' START;
   
   
  state SENT_WINDOW:
  '''state''' SENT_WINDOW:
   send SetWindow goto SENT_WINDOW;
   '''send''' SetWindow '''goto''' SENT_WINDOW;
   send Paint goto SENT_WINDOW;
   '''send''' Paint '''goto''' SENT_WINDOW;
   recv GetBrowserValue goto SENT_WINDOW;
   '''recv''' GetBrowserValue '''goto''' SENT_WINDOW;
  };
  };


Confirmed users
699

edits