static List<VarDataSummary> gatherVarDataSummaries(final List<Token> tokens) { final List<VarDataSummary> summaries = new ArrayList<>(); for (int i = 0; i < tokens.size(); i++) { final Token beginToken = tokens.get(i); if (beginToken.signal() != Signal.BEGIN_VAR_DATA) { throw new IllegalStateException("tokens must begin with BEGIN_VAR_DATA: token=" + beginToken); } ++i; final Token dimensionsToken = tokens.get(i); final int headerTokenCount = dimensionsToken.componentTokenCount(); final List<Token> currentEncodingTokens = tokens.subList(i, i + headerTokenCount); final PrimitiveType lengthType = findPrimitiveByTokenName(currentEncodingTokens, "length"); final PrimitiveType dataType = findPrimitiveByTokenName(currentEncodingTokens, "varData"); summaries.add(new VarDataSummary(beginToken.name(), lengthType, dataType)); i += headerTokenCount; } return summaries; } }
final List<VarDataSummary> varDataSummaries = VarDataSummary.gatherVarDataSummaries(varData);
nextDecoderType = varDataSummary.generateVarDataDecoder( node.contextualName, memberDecoderType, node.depth() + 1, atEndOfCurrentLevel, outputManager, nextDecoderType);
final List<VarDataSummary> varDataSummaries = VarDataSummary.gatherVarDataSummaries(varData);
final List<VarDataSummary> varDataSummaries = VarDataSummary.gatherVarDataSummaries(varData);
nextCoderType = varDataSummary.generateVarDataEncoder( node.contextualName, memberCoderType, node.depth() + 1, atEndOfCurrentLevel, outputManager, nextCoderType);
nextDecoderType = varDataSummary.generateVarDataDecoder( node.contextualName, memberDecoderType, node.depth() + 1, atEndOfCurrentLevel, outputManager, nextDecoderType);
nextCoderType = varDataSummary.generateVarDataEncoder( node.contextualName, memberCoderType, node.depth() + 1, atEndOfCurrentLevel, outputManager, nextCoderType);
static String generateTopVarDataCoders( final String messageTypeName, final List<Token> tokens, final OutputManager outputManager, final String initialNextType, final RustCodecType codecType) throws IOException { final List<VarDataSummary> summaries = VarDataSummary.gatherVarDataSummaries(tokens); String nextCoderType = initialNextType; for (final VarDataSummary summary : reversedList(summaries)) { if (codecType == RustCodecType.Decoder) { nextCoderType = summary.generateVarDataDecoder( messageTypeName, SCRATCH_DECODER_TYPE, 0, false, outputManager, nextCoderType); } else if (codecType == RustCodecType.Encoder) { nextCoderType = summary.generateVarDataEncoder( messageTypeName, SCRATCH_ENCODER_TYPE, 0, false, outputManager, nextCoderType); } else { throw new IllegalArgumentException(format("Unknown RustCodecType %s", codecType)); } } return nextCoderType; }
nextDecoderType = varDataSummary.generateVarDataDecoder( node.contextualName, memberDecoderType, node.depth() + 1, atEndOfCurrentLevel, outputManager, nextDecoderType);
static String generateTopVarDataCoders( final String messageTypeName, final List<Token> tokens, final OutputManager outputManager, final String initialNextType, final RustCodecType codecType) throws IOException { final List<VarDataSummary> summaries = VarDataSummary.gatherVarDataSummaries(tokens); String nextCoderType = initialNextType; for (final VarDataSummary summary : reversedList(summaries)) { if (codecType == RustCodecType.Decoder) { nextCoderType = summary.generateVarDataDecoder( messageTypeName, SCRATCH_DECODER_TYPE, 0, false, outputManager, nextCoderType); } else if (codecType == RustCodecType.Encoder) { nextCoderType = summary.generateVarDataEncoder( messageTypeName, SCRATCH_ENCODER_TYPE, 0, false, outputManager, nextCoderType); } else { throw new IllegalArgumentException(format("Unknown RustCodecType %s", codecType)); } } return nextCoderType; }
static List<VarDataSummary> gatherVarDataSummaries(final List<Token> tokens) { final List<VarDataSummary> summaries = new ArrayList<>(); for (int i = 0; i < tokens.size(); i++) { final Token beginToken = tokens.get(i); if (beginToken.signal() != Signal.BEGIN_VAR_DATA) { throw new IllegalStateException("tokens must begin with BEGIN_VAR_DATA: token=" + beginToken); } ++i; final Token dimensionsToken = tokens.get(i); final int headerTokenCount = dimensionsToken.componentTokenCount(); final List<Token> currentEncodingTokens = tokens.subList(i, i + headerTokenCount); final PrimitiveType lengthType = findPrimitiveByTokenName(currentEncodingTokens, "length"); final PrimitiveType dataType = findPrimitiveByTokenName(currentEncodingTokens, "varData"); summaries.add(new VarDataSummary(beginToken.name(), lengthType, dataType)); i += headerTokenCount; } return summaries; } }
static List<VarDataSummary> gatherVarDataSummaries(final List<Token> tokens) { final List<VarDataSummary> summaries = new ArrayList<>(); for (int i = 0; i < tokens.size(); i++) { final Token beginToken = tokens.get(i); if (beginToken.signal() != Signal.BEGIN_VAR_DATA) { throw new IllegalStateException("tokens must begin with BEGIN_VAR_DATA: token=" + beginToken); } ++i; final Token dimensionsToken = tokens.get(i); final int headerTokenCount = dimensionsToken.componentTokenCount(); final List<Token> currentEncodingTokens = tokens.subList(i, i + headerTokenCount); final PrimitiveType lengthType = findPrimitiveByTokenName(currentEncodingTokens, "length"); final PrimitiveType dataType = findPrimitiveByTokenName(currentEncodingTokens, "varData"); summaries.add(new VarDataSummary(beginToken.name(), lengthType, dataType)); i += headerTokenCount; } return summaries; } }
nextCoderType = varDataSummary.generateVarDataEncoder( node.contextualName, memberCoderType, node.depth() + 1, atEndOfCurrentLevel, outputManager, nextCoderType);
static String generateTopVarDataCoders( final String messageTypeName, final List<Token> tokens, final OutputManager outputManager, final String initialNextType, final RustCodecType codecType) throws IOException { final List<VarDataSummary> summaries = VarDataSummary.gatherVarDataSummaries(tokens); String nextCoderType = initialNextType; for (final VarDataSummary summary : reversedList(summaries)) { if (codecType == RustCodecType.Decoder) { nextCoderType = summary.generateVarDataDecoder( messageTypeName, SCRATCH_DECODER_TYPE, 0, false, outputManager, nextCoderType); } else if (codecType == RustCodecType.Encoder) { nextCoderType = summary.generateVarDataEncoder( messageTypeName, SCRATCH_ENCODER_TYPE, 0, false, outputManager, nextCoderType); } else { throw new IllegalArgumentException(format("Unknown RustCodecType %s", codecType)); } } return nextCoderType; }