2009-12-15 00:35:55 -05:00
|
|
|
module V8
|
|
|
|
# This doesn't do anything at the moment. But the ruby interface will go here
|
|
|
|
# The native interface is under the V8::C module.
|
2009-12-16 01:40:19 -05:00
|
|
|
class Context
|
|
|
|
def initialize
|
|
|
|
@native = C::Context.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def open(&block)
|
|
|
|
@native.open do
|
|
|
|
block.call(self) if block
|
|
|
|
end if block_given?
|
|
|
|
end
|
|
|
|
|
|
|
|
def eval(javascript)
|
|
|
|
self.open do
|
2009-12-16 08:03:57 -05:00
|
|
|
source = V8::C::String.new(javascript.to_s)
|
2009-12-16 01:40:19 -05:00
|
|
|
script = V8::C::Script.new(source)
|
|
|
|
script.Run()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def evaluate(*args)
|
|
|
|
self.eval(*args)
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.open(&block)
|
|
|
|
new.open(&block)
|
|
|
|
end
|
2009-12-15 00:35:55 -05:00
|
|
|
end
|
|
|
|
end
|