ruby_memprofiler_pprof 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/ext/ruby_memprofiler_pprof/backtrace.c +429 -0
- data/ext/ruby_memprofiler_pprof/collector.c +1055 -0
- data/ext/ruby_memprofiler_pprof/compat.c +182 -0
- data/ext/ruby_memprofiler_pprof/extconf.rb +72 -0
- data/ext/ruby_memprofiler_pprof/pprof.upb.c +170 -0
- data/ext/ruby_memprofiler_pprof/pprof.upb.h +848 -0
- data/ext/ruby_memprofiler_pprof/pprof_out.c +285 -0
- data/ext/ruby_memprofiler_pprof/ruby_memprofiler_pprof.c +11 -0
- data/ext/ruby_memprofiler_pprof/ruby_memprofiler_pprof.h +301 -0
- data/ext/ruby_memprofiler_pprof/strtab.c +391 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/BUILD +719 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/CONTRIBUTING.md +37 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/DESIGN.md +201 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/LICENSE +26 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/README.md +78 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/WORKSPACE +58 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/BUILD +53 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/amalgamate.py +129 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/build_defs.bzl +160 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/lua.BUILD +127 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/protobuf.patch +54 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/py_proto_library.bzl +137 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/python_downloads.bzl +84 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/system_python.bzl +101 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/upb_proto_library.bzl +388 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/workspace_deps.bzl +89 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/BUILD +252 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/BUILD.googleapis +54 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/benchmark.cc +333 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/build_defs.bzl +88 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/compare.py +118 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/descriptor.proto +888 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/descriptor_sv.proto +890 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/empty.proto +6 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/gen_protobuf_binary_cc.py +64 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/gen_synthetic_protos.py +118 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/gen_upb_binary_c.py +65 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/cmake/BUILD.bazel +102 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/cmake/README.md +23 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/cmake/build_defs.bzl +73 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/cmake/make_cmakelists.py +340 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/cmake/staleness_test.py +57 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/cmake/staleness_test_lib.py +186 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/docs/render.py +43 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/docs/style-guide.md +65 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/docs/vs-cpp-protos.md +255 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/docs/wrapping-upb.md +444 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/BUILD +216 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/convert.c +394 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/convert.h +63 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/descriptor.c +1694 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/descriptor.h +80 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/descriptor_containers.c +704 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/descriptor_containers.h +114 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/descriptor_pool.c +650 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/descriptor_pool.h +48 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/dist/BUILD.bazel +193 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/dist/dist.bzl +190 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/extension_dict.c +247 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/extension_dict.h +39 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/map.c +522 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/map.h +66 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/message.c +1909 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/message.h +101 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/minimal_test.py +183 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/BUILD +70 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/README.md +11 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/descriptor_database_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/descriptor_pool_test_wrapper.py +45 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/descriptor_test_wrapper.py +46 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/generator_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/json_format_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/keywords_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/message_factory_test_wrapper.py +37 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/message_test_wrapper.py +52 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/proto_builder_test_wrapper.py +32 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/pyproto_test_wrapper.bzl +36 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/reflection_test_wrapper.py +45 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/service_reflection_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/symbol_database_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/text_encoding_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/text_format_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/unknown_fields_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/well_known_types_test_wrapper.py +36 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/wire_format_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/protobuf.c +350 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/protobuf.h +230 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/py_extension.bzl +55 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/python_api.h +61 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/repeated.c +828 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/repeated.h +69 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/unknown_fields.c +404 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/unknown_fields.h +39 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/version_script.lds +6 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/lunit/LICENSE +32 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/lunit/README.google +9 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/lunit/console.lua +156 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/lunit/lunit.lua +725 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/utf8_range/BUILD +19 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/utf8_range/LICENSE +21 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/utf8_range/naive.c +92 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/utf8_range/range2-neon.c +157 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/utf8_range/range2-sse.c +170 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/utf8_range/utf8_range.h +9 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/BUILD.bazel +129 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/README.md +8 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/def.c +939 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/lua_proto_library.bzl +138 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/main.c +83 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/msg.c +1118 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/test.proto +69 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/test_upb.lua +846 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/upb.c +258 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/upb.h +132 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/upb.lua +58 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/upbc.cc +134 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/collections.c +192 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/collections.h +174 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/conformance_upb.c +346 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/conformance_upb_failures.txt +1 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/decode.c +1221 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/decode.h +94 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/decode_fast.c +1055 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/decode_fast.h +153 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/decode_internal.h +211 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/def.c +3262 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/def.h +414 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/def.hpp +438 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/empty.proto +1 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/encode.c +604 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/encode.h +71 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/fuzz/BUILD +13 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/fuzz/file_descriptor_parsenew_fuzzer.cc +43 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/json_decode.c +1509 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/json_decode.h +47 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/json_encode.c +776 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/json_encode.h +62 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table.c +1147 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table.h +189 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table.hpp +112 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table_accessors.c +363 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table_accessors.h +263 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table_accessors_internal.h +59 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table_accessors_test.cc +425 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table_test.cc +230 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/msg.c +428 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/msg.h +114 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/msg_internal.h +836 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/msg_test.cc +491 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/msg_test.proto +195 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/port_def.inc +261 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/port_undef.inc +62 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/reflection.c +323 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/reflection.h +109 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/reflection.hpp +37 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/table.c +926 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/table_internal.h +385 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/test.proto +74 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/test_cpp.cc +186 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/test_cpp.proto +12 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/test_generated_code.cc +977 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/test_table.cc +580 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/text_encode.c +472 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/text_encode.h +64 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/upb.c +362 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/upb.h +378 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/upb.hpp +115 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/upb_internal.h +68 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/BUILD +121 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/README.md +7 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/compare.c +300 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/compare.h +66 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/compare_test.cc +236 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto.c +572 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto.h +62 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto_public_import_test.proto +32 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto_regular_import_test.proto +36 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto_test.cc +143 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto_test.proto +119 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto_weak_import_test.proto +28 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto_wweak_import_test.proto +28 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/required_fields.c +311 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/required_fields.h +94 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/required_fields_test.cc +202 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/required_fields_test.proto +48 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upbc/BUILD +78 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upbc/common.cc +77 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upbc/common.h +112 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upbc/protoc-gen-upb.cc +1997 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upbc/protoc-gen-upbdefs.cc +193 -0
- data/lib/ruby_memprofiler_pprof/atfork.rb +77 -0
- data/lib/ruby_memprofiler_pprof/block_flusher.rb +61 -0
- data/lib/ruby_memprofiler_pprof/file_flusher.rb +45 -0
- data/lib/ruby_memprofiler_pprof/profile_app.rb +30 -0
- data/lib/ruby_memprofiler_pprof/profile_data.rb +18 -0
- data/lib/ruby_memprofiler_pprof/version.rb +5 -0
- data/lib/ruby_memprofiler_pprof.rb +8 -0
- data/libexec/ruby_memprofiler_pprof_profile +16 -0
- metadata +257 -0
|
@@ -0,0 +1,69 @@
|
|
|
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 PYUPB_REPEATED_H__
|
|
29
|
+
#define PYUPB_REPEATED_H__
|
|
30
|
+
|
|
31
|
+
#include <stdbool.h>
|
|
32
|
+
|
|
33
|
+
#include "python/python_api.h"
|
|
34
|
+
#include "upb/def.h"
|
|
35
|
+
|
|
36
|
+
// Creates a new repeated field stub for field `f` of message object `parent`.
|
|
37
|
+
// Precondition: `parent` must be a stub.
|
|
38
|
+
PyObject* PyUpb_RepeatedContainer_NewStub(PyObject* parent,
|
|
39
|
+
const upb_FieldDef* f,
|
|
40
|
+
PyObject* arena);
|
|
41
|
+
|
|
42
|
+
// Returns a repeated field object wrapping `arr`, of field type `f`, which
|
|
43
|
+
// must be on `arena`. If an existing wrapper object exists, it will be
|
|
44
|
+
// returned, otherwise a new object will be created. The caller always owns a
|
|
45
|
+
// ref on the returned value.
|
|
46
|
+
PyObject* PyUpb_RepeatedContainer_GetOrCreateWrapper(upb_Array* arr,
|
|
47
|
+
const upb_FieldDef* f,
|
|
48
|
+
PyObject* arena);
|
|
49
|
+
|
|
50
|
+
// Reifies a repeated field stub to point to the concrete data in `arr`.
|
|
51
|
+
// If `arr` is NULL, an appropriate empty array will be constructed.
|
|
52
|
+
void PyUpb_RepeatedContainer_Reify(PyObject* self, upb_Array* arr);
|
|
53
|
+
|
|
54
|
+
// Reifies this repeated object if it is not already reified.
|
|
55
|
+
upb_Array* PyUpb_RepeatedContainer_EnsureReified(PyObject* self);
|
|
56
|
+
|
|
57
|
+
// Implements repeated_field.extend(iterable). `_self` must be a repeated
|
|
58
|
+
// field (either repeated composite or repeated scalar).
|
|
59
|
+
PyObject* PyUpb_RepeatedContainer_Extend(PyObject* _self, PyObject* value);
|
|
60
|
+
|
|
61
|
+
// Implements repeated_field.add(initial_values). `_self` must be a repeated
|
|
62
|
+
// composite field.
|
|
63
|
+
PyObject* PyUpb_RepeatedCompositeContainer_Add(PyObject* _self, PyObject* args,
|
|
64
|
+
PyObject* kwargs);
|
|
65
|
+
|
|
66
|
+
// Module-level init.
|
|
67
|
+
bool PyUpb_Repeated_Init(PyObject* m);
|
|
68
|
+
|
|
69
|
+
#endif // PYUPB_REPEATED_H__
|
|
@@ -0,0 +1,404 @@
|
|
|
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
|
+
#include "python/unknown_fields.h"
|
|
29
|
+
|
|
30
|
+
#include "python/message.h"
|
|
31
|
+
#include "python/protobuf.h"
|
|
32
|
+
|
|
33
|
+
static const char* PyUpb_DecodeVarint(const char* ptr, const char* end,
|
|
34
|
+
uint64_t* val) {
|
|
35
|
+
*val = 0;
|
|
36
|
+
for (int i = 0; ptr < end && i < 10; i++, ptr++) {
|
|
37
|
+
uint64_t byte = (uint8_t)*ptr;
|
|
38
|
+
*val |= (byte & 0x7f) << (i * 7);
|
|
39
|
+
if ((byte & 0x80) == 0) {
|
|
40
|
+
return ptr + 1;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return NULL;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// -----------------------------------------------------------------------------
|
|
47
|
+
// UnknownFieldSet
|
|
48
|
+
// -----------------------------------------------------------------------------
|
|
49
|
+
|
|
50
|
+
typedef struct {
|
|
51
|
+
PyObject_HEAD;
|
|
52
|
+
PyObject* fields;
|
|
53
|
+
} PyUpb_UnknownFieldSet;
|
|
54
|
+
|
|
55
|
+
static void PyUpb_UnknownFieldSet_Dealloc(PyObject* _self) {
|
|
56
|
+
PyUpb_UnknownFieldSet* self = (PyUpb_UnknownFieldSet*)_self;
|
|
57
|
+
Py_XDECREF(self->fields);
|
|
58
|
+
PyUpb_Dealloc(self);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
PyUpb_UnknownFieldSet* PyUpb_UnknownFieldSet_NewBare(void) {
|
|
62
|
+
PyUpb_ModuleState* s = PyUpb_ModuleState_Get();
|
|
63
|
+
PyUpb_UnknownFieldSet* self =
|
|
64
|
+
(void*)PyType_GenericAlloc(s->unknown_fields_type, 0);
|
|
65
|
+
return self;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Generic functions to skip a value or group.
|
|
69
|
+
|
|
70
|
+
static const char* PyUpb_UnknownFieldSet_SkipGroup(const char* ptr,
|
|
71
|
+
const char* end,
|
|
72
|
+
int group_number);
|
|
73
|
+
|
|
74
|
+
static const char* PyUpb_UnknownFieldSet_SkipField(const char* ptr,
|
|
75
|
+
const char* end,
|
|
76
|
+
uint32_t tag) {
|
|
77
|
+
int field_number = tag >> 3;
|
|
78
|
+
int wire_type = tag & 7;
|
|
79
|
+
switch (wire_type) {
|
|
80
|
+
case kUpb_WireType_Varint: {
|
|
81
|
+
uint64_t val;
|
|
82
|
+
return PyUpb_DecodeVarint(ptr, end, &val);
|
|
83
|
+
}
|
|
84
|
+
case kUpb_WireType_64Bit:
|
|
85
|
+
if (end - ptr < 8) return NULL;
|
|
86
|
+
return ptr + 8;
|
|
87
|
+
case kUpb_WireType_32Bit:
|
|
88
|
+
if (end - ptr < 4) return NULL;
|
|
89
|
+
return ptr + 4;
|
|
90
|
+
case kUpb_WireType_Delimited: {
|
|
91
|
+
uint64_t size;
|
|
92
|
+
ptr = PyUpb_DecodeVarint(ptr, end, &size);
|
|
93
|
+
if (!ptr || end - ptr < size) return NULL;
|
|
94
|
+
return ptr + size;
|
|
95
|
+
}
|
|
96
|
+
case kUpb_WireType_StartGroup:
|
|
97
|
+
return PyUpb_UnknownFieldSet_SkipGroup(ptr, end, field_number);
|
|
98
|
+
case kUpb_WireType_EndGroup:
|
|
99
|
+
return NULL;
|
|
100
|
+
default:
|
|
101
|
+
assert(0);
|
|
102
|
+
return NULL;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
static const char* PyUpb_UnknownFieldSet_SkipGroup(const char* ptr,
|
|
107
|
+
const char* end,
|
|
108
|
+
int group_number) {
|
|
109
|
+
uint32_t end_tag = (group_number << 3) | kUpb_WireType_EndGroup;
|
|
110
|
+
while (true) {
|
|
111
|
+
if (ptr == end) return NULL;
|
|
112
|
+
uint64_t tag;
|
|
113
|
+
ptr = PyUpb_DecodeVarint(ptr, end, &tag);
|
|
114
|
+
if (!ptr) return NULL;
|
|
115
|
+
if (tag == end_tag) return ptr;
|
|
116
|
+
ptr = PyUpb_UnknownFieldSet_SkipField(ptr, end, tag);
|
|
117
|
+
if (!ptr) return NULL;
|
|
118
|
+
}
|
|
119
|
+
return ptr;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// For MessageSet the established behavior is for UnknownFieldSet to interpret
|
|
123
|
+
// the MessageSet wire format:
|
|
124
|
+
// message MessageSet {
|
|
125
|
+
// repeated group Item = 1 {
|
|
126
|
+
// required int32 type_id = 2;
|
|
127
|
+
// required bytes message = 3;
|
|
128
|
+
// }
|
|
129
|
+
// }
|
|
130
|
+
//
|
|
131
|
+
// And create unknown fields like:
|
|
132
|
+
// UnknownField(type_id, WIRE_TYPE_DELIMITED, message)
|
|
133
|
+
//
|
|
134
|
+
// For any unknown fields that are unexpected per the wire format defined above,
|
|
135
|
+
// we drop them on the floor.
|
|
136
|
+
|
|
137
|
+
enum {
|
|
138
|
+
kUpb_MessageSet_StartItemTag = (1 << 3) | kUpb_WireType_StartGroup,
|
|
139
|
+
kUpb_MessageSet_EndItemTag = (1 << 3) | kUpb_WireType_EndGroup,
|
|
140
|
+
kUpb_MessageSet_TypeIdTag = (2 << 3) | kUpb_WireType_Varint,
|
|
141
|
+
kUpb_MessageSet_MessageTag = (3 << 3) | kUpb_WireType_Delimited,
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
static const char* PyUpb_UnknownFieldSet_BuildMessageSetItem(
|
|
145
|
+
PyUpb_UnknownFieldSet* self, const char* ptr, const char* end) {
|
|
146
|
+
PyUpb_ModuleState* s = PyUpb_ModuleState_Get();
|
|
147
|
+
int type_id = 0;
|
|
148
|
+
PyObject* msg = NULL;
|
|
149
|
+
while (true) {
|
|
150
|
+
if (ptr == end) goto err;
|
|
151
|
+
uint64_t tag;
|
|
152
|
+
ptr = PyUpb_DecodeVarint(ptr, end, &tag);
|
|
153
|
+
if (!ptr) goto err;
|
|
154
|
+
switch (tag) {
|
|
155
|
+
case kUpb_MessageSet_EndItemTag:
|
|
156
|
+
goto done;
|
|
157
|
+
case kUpb_MessageSet_TypeIdTag: {
|
|
158
|
+
uint64_t tmp;
|
|
159
|
+
ptr = PyUpb_DecodeVarint(ptr, end, &tmp);
|
|
160
|
+
if (!ptr) goto err;
|
|
161
|
+
if (!type_id) type_id = tmp;
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
case kUpb_MessageSet_MessageTag: {
|
|
165
|
+
uint64_t size;
|
|
166
|
+
ptr = PyUpb_DecodeVarint(ptr, end, &size);
|
|
167
|
+
if (!ptr || end - ptr < size) goto err;
|
|
168
|
+
if (!msg) {
|
|
169
|
+
msg = PyBytes_FromStringAndSize(ptr, size);
|
|
170
|
+
if (!msg) goto err;
|
|
171
|
+
} else {
|
|
172
|
+
// already saw a message here so deliberately skipping the duplicate
|
|
173
|
+
}
|
|
174
|
+
ptr += size;
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
default:
|
|
178
|
+
ptr = PyUpb_UnknownFieldSet_SkipField(ptr, end, tag);
|
|
179
|
+
if (!ptr) goto err;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
done:
|
|
184
|
+
if (type_id && msg) {
|
|
185
|
+
PyObject* field = PyObject_CallFunction(
|
|
186
|
+
s->unknown_field_type, "iiO", type_id, kUpb_WireType_Delimited, msg);
|
|
187
|
+
PyList_Append(self->fields, field);
|
|
188
|
+
}
|
|
189
|
+
Py_XDECREF(msg);
|
|
190
|
+
return ptr;
|
|
191
|
+
|
|
192
|
+
err:
|
|
193
|
+
Py_XDECREF(msg);
|
|
194
|
+
return NULL;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
static const char* PyUpb_UnknownFieldSet_BuildMessageSet(
|
|
198
|
+
PyUpb_UnknownFieldSet* self, const char* ptr, const char* end) {
|
|
199
|
+
self->fields = PyList_New(0);
|
|
200
|
+
while (ptr < end) {
|
|
201
|
+
uint64_t tag;
|
|
202
|
+
ptr = PyUpb_DecodeVarint(ptr, end, &tag);
|
|
203
|
+
if (!ptr) goto err;
|
|
204
|
+
if (tag == kUpb_MessageSet_StartItemTag) {
|
|
205
|
+
ptr = PyUpb_UnknownFieldSet_BuildMessageSetItem(self, ptr, end);
|
|
206
|
+
} else {
|
|
207
|
+
ptr = PyUpb_UnknownFieldSet_SkipField(ptr, end, tag);
|
|
208
|
+
}
|
|
209
|
+
if (!ptr) goto err;
|
|
210
|
+
}
|
|
211
|
+
return ptr;
|
|
212
|
+
|
|
213
|
+
err:
|
|
214
|
+
Py_DECREF(self->fields);
|
|
215
|
+
self->fields = NULL;
|
|
216
|
+
return NULL;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
static const char* PyUpb_UnknownFieldSet_Build(PyUpb_UnknownFieldSet* self,
|
|
220
|
+
const char* ptr, const char* end,
|
|
221
|
+
int group_number);
|
|
222
|
+
|
|
223
|
+
static const char* PyUpb_UnknownFieldSet_BuildValue(
|
|
224
|
+
PyUpb_UnknownFieldSet* self, const char* ptr, const char* end,
|
|
225
|
+
int field_number, int wire_type, int group_number, PyObject** data) {
|
|
226
|
+
switch (wire_type) {
|
|
227
|
+
case kUpb_WireType_Varint: {
|
|
228
|
+
uint64_t val;
|
|
229
|
+
ptr = PyUpb_DecodeVarint(ptr, end, &val);
|
|
230
|
+
if (!ptr) return NULL;
|
|
231
|
+
*data = PyLong_FromUnsignedLongLong(val);
|
|
232
|
+
return ptr;
|
|
233
|
+
}
|
|
234
|
+
case kUpb_WireType_64Bit: {
|
|
235
|
+
if (end - ptr < 8) return NULL;
|
|
236
|
+
uint64_t val;
|
|
237
|
+
memcpy(&val, ptr, 8);
|
|
238
|
+
*data = PyLong_FromUnsignedLongLong(val);
|
|
239
|
+
return ptr + 8;
|
|
240
|
+
}
|
|
241
|
+
case kUpb_WireType_32Bit: {
|
|
242
|
+
if (end - ptr < 4) return NULL;
|
|
243
|
+
uint32_t val;
|
|
244
|
+
memcpy(&val, ptr, 4);
|
|
245
|
+
*data = PyLong_FromUnsignedLongLong(val);
|
|
246
|
+
return ptr + 4;
|
|
247
|
+
}
|
|
248
|
+
case kUpb_WireType_Delimited: {
|
|
249
|
+
uint64_t size;
|
|
250
|
+
ptr = PyUpb_DecodeVarint(ptr, end, &size);
|
|
251
|
+
if (!ptr || end - ptr < size) return NULL;
|
|
252
|
+
*data = PyBytes_FromStringAndSize(ptr, size);
|
|
253
|
+
return ptr + size;
|
|
254
|
+
}
|
|
255
|
+
case kUpb_WireType_StartGroup: {
|
|
256
|
+
PyUpb_UnknownFieldSet* sub = PyUpb_UnknownFieldSet_NewBare();
|
|
257
|
+
if (!sub) return NULL;
|
|
258
|
+
*data = &sub->ob_base;
|
|
259
|
+
return PyUpb_UnknownFieldSet_Build(sub, ptr, end, field_number);
|
|
260
|
+
}
|
|
261
|
+
default:
|
|
262
|
+
assert(0);
|
|
263
|
+
*data = NULL;
|
|
264
|
+
return NULL;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// For non-MessageSet we just build the unknown fields exactly as they exist on
|
|
269
|
+
// the wire.
|
|
270
|
+
static const char* PyUpb_UnknownFieldSet_Build(PyUpb_UnknownFieldSet* self,
|
|
271
|
+
const char* ptr, const char* end,
|
|
272
|
+
int group_number) {
|
|
273
|
+
PyUpb_ModuleState* s = PyUpb_ModuleState_Get();
|
|
274
|
+
self->fields = PyList_New(0);
|
|
275
|
+
while (ptr < end) {
|
|
276
|
+
uint64_t tag;
|
|
277
|
+
ptr = PyUpb_DecodeVarint(ptr, end, &tag);
|
|
278
|
+
if (!ptr) goto err;
|
|
279
|
+
PyObject* data = NULL;
|
|
280
|
+
int field_number = tag >> 3;
|
|
281
|
+
int wire_type = tag & 7;
|
|
282
|
+
if (wire_type == kUpb_WireType_EndGroup) {
|
|
283
|
+
if (field_number != group_number) return NULL;
|
|
284
|
+
return ptr;
|
|
285
|
+
}
|
|
286
|
+
ptr = PyUpb_UnknownFieldSet_BuildValue(self, ptr, end, field_number,
|
|
287
|
+
wire_type, group_number, &data);
|
|
288
|
+
if (!ptr) {
|
|
289
|
+
Py_XDECREF(data);
|
|
290
|
+
goto err;
|
|
291
|
+
}
|
|
292
|
+
assert(data);
|
|
293
|
+
PyObject* field = PyObject_CallFunction(s->unknown_field_type, "iiN",
|
|
294
|
+
field_number, wire_type, data);
|
|
295
|
+
PyList_Append(self->fields, field);
|
|
296
|
+
}
|
|
297
|
+
return ptr;
|
|
298
|
+
|
|
299
|
+
err:
|
|
300
|
+
Py_DECREF(self->fields);
|
|
301
|
+
self->fields = NULL;
|
|
302
|
+
return NULL;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
static PyObject* PyUpb_UnknownFieldSet_New(PyTypeObject* type, PyObject* args,
|
|
306
|
+
PyObject* kwargs) {
|
|
307
|
+
char* kwlist[] = {"message", 0};
|
|
308
|
+
PyObject* py_msg = NULL;
|
|
309
|
+
|
|
310
|
+
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O", kwlist, &py_msg)) {
|
|
311
|
+
return NULL;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
if (!PyUpb_CMessage_Verify(py_msg)) return NULL;
|
|
315
|
+
PyUpb_UnknownFieldSet* self = PyUpb_UnknownFieldSet_NewBare();
|
|
316
|
+
upb_Message* msg = PyUpb_CMessage_GetIfReified(py_msg);
|
|
317
|
+
if (!msg) return &self->ob_base;
|
|
318
|
+
|
|
319
|
+
size_t size;
|
|
320
|
+
const char* ptr = upb_Message_GetUnknown(msg, &size);
|
|
321
|
+
if (size == 0) return &self->ob_base;
|
|
322
|
+
|
|
323
|
+
const char* end = ptr + size;
|
|
324
|
+
const upb_MessageDef* msgdef = PyUpb_CMessage_GetMsgdef(py_msg);
|
|
325
|
+
|
|
326
|
+
bool ok;
|
|
327
|
+
if (upb_MessageDef_IsMessageSet(msgdef)) {
|
|
328
|
+
ok = PyUpb_UnknownFieldSet_BuildMessageSet(self, ptr, end) == end;
|
|
329
|
+
} else {
|
|
330
|
+
ok = PyUpb_UnknownFieldSet_Build(self, ptr, end, -1) == end;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
if (!ok) {
|
|
334
|
+
Py_DECREF(&self->ob_base);
|
|
335
|
+
return NULL;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
return &self->ob_base;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
static Py_ssize_t PyUpb_UnknownFieldSet_Length(PyObject* _self) {
|
|
342
|
+
PyUpb_UnknownFieldSet* self = (PyUpb_UnknownFieldSet*)_self;
|
|
343
|
+
return self->fields ? PyObject_Length(self->fields) : 0;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
static PyObject* PyUpb_UnknownFieldSet_GetItem(PyObject* _self,
|
|
347
|
+
Py_ssize_t index) {
|
|
348
|
+
PyUpb_UnknownFieldSet* self = (PyUpb_UnknownFieldSet*)_self;
|
|
349
|
+
if (!self->fields) {
|
|
350
|
+
PyErr_Format(PyExc_IndexError, "list index (%zd) out of range", index);
|
|
351
|
+
return NULL;
|
|
352
|
+
}
|
|
353
|
+
PyObject* ret = PyList_GetItem(self->fields, index);
|
|
354
|
+
if (ret) Py_INCREF(ret);
|
|
355
|
+
return ret;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
static PyType_Slot PyUpb_UnknownFieldSet_Slots[] = {
|
|
359
|
+
{Py_tp_new, &PyUpb_UnknownFieldSet_New},
|
|
360
|
+
{Py_tp_dealloc, &PyUpb_UnknownFieldSet_Dealloc},
|
|
361
|
+
{Py_sq_length, PyUpb_UnknownFieldSet_Length},
|
|
362
|
+
{Py_sq_item, PyUpb_UnknownFieldSet_GetItem},
|
|
363
|
+
{Py_tp_hash, PyObject_HashNotImplemented},
|
|
364
|
+
{0, NULL},
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
static PyType_Spec PyUpb_UnknownFieldSet_Spec = {
|
|
368
|
+
PYUPB_MODULE_NAME ".UnknownFieldSet", // tp_name
|
|
369
|
+
sizeof(PyUpb_UnknownFieldSet), // tp_basicsize
|
|
370
|
+
0, // tp_itemsize
|
|
371
|
+
Py_TPFLAGS_DEFAULT, // tp_flags
|
|
372
|
+
PyUpb_UnknownFieldSet_Slots,
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
// -----------------------------------------------------------------------------
|
|
376
|
+
// Top Level
|
|
377
|
+
// -----------------------------------------------------------------------------
|
|
378
|
+
|
|
379
|
+
PyObject* PyUpb_UnknownFieldSet_CreateNamedTuple(void) {
|
|
380
|
+
PyObject* mod = NULL;
|
|
381
|
+
PyObject* namedtuple = NULL;
|
|
382
|
+
PyObject* ret = NULL;
|
|
383
|
+
|
|
384
|
+
mod = PyImport_ImportModule("collections");
|
|
385
|
+
if (!mod) goto done;
|
|
386
|
+
namedtuple = PyObject_GetAttrString(mod, "namedtuple");
|
|
387
|
+
if (!namedtuple) goto done;
|
|
388
|
+
ret = PyObject_CallFunction(namedtuple, "s[sss]", "PyUnknownField",
|
|
389
|
+
"field_number", "wire_type", "data");
|
|
390
|
+
|
|
391
|
+
done:
|
|
392
|
+
Py_XDECREF(mod);
|
|
393
|
+
Py_XDECREF(namedtuple);
|
|
394
|
+
return ret;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
bool PyUpb_UnknownFields_Init(PyObject* m) {
|
|
398
|
+
PyUpb_ModuleState* s = PyUpb_ModuleState_GetFromModule(m);
|
|
399
|
+
|
|
400
|
+
s->unknown_fields_type = PyUpb_AddClass(m, &PyUpb_UnknownFieldSet_Spec);
|
|
401
|
+
s->unknown_field_type = PyUpb_UnknownFieldSet_CreateNamedTuple();
|
|
402
|
+
|
|
403
|
+
return s->unknown_fields_type && s->unknown_field_type;
|
|
404
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
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 PYUPB_UNKNOWN_FIELDS_H__
|
|
29
|
+
#define PYUPB_UNKNOWN_FIELDS_H__
|
|
30
|
+
|
|
31
|
+
#include <stdbool.h>
|
|
32
|
+
|
|
33
|
+
#include "python/python_api.h"
|
|
34
|
+
|
|
35
|
+
PyObject* PyUpb_UnknownFields_New(PyObject* msg);
|
|
36
|
+
|
|
37
|
+
bool PyUpb_UnknownFields_Init(PyObject* m);
|
|
38
|
+
|
|
39
|
+
#endif // PYUPB_UNKNOWN_FIELDS_H__
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
|
|
2
|
+
Lunit License
|
|
3
|
+
-------------
|
|
4
|
+
|
|
5
|
+
Lunit is written by Michael Roth <mroth@nessie.de> and is licensed
|
|
6
|
+
under the terms of the MIT license reproduced below.
|
|
7
|
+
|
|
8
|
+
========================================================================
|
|
9
|
+
|
|
10
|
+
Copyright (c) 2004-2010 Michael Roth <mroth@nessie.de>
|
|
11
|
+
|
|
12
|
+
Permission is hereby granted, free of charge, to any person
|
|
13
|
+
obtaining a copy of this software and associated documentation
|
|
14
|
+
files (the "Software"), to deal in the Software without restriction,
|
|
15
|
+
including without limitation the rights to use, copy, modify, merge,
|
|
16
|
+
publish, distribute, sublicense, and/or sell copies of the Software,
|
|
17
|
+
and to permit persons to whom the Software is furnished to do so,
|
|
18
|
+
subject to the following conditions:
|
|
19
|
+
|
|
20
|
+
The above copyright notice and this permission notice shall be
|
|
21
|
+
included in all copies or substantial portions of the Software.
|
|
22
|
+
|
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
24
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
25
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
26
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
27
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
28
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
29
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
30
|
+
|
|
31
|
+
========================================================================
|
|
32
|
+
|