Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ported Ruby extension to upb_msg #8184

Merged
merged 47 commits into from Jan 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
d4de4e6
WIP.
haberman Aug 4, 2020
fed4b6c
WIP.
haberman Aug 12, 2020
f69c62f
WIP.
haberman Aug 17, 2020
e6199a6
WIP.
haberman Sep 9, 2020
b916a7e
WIP.
haberman Sep 10, 2020
b534dc1
WIP.
haberman Sep 21, 2020
c128e55
Merge branch 'master' into ruby-upb-msg2
haberman Nov 17, 2020
8675752
Added some missing files.
haberman Nov 17, 2020
7338f03
WIP.
haberman Nov 18, 2020
3e99f6b
WIP.
haberman Nov 23, 2020
c1b97a9
Updated upb.
haberman Dec 5, 2020
8ca5f9c
Extension loads, but crashes immediately.
haberman Dec 6, 2020
2fbc33b
Gets through the test suite without SEGV!
haberman Dec 9, 2020
f282bac
Test and build for Ruby 3.0
qnighy Dec 11, 2020
a40acfe
Fixed a few more bugs, efficient #inspect is almost done.
haberman Dec 11, 2020
59c544e
Fixed message hash initialization and encode depth checking.
haberman Dec 11, 2020
d7afcfa
A bunch of fixes to failing tests, now 70% passing.
haberman Dec 12, 2020
978f2b8
More than 80% of tests are passing now.
haberman Dec 13, 2020
ac5a9ce
Merge branch 'master' into ruby-3.0
qnighy Dec 14, 2020
7f585f3
Add linux/ruby30 and macos/ruby30
qnighy Dec 14, 2020
9891063
Use rvm master for 3.0.0-preview2
qnighy Dec 14, 2020
dd05452
Over 90% of tests are passing!
haberman Dec 18, 2020
ac7e9d1
Passes all tests!
haberman Dec 22, 2020
113800b
A bunch of cleanup.
haberman Dec 26, 2020
b65352f
Merge branch 'master' into ruby-upb-msg2
haberman Dec 26, 2020
e3a58ea
Removed a bunch more stuff from protobuf.h. There is an intermittent…
haberman Dec 26, 2020
96ac69e
Removed a few more things from protobuf.h.
haberman Dec 26, 2020
dc65f39
Merge branch 'master' into ruby-3.0
qnighy Dec 28, 2020
2f4f698
Ruby 3.0.0-preview2 to 3.0.0
qnighy Dec 28, 2020
46df88e
Merge branch 'master' into ruby-3.0
qnighy Jan 1, 2021
4b58485
Require rake-compiler-dock >= 1.1.0
qnighy Jan 1, 2021
2ba3bdb
More progress, fighting with the object cache.
haberman Jan 1, 2021
4d97d7c
Passes on all Ruby versions!
haberman Jan 5, 2021
1702846
Updated and clarified comment regarding WeakMap.
haberman Jan 5, 2021
773b033
Fixed the wyhash compile.
haberman Jan 5, 2021
a0b4fd3
Fixed conformance tests for Ruby.
haberman Jan 6, 2021
206ef59
Removed debug printf and fixed #inspect for floats.
haberman Jan 7, 2021
53d7f28
Fixed compatibility test to have proper semantics for #to_json.
haberman Jan 7, 2021
2b7ba72
Updated Makefile.am with new file list.
haberman Jan 8, 2021
a8d8fe3
Merge branch 'master' into ruby-upb-msg2
haberman Jan 8, 2021
1b1438f
Don't try to copy wyhash when inside Docker.
haberman Jan 8, 2021
b27ca67
Merge branch 'ruby-3.0' into ruby-upb-msg2
haberman Jan 9, 2021
aa728a7
Fixed bug where we would forget that a sub-object is frozen in Ruby >…
haberman Jan 9, 2021
e9af5a2
Avoid exporting unneeded symbols and refactored a bit of code.
haberman Jan 9, 2021
b7be808
Some more refactoring.
haberman Jan 9, 2021
ea83e5d
Simplified and added more comments.
haberman Jan 10, 2021
0b8040b
Some more comments and simplification. Added a missing license block.
haberman Jan 11, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 8 additions & 4 deletions Makefile.am
Expand Up @@ -1094,17 +1094,21 @@ ruby_EXTRA_DIST= \
ruby/compatibility_tests/v3.0.0/test.sh \
ruby/compatibility_tests/v3.0.0/Rakefile \
ruby/compatibility_tests/v3.0.0/README.md \
ruby/ext/google/protobuf_c/convert.c \
ruby/ext/google/protobuf_c/convert.h \
ruby/ext/google/protobuf_c/defs.c \
ruby/ext/google/protobuf_c/encode_decode.c \
ruby/ext/google/protobuf_c/defs.h \
ruby/ext/google/protobuf_c/extconf.rb \
ruby/ext/google/protobuf_c/map.c \
ruby/ext/google/protobuf_c/map.h \
ruby/ext/google/protobuf_c/message.c \
ruby/ext/google/protobuf_c/message.h \
ruby/ext/google/protobuf_c/protobuf.c \
ruby/ext/google/protobuf_c/protobuf.h \
ruby/ext/google/protobuf_c/repeated_field.c \
ruby/ext/google/protobuf_c/storage.c \
ruby/ext/google/protobuf_c/upb.c \
ruby/ext/google/protobuf_c/upb.h \
ruby/ext/google/protobuf_c/repeated_field.h \
ruby/ext/google/protobuf_c/ruby-upb.c \
ruby/ext/google/protobuf_c/ruby-upb.h \
ruby/ext/google/protobuf_c/wrap_memcpy.c \
ruby/google-protobuf.gemspec \
ruby/lib/google/protobuf/message_exts.rb \
Expand Down
6 changes: 3 additions & 3 deletions conformance/Makefile.am
Expand Up @@ -5,7 +5,7 @@ conformance_protoc_inputs = \
$(top_srcdir)/src/google/protobuf/test_messages_proto3.proto

# proto2 input files, should be separated with proto3, as we
# can't generate proto2 files for ruby, php and objc
# can't generate proto2 files for php.
conformance_proto2_protoc_inputs = \
$(top_srcdir)/src/google/protobuf/test_messages_proto2.proto

Expand Down Expand Up @@ -261,7 +261,7 @@ if USE_EXTERNAL_PROTOC
# Some implementations include pre-generated versions of well-known types.
protoc_middleman: $(conformance_protoc_inputs) $(conformance_proto2_protoc_inputs) $(well_known_type_protoc_inputs) google-protobuf
$(PROTOC) -I$(srcdir) -I$(top_srcdir) --cpp_out=. --java_out=. --ruby_out=. --objc_out=. --python_out=. --php_out=. --js_out=import_style=commonjs,binary:. $(conformance_protoc_inputs)
$(PROTOC) -I$(srcdir) -I$(top_srcdir) --cpp_out=. --java_out=. --objc_out=. --python_out=. --js_out=import_style=commonjs,binary:. $(conformance_proto2_protoc_inputs)
$(PROTOC) -I$(srcdir) -I$(top_srcdir) --cpp_out=. --java_out=. --ruby_out=. --objc_out=. --python_out=. --js_out=import_style=commonjs,binary:. $(conformance_proto2_protoc_inputs)
$(PROTOC) -I$(srcdir) -I$(top_srcdir) --cpp_out=. --java_out=. --ruby_out=. --python_out=. --js_out=import_style=commonjs,binary:google-protobuf $(well_known_type_protoc_inputs)
## $(PROTOC) -I$(srcdir) -I$(top_srcdir) --java_out=lite:lite $(conformance_protoc_inputs) $(well_known_type_protoc_inputs)
touch protoc_middleman
Expand All @@ -273,7 +273,7 @@ else
# building out-of-tree.
protoc_middleman: $(top_srcdir)/src/protoc$(EXEEXT) $(conformance_protoc_inputs) $(conformance_proto2_protoc_inputs) $(well_known_type_protoc_inputs) google-protobuf
oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd --java_out=$$oldpwd --ruby_out=$$oldpwd --objc_out=$$oldpwd --python_out=$$oldpwd --php_out=$$oldpwd --js_out=import_style=commonjs,binary:$$oldpwd $(conformance_protoc_inputs) )
oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd --java_out=$$oldpwd --objc_out=. --python_out=$$oldpwd --js_out=import_style=commonjs,binary:$$oldpwd $(conformance_proto2_protoc_inputs) )
oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd --java_out=$$oldpwd --ruby_out=$$oldpwd --objc_out=$$oldpwd --python_out=$$oldpwd --js_out=import_style=commonjs,binary:$$oldpwd $(conformance_proto2_protoc_inputs) )
oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd --java_out=$$oldpwd --ruby_out=$$oldpwd --python_out=$$oldpwd --js_out=import_style=commonjs,binary:$$oldpwd/google-protobuf $(well_known_type_protoc_inputs) )
## @mkdir -p lite
## oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --java_out=lite:$$oldpwd/lite $(conformance_protoc_inputs) $(well_known_type_protoc_inputs) )
Expand Down
53 changes: 31 additions & 22 deletions conformance/conformance_ruby.rb
Expand Up @@ -32,46 +32,47 @@

require 'conformance_pb'
require 'google/protobuf/test_messages_proto3_pb'
require 'google/protobuf/test_messages_proto2_pb'

$test_count = 0
$verbose = false

def do_test(request)
test_message = ProtobufTestMessages::Proto3::TestAllTypesProto3.new
response = Conformance::ConformanceResponse.new
descriptor = Google::Protobuf::DescriptorPool.generated_pool.lookup(request.message_type)

unless descriptor
response.skipped = "Unknown message type: " + request.message_type
end

begin
case request.payload
when :protobuf_payload
if request.message_type.eql?('protobuf_test_messages.proto3.TestAllTypesProto3')
begin
test_message = ProtobufTestMessages::Proto3::TestAllTypesProto3.decode(
request.protobuf_payload)
rescue Google::Protobuf::ParseError => err
response.parse_error = err.message.encode('utf-8')
return response
end
elsif request.message_type.eql?('protobuf_test_messages.proto2.TestAllTypesProto2')
response.skipped = "Ruby doesn't support proto2"
begin
test_message = descriptor.msgclass.decode(request.protobuf_payload)
rescue Google::Protobuf::ParseError => err
response.parse_error = err.message.encode('utf-8')
return response
else
fail "Protobuf request doesn't have specific payload type"
end

when :json_payload
begin
test_message = ProtobufTestMessages::Proto3::TestAllTypesProto3.decode_json(
request.json_payload)
options = {}
if request.test_category == :JSON_IGNORE_UNKNOWN_PARSING_TEST
options[:ignore_unknown_fields] = true
end
test_message = descriptor.msgclass.decode_json(request.json_payload, options)
rescue Google::Protobuf::ParseError => err
response.parse_error = err.message.encode('utf-8')
return response
end
when :text_payload
begin
response.skipped = "Ruby doesn't support proto2"
return response
end

when :text_payload
begin
response.skipped = "Ruby doesn't support text format"
return response
end

when nil
fail "Request didn't have payload"
Expand All @@ -82,10 +83,18 @@ def do_test(request)
fail 'Unspecified output format'

when :PROTOBUF
response.protobuf_payload = test_message.to_proto
begin
response.protobuf_payload = test_message.to_proto
rescue Google::Protobuf::ParseError => err
response.serialize_error = err.message.encode('utf-8')
end

when :JSON
response.json_payload = test_message.to_json
begin
response.json_payload = test_message.to_json
rescue Google::Protobuf::ParseError => err
response.serialize_error = err.message.encode('utf-8')
end

when nil
fail "Request didn't have requested output format"
Expand Down