Skip to content

Commit c8c9cf3

Browse files
Auto-generate files after cl/698437576
1 parent 35dbd5c commit c8c9cf3

File tree

4 files changed

+122
-106
lines changed

4 files changed

+122
-106
lines changed

php/ext/google/protobuf/php-upb.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -7098,7 +7098,7 @@ static void upb_Decoder_AddKnownMessageSetItem(
70987098
}
70997099
upb_Message* submsg = _upb_Decoder_NewSubMessage2(
71007100
d, ext->ext->UPB_PRIVATE(sub).UPB_PRIVATE(submsg),
7101-
&ext->ext->UPB_PRIVATE(field), (upb_TaggedMessagePtr*)&ext->data);
7101+
&ext->ext->UPB_PRIVATE(field), &ext->data.tagged_msg_val);
71027102
upb_DecodeStatus status = upb_Decode(
71037103
data, size, submsg, upb_MiniTableExtension_GetSubMessage(item_mt),
71047104
d->extreg, d->options, &d->arena);
@@ -7452,7 +7452,7 @@ const char* _upb_Decoder_DecodeKnownField(upb_Decoder* d, const char* ptr,
74527452
_upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_OutOfMemory);
74537453
}
74547454
d->original_msg = msg;
7455-
msg = (upb_Message*)&ext->data;
7455+
msg = &ext->data.UPB_PRIVATE(ext_msg_val);
74567456
if (upb_MiniTableField_IsSubMessage(&ext->ext->UPB_PRIVATE(field))) {
74577457
ext_sub.UPB_PRIVATE(submsg) =
74587458
&ext->ext->UPB_PRIVATE(sub).UPB_PRIVATE(submsg);
@@ -8260,7 +8260,7 @@ static void encode_ext(upb_encstate* e, const upb_Extension* ext,
82608260
sub.UPB_PRIVATE(subenum) =
82618261
ext->ext->UPB_PRIVATE(sub).UPB_PRIVATE(subenum);
82628262
}
8263-
encode_field(e, (upb_Message*)&ext->data, &sub,
8263+
encode_field(e, &ext->data.UPB_PRIVATE(ext_msg_val), &sub,
82648264
&ext->ext->UPB_PRIVATE(field));
82658265
}
82668266
}

php/ext/google/protobuf/php-upb.h

+58-50
Original file line numberDiff line numberDiff line change
@@ -1244,6 +1244,56 @@ UPB_INLINE bool upb_StringView_IsEqual(upb_StringView a, upb_StringView b) {
12441244
#include <string.h>
12451245

12461246

1247+
#ifndef UPB_MESSAGE_INTERNAL_TYPES_H_
1248+
#define UPB_MESSAGE_INTERNAL_TYPES_H_
1249+
1250+
#include <stdint.h>
1251+
1252+
// Must be last.
1253+
1254+
#define UPB_OPAQUE(x) x##_opaque
1255+
1256+
struct upb_Message {
1257+
union {
1258+
uintptr_t UPB_OPAQUE(internal); // tagged pointer, low bit == frozen
1259+
double d; // Forces same size for 32-bit/64-bit builds
1260+
};
1261+
};
1262+
1263+
#ifdef __cplusplus
1264+
extern "C" {
1265+
#endif
1266+
1267+
UPB_INLINE void UPB_PRIVATE(_upb_Message_ShallowFreeze)(
1268+
struct upb_Message* msg) {
1269+
msg->UPB_OPAQUE(internal) |= 1ULL;
1270+
}
1271+
1272+
UPB_API_INLINE bool upb_Message_IsFrozen(const struct upb_Message* msg) {
1273+
return (msg->UPB_OPAQUE(internal) & 1ULL) != 0;
1274+
}
1275+
1276+
UPB_INLINE struct upb_Message_Internal* UPB_PRIVATE(_upb_Message_GetInternal)(
1277+
const struct upb_Message* msg) {
1278+
const uintptr_t tmp = msg->UPB_OPAQUE(internal) & ~1ULL;
1279+
return (struct upb_Message_Internal*)tmp;
1280+
}
1281+
1282+
UPB_INLINE void UPB_PRIVATE(_upb_Message_SetInternal)(
1283+
struct upb_Message* msg, struct upb_Message_Internal* internal) {
1284+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
1285+
msg->UPB_OPAQUE(internal) = (uintptr_t)internal;
1286+
}
1287+
1288+
#ifdef __cplusplus
1289+
} /* extern "C" */
1290+
#endif
1291+
1292+
#undef UPB_OPAQUE
1293+
1294+
1295+
#endif /* UPB_MESSAGE_INTERNAL_TYPES_H_ */
1296+
12471297
// Must be last.
12481298

12491299
#ifdef __cplusplus
@@ -1268,6 +1318,14 @@ typedef union {
12681318
// documentation in kUpb_DecodeOption_ExperimentalAllowUnlinked for more
12691319
// information.
12701320
uintptr_t tagged_msg_val; // upb_TaggedMessagePtr
1321+
1322+
// For an extension field, we are essentially treating ext->data (a
1323+
// upb_MessageValue) as if it were a message with one field that lives at
1324+
// offset 0. This works because upb_MessageValue is precisely one value that
1325+
// can hold any type of data. Recall that an extension can be of any type
1326+
// (scalar, repeated, or message). For a message extension, that will be a
1327+
// single upb_Message* at offset 0 of the upb_MessageValue.
1328+
struct upb_Message UPB_PRIVATE(ext_msg_val);
12711329
} upb_MessageValue;
12721330

12731331
UPB_API_INLINE upb_MessageValue upb_MessageValue_Zero(void) {
@@ -2343,56 +2401,6 @@ bool UPB_PRIVATE(_upb_Message_Realloc)(struct upb_Message* msg, size_t need,
23432401

23442402
#endif /* UPB_MESSAGE_INTERNAL_MESSAGE_H_ */
23452403

2346-
#ifndef UPB_MESSAGE_INTERNAL_TYPES_H_
2347-
#define UPB_MESSAGE_INTERNAL_TYPES_H_
2348-
2349-
#include <stdint.h>
2350-
2351-
// Must be last.
2352-
2353-
#define UPB_OPAQUE(x) x##_opaque
2354-
2355-
struct upb_Message {
2356-
union {
2357-
uintptr_t UPB_OPAQUE(internal); // tagged pointer, low bit == frozen
2358-
double d; // Forces same size for 32-bit/64-bit builds
2359-
};
2360-
};
2361-
2362-
#ifdef __cplusplus
2363-
extern "C" {
2364-
#endif
2365-
2366-
UPB_INLINE void UPB_PRIVATE(_upb_Message_ShallowFreeze)(
2367-
struct upb_Message* msg) {
2368-
msg->UPB_OPAQUE(internal) |= 1ULL;
2369-
}
2370-
2371-
UPB_API_INLINE bool upb_Message_IsFrozen(const struct upb_Message* msg) {
2372-
return (msg->UPB_OPAQUE(internal) & 1ULL) != 0;
2373-
}
2374-
2375-
UPB_INLINE struct upb_Message_Internal* UPB_PRIVATE(_upb_Message_GetInternal)(
2376-
const struct upb_Message* msg) {
2377-
const uintptr_t tmp = msg->UPB_OPAQUE(internal) & ~1ULL;
2378-
return (struct upb_Message_Internal*)tmp;
2379-
}
2380-
2381-
UPB_INLINE void UPB_PRIVATE(_upb_Message_SetInternal)(
2382-
struct upb_Message* msg, struct upb_Message_Internal* internal) {
2383-
UPB_ASSERT(!upb_Message_IsFrozen(msg));
2384-
msg->UPB_OPAQUE(internal) = (uintptr_t)internal;
2385-
}
2386-
2387-
#ifdef __cplusplus
2388-
} /* extern "C" */
2389-
#endif
2390-
2391-
#undef UPB_OPAQUE
2392-
2393-
2394-
#endif /* UPB_MESSAGE_INTERNAL_TYPES_H_ */
2395-
23962404
// Must be last.
23972405

23982406
typedef struct upb_Message upb_Message;

ruby/ext/google/protobuf_c/ruby-upb.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -7098,7 +7098,7 @@ static void upb_Decoder_AddKnownMessageSetItem(
70987098
}
70997099
upb_Message* submsg = _upb_Decoder_NewSubMessage2(
71007100
d, ext->ext->UPB_PRIVATE(sub).UPB_PRIVATE(submsg),
7101-
&ext->ext->UPB_PRIVATE(field), (upb_TaggedMessagePtr*)&ext->data);
7101+
&ext->ext->UPB_PRIVATE(field), &ext->data.tagged_msg_val);
71027102
upb_DecodeStatus status = upb_Decode(
71037103
data, size, submsg, upb_MiniTableExtension_GetSubMessage(item_mt),
71047104
d->extreg, d->options, &d->arena);
@@ -7452,7 +7452,7 @@ const char* _upb_Decoder_DecodeKnownField(upb_Decoder* d, const char* ptr,
74527452
_upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_OutOfMemory);
74537453
}
74547454
d->original_msg = msg;
7455-
msg = (upb_Message*)&ext->data;
7455+
msg = &ext->data.UPB_PRIVATE(ext_msg_val);
74567456
if (upb_MiniTableField_IsSubMessage(&ext->ext->UPB_PRIVATE(field))) {
74577457
ext_sub.UPB_PRIVATE(submsg) =
74587458
&ext->ext->UPB_PRIVATE(sub).UPB_PRIVATE(submsg);
@@ -8260,7 +8260,7 @@ static void encode_ext(upb_encstate* e, const upb_Extension* ext,
82608260
sub.UPB_PRIVATE(subenum) =
82618261
ext->ext->UPB_PRIVATE(sub).UPB_PRIVATE(subenum);
82628262
}
8263-
encode_field(e, (upb_Message*)&ext->data, &sub,
8263+
encode_field(e, &ext->data.UPB_PRIVATE(ext_msg_val), &sub,
82648264
&ext->ext->UPB_PRIVATE(field));
82658265
}
82668266
}

ruby/ext/google/protobuf_c/ruby-upb.h

+58-50
Original file line numberDiff line numberDiff line change
@@ -1246,6 +1246,56 @@ UPB_INLINE bool upb_StringView_IsEqual(upb_StringView a, upb_StringView b) {
12461246
#include <string.h>
12471247

12481248

1249+
#ifndef UPB_MESSAGE_INTERNAL_TYPES_H_
1250+
#define UPB_MESSAGE_INTERNAL_TYPES_H_
1251+
1252+
#include <stdint.h>
1253+
1254+
// Must be last.
1255+
1256+
#define UPB_OPAQUE(x) x##_opaque
1257+
1258+
struct upb_Message {
1259+
union {
1260+
uintptr_t UPB_OPAQUE(internal); // tagged pointer, low bit == frozen
1261+
double d; // Forces same size for 32-bit/64-bit builds
1262+
};
1263+
};
1264+
1265+
#ifdef __cplusplus
1266+
extern "C" {
1267+
#endif
1268+
1269+
UPB_INLINE void UPB_PRIVATE(_upb_Message_ShallowFreeze)(
1270+
struct upb_Message* msg) {
1271+
msg->UPB_OPAQUE(internal) |= 1ULL;
1272+
}
1273+
1274+
UPB_API_INLINE bool upb_Message_IsFrozen(const struct upb_Message* msg) {
1275+
return (msg->UPB_OPAQUE(internal) & 1ULL) != 0;
1276+
}
1277+
1278+
UPB_INLINE struct upb_Message_Internal* UPB_PRIVATE(_upb_Message_GetInternal)(
1279+
const struct upb_Message* msg) {
1280+
const uintptr_t tmp = msg->UPB_OPAQUE(internal) & ~1ULL;
1281+
return (struct upb_Message_Internal*)tmp;
1282+
}
1283+
1284+
UPB_INLINE void UPB_PRIVATE(_upb_Message_SetInternal)(
1285+
struct upb_Message* msg, struct upb_Message_Internal* internal) {
1286+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
1287+
msg->UPB_OPAQUE(internal) = (uintptr_t)internal;
1288+
}
1289+
1290+
#ifdef __cplusplus
1291+
} /* extern "C" */
1292+
#endif
1293+
1294+
#undef UPB_OPAQUE
1295+
1296+
1297+
#endif /* UPB_MESSAGE_INTERNAL_TYPES_H_ */
1298+
12491299
// Must be last.
12501300

12511301
#ifdef __cplusplus
@@ -1270,6 +1320,14 @@ typedef union {
12701320
// documentation in kUpb_DecodeOption_ExperimentalAllowUnlinked for more
12711321
// information.
12721322
uintptr_t tagged_msg_val; // upb_TaggedMessagePtr
1323+
1324+
// For an extension field, we are essentially treating ext->data (a
1325+
// upb_MessageValue) as if it were a message with one field that lives at
1326+
// offset 0. This works because upb_MessageValue is precisely one value that
1327+
// can hold any type of data. Recall that an extension can be of any type
1328+
// (scalar, repeated, or message). For a message extension, that will be a
1329+
// single upb_Message* at offset 0 of the upb_MessageValue.
1330+
struct upb_Message UPB_PRIVATE(ext_msg_val);
12731331
} upb_MessageValue;
12741332

12751333
UPB_API_INLINE upb_MessageValue upb_MessageValue_Zero(void) {
@@ -2345,56 +2403,6 @@ bool UPB_PRIVATE(_upb_Message_Realloc)(struct upb_Message* msg, size_t need,
23452403

23462404
#endif /* UPB_MESSAGE_INTERNAL_MESSAGE_H_ */
23472405

2348-
#ifndef UPB_MESSAGE_INTERNAL_TYPES_H_
2349-
#define UPB_MESSAGE_INTERNAL_TYPES_H_
2350-
2351-
#include <stdint.h>
2352-
2353-
// Must be last.
2354-
2355-
#define UPB_OPAQUE(x) x##_opaque
2356-
2357-
struct upb_Message {
2358-
union {
2359-
uintptr_t UPB_OPAQUE(internal); // tagged pointer, low bit == frozen
2360-
double d; // Forces same size for 32-bit/64-bit builds
2361-
};
2362-
};
2363-
2364-
#ifdef __cplusplus
2365-
extern "C" {
2366-
#endif
2367-
2368-
UPB_INLINE void UPB_PRIVATE(_upb_Message_ShallowFreeze)(
2369-
struct upb_Message* msg) {
2370-
msg->UPB_OPAQUE(internal) |= 1ULL;
2371-
}
2372-
2373-
UPB_API_INLINE bool upb_Message_IsFrozen(const struct upb_Message* msg) {
2374-
return (msg->UPB_OPAQUE(internal) & 1ULL) != 0;
2375-
}
2376-
2377-
UPB_INLINE struct upb_Message_Internal* UPB_PRIVATE(_upb_Message_GetInternal)(
2378-
const struct upb_Message* msg) {
2379-
const uintptr_t tmp = msg->UPB_OPAQUE(internal) & ~1ULL;
2380-
return (struct upb_Message_Internal*)tmp;
2381-
}
2382-
2383-
UPB_INLINE void UPB_PRIVATE(_upb_Message_SetInternal)(
2384-
struct upb_Message* msg, struct upb_Message_Internal* internal) {
2385-
UPB_ASSERT(!upb_Message_IsFrozen(msg));
2386-
msg->UPB_OPAQUE(internal) = (uintptr_t)internal;
2387-
}
2388-
2389-
#ifdef __cplusplus
2390-
} /* extern "C" */
2391-
#endif
2392-
2393-
#undef UPB_OPAQUE
2394-
2395-
2396-
#endif /* UPB_MESSAGE_INTERNAL_TYPES_H_ */
2397-
23982406
// Must be last.
23992407

24002408
typedef struct upb_Message upb_Message;

0 commit comments

Comments
 (0)