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))
|
||||
end
|
||||
end
|
||||
|
||||
def length
|
||||
@native.Length()
|
||||
end
|
||||
end
|
||||
end
|
|
@ -51,19 +51,11 @@ module V8
|
|||
end
|
||||
|
||||
def [](key)
|
||||
open do
|
||||
To.ruby(@native.Global().Get(key.to_s))
|
||||
end
|
||||
@scope[key]
|
||||
end
|
||||
|
||||
def []=(key, value)
|
||||
value.tap do
|
||||
open do
|
||||
@native.Global().tap do |scope|
|
||||
scope.Set(To.v8(key.to_s), To.v8(value))
|
||||
end
|
||||
end
|
||||
end
|
||||
@scope[key] = value
|
||||
end
|
||||
|
||||
def self.open(opts = {}, &block)
|
||||
|
|
|
@ -2,8 +2,10 @@ module V8
|
|||
class Function < V8::Object
|
||||
|
||||
def call(thisObject, *args)
|
||||
this = To.v8(thisObject)
|
||||
To.ruby(@native.Call(this, *args.map {|a| To.v8(a)}))
|
||||
@context.enter do
|
||||
this = To.v8(thisObject)
|
||||
To.ruby(@native.Call(this, *args.map {|a| To.v8(a)}))
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit b31ad73b452ca016898bed475c896e2f741d8f82
|
||||
Subproject commit 633cd074545563a2bb362c97bbc758de6b7710d1
|
Loading…
Reference in a new issue