Skip to content

Commit

Permalink
chore: Finished implementing the
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdutz committed Oct 16, 2024
1 parent 436041b commit 952c05a
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void generate(File outputDir, String version, String languageName, String
typeContext.put("languageName", languageName);
typeContext.put("protocolName", protocolName);
typeContext.put("outputFlavor", outputFlavor);
typeContext.put("helper", getHelper(null, protocolName, outputFlavor, types, options, externalTypes));
typeContext.put("helper", getHelper(null, protocolName, outputFlavor, types, externalTypes, options));
typeContext.put("tracer", Tracer.start("global"));
typeContext.putAll(options);

Expand Down Expand Up @@ -129,7 +129,7 @@ public void generate(File outputDir, String version, String languageName, String
typeContext.put("languageName", languageName);
typeContext.put("protocolName", protocolName);
typeContext.put("outputFlavor", outputFlavor);
typeContext.put("helper", getHelper(null, protocolName, outputFlavor, types, options, externalTypes));
typeContext.put("helper", getHelper(null, protocolName, outputFlavor, types, externalTypes, options));
typeContext.putAll(options);

for (Template template : miscTemplateList) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ import (
"context"
"fmt"

"github.com/apache/plc4x/plc4go/spi/utils"
<#if helper.getRequiredImports()?has_content>
<#list helper.getRequiredImports() as import>
${import}
Expand All @@ -68,10 +67,10 @@ import (
${sectionContent}
</#macro>

<#macro emitImport import>${helper.emitDataIoRequiredImport(import)}</#macro>
<#macro emitImportWithAlias alias import>${helper.emitDataIoRequiredImport(alias, import)}</#macro>
<#macro emitImport import>${helper.emitRequiredImport(import)}</#macro>
<#macro emitImportWithAlias alias import>${helper.emitRequiredImport(alias, import)}</#macro>

<@importSectionWithContentBelow><@emitImport import="github.com/apache/plc4x/plc4go/spi/utils" /><@emitImport import="github.com/apache/plc4x/plc4go/spi/values" /><@emitImportWithAlias alias="api" import="github.com/apache/plc4x/plc4go/pkg/api/values" />
<@importSectionWithContentBelow><@emitImport import="github.com/apache/plc4x/plc4go/spi/utils" />
// Code generated by code-generation. DO NOT EDIT.

<#assign baseType><#if type.type.isPresent()>${helper.getLanguageTypeNameForTypeReference(type.type.orElseThrow())}<#else>string</#if></#assign>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,28 @@ ${helper.fileName(protocolName, languageName, outputFlavor)?replace(".", "/")}/P

package ${outputFlavor?replace("-","")}

<#macro importSectionWithContentBelow>
<#local sectionContent><#nested></#local>
import (
"context"

. "github.com/apache/plc4x/plc4go/protocols/${helper.getSanitizedPackageName()}/${outputFlavor?replace("-","")}/model"
"github.com/apache/plc4x/plc4go/spi/utils"
<#if helper.getRequiredImports()?has_content>
<#list helper.getRequiredImports() as import>
${import}
</#list>
</#if>

"github.com/pkg/errors"
)

${sectionContent}
</#macro>

<#macro emitImport import>${helper.emitRequiredImport(import)}</#macro>
<#macro emitImportWithAlias alias import>${helper.emitRequiredImport(alias, import)}</#macro>

<@importSectionWithContentBelow><@emitImport import="github.com/apache/plc4x/plc4go/spi/utils" />
// Code generated by code-generation. DO NOT EDIT.

type ${helper.getSanitizedProtocolName()?cap_first}ParserHelper struct {
Expand Down Expand Up @@ -83,4 +97,6 @@ func (m ${helper.getSanitizedProtocolName()?cap_first}ParserHelper) Parse(typeNa
}
return nil, errors.Errorf("Unsupported type %s", typeName)
}
</@importSectionWithContentBelow>

</#outputformat>
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,30 @@ ${helper.fileName(protocolName, languageName, outputFlavor)?replace(".", "/")}/X

package ${outputFlavor?replace("-","")}

<#macro importSectionWithContentBelow>
<#local sectionContent><#nested></#local>
import (
"context"
"strings"
"strconv"

. "github.com/apache/plc4x/plc4go/protocols/${helper.getSanitizedPackageName()}/${outputFlavor?replace("-","")}/model"
"github.com/apache/plc4x/plc4go/spi/utils"
<#if helper.getRequiredImports()?has_content>
<#list helper.getRequiredImports() as import>
${import}
</#list>
</#if>

"github.com/pkg/errors"
)

${sectionContent}
</#macro>

<#macro emitImport import>${helper.emitRequiredImport(import)}</#macro>
<#macro emitImportWithAlias alias import>${helper.emitRequiredImport(alias, import)}</#macro>

<@importSectionWithContentBelow><@emitImport import="github.com/apache/plc4x/plc4go/spi/utils" />
// Code generated by code-generation. DO NOT EDIT.

type ${helper.getSanitizedProtocolName()?cap_first}XmlParserHelper struct {
Expand Down Expand Up @@ -127,4 +141,6 @@ func (m ${helper.getSanitizedProtocolName()?cap_first}XmlParserHelper) Parse(typ
}
return nil, errors.Errorf("Unsupported type %s", typeName)
}
</@importSectionWithContentBelow>

</#outputformat>
3 changes: 2 additions & 1 deletion plc4go/protocols/ads/readwrite/ParserHelper.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion plc4go/protocols/ads/readwrite/XmlParserHelper.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 952c05a

Please sign in to comment.