mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 921563 - part 1 - declare return types in IPDL C++ with C++0x late return syntax; r=gps
Every IPDL C++ class contains a bunch of typedefs. Every IPDL C++ source file contains a bunch of typedefs and using statements for the exact same types. Why is that? Because the class itself is not in scope for name lookup of return types of C++ methods. This limitation is annoying, but it makes sense. The typedefs and using statements therefore exist so we can be a little sloppy about return types. Let's stop being sloppy and polluting the global namespace inside these files. Less pollution makes it easier to smash the IPDL files together for unified compilation. One could do this by qualifying all necessary return types...or we could just use the C++0x late return syntax, which guarantees the class *is* in scope for name lookup. I like this version a lot better.
This commit is contained in:
parent
ad1469a2d1
commit
9126a16e06
@ -478,6 +478,7 @@ class MethodDecl(Node):
|
||||
self.never_inline = never_inline # bool
|
||||
self.typeop = typeop # Type or None
|
||||
self.T = T # Type or None
|
||||
self.only_for_definition = False
|
||||
|
||||
def __deepcopy__(self, memo):
|
||||
return MethodDecl(
|
||||
|
@ -189,6 +189,9 @@ class CxxCodeGen(CodePrinter, Visitor):
|
||||
if md.virtual:
|
||||
self.write('virtual ')
|
||||
if md.ret:
|
||||
if md.only_for_definition:
|
||||
self.write('auto ')
|
||||
else:
|
||||
md.ret.accept(self)
|
||||
self.println()
|
||||
self.printdent()
|
||||
@ -204,6 +207,9 @@ class CxxCodeGen(CodePrinter, Visitor):
|
||||
|
||||
if md.const:
|
||||
self.write(' const')
|
||||
if md.ret and md.only_for_definition:
|
||||
self.write(' -> ')
|
||||
md.ret.accept(self)
|
||||
if md.warn_unused:
|
||||
self.write(' NS_WARN_UNUSED_RESULT')
|
||||
if md.pure:
|
||||
|
@ -5316,6 +5316,7 @@ def _splitMethodDefn(md, clsname):
|
||||
md.decl.static = 0
|
||||
md.decl.warn_unused = 0
|
||||
md.decl.never_inline = 0
|
||||
md.decl.only_for_definition = True
|
||||
for param in md.decl.params:
|
||||
if isinstance(param, Param):
|
||||
param.default = None
|
||||
|
Loading…
Reference in New Issue
Block a user