mirror of
https://github.com/rubyjs/mini_racer
synced 2023-03-27 23:21:28 -04:00
Change method name from function_call to call
This makes wording coherent with ExecJS and TheRubyRacer.
This commit is contained in:
parent
9e81a2cce6
commit
c34ef93e10
4 changed files with 19 additions and 19 deletions
|
@ -290,7 +290,7 @@ This calls the function passed as first argument:
|
|||
```ruby
|
||||
context = MiniRacer::Context.new
|
||||
context.eval('function hello(name) { return "Hello, " + name + "!" }')
|
||||
context.function_call('hello', 'George')
|
||||
context.call('hello', 'George')
|
||||
# "Hello, George!"
|
||||
```
|
||||
|
||||
|
|
|
@ -1090,7 +1090,7 @@ rb_context_dispose(VALUE self) {
|
|||
}
|
||||
|
||||
static void*
|
||||
nogvl_context_function_call(void *args) {
|
||||
nogvl_context_call(void *args) {
|
||||
|
||||
FunctionCall *call = (FunctionCall *) args;
|
||||
if (!call) {
|
||||
|
@ -1132,7 +1132,7 @@ static void unblock_function(void *args) {
|
|||
}
|
||||
|
||||
static VALUE
|
||||
rb_context_function_call_unsafe(int argc, VALUE *argv, VALUE self) {
|
||||
rb_context_call_unsafe(int argc, VALUE *argv, VALUE self) {
|
||||
|
||||
ContextInfo* context_info;
|
||||
FunctionCall call;
|
||||
|
@ -1191,7 +1191,7 @@ rb_context_function_call_unsafe(int argc, VALUE *argv, VALUE self) {
|
|||
}
|
||||
}
|
||||
|
||||
rb_thread_call_without_gvl(nogvl_context_function_call, &call, unblock_function, &call);
|
||||
rb_thread_call_without_gvl(nogvl_context_call, &call, unblock_function, &call);
|
||||
free(call.argv);
|
||||
|
||||
if (!call.error) {
|
||||
|
@ -1235,7 +1235,7 @@ extern "C" {
|
|||
rb_define_method(rb_cContext, "dispose_unsafe", (VALUE(*)(...))&rb_context_dispose, 0);
|
||||
rb_define_method(rb_cContext, "heap_stats", (VALUE(*)(...))&rb_heap_stats, 0);
|
||||
rb_define_private_method(rb_cContext, "eval_unsafe",(VALUE(*)(...))&rb_context_eval_unsafe, 2);
|
||||
rb_define_private_method(rb_cContext, "function_call_unsafe", (VALUE(*)(...))&rb_context_function_call_unsafe, -1);
|
||||
rb_define_private_method(rb_cContext, "call_unsafe", (VALUE(*)(...))&rb_context_call_unsafe, -1);
|
||||
|
||||
rb_define_alloc_func(rb_cContext, allocate);
|
||||
rb_define_alloc_func(rb_cSnapshot, allocate_snapshot);
|
||||
|
|
|
@ -186,13 +186,13 @@ module MiniRacer
|
|||
@eval_thread = nil
|
||||
end
|
||||
|
||||
def function_call(function_name, *arguments)
|
||||
raise(ContextDisposedError, 'attempted to call function_call on a disposed context!') if @disposed
|
||||
def call(function_name, *arguments)
|
||||
raise(ContextDisposedError, 'attempted to call function on a disposed context!') if @disposed
|
||||
|
||||
@eval_thread = Thread.current
|
||||
isolate.with_lock do
|
||||
timeout do
|
||||
function_call_unsafe(function_name, *arguments)
|
||||
call_unsafe(function_name, *arguments)
|
||||
end
|
||||
end
|
||||
ensure
|
||||
|
|
|
@ -9,11 +9,11 @@ class MiniRacerFunctionTest < Minitest::Test
|
|||
assert_equal context.eval('f(10)'), "I need 10 foos"
|
||||
|
||||
assert_raises(ArgumentError) do
|
||||
context.function_call
|
||||
context.call
|
||||
end
|
||||
|
||||
count = 4
|
||||
res = context.function_call('f', count)
|
||||
res = context.call('f', count)
|
||||
assert_equal "I need #{count} foos", res
|
||||
end
|
||||
|
||||
|
@ -23,7 +23,7 @@ class MiniRacerFunctionTest < Minitest::Test
|
|||
|
||||
# f is defined, let's call g
|
||||
assert_raises(MiniRacer::RuntimeError) do
|
||||
context.function_call('g')
|
||||
context.call('g')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -33,7 +33,7 @@ class MiniRacerFunctionTest < Minitest::Test
|
|||
|
||||
# f should throw
|
||||
assert_raises(MiniRacer::RuntimeError) do
|
||||
context.function_call('f', 1)
|
||||
context.call('f', 1)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -43,7 +43,7 @@ class MiniRacerFunctionTest < Minitest::Test
|
|||
|
||||
# f is defined, let's call g
|
||||
assert_raises(MiniRacer::RuntimeError) do
|
||||
context.function_call('g')
|
||||
context.call('g')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -53,7 +53,7 @@ class MiniRacerFunctionTest < Minitest::Test
|
|||
|
||||
# f is defined, let's call g
|
||||
assert_raises(MiniRacer::RuntimeError) do
|
||||
context.function_call('f', 1)
|
||||
context.call('f', 1)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -61,13 +61,13 @@ class MiniRacerFunctionTest < Minitest::Test
|
|||
context = MiniRacer::Context.new
|
||||
context.eval("function f(x, y) { return 'I need ' + x + ' ' + y }")
|
||||
|
||||
res = context.function_call('f', 3, "bars")
|
||||
res = context.call('f', 3, "bars")
|
||||
assert_equal "I need 3 bars", res
|
||||
|
||||
res = context.function_call('f', {a: 1}, "bars")
|
||||
res = context.call('f', {a: 1}, "bars")
|
||||
assert_equal "I need [object Object] bars", res
|
||||
|
||||
res = context.function_call('f', [1,2,3], "bars")
|
||||
res = context.call('f', [1,2,3], "bars")
|
||||
assert_equal "I need 1,2,3 bars", res
|
||||
end
|
||||
|
||||
|
@ -76,7 +76,7 @@ class MiniRacerFunctionTest < Minitest::Test
|
|||
context.eval("function f(x, y) { return { vx: x, vy: y, array: [x, y] } }")
|
||||
|
||||
h = { "vx" => 3, "vy" => "bars", "array" => [3, "bars"] }
|
||||
res = context.function_call('f', 3, "bars")
|
||||
res = context.call('f', 3, "bars")
|
||||
assert_equal h, res
|
||||
end
|
||||
|
||||
|
@ -91,7 +91,7 @@ class MiniRacerFunctionTest < Minitest::Test
|
|||
thread_count.times do
|
||||
threads << Thread.new do
|
||||
10.times do |i|
|
||||
context.function_call("f", i)
|
||||
context.call("f", i)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue