/**
 * The MIT License (MIT)
 *
 * Copyright (c) 2019 Erik Moqvist
 *
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use, copy,
 * modify, merge, publish, distribute, sublicense, and/or sell copies
 * of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

/**
 * This file was generated by pbtools.
 */

#include <limits.h>
#include "repeated.h"

#if CHAR_BIT != 8
#    error "Number of bits in a char must be 8."
#endif

void repeated_message_init(
    struct repeated_message_t *self_p,
    struct pbtools_heap_t *heap_p)
{
    self_p->base.heap_p = heap_p;
    self_p->int32s.length = 0;
    self_p->messages.length = 0;
    self_p->strings.length = 0;
    self_p->bytes.length = 0;
}

void repeated_message_encode_inner(
    struct pbtools_encoder_t *encoder_p,
    struct repeated_message_t *self_p)
{
    pbtools_encoder_write_repeated_bytes(encoder_p, 4, &self_p->bytes);
    pbtools_encoder_write_repeated_string(encoder_p, 3, &self_p->strings);
    repeated_message_encode_repeated_inner(
        encoder_p,
        2,
        &self_p->messages);
    pbtools_encoder_write_repeated_int32(encoder_p, 1, &self_p->int32s);
}

void repeated_message_decode_inner(
    struct pbtools_decoder_t *decoder_p,
    struct repeated_message_t *self_p)
{
    int wire_type;
    struct pbtools_repeated_info_t repeated_info_int32s;
    struct pbtools_repeated_info_t repeated_info_messages;
    struct pbtools_repeated_info_t repeated_info_strings;
    struct pbtools_repeated_info_t repeated_info_bytes;

    pbtools_repeated_info_init(&repeated_info_int32s, 1);
    pbtools_repeated_info_init(&repeated_info_messages, 2);
    pbtools_repeated_info_init(&repeated_info_strings, 3);
    pbtools_repeated_info_init(&repeated_info_bytes, 4);

    while (pbtools_decoder_available(decoder_p)) {
        switch (pbtools_decoder_read_tag(decoder_p, &wire_type)) {

        case 1:
            pbtools_repeated_info_decode_int32(
                &repeated_info_int32s,
                decoder_p,
                wire_type);
            break;

        case 2:
            pbtools_repeated_info_decode(&repeated_info_messages,
                                         decoder_p,
                                         wire_type);
            break;

        case 3:
            pbtools_repeated_info_decode_string(
                &repeated_info_strings,
                decoder_p,
                wire_type);
            break;

        case 4:
            pbtools_repeated_info_decode_bytes(
                &repeated_info_bytes,
                decoder_p,
                wire_type);
            break;

        default:
            pbtools_decoder_skip_field(decoder_p, wire_type);
            break;
        }
    }

    pbtools_decoder_decode_repeated_int32(
        decoder_p,
        &repeated_info_int32s,
        &self_p->int32s);
    repeated_message_decode_repeated_inner(
        decoder_p,
        &repeated_info_messages,
        &self_p->messages);
    pbtools_decoder_decode_repeated_string(
        decoder_p,
        &repeated_info_strings,
        &self_p->strings);
    pbtools_decoder_decode_repeated_bytes(
        decoder_p,
        &repeated_info_bytes,
        &self_p->bytes);
}

int repeated_message_int32s_alloc(
    struct repeated_message_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_int32(
                &self_p->base,
                length,
                &self_p->int32s));
}

int repeated_message_messages_alloc(
    struct repeated_message_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated(
                (struct pbtools_repeated_message_t *)&self_p->messages,
                length,
                self_p->base.heap_p,
                sizeof(struct repeated_message_t),
                (pbtools_message_init_t)repeated_message_init));
}

int repeated_message_strings_alloc(
    struct repeated_message_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_string(
                &self_p->base,
                length,
                &self_p->strings));
}

int repeated_message_bytes_alloc(
    struct repeated_message_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_bytes(
                &self_p->base,
                length,
                &self_p->bytes));
}

void repeated_message_encode_repeated_inner(
    struct pbtools_encoder_t *encoder_p,
    int field_number,
    struct repeated_message_repeated_t *repeated_p)
{
    pbtools_encode_repeated_inner(
        encoder_p,
        field_number,
        (struct pbtools_repeated_message_t *)repeated_p,
        sizeof(struct repeated_message_t),
        (pbtools_message_encode_inner_t)repeated_message_encode_inner);
}

void repeated_message_decode_repeated_inner(
    struct pbtools_decoder_t *decoder_p,
    struct pbtools_repeated_info_t *repeated_info_p,
    struct repeated_message_repeated_t *repeated_p)
{
    pbtools_decode_repeated_inner(
        decoder_p,
        repeated_info_p,
        (struct pbtools_repeated_message_t *)repeated_p,
        sizeof(struct repeated_message_t),
        (pbtools_message_init_t)repeated_message_init,
        (pbtools_message_decode_inner_t)repeated_message_decode_inner);
}

struct repeated_message_t *
repeated_message_new(
    void *workspace_p,
    size_t size)
{
    return (pbtools_message_new(
                workspace_p,
                size,
                sizeof(struct repeated_message_t),
                (pbtools_message_init_t)repeated_message_init));
}

int repeated_message_encode(
    struct repeated_message_t *self_p,
    uint8_t *encoded_p,
    size_t size)
{
    return (pbtools_message_encode(
                &self_p->base,
                encoded_p,
                size,
                (pbtools_message_encode_inner_t)repeated_message_encode_inner));
}

int repeated_message_decode(
    struct repeated_message_t *self_p,
    const uint8_t *encoded_p,
    size_t size)
{
    return (pbtools_message_decode(
                &self_p->base,
                encoded_p,
                size,
                (pbtools_message_decode_inner_t)repeated_message_decode_inner));
}

void repeated_message_scalar_value_types_init(
    struct repeated_message_scalar_value_types_t *self_p,
    struct pbtools_heap_t *heap_p)
{
    self_p->base.heap_p = heap_p;
    self_p->int32s.length = 0;
    self_p->int64s.length = 0;
    self_p->sint32s.length = 0;
    self_p->sint64s.length = 0;
    self_p->uint32s.length = 0;
    self_p->uint64s.length = 0;
    self_p->fixed32s.length = 0;
    self_p->fixed64s.length = 0;
    self_p->sfixed32s.length = 0;
    self_p->sfixed64s.length = 0;
    self_p->floats.length = 0;
    self_p->doubles.length = 0;
    self_p->bools.length = 0;
    self_p->strings.length = 0;
    self_p->bytess.length = 0;
}

void repeated_message_scalar_value_types_encode_inner(
    struct pbtools_encoder_t *encoder_p,
    struct repeated_message_scalar_value_types_t *self_p)
{
    pbtools_encoder_write_repeated_bytes(encoder_p, 15, &self_p->bytess);
    pbtools_encoder_write_repeated_string(encoder_p, 14, &self_p->strings);
    pbtools_encoder_write_repeated_bool(encoder_p, 13, &self_p->bools);
    pbtools_encoder_write_repeated_double(encoder_p, 12, &self_p->doubles);
    pbtools_encoder_write_repeated_float(encoder_p, 11, &self_p->floats);
    pbtools_encoder_write_repeated_sfixed64(encoder_p, 10, &self_p->sfixed64s);
    pbtools_encoder_write_repeated_sfixed32(encoder_p, 9, &self_p->sfixed32s);
    pbtools_encoder_write_repeated_fixed64(encoder_p, 8, &self_p->fixed64s);
    pbtools_encoder_write_repeated_fixed32(encoder_p, 7, &self_p->fixed32s);
    pbtools_encoder_write_repeated_uint64(encoder_p, 6, &self_p->uint64s);
    pbtools_encoder_write_repeated_uint32(encoder_p, 5, &self_p->uint32s);
    pbtools_encoder_write_repeated_sint64(encoder_p, 4, &self_p->sint64s);
    pbtools_encoder_write_repeated_sint32(encoder_p, 3, &self_p->sint32s);
    pbtools_encoder_write_repeated_int64(encoder_p, 2, &self_p->int64s);
    pbtools_encoder_write_repeated_int32(encoder_p, 1, &self_p->int32s);
}

void repeated_message_scalar_value_types_decode_inner(
    struct pbtools_decoder_t *decoder_p,
    struct repeated_message_scalar_value_types_t *self_p)
{
    int wire_type;
    struct pbtools_repeated_info_t repeated_info_int32s;
    struct pbtools_repeated_info_t repeated_info_int64s;
    struct pbtools_repeated_info_t repeated_info_sint32s;
    struct pbtools_repeated_info_t repeated_info_sint64s;
    struct pbtools_repeated_info_t repeated_info_uint32s;
    struct pbtools_repeated_info_t repeated_info_uint64s;
    struct pbtools_repeated_info_t repeated_info_fixed32s;
    struct pbtools_repeated_info_t repeated_info_fixed64s;
    struct pbtools_repeated_info_t repeated_info_sfixed32s;
    struct pbtools_repeated_info_t repeated_info_sfixed64s;
    struct pbtools_repeated_info_t repeated_info_floats;
    struct pbtools_repeated_info_t repeated_info_doubles;
    struct pbtools_repeated_info_t repeated_info_bools;
    struct pbtools_repeated_info_t repeated_info_strings;
    struct pbtools_repeated_info_t repeated_info_bytess;

    pbtools_repeated_info_init(&repeated_info_int32s, 1);
    pbtools_repeated_info_init(&repeated_info_int64s, 2);
    pbtools_repeated_info_init(&repeated_info_sint32s, 3);
    pbtools_repeated_info_init(&repeated_info_sint64s, 4);
    pbtools_repeated_info_init(&repeated_info_uint32s, 5);
    pbtools_repeated_info_init(&repeated_info_uint64s, 6);
    pbtools_repeated_info_init(&repeated_info_fixed32s, 7);
    pbtools_repeated_info_init(&repeated_info_fixed64s, 8);
    pbtools_repeated_info_init(&repeated_info_sfixed32s, 9);
    pbtools_repeated_info_init(&repeated_info_sfixed64s, 10);
    pbtools_repeated_info_init(&repeated_info_floats, 11);
    pbtools_repeated_info_init(&repeated_info_doubles, 12);
    pbtools_repeated_info_init(&repeated_info_bools, 13);
    pbtools_repeated_info_init(&repeated_info_strings, 14);
    pbtools_repeated_info_init(&repeated_info_bytess, 15);

    while (pbtools_decoder_available(decoder_p)) {
        switch (pbtools_decoder_read_tag(decoder_p, &wire_type)) {

        case 1:
            pbtools_repeated_info_decode_int32(
                &repeated_info_int32s,
                decoder_p,
                wire_type);
            break;

        case 2:
            pbtools_repeated_info_decode_int64(
                &repeated_info_int64s,
                decoder_p,
                wire_type);
            break;

        case 3:
            pbtools_repeated_info_decode_sint32(
                &repeated_info_sint32s,
                decoder_p,
                wire_type);
            break;

        case 4:
            pbtools_repeated_info_decode_sint64(
                &repeated_info_sint64s,
                decoder_p,
                wire_type);
            break;

        case 5:
            pbtools_repeated_info_decode_uint32(
                &repeated_info_uint32s,
                decoder_p,
                wire_type);
            break;

        case 6:
            pbtools_repeated_info_decode_uint64(
                &repeated_info_uint64s,
                decoder_p,
                wire_type);
            break;

        case 7:
            pbtools_repeated_info_decode_fixed32(
                &repeated_info_fixed32s,
                decoder_p,
                wire_type);
            break;

        case 8:
            pbtools_repeated_info_decode_fixed64(
                &repeated_info_fixed64s,
                decoder_p,
                wire_type);
            break;

        case 9:
            pbtools_repeated_info_decode_sfixed32(
                &repeated_info_sfixed32s,
                decoder_p,
                wire_type);
            break;

        case 10:
            pbtools_repeated_info_decode_sfixed64(
                &repeated_info_sfixed64s,
                decoder_p,
                wire_type);
            break;

        case 11:
            pbtools_repeated_info_decode_float(
                &repeated_info_floats,
                decoder_p,
                wire_type);
            break;

        case 12:
            pbtools_repeated_info_decode_double(
                &repeated_info_doubles,
                decoder_p,
                wire_type);
            break;

        case 13:
            pbtools_repeated_info_decode_bool(
                &repeated_info_bools,
                decoder_p,
                wire_type);
            break;

        case 14:
            pbtools_repeated_info_decode_string(
                &repeated_info_strings,
                decoder_p,
                wire_type);
            break;

        case 15:
            pbtools_repeated_info_decode_bytes(
                &repeated_info_bytess,
                decoder_p,
                wire_type);
            break;

        default:
            pbtools_decoder_skip_field(decoder_p, wire_type);
            break;
        }
    }

    pbtools_decoder_decode_repeated_int32(
        decoder_p,
        &repeated_info_int32s,
        &self_p->int32s);
    pbtools_decoder_decode_repeated_int64(
        decoder_p,
        &repeated_info_int64s,
        &self_p->int64s);
    pbtools_decoder_decode_repeated_sint32(
        decoder_p,
        &repeated_info_sint32s,
        &self_p->sint32s);
    pbtools_decoder_decode_repeated_sint64(
        decoder_p,
        &repeated_info_sint64s,
        &self_p->sint64s);
    pbtools_decoder_decode_repeated_uint32(
        decoder_p,
        &repeated_info_uint32s,
        &self_p->uint32s);
    pbtools_decoder_decode_repeated_uint64(
        decoder_p,
        &repeated_info_uint64s,
        &self_p->uint64s);
    pbtools_decoder_decode_repeated_fixed32(
        decoder_p,
        &repeated_info_fixed32s,
        &self_p->fixed32s);
    pbtools_decoder_decode_repeated_fixed64(
        decoder_p,
        &repeated_info_fixed64s,
        &self_p->fixed64s);
    pbtools_decoder_decode_repeated_sfixed32(
        decoder_p,
        &repeated_info_sfixed32s,
        &self_p->sfixed32s);
    pbtools_decoder_decode_repeated_sfixed64(
        decoder_p,
        &repeated_info_sfixed64s,
        &self_p->sfixed64s);
    pbtools_decoder_decode_repeated_float(
        decoder_p,
        &repeated_info_floats,
        &self_p->floats);
    pbtools_decoder_decode_repeated_double(
        decoder_p,
        &repeated_info_doubles,
        &self_p->doubles);
    pbtools_decoder_decode_repeated_bool(
        decoder_p,
        &repeated_info_bools,
        &self_p->bools);
    pbtools_decoder_decode_repeated_string(
        decoder_p,
        &repeated_info_strings,
        &self_p->strings);
    pbtools_decoder_decode_repeated_bytes(
        decoder_p,
        &repeated_info_bytess,
        &self_p->bytess);
}

int repeated_message_scalar_value_types_int32s_alloc(
    struct repeated_message_scalar_value_types_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_int32(
                &self_p->base,
                length,
                &self_p->int32s));
}

int repeated_message_scalar_value_types_int64s_alloc(
    struct repeated_message_scalar_value_types_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_int64(
                &self_p->base,
                length,
                &self_p->int64s));
}

int repeated_message_scalar_value_types_sint32s_alloc(
    struct repeated_message_scalar_value_types_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_sint32(
                &self_p->base,
                length,
                &self_p->sint32s));
}

int repeated_message_scalar_value_types_sint64s_alloc(
    struct repeated_message_scalar_value_types_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_sint64(
                &self_p->base,
                length,
                &self_p->sint64s));
}

int repeated_message_scalar_value_types_uint32s_alloc(
    struct repeated_message_scalar_value_types_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_uint32(
                &self_p->base,
                length,
                &self_p->uint32s));
}

int repeated_message_scalar_value_types_uint64s_alloc(
    struct repeated_message_scalar_value_types_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_uint64(
                &self_p->base,
                length,
                &self_p->uint64s));
}

int repeated_message_scalar_value_types_fixed32s_alloc(
    struct repeated_message_scalar_value_types_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_fixed32(
                &self_p->base,
                length,
                &self_p->fixed32s));
}

int repeated_message_scalar_value_types_fixed64s_alloc(
    struct repeated_message_scalar_value_types_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_fixed64(
                &self_p->base,
                length,
                &self_p->fixed64s));
}

int repeated_message_scalar_value_types_sfixed32s_alloc(
    struct repeated_message_scalar_value_types_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_sfixed32(
                &self_p->base,
                length,
                &self_p->sfixed32s));
}

int repeated_message_scalar_value_types_sfixed64s_alloc(
    struct repeated_message_scalar_value_types_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_sfixed64(
                &self_p->base,
                length,
                &self_p->sfixed64s));
}

int repeated_message_scalar_value_types_floats_alloc(
    struct repeated_message_scalar_value_types_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_float(
                &self_p->base,
                length,
                &self_p->floats));
}

int repeated_message_scalar_value_types_doubles_alloc(
    struct repeated_message_scalar_value_types_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_double(
                &self_p->base,
                length,
                &self_p->doubles));
}

int repeated_message_scalar_value_types_bools_alloc(
    struct repeated_message_scalar_value_types_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_bool(
                &self_p->base,
                length,
                &self_p->bools));
}

int repeated_message_scalar_value_types_strings_alloc(
    struct repeated_message_scalar_value_types_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_string(
                &self_p->base,
                length,
                &self_p->strings));
}

int repeated_message_scalar_value_types_bytess_alloc(
    struct repeated_message_scalar_value_types_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_bytes(
                &self_p->base,
                length,
                &self_p->bytess));
}

void repeated_message_scalar_value_types_encode_repeated_inner(
    struct pbtools_encoder_t *encoder_p,
    int field_number,
    struct repeated_message_scalar_value_types_repeated_t *repeated_p)
{
    pbtools_encode_repeated_inner(
        encoder_p,
        field_number,
        (struct pbtools_repeated_message_t *)repeated_p,
        sizeof(struct repeated_message_scalar_value_types_t),
        (pbtools_message_encode_inner_t)repeated_message_scalar_value_types_encode_inner);
}

void repeated_message_scalar_value_types_decode_repeated_inner(
    struct pbtools_decoder_t *decoder_p,
    struct pbtools_repeated_info_t *repeated_info_p,
    struct repeated_message_scalar_value_types_repeated_t *repeated_p)
{
    pbtools_decode_repeated_inner(
        decoder_p,
        repeated_info_p,
        (struct pbtools_repeated_message_t *)repeated_p,
        sizeof(struct repeated_message_scalar_value_types_t),
        (pbtools_message_init_t)repeated_message_scalar_value_types_init,
        (pbtools_message_decode_inner_t)repeated_message_scalar_value_types_decode_inner);
}

struct repeated_message_scalar_value_types_t *
repeated_message_scalar_value_types_new(
    void *workspace_p,
    size_t size)
{
    return (pbtools_message_new(
                workspace_p,
                size,
                sizeof(struct repeated_message_scalar_value_types_t),
                (pbtools_message_init_t)repeated_message_scalar_value_types_init));
}

int repeated_message_scalar_value_types_encode(
    struct repeated_message_scalar_value_types_t *self_p,
    uint8_t *encoded_p,
    size_t size)
{
    return (pbtools_message_encode(
                &self_p->base,
                encoded_p,
                size,
                (pbtools_message_encode_inner_t)repeated_message_scalar_value_types_encode_inner));
}

int repeated_message_scalar_value_types_decode(
    struct repeated_message_scalar_value_types_t *self_p,
    const uint8_t *encoded_p,
    size_t size)
{
    return (pbtools_message_decode(
                &self_p->base,
                encoded_p,
                size,
                (pbtools_message_decode_inner_t)repeated_message_scalar_value_types_decode_inner));
}

void repeated_message_scalar_value_types_packed_init(
    struct repeated_message_scalar_value_types_packed_t *self_p,
    struct pbtools_heap_t *heap_p)
{
    self_p->base.heap_p = heap_p;
    self_p->int32s.length = 0;
    self_p->int64s.length = 0;
    self_p->sint32s.length = 0;
    self_p->sint64s.length = 0;
    self_p->uint32s.length = 0;
    self_p->uint64s.length = 0;
    self_p->fixed32s.length = 0;
    self_p->fixed64s.length = 0;
    self_p->sfixed32s.length = 0;
    self_p->sfixed64s.length = 0;
    self_p->floats.length = 0;
    self_p->doubles.length = 0;
    self_p->bools.length = 0;
    self_p->strings.length = 0;
    self_p->bytess.length = 0;
}

void repeated_message_scalar_value_types_packed_encode_inner(
    struct pbtools_encoder_t *encoder_p,
    struct repeated_message_scalar_value_types_packed_t *self_p)
{
    pbtools_encoder_write_repeated_bytes(encoder_p, 15, &self_p->bytess);
    pbtools_encoder_write_repeated_string(encoder_p, 14, &self_p->strings);
    pbtools_encoder_write_repeated_bool(encoder_p, 13, &self_p->bools);
    pbtools_encoder_write_repeated_double(encoder_p, 12, &self_p->doubles);
    pbtools_encoder_write_repeated_float(encoder_p, 11, &self_p->floats);
    pbtools_encoder_write_repeated_sfixed64(encoder_p, 10, &self_p->sfixed64s);
    pbtools_encoder_write_repeated_sfixed32(encoder_p, 9, &self_p->sfixed32s);
    pbtools_encoder_write_repeated_fixed64(encoder_p, 8, &self_p->fixed64s);
    pbtools_encoder_write_repeated_fixed32(encoder_p, 7, &self_p->fixed32s);
    pbtools_encoder_write_repeated_uint64(encoder_p, 6, &self_p->uint64s);
    pbtools_encoder_write_repeated_uint32(encoder_p, 5, &self_p->uint32s);
    pbtools_encoder_write_repeated_sint64(encoder_p, 4, &self_p->sint64s);
    pbtools_encoder_write_repeated_sint32(encoder_p, 3, &self_p->sint32s);
    pbtools_encoder_write_repeated_int64(encoder_p, 2, &self_p->int64s);
    pbtools_encoder_write_repeated_int32(encoder_p, 1, &self_p->int32s);
}

void repeated_message_scalar_value_types_packed_decode_inner(
    struct pbtools_decoder_t *decoder_p,
    struct repeated_message_scalar_value_types_packed_t *self_p)
{
    int wire_type;
    struct pbtools_repeated_info_t repeated_info_int32s;
    struct pbtools_repeated_info_t repeated_info_int64s;
    struct pbtools_repeated_info_t repeated_info_sint32s;
    struct pbtools_repeated_info_t repeated_info_sint64s;
    struct pbtools_repeated_info_t repeated_info_uint32s;
    struct pbtools_repeated_info_t repeated_info_uint64s;
    struct pbtools_repeated_info_t repeated_info_fixed32s;
    struct pbtools_repeated_info_t repeated_info_fixed64s;
    struct pbtools_repeated_info_t repeated_info_sfixed32s;
    struct pbtools_repeated_info_t repeated_info_sfixed64s;
    struct pbtools_repeated_info_t repeated_info_floats;
    struct pbtools_repeated_info_t repeated_info_doubles;
    struct pbtools_repeated_info_t repeated_info_bools;
    struct pbtools_repeated_info_t repeated_info_strings;
    struct pbtools_repeated_info_t repeated_info_bytess;

    pbtools_repeated_info_init(&repeated_info_int32s, 1);
    pbtools_repeated_info_init(&repeated_info_int64s, 2);
    pbtools_repeated_info_init(&repeated_info_sint32s, 3);
    pbtools_repeated_info_init(&repeated_info_sint64s, 4);
    pbtools_repeated_info_init(&repeated_info_uint32s, 5);
    pbtools_repeated_info_init(&repeated_info_uint64s, 6);
    pbtools_repeated_info_init(&repeated_info_fixed32s, 7);
    pbtools_repeated_info_init(&repeated_info_fixed64s, 8);
    pbtools_repeated_info_init(&repeated_info_sfixed32s, 9);
    pbtools_repeated_info_init(&repeated_info_sfixed64s, 10);
    pbtools_repeated_info_init(&repeated_info_floats, 11);
    pbtools_repeated_info_init(&repeated_info_doubles, 12);
    pbtools_repeated_info_init(&repeated_info_bools, 13);
    pbtools_repeated_info_init(&repeated_info_strings, 14);
    pbtools_repeated_info_init(&repeated_info_bytess, 15);

    while (pbtools_decoder_available(decoder_p)) {
        switch (pbtools_decoder_read_tag(decoder_p, &wire_type)) {

        case 1:
            pbtools_repeated_info_decode_int32(
                &repeated_info_int32s,
                decoder_p,
                wire_type);
            break;

        case 2:
            pbtools_repeated_info_decode_int64(
                &repeated_info_int64s,
                decoder_p,
                wire_type);
            break;

        case 3:
            pbtools_repeated_info_decode_sint32(
                &repeated_info_sint32s,
                decoder_p,
                wire_type);
            break;

        case 4:
            pbtools_repeated_info_decode_sint64(
                &repeated_info_sint64s,
                decoder_p,
                wire_type);
            break;

        case 5:
            pbtools_repeated_info_decode_uint32(
                &repeated_info_uint32s,
                decoder_p,
                wire_type);
            break;

        case 6:
            pbtools_repeated_info_decode_uint64(
                &repeated_info_uint64s,
                decoder_p,
                wire_type);
            break;

        case 7:
            pbtools_repeated_info_decode_fixed32(
                &repeated_info_fixed32s,
                decoder_p,
                wire_type);
            break;

        case 8:
            pbtools_repeated_info_decode_fixed64(
                &repeated_info_fixed64s,
                decoder_p,
                wire_type);
            break;

        case 9:
            pbtools_repeated_info_decode_sfixed32(
                &repeated_info_sfixed32s,
                decoder_p,
                wire_type);
            break;

        case 10:
            pbtools_repeated_info_decode_sfixed64(
                &repeated_info_sfixed64s,
                decoder_p,
                wire_type);
            break;

        case 11:
            pbtools_repeated_info_decode_float(
                &repeated_info_floats,
                decoder_p,
                wire_type);
            break;

        case 12:
            pbtools_repeated_info_decode_double(
                &repeated_info_doubles,
                decoder_p,
                wire_type);
            break;

        case 13:
            pbtools_repeated_info_decode_bool(
                &repeated_info_bools,
                decoder_p,
                wire_type);
            break;

        case 14:
            pbtools_repeated_info_decode_string(
                &repeated_info_strings,
                decoder_p,
                wire_type);
            break;

        case 15:
            pbtools_repeated_info_decode_bytes(
                &repeated_info_bytess,
                decoder_p,
                wire_type);
            break;

        default:
            pbtools_decoder_skip_field(decoder_p, wire_type);
            break;
        }
    }

    pbtools_decoder_decode_repeated_int32(
        decoder_p,
        &repeated_info_int32s,
        &self_p->int32s);
    pbtools_decoder_decode_repeated_int64(
        decoder_p,
        &repeated_info_int64s,
        &self_p->int64s);
    pbtools_decoder_decode_repeated_sint32(
        decoder_p,
        &repeated_info_sint32s,
        &self_p->sint32s);
    pbtools_decoder_decode_repeated_sint64(
        decoder_p,
        &repeated_info_sint64s,
        &self_p->sint64s);
    pbtools_decoder_decode_repeated_uint32(
        decoder_p,
        &repeated_info_uint32s,
        &self_p->uint32s);
    pbtools_decoder_decode_repeated_uint64(
        decoder_p,
        &repeated_info_uint64s,
        &self_p->uint64s);
    pbtools_decoder_decode_repeated_fixed32(
        decoder_p,
        &repeated_info_fixed32s,
        &self_p->fixed32s);
    pbtools_decoder_decode_repeated_fixed64(
        decoder_p,
        &repeated_info_fixed64s,
        &self_p->fixed64s);
    pbtools_decoder_decode_repeated_sfixed32(
        decoder_p,
        &repeated_info_sfixed32s,
        &self_p->sfixed32s);
    pbtools_decoder_decode_repeated_sfixed64(
        decoder_p,
        &repeated_info_sfixed64s,
        &self_p->sfixed64s);
    pbtools_decoder_decode_repeated_float(
        decoder_p,
        &repeated_info_floats,
        &self_p->floats);
    pbtools_decoder_decode_repeated_double(
        decoder_p,
        &repeated_info_doubles,
        &self_p->doubles);
    pbtools_decoder_decode_repeated_bool(
        decoder_p,
        &repeated_info_bools,
        &self_p->bools);
    pbtools_decoder_decode_repeated_string(
        decoder_p,
        &repeated_info_strings,
        &self_p->strings);
    pbtools_decoder_decode_repeated_bytes(
        decoder_p,
        &repeated_info_bytess,
        &self_p->bytess);
}

int repeated_message_scalar_value_types_packed_int32s_alloc(
    struct repeated_message_scalar_value_types_packed_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_int32(
                &self_p->base,
                length,
                &self_p->int32s));
}

int repeated_message_scalar_value_types_packed_int64s_alloc(
    struct repeated_message_scalar_value_types_packed_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_int64(
                &self_p->base,
                length,
                &self_p->int64s));
}

int repeated_message_scalar_value_types_packed_sint32s_alloc(
    struct repeated_message_scalar_value_types_packed_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_sint32(
                &self_p->base,
                length,
                &self_p->sint32s));
}

int repeated_message_scalar_value_types_packed_sint64s_alloc(
    struct repeated_message_scalar_value_types_packed_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_sint64(
                &self_p->base,
                length,
                &self_p->sint64s));
}

int repeated_message_scalar_value_types_packed_uint32s_alloc(
    struct repeated_message_scalar_value_types_packed_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_uint32(
                &self_p->base,
                length,
                &self_p->uint32s));
}

int repeated_message_scalar_value_types_packed_uint64s_alloc(
    struct repeated_message_scalar_value_types_packed_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_uint64(
                &self_p->base,
                length,
                &self_p->uint64s));
}

int repeated_message_scalar_value_types_packed_fixed32s_alloc(
    struct repeated_message_scalar_value_types_packed_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_fixed32(
                &self_p->base,
                length,
                &self_p->fixed32s));
}

int repeated_message_scalar_value_types_packed_fixed64s_alloc(
    struct repeated_message_scalar_value_types_packed_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_fixed64(
                &self_p->base,
                length,
                &self_p->fixed64s));
}

int repeated_message_scalar_value_types_packed_sfixed32s_alloc(
    struct repeated_message_scalar_value_types_packed_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_sfixed32(
                &self_p->base,
                length,
                &self_p->sfixed32s));
}

int repeated_message_scalar_value_types_packed_sfixed64s_alloc(
    struct repeated_message_scalar_value_types_packed_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_sfixed64(
                &self_p->base,
                length,
                &self_p->sfixed64s));
}

int repeated_message_scalar_value_types_packed_floats_alloc(
    struct repeated_message_scalar_value_types_packed_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_float(
                &self_p->base,
                length,
                &self_p->floats));
}

int repeated_message_scalar_value_types_packed_doubles_alloc(
    struct repeated_message_scalar_value_types_packed_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_double(
                &self_p->base,
                length,
                &self_p->doubles));
}

int repeated_message_scalar_value_types_packed_bools_alloc(
    struct repeated_message_scalar_value_types_packed_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_bool(
                &self_p->base,
                length,
                &self_p->bools));
}

int repeated_message_scalar_value_types_packed_strings_alloc(
    struct repeated_message_scalar_value_types_packed_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_string(
                &self_p->base,
                length,
                &self_p->strings));
}

int repeated_message_scalar_value_types_packed_bytess_alloc(
    struct repeated_message_scalar_value_types_packed_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_bytes(
                &self_p->base,
                length,
                &self_p->bytess));
}

void repeated_message_scalar_value_types_packed_encode_repeated_inner(
    struct pbtools_encoder_t *encoder_p,
    int field_number,
    struct repeated_message_scalar_value_types_packed_repeated_t *repeated_p)
{
    pbtools_encode_repeated_inner(
        encoder_p,
        field_number,
        (struct pbtools_repeated_message_t *)repeated_p,
        sizeof(struct repeated_message_scalar_value_types_packed_t),
        (pbtools_message_encode_inner_t)repeated_message_scalar_value_types_packed_encode_inner);
}

void repeated_message_scalar_value_types_packed_decode_repeated_inner(
    struct pbtools_decoder_t *decoder_p,
    struct pbtools_repeated_info_t *repeated_info_p,
    struct repeated_message_scalar_value_types_packed_repeated_t *repeated_p)
{
    pbtools_decode_repeated_inner(
        decoder_p,
        repeated_info_p,
        (struct pbtools_repeated_message_t *)repeated_p,
        sizeof(struct repeated_message_scalar_value_types_packed_t),
        (pbtools_message_init_t)repeated_message_scalar_value_types_packed_init,
        (pbtools_message_decode_inner_t)repeated_message_scalar_value_types_packed_decode_inner);
}

struct repeated_message_scalar_value_types_packed_t *
repeated_message_scalar_value_types_packed_new(
    void *workspace_p,
    size_t size)
{
    return (pbtools_message_new(
                workspace_p,
                size,
                sizeof(struct repeated_message_scalar_value_types_packed_t),
                (pbtools_message_init_t)repeated_message_scalar_value_types_packed_init));
}

int repeated_message_scalar_value_types_packed_encode(
    struct repeated_message_scalar_value_types_packed_t *self_p,
    uint8_t *encoded_p,
    size_t size)
{
    return (pbtools_message_encode(
                &self_p->base,
                encoded_p,
                size,
                (pbtools_message_encode_inner_t)repeated_message_scalar_value_types_packed_encode_inner));
}

int repeated_message_scalar_value_types_packed_decode(
    struct repeated_message_scalar_value_types_packed_t *self_p,
    const uint8_t *encoded_p,
    size_t size)
{
    return (pbtools_message_decode(
                &self_p->base,
                encoded_p,
                size,
                (pbtools_message_decode_inner_t)repeated_message_scalar_value_types_packed_decode_inner));
}

void repeated_message_scalar_value_types_not_packed_init(
    struct repeated_message_scalar_value_types_not_packed_t *self_p,
    struct pbtools_heap_t *heap_p)
{
    self_p->base.heap_p = heap_p;
    self_p->int32s.length = 0;
    self_p->int64s.length = 0;
    self_p->sint32s.length = 0;
    self_p->sint64s.length = 0;
    self_p->uint32s.length = 0;
    self_p->uint64s.length = 0;
    self_p->fixed32s.length = 0;
    self_p->fixed64s.length = 0;
    self_p->sfixed32s.length = 0;
    self_p->sfixed64s.length = 0;
    self_p->floats.length = 0;
    self_p->doubles.length = 0;
    self_p->bools.length = 0;
    self_p->strings.length = 0;
    self_p->bytess.length = 0;
}

void repeated_message_scalar_value_types_not_packed_encode_inner(
    struct pbtools_encoder_t *encoder_p,
    struct repeated_message_scalar_value_types_not_packed_t *self_p)
{
    pbtools_encoder_write_repeated_bytes(encoder_p, 15, &self_p->bytess);
    pbtools_encoder_write_repeated_string(encoder_p, 14, &self_p->strings);
    pbtools_encoder_write_repeated_bool(encoder_p, 13, &self_p->bools);
    pbtools_encoder_write_repeated_double(encoder_p, 12, &self_p->doubles);
    pbtools_encoder_write_repeated_float(encoder_p, 11, &self_p->floats);
    pbtools_encoder_write_repeated_sfixed64(encoder_p, 10, &self_p->sfixed64s);
    pbtools_encoder_write_repeated_sfixed32(encoder_p, 9, &self_p->sfixed32s);
    pbtools_encoder_write_repeated_fixed64(encoder_p, 8, &self_p->fixed64s);
    pbtools_encoder_write_repeated_fixed32(encoder_p, 7, &self_p->fixed32s);
    pbtools_encoder_write_repeated_uint64(encoder_p, 6, &self_p->uint64s);
    pbtools_encoder_write_repeated_uint32(encoder_p, 5, &self_p->uint32s);
    pbtools_encoder_write_repeated_sint64(encoder_p, 4, &self_p->sint64s);
    pbtools_encoder_write_repeated_sint32(encoder_p, 3, &self_p->sint32s);
    pbtools_encoder_write_repeated_int64(encoder_p, 2, &self_p->int64s);
    pbtools_encoder_write_repeated_int32(encoder_p, 1, &self_p->int32s);
}

void repeated_message_scalar_value_types_not_packed_decode_inner(
    struct pbtools_decoder_t *decoder_p,
    struct repeated_message_scalar_value_types_not_packed_t *self_p)
{
    int wire_type;
    struct pbtools_repeated_info_t repeated_info_int32s;
    struct pbtools_repeated_info_t repeated_info_int64s;
    struct pbtools_repeated_info_t repeated_info_sint32s;
    struct pbtools_repeated_info_t repeated_info_sint64s;
    struct pbtools_repeated_info_t repeated_info_uint32s;
    struct pbtools_repeated_info_t repeated_info_uint64s;
    struct pbtools_repeated_info_t repeated_info_fixed32s;
    struct pbtools_repeated_info_t repeated_info_fixed64s;
    struct pbtools_repeated_info_t repeated_info_sfixed32s;
    struct pbtools_repeated_info_t repeated_info_sfixed64s;
    struct pbtools_repeated_info_t repeated_info_floats;
    struct pbtools_repeated_info_t repeated_info_doubles;
    struct pbtools_repeated_info_t repeated_info_bools;
    struct pbtools_repeated_info_t repeated_info_strings;
    struct pbtools_repeated_info_t repeated_info_bytess;

    pbtools_repeated_info_init(&repeated_info_int32s, 1);
    pbtools_repeated_info_init(&repeated_info_int64s, 2);
    pbtools_repeated_info_init(&repeated_info_sint32s, 3);
    pbtools_repeated_info_init(&repeated_info_sint64s, 4);
    pbtools_repeated_info_init(&repeated_info_uint32s, 5);
    pbtools_repeated_info_init(&repeated_info_uint64s, 6);
    pbtools_repeated_info_init(&repeated_info_fixed32s, 7);
    pbtools_repeated_info_init(&repeated_info_fixed64s, 8);
    pbtools_repeated_info_init(&repeated_info_sfixed32s, 9);
    pbtools_repeated_info_init(&repeated_info_sfixed64s, 10);
    pbtools_repeated_info_init(&repeated_info_floats, 11);
    pbtools_repeated_info_init(&repeated_info_doubles, 12);
    pbtools_repeated_info_init(&repeated_info_bools, 13);
    pbtools_repeated_info_init(&repeated_info_strings, 14);
    pbtools_repeated_info_init(&repeated_info_bytess, 15);

    while (pbtools_decoder_available(decoder_p)) {
        switch (pbtools_decoder_read_tag(decoder_p, &wire_type)) {

        case 1:
            pbtools_repeated_info_decode_int32(
                &repeated_info_int32s,
                decoder_p,
                wire_type);
            break;

        case 2:
            pbtools_repeated_info_decode_int64(
                &repeated_info_int64s,
                decoder_p,
                wire_type);
            break;

        case 3:
            pbtools_repeated_info_decode_sint32(
                &repeated_info_sint32s,
                decoder_p,
                wire_type);
            break;

        case 4:
            pbtools_repeated_info_decode_sint64(
                &repeated_info_sint64s,
                decoder_p,
                wire_type);
            break;

        case 5:
            pbtools_repeated_info_decode_uint32(
                &repeated_info_uint32s,
                decoder_p,
                wire_type);
            break;

        case 6:
            pbtools_repeated_info_decode_uint64(
                &repeated_info_uint64s,
                decoder_p,
                wire_type);
            break;

        case 7:
            pbtools_repeated_info_decode_fixed32(
                &repeated_info_fixed32s,
                decoder_p,
                wire_type);
            break;

        case 8:
            pbtools_repeated_info_decode_fixed64(
                &repeated_info_fixed64s,
                decoder_p,
                wire_type);
            break;

        case 9:
            pbtools_repeated_info_decode_sfixed32(
                &repeated_info_sfixed32s,
                decoder_p,
                wire_type);
            break;

        case 10:
            pbtools_repeated_info_decode_sfixed64(
                &repeated_info_sfixed64s,
                decoder_p,
                wire_type);
            break;

        case 11:
            pbtools_repeated_info_decode_float(
                &repeated_info_floats,
                decoder_p,
                wire_type);
            break;

        case 12:
            pbtools_repeated_info_decode_double(
                &repeated_info_doubles,
                decoder_p,
                wire_type);
            break;

        case 13:
            pbtools_repeated_info_decode_bool(
                &repeated_info_bools,
                decoder_p,
                wire_type);
            break;

        case 14:
            pbtools_repeated_info_decode_string(
                &repeated_info_strings,
                decoder_p,
                wire_type);
            break;

        case 15:
            pbtools_repeated_info_decode_bytes(
                &repeated_info_bytess,
                decoder_p,
                wire_type);
            break;

        default:
            pbtools_decoder_skip_field(decoder_p, wire_type);
            break;
        }
    }

    pbtools_decoder_decode_repeated_int32(
        decoder_p,
        &repeated_info_int32s,
        &self_p->int32s);
    pbtools_decoder_decode_repeated_int64(
        decoder_p,
        &repeated_info_int64s,
        &self_p->int64s);
    pbtools_decoder_decode_repeated_sint32(
        decoder_p,
        &repeated_info_sint32s,
        &self_p->sint32s);
    pbtools_decoder_decode_repeated_sint64(
        decoder_p,
        &repeated_info_sint64s,
        &self_p->sint64s);
    pbtools_decoder_decode_repeated_uint32(
        decoder_p,
        &repeated_info_uint32s,
        &self_p->uint32s);
    pbtools_decoder_decode_repeated_uint64(
        decoder_p,
        &repeated_info_uint64s,
        &self_p->uint64s);
    pbtools_decoder_decode_repeated_fixed32(
        decoder_p,
        &repeated_info_fixed32s,
        &self_p->fixed32s);
    pbtools_decoder_decode_repeated_fixed64(
        decoder_p,
        &repeated_info_fixed64s,
        &self_p->fixed64s);
    pbtools_decoder_decode_repeated_sfixed32(
        decoder_p,
        &repeated_info_sfixed32s,
        &self_p->sfixed32s);
    pbtools_decoder_decode_repeated_sfixed64(
        decoder_p,
        &repeated_info_sfixed64s,
        &self_p->sfixed64s);
    pbtools_decoder_decode_repeated_float(
        decoder_p,
        &repeated_info_floats,
        &self_p->floats);
    pbtools_decoder_decode_repeated_double(
        decoder_p,
        &repeated_info_doubles,
        &self_p->doubles);
    pbtools_decoder_decode_repeated_bool(
        decoder_p,
        &repeated_info_bools,
        &self_p->bools);
    pbtools_decoder_decode_repeated_string(
        decoder_p,
        &repeated_info_strings,
        &self_p->strings);
    pbtools_decoder_decode_repeated_bytes(
        decoder_p,
        &repeated_info_bytess,
        &self_p->bytess);
}

int repeated_message_scalar_value_types_not_packed_int32s_alloc(
    struct repeated_message_scalar_value_types_not_packed_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_int32(
                &self_p->base,
                length,
                &self_p->int32s));
}

int repeated_message_scalar_value_types_not_packed_int64s_alloc(
    struct repeated_message_scalar_value_types_not_packed_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_int64(
                &self_p->base,
                length,
                &self_p->int64s));
}

int repeated_message_scalar_value_types_not_packed_sint32s_alloc(
    struct repeated_message_scalar_value_types_not_packed_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_sint32(
                &self_p->base,
                length,
                &self_p->sint32s));
}

int repeated_message_scalar_value_types_not_packed_sint64s_alloc(
    struct repeated_message_scalar_value_types_not_packed_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_sint64(
                &self_p->base,
                length,
                &self_p->sint64s));
}

int repeated_message_scalar_value_types_not_packed_uint32s_alloc(
    struct repeated_message_scalar_value_types_not_packed_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_uint32(
                &self_p->base,
                length,
                &self_p->uint32s));
}

int repeated_message_scalar_value_types_not_packed_uint64s_alloc(
    struct repeated_message_scalar_value_types_not_packed_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_uint64(
                &self_p->base,
                length,
                &self_p->uint64s));
}

int repeated_message_scalar_value_types_not_packed_fixed32s_alloc(
    struct repeated_message_scalar_value_types_not_packed_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_fixed32(
                &self_p->base,
                length,
                &self_p->fixed32s));
}

int repeated_message_scalar_value_types_not_packed_fixed64s_alloc(
    struct repeated_message_scalar_value_types_not_packed_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_fixed64(
                &self_p->base,
                length,
                &self_p->fixed64s));
}

int repeated_message_scalar_value_types_not_packed_sfixed32s_alloc(
    struct repeated_message_scalar_value_types_not_packed_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_sfixed32(
                &self_p->base,
                length,
                &self_p->sfixed32s));
}

int repeated_message_scalar_value_types_not_packed_sfixed64s_alloc(
    struct repeated_message_scalar_value_types_not_packed_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_sfixed64(
                &self_p->base,
                length,
                &self_p->sfixed64s));
}

int repeated_message_scalar_value_types_not_packed_floats_alloc(
    struct repeated_message_scalar_value_types_not_packed_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_float(
                &self_p->base,
                length,
                &self_p->floats));
}

int repeated_message_scalar_value_types_not_packed_doubles_alloc(
    struct repeated_message_scalar_value_types_not_packed_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_double(
                &self_p->base,
                length,
                &self_p->doubles));
}

int repeated_message_scalar_value_types_not_packed_bools_alloc(
    struct repeated_message_scalar_value_types_not_packed_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_bool(
                &self_p->base,
                length,
                &self_p->bools));
}

int repeated_message_scalar_value_types_not_packed_strings_alloc(
    struct repeated_message_scalar_value_types_not_packed_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_string(
                &self_p->base,
                length,
                &self_p->strings));
}

int repeated_message_scalar_value_types_not_packed_bytess_alloc(
    struct repeated_message_scalar_value_types_not_packed_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_bytes(
                &self_p->base,
                length,
                &self_p->bytess));
}

void repeated_message_scalar_value_types_not_packed_encode_repeated_inner(
    struct pbtools_encoder_t *encoder_p,
    int field_number,
    struct repeated_message_scalar_value_types_not_packed_repeated_t *repeated_p)
{
    pbtools_encode_repeated_inner(
        encoder_p,
        field_number,
        (struct pbtools_repeated_message_t *)repeated_p,
        sizeof(struct repeated_message_scalar_value_types_not_packed_t),
        (pbtools_message_encode_inner_t)repeated_message_scalar_value_types_not_packed_encode_inner);
}

void repeated_message_scalar_value_types_not_packed_decode_repeated_inner(
    struct pbtools_decoder_t *decoder_p,
    struct pbtools_repeated_info_t *repeated_info_p,
    struct repeated_message_scalar_value_types_not_packed_repeated_t *repeated_p)
{
    pbtools_decode_repeated_inner(
        decoder_p,
        repeated_info_p,
        (struct pbtools_repeated_message_t *)repeated_p,
        sizeof(struct repeated_message_scalar_value_types_not_packed_t),
        (pbtools_message_init_t)repeated_message_scalar_value_types_not_packed_init,
        (pbtools_message_decode_inner_t)repeated_message_scalar_value_types_not_packed_decode_inner);
}

struct repeated_message_scalar_value_types_not_packed_t *
repeated_message_scalar_value_types_not_packed_new(
    void *workspace_p,
    size_t size)
{
    return (pbtools_message_new(
                workspace_p,
                size,
                sizeof(struct repeated_message_scalar_value_types_not_packed_t),
                (pbtools_message_init_t)repeated_message_scalar_value_types_not_packed_init));
}

int repeated_message_scalar_value_types_not_packed_encode(
    struct repeated_message_scalar_value_types_not_packed_t *self_p,
    uint8_t *encoded_p,
    size_t size)
{
    return (pbtools_message_encode(
                &self_p->base,
                encoded_p,
                size,
                (pbtools_message_encode_inner_t)repeated_message_scalar_value_types_not_packed_encode_inner));
}

int repeated_message_scalar_value_types_not_packed_decode(
    struct repeated_message_scalar_value_types_not_packed_t *self_p,
    const uint8_t *encoded_p,
    size_t size)
{
    return (pbtools_message_decode(
                &self_p->base,
                encoded_p,
                size,
                (pbtools_message_decode_inner_t)repeated_message_scalar_value_types_not_packed_decode_inner));
}

void repeated_foo_init(
    struct repeated_foo_t *self_p,
    struct pbtools_heap_t *heap_p)
{
    self_p->base.heap_p = heap_p;
    self_p->messages.length = 0;
    self_p->enums.length = 0;
}

void repeated_foo_encode_inner(
    struct pbtools_encoder_t *encoder_p,
    struct repeated_foo_t *self_p)
{
    pbtools_encoder_write_repeated_int32(encoder_p, 2, &self_p->enums);
    repeated_message_encode_repeated_inner(
        encoder_p,
        1,
        &self_p->messages);
}

void repeated_foo_decode_inner(
    struct pbtools_decoder_t *decoder_p,
    struct repeated_foo_t *self_p)
{
    int wire_type;
    struct pbtools_repeated_info_t repeated_info_messages;
    struct pbtools_repeated_info_t repeated_info_enums;

    pbtools_repeated_info_init(&repeated_info_messages, 1);
    pbtools_repeated_info_init(&repeated_info_enums, 2);

    while (pbtools_decoder_available(decoder_p)) {
        switch (pbtools_decoder_read_tag(decoder_p, &wire_type)) {

        case 1:
            pbtools_repeated_info_decode(&repeated_info_messages,
                                         decoder_p,
                                         wire_type);
            break;

        case 2:
            pbtools_repeated_info_decode_int32(
                &repeated_info_enums,
                decoder_p,
                wire_type);
            break;

        default:
            pbtools_decoder_skip_field(decoder_p, wire_type);
            break;
        }
    }

    repeated_message_decode_repeated_inner(
        decoder_p,
        &repeated_info_messages,
        &self_p->messages);
    pbtools_decoder_decode_repeated_int32(
        decoder_p,
        &repeated_info_enums,
        &self_p->enums);
}

int repeated_foo_messages_alloc(
    struct repeated_foo_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated(
                (struct pbtools_repeated_message_t *)&self_p->messages,
                length,
                self_p->base.heap_p,
                sizeof(struct repeated_message_t),
                (pbtools_message_init_t)repeated_message_init));
}

int repeated_foo_enums_alloc(
    struct repeated_foo_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated_int32(
                &self_p->base,
                length,
                &self_p->enums));
}

void repeated_foo_encode_repeated_inner(
    struct pbtools_encoder_t *encoder_p,
    int field_number,
    struct repeated_foo_repeated_t *repeated_p)
{
    pbtools_encode_repeated_inner(
        encoder_p,
        field_number,
        (struct pbtools_repeated_message_t *)repeated_p,
        sizeof(struct repeated_foo_t),
        (pbtools_message_encode_inner_t)repeated_foo_encode_inner);
}

void repeated_foo_decode_repeated_inner(
    struct pbtools_decoder_t *decoder_p,
    struct pbtools_repeated_info_t *repeated_info_p,
    struct repeated_foo_repeated_t *repeated_p)
{
    pbtools_decode_repeated_inner(
        decoder_p,
        repeated_info_p,
        (struct pbtools_repeated_message_t *)repeated_p,
        sizeof(struct repeated_foo_t),
        (pbtools_message_init_t)repeated_foo_init,
        (pbtools_message_decode_inner_t)repeated_foo_decode_inner);
}

struct repeated_foo_t *
repeated_foo_new(
    void *workspace_p,
    size_t size)
{
    return (pbtools_message_new(
                workspace_p,
                size,
                sizeof(struct repeated_foo_t),
                (pbtools_message_init_t)repeated_foo_init));
}

int repeated_foo_encode(
    struct repeated_foo_t *self_p,
    uint8_t *encoded_p,
    size_t size)
{
    return (pbtools_message_encode(
                &self_p->base,
                encoded_p,
                size,
                (pbtools_message_encode_inner_t)repeated_foo_encode_inner));
}

int repeated_foo_decode(
    struct repeated_foo_t *self_p,
    const uint8_t *encoded_p,
    size_t size)
{
    return (pbtools_message_decode(
                &self_p->base,
                encoded_p,
                size,
                (pbtools_message_decode_inner_t)repeated_foo_decode_inner));
}

void repeated_bar_fie_init(
    struct repeated_bar_fie_t *self_p,
    struct pbtools_heap_t *heap_p)
{
    self_p->base.heap_p = heap_p;
    self_p->inner_foos.length = 0;
}

void repeated_bar_fie_encode_inner(
    struct pbtools_encoder_t *encoder_p,
    struct repeated_bar_fie_t *self_p)
{
    repeated_foo_encode_repeated_inner(
        encoder_p,
        1,
        &self_p->inner_foos);
}

void repeated_bar_fie_decode_inner(
    struct pbtools_decoder_t *decoder_p,
    struct repeated_bar_fie_t *self_p)
{
    int wire_type;
    struct pbtools_repeated_info_t repeated_info_inner_foos;

    pbtools_repeated_info_init(&repeated_info_inner_foos, 1);

    while (pbtools_decoder_available(decoder_p)) {
        switch (pbtools_decoder_read_tag(decoder_p, &wire_type)) {

        case 1:
            pbtools_repeated_info_decode(&repeated_info_inner_foos,
                                         decoder_p,
                                         wire_type);
            break;

        default:
            pbtools_decoder_skip_field(decoder_p, wire_type);
            break;
        }
    }

    repeated_foo_decode_repeated_inner(
        decoder_p,
        &repeated_info_inner_foos,
        &self_p->inner_foos);
}

int repeated_bar_fie_inner_foos_alloc(
    struct repeated_bar_fie_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated(
                (struct pbtools_repeated_message_t *)&self_p->inner_foos,
                length,
                self_p->base.heap_p,
                sizeof(struct repeated_foo_t),
                (pbtools_message_init_t)repeated_foo_init));
}

void repeated_bar_fie_encode_repeated_inner(
    struct pbtools_encoder_t *encoder_p,
    int field_number,
    struct repeated_bar_fie_repeated_t *repeated_p)
{
    pbtools_encode_repeated_inner(
        encoder_p,
        field_number,
        (struct pbtools_repeated_message_t *)repeated_p,
        sizeof(struct repeated_bar_fie_t),
        (pbtools_message_encode_inner_t)repeated_bar_fie_encode_inner);
}

void repeated_bar_fie_decode_repeated_inner(
    struct pbtools_decoder_t *decoder_p,
    struct pbtools_repeated_info_t *repeated_info_p,
    struct repeated_bar_fie_repeated_t *repeated_p)
{
    pbtools_decode_repeated_inner(
        decoder_p,
        repeated_info_p,
        (struct pbtools_repeated_message_t *)repeated_p,
        sizeof(struct repeated_bar_fie_t),
        (pbtools_message_init_t)repeated_bar_fie_init,
        (pbtools_message_decode_inner_t)repeated_bar_fie_decode_inner);
}

void repeated_bar_init(
    struct repeated_bar_t *self_p,
    struct pbtools_heap_t *heap_p)
{
    self_p->base.heap_p = heap_p;
    self_p->foos.length = 0;
    self_p->fies.length = 0;
}

void repeated_bar_encode_inner(
    struct pbtools_encoder_t *encoder_p,
    struct repeated_bar_t *self_p)
{
    repeated_bar_fie_encode_repeated_inner(
        encoder_p,
        2,
        &self_p->fies);
    repeated_foo_encode_repeated_inner(
        encoder_p,
        1,
        &self_p->foos);
}

void repeated_bar_decode_inner(
    struct pbtools_decoder_t *decoder_p,
    struct repeated_bar_t *self_p)
{
    int wire_type;
    struct pbtools_repeated_info_t repeated_info_foos;
    struct pbtools_repeated_info_t repeated_info_fies;

    pbtools_repeated_info_init(&repeated_info_foos, 1);
    pbtools_repeated_info_init(&repeated_info_fies, 2);

    while (pbtools_decoder_available(decoder_p)) {
        switch (pbtools_decoder_read_tag(decoder_p, &wire_type)) {

        case 1:
            pbtools_repeated_info_decode(&repeated_info_foos,
                                         decoder_p,
                                         wire_type);
            break;

        case 2:
            pbtools_repeated_info_decode(&repeated_info_fies,
                                         decoder_p,
                                         wire_type);
            break;

        default:
            pbtools_decoder_skip_field(decoder_p, wire_type);
            break;
        }
    }

    repeated_foo_decode_repeated_inner(
        decoder_p,
        &repeated_info_foos,
        &self_p->foos);
    repeated_bar_fie_decode_repeated_inner(
        decoder_p,
        &repeated_info_fies,
        &self_p->fies);
}

int repeated_bar_foos_alloc(
    struct repeated_bar_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated(
                (struct pbtools_repeated_message_t *)&self_p->foos,
                length,
                self_p->base.heap_p,
                sizeof(struct repeated_foo_t),
                (pbtools_message_init_t)repeated_foo_init));
}

int repeated_bar_fies_alloc(
    struct repeated_bar_t *self_p,
    int length)
{
    return (pbtools_alloc_repeated(
                (struct pbtools_repeated_message_t *)&self_p->fies,
                length,
                self_p->base.heap_p,
                sizeof(struct repeated_bar_fie_t),
                (pbtools_message_init_t)repeated_bar_fie_init));
}

void repeated_bar_encode_repeated_inner(
    struct pbtools_encoder_t *encoder_p,
    int field_number,
    struct repeated_bar_repeated_t *repeated_p)
{
    pbtools_encode_repeated_inner(
        encoder_p,
        field_number,
        (struct pbtools_repeated_message_t *)repeated_p,
        sizeof(struct repeated_bar_t),
        (pbtools_message_encode_inner_t)repeated_bar_encode_inner);
}

void repeated_bar_decode_repeated_inner(
    struct pbtools_decoder_t *decoder_p,
    struct pbtools_repeated_info_t *repeated_info_p,
    struct repeated_bar_repeated_t *repeated_p)
{
    pbtools_decode_repeated_inner(
        decoder_p,
        repeated_info_p,
        (struct pbtools_repeated_message_t *)repeated_p,
        sizeof(struct repeated_bar_t),
        (pbtools_message_init_t)repeated_bar_init,
        (pbtools_message_decode_inner_t)repeated_bar_decode_inner);
}

struct repeated_bar_t *
repeated_bar_new(
    void *workspace_p,
    size_t size)
{
    return (pbtools_message_new(
                workspace_p,
                size,
                sizeof(struct repeated_bar_t),
                (pbtools_message_init_t)repeated_bar_init));
}

int repeated_bar_encode(
    struct repeated_bar_t *self_p,
    uint8_t *encoded_p,
    size_t size)
{
    return (pbtools_message_encode(
                &self_p->base,
                encoded_p,
                size,
                (pbtools_message_encode_inner_t)repeated_bar_encode_inner));
}

int repeated_bar_decode(
    struct repeated_bar_t *self_p,
    const uint8_t *encoded_p,
    size_t size)
{
    return (pbtools_message_decode(
                &self_p->base,
                encoded_p,
                size,
                (pbtools_message_decode_inner_t)repeated_bar_decode_inner));
}
