Skip to content

Commit

Permalink
Bug 1752444 - Part 1: Add {Parent,Child}Impl attributes to ipdl, r=ip…
Browse files Browse the repository at this point in the history
…c-reviewers,mccr8

These attributes replace the previous direct_call.py table which
specified how to locate the concrete implementation of a protocol and
whether it should use a virtual implementation or not.

They work by specifying the concrete type for an actor, and disabling
the automatic inclusion of the implementation's header file, which can
be included explicitly with an `include "";` statement. This allows
customizing both the name and include path of the concrete
implementation of an interface.

Differential Revision: https://phabricator.services.mozilla.com/D137226
  • Loading branch information
mystor committed Feb 9, 2022
1 parent 51677d1 commit 261ef74
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 794 deletions.
35 changes: 32 additions & 3 deletions ipc/ipdl/ipdl/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,21 @@ def visitInclude(self, inc):
def visitStructDecl(self, struct):
for f in struct.fields:
f.accept(self)
for a in struct.attributes.values():
a.accept(self)

def visitStructField(self, field):
field.typespec.accept(self)

def visitUnionDecl(self, union):
for t in union.components:
t.accept(self)
for a in union.attributes.values():
a.accept(self)

def visitUsingStmt(self, using):
for a in using.attributes.values():
a.accept(self)
pass

def visitProtocol(self, p):
for namespace in p.namespaces:
Expand All @@ -83,6 +86,8 @@ def visitProtocol(self, p):
managed.accept(self)
for msgDecl in p.messageDecls:
msgDecl.accept(self)
for a in p.attributes.values():
a.accept(self)

def visitNamespace(self, ns):
pass
Expand All @@ -98,18 +103,26 @@ def visitMessageDecl(self, md):
inParam.accept(self)
for outParam in md.outParams:
outParam.accept(self)
for a in md.attributes.values():
a.accept(self)

def visitParam(self, decl):
pass
for a in decl.attributes.values():
a.accept(self)

def visitTypeSpec(self, ts):
pass

def visitAttribute(self, a):
if isinstance(a.value, Node):
a.value.accept(self)

def visitStringLiteral(self, sl):
pass

def visitDecl(self, d):
pass
for a in d.attributes.values():
a.accept(self)


class Loc:
Expand Down Expand Up @@ -303,6 +316,13 @@ def nestedUpTo(self):

return NESTED_ATTR_MAP.get(self.attributes["NestedUpTo"].value, NOT_NESTED)

def implAttribute(self, side):
assert side in ("parent", "child")
attr = self.attributes.get(side.capitalize() + "Impl")
if attr is not None:
return attr.value
return None


class StructField(Node):
def __init__(self, loc, type, name):
Expand Down Expand Up @@ -402,6 +422,15 @@ def __init__(self, loc, name, value):
self.value = value


class StringLiteral(Node):
def __init__(self, loc, value):
Node.__init__(self, loc)
self.value = value

def __str__(self):
return '"%s"' % self.value


class QualifiedId: # FIXME inherit from node?
def __init__(self, loc, baseid, quals=[]):
assert isinstance(baseid, str)
Expand Down
Loading

0 comments on commit 261ef74

Please sign in to comment.