Make override=1 and pure=1 imply virtual=1 to simplify MethodDecl
Categories
(Core :: IPC, enhancement, P3)
Tracking
()
People
(Reporter: cpeterson, Assigned: cpeterson)
References
Details
Attachments
(3 files)
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Assignee | ||
Comment 4•8 years ago
|
||
![]() |
||
Comment 5•8 years ago
|
||
mozreview-review |
![]() |
||
Comment 6•8 years ago
|
||
mozreview-review |
![]() |
||
Comment 7•8 years ago
|
||
mozreview-review |
Comment 9•8 years ago
|
||
bugherder |
Comment 10•7 years ago
•
|
||
This chunk in ipc/ipdl/ipdl/lower.py makes us output a definition for methods that are marked as pure:
@@ -4887,19 +4893,17 @@ methodDefns."""
cls.stmts[i] = StmtDecl(decl)
defns.addstmts([ defn, Whitespace.NL ])
return cls, defns
def _splitMethodDefn(md, clsname):
saveddecl = deepcopy(md.decl)
md.decl.name = (clsname +'::'+ md.decl.name)
- md.decl.virtual = 0
- md.decl.override = 0
- md.decl.static = 0
+ md.decl.methodspec = MethodSpec.NONE
Note that pure was not set to 0 before, but methodspec is always set to MethodSpec.NONE now. visitMethodDefn checks for MethodSpec.PURE to decide whether to output a definition.
Was that change in behaviour intended?
Assignee | ||
Comment 11•7 years ago
|
||
(In reply to Peter Van der Beken [:peterv] from comment #10)
This chunk in ipc/ipdl/ipdl/lower.py makes us output a definition for methods that are marked as pure:
...
Note that pure was not set to 0 before, but methodspec is always set to MethodSpec.NONE now. visitMethodDefn checks for MethodSpec.PURE to decide whether to output a definition.Was that change in behaviour intended?
Is there a case where _splitMethodDefn() used to produce md.decl.pure == 1 even when md.decl.virtual and md.decl.override were 0?
I haven't looked at this code in a long while, but cgen.py's visitMethodDefn() returns early if md.decl.methodspec == MethodSpec.PURE, so we should not be emitting a pure method definition in C++. Can you share an example of the emitted C++ code?
Comment 12•7 years ago
|
||
(In reply to Chris Peterson [:cpeterson] from comment #11)
Is there a case where _splitMethodDefn() used to produce md.decl.pure == 1 even when md.decl.virtual and md.decl.override were 0?
For any case of md.decl.pure == 1, given that md.decl.virtual and md.decl.override were always explicitly set to 0 here and md.decl.pure wasn't touched.
I haven't looked at this code in a long while, but cgen.py's visitMethodDefn() returns early if md.decl.methodspec == MethodSpec.PURE, so we should not be emitting a pure method definition in C++.
As I pointed out, we now always set md.decl.methodspec to MethodSpec.NONE, never to MethodSpec.PURE.
Can you share an example of the emitted C++ code?
virtual void
ActorDestroy(ActorDestroyReason aWhy) = 0;
https://searchfox.org/mozilla-central/source/__GENERATED__/ipc/ipdl/PMediaParent.cpp#18
auto PMediaParent::ActorDestroy(ActorDestroyReason aWhy) -> void
{
}
Assignee | ||
Comment 13•7 years ago
|
||
(In reply to Peter Van der Beken [:peterv] from comment #12)
(In reply to Chris Peterson [:cpeterson] from comment #11)
Is there a case where _splitMethodDefn() used to produce md.decl.pure == 1 even when md.decl.virtual and md.decl.override were 0?
For any case of md.decl.pure == 1, given that md.decl.virtual and md.decl.override were always explicitly set to 0 here and md.decl.pure wasn't touched.
I see. I'll take a look.
auto PMediaParent::ActorDestroy(ActorDestroyReason aWhy) -> void { }
Defining pure virtual member function is valid C++, but just a waste of space for our use.
Description
•