Merge pull request #486 from haberman/rename2

Some more renaming
pull/13171/head
Joshua Haberman 3 years ago committed by GitHub
commit c80f133eee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 324
      cmake/google/protobuf/descriptor.upb.h
  2. 13
      python/convert.c
  3. 2
      python/convert.h
  4. 16
      python/descriptor.c
  5. 10
      python/extension_dict.c
  6. 53
      python/message.c
  7. 6
      python/message.h
  8. 6
      python/repeated.c
  9. 10
      rename.sed
  10. 5
      run_sed.sh
  11. 35
      tests/conformance_upb.c
  12. 101
      upb/bindings/lua/msg.c
  13. 82
      upb/decode.c
  14. 15
      upb/decode.h
  15. 42
      upb/decode_fast.c
  16. 8
      upb/decode_fast.h
  17. 18
      upb/decode_internal.h
  18. 13
      upb/def.c
  19. 3
      upb/def.h
  20. 18
      upb/encode.c
  21. 11
      upb/encode.h
  22. 60
      upb/json_decode.c
  23. 2
      upb/json_decode.h
  24. 36
      upb/json_encode.c
  25. 2
      upb/json_encode.h
  26. 45
      upb/msg.c
  27. 49
      upb/msg.h
  28. 89
      upb/msg_internal.h
  29. 20
      upb/msg_test.cc
  30. 39
      upb/reflection.c
  31. 30
      upb/reflection.h
  32. 14
      upb/text_encode.c
  33. 6
      upb/text_encode.h
  34. 4
      upb/util/def_to_proto_test.cc
  35. 6
      upb/util/required_fields.c
  36. 2
      upb/util/required_fields.h
  37. 12
      upbc/protoc-gen-upb.cc

@ -169,28 +169,28 @@ 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;
}
UPB_INLINE google_protobuf_FileDescriptorSet* google_protobuf_FileDescriptorSet_parse_ex(const char* buf, size_t size,
const upb_extreg* extreg, int options,
upb_Arena* arena) {
const upb_ExtensionRegistry* extreg,
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;
}
return ret;
}
UPB_INLINE char* google_protobuf_FileDescriptorSet_serialize(const google_protobuf_FileDescriptorSet* msg, upb_Arena* arena, size_t* len) {
return upb_Encode(msg, &google_protobuf_FileDescriptorSet_msginit, arena, len);
return upb_Encode(msg, &google_protobuf_FileDescriptorSet_msginit, 0, arena, len);
}
UPB_INLINE char* google_protobuf_FileDescriptorSet_serialize_ex(const google_protobuf_FileDescriptorSet* msg, int options,
upb_Arena* arena, size_t* len) {
return upb_EncodeEx(msg, &google_protobuf_FileDescriptorSet_msginit, options, arena, len);
return upb_Encode(msg, &google_protobuf_FileDescriptorSet_msginit, options, arena, len);
}
UPB_INLINE bool google_protobuf_FileDescriptorSet_has_file(const google_protobuf_FileDescriptorSet *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(0, 0)); }
UPB_INLINE const google_protobuf_FileDescriptorProto* const* google_protobuf_FileDescriptorSet_file(const google_protobuf_FileDescriptorSet *msg, size_t *len) { return (const google_protobuf_FileDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(0, 0), len); }
@ -217,28 +217,28 @@ 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;
}
UPB_INLINE google_protobuf_FileDescriptorProto* google_protobuf_FileDescriptorProto_parse_ex(const char* buf, size_t size,
const upb_extreg* extreg, int options,
upb_Arena* arena) {
const upb_ExtensionRegistry* extreg,
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;
}
return ret;
}
UPB_INLINE char* google_protobuf_FileDescriptorProto_serialize(const google_protobuf_FileDescriptorProto* msg, upb_Arena* arena, size_t* len) {
return upb_Encode(msg, &google_protobuf_FileDescriptorProto_msginit, arena, len);
return upb_Encode(msg, &google_protobuf_FileDescriptorProto_msginit, 0, arena, len);
}
UPB_INLINE char* google_protobuf_FileDescriptorProto_serialize_ex(const google_protobuf_FileDescriptorProto* msg, int options,
upb_Arena* arena, size_t* len) {
return upb_EncodeEx(msg, &google_protobuf_FileDescriptorProto_msginit, options, arena, len);
return upb_Encode(msg, &google_protobuf_FileDescriptorProto_msginit, options, arena, len);
}
UPB_INLINE bool google_protobuf_FileDescriptorProto_has_name(const google_protobuf_FileDescriptorProto *msg) { return _upb_hasbit(msg, 1); }
UPB_INLINE upb_StringView google_protobuf_FileDescriptorProto_name(const google_protobuf_FileDescriptorProto* msg) {
@ -401,28 +401,28 @@ 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;
}
UPB_INLINE google_protobuf_DescriptorProto* google_protobuf_DescriptorProto_parse_ex(const char* buf, size_t size,
const upb_extreg* extreg, int options,
upb_Arena* arena) {
const upb_ExtensionRegistry* extreg,
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;
}
return ret;
}
UPB_INLINE char* google_protobuf_DescriptorProto_serialize(const google_protobuf_DescriptorProto* msg, upb_Arena* arena, size_t* len) {
return upb_Encode(msg, &google_protobuf_DescriptorProto_msginit, arena, len);
return upb_Encode(msg, &google_protobuf_DescriptorProto_msginit, 0, arena, len);
}
UPB_INLINE char* google_protobuf_DescriptorProto_serialize_ex(const google_protobuf_DescriptorProto* msg, int options,
upb_Arena* arena, size_t* len) {
return upb_EncodeEx(msg, &google_protobuf_DescriptorProto_msginit, options, arena, len);
return upb_Encode(msg, &google_protobuf_DescriptorProto_msginit, options, arena, len);
}
UPB_INLINE bool google_protobuf_DescriptorProto_has_name(const google_protobuf_DescriptorProto *msg) { return _upb_hasbit(msg, 1); }
UPB_INLINE upb_StringView google_protobuf_DescriptorProto_name(const google_protobuf_DescriptorProto* msg) {
@ -575,28 +575,28 @@ 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;
}
UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange* google_protobuf_DescriptorProto_ExtensionRange_parse_ex(const char* buf, size_t size,
const upb_extreg* extreg, int options,
upb_Arena* arena) {
const upb_ExtensionRegistry* extreg,
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;
}
return ret;
}
UPB_INLINE char* google_protobuf_DescriptorProto_ExtensionRange_serialize(const google_protobuf_DescriptorProto_ExtensionRange* msg, upb_Arena* arena, size_t* len) {
return upb_Encode(msg, &google_protobuf_DescriptorProto_ExtensionRange_msginit, arena, len);
return upb_Encode(msg, &google_protobuf_DescriptorProto_ExtensionRange_msginit, 0, arena, len);
}
UPB_INLINE char* google_protobuf_DescriptorProto_ExtensionRange_serialize_ex(const google_protobuf_DescriptorProto_ExtensionRange* msg, int options,
upb_Arena* arena, size_t* len) {
return upb_EncodeEx(msg, &google_protobuf_DescriptorProto_ExtensionRange_msginit, options, arena, len);
return upb_Encode(msg, &google_protobuf_DescriptorProto_ExtensionRange_msginit, options, arena, len);
}
UPB_INLINE bool google_protobuf_DescriptorProto_ExtensionRange_has_start(const google_protobuf_DescriptorProto_ExtensionRange *msg) { return _upb_hasbit(msg, 1); }
UPB_INLINE int32_t google_protobuf_DescriptorProto_ExtensionRange_start(const google_protobuf_DescriptorProto_ExtensionRange* msg) {
@ -641,28 +641,28 @@ 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;
}
UPB_INLINE google_protobuf_DescriptorProto_ReservedRange* google_protobuf_DescriptorProto_ReservedRange_parse_ex(const char* buf, size_t size,
const upb_extreg* extreg, int options,
upb_Arena* arena) {
const upb_ExtensionRegistry* extreg,
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;
}
return ret;
}
UPB_INLINE char* google_protobuf_DescriptorProto_ReservedRange_serialize(const google_protobuf_DescriptorProto_ReservedRange* msg, upb_Arena* arena, size_t* len) {
return upb_Encode(msg, &google_protobuf_DescriptorProto_ReservedRange_msginit, arena, len);
return upb_Encode(msg, &google_protobuf_DescriptorProto_ReservedRange_msginit, 0, arena, len);
}
UPB_INLINE char* google_protobuf_DescriptorProto_ReservedRange_serialize_ex(const google_protobuf_DescriptorProto_ReservedRange* msg, int options,
upb_Arena* arena, size_t* len) {
return upb_EncodeEx(msg, &google_protobuf_DescriptorProto_ReservedRange_msginit, options, arena, len);
return upb_Encode(msg, &google_protobuf_DescriptorProto_ReservedRange_msginit, options, arena, len);
}
UPB_INLINE bool google_protobuf_DescriptorProto_ReservedRange_has_start(const google_protobuf_DescriptorProto_ReservedRange *msg) { return _upb_hasbit(msg, 1); }
UPB_INLINE int32_t google_protobuf_DescriptorProto_ReservedRange_start(const google_protobuf_DescriptorProto_ReservedRange* msg) {
@ -690,28 +690,28 @@ 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;
}
UPB_INLINE google_protobuf_ExtensionRangeOptions* google_protobuf_ExtensionRangeOptions_parse_ex(const char* buf, size_t size,
const upb_extreg* extreg, int options,
upb_Arena* arena) {
const upb_ExtensionRegistry* extreg,
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;
}
return ret;
}
UPB_INLINE char* google_protobuf_ExtensionRangeOptions_serialize(const google_protobuf_ExtensionRangeOptions* msg, upb_Arena* arena, size_t* len) {
return upb_Encode(msg, &google_protobuf_ExtensionRangeOptions_msginit, arena, len);
return upb_Encode(msg, &google_protobuf_ExtensionRangeOptions_msginit, 0, arena, len);
}
UPB_INLINE char* google_protobuf_ExtensionRangeOptions_serialize_ex(const google_protobuf_ExtensionRangeOptions* msg, int options,
upb_Arena* arena, size_t* len) {
return upb_EncodeEx(msg, &google_protobuf_ExtensionRangeOptions_msginit, options, arena, len);
return upb_Encode(msg, &google_protobuf_ExtensionRangeOptions_msginit, options, arena, len);
}
UPB_INLINE bool google_protobuf_ExtensionRangeOptions_has_uninterpreted_option(const google_protobuf_ExtensionRangeOptions *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(0, 0)); }
UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_ExtensionRangeOptions_uninterpreted_option(const google_protobuf_ExtensionRangeOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(0, 0), len); }
@ -738,28 +738,28 @@ 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;
}
UPB_INLINE google_protobuf_FieldDescriptorProto* google_protobuf_FieldDescriptorProto_parse_ex(const char* buf, size_t size,
const upb_extreg* extreg, int options,
upb_Arena* arena) {
const upb_ExtensionRegistry* extreg,
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;
}
return ret;
}
UPB_INLINE char* google_protobuf_FieldDescriptorProto_serialize(const google_protobuf_FieldDescriptorProto* msg, upb_Arena* arena, size_t* len) {
return upb_Encode(msg, &google_protobuf_FieldDescriptorProto_msginit, arena, len);
return upb_Encode(msg, &google_protobuf_FieldDescriptorProto_msginit, 0, arena, len);
}
UPB_INLINE char* google_protobuf_FieldDescriptorProto_serialize_ex(const google_protobuf_FieldDescriptorProto* msg, int options,
upb_Arena* arena, size_t* len) {
return upb_EncodeEx(msg, &google_protobuf_FieldDescriptorProto_msginit, options, arena, len);
return upb_Encode(msg, &google_protobuf_FieldDescriptorProto_msginit, options, arena, len);
}
UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_name(const google_protobuf_FieldDescriptorProto *msg) { return _upb_hasbit(msg, 1); }
UPB_INLINE upb_StringView google_protobuf_FieldDescriptorProto_name(const google_protobuf_FieldDescriptorProto* msg) {
@ -868,28 +868,28 @@ 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;
}
UPB_INLINE google_protobuf_OneofDescriptorProto* google_protobuf_OneofDescriptorProto_parse_ex(const char* buf, size_t size,
const upb_extreg* extreg, int options,
upb_Arena* arena) {
const upb_ExtensionRegistry* extreg,
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;
}
return ret;
}
UPB_INLINE char* google_protobuf_OneofDescriptorProto_serialize(const google_protobuf_OneofDescriptorProto* msg, upb_Arena* arena, size_t* len) {
return upb_Encode(msg, &google_protobuf_OneofDescriptorProto_msginit, arena, len);
return upb_Encode(msg, &google_protobuf_OneofDescriptorProto_msginit, 0, arena, len);
}
UPB_INLINE char* google_protobuf_OneofDescriptorProto_serialize_ex(const google_protobuf_OneofDescriptorProto* msg, int options,
upb_Arena* arena, size_t* len) {
return upb_EncodeEx(msg, &google_protobuf_OneofDescriptorProto_msginit, options, arena, len);
return upb_Encode(msg, &google_protobuf_OneofDescriptorProto_msginit, options, arena, len);
}
UPB_INLINE bool google_protobuf_OneofDescriptorProto_has_name(const google_protobuf_OneofDescriptorProto *msg) { return _upb_hasbit(msg, 1); }
UPB_INLINE upb_StringView google_protobuf_OneofDescriptorProto_name(const google_protobuf_OneofDescriptorProto* msg) {
@ -926,28 +926,28 @@ 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;
}
UPB_INLINE google_protobuf_EnumDescriptorProto* google_protobuf_EnumDescriptorProto_parse_ex(const char* buf, size_t size,
const upb_extreg* extreg, int options,
upb_Arena* arena) {
const upb_ExtensionRegistry* extreg,
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;
}
return ret;
}
UPB_INLINE char* google_protobuf_EnumDescriptorProto_serialize(const google_protobuf_EnumDescriptorProto* msg, upb_Arena* arena, size_t* len) {
return upb_Encode(msg, &google_protobuf_EnumDescriptorProto_msginit, arena, len);
return upb_Encode(msg, &google_protobuf_EnumDescriptorProto_msginit, 0, arena, len);
}
UPB_INLINE char* google_protobuf_EnumDescriptorProto_serialize_ex(const google_protobuf_EnumDescriptorProto* msg, int options,
upb_Arena* arena, size_t* len) {
return upb_EncodeEx(msg, &google_protobuf_EnumDescriptorProto_msginit, options, arena, len);
return upb_Encode(msg, &google_protobuf_EnumDescriptorProto_msginit, options, arena, len);
}
UPB_INLINE bool google_protobuf_EnumDescriptorProto_has_name(const google_protobuf_EnumDescriptorProto *msg) { return _upb_hasbit(msg, 1); }
UPB_INLINE upb_StringView google_protobuf_EnumDescriptorProto_name(const google_protobuf_EnumDescriptorProto* msg) {
@ -1025,28 +1025,28 @@ 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;
}
UPB_INLINE google_protobuf_EnumDescriptorProto_EnumReservedRange* google_protobuf_EnumDescriptorProto_EnumReservedRange_parse_ex(const char* buf, size_t size,
const upb_extreg* extreg, int options,
upb_Arena* arena) {
const upb_ExtensionRegistry* extreg,
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;
}
return ret;
}
UPB_INLINE char* google_protobuf_EnumDescriptorProto_EnumReservedRange_serialize(const google_protobuf_EnumDescriptorProto_EnumReservedRange* msg, upb_Arena* arena, size_t* len) {
return upb_Encode(msg, &google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit, arena, len);
return upb_Encode(msg, &google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit, 0, arena, len);
}
UPB_INLINE char* google_protobuf_EnumDescriptorProto_EnumReservedRange_serialize_ex(const google_protobuf_EnumDescriptorProto_EnumReservedRange* msg, int options,
upb_Arena* arena, size_t* len) {
return upb_EncodeEx(msg, &google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit, options, arena, len);
return upb_Encode(msg, &google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit, options, arena, len);
}
UPB_INLINE bool google_protobuf_EnumDescriptorProto_EnumReservedRange_has_start(const google_protobuf_EnumDescriptorProto_EnumReservedRange *msg) { return _upb_hasbit(msg, 1); }
UPB_INLINE int32_t google_protobuf_EnumDescriptorProto_EnumReservedRange_start(const google_protobuf_EnumDescriptorProto_EnumReservedRange* msg) {
@ -1074,28 +1074,28 @@ 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;
}
UPB_INLINE google_protobuf_EnumValueDescriptorProto* google_protobuf_EnumValueDescriptorProto_parse_ex(const char* buf, size_t size,
const upb_extreg* extreg, int options,
upb_Arena* arena) {
const upb_ExtensionRegistry* extreg,
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;
}
return ret;
}
UPB_INLINE char* google_protobuf_EnumValueDescriptorProto_serialize(const google_protobuf_EnumValueDescriptorProto* msg, upb_Arena* arena, size_t* len) {
return upb_Encode(msg, &google_protobuf_EnumValueDescriptorProto_msginit, arena, len);
return upb_Encode(msg, &google_protobuf_EnumValueDescriptorProto_msginit, 0, arena, len);
}
UPB_INLINE char* google_protobuf_EnumValueDescriptorProto_serialize_ex(const google_protobuf_EnumValueDescriptorProto* msg, int options,
upb_Arena* arena, size_t* len) {
return upb_EncodeEx(msg, &google_protobuf_EnumValueDescriptorProto_msginit, options, arena, len);
return upb_Encode(msg, &google_protobuf_EnumValueDescriptorProto_msginit, options, arena, len);
}
UPB_INLINE bool google_protobuf_EnumValueDescriptorProto_has_name(const google_protobuf_EnumValueDescriptorProto *msg) { return _upb_hasbit(msg, 1); }
UPB_INLINE upb_StringView google_protobuf_EnumValueDescriptorProto_name(const google_protobuf_EnumValueDescriptorProto* msg) {
@ -1140,28 +1140,28 @@ 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;
}
UPB_INLINE google_protobuf_ServiceDescriptorProto* google_protobuf_ServiceDescriptorProto_parse_ex(const char* buf, size_t size,
const upb_extreg* extreg, int options,
upb_Arena* arena) {
const upb_ExtensionRegistry* extreg,
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;
}
return ret;
}
UPB_INLINE char* google_protobuf_ServiceDescriptorProto_serialize(const google_protobuf_ServiceDescriptorProto* msg, upb_Arena* arena, size_t* len) {
return upb_Encode(msg, &google_protobuf_ServiceDescriptorProto_msginit, arena, len);
return upb_Encode(msg, &google_protobuf_ServiceDescriptorProto_msginit, 0, arena, len);
}
UPB_INLINE char* google_protobuf_ServiceDescriptorProto_serialize_ex(const google_protobuf_ServiceDescriptorProto* msg, int options,
upb_Arena* arena, size_t* len) {
return upb_EncodeEx(msg, &google_protobuf_ServiceDescriptorProto_msginit, options, arena, len);
return upb_Encode(msg, &google_protobuf_ServiceDescriptorProto_msginit, options, arena, len);
}
UPB_INLINE bool google_protobuf_ServiceDescriptorProto_has_name(const google_protobuf_ServiceDescriptorProto *msg) { return _upb_hasbit(msg, 1); }
UPB_INLINE upb_StringView google_protobuf_ServiceDescriptorProto_name(const google_protobuf_ServiceDescriptorProto* msg) {
@ -1213,28 +1213,28 @@ 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;
}
UPB_INLINE google_protobuf_MethodDescriptorProto* google_protobuf_MethodDescriptorProto_parse_ex(const char* buf, size_t size,
const upb_extreg* extreg, int options,
upb_Arena* arena) {
const upb_ExtensionRegistry* extreg,
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;
}
return ret;
}
UPB_INLINE char* google_protobuf_MethodDescriptorProto_serialize(const google_protobuf_MethodDescriptorProto* msg, upb_Arena* arena, size_t* len) {
return upb_Encode(msg, &google_protobuf_MethodDescriptorProto_msginit, arena, len);
return upb_Encode(msg, &google_protobuf_MethodDescriptorProto_msginit, 0, arena, len);
}
UPB_INLINE char* google_protobuf_MethodDescriptorProto_serialize_ex(const google_protobuf_MethodDescriptorProto* msg, int options,
upb_Arena* arena, size_t* len) {
return upb_EncodeEx(msg, &google_protobuf_MethodDescriptorProto_msginit, options, arena, len);
return upb_Encode(msg, &google_protobuf_MethodDescriptorProto_msginit, options, arena, len);
}
UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_name(const google_protobuf_MethodDescriptorProto *msg) { return _upb_hasbit(msg, 1); }
UPB_INLINE upb_StringView google_protobuf_MethodDescriptorProto_name(const google_protobuf_MethodDescriptorProto* msg) {
@ -1303,28 +1303,28 @@ 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;
}
UPB_INLINE google_protobuf_FileOptions* google_protobuf_FileOptions_parse_ex(const char* buf, size_t size,
const upb_extreg* extreg, int options,
upb_Arena* arena) {
const upb_ExtensionRegistry* extreg,
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;
}
return ret;
}
UPB_INLINE char* google_protobuf_FileOptions_serialize(const google_protobuf_FileOptions* msg, upb_Arena* arena, size_t* len) {
return upb_Encode(msg, &google_protobuf_FileOptions_msginit, arena, len);
return upb_Encode(msg, &google_protobuf_FileOptions_msginit, 0, arena, len);
}
UPB_INLINE char* google_protobuf_FileOptions_serialize_ex(const google_protobuf_FileOptions* msg, int options,
upb_Arena* arena, size_t* len) {
return upb_EncodeEx(msg, &google_protobuf_FileOptions_msginit, options, arena, len);
return upb_Encode(msg, &google_protobuf_FileOptions_msginit, options, arena, len);
}
UPB_INLINE bool google_protobuf_FileOptions_has_java_package(const google_protobuf_FileOptions *msg) { return _upb_hasbit(msg, 1); }
UPB_INLINE upb_StringView google_protobuf_FileOptions_java_package(const google_protobuf_FileOptions* msg) {
@ -1511,28 +1511,28 @@ 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;
}
UPB_INLINE google_protobuf_MessageOptions* google_protobuf_MessageOptions_parse_ex(const char* buf, size_t size,
const upb_extreg* extreg, int options,
upb_Arena* arena) {
const upb_ExtensionRegistry* extreg,
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;
}
return ret;
}
UPB_INLINE char* google_protobuf_MessageOptions_serialize(const google_protobuf_MessageOptions* msg, upb_Arena* arena, size_t* len) {
return upb_Encode(msg, &google_protobuf_MessageOptions_msginit, arena, len);
return upb_Encode(msg, &google_protobuf_MessageOptions_msginit, 0, arena, len);
}
UPB_INLINE char* google_protobuf_MessageOptions_serialize_ex(const google_protobuf_MessageOptions* msg, int options,
upb_Arena* arena, size_t* len) {
return upb_EncodeEx(msg, &google_protobuf_MessageOptions_msginit, options, arena, len);
return upb_Encode(msg, &google_protobuf_MessageOptions_msginit, options, arena, len);
}
UPB_INLINE bool google_protobuf_MessageOptions_has_message_set_wire_format(const google_protobuf_MessageOptions *msg) { return _upb_hasbit(msg, 1); }
UPB_INLINE bool google_protobuf_MessageOptions_message_set_wire_format(const google_protobuf_MessageOptions* msg) {
@ -1591,28 +1591,28 @@ 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;
}
UPB_INLINE google_protobuf_FieldOptions* google_protobuf_FieldOptions_parse_ex(const char* buf, size_t size,
const upb_extreg* extreg, int options,
upb_Arena* arena) {
const upb_ExtensionRegistry* extreg,
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;
}
return ret;
}
UPB_INLINE char* google_protobuf_FieldOptions_serialize(const google_protobuf_FieldOptions* msg, upb_Arena* arena, size_t* len) {
return upb_Encode(msg, &google_protobuf_FieldOptions_msginit, arena, len);
return upb_Encode(msg, &google_protobuf_FieldOptions_msginit, 0, arena, len);
}
UPB_INLINE char* google_protobuf_FieldOptions_serialize_ex(const google_protobuf_FieldOptions* msg, int options,
upb_Arena* arena, size_t* len) {
return upb_EncodeEx(msg, &google_protobuf_FieldOptions_msginit, options, arena, len);
return upb_Encode(msg, &google_protobuf_FieldOptions_msginit, options, arena, len);
}
UPB_INLINE bool google_protobuf_FieldOptions_has_ctype(const google_protobuf_FieldOptions *msg) { return _upb_hasbit(msg, 1); }
UPB_INLINE int32_t google_protobuf_FieldOptions_ctype(const google_protobuf_FieldOptions* msg) {
@ -1687,28 +1687,28 @@ 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;
}
UPB_INLINE google_protobuf_OneofOptions* google_protobuf_OneofOptions_parse_ex(const char* buf, size_t size,
const upb_extreg* extreg, int options,
upb_Arena* arena) {
const upb_ExtensionRegistry* extreg,
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;
}
return ret;
}
UPB_INLINE char* google_protobuf_OneofOptions_serialize(const google_protobuf_OneofOptions* msg, upb_Arena* arena, size_t* len) {
return upb_Encode(msg, &google_protobuf_OneofOptions_msginit, arena, len);
return upb_Encode(msg, &google_protobuf_OneofOptions_msginit, 0, arena, len);
}
UPB_INLINE char* google_protobuf_OneofOptions_serialize_ex(const google_protobuf_OneofOptions* msg, int options,
upb_Arena* arena, size_t* len) {
return upb_EncodeEx(msg, &google_protobuf_OneofOptions_msginit, options, arena, len);
return upb_Encode(msg, &google_protobuf_OneofOptions_msginit, options, arena, len);
}
UPB_INLINE bool google_protobuf_OneofOptions_has_uninterpreted_option(const google_protobuf_OneofOptions *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(0, 0)); }
UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_OneofOptions_uninterpreted_option(const google_protobuf_OneofOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(0, 0), len); }
@ -1735,28 +1735,28 @@ 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;
}
UPB_INLINE google_protobuf_EnumOptions* google_protobuf_EnumOptions_parse_ex(const char* buf, size_t size,
const upb_extreg* extreg, int options,
upb_Arena* arena) {
const upb_ExtensionRegistry* extreg,
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;
}
return ret;
}
UPB_INLINE char* google_protobuf_EnumOptions_serialize(const google_protobuf_EnumOptions* msg, upb_Arena* arena, size_t* len) {
return upb_Encode(msg, &google_protobuf_EnumOptions_msginit, arena, len);
return upb_Encode(msg, &google_protobuf_EnumOptions_msginit, 0, arena, len);
}
UPB_INLINE char* google_protobuf_EnumOptions_serialize_ex(const google_protobuf_EnumOptions* msg, int options,
upb_Arena* arena, size_t* len) {
return upb_EncodeEx(msg, &google_protobuf_EnumOptions_msginit, options, arena, len);
return upb_Encode(msg, &google_protobuf_EnumOptions_msginit, options, arena, len);
}
UPB_INLINE bool google_protobuf_EnumOptions_has_allow_alias(const google_protobuf_EnumOptions *msg) { return _upb_hasbit(msg, 1); }
UPB_INLINE bool google_protobuf_EnumOptions_allow_alias(const google_protobuf_EnumOptions* msg) {
@ -1799,28 +1799,28 @@ 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;
}
UPB_INLINE google_protobuf_EnumValueOptions* google_protobuf_EnumValueOptions_parse_ex(const char* buf, size_t size,
const upb_extreg* extreg, int options,
upb_Arena* arena) {
const upb_ExtensionRegistry* extreg,
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;
}
return ret;
}
UPB_INLINE char* google_protobuf_EnumValueOptions_serialize(const google_protobuf_EnumValueOptions* msg, upb_Arena* arena, size_t* len) {
return upb_Encode(msg, &google_protobuf_EnumValueOptions_msginit, arena, len);
return upb_Encode(msg, &google_protobuf_EnumValueOptions_msginit, 0, arena, len);
}
UPB_INLINE char* google_protobuf_EnumValueOptions_serialize_ex(const google_protobuf_EnumValueOptions* msg, int options,
upb_Arena* arena, size_t* len) {
return upb_EncodeEx(msg, &google_protobuf_EnumValueOptions_msginit, options, arena, len);
return upb_Encode(msg, &google_protobuf_EnumValueOptions_msginit, options, arena, len);
}
UPB_INLINE bool google_protobuf_EnumValueOptions_has_deprecated(const google_protobuf_EnumValueOptions *msg) { return _upb_hasbit(msg, 1); }
UPB_INLINE bool google_protobuf_EnumValueOptions_deprecated(const google_protobuf_EnumValueOptions* msg) {
@ -1855,28 +1855,28 @@ 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;
}
UPB_INLINE google_protobuf_ServiceOptions* google_protobuf_ServiceOptions_parse_ex(const char* buf, size_t size,
const upb_extreg* extreg, int options,
upb_Arena* arena) {
const upb_ExtensionRegistry* extreg,
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;
}
return ret;
}
UPB_INLINE char* google_protobuf_ServiceOptions_serialize(const google_protobuf_ServiceOptions* msg, upb_Arena* arena, size_t* len) {
return upb_Encode(msg, &google_protobuf_ServiceOptions_msginit, arena, len);
return upb_Encode(msg, &google_protobuf_ServiceOptions_msginit, 0, arena, len);
}
UPB_INLINE char* google_protobuf_ServiceOptions_serialize_ex(const google_protobuf_ServiceOptions* msg, int options,
upb_Arena* arena, size_t* len) {
return upb_EncodeEx(msg, &google_protobuf_ServiceOptions_msginit, options, arena, len);
return upb_Encode(msg, &google_protobuf_ServiceOptions_msginit, options, arena, len);
}
UPB_INLINE bool google_protobuf_ServiceOptions_has_deprecated(const google_protobuf_ServiceOptions *msg) { return _upb_hasbit(msg, 1); }
UPB_INLINE bool google_protobuf_ServiceOptions_deprecated(const google_protobuf_ServiceOptions* msg) {
@ -1911,28 +1911,28 @@ 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;
}
UPB_INLINE google_protobuf_MethodOptions* google_protobuf_MethodOptions_parse_ex(const char* buf, size_t size,
const upb_extreg* extreg, int options,
upb_Arena* arena) {
const upb_ExtensionRegistry* extreg,
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;
}
return ret;
}
UPB_INLINE char* google_protobuf_MethodOptions_serialize(const google_protobuf_MethodOptions* msg, upb_Arena* arena, size_t* len) {
return upb_Encode(msg, &google_protobuf_MethodOptions_msginit, arena, len);
return upb_Encode(msg, &google_protobuf_MethodOptions_msginit, 0, arena, len);
}
UPB_INLINE char* google_protobuf_MethodOptions_serialize_ex(const google_protobuf_MethodOptions* msg, int options,
upb_Arena* arena, size_t* len) {
return upb_EncodeEx(msg, &google_protobuf_MethodOptions_msginit, options, arena, len);
return upb_Encode(msg, &google_protobuf_MethodOptions_msginit, options, arena, len);
}
UPB_INLINE bool google_protobuf_MethodOptions_has_deprecated(const google_protobuf_MethodOptions *msg) { return _upb_hasbit(msg, 1); }
UPB_INLINE bool google_protobuf_MethodOptions_deprecated(const google_protobuf_MethodOptions* msg) {
@ -1975,28 +1975,28 @@ 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;
}
UPB_INLINE google_protobuf_UninterpretedOption* google_protobuf_UninterpretedOption_parse_ex(const char* buf, size_t size,
const upb_extreg* extreg, int options,
upb_Arena* arena) {
const upb_ExtensionRegistry* extreg,
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;
}
return ret;
}
UPB_INLINE char* google_protobuf_UninterpretedOption_serialize(const google_protobuf_UninterpretedOption* msg, upb_Arena* arena, size_t* len) {
return upb_Encode(msg, &google_protobuf_UninterpretedOption_msginit, arena, len);
return upb_Encode(msg, &google_protobuf_UninterpretedOption_msginit, 0, arena, len);
}
UPB_INLINE char* google_protobuf_UninterpretedOption_serialize_ex(const google_protobuf_UninterpretedOption* msg, int options,
upb_Arena* arena, size_t* len) {
return upb_EncodeEx(msg, &google_protobuf_UninterpretedOption_msginit, options, arena, len);
return upb_Encode(msg, &google_protobuf_UninterpretedOption_msginit, options, arena, len);
}
UPB_INLINE bool google_protobuf_UninterpretedOption_has_name(const google_protobuf_UninterpretedOption *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(56, 80)); }
UPB_INLINE const google_protobuf_UninterpretedOption_NamePart* const* google_protobuf_UninterpretedOption_name(const google_protobuf_UninterpretedOption *msg, size_t *len) { return (const google_protobuf_UninterpretedOption_NamePart* const*)_upb_array_accessor(msg, UPB_SIZE(56, 80), len); }
@ -2071,28 +2071,28 @@ 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;
}
UPB_INLINE google_protobuf_UninterpretedOption_NamePart* google_protobuf_UninterpretedOption_NamePart_parse_ex(const char* buf, size_t size,
const upb_extreg* extreg, int options,
upb_Arena* arena) {
const upb_ExtensionRegistry* extreg,
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;
}
return ret;
}
UPB_INLINE char* google_protobuf_UninterpretedOption_NamePart_serialize(const google_protobuf_UninterpretedOption_NamePart* msg, upb_Arena* arena, size_t* len) {
return upb_Encode(msg, &google_protobuf_UninterpretedOption_NamePart_msginit, arena, len);
return upb_Encode(msg, &google_protobuf_UninterpretedOption_NamePart_msginit, 0, arena, len);
}
UPB_INLINE char* google_protobuf_UninterpretedOption_NamePart_serialize_ex(const google_protobuf_UninterpretedOption_NamePart* msg, int options,
upb_Arena* arena, size_t* len) {
return upb_EncodeEx(msg, &google_protobuf_UninterpretedOption_NamePart_msginit, options, arena, len);
return upb_Encode(msg, &google_protobuf_UninterpretedOption_NamePart_msginit, options, arena, len);
}
UPB_INLINE bool google_protobuf_UninterpretedOption_NamePart_has_name_part(const google_protobuf_UninterpretedOption_NamePart *msg) { return _upb_hasbit(msg, 1); }
UPB_INLINE upb_StringView google_protobuf_UninterpretedOption_NamePart_name_part(const google_protobuf_UninterpretedOption_NamePart* msg) {
@ -2120,28 +2120,28 @@ 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;
}
UPB_INLINE google_protobuf_SourceCodeInfo* google_protobuf_SourceCodeInfo_parse_ex(const char* buf, size_t size,
const upb_extreg* extreg, int options,
upb_Arena* arena) {
const upb_ExtensionRegistry* extreg,
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;
}
return ret;
}
UPB_INLINE char* google_protobuf_SourceCodeInfo_serialize(const google_protobuf_SourceCodeInfo* msg, upb_Arena* arena, size_t* len) {
return upb_Encode(msg, &google_protobuf_SourceCodeInfo_msginit, arena, len);
return upb_Encode(msg, &google_protobuf_SourceCodeInfo_msginit, 0, arena, len);
}
UPB_INLINE char* google_protobuf_SourceCodeInfo_serialize_ex(const google_protobuf_SourceCodeInfo* msg, int options,
upb_Arena* arena, size_t* len) {
return upb_EncodeEx(msg, &google_protobuf_SourceCodeInfo_msginit, options, arena, len);
return upb_Encode(msg, &google_protobuf_SourceCodeInfo_msginit, options, arena, len);
}
UPB_INLINE bool google_protobuf_SourceCodeInfo_has_location(const google_protobuf_SourceCodeInfo *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(0, 0)); }
UPB_INLINE const google_protobuf_SourceCodeInfo_Location* const* google_protobuf_SourceCodeInfo_location(const google_protobuf_SourceCodeInfo *msg, size_t *len) { return (const google_protobuf_SourceCodeInfo_Location* const*)_upb_array_accessor(msg, UPB_SIZE(0, 0), len); }
@ -2168,28 +2168,28 @@ 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;
}
UPB_INLINE google_protobuf_SourceCodeInfo_Location* google_protobuf_SourceCodeInfo_Location_parse_ex(const char* buf, size_t size,
const upb_extreg* extreg, int options,
upb_Arena* arena) {
const upb_ExtensionRegistry* extreg,
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;
}
return ret;
}
UPB_INLINE char* google_protobuf_SourceCodeInfo_Location_serialize(const google_protobuf_SourceCodeInfo_Location* msg, upb_Arena* arena, size_t* len) {
return upb_Encode(msg, &google_protobuf_SourceCodeInfo_Location_msginit, arena, len);
return upb_Encode(msg, &google_protobuf_SourceCodeInfo_Location_msginit, 0, arena, len);
}
UPB_INLINE char* google_protobuf_SourceCodeInfo_Location_serialize_ex(const google_protobuf_SourceCodeInfo_Location* msg, int options,
upb_Arena* arena, size_t* len) {
return upb_EncodeEx(msg, &google_protobuf_SourceCodeInfo_Location_msginit, options, arena, len);
return upb_Encode(msg, &google_protobuf_SourceCodeInfo_Location_msginit, options, arena, len);
}
UPB_INLINE int32_t const* google_protobuf_SourceCodeInfo_Location_path(const google_protobuf_SourceCodeInfo_Location *msg, size_t *len) { return (int32_t const*)_upb_array_accessor(msg, UPB_SIZE(20, 40), len); }
UPB_INLINE int32_t const* google_protobuf_SourceCodeInfo_Location_span(const google_protobuf_SourceCodeInfo_Location *msg, size_t *len) { return (int32_t const*)_upb_array_accessor(msg, UPB_SIZE(24, 48), len); }
@ -2250,28 +2250,28 @@ 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;
}
UPB_INLINE google_protobuf_GeneratedCodeInfo* google_protobuf_GeneratedCodeInfo_parse_ex(const char* buf, size_t size,
const upb_extreg* extreg, int options,
upb_Arena* arena) {
const upb_ExtensionRegistry* extreg,
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;
}
return ret;
}
UPB_INLINE char* google_protobuf_GeneratedCodeInfo_serialize(const google_protobuf_GeneratedCodeInfo* msg, upb_Arena* arena, size_t* len) {
return upb_Encode(msg, &google_protobuf_GeneratedCodeInfo_msginit, arena, len);
return upb_Encode(msg, &google_protobuf_GeneratedCodeInfo_msginit, 0, arena, len);
}
UPB_INLINE char* google_protobuf_GeneratedCodeInfo_serialize_ex(const google_protobuf_GeneratedCodeInfo* msg, int options,
upb_Arena* arena, size_t* len) {
return upb_EncodeEx(msg, &google_protobuf_GeneratedCodeInfo_msginit, options, arena, len);
return upb_Encode(msg, &google_protobuf_GeneratedCodeInfo_msginit, options, arena, len);
}
UPB_INLINE bool google_protobuf_GeneratedCodeInfo_has_annotation(const google_protobuf_GeneratedCodeInfo *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(0, 0)); }
UPB_INLINE const google_protobuf_GeneratedCodeInfo_Annotation* const* google_protobuf_GeneratedCodeInfo_annotation(const google_protobuf_GeneratedCodeInfo *msg, size_t *len) { return (const google_protobuf_GeneratedCodeInfo_Annotation* const*)_upb_array_accessor(msg, UPB_SIZE(0, 0), len); }
@ -2298,28 +2298,28 @@ 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;
}
UPB_INLINE google_protobuf_GeneratedCodeInfo_Annotation* google_protobuf_GeneratedCodeInfo_Annotation_parse_ex(const char* buf, size_t size,
const upb_extreg* extreg, int options,
upb_Arena* arena) {
const upb_ExtensionRegistry* extreg,
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;
}
return ret;
}
UPB_INLINE char* google_protobuf_GeneratedCodeInfo_Annotation_serialize(const google_protobuf_GeneratedCodeInfo_Annotation* msg, upb_Arena* arena, size_t* len) {
return upb_Encode(msg, &google_protobuf_GeneratedCodeInfo_Annotation_msginit, arena, len);
return upb_Encode(msg, &google_protobuf_GeneratedCodeInfo_Annotation_msginit, 0, arena, len);
}
UPB_INLINE char* google_protobuf_GeneratedCodeInfo_Annotation_serialize_ex(const google_protobuf_GeneratedCodeInfo_Annotation* msg, int options,
upb_Arena* arena, size_t* len) {
return upb_EncodeEx(msg, &google_protobuf_GeneratedCodeInfo_Annotation_msginit, options, arena, len);
return upb_Encode(msg, &google_protobuf_GeneratedCodeInfo_Annotation_msginit, options, arena, len);
}
UPB_INLINE int32_t const* google_protobuf_GeneratedCodeInfo_Annotation_path(const google_protobuf_GeneratedCodeInfo_Annotation *msg, size_t *len) { return (int32_t const*)_upb_array_accessor(msg, UPB_SIZE(20, 32), len); }
UPB_INLINE bool google_protobuf_GeneratedCodeInfo_Annotation_has_source_file(const google_protobuf_GeneratedCodeInfo_Annotation *msg) { return _upb_hasbit(msg, 1); }

@ -66,7 +66,7 @@ PyObject* PyUpb_UpbToPy(upb_MessageValue val, const upb_FieldDef* f,
return ret;
}
case kUpb_CType_Message:
return PyUpb_CMessage_Get((upb_msg*)val.msg_val,
return PyUpb_CMessage_Get((upb_Message*)val.msg_val,
upb_FieldDef_MessageSubDef(f), arena);
default:
PyErr_Format(PyExc_SystemError,
@ -242,7 +242,7 @@ bool PyUpb_PyToUpb(PyObject* obj, const upb_FieldDef* f, upb_MessageValue* val,
}
}
bool PyUpb_Message_IsEqual(const upb_msg* msg1, const upb_msg* msg2,
bool PyUpb_Message_IsEqual(const upb_Message* msg1, const upb_Message* msg2,
const upb_MessageDef* m);
// -----------------------------------------------------------------------------
@ -341,10 +341,11 @@ bool PyUpb_Array_IsEqual(const upb_Array* arr1, const upb_Array* arr2,
return true;
}
bool PyUpb_Message_IsEqual(const upb_msg* msg1, const upb_msg* msg2,
bool PyUpb_Message_IsEqual(const upb_Message* msg1, const upb_Message* msg2,
const upb_MessageDef* m) {
if (msg1 == msg2) return true;
if (upb_msg_extcount(msg1) != upb_msg_extcount(msg2)) return false;
if (upb_Message_ExtensionCount(msg1) != upb_Message_ExtensionCount(msg2))
return false;
// Compare messages field-by-field. This is slightly tricky, because while
// we can iterate over normal fields in a predictable order, the extension
@ -392,8 +393,8 @@ bool PyUpb_Message_IsEqual(const upb_msg* msg1, const upb_msg* msg2,
if (upb_Message_Next(msg2, m, NULL, &f2, &val2, &iter2)) return false;
size_t usize1, usize2;
const char* uf1 = upb_Message_Getunknown(msg1, &usize1);
const char* uf2 = upb_Message_Getunknown(msg2, &usize2);
const char* uf1 = upb_Message_GetUnknown(msg1, &usize1);
const char* uf2 = upb_Message_GetUnknown(msg2, &usize2);
// 100 is arbitrary, we're trying to prevent stack overflow but it's not
// obvious how deep we should allow here.
return upb_Message_UnknownFieldsAreEqual(uf1, usize1, uf2, usize2, 100) ==

@ -53,7 +53,7 @@ bool PyUpb_ValueEq(upb_MessageValue val1, upb_MessageValue val2,
const upb_FieldDef* f);
// Returns true if the given messages (of type `m`) are equal.
bool PyUpb_Message_IsEqual(const upb_msg* msg1, const upb_msg* msg2,
bool PyUpb_Message_IsEqual(const upb_Message* msg1, const upb_Message* msg2,
const upb_MessageDef* m);
// Returns true if the two arrays (with element type `f`) are equal.

@ -101,7 +101,7 @@ static PyUpb_DescriptorBase* PyUpb_DescriptorBase_Check(
}
static PyObject* PyUpb_DescriptorBase_GetOptions(PyUpb_DescriptorBase* self,
const upb_msg* opts,
const upb_Message* opts,
const upb_MiniTable* layout,
const char* msg_name) {
if (!self->options) {
@ -123,12 +123,12 @@ static PyObject* PyUpb_DescriptorBase_GetOptions(PyUpb_DescriptorBase* self,
size_t size;
PyObject* py_arena = PyUpb_Arena_New();
upb_Arena* arena = PyUpb_Arena_Get(py_arena);
char* pb = upb_Encode(opts, layout, arena, &size);
upb_msg* opts2 = upb_Message_New(m, arena);
char* pb = upb_Encode(opts, layout, 0, 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);
@ -147,10 +147,10 @@ static PyObject* PyUpb_DescriptorBase_GetSerializedProto(
PyUpb_DescriptorBase* self = (void*)_self;
upb_Arena* arena = upb_Arena_New();
if (!arena) PYUPB_RETURN_OOM;
upb_msg* proto = func(self->def, arena);
upb_Message* proto = func(self->def, arena);
if (!proto) goto oom;
size_t size;
char* pb = upb_Encode(proto, layout, arena, &size);
char* pb = upb_Encode(proto, layout, 0, arena, &size);
if (!pb) goto oom;
PyObject* str = PyBytes_FromStringAndSize(pb, size);
upb_Arena_Free(arena);

@ -70,7 +70,7 @@ static PyObject* PyUpb_ExtensionDict_FindExtensionByNumber(PyObject* _self,
const upb_MiniTable* l = upb_MessageDef_MiniTable(m);
const upb_FileDef* file = upb_MessageDef_File(m);
const upb_DefPool* symtab = upb_FileDef_Pool(file);
const upb_extreg* reg = upb_DefPool_ExtensionRegistry(symtab);
const upb_ExtensionRegistry* reg = upb_DefPool_ExtensionRegistry(symtab);
int64_t number = PyLong_AsLong(arg);
const upb_MiniTable_Extension* ext =
(upb_MiniTable_Extension*)_upb_extreg_get(reg, l, number);
@ -92,7 +92,7 @@ static int PyUpb_ExtensionDict_Contains(PyObject* _self, PyObject* key) {
PyUpb_ExtensionDict* self = (PyUpb_ExtensionDict*)_self;
const upb_FieldDef* f = PyUpb_CMessage_GetExtensionDef(self->msg, key);
if (!f) return -1;
upb_msg* msg = PyUpb_CMessage_GetIfReified(self->msg);
upb_Message* msg = PyUpb_CMessage_GetIfReified(self->msg);
if (!msg) return 0;
if (upb_FieldDef_IsRepeated(f)) {
upb_MessageValue val = upb_Message_Get(msg, f);
@ -104,8 +104,8 @@ static int PyUpb_ExtensionDict_Contains(PyObject* _self, PyObject* key) {
static Py_ssize_t PyUpb_ExtensionDict_Length(PyObject* _self) {
PyUpb_ExtensionDict* self = (PyUpb_ExtensionDict*)_self;
upb_msg* msg = PyUpb_CMessage_GetIfReified(self->msg);
return msg ? upb_msg_extcount(msg) : 0;
upb_Message* msg = PyUpb_CMessage_GetIfReified(self->msg);
return msg ? upb_Message_ExtensionCount(msg) : 0;
}
static PyObject* PyUpb_ExtensionDict_Subscript(PyObject* _self, PyObject* key) {
@ -190,7 +190,7 @@ static void PyUpb_ExtensionIterator_Dealloc(void* _self) {
PyObject* PyUpb_ExtensionIterator_IterNext(PyObject* _self) {
PyUpb_ExtensionIterator* self = (PyUpb_ExtensionIterator*)_self;
upb_msg* msg = PyUpb_CMessage_GetIfReified(self->msg);
upb_Message* msg = PyUpb_CMessage_GetIfReified(self->msg);
if (!msg) return NULL;
const upb_MessageDef* m = PyUpb_CMessage_GetMsgdef(self->msg);
const upb_DefPool* symtab = upb_FileDef_Pool(upb_MessageDef_File(m));

@ -192,7 +192,7 @@ typedef struct PyUpb_CMessage {
uintptr_t def; // Tagged, low bit 1 == upb_FieldDef*, else upb_MessageDef*
union {
// when def is msgdef, the data for this msg.
upb_msg* msg;
upb_Message* msg;
// when def is fielddef, owning pointer to parent
struct PyUpb_CMessage* parent;
} ptr;
@ -221,7 +221,7 @@ const upb_MessageDef* PyUpb_CMessage_GetMsgdef(PyObject* self) {
return _PyUpb_CMessage_GetMsgdef((PyUpb_CMessage*)self);
}
static upb_msg* PyUpb_CMessage_GetMsg(PyUpb_CMessage* self) {
static upb_Message* PyUpb_CMessage_GetMsg(PyUpb_CMessage* self) {
assert(!PyUpb_CMessage_IsStub(self));
return self->ptr.msg;
}
@ -243,7 +243,7 @@ bool PyUpb_CMessage_Check(PyObject* self) {
// If the message is reified, returns it. Otherwise, returns NULL.
// If NULL is returned, the object is empty and has no underlying data.
upb_msg* PyUpb_CMessage_GetIfReified(PyObject* _self) {
upb_Message* PyUpb_CMessage_GetIfReified(PyObject* _self) {
PyUpb_CMessage* self = (void*)_self;
return PyUpb_CMessage_IsStub(self) ? NULL : self->ptr.msg;
}
@ -422,7 +422,7 @@ static bool PyUpb_CMessage_InitMessageAttribute(PyObject* _self, PyObject* name,
return ok;
}
static bool PyUpb_CMessage_InitScalarAttribute(upb_msg* msg,
static bool PyUpb_CMessage_InitScalarAttribute(upb_Message* msg,
const upb_FieldDef* f,
PyObject* value,
upb_Arena* arena) {
@ -449,7 +449,7 @@ int PyUpb_CMessage_InitAttributes(PyObject* _self, PyObject* args,
PyObject* name;
PyObject* value;
PyUpb_CMessage_EnsureReified(self);
upb_msg* msg = PyUpb_CMessage_GetMsg(self);
upb_Message* msg = PyUpb_CMessage_GetMsg(self);
upb_Arena* arena = PyUpb_Arena_Get(self->arena);
while (PyDict_Next(kwargs, &pos, &name, &value)) {
@ -520,8 +520,8 @@ static bool PyUpb_CMessage_IsEqual(PyUpb_CMessage* m1, PyObject* _m2) {
const upb_MessageDef* m2_msgdef = _PyUpb_CMessage_GetMsgdef(m2);
assert(m1_msgdef == m2_msgdef);
#endif
const upb_msg* m1_msg = PyUpb_CMessage_GetIfReified((PyObject*)m1);
const upb_msg* m2_msg = PyUpb_CMessage_GetIfReified(_m2);
const upb_Message* m1_msg = PyUpb_CMessage_GetIfReified((PyObject*)m1);
const upb_Message* m2_msg = PyUpb_CMessage_GetIfReified(_m2);
return PyUpb_Message_IsEqual(m1_msg, m2_msg, m1_msgdef);
}
@ -566,8 +566,8 @@ void PyUpb_CMessage_EnsureReified(PyUpb_CMessage* self) {
if (!PyUpb_CMessage_IsStub(self)) return;
upb_Arena* arena = PyUpb_Arena_Get(self->arena);
// This is a non-present message. We need to create a real upb_msg for this
// object and every parent until we reach a present message.
// This is a non-present message. We need to create a real upb_Message for
// this object and every parent until we reach a present message.
PyUpb_CMessage* child = self;
PyUpb_CMessage* parent = self->ptr.parent;
const upb_FieldDef* child_f = PyUpb_CMessage_InitAsMsg(child, arena);
@ -600,7 +600,7 @@ static void PyUpb_CMessage_SyncSubobjs(PyUpb_CMessage* self);
* the set state (having a non-owning pointer to self->ptr.msg).
*/
static void PyUpb_CMessage_Reify(PyUpb_CMessage* self, const upb_FieldDef* f,
upb_msg* msg) {
upb_Message* msg) {
assert(f == PyUpb_CMessage_GetFieldDef(self));
if (!msg) {
const upb_MessageDef* msgdef = PyUpb_CMessage_GetMsgdef((PyObject*)self);
@ -616,7 +616,7 @@ static void PyUpb_CMessage_Reify(PyUpb_CMessage* self, const upb_FieldDef* f,
/*
* PyUpb_CMessage_SyncSubobjs()
*
* This operation must be invoked whenever the underlying upb_msg has been
* This operation must be invoked whenever the underlying upb_Message has been
* mutated directly in C. This will attach any newly-present field data
* to previously returned stub wrapper objects.
*
@ -635,7 +635,7 @@ static void PyUpb_CMessage_SyncSubobjs(PyUpb_CMessage* self) {
PyUpb_WeakMap* subobj_map = self->unset_subobj_map;
if (!subobj_map) return;
upb_msg* msg = PyUpb_CMessage_GetMsg(self);
upb_Message* msg = PyUpb_CMessage_GetMsg(self);
intptr_t iter = PYUPB_WEAKMAP_BEGIN;
const void* key;
PyObject* obj;
@ -661,7 +661,7 @@ static void PyUpb_CMessage_SyncSubobjs(PyUpb_CMessage* self) {
} else {
PyUpb_CMessage* sub = (void*)obj;
assert(self == sub->ptr.parent);
PyUpb_CMessage_Reify(sub, f, (upb_msg*)msgval.msg_val);
PyUpb_CMessage_Reify(sub, f, (upb_Message*)msgval.msg_val);
}
}
@ -675,18 +675,17 @@ static PyObject* PyUpb_CMessage_ToString(PyUpb_CMessage* self) {
if (PyUpb_CMessage_IsStub(self)) {
return PyUnicode_FromStringAndSize(NULL, 0);
}
upb_msg* msg = PyUpb_CMessage_GetMsg(self);
upb_Message* msg = PyUpb_CMessage_GetMsg(self);
const upb_MessageDef* msgdef = _PyUpb_CMessage_GetMsgdef(self);
const upb_DefPool* symtab = upb_FileDef_Pool(upb_MessageDef_File(msgdef));
char buf[1024];
int options = UPB_TXTENC_SKIPUNKNOWN;
size_t size = upb_text_encode(msg, msgdef, symtab, options, buf, sizeof(buf));
size_t size = upb_TextEncode(msg, msgdef, symtab, options, buf, sizeof(buf));
if (size < sizeof(buf)) {
return PyUnicode_FromStringAndSize(buf, size);
} else {
char* buf2 = malloc(size + 1);
size_t size2 =
upb_text_encode(msg, msgdef, symtab, options, buf2, size + 1);
size_t size2 = upb_TextEncode(msg, msgdef, symtab, options, buf2, size + 1);
assert(size == size2);
PyObject* ret = PyUnicode_FromStringAndSize(buf2, size2);
free(buf2);
@ -749,7 +748,7 @@ static void PyUpb_CMessage_Dealloc(PyObject* _self) {
}
}
PyObject* PyUpb_CMessage_Get(upb_msg* u_msg, const upb_MessageDef* m,
PyObject* PyUpb_CMessage_Get(upb_Message* u_msg, const upb_MessageDef* m,
PyObject* arena) {
PyObject* ret = PyUpb_ObjCache_Get(u_msg);
if (ret) return ret;
@ -1011,7 +1010,7 @@ static PyObject* PyUpb_CMessage_IsInitialized(PyObject* _self, PyObject* args) {
} else {
// We just need to return a boolean "true" or "false" for whether all
// required fields are set.
upb_msg* msg = PyUpb_CMessage_GetIfReified(_self);
upb_Message* msg = PyUpb_CMessage_GetIfReified(_self);
const upb_MessageDef* m = PyUpb_CMessage_GetMsgdef(_self);
const upb_DefPool* symtab = upb_FileDef_Pool(upb_MessageDef_File(m));
bool initialized = !upb_util_HasUnsetRequired(msg, m, symtab, NULL);
@ -1052,7 +1051,7 @@ err:
static PyObject* PyUpb_CMessage_ListFields(PyObject* _self, PyObject* arg) {
PyObject* list = PyList_New(0);
upb_msg* msg = PyUpb_CMessage_GetIfReified(_self);
upb_Message* msg = PyUpb_CMessage_GetIfReified(_self);
if (!msg) return list;
size_t iter1 = kUpb_Message_Begin;
@ -1145,7 +1144,7 @@ PyObject* PyUpb_CMessage_MergeFromString(PyObject* _self, PyObject* arg) {
PyUpb_CMessage_EnsureReified(self);
const upb_MessageDef* msgdef = _PyUpb_CMessage_GetMsgdef(self);
const upb_FileDef* file = upb_MessageDef_File(msgdef);
const upb_extreg* extreg =
const upb_ExtensionRegistry* extreg =
upb_DefPool_ExtensionRegistry(upb_FileDef_Pool(file));
const upb_MiniTable* layout = upb_MessageDef_MiniTable(msgdef);
upb_Arena* arena = PyUpb_Arena_Get(self->arena);
@ -1153,7 +1152,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");
@ -1190,7 +1189,7 @@ static PyObject* PyUpb_CMessage_Clear(PyUpb_CMessage* self, PyObject* args) {
PyUpb_WeakMap* subobj_map = self->unset_subobj_map;
if (subobj_map) {
upb_msg* msg = PyUpb_CMessage_GetMsg(self);
upb_Message* msg = PyUpb_CMessage_GetMsg(self);
intptr_t iter = PYUPB_WEAKMAP_BEGIN;
const void* key;
PyObject* obj;
@ -1290,7 +1289,7 @@ static PyObject* PyUpb_CMessage_DiscardUnknownFields(PyUpb_CMessage* self,
static PyObject* PyUpb_CMessage_FindInitializationErrors(PyObject* _self,
PyObject* arg) {
PyUpb_CMessage* self = (void*)_self;
upb_msg* msg = PyUpb_CMessage_GetIfReified(_self);
upb_Message* msg = PyUpb_CMessage_GetIfReified(_self);
const upb_MessageDef* msgdef = _PyUpb_CMessage_GetMsgdef(self);
const upb_DefPool* ext_pool = upb_FileDef_Pool(upb_MessageDef_File(msgdef));
upb_FieldPathEntry* fields;
@ -1363,7 +1362,7 @@ const upb_FieldDef* PyUpb_CMessage_GetExtensionDef(PyObject* _self,
static PyObject* PyUpb_CMessage_HasExtension(PyObject* _self,
PyObject* ext_desc) {
upb_msg* msg = PyUpb_CMessage_GetIfReified(_self);
upb_Message* msg = PyUpb_CMessage_GetIfReified(_self);
const upb_FieldDef* f = PyUpb_CMessage_GetExtensionDef(_self, ext_desc);
if (!f) return NULL;
if (upb_FieldDef_IsRepeated(f)) {
@ -1426,7 +1425,7 @@ PyObject* PyUpb_CMessage_SerializeInternal(PyObject* _self, PyObject* args,
int options = UPB_ENCODE_MAXDEPTH(UINT32_MAX);
if (check_required) options |= kUpb_Encode_CheckRequired;
if (deterministic) options |= kUpb_Encode_Deterministic;
char* pb = upb_EncodeEx(self->ptr.msg, layout, options, arena, &size);
char* pb = upb_Encode(self->ptr.msg, layout, options, arena, &size);
PyObject* ret = NULL;
if (!pb) {
@ -1465,7 +1464,7 @@ static PyObject* PyUpb_CMessage_WhichOneof(PyObject* _self, PyObject* name) {
if (!PyUpb_CMessage_LookupName(self, name, NULL, &o, PyExc_ValueError)) {
return NULL;
}
upb_msg* msg = PyUpb_CMessage_GetIfReified(_self);
upb_Message* msg = PyUpb_CMessage_GetIfReified(_self);
if (!msg) Py_RETURN_NONE;
const upb_FieldDef* f = upb_Message_WhichOneof(msg, o);
if (!f) Py_RETURN_NONE;

@ -45,16 +45,16 @@ void PyUpb_CMessage_SetConcreteSubobj(PyObject* _self, const upb_FieldDef* f,
// Gets a Python wrapper object for message `u_msg` of type `m`, returning a
// cached wrapper if one was previously created. If a new object is created,
// it will reference `arena`, which must own `u_msg`.
PyObject* PyUpb_CMessage_Get(upb_msg* u_msg, const upb_MessageDef* m,
PyObject* PyUpb_CMessage_Get(upb_Message* u_msg, const upb_MessageDef* m,
PyObject* arena);
// Verifies that a Python object is a message. Sets a TypeError exception and
// returns false on failure.
bool PyUpb_CMessage_Check(PyObject* self);
// Gets the upb_msg* for this message object if the message is reified.
// Gets the upb_Message* for this message object if the message is reified.
// Otherwise returns NULL.
upb_msg* PyUpb_CMessage_GetIfReified(PyObject* _self);
upb_Message* PyUpb_CMessage_GetIfReified(PyObject* _self);
// Returns the `upb_MessageDef` for a given CMessage.
const upb_MessageDef* PyUpb_CMessage_GetMsgdef(PyObject* self);

@ -213,7 +213,7 @@ PyObject* PyUpb_RepeatedContainer_DeepCopy(PyObject* _self, PyObject* value) {
if (!result) {
Py_DECREF(clone);
return NULL;
}
}
Py_DECREF(result);
return (PyObject*)clone;
}
@ -577,7 +577,7 @@ static PyObject* PyUpb_RepeatedCompositeContainer_AppendNew(PyObject* _self) {
const upb_FieldDef* f = PyUpb_RepeatedContainer_GetField(self);
upb_Arena* arena = PyUpb_Arena_Get(self->arena);
const upb_MessageDef* m = upb_FieldDef_MessageSubDef(f);
upb_msg* msg = upb_Message_New(m, arena);
upb_Message* msg = upb_Message_New(m, arena);
upb_MessageValue msgval = {.msg_val = msg};
upb_Array_Append(arr, msgval, arena);
return PyUpb_CMessage_Get(msg, m, self->arena);
@ -631,7 +631,7 @@ static PyObject* PyUpb_RepeatedContainer_Insert(PyObject* _self,
if (upb_FieldDef_IsSubMessage(f)) {
// Create message.
const upb_MessageDef* m = upb_FieldDef_MessageSubDef(f);
upb_msg* msg = upb_Message_New(m, arena);
upb_Message* msg = upb_Message_New(m, arena);
PyObject* py_msg = PyUpb_CMessage_Get(msg, m, self->arena);
PyObject* ret = PyUpb_CMessage_MergeFrom(py_msg, value);
Py_DECREF(py_msg);

@ -435,3 +435,13 @@ s/\bLookupEnum\b/FindEnumByName/g;
s/\bLookupFile\b/FindFileByName/g;
s/PyObject_HEAD[^;]/PyObject_HEAD;/g;
s/upb_msg_addunknown/upb_Message_AddUnknown/g;
s/upb_Message_Getunknown/upb_Message_GetUnknown/g;
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;
s/upb_EncodeEx\b/upb_Encode/g;
s/upb_text_encode/upb_TextEncode/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

@ -85,11 +85,11 @@ typedef struct {
const upb_DefPool* symtab;
} ctx;
bool parse_proto(upb_msg* msg, const upb_MessageDef* m, const ctx* c) {
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";
@ -99,10 +99,10 @@ bool parse_proto(upb_msg* msg, const upb_MessageDef* m, const ctx* c) {
}
}
void serialize_proto(const upb_msg* msg, const upb_MessageDef* m,
void serialize_proto(const upb_Message* msg, const upb_MessageDef* m,
const ctx* c) {
size_t len;
char* data = upb_Encode(msg, upb_MessageDef_MiniTable(m), c->arena, &len);
char* data = upb_Encode(msg, upb_MessageDef_MiniTable(m), 0, c->arena, &len);
if (data) {
conformance_ConformanceResponse_set_protobuf_payload(
c->response, upb_StringView_FromDataAndSize(data, len));
@ -113,7 +113,8 @@ void serialize_proto(const upb_msg* msg, const upb_MessageDef* m,
}
}
void serialize_text(const upb_msg* msg, const upb_MessageDef* m, const ctx* c) {
void serialize_text(const upb_Message* msg, const upb_MessageDef* m,
const ctx* c) {
size_t len;
size_t len2;
int opts = 0;
@ -123,15 +124,15 @@ void serialize_text(const upb_msg* msg, const upb_MessageDef* m, const ctx* c) {
opts |= UPB_TXTENC_SKIPUNKNOWN;
}
len = upb_text_encode(msg, m, c->symtab, opts, NULL, 0);
len = upb_TextEncode(msg, m, c->symtab, opts, NULL, 0);
data = upb_Arena_Malloc(c->arena, len + 1);
len2 = upb_text_encode(msg, m, c->symtab, opts, data, len + 1);
len2 = upb_TextEncode(msg, m, c->symtab, opts, data, len + 1);
UPB_ASSERT(len == len2);
conformance_ConformanceResponse_set_text_payload(
c->response, upb_StringView_FromDataAndSize(data, len));
}
bool parse_json(upb_msg* msg, const upb_MessageDef* m, const ctx* c) {
bool parse_json(upb_Message* msg, const upb_MessageDef* m, const ctx* c) {
upb_StringView json = conformance_ConformanceRequest_json_payload(c->request);
upb_Status status;
int opts = 0;
@ -157,7 +158,8 @@ bool parse_json(upb_msg* msg, const upb_MessageDef* m, const ctx* c) {
}
}
void serialize_json(const upb_msg* msg, const upb_MessageDef* m, const ctx* c) {
void serialize_json(const upb_Message* msg, const upb_MessageDef* m,
const ctx* c) {
size_t len;
size_t len2;
int opts = 0;
@ -185,7 +187,7 @@ void serialize_json(const upb_msg* msg, const upb_MessageDef* m, const ctx* c) {
c->response, upb_StringView_FromDataAndSize(data, len));
}
bool parse_input(upb_msg* msg, const upb_MessageDef* m, const ctx* c) {
bool parse_input(upb_Message* msg, const upb_MessageDef* m, const ctx* c) {
switch (conformance_ConformanceRequest_payload_case(c->request)) {
case conformance_ConformanceRequest_payload_protobuf_payload:
return parse_proto(msg, m, c);
@ -203,7 +205,8 @@ bool parse_input(upb_msg* msg, const upb_MessageDef* m, const ctx* c) {
}
}
void write_output(const upb_msg* msg, const upb_MessageDef* m, const ctx* c) {
void write_output(const upb_Message* msg, const upb_MessageDef* m,
const ctx* c) {
switch (conformance_ConformanceRequest_requested_output_format(c->request)) {
case conformance_UNSPECIFIED:
fprintf(stderr, "conformance_upb: Unspecified output format.\n");
@ -227,7 +230,7 @@ void write_output(const upb_msg* msg, const upb_MessageDef* m, const ctx* c) {
}
void DoTest(const ctx* c) {
upb_msg* msg;
upb_Message* msg;
upb_StringView name = conformance_ConformanceRequest_message_type(c->request);
const upb_MessageDef* m =
upb_DefPool_FindMessageByNameWithSize(c->symtab, name.data, name.size);
@ -256,10 +259,10 @@ void DoTest(const ctx* c) {
}
}
void debug_print(const char* label, const upb_msg* msg, const upb_MessageDef* m,
const ctx* c) {
void debug_print(const char* label, const upb_Message* msg,
const upb_MessageDef* m, const ctx* c) {
char buf[512];
upb_text_encode(msg, m, c->symtab, UPB_TXTENC_SINGLELINE, buf, sizeof(buf));
upb_TextEncode(msg, m, c->symtab, UPB_TXTENC_SINGLELINE, buf, sizeof(buf));
fprintf(stderr, "%s: %s\n", label, buf);
}

@ -26,7 +26,7 @@
*/
/*
* lupb_msg -- Message/Array/Map objects in Lua/C that wrap upb/msg.h
* lupb_Message -- Message/Array/Map objects in Lua/C that wrap upb/msg.h
*/
#include "upb/msg.h"
@ -52,7 +52,7 @@
* a cyclic graph cannot be serialized. So it's better to think of this as a
* tree of objects.
*
* The actual data exists at the upb level (upb_msg, upb_Map, upb_Array),
* The actual data exists at the upb level (upb_Message, upb_Map, upb_Array),
* independently of Lua. The upb objects contain all the canonical data and
* edges between objects. Lua wrapper objects expose the upb objects to Lua,
* but ultimately they are just wrappers. They pass through all reads and
@ -65,21 +65,21 @@
* that arena. All wrapper objects strongly reference the arena to which they
* belong.
*
* A global object cache stores a mapping of C pointer (upb_msg*, upb_Array*,
* upb_Map*) to a corresponding Lua wrapper. These references are weak so that
* the wrappers can be collected if they are no longer needed. A new wrapper
* object can always be recreated later.
* A global object cache stores a mapping of C pointer (upb_Message*,
* upb_Array*, upb_Map*) to a corresponding Lua wrapper. These references are
* weak so that the wrappers can be collected if they are no longer needed. A
* new wrapper object can always be recreated later.
*
* +-----+
* lupb_Arena |cache|-weak-+
* | ^ +-----+ |
* | | V
* Lua level | +------------lupb_msg
* Lua level | +------------lupb_Message
* ----------------|-----------------|------------------------------------------
* upb level | |
* | +----V------------------------------+
* +->upb_Arena | upb_msg ...(empty arena storage) |
* +-----------------------------------+
* | +----V----------------------------------+
* +->upb_Arena | upb_Message ...(empty arena storage) |
* +---------------------------------------+
*
* If the user creates a reference between two objects that have different
* arenas, we need to fuse the two arenas together, so that the blocks will
@ -89,15 +89,15 @@
* | |
* V +-----+ V
* lupb_Arena +-weak-|cache|-weak-+ lupb_Arena
* | ^ | +-----+ | ^ |
* | | V V | |
* Lua level | +------------lupb_msg lupb_msg----+ |
* ----------------|-----------------|-------------------------|---------|------
* upb level | | | |
* | +----V----+ +----V----+ V
* +->upb_Arena | upb_msg | | upb_msg | upb_Arena
* +------|--+ +--^------+
* +---------------------+
* | ^ | +-----+ | ^ |
* | | V V | |
* Lua level | +------------lupb_Message lupb_Message--+ |
* ----------------|-----------------|----------------------|-----------|------
* upb level | | | |
* | +----V--------+ +----V--------+ V
* +->upb_Arena | upb_Message | | upb_Message | upb_Arena
* +------|------+ +--^----------+
* +------------------+
* Key invariants:
* 1. every wrapper references the arena that contains it.
* 2. every fused arena includes all arenas that own upb objects reachable
@ -120,7 +120,7 @@
static void lupb_Message_Newmsgwrapper(lua_State* L, int narg,
upb_MessageValue val);
static upb_msg* lupb_msg_check(lua_State* L, int narg);
static upb_Message* lupb_msg_check(lua_State* L, int narg);
static upb_CType lupb_checkfieldtype(lua_State* L, int narg) {
uint32_t n = lupb_checkuint32(L, narg);
@ -633,16 +633,17 @@ static const struct luaL_Reg lupb_map_mm[] = {{"__index", lupb_map_index},
{"__pairs", lupb_map_pairs},
{NULL, NULL}};
/* lupb_msg *******************************************************************/
/* lupb_Message
* *******************************************************************/
typedef struct {
upb_msg* msg;
} lupb_msg;
upb_Message* msg;
} lupb_Message;
/* lupb_msg helpers */
/* lupb_Message helpers */
static upb_msg* lupb_msg_check(lua_State* L, int narg) {
lupb_msg* msg = luaL_checkudata(L, narg, LUPB_MSG);
static upb_Message* lupb_msg_check(lua_State* L, int narg) {
lupb_Message* msg = luaL_checkudata(L, narg, LUPB_MSG);
return msg->msg;
}
@ -669,9 +670,9 @@ static const upb_FieldDef* lupb_msg_checkfield(lua_State* L, int msg,
return f;
}
upb_msg* lupb_msg_pushnew(lua_State* L, int narg) {
upb_Message* lupb_msg_pushnew(lua_State* L, int narg) {
const upb_MessageDef* m = lupb_MessageDef_check(L, narg);
lupb_msg* lmsg = lupb_newuserdata(L, sizeof(lupb_msg), 2, LUPB_MSG);
lupb_Message* lmsg = lupb_newuserdata(L, sizeof(lupb_Message), 2, LUPB_MSG);
upb_Arena* arena = lupb_Arena_pushnew(L);
lua_setiuservalue(L, -2, LUPB_ARENA_INDEX);
@ -691,8 +692,8 @@ upb_msg* lupb_msg_pushnew(lua_State* L, int narg) {
*/
static void lupb_Message_Newmsgwrapper(lua_State* L, int narg,
upb_MessageValue val) {
lupb_msg* lmsg = lupb_newuserdata(L, sizeof(*lmsg), 2, LUPB_MSG);
lmsg->msg = (upb_msg*)val.msg_val; /* XXX: cast isn't great. */
lupb_Message* lmsg = lupb_newuserdata(L, sizeof(*lmsg), 2, LUPB_MSG);
lmsg->msg = (upb_Message*)val.msg_val; /* XXX: cast isn't great. */
lupb_cacheset(L, lmsg->msg);
/* Copy both arena and msgdef into the wrapper. */
@ -747,7 +748,8 @@ static void lupb_Message_Newwrapper(lua_State* L, int narg,
larr->type = upb_FieldDef_CType(f);
larr->arr = val.array;
} else {
lupb_msg* lmsg = lupb_Message_Newud(L, narg, sizeof(*lmsg), LUPB_MSG, f);
lupb_Message* lmsg =
lupb_Message_Newud(L, narg, sizeof(*lmsg), LUPB_MSG, f);
lmsg->msg = val.msg;
}
@ -775,7 +777,7 @@ static void lupb_msg_typechecksubmsg(lua_State* L, int narg, int msgarg,
lua_pop(L, 2);
}
/* lupb_msg Public API */
/* lupb_Message Public API */
/**
* lupb_MessageDef_call
@ -811,7 +813,7 @@ int lupb_MessageDef_call(lua_State* L) {
* msg[field_descriptor] # (for extensions) (TODO)
*/
static int lupb_msg_index(lua_State* L) {
upb_msg* msg = lupb_msg_check(L, 1);
upb_Message* msg = lupb_msg_check(L, 1);
const upb_FieldDef* f = lupb_msg_checkfield(L, 1, 2);
if (upb_FieldDef_IsRepeated(f) || upb_FieldDef_IsSubMessage(f)) {
@ -839,7 +841,7 @@ static int lupb_msg_index(lua_State* L) {
* msg[field_descriptor] = bar # (for extensions) (TODO)
*/
static int lupb_Message_Newindex(lua_State* L) {
upb_msg* msg = lupb_msg_check(L, 1);
upb_Message* msg = lupb_msg_check(L, 1);
const upb_FieldDef* f = lupb_msg_checkfield(L, 1, 2);
upb_MessageValue msgval;
bool merge_arenas = true;
@ -868,7 +870,7 @@ static int lupb_Message_Newindex(lua_State* L) {
}
msgval.array_val = larr->arr;
} else if (upb_FieldDef_IsSubMessage(f)) {
upb_msg* msg = lupb_msg_check(L, 3);
upb_Message* msg = lupb_msg_check(L, 3);
lupb_msg_typechecksubmsg(L, 3, 1, f);
msgval.msg_val = msg;
} else {
@ -896,7 +898,7 @@ static int lupb_Message_Newindex(lua_State* L) {
* etc.
*/
static int lupb_msg_tostring(lua_State* L) {
upb_msg* msg = lupb_msg_check(L, 1);
upb_Message* msg = lupb_msg_check(L, 1);
const upb_MessageDef* m;
char buf[1024];
size_t size;
@ -904,13 +906,13 @@ static int lupb_msg_tostring(lua_State* L) {
lua_getiuservalue(L, 1, LUPB_MSGDEF_INDEX);
m = lupb_MessageDef_check(L, -1);
size = upb_text_encode(msg, m, NULL, 0, buf, sizeof(buf));
size = upb_TextEncode(msg, m, NULL, 0, buf, sizeof(buf));
if (size < sizeof(buf)) {
lua_pushlstring(L, buf, size);
} else {
char* ptr = malloc(size + 1);
upb_text_encode(msg, m, NULL, 0, ptr, size + 1);
upb_TextEncode(msg, m, NULL, 0, ptr, size + 1);
lua_pushlstring(L, ptr, size);
free(ptr);
}
@ -924,7 +926,8 @@ static const struct luaL_Reg lupb_msg_mm[] = {
{"__tostring", lupb_msg_tostring},
{NULL, NULL}};
/* lupb_msg toplevel **********************************************************/
/* lupb_Message toplevel
* **********************************************************/
static int lupb_getoptions(lua_State* L, int narg) {
int options = 0;
@ -950,7 +953,7 @@ static int lupb_decode(lua_State* L) {
const upb_MessageDef* m = lupb_MessageDef_check(L, 1);
const char* pb = lua_tolstring(L, 2, &len);
const upb_MiniTable* layout = upb_MessageDef_MiniTable(m);
upb_msg* msg = lupb_msg_pushnew(L, 1);
upb_Message* msg = lupb_msg_pushnew(L, 1);
upb_Arena* arena = lupb_Arenaget(L, -1);
char* buf;
@ -958,8 +961,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.");
@ -976,7 +979,7 @@ static int lupb_decode(lua_State* L) {
* bin_string = upb.encode(msg)
*/
static int lupb_Encode(lua_State* L) {
const upb_msg* msg = lupb_msg_check(L, 1);
const upb_Message* msg = lupb_msg_check(L, 1);
const upb_MessageDef* m = lupb_Message_Getmsgdef(L, 1);
const upb_MiniTable* layout = upb_MessageDef_MiniTable(m);
int options = lupb_getoptions(L, 2);
@ -985,7 +988,7 @@ static int lupb_Encode(lua_State* L) {
char* result;
arena = lupb_Arena_pushnew(L);
result = upb_EncodeEx(msg, (const void*)layout, options, arena, &size);
result = upb_Encode(msg, (const void*)layout, options, arena, &size);
if (!result) {
lua_pushstring(L, "Error encoding protobuf.");
@ -1009,7 +1012,7 @@ static int lupb_jsondecode(lua_State* L) {
const upb_MessageDef* m = lupb_MessageDef_check(L, 1);
const char* json = lua_tolstring(L, 2, &len);
int options = lupb_getoptions(L, 3);
upb_msg* msg;
upb_Message* msg;
upb_Arena* arena;
upb_Status status;
@ -1029,7 +1032,7 @@ static int lupb_jsondecode(lua_State* L) {
* text_string = upb.json_encode(msg, {upb.JSONENC_EMITDEFAULTS})
*/
static int lupb_jsonencode(lua_State* L) {
upb_msg* msg = lupb_msg_check(L, 1);
upb_Message* msg = lupb_msg_check(L, 1);
const upb_MessageDef* m = lupb_Message_Getmsgdef(L, 1);
int options = lupb_getoptions(L, 2);
char buf[1024];
@ -1060,19 +1063,19 @@ static int lupb_jsonencode(lua_State* L) {
* text_string = upb.text_encode(msg, {upb.TXTENC_SINGLELINE})
*/
static int lupb_textencode(lua_State* L) {
upb_msg* msg = lupb_msg_check(L, 1);
upb_Message* msg = lupb_msg_check(L, 1);
const upb_MessageDef* m = lupb_Message_Getmsgdef(L, 1);
int options = lupb_getoptions(L, 2);
char buf[1024];
size_t size;
size = upb_text_encode(msg, m, NULL, options, buf, sizeof(buf));
size = upb_TextEncode(msg, m, NULL, options, buf, sizeof(buf));
if (size < sizeof(buf)) {
lua_pushlstring(L, buf, size);
} else {
char* ptr = malloc(size + 1);
upb_text_encode(msg, m, NULL, options, ptr, size + 1);
upb_TextEncode(msg, m, NULL, options, ptr, size + 1);
lua_pushlstring(L, ptr, size);
free(ptr);
}

@ -186,7 +186,7 @@ typedef union {
uint32_t size;
} wireval;
static const char* decode_msg(upb_Decoder* d, const char* ptr, upb_msg* msg,
static const char* decode_msg(upb_Decoder* d, const char* ptr, upb_Message* msg,
const upb_MiniTable* layout);
UPB_NORETURN static void* decode_err(upb_Decoder* d, upb_DecodeStatus status) {
@ -296,8 +296,9 @@ static void decode_munge(int type, wireval* val) {
}
}
static upb_msg* decode_newsubmsg(upb_Decoder* d, const upb_MiniTable_Sub* subs,
const upb_MiniTable_Field* field) {
static upb_Message* decode_newsubmsg(upb_Decoder* d,
const upb_MiniTable_Sub* subs,
const upb_MiniTable_Field* field) {
const upb_MiniTable* subl = subs[field->submsg_index].submsg;
return _upb_Message_New_inl(subl, &d->arena);
}
@ -329,8 +330,8 @@ static const char* decode_readstr(upb_Decoder* d, const char* ptr, int size,
UPB_FORCEINLINE
static const char* decode_tosubmsg2(upb_Decoder* d, const char* ptr,
upb_msg* submsg, const upb_MiniTable* subl,
int size) {
upb_Message* submsg,
const upb_MiniTable* subl, int size) {
int saved_delta = decode_pushlimit(d, ptr, size);
if (--d->depth < 0) return decode_err(d, kUpb_DecodeStatus_MaxDepthExceeded);
ptr = decode_msg(d, ptr, submsg, subl);
@ -343,7 +344,7 @@ static const char* decode_tosubmsg2(upb_Decoder* d, const char* ptr,
UPB_FORCEINLINE
static const char* decode_tosubmsg(upb_Decoder* d, const char* ptr,
upb_msg* submsg,
upb_Message* submsg,
const upb_MiniTable_Sub* subs,
const upb_MiniTable_Field* field, int size) {
return decode_tosubmsg2(d, ptr, submsg, subs[field->submsg_index].submsg,
@ -352,7 +353,7 @@ static const char* decode_tosubmsg(upb_Decoder* d, const char* ptr,
UPB_FORCEINLINE
static const char* decode_group(upb_Decoder* d, const char* ptr,
upb_msg* submsg, const upb_MiniTable* subl,
upb_Message* submsg, const upb_MiniTable* subl,
uint32_t number) {
if (--d->depth < 0) return decode_err(d, kUpb_DecodeStatus_MaxDepthExceeded);
if (decode_isdone(d, &ptr)) {
@ -367,7 +368,7 @@ static const char* decode_group(upb_Decoder* d, const char* ptr,
UPB_FORCEINLINE
static const char* decode_togroup(upb_Decoder* d, const char* ptr,
upb_msg* submsg,
upb_Message* submsg,
const upb_MiniTable_Sub* subs,
const upb_MiniTable_Field* field) {
const upb_MiniTable* subl = subs[field->submsg_index].submsg;
@ -385,8 +386,8 @@ static char* encode_varint32(uint32_t val, char* ptr) {
}
UPB_NOINLINE
static bool decode_checkenum_slow(upb_Decoder* d, const char* ptr, upb_msg* msg,
const upb_MiniTable_Enum* e,
static bool decode_checkenum_slow(upb_Decoder* d, const char* ptr,
upb_Message* msg, const upb_MiniTable_Enum* e,
const upb_MiniTable_Field* field,
uint32_t v) {
// OPT: binary search long lists?
@ -404,7 +405,7 @@ static bool decode_checkenum_slow(upb_Decoder* d, const char* ptr, upb_msg* msg,
end = encode_varint32(tag, end);
end = encode_varint32(v, end);
if (!_upb_msg_addunknown(msg, buf, end - buf, &d->arena)) {
if (!_upb_Message_AddUnknown(msg, buf, end - buf, &d->arena)) {
decode_err(d, kUpb_DecodeStatus_OutOfMemory);
}
@ -412,7 +413,7 @@ static bool decode_checkenum_slow(upb_Decoder* d, const char* ptr, upb_msg* msg,
}
UPB_FORCEINLINE
static bool decode_checkenum(upb_Decoder* d, const char* ptr, upb_msg* msg,
static bool decode_checkenum(upb_Decoder* d, const char* ptr, upb_Message* msg,
const upb_MiniTable_Enum* e,
const upb_MiniTable_Field* field, wireval* val) {
uint32_t v = val->uint32_val;
@ -424,7 +425,7 @@ static bool decode_checkenum(upb_Decoder* d, const char* ptr, upb_msg* msg,
UPB_NOINLINE
static const char* decode_enum_toarray(upb_Decoder* d, const char* ptr,
upb_msg* msg, upb_Array* arr,
upb_Message* msg, upb_Array* arr,
const upb_MiniTable_Sub* subs,
const upb_MiniTable_Field* field,
wireval* val) {
@ -504,7 +505,7 @@ static const char* decode_varint_packed(upb_Decoder* d, const char* ptr,
UPB_NOINLINE
static const char* decode_enum_packed(upb_Decoder* d, const char* ptr,
upb_msg* msg, upb_Array* arr,
upb_Message* msg, upb_Array* arr,
const upb_MiniTable_Sub* subs,
const upb_MiniTable_Field* field,
wireval* val) {
@ -529,7 +530,8 @@ static const char* decode_enum_packed(upb_Decoder* d, const char* ptr,
return ptr;
}
static const char* decode_toarray(upb_Decoder* d, const char* ptr, upb_msg* msg,
static const char* decode_toarray(upb_Decoder* d, const char* ptr,
upb_Message* msg,
const upb_MiniTable_Sub* subs,
const upb_MiniTable_Field* field,
wireval* val, int op) {
@ -566,8 +568,8 @@ static const char* decode_toarray(upb_Decoder* d, const char* ptr, upb_msg* msg,
}
case OP_SUBMSG: {
/* Append submessage / group. */
upb_msg* submsg = decode_newsubmsg(d, subs, field);
*UPB_PTR_AT(_upb_array_ptr(arr), arr->len * sizeof(void*), upb_msg*) =
upb_Message* submsg = decode_newsubmsg(d, subs, field);
*UPB_PTR_AT(_upb_array_ptr(arr), arr->len * sizeof(void*), upb_Message*) =
submsg;
arr->len++;
if (UPB_UNLIKELY(field->descriptortype == upb_FieldType_Group)) {
@ -594,8 +596,8 @@ static const char* decode_toarray(upb_Decoder* d, const char* ptr, upb_msg* msg,
}
}
static const char* decode_tomap(upb_Decoder* d, const char* ptr, upb_msg* msg,
const upb_MiniTable_Sub* subs,
static const char* decode_tomap(upb_Decoder* d, const char* ptr,
upb_Message* msg, const upb_MiniTable_Sub* subs,
const upb_MiniTable_Field* field,
wireval* val) {
upb_Map** map_p = UPB_PTR_AT(msg, field->offset, upb_Map*);
@ -630,8 +632,8 @@ static const char* decode_tomap(upb_Decoder* d, const char* ptr, upb_msg* msg,
return ptr;
}
static const char* decode_tomsg(upb_Decoder* d, const char* ptr, upb_msg* msg,
const upb_MiniTable_Sub* subs,
static const char* decode_tomsg(upb_Decoder* d, const char* ptr,
upb_Message* msg, const upb_MiniTable_Sub* subs,
const upb_MiniTable_Field* field, wireval* val,
int op) {
void* mem = UPB_PTR_AT(msg, field->offset, void);
@ -658,8 +660,8 @@ static const char* decode_tomsg(upb_Decoder* d, const char* ptr, upb_msg* msg,
/* Store into message. */
switch (op) {
case OP_SUBMSG: {
upb_msg** submsgp = mem;
upb_msg* submsg = *submsgp;
upb_Message** submsgp = mem;
upb_Message* submsg = *submsgp;
if (!submsg) {
submsg = decode_newsubmsg(d, subs, field);
*submsgp = submsg;
@ -695,7 +697,8 @@ static const char* decode_tomsg(upb_Decoder* d, const char* ptr, upb_msg* msg,
UPB_NOINLINE
const char* decode_checkrequired(upb_Decoder* d, const char* ptr,
const upb_msg* msg, const upb_MiniTable* l) {
const upb_Message* msg,
const upb_MiniTable* l) {
assert(l->required_count);
if (UPB_LIKELY((d->options & kUpb_DecodeOption_CheckRequired) == 0)) {
return ptr;
@ -711,7 +714,8 @@ const char* decode_checkrequired(upb_Decoder* d, const char* ptr,
UPB_FORCEINLINE
static bool decode_tryfastdispatch(upb_Decoder* d, const char** ptr,
upb_msg* msg, const upb_MiniTable* layout) {
upb_Message* msg,
const upb_MiniTable* layout) {
#if UPB_FASTTABLE
if (layout && layout->table_mask != (unsigned char)-1) {
uint16_t tag = fastdecode_loadtag(*ptr);
@ -723,7 +727,8 @@ static bool decode_tryfastdispatch(upb_Decoder* d, const char** ptr,
return false;
}
static const char* decode_msgset(upb_Decoder* d, const char* ptr, upb_msg* msg,
static const char* decode_msgset(upb_Decoder* d, const char* ptr,
upb_Message* msg,
const upb_MiniTable* layout) {
// We create a temporary upb_MiniTable here and abuse its fields as temporary
// storage, to avoid creating lots of MessageSet-specific parsing code-paths:
@ -873,8 +878,8 @@ static const char* decode_wireval(upb_Decoder* d, const char* ptr,
}
UPB_FORCEINLINE
static const char* decode_known(upb_Decoder* d, const char* ptr, upb_msg* msg,
const upb_MiniTable* layout,
static const char* decode_known(upb_Decoder* d, const char* ptr,
upb_Message* msg, const upb_MiniTable* layout,
const upb_MiniTable_Field* field, int op,
wireval* val) {
const upb_MiniTable_Sub* subs = layout->subs;
@ -912,9 +917,9 @@ static const char* decode_reverse_skip_varint(const char* ptr, uint32_t val) {
return ptr;
}
static const char* decode_unknown(upb_Decoder* d, const char* ptr, upb_msg* msg,
int field_number, int wire_type,
wireval val) {
static const char* decode_unknown(upb_Decoder* d, const char* ptr,
upb_Message* msg, int field_number,
int wire_type, wireval val) {
if (field_number == 0) return decode_err(d, kUpb_DecodeStatus_Malformed);
// Since unknown fields are the uncommon case, we do a little extra work here
@ -954,7 +959,7 @@ static const char* decode_unknown(upb_Decoder* d, const char* ptr, upb_msg* msg,
d->unknown_msg = NULL;
d->unknown = NULL;
}
if (!_upb_msg_addunknown(msg, start, ptr - start, &d->arena)) {
if (!_upb_Message_AddUnknown(msg, start, ptr - start, &d->arena)) {
return decode_err(d, kUpb_DecodeStatus_OutOfMemory);
}
} else if (wire_type == kUpb_WireType_StartGroup) {
@ -964,7 +969,7 @@ static const char* decode_unknown(upb_Decoder* d, const char* ptr, upb_msg* msg,
}
UPB_NOINLINE
static const char* decode_msg(upb_Decoder* d, const char* ptr, upb_msg* msg,
static const char* decode_msg(upb_Decoder* d, const char* ptr, upb_Message* msg,
const upb_MiniTable* layout) {
int last_field_index = 0;
@ -1035,8 +1040,8 @@ static const char* decode_msg(upb_Decoder* d, const char* ptr, upb_msg* msg,
}
const char* fastdecode_generic(struct upb_Decoder* d, const char* ptr,
upb_msg* msg, intptr_t table, uint64_t hasbits,
uint64_t data) {
upb_Message* msg, intptr_t table,
uint64_t hasbits, uint64_t data) {
(void)data;
*(uint32_t*)msg |= hasbits;
return decode_msg(d, ptr, msg, decode_totablep(table));
@ -1052,9 +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_extreg* 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;

@ -26,7 +26,7 @@
*/
/*
* upb_decode: parsing into a upb_msg using a upb_MiniTable.
* upb_decode: parsing into a upb_Message using a upb_MiniTable.
*/
#ifndef UPB_DECODE_H_
@ -80,15 +80,10 @@ typedef enum {
kUpb_DecodeStatus_MissingRequired = 5,
} upb_DecodeStatus;
upb_DecodeStatus _upb_decode(const char* buf, size_t size, upb_msg* msg,
const upb_MiniTable* l, const upb_extreg* extreg,
int options, upb_Arena* arena);
UPB_INLINE
upb_DecodeStatus upb_decode(const char* buf, size_t size, upb_msg* 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" */

@ -46,8 +46,8 @@
// The standard set of arguments passed to each parsing function.
// Thanks to x86-64 calling conventions, these will stay in registers.
#define UPB_PARSE_PARAMS \
upb_Decoder *d, const char *ptr, upb_msg *msg, intptr_t table, \
#define UPB_PARSE_PARAMS \
upb_Decoder *d, const char *ptr, upb_Message *msg, intptr_t table, \
uint64_t hasbits, uint64_t data
#define UPB_PARSE_ARGS d, ptr, msg, table, hasbits, data
@ -275,16 +275,16 @@ static fastdecode_nextret fastdecode_nextrepeated(upb_Decoder* d, void* dst,
}
UPB_FORCEINLINE
static void* fastdecode_fieldmem(upb_msg* msg, uint64_t data) {
static void* fastdecode_fieldmem(upb_Message* msg, uint64_t data) {
size_t ofs = data >> 48;
return (char*)msg + ofs;
}
UPB_FORCEINLINE
static void* fastdecode_getfield(upb_Decoder* d, const char* ptr, upb_msg* msg,
uint64_t* data, uint64_t* hasbits,
fastdecode_arr* farr, int valbytes,
upb_card card) {
static void* fastdecode_getfield(upb_Decoder* d, const char* ptr,
upb_Message* msg, uint64_t* data,
uint64_t* hasbits, fastdecode_arr* farr,
int valbytes, upb_card card) {
switch (card) {
case CARD_s: {
uint8_t hasbit_index = *data >> 24;
@ -648,14 +648,14 @@ TAGBYTES(p)
/* string fields **************************************************************/
typedef const char* fastdecode_copystr_func(struct upb_Decoder* d,
const char* ptr, upb_msg* msg,
const char* ptr, upb_Message* msg,
const upb_MiniTable* table,
uint64_t hasbits,
upb_StringView* dst);
UPB_NOINLINE
static const char* fastdecode_verifyutf8(upb_Decoder* d, const char* ptr,
upb_msg* msg, intptr_t table,
upb_Message* msg, intptr_t table,
uint64_t hasbits, uint64_t data) {
upb_StringView* dst = (upb_StringView*)data;
if (!decode_verifyutf8_inl(dst->data, dst->size)) {
@ -699,7 +699,7 @@ static const char* fastdecode_verifyutf8(upb_Decoder* d, const char* ptr,
UPB_NOINLINE
static const char* fastdecode_longstring_utf8(struct upb_Decoder* d,
const char* ptr, upb_msg* msg,
const char* ptr, upb_Message* msg,
intptr_t table, uint64_t hasbits,
uint64_t data) {
upb_StringView* dst = (upb_StringView*)data;
@ -707,11 +707,9 @@ static const char* fastdecode_longstring_utf8(struct upb_Decoder* d,
}
UPB_NOINLINE
static const char* fastdecode_longstring_noutf8(struct upb_Decoder* d,
const char* ptr, upb_msg* msg,
intptr_t table,
uint64_t hasbits,
uint64_t data) {
static const char* fastdecode_longstring_noutf8(
struct upb_Decoder* d, const char* ptr, upb_Message* msg, intptr_t table,
uint64_t hasbits, uint64_t data) {
upb_StringView* dst = (upb_StringView*)data;
FASTDECODE_LONGSTRING(d, ptr, msg, table, hasbits, dst, false);
}
@ -926,8 +924,8 @@ TAGBYTES(r)
/* message fields *************************************************************/
UPB_INLINE
upb_msg* decode_newmsg_ceil(upb_Decoder* d, const upb_MiniTable* l,
int msg_ceil_bytes) {
upb_Message* decode_newmsg_ceil(upb_Decoder* d, const upb_MiniTable* l,
int msg_ceil_bytes) {
size_t size = l->size + sizeof(upb_Message_Internal);
char* msg_data;
if (UPB_LIKELY(msg_ceil_bytes > 0 &&
@ -947,7 +945,7 @@ upb_msg* decode_newmsg_ceil(upb_Decoder* d, const upb_MiniTable* l,
typedef struct {
intptr_t table;
upb_msg* msg;
upb_Message* msg;
} fastdecode_submsgdata;
UPB_FORCEINLINE
@ -970,7 +968,7 @@ static const char* fastdecode_tosubmsg(upb_Decoder* d, const char* ptr,
return fastdecode_err(d, kUpb_DecodeStatus_MaxDepthExceeded); \
} \
\
upb_msg** dst; \
upb_Message** dst; \
uint32_t submsg_idx = (data >> 16) & 0xff; \
const upb_MiniTable* tablep = decode_totablep(table); \
const upb_MiniTable* subtablep = tablep->subs[submsg_idx].submsg; \
@ -982,7 +980,7 @@ static const char* fastdecode_tosubmsg(upb_Decoder* d, const char* ptr,
} \
\
dst = fastdecode_getfield(d, ptr, msg, &data, &hasbits, &farr, \
sizeof(upb_msg*), card); \
sizeof(upb_Message*), card); \
\
if (card == CARD_s) { \
*(uint32_t*)msg |= hasbits; \
@ -991,7 +989,7 @@ static const char* fastdecode_tosubmsg(upb_Decoder* d, const char* ptr,
\
again: \
if (card == CARD_r) { \
dst = fastdecode_resizearr(d, dst, &farr, sizeof(upb_msg*)); \
dst = fastdecode_resizearr(d, dst, &farr, sizeof(upb_Message*)); \
} \
\
submsg.msg = *dst; \
@ -1009,7 +1007,7 @@ static const char* fastdecode_tosubmsg(upb_Decoder* d, const char* ptr,
\
if (card == CARD_r) { \
fastdecode_nextret ret = fastdecode_nextrepeated( \
d, dst, &ptr, &farr, data, tagbytes, sizeof(upb_msg*)); \
d, dst, &ptr, &farr, data, tagbytes, sizeof(upb_Message*)); \
switch (ret.next) { \
case FD_NEXT_SAMEFIELD: \
dst = ret.dst; \

@ -69,11 +69,11 @@ struct upb_Decoder;
// The fallback, generic parsing function that can handle any field type.
// This just uses the regular (non-fast) parser to parse a single field.
const char* fastdecode_generic(struct upb_Decoder* d, const char* ptr,
upb_msg* msg, intptr_t table, uint64_t hasbits,
uint64_t data);
upb_Message* msg, intptr_t table,
uint64_t hasbits, uint64_t data);
#define UPB_PARSE_PARAMS \
struct upb_Decoder *d, const char *ptr, upb_msg *msg, intptr_t table, \
#define UPB_PARSE_PARAMS \
struct upb_Decoder *d, const char *ptr, upb_Message *msg, intptr_t table, \
uint64_t hasbits, uint64_t data
/* primitive fields ***********************************************************/

@ -48,11 +48,12 @@
typedef struct upb_Decoder {
const char* end; /* Can read up to 16 bytes slop beyond this. */
const char* limit_ptr; /* = end + UPB_MIN(limit, 0) */
upb_msg* unknown_msg; /* If non-NULL, add unknown data at buffer flip. */
upb_Message* unknown_msg; /* If non-NULL, add unknown data at buffer flip. */
const char* unknown; /* Start of unknown data. */
const upb_extreg* extreg; /* For looking up extensions during the parse. */
int limit; /* Submessage limit relative to end. */
int depth; /* Tracks recursion depth to bound stack usage. */
const upb_ExtensionRegistry*
extreg; /* For looking up extensions during the parse. */
int limit; /* Submessage limit relative to end. */
int depth; /* Tracks recursion depth to bound stack usage. */
uint32_t end_group; /* field number of END_GROUP tag, else DECODE_NOGROUP */
uint16_t options;
bool missing_required;
@ -102,7 +103,8 @@ non_ascii:
}
const char* decode_checkrequired(upb_Decoder* d, const char* ptr,
const upb_msg* msg, const upb_MiniTable* l);
const upb_Message* msg,
const upb_MiniTable* l);
/* x86-64 pointers always have the high 16 bits matching. So we can shift
* left 8 and right 8 without loss of information. */
@ -121,8 +123,8 @@ const char* decode_isdonefallback_inl(upb_Decoder* d, const char* ptr,
/* Need to copy remaining data into patch buffer. */
UPB_ASSERT(overrun < 16);
if (d->unknown_msg) {
if (!_upb_msg_addunknown(d->unknown_msg, d->unknown, ptr - d->unknown,
&d->arena)) {
if (!_upb_Message_AddUnknown(d->unknown_msg, d->unknown, ptr - d->unknown,
&d->arena)) {
*status = kUpb_DecodeStatus_OutOfMemory;
return NULL;
}
@ -161,7 +163,7 @@ bool decode_isdone(upb_Decoder* d, const char** ptr) {
#if UPB_FASTTABLE
UPB_INLINE
const char* fastdecode_tagdispatch(upb_Decoder* d, const char* ptr,
upb_msg* msg, intptr_t table,
upb_Message* msg, intptr_t table,
uint64_t hasbits, uint64_t tag) {
const upb_MiniTable* table_p = decode_totablep(table);
uint8_t mask = table;

@ -206,7 +206,7 @@ struct upb_DefPool {
upb_strtable syms; /* full_name -> packed def ptr */
upb_strtable files; /* file_name -> upb_FileDef* */
upb_inttable exts; /* upb_MiniTable_Extension* -> upb_FieldDef* */
upb_extreg* extreg;
upb_ExtensionRegistry* extreg;
size_t bytes_loaded;
};
@ -405,8 +405,7 @@ const upb_EnumValueDef* upb_EnumDef_Value(const upb_EnumDef* e, int i) {
return &e->values[i];
}
/* upb_EnumValueDef
* *************************************************************/
/* upb_EnumValueDef ***********************************************************/
const google_protobuf_EnumValueOptions* upb_EnumValueDef_Options(
const upb_EnumValueDef* e) {
@ -1048,8 +1047,7 @@ const upb_MethodDef* upb_ServiceDef_FindMethodByName(const upb_ServiceDef* s,
return NULL;
}
/* upb_DefPool
* *****************************************************************/
/* upb_DefPool ****************************************************************/
void upb_DefPool_Free(upb_DefPool* s) {
upb_Arena_Free(s->arena);
@ -1072,7 +1070,7 @@ upb_DefPool* upb_DefPool_New(void) {
goto err;
}
s->extreg = upb_extreg_new(s->arena);
s->extreg = upb_ExtensionRegistry_New(s->arena);
if (!s->extreg) goto err;
return s;
@ -3162,7 +3160,8 @@ bool _upb_DefPool_registerlayout(upb_DefPool* s, const char* filename,
s->arena);
}
const upb_extreg* upb_DefPool_ExtensionRegistry(const upb_DefPool* s) {
const upb_ExtensionRegistry* upb_DefPool_ExtensionRegistry(
const upb_DefPool* s) {
return s->extreg;
}

@ -373,7 +373,8 @@ const upb_FieldDef* _upb_DefPool_FindExtensionByMiniTable(
const upb_FieldDef* upb_DefPool_FindExtensionByNumber(const upb_DefPool* s,
const upb_MessageDef* m,
int32_t fieldnum);
const upb_extreg* upb_DefPool_ExtensionRegistry(const upb_DefPool* s);
const upb_ExtensionRegistry* upb_DefPool_ExtensionRegistry(
const upb_DefPool* s);
const upb_FieldDef** upb_DefPool_GetAllExtensions(const upb_DefPool* s,
const upb_MessageDef* m,
size_t* count);

@ -198,7 +198,7 @@ static void encode_fixedarray(upb_encstate* e, const upb_Array* arr,
}
}
static void encode_message(upb_encstate* e, const upb_msg* msg,
static void encode_message(upb_encstate* e, const upb_Message* msg,
const upb_MiniTable* m, size_t* size);
static void encode_scalar(upb_encstate* e, const void* _field_mem,
@ -284,7 +284,7 @@ static void encode_scalar(upb_encstate* e, const void* _field_mem,
encode_tag(e, f->number, wire_type);
}
static void encode_array(upb_encstate* e, const upb_msg* msg,
static void encode_array(upb_encstate* e, const upb_Message* msg,
const upb_MiniTable_Sub* subs,
const upb_MiniTable_Field* f) {
const upb_Array* arr = *UPB_PTR_AT(msg, f->offset, upb_Array*);
@ -404,7 +404,7 @@ static void encode_mapentry(upb_encstate* e, uint32_t number,
encode_tag(e, number, kUpb_WireType_Delimited);
}
static void encode_map(upb_encstate* e, const upb_msg* msg,
static void encode_map(upb_encstate* e, const upb_Message* msg,
const upb_MiniTable_Sub* subs,
const upb_MiniTable_Field* f) {
const upb_Map* map = *UPB_PTR_AT(msg, f->offset, const upb_Map*);
@ -436,7 +436,7 @@ static void encode_map(upb_encstate* e, const upb_msg* msg,
}
}
static bool encode_shouldencode(upb_encstate* e, const upb_msg* msg,
static bool encode_shouldencode(upb_encstate* e, const upb_Message* msg,
const upb_MiniTable_Sub* subs,
const upb_MiniTable_Field* f) {
if (f->presence == 0) {
@ -474,7 +474,7 @@ static bool encode_shouldencode(upb_encstate* e, const upb_msg* msg,
}
}
static void encode_field(upb_encstate* e, const upb_msg* msg,
static void encode_field(upb_encstate* e, const upb_Message* msg,
const upb_MiniTable_Sub* subs,
const upb_MiniTable_Field* field) {
switch (upb_FieldMode_Get(field)) {
@ -510,7 +510,7 @@ static void encode_msgset_item(upb_encstate* e,
encode_tag(e, 1, kUpb_WireType_StartGroup);
}
static void encode_message(upb_encstate* e, const upb_msg* msg,
static void encode_message(upb_encstate* e, const upb_Message* msg,
const upb_MiniTable* m, size_t* size) {
size_t pre_len = e->limit - e->ptr;
@ -525,7 +525,7 @@ static void encode_message(upb_encstate* e, const upb_msg* msg,
if ((e->options & kUpb_Encode_SkipUnknown) == 0) {
size_t unknown_size;
const char* unknown = upb_Message_Getunknown(msg, &unknown_size);
const char* unknown = upb_Message_GetUnknown(msg, &unknown_size);
if (unknown) {
encode_bytes(e, unknown, unknown_size);
@ -562,8 +562,8 @@ static void encode_message(upb_encstate* e, const upb_msg* msg,
*size = (e->limit - e->ptr) - pre_len;
}
char* upb_EncodeEx(const void* msg, const upb_MiniTable* l, int options,
upb_Arena* arena, size_t* size) {
char* upb_Encode(const void* msg, const upb_MiniTable* l, int options,
upb_Arena* arena, size_t* size) {
upb_encstate e;
unsigned depth = (unsigned)options >> 16;

@ -26,7 +26,7 @@
*/
/*
* upb_Encode: parsing into a upb_msg using a upb_MiniTable.
* upb_Encode: parsing into a upb_Message using a upb_MiniTable.
*/
#ifndef UPB_ENCODE_H_
@ -59,13 +59,8 @@ enum {
#define UPB_ENCODE_MAXDEPTH(depth) ((depth) << 16)
char* upb_EncodeEx(const void* msg, const upb_MiniTable* l, int options,
upb_Arena* arena, size_t* size);
UPB_INLINE char* upb_Encode(const void* msg, const upb_MiniTable* l,
upb_Arena* arena, size_t* size) {
return upb_EncodeEx(msg, l, 0, arena, size);
}
char* upb_Encode(const void* msg, const upb_MiniTable* l, int options,
upb_Arena* arena, size_t* size);
#include "upb/port_undef.inc"

@ -59,12 +59,13 @@ typedef struct {
enum { JD_OBJECT, JD_ARRAY, JD_STRING, JD_NUMBER, JD_TRUE, JD_FALSE, JD_NULL };
/* Forward declarations of mutually-recursive functions. */
static void jsondec_wellknown(jsondec* d, upb_msg* msg,
static void jsondec_wellknown(jsondec* d, upb_Message* msg,
const upb_MessageDef* m);
static upb_MessageValue jsondec_value(jsondec* d, const upb_FieldDef* f);
static void jsondec_wellknownvalue(jsondec* d, upb_msg* msg,
static void jsondec_wellknownvalue(jsondec* d, upb_Message* msg,
const upb_MessageDef* m);
static void jsondec_object(jsondec* d, upb_msg* msg, const upb_MessageDef* m);
static void jsondec_object(jsondec* d, upb_Message* msg,
const upb_MessageDef* m);
static bool jsondec_streql(upb_StringView str, const char* lit) {
return str.size == strlen(lit) && memcmp(str.data, lit, str.size) == 0;
@ -879,7 +880,7 @@ static upb_MessageValue jsondec_bool(jsondec* d, const upb_FieldDef* f) {
/* Composite types (array/message/map) ****************************************/
static void jsondec_array(jsondec* d, upb_msg* msg, const upb_FieldDef* f) {
static void jsondec_array(jsondec* d, upb_Message* msg, const upb_FieldDef* f) {
upb_Array* arr = upb_Message_Mutable(msg, f, d->arena).array;
jsondec_arrstart(d);
@ -890,7 +891,7 @@ static void jsondec_array(jsondec* d, upb_msg* msg, const upb_FieldDef* f) {
jsondec_arrend(d);
}
static void jsondec_map(jsondec* d, upb_msg* msg, const upb_FieldDef* f) {
static void jsondec_map(jsondec* d, upb_Message* msg, const upb_FieldDef* f) {
upb_Map* map = upb_Message_Mutable(msg, f, d->arena).map;
const upb_MessageDef* entry = upb_FieldDef_MessageSubDef(f);
const upb_FieldDef* key_f =
@ -909,7 +910,8 @@ static void jsondec_map(jsondec* d, upb_msg* msg, const upb_FieldDef* f) {
jsondec_objend(d);
}
static void jsondec_tomsg(jsondec* d, upb_msg* msg, const upb_MessageDef* m) {
static void jsondec_tomsg(jsondec* d, upb_Message* msg,
const upb_MessageDef* m) {
if (upb_MessageDef_WellKnownType(m) == kUpb_WellKnown_Unspecified) {
jsondec_object(d, msg, m);
} else {
@ -919,7 +921,7 @@ static void jsondec_tomsg(jsondec* d, upb_msg* msg, const upb_MessageDef* m) {
static upb_MessageValue jsondec_msg(jsondec* d, const upb_FieldDef* f) {
const upb_MessageDef* m = upb_FieldDef_MessageSubDef(f);
upb_msg* msg = upb_Message_New(m, d->arena);
upb_Message* msg = upb_Message_New(m, d->arena);
upb_MessageValue val;
jsondec_tomsg(d, msg, m);
@ -927,7 +929,8 @@ static upb_MessageValue jsondec_msg(jsondec* d, const upb_FieldDef* f) {
return val;
}
static void jsondec_field(jsondec* d, upb_msg* msg, const upb_MessageDef* m) {
static void jsondec_field(jsondec* d, upb_Message* msg,
const upb_MessageDef* m) {
upb_StringView name;
const upb_FieldDef* f;
const upb_FieldDef* preserved;
@ -978,7 +981,7 @@ static void jsondec_field(jsondec* d, upb_msg* msg, const upb_MessageDef* m) {
} else if (upb_FieldDef_IsRepeated(f)) {
jsondec_array(d, msg, f);
} else if (upb_FieldDef_IsSubMessage(f)) {
upb_msg* submsg = upb_Message_Mutable(msg, f, d->arena).msg;
upb_Message* submsg = upb_Message_Mutable(msg, f, d->arena).msg;
const upb_MessageDef* subm = upb_FieldDef_MessageSubDef(f);
jsondec_tomsg(d, submsg, subm);
} else {
@ -989,7 +992,8 @@ static void jsondec_field(jsondec* d, upb_msg* msg, const upb_MessageDef* m) {
d->debug_field = preserved;
}
static void jsondec_object(jsondec* d, upb_msg* msg, const upb_MessageDef* m) {
static void jsondec_object(jsondec* d, upb_Message* msg,
const upb_MessageDef* m) {
jsondec_objstart(d);
while (jsondec_objnext(d)) {
jsondec_field(d, msg, m);
@ -1080,7 +1084,7 @@ static int64_t jsondec_unixtime(int y, int m, int d, int h, int min, int s) {
return (int64_t)jsondec_epochdays(y, m, d) * 86400 + h * 3600 + min * 60 + s;
}
static void jsondec_timestamp(jsondec* d, upb_msg* msg,
static void jsondec_timestamp(jsondec* d, upb_Message* msg,
const upb_MessageDef* m) {
upb_MessageValue seconds;
upb_MessageValue nanos;
@ -1145,7 +1149,7 @@ malformed:
jsondec_err(d, "Malformed timestamp");
}
static void jsondec_duration(jsondec* d, upb_msg* msg,
static void jsondec_duration(jsondec* d, upb_Message* msg,
const upb_MessageDef* m) {
upb_MessageValue seconds;
upb_MessageValue nanos;
@ -1176,7 +1180,7 @@ static void jsondec_duration(jsondec* d, upb_msg* msg,
d->arena);
}
static void jsondec_listvalue(jsondec* d, upb_msg* msg,
static void jsondec_listvalue(jsondec* d, upb_Message* msg,
const upb_MessageDef* m) {
const upb_FieldDef* values_f = upb_MessageDef_FindFieldByNumberWithSize(m, 1);
const upb_MessageDef* value_m = upb_FieldDef_MessageSubDef(values_f);
@ -1184,7 +1188,7 @@ static void jsondec_listvalue(jsondec* d, upb_msg* msg,
jsondec_arrstart(d);
while (jsondec_arrnext(d)) {
upb_msg* value_msg = upb_Message_New(value_m, d->arena);
upb_Message* value_msg = upb_Message_New(value_m, d->arena);
upb_MessageValue value;
value.msg_val = value_msg;
upb_Array_Append(values, value, d->arena);
@ -1193,7 +1197,8 @@ static void jsondec_listvalue(jsondec* d, upb_msg* msg,
jsondec_arrend(d);
}
static void jsondec_struct(jsondec* d, upb_msg* msg, const upb_MessageDef* m) {
static void jsondec_struct(jsondec* d, upb_Message* msg,
const upb_MessageDef* m) {
const upb_FieldDef* fields_f = upb_MessageDef_FindFieldByNumberWithSize(m, 1);
const upb_MessageDef* entry_m = upb_FieldDef_MessageSubDef(fields_f);
const upb_FieldDef* value_f =
@ -1204,7 +1209,7 @@ static void jsondec_struct(jsondec* d, upb_msg* msg, const upb_MessageDef* m) {
jsondec_objstart(d);
while (jsondec_objnext(d)) {
upb_MessageValue key, value;
upb_msg* value_msg = upb_Message_New(value_m, d->arena);
upb_Message* value_msg = upb_Message_New(value_m, d->arena);
key.str_val = jsondec_string(d);
value.msg_val = value_msg;
upb_Map_Set(fields, key, value, d->arena);
@ -1214,11 +1219,11 @@ static void jsondec_struct(jsondec* d, upb_msg* msg, const upb_MessageDef* m) {
jsondec_objend(d);
}
static void jsondec_wellknownvalue(jsondec* d, upb_msg* msg,
static void jsondec_wellknownvalue(jsondec* d, upb_Message* msg,
const upb_MessageDef* m) {
upb_MessageValue val;
const upb_FieldDef* f;
upb_msg* submsg;
upb_Message* submsg;
switch (jsondec_peek(d)) {
case JD_NUMBER:
@ -1302,7 +1307,7 @@ static upb_StringView jsondec_mask(jsondec* d, const char* buf,
return ret;
}
static void jsondec_fieldmask(jsondec* d, upb_msg* msg,
static void jsondec_fieldmask(jsondec* d, upb_Message* msg,
const upb_MessageDef* m) {
/* repeated string paths = 1; */
const upb_FieldDef* paths_f = upb_MessageDef_FindFieldByNumberWithSize(m, 1);
@ -1325,7 +1330,7 @@ static void jsondec_fieldmask(jsondec* d, upb_msg* msg,
}
}
static void jsondec_anyfield(jsondec* d, upb_msg* msg,
static void jsondec_anyfield(jsondec* d, upb_Message* msg,
const upb_MessageDef* m) {
if (upb_MessageDef_WellKnownType(m) == kUpb_WellKnown_Unspecified) {
/* For regular types: {"@type": "[user type]", "f1": <V1>, "f2": <V2>}
@ -1343,7 +1348,7 @@ static void jsondec_anyfield(jsondec* d, upb_msg* msg,
}
}
static const upb_MessageDef* jsondec_typeurl(jsondec* d, upb_msg* msg,
static const upb_MessageDef* jsondec_typeurl(jsondec* d, upb_Message* msg,
const upb_MessageDef* m) {
const upb_FieldDef* type_url_f =
upb_MessageDef_FindFieldByNumberWithSize(m, 1);
@ -1374,11 +1379,11 @@ static const upb_MessageDef* jsondec_typeurl(jsondec* d, upb_msg* msg,
return type_m;
}
static void jsondec_any(jsondec* d, upb_msg* msg, const upb_MessageDef* m) {
static void jsondec_any(jsondec* d, upb_Message* msg, const upb_MessageDef* m) {
/* string type_url = 1;
* bytes value = 2; */
const upb_FieldDef* value_f = upb_MessageDef_FindFieldByNumberWithSize(m, 2);
upb_msg* any_msg;
upb_Message* any_msg;
const upb_MessageDef* any_m = NULL;
const char* pre_type_data = NULL;
const char* pre_type_end = NULL;
@ -1432,18 +1437,19 @@ static void jsondec_any(jsondec* d, upb_msg* msg, const upb_MessageDef* m) {
jsondec_objend(d);
encoded.str_val.data = upb_Encode(any_msg, upb_MessageDef_MiniTable(any_m),
encoded.str_val.data = upb_Encode(any_msg, upb_MessageDef_MiniTable(any_m), 0,
d->arena, &encoded.str_val.size);
upb_Message_Set(msg, value_f, encoded, d->arena);
}
static void jsondec_wrapper(jsondec* d, upb_msg* msg, const upb_MessageDef* m) {
static void jsondec_wrapper(jsondec* d, upb_Message* msg,
const upb_MessageDef* m) {
const upb_FieldDef* value_f = upb_MessageDef_FindFieldByNumberWithSize(m, 1);
upb_MessageValue val = jsondec_value(d, value_f);
upb_Message_Set(msg, value_f, val, d->arena);
}
static void jsondec_wellknown(jsondec* d, upb_msg* msg,
static void jsondec_wellknown(jsondec* d, upb_Message* msg,
const upb_MessageDef* m) {
switch (upb_MessageDef_WellKnownType(m)) {
case kUpb_WellKnown_Any:
@ -1483,7 +1489,7 @@ static void jsondec_wellknown(jsondec* d, upb_msg* msg,
}
}
bool upb_JsonDecode(const char* buf, size_t size, upb_msg* msg,
bool upb_JsonDecode(const char* buf, size_t size, upb_Message* msg,
const upb_MessageDef* m, const upb_DefPool* symtab,
int options, upb_Arena* arena, upb_Status* status) {
jsondec d;

@ -36,7 +36,7 @@ extern "C" {
enum { upb_JsonDecode_IgnoreUnknown = 1 };
bool upb_JsonDecode(const char* buf, size_t size, upb_msg* msg,
bool upb_JsonDecode(const char* buf, size_t size, upb_Message* msg,
const upb_MessageDef* m, const upb_DefPool* symtab,
int options, upb_Arena* arena, upb_Status* status);

@ -53,15 +53,15 @@ typedef struct {
upb_Arena* arena;
} jsonenc;
static void jsonenc_msg(jsonenc* e, const upb_msg* msg,
static void jsonenc_msg(jsonenc* e, const upb_Message* msg,
const upb_MessageDef* m);
static void jsonenc_scalar(jsonenc* e, upb_MessageValue val,
const upb_FieldDef* f);
static void jsonenc_msgfield(jsonenc* e, const upb_msg* msg,
static void jsonenc_msgfield(jsonenc* e, const upb_Message* msg,
const upb_MessageDef* m);
static void jsonenc_msgfields(jsonenc* e, const upb_msg* msg,
static void jsonenc_msgfields(jsonenc* e, const upb_Message* msg,
const upb_MessageDef* m, bool first);
static void jsonenc_value(jsonenc* e, const upb_msg* msg,
static void jsonenc_value(jsonenc* e, const upb_Message* msg,
const upb_MessageDef* m);
UPB_NORETURN static void jsonenc_err(jsonenc* e, const char* msg) {
@ -138,7 +138,7 @@ static void jsonenc_nanos(jsonenc* e, int32_t nanos) {
jsonenc_printf(e, ".%.*" PRId32, digits, nanos);
}
static void jsonenc_timestamp(jsonenc* e, const upb_msg* msg,
static void jsonenc_timestamp(jsonenc* e, const upb_Message* msg,
const upb_MessageDef* m) {
const upb_FieldDef* seconds_f =
upb_MessageDef_FindFieldByNumberWithSize(m, 1);
@ -181,7 +181,7 @@ static void jsonenc_timestamp(jsonenc* e, const upb_msg* msg,
jsonenc_putstr(e, "Z\"");
}
static void jsonenc_duration(jsonenc* e, const upb_msg* msg,
static void jsonenc_duration(jsonenc* e, const upb_Message* msg,
const upb_MessageDef* m) {
const upb_FieldDef* seconds_f =
upb_MessageDef_FindFieldByNumberWithSize(m, 1);
@ -327,7 +327,7 @@ static void jsonenc_double(jsonenc* e, const char* fmt, double val) {
}
}
static void jsonenc_wrapper(jsonenc* e, const upb_msg* msg,
static void jsonenc_wrapper(jsonenc* e, const upb_Message* msg,
const upb_MessageDef* m) {
const upb_FieldDef* val_f = upb_MessageDef_FindFieldByNumberWithSize(m, 1);
upb_MessageValue val = upb_Message_Get(msg, val_f);
@ -371,7 +371,7 @@ badurl:
UPB_STRINGVIEW_ARGS(type_url));
}
static void jsonenc_any(jsonenc* e, const upb_msg* msg,
static void jsonenc_any(jsonenc* e, const upb_Message* msg,
const upb_MessageDef* m) {
const upb_FieldDef* type_url_f =
upb_MessageDef_FindFieldByNumberWithSize(m, 1);
@ -381,9 +381,9 @@ static void jsonenc_any(jsonenc* e, const upb_msg* msg,
const upb_MessageDef* any_m = jsonenc_getanymsg(e, type_url);
const upb_MiniTable* any_layout = upb_MessageDef_MiniTable(any_m);
upb_Arena* arena = jsonenc_arena(e);
upb_msg* any = upb_Message_New(any_m, arena);
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");
}
@ -432,7 +432,7 @@ static void jsonenc_fieldpath(jsonenc* e, upb_StringView path) {
}
}
static void jsonenc_fieldmask(jsonenc* e, const upb_msg* msg,
static void jsonenc_fieldmask(jsonenc* e, const upb_Message* msg,
const upb_MessageDef* m) {
const upb_FieldDef* paths_f = upb_MessageDef_FindFieldByNumberWithSize(m, 1);
const upb_Array* paths = upb_Message_Get(msg, paths_f).array_val;
@ -451,7 +451,7 @@ static void jsonenc_fieldmask(jsonenc* e, const upb_msg* msg,
jsonenc_putstr(e, "\"");
}
static void jsonenc_struct(jsonenc* e, const upb_msg* msg,
static void jsonenc_struct(jsonenc* e, const upb_Message* msg,
const upb_MessageDef* m) {
const upb_FieldDef* fields_f = upb_MessageDef_FindFieldByNumberWithSize(m, 1);
const upb_Map* fields = upb_Message_Get(msg, fields_f).map_val;
@ -478,7 +478,7 @@ static void jsonenc_struct(jsonenc* e, const upb_msg* msg,
jsonenc_putstr(e, "}");
}
static void jsonenc_listvalue(jsonenc* e, const upb_msg* msg,
static void jsonenc_listvalue(jsonenc* e, const upb_Message* msg,
const upb_MessageDef* m) {
const upb_FieldDef* values_f = upb_MessageDef_FindFieldByNumberWithSize(m, 1);
const upb_MessageDef* values_m = upb_FieldDef_MessageSubDef(values_f);
@ -501,7 +501,7 @@ static void jsonenc_listvalue(jsonenc* e, const upb_msg* msg,
jsonenc_putstr(e, "]");
}
static void jsonenc_value(jsonenc* e, const upb_msg* msg,
static void jsonenc_value(jsonenc* e, const upb_Message* msg,
const upb_MessageDef* m) {
/* TODO(haberman): do we want a reflection method to get oneof case? */
size_t iter = kUpb_Message_Begin;
@ -534,7 +534,7 @@ static void jsonenc_value(jsonenc* e, const upb_msg* msg,
}
}
static void jsonenc_msgfield(jsonenc* e, const upb_msg* msg,
static void jsonenc_msgfield(jsonenc* e, const upb_Message* msg,
const upb_MessageDef* m) {
switch (upb_MessageDef_WellKnownType(m)) {
case kUpb_WellKnown_Unspecified:
@ -711,7 +711,7 @@ static void jsonenc_fieldval(jsonenc* e, const upb_FieldDef* f,
}
}
static void jsonenc_msgfields(jsonenc* e, const upb_msg* msg,
static void jsonenc_msgfields(jsonenc* e, const upb_Message* msg,
const upb_MessageDef* m, bool first) {
upb_MessageValue val;
const upb_FieldDef* f;
@ -735,7 +735,7 @@ static void jsonenc_msgfields(jsonenc* e, const upb_msg* msg,
}
}
static void jsonenc_msg(jsonenc* e, const upb_msg* msg,
static void jsonenc_msg(jsonenc* e, const upb_Message* msg,
const upb_MessageDef* m) {
jsonenc_putstr(e, "{");
jsonenc_msgfields(e, msg, m, true);
@ -753,7 +753,7 @@ static size_t jsonenc_nullz(jsonenc* e, size_t size) {
return ret;
}
size_t upb_JsonEncode(const upb_msg* msg, const upb_MessageDef* m,
size_t upb_JsonEncode(const upb_Message* msg, const upb_MessageDef* m,
const upb_DefPool* ext_pool, int options, char* buf,
size_t size, upb_Status* status) {
jsonenc e;

@ -51,7 +51,7 @@ enum {
* size (excluding NULL) is returned. This means that a return value >= |size|
* implies that the output was truncated. (These are the same semantics as
* snprintf()). */
size_t upb_JsonEncode(const upb_msg* msg, const upb_MessageDef* m,
size_t upb_JsonEncode(const upb_Message* msg, const upb_MessageDef* m,
const upb_DefPool* ext_pool, int options, char* buf,
size_t size, upb_Status* status);

@ -31,26 +31,27 @@
#include "upb/port_def.inc"
#include "upb/table_internal.h"
/** upb_msg *******************************************************************/
/** upb_Message
* *******************************************************************/
static const size_t overhead = sizeof(upb_Message_InternalData);
static const upb_Message_Internal* upb_Message_Getinternal_const(
const upb_msg* msg) {
const upb_Message* msg) {
ptrdiff_t size = sizeof(upb_Message_Internal);
return (upb_Message_Internal*)((char*)msg - size);
}
upb_msg* _upb_Message_New(const upb_MiniTable* l, upb_Arena* a) {
upb_Message* _upb_Message_New(const upb_MiniTable* l, upb_Arena* a) {
return _upb_Message_New_inl(l, a);
}
void _upb_Message_Clear(upb_msg* msg, const upb_MiniTable* l) {
void _upb_Message_Clear(upb_Message* msg, const upb_MiniTable* l) {
void* mem = UPB_PTR_AT(msg, -sizeof(upb_Message_Internal), char);
memset(mem, 0, upb_msg_sizeof(l));
}
static bool realloc_internal(upb_msg* msg, size_t need, upb_Arena* arena) {
static bool realloc_internal(upb_Message* msg, size_t need, upb_Arena* arena) {
upb_Message_Internal* in = upb_Message_Getinternal(msg);
if (!in->internal) {
/* No internal data, allocate from scratch. */
@ -82,8 +83,8 @@ static bool realloc_internal(upb_msg* msg, size_t need, upb_Arena* arena) {
return true;
}
bool _upb_msg_addunknown(upb_msg* msg, const char* data, size_t len,
upb_Arena* arena) {
bool _upb_Message_AddUnknown(upb_Message* msg, const char* data, size_t len,
upb_Arena* arena) {
if (!realloc_internal(msg, len, arena)) return false;
upb_Message_Internal* in = upb_Message_Getinternal(msg);
memcpy(UPB_PTR_AT(in->internal, in->internal->unknown_end, char), data, len);
@ -91,14 +92,14 @@ bool _upb_msg_addunknown(upb_msg* msg, const char* data, size_t len,
return true;
}
void _upb_Message_DiscardUnknown_shallow(upb_msg* msg) {
void _upb_Message_DiscardUnknown_shallow(upb_Message* msg) {
upb_Message_Internal* in = upb_Message_Getinternal(msg);
if (in->internal) {
in->internal->unknown_end = overhead;
}
}
const char* upb_Message_Getunknown(const upb_msg* msg, size_t* len) {
const char* upb_Message_GetUnknown(const upb_Message* msg, size_t* len) {
const upb_Message_Internal* in = upb_Message_Getinternal_const(msg);
if (in->internal) {
*len = in->internal->unknown_end - overhead;
@ -109,7 +110,7 @@ const char* upb_Message_Getunknown(const upb_msg* msg, size_t* len) {
}
}
const upb_Message_Extension* _upb_Message_Getexts(const upb_msg* msg,
const upb_Message_Extension* _upb_Message_Getexts(const upb_Message* msg,
size_t* count) {
const upb_Message_Internal* in = upb_Message_Getinternal_const(msg);
if (in->internal) {
@ -123,7 +124,7 @@ const upb_Message_Extension* _upb_Message_Getexts(const upb_msg* msg,
}
const upb_Message_Extension* _upb_Message_Getext(
const upb_msg* msg, const upb_MiniTable_Extension* e) {
const upb_Message* msg, const upb_MiniTable_Extension* e) {
size_t n;
const upb_Message_Extension* ext = _upb_Message_Getexts(msg, &n);
@ -139,7 +140,8 @@ const upb_Message_Extension* _upb_Message_Getext(
return NULL;
}
void _upb_Message_Clearext(upb_msg* msg, const upb_MiniTable_Extension* ext_l) {
void _upb_Message_Clearext(upb_Message* msg,
const upb_MiniTable_Extension* ext_l) {
upb_Message_Internal* in = upb_Message_Getinternal(msg);
if (!in->internal) return;
const upb_Message_Extension* base =
@ -153,7 +155,7 @@ void _upb_Message_Clearext(upb_msg* msg, const upb_MiniTable_Extension* ext_l) {
}
upb_Message_Extension* _upb_Message_Getorcreateext(
upb_msg* msg, const upb_MiniTable_Extension* e, upb_Arena* arena) {
upb_Message* msg, const upb_MiniTable_Extension* e, upb_Arena* arena) {
upb_Message_Extension* ext =
(upb_Message_Extension*)_upb_Message_Getext(msg, e);
if (ext) return ext;
@ -166,7 +168,7 @@ upb_Message_Extension* _upb_Message_Getorcreateext(
return ext;
}
size_t upb_msg_extcount(const upb_msg* msg) {
size_t upb_Message_ExtensionCount(const upb_Message* msg) {
size_t count;
_upb_Message_Getexts(msg, &count);
return count;
@ -366,9 +368,10 @@ bool _upb_mapsorter_pushmap(_upb_mapsorter* s, upb_FieldType key_type,
return true;
}
/** upb_extreg ****************************************************************/
/** upb_ExtensionRegistry
* ****************************************************************/
struct upb_extreg {
struct upb_ExtensionRegistry {
upb_Arena* arena;
upb_strtable exts; /* Key is upb_MiniTable* concatenated with fieldnum. */
};
@ -380,16 +383,16 @@ static void extreg_key(char* buf, const upb_MiniTable* l, uint32_t fieldnum) {
memcpy(buf + sizeof(l), &fieldnum, sizeof(fieldnum));
}
upb_extreg* upb_extreg_new(upb_Arena* arena) {
upb_extreg* r = upb_Arena_Malloc(arena, sizeof(*r));
upb_ExtensionRegistry* upb_ExtensionRegistry_New(upb_Arena* arena) {
upb_ExtensionRegistry* r = upb_Arena_Malloc(arena, sizeof(*r));
if (!r) return NULL;
r->arena = arena;
if (!upb_strtable_init(&r->exts, 8, arena)) return NULL;
return r;
}
bool _upb_extreg_add(upb_extreg* r, const upb_MiniTable_Extension** e,
size_t count) {
bool _upb_extreg_add(upb_ExtensionRegistry* r,
const upb_MiniTable_Extension** e, size_t count) {
char buf[EXTREG_KEY_SIZE];
const upb_MiniTable_Extension** start = e;
const upb_MiniTable_Extension** end = UPB_PTRADD(e, count);
@ -413,7 +416,7 @@ failure:
return false;
}
const upb_MiniTable_Extension* _upb_extreg_get(const upb_extreg* r,
const upb_MiniTable_Extension* _upb_extreg_get(const upb_ExtensionRegistry* r,
const upb_MiniTable* l,
uint32_t num) {
char buf[EXTREG_KEY_SIZE];

@ -44,9 +44,10 @@
extern "C" {
#endif
/** upb_msg *******************************************************************/
/** upb_Message
* *******************************************************************/
typedef void upb_msg;
typedef void upb_Message;
/* For users these are opaque. They can be obtained from
* upb_MessageDef_MiniTable() but users cannot access any of the members. */
@ -55,34 +56,34 @@ typedef struct upb_MiniTable upb_MiniTable;
/* Adds unknown data (serialized protobuf data) to the given message. The data
* is copied into the message instance. */
void upb_msg_addunknown(upb_msg* msg, const char* data, size_t len,
upb_Arena* arena);
void upb_Message_AddUnknown(upb_Message* msg, const char* data, size_t len,
upb_Arena* arena);
/* Returns a reference to the message's unknown data. */
const char* upb_Message_Getunknown(const upb_msg* msg, size_t* len);
const char* upb_Message_GetUnknown(const upb_Message* msg, size_t* len);
/* Returns the number of extensions present in this message. */
size_t upb_msg_extcount(const upb_msg* msg);
size_t upb_Message_ExtensionCount(const upb_Message* msg);
/** upb_extreg
* *******************************************************************/
/** upb_ExtensionRegistry *****************************************************/
/* Extension registry: a dynamic data structure that stores a map of:
* (upb_MiniTable, number) -> extension info
*
* upb_decode() uses upb_extreg to look up extensions while parsing binary
* format.
* upb_decode() uses upb_ExtensionRegistry to look up extensions while parsing
* binary format.
*
* upb_extreg is part of the mini-table (msglayout) family of objects. Like all
* mini-table objects, it is suitable for reflection-less builds that do not
* want to expose names into the binary.
* upb_ExtensionRegistry is part of the mini-table (msglayout) family of
* objects. Like all mini-table objects, it is suitable for reflection-less
* builds that do not want to expose names into the binary.
*
* Unlike most mini-table types, upb_extreg requires dynamic memory allocation
* and dynamic initialization:
* Unlike most mini-table types, upb_ExtensionRegistry requires dynamic memory
* allocation and dynamic initialization:
* * If reflection is being used, then upb_DefPool will construct an appropriate
* upb_extreg automatically.
* upb_ExtensionRegistry automatically.
* * For a mini-table only build, the user must manually construct the
* upb_extreg and populate it with all of the extensions the user cares about.
* upb_ExtensionRegistry and populate it with all of the extensions the user
* cares about.
* * A third alternative is to manually unpack relevant extensions after the
* main parse is complete, similar to how Any works. This is perhaps the
* nicest solution from the perspective of reducing dependencies, avoiding
@ -96,16 +97,16 @@ size_t upb_msg_extcount(const upb_msg* msg);
* extensions from a generated module and pass the extension registry to the
* binary decoder.
*
* A upb_DefPool provides a upb_extreg, so any users who use reflection do not
* need to populate a upb_extreg directly.
* A upb_DefPool provides a upb_ExtensionRegistry, so any users who use
* reflection do not need to populate a upb_ExtensionRegistry directly.
*/
struct upb_extreg;
typedef struct upb_extreg upb_extreg;
struct upb_ExtensionRegistry;
typedef struct upb_ExtensionRegistry upb_ExtensionRegistry;
/* Creates a upb_extreg in the given arena. The arena must outlive any use of
* the extreg. */
upb_extreg* upb_extreg_new(upb_Arena* arena);
/* Creates a upb_ExtensionRegistry in the given arena. The arena must outlive
* any use of the extreg. */
upb_ExtensionRegistry* upb_ExtensionRegistry_New(upb_Arena* arena);
#ifdef __cplusplus
} /* extern "C" */

@ -116,7 +116,7 @@ struct upb_Decoder;
struct upb_MiniTable;
typedef const char* _upb_FieldParser(struct upb_Decoder* d, const char* ptr,
upb_msg* msg, intptr_t table,
upb_Message* msg, intptr_t table,
uint64_t hasbits, uint64_t data);
typedef struct {
@ -213,26 +213,28 @@ UPB_INLINE uint64_t upb_MiniTable_requiredmask(const upb_MiniTable* l) {
return ((1ULL << n) - 1) << 1;
}
/** upb_extreg ****************************************************************/
/** upb_ExtensionRegistry
* ****************************************************************/
/* Adds the given extension info for message type |l| and field number |num|
* into the registry. Returns false if this message type and field number were
* already in the map, or if memory allocation fails. */
bool _upb_extreg_add(upb_extreg* r, const upb_MiniTable_Extension** e,
size_t count);
bool _upb_extreg_add(upb_ExtensionRegistry* r,
const upb_MiniTable_Extension** e, size_t count);
/* Looks up the extension (if any) defined for message type |l| and field
* number |num|. If an extension was found, copies the field info into |*ext|
* and returns true. Otherwise returns false. */
const upb_MiniTable_Extension* _upb_extreg_get(const upb_extreg* r,
const upb_MiniTable_Extension* _upb_extreg_get(const upb_ExtensionRegistry* r,
const upb_MiniTable* l,
uint32_t num);
/** upb_msg *******************************************************************/
/** upb_Message
* *******************************************************************/
/* Internal members of a upb_msg that track unknown fields and/or extensions.
* We can change this without breaking binary compatibility. We put these
* before the user's data. The user's upb_msg* points after the
/* Internal members of a upb_Message that track unknown fields and/or
* extensions. We can change this without breaking binary compatibility. We put
* these before the user's data. The user's upb_Message* points after the
* upb_Message_Internal. */
typedef struct {
@ -271,41 +273,42 @@ UPB_INLINE size_t upb_msg_sizeof(const upb_MiniTable* l) {
return l->size + sizeof(upb_Message_Internal);
}
UPB_INLINE upb_msg* _upb_Message_New_inl(const upb_MiniTable* l, upb_Arena* a) {
UPB_INLINE upb_Message* _upb_Message_New_inl(const upb_MiniTable* l,
upb_Arena* a) {
size_t size = upb_msg_sizeof(l);
void* mem = upb_Arena_Malloc(a, size);
upb_msg* msg;
upb_Message* msg;
if (UPB_UNLIKELY(!mem)) return NULL;
msg = UPB_PTR_AT(mem, sizeof(upb_Message_Internal), upb_msg);
msg = UPB_PTR_AT(mem, sizeof(upb_Message_Internal), upb_Message);
memset(mem, 0, size);
return msg;
}
/* Creates a new messages with the given layout on the given arena. */
upb_msg* _upb_Message_New(const upb_MiniTable* l, upb_Arena* a);
upb_Message* _upb_Message_New(const upb_MiniTable* l, upb_Arena* a);
UPB_INLINE upb_Message_Internal* upb_Message_Getinternal(upb_msg* msg) {
UPB_INLINE upb_Message_Internal* upb_Message_Getinternal(upb_Message* msg) {
ptrdiff_t size = sizeof(upb_Message_Internal);
return (upb_Message_Internal*)((char*)msg - size);
}
/* Clears the given message. */
void _upb_Message_Clear(upb_msg* msg, const upb_MiniTable* l);
void _upb_Message_Clear(upb_Message* msg, const upb_MiniTable* l);
/* Discards the unknown fields for this message only. */
void _upb_Message_DiscardUnknown_shallow(upb_msg* msg);
void _upb_Message_DiscardUnknown_shallow(upb_Message* msg);
/* Adds unknown data (serialized protobuf data) to the given message. The data
* is copied into the message instance. */
bool _upb_msg_addunknown(upb_msg* msg, const char* data, size_t len,
upb_Arena* arena);
bool _upb_Message_AddUnknown(upb_Message* msg, const char* data, size_t len,
upb_Arena* arena);
/** upb_Message_Extension
* ***************************************************************/
/* The internal representation of an extension is self-describing: it contains
* enough information that we can serialize it to binary format without needing
* to look it up in a upb_extreg.
* to look it up in a upb_ExtensionRegistry.
*
* This representation allocates 16 bytes to data on 64-bit platforms. This is
* rather wasteful for scalars (in the extreme case of bool, it wastes 15
@ -324,33 +327,35 @@ typedef struct {
* message instance. This logically replaces any previously-added extension with
* this number */
upb_Message_Extension* _upb_Message_Getorcreateext(
upb_msg* msg, const upb_MiniTable_Extension* ext, upb_Arena* arena);
upb_Message* msg, const upb_MiniTable_Extension* ext, upb_Arena* arena);
/* Returns an array of extensions for this message. Note: the array is
* ordered in reverse relative to the order of creation. */
const upb_Message_Extension* _upb_Message_Getexts(const upb_msg* msg,
const upb_Message_Extension* _upb_Message_Getexts(const upb_Message* msg,
size_t* count);
/* Returns an extension for the given field number, or NULL if no extension
* exists for this field number. */
const upb_Message_Extension* _upb_Message_Getext(
const upb_msg* msg, const upb_MiniTable_Extension* ext);
const upb_Message* msg, const upb_MiniTable_Extension* ext);
void _upb_Message_Clearext(upb_msg* msg, const upb_MiniTable_Extension* ext);
void _upb_Message_Clearext(upb_Message* msg,
const upb_MiniTable_Extension* ext);
void _upb_Message_Clearext(upb_msg* msg, const upb_MiniTable_Extension* ext);
void _upb_Message_Clearext(upb_Message* msg,
const upb_MiniTable_Extension* ext);
/** Hasbit access *************************************************************/
UPB_INLINE bool _upb_hasbit(const upb_msg* msg, size_t idx) {
UPB_INLINE bool _upb_hasbit(const upb_Message* msg, size_t idx) {
return (*UPB_PTR_AT(msg, idx / 8, const char) & (1 << (idx % 8))) != 0;
}
UPB_INLINE void _upb_sethas(const upb_msg* msg, size_t idx) {
UPB_INLINE void _upb_sethas(const upb_Message* msg, size_t idx) {
(*UPB_PTR_AT(msg, idx / 8, char)) |= (char)(1 << (idx % 8));
}
UPB_INLINE void _upb_clearhas(const upb_msg* msg, size_t idx) {
UPB_INLINE void _upb_clearhas(const upb_Message* msg, size_t idx) {
(*UPB_PTR_AT(msg, idx / 8, char)) &= (char)(~(1 << (idx % 8)));
}
@ -359,24 +364,24 @@ UPB_INLINE size_t _upb_Message_Hasidx(const upb_MiniTable_Field* f) {
return f->presence;
}
UPB_INLINE bool _upb_hasbit_field(const upb_msg* msg,
UPB_INLINE bool _upb_hasbit_field(const upb_Message* msg,
const upb_MiniTable_Field* f) {
return _upb_hasbit(msg, _upb_Message_Hasidx(f));
}
UPB_INLINE void _upb_sethas_field(const upb_msg* msg,
UPB_INLINE void _upb_sethas_field(const upb_Message* msg,
const upb_MiniTable_Field* f) {
_upb_sethas(msg, _upb_Message_Hasidx(f));
}
UPB_INLINE void _upb_clearhas_field(const upb_msg* msg,
UPB_INLINE void _upb_clearhas_field(const upb_Message* msg,
const upb_MiniTable_Field* f) {
_upb_clearhas(msg, _upb_Message_Hasidx(f));
}
/** Oneof case access *********************************************************/
UPB_INLINE uint32_t* _upb_oneofcase(upb_msg* msg, size_t case_ofs) {
UPB_INLINE uint32_t* _upb_oneofcase(upb_Message* msg, size_t case_ofs) {
return UPB_PTR_AT(msg, case_ofs, uint32_t);
}
@ -389,18 +394,18 @@ UPB_INLINE size_t _upb_oneofcase_ofs(const upb_MiniTable_Field* f) {
return ~(ptrdiff_t)f->presence;
}
UPB_INLINE uint32_t* _upb_oneofcase_field(upb_msg* msg,
UPB_INLINE uint32_t* _upb_oneofcase_field(upb_Message* msg,
const upb_MiniTable_Field* f) {
return _upb_oneofcase(msg, _upb_oneofcase_ofs(f));
}
UPB_INLINE uint32_t _upb_getoneofcase_field(const upb_msg* msg,
UPB_INLINE uint32_t _upb_getoneofcase_field(const upb_Message* msg,
const upb_MiniTable_Field* f) {
return _upb_getoneofcase(msg, _upb_oneofcase_ofs(f));
}
UPB_INLINE bool _upb_has_submsg_nohasbit(const upb_msg* msg, size_t ofs) {
return *UPB_PTR_AT(msg, ofs, const upb_msg*) != NULL;
UPB_INLINE bool _upb_has_submsg_nohasbit(const upb_Message* msg, size_t ofs) {
return *UPB_PTR_AT(msg, ofs, const upb_Message*) != NULL;
}
/** upb_Array *****************************************************************/
@ -683,12 +688,12 @@ UPB_INLINE void _upb_Map_Clear(upb_Map* map) {
/* Message map operations, these get the map from the message first. */
UPB_INLINE size_t _upb_msg_map_size(const upb_msg* msg, size_t ofs) {
UPB_INLINE size_t _upb_msg_map_size(const upb_Message* msg, size_t ofs) {
upb_Map* map = *UPB_PTR_AT(msg, ofs, upb_Map*);
return map ? _upb_Map_Size(map) : 0;
}
UPB_INLINE bool _upb_msg_map_get(const upb_msg* msg, size_t ofs,
UPB_INLINE bool _upb_msg_map_get(const upb_Message* msg, size_t ofs,
const void* key, size_t key_size, void* val,
size_t val_size) {
upb_Map* map = *UPB_PTR_AT(msg, ofs, upb_Map*);
@ -696,14 +701,14 @@ UPB_INLINE bool _upb_msg_map_get(const upb_msg* msg, size_t ofs,
return _upb_Map_Get(map, key, key_size, val, val_size);
}
UPB_INLINE void* _upb_msg_map_next(const upb_msg* msg, size_t ofs,
UPB_INLINE void* _upb_msg_map_next(const upb_Message* msg, size_t ofs,
size_t* iter) {
upb_Map* map = *UPB_PTR_AT(msg, ofs, upb_Map*);
if (!map) return NULL;
return _upb_map_next(map, iter);
}
UPB_INLINE bool _upb_msg_map_set(upb_msg* msg, size_t ofs, const void* key,
UPB_INLINE bool _upb_msg_map_set(upb_Message* msg, size_t ofs, const void* key,
size_t key_size, void* val, size_t val_size,
upb_Arena* arena) {
upb_Map** map = UPB_PTR_AT(msg, ofs, upb_Map*);
@ -713,14 +718,14 @@ UPB_INLINE bool _upb_msg_map_set(upb_msg* msg, size_t ofs, const void* key,
return _upb_Map_Set(*map, key, key_size, val, val_size, arena);
}
UPB_INLINE bool _upb_msg_map_delete(upb_msg* msg, size_t ofs, const void* key,
size_t key_size) {
UPB_INLINE bool _upb_msg_map_delete(upb_Message* msg, size_t ofs,
const void* key, size_t key_size) {
upb_Map* map = *UPB_PTR_AT(msg, ofs, upb_Map*);
if (!map) return false;
return _upb_Map_Delete(map, key, key_size);
}
UPB_INLINE void _upb_msg_map_clear(upb_msg* msg, size_t ofs) {
UPB_INLINE void _upb_msg_map_clear(upb_Message* msg, size_t ofs) {
upb_Map* map = *UPB_PTR_AT(msg, ofs, upb_Map*);
if (!map) return;
_upb_Map_Clear(map);

@ -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) {

@ -89,9 +89,10 @@ static const char _upb_CTypeo_sizelg2[12] = {
UPB_SIZE(3, 4), /* kUpb_CType_Bytes */
};
/** upb_msg *******************************************************************/
/** upb_Message
* *******************************************************************/
upb_msg* upb_Message_New(const upb_MessageDef* m, upb_Arena* a) {
upb_Message* upb_Message_New(const upb_MessageDef* m, upb_Arena* a) {
return _upb_Message_New(upb_MessageDef_MiniTable(m), a);
}
@ -99,7 +100,7 @@ static bool in_oneof(const upb_MiniTable_Field* field) {
return field->presence < 0;
}
static upb_MessageValue _upb_Message_Getraw(const upb_msg* msg,
static upb_MessageValue _upb_Message_Getraw(const upb_Message* msg,
const upb_FieldDef* f) {
const upb_MiniTable_Field* field = upb_FieldDef_MiniTable(f);
const char* mem = UPB_PTR_AT(msg, field->offset, char);
@ -108,7 +109,7 @@ static upb_MessageValue _upb_Message_Getraw(const upb_msg* msg,
return val;
}
bool upb_Message_Has(const upb_msg* msg, const upb_FieldDef* f) {
bool upb_Message_Has(const upb_Message* msg, const upb_FieldDef* f) {
assert(upb_FieldDef_HasPresence(f));
if (upb_FieldDef_IsExtension(f)) {
const upb_MiniTable_Extension* ext = _upb_FieldDef_ExtensionMiniTable(f);
@ -127,7 +128,7 @@ bool upb_Message_Has(const upb_msg* msg, const upb_FieldDef* f) {
}
}
const upb_FieldDef* upb_Message_WhichOneof(const upb_msg* msg,
const upb_FieldDef* upb_Message_WhichOneof(const upb_Message* msg,
const upb_OneofDef* o) {
const upb_FieldDef* f = upb_OneofDef_Field(o, 0);
if (upb_OneofDef_IsSynthetic(o)) {
@ -142,7 +143,8 @@ const upb_FieldDef* upb_Message_WhichOneof(const upb_msg* msg,
}
}
upb_MessageValue upb_Message_Get(const upb_msg* msg, const upb_FieldDef* f) {
upb_MessageValue upb_Message_Get(const upb_Message* msg,
const upb_FieldDef* f) {
if (upb_FieldDef_IsExtension(f)) {
const upb_Message_Extension* ext =
_upb_Message_Getext(msg, _upb_FieldDef_ExtensionMiniTable(f));
@ -159,7 +161,8 @@ upb_MessageValue upb_Message_Get(const upb_msg* msg, const upb_FieldDef* f) {
return upb_FieldDef_Default(f);
}
upb_MutableMessageValue upb_Message_Mutable(upb_msg* msg, const upb_FieldDef* f,
upb_MutableMessageValue upb_Message_Mutable(upb_Message* msg,
const upb_FieldDef* f,
upb_Arena* a) {
UPB_ASSERT(upb_FieldDef_IsSubMessage(f) || upb_FieldDef_IsRepeated(f));
if (upb_FieldDef_HasPresence(f) && !upb_Message_Has(msg, f)) {
@ -196,8 +199,8 @@ make:
return ret;
}
bool upb_Message_Set(upb_msg* msg, const upb_FieldDef* f, upb_MessageValue val,
upb_Arena* a) {
bool upb_Message_Set(upb_Message* msg, const upb_FieldDef* f,
upb_MessageValue val, upb_Arena* a) {
if (upb_FieldDef_IsExtension(f)) {
upb_Message_Extension* ext = _upb_Message_Getorcreateext(
msg, _upb_FieldDef_ExtensionMiniTable(f), a);
@ -216,7 +219,7 @@ bool upb_Message_Set(upb_msg* msg, const upb_FieldDef* f, upb_MessageValue val,
return true;
}
void upb_Message_ClearField(upb_msg* msg, const upb_FieldDef* f) {
void upb_Message_ClearField(upb_Message* msg, const upb_FieldDef* f) {
if (upb_FieldDef_IsExtension(f)) {
_upb_Message_Clearext(msg, _upb_FieldDef_ExtensionMiniTable(f));
} else {
@ -235,11 +238,11 @@ void upb_Message_ClearField(upb_msg* msg, const upb_FieldDef* f) {
}
}
void upb_Message_Clear(upb_msg* msg, const upb_MessageDef* m) {
void upb_Message_Clear(upb_Message* msg, const upb_MessageDef* m) {
_upb_Message_Clear(msg, upb_MessageDef_MiniTable(m));
}
bool upb_Message_Next(const upb_msg* msg, const upb_MessageDef* m,
bool upb_Message_Next(const upb_Message* msg, const upb_MessageDef* m,
const upb_DefPool* ext_pool, const upb_FieldDef** out_f,
upb_MessageValue* out_val, size_t* iter) {
size_t i = *iter;
@ -295,7 +298,7 @@ bool upb_Message_Next(const upb_msg* msg, const upb_MessageDef* m,
return false;
}
bool _upb_Message_DiscardUnknown(upb_msg* msg, const upb_MessageDef* m,
bool _upb_Message_DiscardUnknown(upb_Message* msg, const upb_MessageDef* m,
int depth) {
size_t iter = kUpb_Message_Begin;
const upb_FieldDef* f;
@ -320,7 +323,7 @@ bool _upb_Message_DiscardUnknown(upb_msg* msg, const upb_MessageDef* m,
while (upb_MapIterator_Next(map, &iter)) {
upb_MessageValue map_val = upb_MapIterator_Value(map, iter);
if (!_upb_Message_DiscardUnknown((upb_msg*)map_val.msg_val, val_m,
if (!_upb_Message_DiscardUnknown((upb_Message*)map_val.msg_val, val_m,
depth)) {
ret = false;
}
@ -330,12 +333,14 @@ bool _upb_Message_DiscardUnknown(upb_msg* msg, const upb_MessageDef* m,
size_t i, n = upb_Array_Size(arr);
for (i = 0; i < n; i++) {
upb_MessageValue elem = upb_Array_Get(arr, i);
if (!_upb_Message_DiscardUnknown((upb_msg*)elem.msg_val, subm, depth)) {
if (!_upb_Message_DiscardUnknown((upb_Message*)elem.msg_val, subm,
depth)) {
ret = false;
}
}
} else {
if (!_upb_Message_DiscardUnknown((upb_msg*)val.msg_val, subm, depth)) {
if (!_upb_Message_DiscardUnknown((upb_Message*)val.msg_val, subm,
depth)) {
ret = false;
}
}
@ -344,7 +349,7 @@ bool _upb_Message_DiscardUnknown(upb_msg* msg, const upb_MessageDef* m,
return ret;
}
bool upb_Message_DiscardUnknown(upb_msg* msg, const upb_MessageDef* m,
bool upb_Message_DiscardUnknown(upb_Message* msg, const upb_MessageDef* m,
int maxdepth) {
return _upb_Message_DiscardUnknown(msg, m, maxdepth);
}

@ -46,38 +46,40 @@ typedef union {
uint32_t uint32_val;
uint64_t uint64_val;
const upb_Map* map_val;
const upb_msg* msg_val;
const upb_Message* msg_val;
const upb_Array* array_val;
upb_StringView str_val;
} upb_MessageValue;
typedef union {
upb_Map* map;
upb_msg* msg;
upb_Message* msg;
upb_Array* array;
} upb_MutableMessageValue;
upb_MessageValue upb_FieldDef_Default(const upb_FieldDef* f);
/** upb_msg *******************************************************************/
/** upb_Message
* *******************************************************************/
/* Creates a new message of the given type in the given arena. */
upb_msg* upb_Message_New(const upb_MessageDef* m, upb_Arena* a);
upb_Message* upb_Message_New(const upb_MessageDef* m, upb_Arena* a);
/* Returns the value associated with this field. */
upb_MessageValue upb_Message_Get(const upb_msg* msg, const upb_FieldDef* f);
upb_MessageValue upb_Message_Get(const upb_Message* msg, const upb_FieldDef* f);
/* Returns a mutable pointer to a map, array, or submessage value. If the given
* arena is non-NULL this will construct a new object if it was not previously
* present. May not be called for primitive fields. */
upb_MutableMessageValue upb_Message_Mutable(upb_msg* msg, const upb_FieldDef* f,
upb_MutableMessageValue upb_Message_Mutable(upb_Message* msg,
const upb_FieldDef* f,
upb_Arena* a);
/* May only be called for fields where upb_FieldDef_HasPresence(f) == true. */
bool upb_Message_Has(const upb_msg* msg, const upb_FieldDef* f);
bool upb_Message_Has(const upb_Message* msg, const upb_FieldDef* f);
/* Returns the field that is set in the oneof, or NULL if none are set. */
const upb_FieldDef* upb_Message_WhichOneof(const upb_msg* msg,
const upb_FieldDef* upb_Message_WhichOneof(const upb_Message* msg,
const upb_OneofDef* o);
/* Sets the given field to the given value. For a msg/array/map/string, the
@ -85,14 +87,14 @@ const upb_FieldDef* upb_Message_WhichOneof(const upb_msg* msg,
* the same arena or a different arena that outlives it).
*
* Returns false if allocation fails. */
bool upb_Message_Set(upb_msg* msg, const upb_FieldDef* f, upb_MessageValue val,
upb_Arena* a);
bool upb_Message_Set(upb_Message* msg, const upb_FieldDef* f,
upb_MessageValue val, upb_Arena* a);
/* Clears any field presence and sets the value back to its default. */
void upb_Message_ClearField(upb_msg* msg, const upb_FieldDef* f);
void upb_Message_ClearField(upb_Message* msg, const upb_FieldDef* f);
/* Clear all data and unknown fields. */
void upb_Message_Clear(upb_msg* msg, const upb_MessageDef* m);
void upb_Message_Clear(upb_Message* msg, const upb_MessageDef* m);
/* Iterate over present fields.
*
@ -109,12 +111,12 @@ void upb_Message_Clear(upb_msg* msg, const upb_MessageDef* m);
*/
#define kUpb_Message_Begin -1
bool upb_Message_Next(const upb_msg* msg, const upb_MessageDef* m,
bool upb_Message_Next(const upb_Message* msg, const upb_MessageDef* m,
const upb_DefPool* ext_pool, const upb_FieldDef** f,
upb_MessageValue* val, size_t* iter);
/* Clears all unknown field data from this message and all submessages. */
bool upb_Message_DiscardUnknown(upb_msg* msg, const upb_MessageDef* m,
bool upb_Message_DiscardUnknown(upb_Message* msg, const upb_MessageDef* m,
int maxdepth);
/** upb_Array *****************************************************************/

@ -48,7 +48,8 @@ typedef struct {
_upb_mapsorter sorter;
} txtenc;
static void txtenc_msg(txtenc* e, const upb_msg* msg, const upb_MessageDef* m);
static void txtenc_msg(txtenc* e, const upb_Message* msg,
const upb_MessageDef* m);
static void txtenc_putbytes(txtenc* e, const void* data, size_t len) {
size_t have = e->end - e->ptr;
@ -404,7 +405,8 @@ static const char* txtenc_unknown(txtenc* e, const char* ptr, const char* end,
#undef CHK
static void txtenc_msg(txtenc* e, const upb_msg* msg, const upb_MessageDef* m) {
static void txtenc_msg(txtenc* e, const upb_Message* msg,
const upb_MessageDef* m) {
size_t iter = kUpb_Message_Begin;
const upb_FieldDef* f;
upb_MessageValue val;
@ -421,7 +423,7 @@ static void txtenc_msg(txtenc* e, const upb_msg* msg, const upb_MessageDef* m) {
if ((e->options & UPB_TXTENC_SKIPUNKNOWN) == 0) {
size_t len;
const char* ptr = upb_Message_Getunknown(msg, &len);
const char* ptr = upb_Message_GetUnknown(msg, &len);
char* start = e->ptr;
if (ptr) {
if (!txtenc_unknown(e, ptr, ptr + len, -1)) {
@ -443,9 +445,9 @@ size_t txtenc_nullz(txtenc* e, size_t size) {
return ret;
}
size_t upb_text_encode(const upb_msg* msg, const upb_MessageDef* m,
const upb_DefPool* ext_pool, int options, char* buf,
size_t size) {
size_t upb_TextEncode(const upb_Message* msg, const upb_MessageDef* m,
const upb_DefPool* ext_pool, int options, char* buf,
size_t size) {
txtenc e;
e.buf = buf;

@ -53,9 +53,9 @@ enum {
* size (excluding NULL) is returned. This means that a return value >= |size|
* implies that the output was truncated. (These are the same semantics as
* snprintf()). */
size_t upb_text_encode(const upb_msg* msg, const upb_MessageDef* m,
const upb_DefPool* ext_pool, int options, char* buf,
size_t size);
size_t upb_TextEncode(const upb_Message* msg, const upb_MessageDef* m,
const upb_DefPool* ext_pool, int options, char* buf,
size_t size);
#ifdef __cplusplus
} /* extern "C" */

@ -58,7 +58,7 @@ const google::protobuf::Descriptor* AddMessageDescriptor(
// Converts a upb `msg` (with type `msgdef`) into a protobuf Message object from
// the given factory and descriptor.
std::unique_ptr<google::protobuf::Message> ToProto(
const upb_msg* msg, const upb_MessageDef* msgdef,
const upb_Message* msg, const upb_MessageDef* msgdef,
const google::protobuf::Descriptor* desc,
google::protobuf::MessageFactory* factory) {
upb::Arena arena;
@ -67,7 +67,7 @@ std::unique_ptr<google::protobuf::Message> ToProto(
factory->GetPrototype(desc)->New());
size_t size;
const char* buf =
upb_Encode(msg, upb_MessageDef_MiniTable(msgdef), arena.ptr(), &size);
upb_Encode(msg, upb_MessageDef_MiniTable(msgdef), 0, arena.ptr(), &size);
google_msg->ParseFromArray(buf, size);
return google_msg;
}

@ -201,7 +201,7 @@ static void upb_FindContext_Pop(upb_FindContext* ctx) {
}
static void upb_util_FindUnsetInMessage(upb_FindContext* ctx,
const upb_msg* msg,
const upb_Message* msg,
const upb_MessageDef* m) {
// Iterate over all fields to see if any required fields are missing.
for (int i = 0, n = upb_MessageDef_FieldCount(m); i < n; i++) {
@ -229,7 +229,7 @@ static void upb_util_FindUnsetInMessage(upb_FindContext* ctx,
}
static void upb_util_FindUnsetRequiredInternal(upb_FindContext* ctx,
const upb_msg* msg,
const upb_Message* msg,
const upb_MessageDef* m) {
// OPT: add markers in the schema for where we can avoid iterating:
// 1. messages with no required fields.
@ -288,7 +288,7 @@ static void upb_util_FindUnsetRequiredInternal(upb_FindContext* ctx,
}
}
bool upb_util_HasUnsetRequired(const upb_msg* msg, const upb_MessageDef* m,
bool upb_util_HasUnsetRequired(const upb_Message* msg, const upb_MessageDef* m,
const upb_DefPool* ext_pool,
upb_FieldPathEntry** fields) {
upb_FindContext ctx;

@ -81,7 +81,7 @@ size_t upb_FieldPath_ToText(upb_FieldPathEntry** path, char* buf, size_t size);
// that are missing. Each path is terminated with {.field = NULL}, and a final
// {.field = NULL} terminates the list of paths. The caller is responsible for
// freeing this array.
bool upb_util_HasUnsetRequired(const upb_msg* msg, const upb_MessageDef* m,
bool upb_util_HasUnsetRequired(const upb_Message* msg, const upb_MessageDef* m,
const upb_DefPool* ext_pool,
upb_FieldPathEntry** fields);

@ -418,28 +418,28 @@ 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;
}
UPB_INLINE $0* $0_parse_ex(const char* buf, size_t size,
const upb_extreg* extreg, int options,
upb_Arena* arena) {
const upb_ExtensionRegistry* extreg,
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;
}
return ret;
}
UPB_INLINE char* $0_serialize(const $0* msg, upb_Arena* arena, size_t* len) {
return upb_Encode(msg, &$1, arena, len);
return upb_Encode(msg, &$1, 0, arena, len);
}
UPB_INLINE char* $0_serialize_ex(const $0* msg, int options,
upb_Arena* arena, size_t* len) {
return upb_EncodeEx(msg, &$1, options, arena, len);
return upb_Encode(msg, &$1, options, arena, len);
}
)cc",
MessageName(message), MessageInit(message));

Loading…
Cancel
Save