1
0
Fork 0
mirror of https://github.com/rubyjs/therubyracer synced 2023-03-27 23:21:42 -04:00

move most important Context methods to the top

This commit is contained in:
Charles Lowell 2012-06-16 12:49:09 -05:00
parent b54e34747d
commit 38e8902266

View file

@ -19,6 +19,29 @@ module V8
yield self if block_given?
end
def eval(source, filename = '<eval>', line = 1)
if IO === source || StringIO === source
source = source.read
end
enter do
script = try { V8::C::Script::New(source.to_s, filename.to_s) }
to_ruby try {script.Run()}
end
end
def [](key)
enter do
to_ruby(@native.Global().Get(to_v8(key)))
end
end
def []=(key, value)
enter do
@native.Global().Set(to_v8(key), to_v8(value))
end
return value
end
def scope
enter { to_ruby @native.Global() }
end
@ -81,30 +104,5 @@ module V8
self.eval file, filename
end
end
def eval(source, filename = '<eval>', line = 1)
if IO === source || StringIO === source
source = source.read
end
enter do
source = V8::C::String::New(source.to_s)
filename = V8::C::String::New(filename.to_s)
script = try { V8::C::Script::New(source, filename) }
to_ruby try {script.Run()}
end
end
def []=(key, value)
enter do
@native.Global().Set(to_v8(key), to_v8(value))
end
return value
end
def [](key)
enter do
to_ruby(@native.Global().Get(to_v8(key)))
end
end
end
end