Classes | Macros | Functions
encode.c File Reference
#include "upb/encode.h"
#include <setjmp.h>
#include <string.h>
#include "upb/msg_internal.h"
#include "upb/upb.h"
#include "upb/port_def.inc"
Include dependency graph for encode.c:

Go to the source code of this file.

Classes

struct  upb_encstate
 

Macros

#define CASE(ctype, type, wtype, encodeval)
 
#define TAG(wire_type)   (packed ? 0 : (f->number << 3 | wire_type))
 
#define UPB_PB_VARINT_MAX_LEN   10
 
#define VARINT_CASE(ctype, encode)
 

Functions

static void encode_array (upb_encstate *e, const upb_Message *msg, const upb_MiniTable_Sub *subs, const upb_MiniTable_Field *f)
 
static void encode_bytes (upb_encstate *e, const void *data, size_t len)
 
static void encode_double (upb_encstate *e, double d)
 
static UPB_NORETURN void encode_err (upb_encstate *e)
 
static void encode_field (upb_encstate *e, const upb_Message *msg, const upb_MiniTable_Sub *subs, const upb_MiniTable_Field *field)
 
static void encode_fixed32 (upb_encstate *e, uint32_t val)
 
static void encode_fixed64 (upb_encstate *e, uint64_t val)
 
static void encode_fixedarray (upb_encstate *e, const upb_Array *arr, size_t elem_size, uint32_t tag)
 
static void encode_float (upb_encstate *e, float d)
 
static UPB_NOINLINE void encode_growbuffer (upb_encstate *e, size_t bytes)
 
static UPB_NOINLINE void encode_longvarint (upb_encstate *e, uint64_t val)
 
static void encode_map (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_message (upb_encstate *e, const upb_Message *msg, const upb_MiniTable *m, size_t *size)
 
static void encode_msgset_item (upb_encstate *e, const upb_Message_Extension *ext)
 
static UPB_FORCEINLINE void encode_reserve (upb_encstate *e, size_t bytes)
 
static void encode_scalar (upb_encstate *e, const void *_field_mem, 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_tag (upb_encstate *e, uint32_t field_number, uint8_t wire_type)
 
static UPB_FORCEINLINE void encode_varint (upb_encstate *e, uint64_t val)
 
static UPB_NOINLINE 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)
 
char * upb_Encode (const void *msg, const upb_MiniTable *l, int options, upb_Arena *arena, size_t *size)
 
static size_t upb_roundup_pow2 (size_t bytes)
 

Macro Definition Documentation

◆ CASE

#define CASE (   ctype,
  type,
  wtype,
  encodeval 
)
Value:
{ \
ctype val = *(ctype*)field_mem; \
encode_##type(e, encodeval); \
wire_type = wtype; \
break; \
}

◆ TAG

#define TAG (   wire_type)    (packed ? 0 : (f->number << 3 | wire_type))

◆ UPB_PB_VARINT_MAX_LEN

#define UPB_PB_VARINT_MAX_LEN   10

Definition at line 41 of file encode.c.

◆ VARINT_CASE

#define VARINT_CASE (   ctype,
  encode 
)
Value:
{ \
const ctype* start = _upb_array_constptr(arr); \
const ctype* ptr = start + arr->len; \
uint32_t tag = packed ? 0 : (f->number << 3) | kUpb_WireType_Varint; \
do { \
ptr--; \
encode_varint(e, encode); \
if (tag) encode_varint(e, tag); \
} while (ptr != start); \
} \
break;

Function Documentation

◆ encode_array()

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

Definition at line 287 of file encode.c.

◆ encode_bytes()

static void encode_bytes ( upb_encstate e,
const void *  data,
size_t  len 
)
static

Definition at line 114 of file encode.c.

◆ encode_double()

static void encode_double ( upb_encstate e,
double  d 
)
static

Definition at line 152 of file encode.c.

◆ encode_err()

static UPB_NORETURN void encode_err ( upb_encstate e)
static

Definition at line 79 of file encode.c.

◆ encode_field()

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

Definition at line 483 of file encode.c.

◆ encode_fixed32()

static void encode_fixed32 ( upb_encstate e,
uint32_t  val 
)
static

Definition at line 125 of file encode.c.

◆ encode_fixed64()

static void encode_fixed64 ( upb_encstate e,
uint64_t  val 
)
static

Definition at line 120 of file encode.c.

◆ encode_fixedarray()

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

Definition at line 171 of file encode.c.

◆ encode_float()

static void encode_float ( upb_encstate e,
float  d 
)
static

Definition at line 159 of file encode.c.

◆ encode_growbuffer()

static UPB_NOINLINE void encode_growbuffer ( upb_encstate e,
size_t  bytes 
)
static

Definition at line 82 of file encode.c.

◆ encode_longvarint()

static UPB_NOINLINE void encode_longvarint ( upb_encstate e,
uint64_t  val 
)
static

Definition at line 131 of file encode.c.

◆ encode_map()

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

Definition at line 407 of file encode.c.

◆ encode_mapentry()

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

Definition at line 393 of file encode.c.

◆ encode_message()

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

Definition at line 519 of file encode.c.

◆ encode_msgset_item()

static void encode_msgset_item ( upb_encstate e,
const upb_Message_Extension ext 
)
static

Definition at line 507 of file encode.c.

◆ encode_reserve()

static UPB_FORCEINLINE void encode_reserve ( upb_encstate e,
size_t  bytes 
)
static

Definition at line 104 of file encode.c.

◆ encode_scalar()

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

Definition at line 204 of file encode.c.

◆ encode_shouldencode()

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

Definition at line 439 of file encode.c.

◆ encode_tag()

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

Definition at line 166 of file encode.c.

◆ encode_varint()

static UPB_FORCEINLINE void encode_varint ( upb_encstate e,
uint64_t  val 
)
static

Definition at line 143 of file encode.c.

◆ encode_varint64()

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

Definition at line 44 of file encode.c.

◆ encode_zz32()

static uint32_t encode_zz32 ( int32_t  n)
static

Definition at line 55 of file encode.c.

◆ encode_zz64()

static uint64_t encode_zz64 ( int64_t  n)
static

Definition at line 58 of file encode.c.

◆ upb_Encode()

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

Definition at line 573 of file encode.c.

◆ upb_roundup_pow2()

static size_t upb_roundup_pow2 ( size_t  bytes)
static

Definition at line 71 of file encode.c.

ptr
char * ptr
Definition: abseil-cpp/absl/base/internal/low_level_alloc_test.cc:45
grpc._common.encode
def encode(s)
Definition: grpc/_common.py:68
start
static uint64_t start
Definition: benchmark-pound.c:74
autogen_x86imm.f
f
Definition: autogen_x86imm.py:9
tag
static void * tag(intptr_t t)
Definition: bad_client.cc:318
encode_varint
static UPB_FORCEINLINE void encode_varint(upb_encstate *e, uint64_t val)
Definition: encode.c:143
kUpb_WireType_Varint
@ kUpb_WireType_Varint
Definition: upb/upb/upb.h:275
_upb_array_constptr
const UPB_INLINE void * _upb_array_constptr(const upb_array *arr)
Definition: php-upb.h:1340
asyncio_get_stats.type
type
Definition: asyncio_get_stats.py:37


grpc
Author(s):
autogenerated on Fri May 16 2025 03:01:11