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,
|
||||
args=[ f.initExpr(oexpr) for f in sd.fields ])
|
||||
|
||||
# Struct()
|
||||
defctor = ConstructorDefn(ConstructorDecl(sd.name))
|
||||
defctor.addstmt(StmtExpr(callinit))
|
||||
struct.addstmts([ defctor, Whitespace.NL ])
|
||||
# If this is an empty struct (no fields), then the default ctor
|
||||
# and "create-with-fields" ctors are equivalent. So don't bother
|
||||
# with the default ctor.
|
||||
if len(sd.fields):
|
||||
# Struct()
|
||||
defctor = ConstructorDefn(ConstructorDecl(sd.name))
|
||||
defctor.addstmt(StmtExpr(callinit))
|
||||
struct.addstmts([ defctor, Whitespace.NL ])
|
||||
|
||||
# Struct(const field1& _f1, ...)
|
||||
valctor = ConstructorDefn(ConstructorDecl(sd.name,
|
||||
|
@ -274,8 +274,12 @@ def p_NamespaceThing(p):
|
||||
p[0] = p[4]
|
||||
|
||||
def p_StructDecl(p):
|
||||
"""StructDecl : STRUCT ID '{' StructFields '}' ';'"""
|
||||
p[0] = StructDecl(locFromTok(p, 1), p[2], p[4])
|
||||
"""StructDecl : STRUCT ID '{' StructFields '}' ';'
|
||||
| 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):
|
||||
"""StructFields : StructFields StructField ';'
|
||||
|
Loading…
Reference in New Issue
Block a user