Skip to content

Commit 3f743eb

Browse files
authored
Merge pull request #3222 from ntrel/struct-fmt
[spec/struct.dd] Improve formatting, move AggregateDeclaration Signed-off-by: Dennis <dkorpel@users.noreply.github.com> Merged-on-behalf-of: Dennis <dkorpel@users.noreply.github.com>
2 parents defc5d8 + a2e16fa commit 3f743eb

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed

spec/declaration.dd

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,22 @@ $(GNAME Declaration):
1010
$(GLINK VarDeclarations)
1111
$(GLINK AliasDeclaration)
1212
$(GLINK AliasAssign)
13-
$(GLINK2 struct, AggregateDeclaration)
13+
$(GLINK AggregateDeclaration)
1414
$(GLINK2 enum, EnumDeclaration)
1515
$(GLINK2 module, ImportDeclaration)
1616
$(GLINK2 version, ConditionalDeclaration)
1717
$(GLINK2 version, StaticForeachDeclaration)
1818
$(GLINK2 version, StaticAssert)
1919
)
2020

21+
$(GRAMMAR
22+
$(GNAME AggregateDeclaration):
23+
$(GLINK2 class, ClassDeclaration)
24+
$(GLINK2 interface, InterfaceDeclaration)
25+
$(GLINK2 struct, StructDeclaration)
26+
$(GLINK2 struct, UnionDeclaration)
27+
)
28+
2129
$(GRAMMAR
2230
$(GNAME VarDeclarations):
2331
$(GLINK StorageClasses)$(OPT) $(GLINK2 type, BasicType) $(GLINK Declarators) $(D ;)

spec/struct.dd

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,19 @@ $(SPEC_S Structs and Unions,
44

55
$(HEADERNAV_TOC)
66

7+
$(H2 $(LNAME2 intro, Introduction))
8+
79
$(P Whereas classes are reference types, structs are value types.
810
Structs and unions are simple aggregations of data and their
911
associated operations on that data.
1012
)
1113

1214
$(GRAMMAR
13-
$(GNAME AggregateDeclaration):
14-
$(GLINK2 class, ClassDeclaration)
15-
$(GLINK2 interface, InterfaceDeclaration)
16-
$(GLINK StructDeclaration)
17-
$(GLINK UnionDeclaration)
18-
1915
$(GNAME StructDeclaration):
2016
$(D struct) $(GLINK_LEX Identifier) $(D ;)
2117
$(D struct) $(GLINK_LEX Identifier) $(GLINK AggregateBody)
2218
$(GLINK2 template, StructTemplateDeclaration)
23-
$(GLINK AnonStructDeclaration)
19+
$(I AnonStructDeclaration)
2420

2521
$(GNAME AnonStructDeclaration):
2622
$(D struct) $(GLINK AggregateBody)
@@ -29,7 +25,7 @@ $(GNAME UnionDeclaration):
2925
$(D union) $(GLINK_LEX Identifier) $(D ;)
3026
$(D union) $(GLINK_LEX Identifier) $(GLINK AggregateBody)
3127
$(GLINK2 template, UnionTemplateDeclaration)
32-
$(GLINK AnonUnionDeclaration)
28+
$(I AnonUnionDeclaration)
3329

3430
$(GNAME AnonUnionDeclaration):
3531
$(D union) $(GLINK AggregateBody)
@@ -114,7 +110,7 @@ $(H2 $(LNAME2 POD, Plain Old Data))
114110

115111
$(H2 $(LNAME2 opaque_struct_unions, Opaque Structs and Unions))
116112

117-
$(P Opaque struct and union declarations do not have a $(GLINK AggregateBody):)
113+
$(P Opaque struct and union declarations do not have an $(GLINK AggregateBody):)
118114

119115
---
120116
struct S;
@@ -323,7 +319,7 @@ S t = s; // sets t.a to 3, S.opCall(S) is not called
323319

324320
$(H2 $(LEGACY_LNAME2 StructLiteral, struct-literal, Struct Literals))
325321

326-
$(P Struct literals consist of the name of the struct followed
322+
$(P A struct literal consists of the name of the struct followed
327323
by a parenthesized argument list:)
328324

329325
$(SPEC_RUNNABLE_EXAMPLE_RUN
@@ -360,7 +356,7 @@ $(TROW $(D .sizeof), Size in bytes of struct)
360356
$(TROW $(D .alignof), Size boundary struct needs to be aligned on)
361357
)
362358

363-
$(H2 $(LNAME2 struct_instance_properties, Struct Instance Properties))
359+
$(H3 $(LNAME2 struct_instance_properties, Struct Instance Properties))
364360

365361
$(TABLE2 Struct Instance Properties,
366362
$(THEAD Name, Description)
@@ -369,7 +365,7 @@ $(TROW $(D .tupleof), An $(DDSUBLINK spec/template, variadic-templates, expressi
369365
$(DDSUBLINK spec/class, class_properties, Class Properties) for a class-based example.)
370366
)
371367

372-
$(H2 $(LNAME2 struct_field_properties, Struct Field Properties))
368+
$(H3 $(LNAME2 struct_field_properties, Struct Field Properties))
373369

374370
$(TABLE2 Struct Field Properties,
375371
$(THEAD Name, Description)
@@ -407,8 +403,8 @@ $(H2 $(LEGACY_LNAME2 Struct-Constructor, struct-constructor, Struct Constructors
407403

408404
$(P Struct constructors are used to initialize an instance of a struct when a more
409405
complex construction is needed than is allowed by
410-
$(LINK2 #static_struct_init, static initialization) or a
411-
$(LINK2 #struct-literal, struct literal).
406+
$(RELATIVE_LINK2 static_struct_init, static initialization) or a
407+
$(RELATIVE_LINK2 struct-literal, struct literal).
412408
)
413409

414410
$(P Constructors are defined with a function name of `this` and have no return value.
@@ -728,7 +724,7 @@ $(H3 $(LNAME2 field-init, Field initialization inside a constructor))
728724
---
729725
)
730726

731-
$(P If the field type has an $(LINK2 operatoroverloading.html#assignment, `opAssign`)
727+
$(P If the field type has an $(DDSUBLINK spec/operatoroverloading, assignment, `opAssign`)
732728
method, it will not be used for initialization.)
733729

734730
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
@@ -1549,14 +1545,14 @@ $(GNAME Invariant):
15491545
$(P Struct $(I Invariant)s must hold
15501546
at the entry and exit of all public or exported non-static member functions.
15511547
The order of application of invariants is:
1548+
)
15521549
$(OL
15531550
$(LI preconditions)
15541551
$(LI invariant)
15551552
$(LI function body)
15561553
$(LI invariant)
15571554
$(LI postconditions)
15581555
)
1559-
)
15601556

15611557
$(P The invariant need not hold if the struct instance is implicitly constructed using
15621558
the default $(D .init) value.)
@@ -1666,8 +1662,8 @@ $(H2 $(LEGACY_LNAME2 AssignOverload, assign-overload, Identity Assignment Overlo
16661662
these conditions hold:)
16671663

16681664
$(UL
1669-
$(LI it has a $(LINK2 #struct-destructor, destructor))
1670-
$(LI it has a $(LINK2 #struct-postblit, postblit))
1665+
$(LI it has a $(RELATIVE_LINK2 struct-destructor, destructor))
1666+
$(LI it has a $(RELATIVE_LINK2 struct-postblit, postblit))
16711667
$(LI it has a field with an identity assignment overload)
16721668
)
16731669

0 commit comments

Comments
 (0)