Skip to content

Commit

Permalink
Bug 1689147 - Part 1: Add extended attribute syntax to IPDL, r=mccr8
Browse files Browse the repository at this point in the history
  • Loading branch information
mystor committed Feb 9, 2021
1 parent a9371fd commit 63fd915
Show file tree
Hide file tree
Showing 32 changed files with 177 additions and 79 deletions.
2 changes: 1 addition & 1 deletion dom/cache/PCacheOp.ipdl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ include CacheTypes;

include "ipc/ErrorIPCUtils.h";

using moveonly mozilla::ErrorResult from "mozilla/ErrorResult.h";
[MoveOnly] using mozilla::ErrorResult from "mozilla/ErrorResult.h";

namespace mozilla {
namespace dom {
Expand Down
2 changes: 1 addition & 1 deletion dom/indexedDB/PBackgroundIDBSharedTypes.ipdlh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ using class mozilla::dom::indexedDB::KeyPath
using mozilla::dom::quota::PersistenceType
from "mozilla/dom/quota/PersistenceType.h";

using moveonly mozilla::SerializedStructuredCloneBuffer
[MoveOnly] using mozilla::SerializedStructuredCloneBuffer
from "mozilla/ipc/SerializedStructuredCloneBuffer.h";

namespace mozilla {
Expand Down
16 changes: 8 additions & 8 deletions dom/ipc/DOMTypes.ipdlh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ include ProtocolTypes;

using struct mozilla::void_t from "mozilla/ipc/IPCCore.h";

using moveonly struct mozilla::SerializedStructuredCloneBuffer
[MoveOnly] using struct mozilla::SerializedStructuredCloneBuffer
from "mozilla/ipc/SerializedStructuredCloneBuffer.h";

using class mozilla::dom::LoadingSessionHistoryInfo
Expand All @@ -39,15 +39,15 @@ using nsSizeMode from "nsIWidgetListener.h";
using ScrollbarPreference from "mozilla/ScrollbarPreferences.h";
using hal::ScreenOrientation from "mozilla/HalScreenConfiguration.h";
using mozilla::gfx::SurfaceFormat from "mozilla/gfx/Types.h";
using refcounted class nsIPrincipal from "nsIPrincipal.h";
[RefCounted] using class nsIPrincipal from "nsIPrincipal.h";
using mozilla::dom::MaybeDiscardedBrowsingContext from "mozilla/dom/BrowsingContext.h";
using refcounted class nsIURI from "nsIURI.h";
using refcounted class nsIContentSecurityPolicy from "nsIContentSecurityPolicy.h";
using refcounted class nsIInputStream from "mozilla/ipc/IPCStreamUtils.h";
using refcounted class nsIReferrerInfo from "nsIReferrerInfo.h";
using refcounted class nsIVariant from "nsIVariant.h";
[RefCounted] using class nsIURI from "nsIURI.h";
[RefCounted] using class nsIContentSecurityPolicy from "nsIContentSecurityPolicy.h";
[RefCounted] using class nsIInputStream from "mozilla/ipc/IPCStreamUtils.h";
[RefCounted] using class nsIReferrerInfo from "nsIReferrerInfo.h";
[RefCounted] using class nsIVariant from "nsIVariant.h";
using class mozilla::TimeStamp from "mozilla/TimeStamp.h";
using refcounted class mozilla::dom::BrowsingContext from "mozilla/dom/BrowsingContext.h";
[RefCounted] using class mozilla::dom::BrowsingContext from "mozilla/dom/BrowsingContext.h";

namespace mozilla {
namespace dom {
Expand Down
2 changes: 1 addition & 1 deletion dom/ipc/PBrowser.ipdl
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ using struct CollectedInputDataValue from "mozilla/dom/SessionStoreMessageUtils.
using mozilla::ContentBlockingNotifier::StorageAccessPermissionGrantedReason from "mozilla/ContentBlockingNotifier.h";
using CallerType from "mozilla/dom/BindingDeclarations.h";
using mozilla::dom::EmbedderElementEventType from "mozilla/dom/TabMessageTypes.h";
using refcounted class nsDocShellLoadState from "nsDocShellLoadState.h";
[RefCounted] using class nsDocShellLoadState from "nsDocShellLoadState.h";
using mozilla::IntrinsicSize from "nsIFrame.h";
using mozilla::AspectRatio from "mozilla/AspectRatio.h";

Expand Down
2 changes: 1 addition & 1 deletion dom/ipc/PBrowserBridge.ipdl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ using struct nsRect from "nsRect.h";
using CallerType from "mozilla/dom/BindingDeclarations.h";
using nsIntRect from "nsRect.h";
using mozilla::dom::EmbedderElementEventType from "mozilla/dom/TabMessageTypes.h";
using refcounted class nsDocShellLoadState from "nsDocShellLoadState.h";
[RefCounted] using class nsDocShellLoadState from "nsDocShellLoadState.h";
using mozilla::IntrinsicSize from "nsIFrame.h";
using mozilla::AspectRatio from "mozilla/AspectRatio.h";

Expand Down
16 changes: 8 additions & 8 deletions dom/ipc/PContent.ipdl
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ include "mozilla/ipc/ByteBufUtils.h";
include "mozilla/ipc/URIUtils.h";
include "mozilla/PermissionDelegateIPCUtils.h";

using refcounted class nsIDOMGeoPosition from "nsGeoPositionIPCSerialiser.h";
using refcounted class nsIAlertNotification from "mozilla/AlertNotificationIPCSerializer.h";
[RefCounted] using class nsIDOMGeoPosition from "nsGeoPositionIPCSerialiser.h";
[RefCounted] using class nsIAlertNotification from "mozilla/AlertNotificationIPCSerializer.h";

using struct ChromePackage from "mozilla/chrome/RegistryMessageUtils.h";
using struct SubstitutionMapping from "mozilla/chrome/RegistryMessageUtils.h";
Expand Down Expand Up @@ -112,9 +112,9 @@ using mozilla::Telemetry::ScalarAction from "mozilla/TelemetryComms.h";
using mozilla::Telemetry::KeyedScalarAction from "mozilla/TelemetryComms.h";
using mozilla::Telemetry::DynamicScalarDefinition from "mozilla/TelemetryComms.h";
using mozilla::Telemetry::ChildEventData from "mozilla/TelemetryComms.h";
using moveonly mozilla::UntrustedModulesData from "mozilla/UntrustedModulesData.h";
using moveonly mozilla::ModulePaths from "mozilla/UntrustedModulesData.h";
using moveonly mozilla::ModulesMapResult from "mozilla/UntrustedModulesData.h";
[MoveOnly] using mozilla::UntrustedModulesData from "mozilla/UntrustedModulesData.h";
[MoveOnly] using mozilla::ModulePaths from "mozilla/UntrustedModulesData.h";
[MoveOnly] using mozilla::ModulesMapResult from "mozilla/UntrustedModulesData.h";
using mozilla::Telemetry::DiscardedData from "mozilla/TelemetryComms.h";
using mozilla::CrossProcessMutexHandle from "mozilla/ipc/CrossProcessMutex.h";
using mozilla::dom::MaybeDiscardedBrowsingContext from "mozilla/dom/BrowsingContext.h";
Expand All @@ -134,22 +134,22 @@ using mozilla::dom::MediaMetadataBase from "mozilla/dom/MediaMetadata.h";
using mozilla::dom::MediaSessionAction from "mozilla/dom/MediaSessionBinding.h";
using mozilla::dom::MediaSessionPlaybackState from "mozilla/dom/MediaSessionBinding.h";
using mozilla::dom::PositionState from "mozilla/dom/MediaSession.h";
using refcounted class nsDocShellLoadState from "nsDocShellLoadState.h";
[RefCounted] using class nsDocShellLoadState from "nsDocShellLoadState.h";
using mozilla::dom::ServiceWorkerShutdownState::Progress from "mozilla/dom/ServiceWorkerShutdownState.h";
using mozilla::ContentBlockingNotifier::StorageAccessPermissionGrantedReason from "mozilla/ContentBlockingNotifier.h";
using mozilla::ContentBlockingNotifier::BlockingDecision from "mozilla/ContentBlockingNotifier.h";
using mozilla::ContentBlocking::StorageAccessPromptChoices from "mozilla/ContentBlocking.h";
using JSActorMessageKind from "mozilla/dom/JSActor.h";
using JSActorMessageMeta from "mozilla/dom/PWindowGlobal.h";
using mozilla::PermissionDelegateHandler::DelegatedPermissionList from "mozilla/PermissionDelegateHandler.h";
using refcounted class nsILayoutHistoryState from "nsILayoutHistoryState.h";
[RefCounted] using class nsILayoutHistoryState from "nsILayoutHistoryState.h";
using class mozilla::dom::SessionHistoryInfo from "mozilla/dom/SessionHistoryEntry.h";
using struct nsPoint from "nsPoint.h";
using struct mozilla::dom::LoadingSessionHistoryInfo from "mozilla/dom/SessionHistoryEntry.h";
using mozilla::PDMFactory::MediaCodecsSupported from "PDMFactory.h";
using mozilla::RemoteDecodeIn from "mozilla/RemoteDecoderManagerChild.h";
using mozilla::dom::PerformanceTimingData from "mozilla/dom/PerformanceTiming.h";
using refcounted mozilla::dom::FeaturePolicy from "mozilla/dom/FeaturePolicy.h";
[RefCounted] using mozilla::dom::FeaturePolicy from "mozilla/dom/FeaturePolicy.h";

union ChromeRegistryItem
{
Expand Down
2 changes: 1 addition & 1 deletion dom/ipc/PURLClassifierLocal.ipdl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ include PURLClassifierInfo;

include "mozilla/ipc/URIUtils.h";

using refcounted class nsIURI from "nsIURI.h";
[RefCounted] using class nsIURI from "nsIURI.h";

namespace mozilla {
namespace dom {
Expand Down
8 changes: 4 additions & 4 deletions dom/ipc/PWindowGlobal.ipdl
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ include "mozilla/layers/LayersMessageUtils.h";

using JSActorMessageKind from "mozilla/dom/JSActor.h";
using mozilla::gfx::IntRect from "mozilla/gfx/Rect.h";
using moveonly mozilla::gfx::PaintFragment from "mozilla/gfx/CrossProcessPaint.h";
[MoveOnly] using mozilla::gfx::PaintFragment from "mozilla/gfx/CrossProcessPaint.h";
using nscolor from "nsColor.h";
using refcounted class nsDocShellLoadState from "nsDocShellLoadState.h";
[RefCounted] using class nsDocShellLoadState from "nsDocShellLoadState.h";
using mozilla::dom::XPCOMPermitUnloadAction from "nsIContentViewer.h";
using mozilla::dom::TabId from "mozilla/dom/ipc/IdType.h";
using mozilla::layers::LayersId from "mozilla/layers/LayersTypes.h";
using refcounted class nsITransportSecurityInfo from "nsITransportSecurityInfo.h";
[RefCounted] using class nsITransportSecurityInfo from "nsITransportSecurityInfo.h";
using mozilla::UseCounters from "mozilla/UseCounter.h";
using mozilla::dom::MaybeDiscardedWindowContext from "mozilla/dom/WindowContext.h";
using refcounted mozilla::dom::FeaturePolicy from "mozilla/dom/FeaturePolicy.h";
[RefCounted] using mozilla::dom::FeaturePolicy from "mozilla/dom/FeaturePolicy.h";

namespace mozilla {
namespace dom {
Expand Down
2 changes: 1 addition & 1 deletion dom/ipc/WindowGlobalTypes.ipdlh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ include NeckoChannelParams;
include DOMTypes;

using mozilla::dom::WindowContextInitializer from "mozilla/dom/WindowContext.h";
using refcounted class nsITransportSecurityInfo from "nsITransportSecurityInfo.h";
[RefCounted] using class nsITransportSecurityInfo from "nsITransportSecurityInfo.h";

namespace mozilla {
namespace dom {
Expand Down
6 changes: 3 additions & 3 deletions dom/media/ipc/PRDD.ipdl
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ include protocol PRemoteDecoderManager;
include protocol PVideoBridge;

using mozilla::dom::NativeThreadId from "mozilla/dom/NativeThreadId.h";
using moveonly mozilla::UntrustedModulesData from "mozilla/UntrustedModulesData.h";
using moveonly mozilla::ModulePaths from "mozilla/UntrustedModulesData.h";
using moveonly mozilla::ModulesMapResult from "mozilla/UntrustedModulesData.h";
[MoveOnly] using mozilla::UntrustedModulesData from "mozilla/UntrustedModulesData.h";
[MoveOnly] using mozilla::ModulePaths from "mozilla/UntrustedModulesData.h";
[MoveOnly] using mozilla::ModulesMapResult from "mozilla/UntrustedModulesData.h";
using mozilla::PDMFactory::MediaCodecsSupported from "PDMFactory.h";

namespace mozilla {
Expand Down
6 changes: 3 additions & 3 deletions dom/media/ipc/PRemoteDecoder.ipdl
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ using mozilla::MediaDataDecoder::ConversionRequired from "PlatformDecoderModule.
using mozilla::TrackInfo::TrackType from "MediaInfo.h";
using mozilla::layers::LayersBackend from "mozilla/layers/LayersTypes.h";
using mozilla::MediaResult from "MediaResult.h";
using refcounted class mozilla::ArrayOfRemoteMediaRawData from "mozilla/RemoteMediaData.h";
using refcounted class mozilla::ArrayOfRemoteAudioData from "mozilla/RemoteMediaData.h";
using refcounted class mozilla::ArrayOfRemoteVideoData from "mozilla/RemoteMediaData.h";
[RefCounted] using class mozilla::ArrayOfRemoteMediaRawData from "mozilla/RemoteMediaData.h";
[RefCounted] using class mozilla::ArrayOfRemoteAudioData from "mozilla/RemoteMediaData.h";
[RefCounted] using class mozilla::ArrayOfRemoteVideoData from "mozilla/RemoteMediaData.h";
include PMediaDecoderParams;
include LayersSurfaces;

Expand Down
2 changes: 1 addition & 1 deletion dom/payments/ipc/PPaymentRequest.ipdl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ include protocol PBrowser;

include "mozilla/dom/PermissionMessageUtils.h";

using refcounted class nsIPrincipal from "nsIPrincipal.h";
[RefCounted] using class nsIPrincipal from "nsIPrincipal.h";

namespace mozilla {
namespace dom {
Expand Down
2 changes: 1 addition & 1 deletion dom/presentation/ipc/PPresentation.ipdl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ include InputStreamParams;

include "mozilla/dom/PermissionMessageUtils.h";

using refcounted class nsIPrincipal from "nsIPrincipal.h";
[RefCounted] using class nsIPrincipal from "nsIPrincipal.h";
using mozilla::dom::TabId from "mozilla/dom/ipc/IdType.h";

namespace mozilla {
Expand Down
2 changes: 1 addition & 1 deletion dom/webbrowserpersist/PWebBrowserPersistDocument.ipdl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ include NeckoChannelParams;

include "mozilla/dom/ReferrerInfoUtils.h";

using refcounted class nsIReferrerInfo from "nsIReferrerInfo.h";
[RefCounted] using class nsIReferrerInfo from "nsIReferrerInfo.h";

namespace mozilla {

Expand Down
4 changes: 2 additions & 2 deletions gfx/layers/ipc/PWebRenderBridge.ipdl
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ using mozilla::wr::BuiltDisplayListDescriptor from "mozilla/webrender/webrender_
using mozilla::wr::IdNamespace from "mozilla/webrender/WebRenderTypes.h";
using mozilla::wr::MaybeIdNamespace from "mozilla/webrender/WebRenderTypes.h";
using mozilla::wr::ExternalImageKeyPair from "mozilla/webrender/WebRenderTypes.h";
using moveonly mozilla::layers::DisplayListData from "mozilla/layers/RenderRootTypes.h";
using moveonly mozilla::layers::MaybeTransactionData from "mozilla/layers/RenderRootTypes.h";
[MoveOnly] using mozilla::layers::DisplayListData from "mozilla/layers/RenderRootTypes.h";
[MoveOnly] using mozilla::layers::MaybeTransactionData from "mozilla/layers/RenderRootTypes.h";
using mozilla::layers::FocusTarget from "mozilla/layers/FocusTarget.h";
using mozilla::layers::LayersObserverEpoch from "mozilla/layers/LayersTypes.h";
using mozilla::layers::TransactionId from "mozilla/layers/LayersTypes.h";
Expand Down
22 changes: 16 additions & 6 deletions ipc/ipdl/ipdl/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ def visitUnionDecl(self, union):
t.accept(self)

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

def visitProtocol(self, p):
Expand Down Expand Up @@ -88,6 +90,9 @@ def visitParam(self, decl):
def visitTypeSpec(self, ts):
pass

def visitAttribute(self, a):
pass

def visitDecl(self, d):
pass

Expand Down Expand Up @@ -193,8 +198,7 @@ def __init__(
cxxTypeSpec,
cxxHeader=None,
kind=None,
refcounted=False,
moveonly=False,
attributes={},
):
Node.__init__(self, loc)
assert not isinstance(cxxTypeSpec, str)
Expand All @@ -203,8 +207,7 @@ def __init__(
self.type = cxxTypeSpec
self.header = cxxHeader
self.kind = kind
self.refcounted = refcounted
self.moveonly = moveonly
self.attributes = attributes

def canBeForwardDeclared(self):
return self.isClass() or self.isStruct()
Expand All @@ -216,10 +219,10 @@ def isStruct(self):
return self.kind == "struct"

def isRefcounted(self):
return self.refcounted
return "RefCounted" in self.attributes

def isMoveonly(self):
return self.moveonly
return "MoveOnly" in self.attributes


# "singletons"
Expand Down Expand Up @@ -372,6 +375,13 @@ def __str__(self):
return str(self.spec)


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


class QualifiedId: # FIXME inherit from node?
def __init__(self, loc, baseid, quals=[]):
assert isinstance(baseid, str)
Expand Down
57 changes: 42 additions & 15 deletions ipc/ipdl/ipdl/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ def locFromTok(p, num):
"prio",
"protocol",
"refcounted",
"moveonly",
"returns",
"struct",
"sync",
Expand All @@ -160,7 +159,7 @@ def locFromTok(p, num):

t_COLONCOLON = "::"

literals = "(){}[]<>;:,?"
literals = "(){}[]<>;:,?="
t_ignore = " \f\t\v"


Expand Down Expand Up @@ -313,21 +312,14 @@ def p_MaybeRefcounted(p):
p[0] = 2 == len(p)


def p_MaybeMoveOnly(p):
"""MaybeMoveOnly : MOVEONLY
|"""
p[0] = 2 == len(p)


def p_UsingStmt(p):
"""UsingStmt : USING MaybeRefcounted MaybeMoveOnly UsingKind CxxType FROM STRING"""
"""UsingStmt : Attributes USING UsingKind CxxType FROM STRING"""
p[0] = UsingStmt(
locFromTok(p, 1),
refcounted=p[2],
moveonly=p[3],
kind=p[4],
cxxTypeSpec=p[5],
cxxHeader=p[7],
locFromTok(p, 2),
attributes=p[1],
kind=p[3],
cxxTypeSpec=p[4],
cxxHeader=p[6],
)


Expand Down Expand Up @@ -582,6 +574,41 @@ def p_MessageTainted(p):
p[0] = p[1]


# --------------------
# Attributes
def p_Attributes(p):
"""Attributes : '[' AttributeList ']'
|"""
p[0] = {}
if 4 == len(p):
for attr in p[2]:
if attr.name in p[0]:
_error(attr.loc, "Repeated extended attribute `%s'", attr.name)
p[0][attr.name] = attr


def p_AttributeList(p):
"""AttributeList : Attribute ',' AttributeList
| Attribute"""
p[0] = [p[1]]
if 4 == len(p):
p[0] += p[3]


def p_Attribute(p):
"""Attribute : ID AttributeValue"""
p[0] = Attribute(locFromTok(p, 1), p[1], p[2])


def p_AttributeValue(p):
"""AttributeValue : '=' ID
|"""
if 1 == len(p):
p[0] = None
else:
p[0] = p[2]


# --------------------
# Minor stuff
def p_Nested(p):
Expand Down
Loading

0 comments on commit 63fd915

Please sign in to comment.