Commit Graph

86 Commits

Author SHA1 Message Date
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
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
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
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