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: d51518c5bcd2
Choose a base ref
...
head repository: rubinius/rubinius
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7772d0539f57
Choose a head ref
  • 3 commits
  • 5 files changed
  • 1 contributor

Commits on Dec 2, 2014

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    5be264f View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    36a5900 View commit details
  3. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    7772d05 View commit details
2 changes: 1 addition & 1 deletion kernel/common/autoload.rb
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@ def resolve
end
end

def find_const under
def find_const(under)
current, constant = under, undefined

while current
4 changes: 4 additions & 0 deletions spec/ruby/optional/capi/class_spec.rb
Original file line number Diff line number Diff line change
@@ -10,6 +10,10 @@
@s.send(@method, "CApiClassSpecs::A::B").should equal(CApiClassSpecs::A::B)
end

it "resolves autoload constants" do
@s.send(@method, "CApiClassSpecs::A::D").name.should == "CApiClassSpecs::A::D"
end

it "raises an ArgumentError if a constant in the path does not exist" do
lambda { @s.send(@method, "CApiClassSpecs::NotDefined::B") }.should raise_error(ArgumentError)
end
1 change: 1 addition & 0 deletions spec/ruby/optional/capi/fixtures/class.rb
Original file line number Diff line number Diff line change
@@ -77,6 +77,7 @@ def call_super_method

class A
C = 1
autoload :D, File.expand_path('../path_to_class.rb', __FILE__)

class B
end
6 changes: 6 additions & 0 deletions spec/ruby/optional/capi/fixtures/path_to_class.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class CApiClassSpecs
class A
module D
end
end
end
7 changes: 7 additions & 0 deletions vm/capi/class.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "builtin/autoload.hpp"
#include "builtin/class.hpp"
#include "builtin/module.hpp"
#include "builtin/string.hpp"
@@ -107,6 +108,12 @@ extern "C" {
rb_raise(rb_eArgError, "undefined class or module %s", path);
}

if(Autoload* autoload = try_as<Autoload>(val)) {
VALUE m = capi_fast_call(env->get_handle(autoload),
rb_intern("call"), 1, env->get_handle(mod));
val = env->get_object(m);
}

if(!(mod = try_as<Module>(val))) {
free(pathd);
capi_raise_type_error(Module::type, val);