Skip to content

Commit

Permalink
fix(code-gen/go): fix issues with parameter with a multi inheritance …
Browse files Browse the repository at this point in the history
…constructor order
  • Loading branch information
sruehl committed Sep 26, 2024
1 parent a41bf1c commit fecd3c8
Show file tree
Hide file tree
Showing 1,147 changed files with 2,418 additions and 1,790 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -371,19 +371,14 @@ func (m *_${type.name}) Get${field.name?cap_first}() ${helper.getLanguageTypeNam
// New${type.name} factory function for _${type.name}
<@compress single_line=true>
func New${type.name}(
<#list type.propertyFields as field>
<#assign needsSeparator = false>
<#list type.getAllPropertyFields() as field>
<#assign needsSeparator = true>
${field.name} <#if helper.needsPointerAccess(field)>*</#if>${helper.getLanguageTypeNameForField(field)}
<#sep>, </#sep>
</#list>
<#if type.parentType.isPresent()>
<#if type.propertyFields?has_content && type.parentPropertyFields?has_content>, </#if>
<#list type.parentPropertyFields as parentField>
${parentField.name} <#if helper.needsPointerAccess(parentField)>*</#if>${helper.getLanguageTypeNameForField(parentField)}
<#sep>, </#sep>
</#list>
</#if>
<#if filteredParserArguments?has_content>
<#if type.allPropertyFields?has_content>, </#if>
<#if needsSeparator>, </#if>
<#list filteredParserArguments as parserArgument>
${parserArgument.name} ${helper.getLanguageTypeNameForTypeReference(parserArgument.type)}
<#sep>, </#sep>
Expand Down Expand Up @@ -411,7 +406,28 @@ if ${fieldName} == nil {
</#list>
<#if type.parentType.isPresent()>
_result := &_${type.name}{
${type.parentType.orElseThrow().name}Contract: New${type.parentType.orElseThrow().name}(<#list type.parentPropertyFields as parentField>${parentField.name}<#sep>, </#list><#if filteredParentParserArguments?has_content><#if type.parentPropertyFields?has_content>, </#if><#list filteredParentParserArguments as arg>${arg.name}<#sep>, </#sep></#list></#if>),
<@compress single_line=true>
${type.parentType.orElseThrow().name}Contract:
<#assign needsSeparator = false>
New${type.parentType.orElseThrow().name}(
<#if type.parentPropertyFields?has_content>
<#list type.parentPropertyFields as parentField>
<#assign needsSeparator = true>
${parentField.name}<#sep>, </#sep>
</#list>
</#if>
<#if type.parentType.isPresent() && type.parentType.orElseThrow().allParserArguments.isPresent()>
<#assign filteredParentParserArguments = type.parentType.orElseThrow().allParserArguments.orElseThrow()?filter(arg -> !type.parentType.orElseThrow().asComplexTypeDefinition().orElseThrow().isDiscriminatorField(arg.name))>
<#if filteredParentParserArguments?has_content>
<#if needsSeparator>, </#if>
<#list filteredParentParserArguments as parserArgument>
${parserArgument.name}<#sep>, </#sep>
</#list>
</#if>
</#if>
),
</@compress>

<#list type.propertyFields as field>
${field.name?cap_first}: ${field.name},
</#list>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ public<#if type.isDiscriminatedParentTypeDefinition()> abstract</#if> class ${ty
super(
<#assign needsSeparator = false>
<#if type.parentPropertyFields?has_content>
<#list type.parentPropertyFields as field>
<#list type.parentPropertyFields as parentField>
<#assign needsSeparator = true>
${field.name}<#sep>, </#sep>
${parentField.name}<#sep>, </#sep>
</#list>
</#if>
<#if helper.isGeneratePropertiesForParserArguments()>
Expand Down
40 changes: 30 additions & 10 deletions plc4go/internal/ads/MessageTemplates.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,43 +30,63 @@ func (m *Connection) NewAdsReadDeviceInfoRequest() adsModel.AmsTCPPacket {

func (m *Connection) NewAdsReadRequest(indexGroup uint32, indexOffset uint32, length uint32) adsModel.AmsTCPPacket {
return adsModel.NewAmsTCPPacket(
adsModel.NewAdsReadRequest(indexGroup, indexOffset, length,
adsModel.NewAdsReadRequest(
m.configuration.TargetAmsNetId, m.configuration.TargetAmsPort,
m.configuration.SourceAmsNetId, m.configuration.SourceAmsPort, 0, m.driverContext.getInvokeId()))
m.configuration.SourceAmsNetId, m.configuration.SourceAmsPort,
0,
m.driverContext.getInvokeId(),
indexGroup, indexOffset, length,
),
)
}

func (m *Connection) NewAdsWriteRequest(indexGroup uint32, indexOffset uint32, data []byte) adsModel.AmsTCPPacket {
return adsModel.NewAmsTCPPacket(
adsModel.NewAdsWriteRequest(
indexGroup, indexOffset, data,
m.configuration.TargetAmsNetId, m.configuration.TargetAmsPort,
m.configuration.SourceAmsNetId, m.configuration.SourceAmsPort,
0, m.driverContext.getInvokeId()))
0,
m.driverContext.getInvokeId(),
indexGroup, indexOffset,
data,
),
)
}

func (m *Connection) NewAdsReadWriteRequest(indexGroup uint32, indexOffset uint32, readLength uint32, items []adsModel.AdsMultiRequestItem, writeData []byte) adsModel.AmsTCPPacket {
return adsModel.NewAmsTCPPacket(
adsModel.NewAdsReadWriteRequest(
indexGroup, indexOffset, readLength, items, writeData,
m.configuration.TargetAmsNetId, m.configuration.TargetAmsPort,
m.configuration.SourceAmsNetId, m.configuration.SourceAmsPort,
0, m.driverContext.getInvokeId()))
0,
m.driverContext.getInvokeId(),
indexGroup, indexOffset, readLength, items,
writeData,
),
)
}

func (m *Connection) NewAdsAddDeviceNotificationRequest(indexGroup uint32, indexOffset uint32, length uint32, transmissionMode adsModel.AdsTransMode, maxDelay uint32, cycleTime uint32) adsModel.AmsTCPPacket {
return adsModel.NewAmsTCPPacket(
adsModel.NewAdsAddDeviceNotificationRequest(
indexGroup, indexOffset, length, transmissionMode, maxDelay, cycleTime,
m.configuration.TargetAmsNetId, m.configuration.TargetAmsPort,
m.configuration.SourceAmsNetId, m.configuration.SourceAmsPort,
0, m.driverContext.getInvokeId()))
0,
m.driverContext.getInvokeId(),
indexGroup, indexOffset, length,
transmissionMode, maxDelay, cycleTime,
),
)
}

func (m *Connection) NewAdsDeleteDeviceNotificationRequest(notificationHandle uint32) adsModel.AmsTCPPacket {
return adsModel.NewAmsTCPPacket(
adsModel.NewAdsDeleteDeviceNotificationRequest(
notificationHandle,
m.configuration.TargetAmsNetId, m.configuration.TargetAmsPort,
m.configuration.SourceAmsNetId, m.configuration.SourceAmsPort,
0, m.driverContext.getInvokeId()))
0,
m.driverContext.getInvokeId(),
notificationHandle,
),
)
}
4 changes: 2 additions & 2 deletions plc4go/internal/bacnetip/Discoverer.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ func (d *Discoverer) broadcastAndDiscover(ctx context.Context, communicationChan
objectType = uint16(objectTypeByName)
}
objectIdentifier := driverModel.CreateBACnetContextTagObjectIdentifier(2, objectType, uint32(identifier.instance))
object = driverModel.NewBACnetUnconfirmedServiceRequestWhoHasObjectIdentifier(objectIdentifier, objectIdentifier.GetHeader())
object = driverModel.NewBACnetUnconfirmedServiceRequestWhoHasObjectIdentifier(objectIdentifier.GetHeader(), objectIdentifier)
} else if name := whoHasOptions.object.name; name != nil {
characterString := driverModel.CreateBACnetContextTagCharacterString(3, driverModel.BACnetCharacterEncoding_ISO_10646, *name)
object = driverModel.NewBACnetUnconfirmedServiceRequestWhoHasObjectName(characterString, characterString.GetHeader())
object = driverModel.NewBACnetUnconfirmedServiceRequestWhoHasObjectName(characterString.GetHeader(), characterString)
} else {
panic("Invalid state")
}
Expand Down
Loading

0 comments on commit fecd3c8

Please sign in to comment.