mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 753159: Allow empty structs. r=bent
This commit is contained in:
parent
045aefbfce
commit
e52fe0f199
@ -1816,10 +1816,14 @@ def _generateCxxStruct(sd):
|
|||||||
return ExprCall(assignvar,
|
return ExprCall(assignvar,
|
||||||
args=[ f.initExpr(oexpr) for f in sd.fields ])
|
args=[ f.initExpr(oexpr) for f in sd.fields ])
|
||||||
|
|
||||||
# Struct()
|
# If this is an empty struct (no fields), then the default ctor
|
||||||
defctor = ConstructorDefn(ConstructorDecl(sd.name))
|
# and "create-with-fields" ctors are equivalent. So don't bother
|
||||||
defctor.addstmt(StmtExpr(callinit))
|
# with the default ctor.
|
||||||
struct.addstmts([ defctor, Whitespace.NL ])
|
if len(sd.fields):
|
||||||
|
# Struct()
|
||||||
|
defctor = ConstructorDefn(ConstructorDecl(sd.name))
|
||||||
|
defctor.addstmt(StmtExpr(callinit))
|
||||||
|
struct.addstmts([ defctor, Whitespace.NL ])
|
||||||
|
|
||||||
# Struct(const field1& _f1, ...)
|
# Struct(const field1& _f1, ...)
|
||||||
valctor = ConstructorDefn(ConstructorDecl(sd.name,
|
valctor = ConstructorDefn(ConstructorDecl(sd.name,
|
||||||
|
@ -274,8 +274,12 @@ def p_NamespaceThing(p):
|
|||||||
p[0] = p[4]
|
p[0] = p[4]
|
||||||
|
|
||||||
def p_StructDecl(p):
|
def p_StructDecl(p):
|
||||||
"""StructDecl : STRUCT ID '{' StructFields '}' ';'"""
|
"""StructDecl : STRUCT ID '{' StructFields '}' ';'
|
||||||
p[0] = StructDecl(locFromTok(p, 1), p[2], p[4])
|
| STRUCT ID '{' '}' ';'"""
|
||||||
|
if 7 == len(p):
|
||||||
|
p[0] = StructDecl(locFromTok(p, 1), p[2], p[4])
|
||||||
|
else:
|
||||||
|
p[0] = StructDecl(locFromTok(p, 1), p[2], [ ])
|
||||||
|
|
||||||
def p_StructFields(p):
|
def p_StructFields(p):
|
||||||
"""StructFields : StructFields StructField ';'
|
"""StructFields : StructFields StructField ';'
|
||||||
|
Loading…
Reference in New Issue
Block a user