|
|
@ -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); |
|
|
|
} |
|
|
|
} |
|
|
|