Skip to content

Commit 9df31ee

Browse files
author
Chris Busbey
committed
fixed gen bug where components were duplicated
1 parent 3768cfe commit 9df31ee

File tree

33 files changed

+726
-2257
lines changed

33 files changed

+726
-2257
lines changed

datadictionary/build.go

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func (b *builder) build(doc *XMLDoc) (*DataDictionary, error) {
4040
return b.dict, nil
4141
}
4242

43-
func (b builder) findOrBuildComponent(xmlMember *XMLComponentMember) (*ComponentType, error) {
43+
func (b builder) findOrBuildComponentType(xmlMember *XMLComponentMember) (*ComponentType, error) {
4444
if comp, preBuilt := b.dict.ComponentTypes[xmlMember.Name]; preBuilt {
4545
return comp, nil
4646
}
@@ -55,7 +55,7 @@ func (b builder) findOrBuildComponent(xmlMember *XMLComponentMember) (*Component
5555
var comp *ComponentType
5656
var err error
5757

58-
if comp, err = b.buildComponent(xmlComp); err != nil {
58+
if comp, err = b.buildComponentType(xmlComp); err != nil {
5959
return nil, err
6060
}
6161

@@ -64,27 +64,32 @@ func (b builder) findOrBuildComponent(xmlMember *XMLComponentMember) (*Component
6464
return comp, nil
6565
}
6666

67-
func (b builder) buildComponent(xmlComponent *XMLComponent) (*ComponentType, error) {
67+
func (b builder) buildComponentType(xmlComponent *XMLComponent) (*ComponentType, error) {
6868
c := &ComponentType{name: xmlComponent.Name}
6969

7070
for _, member := range xmlComponent.Members {
7171
if member.XMLName.Local == "component" {
72-
var childComponent *ComponentType
72+
var childComponentType *ComponentType
7373
var err error
74-
if childComponent, err = b.findOrBuildComponent(member); err != nil {
74+
if childComponentType, err = b.findOrBuildComponentType(member); err != nil {
7575
return nil, err
7676
}
7777

78-
//FIXME
79-
for _, part := range childComponent.Parts {
80-
c.Parts = append(c.Parts, part)
78+
childComponent := Component{
79+
ComponentType: childComponentType,
80+
required: (member.Required == "Y"),
8181
}
82+
83+
c.Parts = append(c.Parts, childComponent)
84+
c.Fields = append(c.Fields, childComponentType.Fields...)
8285
} else {
8386
var field *FieldDef
8487
var err error
8588
if field, err = b.buildFieldDef(member); err != nil {
8689
return nil, err
8790
}
91+
92+
c.Fields = append(c.Fields, field)
8893
c.Parts = append(c.Parts, field)
8994
}
9095
}
@@ -99,7 +104,7 @@ func (b builder) buildComponents() error {
99104
if _, allReadyBuilt := b.dict.ComponentTypes[c.Name]; !allReadyBuilt {
100105
var builtComponent *ComponentType
101106
var err error
102-
if builtComponent, err = b.buildComponent(c); err != nil {
107+
if builtComponent, err = b.buildComponentType(c); err != nil {
103108
return err
104109
}
105110
b.dict.ComponentTypes[c.Name] = builtComponent
@@ -136,12 +141,8 @@ func (b builder) buildMessageDef(xmlMessage *XMLComponent) (*MessageDef, error)
136141
return nil, newUnknownComponent(member.Name)
137142
}
138143

139-
for _, part := range comp.Parts {
140-
switch f := part.(type) {
141-
//FIXME: component?
142-
case *FieldDef:
143-
m.Fields[f.Tag] = f
144-
}
144+
for _, f := range comp.Fields {
145+
m.Fields[f.Tag] = f
145146
}
146147

147148
m.Parts = append(m.Parts, Component{ComponentType: comp, required: (member.Required == "Y")})
@@ -181,7 +182,7 @@ func (b builder) buildGroupFieldDef(xmlField *XMLComponentMember, groupFieldType
181182
if member.XMLName.Local == "component" {
182183
var err error
183184
var comp *ComponentType
184-
if comp, err = b.findOrBuildComponent(member); err != nil {
185+
if comp, err = b.findOrBuildComponentType(member); err != nil {
185186
return nil, err
186187
}
187188

datadictionary/datadictionary.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,12 @@ type MessagePart interface {
2828

2929
//ComponentType is a grouping of fields.
3030
type ComponentType struct {
31-
name string
31+
name string
32+
// MessageParts in declaration order contained in this component
3233
Parts []MessagePart
34+
//All fields contained in this component. Includes fields encapsulated in
35+
//components of this component
36+
Fields []*FieldDef
3337
}
3438

3539
//Name returns the name of this component type

fix44/underlyinginstrument/UnderlyingInstrument.go

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package underlyinginstrument
22

3+
import (
4+
"github.com/quickfixgo/quickfix/fix44/underlyingstipulations"
5+
)
6+
37
//NoUnderlyingSecurityAltID is a repeating group in UnderlyingInstrument
48
type NoUnderlyingSecurityAltID struct {
59
//UnderlyingSecurityAltID is a non-required field for NoUnderlyingSecurityAltID.
@@ -8,14 +12,6 @@ type NoUnderlyingSecurityAltID struct {
812
UnderlyingSecurityAltIDSource *string `fix:"459"`
913
}
1014

11-
//NoUnderlyingStips is a repeating group in UnderlyingInstrument
12-
type NoUnderlyingStips struct {
13-
//UnderlyingStipType is a non-required field for NoUnderlyingStips.
14-
UnderlyingStipType *string `fix:"888"`
15-
//UnderlyingStipValue is a non-required field for NoUnderlyingStips.
16-
UnderlyingStipValue *string `fix:"889"`
17-
}
18-
1915
//UnderlyingInstrument is a fix44 Component
2016
type UnderlyingInstrument struct {
2117
//UnderlyingSymbol is a non-required field for UnderlyingInstrument.
@@ -108,8 +104,8 @@ type UnderlyingInstrument struct {
108104
UnderlyingCurrentValue *float64 `fix:"885"`
109105
//UnderlyingEndValue is a non-required field for UnderlyingInstrument.
110106
UnderlyingEndValue *float64 `fix:"886"`
111-
//NoUnderlyingStips is a non-required field for UnderlyingInstrument.
112-
NoUnderlyingStips []NoUnderlyingStips `fix:"887,omitempty"`
107+
//UnderlyingStipulations Component
108+
underlyingstipulations.UnderlyingStipulations
113109
}
114110

115111
func (m *UnderlyingInstrument) SetUnderlyingSymbol(v string) { m.UnderlyingSymbol = &v }
@@ -169,14 +165,13 @@ func (m *UnderlyingInstrument) SetEncodedUnderlyingSecurityDescLen(v int) {
169165
func (m *UnderlyingInstrument) SetEncodedUnderlyingSecurityDesc(v string) {
170166
m.EncodedUnderlyingSecurityDesc = &v
171167
}
172-
func (m *UnderlyingInstrument) SetUnderlyingCPProgram(v string) { m.UnderlyingCPProgram = &v }
173-
func (m *UnderlyingInstrument) SetUnderlyingCPRegType(v string) { m.UnderlyingCPRegType = &v }
174-
func (m *UnderlyingInstrument) SetUnderlyingCurrency(v string) { m.UnderlyingCurrency = &v }
175-
func (m *UnderlyingInstrument) SetUnderlyingQty(v float64) { m.UnderlyingQty = &v }
176-
func (m *UnderlyingInstrument) SetUnderlyingPx(v float64) { m.UnderlyingPx = &v }
177-
func (m *UnderlyingInstrument) SetUnderlyingDirtyPrice(v float64) { m.UnderlyingDirtyPrice = &v }
178-
func (m *UnderlyingInstrument) SetUnderlyingEndPrice(v float64) { m.UnderlyingEndPrice = &v }
179-
func (m *UnderlyingInstrument) SetUnderlyingStartValue(v float64) { m.UnderlyingStartValue = &v }
180-
func (m *UnderlyingInstrument) SetUnderlyingCurrentValue(v float64) { m.UnderlyingCurrentValue = &v }
181-
func (m *UnderlyingInstrument) SetUnderlyingEndValue(v float64) { m.UnderlyingEndValue = &v }
182-
func (m *UnderlyingInstrument) SetNoUnderlyingStips(v []NoUnderlyingStips) { m.NoUnderlyingStips = v }
168+
func (m *UnderlyingInstrument) SetUnderlyingCPProgram(v string) { m.UnderlyingCPProgram = &v }
169+
func (m *UnderlyingInstrument) SetUnderlyingCPRegType(v string) { m.UnderlyingCPRegType = &v }
170+
func (m *UnderlyingInstrument) SetUnderlyingCurrency(v string) { m.UnderlyingCurrency = &v }
171+
func (m *UnderlyingInstrument) SetUnderlyingQty(v float64) { m.UnderlyingQty = &v }
172+
func (m *UnderlyingInstrument) SetUnderlyingPx(v float64) { m.UnderlyingPx = &v }
173+
func (m *UnderlyingInstrument) SetUnderlyingDirtyPrice(v float64) { m.UnderlyingDirtyPrice = &v }
174+
func (m *UnderlyingInstrument) SetUnderlyingEndPrice(v float64) { m.UnderlyingEndPrice = &v }
175+
func (m *UnderlyingInstrument) SetUnderlyingStartValue(v float64) { m.UnderlyingStartValue = &v }
176+
func (m *UnderlyingInstrument) SetUnderlyingCurrentValue(v float64) { m.UnderlyingCurrentValue = &v }
177+
func (m *UnderlyingInstrument) SetUnderlyingEndValue(v float64) { m.UnderlyingEndValue = &v }

fix50/instrument/Instrument.go

Lines changed: 60 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,11 @@
11
package instrument
22

33
import (
4-
"github.com/quickfixgo/quickfix/fix50/instrumentptyssubgrp"
4+
"github.com/quickfixgo/quickfix/fix50/evntgrp"
5+
"github.com/quickfixgo/quickfix/fix50/instrumentparties"
6+
"github.com/quickfixgo/quickfix/fix50/secaltidgrp"
57
)
68

7-
//NoSecurityAltID is a repeating group in Instrument
8-
type NoSecurityAltID struct {
9-
//SecurityAltID is a non-required field for NoSecurityAltID.
10-
SecurityAltID *string `fix:"455"`
11-
//SecurityAltIDSource is a non-required field for NoSecurityAltID.
12-
SecurityAltIDSource *string `fix:"456"`
13-
}
14-
15-
//NoEvents is a repeating group in Instrument
16-
type NoEvents struct {
17-
//EventType is a non-required field for NoEvents.
18-
EventType *int `fix:"865"`
19-
//EventDate is a non-required field for NoEvents.
20-
EventDate *string `fix:"866"`
21-
//EventPx is a non-required field for NoEvents.
22-
EventPx *float64 `fix:"867"`
23-
//EventText is a non-required field for NoEvents.
24-
EventText *string `fix:"868"`
25-
}
26-
27-
//NoInstrumentParties is a repeating group in Instrument
28-
type NoInstrumentParties struct {
29-
//InstrumentPartyID is a non-required field for NoInstrumentParties.
30-
InstrumentPartyID *string `fix:"1019"`
31-
//InstrumentPartyIDSource is a non-required field for NoInstrumentParties.
32-
InstrumentPartyIDSource *string `fix:"1050"`
33-
//InstrumentPartyRole is a non-required field for NoInstrumentParties.
34-
InstrumentPartyRole *int `fix:"1051"`
35-
//InstrumentPtysSubGrp Component
36-
instrumentptyssubgrp.InstrumentPtysSubGrp
37-
}
38-
399
//Instrument is a fix50 Component
4010
type Instrument struct {
4111
//Symbol is a non-required field for Instrument.
@@ -46,8 +16,8 @@ type Instrument struct {
4616
SecurityID *string `fix:"48"`
4717
//SecurityIDSource is a non-required field for Instrument.
4818
SecurityIDSource *string `fix:"22"`
49-
//NoSecurityAltID is a non-required field for Instrument.
50-
NoSecurityAltID []NoSecurityAltID `fix:"454,omitempty"`
19+
//SecAltIDGrp Component
20+
secaltidgrp.SecAltIDGrp
5121
//Product is a non-required field for Instrument.
5222
Product *int `fix:"460"`
5323
//CFICode is a non-required field for Instrument.
@@ -116,8 +86,8 @@ type Instrument struct {
11686
CPProgram *int `fix:"875"`
11787
//CPRegType is a non-required field for Instrument.
11888
CPRegType *string `fix:"876"`
119-
//NoEvents is a non-required field for Instrument.
120-
NoEvents []NoEvents `fix:"864,omitempty"`
89+
//EvntGrp Component
90+
evntgrp.EvntGrp
12191
//DatedDate is a non-required field for Instrument.
12292
DatedDate *string `fix:"873"`
12393
//InterestAccrualDate is a non-required field for Instrument.
@@ -138,8 +108,8 @@ type Instrument struct {
138108
PositionLimit *int `fix:"970"`
139109
//NTPositionLimit is a non-required field for Instrument.
140110
NTPositionLimit *int `fix:"971"`
141-
//NoInstrumentParties is a non-required field for Instrument.
142-
NoInstrumentParties []NoInstrumentParties `fix:"1018,omitempty"`
111+
//InstrumentParties Component
112+
instrumentparties.InstrumentParties
143113
//UnitOfMeasure is a non-required field for Instrument.
144114
UnitOfMeasure *string `fix:"996"`
145115
//TimeUnit is a non-required field for Instrument.
@@ -148,57 +118,54 @@ type Instrument struct {
148118
MaturityTime *string `fix:"1079"`
149119
}
150120

151-
func (m *Instrument) SetSymbol(v string) { m.Symbol = &v }
152-
func (m *Instrument) SetSymbolSfx(v string) { m.SymbolSfx = &v }
153-
func (m *Instrument) SetSecurityID(v string) { m.SecurityID = &v }
154-
func (m *Instrument) SetSecurityIDSource(v string) { m.SecurityIDSource = &v }
155-
func (m *Instrument) SetNoSecurityAltID(v []NoSecurityAltID) { m.NoSecurityAltID = v }
156-
func (m *Instrument) SetProduct(v int) { m.Product = &v }
157-
func (m *Instrument) SetCFICode(v string) { m.CFICode = &v }
158-
func (m *Instrument) SetSecurityType(v string) { m.SecurityType = &v }
159-
func (m *Instrument) SetSecuritySubType(v string) { m.SecuritySubType = &v }
160-
func (m *Instrument) SetMaturityMonthYear(v string) { m.MaturityMonthYear = &v }
161-
func (m *Instrument) SetMaturityDate(v string) { m.MaturityDate = &v }
162-
func (m *Instrument) SetCouponPaymentDate(v string) { m.CouponPaymentDate = &v }
163-
func (m *Instrument) SetIssueDate(v string) { m.IssueDate = &v }
164-
func (m *Instrument) SetRepoCollateralSecurityType(v int) { m.RepoCollateralSecurityType = &v }
165-
func (m *Instrument) SetRepurchaseTerm(v int) { m.RepurchaseTerm = &v }
166-
func (m *Instrument) SetRepurchaseRate(v float64) { m.RepurchaseRate = &v }
167-
func (m *Instrument) SetFactor(v float64) { m.Factor = &v }
168-
func (m *Instrument) SetCreditRating(v string) { m.CreditRating = &v }
169-
func (m *Instrument) SetInstrRegistry(v string) { m.InstrRegistry = &v }
170-
func (m *Instrument) SetCountryOfIssue(v string) { m.CountryOfIssue = &v }
171-
func (m *Instrument) SetStateOrProvinceOfIssue(v string) { m.StateOrProvinceOfIssue = &v }
172-
func (m *Instrument) SetLocaleOfIssue(v string) { m.LocaleOfIssue = &v }
173-
func (m *Instrument) SetRedemptionDate(v string) { m.RedemptionDate = &v }
174-
func (m *Instrument) SetStrikePrice(v float64) { m.StrikePrice = &v }
175-
func (m *Instrument) SetStrikeCurrency(v string) { m.StrikeCurrency = &v }
176-
func (m *Instrument) SetOptAttribute(v string) { m.OptAttribute = &v }
177-
func (m *Instrument) SetContractMultiplier(v float64) { m.ContractMultiplier = &v }
178-
func (m *Instrument) SetCouponRate(v float64) { m.CouponRate = &v }
179-
func (m *Instrument) SetSecurityExchange(v string) { m.SecurityExchange = &v }
180-
func (m *Instrument) SetIssuer(v string) { m.Issuer = &v }
181-
func (m *Instrument) SetEncodedIssuerLen(v int) { m.EncodedIssuerLen = &v }
182-
func (m *Instrument) SetEncodedIssuer(v string) { m.EncodedIssuer = &v }
183-
func (m *Instrument) SetSecurityDesc(v string) { m.SecurityDesc = &v }
184-
func (m *Instrument) SetEncodedSecurityDescLen(v int) { m.EncodedSecurityDescLen = &v }
185-
func (m *Instrument) SetEncodedSecurityDesc(v string) { m.EncodedSecurityDesc = &v }
186-
func (m *Instrument) SetPool(v string) { m.Pool = &v }
187-
func (m *Instrument) SetContractSettlMonth(v string) { m.ContractSettlMonth = &v }
188-
func (m *Instrument) SetCPProgram(v int) { m.CPProgram = &v }
189-
func (m *Instrument) SetCPRegType(v string) { m.CPRegType = &v }
190-
func (m *Instrument) SetNoEvents(v []NoEvents) { m.NoEvents = v }
191-
func (m *Instrument) SetDatedDate(v string) { m.DatedDate = &v }
192-
func (m *Instrument) SetInterestAccrualDate(v string) { m.InterestAccrualDate = &v }
193-
func (m *Instrument) SetSecurityStatus(v string) { m.SecurityStatus = &v }
194-
func (m *Instrument) SetSettleOnOpenFlag(v string) { m.SettleOnOpenFlag = &v }
195-
func (m *Instrument) SetInstrmtAssignmentMethod(v string) { m.InstrmtAssignmentMethod = &v }
196-
func (m *Instrument) SetStrikeMultiplier(v float64) { m.StrikeMultiplier = &v }
197-
func (m *Instrument) SetStrikeValue(v float64) { m.StrikeValue = &v }
198-
func (m *Instrument) SetMinPriceIncrement(v float64) { m.MinPriceIncrement = &v }
199-
func (m *Instrument) SetPositionLimit(v int) { m.PositionLimit = &v }
200-
func (m *Instrument) SetNTPositionLimit(v int) { m.NTPositionLimit = &v }
201-
func (m *Instrument) SetNoInstrumentParties(v []NoInstrumentParties) { m.NoInstrumentParties = v }
202-
func (m *Instrument) SetUnitOfMeasure(v string) { m.UnitOfMeasure = &v }
203-
func (m *Instrument) SetTimeUnit(v string) { m.TimeUnit = &v }
204-
func (m *Instrument) SetMaturityTime(v string) { m.MaturityTime = &v }
121+
func (m *Instrument) SetSymbol(v string) { m.Symbol = &v }
122+
func (m *Instrument) SetSymbolSfx(v string) { m.SymbolSfx = &v }
123+
func (m *Instrument) SetSecurityID(v string) { m.SecurityID = &v }
124+
func (m *Instrument) SetSecurityIDSource(v string) { m.SecurityIDSource = &v }
125+
func (m *Instrument) SetProduct(v int) { m.Product = &v }
126+
func (m *Instrument) SetCFICode(v string) { m.CFICode = &v }
127+
func (m *Instrument) SetSecurityType(v string) { m.SecurityType = &v }
128+
func (m *Instrument) SetSecuritySubType(v string) { m.SecuritySubType = &v }
129+
func (m *Instrument) SetMaturityMonthYear(v string) { m.MaturityMonthYear = &v }
130+
func (m *Instrument) SetMaturityDate(v string) { m.MaturityDate = &v }
131+
func (m *Instrument) SetCouponPaymentDate(v string) { m.CouponPaymentDate = &v }
132+
func (m *Instrument) SetIssueDate(v string) { m.IssueDate = &v }
133+
func (m *Instrument) SetRepoCollateralSecurityType(v int) { m.RepoCollateralSecurityType = &v }
134+
func (m *Instrument) SetRepurchaseTerm(v int) { m.RepurchaseTerm = &v }
135+
func (m *Instrument) SetRepurchaseRate(v float64) { m.RepurchaseRate = &v }
136+
func (m *Instrument) SetFactor(v float64) { m.Factor = &v }
137+
func (m *Instrument) SetCreditRating(v string) { m.CreditRating = &v }
138+
func (m *Instrument) SetInstrRegistry(v string) { m.InstrRegistry = &v }
139+
func (m *Instrument) SetCountryOfIssue(v string) { m.CountryOfIssue = &v }
140+
func (m *Instrument) SetStateOrProvinceOfIssue(v string) { m.StateOrProvinceOfIssue = &v }
141+
func (m *Instrument) SetLocaleOfIssue(v string) { m.LocaleOfIssue = &v }
142+
func (m *Instrument) SetRedemptionDate(v string) { m.RedemptionDate = &v }
143+
func (m *Instrument) SetStrikePrice(v float64) { m.StrikePrice = &v }
144+
func (m *Instrument) SetStrikeCurrency(v string) { m.StrikeCurrency = &v }
145+
func (m *Instrument) SetOptAttribute(v string) { m.OptAttribute = &v }
146+
func (m *Instrument) SetContractMultiplier(v float64) { m.ContractMultiplier = &v }
147+
func (m *Instrument) SetCouponRate(v float64) { m.CouponRate = &v }
148+
func (m *Instrument) SetSecurityExchange(v string) { m.SecurityExchange = &v }
149+
func (m *Instrument) SetIssuer(v string) { m.Issuer = &v }
150+
func (m *Instrument) SetEncodedIssuerLen(v int) { m.EncodedIssuerLen = &v }
151+
func (m *Instrument) SetEncodedIssuer(v string) { m.EncodedIssuer = &v }
152+
func (m *Instrument) SetSecurityDesc(v string) { m.SecurityDesc = &v }
153+
func (m *Instrument) SetEncodedSecurityDescLen(v int) { m.EncodedSecurityDescLen = &v }
154+
func (m *Instrument) SetEncodedSecurityDesc(v string) { m.EncodedSecurityDesc = &v }
155+
func (m *Instrument) SetPool(v string) { m.Pool = &v }
156+
func (m *Instrument) SetContractSettlMonth(v string) { m.ContractSettlMonth = &v }
157+
func (m *Instrument) SetCPProgram(v int) { m.CPProgram = &v }
158+
func (m *Instrument) SetCPRegType(v string) { m.CPRegType = &v }
159+
func (m *Instrument) SetDatedDate(v string) { m.DatedDate = &v }
160+
func (m *Instrument) SetInterestAccrualDate(v string) { m.InterestAccrualDate = &v }
161+
func (m *Instrument) SetSecurityStatus(v string) { m.SecurityStatus = &v }
162+
func (m *Instrument) SetSettleOnOpenFlag(v string) { m.SettleOnOpenFlag = &v }
163+
func (m *Instrument) SetInstrmtAssignmentMethod(v string) { m.InstrmtAssignmentMethod = &v }
164+
func (m *Instrument) SetStrikeMultiplier(v float64) { m.StrikeMultiplier = &v }
165+
func (m *Instrument) SetStrikeValue(v float64) { m.StrikeValue = &v }
166+
func (m *Instrument) SetMinPriceIncrement(v float64) { m.MinPriceIncrement = &v }
167+
func (m *Instrument) SetPositionLimit(v int) { m.PositionLimit = &v }
168+
func (m *Instrument) SetNTPositionLimit(v int) { m.NTPositionLimit = &v }
169+
func (m *Instrument) SetUnitOfMeasure(v string) { m.UnitOfMeasure = &v }
170+
func (m *Instrument) SetTimeUnit(v string) { m.TimeUnit = &v }
171+
func (m *Instrument) SetMaturityTime(v string) { m.MaturityTime = &v }

0 commit comments

Comments
 (0)