remove in/out/inout syntax in favor of parent:, child:, and both: labels
authorChris Jones <jones.chris.g@gmail.com>
Fri, 10 Jul 2009 19:19:54 -0500
changeset 35769 a22c2cc3af1f0df92134b804aa6d2cf38f7e4302
parent 35768 82c83a8dfe46dca01c732af816054b9ae0aa2286
child 35770 bbcef80246c85787753bc1ea6d62ef30d1c9ba7f
push id10694
push userbsmedberg@mozilla.com
push dateMon, 14 Dec 2009 15:23:10 +0000
treeherdermozilla-central@683dfdc4adf0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone1.9.2a1pre
remove in/out/inout syntax in favor of parent:, child:, and both: labels
dom/ipc/IFrameEmbedding.ipdl
dom/plugins/NPAPI.ipdl
dom/plugins/NPP.ipdl
ipc/ipdl/ipdl/ast.py
ipc/ipdl/ipdl/parser.py
ipc/ipdl/ipdl/type.py
--- a/dom/ipc/IFrameEmbedding.ipdl
+++ b/dom/ipc/IFrameEmbedding.ipdl
@@ -1,14 +1,15 @@
 using MagicWindowHandle;
 using PRUint32;
 
 rpc protocol IFrameEmbedding
 {
-    rpc out init(MagicWindowHandle parentWidget);
+child:
+    rpc init(MagicWindowHandle parentWidget);
 
-    rpc out loadURL(String uri);
+    rpc loadURL(String uri);
 
-    rpc out move(PRUint32 x,
-                 PRUint32 y,
-                 PRUint32 width,
-                 PRUint32 height);
+    rpc move(PRUint32 x,
+             PRUint32 y,
+             PRUint32 width,
+             PRUint32 height);
 };
--- a/dom/plugins/NPAPI.ipdl
+++ b/dom/plugins/NPAPI.ipdl
@@ -8,22 +8,22 @@ using NPError;
 namespace mozilla {
 namespace plugins {
 
 rpc protocol NPAPI
 {
     manages NPP;
 //    manages NPObject;
 
-    rpc out NP_Initialize() returns (NPError rv);
+child:
+    rpc NP_Initialize() returns (NPError rv);
 
-
-    rpc out NPP(String aMimeType,
+    rpc NPP(String aMimeType,
                 uint16_t aMode,
                 StringArray aNames,
                 StringArray aValues) returns (NPError rv);
-    rpc out ~NPP() returns (NPError rv);
+    rpc ~NPP() returns (NPError rv);
 
 //    rpc in TradeNPPsForSomeReason(NPP n) returns (NPP n2);
 };
 
 } // namespace plugins
 } // namespace mozilla
--- a/dom/plugins/NPP.ipdl
+++ b/dom/plugins/NPP.ipdl
@@ -10,16 +10,18 @@ namespace mozilla {
 namespace plugins {
 
 rpc protocol NPP
 {
     manager NPAPI;
 
     // manages NPStream;
 
-    rpc out NPP_SetWindow(NPWindow window) returns (NPError rv);
+child:
+    rpc NPP_SetWindow(NPWindow window) returns (NPError rv);
+    rpc NPP_GetValue(String key) returns (String value);
 
-    rpc out NPP_GetValue(String key) returns (String value);
-    rpc in NPN_GetValue(String key) returns (String value);
+parent:
+    rpc NPN_GetValue(String key) returns (String value);
 };
 
 } // namespace plugins
 } // namespace mozilla
--- a/ipc/ipdl/ipdl/ast.py
+++ b/ipc/ipdl/ipdl/ast.py
@@ -199,17 +199,17 @@ class IN:
     def prettySS(cls, ss): return _prettyTable['in'][ss.pretty]
 class OUT:
     pretty = 'out'
     @classmethod
     def __hash__(cls): return hash(cls.pretty)
     @classmethod
     def __str__(cls):  return cls.pretty
     @staticmethod
-    def pretty(ss): return _prettyTable['out'][ss.pretty]
+    def prettySS(ss): return _prettyTable['out'][ss.pretty]
 
 _prettyTable = {
     IN  : { 'async': 'AsyncRecv',
             'sync': 'SyncRecv',
             'rpc': 'RpcAnswer' },
     OUT : { 'async': 'AsyncSend',
             'sync': 'SyncSend',
             'rpc': 'RpcCall' }
--- a/ipc/ipdl/ipdl/parser.py
+++ b/ipc/ipdl/ipdl/parser.py
@@ -59,16 +59,17 @@ class Parser:
     def __init__(self, debug=0):
         self.debug = debug
         self.filename = None
         self.includedirs = None
         self.loc = None         # not always up to date
         self.lexer = None
         self.parser = None
         self.tu = TranslationUnit()
+        self.direction = None
 
     def parse(self, input, filename, includedirs):
         assert os.path.isabs(filename)
 
         if filename in Parser.parsed:
             return Parser.parsed[filename].tu
 
         self.lexer = lex.lex(debug=self.debug,
@@ -83,17 +84,17 @@ class Parser:
         self.includedirs = includedirs
         self.tu.filename = filename
 
         Parser.parsed[filename] = self
         Parser.parseStack.append(Parser.current)
         Parser.current = self
 
         ast = self.parser.parse(input=input, lexer=self.lexer,
-                                 debug=self.debug)
+                                debug=self.debug)
 
         Parser.current = Parser.parseStack.pop()
         return ast
 
     def resolveIncludePath(self, filepath):
         '''Return the absolute path from which the possibly partial
 |filepath| should be read, or |None| if |filepath| can't be located.'''
         for incdir in self.includedirs +[ '' ]:
@@ -119,25 +120,25 @@ def locFromTok(p, num):
     return Loc(Parser.current.filename, p.lineno(num))
 
 
 ##-----------------------------------------------------------------------------
 
 reserved = set((
         'answer',
         'async',
+        'both',
         'call',
+        'child',
         'goto',
-        'in',
         'include',
-        'inout',
         'manager',
         'manages',
         'namespace',
-        'out',
+        'parent',
         'protocol',
         'recv',
         'returns',
         'rpc',
         'send',
         'share',
         'sync',
         'transfer',
@@ -271,29 +272,59 @@ def p_ManagerStmtOpt(p):
     else:
         p[0] = ManagerStmt(locFromTok(p, 1), p[2])
 
 def p_ManagesStmt(p):
     """ManagesStmt : MANAGES ID ';'"""
     p[0] = ManagesStmt(locFromTok(p, 1), p[2])
 
 def p_MessageDecls(p):
-    """MessageDecls : MessageDecls MessageDecl ';'
-                    | MessageDecl ';'"""
-    if 3 == len(p):
+    """MessageDecls : MessageDecls MessageDeclThing
+                    | MessageDeclThing"""
+    if 2 == len(p):
         p[0] = [ p[1] ]
     else:
         p[1].append(p[2])
         p[0] = p[1]
 
+def p_MessageDeclThing(p):
+    """MessageDeclThing : MessageDirectionLabel ':' MessageDecl ';'
+                        | MessageDecl ';'"""
+    if 3 == len(p):
+        p[0] = p[1]
+    else:
+        p[0] = p[3]
+
+def p_MessageDirectionLabel(p):
+    """MessageDirectionLabel : PARENT
+                             | CHILD
+                             | BOTH"""
+    if p[1] == 'parent':
+        Parser.current.direction = IN
+    elif p[1] == 'child':
+        Parser.current.direction = OUT
+    elif p[1] == 'both':
+        Parser.current.direction = INOUT
+    else:
+        assert 0
+
 def p_MessageDecl(p):
-    """MessageDecl : SendSemanticsQual DirectionQual MessageBody"""
-    msg = p[3]
-    msg.sendSemantics = p[1]
-    msg.direction = p[2]
+    """MessageDecl : SendSemanticsQual MessageBody
+                   | MessageBody"""
+    if Parser.current.direction is None:
+        p_error(p[1])
+
+    if 2 == len(p):
+        msg = p[1]
+        msg.sendSemantics = ASYNC
+    else:
+        msg = p[2]
+        msg.sendSemantics = p[1]
+
+    msg.direction = Parser.current.direction
     p[0] = msg
 
 def p_MessageBody(p):
     """MessageBody : MessageId MessageInParams MessageOutParams"""
     # FIXME/cjones: need better loc info: use one of the quals
     msg = MessageDecl(locFromTok(p, 1))
     msg.name = p[1]
     msg.addInParams(p[2])
@@ -318,26 +349,31 @@ def p_MessageOutParams(p):
         p[0] = [ ]
     else:
         p[0] = p[3]
 
 ##--------------------
 ## State machine
 
 def p_TransitionStmts(p):
-    """TransitionStmts : TransitionStmts TransitionStmt
-                       | TransitionStmt
+    """TransitionStmts : TransitionStmtsNonEmpty
                        | """
+    if 2 == len(p):
+        p[0] = p[1]
+    else:
+        p[0] = [ ]
+
+def p_TransitionStmtsNonEmpty(p):
+    """TransitionStmtsNonEmpty : TransitionStmtsNonEmpty TransitionStmt
+                               | TransitionStmt"""
     if 3 == len(p):
         p[1].append(p[2])
         p[0] = p[1]
     elif 2 == len(p):
         p[0] = [ p[1] ]
-    else:
-        p[0] = [ ]
 
 def p_TransitionStmt(p):
     """TransitionStmt : State ':' Transitions"""
     p[0] = TransitionStmt(locFromTok(p, 1), p[1], p[3])
 
 def p_Transitions(p):
     """Transitions : Transitions Transition
                    | Transition"""
@@ -363,40 +399,24 @@ def p_State(p):
     """State : ID"""
     p[0] = State(locFromTok(p, 1), p[1])
 
 ##--------------------
 ## Minor stuff
 def p_SendSemanticsQual(p):
     """SendSemanticsQual : ASYNC
                          | RPC
-                         | SYNC
-                         | """
-    if 1 == len(p):
-        p[0] = ASYNC
-        return
-
+                         | SYNC"""
     s = p[1]
     if 'async' == s: p[0] = ASYNC
     elif 'rpc' == s: p[0] = RPC
     elif 'sync'== s: p[0] = SYNC
     else:
         assert 0
 
-def p_DirectionQual(p):
-    """DirectionQual : IN
-                     | INOUT
-                     | OUT"""
-    s = p[1]
-    if 'in' == s:  p[0] = IN
-    elif 'inout' == s:  p[0] = INOUT
-    elif 'out' == s:  p[0] = OUT
-    else:
-        assert 0
-
 def p_ParamList(p):
     """ParamList : ParamList ',' Param
                  | Param
                  | """
     if 1 == len(p):
         p[0] = [ ]
     elif 2 == len(p):
         p[0] = [ p[1] ]
--- a/ipc/ipdl/ipdl/type.py
+++ b/ipc/ipdl/ipdl/type.py
@@ -791,9 +791,9 @@ class CheckTypes(Visitor):
             or _YNC is impliedSems and t.msg.type.isRpc()
             or RPC is impliedSems and (not t.msg.type.isRpc())):
             mtype = t.msg.type
 
             self.errors.append(errormsg(
                     loc, "%s %s message `%s' is not `%s'd",
                     mtype.sendSemantics.pretty, mtype.direction.pretty,
                     t.msg.progname,
-                    trigger))
+                    t.trigger.pretty))