Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rubinius/rubinius
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 78ab83f49f0e
Choose a base ref
...
head repository: rubinius/rubinius
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 706802fb796e
Choose a head ref
  • 2 commits
  • 4 files changed
  • 1 contributor

Commits on Dec 17, 2014

  1. Aliased rb_ary_new_from_args to rb_ary_new3.

    In MRI it's the other way around: rb_ary_new3 is the alias. However, in our case
    this breaks certain parts (e.g. rubysl-openssl) for reasons unknown to me. Since
    it doesn't really matter which one is the alias I decided to alias
    rb_ary_new_from_args to rb_ary_new3 instead of the other way around.
    Yorick Peterse committed Dec 17, 2014

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    f137a5d View commit details
  2. Added specs for rb_ary_new_from_args.

    Yorick Peterse committed Dec 17, 2014
    Copy the full SHA
    706802f View commit details
Showing with 19 additions and 0 deletions.
  1. +6 −0 spec/ruby/optional/capi/array_spec.rb
  2. +10 −0 spec/ruby/optional/capi/ext/array_spec.c
  3. +1 −0 spec/ruby/optional/capi/ext/rubyspec.h
  4. +2 −0 vm/include/capi/ruby/ruby.h
6 changes: 6 additions & 0 deletions spec/ruby/optional/capi/array_spec.rb
Original file line number Diff line number Diff line change
@@ -42,6 +42,12 @@
end
end

describe "rb_ary_new_from_args" do
it "returns an array with the passed cardinality and varargs" do
@s.rb_ary_new_from_args(1,2,3).should == [1,2,3]
end
end

describe "rb_ary_new4" do
it "returns returns an array with the passed values" do
@s.rb_ary_new4(1,2,3).should == [1,2,3]
10 changes: 10 additions & 0 deletions spec/ruby/optional/capi/ext/array_spec.c
Original file line number Diff line number Diff line change
@@ -165,6 +165,12 @@ static VALUE array_spec_rb_ary_new3(VALUE self, VALUE first, VALUE second, VALUE
}
#endif

#ifdef HAVE_RB_ARY_NEW_FROM_ARGS
static VALUE array_spec_rb_ary_new_from_args(VALUE self, VALUE first, VALUE second, VALUE third) {
return rb_ary_new_from_args(3, first, second, third);
}
#endif

#ifdef HAVE_RB_ARY_NEW4
static VALUE array_spec_rb_ary_new4(VALUE self, VALUE first, VALUE second, VALUE third) {
VALUE values[3];
@@ -379,6 +385,10 @@ void Init_array_spec() {
rb_define_method(cls, "rb_ary_new3", array_spec_rb_ary_new3, 3);
#endif

#ifdef HAVE_RB_ARY_NEW_FROM_ARGS
rb_define_method(cls, "rb_ary_new_from_args", array_spec_rb_ary_new_from_args, 3);
#endif

#ifdef HAVE_RB_ARY_NEW4
rb_define_method(cls, "rb_ary_new4", array_spec_rb_ary_new4, 3);
#endif
1 change: 1 addition & 0 deletions spec/ruby/optional/capi/ext/rubyspec.h
Original file line number Diff line number Diff line change
@@ -63,6 +63,7 @@
#define HAVE_RB_ARY_NEW 1
#define HAVE_RB_ARY_NEW2 1
#define HAVE_RB_ARY_NEW3 1
#define HAVE_RB_ARY_NEW_FROM_ARGS 1
#define HAVE_RB_ARY_NEW4 1
#define HAVE_RB_ARY_POP 1
#define HAVE_RB_ARY_PUSH 1
2 changes: 2 additions & 0 deletions vm/include/capi/ruby/ruby.h
Original file line number Diff line number Diff line change
@@ -921,6 +921,8 @@ struct RTypedData {
/** New Array of given length, filled with varargs elements. */
VALUE rb_ary_new3(unsigned long length, ...);

#define rb_ary_new_from_args rb_ary_new3

/** New Array of given length, filled with copies of given object. */
VALUE rb_ary_new4(unsigned long length, const VALUE* object);