therubyracer 0.4.7-x86-darwin-10 → 0.4.8-x86-darwin-10

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of therubyracer might be problematic. Click here for more details.

data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.4.8 2010-02-08
2
+ * 1 major enhancements
3
+ * expose line number and source name on JavascriptErrors.
4
+
1
5
  === 0.4.5 2010-01-18
2
6
  * 3 major enhancements
3
7
  * case munging so that ruby methods(perl_case) are accessed through javascript in camelCase.
data/Manifest.txt CHANGED
@@ -4,7 +4,6 @@ Manifest.txt
4
4
  README.rdoc
5
5
  Rakefile
6
6
  docs/data_conversion.txt
7
- ext/v8/Makefile
8
7
  ext/v8/callbacks.cpp
9
8
  ext/v8/callbacks.h
10
9
  ext/v8/convert_ruby.cpp
data/Rakefile CHANGED
@@ -41,6 +41,11 @@ Rake::ExtensionTask.new("v8", $hoe.spec) do |ext|
41
41
  ext.source_pattern = "*.{cpp,h}"
42
42
  end
43
43
 
44
+
45
+ task :clean do
46
+ sh "rm -f ext/v8/Makefile"
47
+ end
48
+
44
49
  require 'newgem/tasks'
45
50
  Dir['tasks/**/*.rake'].each { |t| load t }
46
51
 
Binary file
data/ext/v8/v8.cpp CHANGED
@@ -43,7 +43,7 @@ extern "C" {
43
43
  rb_define_singleton_method(V8_C_Context, "GetCurrent", (VALUE(*)(...)) v8_Context_GetCurrent, 0);
44
44
  rb_define_method(V8_C_Context, "Global", (VALUE(*)(...)) v8_cxt_Global, 0);
45
45
  rb_define_method(V8_C_Context, "open", (VALUE(*)(...)) v8_cxt_open, 0);
46
- rb_define_method(V8_C_Context, "eval", (VALUE(*)(...)) v8_cxt_eval, 1);
46
+ rb_define_method(V8_C_Context, "eval", (VALUE(*)(...)) v8_cxt_eval, 2);
47
47
  rb_define_method(V8_C_Context, "eql?", (VALUE(*)(...)) v8_cxt_eql, 1);
48
48
  rb_define_method(V8_C_Context, "==", (VALUE(*)(...)) v8_cxt_eql, 1);
49
49
 
@@ -75,6 +75,14 @@ extern "C" {
75
75
 
76
76
  V8_C_Message = rb_define_class_under(rb_mNative, "Message", rb_cObject);
77
77
  rb_define_method(V8_C_Message, "Get", (VALUE(*)(...))v8_Message_Get, 0);
78
+ rb_define_method(V8_C_Message, "GetSourceLine", (VALUE(*)(...))v8_Message_GetSourceLine, 0);
79
+ rb_define_method(V8_C_Message, "GetScriptResourceName", (VALUE(*)(...))v8_Message_GetScriptResourceName, 0);
80
+ rb_define_method(V8_C_Message, "GetLineNumber", (VALUE(*)(...))v8_Message_GetLineNumber, 0);
81
+ rb_define_method(V8_C_Message, "GetStartPosition", (VALUE(*)(...))v8_Message_GetStartPosition, 0);
82
+ rb_define_method(V8_C_Message, "GetEndPosition", (VALUE(*)(...)) v8_Message_GetEndPosition, 0);
83
+ rb_define_method(V8_C_Message, "GetStartColumn", (VALUE(*)(...)) v8_Message_GetStartColumn, 0);
84
+ rb_define_method(V8_C_Message, "GetEndColumn", (VALUE(*)(...)) v8_Message_GetEndColumn, 0);
85
+
78
86
 
79
87
  V8_C_Function = rb_define_class_under(rb_mNative, "Function", V8_C_Object);
80
88
  }
data/ext/v8/v8_cxt.cpp CHANGED
@@ -20,7 +20,6 @@ VALUE v8_Context_New(int argc, VALUE *argv, VALUE self) {
20
20
  Persistent<Context> context = Context::New(0, Racer_Create_V8_ObjectTemplate(scope));
21
21
  Context::Scope enter(context);
22
22
  context->Global()->SetHiddenValue(String::New("TheRubyRacer::RubyObject"), External::Wrap((void *)scope));
23
- // context->Global()->SetPointerInInternalField(0, (void*)scope);
24
23
  VALUE ref = V8_Ref_Create(self, context, scope);
25
24
  context.Dispose();
26
25
  return ref;
@@ -59,13 +58,14 @@ VALUE v8_cxt_open(VALUE self) {
59
58
  }
60
59
  }
61
60
 
62
- VALUE v8_cxt_eval(VALUE self, VALUE source) {
61
+ VALUE v8_cxt_eval(VALUE self, VALUE source, VALUE filename) {
63
62
  HandleScope handles;
64
63
  TryCatch exceptions;
65
64
  Local<Context> cxt = V8_Ref_Get<Context>(self);
66
65
  Context::Scope enter(cxt);
67
66
  Local<Value> source_str = RB2V8(source);
68
- Local<Script> script = Script::Compile(source_str->ToString());
67
+ Local<Value> source_name = RTEST(filename) ? RB2V8(filename) : *String::New("<eval>");
68
+ Local<Script> script = Script::Compile(source_str->ToString(), source_name);
69
69
  if (exceptions.HasCaught()) {
70
70
  return V8_Ref_Create(V8_C_Message, exceptions.Message());
71
71
  }
data/ext/v8/v8_cxt.h CHANGED
@@ -14,7 +14,7 @@ VALUE v8_Context_InContext(VALUE self);
14
14
  VALUE v8_Context_GetCurrent(VALUE self);
15
15
  VALUE v8_cxt_Global(VALUE self);
16
16
  VALUE v8_cxt_open(VALUE self);
17
- VALUE v8_cxt_eval(VALUE self, VALUE source);
17
+ VALUE v8_cxt_eval(VALUE self, VALUE source, VALUE filename);
18
18
  VALUE v8_cxt_eql(VALUE self, VALUE other);
19
19
 
20
20
  #endif
data/ext/v8/v8_msg.cpp CHANGED
@@ -14,4 +14,41 @@ VALUE v8_Message_Get(VALUE self) {
14
14
  Local<Message> message = V8_Ref_Get<Message>(self);
15
15
  Local<Value> str = message->Get();
16
16
  return V82RB(str);
17
- }
17
+ }
18
+
19
+ VALUE v8_Message_GetSourceLine(VALUE self) {
20
+ Local<Message> message = V8_Ref_Get<Message>(self);
21
+ Local<Value> line = message->GetSourceLine();
22
+ return V82RB(line);
23
+ }
24
+
25
+ VALUE v8_Message_GetScriptResourceName(VALUE self) {
26
+ Local<Message> message = V8_Ref_Get<Message>(self);
27
+ Handle<Value> name = message->GetScriptResourceName();
28
+ return V82RB(name);
29
+ }
30
+
31
+ VALUE v8_Message_GetLineNumber(VALUE self) {
32
+ Local<Message> message = V8_Ref_Get<Message>(self);
33
+ return INT2FIX(message->GetLineNumber());
34
+ }
35
+
36
+ VALUE v8_Message_GetStartPosition(VALUE self) {
37
+ Local<Message> message = V8_Ref_Get<Message>(self);
38
+ return INT2FIX(message->GetStartPosition());
39
+ }
40
+
41
+ VALUE v8_Message_GetEndPosition(VALUE self) {
42
+ Local<Message> message = V8_Ref_Get<Message>(self);
43
+ return INT2FIX(message->GetEndPosition());
44
+ }
45
+
46
+ VALUE v8_Message_GetStartColumn(VALUE self) {
47
+ Local<Message> message = V8_Ref_Get<Message>(self);
48
+ return INT2FIX(message->GetStartColumn());
49
+ }
50
+
51
+ VALUE v8_Message_GetEndColumn(VALUE self) {
52
+ Local<Message> message = V8_Ref_Get<Message>(self);
53
+ return INT2FIX(message->GetEndColumn());
54
+ }
data/ext/v8/v8_msg.h CHANGED
@@ -7,4 +7,12 @@
7
7
  extern VALUE V8_C_Message;
8
8
  VALUE V8_Wrap_Message(v8::Handle<v8::Message> msg);
9
9
  VALUE v8_Message_Get(VALUE self);
10
+ VALUE v8_Message_GetSourceLine(VALUE self);
11
+ VALUE v8_Message_GetScriptResourceName(VALUE self);
12
+ VALUE v8_Message_GetLineNumber(VALUE self);
13
+ VALUE v8_Message_GetStartPosition(VALUE self);
14
+ VALUE v8_Message_GetEndPosition(VALUE self);
15
+ VALUE v8_Message_GetStartColumn(VALUE self);
16
+ VALUE v8_Message_GetEndColumn(VALUE self);
17
+
10
18
  #endif
data/lib/v8.rb CHANGED
@@ -2,7 +2,7 @@ $:.unshift(File.dirname(__FILE__)) unless
2
2
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
3
 
4
4
  module V8
5
- VERSION = '0.4.7'
5
+ VERSION = '0.4.8'
6
6
  require 'v8/v8' #native glue
7
7
  require 'v8/to'
8
8
  require 'v8/context'
data/lib/v8/context.rb CHANGED
@@ -23,7 +23,7 @@ module V8
23
23
  javascript = javascript.read()
24
24
  end
25
25
  @native.open do
26
- @native.eval(javascript).tap do |result|
26
+ @native.eval(javascript, sourcename).tap do |result|
27
27
  raise JavascriptError.new(result) if result.kind_of?(C::Message)
28
28
  return To.ruby(result)
29
29
  end
@@ -79,8 +79,22 @@ module V8
79
79
  end
80
80
  class JavascriptError < StandardError
81
81
  def initialize(v8_message)
82
- super(v8_message.Get())
82
+ super("#{v8_message.Get()}: #{v8_message.GetSourceLine()}")
83
+ @native = v8_message
83
84
  end
85
+
86
+ def source_name
87
+ @native.GetScriptResourceName()
88
+ end
89
+
90
+ def source_line
91
+ @native.GetSourceLine()
92
+ end
93
+
94
+ def line_number
95
+ @native.GetLineNumber()
96
+ end
97
+
84
98
  end
85
99
  class RunawayScriptError < ContextError
86
100
  end
data/lib/v8/v8.bundle CHANGED
Binary file
@@ -390,5 +390,16 @@ end
390
390
  Context.eval('does not compiles')
391
391
  }.should raise_error
392
392
  end
393
+
394
+ it "should track message state" do
395
+ begin
396
+ Context.open do |cxt|
397
+ cxt.eval("var foo = 'bar';\nsyntax error!", "foo.js")
398
+ end
399
+ rescue JavascriptError => e
400
+ e.line_number.should == 2
401
+ e.source_name.should == "foo.js"
402
+ end
403
+ end
393
404
  end
394
405
  end
data/therubyracer.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{therubyracer}
5
- s.version = "0.4.7"
5
+ s.version = "0.4.8"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Charles Lowell", "Bill Robertson"]
9
- s.date = %q{2010-02-04}
9
+ s.date = %q{2010-02-08}
10
10
  s.description = %q{Embed the V8 Javascript interpreter into Ruby.}
11
11
  s.email = ["cowboyd@thefrontside.net", "billrobertson42@gmail.com"]
12
12
  s.extensions = ["ext/v8/extconf.rb"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: therubyracer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.7
4
+ version: 0.4.8
5
5
  platform: x86-darwin-10
6
6
  authors:
7
7
  - Charles Lowell
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2010-02-05 00:00:00 -06:00
13
+ date: 2010-02-08 00:00:00 -06:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -48,7 +48,6 @@ files:
48
48
  - README.rdoc
49
49
  - Rakefile
50
50
  - docs/data_conversion.txt
51
- - ext/v8/Makefile
52
51
  - ext/v8/callbacks.cpp
53
52
  - ext/v8/callbacks.h
54
53
  - ext/v8/convert_ruby.cpp
data/ext/v8/Makefile DELETED
@@ -1,169 +0,0 @@
1
-
2
- SHELL = /bin/sh
3
-
4
- #### Start of system configuration section. ####
5
-
6
- srcdir = .
7
- topdir = /opt/local/lib/ruby/1.8/i686-darwin10
8
- hdrdir = $(topdir)
9
- VPATH = $(srcdir):$(topdir):$(hdrdir)
10
- exec_prefix = $(prefix)
11
- prefix = $(DESTDIR)/opt/local
12
- sharedstatedir = $(prefix)/com
13
- mandir = $(DESTDIR)/opt/local/share/man
14
- psdir = $(docdir)
15
- oldincludedir = $(DESTDIR)/usr/include
16
- localedir = $(datarootdir)/locale
17
- bindir = $(exec_prefix)/bin
18
- libexecdir = $(exec_prefix)/libexec
19
- sitedir = $(libdir)/ruby/site_ruby
20
- htmldir = $(docdir)
21
- vendorarchdir = $(vendorlibdir)/$(sitearch)
22
- includedir = $(prefix)/include
23
- infodir = $(datarootdir)/info
24
- vendorlibdir = $(vendordir)/$(ruby_version)
25
- sysconfdir = $(prefix)/etc
26
- libdir = $(exec_prefix)/lib
27
- sbindir = $(exec_prefix)/sbin
28
- rubylibdir = $(libdir)/ruby/$(ruby_version)
29
- docdir = $(datarootdir)/doc/$(PACKAGE)
30
- dvidir = $(docdir)
31
- vendordir = $(DESTDIR)/opt/local/lib/ruby/vendor_ruby
32
- datarootdir = $(prefix)/share
33
- pdfdir = $(docdir)
34
- archdir = $(rubylibdir)/$(arch)
35
- sitearchdir = $(sitelibdir)/$(sitearch)
36
- datadir = $(datarootdir)
37
- localstatedir = $(prefix)/var
38
- sitelibdir = $(sitedir)/$(ruby_version)
39
-
40
- CC = /usr/bin/gcc-4.2
41
- LIBRUBY = $(LIBRUBY_SO)
42
- LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
43
- LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
44
- LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
45
-
46
- RUBY_EXTCONF_H =
47
- CFLAGS = -fno-common -O2 -arch x86_64 -fno-common -pipe -fno-common $(cflags) -arch x86_64
48
- INCFLAGS = -I. -I$(topdir) -I$(hdrdir) -I$(srcdir)
49
- DEFS =
50
- CPPFLAGS = -I/Users/cowboyd/Projects/therubyracer/ext/v8/upstream/2.0.6/include -I/opt/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE $(DEFS) $(cppflags) -Wall
51
- CXXFLAGS = $(CFLAGS)
52
- ldflags = -L. -L/opt/local/lib
53
- dldflags =
54
- archflag = -arch x86_64
55
- DLDFLAGS = $(ldflags) $(dldflags) $(archflag)
56
- LDSHARED = $(CC) -dynamic -bundle -undefined suppress -flat_namespace
57
- AR = ar
58
- EXEEXT =
59
-
60
- RUBY_INSTALL_NAME = ruby
61
- RUBY_SO_NAME = ruby
62
- arch = i686-darwin10
63
- sitearch = i686-darwin10
64
- ruby_version = 1.8
65
- ruby = /opt/local/bin/ruby
66
- RUBY = $(ruby)
67
- RM = rm -f
68
- MAKEDIRS = mkdir -p
69
- INSTALL = /usr/bin/install -c
70
- INSTALL_PROG = $(INSTALL) -m 0755
71
- INSTALL_DATA = $(INSTALL) -m 644
72
- COPY = cp
73
-
74
- #### End of system configuration section. ####
75
-
76
- preload =
77
-
78
- libpath = . $(libdir) /Users/cowboyd/Projects/therubyracer/ext/v8/upstream/2.0.6
79
- LIBPATH = -L. -L$(libdir) -L/Users/cowboyd/Projects/therubyracer/ext/v8/upstream/2.0.6
80
- DEFFILE =
81
-
82
- CLEANFILES = mkmf.log
83
- DISTCLEANFILES =
84
-
85
- extout =
86
- extout_prefix =
87
- target_prefix =
88
- LOCAL_LIBS =
89
- LIBS = $(LIBRUBYARG_SHARED) -lpthread -ldl -lobjc
90
- SRCS = callbacks.cpp convert_ruby.cpp convert_string.cpp convert_v8.cpp converters.cpp v8.cpp v8_cxt.cpp v8_func.cpp v8_msg.cpp v8_obj.cpp v8_ref.cpp v8_script.cpp v8_standalone.cpp v8_str.cpp v8_template.cpp
91
- OBJS = callbacks.o convert_ruby.o convert_string.o convert_v8.o converters.o v8.o v8_cxt.o v8_func.o v8_msg.o v8_obj.o v8_ref.o v8_script.o v8_standalone.o v8_str.o v8_template.o
92
- TARGET = v8
93
- DLLIB = $(TARGET).bundle
94
- EXTSTATIC =
95
- STATIC_LIB =
96
-
97
- BINDIR = $(bindir)
98
- RUBYCOMMONDIR = $(sitedir)$(target_prefix)
99
- RUBYLIBDIR = $(sitelibdir)$(target_prefix)
100
- RUBYARCHDIR = $(sitearchdir)$(target_prefix)
101
-
102
- TARGET_SO = $(DLLIB)
103
- CLEANLIBS = $(TARGET).bundle $(TARGET).il? $(TARGET).tds $(TARGET).map
104
- CLEANOBJS = *.o *.a *.s[ol] *.pdb *.exp *.bak
105
-
106
- all: $(DLLIB)
107
- static: $(STATIC_LIB)
108
-
109
- clean:
110
- @-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
111
-
112
- distclean: clean
113
- @-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
114
- @-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
115
-
116
- realclean: distclean
117
- install: install-so install-rb
118
-
119
- install-so: $(RUBYARCHDIR)
120
- install-so: $(RUBYARCHDIR)/$(DLLIB)
121
- $(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
122
- $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
123
- install-rb: pre-install-rb install-rb-default
124
- install-rb-default: pre-install-rb-default
125
- pre-install-rb: Makefile
126
- pre-install-rb-default: Makefile
127
- $(RUBYARCHDIR):
128
- $(MAKEDIRS) $@
129
-
130
- site-install: site-install-so site-install-rb
131
- site-install-so: install-so
132
- site-install-rb: install-rb
133
-
134
- .SUFFIXES: .c .m .cc .cxx .cpp .C .o
135
-
136
- .cc.o:
137
- $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
138
-
139
- .cxx.o:
140
- $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
141
-
142
- .cpp.o:
143
- $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
144
-
145
- .C.o:
146
- $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
147
-
148
- .c.o:
149
- $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) -c $<
150
-
151
- $(DLLIB): $(OBJS) Makefile
152
- @-$(RM) $@
153
- $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
154
-
155
-
156
-
157
- $(OBJS): ruby.h defines.h
158
-
159
- test: all
160
- @echo running spec...
161
- spec -O spec/spec.opts spec/therubyracer_spec.rb
162
-
163
- docs/cpp:
164
- mkdir -p docs/cpp
165
-
166
- docs: all docs/cpp
167
- @echo Generate C++ docs to docs/cpp/html
168
- doxygen Doxyfile
169
-