chromium/third_party/grpc/src/third_party/upb/upb/encode.c

/*
 * Copyright (c) 2009-2021, Google LLC
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of Google LLC nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT,
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/* We encode backwards, to avoid pre-computing lengths (one-pass encode). */

#include "upb/encode.h"

#include <setjmp.h>
#include <string.h>

#include "upb/extension_registry.h"
#include "upb/msg_internal.h"
#include "upb/upb.h"

/* Must be last. */
#include "upb/port_def.inc"

#define UPB_PB_VARINT_MAX_LEN

UPB_NOINLINE
static size_t encode_varint64(uint64_t val, char* buf) {}

static uint32_t encode_zz32(int32_t n) {}
static uint64_t encode_zz64(int64_t n) {}

upb_encstate;

static size_t upb_roundup_pow2(size_t bytes) {}

UPB_NORETURN static void encode_err(upb_encstate* e, upb_EncodeStatus s) {}

UPB_NOINLINE
static void encode_growbuffer(upb_encstate* e, size_t bytes) {}

/* Call to ensure that at least "bytes" bytes are available for writing at
 * e->ptr.  Returns false if the bytes could not be allocated. */
UPB_FORCEINLINE
static void encode_reserve(upb_encstate* e, size_t bytes) {}

/* Writes the given bytes to the buffer, handling reserve/advance. */
static void encode_bytes(upb_encstate* e, const void* data, size_t len) {}

static void encode_fixed64(upb_encstate* e, uint64_t val) {}

static void encode_fixed32(upb_encstate* e, uint32_t val) {}

UPB_NOINLINE
static void encode_longvarint(upb_encstate* e, uint64_t val) {}

UPB_FORCEINLINE
static void encode_varint(upb_encstate* e, uint64_t val) {}

static void encode_double(upb_encstate* e, double d) {}

static void encode_float(upb_encstate* e, float d) {}

static void encode_tag(upb_encstate* e, uint32_t field_number,
                       uint8_t wire_type) {}

static void encode_fixedarray(upb_encstate* e, const upb_Array* arr,
                              size_t elem_size, uint32_t tag) {}

static void encode_message(upb_encstate* e, const upb_Message* msg,
                           const upb_MiniTable* m, size_t* size);

static void encode_scalar(upb_encstate* e, const void* _field_mem,
                          const upb_MiniTable_Sub* subs,
                          const upb_MiniTable_Field* f) {}

static void encode_array(upb_encstate* e, const upb_Message* msg,
                         const upb_MiniTable_Sub* subs,
                         const upb_MiniTable_Field* f) {}

static void encode_mapentry(upb_encstate* e, uint32_t number,
                            const upb_MiniTable* layout,
                            const upb_MapEntry* ent) {}

static void encode_map(upb_encstate* e, const upb_Message* msg,
                       const upb_MiniTable_Sub* subs,
                       const upb_MiniTable_Field* f) {}

static bool encode_shouldencode(upb_encstate* e, const upb_Message* msg,
                                const upb_MiniTable_Sub* subs,
                                const upb_MiniTable_Field* f) {}

static void encode_field(upb_encstate* e, const upb_Message* msg,
                         const upb_MiniTable_Sub* subs,
                         const upb_MiniTable_Field* field) {}

/* message MessageSet {
 *   repeated group Item = 1 {
 *     required int32 type_id = 2;
 *     required string message = 3;
 *   }
 * } */
static void encode_msgset_item(upb_encstate* e,
                               const upb_Message_Extension* ext) {}

static void encode_message(upb_encstate* e, const upb_Message* msg,
                           const upb_MiniTable* m, size_t* size) {}

upb_EncodeStatus upb_Encode(const void* msg, const upb_MiniTable* l,
                            int options, upb_Arena* arena, char** buf,
                            size_t* size) {}