Bug 1720688 - Support extended attribute syntax in protocol declarations, r=mccr8

Differential Revision: https://phabricator.services.mozilla.com/D119975
This commit is contained in:
Kashav Madan 2021-07-22 02:24:43 +00:00
parent 69d9eb3fdb
commit 5781dca888
75 changed files with 132 additions and 123 deletions

View File

@ -23,7 +23,7 @@ struct TextAttributesRun {
};
nested(upto inside_sync) sync protocol PDocAccessiblePlatformExt {
[NestedUpTo=inside_sync] sync protocol PDocAccessiblePlatformExt {
manager PDocAccessible;
child:

View File

@ -76,7 +76,7 @@ struct TextRangeData
int32_t EndOffset;
};
nested(upto inside_sync) sync protocol PDocAccessible
[NestedUpTo=inside_sync] sync protocol PDocAccessible
{
manager PBrowser;
manages PDocAccessiblePlatformExt;

View File

@ -14,7 +14,7 @@ namespace mozilla {
namespace dom {
namespace cache {
refcounted protocol PCacheStreamControl
[RefCounted] protocol PCacheStreamControl
{
manager PBackground;

View File

@ -36,7 +36,7 @@ namespace dom {
* command from the content process, and a WebGLParent in the compositor
* process that runs the commands.
*/
sync refcounted protocol PWebGL
[RefCounted] sync protocol PWebGL
{
manager PCompositorBridge;

View File

@ -13,7 +13,7 @@ include IPCStream;
namespace mozilla {
refcounted protocol PRemoteLazyInputStream
[RefCounted] protocol PRemoteLazyInputStream
{
manager PBackground or PContent or PSocketProcess;

View File

@ -66,7 +66,7 @@ union FileSystemResponseValue
FileSystemErrorResponse;
};
refcounted protocol PFileSystemRequest
[RefCounted] protocol PFileSystemRequest
{
manager PBackground;

View File

@ -10,7 +10,7 @@ using mozilla::dom::GamepadHandle from "mozilla/dom/GamepadHandle.h";
namespace mozilla {
namespace dom {
refcounted protocol PGamepadEventChannel {
[RefCounted] protocol PGamepadEventChannel {
manager PBackground;
parent:
async __delete__();

View File

@ -10,7 +10,7 @@ using mozilla::dom::GamepadHandle from "mozilla/dom/GamepadHandle.h";
namespace mozilla {
namespace dom {
refcounted protocol PGamepadTestChannel {
[RefCounted] protocol PGamepadTestChannel {
manager PBackground;
parent:
async GamepadTestEvent(uint32_t aID, GamepadChangeEvent aGamepadEvent);

View File

@ -83,7 +83,7 @@ union CursorResponse
IndexKeyCursorResponse[];
};
refcounted protocol PBackgroundIDBCursor
[RefCounted] protocol PBackgroundIDBCursor
{
manager PBackgroundIDBTransaction or PBackgroundIDBVersionChangeTransaction;

View File

@ -39,7 +39,7 @@ union FactoryRequestParams
DeleteDatabaseRequestParams;
};
sync refcounted protocol PBackgroundIDBFactory
[RefCounted] sync protocol PBackgroundIDBFactory
{
manager PBackground;

View File

@ -14,7 +14,7 @@ namespace mozilla {
namespace dom {
namespace indexedDB {
refcounted protocol PBackgroundIDBTransaction {
[RefCounted] protocol PBackgroundIDBTransaction {
manager PBackgroundIDBDatabase;
manages PBackgroundIDBCursor;

View File

@ -18,7 +18,7 @@ namespace mozilla {
namespace dom {
namespace indexedDB {
refcounted protocol PBackgroundIDBVersionChangeTransaction {
[RefCounted] protocol PBackgroundIDBVersionChangeTransaction {
manager PBackgroundIDBDatabase;
manages PBackgroundIDBCursor;

View File

@ -176,7 +176,7 @@ struct PrintPreviewResultInfo
* See `dom/docs/Fission-IPC-Diagram.svg` for an overview of the DOM IPC
* actors.
*/
nested(upto inside_cpow) sync refcounted protocol PBrowser
[NestedUpTo=inside_cpow, RefCounted] sync protocol PBrowser
{
manager PContent;

View File

@ -41,7 +41,7 @@ namespace dom {
* See `dom/docs/Fission-IPC-Diagram.svg` for an overview of the DOM IPC
* actors.
*/
async refcounted protocol PBrowserBridge {
[RefCounted] async protocol PBrowserBridge {
manager PBrowser;
child:

View File

@ -414,7 +414,7 @@ union BlobURLDataRequestResult
* and a content process. There is exactly one PContentParent/PContentChild pair
* for each content process.
*/
nested(upto inside_cpow) sync protocol PContent
[NestedUpTo=inside_cpow] sync protocol PContent
{
manages PBrowser;
manages PContentPermissionRequest;

View File

@ -20,7 +20,7 @@ namespace dom {
* `mozilla::dom::InProcess{Parent, Child}::Singleton()` should be used to get
* an instance of this actor.
*/
async refcounted protocol PInProcess
[RefCounted] async protocol PInProcess
{
manages PExtensions;
manages PWindowGlobal;

View File

@ -59,7 +59,7 @@ struct IPCWebShareData
* link either between the chrome/content process, or will be in-process, for
* documents which are loaded in the chrome process.
*/
async refcounted protocol PWindowGlobal
[RefCounted] async protocol PWindowGlobal
{
manager PBrowser or PInProcess;

View File

@ -15,7 +15,7 @@ include "GMPMessageUtils.h";
namespace mozilla {
namespace gmp {
async refcounted protocol PChromiumCDM
[RefCounted] async protocol PChromiumCDM
{
manager PGMPContent;
child:

View File

@ -14,7 +14,7 @@ include protocol PSandboxTesting;
namespace mozilla {
namespace gmp {
intr refcounted protocol PGMPContent
[RefCounted] intr protocol PGMPContent
{
manages PGMPVideoDecoder;
manages PGMPVideoEncoder;

View File

@ -11,7 +11,7 @@ using base::ProcessId from "base/process.h";
namespace mozilla {
namespace gmp {
sync refcounted protocol PGMPService
[RefCounted] sync protocol PGMPService
{
parent:
sync LaunchGMP(NodeIdVariant nodeIdVariant,

View File

@ -14,7 +14,7 @@ include "GMPMessageUtils.h";
namespace mozilla {
namespace gmp {
intr refcounted protocol PGMPVideoDecoder
[RefCounted] intr protocol PGMPVideoDecoder
{
manager PGMPContent;
child:

View File

@ -15,7 +15,7 @@ include "GMPMessageUtils.h";
namespace mozilla {
namespace gmp {
intr refcounted protocol PGMPVideoEncoder
[RefCounted] intr protocol PGMPVideoEncoder
{
manager PGMPContent;
child:

View File

@ -10,7 +10,7 @@ include DOMTypes;
namespace mozilla {
namespace dom {
refcounted protocol PServiceWorker
[RefCounted] protocol PServiceWorker
{
manager PBackground;

View File

@ -12,7 +12,7 @@ include "mozilla/dom/ServiceWorkerIPCUtils.h";
namespace mozilla {
namespace dom {
refcounted protocol PServiceWorkerContainer
[RefCounted] protocol PServiceWorkerContainer
{
manager PBackground;

View File

@ -12,7 +12,7 @@ include "ipc/ErrorIPCUtils.h";
namespace mozilla {
namespace dom {
refcounted protocol PServiceWorkerRegistration
[RefCounted] protocol PServiceWorkerRegistration
{
manager PBackground;

View File

@ -40,7 +40,7 @@ struct SSCacheCopy {
SSSetItemInfo[] data;
};
sync refcounted protocol PBackgroundSessionStorageCache
[RefCounted] sync protocol PBackgroundSessionStorageCache
{
manager PBackgroundSessionStorageManager;

View File

@ -8,7 +8,7 @@ include protocol PBackgroundSessionStorageCache;
namespace mozilla {
namespace dom {
sync refcounted protocol PBackgroundSessionStorageManager
[RefCounted] sync protocol PBackgroundSessionStorageManager
{
manager PBackground;
manages PBackgroundSessionStorageCache;

View File

@ -31,7 +31,7 @@ namespace layers {
* and the parent side lives on the main thread in the GPU process. If there
* is no GPU process, then this protocol is not instantiated.
*/
sync refcounted protocol PAPZInputBridge
[RefCounted] sync protocol PAPZInputBridge
{
manager PGPU;

View File

@ -16,7 +16,7 @@ namespace layers {
/**
* PCanvas is the IPDL for recorded Canvas drawing.
*/
async refcounted protocol PCanvas {
[RefCounted] async protocol PCanvas {
parent:
/**
* Initialize a CanvasTranslator for a particular TextureType, which

View File

@ -92,7 +92,7 @@ struct FrameStats {
* protocol, which is per-browser. A lot of the functions in the protocol are
* basically multiplexing/demultiplexing stuff in PLayerTransaction.
*/
sync refcounted protocol PCompositorBridge
[RefCounted] sync protocol PCompositorBridge
{
manager PCompositorManager;

View File

@ -57,7 +57,7 @@ struct ScreenConfiguration {
namespace hal_sandbox {
nested(upto inside_cpow) sync protocol PHal {
[NestedUpTo=inside_cpow] sync protocol PHal {
manager PContent;
child:

View File

@ -77,7 +77,7 @@ using class mozilla::dom::SSCacheCopy from "mozilla/dom/PBackgroundSessionStorag
namespace mozilla {
namespace ipc {
sync refcounted protocol PBackground
[RefCounted] sync protocol PBackground
{
manages PBackgroundDataBridge;
manages PBackgroundIDBFactory;

View File

@ -32,7 +32,7 @@ namespace ipc {
* process, child process informs the scheduler and the process is moved back
* to the default queue.
*/
async refcounted protocol PIdleScheduler
[RefCounted] async protocol PIdleScheduler
{
manager PBackground;

View File

@ -272,12 +272,22 @@ class Namespace(Node):
class Protocol(NamespacedNode):
def __init__(self, loc):
NamespacedNode.__init__(self, loc)
self.attributes = {}
self.sendSemantics = ASYNC
self.nested = NOT_NESTED
self.managers = []
self.managesStmts = []
self.messageDecls = []
def nested(self):
if "NestedUpTo" not in self.attributes:
return NOT_NESTED
return {
"not": NOT_NESTED,
"inside_sync": INSIDE_SYNC_NESTED,
"inside_cpow": INSIDE_CPOW_NESTED,
}[self.attributes["NestedUpTo"].value]
class StructField(Node):
def __init__(self, loc, type, name):

View File

@ -130,18 +130,15 @@ reserved = set(
"manager",
"manages",
"namespace",
"nested",
"nullable",
"or",
"parent",
"protocol",
"refcounted",
"returns",
"struct",
"sync",
"union",
"UniquePtr",
"upto",
"using",
)
)
@ -294,12 +291,6 @@ def p_UsingKind(p):
p[0] = p[1] if 2 == len(p) else None
def p_MaybeRefcounted(p):
"""MaybeRefcounted : REFCOUNTED
|"""
p[0] = 2 == len(p)
def p_UsingStmt(p):
"""UsingStmt : Attributes USING UsingKind CxxType FROM STRING"""
p[0] = UsingStmt(
@ -378,14 +369,13 @@ def p_ComponentTypes(p):
def p_ProtocolDefn(p):
"""ProtocolDefn : OptionalProtocolSendSemanticsQual MaybeRefcounted \
"""ProtocolDefn : Attributes OptionalSendSemantics \
PROTOCOL ID '{' ProtocolBody '}' ';'"""
protocol = p[6]
protocol.loc = locFromTok(p, 3)
protocol.name = p[4]
protocol.nested = p[1][0]
protocol.sendSemantics = p[1][1]
protocol.refcounted = p[2]
protocol.attributes = p[1]
protocol.sendSemantics = p[2]
p[0] = protocol
if Parser.current.type == "header":
@ -559,19 +549,6 @@ def p_AttributeValue(p):
p[0] = p[2]
# --------------------
# Minor stuff
def p_Nested(p):
"""Nested : ID"""
kinds = {"not": 1, "inside_sync": 2, "inside_cpow": 3}
if p[1] not in kinds:
_error(
locFromTok(p, 1), "Expected not, inside_sync, or inside_cpow for nested()"
)
p[0] = {"nested": kinds[p[1]]}
def p_SendSemantics(p):
"""SendSemantics : ASYNC
| SYNC
@ -585,38 +562,17 @@ def p_SendSemantics(p):
p[0] = INTR
def p_OptionalProtocolSendSemanticsQual(p):
"""OptionalProtocolSendSemanticsQual : ProtocolSendSemanticsQual
def p_OptionalSendSemantics(p):
"""OptionalSendSemantics : SendSemantics
|"""
if 2 == len(p):
p[0] = p[1]
else:
p[0] = [NOT_NESTED, ASYNC]
p[0] = ASYNC
def p_ProtocolSendSemanticsQual(p):
"""ProtocolSendSemanticsQual : ASYNC
| SYNC
| NESTED '(' UPTO Nested ')' ASYNC
| NESTED '(' UPTO Nested ')' SYNC
| INTR"""
if p[1] == "nested":
mtype = p[6]
nested = p[4]
else:
mtype = p[1]
nested = NOT_NESTED
if mtype == "async":
mtype = ASYNC
elif mtype == "sync":
mtype = SYNC
elif mtype == "intr":
mtype = INTR
else:
assert 0
p[0] = [nested, mtype]
# --------------------
# Minor stuff
def p_ParamList(p):

View File

@ -914,7 +914,9 @@ class GatherDecls(TcheckVisitor):
fullname = str(qname)
p.decl = self.declare(
loc=p.loc,
type=ProtocolType(qname, p.nested, p.sendSemantics, p.refcounted),
type=ProtocolType(
qname, p.nested(), p.sendSemantics, "RefCounted" in p.attributes
),
shortname=p.name,
fullname=None if 0 == len(qname.quals) else fullname,
)
@ -1164,6 +1166,14 @@ class GatherDecls(TcheckVisitor):
if not (p.managers or p.messageDecls or p.managesStmts):
self.error(p.loc, "top-level protocol `%s' cannot be empty", p.name)
self.checkAttributes(
p.attributes,
{
"RefCounted": None,
"NestedUpTo": ("not", "inside_sync", "inside_cpow"),
},
)
setattr(self, "currentProtocolDecl", p.decl)
for msg in p.messageDecls:
msg.accept(self)
@ -1479,6 +1489,11 @@ class CheckTypes(TcheckVisitor):
mgrtype.name(),
)
if ptype.isInterrupt() and ptype.nestedRange != (NOT_NESTED, NOT_NESTED):
self.error(
p.decl.loc, "intr protocol `%s' cannot specify [NestedUpTo]", p.name
)
if ptype.isToplevel():
cycles = checkcycles(p.decl.type)
if cycles:

View File

@ -1,7 +1,7 @@
namespace mozilla {
namespace _ipdltest {
nested(upto inside_sync) sync protocol PTestCancel
[NestedUpTo=inside_sync] sync protocol PTestCancel
{
// Test1
child:

View File

@ -1,7 +1,7 @@
namespace mozilla {
namespace _ipdltest {
nested(upto inside_cpow) sync protocol PTestDemon
[NestedUpTo=inside_cpow] sync protocol PTestDemon
{
child:
async Start();

View File

@ -1,7 +1,7 @@
namespace mozilla {
namespace _ipdltest {
nested(upto inside_cpow) sync protocol PTestHighestPrio
[NestedUpTo=inside_cpow] sync protocol PTestHighestPrio
{
parent:
[Nested=inside_cpow] async Msg1();

View File

@ -1,7 +1,7 @@
namespace mozilla {
namespace _ipdltest {
nested(upto inside_sync) sync protocol PTestRPC
[NestedUpTo=inside_sync] sync protocol PTestRPC
{
parent:
[Nested=inside_sync] sync Test1_Start() returns (uint32_t result);

View File

@ -1,7 +1,7 @@
namespace mozilla {
namespace _ipdltest {
nested(upto inside_cpow) sync protocol PTestUrgency
[NestedUpTo=inside_cpow] sync protocol PTestUrgency
{
parent:
[Nested=inside_sync] sync Test1() returns (uint32_t result);

View File

@ -1,7 +1,7 @@
namespace mozilla {
namespace _ipdltest {
nested(upto inside_cpow) sync protocol PTestUrgentHangs
[NestedUpTo=inside_sync] sync protocol PTestUrgentHangs
{
parent:
[Nested=inside_sync] sync Test1_2();

View File

@ -2,7 +2,7 @@
include protocol PBadNestedManager;
nested(upto inside_sync) async protocol PBadNestedManagee {
[NestedUpTo=inside_sync] async protocol PBadNestedManagee {
manager PBadNestedManager;
child:
async __delete__();

View File

@ -2,7 +2,7 @@
include protocol PBadNestedManagee;
nested(upto not) async protocol PBadNestedManager {
[NestedUpTo=not] async protocol PBadNestedManager {
manages PBadNestedManagee;
parent:
async PBadNestedManagee();

View File

@ -0,0 +1,6 @@
//error: Repeated extended attribute `RefCounted'
[RefCounted, RefCounted] async protocol PExtendedAttrRepeated {
parent:
async Msg();
};

View File

@ -0,0 +1,6 @@
//error: unexpected value for valueless attribute `RefCounted'
[RefCounted=invalid] async protocol PExtendedAttrUnexpectedValue {
parent:
async Msg();
};

View File

@ -0,0 +1,6 @@
//error: unknown attribute `InvalidAttr'
[InvalidAttr] async protocol PExtendedAttrUnknownValue {
parent:
async Msg();
};

View File

@ -0,0 +1,6 @@
//error: intr protocol `PIntrNestedProtocol' cannot specify [NestedUpTo]
[NestedUpTo=inside_sync] intr protocol PIntrNestedProtocol {
child:
intr Msg();
};

View File

@ -0,0 +1,4 @@
[NestedUpTo=inside_sync,RefCounted] async protocol PExtendedAttrMultipleAttributes {
parent:
async Msg();
};

View File

@ -1,7 +1,7 @@
nested(upto inside_cpow) sync protocol PNested {
[NestedUpTo=inside_cpow] sync protocol PNested {
parent:
[Nested=not] async NotNested();
[Nested=inside_sync] sync InsideSync();
[Nested=inside_cpow] async InsideCpow();
[Nested=inside_cpow] sync InsideCpowSync();
};
};

View File

@ -1,4 +1,4 @@
async refcounted protocol PRefcounted {
[RefCounted] async protocol PRefcounted {
child:
async __delete__();
};

View File

@ -4,7 +4,7 @@ include protocol PSyncSyncManagee;
* in the Rust IPDL parser that was treating "sync" like "async" in the
* nested case.
*/
nested(upto not) sync protocol PSyncSyncManager {
[NestedUpTo=not] sync protocol PSyncSyncManager {
manages PSyncSyncManagee;
parent:
async PSyncSyncManagee();

View File

@ -9,7 +9,7 @@ include protocol PPrinting;
namespace mozilla {
namespace layout {
async refcounted protocol PRemotePrintJob
[RefCounted] async protocol PRemotePrintJob
{
manager PPrinting;

View File

@ -27,7 +27,7 @@ namespace net {
* @see nsICookiePermission
*/
nested(upto inside_cpow) sync protocol PCookieService
[NestedUpTo=inside_cpow] sync protocol PCookieService
{
manager PNecko;

View File

@ -17,7 +17,7 @@ using mozilla::OriginAttributes from "mozilla/ipc/BackgroundUtils.h";
namespace mozilla {
namespace net {
async refcounted protocol PDNSRequest
[RefCounted] async protocol PDNSRequest
{
manager PNecko or PSocketProcess;

View File

@ -9,7 +9,7 @@ include protocol PSocketProcess;
namespace mozilla {
namespace net {
async refcounted protocol PNativeDNSResolverOverride
[RefCounted] async protocol PNativeDNSResolverOverride
{
manager PSocketProcess;

View File

@ -11,7 +11,7 @@ include PSMIPCTypes;
namespace mozilla {
namespace net {
async refcounted protocol PTRRService
[RefCounted] async protocol PTRRService
{
manager PSocketProcess;

View File

@ -10,7 +10,7 @@ include protocol PNecko;
namespace mozilla {
namespace net {
async refcounted protocol PDataChannel
[RefCounted] async protocol PDataChannel
{
manager PNecko;

View File

@ -22,7 +22,7 @@ using mozilla::net::NetAddr from "mozilla/net/DNS.h";
namespace mozilla {
namespace net {
refcounted protocol PDocumentChannel
[RefCounted] protocol PDocumentChannel
{
manager PNecko;

View File

@ -13,7 +13,7 @@ namespace net {
/* Used to facilitate http redirects to file:// - see
* https://bugzilla.mozilla.org/show_bug.cgi?id=1345094
*/
async refcounted protocol PFileChannel
[RefCounted] async protocol PFileChannel
{
manager PNecko;

View File

@ -10,7 +10,7 @@ include protocol PSocketProcess;
namespace mozilla {
namespace net {
refcounted protocol PInputChannelThrottleQueue
[RefCounted] protocol PInputChannelThrottleQueue
{
manager PSocketProcess;

View File

@ -49,7 +49,7 @@ namespace mozilla {
namespace net {
//-------------------------------------------------------------------
nested(upto inside_cpow) sync protocol PNecko
[NestedUpTo=inside_cpow] sync protocol PNecko
{
manager PContent;
manages PHttpChannel;

View File

@ -9,7 +9,7 @@ include NeckoChannelParams;
namespace mozilla {
namespace net {
async refcounted protocol PProxyConfigLookup
[RefCounted] async protocol PProxyConfigLookup
{
manager PSocketProcess;

View File

@ -17,7 +17,7 @@ namespace net {
* content process and PSocketProcessBridgeParent lives in
* socket process.
*/
nested(upto inside_cpow) sync protocol PSocketProcessBridge
[NestedUpTo=inside_cpow] sync protocol PSocketProcessBridge
{
parent:

View File

@ -12,7 +12,7 @@ using mozilla::OriginAttributes from "mozilla/ipc/BackgroundUtils.h";
namespace mozilla {
namespace net {
refcounted protocol PAltService
[RefCounted] protocol PAltService
{
manager PSocketProcess;

View File

@ -10,7 +10,7 @@ include protocol PSocketProcess;
namespace mozilla {
namespace net {
refcounted protocol PAltSvcTransaction
[RefCounted] protocol PAltSvcTransaction
{
manager PSocketProcess;

View File

@ -10,7 +10,7 @@ namespace mozilla {
namespace net {
//-------------------------------------------------------------------
async refcounted protocol PBackgroundDataBridge
[RefCounted] async protocol PBackgroundDataBridge
{
manager PBackground;

View File

@ -19,7 +19,7 @@ namespace mozilla {
namespace net {
//-------------------------------------------------------------------
async refcounted protocol PHttpBackgroundChannel
[RefCounted] async protocol PHttpBackgroundChannel
{
manager PBackground;

View File

@ -23,7 +23,7 @@ namespace mozilla {
namespace net {
//-------------------------------------------------------------------
refcounted protocol PHttpChannel
[RefCounted] protocol PHttpChannel
{
manager PNecko;

View File

@ -14,7 +14,7 @@ include NeckoChannelParams;
namespace mozilla {
namespace net {
async refcounted protocol PHttpConnectionMgr
[RefCounted] async protocol PHttpConnectionMgr
{
manager PSocketProcess;
@ -37,4 +37,4 @@ child:
};
} // namespace net
} // namespace mozilla
} // namespace mozilla

View File

@ -33,7 +33,7 @@ struct NetworkAddressArg {
bool echConfigUsed;
};
refcounted protocol PHttpTransaction
[RefCounted] protocol PHttpTransaction
{
manager PSocketProcess;

View File

@ -11,7 +11,7 @@ include PSMIPCTypes;
namespace mozilla {
namespace psm {
refcounted protocol PVerifySSLServerCert
[RefCounted] protocol PVerifySSLServerCert
{
manager PBackground;

View File

@ -27,7 +27,7 @@ struct FrameTransitionData
* child process, which can be accessed via
* `mozilla::extensions::ExtensionsChild::Get()`.
*/
refcounted protocol PExtensions
[RefCounted] protocol PExtensions
{
manager PContent or PInProcess;

View File

@ -9,7 +9,7 @@ include protocol PContent;
namespace mozilla {
namespace dom {
refcounted protocol PExternalHelperApp
[RefCounted] protocol PExternalHelperApp
{
manager PContent;

View File

@ -23,7 +23,7 @@ struct HandlerInfo {
long preferredAction;
};
sync refcounted protocol PHandlerService
[RefCounted] sync protocol PHandlerService
{
manager PContent;