Implemented scalar fields for upb.js and Dart+upb.js.

PiperOrigin-RevId: 522658020
pull/13171/head
Joshua Haberman 2 years ago committed by Copybara-Service
parent 7ebeb6006b
commit a918473c65
  1. 4
      upb/mem/arena.h
  2. 4
      upb/message/accessors.h
  3. 5
      upb/mini_table/field_internal.h
  4. 4
      upb/mini_table/message_internal.h

@ -49,10 +49,14 @@
typedef struct upb_Arena upb_Arena;
// LINT.IfChange(arena_head)
typedef struct {
char *ptr, *end;
} _upb_ArenaHead;
// LINT.ThenChange(//depot/google3/third_party/upb/js/impl/upb_bits/arena.ts:arena_head)
#ifdef __cplusplus
extern "C" {
#endif

@ -87,6 +87,8 @@ UPB_INLINE void _upb_Message_SetPresence(upb_Message* msg,
}
}
// LINT.IfChange(message_raw_fields)
UPB_INLINE bool _upb_MiniTable_ValueIsNonZero(const void* default_val,
const upb_MiniTableField* field) {
char zero[16] = {0};
@ -125,6 +127,8 @@ UPB_INLINE void _upb_MiniTable_CopyFieldData(void* to, const void* from,
UPB_UNREACHABLE();
}
// LINT.ThenChange(//depot/google3/third_party/upb/js/impl/upb_bits/message.ts:message_raw_fields)
UPB_INLINE size_t
_upb_MiniTable_ElementSizeLg2(const upb_MiniTableField* field) {
const unsigned char table[] = {

@ -34,6 +34,8 @@
// Must be last.
#include "upb/port/def.inc"
// LINT.IfChange(mini_table_field_layout)
struct upb_MiniTableField {
uint32_t number;
uint16_t offset;
@ -82,6 +84,8 @@ typedef enum {
#define kUpb_FieldRep_Shift 6
// LINT.ThenChange(//depot/google3/third_party/upb/js/impl/upb_bits/mini_table_field.ts:mini_table_field_layout)
UPB_INLINE upb_FieldRep
_upb_MiniTableField_GetRep(const upb_MiniTableField* field) {
return (upb_FieldRep)(field->mode >> kUpb_FieldRep_Shift);
@ -173,6 +177,7 @@ UPB_INLINE uint32_t _upb_getoneofcase_field(const upb_Message* msg,
}
// LINT.ThenChange(GoogleInternalName2)
// LINT.ThenChange(//depot/google3/third_party/upb/js/impl/upb_bits/presence.ts:presence_logic)
#ifdef __cplusplus
} /* extern "C" */

@ -56,6 +56,8 @@ typedef enum {
kUpb_ExtMode_IsMapEntry = 4,
} upb_ExtMode;
// LINT.IfChange(mini_table_layout)
// upb_MiniTable represents the memory layout of a given upb_MessageDef.
// The members are public so generated code can initialize them,
// but users MUST NOT directly read or write any of its members.
@ -79,6 +81,8 @@ struct upb_MiniTable {
_upb_FastTable_Entry fasttable[];
};
// LINT.ThenChange(//depot/google3/third_party/upb/js/impl/upb_bits/mini_table.ts:presence_logic)
// Map entries aren't actually stored for map fields, they are only used during
// parsing. For parsing, it helps a lot if all map entry messages have the same
// layout. The layout code in mini_table/decode.c will ensure that all map

Loading…
Cancel
Save