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
Родитель 661b4db5f0
Коммит 86a03e6701
14 изменённых файлов: 54 добавлений и 57 удалений

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -14,7 +14,7 @@ namespace dom {
// 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
// with the parent and should be updated dynamically if necessary.
comparable struct IPCServiceWorkerDescriptor
[Comparable] struct IPCServiceWorkerDescriptor
{
uint64_t id;
uint64_t registrationId;

Просмотреть файл

@ -17,7 +17,7 @@ namespace dom {
// 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
// with the parent and should be updated dynamically if necessary.
comparable struct IPCServiceWorkerRegistrationDescriptor
[Comparable] struct IPCServiceWorkerRegistrationDescriptor
{
uint64_t id;
uint64_t version;

Просмотреть файл

@ -126,7 +126,7 @@ union TimingFunction {
struct LayerColor { DeviceColor value; };
comparable union Animatable {
[Comparable] union Animatable {
null_t;
float;
nscolor;
@ -150,7 +150,7 @@ struct AnimationSegment {
TimingFunction sampleFn;
};
comparable struct MotionPathData {
[Comparable] struct MotionPathData {
// the transform-origin property for motion in css pixels
CSSPoint origin;
// the adjustment for the anchor point of motion path.
@ -158,7 +158,7 @@ comparable struct MotionPathData {
RayReferenceData rayReferenceData;
};
comparable struct PartialPrerenderData {
[Comparable] struct PartialPrerenderData {
LayoutDeviceRect rect;
SideBits overflowedSides;
// 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
// 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
nsPoint origin;
// the transform-origin property for the transform in device pixels
@ -310,7 +310,7 @@ struct LayerAttributes {
};
// See nsIWidget Configurations
comparable struct PluginWindowData {
[Comparable] struct PluginWindowData {
uintptr_t windowId;
LayoutDeviceIntRect[] clip;
LayoutDeviceIntRect bounds;

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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