Skip to content

Commit

Permalink
upb: fix Dart empty imports
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 627794151
  • Loading branch information
ericsalo authored and copybara-github committed Apr 24, 2024
1 parent 5587559 commit 8be1312
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions upb/reflection/def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class FieldDefPtr {
OneofDefPtr real_containing_oneof() const;

// Convenient field type tests.
bool IsEnum() const { return upb_FieldDef_IsEnum(ptr_); }
bool IsSubMessage() const { return upb_FieldDef_IsSubMessage(ptr_); }
bool IsString() const { return upb_FieldDef_IsString(ptr_); }
bool IsSequence() const { return upb_FieldDef_IsRepeated(ptr_); }
Expand Down
11 changes: 7 additions & 4 deletions upb/reflection/field_def.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,11 @@ upb_MessageValue upb_FieldDef_Default(const upb_FieldDef* f) {
}

const upb_MessageDef* upb_FieldDef_MessageSubDef(const upb_FieldDef* f) {
return upb_FieldDef_CType(f) == kUpb_CType_Message ? f->sub.msgdef : NULL;
return upb_FieldDef_IsSubMessage(f) ? f->sub.msgdef : NULL;
}

const upb_EnumDef* upb_FieldDef_EnumSubDef(const upb_FieldDef* f) {
return upb_FieldDef_CType(f) == kUpb_CType_Enum ? f->sub.enumdef : NULL;
return upb_FieldDef_IsEnum(f) ? f->sub.enumdef : NULL;
}

const upb_MiniTableField* upb_FieldDef_MiniTable(const upb_FieldDef* f) {
Expand Down Expand Up @@ -310,8 +310,11 @@ bool upb_FieldDef_HasDefault(const upb_FieldDef* f) { return f->has_default; }
bool upb_FieldDef_HasPresence(const upb_FieldDef* f) { return f->has_presence; }

bool upb_FieldDef_HasSubDef(const upb_FieldDef* f) {
return upb_FieldDef_IsSubMessage(f) ||
upb_FieldDef_CType(f) == kUpb_CType_Enum;
return upb_FieldDef_IsSubMessage(f) || upb_FieldDef_IsEnum(f);
}

bool upb_FieldDef_IsEnum(const upb_FieldDef* f) {
return upb_FieldDef_CType(f) == kUpb_CType_Enum;
}

bool upb_FieldDef_IsMap(const upb_FieldDef* f) {
Expand Down
1 change: 1 addition & 0 deletions upb/reflection/field_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ bool upb_FieldDef_HasOptions(const upb_FieldDef* f);
UPB_API bool upb_FieldDef_HasPresence(const upb_FieldDef* f);
bool upb_FieldDef_HasSubDef(const upb_FieldDef* f);
uint32_t upb_FieldDef_Index(const upb_FieldDef* f);
UPB_API bool upb_FieldDef_IsEnum(const upb_FieldDef* f);
bool upb_FieldDef_IsExtension(const upb_FieldDef* f);
UPB_API bool upb_FieldDef_IsMap(const upb_FieldDef* f);
bool upb_FieldDef_IsOptional(const upb_FieldDef* f);
Expand Down

0 comments on commit 8be1312

Please sign in to comment.