ruby_memprofiler_pprof 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (200) hide show
  1. checksums.yaml +7 -0
  2. data/ext/ruby_memprofiler_pprof/backtrace.c +429 -0
  3. data/ext/ruby_memprofiler_pprof/collector.c +1055 -0
  4. data/ext/ruby_memprofiler_pprof/compat.c +182 -0
  5. data/ext/ruby_memprofiler_pprof/extconf.rb +72 -0
  6. data/ext/ruby_memprofiler_pprof/pprof.upb.c +170 -0
  7. data/ext/ruby_memprofiler_pprof/pprof.upb.h +848 -0
  8. data/ext/ruby_memprofiler_pprof/pprof_out.c +285 -0
  9. data/ext/ruby_memprofiler_pprof/ruby_memprofiler_pprof.c +11 -0
  10. data/ext/ruby_memprofiler_pprof/ruby_memprofiler_pprof.h +301 -0
  11. data/ext/ruby_memprofiler_pprof/strtab.c +391 -0
  12. data/ext/ruby_memprofiler_pprof/vendor/upb/BUILD +719 -0
  13. data/ext/ruby_memprofiler_pprof/vendor/upb/CONTRIBUTING.md +37 -0
  14. data/ext/ruby_memprofiler_pprof/vendor/upb/DESIGN.md +201 -0
  15. data/ext/ruby_memprofiler_pprof/vendor/upb/LICENSE +26 -0
  16. data/ext/ruby_memprofiler_pprof/vendor/upb/README.md +78 -0
  17. data/ext/ruby_memprofiler_pprof/vendor/upb/WORKSPACE +58 -0
  18. data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/BUILD +53 -0
  19. data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/amalgamate.py +129 -0
  20. data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/build_defs.bzl +160 -0
  21. data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/lua.BUILD +127 -0
  22. data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/protobuf.patch +54 -0
  23. data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/py_proto_library.bzl +137 -0
  24. data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/python_downloads.bzl +84 -0
  25. data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/system_python.bzl +101 -0
  26. data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/upb_proto_library.bzl +388 -0
  27. data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/workspace_deps.bzl +89 -0
  28. data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/BUILD +252 -0
  29. data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/BUILD.googleapis +54 -0
  30. data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/benchmark.cc +333 -0
  31. data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/build_defs.bzl +88 -0
  32. data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/compare.py +118 -0
  33. data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/descriptor.proto +888 -0
  34. data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/descriptor_sv.proto +890 -0
  35. data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/empty.proto +6 -0
  36. data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/gen_protobuf_binary_cc.py +64 -0
  37. data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/gen_synthetic_protos.py +118 -0
  38. data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/gen_upb_binary_c.py +65 -0
  39. data/ext/ruby_memprofiler_pprof/vendor/upb/cmake/BUILD.bazel +102 -0
  40. data/ext/ruby_memprofiler_pprof/vendor/upb/cmake/README.md +23 -0
  41. data/ext/ruby_memprofiler_pprof/vendor/upb/cmake/build_defs.bzl +73 -0
  42. data/ext/ruby_memprofiler_pprof/vendor/upb/cmake/make_cmakelists.py +340 -0
  43. data/ext/ruby_memprofiler_pprof/vendor/upb/cmake/staleness_test.py +57 -0
  44. data/ext/ruby_memprofiler_pprof/vendor/upb/cmake/staleness_test_lib.py +186 -0
  45. data/ext/ruby_memprofiler_pprof/vendor/upb/docs/render.py +43 -0
  46. data/ext/ruby_memprofiler_pprof/vendor/upb/docs/style-guide.md +65 -0
  47. data/ext/ruby_memprofiler_pprof/vendor/upb/docs/vs-cpp-protos.md +255 -0
  48. data/ext/ruby_memprofiler_pprof/vendor/upb/docs/wrapping-upb.md +444 -0
  49. data/ext/ruby_memprofiler_pprof/vendor/upb/python/BUILD +216 -0
  50. data/ext/ruby_memprofiler_pprof/vendor/upb/python/convert.c +394 -0
  51. data/ext/ruby_memprofiler_pprof/vendor/upb/python/convert.h +63 -0
  52. data/ext/ruby_memprofiler_pprof/vendor/upb/python/descriptor.c +1694 -0
  53. data/ext/ruby_memprofiler_pprof/vendor/upb/python/descriptor.h +80 -0
  54. data/ext/ruby_memprofiler_pprof/vendor/upb/python/descriptor_containers.c +704 -0
  55. data/ext/ruby_memprofiler_pprof/vendor/upb/python/descriptor_containers.h +114 -0
  56. data/ext/ruby_memprofiler_pprof/vendor/upb/python/descriptor_pool.c +650 -0
  57. data/ext/ruby_memprofiler_pprof/vendor/upb/python/descriptor_pool.h +48 -0
  58. data/ext/ruby_memprofiler_pprof/vendor/upb/python/dist/BUILD.bazel +193 -0
  59. data/ext/ruby_memprofiler_pprof/vendor/upb/python/dist/dist.bzl +190 -0
  60. data/ext/ruby_memprofiler_pprof/vendor/upb/python/extension_dict.c +247 -0
  61. data/ext/ruby_memprofiler_pprof/vendor/upb/python/extension_dict.h +39 -0
  62. data/ext/ruby_memprofiler_pprof/vendor/upb/python/map.c +522 -0
  63. data/ext/ruby_memprofiler_pprof/vendor/upb/python/map.h +66 -0
  64. data/ext/ruby_memprofiler_pprof/vendor/upb/python/message.c +1909 -0
  65. data/ext/ruby_memprofiler_pprof/vendor/upb/python/message.h +101 -0
  66. data/ext/ruby_memprofiler_pprof/vendor/upb/python/minimal_test.py +183 -0
  67. data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/BUILD +70 -0
  68. data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/README.md +11 -0
  69. data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/descriptor_database_test_wrapper.py +30 -0
  70. data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/descriptor_pool_test_wrapper.py +45 -0
  71. data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/descriptor_test_wrapper.py +46 -0
  72. data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/generator_test_wrapper.py +30 -0
  73. data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/json_format_test_wrapper.py +30 -0
  74. data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/keywords_test_wrapper.py +30 -0
  75. data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/message_factory_test_wrapper.py +37 -0
  76. data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/message_test_wrapper.py +52 -0
  77. data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/proto_builder_test_wrapper.py +32 -0
  78. data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/pyproto_test_wrapper.bzl +36 -0
  79. data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/reflection_test_wrapper.py +45 -0
  80. data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/service_reflection_test_wrapper.py +30 -0
  81. data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/symbol_database_test_wrapper.py +30 -0
  82. data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/text_encoding_test_wrapper.py +30 -0
  83. data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/text_format_test_wrapper.py +30 -0
  84. data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/unknown_fields_test_wrapper.py +30 -0
  85. data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/well_known_types_test_wrapper.py +36 -0
  86. data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/wire_format_test_wrapper.py +30 -0
  87. data/ext/ruby_memprofiler_pprof/vendor/upb/python/protobuf.c +350 -0
  88. data/ext/ruby_memprofiler_pprof/vendor/upb/python/protobuf.h +230 -0
  89. data/ext/ruby_memprofiler_pprof/vendor/upb/python/py_extension.bzl +55 -0
  90. data/ext/ruby_memprofiler_pprof/vendor/upb/python/python_api.h +61 -0
  91. data/ext/ruby_memprofiler_pprof/vendor/upb/python/repeated.c +828 -0
  92. data/ext/ruby_memprofiler_pprof/vendor/upb/python/repeated.h +69 -0
  93. data/ext/ruby_memprofiler_pprof/vendor/upb/python/unknown_fields.c +404 -0
  94. data/ext/ruby_memprofiler_pprof/vendor/upb/python/unknown_fields.h +39 -0
  95. data/ext/ruby_memprofiler_pprof/vendor/upb/python/version_script.lds +6 -0
  96. data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/lunit/LICENSE +32 -0
  97. data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/lunit/README.google +9 -0
  98. data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/lunit/console.lua +156 -0
  99. data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/lunit/lunit.lua +725 -0
  100. data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/utf8_range/BUILD +19 -0
  101. data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/utf8_range/LICENSE +21 -0
  102. data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/utf8_range/naive.c +92 -0
  103. data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/utf8_range/range2-neon.c +157 -0
  104. data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/utf8_range/range2-sse.c +170 -0
  105. data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/utf8_range/utf8_range.h +9 -0
  106. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/BUILD.bazel +129 -0
  107. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/README.md +8 -0
  108. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/def.c +939 -0
  109. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/lua_proto_library.bzl +138 -0
  110. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/main.c +83 -0
  111. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/msg.c +1118 -0
  112. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/test.proto +69 -0
  113. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/test_upb.lua +846 -0
  114. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/upb.c +258 -0
  115. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/upb.h +132 -0
  116. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/upb.lua +58 -0
  117. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/upbc.cc +134 -0
  118. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/collections.c +192 -0
  119. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/collections.h +174 -0
  120. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/conformance_upb.c +346 -0
  121. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/conformance_upb_failures.txt +1 -0
  122. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/decode.c +1221 -0
  123. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/decode.h +94 -0
  124. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/decode_fast.c +1055 -0
  125. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/decode_fast.h +153 -0
  126. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/decode_internal.h +211 -0
  127. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/def.c +3262 -0
  128. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/def.h +414 -0
  129. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/def.hpp +438 -0
  130. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/empty.proto +1 -0
  131. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/encode.c +604 -0
  132. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/encode.h +71 -0
  133. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/fuzz/BUILD +13 -0
  134. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/fuzz/file_descriptor_parsenew_fuzzer.cc +43 -0
  135. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/json_decode.c +1509 -0
  136. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/json_decode.h +47 -0
  137. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/json_encode.c +776 -0
  138. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/json_encode.h +62 -0
  139. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table.c +1147 -0
  140. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table.h +189 -0
  141. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table.hpp +112 -0
  142. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table_accessors.c +363 -0
  143. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table_accessors.h +263 -0
  144. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table_accessors_internal.h +59 -0
  145. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table_accessors_test.cc +425 -0
  146. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table_test.cc +230 -0
  147. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/msg.c +428 -0
  148. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/msg.h +114 -0
  149. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/msg_internal.h +836 -0
  150. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/msg_test.cc +491 -0
  151. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/msg_test.proto +195 -0
  152. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/port_def.inc +261 -0
  153. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/port_undef.inc +62 -0
  154. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/reflection.c +323 -0
  155. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/reflection.h +109 -0
  156. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/reflection.hpp +37 -0
  157. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/table.c +926 -0
  158. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/table_internal.h +385 -0
  159. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/test.proto +74 -0
  160. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/test_cpp.cc +186 -0
  161. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/test_cpp.proto +12 -0
  162. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/test_generated_code.cc +977 -0
  163. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/test_table.cc +580 -0
  164. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/text_encode.c +472 -0
  165. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/text_encode.h +64 -0
  166. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/upb.c +362 -0
  167. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/upb.h +378 -0
  168. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/upb.hpp +115 -0
  169. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/upb_internal.h +68 -0
  170. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/BUILD +121 -0
  171. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/README.md +7 -0
  172. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/compare.c +300 -0
  173. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/compare.h +66 -0
  174. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/compare_test.cc +236 -0
  175. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto.c +572 -0
  176. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto.h +62 -0
  177. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto_public_import_test.proto +32 -0
  178. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto_regular_import_test.proto +36 -0
  179. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto_test.cc +143 -0
  180. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto_test.proto +119 -0
  181. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto_weak_import_test.proto +28 -0
  182. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto_wweak_import_test.proto +28 -0
  183. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/required_fields.c +311 -0
  184. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/required_fields.h +94 -0
  185. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/required_fields_test.cc +202 -0
  186. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/required_fields_test.proto +48 -0
  187. data/ext/ruby_memprofiler_pprof/vendor/upb/upbc/BUILD +78 -0
  188. data/ext/ruby_memprofiler_pprof/vendor/upb/upbc/common.cc +77 -0
  189. data/ext/ruby_memprofiler_pprof/vendor/upb/upbc/common.h +112 -0
  190. data/ext/ruby_memprofiler_pprof/vendor/upb/upbc/protoc-gen-upb.cc +1997 -0
  191. data/ext/ruby_memprofiler_pprof/vendor/upb/upbc/protoc-gen-upbdefs.cc +193 -0
  192. data/lib/ruby_memprofiler_pprof/atfork.rb +77 -0
  193. data/lib/ruby_memprofiler_pprof/block_flusher.rb +61 -0
  194. data/lib/ruby_memprofiler_pprof/file_flusher.rb +45 -0
  195. data/lib/ruby_memprofiler_pprof/profile_app.rb +30 -0
  196. data/lib/ruby_memprofiler_pprof/profile_data.rb +18 -0
  197. data/lib/ruby_memprofiler_pprof/version.rb +5 -0
  198. data/lib/ruby_memprofiler_pprof.rb +8 -0
  199. data/libexec/ruby_memprofiler_pprof_profile +16 -0
  200. metadata +257 -0
@@ -0,0 +1,378 @@
1
+ /*
2
+ * Copyright (c) 2009-2021, Google LLC
3
+ * All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without
6
+ * modification, are permitted provided that the following conditions are met:
7
+ * * Redistributions of source code must retain the above copyright
8
+ * notice, this list of conditions and the following disclaimer.
9
+ * * Redistributions in binary form must reproduce the above copyright
10
+ * notice, this list of conditions and the following disclaimer in the
11
+ * documentation and/or other materials provided with the distribution.
12
+ * * Neither the name of Google LLC nor the
13
+ * names of its contributors may be used to endorse or promote products
14
+ * derived from this software without specific prior written permission.
15
+ *
16
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19
+ * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT,
20
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
+ */
27
+
28
+ /*
29
+ * This file contains shared definitions that are widely used across upb.
30
+ */
31
+
32
+ #ifndef UPB_H_
33
+ #define UPB_H_
34
+
35
+ #include <assert.h>
36
+ #include <stdarg.h>
37
+ #include <stdbool.h>
38
+ #include <stddef.h>
39
+ #include <stdint.h>
40
+ #include <string.h>
41
+
42
+ #include "upb/port_def.inc"
43
+
44
+ #ifdef __cplusplus
45
+ extern "C" {
46
+ #endif
47
+
48
+ /* upb_Status *****************************************************************/
49
+
50
+ #define _kUpb_Status_MaxMessage 127
51
+
52
+ typedef struct {
53
+ bool ok;
54
+ char msg[_kUpb_Status_MaxMessage]; /* Error message; NULL-terminated. */
55
+ } upb_Status;
56
+
57
+ const char* upb_Status_ErrorMessage(const upb_Status* status);
58
+ bool upb_Status_IsOk(const upb_Status* status);
59
+
60
+ /* These are no-op if |status| is NULL. */
61
+ void upb_Status_Clear(upb_Status* status);
62
+ void upb_Status_SetErrorMessage(upb_Status* status, const char* msg);
63
+ void upb_Status_SetErrorFormat(upb_Status* status, const char* fmt, ...)
64
+ UPB_PRINTF(2, 3);
65
+ void upb_Status_VSetErrorFormat(upb_Status* status, const char* fmt,
66
+ va_list args) UPB_PRINTF(2, 0);
67
+ void upb_Status_VAppendErrorFormat(upb_Status* status, const char* fmt,
68
+ va_list args) UPB_PRINTF(2, 0);
69
+
70
+ /** upb_StringView ************************************************************/
71
+
72
+ typedef struct {
73
+ const char* data;
74
+ size_t size;
75
+ } upb_StringView;
76
+
77
+ UPB_INLINE upb_StringView upb_StringView_FromDataAndSize(const char* data,
78
+ size_t size) {
79
+ upb_StringView ret;
80
+ ret.data = data;
81
+ ret.size = size;
82
+ return ret;
83
+ }
84
+
85
+ UPB_INLINE upb_StringView upb_StringView_FromString(const char* data) {
86
+ return upb_StringView_FromDataAndSize(data, strlen(data));
87
+ }
88
+
89
+ UPB_INLINE bool upb_StringView_IsEqual(upb_StringView a, upb_StringView b) {
90
+ return a.size == b.size && memcmp(a.data, b.data, a.size) == 0;
91
+ }
92
+
93
+ #define UPB_STRINGVIEW_INIT(ptr, len) \
94
+ { ptr, len }
95
+
96
+ #define UPB_STRINGVIEW_FORMAT "%.*s"
97
+ #define UPB_STRINGVIEW_ARGS(view) (int)(view).size, (view).data
98
+
99
+ /** upb_alloc *****************************************************************/
100
+
101
+ /* A upb_alloc is a possibly-stateful allocator object.
102
+ *
103
+ * It could either be an arena allocator (which doesn't require individual
104
+ * free() calls) or a regular malloc() (which does). The client must therefore
105
+ * free memory unless it knows that the allocator is an arena allocator. */
106
+
107
+ struct upb_alloc;
108
+ typedef struct upb_alloc upb_alloc;
109
+
110
+ /* A malloc()/free() function.
111
+ * If "size" is 0 then the function acts like free(), otherwise it acts like
112
+ * realloc(). Only "oldsize" bytes from a previous allocation are preserved. */
113
+ typedef void* upb_alloc_func(upb_alloc* alloc, void* ptr, size_t oldsize,
114
+ size_t size);
115
+
116
+ struct upb_alloc {
117
+ upb_alloc_func* func;
118
+ };
119
+
120
+ UPB_INLINE void* upb_malloc(upb_alloc* alloc, size_t size) {
121
+ UPB_ASSERT(alloc);
122
+ return alloc->func(alloc, NULL, 0, size);
123
+ }
124
+
125
+ UPB_INLINE void* upb_realloc(upb_alloc* alloc, void* ptr, size_t oldsize,
126
+ size_t size) {
127
+ UPB_ASSERT(alloc);
128
+ return alloc->func(alloc, ptr, oldsize, size);
129
+ }
130
+
131
+ UPB_INLINE void upb_free(upb_alloc* alloc, void* ptr) {
132
+ assert(alloc);
133
+ alloc->func(alloc, ptr, 0, 0);
134
+ }
135
+
136
+ /* The global allocator used by upb. Uses the standard malloc()/free(). */
137
+
138
+ extern upb_alloc upb_alloc_global;
139
+
140
+ /* Functions that hard-code the global malloc.
141
+ *
142
+ * We still get benefit because we can put custom logic into our global
143
+ * allocator, like injecting out-of-memory faults in debug/testing builds. */
144
+
145
+ UPB_INLINE void* upb_gmalloc(size_t size) {
146
+ return upb_malloc(&upb_alloc_global, size);
147
+ }
148
+
149
+ UPB_INLINE void* upb_grealloc(void* ptr, size_t oldsize, size_t size) {
150
+ return upb_realloc(&upb_alloc_global, ptr, oldsize, size);
151
+ }
152
+
153
+ UPB_INLINE void upb_gfree(void* ptr) { upb_free(&upb_alloc_global, ptr); }
154
+
155
+ /* upb_Arena ******************************************************************/
156
+
157
+ /* upb_Arena is a specific allocator implementation that uses arena allocation.
158
+ * The user provides an allocator that will be used to allocate the underlying
159
+ * arena blocks. Arenas by nature do not require the individual allocations
160
+ * to be freed. However the Arena does allow users to register cleanup
161
+ * functions that will run when the arena is destroyed.
162
+ *
163
+ * A upb_Arena is *not* thread-safe.
164
+ *
165
+ * You could write a thread-safe arena allocator that satisfies the
166
+ * upb_alloc interface, but it would not be as efficient for the
167
+ * single-threaded case. */
168
+
169
+ typedef void upb_CleanupFunc(void* ud);
170
+
171
+ struct upb_Arena;
172
+ typedef struct upb_Arena upb_Arena;
173
+
174
+ typedef struct {
175
+ /* We implement the allocator interface.
176
+ * This must be the first member of upb_Arena!
177
+ * TODO(haberman): remove once handlers are gone. */
178
+ upb_alloc alloc;
179
+
180
+ char *ptr, *end;
181
+ } _upb_ArenaHead;
182
+
183
+ /* Creates an arena from the given initial block (if any -- n may be 0).
184
+ * Additional blocks will be allocated from |alloc|. If |alloc| is NULL, this
185
+ * is a fixed-size arena and cannot grow. */
186
+ upb_Arena* upb_Arena_Init(void* mem, size_t n, upb_alloc* alloc);
187
+ void upb_Arena_Free(upb_Arena* a);
188
+ bool upb_Arena_AddCleanup(upb_Arena* a, void* ud, upb_CleanupFunc* func);
189
+ bool upb_Arena_Fuse(upb_Arena* a, upb_Arena* b);
190
+ void* _upb_Arena_SlowMalloc(upb_Arena* a, size_t size);
191
+
192
+ UPB_INLINE upb_alloc* upb_Arena_Alloc(upb_Arena* a) { return (upb_alloc*)a; }
193
+
194
+ UPB_INLINE size_t _upb_ArenaHas(upb_Arena* a) {
195
+ _upb_ArenaHead* h = (_upb_ArenaHead*)a;
196
+ return (size_t)(h->end - h->ptr);
197
+ }
198
+
199
+ UPB_INLINE void* _upb_Arena_FastMalloc(upb_Arena* a, size_t size) {
200
+ _upb_ArenaHead* h = (_upb_ArenaHead*)a;
201
+ void* ret = h->ptr;
202
+ UPB_ASSERT(UPB_ALIGN_MALLOC((uintptr_t)ret) == (uintptr_t)ret);
203
+ UPB_ASSERT(UPB_ALIGN_MALLOC(size) == size);
204
+ UPB_UNPOISON_MEMORY_REGION(ret, size);
205
+
206
+ h->ptr += size;
207
+
208
+ #if UPB_ASAN
209
+ {
210
+ size_t guard_size = 32;
211
+ if (_upb_ArenaHas(a) >= guard_size) {
212
+ h->ptr += guard_size;
213
+ } else {
214
+ h->ptr = h->end;
215
+ }
216
+ }
217
+ #endif
218
+
219
+ return ret;
220
+ }
221
+
222
+ UPB_INLINE void* upb_Arena_Malloc(upb_Arena* a, size_t size) {
223
+ size = UPB_ALIGN_MALLOC(size);
224
+
225
+ if (UPB_UNLIKELY(_upb_ArenaHas(a) < size)) {
226
+ return _upb_Arena_SlowMalloc(a, size);
227
+ }
228
+
229
+ return _upb_Arena_FastMalloc(a, size);
230
+ }
231
+
232
+ // Shrinks the last alloc from arena.
233
+ // REQUIRES: (ptr, oldsize) was the last malloc/realloc from this arena.
234
+ // We could also add a upb_Arena_TryShrinkLast() which is simply a no-op if
235
+ // this was not the last alloc.
236
+ UPB_INLINE void upb_Arena_ShrinkLast(upb_Arena* a, void* ptr, size_t oldsize,
237
+ size_t size) {
238
+ _upb_ArenaHead* h = (_upb_ArenaHead*)a;
239
+ oldsize = UPB_ALIGN_MALLOC(oldsize);
240
+ size = UPB_ALIGN_MALLOC(size);
241
+ UPB_ASSERT((char*)ptr + oldsize == h->ptr); // Must be the last alloc.
242
+ UPB_ASSERT(size <= oldsize);
243
+ h->ptr = (char*)ptr + size;
244
+ }
245
+
246
+ UPB_INLINE void* upb_Arena_Realloc(upb_Arena* a, void* ptr, size_t oldsize,
247
+ size_t size) {
248
+ _upb_ArenaHead* h = (_upb_ArenaHead*)a;
249
+ oldsize = UPB_ALIGN_MALLOC(oldsize);
250
+ size = UPB_ALIGN_MALLOC(size);
251
+ bool is_most_recent_alloc = (uintptr_t)ptr + oldsize == (uintptr_t)h->ptr;
252
+
253
+ if (is_most_recent_alloc) {
254
+ ptrdiff_t diff = size - oldsize;
255
+ if ((ptrdiff_t)_upb_ArenaHas(a) >= diff) {
256
+ h->ptr += diff;
257
+ return ptr;
258
+ }
259
+ } else if (size <= oldsize) {
260
+ return ptr;
261
+ }
262
+
263
+ void* ret = upb_Arena_Malloc(a, size);
264
+
265
+ if (ret && oldsize > 0) {
266
+ memcpy(ret, ptr, UPB_MIN(oldsize, size));
267
+ }
268
+
269
+ return ret;
270
+ }
271
+
272
+ UPB_INLINE upb_Arena* upb_Arena_New(void) {
273
+ return upb_Arena_Init(NULL, 0, &upb_alloc_global);
274
+ }
275
+
276
+ /* Constants ******************************************************************/
277
+
278
+ /* A list of types as they are encoded on-the-wire. */
279
+ typedef enum {
280
+ kUpb_WireType_Varint = 0,
281
+ kUpb_WireType_64Bit = 1,
282
+ kUpb_WireType_Delimited = 2,
283
+ kUpb_WireType_StartGroup = 3,
284
+ kUpb_WireType_EndGroup = 4,
285
+ kUpb_WireType_32Bit = 5
286
+ } upb_WireType;
287
+
288
+ /* The types a field can have. Note that this list is not identical to the
289
+ * types defined in descriptor.proto, which gives INT32 and SINT32 separate
290
+ * types (we distinguish the two with the "integer encoding" enum below). */
291
+ typedef enum {
292
+ kUpb_CType_Bool = 1,
293
+ kUpb_CType_Float = 2,
294
+ kUpb_CType_Int32 = 3,
295
+ kUpb_CType_UInt32 = 4,
296
+ kUpb_CType_Enum = 5, /* Enum values are int32. */
297
+ kUpb_CType_Message = 6,
298
+ kUpb_CType_Double = 7,
299
+ kUpb_CType_Int64 = 8,
300
+ kUpb_CType_UInt64 = 9,
301
+ kUpb_CType_String = 10,
302
+ kUpb_CType_Bytes = 11
303
+ } upb_CType;
304
+
305
+ /* The repeated-ness of each field; this matches descriptor.proto. */
306
+ typedef enum {
307
+ kUpb_Label_Optional = 1,
308
+ kUpb_Label_Required = 2,
309
+ kUpb_Label_Repeated = 3
310
+ } upb_Label;
311
+
312
+ /* Descriptor types, as defined in descriptor.proto. */
313
+ typedef enum {
314
+ kUpb_FieldType_Double = 1,
315
+ kUpb_FieldType_Float = 2,
316
+ kUpb_FieldType_Int64 = 3,
317
+ kUpb_FieldType_UInt64 = 4,
318
+ kUpb_FieldType_Int32 = 5,
319
+ kUpb_FieldType_Fixed64 = 6,
320
+ kUpb_FieldType_Fixed32 = 7,
321
+ kUpb_FieldType_Bool = 8,
322
+ kUpb_FieldType_String = 9,
323
+ kUpb_FieldType_Group = 10,
324
+ kUpb_FieldType_Message = 11,
325
+ kUpb_FieldType_Bytes = 12,
326
+ kUpb_FieldType_UInt32 = 13,
327
+ kUpb_FieldType_Enum = 14,
328
+ kUpb_FieldType_SFixed32 = 15,
329
+ kUpb_FieldType_SFixed64 = 16,
330
+ kUpb_FieldType_SInt32 = 17,
331
+ kUpb_FieldType_SInt64 = 18
332
+ } upb_FieldType;
333
+
334
+ #define kUpb_Map_Begin ((size_t)-1)
335
+
336
+ UPB_INLINE bool _upb_IsLittleEndian(void) {
337
+ int x = 1;
338
+ return *(char*)&x == 1;
339
+ }
340
+
341
+ UPB_INLINE uint32_t _upb_BigEndian_Swap32(uint32_t val) {
342
+ if (_upb_IsLittleEndian()) {
343
+ return val;
344
+ } else {
345
+ return ((val & 0xff) << 24) | ((val & 0xff00) << 8) |
346
+ ((val & 0xff0000) >> 8) | ((val & 0xff000000) >> 24);
347
+ }
348
+ }
349
+
350
+ UPB_INLINE uint64_t _upb_BigEndian_Swap64(uint64_t val) {
351
+ if (_upb_IsLittleEndian()) {
352
+ return val;
353
+ } else {
354
+ return ((uint64_t)_upb_BigEndian_Swap32(val) << 32) |
355
+ _upb_BigEndian_Swap32(val >> 32);
356
+ }
357
+ }
358
+
359
+ UPB_INLINE int _upb_Log2Ceiling(int x) {
360
+ if (x <= 1) return 0;
361
+ #ifdef __GNUC__
362
+ return 32 - __builtin_clz(x - 1);
363
+ #else
364
+ int lg2 = 0;
365
+ while (1 << lg2 < x) lg2++;
366
+ return lg2;
367
+ #endif
368
+ }
369
+
370
+ UPB_INLINE int _upb_Log2CeilingSize(int x) { return 1 << _upb_Log2Ceiling(x); }
371
+
372
+ #include "upb/port_undef.inc"
373
+
374
+ #ifdef __cplusplus
375
+ } /* extern "C" */
376
+ #endif
377
+
378
+ #endif /* UPB_H_ */
@@ -0,0 +1,115 @@
1
+ // Copyright (c) 2009-2021, Google LLC
2
+ // All rights reserved.
3
+ //
4
+ // Redistribution and use in source and binary forms, with or without
5
+ // modification, are permitted provided that the following conditions are met:
6
+ // * Redistributions of source code must retain the above copyright
7
+ // notice, this list of conditions and the following disclaimer.
8
+ // * Redistributions in binary form must reproduce the above copyright
9
+ // notice, this list of conditions and the following disclaimer in the
10
+ // documentation and/or other materials provided with the distribution.
11
+ // * Neither the name of Google LLC nor the
12
+ // names of its contributors may be used to endorse or promote products
13
+ // derived from this software without specific prior written permission.
14
+ //
15
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
+ // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
+ // ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT,
19
+ // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
+ // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
+ // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
+ // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
+ // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
+
26
+ #ifndef UPB_HPP_
27
+ #define UPB_HPP_
28
+
29
+ #include <memory>
30
+
31
+ #include "upb/upb.h"
32
+
33
+ namespace upb {
34
+
35
+ class Status {
36
+ public:
37
+ Status() { upb_Status_Clear(&status_); }
38
+
39
+ upb_Status* ptr() { return &status_; }
40
+
41
+ // Returns true if there is no error.
42
+ bool ok() const { return upb_Status_IsOk(&status_); }
43
+
44
+ // Guaranteed to be NULL-terminated.
45
+ const char* error_message() const {
46
+ return upb_Status_ErrorMessage(&status_);
47
+ }
48
+
49
+ // The error message will be truncated if it is longer than
50
+ // _kUpb_Status_MaxMessage-4.
51
+ void SetErrorMessage(const char* msg) {
52
+ upb_Status_SetErrorMessage(&status_, msg);
53
+ }
54
+ void SetFormattedErrorMessage(const char* fmt, ...) {
55
+ va_list args;
56
+ va_start(args, fmt);
57
+ upb_Status_VSetErrorFormat(&status_, fmt, args);
58
+ va_end(args);
59
+ }
60
+
61
+ // Resets the status to a successful state with no message.
62
+ void Clear() { upb_Status_Clear(&status_); }
63
+
64
+ private:
65
+ upb_Status status_;
66
+ };
67
+
68
+ class Arena {
69
+ public:
70
+ // A simple arena with no initial memory block and the default allocator.
71
+ Arena() : ptr_(upb_Arena_New(), upb_Arena_Free) {}
72
+ Arena(char* initial_block, size_t size)
73
+ : ptr_(upb_Arena_Init(initial_block, size, &upb_alloc_global),
74
+ upb_Arena_Free) {}
75
+
76
+ upb_Arena* ptr() { return ptr_.get(); }
77
+
78
+ // Allows this arena to be used as a generic allocator.
79
+ //
80
+ // The arena does not need free() calls so when using Arena as an allocator
81
+ // it is safe to skip them. However they are no-ops so there is no harm in
82
+ // calling free() either.
83
+ upb_alloc* allocator() { return upb_Arena_Alloc(ptr_.get()); }
84
+
85
+ // Add a cleanup function to run when the arena is destroyed.
86
+ // Returns false on out-of-memory.
87
+ template <class T>
88
+ bool Own(T* obj) {
89
+ return upb_Arena_AddCleanup(ptr_.get(), obj,
90
+ [](void* obj) { delete static_cast<T*>(obj); });
91
+ }
92
+
93
+ void Fuse(Arena& other) { upb_Arena_Fuse(ptr(), other.ptr()); }
94
+
95
+ private:
96
+ std::unique_ptr<upb_Arena, decltype(&upb_Arena_Free)> ptr_;
97
+ };
98
+
99
+ // InlinedArena seeds the arenas with a predefined amount of memory. No
100
+ // heap memory will be allocated until the initial block is exceeded.
101
+ template <int N>
102
+ class InlinedArena : public Arena {
103
+ public:
104
+ InlinedArena() : Arena(initial_block_, N) {}
105
+
106
+ private:
107
+ InlinedArena(const InlinedArena*) = delete;
108
+ InlinedArena& operator=(const InlinedArena*) = delete;
109
+
110
+ char initial_block_[N];
111
+ };
112
+
113
+ } // namespace upb
114
+
115
+ #endif // UPB_HPP_
@@ -0,0 +1,68 @@
1
+ /*
2
+ * Copyright (c) 2009-2021, Google LLC
3
+ * All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without
6
+ * modification, are permitted provided that the following conditions are met:
7
+ * * Redistributions of source code must retain the above copyright
8
+ * notice, this list of conditions and the following disclaimer.
9
+ * * Redistributions in binary form must reproduce the above copyright
10
+ * notice, this list of conditions and the following disclaimer in the
11
+ * documentation and/or other materials provided with the distribution.
12
+ * * Neither the name of Google LLC nor the
13
+ * names of its contributors may be used to endorse or promote products
14
+ * derived from this software without specific prior written permission.
15
+ *
16
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19
+ * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT,
20
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
+ */
27
+
28
+ #ifndef UPB_INT_H_
29
+ #define UPB_INT_H_
30
+
31
+ #include "upb/upb.h"
32
+
33
+ struct mem_block;
34
+ typedef struct mem_block mem_block;
35
+
36
+ struct upb_Arena {
37
+ _upb_ArenaHead head;
38
+ /* Stores cleanup metadata for this arena.
39
+ * - a pointer to the current cleanup counter.
40
+ * - a boolean indicating if there is an unowned initial block. */
41
+ uintptr_t cleanup_metadata;
42
+
43
+ /* Allocator to allocate arena blocks. We are responsible for freeing these
44
+ * when we are destroyed. */
45
+ upb_alloc* block_alloc;
46
+ uint32_t last_size;
47
+
48
+ /* When multiple arenas are fused together, each arena points to a parent
49
+ * arena (root points to itself). The root tracks how many live arenas
50
+ * reference it. */
51
+ uint32_t refcount; /* Only used when a->parent == a */
52
+ struct upb_Arena* parent;
53
+
54
+ /* Linked list of blocks to free/cleanup. */
55
+ mem_block *freelist, *freelist_tail;
56
+ };
57
+
58
+ // Encodes a float or double that is round-trippable, but as short as possible.
59
+ // These routines are not fully optimal (not guaranteed to be shortest), but are
60
+ // short-ish and match the implementation that has been used in protobuf since
61
+ // the beginning.
62
+ //
63
+ // The given buffer size must be at least kUpb_RoundTripBufferSize.
64
+ enum { kUpb_RoundTripBufferSize = 32 };
65
+ void _upb_EncodeRoundTripDouble(double val, char* buf, size_t size);
66
+ void _upb_EncodeRoundTripFloat(float val, char* buf, size_t size);
67
+
68
+ #endif /* UPB_INT_H_ */
@@ -0,0 +1,121 @@
1
+ load(
2
+ "//bazel:upb_proto_library.bzl",
3
+ "upb_proto_library",
4
+ "upb_proto_reflection_library",
5
+ )
6
+
7
+ licenses(["notice"])
8
+
9
+ # Def to Proto
10
+
11
+ cc_library(
12
+ name = "def_to_proto",
13
+ srcs = ["def_to_proto.c"],
14
+ hdrs = ["def_to_proto.h"],
15
+ visibility = ["//visibility:public"],
16
+ deps = [
17
+ "//:port",
18
+ "//:reflection",
19
+ ],
20
+ )
21
+
22
+ proto_library(
23
+ name = "def_to_proto_test_proto",
24
+ srcs = [
25
+ "def_to_proto_public_import_test.proto",
26
+ "def_to_proto_regular_import_test.proto",
27
+ "def_to_proto_test.proto",
28
+ ],
29
+ )
30
+
31
+ upb_proto_library(
32
+ name = "def_to_proto_test_upb_proto",
33
+ deps = ["def_to_proto_test_proto"],
34
+ )
35
+
36
+ upb_proto_reflection_library(
37
+ name = "def_to_proto_test_upb_proto_reflection",
38
+ deps = ["def_to_proto_test_proto"],
39
+ )
40
+
41
+ cc_test(
42
+ name = "def_to_proto_test",
43
+ srcs = ["def_to_proto_test.cc"],
44
+ deps = [
45
+ ":def_to_proto",
46
+ ":def_to_proto_test_upb_proto",
47
+ ":def_to_proto_test_upb_proto_reflection",
48
+ "//:descriptor_upb_proto_reflection",
49
+ "//:reflection",
50
+ "//:upb",
51
+ "@com_google_absl//absl/strings",
52
+ "@com_google_googletest//:gtest_main",
53
+ "@com_google_protobuf//:protobuf",
54
+ ],
55
+ )
56
+
57
+ # Required fields
58
+
59
+ cc_library(
60
+ name = "required_fields",
61
+ srcs = ["required_fields.c"],
62
+ hdrs = ["required_fields.h"],
63
+ visibility = ["//visibility:public"],
64
+ deps = [
65
+ "//:port",
66
+ "//:reflection",
67
+ ],
68
+ )
69
+
70
+ proto_library(
71
+ name = "required_fields_test_proto",
72
+ srcs = ["required_fields_test.proto"],
73
+ )
74
+
75
+ upb_proto_library(
76
+ name = "required_fields_test_upb_proto",
77
+ deps = ["required_fields_test_proto"],
78
+ )
79
+
80
+ upb_proto_reflection_library(
81
+ name = "required_fields_test_upb_proto_reflection",
82
+ deps = ["required_fields_test_proto"],
83
+ )
84
+
85
+ cc_test(
86
+ name = "required_fields_test",
87
+ srcs = ["required_fields_test.cc"],
88
+ deps = [
89
+ ":required_fields",
90
+ ":required_fields_test_upb_proto",
91
+ ":required_fields_test_upb_proto_reflection",
92
+ "//:json",
93
+ "//:reflection",
94
+ "//:upb",
95
+ "@com_google_absl//absl/strings",
96
+ "@com_google_googletest//:gtest_main",
97
+ ],
98
+ )
99
+
100
+ # Compare
101
+
102
+ cc_library(
103
+ name = "compare",
104
+ srcs = ["compare.c"],
105
+ hdrs = ["compare.h"],
106
+ visibility = ["//visibility:public"],
107
+ deps = [
108
+ "//:port",
109
+ "//:reflection",
110
+ ],
111
+ )
112
+
113
+ cc_test(
114
+ name = "compare_test",
115
+ srcs = ["compare_test.cc"],
116
+ deps = [
117
+ ":compare",
118
+ "@com_google_absl//absl/strings",
119
+ "@com_google_googletest//:gtest_main",
120
+ ],
121
+ )
@@ -0,0 +1,7 @@
1
+
2
+ # upb util library
3
+
4
+ The libraries in this directory contain useful functionality that is layered
5
+ on top of the main upb APIs. In other words, the APIs in this directory have
6
+ no special access to upb internals; you could easily implement the same things
7
+ yourself.