upb: add upb_FieldDef_LayoutIndex()

PiperOrigin-RevId: 618007325
pull/16234/head
Eric Salo 11 months ago committed by Copybara-Service
parent 821e854b5a
commit 0f23c3f0c6
  1. 4
      upb/reflection/def.hpp
  2. 4
      upb/reflection/field_def.c
  3. 2
      upb/reflection/field_def.h

@ -18,6 +18,7 @@
#include "upb/base/status.hpp"
#include "upb/base/string_view.h"
#include "upb/mem/arena.hpp"
#include "upb/message/value.h"
#include "upb/mini_descriptor/decode.h"
#include "upb/mini_table/enum.h"
#include "upb/mini_table/field.h"
@ -87,6 +88,9 @@ class FieldDefPtr {
// been finalized.
uint32_t index() const { return upb_FieldDef_Index(ptr_); }
// Index into msgdef->layout->fields or file->exts
uint32_t layout_index() const { return upb_FieldDef_LayoutIndex(ptr_); }
// The MessageDef to which this field belongs (for extensions, the extended
// message).
MessageDefPtr containing_type() const;

@ -122,6 +122,10 @@ upb_FieldType upb_FieldDef_Type(const upb_FieldDef* f) {
uint32_t upb_FieldDef_Index(const upb_FieldDef* f) { return f->index_; }
uint32_t upb_FieldDef_LayoutIndex(const upb_FieldDef* f) {
return f->layout_index;
}
upb_Label upb_FieldDef_Label(const upb_FieldDef* f) {
// TODO: remove once we can deprecate kUpb_Label_Required.
if (UPB_DESC(FeatureSet_field_presence)(f->resolved_features) ==

@ -14,6 +14,7 @@
#include "upb/base/descriptor_constants.h"
#include "upb/base/string_view.h"
#include "upb/message/value.h"
#include "upb/mini_table/extension.h"
#include "upb/mini_table/field.h"
#include "upb/reflection/common.h"
@ -55,6 +56,7 @@ bool upb_FieldDef_IsString(const upb_FieldDef* f);
UPB_API bool upb_FieldDef_IsSubMessage(const upb_FieldDef* f);
UPB_API const char* upb_FieldDef_JsonName(const upb_FieldDef* f);
UPB_API upb_Label upb_FieldDef_Label(const upb_FieldDef* f);
uint32_t upb_FieldDef_LayoutIndex(const upb_FieldDef* f);
UPB_API const upb_MessageDef* upb_FieldDef_MessageSubDef(const upb_FieldDef* f);
bool _upb_FieldDef_ValidateUtf8(const upb_FieldDef* f);

Loading…
Cancel
Save