mirror of
https://github.com/rubyjs/therubyracer
synced 2023-03-27 23:21:42 -04:00
move funcalls into their own module
This commit is contained in:
parent
597b840997
commit
9ef1695abd
4 changed files with 17 additions and 4 deletions
|
@ -2,6 +2,7 @@
|
|||
#include "v8_value.h"
|
||||
#include "v8_obj.h"
|
||||
#include "v8_func.h"
|
||||
#include "v8_array.h"
|
||||
#include "v8_str.h"
|
||||
|
||||
using namespace v8;
|
||||
|
|
|
@ -19,7 +19,19 @@ namespace {
|
|||
rb_scan_args(argc, argv, "1*", &recv, &f_argv);
|
||||
|
||||
Local<Function> function = V8_Ref_Get<Function>(self);
|
||||
Local<Object> thisObject = V8_Ref_Get<Object>(recv);
|
||||
Local<Object> thisObject;
|
||||
if (NIL_P(recv)) {
|
||||
if (Context::InContext()) {
|
||||
thisObject = Context::GetEntered()->Global();
|
||||
} else {
|
||||
Persistent<Context> cxt = Context::New();
|
||||
Context::Scope scope(cxt);
|
||||
thisObject = cxt->Global();
|
||||
cxt.Dispose();
|
||||
}
|
||||
} else {
|
||||
thisObject = V8_Ref_Get<Object>(recv);
|
||||
}
|
||||
int f_argc = argc - 1;
|
||||
Local<Value> arguments[f_argc];
|
||||
for (int i = 0; i < f_argc; i++) {
|
||||
|
|
|
@ -6,7 +6,7 @@ module V8
|
|||
case value
|
||||
when V8::C::Function then V8::Function.new(value)
|
||||
when V8::C::Object then V8::Object.new(value)
|
||||
when V8::C::String then "Wonkers!"
|
||||
when V8::C::String then value.Utf8Value()
|
||||
else
|
||||
value
|
||||
end
|
||||
|
|
|
@ -6,7 +6,7 @@ describe C::Function do
|
|||
it "is callable" do
|
||||
C::Context.new.open do |cxt|
|
||||
f = cxt.eval('(function() {return "Hello World"})', '<eval>');
|
||||
f.Call(cxt.Global).should == "Hello World"
|
||||
f.Call(cxt.Global).AsciiValue().should == "Hello World"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -37,6 +37,6 @@ describe C::Function do
|
|||
C::Context.new.open do |cxt|
|
||||
@f = cxt.eval('(function() {return "Call Me"})', 'eval')
|
||||
end
|
||||
@f.Call(nil).should == "Call Me"
|
||||
@f.Call(nil).Utf8Value().should == "Call Me"
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue