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

Merge branch 'master' into 0.10

Conflicts:
	lib/v8/version.rb
This commit is contained in:
Charles Lowell 2012-03-28 15:40:29 -05:00
commit 410fe595da
7 changed files with 43 additions and 26 deletions

9
.travis.yml Normal file
View file

@ -0,0 +1,9 @@
rvm:
- 1.9.2
- 1.9.3
- 1.8.7
notifications:
recipients:
- cowboyd@thefrontside.net
script: bundle exec rake compile spec
before_install: git submodule update --init

View file

@ -48,7 +48,7 @@ embed a ruby object into your scope and access its properties/methods from javas
lhs + rhs
end
end
cxt['math'] = MyMath.new
cxt.eval("math.plus(20,22)") #=> 42
@ -59,7 +59,7 @@ make a ruby object *be* your global javascript scope.
cxt.eval("plus(20,22)") #=> 42
end
you can do the same thing with Object#eval_js
you can do the same thing with Object#eval_js
math.eval_js("plus(20,22)")
@ -96,14 +96,14 @@ exposed by default. E.g.
super
end
end
class B < A
def b
"b"
end
end
V8::Context.new do |cxt|
cxt['a'] = A.new
cxt['b'] = B.new
@ -138,6 +138,9 @@ To use the ruby racer in rails, or any application using Bundler to manage gems,
bundle install
rake compile
## Sponsored by
<a href="http://thefrontside.net">![The Frontside](http://github.com/cowboyd/therubyracer/raw/master/thefrontside.png)</a>
## LICENSE:
(The MIT License)

View file

@ -18,8 +18,8 @@ $CPPFLAGS += " -Wall" unless $CPPFLAGS.split.include? "-Wall"
$CPPFLAGS += " -g" unless $CPPFLAGS.split.include? "-g"
$CPPFLAGS += " -rdynamic" unless $CPPFLAGS.split.include? "-rdynamic"
$DEFLIBPATH.unshift(Libv8.library_path)
$LIBS << ' -lv8 -lpthread'
$LDFLAGS.insert 0, "#{Libv8.library_path}/libv8.#{$LIBEXT} "
$LIBS << ' -lpthread'
CONFIG['LDSHARED'] = '$(CXX) -shared' unless RUBY_PLATFORM =~ /darwin/

View file

@ -3,7 +3,7 @@ require 'ostruct'
module V8
module CLI
def self.run(exename = 'v8', args = [])
def self.run(exename = 'v8', args = [])
options = OpenStruct.new
options.libs = []
options.libdirs = []
@ -30,12 +30,12 @@ module V8
puts "V8 Version #{Libv8::V8_VERSION}"
exit
elsif options.selftest
self.test
self.test
end
Context.new(:with => Shell.new) do |cxt|
for libfile in options.libs do
load(cxt,libfile)
end
end
if options.interactive
repl(cxt, exename)
elsif options.execute
@ -60,35 +60,36 @@ module V8
puts e
end
end
def self.test
begin
require 'rubygems'
require 'rspec'
specs = File.expand_path('../../../spec', __FILE__)
$:.unshift specs
ARGV.clear
ARGV << File.dirname(__FILE__) + '/../../spec/'
ARGV << specs
::RSpec::Core::Runner.autorun
exit(0)
rescue LoadError => e
puts "selftest requires rspec to be installed (gem install rspec)"
exit(1)
end
end
def self.repl(cxt, exename)
require 'readline'
puts "help() for help. quit() to quit."
puts "The Ruby Racer #{V8::VERSION}"
puts "Vroom Vroom!"
puts "Vroom Vroom!"
trap("SIGINT") do
puts "^C"
end
end
loop do
line = Readline.readline("#{exename}> ", true)
begin
result = cxt.eval(line, '<shell>')
puts(result) unless result.nil?
puts(result) unless result.nil?
rescue V8::JSError => e
puts e.message
puts e.backtrace(:javascript)
@ -96,9 +97,9 @@ module V8
puts e
puts e.backtrace.join("\n")
end
end
end
end
end
class Shell
def to_s
"[object Shell]"
@ -111,18 +112,18 @@ module V8
def exit(status = 0)
Kernel.exit(status)
end
alias_method :quit, :exit
def help(*args)
<<-HELP
print(msg)
print msg to STDOUT
print msg to STDOUT
exit(status = 0)
exit the shell
also: quit()
evalrb(source)
evaluate some ruby source
HELP

View file

@ -84,6 +84,10 @@ module V8
[]
end
end
def self.passes_this_argument?
true
end
end
module C

View file

@ -74,7 +74,7 @@ module V8
if id = @rb_proxies_js2rb[object]
ObjectSpace._id2ref id
end
rescue RangeError => e
rescue RangeError
# sometimes, the Ruby proxy has been garbage collected, but
# the finalizer which runs has not been called. That's OK
# we just clear out the entry, and return nil so that a new

BIN
thefrontside.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB