google-protobuf 3.23.3 → 4.27.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.
Potentially problematic release.
This version of google-protobuf might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/ext/google/protobuf_c/Rakefile +3 -0
- data/ext/google/protobuf_c/convert.c +28 -72
- data/ext/google/protobuf_c/convert.h +3 -28
- data/ext/google/protobuf_c/defs.c +512 -60
- 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 +72 -0
- data/ext/google/protobuf_c/map.c +28 -36
- data/ext/google/protobuf_c/map.h +6 -28
- data/ext/google/protobuf_c/message.c +88 -143
- data/ext/google/protobuf_c/message.h +10 -32
- data/ext/google/protobuf_c/protobuf.c +49 -175
- data/ext/google/protobuf_c/protobuf.h +24 -32
- data/ext/google/protobuf_c/repeated_field.c +23 -33
- data/ext/google/protobuf_c/repeated_field.h +6 -28
- data/ext/google/protobuf_c/ruby-upb.c +13046 -10690
- data/ext/google/protobuf_c/ruby-upb.h +8405 -5836
- data/ext/google/protobuf_c/shared_convert.c +69 -0
- data/ext/google/protobuf_c/shared_convert.h +26 -0
- data/ext/google/protobuf_c/shared_message.c +37 -0
- data/ext/google/protobuf_c/shared_message.h +21 -0
- data/ext/google/protobuf_c/third_party/utf8_range/utf8_range.c +467 -0
- data/ext/google/protobuf_c/third_party/utf8_range/utf8_range.h +9 -8
- data/ext/google/protobuf_c/wrap_memcpy.c +3 -26
- data/lib/google/protobuf/any_pb.rb +1 -22
- data/lib/google/protobuf/api_pb.rb +1 -24
- data/lib/google/protobuf/descriptor_pb.rb +14 -23
- data/lib/google/protobuf/duration_pb.rb +1 -22
- data/lib/google/protobuf/empty_pb.rb +1 -22
- data/lib/google/protobuf/ffi/descriptor.rb +166 -0
- data/lib/google/protobuf/ffi/descriptor_pool.rb +77 -0
- data/lib/google/protobuf/ffi/enum_descriptor.rb +173 -0
- data/lib/google/protobuf/ffi/ffi.rb +210 -0
- data/lib/google/protobuf/ffi/field_descriptor.rb +330 -0
- data/lib/google/protobuf/ffi/file_descriptor.rb +49 -0
- data/lib/google/protobuf/ffi/internal/arena.rb +66 -0
- data/lib/google/protobuf/ffi/internal/convert.rb +289 -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 +409 -0
- data/lib/google/protobuf/ffi/message.rb +659 -0
- data/lib/google/protobuf/ffi/method_descriptor.rb +114 -0
- data/lib/google/protobuf/ffi/object_cache.rb +30 -0
- data/lib/google/protobuf/ffi/oneof_descriptor.rb +97 -0
- data/lib/google/protobuf/ffi/repeated_field.rb +385 -0
- data/lib/google/protobuf/ffi/service_descriptor.rb +107 -0
- data/lib/google/protobuf/field_mask_pb.rb +1 -22
- data/lib/google/protobuf/internal/object_cache.rb +99 -0
- data/lib/google/protobuf/message_exts.rb +3 -26
- data/lib/google/protobuf/plugin_pb.rb +2 -24
- data/lib/google/protobuf/repeated_field.rb +7 -31
- data/lib/google/protobuf/source_context_pb.rb +1 -22
- data/lib/google/protobuf/struct_pb.rb +1 -22
- data/lib/google/protobuf/timestamp_pb.rb +1 -22
- data/lib/google/protobuf/type_pb.rb +1 -24
- data/lib/google/protobuf/well_known_types.rb +5 -34
- data/lib/google/protobuf/wrappers_pb.rb +1 -22
- data/lib/google/protobuf.rb +27 -45
- data/lib/google/protobuf_ffi.rb +51 -0
- data/lib/google/protobuf_native.rb +19 -0
- data/lib/google/tasks/ffi.rake +100 -0
- metadata +89 -8
- data/ext/google/protobuf_c/third_party/utf8_range/naive.c +0 -92
- data/ext/google/protobuf_c/third_party/utf8_range/range2-neon.c +0 -157
- data/ext/google/protobuf_c/third_party/utf8_range/range2-sse.c +0 -170
- data/lib/google/protobuf/descriptor_dsl.rb +0 -465
data/lib/google/protobuf.rb
CHANGED
@@ -1,35 +1,13 @@
|
|
1
1
|
# Protocol Buffers - Google's data interchange format
|
2
2
|
# Copyright 2008 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
|
# require mixins before we hook them into the java & c code
|
32
9
|
require 'google/protobuf/message_exts'
|
10
|
+
require 'google/protobuf/internal/object_cache'
|
33
11
|
|
34
12
|
# We define these before requiring the platform-specific modules.
|
35
13
|
# That way the module init can grab references to these.
|
@@ -38,26 +16,16 @@ module Google
|
|
38
16
|
class Error < StandardError; end
|
39
17
|
class ParseError < Error; end
|
40
18
|
class TypeError < ::TypeError; end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
if RUBY_PLATFORM == "java"
|
45
|
-
require 'json'
|
46
|
-
require 'google/protobuf_java'
|
47
|
-
else
|
48
|
-
begin
|
49
|
-
require "google/#{RUBY_VERSION.sub(/\.\d+$/, '')}/protobuf_c"
|
50
|
-
rescue LoadError
|
51
|
-
require 'google/protobuf_c'
|
52
|
-
end
|
53
19
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
20
|
+
PREFER_FFI = case ENV['PROTOCOL_BUFFERS_RUBY_IMPLEMENTATION']
|
21
|
+
when nil, "", /^native$/i
|
22
|
+
false
|
23
|
+
when /^ffi$/i
|
24
|
+
true
|
25
|
+
else
|
26
|
+
warn "Unexpected value `#{ENV['PROTOCOL_BUFFERS_RUBY_IMPLEMENTATION']}` for environment variable `PROTOCOL_BUFFERS_RUBY_IMPLEMENTATION`. Should be either \"FFI\", \"NATIVE\"."
|
27
|
+
false
|
28
|
+
end
|
61
29
|
|
62
30
|
def self.encode(msg, options = {})
|
63
31
|
msg.to_proto(options)
|
@@ -75,5 +43,19 @@ module Google
|
|
75
43
|
klass.decode_json(json, options)
|
76
44
|
end
|
77
45
|
|
46
|
+
IMPLEMENTATION = if PREFER_FFI
|
47
|
+
begin
|
48
|
+
require 'google/protobuf_ffi'
|
49
|
+
:FFI
|
50
|
+
rescue LoadError
|
51
|
+
warn "Caught exception `#{$!.message}` while loading FFI implementation of google/protobuf."
|
52
|
+
warn "Falling back to native implementation."
|
53
|
+
require 'google/protobuf_native'
|
54
|
+
:NATIVE
|
55
|
+
end
|
56
|
+
else
|
57
|
+
require 'google/protobuf_native'
|
58
|
+
:NATIVE
|
59
|
+
end
|
78
60
|
end
|
79
61
|
end
|
@@ -0,0 +1,51 @@
|
|
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
|
+
require 'ffi-compiler/loader'
|
9
|
+
require 'google/protobuf/ffi/ffi'
|
10
|
+
require 'google/protobuf/ffi/internal/type_safety'
|
11
|
+
require 'google/protobuf/ffi/internal/pointer_helper'
|
12
|
+
require 'google/protobuf/ffi/internal/arena'
|
13
|
+
require 'google/protobuf/ffi/internal/convert'
|
14
|
+
require 'google/protobuf/ffi/descriptor'
|
15
|
+
require 'google/protobuf/ffi/enum_descriptor'
|
16
|
+
require 'google/protobuf/ffi/field_descriptor'
|
17
|
+
require 'google/protobuf/ffi/oneof_descriptor'
|
18
|
+
require 'google/protobuf/ffi/method_descriptor'
|
19
|
+
require 'google/protobuf/ffi/service_descriptor'
|
20
|
+
require 'google/protobuf/ffi/descriptor_pool'
|
21
|
+
require 'google/protobuf/ffi/file_descriptor'
|
22
|
+
require 'google/protobuf/ffi/map'
|
23
|
+
require 'google/protobuf/ffi/object_cache'
|
24
|
+
require 'google/protobuf/ffi/repeated_field'
|
25
|
+
require 'google/protobuf/ffi/message'
|
26
|
+
|
27
|
+
module Google
|
28
|
+
module Protobuf
|
29
|
+
def self.deep_copy(object)
|
30
|
+
case object
|
31
|
+
when RepeatedField
|
32
|
+
RepeatedField.send(:deep_copy, object)
|
33
|
+
when Google::Protobuf::Map
|
34
|
+
Google::Protobuf::Map.deep_copy(object)
|
35
|
+
when Google::Protobuf::MessageExts
|
36
|
+
object.class.send(:deep_copy, object.instance_variable_get(:@msg))
|
37
|
+
else
|
38
|
+
raise NotImplementedError
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.discard_unknown(message)
|
43
|
+
raise FrozenError if message.frozen?
|
44
|
+
raise ArgumentError.new "Expected message, got #{message.class} instead." if message.instance_variable_get(:@msg).nil?
|
45
|
+
unless Google::Protobuf::FFI.message_discard_unknown(message.instance_variable_get(:@msg), message.class.descriptor, 128)
|
46
|
+
raise RuntimeError.new "Messages nested too deeply."
|
47
|
+
end
|
48
|
+
nil
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,19 @@
|
|
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
|
+
if RUBY_PLATFORM == "java"
|
9
|
+
require 'json'
|
10
|
+
require 'google/protobuf_java'
|
11
|
+
else
|
12
|
+
begin
|
13
|
+
require "google/#{RUBY_VERSION.sub(/\.\d+$/, '')}/protobuf_c"
|
14
|
+
rescue LoadError
|
15
|
+
require 'google/protobuf_c'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'google/protobuf/repeated_field'
|
@@ -0,0 +1,100 @@
|
|
1
|
+
# # @param task [FFI::Compiler::CompileTask] task to configure
|
2
|
+
def configure_common_compile_task(task)
|
3
|
+
if FileUtils.pwd.include? 'ext'
|
4
|
+
src_dir = '.'
|
5
|
+
third_party_path = 'third_party/utf8_range'
|
6
|
+
else
|
7
|
+
src_dir = 'ext/google/protobuf_c'
|
8
|
+
third_party_path = 'ext/google/protobuf_c/third_party/utf8_range'
|
9
|
+
end
|
10
|
+
|
11
|
+
task.add_include_path third_party_path
|
12
|
+
task.add_define 'NDEBUG'
|
13
|
+
task.cflags << "-std=gnu99 -O3"
|
14
|
+
[
|
15
|
+
:convert, :defs, :map, :message, :protobuf, :repeated_field, :wrap_memcpy
|
16
|
+
].each { |file| task.exclude << "/#{file}.c" }
|
17
|
+
task.ext_dir = src_dir
|
18
|
+
task.source_dirs = [src_dir]
|
19
|
+
if RbConfig::CONFIG['target_os'] =~ /darwin|linux/
|
20
|
+
task.cflags << "-Wall -Wsign-compare -Wno-declaration-after-statement"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# FFI::CompilerTask's constructor walks the filesystem at task definition time
|
25
|
+
# to create subtasks for each source file, so files from third_party must be
|
26
|
+
# copied into place before the task is defined for it to work correctly.
|
27
|
+
# TODO Is there a sane way to check for generated protos under lib too?
|
28
|
+
def with_generated_files
|
29
|
+
expected_path = FileUtils.pwd.include?('ext') ? 'third_party/utf8_range' : 'ext/google/protobuf_c/third_party/utf8_range'
|
30
|
+
if File.directory?(expected_path)
|
31
|
+
yield
|
32
|
+
else
|
33
|
+
task :default do
|
34
|
+
# It is possible, especially in cases like the first invocation of
|
35
|
+
# `rake test` following `rake clean` or a fresh checkout that the
|
36
|
+
# `copy_third_party` task has been executed since initial task definition.
|
37
|
+
# If so, run the task definition block now and invoke it explicitly.
|
38
|
+
if File.directory?(expected_path)
|
39
|
+
yield
|
40
|
+
Rake::Task[:default].invoke
|
41
|
+
else
|
42
|
+
raise "Missing directory #{File.absolute_path(expected_path)}." +
|
43
|
+
" Did you forget to run `rake copy_third_party` before building" +
|
44
|
+
" native extensions?"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
begin
|
51
|
+
require "ffi-compiler/compile_task"
|
52
|
+
|
53
|
+
desc "Compile Protobuf library for FFI"
|
54
|
+
namespace "ffi-protobuf" do
|
55
|
+
with_generated_files do
|
56
|
+
# Compile Ruby UPB separately in order to limit use of -DUPB_BUILD_API to one
|
57
|
+
# compilation unit.
|
58
|
+
desc "Compile UPB library for FFI"
|
59
|
+
namespace "ffi-upb" do
|
60
|
+
with_generated_files do
|
61
|
+
FFI::Compiler::CompileTask.new('ruby-upb') do |c|
|
62
|
+
configure_common_compile_task c
|
63
|
+
c.add_define "UPB_BUILD_API"
|
64
|
+
c.exclude << "/glue.c"
|
65
|
+
c.exclude << "/shared_message.c"
|
66
|
+
c.exclude << "/shared_convert.c"
|
67
|
+
if RbConfig::CONFIG['target_os'] =~ /darwin|linux/
|
68
|
+
c.cflags << "-fvisibility=hidden"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
FFI::Compiler::CompileTask.new 'protobuf_c_ffi' do |c|
|
75
|
+
configure_common_compile_task c
|
76
|
+
# Ruby UPB was already compiled with different flags.
|
77
|
+
c.exclude << "/utf8_range.c"
|
78
|
+
c.exclude << "/ruby-upb.c"
|
79
|
+
end
|
80
|
+
|
81
|
+
# Setup dependencies so that the .o files generated by building ffi-upb are
|
82
|
+
# available to link here.
|
83
|
+
# TODO Can this be simplified? Can the single shared library be used
|
84
|
+
# instead of the object files?
|
85
|
+
protobuf_c_task = Rake::Task[:default]
|
86
|
+
protobuf_c_shared_lib_task = Rake::Task[protobuf_c_task.prereqs.last]
|
87
|
+
ruby_upb_shared_lib_task = Rake::Task[:"ffi-upb:default"].prereqs.first
|
88
|
+
Rake::Task[ruby_upb_shared_lib_task].prereqs.each do |dependency|
|
89
|
+
protobuf_c_shared_lib_task.prereqs.prepend dependency
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
rescue LoadError
|
94
|
+
desc "Compile Protobuf library for FFI"
|
95
|
+
namespace "ffi-protobuf" do
|
96
|
+
task :default do
|
97
|
+
warn "Skipping build of FFI; `gem install ffi-compiler` to enable."
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-protobuf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.27.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Protobuf Authors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler-dock
|
@@ -24,6 +24,62 @@ dependencies:
|
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 1.2.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bigdecimal
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '13'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '13'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: ffi
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: ffi-compiler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1'
|
27
83
|
- !ruby/object:Gem::Dependency
|
28
84
|
name: rake-compiler
|
29
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -63,13 +119,16 @@ email: protobuf@googlegroups.com
|
|
63
119
|
executables: []
|
64
120
|
extensions:
|
65
121
|
- ext/google/protobuf_c/extconf.rb
|
122
|
+
- ext/google/protobuf_c/Rakefile
|
66
123
|
extra_rdoc_files: []
|
67
124
|
files:
|
125
|
+
- ext/google/protobuf_c/Rakefile
|
68
126
|
- ext/google/protobuf_c/convert.c
|
69
127
|
- ext/google/protobuf_c/convert.h
|
70
128
|
- ext/google/protobuf_c/defs.c
|
71
129
|
- ext/google/protobuf_c/defs.h
|
72
130
|
- ext/google/protobuf_c/extconf.rb
|
131
|
+
- ext/google/protobuf_c/glue.c
|
73
132
|
- ext/google/protobuf_c/map.c
|
74
133
|
- ext/google/protobuf_c/map.h
|
75
134
|
- ext/google/protobuf_c/message.c
|
@@ -80,20 +139,39 @@ files:
|
|
80
139
|
- ext/google/protobuf_c/repeated_field.h
|
81
140
|
- ext/google/protobuf_c/ruby-upb.c
|
82
141
|
- ext/google/protobuf_c/ruby-upb.h
|
142
|
+
- ext/google/protobuf_c/shared_convert.c
|
143
|
+
- ext/google/protobuf_c/shared_convert.h
|
144
|
+
- ext/google/protobuf_c/shared_message.c
|
145
|
+
- ext/google/protobuf_c/shared_message.h
|
83
146
|
- ext/google/protobuf_c/third_party/utf8_range/LICENSE
|
84
|
-
- ext/google/protobuf_c/third_party/utf8_range/
|
85
|
-
- ext/google/protobuf_c/third_party/utf8_range/range2-neon.c
|
86
|
-
- ext/google/protobuf_c/third_party/utf8_range/range2-sse.c
|
147
|
+
- ext/google/protobuf_c/third_party/utf8_range/utf8_range.c
|
87
148
|
- ext/google/protobuf_c/third_party/utf8_range/utf8_range.h
|
88
149
|
- ext/google/protobuf_c/wrap_memcpy.c
|
89
150
|
- lib/google/protobuf.rb
|
90
151
|
- lib/google/protobuf/any_pb.rb
|
91
152
|
- lib/google/protobuf/api_pb.rb
|
92
|
-
- lib/google/protobuf/descriptor_dsl.rb
|
93
153
|
- lib/google/protobuf/descriptor_pb.rb
|
94
154
|
- lib/google/protobuf/duration_pb.rb
|
95
155
|
- lib/google/protobuf/empty_pb.rb
|
156
|
+
- lib/google/protobuf/ffi/descriptor.rb
|
157
|
+
- lib/google/protobuf/ffi/descriptor_pool.rb
|
158
|
+
- lib/google/protobuf/ffi/enum_descriptor.rb
|
159
|
+
- lib/google/protobuf/ffi/ffi.rb
|
160
|
+
- lib/google/protobuf/ffi/field_descriptor.rb
|
161
|
+
- lib/google/protobuf/ffi/file_descriptor.rb
|
162
|
+
- lib/google/protobuf/ffi/internal/arena.rb
|
163
|
+
- lib/google/protobuf/ffi/internal/convert.rb
|
164
|
+
- lib/google/protobuf/ffi/internal/pointer_helper.rb
|
165
|
+
- lib/google/protobuf/ffi/internal/type_safety.rb
|
166
|
+
- lib/google/protobuf/ffi/map.rb
|
167
|
+
- lib/google/protobuf/ffi/message.rb
|
168
|
+
- lib/google/protobuf/ffi/method_descriptor.rb
|
169
|
+
- lib/google/protobuf/ffi/object_cache.rb
|
170
|
+
- lib/google/protobuf/ffi/oneof_descriptor.rb
|
171
|
+
- lib/google/protobuf/ffi/repeated_field.rb
|
172
|
+
- lib/google/protobuf/ffi/service_descriptor.rb
|
96
173
|
- lib/google/protobuf/field_mask_pb.rb
|
174
|
+
- lib/google/protobuf/internal/object_cache.rb
|
97
175
|
- lib/google/protobuf/message_exts.rb
|
98
176
|
- lib/google/protobuf/plugin_pb.rb
|
99
177
|
- lib/google/protobuf/repeated_field.rb
|
@@ -103,11 +181,14 @@ files:
|
|
103
181
|
- lib/google/protobuf/type_pb.rb
|
104
182
|
- lib/google/protobuf/well_known_types.rb
|
105
183
|
- lib/google/protobuf/wrappers_pb.rb
|
184
|
+
- lib/google/protobuf_ffi.rb
|
185
|
+
- lib/google/protobuf_native.rb
|
186
|
+
- lib/google/tasks/ffi.rake
|
106
187
|
homepage: https://developers.google.com/protocol-buffers
|
107
188
|
licenses:
|
108
189
|
- BSD-3-Clause
|
109
190
|
metadata:
|
110
|
-
source_code_uri: https://github.com/protocolbuffers/protobuf/tree/
|
191
|
+
source_code_uri: https://github.com/protocolbuffers/protobuf/tree/v4.27.1/ruby
|
111
192
|
post_install_message:
|
112
193
|
rdoc_options: []
|
113
194
|
require_paths:
|
@@ -116,7 +197,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
116
197
|
requirements:
|
117
198
|
- - ">="
|
118
199
|
- !ruby/object:Gem::Version
|
119
|
-
version: '
|
200
|
+
version: '3.0'
|
120
201
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
202
|
requirements:
|
122
203
|
- - ">="
|
@@ -1,92 +0,0 @@
|
|
1
|
-
#include <stdio.h>
|
2
|
-
|
3
|
-
/*
|
4
|
-
* http://www.unicode.org/versions/Unicode6.0.0/ch03.pdf - page 94
|
5
|
-
*
|
6
|
-
* Table 3-7. Well-Formed UTF-8 Byte Sequences
|
7
|
-
*
|
8
|
-
* +--------------------+------------+-------------+------------+-------------+
|
9
|
-
* | Code Points | First Byte | Second Byte | Third Byte | Fourth Byte |
|
10
|
-
* +--------------------+------------+-------------+------------+-------------+
|
11
|
-
* | U+0000..U+007F | 00..7F | | | |
|
12
|
-
* +--------------------+------------+-------------+------------+-------------+
|
13
|
-
* | U+0080..U+07FF | C2..DF | 80..BF | | |
|
14
|
-
* +--------------------+------------+-------------+------------+-------------+
|
15
|
-
* | U+0800..U+0FFF | E0 | A0..BF | 80..BF | |
|
16
|
-
* +--------------------+------------+-------------+------------+-------------+
|
17
|
-
* | U+1000..U+CFFF | E1..EC | 80..BF | 80..BF | |
|
18
|
-
* +--------------------+------------+-------------+------------+-------------+
|
19
|
-
* | U+D000..U+D7FF | ED | 80..9F | 80..BF | |
|
20
|
-
* +--------------------+------------+-------------+------------+-------------+
|
21
|
-
* | U+E000..U+FFFF | EE..EF | 80..BF | 80..BF | |
|
22
|
-
* +--------------------+------------+-------------+------------+-------------+
|
23
|
-
* | U+10000..U+3FFFF | F0 | 90..BF | 80..BF | 80..BF |
|
24
|
-
* +--------------------+------------+-------------+------------+-------------+
|
25
|
-
* | U+40000..U+FFFFF | F1..F3 | 80..BF | 80..BF | 80..BF |
|
26
|
-
* +--------------------+------------+-------------+------------+-------------+
|
27
|
-
* | U+100000..U+10FFFF | F4 | 80..8F | 80..BF | 80..BF |
|
28
|
-
* +--------------------+------------+-------------+------------+-------------+
|
29
|
-
*/
|
30
|
-
|
31
|
-
/* Return 0 - success, >0 - index(1 based) of first error char */
|
32
|
-
int utf8_naive(const unsigned char *data, int len)
|
33
|
-
{
|
34
|
-
int err_pos = 1;
|
35
|
-
|
36
|
-
while (len) {
|
37
|
-
int bytes;
|
38
|
-
const unsigned char byte1 = data[0];
|
39
|
-
|
40
|
-
/* 00..7F */
|
41
|
-
if (byte1 <= 0x7F) {
|
42
|
-
bytes = 1;
|
43
|
-
/* C2..DF, 80..BF */
|
44
|
-
} else if (len >= 2 && byte1 >= 0xC2 && byte1 <= 0xDF &&
|
45
|
-
(signed char)data[1] <= (signed char)0xBF) {
|
46
|
-
bytes = 2;
|
47
|
-
} else if (len >= 3) {
|
48
|
-
const unsigned char byte2 = data[1];
|
49
|
-
|
50
|
-
/* Is byte2, byte3 between 0x80 ~ 0xBF */
|
51
|
-
const int byte2_ok = (signed char)byte2 <= (signed char)0xBF;
|
52
|
-
const int byte3_ok = (signed char)data[2] <= (signed char)0xBF;
|
53
|
-
|
54
|
-
if (byte2_ok && byte3_ok &&
|
55
|
-
/* E0, A0..BF, 80..BF */
|
56
|
-
((byte1 == 0xE0 && byte2 >= 0xA0) ||
|
57
|
-
/* E1..EC, 80..BF, 80..BF */
|
58
|
-
(byte1 >= 0xE1 && byte1 <= 0xEC) ||
|
59
|
-
/* ED, 80..9F, 80..BF */
|
60
|
-
(byte1 == 0xED && byte2 <= 0x9F) ||
|
61
|
-
/* EE..EF, 80..BF, 80..BF */
|
62
|
-
(byte1 >= 0xEE && byte1 <= 0xEF))) {
|
63
|
-
bytes = 3;
|
64
|
-
} else if (len >= 4) {
|
65
|
-
/* Is byte4 between 0x80 ~ 0xBF */
|
66
|
-
const int byte4_ok = (signed char)data[3] <= (signed char)0xBF;
|
67
|
-
|
68
|
-
if (byte2_ok && byte3_ok && byte4_ok &&
|
69
|
-
/* F0, 90..BF, 80..BF, 80..BF */
|
70
|
-
((byte1 == 0xF0 && byte2 >= 0x90) ||
|
71
|
-
/* F1..F3, 80..BF, 80..BF, 80..BF */
|
72
|
-
(byte1 >= 0xF1 && byte1 <= 0xF3) ||
|
73
|
-
/* F4, 80..8F, 80..BF, 80..BF */
|
74
|
-
(byte1 == 0xF4 && byte2 <= 0x8F))) {
|
75
|
-
bytes = 4;
|
76
|
-
} else {
|
77
|
-
return err_pos;
|
78
|
-
}
|
79
|
-
} else {
|
80
|
-
return err_pos;
|
81
|
-
}
|
82
|
-
} else {
|
83
|
-
return err_pos;
|
84
|
-
}
|
85
|
-
|
86
|
-
len -= bytes;
|
87
|
-
err_pos += bytes;
|
88
|
-
data += bytes;
|
89
|
-
}
|
90
|
-
|
91
|
-
return 0;
|
92
|
-
}
|
@@ -1,157 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Process 2x16 bytes in each iteration.
|
3
|
-
* Comments removed for brevity. See range-neon.c for details.
|
4
|
-
*/
|
5
|
-
#ifdef __aarch64__
|
6
|
-
|
7
|
-
#include <stdio.h>
|
8
|
-
#include <stdint.h>
|
9
|
-
#include <arm_neon.h>
|
10
|
-
|
11
|
-
int utf8_naive(const unsigned char *data, int len);
|
12
|
-
|
13
|
-
static const uint8_t _first_len_tbl[] = {
|
14
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3,
|
15
|
-
};
|
16
|
-
|
17
|
-
static const uint8_t _first_range_tbl[] = {
|
18
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 8, 8,
|
19
|
-
};
|
20
|
-
|
21
|
-
static const uint8_t _range_min_tbl[] = {
|
22
|
-
0x00, 0x80, 0x80, 0x80, 0xA0, 0x80, 0x90, 0x80,
|
23
|
-
0xC2, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
24
|
-
};
|
25
|
-
static const uint8_t _range_max_tbl[] = {
|
26
|
-
0x7F, 0xBF, 0xBF, 0xBF, 0xBF, 0x9F, 0xBF, 0x8F,
|
27
|
-
0xF4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
28
|
-
};
|
29
|
-
|
30
|
-
static const uint8_t _range_adjust_tbl[] = {
|
31
|
-
2, 3, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0,
|
32
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0,
|
33
|
-
};
|
34
|
-
|
35
|
-
/* Return 0 on success, -1 on error */
|
36
|
-
int utf8_range2(const unsigned char *data, int len)
|
37
|
-
{
|
38
|
-
if (len >= 32) {
|
39
|
-
uint8x16_t prev_input = vdupq_n_u8(0);
|
40
|
-
uint8x16_t prev_first_len = vdupq_n_u8(0);
|
41
|
-
|
42
|
-
const uint8x16_t first_len_tbl = vld1q_u8(_first_len_tbl);
|
43
|
-
const uint8x16_t first_range_tbl = vld1q_u8(_first_range_tbl);
|
44
|
-
const uint8x16_t range_min_tbl = vld1q_u8(_range_min_tbl);
|
45
|
-
const uint8x16_t range_max_tbl = vld1q_u8(_range_max_tbl);
|
46
|
-
const uint8x16x2_t range_adjust_tbl = vld2q_u8(_range_adjust_tbl);
|
47
|
-
|
48
|
-
const uint8x16_t const_1 = vdupq_n_u8(1);
|
49
|
-
const uint8x16_t const_2 = vdupq_n_u8(2);
|
50
|
-
const uint8x16_t const_e0 = vdupq_n_u8(0xE0);
|
51
|
-
|
52
|
-
uint8x16_t error1 = vdupq_n_u8(0);
|
53
|
-
uint8x16_t error2 = vdupq_n_u8(0);
|
54
|
-
uint8x16_t error3 = vdupq_n_u8(0);
|
55
|
-
uint8x16_t error4 = vdupq_n_u8(0);
|
56
|
-
|
57
|
-
while (len >= 32) {
|
58
|
-
/******************* two blocks interleaved **********************/
|
59
|
-
|
60
|
-
#if defined(__GNUC__) && !defined(__clang__) && (__GNUC__ < 8)
|
61
|
-
/* gcc doesn't support vldq1_u8_x2 until version 8 */
|
62
|
-
const uint8x16_t input_a = vld1q_u8(data);
|
63
|
-
const uint8x16_t input_b = vld1q_u8(data + 16);
|
64
|
-
#else
|
65
|
-
/* Forces a double load on Clang */
|
66
|
-
const uint8x16x2_t input_pair = vld1q_u8_x2(data);
|
67
|
-
const uint8x16_t input_a = input_pair.val[0];
|
68
|
-
const uint8x16_t input_b = input_pair.val[1];
|
69
|
-
#endif
|
70
|
-
|
71
|
-
const uint8x16_t high_nibbles_a = vshrq_n_u8(input_a, 4);
|
72
|
-
const uint8x16_t high_nibbles_b = vshrq_n_u8(input_b, 4);
|
73
|
-
|
74
|
-
const uint8x16_t first_len_a =
|
75
|
-
vqtbl1q_u8(first_len_tbl, high_nibbles_a);
|
76
|
-
const uint8x16_t first_len_b =
|
77
|
-
vqtbl1q_u8(first_len_tbl, high_nibbles_b);
|
78
|
-
|
79
|
-
uint8x16_t range_a = vqtbl1q_u8(first_range_tbl, high_nibbles_a);
|
80
|
-
uint8x16_t range_b = vqtbl1q_u8(first_range_tbl, high_nibbles_b);
|
81
|
-
|
82
|
-
range_a =
|
83
|
-
vorrq_u8(range_a, vextq_u8(prev_first_len, first_len_a, 15));
|
84
|
-
range_b =
|
85
|
-
vorrq_u8(range_b, vextq_u8(first_len_a, first_len_b, 15));
|
86
|
-
|
87
|
-
uint8x16_t tmp1_a, tmp2_a, tmp1_b, tmp2_b;
|
88
|
-
tmp1_a = vextq_u8(prev_first_len, first_len_a, 14);
|
89
|
-
tmp1_a = vqsubq_u8(tmp1_a, const_1);
|
90
|
-
range_a = vorrq_u8(range_a, tmp1_a);
|
91
|
-
|
92
|
-
tmp1_b = vextq_u8(first_len_a, first_len_b, 14);
|
93
|
-
tmp1_b = vqsubq_u8(tmp1_b, const_1);
|
94
|
-
range_b = vorrq_u8(range_b, tmp1_b);
|
95
|
-
|
96
|
-
tmp2_a = vextq_u8(prev_first_len, first_len_a, 13);
|
97
|
-
tmp2_a = vqsubq_u8(tmp2_a, const_2);
|
98
|
-
range_a = vorrq_u8(range_a, tmp2_a);
|
99
|
-
|
100
|
-
tmp2_b = vextq_u8(first_len_a, first_len_b, 13);
|
101
|
-
tmp2_b = vqsubq_u8(tmp2_b, const_2);
|
102
|
-
range_b = vorrq_u8(range_b, tmp2_b);
|
103
|
-
|
104
|
-
uint8x16_t shift1_a = vextq_u8(prev_input, input_a, 15);
|
105
|
-
uint8x16_t pos_a = vsubq_u8(shift1_a, const_e0);
|
106
|
-
range_a = vaddq_u8(range_a, vqtbl2q_u8(range_adjust_tbl, pos_a));
|
107
|
-
|
108
|
-
uint8x16_t shift1_b = vextq_u8(input_a, input_b, 15);
|
109
|
-
uint8x16_t pos_b = vsubq_u8(shift1_b, const_e0);
|
110
|
-
range_b = vaddq_u8(range_b, vqtbl2q_u8(range_adjust_tbl, pos_b));
|
111
|
-
|
112
|
-
uint8x16_t minv_a = vqtbl1q_u8(range_min_tbl, range_a);
|
113
|
-
uint8x16_t maxv_a = vqtbl1q_u8(range_max_tbl, range_a);
|
114
|
-
|
115
|
-
uint8x16_t minv_b = vqtbl1q_u8(range_min_tbl, range_b);
|
116
|
-
uint8x16_t maxv_b = vqtbl1q_u8(range_max_tbl, range_b);
|
117
|
-
|
118
|
-
error1 = vorrq_u8(error1, vcltq_u8(input_a, minv_a));
|
119
|
-
error2 = vorrq_u8(error2, vcgtq_u8(input_a, maxv_a));
|
120
|
-
|
121
|
-
error3 = vorrq_u8(error3, vcltq_u8(input_b, minv_b));
|
122
|
-
error4 = vorrq_u8(error4, vcgtq_u8(input_b, maxv_b));
|
123
|
-
|
124
|
-
/************************ next iteration *************************/
|
125
|
-
prev_input = input_b;
|
126
|
-
prev_first_len = first_len_b;
|
127
|
-
|
128
|
-
data += 32;
|
129
|
-
len -= 32;
|
130
|
-
}
|
131
|
-
error1 = vorrq_u8(error1, error2);
|
132
|
-
error1 = vorrq_u8(error1, error3);
|
133
|
-
error1 = vorrq_u8(error1, error4);
|
134
|
-
|
135
|
-
if (vmaxvq_u8(error1))
|
136
|
-
return -1;
|
137
|
-
|
138
|
-
uint32_t token4;
|
139
|
-
vst1q_lane_u32(&token4, vreinterpretq_u32_u8(prev_input), 3);
|
140
|
-
|
141
|
-
const int8_t *token = (const int8_t *)&token4;
|
142
|
-
int lookahead = 0;
|
143
|
-
if (token[3] > (int8_t)0xBF)
|
144
|
-
lookahead = 1;
|
145
|
-
else if (token[2] > (int8_t)0xBF)
|
146
|
-
lookahead = 2;
|
147
|
-
else if (token[1] > (int8_t)0xBF)
|
148
|
-
lookahead = 3;
|
149
|
-
|
150
|
-
data -= lookahead;
|
151
|
-
len += lookahead;
|
152
|
-
}
|
153
|
-
|
154
|
-
return utf8_naive(data, len);
|
155
|
-
}
|
156
|
-
|
157
|
-
#endif
|