Commit Graph

63 Commits

Author SHA1 Message Date
@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
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
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
3ee2e20539 Merge pull request #1144 from dongjoon-hyun/remove_redundant_the
Remove redundant `the`.
2016-02-11 17:17:48 -08:00
Dongjoon Hyun
7a9040fe7f Remove redundant the in comments. 2016-02-03 15:27:27 -08:00
Anders Carling
0559f3ee9e Add field name to initialization map exceptions 2015-11-20 21:57:28 +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
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
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
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
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
Adam Greene
cd7ebbe54f make repeated_field quack like an array 2015-05-14 10:38:11 -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
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
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
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