mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
Bug 570099: Allow Shmems to be used in IPDL structs. r=benjamn
This commit is contained in:
parent
0df9d481ab
commit
2d2a5f4b25
@ -145,6 +145,17 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator==(const Shmem& aRhs) const
|
||||
{
|
||||
// need to compare IDs because of AdoptShmem(); two Shmems might
|
||||
// refer to the same segment but with different IDs for different
|
||||
// protocol trees. (NB: it's possible for this method to
|
||||
// spuriously return true if AdoptShmem() gives the same ID for
|
||||
// two protocol trees, but I don't think that can cause any
|
||||
// problems since the Shmems really would be indistinguishable.)
|
||||
return mSegment == aRhs.mSegment && mId == aRhs.mId;
|
||||
}
|
||||
|
||||
// Returns whether this Shmem is writable by you, and thus whether you can
|
||||
// transfer writability to another actor.
|
||||
bool
|
||||
|
@ -605,6 +605,13 @@ class _StructField(_CompoundTypeComponent):
|
||||
ref = ExprDeref(ref)
|
||||
return ref
|
||||
|
||||
def constRefExpr(self, thisexpr=None):
|
||||
# sigh, gross hack
|
||||
refexpr = self.refExpr(thisexpr)
|
||||
if 'Shmem' == self.ipdltype.name():
|
||||
refexpr = ExprCast(refexpr, Type('Shmem', ref=1), const=1)
|
||||
return refexpr
|
||||
|
||||
def argVar(self):
|
||||
return ExprVar('_'+ self.name)
|
||||
|
||||
@ -1488,6 +1495,12 @@ stmt. Some types generate both kinds.'''
|
||||
def visitArrayType(self, t):
|
||||
return TypeVisitor.visitArrayType(self, t)
|
||||
|
||||
def visitShmemType(self, s):
|
||||
if s in self.visited: return
|
||||
self.visited.add(s)
|
||||
self.usingTypedefs.append(Typedef(Type('mozilla::ipc::Shmem'),
|
||||
'Shmem'))
|
||||
|
||||
def visitVoidType(self, v): assert 0
|
||||
def visitMessageType(self, v): assert 0
|
||||
def visitProtocolType(self, v): assert 0
|
||||
@ -1587,9 +1600,11 @@ def _generateCxxStruct(sd):
|
||||
force_inline=1))
|
||||
get.addstmt(StmtReturn(f.refExpr()))
|
||||
|
||||
getconst = deepcopy(get)
|
||||
getconst.decl.ret = f.constRefType()
|
||||
getconst.decl.const = 1
|
||||
getconstdecl = deepcopy(get.decl)
|
||||
getconstdecl.ret = f.constRefType()
|
||||
getconstdecl.const = 1
|
||||
getconst = MethodDefn(getconstdecl)
|
||||
getconst.addstmt(StmtReturn(f.constRefExpr()))
|
||||
|
||||
struct.addstmts([ get, getconst, Whitespace.NL ])
|
||||
|
||||
|
@ -87,6 +87,11 @@ struct SetAttrs {
|
||||
};
|
||||
union Op { null_t; SetAttrs; };
|
||||
|
||||
struct ShmemStruct {
|
||||
int i;
|
||||
Shmem mem;
|
||||
};
|
||||
|
||||
} // namespace _foo
|
||||
} // namespace mozilla
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user