Commit Graph

98 Commits

Author SHA1 Message Date
micw523
0038ff49af Remove Debug Statement for Win/MinGW (#5283) 2018-10-23 12:50:57 -07:00
Paul Yang
333b3ceab6
Add ruby 2.3, 2.4 and 2.5 test for linux. (#5256)
* Add ruby 2.3, 2.4 and 2.5 test for linux.

* Update kokoro files

* Add back commented gc test

* Fix gc_test failure

* Remove unused code

* Update ruby 2.5.0 to 2.5.1

* Update ruby 2.3 to 2.3.8

* Remove useless comment
2018-10-18 11:16:55 -07:00
Joshua Haberman
19ef4ab1c2
Merge pull request #4816 from hrsht/hrsht/zanker-proto2
Basic Proto2 support for Ruby gem
2018-09-27 15:23:10 -07:00
Harshit Chopra
d0535cc09e Adds support for proto2 syntax for Ruby gem.
This change only adds basic proto2 support without advanced features
like extensions, custom options, maps, etc.

The protoc binary now generates ruby code for proto2 syntax.
However, for now, it is restricted to proto2 files without advanced features
like extensions, in which case it still errors out.

This change also modifies the DSL to add proto messages to the DescriptorPool.
There is a new DSL Builder#add_file to create a new FileDescriptor. With this,
the generated ruby DSL looks something like:

Google::Protobuf::DescriptorPool.generated_pool.build do
  add_file "test.proto" do
    add_message "foo" do
      optional :val, :int32, 1
    end
  end
end
2018-09-27 14:21:16 -04:00
Feng Xiao
afe98de32a Replace repo links. 2018-08-22 11:55:30 -07:00
Adam Cozzette
94d55e5292 Merge branch '3.6.x' into merge-3-6-x 2018-08-01 13:44:55 -07:00
Paul Yang
e508fc0c66
Check the message to be encoded is the wrong type. (#4885) (#4949)
* Check the message to be encoded is the wrong type. (#4885)

* Change TypeError to ArgumentError
2018-07-23 11:05:28 -07:00
Paul Yang
8356d270a5 Add continuous test for ruby 2.3, 2.4 and 2.5 (#4829)
* Add continuous test for ruby 2.3, 2.4 and 2.5

* Change ruby 2.5 to 2.5.0

* No need to provide argument to rb_funcall when argc is 0

* Fix tests for ruby 2.5

* Use rescue instead of assert_raise to accept subclass of error
2018-07-17 17:34:25 -07:00
Paul Yang
40f9ef2f56
Check the message to be encoded is the wrong type. (#4885) 2018-07-12 11:04:29 -07:00
Paul Yang
78ba021b84
Add continuous test for ruby 2.3, 2.4 and 2.5 (#4829)
* Add continuous test for ruby 2.3, 2.4 and 2.5

* Change ruby 2.5 to 2.5.0

* No need to provide argument to rb_funcall when argc is 0

* Fix tests for ruby 2.5

* Use rescue instead of assert_raise to accept subclass of error
2018-07-02 15:11:36 -07:00
Joshua Haberman
59e04d80cc
Merge pull request #4321 from devwout/ruby_json_omit_repeated
Ruby JSON encoding omits zero-length repeated fields by default.
2018-07-02 14:00:05 -07:00
Zachary Anker
70544627cb When initializing a message, skip a field if value is nil (#3693) 2018-06-26 20:27:24 -07:00
Erik Benoist
74f8e24232 Adds a base class for all explicitly raised TypeErrors (#4255)
* This allows for ruby code to catch and handle Protobuf
    TypeErrors separately from the standard Ruby TypeError

  * Maintains backwards compatibility by having the new
    Google::Protobuf::TypeError inherit from the base
    TypeError. Any code that was catching TypeError should
    continue to work.
2018-06-26 20:24:24 -07:00
Paul Yang
f7ada1280f
Build ruby gem on kokoro (#4819)
* Install rake compiler

* Add kokoro config to build ruby gem on linux

* Rename from linix to linux

* Fix prepare_build.sh name

* Clean up

* Install bundler

* Install bundler

* Use c99 in order to build gem on mingw-32 on ruby 2.0.0

See https://github.com/rake-compiler/rake-compiler-dock/issues/4

* Move c99 config to extcofig.rb
2018-06-25 11:14:49 -07:00
Ewout
7b8f571756 Ruby JSON encoding omits zero-length repeated fields by default.
This makes it behave the same way as the other implementations.
It is also nice to always encode an empty message as {}.
2018-02-20 17:13:21 +01:00
Michael Collis
2a6eaeb86e
Fix scope resolution for MessageExts in Ruby 2018-01-12 15:16:16 -05:00
Jisi Liu
383a4941d5 Merge remote-tracking branch 'origin/3.5.x' into master 2018-01-03 09:28:40 -08:00
Paul Yang
cf7c15e31a
Fix ruby gc_test in ruby 2.4 (#4011)
* Fix ruby gc_test in ruby 2.4

* Initialize global variables to Qnil.
2017-12-08 12:38:25 -08:00
Paul Yang
0e7b589566
Add discard unknown API in ruby. (#3990)
* Add discard unknown API in ruby.

* Add test for oneof message field.

* Add TestUnknown to represent unknown field data clearly.

* Only serialize the message with unknown fields itself in test.

* Move discard_unknown from Message to Google.Protobuf
2017-12-07 14:18:38 -08:00
Joshua Haberman
0289dd8f90
Merge pull request #2519 from rubynerd-forks/ruby-fix-repeated-message-type-field
unwrap descriptor class before comparison of RepeatedField types
2017-11-29 10:07:35 -08:00
Paul Yang
23adfeb003 Reserve unknown in Ruby (#3763)
* Reserve unknown in ruby

* Revert ruby tests. Wait for cpp impl for conformance test

* Add conformance test for preserving unknown

* Add unknown field conformance test to csharp failure list.

* Fix comments

* Fix comment

* Fix comments

* Fix typo

* Use stringsink_string directly

* Mark hd unused

* Remove unused encodeunknown_handlerfunc
2017-10-26 14:41:43 -07:00
Paul Yang
cd5f49d094 Fix ruby segment fault (#3708)
* Fix ruby segment fault

1) rb_ary_new cannot be called during allocate function. During allocate
fucntion, the containing object hasn't been marked and rb_ary_new may
invoke gc to collect containing object.
2) The global map should be marked before allocating it. Otherwise it
may be garbage collected.

* Add test

* Remove commented code

* Fix grammer error
2017-10-03 17:28:49 -07:00
Joshua Haberman
4fc75296c7 Merge pull request #3627 from zanker/zanker/add-submsg-hash-init
Allow initializing a chain of protos using only a hash in Ruby
2017-09-21 15:08:45 -07:00
Zachary Anker
633ef8bde9 Update message.c 2017-09-21 09:26:54 -07:00
Zachary Anker
8eae3fe6e9 Update message.c 2017-09-20 12:45:42 -07:00
Zachary Anker
87714836e3 Allow initializing a chain of protos using only a hash 2017-09-20 11:39:46 -07:00
Zachary Anker
83264bd160 Fixed to_h with repeated messages to return hashes in Ruby 2017-09-20 11:38:05 -07:00
Aaron Patterson
f55c6ec24f
Storing the frame on the map means we don't need the array 2017-08-30 11:38:09 -07:00
Aaron Patterson
d6152dd51c
Move parse frame array to the Map object
This makes the frame stack per-parser, and per-thread.  Fixes #3250
2017-08-30 11:38:04 -07:00
Joshua Haberman
1325588982 Updated upb to fix JSON conformance issues. (#3206)
* Fixed a bunch of Ruby conformance errors.

* Fixed some more Ruby conformance errors in JSON.
2017-06-19 15:13:24 -07:00
Joshua Haberman
b28617b813 Merge pull request #2815 from devwout/ruby_json_emit_defaults
Ruby version optionally emits default values in JSON encoding.
2017-05-15 08:05:27 -07:00
Adam Cozzette
ea5ef14aa0 Ruby: only link against specific version of memcpy if we're using glibc
We have some special code in wrap_memcpy.c to ensure that we use the
2.2.5 version of memcpy, for compatibility with older versions of glibc.
However, we need to make sure we only attempt to do this when we are
actually building with glibc, so that the code can also build
successfully against other libc implementations such as musl.
2017-03-17 11:23:01 -07:00
Josh Haberman
9c6b8cb9bf Ruby: fixed Message#to_h for map fields. 2017-03-14 14:27:16 -07:00
Ewout
008dc92c9d Ruby version optionally emits default values in JSON encoding.
Usage: Message.encode_json(m, emit_defaults: true)
Message fields that are nil will still not appear in the encoded JSON.
2017-03-09 20:47:56 +01:00
Adam Cozzette
9fa40314fc Ruby: wrap calls to memcpy so that gem is compatible with pre-2.14 glibc
This commit adds a __wrap_memcpy function and a linker flag to use that
in place of memcpy for our Ruby gem C extension. This allows us to
always use the 2.2.5 version of memcpy, making it possible to use the
gem on distributions with pre-2.14 versions of glibc.

Before this change:
$ objdump -T protobuf_c.so | grep memcpy
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.3.4 __memcpy_chk
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.14  memcpy

After:
$ objdump -T protobuf_c.so | grep memcpy
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 memcpy
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.3.4 __memcpy_chk
0000000000042450 g    DF .text  0000000000000005  Base __wrap_memcpy

This is based on gRPC's solution to a similar problem:
5098508d2d/src/core/lib/support/wrap_memcpy.c

This fixes issue #2783.
2017-03-09 10:03:22 -08:00
Paul Yang
7f3e237071 Merge 3.2.x branch into master (#2648)
* Down-integrate internal changes to github.

* Update conformance test failure list.

* Explicitly import used class in nano test to avoid random test fail.

* Update _GNUC_VER to use the correct implementation of atomic operation
on Mac.

* maps_test.js: check whether Symbol is defined before using it (#2524)

Symbol is not yet available on older versions of Node.js and so this
test fails with them. This change just directly checks whether Symbol is
available before we try to use it.

* Added well_known_types_embed.cc to CLEANFILES so that it gets cleaned up

* Updated Makefile.am to fix out-of-tree builds

* Added Bazel genrule for generating well_known_types_embed.cc

In pull request #2517 I made this change for the CMake and autotools
builds but forgot to do it for the Bazel build.

* Update _GNUC_VER to use the correct implementation of atomic operation on Mac.

* Add new js file in extra dist.

* Bump version number to 3.2.0

* Fixed issue with autoloading - Invalid paths (#2538)

* PHP fix int64 decoding (#2516)

* fix int64 decoding

* fix int64 decoding + tests

* Fix int64 decoding on 32-bit machines.

* Fix warning in compiler/js/embed.cc

embed.cc: In function ‘std::string CEscape(const string&)’:
embed.cc:51:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < str.size(); ++i) {
                                ^

* Fix include in auto-generated well_known_types_embed.cc

Restore include style fix (e3da722) that has been trampled by
auto-generation of well_known_types_embed.cc

* Fixed cross compilations with the Autotools build

Pull request #2517 caused cross compilations to start failing, because
the js_embed binary was being built to run on the target platform
instead of on the build machine. This change updates the Autotools build
to use the AX_PROG_CXX_FOR_BUILD macro to find a suitable compiler for
the build machine and always use that when building js_embed.

* Minor fix for autocreated object repeated fields and maps.

- If setting/clearing a repeated field/map that was objects, check the class
  before checking the autocreator.
- Just to be paranoid, don’t mutate within copy/mutableCopy for the autocreated
  classes to ensure there is less chance of issues if someone does something
  really crazy threading wise.
- Some more tests for the internal AutocreatedArray/AutocreatedDictionary
  classes to ensure things are working as expected.
- Add Xcode 8.2 to the full_mac_build.sh supported list.

* Fix generation of extending nested messages in JavaScript (#2439)

* Fix generation of extending nested messages in JavaScript

* Added missing test8.proto to build

* Fix generated code when there is no namespace but there is enum definition.

* Decoding unknown field should succeed.

* Add embed.cc in src/Makefile.am to fix dist check.

* Fixed "make distcheck" for the Autotools build

To make the test pass I needed to fix out-of-tree builds and update
EXTRA_DIST and CLEANFILES.

* Remove redundent embed.cc from src/Makefile.am

* Update version number to 3.2.0-rc.1 (#2578)

* Change protoc-artifacts version to 3.2.0-rc.1

* Update version number to 3.2.0rc2

* Update change logs for 3.2.0 release.

* Update php README

* Update upb, fixes some bugs (including a hash table problem). (#2611)

* Update upb, fixes some bugs (including a hash table problem).

* Ruby: added a test for the previous hash table corruption.

Verified that this triggers the bug in the currently released
version.

* Ruby: bugfix for SEGV.

* Ruby: removed old code for dup'ing defs.

* Reverting deployment target to 7.0 (#2618)

The Protobuf library doesn’t require the 7.1 deployment target so
reverting it back to 7.0

* Fix typo that breaks builds on big-endian (#2632)

* Bump version number to 3.2.0
2017-01-31 09:17:32 -08:00
@rubynerd
f3e86fd26a handle sanity check for repeating enums correctly 2016-12-30 02:26:25 +00:00
@rubynerd
c64830bbca unwrap descriptor class before comparison of RepeatedField types
self->field_type_class returns the correct Ruby class, get_def_obj
returns the Descriptor object used to generate the Ruby class via
msgclass, so to compare the two types we get the msgclass from the
descriptor.
2016-12-19 23:49:16 +00:00
Marcin Wyszynski
74a636a7a2 Move variable declarations before actual code 2016-11-14 21:45:37 +01:00
Marcin Wyszynski
3bdaaa5dda More Ruby-eqsue interface 2016-11-03 14:19:10 +01:00
Brendan Ribera
de028631fc fix #2036: use rb_hash_* to accumulate hashes
Instead of shifting/xoring the hash at each field, use the built-in ruby
apis for generating a hash from multiple input values.

Now returns a Fixnum.
2016-08-30 16:22:49 -07:00
Josh Haberman
3a674ffe05 upb bugfix: JSON map entry keys were passing the wrong closure. 2016-08-29 15:28:59 -07:00
Josh Haberman
d4213d839f Ruby: make sure map parsing frames are GC-rooted. 2016-08-26 09:03:55 -07:00
Josh Haberman
ff7f68ae9f Ruby: encode and freeze strings when the are assigned or decoded. 2016-07-21 11:37:54 -07:00
Otto Kekäläinen
3808d091f8 Fix spelling in strings and comments 2016-07-03 15:26:04 +03:00
Josh Haberman
2d514ce2d8 Fixed oneof behavior for enums and fixed JRuby. 2016-05-18 15:39:29 -07:00
Josh Haberman
545527e8cf Ruby oneofs: return default instead of nil for unset fields. 2016-05-18 10:58:02 -07:00
Josh Haberman
d419ca10b4 Updated upb and simplified ruby code a bit with new upb method. 2016-04-22 14:12:10 -07:00
Josh Haberman
e67ef3d449 Bugfix for JSON error case. 2016-04-14 20:27:45 -07:00
Josh Haberman
194ad621bb Ruby JSON: always accept both camelCase and original field names.
For JSON encoding we provide a new option to decide at
encode time whether to use camelCase or original proto field
names:

  json = MapMessage.encode_json(m, :preserve_proto_fieldnames => true)
2016-04-14 18:33:17 -07:00