therubyracer-discourse 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +23 -0
  3. data/.travis.yml +11 -0
  4. data/Changelog.md +247 -0
  5. data/Gemfile +9 -0
  6. data/README.md +176 -0
  7. data/Rakefile +42 -0
  8. data/benchmarks.rb +218 -0
  9. data/ext/v8/accessor.cc +181 -0
  10. data/ext/v8/array.cc +26 -0
  11. data/ext/v8/backref.cc +45 -0
  12. data/ext/v8/constants.cc +34 -0
  13. data/ext/v8/constraints.cc +52 -0
  14. data/ext/v8/context.cc +130 -0
  15. data/ext/v8/date.cc +18 -0
  16. data/ext/v8/exception.cc +38 -0
  17. data/ext/v8/extconf.rb +34 -0
  18. data/ext/v8/external.cc +43 -0
  19. data/ext/v8/function.cc +58 -0
  20. data/ext/v8/gc.cc +43 -0
  21. data/ext/v8/handles.cc +34 -0
  22. data/ext/v8/heap.cc +35 -0
  23. data/ext/v8/init.cc +39 -0
  24. data/ext/v8/invocation.cc +86 -0
  25. data/ext/v8/locker.cc +77 -0
  26. data/ext/v8/message.cc +51 -0
  27. data/ext/v8/object.cc +335 -0
  28. data/ext/v8/primitive.cc +8 -0
  29. data/ext/v8/rr.cc +83 -0
  30. data/ext/v8/rr.h +934 -0
  31. data/ext/v8/script.cc +115 -0
  32. data/ext/v8/signature.cc +18 -0
  33. data/ext/v8/stack.cc +76 -0
  34. data/ext/v8/string.cc +47 -0
  35. data/ext/v8/template.cc +175 -0
  36. data/ext/v8/trycatch.cc +87 -0
  37. data/ext/v8/v8.cc +87 -0
  38. data/ext/v8/value.cc +239 -0
  39. data/lib/v8.rb +30 -0
  40. data/lib/v8/access.rb +5 -0
  41. data/lib/v8/access/indices.rb +40 -0
  42. data/lib/v8/access/invocation.rb +47 -0
  43. data/lib/v8/access/names.rb +65 -0
  44. data/lib/v8/array.rb +26 -0
  45. data/lib/v8/context.rb +256 -0
  46. data/lib/v8/conversion.rb +36 -0
  47. data/lib/v8/conversion/array.rb +11 -0
  48. data/lib/v8/conversion/class.rb +119 -0
  49. data/lib/v8/conversion/code.rb +38 -0
  50. data/lib/v8/conversion/fixnum.rb +11 -0
  51. data/lib/v8/conversion/fundamental.rb +11 -0
  52. data/lib/v8/conversion/hash.rb +11 -0
  53. data/lib/v8/conversion/indentity.rb +31 -0
  54. data/lib/v8/conversion/method.rb +26 -0
  55. data/lib/v8/conversion/object.rb +28 -0
  56. data/lib/v8/conversion/primitive.rb +7 -0
  57. data/lib/v8/conversion/proc.rb +5 -0
  58. data/lib/v8/conversion/reference.rb +16 -0
  59. data/lib/v8/conversion/string.rb +12 -0
  60. data/lib/v8/conversion/symbol.rb +7 -0
  61. data/lib/v8/conversion/time.rb +13 -0
  62. data/lib/v8/error.rb +169 -0
  63. data/lib/v8/function.rb +28 -0
  64. data/lib/v8/object.rb +79 -0
  65. data/lib/v8/stack.rb +85 -0
  66. data/lib/v8/version.rb +3 -0
  67. data/lib/v8/weak.rb +73 -0
  68. data/spec/c/array_spec.rb +17 -0
  69. data/spec/c/constants_spec.rb +20 -0
  70. data/spec/c/exception_spec.rb +26 -0
  71. data/spec/c/external_spec.rb +9 -0
  72. data/spec/c/function_spec.rb +46 -0
  73. data/spec/c/handles_spec.rb +35 -0
  74. data/spec/c/locker_spec.rb +38 -0
  75. data/spec/c/object_spec.rb +46 -0
  76. data/spec/c/script_spec.rb +28 -0
  77. data/spec/c/string_spec.rb +16 -0
  78. data/spec/c/template_spec.rb +30 -0
  79. data/spec/c/trycatch_spec.rb +51 -0
  80. data/spec/mem/blunt_spec.rb +42 -0
  81. data/spec/redjs_spec.rb +10 -0
  82. data/spec/spec_helper.rb +45 -0
  83. data/spec/threading_spec.rb +64 -0
  84. data/spec/v8/context_spec.rb +19 -0
  85. data/spec/v8/conversion_spec.rb +52 -0
  86. data/spec/v8/error_spec.rb +165 -0
  87. data/spec/v8/function_spec.rb +9 -0
  88. data/spec/v8/object_spec.rb +15 -0
  89. data/thefrontside.png +0 -0
  90. data/therubyracer.gemspec +21 -0
  91. metadata +163 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: aa14c877caecbbb5441438cf1ea9789f403efb1d
4
+ data.tar.gz: 74fbe74f712298ae0c7efe93d7ff2946ebe14323
5
+ SHA512:
6
+ metadata.gz: e18ac8b348a130067ae0243aa5f25e44f4d222f95878dbfe3a767af8d511f4645cb16b69312ea294fb7f61c5816a6e0f9eb80e2f8dc7516039361ac8fac5d4dc
7
+ data.tar.gz: b91d0c82b36d278d110ba7f42498aa569e5f8c82646f9ce40a57fda5029de83885393ee4d0e1ce4bc5774aa194215f3a38b8660e039309f641f7f9225d685a6b
@@ -0,0 +1,23 @@
1
+ *.gem
2
+ *.rbc
3
+ .rbx/
4
+ .rvmrc
5
+ .bundle
6
+ .config
7
+ .yardoc
8
+ .project
9
+ .cproject
10
+ Gemfile.lock
11
+ InstalledFiles
12
+ _yardoc
13
+ coverage
14
+ doc/
15
+ lib/bundler/man
16
+ lib/v8/*.bundle
17
+ lib/v8/*.so
18
+ pkg
19
+ rdoc
20
+ spec/reports
21
+ test/tmp
22
+ test/version_tmp
23
+ tmp
@@ -0,0 +1,11 @@
1
+ rvm:
2
+ - 2.0.0
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - 1.8.7
6
+ - rbx-18mode
7
+ - rbx-19mode
8
+ notifications:
9
+ recipients:
10
+ - cowboyd@thefrontside.net
11
+ script: bundle exec rake compile spec
@@ -0,0 +1,247 @@
1
+ # Changelog
2
+
3
+ ## 0.11.1 2013/01/04
4
+
5
+ * reintroduce the dependency on libv8
6
+ * libv8 can be disabled by installing it with the --with-system-v8 flag
7
+
8
+ ## 0.11.0 2012/12/04
9
+
10
+ * upgrade V8 version to 3.11.8
11
+ * remove dependency on libv8. enable compilation against system v8
12
+ * complete re-write of low-level C layer for dramatically increased stability and performance
13
+ * more faithful and complete coverage of the low-level C API
14
+ * ease the building of binary gems
15
+ * official support for Rubinius
16
+ * ability to query V8 for memory usage and set resource constraints
17
+ * extensible conversion framework for thunking Ruby values to V8 and vice-versa
18
+ * extensible invocation framework for calling Ruby code (Proc, Method, etc...) from JavaScript
19
+ * extensible access framework for interacting with Ruby properties from JavaScript
20
+ * provide explicit context teardown for distributed cycles of garbage.
21
+
22
+
23
+ ## 0.10.1 2012/04/05
24
+
25
+ * [bugfix] V8::Object#respond_to? did not call super
26
+
27
+ ## 0.10.0 2012/03/28
28
+
29
+ * [incompatible] embedded lambdas now take JS `this` object as first object
30
+ * add sponsorship image to the README
31
+ * enable Travis CI
32
+
33
+ ## 0.9.9 2011/11/08
34
+
35
+ * remove GCC specific C++ extension to fix llvm build.
36
+
37
+ ## 0.9.8 2011/11/07
38
+
39
+ * let Rake version float again.
40
+
41
+ ## 0.9.7 2011/10/06
42
+ * build fixes
43
+ * fix rake dependency at 0.8.7 while the Rake team sorts some shit out.
44
+
45
+ ## 0.9.6 2011/10/06
46
+
47
+ * make build compatible with Gentoo
48
+
49
+ ## 0.9.5 - 2011/10/05
50
+
51
+ * remove GCC specific code to enable build on BSD
52
+ * let Rake dependency float
53
+
54
+ ## 0.9.4 - 2011/08/22
55
+
56
+ * Fix an issue with the compilation include paths which allowed compilation against conflicting libv8's
57
+
58
+ ## 0.9.3 - 2011/08/11
59
+
60
+ * Better documentation for the C extension memory management
61
+ * Always lock V8 operations, always.
62
+ * GH-86 Context#[], Context#[]= always looks up values from the JavaScript scope, even when it's a Ruby object
63
+
64
+ ## 0.9.2 - 2011/06/23
65
+
66
+ * fix issue with 1.8.7 where object allocation inside of GC was segfaulting
67
+
68
+ ## 0.9.1 - 2011/06/17
69
+
70
+ * never perform V8 operations inside Ruby GC
71
+ * refactor locking interface
72
+ * add documentation for v8_handle
73
+
74
+ ## 0.9.0 - 2011/06/10
75
+
76
+ * extract libv8 into installable binary for most platforms
77
+ * fix numerous memory leaks
78
+ * expose the V8 debugger via V8::C::Debug::EnableAgent()
79
+ * force UTf-8 encoding on strings returned from javascript in ruby 1.9
80
+ * remove deprecated evaluate() methods
81
+ * make the currently executing JavaScript stack available via Context#stack
82
+
83
+ ## 0.8.1 - 2011/03/07
84
+
85
+ * upgrade to v8 3.1.8
86
+ * remove bin/v8 which conflicted with v8 executeable
87
+ * decruft all the crap that had accumulated in the gem
88
+ * Javascript Objects are now always mapped to the same V8::Object when read from the context
89
+
90
+ ## 0.8.0 - 2010/12/02
91
+
92
+ * every V8 Context gets its own unique access strategy
93
+ * ruby methods and procs embedded in javascript always return the same function per context.
94
+ * ruby classes and subclasses are now all connected via the javascript prototype chain
95
+ * better error reporting on syntax errors
96
+ * upgrade to rspec 2
97
+ * several bug fixes and stability fixes
98
+
99
+ ## 0.7.5 - 2010/08/03
100
+
101
+ * upgrade to V8 2.3.3
102
+ * property interceptors from ruby via [] and []=
103
+ * indexed property access via [] and []=
104
+ * property
105
+ * several bugfixes
106
+ * stability: eliminate many segfaults
107
+ * don't enumerate property setters such as foo= from javascript
108
+
109
+ ## 0.7.4 - 2010/06/15
110
+
111
+ * bug fix for rvm ruby installs incorrectly detected as 32bit
112
+
113
+ ## 0.7.3 - 2010/06/15
114
+
115
+ * don't catch SystemExit and NoMemoryError
116
+ * fix bug bundling gem
117
+
118
+ ## 0.7.2 - 2010/06/14
119
+
120
+ * embed ruby classes as constructors
121
+ * support for rubinius
122
+ * uniform backtrace() function on JSError mixes the ruby
123
+ * String::NewSymbol() is now scriptable
124
+ * InstanceTemplate(), PrototypeTemplate(), Inherit() methods on v8::FunctionTemplate now scriptable.
125
+ * reuse the standard ruby object access template
126
+ * fix a bunch of compile warnings
127
+ * Store any ruby object in V8 with V8::C::External
128
+
129
+ ## 0.7.1 - 2010/06/03
130
+
131
+ * Function#call() now uses the global scope for 'this' by default
132
+ * Function#methodcall() added to allow passing in 'this' object
133
+ * Function#new() method to invoke javascript constructor from ruby
134
+ * access javascript properties and call javascript methods from ruby
135
+ * bundled Jasmine DOM-Less browser testing framework.
136
+
137
+ * added Object::GetHiddenValue() to v8 metal
138
+ * added Handle::IsEmpty() to v8 metal
139
+ * fixed bug where iterating over arrays sometimes failed
140
+ * numerous bug /segfault fixes.
141
+
142
+ ## 0.7.0 - 2010/05/31
143
+
144
+ * upgraded to V8 2.1.10
145
+ * added low level scripting interface for V8 objects
146
+ * ruby object property/method access is now implemented in ruby
147
+ * auto-convert javascript arrays to rb arrays and vice-versa
148
+ * auto-convert ruby hashes into javascript objects
149
+ * auto-convert javascript Date into ruby Time object and vice versa.
150
+ * better exception handling when passing through multiple language boundaries
151
+ * objects maintain referential integrity when passing objects from ruby to javascript and vice-versa
152
+ * added debug compile option for getting C/C++ backtraces whenever segfaults occur.
153
+ * official support for REE 1.8.7
154
+ * fixed numerous segfaults
155
+ * implemented V8::Value#to_s
156
+ * the global scope is available to every V8::Context as the 'scope' attribute
157
+ * properly convert ruby boolean values into V8 booleans.
158
+
159
+ ## 0.6.3 - 2010/05/07
160
+
161
+ * FIX: linkage error on OSX /usr/bin/ruby
162
+
163
+ ## 0.6.2 - 2010/05/06
164
+
165
+ * FIX: linkage error on OSX 10.5
166
+
167
+ ## 0.6.1 - 2010/05/03
168
+
169
+ * call JavaScript functions from Ruby
170
+
171
+ ## 0.6.0 - 2010/03/31
172
+
173
+ * ruby 1.9 compatible
174
+ * full featured command line bin/v8 and bin/therubyracer
175
+ * self validating install (v8 --selftest)
176
+ * Only dependency to build gem from source is rubygems.
177
+
178
+ ## 0.5.5 - 2010/03/15
179
+
180
+ * fix string encoding issue that was breaking RHEL 5.x
181
+ * fix pthread linking issue on RHEL 5.2
182
+
183
+ ## 0.5.4 - 2010/03/09
184
+
185
+ * add ext directory to gem require paths which was causing problems for non-binary gems
186
+
187
+ ## 0.5.3 - 2010/03/01
188
+
189
+ * added full back trace to javascript code
190
+
191
+ ## 0.5.2 - 2010/02/26
192
+
193
+ * added javascript shell (bin/therubyracer)
194
+ * added to_s method for embedded ruby objects
195
+ * added line number and file name to error message.
196
+
197
+ ## 0.5.1 - 2010/02/17
198
+
199
+ * fix bug in 1.8.6 by creating Object#tap if it does not exist
200
+
201
+ ## 0.5.0 - 2010/02/17
202
+
203
+ * support for Linux 64 bit
204
+
205
+ ## 0.4.9 - 2010/02/16
206
+
207
+ * support for Linux 32 bit
208
+
209
+ ## 0.4.8 - 2010/02/08
210
+
211
+ * expose line number and source name on JavascriptErrors.
212
+
213
+ ## 0.4.5 - 2010/01/18
214
+
215
+ * case munging so that ruby methods(perl_case) are accessed through javascript in camelCase.
216
+ * access 0-arity ruby methods as javascript properties
217
+ * invoke ruby setters from javascript as properties
218
+ * contexts detect whether they are open or not and open when needed
219
+
220
+ ## 0.4.4 - 2010/01/14
221
+
222
+ * Ruby objects embedded into javascript are passed back to ruby as themselves and not a wrapped V8 object wrapping a ruby object.
223
+ * Use any ruby object as the scope of eval().
224
+ * quick and dirty V8.eval() method added
225
+ * native objects have a reference to the context that created them.
226
+ * context now has equality check.
227
+ * expose InContext() and GetCurrent() methods.
228
+ * fix a couple of segmentation faults
229
+
230
+ ## 0.4.3 - 2010/10/11
231
+
232
+ * access properties on Ruby objects with their camel case equivalents
233
+ * reflect JavaScript objects into Ruby and access their properties
234
+ * load JavaScript source from an IO object or by filename
235
+
236
+ ## 0.4.2 - 2010/10/10
237
+
238
+ * embed Ruby Objects into Javascript and call their methods
239
+
240
+ ## 0.4.1 - 2010/01/09
241
+
242
+ * embed bare Proc and Method objects into JavaScript and call them
243
+ * catch JavaScript exceptions from Ruby
244
+
245
+ ## 0.4.0 - 2009/12/21
246
+
247
+ * evaluate JavaScript code from inside Ruby.
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'redjs', :git => 'https://github.com/cowboyd/redjs.git'
6
+ gem "rake"
7
+ gem "rspec", "~> 2.0"
8
+ gem "rake-compiler"
9
+ gem 'gem-compiler' unless Object.const_defined?(:RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
@@ -0,0 +1,176 @@
1
+ # therubyracer
2
+
3
+ * [http://github.com/cowboyd/therubyracer](http://github.com/cowboyd/therubyracer)
4
+ * [http://groups.google.com/group/therubyracer](http://groups.google.com/group/therubyracer)
5
+ * [irc://irc.freenode.net/therubyracer](http://groups.google.com/group/therubyracer)
6
+ * [Documentation](https://github.com/cowboyd/therubyracer/wiki)
7
+
8
+ ### DESCRIPTION
9
+
10
+ Embed the V8 JavaScript interpreter into Ruby.
11
+
12
+ ### FEATURES
13
+
14
+ * Evaluate JavaScript from within Ruby
15
+ * Embed your Ruby objects into the JavaScript world
16
+ * Manipulate JavaScript objects and call JavaScript functions from Ruby
17
+ * API compatible with the The Ruby Rhino (for JRuby: http://github.com/cowboyd/therubyrhino)
18
+
19
+ ### SYNOPSIS
20
+
21
+ gem install therubyracer
22
+
23
+ then in your Ruby code
24
+
25
+ require 'v8'
26
+ # or if using bundler (as with Rails), add the following to your Gemfile
27
+ gem "therubyracer", :require => 'v8'
28
+
29
+ evaluate some simple JavaScript
30
+
31
+ cxt = V8::Context.new
32
+ cxt.eval('7 * 6') #=> 42
33
+
34
+ embed values into the scope of your context
35
+
36
+ cxt['foo'] = "bar"
37
+ cxt.eval('foo') # => "bar"
38
+
39
+ embed Ruby code into your scope and call it from JavaScript
40
+
41
+ cxt["say"] = lambda {|this, word, times| word * times}
42
+ cxt.eval("say('Hello', 3)") #=> HelloHelloHello
43
+
44
+ embed a Ruby object into your scope and access its properties/methods
45
+ from JavaScript
46
+
47
+ class MyMath
48
+ def plus(lhs, rhs)
49
+ lhs + rhs
50
+ end
51
+ end
52
+
53
+ cxt['math'] = MyMath.new
54
+ cxt.eval("math.plus(20,22)") #=> 42
55
+
56
+ make a Ruby object *be* your global JavaScript scope.
57
+
58
+ math = MyMath.new
59
+ V8::Context.new(:with => math) do |cxt|
60
+ cxt.eval("plus(20,22)") #=> 42
61
+ end
62
+
63
+ you can do the same thing with Object#eval_js
64
+
65
+ math.eval_js("plus(20,22)")
66
+
67
+ ### Different ways of loading JavaScript source
68
+
69
+ In addition to just evaluating strings, you can also use streams, such
70
+ as files.
71
+
72
+ evaluate bytes read from any File/IO object:
73
+
74
+ File.open("mysource.js") do |file|
75
+ cxt.eval(file, "mysource.js")
76
+ end
77
+
78
+ or load it by filename
79
+
80
+ cxt.load("mysource.js")
81
+
82
+ ### Safe by default, dangerous by demand
83
+
84
+ The Ruby Racer is designed to let you evaluate JavaScript as safely as
85
+ possible unless you tell it to do something more dangerous. The
86
+ default context is a hermetically sealed JavaScript environment with
87
+ only the standard JavaScript objects and functions. Nothing from the
88
+ Ruby world is accessible at all.
89
+
90
+ For Ruby objects that you explicitly embed into JavaScript, by default
91
+ only the _public_ methods _below_ `Object` are exposed by default.
92
+ E.g.
93
+
94
+ class A
95
+ def a
96
+ "a"
97
+ end
98
+
99
+ def to_s
100
+ super
101
+ end
102
+ end
103
+
104
+ class B < A
105
+ def b
106
+ "b"
107
+ end
108
+ end
109
+
110
+
111
+ V8::Context.new do |cxt|
112
+ cxt['a'] = A.new
113
+ cxt['b'] = B.new
114
+ cxt.eval("a.a") # => 'a'
115
+ cxt.eval("b.b") # => 'b'
116
+ cxt.eval("b.a") # => 'a'
117
+ cxt.eval("b.to_s") # => #<B:0x101776be8> (because A explicitly defined it)
118
+ cxt.eval("b.object_id") #=> undefined, object_id is on Object
119
+ end
120
+
121
+ If needed, you can override the [Ruby Access][access] to allow whatever
122
+ behavior you'd like.
123
+
124
+ [access]:https://github.com/cowboyd/therubyracer/blob/master/lib/v8/access.rb
125
+
126
+ More documentation can be found on the [GitHub wiki](https://github.com/cowboyd/therubyracer/wiki)
127
+
128
+ ### PREREQUISITES
129
+
130
+ The Ruby Racer requires the V8 Javascript engine, but it offloads the
131
+ handling of this dependency to the
132
+ [libv8](https://github.com/cowboyd/libv8) gem. Because libv8 is now a
133
+ gem dependency, you do not need a separate libv8 entry in your
134
+ project's Gemfile.
135
+
136
+ Please see [libv8](https://github.com/cowboyd/libv8) for V8 runtime
137
+ installation options.
138
+
139
+ ### DEVELOP
140
+
141
+ git clone git://github.com/cowboyd/therubyracer.git
142
+ cd therubyracer
143
+ bundle install
144
+ rake compile
145
+
146
+ ### Sponsored by
147
+
148
+ <a href="http://thefrontside.net">![The Frontside](http://github.com/cowboyd/therubyracer/raw/master/thefrontside.png)</a>
149
+
150
+ ### LICENSE:
151
+
152
+ (The MIT License)
153
+
154
+ Copyright (c) 2009,2010,2011,2012 Charles Lowell
155
+
156
+ Permission is hereby granted, free of charge, to any person obtaining
157
+ a copy of this software and associated documentation files (the
158
+ 'Software'), to deal in the Software without restriction, including
159
+ without limitation the rights to use, copy, modify, merge, publish,
160
+ distribute, sublicense, and/or sell copies of the Software, and to
161
+ permit persons to whom the Software is furnished to do so, subject to
162
+ the following conditions:
163
+
164
+ The above copyright notice and this permission notice shall be
165
+ included in all copies or substantial portions of the Software.
166
+
167
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
168
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
169
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
170
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
171
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
172
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
173
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
174
+
175
+ [1]: https://github.com/cowboyd/libv8
176
+ [2]: http://code.google.com/p/v8/wiki/BuildingWithGYP