From 0e286b4037fa395bd8e4202d36b530308f7d52ba Mon Sep 17 00:00:00 2001 From: Eric Salo Date: Thu, 5 Jan 2023 15:00:51 -0800 Subject: [PATCH] hook up Dart Int64 scalars PiperOrigin-RevId: 500017090 --- upbc/upbc_so.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/upbc/upbc_so.c b/upbc/upbc_so.c index 6e498865be..b40b9b645a 100644 --- a/upbc/upbc_so.c +++ b/upbc/upbc_so.c @@ -40,3 +40,43 @@ // Must be last. #include "upb/port/def.inc" + +// JavaScript doesn't directly support 64-bit ints so we must split them. + +UPB_API_INLINE uint32_t upb_Message_GetInt64Hi(const upb_Message* msg, + const upb_MiniTableField* field, + uint32_t default_value) { + return (uint32_t)(upb_Message_GetInt64(msg, field, default_value) >> 32); +} + +UPB_API_INLINE uint32_t upb_Message_GetInt64Lo(const upb_Message* msg, + const upb_MiniTableField* field, + uint32_t default_value) { + return (uint32_t)upb_Message_GetInt64(msg, field, default_value); +} + +UPB_API_INLINE bool upb_Message_SetInt64Split(upb_Message* msg, + const upb_MiniTableField* field, + uint32_t hi, uint32_t lo, + upb_Arena* a) { + return upb_Message_SetInt64(msg, field, ((int64_t)hi << 32) | lo, a); +} + +UPB_API_INLINE uint32_t upb_Message_GetUInt64Hi(const upb_Message* msg, + const upb_MiniTableField* field, + uint32_t default_value) { + return (uint32_t)(upb_Message_GetUInt64(msg, field, default_value) >> 32); +} + +UPB_API_INLINE uint32_t upb_Message_GetUInt64Lo(const upb_Message* msg, + const upb_MiniTableField* field, + uint32_t default_value) { + return (uint32_t)upb_Message_GetUInt64(msg, field, default_value); +} + +UPB_API_INLINE bool upb_Message_SetUInt64Split(upb_Message* msg, + const upb_MiniTableField* field, + uint32_t hi, uint32_t lo, + upb_Arena* a) { + return upb_Message_SetUInt64(msg, field, ((uint64_t)hi << 32) | lo, a); +}