Bug 1689147 - Part 5: Change comparable to an extended attribute, r=mccr8

Differential Revision: https://phabricator.services.mozilla.com/D103370
This commit is contained in:
Nika Layzell 2021-02-09 16:50:23 +00:00
parent 661b4db5f0
commit 86a03e6701
14 changed files with 54 additions and 57 deletions

View File

@ -31,7 +31,7 @@ struct ClientSourceConstructorArgs
TimeStamp creationTime; TimeStamp creationTime;
}; };
comparable struct IPCClientInfo [Comparable] struct IPCClientInfo
{ {
nsID id; nsID id;
nsID? agentClusterId; nsID? agentClusterId;

View File

@ -9,7 +9,7 @@ using mozilla::TimeStamp from "mozilla/TimeStamp.h";
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
comparable struct MIDIPortInfo { [Comparable] struct MIDIPortInfo {
nsString id; nsString id;
nsString name; nsString name;
nsString manufacturer; nsString manufacturer;

View File

@ -14,7 +14,7 @@ namespace dom {
// IPC type with enough information to create a ServiceWorker DOM object // IPC type with enough information to create a ServiceWorker DOM object
// in a child process. Note that the state may be slightly out-of-sync // in a child process. Note that the state may be slightly out-of-sync
// with the parent and should be updated dynamically if necessary. // with the parent and should be updated dynamically if necessary.
comparable struct IPCServiceWorkerDescriptor [Comparable] struct IPCServiceWorkerDescriptor
{ {
uint64_t id; uint64_t id;
uint64_t registrationId; uint64_t registrationId;

View File

@ -17,7 +17,7 @@ namespace dom {
// IPC type with enough information to create a ServiceWorker DOM object // IPC type with enough information to create a ServiceWorker DOM object
// in a child process. Note that the state may be slightly out-of-sync // in a child process. Note that the state may be slightly out-of-sync
// with the parent and should be updated dynamically if necessary. // with the parent and should be updated dynamically if necessary.
comparable struct IPCServiceWorkerRegistrationDescriptor [Comparable] struct IPCServiceWorkerRegistrationDescriptor
{ {
uint64_t id; uint64_t id;
uint64_t version; uint64_t version;

View File

@ -126,7 +126,7 @@ union TimingFunction {
struct LayerColor { DeviceColor value; }; struct LayerColor { DeviceColor value; };
comparable union Animatable { [Comparable] union Animatable {
null_t; null_t;
float; float;
nscolor; nscolor;
@ -150,7 +150,7 @@ struct AnimationSegment {
TimingFunction sampleFn; TimingFunction sampleFn;
}; };
comparable struct MotionPathData { [Comparable] struct MotionPathData {
// the transform-origin property for motion in css pixels // the transform-origin property for motion in css pixels
CSSPoint origin; CSSPoint origin;
// the adjustment for the anchor point of motion path. // the adjustment for the anchor point of motion path.
@ -158,7 +158,7 @@ comparable struct MotionPathData {
RayReferenceData rayReferenceData; RayReferenceData rayReferenceData;
}; };
comparable struct PartialPrerenderData { [Comparable] struct PartialPrerenderData {
LayoutDeviceRect rect; LayoutDeviceRect rect;
SideBits overflowedSides; SideBits overflowedSides;
// the scroll id of the nearest scrollable frame of this partial prerender // the scroll id of the nearest scrollable frame of this partial prerender
@ -177,7 +177,7 @@ comparable struct PartialPrerenderData {
// Transforms need extra information to correctly convert the list of transform // Transforms need extra information to correctly convert the list of transform
// functions to a Matrix4x4 that can be applied directly to the layer. // functions to a Matrix4x4 that can be applied directly to the layer.
comparable struct TransformData { [Comparable] struct TransformData {
// the origin of the frame being transformed in app units // the origin of the frame being transformed in app units
nsPoint origin; nsPoint origin;
// the transform-origin property for the transform in device pixels // the transform-origin property for the transform in device pixels
@ -310,7 +310,7 @@ struct LayerAttributes {
}; };
// See nsIWidget Configurations // See nsIWidget Configurations
comparable struct PluginWindowData { [Comparable] struct PluginWindowData {
uintptr_t windowId; uintptr_t windowId;
LayoutDeviceIntRect[] clip; LayoutDeviceIntRect[] clip;
LayoutDeviceIntRect bounds; LayoutDeviceIntRect bounds;

View File

@ -23,18 +23,18 @@ using mozilla::layers::MaybeVideoBridgeSource from "mozilla/layers/VideoBridgeUt
namespace mozilla { namespace mozilla {
namespace layers { namespace layers {
comparable struct SurfaceDescriptorFileMapping { [Comparable] struct SurfaceDescriptorFileMapping {
WindowsHandle handle; WindowsHandle handle;
SurfaceFormat format; SurfaceFormat format;
IntSize size; IntSize size;
}; };
comparable struct SurfaceDescriptorDIB { [Comparable] struct SurfaceDescriptorDIB {
// gfxWindowsSurface* // gfxWindowsSurface*
uintptr_t surface; uintptr_t surface;
}; };
comparable struct SurfaceDescriptorD3D10 { [Comparable] struct SurfaceDescriptorD3D10 {
WindowsHandle handle; WindowsHandle handle;
SurfaceFormat format; SurfaceFormat format;
IntSize size; IntSize size;
@ -42,7 +42,7 @@ comparable struct SurfaceDescriptorD3D10 {
ColorRange colorRange; ColorRange colorRange;
}; };
comparable struct SurfaceDescriptorDXGIYCbCr { [Comparable] struct SurfaceDescriptorDXGIYCbCr {
WindowsHandle handleY; WindowsHandle handleY;
WindowsHandle handleCb; WindowsHandle handleCb;
WindowsHandle handleCr; WindowsHandle handleCr;
@ -54,14 +54,14 @@ comparable struct SurfaceDescriptorDXGIYCbCr {
ColorRange colorRange; ColorRange colorRange;
}; };
comparable struct SurfaceDescriptorMacIOSurface { [Comparable] struct SurfaceDescriptorMacIOSurface {
uint32_t surfaceId; uint32_t surfaceId;
double scaleFactor; double scaleFactor;
bool isOpaque; bool isOpaque;
YUVColorSpace yUVColorSpace; YUVColorSpace yUVColorSpace;
}; };
comparable struct SurfaceDescriptorDMABuf { [Comparable] struct SurfaceDescriptorDMABuf {
uint32_t bufferType; uint32_t bufferType;
uint64_t modifier; uint64_t modifier;
uint32_t flags; uint32_t flags;
@ -77,7 +77,7 @@ comparable struct SurfaceDescriptorDMABuf {
FileDescriptor[] refCount; FileDescriptor[] refCount;
}; };
comparable struct SurfaceTextureDescriptor { [Comparable] struct SurfaceTextureDescriptor {
uint64_t handle; uint64_t handle;
IntSize size; IntSize size;
SurfaceFormat format; SurfaceFormat format;
@ -85,21 +85,21 @@ comparable struct SurfaceTextureDescriptor {
bool ignoreTransform; bool ignoreTransform;
}; };
comparable struct SurfaceDescriptorAndroidHardwareBuffer { [Comparable] struct SurfaceDescriptorAndroidHardwareBuffer {
FileDescriptor handle; FileDescriptor handle;
uint64_t bufferId; uint64_t bufferId;
IntSize size; IntSize size;
SurfaceFormat format; SurfaceFormat format;
}; };
comparable struct EGLImageDescriptor { [Comparable] struct EGLImageDescriptor {
uintptr_t image; // `EGLImage` is a `void*`. uintptr_t image; // `EGLImage` is a `void*`.
uintptr_t fence; uintptr_t fence;
IntSize size; IntSize size;
bool hasAlpha; bool hasAlpha;
}; };
comparable struct SurfaceDescriptorSharedGLTexture { [Comparable] struct SurfaceDescriptorSharedGLTexture {
uint32_t texture; uint32_t texture;
uint32_t target; uint32_t target;
uintptr_t fence; uintptr_t fence;
@ -108,7 +108,7 @@ comparable struct SurfaceDescriptorSharedGLTexture {
}; };
comparable union RemoteDecoderVideoSubDescriptor { [Comparable] union RemoteDecoderVideoSubDescriptor {
SurfaceDescriptorD3D10; SurfaceDescriptorD3D10;
SurfaceDescriptorDXGIYCbCr; SurfaceDescriptorDXGIYCbCr;
SurfaceDescriptorDMABuf; SurfaceDescriptorDMABuf;
@ -116,30 +116,30 @@ comparable union RemoteDecoderVideoSubDescriptor {
null_t; null_t;
}; };
comparable struct SurfaceDescriptorRemoteDecoder { [Comparable] struct SurfaceDescriptorRemoteDecoder {
uint64_t handle; uint64_t handle;
RemoteDecoderVideoSubDescriptor subdesc; RemoteDecoderVideoSubDescriptor subdesc;
MaybeVideoBridgeSource source; MaybeVideoBridgeSource source;
}; };
comparable struct SurfaceDescriptorPlugin { [Comparable] struct SurfaceDescriptorPlugin {
uint64_t id; uint64_t id;
SurfaceDescriptorD3D10 pluginSurf; SurfaceDescriptorD3D10 pluginSurf;
SurfaceDescriptorD3D10 displaySurf; SurfaceDescriptorD3D10 displaySurf;
}; };
comparable union SurfaceDescriptorGPUVideo { [Comparable] union SurfaceDescriptorGPUVideo {
SurfaceDescriptorRemoteDecoder; SurfaceDescriptorRemoteDecoder;
SurfaceDescriptorPlugin; SurfaceDescriptorPlugin;
}; };
comparable struct RGBDescriptor { [Comparable] struct RGBDescriptor {
IntSize size; IntSize size;
SurfaceFormat format; SurfaceFormat format;
bool hasIntermediateBuffer; bool hasIntermediateBuffer;
}; };
comparable struct YCbCrDescriptor { [Comparable] struct YCbCrDescriptor {
IntRect display; IntRect display;
IntSize ySize; IntSize ySize;
uint32_t yStride; uint32_t yStride;
@ -155,22 +155,22 @@ comparable struct YCbCrDescriptor {
bool hasIntermediateBuffer; bool hasIntermediateBuffer;
}; };
comparable union BufferDescriptor { [Comparable] union BufferDescriptor {
RGBDescriptor; RGBDescriptor;
YCbCrDescriptor; YCbCrDescriptor;
}; };
comparable union MemoryOrShmem { [Comparable] union MemoryOrShmem {
uintptr_t; uintptr_t;
Shmem; Shmem;
}; };
comparable struct SurfaceDescriptorBuffer { [Comparable] struct SurfaceDescriptorBuffer {
BufferDescriptor desc; BufferDescriptor desc;
MemoryOrShmem data; MemoryOrShmem data;
}; };
comparable struct SurfaceDescriptorShared [Comparable] struct SurfaceDescriptorShared
{ {
IntSize size; IntSize size;
int32_t stride; int32_t stride;
@ -178,11 +178,11 @@ comparable struct SurfaceDescriptorShared
Handle handle; Handle handle;
}; };
comparable struct SurfaceDescriptorRecorded { [Comparable] struct SurfaceDescriptorRecorded {
int64_t textureId; int64_t textureId;
}; };
comparable union SurfaceDescriptor { [Comparable] union SurfaceDescriptor {
SurfaceDescriptorBuffer; SurfaceDescriptorBuffer;
SurfaceDescriptorDIB; SurfaceDescriptorDIB;
SurfaceDescriptorD3D10; SurfaceDescriptorD3D10;

View File

@ -8,14 +8,14 @@ using struct mozilla::void_t from "mozilla/ipc/IPCCore.h";
namespace mozilla { namespace mozilla {
namespace ipc { namespace ipc {
comparable struct ContentSecurityPolicy [Comparable] struct ContentSecurityPolicy
{ {
nsString policy; nsString policy;
bool reportOnlyFlag; bool reportOnlyFlag;
bool deliveredViaMetaTagFlag; bool deliveredViaMetaTagFlag;
}; };
comparable struct ContentPrincipalInfo [Comparable] struct ContentPrincipalInfo
{ {
OriginAttributes attrs; OriginAttributes attrs;
@ -36,22 +36,22 @@ comparable struct ContentPrincipalInfo
nsCString baseDomain; nsCString baseDomain;
}; };
comparable struct SystemPrincipalInfo [Comparable] struct SystemPrincipalInfo
{ }; { };
comparable struct NullPrincipalInfo [Comparable] struct NullPrincipalInfo
{ {
OriginAttributes attrs; OriginAttributes attrs;
nsCString spec; nsCString spec;
}; };
comparable struct ExpandedPrincipalInfo [Comparable] struct ExpandedPrincipalInfo
{ {
OriginAttributes attrs; OriginAttributes attrs;
PrincipalInfo[] allowlist; PrincipalInfo[] allowlist;
}; };
comparable union PrincipalInfo [Comparable] union PrincipalInfo
{ {
ContentPrincipalInfo; ContentPrincipalInfo;
SystemPrincipalInfo; SystemPrincipalInfo;
@ -59,7 +59,7 @@ comparable union PrincipalInfo
ExpandedPrincipalInfo; ExpandedPrincipalInfo;
}; };
comparable struct CSPInfo [Comparable] struct CSPInfo
{ {
ContentSecurityPolicy[] policyInfos; ContentSecurityPolicy[] policyInfos;
PrincipalInfo requestPrincipalInfo; PrincipalInfo requestPrincipalInfo;

View File

@ -286,10 +286,10 @@ class StructField(Node):
class StructDecl(NamespacedNode): class StructDecl(NamespacedNode):
def __init__(self, loc, name, fields, comparable): def __init__(self, loc, name, fields, attributes):
NamespacedNode.__init__(self, loc, name) NamespacedNode.__init__(self, loc, name)
self.fields = fields self.fields = fields
self.comparable = comparable self.attributes = attributes
# A list of indices into `fields` for determining the order in # A list of indices into `fields` for determining the order in
# which fields are laid out in memory. We don't just reorder # which fields are laid out in memory. We don't just reorder
# `fields` itself so as to keep the ordering reasonably stable # `fields` itself so as to keep the ordering reasonably stable
@ -298,10 +298,10 @@ class StructDecl(NamespacedNode):
class UnionDecl(NamespacedNode): class UnionDecl(NamespacedNode):
def __init__(self, loc, name, components, comparable): def __init__(self, loc, name, components, attributes):
NamespacedNode.__init__(self, loc, name) NamespacedNode.__init__(self, loc, name)
self.components = components self.components = components
self.comparable = comparable self.attributes = attributes
class Manager(Node): class Manager(Node):

View File

@ -2674,7 +2674,7 @@ def _generateCxxStruct(sd):
# The default copy, move, and assignment constructors, and the default # The default copy, move, and assignment constructors, and the default
# destructor, will do the right thing. # destructor, will do the right thing.
if sd.comparable: if "Comparable" in sd.attributes:
# bool operator==(const Struct& _o) # bool operator==(const Struct& _o)
ovar = ExprVar("_o") ovar = ExprVar("_o")
opeqeq = MethodDefn( opeqeq = MethodDefn(
@ -3272,7 +3272,7 @@ def _generateCxxUnion(ud):
) )
cls.addstmts([opeq, Whitespace.NL]) cls.addstmts([opeq, Whitespace.NL])
if ud.comparable: if "Comparable" in ud.attributes:
# bool operator==(const T&) # bool operator==(const T&)
for c in ud.components: for c in ud.components:
opeqeq = MethodDefn( opeqeq = MethodDefn(

View File

@ -124,7 +124,6 @@ reserved = set(
"both", "both",
"child", "child",
"class", "class",
"comparable",
"from", "from",
"include", "include",
"intr", "intr",
@ -295,12 +294,6 @@ def p_UsingKind(p):
p[0] = p[1] if 2 == len(p) else None p[0] = p[1] if 2 == len(p) else None
def p_MaybeComparable(p):
"""MaybeComparable : COMPARABLE
|"""
p[0] = 2 == len(p)
def p_MaybeRefcounted(p): def p_MaybeRefcounted(p):
"""MaybeRefcounted : REFCOUNTED """MaybeRefcounted : REFCOUNTED
|""" |"""
@ -346,8 +339,8 @@ def p_NamespaceThing(p):
def p_StructDecl(p): def p_StructDecl(p):
"""StructDecl : MaybeComparable STRUCT ID '{' StructFields '}' ';' """StructDecl : Attributes STRUCT ID '{' StructFields '}' ';'
| MaybeComparable STRUCT ID '{' '}' ';'""" | Attributes STRUCT ID '{' '}' ';'"""
if 8 == len(p): if 8 == len(p):
p[0] = StructDecl(locFromTok(p, 2), p[3], p[5], p[1]) p[0] = StructDecl(locFromTok(p, 2), p[3], p[5], p[1])
else: else:
@ -370,7 +363,7 @@ def p_StructField(p):
def p_UnionDecl(p): def p_UnionDecl(p):
"""UnionDecl : MaybeComparable UNION ID '{' ComponentTypes '}' ';'""" """UnionDecl : Attributes UNION ID '{' ComponentTypes '}' ';'"""
p[0] = UnionDecl(locFromTok(p, 2), p[3], p[5], p[1]) p[0] = UnionDecl(locFromTok(p, 2), p[3], p[5], p[1])

View File

@ -1049,6 +1049,8 @@ class GatherDecls(TcheckVisitor):
self.symtab.enterScope() self.symtab.enterScope()
sd.visited = True sd.visited = True
self.checkAttributes(sd.attributes, {"Comparable": None})
for f in sd.fields: for f in sd.fields:
ftypedecl = self.symtab.lookup(str(f.typespec)) ftypedecl = self.symtab.lookup(str(f.typespec))
if ftypedecl is None: if ftypedecl is None:
@ -1078,6 +1080,8 @@ class GatherDecls(TcheckVisitor):
if len(utype.components): if len(utype.components):
return return
self.checkAttributes(ud.attributes, {"Comparable": None})
for c in ud.components: for c in ud.components:
cdecl = self.symtab.lookup(str(c)) cdecl = self.symtab.lookup(str(c))
if cdecl is None: if cdecl is None:

View File

@ -1,4 +1,4 @@
comparable struct S { [Comparable] struct S {
int i; int i;
double d; double d;
}; };

View File

@ -1,4 +1,4 @@
comparable union Basic { [Comparable] union Basic {
int; int;
double; double;
}; };

View File

@ -16,7 +16,7 @@ struct LookAndFeelInt {
int32_t value; int32_t value;
}; };
comparable struct LookAndFeelFont { [Comparable] struct LookAndFeelFont {
bool haveFont; bool haveFont;
nsString name; nsString name;
float size; float size;