mirror of
https://github.com/rubyjs/therubyracer
synced 2023-03-27 23:21:42 -04:00
expose global scope as an attribute on context. Add Array#length. kinda useful :)
This commit is contained in:
parent
f81cc92fca
commit
fea99b72bd
4 changed files with 11 additions and 13 deletions
|
@ -7,5 +7,9 @@ module V8
|
||||||
yield To.ruby(@native.Get(i))
|
yield To.ruby(@native.Get(i))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def length
|
||||||
|
@native.Length()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -51,19 +51,11 @@ module V8
|
||||||
end
|
end
|
||||||
|
|
||||||
def [](key)
|
def [](key)
|
||||||
open do
|
@scope[key]
|
||||||
To.ruby(@native.Global().Get(key.to_s))
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def []=(key, value)
|
def []=(key, value)
|
||||||
value.tap do
|
@scope[key] = value
|
||||||
open do
|
|
||||||
@native.Global().tap do |scope|
|
|
||||||
scope.Set(To.v8(key.to_s), To.v8(value))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.open(opts = {}, &block)
|
def self.open(opts = {}, &block)
|
||||||
|
|
|
@ -2,8 +2,10 @@ module V8
|
||||||
class Function < V8::Object
|
class Function < V8::Object
|
||||||
|
|
||||||
def call(thisObject, *args)
|
def call(thisObject, *args)
|
||||||
this = To.v8(thisObject)
|
@context.enter do
|
||||||
To.ruby(@native.Call(this, *args.map {|a| To.v8(a)}))
|
this = To.v8(thisObject)
|
||||||
|
To.ruby(@native.Call(this, *args.map {|a| To.v8(a)}))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit b31ad73b452ca016898bed475c896e2f741d8f82
|
Subproject commit 633cd074545563a2bb362c97bbc758de6b7710d1
|
Loading…
Reference in a new issue