Commit Graph

530 Commits

Author SHA1 Message Date
Jason Lunn
07f3cab3dd Set platform to "java" under JRuby
Proposed fix for #1594
2016-09-29 00:18:55 -04:00
Brendan Ribera
05aa0df532 Fix hash computation for JRuby's RubyMessage
`System.identityHashCode` returns a hash that does not consider a
Message's values. This means two Messages with identical values will not
have identical hashCodes.

This patch uses the pattern from RubyMap to combine the hashCodes from
all values in a given message and produce a unique, consistent,
value-based hash.
2016-09-20 11:07:42 -07:00
Joshua Haberman
b5bbdb0967 Merge pull request #2037 from abscondment/fix-2036-ruby-hash
Fix #2036 (Ruby `hash` broken for Messages with repeated fields.)
2016-09-18 21:38:51 -07:00
Jisi Liu
58860c021f Merge remote-tracking branch 'origin/3.0.x' into merge 2016-09-14 09:37:48 -07:00
Jisi Liu
6e11540b32 Bump version number to 3.0.2 2016-09-02 11:57:49 -07: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
Brendan Ribera
047419a172 failing test for #2036:
* add a repeated field to the tested hash
* also assert that two messages with identical values produce identical hashes
2016-08-30 16:21:33 -07:00
Joshua Haberman
dd45c0b9fd Merge pull request #2012 from haberman/rubymapgcfix
Ruby: make sure map parsing frames are GC-rooted.
2016-08-30 09:57:50 -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
Nicolas Noble
866d3e5327 Fixing regular expression...
This will allow loading the extension for Ruby 2.1.10...
2016-08-23 22:46:26 -07:00
Joshua Haberman
8d8115bf52 Merge pull request #1878 from haberman/rubywkt
Ruby: added API support for well-known types.
2016-08-01 17:31:00 -07:00
Josh Haberman
3cec2ea8d6 Ruby: added custom Struct exception type and fixed Makefile.am. 2016-08-01 14:34:54 -07:00
Josh Haberman
a207a2bd00 Fix for JRuby (assert_true is not present). 2016-07-28 17:54:16 -07:00
Josh Haberman
e3094a8d80 Ruby: added API support for well-known types. 2016-07-28 17:02:33 -07:00
Joshua Haberman
234ec01795 Merge pull request #1847 from haberman/GAfixes
GA fixes
2016-07-26 10:55:34 -07:00
Josh Haberman
6d92233e72 Added unit test for PascalCasing package names in Ruby. 2016-07-25 15:16:23 -07:00
Joshua Haberman
b1cecb6762 Merge pull request #1837 from haberman/rubygencodename
Ruby: generated foo.proto -> foo_pb.rb instead of foo.rb.
2016-07-25 14:58:41 -07:00
Jisi Liu
0973822d03 remove extra zeros. 2016-07-25 14:14:44 -07:00
Jisi Liu
5a6c921217 Make jruby still depend on beta-4 2016-07-25 13:19:52 -07:00
Jisi Liu
fb7a7c5f1f Bump version number for GA 2016-07-25 12:07:56 -07:00
Josh Haberman
4f19797baf Ruby: generated foo.proto -> foo_pb.rb instead of foo.rb.
This brings us more into line with other langauges, and makes it more
obvious when we are requiring protobuf generated code.
2016-07-25 11:09:23 -07:00
Joshua Haberman
44bd6bda58 Merge pull request #1821 from haberman/rubyfreezestr
Ruby: encode and freeze strings when the are assigned or decoded.
2016-07-25 10:09:15 -07:00
Josh Haberman
d07a9963df Ruby: fixed string freezing for JRuby. 2016-07-25 01:26:14 -07:00
Feng Xiao
20fbb357d0 Add more tests to jenkins.
1. Added ruby22 and jruby tests to jenkins.
2. Added javascript tests to jenkins.
3. Added golang tests to jenkins.
4. Removed ruby19/ruby20 tests from travis. Support for ruby 2.0 has
   ended since 2016/02/24.
   https://www.ruby-lang.org/en/news/2016/02/24/support-plan-of-ruby-2-0-0-and-2-1/

Change-Id: Ie984b06772335352a4be7067ab2485f923875685
2016-07-21 18:11:12 -07:00
Josh Haberman
ff7f68ae9f Ruby: encode and freeze strings when the are assigned or decoded. 2016-07-21 11:37:54 -07:00
Feng Xiao
932f94e16e Update version number to 3.0.0-beta-4 2016-07-13 16:08:47 -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
Jisi Liu
5dea2017db Update version numbers for other languages 2016-05-10 15:43:39 -07:00
Nicolas "Pixel" Noble
edd29498f4 Properly generating well known proto files for the macos build. 2016-05-04 02:40:25 +02:00
Joshua Haberman
7dda312224 Merge pull request #1473 from nicolasnoble/rake-tweaks
Few tweaks to the rakefile to permit native gems compilation with the proto files generation.
2016-05-03 13:10:02 -07:00
Nicolas "Pixel" Noble
236b93937f Addressing concerns. 2016-04-30 02:15:15 +02:00
Nicolas "Pixel" Noble
1f8b6da920 Few tweaks to the rakefile to permit native gems compilation with the proto files generation. 2016-04-29 20:00:43 +02:00
Adam Cozzette
b53417c735 Merge pull request #1462 from acozzette/ruby-2.3
Added dig and bsearch_index to RepeatedField methods forwarded to array
2016-04-28 08:26:26 -07:00
Adam Cozzette
bbb68fe63d Added dig and bsearch_index to RepeatedField methods forwarded to array
This fixes the test_acts_likes_an_array test in RepeatedFieldTest, which
checks that repeated fields respond to the same methods as regular Ruby
arrays. The bsearch_index and dig array methods seem to be new in Ruby
2.3 and so we should support those.
2016-04-27 10:51:22 -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
800e986012 Remove no longer applicable documentation from README.md. 2016-04-14 18:42:22 -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
Josh Haberman
90c7f6e55e Documented the JSON change and compatibility flags. 2016-04-14 12:48:41 -07:00
Josh Haberman
94e54b39c8 Updated upb: picked up legacy JSON flags to help Ruby users migrate.
The flags are:

  UPB_JSON_ACCEPT_LEGACY_FIELD_NAMES
  UPB_JSON_WRITE_LEGACY_FIELD_NAMES

The first just allows the parser to accept the old field names.
The second makes the printer print the old field names.

These flags are intended to be temporary, as a migration aid
for users.
2016-04-14 12:06:09 -07:00
Joshua Haberman
e70f9256af Merge pull request #1139 from haberman/rubyjsoncamel
Changed Ruby to properly camelCase its JSON by default.
2016-03-04 17:31:11 -08:00
Josh Haberman
513875da77 Generate well-known types in Ruby extension and prune unneeded proto2 dependencies. 2016-03-03 14:08:54 -08:00
Josh Haberman
f654d49dd6 Updated upb from latest changes. 2016-02-18 11:48:54 -08:00
Josh Haberman
78da66698b Changed Ruby to properly camelCase its JSON by default. 2016-02-18 10:50:14 -08:00
Joshua Haberman
8fc045d8d2 Merge pull request #1224 from google/rubysentinel
Removed 'optional' from proto3 syntax file.
2016-02-16 15:43:21 -08:00
Joshua Haberman
3ee2e20539 Merge pull request #1144 from dongjoon-hyun/remove_redundant_the
Remove redundant `the`.
2016-02-11 17:17:48 -08:00
Joshua Haberman
caf1fb7197 Merge pull request #997 from anderscarling/better_errors
ruby: Better exception text for common cases
2016-02-11 12:41:34 -08:00
Josh Haberman
69ac430c02 Removed 'optional' from proto3 syntax file. 2016-02-10 14:16:49 -08:00
Nicolas "Pixel" Noble
bbb188acdd Actually enabling cross compilation. 2016-02-06 00:55:45 +01:00
Nicolas "Pixel" Noble
4e141bb3b8 Removing usage of git - not everyone grabs the gem using it. 2016-02-06 00:55:28 +01:00
Josh Haberman
70a4b03086 Add rake-compiler-dock as a dep. 2016-02-04 14:18:14 -08:00
Josh Haberman
af4aa9bd64 Added support for binary gems. 2016-02-04 10:44:22 -08:00
Dongjoon Hyun
7a9040fe7f Remove redundant the in comments. 2016-02-03 15:27:27 -08:00
Josh Haberman
fc7f8d9cd0 Fixed Ruby conformance tests by running them under rvm Ruby. 2016-01-11 21:16:42 -08:00
Josh Haberman
bf50ec4ac9 Added debugging output to debug type= problem on Travis. 2016-01-11 16:15:46 -08:00
Josh Haberman
e891c29f9b Allow conformance test runner to tolerate crashes, and re-enable conformance tests. 2016-01-11 16:15:46 -08:00
Feng Xiao
8675989bf7 Disable conformance tests for csharp and ruby.
The testee program of these two languages crashes on some test input.
2015-12-21 13:22:21 -08:00
Feng Xiao
aa7e17a6f6 Update version numbers.
Version number for beta languages is updated to v3.0.0-beta-2.
Version number for alpha languages is updated to v3.0.0-alpha-5.
2015-12-21 11:31:51 -08:00
Anders Carling
3a5f213cca Invoke super implementation instead of raising error 2015-11-23 14:53:33 +01:00
Anders Carling
0559f3ee9e Add field name to initialization map exceptions 2015-11-20 21:57:28 +01:00
Anders Carling
8bcd0d7fc7 Use same exception class in ruby and jruby 2015-11-20 21:56:04 +01:00
Anders Carling
0df1e398eb Raise NoMethodError for unknown fields
More informative and more ruby-like
2015-11-20 21:55:18 +01:00
Josh Haberman
14e2b4fa51 A very small fix to silence some warnings.
Also updated the Gemfile.lock since alpha-4 has been
pushed to RubyGems.

Change-Id: I8ddc5f125f28aa9a33c88dfe48251a75a877e1d3
2015-09-28 08:56:14 -07:00
Feng Xiao
1942a2bd2e Make jruby use Java 3.0.0-alpha-3. 2015-08-26 21:20:59 -07:00
Feng Xiao
ffe9215140 Update version number.
Protoc, C++ runtime and Java runtime are updated to v3.0.0-beta-1, other
languages are updated to v3.0.0-alpha-4.
2015-08-26 15:11:43 -07:00
Joshua Haberman
eb65c69e14 Merge pull request #584 from haberman/cwarnings
Ruby: Conform to C89/C90 variable declaration rules.
2015-08-21 09:00:40 -07:00
Josh Haberman
d61e6adfcc Return TypedData_Wrap_Struct directly.
Change-Id: I6cf77f01370204ad4bc7b345a040a9a3de1706a0
2015-08-20 16:41:32 -07:00
Josh Haberman
5bdf4a4271 Fixed several Ruby conformance test cases through upb update.
Change-Id: Ief77de7134e05e07b1a7e3970d49880c2d5e6fe9
2015-08-12 18:50:15 -07:00
Josh Haberman
c2c43a4917 Fixed lint errors and responded to CR comments.
Change-Id: If7b1cc0f03f609a7f43ddafc8509b44207c60910
2015-07-17 16:29:10 -07:00
Josh Haberman
95ee8fb88e Exclude JRuby from conformance tests for now.
Change-Id: Id008ebac5159f773e1bde8b85acb2626cbd16de8
2015-07-17 16:20:01 -07:00
Josh Haberman
181c7f2636 Added Ruby to conformance tests.
This involved fixing a few important bugs in the
Ruby implementation -- mostly cases of mixing
upb field types and descriptor types (upb field
types do not distinguish between int/sint/fixed/sfixed
like descriptor types do).

Also added protobuf-specific exceptions so parse
errors can be caught specifically.

Change-Id: Ib49d3db976900b2c6f3455c8b88af52cfb86e036
2015-07-16 12:25:55 -07:00
Josh Haberman
a1daeaba80 Conform to C89/C90 variable declaration rules.
While we are C99 in general, the Ruby build system
for building C extensions enables several flags that
throw warnings for C89/C90 variable ordering rules.
To avoid spewing a million warnings (or trying to
specifically override these warnings with command-line
flags, which would be tricky and possibly fragile)
we conform to Ruby's world of C89/C90.

Change-Id: I0e03e62d95068dfdfde112df0fb16a248a2f32a0
2015-07-10 12:05:14 -07:00
Josh Haberman
8c717ad530 Worked around memory leak bug in Ruby interpreter.
Change-Id: I8e2b425f9008e6b82d41d59783bb8b04af1f886f
Fixes: https://github.com/google/protobuf/issues/474.
2015-07-08 14:14:58 -07:00
Josh Haberman
fb8ed707a2 Update upb to fix two bugs in the Ruby library.
Fixes:
  https://github.com/google/protobuf/issues/502
  https://github.com/google/protobuf/issues/425
2015-06-22 17:23:55 -07:00
Josh Haberman
e3ce451b60 Fixed compiler warnings and added -std=c99.
upb no longer requires -std=c99 but the Ruby/C
code still uses C99 features.
2015-06-09 11:08:25 -07:00
Josh Haberman
e8ed021ee7 Updated upb to latest version (C89).
Since this version of upb supports C89, all of the
extra compiler flags are no longer required.
2015-06-08 17:56:03 -07:00
Bo Yang
e107e2d68e Update version number to 3.0.0-alpha-4 2015-05-29 11:00:57 -07:00
teboring
9839c0c2c9 Update version number to 3.0.0-alpha-3 2015-05-23 09:20:23 -07:00
Bo Yang
5db217305f down-integrate internal changes 2015-05-21 19:32:02 -07:00
Chris Fallin
231886f632 Ruby C extension speedup: don't re-intern constant string needlessly.
Also fixed lines with > 80 char length.
2015-05-19 16:19:00 -07:00
Joshua Haberman
202f87f8de Merge pull request #387 from cfallin/ruby-upb-update
Update MRI C Ruby extension to use new version of upb (with upb_env).
2015-05-18 14:07:21 -07:00
Tamir Duberstein
e54c14552f Don't hardcode bash 2015-05-15 17:41:04 -04:00
Chris Fallin
d326277397 Update MRI C Ruby extension to use new version of upb.
- Alter encode/decode paths to use the `upb_env` (environment)
  abstraction.
- Update upb amalgamation to upstream `93791bfe`.
- Fix a compilation warning (void*->char* cast).
- Modify build flags so that upb doesn't produce warnings -- the Travis
  build logs were pretty cluttered previously.
2015-05-15 11:36:12 -07:00
Chris Fallin
a526605aec Merge pull request #338 from skippy/encode-decode-helpers
ruby: Encode decode cleanup and behavior normalization
2015-05-15 10:52:56 -07:00
Chris Fallin
e96b5b6b7b Merge pull request #385 from cfallin/travis-refactor
Refactor Travis tests: split configs and run in parallel.
2015-05-14 15:05:08 -07:00
Chris Fallin
20e94b24dd Refactor Travis tests: split configs and run in parallel. 2015-05-14 11:48:21 -07:00
Adam Greene
cd7ebbe54f make repeated_field quack like an array 2015-05-14 10:38:11 -07:00
Chris Fallin
eb37551ae4 Added Ruby to Travis testing.
- Added RVM-based Ruby test driver that tests MRI and JRuby.
- Fixed JRuby compilation (at least in my current setup): force source
  version to 1.6 (Java 6) to allow generics and annotations.
- Modify the skipped JRuby JSON tests so that the exit code is 0 (skip()
  results in a failing exit code from `rake test`). An upcoming PR
  should fix JSON under JRuby in general soon.
2015-05-13 14:58:48 -07:00
Adam Greene
d1b52a00e0 adding and simplifying encoders/decoders
* make consistent between mri and jruby
* create a #to_h and have it use symbols for keys
* add #to_json and #to_proto helpers on the Google::Protobuf message classes
2015-05-13 10:03:56 -07:00
Chris Fallin
16a283f794 Merge pull request #334 from skippy/allow-msg-to-accept-nil
ruby: allow a message field to be unset
2015-05-02 19:02:08 -07:00
Adam Greene
64678265c5 allow a message field to be unset 2015-05-02 13:48:23 -07:00
Adam Greene
d55733c76e return nil if array index indicie is out of bounds
ruby arrays don't throw an exception; they return nil.  Lets do the
same!

this fix also includes the ability to use negative array indicies
2015-05-01 22:50:57 -07:00
Adam Greene
c70b6058ea add size alias for length
starting to make `RepeatedField` quack like an array

additional changes:
* make sure gemspec gets all ruby code files
* add homepage in gem spec removes one of the warnings, and the gem spec authors are pushing
everyone to include a homepage in the gem
* remove excess whitespace in test suite to bring formatting inline with the rest of the file
2015-05-01 11:48:04 -07:00
Adam Greene
761cfa08e6 build cleanups
* update docs to simplify build steps
* Gemfile.lock seemed to have an older version specified
* do not check in the pkg dir
2015-05-01 08:48:56 -07:00
Chris Fallin
14fd96224c Bump gem version to release bugfix. 2015-04-13 14:04:12 -07:00
Chris Fallin
e9abbd23fb Fixed issue #283: crash in JSON handler cleanup.
Includes repro test case from @wfarr.
2015-04-13 14:02:43 -07:00
Isaiah Peng
27e2b57830 add jruby support by protobuf-java reflection API 2015-03-10 23:14:08 +01:00
Chris Fallin
dfdec3b654 Updated Ruby gem version and added note to ruby/README.md regarding version number scheme.
Change-Id: Idb29077c153530de78ce28c094442aa8f51ddd25
2015-03-03 10:56:23 -08:00
Jisi Liu
40f2df3c16 Bump the version number to 3.0.0-alpha-3-pre
Change-Id: I33479e529b060e4fed532a827a386d3baecc835e
2015-03-02 19:31:31 -08:00
Chris Fallin
21fb217e6a Updated Ruby README with more details on getting started.
Change-Id: I54df314660cdb861ad8c4da75a08d4cb97faf638
2015-02-23 12:28:43 -08:00
Chris Fallin
11ad1bd277 Update Ruby gem version to 3.0.0.alpha.2.0.
This update conforms to our two-numbers-after-alpha scheme that allows
us to bump the last number if we need to re-upload a gem. (Rubygems does
not allow re-use of a version number once a gem is uploaded.)

Change-Id: Ia8e7c129d19800afd66f8052785cf5a00462c7ba
2015-02-20 18:06:31 -08:00
Chris Fallin
6ad8f547fe Updated Ruby README.
Change-Id: I8c3717f549c9b4e9d07c77ec5875c9cd62b296ac
2015-02-20 17:49:14 -08:00
Chris Fallin
db87a9c07a Merge pull request #211 from isaiah/map_inspect
Ruby implementation Map#inspect should be consistent with Hash#inspect
2015-02-17 13:02:32 -06:00
Isaiah Peng
4502626fa7 Google::Protobuf::Map#inspect should be consistent with Hash#inspect 2015-02-14 22:15:12 +01:00
Chris Fallin
315b93fdcc Addressed code-review comment. 2015-02-13 14:32:09 -08:00
Chris Fallin
a2bea0a001 Properly support maps in Ruby protoc and another bugfix.
Previously, we supported map fields in the Ruby DSL. However, we never
connected the final link in the chain and generated `map` DSL commands
for map fields in `.proto` files. My apologies -- I had been testing
with the DSL directly so I missed this.

Also fixed a handlerdata-setup-infinite-loop when a map value field's
type is its containing message.
2015-02-12 16:08:01 -08:00
Joshua Haberman
20490e33ca Merge pull request #189 from cfallin/update-ruby-upb
Updated to latest upb and added test for JSON map operation.
2015-02-05 15:22:17 -08:00
Chris Fallin
06bf6308ea README.md update for Ruby gem. 2015-02-05 14:58:57 -08:00
Chris Fallin
e7e79a43ed Merge pull request #190 from isaiah/to_ary
add #to_ary to RepeatedField
2015-02-03 09:57:13 -08:00
Isaiah Peng
ee5f6e9a35 add #to_ary to RepeatedField 2015-02-03 16:45:12 +01:00
Chris Fallin
a50759254f Updated to latest upb and added test for JSON map operation. 2015-02-02 15:07:34 -08:00
Chris Fallin
a3953da536 Updated based on code-review comments. 2015-02-02 13:16:57 -08:00
Chris Fallin
eb33f9d3d6 Updated based on code-review comments. 2015-02-02 13:03:08 -08:00
Chris Fallin
07b8b0f28d Addressed code-review comments. 2015-01-26 13:52:51 -08:00
Chris Fallin
9de35e7421 Addressed code-review comments. 2015-01-26 11:23:19 -08:00
Chris Fallin
e2debef5d8 Ruby extension: added oneof accessor. 2015-01-14 18:02:27 -08:00
Chris Fallin
e1b7d38d9a Addressed code-review comments. 2015-01-14 17:14:05 -08:00
Chris Fallin
3f3820d8f8 Two tests for Ruby code generator:
- A golden-file test that ensures protoc produces known-valid output.
- A Ruby test that loads that golden file and ensures it actually works
  with the extension.

This split strategy allows us to test end-to-end without needing to
integrate the Ruby gem build system and the protoc build system. This is
desirable because we do not want a gem build/install to depend on
building protoc, and we do not want building protoc to depend on
building and testing the gem.
2015-01-14 15:44:46 -08:00
Chris Fallin
fcd8889d5b Support oneofs in MRI Ruby C extension. 2015-01-14 14:35:57 -08:00
Chris Fallin
ace4212e60 Line-wraps at 80 chars. 2015-01-13 13:47:58 -08:00
Chris Fallin
addd26cbb3 Addressed code-review comments. 2015-01-12 16:09:35 -08:00
Chris Fallin
97b663a8be Update upb amalgamation. 2015-01-09 16:15:22 -08:00
Chris Fallin
4c92289766 Addressed code-review comments. 2015-01-09 15:37:55 -08:00
Chris Fallin
80276ac021 Addressed code-review comments. 2015-01-06 18:01:32 -08:00
Chris Fallin
fd1a3ff11d Support for maps in the MRI C Ruby extension.
This adds the Map container and support for parsing and serializing maps
in the protobuf wire format (as defined by the C++ implementation, with
MapEntry submessages in a repeated field). JSON map
serialization/parsing are not yet supported as these will require some
changes to upb as well.
2015-01-06 15:44:09 -08:00
Chris Fallin
91473dcebf Rename protobuf Ruby module to google/protobuf and rework its build
system. The Ruby module build now uses an amalgamated distribution of
upb, and successfully builds a Ruby gem called 'google-protobuf' with
module 'google/protobuf'.
2014-12-12 15:58:26 -08:00
Chris Fallin
973f425725 Provide a Ruby extension.
This adds a Ruby extension in ruby/ that is based on the 'upb' library
(now included as a submodule), and adds support for Ruby code generation
to the protoc compiler.
2014-12-09 16:55:59 -08:00