google-protobuf 3.22.0 → 3.25.5
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 +4 -4
- data/ext/google/protobuf_c/Rakefile +3 -0
- data/ext/google/protobuf_c/convert.c +23 -70
- data/ext/google/protobuf_c/convert.h +3 -28
- data/ext/google/protobuf_c/defs.c +175 -52
- data/ext/google/protobuf_c/defs.h +3 -28
- data/ext/google/protobuf_c/extconf.rb +2 -1
- data/ext/google/protobuf_c/glue.c +56 -0
- data/ext/google/protobuf_c/map.c +27 -28
- data/ext/google/protobuf_c/map.h +6 -28
- data/ext/google/protobuf_c/message.c +83 -83
- data/ext/google/protobuf_c/message.h +10 -28
- data/ext/google/protobuf_c/protobuf.c +39 -176
- data/ext/google/protobuf_c/protobuf.h +24 -32
- data/ext/google/protobuf_c/repeated_field.c +28 -29
- data/ext/google/protobuf_c/repeated_field.h +6 -28
- data/ext/google/protobuf_c/ruby-upb.c +2982 -2494
- data/ext/google/protobuf_c/ruby-upb.h +5838 -3467
- data/ext/google/protobuf_c/shared_convert.c +64 -0
- data/ext/google/protobuf_c/shared_convert.h +26 -0
- data/ext/google/protobuf_c/shared_message.c +65 -0
- data/ext/google/protobuf_c/shared_message.h +25 -0
- data/ext/google/protobuf_c/wrap_memcpy.c +3 -26
- data/lib/google/protobuf/any_pb.rb +24 -5
- data/lib/google/protobuf/api_pb.rb +26 -23
- data/lib/google/protobuf/descriptor_pb.rb +40 -252
- data/lib/google/protobuf/duration_pb.rb +24 -5
- data/lib/google/protobuf/empty_pb.rb +24 -3
- data/lib/google/protobuf/ffi/descriptor.rb +165 -0
- data/lib/google/protobuf/ffi/descriptor_pool.rb +75 -0
- data/lib/google/protobuf/ffi/enum_descriptor.rb +171 -0
- data/lib/google/protobuf/ffi/ffi.rb +213 -0
- data/lib/google/protobuf/ffi/field_descriptor.rb +319 -0
- data/lib/google/protobuf/ffi/file_descriptor.rb +59 -0
- data/lib/google/protobuf/ffi/internal/arena.rb +66 -0
- data/lib/google/protobuf/ffi/internal/convert.rb +305 -0
- data/lib/google/protobuf/ffi/internal/pointer_helper.rb +35 -0
- data/lib/google/protobuf/ffi/internal/type_safety.rb +25 -0
- data/lib/google/protobuf/ffi/map.rb +407 -0
- data/lib/google/protobuf/ffi/message.rb +662 -0
- data/lib/google/protobuf/ffi/object_cache.rb +30 -0
- data/lib/google/protobuf/ffi/oneof_descriptor.rb +95 -0
- data/lib/google/protobuf/ffi/repeated_field.rb +383 -0
- data/lib/google/protobuf/field_mask_pb.rb +24 -4
- data/lib/google/protobuf/message_exts.rb +3 -26
- data/lib/google/protobuf/object_cache.rb +97 -0
- data/lib/google/protobuf/plugin_pb.rb +25 -28
- data/lib/google/protobuf/repeated_field.rb +3 -26
- data/lib/google/protobuf/source_context_pb.rb +24 -4
- data/lib/google/protobuf/struct_pb.rb +24 -20
- data/lib/google/protobuf/timestamp_pb.rb +24 -5
- data/lib/google/protobuf/type_pb.rb +26 -68
- data/lib/google/protobuf/well_known_types.rb +5 -34
- data/lib/google/protobuf/wrappers_pb.rb +24 -28
- data/lib/google/protobuf.rb +27 -45
- data/lib/google/protobuf_ffi.rb +50 -0
- data/lib/google/protobuf_native.rb +20 -0
- data/lib/google/tasks/ffi.rake +102 -0
- metadata +72 -4
@@ -0,0 +1,64 @@
|
|
1
|
+
// Protocol Buffers - Google's data interchange format
|
2
|
+
// Copyright 2023 Google Inc. All rights reserved.
|
3
|
+
//
|
4
|
+
// Use of this source code is governed by a BSD-style
|
5
|
+
// license that can be found in the LICENSE file or at
|
6
|
+
// https://developers.google.com/open-source/licenses/bsd
|
7
|
+
|
8
|
+
// -----------------------------------------------------------------------------
|
9
|
+
// Ruby <-> upb data conversion functions. Strictly free of dependencies on
|
10
|
+
// Ruby interpreter internals.
|
11
|
+
|
12
|
+
#include "shared_convert.h"
|
13
|
+
|
14
|
+
bool shared_Msgval_IsEqual(upb_MessageValue val1, upb_MessageValue val2,
|
15
|
+
upb_CType type, upb_MessageDef* msgdef,
|
16
|
+
upb_Status* status) {
|
17
|
+
switch (type) {
|
18
|
+
case kUpb_CType_Bool:
|
19
|
+
return memcmp(&val1, &val2, 1) == 0;
|
20
|
+
case kUpb_CType_Float:
|
21
|
+
case kUpb_CType_Int32:
|
22
|
+
case kUpb_CType_UInt32:
|
23
|
+
case kUpb_CType_Enum:
|
24
|
+
return memcmp(&val1, &val2, 4) == 0;
|
25
|
+
case kUpb_CType_Double:
|
26
|
+
case kUpb_CType_Int64:
|
27
|
+
case kUpb_CType_UInt64:
|
28
|
+
return memcmp(&val1, &val2, 8) == 0;
|
29
|
+
case kUpb_CType_String:
|
30
|
+
case kUpb_CType_Bytes:
|
31
|
+
return val1.str_val.size == val2.str_val.size &&
|
32
|
+
memcmp(val1.str_val.data, val2.str_val.data, val1.str_val.size) ==
|
33
|
+
0;
|
34
|
+
case kUpb_CType_Message:
|
35
|
+
return shared_Message_Equal(val1.msg_val, val2.msg_val, msgdef, status);
|
36
|
+
default:
|
37
|
+
upb_Status_SetErrorMessage(status, "Internal error, unexpected type");
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
uint64_t shared_Msgval_GetHash(upb_MessageValue val, upb_CType type,
|
42
|
+
upb_MessageDef* msgdef, uint64_t seed,
|
43
|
+
upb_Status* status) {
|
44
|
+
switch (type) {
|
45
|
+
case kUpb_CType_Bool:
|
46
|
+
return _upb_Hash(&val, 1, seed);
|
47
|
+
case kUpb_CType_Float:
|
48
|
+
case kUpb_CType_Int32:
|
49
|
+
case kUpb_CType_UInt32:
|
50
|
+
case kUpb_CType_Enum:
|
51
|
+
return _upb_Hash(&val, 4, seed);
|
52
|
+
case kUpb_CType_Double:
|
53
|
+
case kUpb_CType_Int64:
|
54
|
+
case kUpb_CType_UInt64:
|
55
|
+
return _upb_Hash(&val, 8, seed);
|
56
|
+
case kUpb_CType_String:
|
57
|
+
case kUpb_CType_Bytes:
|
58
|
+
return _upb_Hash(val.str_val.data, val.str_val.size, seed);
|
59
|
+
case kUpb_CType_Message:
|
60
|
+
return shared_Message_Hash(val.msg_val, msgdef, seed, status);
|
61
|
+
default:
|
62
|
+
upb_Status_SetErrorMessage(status, "Internal error, unexpected type");
|
63
|
+
}
|
64
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
// Protocol Buffers - Google's data interchange format
|
2
|
+
// Copyright 2023 Google Inc. All rights reserved.
|
3
|
+
//
|
4
|
+
// Use of this source code is governed by a BSD-style
|
5
|
+
// license that can be found in the LICENSE file or at
|
6
|
+
// https://developers.google.com/open-source/licenses/bsd
|
7
|
+
|
8
|
+
// -----------------------------------------------------------------------------
|
9
|
+
// Ruby <-> upb data conversion functions. Strictly free of dependencies on
|
10
|
+
// Ruby interpreter internals.
|
11
|
+
|
12
|
+
#ifndef RUBY_PROTOBUF_SHARED_CONVERT_H_
|
13
|
+
#define RUBY_PROTOBUF_SHARED_CONVERT_H_
|
14
|
+
|
15
|
+
#include "ruby-upb.h"
|
16
|
+
#include "shared_message.h"
|
17
|
+
|
18
|
+
bool shared_Msgval_IsEqual(upb_MessageValue val1, upb_MessageValue val2,
|
19
|
+
upb_CType type, upb_MessageDef* msgdef,
|
20
|
+
upb_Status* status);
|
21
|
+
|
22
|
+
uint64_t shared_Msgval_GetHash(upb_MessageValue val, upb_CType type,
|
23
|
+
upb_MessageDef* msgdef, uint64_t seed,
|
24
|
+
upb_Status* status);
|
25
|
+
|
26
|
+
#endif // RUBY_PROTOBUF_SHARED_CONVERT_H_
|
@@ -0,0 +1,65 @@
|
|
1
|
+
// Protocol Buffers - Google's data interchange format
|
2
|
+
// Copyright 2023 Google Inc. All rights reserved.
|
3
|
+
//
|
4
|
+
// Use of this source code is governed by a BSD-style
|
5
|
+
// license that can be found in the LICENSE file or at
|
6
|
+
// https://developers.google.com/open-source/licenses/bsd
|
7
|
+
|
8
|
+
// -----------------------------------------------------------------------------
|
9
|
+
// Ruby Message functions. Strictly free of dependencies on
|
10
|
+
// Ruby interpreter internals.
|
11
|
+
|
12
|
+
#include "shared_message.h"
|
13
|
+
|
14
|
+
// Support function for Message_Hash. Returns a hash value for the given
|
15
|
+
// message.
|
16
|
+
uint64_t shared_Message_Hash(const upb_Message* msg, const upb_MessageDef* m,
|
17
|
+
uint64_t seed, upb_Status* status) {
|
18
|
+
upb_Arena* arena = upb_Arena_New();
|
19
|
+
char* data;
|
20
|
+
size_t size;
|
21
|
+
|
22
|
+
// Hash a deterministically serialized payloads with no unknown fields.
|
23
|
+
upb_EncodeStatus encode_status = upb_Encode(
|
24
|
+
msg, upb_MessageDef_MiniTable(m),
|
25
|
+
kUpb_EncodeOption_SkipUnknown | kUpb_EncodeOption_Deterministic, arena,
|
26
|
+
&data, &size);
|
27
|
+
|
28
|
+
if (encode_status == kUpb_EncodeStatus_Ok) {
|
29
|
+
uint64_t ret = _upb_Hash(data, size, seed);
|
30
|
+
upb_Arena_Free(arena);
|
31
|
+
return ret;
|
32
|
+
} else {
|
33
|
+
upb_Arena_Free(arena);
|
34
|
+
upb_Status_SetErrorMessage(status, "Error calculating hash");
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
// Support function for Message_Equal
|
39
|
+
bool shared_Message_Equal(const upb_Message* m1, const upb_Message* m2,
|
40
|
+
const upb_MessageDef* m, upb_Status* status) {
|
41
|
+
if (m1 == m2) return true;
|
42
|
+
|
43
|
+
size_t size1, size2;
|
44
|
+
int encode_opts =
|
45
|
+
kUpb_EncodeOption_SkipUnknown | kUpb_EncodeOption_Deterministic;
|
46
|
+
upb_Arena* arena_tmp = upb_Arena_New();
|
47
|
+
const upb_MiniTable* layout = upb_MessageDef_MiniTable(m);
|
48
|
+
|
49
|
+
// Compare deterministically serialized payloads with no unknown fields.
|
50
|
+
char* data1;
|
51
|
+
char* data2;
|
52
|
+
upb_EncodeStatus status1 =
|
53
|
+
upb_Encode(m1, layout, encode_opts, arena_tmp, &data1, &size1);
|
54
|
+
upb_EncodeStatus status2 =
|
55
|
+
upb_Encode(m2, layout, encode_opts, arena_tmp, &data2, &size2);
|
56
|
+
|
57
|
+
if (status1 == kUpb_EncodeStatus_Ok && status2 == kUpb_EncodeStatus_Ok) {
|
58
|
+
bool ret = (size1 == size2) && (memcmp(data1, data2, size1) == 0);
|
59
|
+
upb_Arena_Free(arena_tmp);
|
60
|
+
return ret;
|
61
|
+
} else {
|
62
|
+
upb_Arena_Free(arena_tmp);
|
63
|
+
upb_Status_SetErrorMessage(status, "Error comparing messages");
|
64
|
+
}
|
65
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
// Protocol Buffers - Google's data interchange format
|
2
|
+
// Copyright 2023 Google Inc. All rights reserved.
|
3
|
+
//
|
4
|
+
// Use of this source code is governed by a BSD-style
|
5
|
+
// license that can be found in the LICENSE file or at
|
6
|
+
// https://developers.google.com/open-source/licenses/bsd
|
7
|
+
|
8
|
+
// -----------------------------------------------------------------------------
|
9
|
+
// Ruby Message functions. Strictly free of dependencies on
|
10
|
+
// Ruby interpreter internals.
|
11
|
+
|
12
|
+
#ifndef RUBY_PROTOBUF_SHARED_MESSAGE_H_
|
13
|
+
#define RUBY_PROTOBUF_SHARED_MESSAGE_H_
|
14
|
+
|
15
|
+
#include "ruby-upb.h"
|
16
|
+
|
17
|
+
// Returns a hash value for the given message.
|
18
|
+
uint64_t shared_Message_Hash(const upb_Message* msg, const upb_MessageDef* m,
|
19
|
+
uint64_t seed, upb_Status* status);
|
20
|
+
|
21
|
+
// Returns true if these two messages are equal.
|
22
|
+
bool shared_Message_Equal(const upb_Message* m1, const upb_Message* m2,
|
23
|
+
const upb_MessageDef* m, upb_Status* status);
|
24
|
+
|
25
|
+
#endif // RUBY_PROTOBUF_SHARED_MESSAGE_H_
|
@@ -1,32 +1,9 @@
|
|
1
1
|
// Protocol Buffers - Google's data interchange format
|
2
2
|
// Copyright 2017 Google Inc. All rights reserved.
|
3
|
-
// https://developers.google.com/protocol-buffers/
|
4
3
|
//
|
5
|
-
//
|
6
|
-
//
|
7
|
-
//
|
8
|
-
//
|
9
|
-
// * Redistributions of source code must retain the above copyright
|
10
|
-
// notice, this list of conditions and the following disclaimer.
|
11
|
-
// * Redistributions in binary form must reproduce the above
|
12
|
-
// copyright notice, this list of conditions and the following disclaimer
|
13
|
-
// in the documentation and/or other materials provided with the
|
14
|
-
// distribution.
|
15
|
-
// * Neither the name of Google Inc. nor the names of its
|
16
|
-
// contributors may be used to endorse or promote products derived from
|
17
|
-
// this software without specific prior written permission.
|
18
|
-
//
|
19
|
-
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
20
|
-
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
21
|
-
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
22
|
-
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
23
|
-
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
24
|
-
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
25
|
-
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
26
|
-
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
27
|
-
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
28
|
-
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
29
|
-
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
4
|
+
// Use of this source code is governed by a BSD-style
|
5
|
+
// license that can be found in the LICENSE file or at
|
6
|
+
// https://developers.google.com/open-source/licenses/bsd
|
30
7
|
|
31
8
|
#include <string.h>
|
32
9
|
|
@@ -1,15 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
3
|
# source: google/protobuf/any.proto
|
3
4
|
|
4
5
|
require 'google/protobuf'
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
|
8
|
+
descriptor_data = "\n\x19google/protobuf/any.proto\x12\x0fgoogle.protobuf\"&\n\x03\x41ny\x12\x10\n\x08type_url\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x0c\x42v\n\x13\x63om.google.protobufB\x08\x41nyProtoP\x01Z,google.golang.org/protobuf/types/known/anypb\xa2\x02\x03GPB\xaa\x02\x1eGoogle.Protobuf.WellKnownTypesb\x06proto3"
|
9
|
+
|
10
|
+
pool = Google::Protobuf::DescriptorPool.generated_pool
|
11
|
+
|
12
|
+
begin
|
13
|
+
pool.add_serialized_file(descriptor_data)
|
14
|
+
rescue TypeError
|
15
|
+
# Compatibility code: will be removed in the next major version.
|
16
|
+
require 'google/protobuf/descriptor_pb'
|
17
|
+
parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data)
|
18
|
+
parsed.clear_dependency
|
19
|
+
serialized = parsed.class.encode(parsed)
|
20
|
+
file = pool.add_serialized_file(serialized)
|
21
|
+
warn "Warning: Protobuf detected an import path issue while loading generated file #{__FILE__}"
|
22
|
+
imports = [
|
23
|
+
]
|
24
|
+
imports.each do |type_name, expected_filename|
|
25
|
+
import_file = pool.lookup(type_name).file_descriptor
|
26
|
+
if import_file.name != expected_filename
|
27
|
+
warn "- #{file.name} imports #{expected_filename}, but that import was loaded as #{import_file.name}"
|
11
28
|
end
|
12
29
|
end
|
30
|
+
warn "Each proto file must use a consistent fully-qualified name."
|
31
|
+
warn "This will become an error in the next major version."
|
13
32
|
end
|
14
33
|
|
15
34
|
module Google
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
3
|
# source: google/protobuf/api.proto
|
3
4
|
|
@@ -6,31 +7,33 @@ require 'google/protobuf'
|
|
6
7
|
require 'google/protobuf/source_context_pb'
|
7
8
|
require 'google/protobuf/type_pb'
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
10
|
+
|
11
|
+
descriptor_data = "\n\x19google/protobuf/api.proto\x12\x0fgoogle.protobuf\x1a$google/protobuf/source_context.proto\x1a\x1agoogle/protobuf/type.proto\"\x81\x02\n\x03\x41pi\x12\x0c\n\x04name\x18\x01 \x01(\t\x12(\n\x07methods\x18\x02 \x03(\x0b\x32\x17.google.protobuf.Method\x12(\n\x07options\x18\x03 \x03(\x0b\x32\x17.google.protobuf.Option\x12\x0f\n\x07version\x18\x04 \x01(\t\x12\x36\n\x0esource_context\x18\x05 \x01(\x0b\x32\x1e.google.protobuf.SourceContext\x12&\n\x06mixins\x18\x06 \x03(\x0b\x32\x16.google.protobuf.Mixin\x12\'\n\x06syntax\x18\x07 \x01(\x0e\x32\x17.google.protobuf.Syntax\"\xd5\x01\n\x06Method\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x18\n\x10request_type_url\x18\x02 \x01(\t\x12\x19\n\x11request_streaming\x18\x03 \x01(\x08\x12\x19\n\x11response_type_url\x18\x04 \x01(\t\x12\x1a\n\x12response_streaming\x18\x05 \x01(\x08\x12(\n\x07options\x18\x06 \x03(\x0b\x32\x17.google.protobuf.Option\x12\'\n\x06syntax\x18\x07 \x01(\x0e\x32\x17.google.protobuf.Syntax\"#\n\x05Mixin\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0c\n\x04root\x18\x02 \x01(\tBv\n\x13\x63om.google.protobufB\x08\x41piProtoP\x01Z,google.golang.org/protobuf/types/known/apipb\xa2\x02\x03GPB\xaa\x02\x1eGoogle.Protobuf.WellKnownTypesb\x06proto3"
|
12
|
+
|
13
|
+
pool = Google::Protobuf::DescriptorPool.generated_pool
|
14
|
+
|
15
|
+
begin
|
16
|
+
pool.add_serialized_file(descriptor_data)
|
17
|
+
rescue TypeError
|
18
|
+
# Compatibility code: will be removed in the next major version.
|
19
|
+
require 'google/protobuf/descriptor_pb'
|
20
|
+
parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data)
|
21
|
+
parsed.clear_dependency
|
22
|
+
serialized = parsed.class.encode(parsed)
|
23
|
+
file = pool.add_serialized_file(serialized)
|
24
|
+
warn "Warning: Protobuf detected an import path issue while loading generated file #{__FILE__}"
|
25
|
+
imports = [
|
26
|
+
["google.protobuf.Option", "google/protobuf/type.proto"],
|
27
|
+
["google.protobuf.SourceContext", "google/protobuf/source_context.proto"],
|
28
|
+
]
|
29
|
+
imports.each do |type_name, expected_filename|
|
30
|
+
import_file = pool.lookup(type_name).file_descriptor
|
31
|
+
if import_file.name != expected_filename
|
32
|
+
warn "- #{file.name} imports #{expected_filename}, but that import was loaded as #{import_file.name}"
|
32
33
|
end
|
33
34
|
end
|
35
|
+
warn "Each proto file must use a consistent fully-qualified name."
|
36
|
+
warn "This will become an error in the next major version."
|
34
37
|
end
|
35
38
|
|
36
39
|
module Google
|