Auto-generate files after cl/970851165
diff --git a/php/ext/google/protobuf/php-upb.c b/php/ext/google/protobuf/php-upb.c index 1ca1ab2..5331867 100644 --- a/php/ext/google/protobuf/php-upb.c +++ b/php/ext/google/protobuf/php-upb.c
@@ -9244,6 +9244,33 @@ // Must be last. +bool upb_Message_NextWireFormatUnknown(const struct upb_Message* msg, + struct upb_Arena** arena, + upb_StringView* data, uintptr_t* iter) { + upb_MessageUnknown unknown; + if (!upb_Message_NextUnknown2(msg, &unknown, iter)) { + return false; + } + if (unknown.type == kUpb_MessageUnknownType_StringView) { + *data = unknown.value.bytes; + return true; + } + UPB_ASSERT(unknown.type == kUpb_MessageUnknownType_NonCanonicalExtension); + if (!*arena) { + *arena = upb_Arena_New(); + if (!*arena) { + return false; + } + } + upb_EncodeStatus status = + upb_EncodeExtension(unknown.value.extension, *arena, data, + /*encode_options=*/0); + if (status != kUpb_EncodeStatus_Ok) { + return false; + } + return true; +} + static upb_FindUnknownRet2 upb_FindUnknownRet2_ParseError(void) { return (upb_FindUnknownRet2){.status = kUpb_FindUnknown_ParseError}; }
diff --git a/php/ext/google/protobuf/php-upb.h b/php/ext/google/protobuf/php-upb.h index cbd4c83..15c8557 100644 --- a/php/ext/google/protobuf/php-upb.h +++ b/php/ext/google/protobuf/php-upb.h
@@ -16968,6 +16968,24 @@ return false; } +// Iterates over unknown fields in wire format (upb_StringView). +// If an unknown field is a non-canonical extension, it is automatically +// encoded into wire format into `*arena` using default encode options (0). +// +// `arena` is a pointer to `upb_Arena*`. If `*arena` is NULL when a +// non-canonical extension is encountered, an arena will be lazily created via +// `upb_Arena_New()`. The caller is responsible for freeing `*arena` (if +// non-NULL) using `upb_Arena_Free(*arena)` after iteration completes. +// +// NOTE: Automatically encoding non-canonical extensions into wire format may +// incur a performance penalty if non-canonical extensions are present, as +// encoding requires allocating temporary buffers in `*arena`. Use +// `upb_Message_NextUnknown2` if you want to inspect non-canonical extensions +// directly without encoding them. +UPB_NODISCARD bool upb_Message_NextWireFormatUnknown( + const struct upb_Message* msg, struct upb_Arena** arena, + upb_StringView* data, uintptr_t* iter); + typedef enum { kUpb_FindUnknown_Ok, kUpb_FindUnknown_NotPresent, @@ -17073,6 +17091,33 @@ #endif /* UPB_MESSAGE_UNKNOWN_FIELDS_H_ */ +#ifndef UPB_WIRE_ENCODE_EXTENSION_H_ +#define UPB_WIRE_ENCODE_EXTENSION_H_ + + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +struct upb_Extension; + +// Encodes an extension (`upb_Extension*`) to bytes. +// +// This can be used to encode an extension into the provided arena. +// Returns `kUpb_EncodeStatus_Ok` on success. +UPB_NODISCARD upb_EncodeStatus +upb_EncodeExtension(const struct upb_Extension* ext, struct upb_Arena* arena, + upb_StringView* view, int encode_options); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_WIRE_ENCODE_EXTENSION_H_ */ + #ifndef UPB_WIRE_EPS_COPY_INPUT_STREAM_H_ #define UPB_WIRE_EPS_COPY_INPUT_STREAM_H_ @@ -19663,33 +19708,6 @@ #endif /* UPB_WIRE_INTERNAL_DECODER_H_ */ - -#ifndef UPB_WIRE_ENCODE_EXTENSION_H_ -#define UPB_WIRE_ENCODE_EXTENSION_H_ - - -// Must be last. - -#ifdef __cplusplus -extern "C" { -#endif - -struct upb_Extension; - -// Encodes an extension (`upb_Extension*`) to bytes. -// -// This can be used to encode an extension into the provided arena. -// Returns `kUpb_EncodeStatus_Ok` on success. -UPB_NODISCARD upb_EncodeStatus -upb_EncodeExtension(const struct upb_Extension* ext, struct upb_Arena* arena, - upb_StringView* view, int encode_options); - -#ifdef __cplusplus -} /* extern "C" */ -#endif - - -#endif /* UPB_WIRE_ENCODE_EXTENSION_H_ */ #ifndef GOOGLE_UPB_UPB_WIRE_WRITER_H__ #define GOOGLE_UPB_UPB_WIRE_WRITER_H__
diff --git a/ruby/ext/google/protobuf_c/ruby-upb.c b/ruby/ext/google/protobuf_c/ruby-upb.c index 9e81b6f..876f4f4 100644 --- a/ruby/ext/google/protobuf_c/ruby-upb.c +++ b/ruby/ext/google/protobuf_c/ruby-upb.c
@@ -7997,6 +7997,33 @@ // Must be last. +bool upb_Message_NextWireFormatUnknown(const struct upb_Message* msg, + struct upb_Arena** arena, + upb_StringView* data, uintptr_t* iter) { + upb_MessageUnknown unknown; + if (!upb_Message_NextUnknown2(msg, &unknown, iter)) { + return false; + } + if (unknown.type == kUpb_MessageUnknownType_StringView) { + *data = unknown.value.bytes; + return true; + } + UPB_ASSERT(unknown.type == kUpb_MessageUnknownType_NonCanonicalExtension); + if (!*arena) { + *arena = upb_Arena_New(); + if (!*arena) { + return false; + } + } + upb_EncodeStatus status = + upb_EncodeExtension(unknown.value.extension, *arena, data, + /*encode_options=*/0); + if (status != kUpb_EncodeStatus_Ok) { + return false; + } + return true; +} + static upb_FindUnknownRet2 upb_FindUnknownRet2_ParseError(void) { return (upb_FindUnknownRet2){.status = kUpb_FindUnknown_ParseError}; }
diff --git a/ruby/ext/google/protobuf_c/ruby-upb.h b/ruby/ext/google/protobuf_c/ruby-upb.h index 6f27aee..e7d8c94 100755 --- a/ruby/ext/google/protobuf_c/ruby-upb.h +++ b/ruby/ext/google/protobuf_c/ruby-upb.h
@@ -16682,6 +16682,24 @@ return false; } +// Iterates over unknown fields in wire format (upb_StringView). +// If an unknown field is a non-canonical extension, it is automatically +// encoded into wire format into `*arena` using default encode options (0). +// +// `arena` is a pointer to `upb_Arena*`. If `*arena` is NULL when a +// non-canonical extension is encountered, an arena will be lazily created via +// `upb_Arena_New()`. The caller is responsible for freeing `*arena` (if +// non-NULL) using `upb_Arena_Free(*arena)` after iteration completes. +// +// NOTE: Automatically encoding non-canonical extensions into wire format may +// incur a performance penalty if non-canonical extensions are present, as +// encoding requires allocating temporary buffers in `*arena`. Use +// `upb_Message_NextUnknown2` if you want to inspect non-canonical extensions +// directly without encoding them. +UPB_NODISCARD bool upb_Message_NextWireFormatUnknown( + const struct upb_Message* msg, struct upb_Arena** arena, + upb_StringView* data, uintptr_t* iter); + typedef enum { kUpb_FindUnknown_Ok, kUpb_FindUnknown_NotPresent, @@ -16787,6 +16805,33 @@ #endif /* UPB_MESSAGE_UNKNOWN_FIELDS_H_ */ +#ifndef UPB_WIRE_ENCODE_EXTENSION_H_ +#define UPB_WIRE_ENCODE_EXTENSION_H_ + + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +struct upb_Extension; + +// Encodes an extension (`upb_Extension*`) to bytes. +// +// This can be used to encode an extension into the provided arena. +// Returns `kUpb_EncodeStatus_Ok` on success. +UPB_NODISCARD upb_EncodeStatus +upb_EncodeExtension(const struct upb_Extension* ext, struct upb_Arena* arena, + upb_StringView* view, int encode_options); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_WIRE_ENCODE_EXTENSION_H_ */ + #ifndef UPB_WIRE_EPS_COPY_INPUT_STREAM_H_ #define UPB_WIRE_EPS_COPY_INPUT_STREAM_H_ @@ -19487,33 +19532,6 @@ #endif /* UPB_WIRE_INTERNAL_DECODER_H_ */ - -#ifndef UPB_WIRE_ENCODE_EXTENSION_H_ -#define UPB_WIRE_ENCODE_EXTENSION_H_ - - -// Must be last. - -#ifdef __cplusplus -extern "C" { -#endif - -struct upb_Extension; - -// Encodes an extension (`upb_Extension*`) to bytes. -// -// This can be used to encode an extension into the provided arena. -// Returns `kUpb_EncodeStatus_Ok` on success. -UPB_NODISCARD upb_EncodeStatus -upb_EncodeExtension(const struct upb_Extension* ext, struct upb_Arena* arena, - upb_StringView* view, int encode_options); - -#ifdef __cplusplus -} /* extern "C" */ -#endif - - -#endif /* UPB_WIRE_ENCODE_EXTENSION_H_ */ #ifndef GOOGLE_UPB_UPB_WIRE_WRITER_H__ #define GOOGLE_UPB_UPB_WIRE_WRITER_H__