From eea1e129006ce20545e1ebd4891e300a35374675 Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Wed, 6 Dec 2023 15:40:18 +0000 Subject: [PATCH] Auto-generate files after cl/588418734 --- php/ext/google/protobuf/php-upb.h | 37 ++++++++++++++++++++++----- ruby/ext/google/protobuf_c/ruby-upb.h | 37 ++++++++++++++++++++++----- 2 files changed, 60 insertions(+), 14 deletions(-) diff --git a/php/ext/google/protobuf/php-upb.h b/php/ext/google/protobuf/php-upb.h index a3587dd16d..c9799b495c 100644 --- a/php/ext/google/protobuf/php-upb.h +++ b/php/ext/google/protobuf/php-upb.h @@ -1497,6 +1497,24 @@ UPB_INLINE const struct upb_MiniTableEnum* UPB_PRIVATE( m->UPB_PRIVATE(subs)[f->UPB_PRIVATE(submsg_index)]); } +UPB_INLINE const struct upb_MiniTableField* UPB_PRIVATE(_upb_MiniTable_MapKey)( + const struct upb_MiniTable* m) { + UPB_ASSERT(UPB_PRIVATE(_upb_MiniTable_FieldCount)(m) == 2); + const struct upb_MiniTableField* f = + UPB_PRIVATE(_upb_MiniTable_GetFieldByIndex)(m, 0); + UPB_ASSERT(UPB_PRIVATE(_upb_MiniTableField_Number)(f) == 1); + return f; +} + +UPB_INLINE const struct upb_MiniTableField* UPB_PRIVATE( + _upb_MiniTable_MapValue)(const struct upb_MiniTable* m) { + UPB_ASSERT(UPB_PRIVATE(_upb_MiniTable_FieldCount)(m) == 2); + const struct upb_MiniTableField* f = + UPB_PRIVATE(_upb_MiniTable_GetFieldByIndex)(m, 1); + UPB_ASSERT(UPB_PRIVATE(_upb_MiniTableField_Number)(f) == 2); + return f; +} + UPB_INLINE bool UPB_PRIVATE(_upb_MiniTable_MessageFieldIsLinked)( const struct upb_MiniTable* m, const struct upb_MiniTableField* f) { return UPB_PRIVATE(_upb_MiniTable_GetSubMessageTable)(m, f) != NULL; @@ -1554,6 +1572,18 @@ UPB_API_INLINE const upb_MiniTableEnum* upb_MiniTable_GetSubEnumTable( return UPB_PRIVATE(_upb_MiniTable_GetSubEnumTable)(m, f); } +// Returns the MiniTableField for the key of a map. +UPB_API_INLINE const upb_MiniTableField* upb_MiniTable_MapKey( + const upb_MiniTable* m) { + return UPB_PRIVATE(_upb_MiniTable_MapKey)(m); +} + +// Returns the MiniTableField for the value of a map. +UPB_API_INLINE const upb_MiniTableField* upb_MiniTable_MapValue( + const upb_MiniTable* m) { + return UPB_PRIVATE(_upb_MiniTable_MapValue)(m); +} + // Returns true if this MiniTable field is linked to a MiniTable for the // sub-message. UPB_API_INLINE bool upb_MiniTable_MessageFieldIsLinked( @@ -1561,13 +1591,6 @@ UPB_API_INLINE bool upb_MiniTable_MessageFieldIsLinked( return UPB_PRIVATE(_upb_MiniTable_MessageFieldIsLinked)(m, f); } -// TODO: Implement convenience getters for map entries: -// -// upb_MiniTable_GetMapKey() -// upb_MiniTable_GetMapValue() -// These could also assert that this is indeed a map entry (well, as best we -// can. We can assert that there are two fields with field numbers 1 and 2). - // If this field is in a oneof, returns the first field in the oneof. // // Otherwise returns NULL. diff --git a/ruby/ext/google/protobuf_c/ruby-upb.h b/ruby/ext/google/protobuf_c/ruby-upb.h index adef471dbd..a433e13bd8 100755 --- a/ruby/ext/google/protobuf_c/ruby-upb.h +++ b/ruby/ext/google/protobuf_c/ruby-upb.h @@ -1499,6 +1499,24 @@ UPB_INLINE const struct upb_MiniTableEnum* UPB_PRIVATE( m->UPB_PRIVATE(subs)[f->UPB_PRIVATE(submsg_index)]); } +UPB_INLINE const struct upb_MiniTableField* UPB_PRIVATE(_upb_MiniTable_MapKey)( + const struct upb_MiniTable* m) { + UPB_ASSERT(UPB_PRIVATE(_upb_MiniTable_FieldCount)(m) == 2); + const struct upb_MiniTableField* f = + UPB_PRIVATE(_upb_MiniTable_GetFieldByIndex)(m, 0); + UPB_ASSERT(UPB_PRIVATE(_upb_MiniTableField_Number)(f) == 1); + return f; +} + +UPB_INLINE const struct upb_MiniTableField* UPB_PRIVATE( + _upb_MiniTable_MapValue)(const struct upb_MiniTable* m) { + UPB_ASSERT(UPB_PRIVATE(_upb_MiniTable_FieldCount)(m) == 2); + const struct upb_MiniTableField* f = + UPB_PRIVATE(_upb_MiniTable_GetFieldByIndex)(m, 1); + UPB_ASSERT(UPB_PRIVATE(_upb_MiniTableField_Number)(f) == 2); + return f; +} + UPB_INLINE bool UPB_PRIVATE(_upb_MiniTable_MessageFieldIsLinked)( const struct upb_MiniTable* m, const struct upb_MiniTableField* f) { return UPB_PRIVATE(_upb_MiniTable_GetSubMessageTable)(m, f) != NULL; @@ -1556,6 +1574,18 @@ UPB_API_INLINE const upb_MiniTableEnum* upb_MiniTable_GetSubEnumTable( return UPB_PRIVATE(_upb_MiniTable_GetSubEnumTable)(m, f); } +// Returns the MiniTableField for the key of a map. +UPB_API_INLINE const upb_MiniTableField* upb_MiniTable_MapKey( + const upb_MiniTable* m) { + return UPB_PRIVATE(_upb_MiniTable_MapKey)(m); +} + +// Returns the MiniTableField for the value of a map. +UPB_API_INLINE const upb_MiniTableField* upb_MiniTable_MapValue( + const upb_MiniTable* m) { + return UPB_PRIVATE(_upb_MiniTable_MapValue)(m); +} + // Returns true if this MiniTable field is linked to a MiniTable for the // sub-message. UPB_API_INLINE bool upb_MiniTable_MessageFieldIsLinked( @@ -1563,13 +1593,6 @@ UPB_API_INLINE bool upb_MiniTable_MessageFieldIsLinked( return UPB_PRIVATE(_upb_MiniTable_MessageFieldIsLinked)(m, f); } -// TODO: Implement convenience getters for map entries: -// -// upb_MiniTable_GetMapKey() -// upb_MiniTable_GetMapValue() -// These could also assert that this is indeed a map entry (well, as best we -// can. We can assert that there are two fields with field numbers 1 and 2). - // If this field is in a oneof, returns the first field in the oneof. // // Otherwise returns NULL.