Rewrite of the decoder (#263)

New code is smaller (in both source size and compiled size) and faster.

# Speed

The decoder speeds up on all machines I tested, though the amount of speedup varies. I was only able to test Intel CPUs.

### Linux Desktop
```
CPU: Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
OS: Linux

name         	old time/op  new time/op  delta
CreateArena   	 4.72ns ± 0%  4.93ns ± 0%   +4.47%  (p=0.000 n=11+11)
ParseDescriptor  12.4µs ± 1%   9.1µs ± 1%  -26.65%  (p=0.000 n=11+11)
```

### Mac Laptop
```
CPU: Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
OS: macOS

name             old time/op  new time/op  delta
CreateArena      5.33ns ± 3%  5.58ns ± 2%   +4.69%  (p=0.000 n=12+12)
ParseDescriptor  15.0µs ± 2%  11.9µs ± 2%  -20.20%  (p=0.000 n=12+12)
```

### Linux Workstation
```
CPU: Intel(R) Xeon(R) Gold 6154 CPU @ 3.00GHz
OS: Linux

name             old time/op  new time/op  delta
CreateArena      5.29ns ± 0%  5.52ns ± 0%   +4.37%  (p=0.000 n=10+12)
ParseDescriptor  18.6µs ± 0%  16.4µs ± 0%  -11.54%  (p=0.000 n=12+12)
```

# Size

A few source files grow marginally because of some arena functionality moved inline. But `upb/decode.c` shrinks by 30% on Linux:

```
     VM SIZE    
 -------------- 
  +2.1%    +283    upb/json_decode.c
   +24%    +205    upb/msg.c
  +8.4%    +115    upb/upb.c
  +0.9%     +28    upb/reflection.c
  [ = ]       0    upb/def.c
  [ = ]       0    upb/encode.c
  [ = ]       0    upb/json_encode.c
  [ = ]       0    upb/table.c
 -30.3% -1.51Ki    upb/decode.c
  -0.7%    -738    TOTAL
```
pull/13171/head
Joshua Haberman 5 years ago committed by GitHub
parent 4e2505edaa
commit 08b6d2d6fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 32
      benchmark.py
  2. 352
      generated_for_cmake/google/protobuf/descriptor.upb.h
  3. 6
      tests/conformance_upb.c
  4. 5
      tests/test_generated_code.c
  5. 818
      upb/decode.c
  6. 5
      upb/encode.c
  7. 23
      upb/msg.c
  8. 14
      upb/msg.h
  9. 15
      upb/port_def.inc
  10. 2
      upb/port_undef.inc
  11. 15
      upb/reflection.c
  12. 54
      upb/upb.c
  13. 52
      upb/upb.h
  14. 19
      upbc/generator.cc

@ -0,0 +1,32 @@
#!/usr/bin/env python3
import json
import subprocess
import re
def Run(cmd):
subprocess.check_call(cmd, shell=True)
def RunAgainstBranch(branch, outfile, runs=12):
tmpfile = "/tmp/bench-output.json"
Run("rm -rf {}".format(tmpfile))
Run("git checkout {}".format(branch))
Run("bazel build -c opt :benchmark")
Run("./bazel-bin/benchmark --benchmark_out_format=json --benchmark_out={} --benchmark_repetitions={}".format(tmpfile, runs))
with open(tmpfile) as f:
bench_json = json.load(f)
with open(outfile, "w") as f:
for run in bench_json["benchmarks"]:
name = re.sub(r'^BM_', 'Benchmark', run["name"])
if name.endswith("_mean") or name.endswith("_median") or name.endswith("_stddev"):
continue
values = (name, run["iterations"], run["cpu_time"])
print("{} {} {} ns/op".format(*values), file=f)
RunAgainstBranch("master", "/tmp/old.txt")
RunAgainstBranch("decoder", "/tmp/new.txt")
Run("~/go/bin/benchstat /tmp/old.txt /tmp/new.txt")

@ -198,30 +198,30 @@ UPB_INLINE char *google_protobuf_FileDescriptorProto_serialize(const google_prot
}
UPB_INLINE bool google_protobuf_FileDescriptorProto_has_name(const google_protobuf_FileDescriptorProto *msg) { return _upb_has_field(msg, 1); }
UPB_INLINE upb_strview google_protobuf_FileDescriptorProto_name(const google_protobuf_FileDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)); }
UPB_INLINE upb_strview google_protobuf_FileDescriptorProto_name(const google_protobuf_FileDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview); }
UPB_INLINE bool google_protobuf_FileDescriptorProto_has_package(const google_protobuf_FileDescriptorProto *msg) { return _upb_has_field(msg, 2); }
UPB_INLINE upb_strview google_protobuf_FileDescriptorProto_package(const google_protobuf_FileDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(12, 24)); }
UPB_INLINE upb_strview google_protobuf_FileDescriptorProto_package(const google_protobuf_FileDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(12, 24), upb_strview); }
UPB_INLINE upb_strview const* google_protobuf_FileDescriptorProto_dependency(const google_protobuf_FileDescriptorProto *msg, size_t *len) { return (upb_strview const*)_upb_array_accessor(msg, UPB_SIZE(36, 72), len); }
UPB_INLINE const google_protobuf_DescriptorProto* const* google_protobuf_FileDescriptorProto_message_type(const google_protobuf_FileDescriptorProto *msg, size_t *len) { return (const google_protobuf_DescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(40, 80), len); }
UPB_INLINE const google_protobuf_EnumDescriptorProto* const* google_protobuf_FileDescriptorProto_enum_type(const google_protobuf_FileDescriptorProto *msg, size_t *len) { return (const google_protobuf_EnumDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(44, 88), len); }
UPB_INLINE const google_protobuf_ServiceDescriptorProto* const* google_protobuf_FileDescriptorProto_service(const google_protobuf_FileDescriptorProto *msg, size_t *len) { return (const google_protobuf_ServiceDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(48, 96), len); }
UPB_INLINE const google_protobuf_FieldDescriptorProto* const* google_protobuf_FileDescriptorProto_extension(const google_protobuf_FileDescriptorProto *msg, size_t *len) { return (const google_protobuf_FieldDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(52, 104), len); }
UPB_INLINE bool google_protobuf_FileDescriptorProto_has_options(const google_protobuf_FileDescriptorProto *msg) { return _upb_has_field(msg, 4); }
UPB_INLINE const google_protobuf_FileOptions* google_protobuf_FileDescriptorProto_options(const google_protobuf_FileDescriptorProto *msg) { return UPB_FIELD_AT(msg, const google_protobuf_FileOptions*, UPB_SIZE(28, 56)); }
UPB_INLINE const google_protobuf_FileOptions* google_protobuf_FileDescriptorProto_options(const google_protobuf_FileDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(28, 56), const google_protobuf_FileOptions*); }
UPB_INLINE bool google_protobuf_FileDescriptorProto_has_source_code_info(const google_protobuf_FileDescriptorProto *msg) { return _upb_has_field(msg, 5); }
UPB_INLINE const google_protobuf_SourceCodeInfo* google_protobuf_FileDescriptorProto_source_code_info(const google_protobuf_FileDescriptorProto *msg) { return UPB_FIELD_AT(msg, const google_protobuf_SourceCodeInfo*, UPB_SIZE(32, 64)); }
UPB_INLINE const google_protobuf_SourceCodeInfo* google_protobuf_FileDescriptorProto_source_code_info(const google_protobuf_FileDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(32, 64), const google_protobuf_SourceCodeInfo*); }
UPB_INLINE int32_t const* google_protobuf_FileDescriptorProto_public_dependency(const google_protobuf_FileDescriptorProto *msg, size_t *len) { return (int32_t const*)_upb_array_accessor(msg, UPB_SIZE(56, 112), len); }
UPB_INLINE int32_t const* google_protobuf_FileDescriptorProto_weak_dependency(const google_protobuf_FileDescriptorProto *msg, size_t *len) { return (int32_t const*)_upb_array_accessor(msg, UPB_SIZE(60, 120), len); }
UPB_INLINE bool google_protobuf_FileDescriptorProto_has_syntax(const google_protobuf_FileDescriptorProto *msg) { return _upb_has_field(msg, 3); }
UPB_INLINE upb_strview google_protobuf_FileDescriptorProto_syntax(const google_protobuf_FileDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(20, 40)); }
UPB_INLINE upb_strview google_protobuf_FileDescriptorProto_syntax(const google_protobuf_FileDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(20, 40), upb_strview); }
UPB_INLINE void google_protobuf_FileDescriptorProto_set_name(google_protobuf_FileDescriptorProto *msg, upb_strview value) {
_upb_sethas(msg, 1);
UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview) = value;
}
UPB_INLINE void google_protobuf_FileDescriptorProto_set_package(google_protobuf_FileDescriptorProto *msg, upb_strview value) {
_upb_sethas(msg, 2);
UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(12, 24)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(12, 24), upb_strview) = value;
}
UPB_INLINE upb_strview* google_protobuf_FileDescriptorProto_mutable_dependency(google_protobuf_FileDescriptorProto *msg, size_t *len) {
return (upb_strview*)_upb_array_mutable_accessor(msg, UPB_SIZE(36, 72), len);
@ -287,7 +287,7 @@ UPB_INLINE struct google_protobuf_FieldDescriptorProto* google_protobuf_FileDesc
}
UPB_INLINE void google_protobuf_FileDescriptorProto_set_options(google_protobuf_FileDescriptorProto *msg, google_protobuf_FileOptions* value) {
_upb_sethas(msg, 4);
UPB_FIELD_AT(msg, google_protobuf_FileOptions*, UPB_SIZE(28, 56)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(28, 56), google_protobuf_FileOptions*) = value;
}
UPB_INLINE struct google_protobuf_FileOptions* google_protobuf_FileDescriptorProto_mutable_options(google_protobuf_FileDescriptorProto *msg, upb_arena *arena) {
struct google_protobuf_FileOptions* sub = (struct google_protobuf_FileOptions*)google_protobuf_FileDescriptorProto_options(msg);
@ -300,7 +300,7 @@ UPB_INLINE struct google_protobuf_FileOptions* google_protobuf_FileDescriptorPro
}
UPB_INLINE void google_protobuf_FileDescriptorProto_set_source_code_info(google_protobuf_FileDescriptorProto *msg, google_protobuf_SourceCodeInfo* value) {
_upb_sethas(msg, 5);
UPB_FIELD_AT(msg, google_protobuf_SourceCodeInfo*, UPB_SIZE(32, 64)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(32, 64), google_protobuf_SourceCodeInfo*) = value;
}
UPB_INLINE struct google_protobuf_SourceCodeInfo* google_protobuf_FileDescriptorProto_mutable_source_code_info(google_protobuf_FileDescriptorProto *msg, upb_arena *arena) {
struct google_protobuf_SourceCodeInfo* sub = (struct google_protobuf_SourceCodeInfo*)google_protobuf_FileDescriptorProto_source_code_info(msg);
@ -333,7 +333,7 @@ UPB_INLINE bool google_protobuf_FileDescriptorProto_add_weak_dependency(google_p
}
UPB_INLINE void google_protobuf_FileDescriptorProto_set_syntax(google_protobuf_FileDescriptorProto *msg, upb_strview value) {
_upb_sethas(msg, 3);
UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(20, 40)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(20, 40), upb_strview) = value;
}
/* google.protobuf.DescriptorProto */
@ -351,21 +351,21 @@ UPB_INLINE char *google_protobuf_DescriptorProto_serialize(const google_protobuf
}
UPB_INLINE bool google_protobuf_DescriptorProto_has_name(const google_protobuf_DescriptorProto *msg) { return _upb_has_field(msg, 1); }
UPB_INLINE upb_strview google_protobuf_DescriptorProto_name(const google_protobuf_DescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)); }
UPB_INLINE upb_strview google_protobuf_DescriptorProto_name(const google_protobuf_DescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview); }
UPB_INLINE const google_protobuf_FieldDescriptorProto* const* google_protobuf_DescriptorProto_field(const google_protobuf_DescriptorProto *msg, size_t *len) { return (const google_protobuf_FieldDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(16, 32), len); }
UPB_INLINE const google_protobuf_DescriptorProto* const* google_protobuf_DescriptorProto_nested_type(const google_protobuf_DescriptorProto *msg, size_t *len) { return (const google_protobuf_DescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(20, 40), len); }
UPB_INLINE const google_protobuf_EnumDescriptorProto* const* google_protobuf_DescriptorProto_enum_type(const google_protobuf_DescriptorProto *msg, size_t *len) { return (const google_protobuf_EnumDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(24, 48), len); }
UPB_INLINE const google_protobuf_DescriptorProto_ExtensionRange* const* google_protobuf_DescriptorProto_extension_range(const google_protobuf_DescriptorProto *msg, size_t *len) { return (const google_protobuf_DescriptorProto_ExtensionRange* const*)_upb_array_accessor(msg, UPB_SIZE(28, 56), len); }
UPB_INLINE const google_protobuf_FieldDescriptorProto* const* google_protobuf_DescriptorProto_extension(const google_protobuf_DescriptorProto *msg, size_t *len) { return (const google_protobuf_FieldDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(32, 64), len); }
UPB_INLINE bool google_protobuf_DescriptorProto_has_options(const google_protobuf_DescriptorProto *msg) { return _upb_has_field(msg, 2); }
UPB_INLINE const google_protobuf_MessageOptions* google_protobuf_DescriptorProto_options(const google_protobuf_DescriptorProto *msg) { return UPB_FIELD_AT(msg, const google_protobuf_MessageOptions*, UPB_SIZE(12, 24)); }
UPB_INLINE const google_protobuf_MessageOptions* google_protobuf_DescriptorProto_options(const google_protobuf_DescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(12, 24), const google_protobuf_MessageOptions*); }
UPB_INLINE const google_protobuf_OneofDescriptorProto* const* google_protobuf_DescriptorProto_oneof_decl(const google_protobuf_DescriptorProto *msg, size_t *len) { return (const google_protobuf_OneofDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(36, 72), len); }
UPB_INLINE const google_protobuf_DescriptorProto_ReservedRange* const* google_protobuf_DescriptorProto_reserved_range(const google_protobuf_DescriptorProto *msg, size_t *len) { return (const google_protobuf_DescriptorProto_ReservedRange* const*)_upb_array_accessor(msg, UPB_SIZE(40, 80), len); }
UPB_INLINE upb_strview const* google_protobuf_DescriptorProto_reserved_name(const google_protobuf_DescriptorProto *msg, size_t *len) { return (upb_strview const*)_upb_array_accessor(msg, UPB_SIZE(44, 88), len); }
UPB_INLINE void google_protobuf_DescriptorProto_set_name(google_protobuf_DescriptorProto *msg, upb_strview value) {
_upb_sethas(msg, 1);
UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview) = value;
}
UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_DescriptorProto_mutable_field(google_protobuf_DescriptorProto *msg, size_t *len) {
return (google_protobuf_FieldDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(16, 32), len);
@ -434,7 +434,7 @@ UPB_INLINE struct google_protobuf_FieldDescriptorProto* google_protobuf_Descript
}
UPB_INLINE void google_protobuf_DescriptorProto_set_options(google_protobuf_DescriptorProto *msg, google_protobuf_MessageOptions* value) {
_upb_sethas(msg, 2);
UPB_FIELD_AT(msg, google_protobuf_MessageOptions*, UPB_SIZE(12, 24)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(12, 24), google_protobuf_MessageOptions*) = value;
}
UPB_INLINE struct google_protobuf_MessageOptions* google_protobuf_DescriptorProto_mutable_options(google_protobuf_DescriptorProto *msg, upb_arena *arena) {
struct google_protobuf_MessageOptions* sub = (struct google_protobuf_MessageOptions*)google_protobuf_DescriptorProto_options(msg);
@ -497,23 +497,23 @@ UPB_INLINE char *google_protobuf_DescriptorProto_ExtensionRange_serialize(const
}
UPB_INLINE bool google_protobuf_DescriptorProto_ExtensionRange_has_start(const google_protobuf_DescriptorProto_ExtensionRange *msg) { return _upb_has_field(msg, 1); }
UPB_INLINE int32_t google_protobuf_DescriptorProto_ExtensionRange_start(const google_protobuf_DescriptorProto_ExtensionRange *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(4, 4)); }
UPB_INLINE int32_t google_protobuf_DescriptorProto_ExtensionRange_start(const google_protobuf_DescriptorProto_ExtensionRange *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 4), int32_t); }
UPB_INLINE bool google_protobuf_DescriptorProto_ExtensionRange_has_end(const google_protobuf_DescriptorProto_ExtensionRange *msg) { return _upb_has_field(msg, 2); }
UPB_INLINE int32_t google_protobuf_DescriptorProto_ExtensionRange_end(const google_protobuf_DescriptorProto_ExtensionRange *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)); }
UPB_INLINE int32_t google_protobuf_DescriptorProto_ExtensionRange_end(const google_protobuf_DescriptorProto_ExtensionRange *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t); }
UPB_INLINE bool google_protobuf_DescriptorProto_ExtensionRange_has_options(const google_protobuf_DescriptorProto_ExtensionRange *msg) { return _upb_has_field(msg, 3); }
UPB_INLINE const google_protobuf_ExtensionRangeOptions* google_protobuf_DescriptorProto_ExtensionRange_options(const google_protobuf_DescriptorProto_ExtensionRange *msg) { return UPB_FIELD_AT(msg, const google_protobuf_ExtensionRangeOptions*, UPB_SIZE(12, 16)); }
UPB_INLINE const google_protobuf_ExtensionRangeOptions* google_protobuf_DescriptorProto_ExtensionRange_options(const google_protobuf_DescriptorProto_ExtensionRange *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(12, 16), const google_protobuf_ExtensionRangeOptions*); }
UPB_INLINE void google_protobuf_DescriptorProto_ExtensionRange_set_start(google_protobuf_DescriptorProto_ExtensionRange *msg, int32_t value) {
_upb_sethas(msg, 1);
UPB_FIELD_AT(msg, int32_t, UPB_SIZE(4, 4)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(4, 4), int32_t) = value;
}
UPB_INLINE void google_protobuf_DescriptorProto_ExtensionRange_set_end(google_protobuf_DescriptorProto_ExtensionRange *msg, int32_t value) {
_upb_sethas(msg, 2);
UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t) = value;
}
UPB_INLINE void google_protobuf_DescriptorProto_ExtensionRange_set_options(google_protobuf_DescriptorProto_ExtensionRange *msg, google_protobuf_ExtensionRangeOptions* value) {
_upb_sethas(msg, 3);
UPB_FIELD_AT(msg, google_protobuf_ExtensionRangeOptions*, UPB_SIZE(12, 16)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(12, 16), google_protobuf_ExtensionRangeOptions*) = value;
}
UPB_INLINE struct google_protobuf_ExtensionRangeOptions* google_protobuf_DescriptorProto_ExtensionRange_mutable_options(google_protobuf_DescriptorProto_ExtensionRange *msg, upb_arena *arena) {
struct google_protobuf_ExtensionRangeOptions* sub = (struct google_protobuf_ExtensionRangeOptions*)google_protobuf_DescriptorProto_ExtensionRange_options(msg);
@ -540,17 +540,17 @@ UPB_INLINE char *google_protobuf_DescriptorProto_ReservedRange_serialize(const g
}
UPB_INLINE bool google_protobuf_DescriptorProto_ReservedRange_has_start(const google_protobuf_DescriptorProto_ReservedRange *msg) { return _upb_has_field(msg, 1); }
UPB_INLINE int32_t google_protobuf_DescriptorProto_ReservedRange_start(const google_protobuf_DescriptorProto_ReservedRange *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(4, 4)); }
UPB_INLINE int32_t google_protobuf_DescriptorProto_ReservedRange_start(const google_protobuf_DescriptorProto_ReservedRange *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 4), int32_t); }
UPB_INLINE bool google_protobuf_DescriptorProto_ReservedRange_has_end(const google_protobuf_DescriptorProto_ReservedRange *msg) { return _upb_has_field(msg, 2); }
UPB_INLINE int32_t google_protobuf_DescriptorProto_ReservedRange_end(const google_protobuf_DescriptorProto_ReservedRange *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)); }
UPB_INLINE int32_t google_protobuf_DescriptorProto_ReservedRange_end(const google_protobuf_DescriptorProto_ReservedRange *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t); }
UPB_INLINE void google_protobuf_DescriptorProto_ReservedRange_set_start(google_protobuf_DescriptorProto_ReservedRange *msg, int32_t value) {
_upb_sethas(msg, 1);
UPB_FIELD_AT(msg, int32_t, UPB_SIZE(4, 4)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(4, 4), int32_t) = value;
}
UPB_INLINE void google_protobuf_DescriptorProto_ReservedRange_set_end(google_protobuf_DescriptorProto_ReservedRange *msg, int32_t value) {
_upb_sethas(msg, 2);
UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t) = value;
}
/* google.protobuf.ExtensionRangeOptions */
@ -598,57 +598,57 @@ UPB_INLINE char *google_protobuf_FieldDescriptorProto_serialize(const google_pro
}
UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_name(const google_protobuf_FieldDescriptorProto *msg) { return _upb_has_field(msg, 5); }
UPB_INLINE upb_strview google_protobuf_FieldDescriptorProto_name(const google_protobuf_FieldDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(32, 32)); }
UPB_INLINE upb_strview google_protobuf_FieldDescriptorProto_name(const google_protobuf_FieldDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(32, 32), upb_strview); }
UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_extendee(const google_protobuf_FieldDescriptorProto *msg) { return _upb_has_field(msg, 6); }
UPB_INLINE upb_strview google_protobuf_FieldDescriptorProto_extendee(const google_protobuf_FieldDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(40, 48)); }
UPB_INLINE upb_strview google_protobuf_FieldDescriptorProto_extendee(const google_protobuf_FieldDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(40, 48), upb_strview); }
UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_number(const google_protobuf_FieldDescriptorProto *msg) { return _upb_has_field(msg, 3); }
UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_number(const google_protobuf_FieldDescriptorProto *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(24, 24)); }
UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_number(const google_protobuf_FieldDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(24, 24), int32_t); }
UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_label(const google_protobuf_FieldDescriptorProto *msg) { return _upb_has_field(msg, 1); }
UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_label(const google_protobuf_FieldDescriptorProto *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)); }
UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_label(const google_protobuf_FieldDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t); }
UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_type(const google_protobuf_FieldDescriptorProto *msg) { return _upb_has_field(msg, 2); }
UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_type(const google_protobuf_FieldDescriptorProto *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(16, 16)); }
UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_type(const google_protobuf_FieldDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(16, 16), int32_t); }
UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_type_name(const google_protobuf_FieldDescriptorProto *msg) { return _upb_has_field(msg, 7); }
UPB_INLINE upb_strview google_protobuf_FieldDescriptorProto_type_name(const google_protobuf_FieldDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(48, 64)); }
UPB_INLINE upb_strview google_protobuf_FieldDescriptorProto_type_name(const google_protobuf_FieldDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(48, 64), upb_strview); }
UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_default_value(const google_protobuf_FieldDescriptorProto *msg) { return _upb_has_field(msg, 8); }
UPB_INLINE upb_strview google_protobuf_FieldDescriptorProto_default_value(const google_protobuf_FieldDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(56, 80)); }
UPB_INLINE upb_strview google_protobuf_FieldDescriptorProto_default_value(const google_protobuf_FieldDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(56, 80), upb_strview); }
UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_options(const google_protobuf_FieldDescriptorProto *msg) { return _upb_has_field(msg, 10); }
UPB_INLINE const google_protobuf_FieldOptions* google_protobuf_FieldDescriptorProto_options(const google_protobuf_FieldDescriptorProto *msg) { return UPB_FIELD_AT(msg, const google_protobuf_FieldOptions*, UPB_SIZE(72, 112)); }
UPB_INLINE const google_protobuf_FieldOptions* google_protobuf_FieldDescriptorProto_options(const google_protobuf_FieldDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(72, 112), const google_protobuf_FieldOptions*); }
UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_oneof_index(const google_protobuf_FieldDescriptorProto *msg) { return _upb_has_field(msg, 4); }
UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_oneof_index(const google_protobuf_FieldDescriptorProto *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(28, 28)); }
UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_oneof_index(const google_protobuf_FieldDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(28, 28), int32_t); }
UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_json_name(const google_protobuf_FieldDescriptorProto *msg) { return _upb_has_field(msg, 9); }
UPB_INLINE upb_strview google_protobuf_FieldDescriptorProto_json_name(const google_protobuf_FieldDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(64, 96)); }
UPB_INLINE upb_strview google_protobuf_FieldDescriptorProto_json_name(const google_protobuf_FieldDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(64, 96), upb_strview); }
UPB_INLINE void google_protobuf_FieldDescriptorProto_set_name(google_protobuf_FieldDescriptorProto *msg, upb_strview value) {
_upb_sethas(msg, 5);
UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(32, 32)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(32, 32), upb_strview) = value;
}
UPB_INLINE void google_protobuf_FieldDescriptorProto_set_extendee(google_protobuf_FieldDescriptorProto *msg, upb_strview value) {
_upb_sethas(msg, 6);
UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(40, 48)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(40, 48), upb_strview) = value;
}
UPB_INLINE void google_protobuf_FieldDescriptorProto_set_number(google_protobuf_FieldDescriptorProto *msg, int32_t value) {
_upb_sethas(msg, 3);
UPB_FIELD_AT(msg, int32_t, UPB_SIZE(24, 24)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(24, 24), int32_t) = value;
}
UPB_INLINE void google_protobuf_FieldDescriptorProto_set_label(google_protobuf_FieldDescriptorProto *msg, int32_t value) {
_upb_sethas(msg, 1);
UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t) = value;
}
UPB_INLINE void google_protobuf_FieldDescriptorProto_set_type(google_protobuf_FieldDescriptorProto *msg, int32_t value) {
_upb_sethas(msg, 2);
UPB_FIELD_AT(msg, int32_t, UPB_SIZE(16, 16)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(16, 16), int32_t) = value;
}
UPB_INLINE void google_protobuf_FieldDescriptorProto_set_type_name(google_protobuf_FieldDescriptorProto *msg, upb_strview value) {
_upb_sethas(msg, 7);
UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(48, 64)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(48, 64), upb_strview) = value;
}
UPB_INLINE void google_protobuf_FieldDescriptorProto_set_default_value(google_protobuf_FieldDescriptorProto *msg, upb_strview value) {
_upb_sethas(msg, 8);
UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(56, 80)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(56, 80), upb_strview) = value;
}
UPB_INLINE void google_protobuf_FieldDescriptorProto_set_options(google_protobuf_FieldDescriptorProto *msg, google_protobuf_FieldOptions* value) {
_upb_sethas(msg, 10);
UPB_FIELD_AT(msg, google_protobuf_FieldOptions*, UPB_SIZE(72, 112)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(72, 112), google_protobuf_FieldOptions*) = value;
}
UPB_INLINE struct google_protobuf_FieldOptions* google_protobuf_FieldDescriptorProto_mutable_options(google_protobuf_FieldDescriptorProto *msg, upb_arena *arena) {
struct google_protobuf_FieldOptions* sub = (struct google_protobuf_FieldOptions*)google_protobuf_FieldDescriptorProto_options(msg);
@ -661,11 +661,11 @@ UPB_INLINE struct google_protobuf_FieldOptions* google_protobuf_FieldDescriptorP
}
UPB_INLINE void google_protobuf_FieldDescriptorProto_set_oneof_index(google_protobuf_FieldDescriptorProto *msg, int32_t value) {
_upb_sethas(msg, 4);
UPB_FIELD_AT(msg, int32_t, UPB_SIZE(28, 28)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(28, 28), int32_t) = value;
}
UPB_INLINE void google_protobuf_FieldDescriptorProto_set_json_name(google_protobuf_FieldDescriptorProto *msg, upb_strview value) {
_upb_sethas(msg, 9);
UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(64, 96)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(64, 96), upb_strview) = value;
}
/* google.protobuf.OneofDescriptorProto */
@ -683,17 +683,17 @@ UPB_INLINE char *google_protobuf_OneofDescriptorProto_serialize(const google_pro
}
UPB_INLINE bool google_protobuf_OneofDescriptorProto_has_name(const google_protobuf_OneofDescriptorProto *msg) { return _upb_has_field(msg, 1); }
UPB_INLINE upb_strview google_protobuf_OneofDescriptorProto_name(const google_protobuf_OneofDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)); }
UPB_INLINE upb_strview google_protobuf_OneofDescriptorProto_name(const google_protobuf_OneofDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview); }
UPB_INLINE bool google_protobuf_OneofDescriptorProto_has_options(const google_protobuf_OneofDescriptorProto *msg) { return _upb_has_field(msg, 2); }
UPB_INLINE const google_protobuf_OneofOptions* google_protobuf_OneofDescriptorProto_options(const google_protobuf_OneofDescriptorProto *msg) { return UPB_FIELD_AT(msg, const google_protobuf_OneofOptions*, UPB_SIZE(12, 24)); }
UPB_INLINE const google_protobuf_OneofOptions* google_protobuf_OneofDescriptorProto_options(const google_protobuf_OneofDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(12, 24), const google_protobuf_OneofOptions*); }
UPB_INLINE void google_protobuf_OneofDescriptorProto_set_name(google_protobuf_OneofDescriptorProto *msg, upb_strview value) {
_upb_sethas(msg, 1);
UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview) = value;
}
UPB_INLINE void google_protobuf_OneofDescriptorProto_set_options(google_protobuf_OneofDescriptorProto *msg, google_protobuf_OneofOptions* value) {
_upb_sethas(msg, 2);
UPB_FIELD_AT(msg, google_protobuf_OneofOptions*, UPB_SIZE(12, 24)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(12, 24), google_protobuf_OneofOptions*) = value;
}
UPB_INLINE struct google_protobuf_OneofOptions* google_protobuf_OneofDescriptorProto_mutable_options(google_protobuf_OneofDescriptorProto *msg, upb_arena *arena) {
struct google_protobuf_OneofOptions* sub = (struct google_protobuf_OneofOptions*)google_protobuf_OneofDescriptorProto_options(msg);
@ -720,16 +720,16 @@ UPB_INLINE char *google_protobuf_EnumDescriptorProto_serialize(const google_prot
}
UPB_INLINE bool google_protobuf_EnumDescriptorProto_has_name(const google_protobuf_EnumDescriptorProto *msg) { return _upb_has_field(msg, 1); }
UPB_INLINE upb_strview google_protobuf_EnumDescriptorProto_name(const google_protobuf_EnumDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)); }
UPB_INLINE upb_strview google_protobuf_EnumDescriptorProto_name(const google_protobuf_EnumDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview); }
UPB_INLINE const google_protobuf_EnumValueDescriptorProto* const* google_protobuf_EnumDescriptorProto_value(const google_protobuf_EnumDescriptorProto *msg, size_t *len) { return (const google_protobuf_EnumValueDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(16, 32), len); }
UPB_INLINE bool google_protobuf_EnumDescriptorProto_has_options(const google_protobuf_EnumDescriptorProto *msg) { return _upb_has_field(msg, 2); }
UPB_INLINE const google_protobuf_EnumOptions* google_protobuf_EnumDescriptorProto_options(const google_protobuf_EnumDescriptorProto *msg) { return UPB_FIELD_AT(msg, const google_protobuf_EnumOptions*, UPB_SIZE(12, 24)); }
UPB_INLINE const google_protobuf_EnumOptions* google_protobuf_EnumDescriptorProto_options(const google_protobuf_EnumDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(12, 24), const google_protobuf_EnumOptions*); }
UPB_INLINE const google_protobuf_EnumDescriptorProto_EnumReservedRange* const* google_protobuf_EnumDescriptorProto_reserved_range(const google_protobuf_EnumDescriptorProto *msg, size_t *len) { return (const google_protobuf_EnumDescriptorProto_EnumReservedRange* const*)_upb_array_accessor(msg, UPB_SIZE(20, 40), len); }
UPB_INLINE upb_strview const* google_protobuf_EnumDescriptorProto_reserved_name(const google_protobuf_EnumDescriptorProto *msg, size_t *len) { return (upb_strview const*)_upb_array_accessor(msg, UPB_SIZE(24, 48), len); }
UPB_INLINE void google_protobuf_EnumDescriptorProto_set_name(google_protobuf_EnumDescriptorProto *msg, upb_strview value) {
_upb_sethas(msg, 1);
UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview) = value;
}
UPB_INLINE google_protobuf_EnumValueDescriptorProto** google_protobuf_EnumDescriptorProto_mutable_value(google_protobuf_EnumDescriptorProto *msg, size_t *len) {
return (google_protobuf_EnumValueDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(16, 32), len);
@ -746,7 +746,7 @@ UPB_INLINE struct google_protobuf_EnumValueDescriptorProto* google_protobuf_Enum
}
UPB_INLINE void google_protobuf_EnumDescriptorProto_set_options(google_protobuf_EnumDescriptorProto *msg, google_protobuf_EnumOptions* value) {
_upb_sethas(msg, 2);
UPB_FIELD_AT(msg, google_protobuf_EnumOptions*, UPB_SIZE(12, 24)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(12, 24), google_protobuf_EnumOptions*) = value;
}
UPB_INLINE struct google_protobuf_EnumOptions* google_protobuf_EnumDescriptorProto_mutable_options(google_protobuf_EnumDescriptorProto *msg, upb_arena *arena) {
struct google_protobuf_EnumOptions* sub = (struct google_protobuf_EnumOptions*)google_protobuf_EnumDescriptorProto_options(msg);
@ -796,17 +796,17 @@ UPB_INLINE char *google_protobuf_EnumDescriptorProto_EnumReservedRange_serialize
}
UPB_INLINE bool google_protobuf_EnumDescriptorProto_EnumReservedRange_has_start(const google_protobuf_EnumDescriptorProto_EnumReservedRange *msg) { return _upb_has_field(msg, 1); }
UPB_INLINE int32_t google_protobuf_EnumDescriptorProto_EnumReservedRange_start(const google_protobuf_EnumDescriptorProto_EnumReservedRange *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(4, 4)); }
UPB_INLINE int32_t google_protobuf_EnumDescriptorProto_EnumReservedRange_start(const google_protobuf_EnumDescriptorProto_EnumReservedRange *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 4), int32_t); }
UPB_INLINE bool google_protobuf_EnumDescriptorProto_EnumReservedRange_has_end(const google_protobuf_EnumDescriptorProto_EnumReservedRange *msg) { return _upb_has_field(msg, 2); }
UPB_INLINE int32_t google_protobuf_EnumDescriptorProto_EnumReservedRange_end(const google_protobuf_EnumDescriptorProto_EnumReservedRange *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)); }
UPB_INLINE int32_t google_protobuf_EnumDescriptorProto_EnumReservedRange_end(const google_protobuf_EnumDescriptorProto_EnumReservedRange *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t); }
UPB_INLINE void google_protobuf_EnumDescriptorProto_EnumReservedRange_set_start(google_protobuf_EnumDescriptorProto_EnumReservedRange *msg, int32_t value) {
_upb_sethas(msg, 1);
UPB_FIELD_AT(msg, int32_t, UPB_SIZE(4, 4)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(4, 4), int32_t) = value;
}
UPB_INLINE void google_protobuf_EnumDescriptorProto_EnumReservedRange_set_end(google_protobuf_EnumDescriptorProto_EnumReservedRange *msg, int32_t value) {
_upb_sethas(msg, 2);
UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t) = value;
}
/* google.protobuf.EnumValueDescriptorProto */
@ -824,23 +824,23 @@ UPB_INLINE char *google_protobuf_EnumValueDescriptorProto_serialize(const google
}
UPB_INLINE bool google_protobuf_EnumValueDescriptorProto_has_name(const google_protobuf_EnumValueDescriptorProto *msg) { return _upb_has_field(msg, 2); }
UPB_INLINE upb_strview google_protobuf_EnumValueDescriptorProto_name(const google_protobuf_EnumValueDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 8)); }
UPB_INLINE upb_strview google_protobuf_EnumValueDescriptorProto_name(const google_protobuf_EnumValueDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(8, 8), upb_strview); }
UPB_INLINE bool google_protobuf_EnumValueDescriptorProto_has_number(const google_protobuf_EnumValueDescriptorProto *msg) { return _upb_has_field(msg, 1); }
UPB_INLINE int32_t google_protobuf_EnumValueDescriptorProto_number(const google_protobuf_EnumValueDescriptorProto *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(4, 4)); }
UPB_INLINE int32_t google_protobuf_EnumValueDescriptorProto_number(const google_protobuf_EnumValueDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 4), int32_t); }
UPB_INLINE bool google_protobuf_EnumValueDescriptorProto_has_options(const google_protobuf_EnumValueDescriptorProto *msg) { return _upb_has_field(msg, 3); }
UPB_INLINE const google_protobuf_EnumValueOptions* google_protobuf_EnumValueDescriptorProto_options(const google_protobuf_EnumValueDescriptorProto *msg) { return UPB_FIELD_AT(msg, const google_protobuf_EnumValueOptions*, UPB_SIZE(16, 24)); }
UPB_INLINE const google_protobuf_EnumValueOptions* google_protobuf_EnumValueDescriptorProto_options(const google_protobuf_EnumValueDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(16, 24), const google_protobuf_EnumValueOptions*); }
UPB_INLINE void google_protobuf_EnumValueDescriptorProto_set_name(google_protobuf_EnumValueDescriptorProto *msg, upb_strview value) {
_upb_sethas(msg, 2);
UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 8)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(8, 8), upb_strview) = value;
}
UPB_INLINE void google_protobuf_EnumValueDescriptorProto_set_number(google_protobuf_EnumValueDescriptorProto *msg, int32_t value) {
_upb_sethas(msg, 1);
UPB_FIELD_AT(msg, int32_t, UPB_SIZE(4, 4)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(4, 4), int32_t) = value;
}
UPB_INLINE void google_protobuf_EnumValueDescriptorProto_set_options(google_protobuf_EnumValueDescriptorProto *msg, google_protobuf_EnumValueOptions* value) {
_upb_sethas(msg, 3);
UPB_FIELD_AT(msg, google_protobuf_EnumValueOptions*, UPB_SIZE(16, 24)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(16, 24), google_protobuf_EnumValueOptions*) = value;
}
UPB_INLINE struct google_protobuf_EnumValueOptions* google_protobuf_EnumValueDescriptorProto_mutable_options(google_protobuf_EnumValueDescriptorProto *msg, upb_arena *arena) {
struct google_protobuf_EnumValueOptions* sub = (struct google_protobuf_EnumValueOptions*)google_protobuf_EnumValueDescriptorProto_options(msg);
@ -867,14 +867,14 @@ UPB_INLINE char *google_protobuf_ServiceDescriptorProto_serialize(const google_p
}
UPB_INLINE bool google_protobuf_ServiceDescriptorProto_has_name(const google_protobuf_ServiceDescriptorProto *msg) { return _upb_has_field(msg, 1); }
UPB_INLINE upb_strview google_protobuf_ServiceDescriptorProto_name(const google_protobuf_ServiceDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)); }
UPB_INLINE upb_strview google_protobuf_ServiceDescriptorProto_name(const google_protobuf_ServiceDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview); }
UPB_INLINE const google_protobuf_MethodDescriptorProto* const* google_protobuf_ServiceDescriptorProto_method(const google_protobuf_ServiceDescriptorProto *msg, size_t *len) { return (const google_protobuf_MethodDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(16, 32), len); }
UPB_INLINE bool google_protobuf_ServiceDescriptorProto_has_options(const google_protobuf_ServiceDescriptorProto *msg) { return _upb_has_field(msg, 2); }
UPB_INLINE const google_protobuf_ServiceOptions* google_protobuf_ServiceDescriptorProto_options(const google_protobuf_ServiceDescriptorProto *msg) { return UPB_FIELD_AT(msg, const google_protobuf_ServiceOptions*, UPB_SIZE(12, 24)); }
UPB_INLINE const google_protobuf_ServiceOptions* google_protobuf_ServiceDescriptorProto_options(const google_protobuf_ServiceDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(12, 24), const google_protobuf_ServiceOptions*); }
UPB_INLINE void google_protobuf_ServiceDescriptorProto_set_name(google_protobuf_ServiceDescriptorProto *msg, upb_strview value) {
_upb_sethas(msg, 1);
UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview) = value;
}
UPB_INLINE google_protobuf_MethodDescriptorProto** google_protobuf_ServiceDescriptorProto_mutable_method(google_protobuf_ServiceDescriptorProto *msg, size_t *len) {
return (google_protobuf_MethodDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(16, 32), len);
@ -891,7 +891,7 @@ UPB_INLINE struct google_protobuf_MethodDescriptorProto* google_protobuf_Service
}
UPB_INLINE void google_protobuf_ServiceDescriptorProto_set_options(google_protobuf_ServiceDescriptorProto *msg, google_protobuf_ServiceOptions* value) {
_upb_sethas(msg, 2);
UPB_FIELD_AT(msg, google_protobuf_ServiceOptions*, UPB_SIZE(12, 24)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(12, 24), google_protobuf_ServiceOptions*) = value;
}
UPB_INLINE struct google_protobuf_ServiceOptions* google_protobuf_ServiceDescriptorProto_mutable_options(google_protobuf_ServiceDescriptorProto *msg, upb_arena *arena) {
struct google_protobuf_ServiceOptions* sub = (struct google_protobuf_ServiceOptions*)google_protobuf_ServiceDescriptorProto_options(msg);
@ -918,33 +918,33 @@ UPB_INLINE char *google_protobuf_MethodDescriptorProto_serialize(const google_pr
}
UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_name(const google_protobuf_MethodDescriptorProto *msg) { return _upb_has_field(msg, 3); }
UPB_INLINE upb_strview google_protobuf_MethodDescriptorProto_name(const google_protobuf_MethodDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)); }
UPB_INLINE upb_strview google_protobuf_MethodDescriptorProto_name(const google_protobuf_MethodDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview); }
UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_input_type(const google_protobuf_MethodDescriptorProto *msg) { return _upb_has_field(msg, 4); }
UPB_INLINE upb_strview google_protobuf_MethodDescriptorProto_input_type(const google_protobuf_MethodDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(12, 24)); }
UPB_INLINE upb_strview google_protobuf_MethodDescriptorProto_input_type(const google_protobuf_MethodDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(12, 24), upb_strview); }
UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_output_type(const google_protobuf_MethodDescriptorProto *msg) { return _upb_has_field(msg, 5); }
UPB_INLINE upb_strview google_protobuf_MethodDescriptorProto_output_type(const google_protobuf_MethodDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(20, 40)); }
UPB_INLINE upb_strview google_protobuf_MethodDescriptorProto_output_type(const google_protobuf_MethodDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(20, 40), upb_strview); }
UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_options(const google_protobuf_MethodDescriptorProto *msg) { return _upb_has_field(msg, 6); }
UPB_INLINE const google_protobuf_MethodOptions* google_protobuf_MethodDescriptorProto_options(const google_protobuf_MethodDescriptorProto *msg) { return UPB_FIELD_AT(msg, const google_protobuf_MethodOptions*, UPB_SIZE(28, 56)); }
UPB_INLINE const google_protobuf_MethodOptions* google_protobuf_MethodDescriptorProto_options(const google_protobuf_MethodDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(28, 56), const google_protobuf_MethodOptions*); }
UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_client_streaming(const google_protobuf_MethodDescriptorProto *msg) { return _upb_has_field(msg, 1); }
UPB_INLINE bool google_protobuf_MethodDescriptorProto_client_streaming(const google_protobuf_MethodDescriptorProto *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)); }
UPB_INLINE bool google_protobuf_MethodDescriptorProto_client_streaming(const google_protobuf_MethodDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(1, 1), bool); }
UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_server_streaming(const google_protobuf_MethodDescriptorProto *msg) { return _upb_has_field(msg, 2); }
UPB_INLINE bool google_protobuf_MethodDescriptorProto_server_streaming(const google_protobuf_MethodDescriptorProto *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(2, 2)); }
UPB_INLINE bool google_protobuf_MethodDescriptorProto_server_streaming(const google_protobuf_MethodDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(2, 2), bool); }
UPB_INLINE void google_protobuf_MethodDescriptorProto_set_name(google_protobuf_MethodDescriptorProto *msg, upb_strview value) {
_upb_sethas(msg, 3);
UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview) = value;
}
UPB_INLINE void google_protobuf_MethodDescriptorProto_set_input_type(google_protobuf_MethodDescriptorProto *msg, upb_strview value) {
_upb_sethas(msg, 4);
UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(12, 24)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(12, 24), upb_strview) = value;
}
UPB_INLINE void google_protobuf_MethodDescriptorProto_set_output_type(google_protobuf_MethodDescriptorProto *msg, upb_strview value) {
_upb_sethas(msg, 5);
UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(20, 40)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(20, 40), upb_strview) = value;
}
UPB_INLINE void google_protobuf_MethodDescriptorProto_set_options(google_protobuf_MethodDescriptorProto *msg, google_protobuf_MethodOptions* value) {
_upb_sethas(msg, 6);
UPB_FIELD_AT(msg, google_protobuf_MethodOptions*, UPB_SIZE(28, 56)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(28, 56), google_protobuf_MethodOptions*) = value;
}
UPB_INLINE struct google_protobuf_MethodOptions* google_protobuf_MethodDescriptorProto_mutable_options(google_protobuf_MethodDescriptorProto *msg, upb_arena *arena) {
struct google_protobuf_MethodOptions* sub = (struct google_protobuf_MethodOptions*)google_protobuf_MethodDescriptorProto_options(msg);
@ -957,11 +957,11 @@ UPB_INLINE struct google_protobuf_MethodOptions* google_protobuf_MethodDescripto
}
UPB_INLINE void google_protobuf_MethodDescriptorProto_set_client_streaming(google_protobuf_MethodDescriptorProto *msg, bool value) {
_upb_sethas(msg, 1);
UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(1, 1), bool) = value;
}
UPB_INLINE void google_protobuf_MethodDescriptorProto_set_server_streaming(google_protobuf_MethodDescriptorProto *msg, bool value) {
_upb_sethas(msg, 2);
UPB_FIELD_AT(msg, bool, UPB_SIZE(2, 2)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(2, 2), bool) = value;
}
/* google.protobuf.FileOptions */
@ -979,126 +979,126 @@ UPB_INLINE char *google_protobuf_FileOptions_serialize(const google_protobuf_Fil
}
UPB_INLINE bool google_protobuf_FileOptions_has_java_package(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 11); }
UPB_INLINE upb_strview google_protobuf_FileOptions_java_package(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(28, 32)); }
UPB_INLINE upb_strview google_protobuf_FileOptions_java_package(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(28, 32), upb_strview); }
UPB_INLINE bool google_protobuf_FileOptions_has_java_outer_classname(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 12); }
UPB_INLINE upb_strview google_protobuf_FileOptions_java_outer_classname(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(36, 48)); }
UPB_INLINE upb_strview google_protobuf_FileOptions_java_outer_classname(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(36, 48), upb_strview); }
UPB_INLINE bool google_protobuf_FileOptions_has_optimize_for(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 1); }
UPB_INLINE int32_t google_protobuf_FileOptions_optimize_for(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)); }
UPB_INLINE int32_t google_protobuf_FileOptions_optimize_for(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t); }
UPB_INLINE bool google_protobuf_FileOptions_has_java_multiple_files(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 2); }
UPB_INLINE bool google_protobuf_FileOptions_java_multiple_files(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(16, 16)); }
UPB_INLINE bool google_protobuf_FileOptions_java_multiple_files(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(16, 16), bool); }
UPB_INLINE bool google_protobuf_FileOptions_has_go_package(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 13); }
UPB_INLINE upb_strview google_protobuf_FileOptions_go_package(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(44, 64)); }
UPB_INLINE upb_strview google_protobuf_FileOptions_go_package(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(44, 64), upb_strview); }
UPB_INLINE bool google_protobuf_FileOptions_has_cc_generic_services(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 3); }
UPB_INLINE bool google_protobuf_FileOptions_cc_generic_services(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(17, 17)); }
UPB_INLINE bool google_protobuf_FileOptions_cc_generic_services(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(17, 17), bool); }
UPB_INLINE bool google_protobuf_FileOptions_has_java_generic_services(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 4); }
UPB_INLINE bool google_protobuf_FileOptions_java_generic_services(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(18, 18)); }
UPB_INLINE bool google_protobuf_FileOptions_java_generic_services(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(18, 18), bool); }
UPB_INLINE bool google_protobuf_FileOptions_has_py_generic_services(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 5); }
UPB_INLINE bool google_protobuf_FileOptions_py_generic_services(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(19, 19)); }
UPB_INLINE bool google_protobuf_FileOptions_py_generic_services(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(19, 19), bool); }
UPB_INLINE bool google_protobuf_FileOptions_has_java_generate_equals_and_hash(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 6); }
UPB_INLINE bool google_protobuf_FileOptions_java_generate_equals_and_hash(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(20, 20)); }
UPB_INLINE bool google_protobuf_FileOptions_java_generate_equals_and_hash(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(20, 20), bool); }
UPB_INLINE bool google_protobuf_FileOptions_has_deprecated(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 7); }
UPB_INLINE bool google_protobuf_FileOptions_deprecated(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(21, 21)); }
UPB_INLINE bool google_protobuf_FileOptions_deprecated(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(21, 21), bool); }
UPB_INLINE bool google_protobuf_FileOptions_has_java_string_check_utf8(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 8); }
UPB_INLINE bool google_protobuf_FileOptions_java_string_check_utf8(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(22, 22)); }
UPB_INLINE bool google_protobuf_FileOptions_java_string_check_utf8(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(22, 22), bool); }
UPB_INLINE bool google_protobuf_FileOptions_has_cc_enable_arenas(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 9); }
UPB_INLINE bool google_protobuf_FileOptions_cc_enable_arenas(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(23, 23)); }
UPB_INLINE bool google_protobuf_FileOptions_cc_enable_arenas(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(23, 23), bool); }
UPB_INLINE bool google_protobuf_FileOptions_has_objc_class_prefix(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 14); }
UPB_INLINE upb_strview google_protobuf_FileOptions_objc_class_prefix(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(52, 80)); }
UPB_INLINE upb_strview google_protobuf_FileOptions_objc_class_prefix(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(52, 80), upb_strview); }
UPB_INLINE bool google_protobuf_FileOptions_has_csharp_namespace(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 15); }
UPB_INLINE upb_strview google_protobuf_FileOptions_csharp_namespace(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(60, 96)); }
UPB_INLINE upb_strview google_protobuf_FileOptions_csharp_namespace(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(60, 96), upb_strview); }
UPB_INLINE bool google_protobuf_FileOptions_has_swift_prefix(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 16); }
UPB_INLINE upb_strview google_protobuf_FileOptions_swift_prefix(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(68, 112)); }
UPB_INLINE upb_strview google_protobuf_FileOptions_swift_prefix(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(68, 112), upb_strview); }
UPB_INLINE bool google_protobuf_FileOptions_has_php_class_prefix(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 17); }
UPB_INLINE upb_strview google_protobuf_FileOptions_php_class_prefix(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(76, 128)); }
UPB_INLINE upb_strview google_protobuf_FileOptions_php_class_prefix(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(76, 128), upb_strview); }
UPB_INLINE bool google_protobuf_FileOptions_has_php_namespace(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 18); }
UPB_INLINE upb_strview google_protobuf_FileOptions_php_namespace(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(84, 144)); }
UPB_INLINE upb_strview google_protobuf_FileOptions_php_namespace(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(84, 144), upb_strview); }
UPB_INLINE bool google_protobuf_FileOptions_has_php_generic_services(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 10); }
UPB_INLINE bool google_protobuf_FileOptions_php_generic_services(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(24, 24)); }
UPB_INLINE bool google_protobuf_FileOptions_php_generic_services(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(24, 24), bool); }
UPB_INLINE bool google_protobuf_FileOptions_has_php_metadata_namespace(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 19); }
UPB_INLINE upb_strview google_protobuf_FileOptions_php_metadata_namespace(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(92, 160)); }
UPB_INLINE upb_strview google_protobuf_FileOptions_php_metadata_namespace(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(92, 160), upb_strview); }
UPB_INLINE bool google_protobuf_FileOptions_has_ruby_package(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 20); }
UPB_INLINE upb_strview google_protobuf_FileOptions_ruby_package(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(100, 176)); }
UPB_INLINE upb_strview google_protobuf_FileOptions_ruby_package(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(100, 176), upb_strview); }
UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_FileOptions_uninterpreted_option(const google_protobuf_FileOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(108, 192), len); }
UPB_INLINE void google_protobuf_FileOptions_set_java_package(google_protobuf_FileOptions *msg, upb_strview value) {
_upb_sethas(msg, 11);
UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(28, 32)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(28, 32), upb_strview) = value;
}
UPB_INLINE void google_protobuf_FileOptions_set_java_outer_classname(google_protobuf_FileOptions *msg, upb_strview value) {
_upb_sethas(msg, 12);
UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(36, 48)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(36, 48), upb_strview) = value;
}
UPB_INLINE void google_protobuf_FileOptions_set_optimize_for(google_protobuf_FileOptions *msg, int32_t value) {
_upb_sethas(msg, 1);
UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t) = value;
}
UPB_INLINE void google_protobuf_FileOptions_set_java_multiple_files(google_protobuf_FileOptions *msg, bool value) {
_upb_sethas(msg, 2);
UPB_FIELD_AT(msg, bool, UPB_SIZE(16, 16)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(16, 16), bool) = value;
}
UPB_INLINE void google_protobuf_FileOptions_set_go_package(google_protobuf_FileOptions *msg, upb_strview value) {
_upb_sethas(msg, 13);
UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(44, 64)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(44, 64), upb_strview) = value;
}
UPB_INLINE void google_protobuf_FileOptions_set_cc_generic_services(google_protobuf_FileOptions *msg, bool value) {
_upb_sethas(msg, 3);
UPB_FIELD_AT(msg, bool, UPB_SIZE(17, 17)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(17, 17), bool) = value;
}
UPB_INLINE void google_protobuf_FileOptions_set_java_generic_services(google_protobuf_FileOptions *msg, bool value) {
_upb_sethas(msg, 4);
UPB_FIELD_AT(msg, bool, UPB_SIZE(18, 18)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(18, 18), bool) = value;
}
UPB_INLINE void google_protobuf_FileOptions_set_py_generic_services(google_protobuf_FileOptions *msg, bool value) {
_upb_sethas(msg, 5);
UPB_FIELD_AT(msg, bool, UPB_SIZE(19, 19)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(19, 19), bool) = value;
}
UPB_INLINE void google_protobuf_FileOptions_set_java_generate_equals_and_hash(google_protobuf_FileOptions *msg, bool value) {
_upb_sethas(msg, 6);
UPB_FIELD_AT(msg, bool, UPB_SIZE(20, 20)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(20, 20), bool) = value;
}
UPB_INLINE void google_protobuf_FileOptions_set_deprecated(google_protobuf_FileOptions *msg, bool value) {
_upb_sethas(msg, 7);
UPB_FIELD_AT(msg, bool, UPB_SIZE(21, 21)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(21, 21), bool) = value;
}
UPB_INLINE void google_protobuf_FileOptions_set_java_string_check_utf8(google_protobuf_FileOptions *msg, bool value) {
_upb_sethas(msg, 8);
UPB_FIELD_AT(msg, bool, UPB_SIZE(22, 22)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(22, 22), bool) = value;
}
UPB_INLINE void google_protobuf_FileOptions_set_cc_enable_arenas(google_protobuf_FileOptions *msg, bool value) {
_upb_sethas(msg, 9);
UPB_FIELD_AT(msg, bool, UPB_SIZE(23, 23)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(23, 23), bool) = value;
}
UPB_INLINE void google_protobuf_FileOptions_set_objc_class_prefix(google_protobuf_FileOptions *msg, upb_strview value) {
_upb_sethas(msg, 14);
UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(52, 80)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(52, 80), upb_strview) = value;
}
UPB_INLINE void google_protobuf_FileOptions_set_csharp_namespace(google_protobuf_FileOptions *msg, upb_strview value) {
_upb_sethas(msg, 15);
UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(60, 96)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(60, 96), upb_strview) = value;
}
UPB_INLINE void google_protobuf_FileOptions_set_swift_prefix(google_protobuf_FileOptions *msg, upb_strview value) {
_upb_sethas(msg, 16);
UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(68, 112)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(68, 112), upb_strview) = value;
}
UPB_INLINE void google_protobuf_FileOptions_set_php_class_prefix(google_protobuf_FileOptions *msg, upb_strview value) {
_upb_sethas(msg, 17);
UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(76, 128)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(76, 128), upb_strview) = value;
}
UPB_INLINE void google_protobuf_FileOptions_set_php_namespace(google_protobuf_FileOptions *msg, upb_strview value) {
_upb_sethas(msg, 18);
UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(84, 144)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(84, 144), upb_strview) = value;
}
UPB_INLINE void google_protobuf_FileOptions_set_php_generic_services(google_protobuf_FileOptions *msg, bool value) {
_upb_sethas(msg, 10);
UPB_FIELD_AT(msg, bool, UPB_SIZE(24, 24)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(24, 24), bool) = value;
}
UPB_INLINE void google_protobuf_FileOptions_set_php_metadata_namespace(google_protobuf_FileOptions *msg, upb_strview value) {
_upb_sethas(msg, 19);
UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(92, 160)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(92, 160), upb_strview) = value;
}
UPB_INLINE void google_protobuf_FileOptions_set_ruby_package(google_protobuf_FileOptions *msg, upb_strview value) {
_upb_sethas(msg, 20);
UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(100, 176)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(100, 176), upb_strview) = value;
}
UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_FileOptions_mutable_uninterpreted_option(google_protobuf_FileOptions *msg, size_t *len) {
return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(108, 192), len);
@ -1129,30 +1129,30 @@ UPB_INLINE char *google_protobuf_MessageOptions_serialize(const google_protobuf_
}
UPB_INLINE bool google_protobuf_MessageOptions_has_message_set_wire_format(const google_protobuf_MessageOptions *msg) { return _upb_has_field(msg, 1); }
UPB_INLINE bool google_protobuf_MessageOptions_message_set_wire_format(const google_protobuf_MessageOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)); }
UPB_INLINE bool google_protobuf_MessageOptions_message_set_wire_format(const google_protobuf_MessageOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(1, 1), bool); }
UPB_INLINE bool google_protobuf_MessageOptions_has_no_standard_descriptor_accessor(const google_protobuf_MessageOptions *msg) { return _upb_has_field(msg, 2); }
UPB_INLINE bool google_protobuf_MessageOptions_no_standard_descriptor_accessor(const google_protobuf_MessageOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(2, 2)); }
UPB_INLINE bool google_protobuf_MessageOptions_no_standard_descriptor_accessor(const google_protobuf_MessageOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(2, 2), bool); }
UPB_INLINE bool google_protobuf_MessageOptions_has_deprecated(const google_protobuf_MessageOptions *msg) { return _upb_has_field(msg, 3); }
UPB_INLINE bool google_protobuf_MessageOptions_deprecated(const google_protobuf_MessageOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(3, 3)); }
UPB_INLINE bool google_protobuf_MessageOptions_deprecated(const google_protobuf_MessageOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(3, 3), bool); }
UPB_INLINE bool google_protobuf_MessageOptions_has_map_entry(const google_protobuf_MessageOptions *msg) { return _upb_has_field(msg, 4); }
UPB_INLINE bool google_protobuf_MessageOptions_map_entry(const google_protobuf_MessageOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(4, 4)); }
UPB_INLINE bool google_protobuf_MessageOptions_map_entry(const google_protobuf_MessageOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 4), bool); }
UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_MessageOptions_uninterpreted_option(const google_protobuf_MessageOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(8, 8), len); }
UPB_INLINE void google_protobuf_MessageOptions_set_message_set_wire_format(google_protobuf_MessageOptions *msg, bool value) {
_upb_sethas(msg, 1);
UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(1, 1), bool) = value;
}
UPB_INLINE void google_protobuf_MessageOptions_set_no_standard_descriptor_accessor(google_protobuf_MessageOptions *msg, bool value) {
_upb_sethas(msg, 2);
UPB_FIELD_AT(msg, bool, UPB_SIZE(2, 2)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(2, 2), bool) = value;
}
UPB_INLINE void google_protobuf_MessageOptions_set_deprecated(google_protobuf_MessageOptions *msg, bool value) {
_upb_sethas(msg, 3);
UPB_FIELD_AT(msg, bool, UPB_SIZE(3, 3)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(3, 3), bool) = value;
}
UPB_INLINE void google_protobuf_MessageOptions_set_map_entry(google_protobuf_MessageOptions *msg, bool value) {
_upb_sethas(msg, 4);
UPB_FIELD_AT(msg, bool, UPB_SIZE(4, 4)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(4, 4), bool) = value;
}
UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_MessageOptions_mutable_uninterpreted_option(google_protobuf_MessageOptions *msg, size_t *len) {
return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(8, 8), len);
@ -1183,42 +1183,42 @@ UPB_INLINE char *google_protobuf_FieldOptions_serialize(const google_protobuf_Fi
}
UPB_INLINE bool google_protobuf_FieldOptions_has_ctype(const google_protobuf_FieldOptions *msg) { return _upb_has_field(msg, 1); }
UPB_INLINE int32_t google_protobuf_FieldOptions_ctype(const google_protobuf_FieldOptions *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)); }
UPB_INLINE int32_t google_protobuf_FieldOptions_ctype(const google_protobuf_FieldOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t); }
UPB_INLINE bool google_protobuf_FieldOptions_has_packed(const google_protobuf_FieldOptions *msg) { return _upb_has_field(msg, 3); }
UPB_INLINE bool google_protobuf_FieldOptions_packed(const google_protobuf_FieldOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(24, 24)); }
UPB_INLINE bool google_protobuf_FieldOptions_packed(const google_protobuf_FieldOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(24, 24), bool); }
UPB_INLINE bool google_protobuf_FieldOptions_has_deprecated(const google_protobuf_FieldOptions *msg) { return _upb_has_field(msg, 4); }
UPB_INLINE bool google_protobuf_FieldOptions_deprecated(const google_protobuf_FieldOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(25, 25)); }
UPB_INLINE bool google_protobuf_FieldOptions_deprecated(const google_protobuf_FieldOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(25, 25), bool); }
UPB_INLINE bool google_protobuf_FieldOptions_has_lazy(const google_protobuf_FieldOptions *msg) { return _upb_has_field(msg, 5); }
UPB_INLINE bool google_protobuf_FieldOptions_lazy(const google_protobuf_FieldOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(26, 26)); }
UPB_INLINE bool google_protobuf_FieldOptions_lazy(const google_protobuf_FieldOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(26, 26), bool); }
UPB_INLINE bool google_protobuf_FieldOptions_has_jstype(const google_protobuf_FieldOptions *msg) { return _upb_has_field(msg, 2); }
UPB_INLINE int32_t google_protobuf_FieldOptions_jstype(const google_protobuf_FieldOptions *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(16, 16)); }
UPB_INLINE int32_t google_protobuf_FieldOptions_jstype(const google_protobuf_FieldOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(16, 16), int32_t); }
UPB_INLINE bool google_protobuf_FieldOptions_has_weak(const google_protobuf_FieldOptions *msg) { return _upb_has_field(msg, 6); }
UPB_INLINE bool google_protobuf_FieldOptions_weak(const google_protobuf_FieldOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(27, 27)); }
UPB_INLINE bool google_protobuf_FieldOptions_weak(const google_protobuf_FieldOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(27, 27), bool); }
UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_FieldOptions_uninterpreted_option(const google_protobuf_FieldOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(28, 32), len); }
UPB_INLINE void google_protobuf_FieldOptions_set_ctype(google_protobuf_FieldOptions *msg, int32_t value) {
_upb_sethas(msg, 1);
UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t) = value;
}
UPB_INLINE void google_protobuf_FieldOptions_set_packed(google_protobuf_FieldOptions *msg, bool value) {
_upb_sethas(msg, 3);
UPB_FIELD_AT(msg, bool, UPB_SIZE(24, 24)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(24, 24), bool) = value;
}
UPB_INLINE void google_protobuf_FieldOptions_set_deprecated(google_protobuf_FieldOptions *msg, bool value) {
_upb_sethas(msg, 4);
UPB_FIELD_AT(msg, bool, UPB_SIZE(25, 25)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(25, 25), bool) = value;
}
UPB_INLINE void google_protobuf_FieldOptions_set_lazy(google_protobuf_FieldOptions *msg, bool value) {
_upb_sethas(msg, 5);
UPB_FIELD_AT(msg, bool, UPB_SIZE(26, 26)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(26, 26), bool) = value;
}
UPB_INLINE void google_protobuf_FieldOptions_set_jstype(google_protobuf_FieldOptions *msg, int32_t value) {
_upb_sethas(msg, 2);
UPB_FIELD_AT(msg, int32_t, UPB_SIZE(16, 16)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(16, 16), int32_t) = value;
}
UPB_INLINE void google_protobuf_FieldOptions_set_weak(google_protobuf_FieldOptions *msg, bool value) {
_upb_sethas(msg, 6);
UPB_FIELD_AT(msg, bool, UPB_SIZE(27, 27)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(27, 27), bool) = value;
}
UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_FieldOptions_mutable_uninterpreted_option(google_protobuf_FieldOptions *msg, size_t *len) {
return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(28, 32), len);
@ -1279,18 +1279,18 @@ UPB_INLINE char *google_protobuf_EnumOptions_serialize(const google_protobuf_Enu
}
UPB_INLINE bool google_protobuf_EnumOptions_has_allow_alias(const google_protobuf_EnumOptions *msg) { return _upb_has_field(msg, 1); }
UPB_INLINE bool google_protobuf_EnumOptions_allow_alias(const google_protobuf_EnumOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)); }
UPB_INLINE bool google_protobuf_EnumOptions_allow_alias(const google_protobuf_EnumOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(1, 1), bool); }
UPB_INLINE bool google_protobuf_EnumOptions_has_deprecated(const google_protobuf_EnumOptions *msg) { return _upb_has_field(msg, 2); }
UPB_INLINE bool google_protobuf_EnumOptions_deprecated(const google_protobuf_EnumOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(2, 2)); }
UPB_INLINE bool google_protobuf_EnumOptions_deprecated(const google_protobuf_EnumOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(2, 2), bool); }
UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_EnumOptions_uninterpreted_option(const google_protobuf_EnumOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(4, 8), len); }
UPB_INLINE void google_protobuf_EnumOptions_set_allow_alias(google_protobuf_EnumOptions *msg, bool value) {
_upb_sethas(msg, 1);
UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(1, 1), bool) = value;
}
UPB_INLINE void google_protobuf_EnumOptions_set_deprecated(google_protobuf_EnumOptions *msg, bool value) {
_upb_sethas(msg, 2);
UPB_FIELD_AT(msg, bool, UPB_SIZE(2, 2)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(2, 2), bool) = value;
}
UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_EnumOptions_mutable_uninterpreted_option(google_protobuf_EnumOptions *msg, size_t *len) {
return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(4, 8), len);
@ -1321,12 +1321,12 @@ UPB_INLINE char *google_protobuf_EnumValueOptions_serialize(const google_protobu
}
UPB_INLINE bool google_protobuf_EnumValueOptions_has_deprecated(const google_protobuf_EnumValueOptions *msg) { return _upb_has_field(msg, 1); }
UPB_INLINE bool google_protobuf_EnumValueOptions_deprecated(const google_protobuf_EnumValueOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)); }
UPB_INLINE bool google_protobuf_EnumValueOptions_deprecated(const google_protobuf_EnumValueOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(1, 1), bool); }
UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_EnumValueOptions_uninterpreted_option(const google_protobuf_EnumValueOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(4, 8), len); }
UPB_INLINE void google_protobuf_EnumValueOptions_set_deprecated(google_protobuf_EnumValueOptions *msg, bool value) {
_upb_sethas(msg, 1);
UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(1, 1), bool) = value;
}
UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_EnumValueOptions_mutable_uninterpreted_option(google_protobuf_EnumValueOptions *msg, size_t *len) {
return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(4, 8), len);
@ -1357,12 +1357,12 @@ UPB_INLINE char *google_protobuf_ServiceOptions_serialize(const google_protobuf_
}
UPB_INLINE bool google_protobuf_ServiceOptions_has_deprecated(const google_protobuf_ServiceOptions *msg) { return _upb_has_field(msg, 1); }
UPB_INLINE bool google_protobuf_ServiceOptions_deprecated(const google_protobuf_ServiceOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)); }
UPB_INLINE bool google_protobuf_ServiceOptions_deprecated(const google_protobuf_ServiceOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(1, 1), bool); }
UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_ServiceOptions_uninterpreted_option(const google_protobuf_ServiceOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(4, 8), len); }
UPB_INLINE void google_protobuf_ServiceOptions_set_deprecated(google_protobuf_ServiceOptions *msg, bool value) {
_upb_sethas(msg, 1);
UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(1, 1), bool) = value;
}
UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_ServiceOptions_mutable_uninterpreted_option(google_protobuf_ServiceOptions *msg, size_t *len) {
return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(4, 8), len);
@ -1393,18 +1393,18 @@ UPB_INLINE char *google_protobuf_MethodOptions_serialize(const google_protobuf_M
}
UPB_INLINE bool google_protobuf_MethodOptions_has_deprecated(const google_protobuf_MethodOptions *msg) { return _upb_has_field(msg, 2); }
UPB_INLINE bool google_protobuf_MethodOptions_deprecated(const google_protobuf_MethodOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(16, 16)); }
UPB_INLINE bool google_protobuf_MethodOptions_deprecated(const google_protobuf_MethodOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(16, 16), bool); }
UPB_INLINE bool google_protobuf_MethodOptions_has_idempotency_level(const google_protobuf_MethodOptions *msg) { return _upb_has_field(msg, 1); }
UPB_INLINE int32_t google_protobuf_MethodOptions_idempotency_level(const google_protobuf_MethodOptions *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)); }
UPB_INLINE int32_t google_protobuf_MethodOptions_idempotency_level(const google_protobuf_MethodOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t); }
UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_MethodOptions_uninterpreted_option(const google_protobuf_MethodOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(20, 24), len); }
UPB_INLINE void google_protobuf_MethodOptions_set_deprecated(google_protobuf_MethodOptions *msg, bool value) {
_upb_sethas(msg, 2);
UPB_FIELD_AT(msg, bool, UPB_SIZE(16, 16)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(16, 16), bool) = value;
}
UPB_INLINE void google_protobuf_MethodOptions_set_idempotency_level(google_protobuf_MethodOptions *msg, int32_t value) {
_upb_sethas(msg, 1);
UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t) = value;
}
UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_MethodOptions_mutable_uninterpreted_option(google_protobuf_MethodOptions *msg, size_t *len) {
return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(20, 24), len);
@ -1436,17 +1436,17 @@ UPB_INLINE char *google_protobuf_UninterpretedOption_serialize(const google_prot
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); }
UPB_INLINE bool google_protobuf_UninterpretedOption_has_identifier_value(const google_protobuf_UninterpretedOption *msg) { return _upb_has_field(msg, 4); }
UPB_INLINE upb_strview google_protobuf_UninterpretedOption_identifier_value(const google_protobuf_UninterpretedOption *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(32, 32)); }
UPB_INLINE upb_strview google_protobuf_UninterpretedOption_identifier_value(const google_protobuf_UninterpretedOption *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(32, 32), upb_strview); }
UPB_INLINE bool google_protobuf_UninterpretedOption_has_positive_int_value(const google_protobuf_UninterpretedOption *msg) { return _upb_has_field(msg, 1); }
UPB_INLINE uint64_t google_protobuf_UninterpretedOption_positive_int_value(const google_protobuf_UninterpretedOption *msg) { return UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(8, 8)); }
UPB_INLINE uint64_t google_protobuf_UninterpretedOption_positive_int_value(const google_protobuf_UninterpretedOption *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(8, 8), uint64_t); }
UPB_INLINE bool google_protobuf_UninterpretedOption_has_negative_int_value(const google_protobuf_UninterpretedOption *msg) { return _upb_has_field(msg, 2); }
UPB_INLINE int64_t google_protobuf_UninterpretedOption_negative_int_value(const google_protobuf_UninterpretedOption *msg) { return UPB_FIELD_AT(msg, int64_t, UPB_SIZE(16, 16)); }
UPB_INLINE int64_t google_protobuf_UninterpretedOption_negative_int_value(const google_protobuf_UninterpretedOption *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(16, 16), int64_t); }
UPB_INLINE bool google_protobuf_UninterpretedOption_has_double_value(const google_protobuf_UninterpretedOption *msg) { return _upb_has_field(msg, 3); }
UPB_INLINE double google_protobuf_UninterpretedOption_double_value(const google_protobuf_UninterpretedOption *msg) { return UPB_FIELD_AT(msg, double, UPB_SIZE(24, 24)); }
UPB_INLINE double google_protobuf_UninterpretedOption_double_value(const google_protobuf_UninterpretedOption *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(24, 24), double); }
UPB_INLINE bool google_protobuf_UninterpretedOption_has_string_value(const google_protobuf_UninterpretedOption *msg) { return _upb_has_field(msg, 5); }
UPB_INLINE upb_strview google_protobuf_UninterpretedOption_string_value(const google_protobuf_UninterpretedOption *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(40, 48)); }
UPB_INLINE upb_strview google_protobuf_UninterpretedOption_string_value(const google_protobuf_UninterpretedOption *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(40, 48), upb_strview); }
UPB_INLINE bool google_protobuf_UninterpretedOption_has_aggregate_value(const google_protobuf_UninterpretedOption *msg) { return _upb_has_field(msg, 6); }
UPB_INLINE upb_strview google_protobuf_UninterpretedOption_aggregate_value(const google_protobuf_UninterpretedOption *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(48, 64)); }
UPB_INLINE upb_strview google_protobuf_UninterpretedOption_aggregate_value(const google_protobuf_UninterpretedOption *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(48, 64), upb_strview); }
UPB_INLINE google_protobuf_UninterpretedOption_NamePart** google_protobuf_UninterpretedOption_mutable_name(google_protobuf_UninterpretedOption *msg, size_t *len) {
return (google_protobuf_UninterpretedOption_NamePart**)_upb_array_mutable_accessor(msg, UPB_SIZE(56, 80), len);
@ -1463,27 +1463,27 @@ UPB_INLINE struct google_protobuf_UninterpretedOption_NamePart* google_protobuf_
}
UPB_INLINE void google_protobuf_UninterpretedOption_set_identifier_value(google_protobuf_UninterpretedOption *msg, upb_strview value) {
_upb_sethas(msg, 4);
UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(32, 32)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(32, 32), upb_strview) = value;
}
UPB_INLINE void google_protobuf_UninterpretedOption_set_positive_int_value(google_protobuf_UninterpretedOption *msg, uint64_t value) {
_upb_sethas(msg, 1);
UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(8, 8)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(8, 8), uint64_t) = value;
}
UPB_INLINE void google_protobuf_UninterpretedOption_set_negative_int_value(google_protobuf_UninterpretedOption *msg, int64_t value) {
_upb_sethas(msg, 2);
UPB_FIELD_AT(msg, int64_t, UPB_SIZE(16, 16)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(16, 16), int64_t) = value;
}
UPB_INLINE void google_protobuf_UninterpretedOption_set_double_value(google_protobuf_UninterpretedOption *msg, double value) {
_upb_sethas(msg, 3);
UPB_FIELD_AT(msg, double, UPB_SIZE(24, 24)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(24, 24), double) = value;
}
UPB_INLINE void google_protobuf_UninterpretedOption_set_string_value(google_protobuf_UninterpretedOption *msg, upb_strview value) {
_upb_sethas(msg, 5);
UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(40, 48)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(40, 48), upb_strview) = value;
}
UPB_INLINE void google_protobuf_UninterpretedOption_set_aggregate_value(google_protobuf_UninterpretedOption *msg, upb_strview value) {
_upb_sethas(msg, 6);
UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(48, 64)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(48, 64), upb_strview) = value;
}
/* google.protobuf.UninterpretedOption.NamePart */
@ -1501,17 +1501,17 @@ UPB_INLINE char *google_protobuf_UninterpretedOption_NamePart_serialize(const go
}
UPB_INLINE bool google_protobuf_UninterpretedOption_NamePart_has_name_part(const google_protobuf_UninterpretedOption_NamePart *msg) { return _upb_has_field(msg, 2); }
UPB_INLINE upb_strview google_protobuf_UninterpretedOption_NamePart_name_part(const google_protobuf_UninterpretedOption_NamePart *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)); }
UPB_INLINE upb_strview google_protobuf_UninterpretedOption_NamePart_name_part(const google_protobuf_UninterpretedOption_NamePart *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview); }
UPB_INLINE bool google_protobuf_UninterpretedOption_NamePart_has_is_extension(const google_protobuf_UninterpretedOption_NamePart *msg) { return _upb_has_field(msg, 1); }
UPB_INLINE bool google_protobuf_UninterpretedOption_NamePart_is_extension(const google_protobuf_UninterpretedOption_NamePart *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)); }
UPB_INLINE bool google_protobuf_UninterpretedOption_NamePart_is_extension(const google_protobuf_UninterpretedOption_NamePart *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(1, 1), bool); }
UPB_INLINE void google_protobuf_UninterpretedOption_NamePart_set_name_part(google_protobuf_UninterpretedOption_NamePart *msg, upb_strview value) {
_upb_sethas(msg, 2);
UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview) = value;
}
UPB_INLINE void google_protobuf_UninterpretedOption_NamePart_set_is_extension(google_protobuf_UninterpretedOption_NamePart *msg, bool value) {
_upb_sethas(msg, 1);
UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(1, 1), bool) = value;
}
/* google.protobuf.SourceCodeInfo */
@ -1561,9 +1561,9 @@ UPB_INLINE char *google_protobuf_SourceCodeInfo_Location_serialize(const google_
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); }
UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_has_leading_comments(const google_protobuf_SourceCodeInfo_Location *msg) { return _upb_has_field(msg, 1); }
UPB_INLINE upb_strview google_protobuf_SourceCodeInfo_Location_leading_comments(const google_protobuf_SourceCodeInfo_Location *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)); }
UPB_INLINE upb_strview google_protobuf_SourceCodeInfo_Location_leading_comments(const google_protobuf_SourceCodeInfo_Location *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview); }
UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_has_trailing_comments(const google_protobuf_SourceCodeInfo_Location *msg) { return _upb_has_field(msg, 2); }
UPB_INLINE upb_strview google_protobuf_SourceCodeInfo_Location_trailing_comments(const google_protobuf_SourceCodeInfo_Location *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(12, 24)); }
UPB_INLINE upb_strview google_protobuf_SourceCodeInfo_Location_trailing_comments(const google_protobuf_SourceCodeInfo_Location *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(12, 24), upb_strview); }
UPB_INLINE upb_strview const* google_protobuf_SourceCodeInfo_Location_leading_detached_comments(const google_protobuf_SourceCodeInfo_Location *msg, size_t *len) { return (upb_strview const*)_upb_array_accessor(msg, UPB_SIZE(28, 56), len); }
UPB_INLINE int32_t* google_protobuf_SourceCodeInfo_Location_mutable_path(google_protobuf_SourceCodeInfo_Location *msg, size_t *len) {
@ -1588,11 +1588,11 @@ UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_add_span(google_protobuf
}
UPB_INLINE void google_protobuf_SourceCodeInfo_Location_set_leading_comments(google_protobuf_SourceCodeInfo_Location *msg, upb_strview value) {
_upb_sethas(msg, 1);
UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview) = value;
}
UPB_INLINE void google_protobuf_SourceCodeInfo_Location_set_trailing_comments(google_protobuf_SourceCodeInfo_Location *msg, upb_strview value) {
_upb_sethas(msg, 2);
UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(12, 24)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(12, 24), upb_strview) = value;
}
UPB_INLINE upb_strview* google_protobuf_SourceCodeInfo_Location_mutable_leading_detached_comments(google_protobuf_SourceCodeInfo_Location *msg, size_t *len) {
return (upb_strview*)_upb_array_mutable_accessor(msg, UPB_SIZE(28, 56), len);
@ -1651,11 +1651,11 @@ UPB_INLINE char *google_protobuf_GeneratedCodeInfo_Annotation_serialize(const go
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_has_field(msg, 3); }
UPB_INLINE upb_strview google_protobuf_GeneratedCodeInfo_Annotation_source_file(const google_protobuf_GeneratedCodeInfo_Annotation *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(12, 16)); }
UPB_INLINE upb_strview google_protobuf_GeneratedCodeInfo_Annotation_source_file(const google_protobuf_GeneratedCodeInfo_Annotation *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(12, 16), upb_strview); }
UPB_INLINE bool google_protobuf_GeneratedCodeInfo_Annotation_has_begin(const google_protobuf_GeneratedCodeInfo_Annotation *msg) { return _upb_has_field(msg, 1); }
UPB_INLINE int32_t google_protobuf_GeneratedCodeInfo_Annotation_begin(const google_protobuf_GeneratedCodeInfo_Annotation *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(4, 4)); }
UPB_INLINE int32_t google_protobuf_GeneratedCodeInfo_Annotation_begin(const google_protobuf_GeneratedCodeInfo_Annotation *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 4), int32_t); }
UPB_INLINE bool google_protobuf_GeneratedCodeInfo_Annotation_has_end(const google_protobuf_GeneratedCodeInfo_Annotation *msg) { return _upb_has_field(msg, 2); }
UPB_INLINE int32_t google_protobuf_GeneratedCodeInfo_Annotation_end(const google_protobuf_GeneratedCodeInfo_Annotation *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)); }
UPB_INLINE int32_t google_protobuf_GeneratedCodeInfo_Annotation_end(const google_protobuf_GeneratedCodeInfo_Annotation *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t); }
UPB_INLINE int32_t* google_protobuf_GeneratedCodeInfo_Annotation_mutable_path(google_protobuf_GeneratedCodeInfo_Annotation *msg, size_t *len) {
return (int32_t*)_upb_array_mutable_accessor(msg, UPB_SIZE(20, 32), len);
@ -1669,15 +1669,15 @@ UPB_INLINE bool google_protobuf_GeneratedCodeInfo_Annotation_add_path(google_pro
}
UPB_INLINE void google_protobuf_GeneratedCodeInfo_Annotation_set_source_file(google_protobuf_GeneratedCodeInfo_Annotation *msg, upb_strview value) {
_upb_sethas(msg, 3);
UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(12, 16)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(12, 16), upb_strview) = value;
}
UPB_INLINE void google_protobuf_GeneratedCodeInfo_Annotation_set_begin(google_protobuf_GeneratedCodeInfo_Annotation *msg, int32_t value) {
_upb_sethas(msg, 1);
UPB_FIELD_AT(msg, int32_t, UPB_SIZE(4, 4)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(4, 4), int32_t) = value;
}
UPB_INLINE void google_protobuf_GeneratedCodeInfo_Annotation_set_end(google_protobuf_GeneratedCodeInfo_Annotation *msg, int32_t value) {
_upb_sethas(msg, 2);
UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)) = value;
*UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t) = value;
}
#ifdef __cplusplus

@ -19,6 +19,8 @@
#include "upb/json_encode.h"
#include "upb/text_encode.h"
#include "upb/port_def.inc"
int test_count = 0;
bool verbose = false; /* Set to true to get req/resp printed on stderr. */
@ -94,7 +96,7 @@ void serialize_text(const upb_msg *msg, const upb_msgdef *m, const ctx *c) {
len = upb_text_encode(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);
assert(len == len2);
UPB_ASSERT(len == len2);
conformance_ConformanceResponse_set_text_payload(
c->response, upb_strview_make(data, len));
}
@ -149,7 +151,7 @@ void serialize_json(const upb_msg *msg, const upb_msgdef *m, const ctx *c) {
data = upb_arena_malloc(c->arena, len + 1);
len2 = upb_json_encode(msg, m, c->symtab, opts, data, len + 1, &status);
assert(len == len2);
UPB_ASSERT(len == len2);
conformance_ConformanceResponse_set_json_payload(
c->response, upb_strview_make(data, len));
}

@ -123,6 +123,11 @@ static void test_string_double_map() {
double val;
upb_test_MapTest_map_string_double_set(msg, test_str_view, 1.5, arena);
ASSERT(msg);
ASSERT(upb_test_MapTest_map_string_double_get(msg, test_str_view, &val));
ASSERT(val == 1.5);
val = 0;
serialized.data = upb_test_MapTest_serialize(msg, arena, &serialized.size);
ASSERT(serialized.data);

@ -1,7 +1,9 @@
#include <setjmp.h>
#include <string.h>
#include "upb/upb.h"
#include "upb/decode.h"
#include "upb/upb.h"
#include "upb/port_def.inc"
@ -51,566 +53,488 @@ static const uint8_t desctype_to_mapsize[] = {
8, /* SINT64 */
};
static const unsigned fixed32_ok = (1 << UPB_DTYPE_FLOAT) |
(1 << UPB_DTYPE_FIXED32) |
(1 << UPB_DTYPE_SFIXED32);
static const unsigned fixed64_ok = (1 << UPB_DTYPE_DOUBLE) |
(1 << UPB_DTYPE_FIXED64) |
(1 << UPB_DTYPE_SFIXED64);
/* Op: an action to be performed for a wire-type/field-type combination. */
#define OP_SCALAR_LG2(n) (n)
#define OP_FIXPCK_LG2(n) (n + 4)
#define OP_VARPCK_LG2(n) (n + 8)
#define OP_STRING 4
#define OP_SUBMSG 5
static const int8_t varint_ops[19] = {
-1, /* field not found */
-1, /* DOUBLE */
-1, /* FLOAT */
OP_SCALAR_LG2(3), /* INT64 */
OP_SCALAR_LG2(3), /* UINT64 */
OP_SCALAR_LG2(2), /* INT32 */
-1, /* FIXED64 */
-1, /* FIXED32 */
OP_SCALAR_LG2(0), /* BOOL */
-1, /* STRING */
-1, /* GROUP */
-1, /* MESSAGE */
-1, /* BYTES */
OP_SCALAR_LG2(2), /* UINT32 */
OP_SCALAR_LG2(2), /* ENUM */
-1, /* SFIXED32 */
-1, /* SFIXED64 */
OP_SCALAR_LG2(2), /* SINT32 */
OP_SCALAR_LG2(3), /* SINT64 */
};
static const int8_t delim_ops[37] = {
/* For non-repeated field type. */
-1, /* field not found */
-1, /* DOUBLE */
-1, /* FLOAT */
-1, /* INT64 */
-1, /* UINT64 */
-1, /* INT32 */
-1, /* FIXED64 */
-1, /* FIXED32 */
-1, /* BOOL */
OP_STRING, /* STRING */
-1, /* GROUP */
OP_SUBMSG, /* MESSAGE */
OP_STRING, /* BYTES */
-1, /* UINT32 */
-1, /* ENUM */
-1, /* SFIXED32 */
-1, /* SFIXED64 */
-1, /* SINT32 */
-1, /* SINT64 */
/* For repeated field type. */
OP_FIXPCK_LG2(3), /* REPEATED DOUBLE */
OP_FIXPCK_LG2(2), /* REPEATED FLOAT */
OP_VARPCK_LG2(3), /* REPEATED INT64 */
OP_VARPCK_LG2(3), /* REPEATED UINT64 */
OP_VARPCK_LG2(2), /* REPEATED INT32 */
OP_FIXPCK_LG2(3), /* REPEATED FIXED64 */
OP_FIXPCK_LG2(2), /* REPEATED FIXED32 */
OP_VARPCK_LG2(0), /* REPEATED BOOL */
OP_STRING, /* REPEATED STRING */
OP_SUBMSG, /* REPEATED GROUP */
OP_SUBMSG, /* REPEATED MESSAGE */
OP_STRING, /* REPEATED BYTES */
OP_VARPCK_LG2(2), /* REPEATED UINT32 */
OP_VARPCK_LG2(2), /* REPEATED ENUM */
OP_FIXPCK_LG2(2), /* REPEATED SFIXED32 */
OP_FIXPCK_LG2(3), /* REPEATED SFIXED64 */
OP_VARPCK_LG2(2), /* REPEATED SINT32 */
OP_VARPCK_LG2(3), /* REPEATED SINT64 */
};
/* Data pertaining to the parse. */
typedef struct {
const char *field_start; /* Start of this field. */
const char *limit; /* End of delimited region or end of buffer. */
upb_arena *arena;
int depth;
uint32_t end_group; /* Set to field number of END_GROUP tag, if any. */
jmp_buf err;
} upb_decstate;
#define CHK(x) if (!(x)) { return 0; }
#define PTR_AT(msg, ofs, type) (type*)((const char*)msg + ofs)
typedef union {
bool bool_val;
int32_t int32_val;
int64_t int64_val;
uint32_t uint32_val;
uint64_t uint64_val;
upb_strview str_val;
} wireval;
static const char *upb_decode_message(const char *ptr, const upb_msglayout *l,
upb_msg *msg, upb_decstate *d);
static const char *decode_msg(upb_decstate *d, const char *ptr, upb_msg *msg,
const upb_msglayout *layout);
static const char *upb_decode_varint(const char *ptr, const char *limit,
uint64_t *val) {
UPB_NORETURN static void decode_err(upb_decstate *d) { longjmp(d->err, 1); }
static bool decode_reserve(upb_decstate *d, upb_array *arr, int elem) {
bool need_realloc = arr->size - arr->len < elem;
if (need_realloc && !_upb_array_realloc(arr, arr->len + elem, d->arena)) {
decode_err(d);
}
return need_realloc;
}
UPB_NOINLINE
static const char *decode_longvarint64(upb_decstate *d, const char *ptr,
const char *limit, uint64_t *val) {
uint8_t byte;
int bitpos = 0;
*val = 0;
uint64_t out = 0;
do {
CHK(bitpos < 70 && ptr < limit);
if (bitpos >= 70 || ptr == limit) decode_err(d);
byte = *ptr;
*val |= (uint64_t)(byte & 0x7F) << bitpos;
out |= (uint64_t)(byte & 0x7F) << bitpos;
ptr++;
bitpos += 7;
} while (byte & 0x80);
*val = out;
return ptr;
}
static const char *upb_decode_varint32(const char *ptr, const char *limit,
uint32_t *val) {
UPB_FORCEINLINE
static const char *decode_varint64(upb_decstate *d, const char *ptr,
const char *limit, uint64_t *val) {
if (UPB_LIKELY(ptr < limit && (*ptr & 0x80) == 0)) {
*val = (uint8_t)*ptr;
return ptr + 1;
} else {
return decode_longvarint64(d, ptr, limit, val);
}
}
static const char *decode_varint32(upb_decstate *d, const char *ptr,
const char *limit, uint32_t *val) {
uint64_t u64;
CHK(ptr = upb_decode_varint(ptr, limit, &u64))
CHK(u64 <= UINT32_MAX);
ptr = decode_varint64(d, ptr, limit, &u64);
if (u64 > UINT32_MAX) decode_err(d);
*val = (uint32_t)u64;
return ptr;
}
static const char *upb_decode_64bit(const char *ptr, const char *limit,
uint64_t *val) {
CHK(limit - ptr >= 8);
memcpy(val, ptr, 8);
return ptr + 8;
static void decode_munge(int type, wireval *val) {
switch (type) {
case UPB_DESCRIPTOR_TYPE_BOOL:
val->bool_val = val->uint64_val != 0;
break;
case UPB_DESCRIPTOR_TYPE_SINT32: {
uint32_t n = val->uint32_val;
val->int32_val = (n >> 1) ^ -(int32_t)(n & 1);
break;
}
static const char *upb_decode_32bit(const char *ptr, const char *limit,
uint32_t *val) {
CHK(limit - ptr >= 4);
memcpy(val, ptr, 4);
return ptr + 4;
case UPB_DESCRIPTOR_TYPE_SINT64: {
uint64_t n = val->uint64_val;
val->int64_val = (n >> 1) ^ -(int64_t)(n & 1);
break;
}
static int32_t upb_zzdecode_32(uint32_t n) {
return (n >> 1) ^ -(int32_t)(n & 1);
}
static int64_t upb_zzdecode_64(uint64_t n) {
return (n >> 1) ^ -(int64_t)(n & 1);
}
static const char *upb_decode_string(const char *ptr, const char *limit,
int *outlen) {
uint32_t len;
CHK(ptr = upb_decode_varint32(ptr, limit, &len));
CHK(len < INT32_MAX);
CHK(limit - ptr >= (int32_t)len);
static const upb_msglayout_field *upb_find_field(const upb_msglayout *l,
uint32_t field_number) {
static upb_msglayout_field none = {0};
*outlen = len;
return ptr;
/* Lots of optimization opportunities here. */
int i;
if (l == NULL) return &none;
for (i = 0; i < l->field_count; i++) {
if (l->fields[i].number == field_number) {
return &l->fields[i];
}
static void upb_set32(void *msg, size_t ofs, uint32_t val) {
memcpy((char*)msg + ofs, &val, sizeof(val));
}
static const char *upb_append_unknown(const char *ptr, upb_msg *msg,
upb_decstate *d) {
upb_msg_addunknown(msg, d->field_start, ptr - d->field_start, d->arena);
return ptr;
return &none; /* Unknown field. */
}
static const char *upb_skip_unknownfielddata(const char *ptr, upb_decstate *d,
uint32_t tag) {
switch (tag & 7) {
case UPB_WIRE_TYPE_VARINT: {
uint64_t val;
return upb_decode_varint(ptr, d->limit, &val);
}
case UPB_WIRE_TYPE_32BIT: {
uint32_t val;
return upb_decode_32bit(ptr, d->limit, &val);
}
case UPB_WIRE_TYPE_64BIT: {
uint64_t val;
return upb_decode_64bit(ptr, d->limit, &val);
}
case UPB_WIRE_TYPE_DELIMITED: {
int len;
CHK(ptr = upb_decode_string(ptr, d->limit, &len));
return ptr + len;
}
case UPB_WIRE_TYPE_START_GROUP: {
uint32_t field_number = tag >> 3;
while (ptr < d->limit && d->end_group == 0) {
uint32_t tag = 0;
CHK(ptr = upb_decode_varint32(ptr, d->limit, &tag));
CHK(ptr = upb_skip_unknownfielddata(ptr, d, tag));
}
CHK(d->end_group == field_number);
d->end_group = 0;
return ptr;
}
case UPB_WIRE_TYPE_END_GROUP:
d->end_group = tag >> 3;
return ptr;
}
return false;
static upb_msg *decode_newsubmsg(upb_decstate *d, const upb_msglayout *layout,
const upb_msglayout_field *field) {
const upb_msglayout *subl = layout->submsgs[field->submsg_index];
return _upb_msg_new(subl, d->arena);
}
static void *upb_array_reserve(upb_array *arr, size_t elements,
size_t elem_size, upb_arena *arena) {
if (arr->size - arr->len < elements) {
CHK(_upb_array_realloc(arr, arr->len + elements, arena));
}
return (char*)_upb_array_ptr(arr) + (arr->len * elem_size);
static void decode_tosubmsg(upb_decstate *d, upb_msg *submsg,
const upb_msglayout *layout,
const upb_msglayout_field *field, upb_strview val) {
const upb_msglayout *subl = layout->submsgs[field->submsg_index];
const char *saved_limit = d->limit;
if (--d->depth < 0) decode_err(d);
d->limit = val.data + val.size;
decode_msg(d, val.data, submsg, subl);
d->limit = saved_limit;
if (d->end_group != 0) decode_err(d);
d->depth++;
}
bool upb_array_add(upb_array *arr, size_t elements, size_t elem_size,
const void *data, upb_arena *arena) {
void *dest = upb_array_reserve(arr, elements, elem_size, arena);
CHK(dest);
arr->len += elements;
memcpy(dest, data, elements * elem_size);
return true;
static const char *decode_group(upb_decstate *d, const char *ptr,
upb_msg *submsg, const upb_msglayout *subl,
uint32_t number) {
if (--d->depth < 0) decode_err(d);
ptr = decode_msg(d, ptr, submsg, subl);
if (d->end_group != number) decode_err(d);
d->end_group = 0;
d->depth++;
return ptr;
}
static upb_array *upb_getarr(upb_msg *msg, const upb_msglayout_field *field) {
UPB_ASSERT(field->label == UPB_LABEL_REPEATED);
return *PTR_AT(msg, field->offset, upb_array*);
static const char *decode_togroup(upb_decstate *d, const char *ptr,
upb_msg *submsg, const upb_msglayout *layout,
const upb_msglayout_field *field) {
const upb_msglayout *subl = layout->submsgs[field->submsg_index];
return decode_group(d, ptr, submsg, subl, field->number);
}
static upb_array *upb_getorcreatearr(upb_msg *msg,
const upb_msglayout_field *field,
upb_decstate *d) {
upb_array *arr = upb_getarr(msg, field);
static const char *decode_toarray(upb_decstate *d, const char *ptr,
upb_msg *msg, const upb_msglayout *layout,
const upb_msglayout_field *field, wireval val,
int op) {
upb_array **arrp = UPB_PTR_AT(msg, field->offset, void);
upb_array *arr = *arrp;
void *mem;
if (!arr) {
upb_fieldtype_t type = desctype_to_fieldtype[field->descriptortype];
arr = _upb_array_new(d->arena, type);
CHK(arr);
*PTR_AT(msg, field->offset, upb_array*) = arr;
}
return arr;
}
static upb_msg *upb_getorcreatemsg(upb_msg *msg,
const upb_msglayout_field *field,
const upb_msglayout *layout,
upb_decstate *d) {
upb_msg **submsg = PTR_AT(msg, field->offset, upb_msg*);
UPB_ASSERT(field->label != UPB_LABEL_REPEATED);
if (!*submsg) {
*submsg = _upb_msg_new(layout, d->arena);
CHK(*submsg);
}
return *submsg;
}
static upb_msg *upb_addmsg(upb_msg *msg,
const upb_msglayout_field *field,
const upb_msglayout *layout,
upb_decstate *d) {
upb_msg *submsg;
upb_array *arr = upb_getorcreatearr(msg, field, d);
UPB_ASSERT(field->label == UPB_LABEL_REPEATED);
UPB_ASSERT(field->descriptortype == UPB_DESCRIPTOR_TYPE_MESSAGE ||
field->descriptortype == UPB_DESCRIPTOR_TYPE_GROUP);
submsg = _upb_msg_new(layout, d->arena);
CHK(submsg);
upb_array_add(arr, 1, sizeof(submsg), &submsg, d->arena);
return submsg;
}
static void upb_sethasbit(upb_msg *msg, const upb_msglayout_field *field) {
int32_t hasbit = field->presence;
UPB_ASSERT(field->presence > 0);
*PTR_AT(msg, hasbit / 8, char) |= (1 << (hasbit % 8));
}
static void upb_setoneofcase(upb_msg *msg, const upb_msglayout_field *field) {
UPB_ASSERT(field->presence < 0);
upb_set32(msg, ~field->presence, field->number);
if (!arr) decode_err(d);
*arrp = arr;
}
static bool upb_decode_addval(upb_msg *msg, const upb_msglayout_field *field,
void *val, size_t size, upb_decstate *d) {
char *field_mem = PTR_AT(msg, field->offset, char);
upb_array *arr;
decode_reserve(d, arr, 1);
if (field->label == UPB_LABEL_REPEATED) {
arr = upb_getorcreatearr(msg, field, d);
CHK(arr);
field_mem = upb_array_reserve(arr, 1, size, d->arena);
CHK(field_mem);
}
memcpy(field_mem, val, size);
return true;
}
static void upb_decode_setpresent(upb_msg *msg,
const upb_msglayout_field *field) {
if (field->label == UPB_LABEL_REPEATED) {
upb_array *arr = upb_getarr(msg, field);
UPB_ASSERT(arr->len < arr->size);
switch (op) {
case OP_SCALAR_LG2(0):
case OP_SCALAR_LG2(2):
case OP_SCALAR_LG2(3):
/* Append scalar value. */
mem = UPB_PTR_AT(_upb_array_ptr(arr), arr->len << op, void);
arr->len++;
} else if (field->presence < 0) {
upb_setoneofcase(msg, field);
} else if (field->presence > 0) {
upb_sethasbit(msg, field);
}
}
static const char *upb_decode_msgfield(const char *ptr,
const upb_msglayout *layout, int limit,
upb_msg *msg, upb_decstate *d) {
const char* saved_limit = d->limit;
d->limit = ptr + limit;
CHK(--d->depth >= 0);
ptr = upb_decode_message(ptr, layout, msg, d);
d->depth++;
d->limit = saved_limit;
CHK(d->end_group == 0);
return ptr;
}
static const char *upb_decode_groupfield(const char *ptr,
const upb_msglayout *layout,
int field_number, upb_msg *msg,
upb_decstate *d) {
CHK(--d->depth >= 0);
ptr = upb_decode_message(ptr, layout, msg, d);
d->depth++;
CHK(d->end_group == field_number);
d->end_group = 0;
memcpy(mem, &val, 1 << op);
return ptr;
}
static const char *upb_decode_varintfield(const char *ptr, upb_msg *msg,
const upb_msglayout_field *field,
upb_decstate *d) {
uint64_t val;
CHK(ptr = upb_decode_varint(ptr, d->limit, &val));
switch (field->descriptortype) {
case UPB_DESCRIPTOR_TYPE_INT64:
case UPB_DESCRIPTOR_TYPE_UINT64:
CHK(upb_decode_addval(msg, field, &val, sizeof(val), d));
break;
case UPB_DESCRIPTOR_TYPE_INT32:
case UPB_DESCRIPTOR_TYPE_UINT32:
case UPB_DESCRIPTOR_TYPE_ENUM: {
uint32_t val32 = (uint32_t)val;
CHK(upb_decode_addval(msg, field, &val32, sizeof(val32), d));
break;
}
case UPB_DESCRIPTOR_TYPE_BOOL: {
bool valbool = val != 0;
CHK(upb_decode_addval(msg, field, &valbool, sizeof(valbool), d));
break;
}
case UPB_DESCRIPTOR_TYPE_SINT32: {
int32_t decoded = upb_zzdecode_32((uint32_t)val);
CHK(upb_decode_addval(msg, field, &decoded, sizeof(decoded), d));
break;
}
case UPB_DESCRIPTOR_TYPE_SINT64: {
int64_t decoded = upb_zzdecode_64(val);
CHK(upb_decode_addval(msg, field, &decoded, sizeof(decoded), d));
break;
}
default:
return upb_append_unknown(ptr, msg, d);
}
upb_decode_setpresent(msg, field);
case OP_STRING:
/* Append string. */
mem =
UPB_PTR_AT(_upb_array_ptr(arr), arr->len * sizeof(upb_strview), void);
arr->len++;
memcpy(mem, &val, sizeof(upb_strview));
return ptr;
case OP_SUBMSG: {
/* Append submessage / group. */
upb_msg *submsg = decode_newsubmsg(d, layout, field);
*UPB_PTR_AT(_upb_array_ptr(arr), arr->len * sizeof(void *), upb_msg *) =
submsg;
arr->len++;
if (UPB_UNLIKELY(field->descriptortype == UPB_DTYPE_GROUP)) {
ptr = decode_togroup(d, ptr, submsg, layout, field);
} else {
decode_tosubmsg(d, submsg, layout, field, val.str_val);
}
static const char *upb_decode_64bitfield(const char *ptr,
const upb_msglayout_field *field,
upb_msg *msg, upb_decstate *d) {
uint64_t val;
CHK(ptr = upb_decode_64bit(ptr, d->limit, &val));
switch (field->descriptortype) {
case UPB_DESCRIPTOR_TYPE_DOUBLE:
case UPB_DESCRIPTOR_TYPE_FIXED64:
case UPB_DESCRIPTOR_TYPE_SFIXED64:
CHK(upb_decode_addval(msg, field, &val, sizeof(val), d));
break;
default:
return upb_append_unknown(ptr, msg, d);
}
upb_decode_setpresent(msg, field);
return ptr;
}
static const char *upb_decode_32bitfield(const char *ptr,
const upb_msglayout_field *field,
upb_msg *msg, upb_decstate *d) {
uint32_t val;
CHK(ptr = upb_decode_32bit(ptr, d->limit, &val));
switch (field->descriptortype) {
case UPB_DESCRIPTOR_TYPE_FLOAT:
case UPB_DESCRIPTOR_TYPE_FIXED32:
case UPB_DESCRIPTOR_TYPE_SFIXED32:
CHK(upb_decode_addval(msg, field, &val, sizeof(val), d));
break;
default:
return upb_append_unknown(ptr, msg, d);
}
upb_decode_setpresent(msg, field);
case OP_FIXPCK_LG2(2):
case OP_FIXPCK_LG2(3): {
/* Fixed packed. */
int lg2 = op - OP_FIXPCK_LG2(0);
int mask = (1 << lg2) - 1;
int count = val.str_val.size >> lg2;
if ((val.str_val.size & mask) != 0) {
decode_err(d); /* Length isn't a round multiple of elem size. */
}
decode_reserve(d, arr, count);
mem = UPB_PTR_AT(_upb_array_ptr(arr), arr->len << lg2, void);
arr->len += count;
memcpy(mem, val.str_val.data, count << op);
return ptr;
}
static const char *upb_decode_fixedpacked(const char *ptr, upb_decstate *d,
upb_array *arr, uint32_t len,
int elem_size) {
size_t elements = len / elem_size;
CHK((size_t)(elements * elem_size) == len);
CHK(upb_array_add(arr, elements, elem_size, ptr, d->arena));
return ptr + len;
case OP_VARPCK_LG2(0):
case OP_VARPCK_LG2(2):
case OP_VARPCK_LG2(3): {
/* Varint packed. */
int lg2 = op - OP_VARPCK_LG2(0);
int scale = 1 << lg2;
const char *ptr = val.str_val.data;
const char *end = ptr + val.str_val.size;
char *out = UPB_PTR_AT(_upb_array_ptr(arr), arr->len << lg2, void);
while (ptr < end) {
wireval elem;
ptr = decode_varint64(d, ptr, end, &elem.uint64_val);
decode_munge(field->descriptortype, &elem);
if (decode_reserve(d, arr, 1)) {
out = UPB_PTR_AT(_upb_array_ptr(arr), arr->len << lg2, void);
}
static const char *upb_decode_strfield(const char *ptr, upb_decstate *d,
uint32_t len, upb_strview *str) {
str->data = ptr;
str->size = len;
return ptr + len;
arr->len++;
memcpy(out, &elem, scale);
out += scale;
}
static const char *upb_decode_toarray(const char *ptr,
const upb_msglayout *layout,
const upb_msglayout_field *field, int len,
upb_msg *msg, upb_decstate *d) {
upb_array *arr = upb_getorcreatearr(msg, field, d);
CHK(arr);
#define VARINT_CASE(ctype, decode) \
VARINT_CASE_EX(ctype, decode, decode)
#define VARINT_CASE_EX(ctype, decode, dtype) \
{ \
const char *limit = ptr + len; \
while (ptr < limit) { \
uint64_t val; \
ctype decoded; \
CHK(ptr = upb_decode_varint(ptr, limit, &val)); \
decoded = (decode)((dtype)val); \
CHK(upb_array_add(arr, 1, sizeof(decoded), &decoded, d->arena)); \
} \
return ptr; \
}
switch (field->descriptortype) {
case UPB_DESCRIPTOR_TYPE_STRING:
case UPB_DESCRIPTOR_TYPE_BYTES: {
upb_strview str;
ptr = upb_decode_strfield(ptr, d, len, &str);
CHK(upb_array_add(arr, 1, sizeof(str), &str, d->arena));
if (ptr != end) decode_err(d);
return ptr;
}
case UPB_DESCRIPTOR_TYPE_FLOAT:
case UPB_DESCRIPTOR_TYPE_FIXED32:
case UPB_DESCRIPTOR_TYPE_SFIXED32:
return upb_decode_fixedpacked(ptr, d, arr, len, sizeof(int32_t));
case UPB_DESCRIPTOR_TYPE_DOUBLE:
case UPB_DESCRIPTOR_TYPE_FIXED64:
case UPB_DESCRIPTOR_TYPE_SFIXED64:
return upb_decode_fixedpacked(ptr, d, arr, len, sizeof(int64_t));
case UPB_DESCRIPTOR_TYPE_INT32:
case UPB_DESCRIPTOR_TYPE_UINT32:
case UPB_DESCRIPTOR_TYPE_ENUM:
VARINT_CASE(uint32_t, uint32_t);
case UPB_DESCRIPTOR_TYPE_INT64:
case UPB_DESCRIPTOR_TYPE_UINT64:
VARINT_CASE(uint64_t, uint64_t);
case UPB_DESCRIPTOR_TYPE_BOOL:
VARINT_CASE(bool, bool);
case UPB_DESCRIPTOR_TYPE_SINT32:
VARINT_CASE_EX(int32_t, upb_zzdecode_32, uint32_t);
case UPB_DESCRIPTOR_TYPE_SINT64:
VARINT_CASE_EX(int64_t, upb_zzdecode_64, uint64_t);
case UPB_DESCRIPTOR_TYPE_MESSAGE: {
const upb_msglayout *subl = layout->submsgs[field->submsg_index];
upb_msg *submsg = upb_addmsg(msg, field, subl, d);
CHK(submsg);
return upb_decode_msgfield(ptr, subl, len, submsg, d);
}
case UPB_DESCRIPTOR_TYPE_GROUP:
return upb_append_unknown(ptr, msg, d);
}
#undef VARINT_CASE
default:
UPB_UNREACHABLE();
}
}
static const char *upb_decode_mapfield(const char *ptr,
static void decode_tomap(upb_decstate *d, upb_msg *msg,
const upb_msglayout *layout,
const upb_msglayout_field *field,
int len, upb_msg *msg, upb_decstate *d) {
upb_map *map = *PTR_AT(msg, field->offset, upb_map*);
const upb_msglayout *entry = layout->submsgs[field->submsg_index];
const upb_msglayout_field *field, wireval val) {
upb_map **map_p = UPB_PTR_AT(msg, field->offset, upb_map *);
upb_map *map = *map_p;
upb_map_entry ent;
if (!map) {
/* Lazily create map. */
const upb_msglayout *entry = layout->submsgs[field->submsg_index];
const upb_msglayout_field *key_field = &entry->fields[0];
const upb_msglayout_field *val_field = &entry->fields[1];
char key_size = desctype_to_mapsize[key_field->descriptortype];
char val_size = desctype_to_mapsize[val_field->descriptortype];
UPB_ASSERT(key_field->number == 1);
UPB_ASSERT(val_field->number == 2);
UPB_ASSERT(key_field->offset == 0);
UPB_ASSERT(val_field->offset == sizeof(upb_strview));
map = _upb_map_new(d->arena, key_size, val_size);
*PTR_AT(msg, field->offset, upb_map*) = map;
*map_p = map;
}
/* Parse map entry. */
memset(&ent, 0, sizeof(ent));
CHK(ptr = upb_decode_msgfield(ptr, entry, len, &ent.k, d));
decode_tosubmsg(d, &ent.k, layout, field, val.str_val);
/* Insert into map. */
_upb_map_set(map, &ent.k, map->key_size, &ent.v, map->val_size, d->arena);
return ptr;
}
static const char *upb_decode_delimitedfield(const char *ptr,
static const char *decode_tomsg(upb_decstate *d, const char *ptr, upb_msg *msg,
const upb_msglayout *layout,
const upb_msglayout_field *field,
upb_msg *msg, upb_decstate *d) {
int len;
CHK(ptr = upb_decode_string(ptr, d->limit, &len));
if (field->label == UPB_LABEL_REPEATED) {
return upb_decode_toarray(ptr, layout, field, len, msg, d);
} else if (field->label == UPB_LABEL_MAP) {
return upb_decode_mapfield(ptr, layout, field, len, msg, d);
const upb_msglayout_field *field, wireval val,
int op) {
void *mem = UPB_PTR_AT(msg, field->offset, void);
int type = field->descriptortype;
/* Set presence if necessary. */
if (field->presence < 0) {
/* Oneof case */
*UPB_PTR_AT(msg, -field->presence, int32_t) = field->number;
} else if (field->presence > 0) {
/* Hasbit */
uint32_t hasbit = field->presence;
*UPB_PTR_AT(msg, hasbit / 8, uint8_t) |= (1 << (hasbit % 8));
}
/* Store into message. */
switch (op) {
case OP_SUBMSG: {
upb_msg **submsgp = mem;
upb_msg *submsg = *submsgp;
if (!submsg) {
submsg = decode_newsubmsg(d, layout, field);
*submsgp = submsg;
}
if (UPB_UNLIKELY(type == UPB_DTYPE_GROUP)) {
ptr = decode_togroup(d, ptr, submsg, layout, field);
} else {
switch (field->descriptortype) {
case UPB_DESCRIPTOR_TYPE_STRING:
case UPB_DESCRIPTOR_TYPE_BYTES: {
upb_strview str;
ptr = upb_decode_strfield(ptr, d, len, &str);
CHK(upb_decode_addval(msg, field, &str, sizeof(str), d));
break;
decode_tosubmsg(d, submsg, layout, field, val.str_val);
}
case UPB_DESCRIPTOR_TYPE_MESSAGE: {
const upb_msglayout *subl = layout->submsgs[field->submsg_index];
upb_msg *submsg = upb_getorcreatemsg(msg, field, subl, d);
CHK(submsg);
CHK(ptr = upb_decode_msgfield(ptr, subl, len, submsg, d));
break;
}
case OP_STRING:
memcpy(mem, &val, sizeof(upb_strview));
break;
case OP_SCALAR_LG2(3):
memcpy(mem, &val, 8);
break;
case OP_SCALAR_LG2(2):
memcpy(mem, &val, 4);
break;
case OP_SCALAR_LG2(0):
memcpy(mem, &val, 1);
break;
default:
/* TODO(haberman): should we accept the last element of a packed? */
return upb_append_unknown(ptr + len, msg, d);
}
upb_decode_setpresent(msg, field);
return ptr;
}
}
static const upb_msglayout_field *upb_find_field(const upb_msglayout *l,
uint32_t field_number) {
/* Lots of optimization opportunities here. */
int i;
for (i = 0; i < l->field_count; i++) {
if (l->fields[i].number == field_number) {
return &l->fields[i];
}
UPB_UNREACHABLE();
}
return NULL; /* Unknown field. */
return ptr;
}
static const char *upb_decode_field(const char *ptr,
const upb_msglayout *layout, upb_msg *msg,
upb_decstate *d) {
static const char *decode_msg(upb_decstate *d, const char *ptr, upb_msg *msg,
const upb_msglayout *layout) {
while (ptr < d->limit) {
uint32_t tag;
const upb_msglayout_field *field;
int field_number;
int wire_type;
const char *field_start = ptr;
wireval val;
int op;
d->field_start = ptr;
CHK(ptr = upb_decode_varint32(ptr, d->limit, &tag));
ptr = decode_varint32(d, ptr, d->limit, &tag);
field_number = tag >> 3;
wire_type = tag & 7;
field = upb_find_field(layout, field_number);
if (field) {
switch (tag & 7) {
switch (wire_type) {
case UPB_WIRE_TYPE_VARINT:
return upb_decode_varintfield(ptr, msg, field, d);
ptr = decode_varint64(d, ptr, d->limit, &val.uint64_val);
op = varint_ops[field->descriptortype];
decode_munge(field->descriptortype, &val);
break;
case UPB_WIRE_TYPE_32BIT:
return upb_decode_32bitfield(ptr, field, msg, d);
if (d->limit - ptr < 4) decode_err(d);
memcpy(&val, ptr, 4);
ptr += 4;
op = OP_SCALAR_LG2(2);
if (((1 << field->descriptortype) & fixed32_ok) == 0) goto unknown;
break;
case UPB_WIRE_TYPE_64BIT:
return upb_decode_64bitfield(ptr, field, msg, d);
case UPB_WIRE_TYPE_DELIMITED:
return upb_decode_delimitedfield(ptr, layout, field, msg, d);
case UPB_WIRE_TYPE_START_GROUP: {
const upb_msglayout *subl = layout->submsgs[field->submsg_index];
upb_msg *group;
if (field->label == UPB_LABEL_REPEATED) {
group = upb_addmsg(msg, field, subl, d);
} else {
group = upb_getorcreatemsg(msg, field, subl, d);
}
return upb_decode_groupfield(ptr, subl, field_number, group, d);
if (d->limit - ptr < 8) decode_err(d);
memcpy(&val, ptr, 8);
ptr += 8;
op = OP_SCALAR_LG2(3);
if (((1 << field->descriptortype) & fixed64_ok) == 0) goto unknown;
break;
case UPB_WIRE_TYPE_DELIMITED: {
uint32_t size;
int ndx = field->descriptortype;
if (field->label == UPB_LABEL_REPEATED) ndx += 18;
ptr = decode_varint32(d, ptr, d->limit, &size);
if (size >= INT32_MAX || (size_t)(d->limit - ptr) < size) {
decode_err(d); /* Length overflow. */
}
val.str_val.data = ptr;
val.str_val.size = size;
ptr += size;
op = delim_ops[ndx];
break;
}
case UPB_WIRE_TYPE_START_GROUP:
val.int32_val = field_number;
op = OP_SUBMSG;
if (field->descriptortype != UPB_DTYPE_GROUP) goto unknown;
break;
case UPB_WIRE_TYPE_END_GROUP:
d->end_group = field_number;
return ptr;
default:
CHK(false);
decode_err(d);
}
if (op >= 0) {
/* Parse, using op for dispatch. */
switch (field->label) {
case UPB_LABEL_REPEATED:
ptr = decode_toarray(d, ptr, msg, layout, field, val, op);
break;
case UPB_LABEL_MAP:
decode_tomap(d, msg, layout, field, val);
break;
default:
ptr = decode_tomsg(d, ptr, msg, layout, field, val, op);
break;
}
} else {
CHK(field_number != 0);
CHK(ptr = upb_skip_unknownfielddata(ptr, d, tag));
CHK(ptr = upb_append_unknown(ptr, msg, d));
return ptr;
unknown:
/* Skip unknown field. */
if (field_number == 0) decode_err(d);
if (wire_type == UPB_WIRE_TYPE_START_GROUP) {
ptr = decode_group(d, ptr, NULL, NULL, field_number);
}
if (msg) {
if (!_upb_msg_addunknown(msg, field_start, ptr - field_start,
d->arena)) {
decode_err(d);
}
}
UPB_UNREACHABLE();
}
static const char *upb_decode_message(const char *ptr, const upb_msglayout *l,
upb_msg *msg, upb_decstate *d) {
while (ptr < d->limit) {
CHK(ptr = upb_decode_field(ptr, l, msg, d));
}
if (ptr != d->limit) decode_err(d);
return ptr;
}
@ -622,12 +546,16 @@ bool upb_decode(const char *buf, size_t size, void *msg, const upb_msglayout *l,
state.depth = 64;
state.end_group = 0;
/* Early exit required for buf==NULL case. */
if (setjmp(state.err)) return false;
if (size == 0) return true;
decode_msg(&state, buf, msg, l);
CHK(upb_decode_message(buf, l, msg, &state));
return state.end_group == 0;
}
#undef CHK
#undef PTR_AT
#undef OP_SCALAR_LG2
#undef OP_FIXPCK_LG2
#undef OP_VARPCK_LG2
#undef OP_STRING
#undef OP_SUBMSG

@ -113,15 +113,14 @@ static bool upb_put_float(upb_encstate *e, float d) {
static uint32_t upb_readcase(const char *msg, const upb_msglayout_field *f) {
uint32_t ret;
uint32_t offset = ~f->presence;
memcpy(&ret, msg + offset, sizeof(ret));
memcpy(&ret, msg - f->presence, sizeof(ret));
return ret;
}
static bool upb_readhasbit(const char *msg, const upb_msglayout_field *f) {
uint32_t hasbit = f->presence;
UPB_ASSERT(f->presence > 0);
return msg[hasbit / 8] & (1 << (hasbit % 8));
return (*UPB_PTR_AT(msg, hasbit / 8, uint8_t)) & (1 << (hasbit % 8));
}
static bool upb_put_tag(upb_encstate *e, int field_number, int wire_type) {

@ -5,8 +5,6 @@
#include "upb/port_def.inc"
#define VOIDPTR_AT(msg, ofs) (void*)((char*)msg + (int)ofs)
/** upb_msg *******************************************************************/
static const char _upb_fieldtype_to_sizelg2[12] = {
@ -38,22 +36,22 @@ static size_t upb_msg_sizeof(const upb_msglayout *l) {
}
static upb_msg_internal *upb_msg_getinternal(upb_msg *msg) {
return VOIDPTR_AT(msg, -sizeof(upb_msg_internal));
return UPB_PTR_AT(msg, -sizeof(upb_msg_internal), upb_msg_internal);
}
static const upb_msg_internal *upb_msg_getinternal_const(const upb_msg *msg) {
return VOIDPTR_AT(msg, -sizeof(upb_msg_internal));
return UPB_PTR_AT(msg, -sizeof(upb_msg_internal), upb_msg_internal);
}
static upb_msg_internal_withext *upb_msg_getinternalwithext(
upb_msg *msg, const upb_msglayout *l) {
UPB_ASSERT(l->extendable);
return VOIDPTR_AT(msg, -sizeof(upb_msg_internal_withext));
return UPB_PTR_AT(msg, -sizeof(upb_msg_internal_withext),
upb_msg_internal_withext);
}
upb_msg *_upb_msg_new(const upb_msglayout *l, upb_arena *a) {
upb_alloc *alloc = upb_arena_alloc(a);
void *mem = upb_malloc(alloc, upb_msg_sizeof(l));
void *mem = upb_arena_malloc(a, upb_msg_sizeof(l));
upb_msg_internal *in;
upb_msg *msg;
@ -61,7 +59,7 @@ upb_msg *_upb_msg_new(const upb_msglayout *l, upb_arena *a) {
return NULL;
}
msg = VOIDPTR_AT(mem, upb_msg_internalsize(l));
msg = UPB_PTR_AT(mem, upb_msg_internalsize(l), upb_msg);
/* Initialize normal members. */
memset(msg, 0, l->size);
@ -79,18 +77,21 @@ upb_msg *_upb_msg_new(const upb_msglayout *l, upb_arena *a) {
return msg;
}
void upb_msg_addunknown(upb_msg *msg, const char *data, size_t len,
bool _upb_msg_addunknown(upb_msg *msg, const char *data, size_t len,
upb_arena *arena) {
upb_msg_internal *in = upb_msg_getinternal(msg);
if (len > in->unknown_size - in->unknown_len) {
upb_alloc *alloc = upb_arena_alloc(arena);
size_t need = in->unknown_size + len;
size_t newsize = UPB_MAX(in->unknown_size * 2, need);
in->unknown = upb_realloc(alloc, in->unknown, in->unknown_size, newsize);
void *mem = upb_realloc(alloc, in->unknown, in->unknown_size, newsize);
if (!mem) return false;
in->unknown = mem;
in->unknown_size = newsize;
}
memcpy(in->unknown + in->unknown_len, data, len);
in->unknown_len += len;
return true;
}
const char *upb_msg_getunknown(const upb_msg *msg, size_t *len) {
@ -192,5 +193,3 @@ upb_map *_upb_map_new(upb_arena *a, size_t key_size, size_t value_size) {
return map;
}
#undef VOIDPTR_AT

@ -39,7 +39,7 @@ enum {
typedef struct {
uint32_t number;
uint16_t offset;
int16_t presence; /* If >0, hasbit_index+1. If <0, oneof_index+1. */
int16_t presence; /* If >0, hasbit_index. If <0, -oneof_index. */
uint16_t submsg_index; /* undefined if descriptortype != MESSAGE or GROUP. */
uint8_t descriptortype;
uint8_t label;
@ -82,7 +82,7 @@ upb_msg *_upb_msg_new(const upb_msglayout *l, upb_arena *a);
/* 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,
bool _upb_msg_addunknown(upb_msg *msg, const char *data, size_t len,
upb_arena *arena);
/* Returns a reference to the message's unknown data. */
@ -315,21 +315,21 @@ 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_map *map = UPB_FIELD_AT(msg, upb_map *, 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,
const void *key, size_t key_size, void *val,
size_t val_size) {
upb_map *map = UPB_FIELD_AT(msg, upb_map *, ofs);
upb_map *map = *UPB_PTR_AT(msg, ofs, upb_map *);
if (!map) return false;
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,
size_t *iter) {
upb_map *map = UPB_FIELD_AT(msg, upb_map *, ofs);
upb_map *map = *UPB_PTR_AT(msg, ofs, upb_map *);
if (!map) return NULL;
return _upb_map_next(map, iter);
}
@ -346,13 +346,13 @@ UPB_INLINE bool _upb_msg_map_set(upb_msg *msg, size_t ofs, const void *key,
UPB_INLINE bool _upb_msg_map_delete(upb_msg *msg, size_t ofs, const void *key,
size_t key_size) {
upb_map *map = UPB_FIELD_AT(msg, upb_map *, ofs);
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_map *map = UPB_FIELD_AT(msg, upb_map *, ofs);
upb_map *map = *UPB_PTR_AT(msg, ofs, upb_map *);
if (!map) return;
_upb_map_clear(map);
}

@ -28,20 +28,19 @@
#define UPB_SIZE(size32, size64) size64
#endif
/* These macros aren't really "port", they are helper macros that we don't want
* to leak.
/* If we always read/write as a consistent type to each address, this shouldn't
* violate aliasing.
*/
#define UPB_FIELD_AT(msg, fieldtype, offset) \
*(fieldtype*)((const char*)(msg) + offset)
#define UPB_PTR_AT(msg, ofs, type) ((type*)((char*)(msg) + (ofs)))
#define UPB_READ_ONEOF(msg, fieldtype, offset, case_offset, case_val, default) \
UPB_FIELD_AT(msg, int, case_offset) == case_val \
? UPB_FIELD_AT(msg, fieldtype, offset) \
*UPB_PTR_AT(msg, case_offset, int) == case_val \
? *UPB_PTR_AT(msg, offset, fieldtype) \
: default
#define UPB_WRITE_ONEOF(msg, fieldtype, offset, value, case_offset, case_val) \
UPB_FIELD_AT(msg, int, case_offset) = case_val; \
UPB_FIELD_AT(msg, fieldtype, offset) = value;
*UPB_PTR_AT(msg, case_offset, int) = case_val; \
*UPB_PTR_AT(msg, offset, fieldtype) = value;
#define UPB_MAPTYPE_STRING 0

@ -2,7 +2,7 @@
#undef UPB_MAPTYPE_STRING
#undef UPB_SIZE
#undef UPB_FIELD_AT
#undef UPB_PTR_AT
#undef UPB_READ_ONEOF
#undef UPB_WRITE_ONEOF
#undef UPB_INLINE

@ -47,11 +47,6 @@ static char _upb_fieldtype_to_mapsize[12] = {
/** upb_msg *******************************************************************/
/* If we always read/write as a consistent type to each address, this shouldn't
* violate aliasing.
*/
#define PTR_AT(msg, ofs, type) (type*)((char*)msg + ofs)
upb_msg *upb_msg_new(const upb_msgdef *m, upb_arena *a) {
return _upb_msg_new(upb_msgdef_layout(m), a);
}
@ -63,12 +58,12 @@ static bool in_oneof(const upb_msglayout_field *field) {
static uint32_t *oneofcase(const upb_msg *msg,
const upb_msglayout_field *field) {
UPB_ASSERT(in_oneof(field));
return PTR_AT(msg, ~field->presence, uint32_t);
return UPB_PTR_AT(msg, -field->presence, uint32_t);
}
static upb_msgval _upb_msg_getraw(const upb_msg *msg, const upb_fielddef *f) {
const upb_msglayout_field *field = upb_fielddef_layout(f);
const char *mem = PTR_AT(msg, field->offset, char);
const char *mem = UPB_PTR_AT(msg, field->offset, char);
upb_msgval val = {0};
int size = upb_fielddef_isseq(f) ? sizeof(void *)
: field_size[field->descriptortype];
@ -82,7 +77,7 @@ bool upb_msg_has(const upb_msg *msg, const upb_fielddef *f) {
return *oneofcase(msg, field) == field->number;
} else if (field->presence > 0) {
uint32_t hasbit = field->presence;
return *PTR_AT(msg, hasbit / 8, char) & (1 << (hasbit % 8));
return *UPB_PTR_AT(msg, hasbit / 8, uint8_t) & (1 << (hasbit % 8));
} else {
UPB_ASSERT(field->descriptortype == UPB_DESCRIPTOR_TYPE_MESSAGE ||
field->descriptortype == UPB_DESCRIPTOR_TYPE_GROUP);
@ -147,7 +142,7 @@ upb_mutmsgval upb_msg_mutable(upb_msg *msg, const upb_fielddef *f,
upb_arena *a) {
const upb_msglayout_field *field = upb_fielddef_layout(f);
upb_mutmsgval ret;
char *mem = PTR_AT(msg, field->offset, char);
char *mem = UPB_PTR_AT(msg, field->offset, char);
bool wrong_oneof = in_oneof(field) && *oneofcase(msg, field) != field->number;
memcpy(&ret, mem, sizeof(void*));
@ -177,7 +172,7 @@ upb_mutmsgval upb_msg_mutable(upb_msg *msg, const upb_fielddef *f,
void upb_msg_set(upb_msg *msg, const upb_fielddef *f, upb_msgval val,
upb_arena *a) {
const upb_msglayout_field *field = upb_fielddef_layout(f);
char *mem = PTR_AT(msg, field->offset, char);
char *mem = UPB_PTR_AT(msg, field->offset, char);
int size = upb_fielddef_isseq(f) ? sizeof(void *)
: field_size[field->descriptortype];
memcpy(mem, &val, size);

@ -74,16 +74,10 @@ upb_alloc upb_alloc_global = {&upb_global_allocfunc};
/* upb_arena ******************************************************************/
/* Be conservative and choose 16 in case anyone is using SSE. */
static const size_t maxalign = 16;
static size_t align_up_max(size_t size) {
return ((size + maxalign - 1) / maxalign) * maxalign;
}
struct upb_arena {
/* We implement the allocator interface.
* This must be the first member of upb_arena! */
upb_alloc alloc;
_upb_arena_head head;
char *start;
/* Allocator to allocate arena blocks. We are responsible for freeing these
* when we are destroyed. */
@ -102,8 +96,6 @@ struct upb_arena {
typedef struct mem_block {
struct mem_block *next;
size_t size;
size_t used;
bool owned;
/* Data follows. */
} mem_block;
@ -118,12 +110,17 @@ static void upb_arena_addblock(upb_arena *a, void *ptr, size_t size,
bool owned) {
mem_block *block = ptr;
if (a->block_head) {
a->bytes_allocated += a->head.ptr - a->start;
}
block->next = a->block_head;
block->size = size;
block->used = align_up_max(sizeof(mem_block));
block->owned = owned;
a->block_head = block;
a->start = (char*)block + _upb_arena_alignup(sizeof(mem_block));
a->head.ptr = a->start;
a->head.end = (char*)block + size;
/* TODO(haberman): ASAN poison. */
}
@ -142,39 +139,31 @@ static mem_block *upb_arena_allocblock(upb_arena *a, size_t size) {
return block;
}
void *_upb_arena_slowmalloc(upb_arena *a, size_t size) {
mem_block *block = upb_arena_allocblock(a, size);
if (!block) return NULL; /* Out of memory. */
return upb_arena_malloc(a, size);
}
static void *upb_arena_doalloc(upb_alloc *alloc, void *ptr, size_t oldsize,
size_t size) {
upb_arena *a = (upb_arena*)alloc; /* upb_alloc is initial member. */
mem_block *block = a->block_head;
void *ret;
if (size == 0) {
return NULL; /* We are an arena, don't need individual frees. */
}
size = align_up_max(size);
ret = upb_arena_malloc(a, size);
if (!ret) return NULL;
/* TODO(haberman): special-case if this is a realloc of the last alloc? */
if (!block || block->size - block->used < size) {
/* Slow path: have to allocate a new block. */
block = upb_arena_allocblock(a, size);
if (!block) {
return NULL; /* Out of memory. */
}
}
ret = (char*)block + block->used;
block->used += size;
if (oldsize > 0) {
memcpy(ret, ptr, oldsize); /* Preserve existing data. */
}
/* TODO(haberman): ASAN unpoison. */
a->bytes_allocated += size;
return ret;
}
@ -203,7 +192,10 @@ upb_arena *upb_arena_init(void *mem, size_t n, upb_alloc *alloc) {
a = (void*)((char*)mem + n - sizeof(*a));
n -= sizeof(*a);
a->alloc.func = &upb_arena_doalloc;
a->head.alloc.func = &upb_arena_doalloc;
a->head.ptr = NULL;
a->head.end = NULL;
a->start = NULL;
a->block_alloc = &upb_alloc_global;
a->bytes_allocated = 0;
a->next_block_size = 256;
@ -243,7 +235,7 @@ void upb_arena_free(upb_arena *a) {
}
bool upb_arena_addcleanup(upb_arena *a, void *ud, upb_cleanup_func *func) {
cleanup_ent *ent = upb_malloc(&a->alloc, sizeof(cleanup_ent));
cleanup_ent *ent = upb_malloc(&a->head.alloc, sizeof(cleanup_ent));
if (!ent) {
return false; /* Out of memory. */
}
@ -257,5 +249,5 @@ bool upb_arena_addcleanup(upb_arena *a, void *ud, upb_cleanup_func *func) {
}
size_t upb_arena_bytesallocated(const upb_arena *a) {
return a->bytes_allocated;
return a->bytes_allocated + (a->head.ptr - a->start);
}

@ -209,6 +209,19 @@ typedef struct upb_arena upb_arena;
extern "C" {
#endif
typedef struct {
/* We implement the allocator interface.
* This must be the first member of upb_arena! */
upb_alloc alloc;
char *ptr, *end;
} _upb_arena_head;
UPB_INLINE size_t _upb_arena_alignup(size_t size) {
const size_t maxalign = 16;
return ((size + maxalign - 1) / maxalign) * maxalign;
}
/* Creates an arena from the given initial block (if any -- n may be 0).
* Additional blocks will be allocated from |alloc|. If |alloc| is NULL, this
* is a fixed-size arena and cannot grow. */
@ -216,19 +229,30 @@ upb_arena *upb_arena_init(void *mem, size_t n, upb_alloc *alloc);
void upb_arena_free(upb_arena *a);
bool upb_arena_addcleanup(upb_arena *a, void *ud, upb_cleanup_func *func);
size_t upb_arena_bytesallocated(const upb_arena *a);
void *_upb_arena_slowmalloc(upb_arena *a, size_t size);
UPB_INLINE upb_alloc *upb_arena_alloc(upb_arena *a) { return (upb_alloc*)a; }
/* Convenience wrappers around upb_alloc functions. */
UPB_INLINE void *upb_arena_malloc(upb_arena *a, size_t size) {
return upb_malloc(upb_arena_alloc(a), size);
_upb_arena_head *h = (_upb_arena_head*)a;
size = _upb_arena_alignup(size);
if (UPB_LIKELY((size_t)(h->end - h->ptr) >= size)) {
void* ret = h->ptr;
h->ptr += size;
return ret;
} else {
return _upb_arena_slowmalloc(a, size);
}
}
UPB_INLINE void *upb_arena_realloc(upb_arena *a, void *ptr, size_t oldsize,
size_t size) {
if (oldsize == 0) {
return upb_arena_malloc(a, size);
} else {
return upb_realloc(upb_arena_alloc(a), ptr, oldsize, size);
}
}
UPB_INLINE upb_arena *upb_arena_new(void) {
return upb_arena_init(NULL, 0, &upb_alloc_global);
@ -338,6 +362,7 @@ typedef enum {
/* Descriptor types, as defined in descriptor.proto. */
typedef enum {
/* Old (long) names. TODO(haberman): remove */
UPB_DESCRIPTOR_TYPE_DOUBLE = 1,
UPB_DESCRIPTOR_TYPE_FLOAT = 2,
UPB_DESCRIPTOR_TYPE_INT64 = 3,
@ -355,7 +380,26 @@ typedef enum {
UPB_DESCRIPTOR_TYPE_SFIXED32 = 15,
UPB_DESCRIPTOR_TYPE_SFIXED64 = 16,
UPB_DESCRIPTOR_TYPE_SINT32 = 17,
UPB_DESCRIPTOR_TYPE_SINT64 = 18
UPB_DESCRIPTOR_TYPE_SINT64 = 18,
UPB_DTYPE_DOUBLE = 1,
UPB_DTYPE_FLOAT = 2,
UPB_DTYPE_INT64 = 3,
UPB_DTYPE_UINT64 = 4,
UPB_DTYPE_INT32 = 5,
UPB_DTYPE_FIXED64 = 6,
UPB_DTYPE_FIXED32 = 7,
UPB_DTYPE_BOOL = 8,
UPB_DTYPE_STRING = 9,
UPB_DTYPE_GROUP = 10,
UPB_DTYPE_MESSAGE = 11,
UPB_DTYPE_BYTES = 12,
UPB_DTYPE_UINT32 = 13,
UPB_DTYPE_ENUM = 14,
UPB_DTYPE_SFIXED32 = 15,
UPB_DTYPE_SFIXED64 = 16,
UPB_DTYPE_SINT32 = 17,
UPB_DTYPE_SINT64 = 18
} upb_descriptortype_t;
#define UPB_MAP_BEGIN -1

@ -364,7 +364,7 @@ void GenerateMessageInHeader(const protobuf::Descriptor* message, Output& output
fullname);
output(
"UPB_INLINE $0_oneofcases $1_$2_case(const $1* msg) { "
"return ($0_oneofcases)UPB_FIELD_AT(msg, int32_t, $3); }\n"
"return ($0_oneofcases)*UPB_PTR_AT(msg, $3, int32_t); }\n"
"\n",
fullname, msgname, oneof->name(),
GetSizeInit(layout.GetOneofCaseOffset(oneof)));
@ -441,7 +441,7 @@ void GenerateMessageInHeader(const protobuf::Descriptor* message, Output& output
} else {
output(
"UPB_INLINE $0 $1_$2(const $1 *msg) { "
"return UPB_FIELD_AT(msg, $0, $3); }\n",
"return *UPB_PTR_AT(msg, $3, $0); }\n",
CTypeConst(field), msgname, field->name(),
GetSizeInit(layout.GetFieldOffset(field)));
}
@ -556,7 +556,7 @@ void GenerateMessageInHeader(const protobuf::Descriptor* message, Output& output
output(" _upb_sethas(msg, $0);\n", layout.GetHasbitIndex(field));
}
output(
" UPB_FIELD_AT(msg, $0, $1) = value;\n"
" *UPB_PTR_AT(msg, $1, $0) = value;\n"
"}\n",
CType(field), GetSizeInit(layout.GetFieldOffset(field)));
}
@ -699,7 +699,6 @@ void WriteSource(const protobuf::FileDescriptor* file, Output& output) {
std::string msgname = ToCIdent(message->full_name());
std::string fields_array_ref = "NULL";
std::string submsgs_array_ref = "NULL";
std::string oneofs_array_ref = "NULL";
absl::flat_hash_map<const protobuf::Descriptor*, int> submsg_indexes;
MessageLayout layout(message);
std::vector<const protobuf::FieldDescriptor*> sorted_submsgs =
@ -742,14 +741,18 @@ void WriteSource(const protobuf::FileDescriptor* file, Output& output) {
}
if (MessageLayout::HasHasbit(field)) {
presence = absl::StrCat(layout.GetHasbitIndex(field));
int index = layout.GetHasbitIndex(field);
assert(index != 0);
presence = absl::StrCat(index);
} else if (field->containing_oneof()) {
MessageLayout::Size case_offset =
layout.GetOneofCaseOffset(field->containing_oneof());
// Our encoding that distinguishes oneofs from presence-having fields.
case_offset.size32 = -case_offset.size32 - 1;
case_offset.size64 = -case_offset.size64 - 1;
// We encode as negative to distinguish from hasbits.
case_offset.size32 = -case_offset.size32;
case_offset.size64 = -case_offset.size64;
assert(case_offset.size32 != 0);
assert(case_offset.size64 != 0);
presence = GetSizeInit(case_offset);
}
// Sync '4' with UPB_LABEL_MAP in upb/msg.h.

Loading…
Cancel
Save