Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove support for var-args in plc4j #1739

Merged
merged 2 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -580,32 +580,6 @@ public<#if type.isDiscriminatedParentTypeDefinition()> abstract</#if> class ${ty
return lengthInBits;
}

<#-- The parse and serialize methods here are just proxies for forwardning the requests to static counterparts -->
<#if !type.isDiscriminatedChildTypeDefinition()>
public static ${type.name} staticParse(ReadBuffer readBuffer, Object... args) throws ParseException {
PositionAware positionAware = readBuffer;
<#if parserArguments?has_content>
if((args == null) || (args.length != ${parserArguments?size})) {
throw new PlcRuntimeException("Wrong number of arguments, expected ${parserArguments?size}, but got " + args.length);
}
<#list parserArguments as parserArgument>
<#assign languageName=helper.getLanguageTypeNameForTypeReference(parserArgument.type, false)>
${languageName} ${parserArgument.name};
if(args[${parserArgument?index}] instanceof ${languageName}) {
${parserArgument.name} = (${languageName}) args[${parserArgument?index}];
<#if parserArgument.type.isSimpleTypeReference() || parserArgument.type.isEnumTypeReference()>
} else if (args[${parserArgument?index}] instanceof String) {
${parserArgument.name} = ${languageName}.valueOf((String) args[${parserArgument?index}]);
</#if>
} else {
throw new PlcRuntimeException("Argument ${parserArgument?index} expected to be of type ${languageName} or a string which is parseable but was " + args[${parserArgument?index}].getClass().getName());
}
</#list>
</#if>
return staticParse(readBuffer<#if parserArguments?has_content>, <#list parserArguments as parserArgument>${parserArgument.name}<#sep>, </#sep></#list></#if>);
}

</#if>
<#-- Here come the actual parse and serialize methods that actually do the parsing and serlaizing -->
<#assign hasParserArguments=parserArguments?has_content/>
<#assign parserArgumentList><#if hasParserArguments><#list parserArguments as parserArgument>${helper.getLanguageTypeNameForTypeReference(parserArgument.type, false)} ${parserArgument.name}<#sep>, </#sep></#list></#if></#assign>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,6 @@ public int getLengthInBits() {
return lengthInBits;
}

public static CIPEncapsulationPacket staticParse(ReadBuffer readBuffer, Object... args)
throws ParseException {
PositionAware positionAware = readBuffer;
return staticParse(readBuffer);
}

public static CIPEncapsulationPacket staticParse(ReadBuffer readBuffer) throws ParseException {
readBuffer.pullContext("CIPEncapsulationPacket");
PositionAware positionAware = readBuffer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,6 @@ public int getLengthInBits() {
return lengthInBits;
}

public static DF1RequestCommand staticParse(ReadBuffer readBuffer, Object... args)
throws ParseException {
PositionAware positionAware = readBuffer;
return staticParse(readBuffer);
}

public static DF1RequestCommand staticParse(ReadBuffer readBuffer) throws ParseException {
readBuffer.pullContext("DF1RequestCommand");
PositionAware positionAware = readBuffer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,6 @@ public int getLengthInBits() {
return lengthInBits;
}

public static DF1RequestMessage staticParse(ReadBuffer readBuffer, Object... args)
throws ParseException {
PositionAware positionAware = readBuffer;
return staticParse(readBuffer);
}

public static DF1RequestMessage staticParse(ReadBuffer readBuffer) throws ParseException {
readBuffer.pullContext("DF1RequestMessage");
PositionAware positionAware = readBuffer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,26 +143,6 @@ public int getLengthInBits() {
return lengthInBits;
}

public static DF1ResponseMessage staticParse(ReadBuffer readBuffer, Object... args)
throws ParseException {
PositionAware positionAware = readBuffer;
if ((args == null) || (args.length != 1)) {
throw new PlcRuntimeException(
"Wrong number of arguments, expected 1, but got " + args.length);
}
Integer payloadLength;
if (args[0] instanceof Integer) {
payloadLength = (Integer) args[0];
} else if (args[0] instanceof String) {
payloadLength = Integer.valueOf((String) args[0]);
} else {
throw new PlcRuntimeException(
"Argument 0 expected to be of type Integer or a string which is parseable but was "
+ args[0].getClass().getName());
}
return staticParse(readBuffer, payloadLength);
}

public static DF1ResponseMessage staticParse(ReadBuffer readBuffer, Integer payloadLength)
throws ParseException {
readBuffer.pullContext("DF1ResponseMessage");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,6 @@ public int getLengthInBits() {
return lengthInBits;
}

public static AdsDiscovery staticParse(ReadBuffer readBuffer, Object... args)
throws ParseException {
PositionAware positionAware = readBuffer;
return staticParse(readBuffer);
}

public static AdsDiscovery staticParse(ReadBuffer readBuffer) throws ParseException {
readBuffer.pullContext("AdsDiscovery");
PositionAware positionAware = readBuffer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,6 @@ public int getLengthInBits() {
return lengthInBits;
}

public static AdsDiscoveryBlock staticParse(ReadBuffer readBuffer, Object... args)
throws ParseException {
PositionAware positionAware = readBuffer;
return staticParse(readBuffer);
}

public static AdsDiscoveryBlock staticParse(ReadBuffer readBuffer) throws ParseException {
readBuffer.pullContext("AdsDiscoveryBlock");
PositionAware positionAware = readBuffer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,6 @@ public int getLengthInBits() {
return lengthInBits;
}

public static AdsDiscoveryConstants staticParse(ReadBuffer readBuffer, Object... args)
throws ParseException {
PositionAware positionAware = readBuffer;
return staticParse(readBuffer);
}

public static AdsDiscoveryConstants staticParse(ReadBuffer readBuffer) throws ParseException {
readBuffer.pullContext("AdsDiscoveryConstants");
PositionAware positionAware = readBuffer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,6 @@ public int getLengthInBits() {
return lengthInBits;
}

public static AmsNetId staticParse(ReadBuffer readBuffer, Object... args) throws ParseException {
PositionAware positionAware = readBuffer;
return staticParse(readBuffer);
}

public static AmsNetId staticParse(ReadBuffer readBuffer) throws ParseException {
readBuffer.pullContext("AmsNetId");
PositionAware positionAware = readBuffer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,6 @@ public int getLengthInBits() {
return lengthInBits;
}

public static AmsString staticParse(ReadBuffer readBuffer, Object... args) throws ParseException {
PositionAware positionAware = readBuffer;
return staticParse(readBuffer);
}

public static AmsString staticParse(ReadBuffer readBuffer) throws ParseException {
readBuffer.pullContext("AmsString");
PositionAware positionAware = readBuffer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,6 @@ public int getLengthInBits() {
return lengthInBits;
}

public static AdsConstants staticParse(ReadBuffer readBuffer, Object... args)
throws ParseException {
PositionAware positionAware = readBuffer;
return staticParse(readBuffer);
}

public static AdsConstants staticParse(ReadBuffer readBuffer) throws ParseException {
readBuffer.pullContext("AdsConstants");
PositionAware positionAware = readBuffer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,6 @@ public int getLengthInBits() {
return lengthInBits;
}

public static AdsDataTypeArrayInfo staticParse(ReadBuffer readBuffer, Object... args)
throws ParseException {
PositionAware positionAware = readBuffer;
return staticParse(readBuffer);
}

public static AdsDataTypeArrayInfo staticParse(ReadBuffer readBuffer) throws ParseException {
readBuffer.pullContext("AdsDataTypeArrayInfo");
PositionAware positionAware = readBuffer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,12 +429,6 @@ public int getLengthInBits() {
return lengthInBits;
}

public static AdsDataTypeTableChildEntry staticParse(ReadBuffer readBuffer, Object... args)
throws ParseException {
PositionAware positionAware = readBuffer;
return staticParse(readBuffer);
}

public static AdsDataTypeTableChildEntry staticParse(ReadBuffer readBuffer)
throws ParseException {
readBuffer.pullContext("AdsDataTypeTableChildEntry");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,12 +429,6 @@ public int getLengthInBits() {
return lengthInBits;
}

public static AdsDataTypeTableEntry staticParse(ReadBuffer readBuffer, Object... args)
throws ParseException {
PositionAware positionAware = readBuffer;
return staticParse(readBuffer);
}

public static AdsDataTypeTableEntry staticParse(ReadBuffer readBuffer) throws ParseException {
readBuffer.pullContext("AdsDataTypeTableEntry");
PositionAware positionAware = readBuffer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,26 +74,6 @@ public int getLengthInBits() {
return lengthInBits;
}

public static AdsMultiRequestItem staticParse(ReadBuffer readBuffer, Object... args)
throws ParseException {
PositionAware positionAware = readBuffer;
if ((args == null) || (args.length != 1)) {
throw new PlcRuntimeException(
"Wrong number of arguments, expected 1, but got " + args.length);
}
Long indexGroup;
if (args[0] instanceof Long) {
indexGroup = (Long) args[0];
} else if (args[0] instanceof String) {
indexGroup = Long.valueOf((String) args[0]);
} else {
throw new PlcRuntimeException(
"Argument 0 expected to be of type Long or a string which is parseable but was "
+ args[0].getClass().getName());
}
return staticParse(readBuffer, indexGroup);
}

public static AdsMultiRequestItem staticParse(ReadBuffer readBuffer, Long indexGroup)
throws ParseException {
readBuffer.pullContext("AdsMultiRequestItem");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,6 @@ public int getLengthInBits() {
return lengthInBits;
}

public static AdsNotificationSample staticParse(ReadBuffer readBuffer, Object... args)
throws ParseException {
PositionAware positionAware = readBuffer;
return staticParse(readBuffer);
}

public static AdsNotificationSample staticParse(ReadBuffer readBuffer) throws ParseException {
readBuffer.pullContext("AdsNotificationSample");
PositionAware positionAware = readBuffer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,6 @@ public int getLengthInBits() {
return lengthInBits;
}

public static AdsStampHeader staticParse(ReadBuffer readBuffer, Object... args)
throws ParseException {
PositionAware positionAware = readBuffer;
return staticParse(readBuffer);
}

public static AdsStampHeader staticParse(ReadBuffer readBuffer) throws ParseException {
readBuffer.pullContext("AdsStampHeader");
PositionAware positionAware = readBuffer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -545,12 +545,6 @@ public int getLengthInBits() {
return lengthInBits;
}

public static AdsSymbolTableEntry staticParse(ReadBuffer readBuffer, Object... args)
throws ParseException {
PositionAware positionAware = readBuffer;
return staticParse(readBuffer);
}

public static AdsSymbolTableEntry staticParse(ReadBuffer readBuffer) throws ParseException {
readBuffer.pullContext("AdsSymbolTableEntry");
PositionAware positionAware = readBuffer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,6 @@ public int getLengthInBits() {
return lengthInBits;
}

public static AdsTableSizes staticParse(ReadBuffer readBuffer, Object... args)
throws ParseException {
PositionAware positionAware = readBuffer;
return staticParse(readBuffer);
}

public static AdsTableSizes staticParse(ReadBuffer readBuffer) throws ParseException {
readBuffer.pullContext("AdsTableSizes");
PositionAware positionAware = readBuffer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,6 @@ public int getLengthInBits() {
return lengthInBits;
}

public static AmsNetId staticParse(ReadBuffer readBuffer, Object... args) throws ParseException {
PositionAware positionAware = readBuffer;
return staticParse(readBuffer);
}

public static AmsNetId staticParse(ReadBuffer readBuffer) throws ParseException {
readBuffer.pullContext("AmsNetId");
PositionAware positionAware = readBuffer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,6 @@ public int getLengthInBits() {
return lengthInBits;
}

public static AmsPacket staticParse(ReadBuffer readBuffer, Object... args) throws ParseException {
PositionAware positionAware = readBuffer;
return staticParse(readBuffer);
}

public static AmsPacket staticParse(ReadBuffer readBuffer) throws ParseException {
readBuffer.pullContext("AmsPacket");
PositionAware positionAware = readBuffer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,6 @@ public int getLengthInBits() {
return lengthInBits;
}

public static AmsSerialAcknowledgeFrame staticParse(ReadBuffer readBuffer, Object... args)
throws ParseException {
PositionAware positionAware = readBuffer;
return staticParse(readBuffer);
}

public static AmsSerialAcknowledgeFrame staticParse(ReadBuffer readBuffer) throws ParseException {
readBuffer.pullContext("AmsSerialAcknowledgeFrame");
PositionAware positionAware = readBuffer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,6 @@ public int getLengthInBits() {
return lengthInBits;
}

public static AmsSerialFrame staticParse(ReadBuffer readBuffer, Object... args)
throws ParseException {
PositionAware positionAware = readBuffer;
return staticParse(readBuffer);
}

public static AmsSerialFrame staticParse(ReadBuffer readBuffer) throws ParseException {
readBuffer.pullContext("AmsSerialFrame");
PositionAware positionAware = readBuffer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,6 @@ public int getLengthInBits() {
return lengthInBits;
}

public static AmsSerialResetFrame staticParse(ReadBuffer readBuffer, Object... args)
throws ParseException {
PositionAware positionAware = readBuffer;
return staticParse(readBuffer);
}

public static AmsSerialResetFrame staticParse(ReadBuffer readBuffer) throws ParseException {
readBuffer.pullContext("AmsSerialResetFrame");
PositionAware positionAware = readBuffer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,6 @@ public int getLengthInBits() {
return lengthInBits;
}

public static AmsTCPPacket staticParse(ReadBuffer readBuffer, Object... args)
throws ParseException {
PositionAware positionAware = readBuffer;
return staticParse(readBuffer);
}

public static AmsTCPPacket staticParse(ReadBuffer readBuffer) throws ParseException {
readBuffer.pullContext("AmsTCPPacket");
PositionAware positionAware = readBuffer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,25 +88,6 @@ public int getLengthInBits() {
return lengthInBits;
}

public static APDU staticParse(ReadBuffer readBuffer, Object... args) throws ParseException {
PositionAware positionAware = readBuffer;
if ((args == null) || (args.length != 1)) {
throw new PlcRuntimeException(
"Wrong number of arguments, expected 1, but got " + args.length);
}
Integer apduLength;
if (args[0] instanceof Integer) {
apduLength = (Integer) args[0];
} else if (args[0] instanceof String) {
apduLength = Integer.valueOf((String) args[0]);
} else {
throw new PlcRuntimeException(
"Argument 0 expected to be of type Integer or a string which is parseable but was "
+ args[0].getClass().getName());
}
return staticParse(readBuffer, apduLength);
}

public static APDU staticParse(ReadBuffer readBuffer, Integer apduLength) throws ParseException {
readBuffer.pullContext("APDU");
PositionAware positionAware = readBuffer;
Expand Down
Loading
Loading