Switch to a single upb_Decode.

pull/13171/head
Joshua Haberman 3 years ago
parent 499c2cc8b1
commit 72af9dc0cc
  1. 108
      cmake/google/protobuf/descriptor.upb.h
  2. 6
      python/descriptor.c
  3. 2
      python/message.c
  4. 1
      rename.sed
  5. 5
      run_sed.sh
  6. 4
      tests/conformance_upb.c
  7. 4
      upb/bindings/lua/msg.c
  8. 8
      upb/decode.c
  9. 14
      upb/decode.h
  10. 2
      upb/json_encode.c
  11. 20
      upb/msg_test.cc
  12. 4
      upbc/protoc-gen-upb.cc

@ -169,7 +169,7 @@ UPB_INLINE google_protobuf_FileDescriptorSet* google_protobuf_FileDescriptorSet_
UPB_INLINE google_protobuf_FileDescriptorSet* google_protobuf_FileDescriptorSet_parse(const char* buf, size_t size, upb_Arena* arena) {
google_protobuf_FileDescriptorSet* ret = google_protobuf_FileDescriptorSet_new(arena);
if (!ret) return NULL;
if (upb_decode(buf, size, ret, &google_protobuf_FileDescriptorSet_msginit, arena) != kUpb_DecodeStatus_Ok) {
if (upb_Decode(buf, size, ret, &google_protobuf_FileDescriptorSet_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
return NULL;
}
return ret;
@ -179,7 +179,7 @@ UPB_INLINE google_protobuf_FileDescriptorSet* google_protobuf_FileDescriptorSet_
int options, upb_Arena* arena) {
google_protobuf_FileDescriptorSet* ret = google_protobuf_FileDescriptorSet_new(arena);
if (!ret) return NULL;
if (_upb_decode(buf, size, ret, &google_protobuf_FileDescriptorSet_msginit, extreg, options, arena) !=
if (upb_Decode(buf, size, ret, &google_protobuf_FileDescriptorSet_msginit, extreg, options, arena) !=
kUpb_DecodeStatus_Ok) {
return NULL;
}
@ -217,7 +217,7 @@ UPB_INLINE google_protobuf_FileDescriptorProto* google_protobuf_FileDescriptorPr
UPB_INLINE google_protobuf_FileDescriptorProto* google_protobuf_FileDescriptorProto_parse(const char* buf, size_t size, upb_Arena* arena) {
google_protobuf_FileDescriptorProto* ret = google_protobuf_FileDescriptorProto_new(arena);
if (!ret) return NULL;
if (upb_decode(buf, size, ret, &google_protobuf_FileDescriptorProto_msginit, arena) != kUpb_DecodeStatus_Ok) {
if (upb_Decode(buf, size, ret, &google_protobuf_FileDescriptorProto_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
return NULL;
}
return ret;
@ -227,7 +227,7 @@ UPB_INLINE google_protobuf_FileDescriptorProto* google_protobuf_FileDescriptorPr
int options, upb_Arena* arena) {
google_protobuf_FileDescriptorProto* ret = google_protobuf_FileDescriptorProto_new(arena);
if (!ret) return NULL;
if (_upb_decode(buf, size, ret, &google_protobuf_FileDescriptorProto_msginit, extreg, options, arena) !=
if (upb_Decode(buf, size, ret, &google_protobuf_FileDescriptorProto_msginit, extreg, options, arena) !=
kUpb_DecodeStatus_Ok) {
return NULL;
}
@ -401,7 +401,7 @@ UPB_INLINE google_protobuf_DescriptorProto* google_protobuf_DescriptorProto_new(
UPB_INLINE google_protobuf_DescriptorProto* google_protobuf_DescriptorProto_parse(const char* buf, size_t size, upb_Arena* arena) {
google_protobuf_DescriptorProto* ret = google_protobuf_DescriptorProto_new(arena);
if (!ret) return NULL;
if (upb_decode(buf, size, ret, &google_protobuf_DescriptorProto_msginit, arena) != kUpb_DecodeStatus_Ok) {
if (upb_Decode(buf, size, ret, &google_protobuf_DescriptorProto_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
return NULL;
}
return ret;
@ -411,7 +411,7 @@ UPB_INLINE google_protobuf_DescriptorProto* google_protobuf_DescriptorProto_pars
int options, upb_Arena* arena) {
google_protobuf_DescriptorProto* ret = google_protobuf_DescriptorProto_new(arena);
if (!ret) return NULL;
if (_upb_decode(buf, size, ret, &google_protobuf_DescriptorProto_msginit, extreg, options, arena) !=
if (upb_Decode(buf, size, ret, &google_protobuf_DescriptorProto_msginit, extreg, options, arena) !=
kUpb_DecodeStatus_Ok) {
return NULL;
}
@ -575,7 +575,7 @@ UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange* google_protobuf_Descr
UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange* google_protobuf_DescriptorProto_ExtensionRange_parse(const char* buf, size_t size, upb_Arena* arena) {
google_protobuf_DescriptorProto_ExtensionRange* ret = google_protobuf_DescriptorProto_ExtensionRange_new(arena);
if (!ret) return NULL;
if (upb_decode(buf, size, ret, &google_protobuf_DescriptorProto_ExtensionRange_msginit, arena) != kUpb_DecodeStatus_Ok) {
if (upb_Decode(buf, size, ret, &google_protobuf_DescriptorProto_ExtensionRange_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
return NULL;
}
return ret;
@ -585,7 +585,7 @@ UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange* google_protobuf_Descr
int options, upb_Arena* arena) {
google_protobuf_DescriptorProto_ExtensionRange* ret = google_protobuf_DescriptorProto_ExtensionRange_new(arena);
if (!ret) return NULL;
if (_upb_decode(buf, size, ret, &google_protobuf_DescriptorProto_ExtensionRange_msginit, extreg, options, arena) !=
if (upb_Decode(buf, size, ret, &google_protobuf_DescriptorProto_ExtensionRange_msginit, extreg, options, arena) !=
kUpb_DecodeStatus_Ok) {
return NULL;
}
@ -641,7 +641,7 @@ UPB_INLINE google_protobuf_DescriptorProto_ReservedRange* google_protobuf_Descri
UPB_INLINE google_protobuf_DescriptorProto_ReservedRange* google_protobuf_DescriptorProto_ReservedRange_parse(const char* buf, size_t size, upb_Arena* arena) {
google_protobuf_DescriptorProto_ReservedRange* ret = google_protobuf_DescriptorProto_ReservedRange_new(arena);
if (!ret) return NULL;
if (upb_decode(buf, size, ret, &google_protobuf_DescriptorProto_ReservedRange_msginit, arena) != kUpb_DecodeStatus_Ok) {
if (upb_Decode(buf, size, ret, &google_protobuf_DescriptorProto_ReservedRange_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
return NULL;
}
return ret;
@ -651,7 +651,7 @@ UPB_INLINE google_protobuf_DescriptorProto_ReservedRange* google_protobuf_Descri
int options, upb_Arena* arena) {
google_protobuf_DescriptorProto_ReservedRange* ret = google_protobuf_DescriptorProto_ReservedRange_new(arena);
if (!ret) return NULL;
if (_upb_decode(buf, size, ret, &google_protobuf_DescriptorProto_ReservedRange_msginit, extreg, options, arena) !=
if (upb_Decode(buf, size, ret, &google_protobuf_DescriptorProto_ReservedRange_msginit, extreg, options, arena) !=
kUpb_DecodeStatus_Ok) {
return NULL;
}
@ -690,7 +690,7 @@ UPB_INLINE google_protobuf_ExtensionRangeOptions* google_protobuf_ExtensionRange
UPB_INLINE google_protobuf_ExtensionRangeOptions* google_protobuf_ExtensionRangeOptions_parse(const char* buf, size_t size, upb_Arena* arena) {
google_protobuf_ExtensionRangeOptions* ret = google_protobuf_ExtensionRangeOptions_new(arena);
if (!ret) return NULL;
if (upb_decode(buf, size, ret, &google_protobuf_ExtensionRangeOptions_msginit, arena) != kUpb_DecodeStatus_Ok) {
if (upb_Decode(buf, size, ret, &google_protobuf_ExtensionRangeOptions_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
return NULL;
}
return ret;
@ -700,7 +700,7 @@ UPB_INLINE google_protobuf_ExtensionRangeOptions* google_protobuf_ExtensionRange
int options, upb_Arena* arena) {
google_protobuf_ExtensionRangeOptions* ret = google_protobuf_ExtensionRangeOptions_new(arena);
if (!ret) return NULL;
if (_upb_decode(buf, size, ret, &google_protobuf_ExtensionRangeOptions_msginit, extreg, options, arena) !=
if (upb_Decode(buf, size, ret, &google_protobuf_ExtensionRangeOptions_msginit, extreg, options, arena) !=
kUpb_DecodeStatus_Ok) {
return NULL;
}
@ -738,7 +738,7 @@ UPB_INLINE google_protobuf_FieldDescriptorProto* google_protobuf_FieldDescriptor
UPB_INLINE google_protobuf_FieldDescriptorProto* google_protobuf_FieldDescriptorProto_parse(const char* buf, size_t size, upb_Arena* arena) {
google_protobuf_FieldDescriptorProto* ret = google_protobuf_FieldDescriptorProto_new(arena);
if (!ret) return NULL;
if (upb_decode(buf, size, ret, &google_protobuf_FieldDescriptorProto_msginit, arena) != kUpb_DecodeStatus_Ok) {
if (upb_Decode(buf, size, ret, &google_protobuf_FieldDescriptorProto_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
return NULL;
}
return ret;
@ -748,7 +748,7 @@ UPB_INLINE google_protobuf_FieldDescriptorProto* google_protobuf_FieldDescriptor
int options, upb_Arena* arena) {
google_protobuf_FieldDescriptorProto* ret = google_protobuf_FieldDescriptorProto_new(arena);
if (!ret) return NULL;
if (_upb_decode(buf, size, ret, &google_protobuf_FieldDescriptorProto_msginit, extreg, options, arena) !=
if (upb_Decode(buf, size, ret, &google_protobuf_FieldDescriptorProto_msginit, extreg, options, arena) !=
kUpb_DecodeStatus_Ok) {
return NULL;
}
@ -868,7 +868,7 @@ UPB_INLINE google_protobuf_OneofDescriptorProto* google_protobuf_OneofDescriptor
UPB_INLINE google_protobuf_OneofDescriptorProto* google_protobuf_OneofDescriptorProto_parse(const char* buf, size_t size, upb_Arena* arena) {
google_protobuf_OneofDescriptorProto* ret = google_protobuf_OneofDescriptorProto_new(arena);
if (!ret) return NULL;
if (upb_decode(buf, size, ret, &google_protobuf_OneofDescriptorProto_msginit, arena) != kUpb_DecodeStatus_Ok) {
if (upb_Decode(buf, size, ret, &google_protobuf_OneofDescriptorProto_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
return NULL;
}
return ret;
@ -878,7 +878,7 @@ UPB_INLINE google_protobuf_OneofDescriptorProto* google_protobuf_OneofDescriptor
int options, upb_Arena* arena) {
google_protobuf_OneofDescriptorProto* ret = google_protobuf_OneofDescriptorProto_new(arena);
if (!ret) return NULL;
if (_upb_decode(buf, size, ret, &google_protobuf_OneofDescriptorProto_msginit, extreg, options, arena) !=
if (upb_Decode(buf, size, ret, &google_protobuf_OneofDescriptorProto_msginit, extreg, options, arena) !=
kUpb_DecodeStatus_Ok) {
return NULL;
}
@ -926,7 +926,7 @@ UPB_INLINE google_protobuf_EnumDescriptorProto* google_protobuf_EnumDescriptorPr
UPB_INLINE google_protobuf_EnumDescriptorProto* google_protobuf_EnumDescriptorProto_parse(const char* buf, size_t size, upb_Arena* arena) {
google_protobuf_EnumDescriptorProto* ret = google_protobuf_EnumDescriptorProto_new(arena);
if (!ret) return NULL;
if (upb_decode(buf, size, ret, &google_protobuf_EnumDescriptorProto_msginit, arena) != kUpb_DecodeStatus_Ok) {
if (upb_Decode(buf, size, ret, &google_protobuf_EnumDescriptorProto_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
return NULL;
}
return ret;
@ -936,7 +936,7 @@ UPB_INLINE google_protobuf_EnumDescriptorProto* google_protobuf_EnumDescriptorPr
int options, upb_Arena* arena) {
google_protobuf_EnumDescriptorProto* ret = google_protobuf_EnumDescriptorProto_new(arena);
if (!ret) return NULL;
if (_upb_decode(buf, size, ret, &google_protobuf_EnumDescriptorProto_msginit, extreg, options, arena) !=
if (upb_Decode(buf, size, ret, &google_protobuf_EnumDescriptorProto_msginit, extreg, options, arena) !=
kUpb_DecodeStatus_Ok) {
return NULL;
}
@ -1025,7 +1025,7 @@ UPB_INLINE google_protobuf_EnumDescriptorProto_EnumReservedRange* google_protobu
UPB_INLINE google_protobuf_EnumDescriptorProto_EnumReservedRange* google_protobuf_EnumDescriptorProto_EnumReservedRange_parse(const char* buf, size_t size, upb_Arena* arena) {
google_protobuf_EnumDescriptorProto_EnumReservedRange* ret = google_protobuf_EnumDescriptorProto_EnumReservedRange_new(arena);
if (!ret) return NULL;
if (upb_decode(buf, size, ret, &google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit, arena) != kUpb_DecodeStatus_Ok) {
if (upb_Decode(buf, size, ret, &google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
return NULL;
}
return ret;
@ -1035,7 +1035,7 @@ UPB_INLINE google_protobuf_EnumDescriptorProto_EnumReservedRange* google_protobu
int options, upb_Arena* arena) {
google_protobuf_EnumDescriptorProto_EnumReservedRange* ret = google_protobuf_EnumDescriptorProto_EnumReservedRange_new(arena);
if (!ret) return NULL;
if (_upb_decode(buf, size, ret, &google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit, extreg, options, arena) !=
if (upb_Decode(buf, size, ret, &google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit, extreg, options, arena) !=
kUpb_DecodeStatus_Ok) {
return NULL;
}
@ -1074,7 +1074,7 @@ UPB_INLINE google_protobuf_EnumValueDescriptorProto* google_protobuf_EnumValueDe
UPB_INLINE google_protobuf_EnumValueDescriptorProto* google_protobuf_EnumValueDescriptorProto_parse(const char* buf, size_t size, upb_Arena* arena) {
google_protobuf_EnumValueDescriptorProto* ret = google_protobuf_EnumValueDescriptorProto_new(arena);
if (!ret) return NULL;
if (upb_decode(buf, size, ret, &google_protobuf_EnumValueDescriptorProto_msginit, arena) != kUpb_DecodeStatus_Ok) {
if (upb_Decode(buf, size, ret, &google_protobuf_EnumValueDescriptorProto_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
return NULL;
}
return ret;
@ -1084,7 +1084,7 @@ UPB_INLINE google_protobuf_EnumValueDescriptorProto* google_protobuf_EnumValueDe
int options, upb_Arena* arena) {
google_protobuf_EnumValueDescriptorProto* ret = google_protobuf_EnumValueDescriptorProto_new(arena);
if (!ret) return NULL;
if (_upb_decode(buf, size, ret, &google_protobuf_EnumValueDescriptorProto_msginit, extreg, options, arena) !=
if (upb_Decode(buf, size, ret, &google_protobuf_EnumValueDescriptorProto_msginit, extreg, options, arena) !=
kUpb_DecodeStatus_Ok) {
return NULL;
}
@ -1140,7 +1140,7 @@ UPB_INLINE google_protobuf_ServiceDescriptorProto* google_protobuf_ServiceDescri
UPB_INLINE google_protobuf_ServiceDescriptorProto* google_protobuf_ServiceDescriptorProto_parse(const char* buf, size_t size, upb_Arena* arena) {
google_protobuf_ServiceDescriptorProto* ret = google_protobuf_ServiceDescriptorProto_new(arena);
if (!ret) return NULL;
if (upb_decode(buf, size, ret, &google_protobuf_ServiceDescriptorProto_msginit, arena) != kUpb_DecodeStatus_Ok) {
if (upb_Decode(buf, size, ret, &google_protobuf_ServiceDescriptorProto_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
return NULL;
}
return ret;
@ -1150,7 +1150,7 @@ UPB_INLINE google_protobuf_ServiceDescriptorProto* google_protobuf_ServiceDescri
int options, upb_Arena* arena) {
google_protobuf_ServiceDescriptorProto* ret = google_protobuf_ServiceDescriptorProto_new(arena);
if (!ret) return NULL;
if (_upb_decode(buf, size, ret, &google_protobuf_ServiceDescriptorProto_msginit, extreg, options, arena) !=
if (upb_Decode(buf, size, ret, &google_protobuf_ServiceDescriptorProto_msginit, extreg, options, arena) !=
kUpb_DecodeStatus_Ok) {
return NULL;
}
@ -1213,7 +1213,7 @@ UPB_INLINE google_protobuf_MethodDescriptorProto* google_protobuf_MethodDescript
UPB_INLINE google_protobuf_MethodDescriptorProto* google_protobuf_MethodDescriptorProto_parse(const char* buf, size_t size, upb_Arena* arena) {
google_protobuf_MethodDescriptorProto* ret = google_protobuf_MethodDescriptorProto_new(arena);
if (!ret) return NULL;
if (upb_decode(buf, size, ret, &google_protobuf_MethodDescriptorProto_msginit, arena) != kUpb_DecodeStatus_Ok) {
if (upb_Decode(buf, size, ret, &google_protobuf_MethodDescriptorProto_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
return NULL;
}
return ret;
@ -1223,7 +1223,7 @@ UPB_INLINE google_protobuf_MethodDescriptorProto* google_protobuf_MethodDescript
int options, upb_Arena* arena) {
google_protobuf_MethodDescriptorProto* ret = google_protobuf_MethodDescriptorProto_new(arena);
if (!ret) return NULL;
if (_upb_decode(buf, size, ret, &google_protobuf_MethodDescriptorProto_msginit, extreg, options, arena) !=
if (upb_Decode(buf, size, ret, &google_protobuf_MethodDescriptorProto_msginit, extreg, options, arena) !=
kUpb_DecodeStatus_Ok) {
return NULL;
}
@ -1303,7 +1303,7 @@ UPB_INLINE google_protobuf_FileOptions* google_protobuf_FileOptions_new(upb_Aren
UPB_INLINE google_protobuf_FileOptions* google_protobuf_FileOptions_parse(const char* buf, size_t size, upb_Arena* arena) {
google_protobuf_FileOptions* ret = google_protobuf_FileOptions_new(arena);
if (!ret) return NULL;
if (upb_decode(buf, size, ret, &google_protobuf_FileOptions_msginit, arena) != kUpb_DecodeStatus_Ok) {
if (upb_Decode(buf, size, ret, &google_protobuf_FileOptions_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
return NULL;
}
return ret;
@ -1313,7 +1313,7 @@ UPB_INLINE google_protobuf_FileOptions* google_protobuf_FileOptions_parse_ex(con
int options, upb_Arena* arena) {
google_protobuf_FileOptions* ret = google_protobuf_FileOptions_new(arena);
if (!ret) return NULL;
if (_upb_decode(buf, size, ret, &google_protobuf_FileOptions_msginit, extreg, options, arena) !=
if (upb_Decode(buf, size, ret, &google_protobuf_FileOptions_msginit, extreg, options, arena) !=
kUpb_DecodeStatus_Ok) {
return NULL;
}
@ -1511,7 +1511,7 @@ UPB_INLINE google_protobuf_MessageOptions* google_protobuf_MessageOptions_new(up
UPB_INLINE google_protobuf_MessageOptions* google_protobuf_MessageOptions_parse(const char* buf, size_t size, upb_Arena* arena) {
google_protobuf_MessageOptions* ret = google_protobuf_MessageOptions_new(arena);
if (!ret) return NULL;
if (upb_decode(buf, size, ret, &google_protobuf_MessageOptions_msginit, arena) != kUpb_DecodeStatus_Ok) {
if (upb_Decode(buf, size, ret, &google_protobuf_MessageOptions_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
return NULL;
}
return ret;
@ -1521,7 +1521,7 @@ UPB_INLINE google_protobuf_MessageOptions* google_protobuf_MessageOptions_parse_
int options, upb_Arena* arena) {
google_protobuf_MessageOptions* ret = google_protobuf_MessageOptions_new(arena);
if (!ret) return NULL;
if (_upb_decode(buf, size, ret, &google_protobuf_MessageOptions_msginit, extreg, options, arena) !=
if (upb_Decode(buf, size, ret, &google_protobuf_MessageOptions_msginit, extreg, options, arena) !=
kUpb_DecodeStatus_Ok) {
return NULL;
}
@ -1591,7 +1591,7 @@ UPB_INLINE google_protobuf_FieldOptions* google_protobuf_FieldOptions_new(upb_Ar
UPB_INLINE google_protobuf_FieldOptions* google_protobuf_FieldOptions_parse(const char* buf, size_t size, upb_Arena* arena) {
google_protobuf_FieldOptions* ret = google_protobuf_FieldOptions_new(arena);
if (!ret) return NULL;
if (upb_decode(buf, size, ret, &google_protobuf_FieldOptions_msginit, arena) != kUpb_DecodeStatus_Ok) {
if (upb_Decode(buf, size, ret, &google_protobuf_FieldOptions_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
return NULL;
}
return ret;
@ -1601,7 +1601,7 @@ UPB_INLINE google_protobuf_FieldOptions* google_protobuf_FieldOptions_parse_ex(c
int options, upb_Arena* arena) {
google_protobuf_FieldOptions* ret = google_protobuf_FieldOptions_new(arena);
if (!ret) return NULL;
if (_upb_decode(buf, size, ret, &google_protobuf_FieldOptions_msginit, extreg, options, arena) !=
if (upb_Decode(buf, size, ret, &google_protobuf_FieldOptions_msginit, extreg, options, arena) !=
kUpb_DecodeStatus_Ok) {
return NULL;
}
@ -1687,7 +1687,7 @@ UPB_INLINE google_protobuf_OneofOptions* google_protobuf_OneofOptions_new(upb_Ar
UPB_INLINE google_protobuf_OneofOptions* google_protobuf_OneofOptions_parse(const char* buf, size_t size, upb_Arena* arena) {
google_protobuf_OneofOptions* ret = google_protobuf_OneofOptions_new(arena);
if (!ret) return NULL;
if (upb_decode(buf, size, ret, &google_protobuf_OneofOptions_msginit, arena) != kUpb_DecodeStatus_Ok) {
if (upb_Decode(buf, size, ret, &google_protobuf_OneofOptions_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
return NULL;
}
return ret;
@ -1697,7 +1697,7 @@ UPB_INLINE google_protobuf_OneofOptions* google_protobuf_OneofOptions_parse_ex(c
int options, upb_Arena* arena) {
google_protobuf_OneofOptions* ret = google_protobuf_OneofOptions_new(arena);
if (!ret) return NULL;
if (_upb_decode(buf, size, ret, &google_protobuf_OneofOptions_msginit, extreg, options, arena) !=
if (upb_Decode(buf, size, ret, &google_protobuf_OneofOptions_msginit, extreg, options, arena) !=
kUpb_DecodeStatus_Ok) {
return NULL;
}
@ -1735,7 +1735,7 @@ UPB_INLINE google_protobuf_EnumOptions* google_protobuf_EnumOptions_new(upb_Aren
UPB_INLINE google_protobuf_EnumOptions* google_protobuf_EnumOptions_parse(const char* buf, size_t size, upb_Arena* arena) {
google_protobuf_EnumOptions* ret = google_protobuf_EnumOptions_new(arena);
if (!ret) return NULL;
if (upb_decode(buf, size, ret, &google_protobuf_EnumOptions_msginit, arena) != kUpb_DecodeStatus_Ok) {
if (upb_Decode(buf, size, ret, &google_protobuf_EnumOptions_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
return NULL;
}
return ret;
@ -1745,7 +1745,7 @@ UPB_INLINE google_protobuf_EnumOptions* google_protobuf_EnumOptions_parse_ex(con
int options, upb_Arena* arena) {
google_protobuf_EnumOptions* ret = google_protobuf_EnumOptions_new(arena);
if (!ret) return NULL;
if (_upb_decode(buf, size, ret, &google_protobuf_EnumOptions_msginit, extreg, options, arena) !=
if (upb_Decode(buf, size, ret, &google_protobuf_EnumOptions_msginit, extreg, options, arena) !=
kUpb_DecodeStatus_Ok) {
return NULL;
}
@ -1799,7 +1799,7 @@ UPB_INLINE google_protobuf_EnumValueOptions* google_protobuf_EnumValueOptions_ne
UPB_INLINE google_protobuf_EnumValueOptions* google_protobuf_EnumValueOptions_parse(const char* buf, size_t size, upb_Arena* arena) {
google_protobuf_EnumValueOptions* ret = google_protobuf_EnumValueOptions_new(arena);
if (!ret) return NULL;
if (upb_decode(buf, size, ret, &google_protobuf_EnumValueOptions_msginit, arena) != kUpb_DecodeStatus_Ok) {
if (upb_Decode(buf, size, ret, &google_protobuf_EnumValueOptions_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
return NULL;
}
return ret;
@ -1809,7 +1809,7 @@ UPB_INLINE google_protobuf_EnumValueOptions* google_protobuf_EnumValueOptions_pa
int options, upb_Arena* arena) {
google_protobuf_EnumValueOptions* ret = google_protobuf_EnumValueOptions_new(arena);
if (!ret) return NULL;
if (_upb_decode(buf, size, ret, &google_protobuf_EnumValueOptions_msginit, extreg, options, arena) !=
if (upb_Decode(buf, size, ret, &google_protobuf_EnumValueOptions_msginit, extreg, options, arena) !=
kUpb_DecodeStatus_Ok) {
return NULL;
}
@ -1855,7 +1855,7 @@ UPB_INLINE google_protobuf_ServiceOptions* google_protobuf_ServiceOptions_new(up
UPB_INLINE google_protobuf_ServiceOptions* google_protobuf_ServiceOptions_parse(const char* buf, size_t size, upb_Arena* arena) {
google_protobuf_ServiceOptions* ret = google_protobuf_ServiceOptions_new(arena);
if (!ret) return NULL;
if (upb_decode(buf, size, ret, &google_protobuf_ServiceOptions_msginit, arena) != kUpb_DecodeStatus_Ok) {
if (upb_Decode(buf, size, ret, &google_protobuf_ServiceOptions_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
return NULL;
}
return ret;
@ -1865,7 +1865,7 @@ UPB_INLINE google_protobuf_ServiceOptions* google_protobuf_ServiceOptions_parse_
int options, upb_Arena* arena) {
google_protobuf_ServiceOptions* ret = google_protobuf_ServiceOptions_new(arena);
if (!ret) return NULL;
if (_upb_decode(buf, size, ret, &google_protobuf_ServiceOptions_msginit, extreg, options, arena) !=
if (upb_Decode(buf, size, ret, &google_protobuf_ServiceOptions_msginit, extreg, options, arena) !=
kUpb_DecodeStatus_Ok) {
return NULL;
}
@ -1911,7 +1911,7 @@ UPB_INLINE google_protobuf_MethodOptions* google_protobuf_MethodOptions_new(upb_
UPB_INLINE google_protobuf_MethodOptions* google_protobuf_MethodOptions_parse(const char* buf, size_t size, upb_Arena* arena) {
google_protobuf_MethodOptions* ret = google_protobuf_MethodOptions_new(arena);
if (!ret) return NULL;
if (upb_decode(buf, size, ret, &google_protobuf_MethodOptions_msginit, arena) != kUpb_DecodeStatus_Ok) {
if (upb_Decode(buf, size, ret, &google_protobuf_MethodOptions_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
return NULL;
}
return ret;
@ -1921,7 +1921,7 @@ UPB_INLINE google_protobuf_MethodOptions* google_protobuf_MethodOptions_parse_ex
int options, upb_Arena* arena) {
google_protobuf_MethodOptions* ret = google_protobuf_MethodOptions_new(arena);
if (!ret) return NULL;
if (_upb_decode(buf, size, ret, &google_protobuf_MethodOptions_msginit, extreg, options, arena) !=
if (upb_Decode(buf, size, ret, &google_protobuf_MethodOptions_msginit, extreg, options, arena) !=
kUpb_DecodeStatus_Ok) {
return NULL;
}
@ -1975,7 +1975,7 @@ UPB_INLINE google_protobuf_UninterpretedOption* google_protobuf_UninterpretedOpt
UPB_INLINE google_protobuf_UninterpretedOption* google_protobuf_UninterpretedOption_parse(const char* buf, size_t size, upb_Arena* arena) {
google_protobuf_UninterpretedOption* ret = google_protobuf_UninterpretedOption_new(arena);
if (!ret) return NULL;
if (upb_decode(buf, size, ret, &google_protobuf_UninterpretedOption_msginit, arena) != kUpb_DecodeStatus_Ok) {
if (upb_Decode(buf, size, ret, &google_protobuf_UninterpretedOption_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
return NULL;
}
return ret;
@ -1985,7 +1985,7 @@ UPB_INLINE google_protobuf_UninterpretedOption* google_protobuf_UninterpretedOpt
int options, upb_Arena* arena) {
google_protobuf_UninterpretedOption* ret = google_protobuf_UninterpretedOption_new(arena);
if (!ret) return NULL;
if (_upb_decode(buf, size, ret, &google_protobuf_UninterpretedOption_msginit, extreg, options, arena) !=
if (upb_Decode(buf, size, ret, &google_protobuf_UninterpretedOption_msginit, extreg, options, arena) !=
kUpb_DecodeStatus_Ok) {
return NULL;
}
@ -2071,7 +2071,7 @@ UPB_INLINE google_protobuf_UninterpretedOption_NamePart* google_protobuf_Uninter
UPB_INLINE google_protobuf_UninterpretedOption_NamePart* google_protobuf_UninterpretedOption_NamePart_parse(const char* buf, size_t size, upb_Arena* arena) {
google_protobuf_UninterpretedOption_NamePart* ret = google_protobuf_UninterpretedOption_NamePart_new(arena);
if (!ret) return NULL;
if (upb_decode(buf, size, ret, &google_protobuf_UninterpretedOption_NamePart_msginit, arena) != kUpb_DecodeStatus_Ok) {
if (upb_Decode(buf, size, ret, &google_protobuf_UninterpretedOption_NamePart_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
return NULL;
}
return ret;
@ -2081,7 +2081,7 @@ UPB_INLINE google_protobuf_UninterpretedOption_NamePart* google_protobuf_Uninter
int options, upb_Arena* arena) {
google_protobuf_UninterpretedOption_NamePart* ret = google_protobuf_UninterpretedOption_NamePart_new(arena);
if (!ret) return NULL;
if (_upb_decode(buf, size, ret, &google_protobuf_UninterpretedOption_NamePart_msginit, extreg, options, arena) !=
if (upb_Decode(buf, size, ret, &google_protobuf_UninterpretedOption_NamePart_msginit, extreg, options, arena) !=
kUpb_DecodeStatus_Ok) {
return NULL;
}
@ -2120,7 +2120,7 @@ UPB_INLINE google_protobuf_SourceCodeInfo* google_protobuf_SourceCodeInfo_new(up
UPB_INLINE google_protobuf_SourceCodeInfo* google_protobuf_SourceCodeInfo_parse(const char* buf, size_t size, upb_Arena* arena) {
google_protobuf_SourceCodeInfo* ret = google_protobuf_SourceCodeInfo_new(arena);
if (!ret) return NULL;
if (upb_decode(buf, size, ret, &google_protobuf_SourceCodeInfo_msginit, arena) != kUpb_DecodeStatus_Ok) {
if (upb_Decode(buf, size, ret, &google_protobuf_SourceCodeInfo_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
return NULL;
}
return ret;
@ -2130,7 +2130,7 @@ UPB_INLINE google_protobuf_SourceCodeInfo* google_protobuf_SourceCodeInfo_parse_
int options, upb_Arena* arena) {
google_protobuf_SourceCodeInfo* ret = google_protobuf_SourceCodeInfo_new(arena);
if (!ret) return NULL;
if (_upb_decode(buf, size, ret, &google_protobuf_SourceCodeInfo_msginit, extreg, options, arena) !=
if (upb_Decode(buf, size, ret, &google_protobuf_SourceCodeInfo_msginit, extreg, options, arena) !=
kUpb_DecodeStatus_Ok) {
return NULL;
}
@ -2168,7 +2168,7 @@ UPB_INLINE google_protobuf_SourceCodeInfo_Location* google_protobuf_SourceCodeIn
UPB_INLINE google_protobuf_SourceCodeInfo_Location* google_protobuf_SourceCodeInfo_Location_parse(const char* buf, size_t size, upb_Arena* arena) {
google_protobuf_SourceCodeInfo_Location* ret = google_protobuf_SourceCodeInfo_Location_new(arena);
if (!ret) return NULL;
if (upb_decode(buf, size, ret, &google_protobuf_SourceCodeInfo_Location_msginit, arena) != kUpb_DecodeStatus_Ok) {
if (upb_Decode(buf, size, ret, &google_protobuf_SourceCodeInfo_Location_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
return NULL;
}
return ret;
@ -2178,7 +2178,7 @@ UPB_INLINE google_protobuf_SourceCodeInfo_Location* google_protobuf_SourceCodeIn
int options, upb_Arena* arena) {
google_protobuf_SourceCodeInfo_Location* ret = google_protobuf_SourceCodeInfo_Location_new(arena);
if (!ret) return NULL;
if (_upb_decode(buf, size, ret, &google_protobuf_SourceCodeInfo_Location_msginit, extreg, options, arena) !=
if (upb_Decode(buf, size, ret, &google_protobuf_SourceCodeInfo_Location_msginit, extreg, options, arena) !=
kUpb_DecodeStatus_Ok) {
return NULL;
}
@ -2250,7 +2250,7 @@ UPB_INLINE google_protobuf_GeneratedCodeInfo* google_protobuf_GeneratedCodeInfo_
UPB_INLINE google_protobuf_GeneratedCodeInfo* google_protobuf_GeneratedCodeInfo_parse(const char* buf, size_t size, upb_Arena* arena) {
google_protobuf_GeneratedCodeInfo* ret = google_protobuf_GeneratedCodeInfo_new(arena);
if (!ret) return NULL;
if (upb_decode(buf, size, ret, &google_protobuf_GeneratedCodeInfo_msginit, arena) != kUpb_DecodeStatus_Ok) {
if (upb_Decode(buf, size, ret, &google_protobuf_GeneratedCodeInfo_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
return NULL;
}
return ret;
@ -2260,7 +2260,7 @@ UPB_INLINE google_protobuf_GeneratedCodeInfo* google_protobuf_GeneratedCodeInfo_
int options, upb_Arena* arena) {
google_protobuf_GeneratedCodeInfo* ret = google_protobuf_GeneratedCodeInfo_new(arena);
if (!ret) return NULL;
if (_upb_decode(buf, size, ret, &google_protobuf_GeneratedCodeInfo_msginit, extreg, options, arena) !=
if (upb_Decode(buf, size, ret, &google_protobuf_GeneratedCodeInfo_msginit, extreg, options, arena) !=
kUpb_DecodeStatus_Ok) {
return NULL;
}
@ -2298,7 +2298,7 @@ UPB_INLINE google_protobuf_GeneratedCodeInfo_Annotation* google_protobuf_Generat
UPB_INLINE google_protobuf_GeneratedCodeInfo_Annotation* google_protobuf_GeneratedCodeInfo_Annotation_parse(const char* buf, size_t size, upb_Arena* arena) {
google_protobuf_GeneratedCodeInfo_Annotation* ret = google_protobuf_GeneratedCodeInfo_Annotation_new(arena);
if (!ret) return NULL;
if (upb_decode(buf, size, ret, &google_protobuf_GeneratedCodeInfo_Annotation_msginit, arena) != kUpb_DecodeStatus_Ok) {
if (upb_Decode(buf, size, ret, &google_protobuf_GeneratedCodeInfo_Annotation_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
return NULL;
}
return ret;
@ -2308,7 +2308,7 @@ UPB_INLINE google_protobuf_GeneratedCodeInfo_Annotation* google_protobuf_Generat
int options, upb_Arena* arena) {
google_protobuf_GeneratedCodeInfo_Annotation* ret = google_protobuf_GeneratedCodeInfo_Annotation_new(arena);
if (!ret) return NULL;
if (_upb_decode(buf, size, ret, &google_protobuf_GeneratedCodeInfo_Annotation_msginit, extreg, options, arena) !=
if (upb_Decode(buf, size, ret, &google_protobuf_GeneratedCodeInfo_Annotation_msginit, extreg, options, arena) !=
kUpb_DecodeStatus_Ok) {
return NULL;
}

@ -126,9 +126,9 @@ static PyObject* PyUpb_DescriptorBase_GetOptions(PyUpb_DescriptorBase* self,
char* pb = upb_Encode(opts, layout, arena, &size);
upb_Message* opts2 = upb_Message_New(m, arena);
assert(opts2);
bool ok = _upb_decode(pb, size, opts2, upb_MessageDef_MiniTable(m),
upb_DefPool_ExtensionRegistry(symtab), 0,
arena) == kUpb_DecodeStatus_Ok;
bool ok = upb_Decode(pb, size, opts2, upb_MessageDef_MiniTable(m),
upb_DefPool_ExtensionRegistry(symtab), 0,
arena) == kUpb_DecodeStatus_Ok;
(void)ok;
assert(ok);

@ -1153,7 +1153,7 @@ PyObject* PyUpb_CMessage_MergeFromString(PyObject* _self, PyObject* arg) {
int options =
UPB_DECODE_MAXDEPTH(state->allow_oversize_protos ? UINT32_MAX : 100);
upb_DecodeStatus status =
_upb_decode(buf, size, self->ptr.msg, layout, extreg, options, arena);
upb_Decode(buf, size, self->ptr.msg, layout, extreg, options, arena);
Py_XDECREF(bytes);
if (status != kUpb_DecodeStatus_Ok) {
PyErr_Format(state->decode_error_class, "Error parsing message");

@ -442,3 +442,4 @@ s/upb_msg_extcount/upb_Message_ExtensionCount/g;
s/\bupb_extreg\b/upb_ExtensionRegistry/g;
s/upb_extreg_new/upb_ExtensionRegistry_New/g;
s/upb_msg\b/upb_Message/g;
s/_upb_decode\b/upb_Decode/g;

@ -1,3 +1,8 @@
shopt -s globstar
sed -i -f rename.sed **/*.c **/*.cc **/*.h **/*.hpp **/*.py
# Since sed can't handle multi-line patterns:
perl -i -pe 'BEGIN{undef $/;} s/\bupb_decode\(([^,\)]+),([^,]+),([^,]+),([^,]+),([^,\)]+)\)/upb_Decode(\1, \2, \3, \4, NULL, 0, \5)/smg' **/*.c **/*.cc **/*.h **/*.hpp
perl -i -pe 'BEGIN{undef $/;} s/\bupb_Encode\(([^,\)]+),([^,]+),([^,]+),([^,\)]+)\)/upb_Encode(\1, \2, 0, \3, \4)/smg' **/*.c **/*.cc **/*.h **/*.hpp
clang-format -i **/*.c **/*.cc **/*.h **/*.hpp

@ -88,8 +88,8 @@ typedef struct {
bool parse_proto(upb_Message* msg, const upb_MessageDef* m, const ctx* c) {
upb_StringView proto =
conformance_ConformanceRequest_protobuf_payload(c->request);
if (upb_decode(proto.data, proto.size, msg, upb_MessageDef_MiniTable(m),
c->arena) == kUpb_DecodeStatus_Ok) {
if (upb_Decode(proto.data, proto.size, msg, upb_MessageDef_MiniTable(m), NULL,
0, c->arena) == kUpb_DecodeStatus_Ok) {
return true;
} else {
static const char msg[] = "Parse error";

@ -962,8 +962,8 @@ static int lupb_decode(lua_State* L) {
buf = upb_Arena_Malloc(arena, len);
memcpy(buf, pb, len);
upb_DecodeStatus status = _upb_decode(buf, len, msg, layout, NULL,
kUpb_DecodeOption_AliasString, arena);
upb_DecodeStatus status = upb_Decode(buf, len, msg, layout, NULL,
kUpb_DecodeOption_AliasString, arena);
if (status != kUpb_DecodeStatus_Ok) {
lua_pushstring(L, "Error decoding protobuf.");

@ -1057,10 +1057,10 @@ static upb_DecodeStatus decode_top(struct upb_Decoder* d, const char* buf,
return kUpb_DecodeStatus_Ok;
}
upb_DecodeStatus _upb_decode(const char* buf, size_t size, void* msg,
const upb_MiniTable* l,
const upb_ExtensionRegistry* extreg, int options,
upb_Arena* arena) {
upb_DecodeStatus upb_Decode(const char* buf, size_t size, void* msg,
const upb_MiniTable* l,
const upb_ExtensionRegistry* extreg, int options,
upb_Arena* arena) {
upb_Decoder state;
unsigned depth = (unsigned)options >> 16;

@ -80,16 +80,10 @@ typedef enum {
kUpb_DecodeStatus_MissingRequired = 5,
} upb_DecodeStatus;
upb_DecodeStatus _upb_decode(const char* buf, size_t size, upb_Message* msg,
const upb_MiniTable* l,
const upb_ExtensionRegistry* extreg, int options,
upb_Arena* arena);
UPB_INLINE
upb_DecodeStatus upb_decode(const char* buf, size_t size, upb_Message* msg,
const upb_MiniTable* l, upb_Arena* arena) {
return _upb_decode(buf, size, msg, l, NULL, 0, arena);
}
upb_DecodeStatus upb_Decode(const char* buf, size_t size, upb_Message* msg,
const upb_MiniTable* l,
const upb_ExtensionRegistry* extreg, int options,
upb_Arena* arena);
#ifdef __cplusplus
} /* extern "C" */

@ -383,7 +383,7 @@ static void jsonenc_any(jsonenc* e, const upb_Message* msg,
upb_Arena* arena = jsonenc_arena(e);
upb_Message* any = upb_Message_New(any_m, arena);
if (upb_decode(value.data, value.size, any, any_layout, arena) !=
if (upb_Decode(value.data, value.size, any, any_layout, NULL, 0, arena) !=
kUpb_DecodeStatus_Ok) {
jsonenc_err(e, "Error decoding message in Any");
}

@ -246,8 +246,8 @@ TEST(MessageTest, DecodeRequiredFieldsTopLevelMessage) {
// Fails, because required fields are missing.
EXPECT_EQ(kUpb_DecodeStatus_MissingRequired,
_upb_decode(NULL, 0, test_msg, &upb_test_TestRequiredFields_msginit,
NULL, kUpb_DecodeOption_CheckRequired, arena.ptr()));
upb_Decode(NULL, 0, test_msg, &upb_test_TestRequiredFields_msginit,
NULL, kUpb_DecodeOption_CheckRequired, arena.ptr()));
upb_test_TestRequiredFields_set_required_int32(test_msg, 1);
size_t size;
@ -259,9 +259,9 @@ TEST(MessageTest, DecodeRequiredFieldsTopLevelMessage) {
// Fails, but the code path is slightly different because the serialized
// payload is not empty.
EXPECT_EQ(kUpb_DecodeStatus_MissingRequired,
_upb_decode(serialized, size, test_msg,
&upb_test_TestRequiredFields_msginit, NULL,
kUpb_DecodeOption_CheckRequired, arena.ptr()));
upb_Decode(serialized, size, test_msg,
&upb_test_TestRequiredFields_msginit, NULL,
kUpb_DecodeOption_CheckRequired, arena.ptr()));
empty_msg = upb_test_EmptyMessage_new(arena.ptr());
upb_test_TestRequiredFields_set_required_int32(test_msg, 1);
@ -270,8 +270,8 @@ TEST(MessageTest, DecodeRequiredFieldsTopLevelMessage) {
// Succeeds, because required fields are present (though not in the input).
EXPECT_EQ(kUpb_DecodeStatus_Ok,
_upb_decode(NULL, 0, test_msg, &upb_test_TestRequiredFields_msginit,
NULL, kUpb_DecodeOption_CheckRequired, arena.ptr()));
upb_Decode(NULL, 0, test_msg, &upb_test_TestRequiredFields_msginit,
NULL, kUpb_DecodeOption_CheckRequired, arena.ptr()));
// Serialize a complete payload.
serialized =
@ -288,9 +288,9 @@ TEST(MessageTest, DecodeRequiredFieldsTopLevelMessage) {
upb_test_TestRequiredFields_set_optional_message(
test_msg2, upb_test_TestRequiredFields_new(arena.ptr()));
EXPECT_EQ(kUpb_DecodeStatus_Ok,
_upb_decode(serialized, size, test_msg2,
&upb_test_TestRequiredFields_msginit, NULL,
kUpb_DecodeOption_CheckRequired, arena.ptr()));
upb_Decode(serialized, size, test_msg2,
&upb_test_TestRequiredFields_msginit, NULL,
kUpb_DecodeOption_CheckRequired, arena.ptr()));
}
TEST(MessageTest, DecodeRequiredFieldsSubMessage) {

@ -418,7 +418,7 @@ void GenerateMessageInHeader(const protobuf::Descriptor* message,
UPB_INLINE $0* $0_parse(const char* buf, size_t size, upb_Arena* arena) {
$0* ret = $0_new(arena);
if (!ret) return NULL;
if (upb_decode(buf, size, ret, &$1, arena) != kUpb_DecodeStatus_Ok) {
if (upb_Decode(buf, size, ret, &$1, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
return NULL;
}
return ret;
@ -428,7 +428,7 @@ void GenerateMessageInHeader(const protobuf::Descriptor* message,
int options, upb_Arena* arena) {
$0* ret = $0_new(arena);
if (!ret) return NULL;
if (_upb_decode(buf, size, ret, &$1, extreg, options, arena) !=
if (upb_Decode(buf, size, ret, &$1, extreg, options, arena) !=
kUpb_DecodeStatus_Ok) {
return NULL;
}

Loading…
Cancel
Save