upb: remove duplicate typedef for upb_TaggedMessagePtr

PiperOrigin-RevId: 596706308
pull/15316/head
Eric Salo 11 months ago committed by Copybara-Service
parent 434d109d9c
commit 87618fcbdd
  1. 4
      upb/message/internal/accessors.h
  2. 13
      upb/message/internal/tagged_ptr.h
  3. 6
      upb/message/value.h

@ -311,8 +311,8 @@ UPB_INLINE void _upb_Message_AssertMapIsUntagged(
UPB_UNUSED(msg); UPB_UNUSED(msg);
UPB_PRIVATE(_upb_MiniTableField_CheckIsMap)(field); UPB_PRIVATE(_upb_MiniTableField_CheckIsMap)(field);
#ifndef NDEBUG #ifndef NDEBUG
upb_TaggedMessagePtr default_val = 0; uintptr_t default_val = 0;
upb_TaggedMessagePtr tagged; uintptr_t tagged;
_upb_Message_GetNonExtensionField(msg, field, &default_val, &tagged); _upb_Message_GetNonExtensionField(msg, field, &default_val, &tagged);
UPB_ASSERT(!UPB_PRIVATE(_upb_TaggedMessagePtr_IsEmpty)(tagged)); UPB_ASSERT(!UPB_PRIVATE(_upb_TaggedMessagePtr_IsEmpty)(tagged));
#endif #endif

@ -15,37 +15,34 @@
// Must be last. // Must be last.
#include "upb/port/def.inc" #include "upb/port/def.inc"
typedef uintptr_t upb_TaggedMessagePtr;
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
// Internal-only because empty messages cannot be created by the user. // Internal-only because empty messages cannot be created by the user.
UPB_INLINE upb_TaggedMessagePtr UPB_INLINE uintptr_t
UPB_PRIVATE(_upb_TaggedMessagePtr_Pack)(struct upb_Message* ptr, bool empty) { UPB_PRIVATE(_upb_TaggedMessagePtr_Pack)(struct upb_Message* ptr, bool empty) {
UPB_ASSERT(((uintptr_t)ptr & 1) == 0); UPB_ASSERT(((uintptr_t)ptr & 1) == 0);
return (uintptr_t)ptr | (empty ? 1 : 0); return (uintptr_t)ptr | (empty ? 1 : 0);
} }
UPB_INLINE bool UPB_PRIVATE(_upb_TaggedMessagePtr_IsEmpty)( UPB_INLINE bool UPB_PRIVATE(_upb_TaggedMessagePtr_IsEmpty)(uintptr_t ptr) {
upb_TaggedMessagePtr ptr) {
return ptr & 1; return ptr & 1;
} }
UPB_INLINE struct upb_Message* UPB_PRIVATE(_upb_TaggedMessagePtr_GetMessage)( UPB_INLINE struct upb_Message* UPB_PRIVATE(_upb_TaggedMessagePtr_GetMessage)(
upb_TaggedMessagePtr ptr) { uintptr_t ptr) {
return (struct upb_Message*)(ptr & ~(uintptr_t)1); return (struct upb_Message*)(ptr & ~(uintptr_t)1);
} }
UPB_INLINE struct upb_Message* UPB_PRIVATE( UPB_INLINE struct upb_Message* UPB_PRIVATE(
_upb_TaggedMessagePtr_GetNonEmptyMessage)(upb_TaggedMessagePtr ptr) { _upb_TaggedMessagePtr_GetNonEmptyMessage)(uintptr_t ptr) {
UPB_ASSERT(!UPB_PRIVATE(_upb_TaggedMessagePtr_IsEmpty)(ptr)); UPB_ASSERT(!UPB_PRIVATE(_upb_TaggedMessagePtr_IsEmpty)(ptr));
return UPB_PRIVATE(_upb_TaggedMessagePtr_GetMessage)(ptr); return UPB_PRIVATE(_upb_TaggedMessagePtr_GetMessage)(ptr);
} }
UPB_INLINE struct upb_Message* UPB_PRIVATE( UPB_INLINE struct upb_Message* UPB_PRIVATE(
_upb_TaggedMessagePtr_GetEmptyMessage)(upb_TaggedMessagePtr ptr) { _upb_TaggedMessagePtr_GetEmptyMessage)(uintptr_t ptr) {
UPB_ASSERT(UPB_PRIVATE(_upb_TaggedMessagePtr_IsEmpty)(ptr)); UPB_ASSERT(UPB_PRIVATE(_upb_TaggedMessagePtr_IsEmpty)(ptr));
return UPB_PRIVATE(_upb_TaggedMessagePtr_GetMessage)(ptr); return UPB_PRIVATE(_upb_TaggedMessagePtr_GetMessage)(ptr);
} }

@ -14,10 +14,6 @@
#include <stdint.h> #include <stdint.h>
#include "upb/base/string_view.h" #include "upb/base/string_view.h"
#include "upb/message/internal/array.h"
#include "upb/message/internal/map.h"
#include "upb/message/internal/message.h"
#include "upb/message/internal/tagged_ptr.h"
typedef union { typedef union {
bool bool_val; bool bool_val;
@ -36,7 +32,7 @@ typedef union {
// msg_val if unlinked sub-messages may possibly be in use. See the // msg_val if unlinked sub-messages may possibly be in use. See the
// documentation in kUpb_DecodeOption_ExperimentalAllowUnlinked for more // documentation in kUpb_DecodeOption_ExperimentalAllowUnlinked for more
// information. // information.
upb_TaggedMessagePtr tagged_msg_val; uintptr_t tagged_msg_val; // upb_TaggedMessagePtr
} upb_MessageValue; } upb_MessageValue;
typedef union { typedef union {

Loading…
Cancel
Save