jbarnette-johnson 1.0.0.200806240111 → 1.0.0.200807291507

Sign up to get free protection for your applications and to get access to all the features.
Files changed (269) hide show
  1. data/MANIFEST +1 -0
  2. data/Rakefile +3 -10
  3. data/bin/johnson +2 -1
  4. data/ext/spidermonkey/context.c +3 -4
  5. data/ext/spidermonkey/context.h +1 -1
  6. data/ext/spidermonkey/conversions.c +39 -33
  7. data/ext/spidermonkey/debugger.c +5 -5
  8. data/ext/spidermonkey/immutable_node.c.erb +11 -11
  9. data/ext/spidermonkey/jroot.h +4 -4
  10. data/ext/spidermonkey/js_land_proxy.c +9 -8
  11. data/ext/spidermonkey/ruby_land_proxy.c +5 -4
  12. data/ext/spidermonkey/runtime.c +1 -1
  13. data/johnson.gemspec +36 -0
  14. data/lib/hoe.rb +0 -7
  15. data/lib/johnson/cli/options.rb +10 -4
  16. data/lib/johnson/spidermonkey/runtime.rb +2 -2
  17. data/lib/johnson/version.rb +4 -2
  18. data/lib/johnson.rb +1 -0
  19. data/test/johnson/runtime_test.rb +11 -0
  20. data/test/johnson/spidermonkey/ruby_land_proxy_test.rb +6 -0
  21. data/vendor/spidermonkey/.cvsignore +9 -0
  22. data/vendor/spidermonkey/Makefile.in +462 -0
  23. data/vendor/spidermonkey/Makefile.ref +364 -0
  24. data/vendor/spidermonkey/README.html +820 -0
  25. data/vendor/spidermonkey/SpiderMonkey.rsp +12 -0
  26. data/vendor/spidermonkey/Y.js +19 -0
  27. data/vendor/spidermonkey/build.mk +43 -0
  28. data/vendor/spidermonkey/config/AIX4.1.mk +65 -0
  29. data/vendor/spidermonkey/config/AIX4.2.mk +64 -0
  30. data/vendor/spidermonkey/config/AIX4.3.mk +65 -0
  31. data/vendor/spidermonkey/config/Darwin.mk +83 -0
  32. data/vendor/spidermonkey/config/Darwin1.3.mk +81 -0
  33. data/vendor/spidermonkey/config/Darwin1.4.mk +41 -0
  34. data/vendor/spidermonkey/config/Darwin5.2.mk +81 -0
  35. data/vendor/spidermonkey/config/Darwin5.3.mk +81 -0
  36. data/vendor/spidermonkey/config/HP-UXB.10.10.mk +77 -0
  37. data/vendor/spidermonkey/config/HP-UXB.10.20.mk +77 -0
  38. data/vendor/spidermonkey/config/HP-UXB.11.00.mk +80 -0
  39. data/vendor/spidermonkey/config/IRIX.mk +87 -0
  40. data/vendor/spidermonkey/config/IRIX5.3.mk +44 -0
  41. data/vendor/spidermonkey/config/IRIX6.1.mk +44 -0
  42. data/vendor/spidermonkey/config/IRIX6.2.mk +44 -0
  43. data/vendor/spidermonkey/config/IRIX6.3.mk +44 -0
  44. data/vendor/spidermonkey/config/IRIX6.5.mk +44 -0
  45. data/vendor/spidermonkey/config/Linux_All.mk +103 -0
  46. data/vendor/spidermonkey/config/Mac_OS10.0.mk +82 -0
  47. data/vendor/spidermonkey/config/OSF1V4.0.mk +72 -0
  48. data/vendor/spidermonkey/config/OSF1V5.0.mk +69 -0
  49. data/vendor/spidermonkey/config/SunOS4.1.4.mk +101 -0
  50. data/vendor/spidermonkey/config/SunOS5.10.mk +50 -0
  51. data/vendor/spidermonkey/config/SunOS5.3.mk +91 -0
  52. data/vendor/spidermonkey/config/SunOS5.4.mk +92 -0
  53. data/vendor/spidermonkey/config/SunOS5.5.1.mk +44 -0
  54. data/vendor/spidermonkey/config/SunOS5.5.mk +87 -0
  55. data/vendor/spidermonkey/config/SunOS5.6.mk +89 -0
  56. data/vendor/spidermonkey/config/SunOS5.7.mk +44 -0
  57. data/vendor/spidermonkey/config/SunOS5.8.mk +44 -0
  58. data/vendor/spidermonkey/config/SunOS5.9.mk +44 -0
  59. data/vendor/spidermonkey/config/WINNT4.0.mk +117 -0
  60. data/vendor/spidermonkey/config/WINNT5.0.mk +117 -0
  61. data/vendor/spidermonkey/config/WINNT5.1.mk +117 -0
  62. data/vendor/spidermonkey/config/WINNT5.2.mk +117 -0
  63. data/vendor/spidermonkey/config/WINNT6.0.mk +117 -0
  64. data/vendor/spidermonkey/config/dgux.mk +64 -0
  65. data/vendor/spidermonkey/config.mk +192 -0
  66. data/vendor/spidermonkey/editline/Makefile.ref +144 -0
  67. data/vendor/spidermonkey/editline/README +83 -0
  68. data/vendor/spidermonkey/editline/editline.3 +175 -0
  69. data/vendor/spidermonkey/editline/editline.c +1369 -0
  70. data/vendor/spidermonkey/editline/editline.h +135 -0
  71. data/vendor/spidermonkey/editline/sysunix.c +182 -0
  72. data/vendor/spidermonkey/editline/unix.h +82 -0
  73. data/vendor/spidermonkey/fdlibm/.cvsignore +7 -0
  74. data/vendor/spidermonkey/fdlibm/Makefile.in +127 -0
  75. data/vendor/spidermonkey/fdlibm/Makefile.ref +192 -0
  76. data/vendor/spidermonkey/fdlibm/e_acos.c +147 -0
  77. data/vendor/spidermonkey/fdlibm/e_acosh.c +105 -0
  78. data/vendor/spidermonkey/fdlibm/e_asin.c +156 -0
  79. data/vendor/spidermonkey/fdlibm/e_atan2.c +165 -0
  80. data/vendor/spidermonkey/fdlibm/e_atanh.c +110 -0
  81. data/vendor/spidermonkey/fdlibm/e_cosh.c +133 -0
  82. data/vendor/spidermonkey/fdlibm/e_exp.c +202 -0
  83. data/vendor/spidermonkey/fdlibm/e_fmod.c +184 -0
  84. data/vendor/spidermonkey/fdlibm/e_gamma.c +71 -0
  85. data/vendor/spidermonkey/fdlibm/e_gamma_r.c +70 -0
  86. data/vendor/spidermonkey/fdlibm/e_hypot.c +173 -0
  87. data/vendor/spidermonkey/fdlibm/e_j0.c +524 -0
  88. data/vendor/spidermonkey/fdlibm/e_j1.c +523 -0
  89. data/vendor/spidermonkey/fdlibm/e_jn.c +315 -0
  90. data/vendor/spidermonkey/fdlibm/e_lgamma.c +71 -0
  91. data/vendor/spidermonkey/fdlibm/e_lgamma_r.c +347 -0
  92. data/vendor/spidermonkey/fdlibm/e_log.c +184 -0
  93. data/vendor/spidermonkey/fdlibm/e_log10.c +134 -0
  94. data/vendor/spidermonkey/fdlibm/e_pow.c +386 -0
  95. data/vendor/spidermonkey/fdlibm/e_rem_pio2.c +222 -0
  96. data/vendor/spidermonkey/fdlibm/e_remainder.c +120 -0
  97. data/vendor/spidermonkey/fdlibm/e_scalb.c +89 -0
  98. data/vendor/spidermonkey/fdlibm/e_sinh.c +122 -0
  99. data/vendor/spidermonkey/fdlibm/e_sqrt.c +497 -0
  100. data/vendor/spidermonkey/fdlibm/fdlibm.h +273 -0
  101. data/vendor/spidermonkey/fdlibm/fdlibm.mak +1453 -0
  102. data/vendor/spidermonkey/fdlibm/fdlibm.mdp +0 -0
  103. data/vendor/spidermonkey/fdlibm/k_cos.c +135 -0
  104. data/vendor/spidermonkey/fdlibm/k_rem_pio2.c +354 -0
  105. data/vendor/spidermonkey/fdlibm/k_sin.c +114 -0
  106. data/vendor/spidermonkey/fdlibm/k_standard.c +785 -0
  107. data/vendor/spidermonkey/fdlibm/k_tan.c +170 -0
  108. data/vendor/spidermonkey/fdlibm/s_asinh.c +101 -0
  109. data/vendor/spidermonkey/fdlibm/s_atan.c +175 -0
  110. data/vendor/spidermonkey/fdlibm/s_cbrt.c +133 -0
  111. data/vendor/spidermonkey/fdlibm/s_ceil.c +120 -0
  112. data/vendor/spidermonkey/fdlibm/s_copysign.c +72 -0
  113. data/vendor/spidermonkey/fdlibm/s_cos.c +118 -0
  114. data/vendor/spidermonkey/fdlibm/s_erf.c +356 -0
  115. data/vendor/spidermonkey/fdlibm/s_expm1.c +267 -0
  116. data/vendor/spidermonkey/fdlibm/s_fabs.c +70 -0
  117. data/vendor/spidermonkey/fdlibm/s_finite.c +71 -0
  118. data/vendor/spidermonkey/fdlibm/s_floor.c +121 -0
  119. data/vendor/spidermonkey/fdlibm/s_frexp.c +99 -0
  120. data/vendor/spidermonkey/fdlibm/s_ilogb.c +85 -0
  121. data/vendor/spidermonkey/fdlibm/s_isnan.c +74 -0
  122. data/vendor/spidermonkey/fdlibm/s_ldexp.c +66 -0
  123. data/vendor/spidermonkey/fdlibm/s_lib_version.c +73 -0
  124. data/vendor/spidermonkey/fdlibm/s_log1p.c +211 -0
  125. data/vendor/spidermonkey/fdlibm/s_logb.c +79 -0
  126. data/vendor/spidermonkey/fdlibm/s_matherr.c +64 -0
  127. data/vendor/spidermonkey/fdlibm/s_modf.c +132 -0
  128. data/vendor/spidermonkey/fdlibm/s_nextafter.c +124 -0
  129. data/vendor/spidermonkey/fdlibm/s_rint.c +131 -0
  130. data/vendor/spidermonkey/fdlibm/s_scalbn.c +107 -0
  131. data/vendor/spidermonkey/fdlibm/s_signgam.c +40 -0
  132. data/vendor/spidermonkey/fdlibm/s_significand.c +68 -0
  133. data/vendor/spidermonkey/fdlibm/s_sin.c +118 -0
  134. data/vendor/spidermonkey/fdlibm/s_tan.c +112 -0
  135. data/vendor/spidermonkey/fdlibm/s_tanh.c +122 -0
  136. data/vendor/spidermonkey/fdlibm/w_acos.c +78 -0
  137. data/vendor/spidermonkey/fdlibm/w_acosh.c +78 -0
  138. data/vendor/spidermonkey/fdlibm/w_asin.c +80 -0
  139. data/vendor/spidermonkey/fdlibm/w_atan2.c +79 -0
  140. data/vendor/spidermonkey/fdlibm/w_atanh.c +81 -0
  141. data/vendor/spidermonkey/fdlibm/w_cosh.c +77 -0
  142. data/vendor/spidermonkey/fdlibm/w_exp.c +88 -0
  143. data/vendor/spidermonkey/fdlibm/w_fmod.c +78 -0
  144. data/vendor/spidermonkey/fdlibm/w_gamma.c +85 -0
  145. data/vendor/spidermonkey/fdlibm/w_gamma_r.c +81 -0
  146. data/vendor/spidermonkey/fdlibm/w_hypot.c +78 -0
  147. data/vendor/spidermonkey/fdlibm/w_j0.c +105 -0
  148. data/vendor/spidermonkey/fdlibm/w_j1.c +106 -0
  149. data/vendor/spidermonkey/fdlibm/w_jn.c +128 -0
  150. data/vendor/spidermonkey/fdlibm/w_lgamma.c +85 -0
  151. data/vendor/spidermonkey/fdlibm/w_lgamma_r.c +81 -0
  152. data/vendor/spidermonkey/fdlibm/w_log.c +78 -0
  153. data/vendor/spidermonkey/fdlibm/w_log10.c +81 -0
  154. data/vendor/spidermonkey/fdlibm/w_pow.c +99 -0
  155. data/vendor/spidermonkey/fdlibm/w_remainder.c +77 -0
  156. data/vendor/spidermonkey/fdlibm/w_scalb.c +95 -0
  157. data/vendor/spidermonkey/fdlibm/w_sinh.c +77 -0
  158. data/vendor/spidermonkey/fdlibm/w_sqrt.c +77 -0
  159. data/vendor/spidermonkey/javascript-trace.d +73 -0
  160. data/vendor/spidermonkey/js.c +3951 -0
  161. data/vendor/spidermonkey/js.mak +4438 -0
  162. data/vendor/spidermonkey/js.mdp +0 -0
  163. data/vendor/spidermonkey/js.msg +307 -0
  164. data/vendor/spidermonkey/js.pkg +2 -0
  165. data/vendor/spidermonkey/js3240.rc +79 -0
  166. data/vendor/spidermonkey/jsOS240.def +654 -0
  167. data/vendor/spidermonkey/jsapi.c +5836 -0
  168. data/vendor/spidermonkey/jsapi.h +2624 -0
  169. data/vendor/spidermonkey/jsarena.c +450 -0
  170. data/vendor/spidermonkey/jsarena.h +318 -0
  171. data/vendor/spidermonkey/jsarray.c +2988 -0
  172. data/vendor/spidermonkey/jsarray.h +124 -0
  173. data/vendor/spidermonkey/jsatom.c +1045 -0
  174. data/vendor/spidermonkey/jsatom.h +442 -0
  175. data/vendor/spidermonkey/jsbit.h +253 -0
  176. data/vendor/spidermonkey/jsbool.c +176 -0
  177. data/vendor/spidermonkey/jsbool.h +73 -0
  178. data/vendor/spidermonkey/jsclist.h +139 -0
  179. data/vendor/spidermonkey/jscntxt.c +1348 -0
  180. data/vendor/spidermonkey/jscntxt.h +1120 -0
  181. data/vendor/spidermonkey/jscompat.h +57 -0
  182. data/vendor/spidermonkey/jsconfig.h +248 -0
  183. data/vendor/spidermonkey/jsconfig.mk +181 -0
  184. data/vendor/spidermonkey/jscpucfg.c +383 -0
  185. data/vendor/spidermonkey/jscpucfg.h +212 -0
  186. data/vendor/spidermonkey/jsdate.c +2398 -0
  187. data/vendor/spidermonkey/jsdate.h +124 -0
  188. data/vendor/spidermonkey/jsdbgapi.c +1799 -0
  189. data/vendor/spidermonkey/jsdbgapi.h +464 -0
  190. data/vendor/spidermonkey/jsdhash.c +868 -0
  191. data/vendor/spidermonkey/jsdhash.h +592 -0
  192. data/vendor/spidermonkey/jsdtoa.c +3167 -0
  193. data/vendor/spidermonkey/jsdtoa.h +130 -0
  194. data/vendor/spidermonkey/jsdtracef.c +317 -0
  195. data/vendor/spidermonkey/jsdtracef.h +77 -0
  196. data/vendor/spidermonkey/jsemit.c +6909 -0
  197. data/vendor/spidermonkey/jsemit.h +741 -0
  198. data/vendor/spidermonkey/jsexn.c +1371 -0
  199. data/vendor/spidermonkey/jsexn.h +96 -0
  200. data/vendor/spidermonkey/jsfile.c +2736 -0
  201. data/vendor/spidermonkey/jsfile.h +56 -0
  202. data/vendor/spidermonkey/jsfile.msg +90 -0
  203. data/vendor/spidermonkey/jsfun.c +2634 -0
  204. data/vendor/spidermonkey/jsfun.h +254 -0
  205. data/vendor/spidermonkey/jsgc.c +3554 -0
  206. data/vendor/spidermonkey/jsgc.h +403 -0
  207. data/vendor/spidermonkey/jshash.c +476 -0
  208. data/vendor/spidermonkey/jshash.h +151 -0
  209. data/vendor/spidermonkey/jsify.pl +485 -0
  210. data/vendor/spidermonkey/jsinterp.c +6981 -0
  211. data/vendor/spidermonkey/jsinterp.h +521 -0
  212. data/vendor/spidermonkey/jsinvoke.c +43 -0
  213. data/vendor/spidermonkey/jsiter.c +1067 -0
  214. data/vendor/spidermonkey/jsiter.h +122 -0
  215. data/vendor/spidermonkey/jskeyword.tbl +124 -0
  216. data/vendor/spidermonkey/jskwgen.c +460 -0
  217. data/vendor/spidermonkey/jslibmath.h +266 -0
  218. data/vendor/spidermonkey/jslock.c +1309 -0
  219. data/vendor/spidermonkey/jslock.h +313 -0
  220. data/vendor/spidermonkey/jslocko.asm +60 -0
  221. data/vendor/spidermonkey/jslog2.c +94 -0
  222. data/vendor/spidermonkey/jslong.c +264 -0
  223. data/vendor/spidermonkey/jslong.h +412 -0
  224. data/vendor/spidermonkey/jsmath.c +568 -0
  225. data/vendor/spidermonkey/jsmath.h +57 -0
  226. data/vendor/spidermonkey/jsnum.c +1228 -0
  227. data/vendor/spidermonkey/jsnum.h +283 -0
  228. data/vendor/spidermonkey/jsobj.c +5266 -0
  229. data/vendor/spidermonkey/jsobj.h +709 -0
  230. data/vendor/spidermonkey/jsopcode.c +5245 -0
  231. data/vendor/spidermonkey/jsopcode.h +394 -0
  232. data/vendor/spidermonkey/jsopcode.tbl +523 -0
  233. data/vendor/spidermonkey/jsotypes.h +202 -0
  234. data/vendor/spidermonkey/jsparse.c +6680 -0
  235. data/vendor/spidermonkey/jsparse.h +511 -0
  236. data/vendor/spidermonkey/jsprf.c +1262 -0
  237. data/vendor/spidermonkey/jsprf.h +150 -0
  238. data/vendor/spidermonkey/jsproto.tbl +128 -0
  239. data/vendor/spidermonkey/jsprvtd.h +267 -0
  240. data/vendor/spidermonkey/jspubtd.h +744 -0
  241. data/vendor/spidermonkey/jsregexp.c +4352 -0
  242. data/vendor/spidermonkey/jsregexp.h +183 -0
  243. data/vendor/spidermonkey/jsreops.tbl +145 -0
  244. data/vendor/spidermonkey/jsscan.c +2003 -0
  245. data/vendor/spidermonkey/jsscan.h +387 -0
  246. data/vendor/spidermonkey/jsscope.c +1948 -0
  247. data/vendor/spidermonkey/jsscope.h +418 -0
  248. data/vendor/spidermonkey/jsscript.c +1832 -0
  249. data/vendor/spidermonkey/jsscript.h +287 -0
  250. data/vendor/spidermonkey/jsshell.msg +50 -0
  251. data/vendor/spidermonkey/jsstddef.h +83 -0
  252. data/vendor/spidermonkey/jsstr.c +5004 -0
  253. data/vendor/spidermonkey/jsstr.h +641 -0
  254. data/vendor/spidermonkey/jstypes.h +475 -0
  255. data/vendor/spidermonkey/jsutil.c +345 -0
  256. data/vendor/spidermonkey/jsutil.h +157 -0
  257. data/vendor/spidermonkey/jsxdrapi.c +800 -0
  258. data/vendor/spidermonkey/jsxdrapi.h +218 -0
  259. data/vendor/spidermonkey/jsxml.c +8471 -0
  260. data/vendor/spidermonkey/jsxml.h +349 -0
  261. data/vendor/spidermonkey/lock_SunOS.s +119 -0
  262. data/vendor/spidermonkey/perfect.js +39 -0
  263. data/vendor/spidermonkey/plify_jsdhash.sed +36 -0
  264. data/vendor/spidermonkey/prmjtime.c +846 -0
  265. data/vendor/spidermonkey/prmjtime.h +103 -0
  266. data/vendor/spidermonkey/resource.h +15 -0
  267. data/vendor/spidermonkey/rules.mk +197 -0
  268. data/vendor/spidermonkey/win32.order +384 -0
  269. metadata +4 -3
data/MANIFEST CHANGED
@@ -30,6 +30,7 @@ ext/spidermonkey/runtime.c
30
30
  ext/spidermonkey/runtime.h
31
31
  ext/spidermonkey/spidermonkey.c
32
32
  ext/spidermonkey/spidermonkey.h
33
+ johnson.gemspec
33
34
  js/johnson/browser.js
34
35
  js/johnson/browser/env.js
35
36
  js/johnson/browser/jquery.js
data/Rakefile CHANGED
@@ -33,11 +33,9 @@ HOE = Hoe.new("johnson", Johnson::VERSION) do |p|
33
33
  end
34
34
 
35
35
  namespace :gem do
36
- namespace :spec do
37
- task :generate do
38
- File.open("johnson.gemspec", "w") do |f|
39
- f.puts(HOE.spec.to_ruby)
40
- end
36
+ task :spec do
37
+ File.open("johnson.gemspec", "w") do |f|
38
+ f.puts(HOE.spec.to_ruby)
41
39
  end
42
40
  end
43
41
  end
@@ -102,11 +100,6 @@ file "vendor/spidermonkey/config/MINGW32.mk" => "MINGW32.mk" do |t|
102
100
  cp t.prerequisites.first, t.name
103
101
  end
104
102
 
105
- file "vendor/spidermonkey/jsapi.h" do
106
- # if this file's missing, pull in the submodule
107
- sh "git submodule init && git submodule update"
108
- end
109
-
110
103
  file "ext/spidermonkey/spidermonkey.#{kind}" =>
111
104
  ["ext/spidermonkey/Makefile"] + FileList["ext/spidermonkey/*.{c,h}"].to_a do |t|
112
105
 
data/bin/johnson CHANGED
@@ -56,11 +56,12 @@ def eval_in_ruby(expression, bind_to)
56
56
  end
57
57
 
58
58
  options = Johnson::CLI::Options.parse!(ARGV)
59
+
59
60
  options.load_paths.each { |d| $LOAD_PATH << d }
61
+ options.paths_to_require.each { |p| RUNTIME.evaluate("Johnson.require('#{p}')") }
60
62
  options.files_to_preload.each { |f| RUNTIME.load(f) }
61
63
 
62
64
  unless options.expressions.empty?
63
- # magic comment, do not remove
64
65
  options.expressions.each { |e| RUNTIME.evaluate(e, '-e') }
65
66
  exit if !options.file_to_evaluate
66
67
  end
@@ -48,7 +48,7 @@ initialize_native(VALUE self, VALUE rb_runtime, VALUE UNUSED(options))
48
48
  Data_Get_Struct(self, JohnsonContext, context);
49
49
  Data_Get_Struct(rb_runtime, JohnsonRuntime, runtime);
50
50
 
51
- if ((context->js = JS_NewContext(runtime->js, 8192)))
51
+ if ((context->js = JS_NewContext(runtime->js, 8192L)))
52
52
  {
53
53
  // See if the runtime already has a shared global object.
54
54
  JSObject* global = runtime->global;
@@ -89,8 +89,7 @@ initialize_native(VALUE self, VALUE rb_runtime, VALUE UNUSED(options))
89
89
  //// INFRASTRUCTURE BELOW HERE ////////////////////////////////////////////
90
90
  ///////////////////////////////////////////////////////////////////////////
91
91
 
92
- static void deallocate(JohnsonContext* context)
93
- {
92
+ static void deallocate(JohnsonContext *context) {
94
93
  JS_SetContextPrivate(context->js, 0);
95
94
  JS_DestroyContext(context->js);
96
95
  free(context);
@@ -98,7 +97,7 @@ static void deallocate(JohnsonContext* context)
98
97
 
99
98
  static VALUE allocate(VALUE klass)
100
99
  {
101
- JohnsonContext* context = calloc(1, sizeof(JohnsonContext));
100
+ JohnsonContext* context = calloc(1L, sizeof(JohnsonContext));
102
101
  return Data_Wrap_Struct(klass, 0, deallocate, context);
103
102
  }
104
103
 
@@ -3,7 +3,7 @@
3
3
 
4
4
  #include "spidermonkey.h"
5
5
 
6
- #define MAX_EXCEPTION_MESSAGE_SIZE 2048
6
+ #define MAX_EXCEPTION_MESSAGE_SIZE 2048L
7
7
 
8
8
  typedef struct {
9
9
  JSContext *js;
@@ -22,7 +22,7 @@ static JSBool convert_symbol_to_js(JohnsonRuntime* runtime, VALUE symbol, jsval*
22
22
  PREPARE_JROOTS(context, 2);
23
23
 
24
24
  VALUE to_s = CALL_RUBY_WRAPPER(rb_funcall_0, symbol, rb_intern("to_s"), 0);
25
- jsval name = STRING_TO_JSVAL(JS_NewStringCopyN(context, StringValuePtr(to_s), (unsigned) StringValueLen(to_s)));
25
+ jsval name = STRING_TO_JSVAL(JS_NewStringCopyN(context, StringValuePtr(to_s), (size_t) StringValueLen(to_s)));
26
26
 
27
27
  JROOT(name);
28
28
 
@@ -40,60 +40,64 @@ static JSBool convert_symbol_to_js(JohnsonRuntime* runtime, VALUE symbol, jsval*
40
40
  static JSBool convert_regexp_to_js(JohnsonRuntime* runtime, VALUE regexp, jsval* retval)
41
41
  {
42
42
  JSContext * context = johnson_get_current_context(runtime);
43
+ PREPARE_JROOTS(context, 0);
43
44
  VALUE source = rb_funcall(regexp, rb_intern("source"), 0);
44
- int options = NUM2INT(rb_funcall(regexp, rb_intern("options"), 0));
45
+ jsint options = (jsint)(NUM2INT(rb_funcall(regexp, rb_intern("options"), 0)));
45
46
 
46
47
  JSObject* obj = JS_NewRegExpObject(context,
47
48
  StringValuePtr(source),
48
- (unsigned) StringValueLen(source),
49
+ (size_t) StringValueLen(source),
49
50
  (unsigned) options);
50
51
 
51
- if (obj) {
52
- *retval = OBJECT_TO_JSVAL(obj);
53
- return JS_TRUE;
54
- } else {
55
- return JS_FALSE;
56
- }
52
+ JCHECK(obj);
53
+ *retval = OBJECT_TO_JSVAL(obj);
54
+ JRETURN;
57
55
  }
58
56
 
59
57
  JSBool convert_to_js(JohnsonRuntime* runtime, VALUE ruby, jsval* retval)
60
58
  {
61
59
  JSContext * context = johnson_get_current_context(runtime);
60
+ PREPARE_JROOTS(context, 0);
62
61
  switch(TYPE(ruby))
63
62
  {
64
63
  case T_NIL:
65
64
  *retval = JSVAL_NULL;
66
- return JS_TRUE;
65
+ JRETURN;
67
66
 
68
67
  case T_TRUE:
69
68
  *retval = JSVAL_TRUE;
70
- return JS_TRUE;
69
+ JRETURN;
71
70
 
72
71
  case T_FALSE:
73
72
  *retval = JSVAL_FALSE;
74
- return JS_TRUE;
73
+ JRETURN;
75
74
 
76
75
  case T_STRING:
77
76
  {
78
- JSString* str = JS_NewStringCopyN(context, StringValuePtr(ruby), (unsigned) StringValueLen(ruby));
79
- if (str) {
80
- *retval = STRING_TO_JSVAL(str);
81
- return JS_TRUE;
82
- } else {
83
- return JS_FALSE;
84
- }
77
+ JSString* str = JS_NewStringCopyN(context, StringValuePtr(ruby), (size_t) StringValueLen(ruby));
78
+ JCHECK(str);
79
+ *retval = STRING_TO_JSVAL(str);
80
+ JRETURN;
85
81
  }
86
82
 
87
83
  case T_FIXNUM:
88
- *retval = INT_TO_JSVAL(NUM2INT(ruby));
89
- return JS_TRUE;
84
+ {
85
+ long val = NUM2LONG(ruby);
86
+ if (val >= JSVAL_INT_MIN && val <= JSVAL_INT_MAX)
87
+ {
88
+ *retval = INT_TO_JSVAL((jsint)val);
89
+ JRETURN;
90
+ }
91
+ }
90
92
 
91
93
  case T_FLOAT:
92
94
  case T_BIGNUM:
93
- return convert_float_or_bignum_to_js(runtime, ruby, retval);
95
+ JCHECK(convert_float_or_bignum_to_js(runtime, ruby, retval));
96
+ JRETURN;
94
97
 
95
98
  case T_SYMBOL:
96
- return convert_symbol_to_js(runtime, ruby, retval);
99
+ JCHECK(convert_symbol_to_js(runtime, ruby, retval));
100
+ JRETURN;
97
101
 
98
102
  case T_CLASS:
99
103
  case T_ARRAY:
@@ -102,24 +106,26 @@ JSBool convert_to_js(JohnsonRuntime* runtime, VALUE ruby, jsval* retval)
102
106
  case T_FILE:
103
107
  case T_STRUCT:
104
108
  case T_OBJECT:
105
- return make_js_land_proxy(runtime, ruby, retval);
109
+ JCHECK(make_js_land_proxy(runtime, ruby, retval));
110
+ JRETURN;
106
111
 
107
112
  case T_REGEXP:
108
- return convert_regexp_to_js(runtime, ruby, retval);
113
+ JCHECK(convert_regexp_to_js(runtime, ruby, retval));
114
+ JRETURN;
109
115
 
110
116
  case T_DATA: // HEY! keep T_DATA last for fall-through
111
117
  if (ruby_value_is_proxy(ruby))
112
- return unwrap_ruby_land_proxy(runtime, ruby, retval);
118
+ JCHECK(unwrap_ruby_land_proxy(runtime, ruby, retval));
119
+ else // If we can't identify the object, just wrap it
120
+ JCHECK(make_js_land_proxy(runtime, ruby, retval));
121
+ JRETURN;
113
122
 
114
- // If we can't identify the object, just wrap it
115
- return make_js_land_proxy(runtime, ruby, retval);
116
-
117
123
  default:
118
- rb_raise(rb_eRuntimeError, "unknown ruby type in switch");
124
+ JERROR("unknown ruby type in switch");
119
125
  }
120
126
 
121
127
  *retval = JSVAL_NULL;
122
- return JS_TRUE;
128
+ JRETURN;
123
129
  }
124
130
 
125
131
  VALUE convert_js_string_to_ruby(JohnsonRuntime* runtime, JSString* str)
@@ -129,7 +135,7 @@ VALUE convert_js_string_to_ruby(JohnsonRuntime* runtime, JSString* str)
129
135
  JROOT(str);
130
136
  char* bytes = JS_GetStringBytes(str);
131
137
  JCHECK(bytes);
132
- JRETURN_RUBY(rb_str_new(bytes, (signed)JS_GetStringLength(str)));
138
+ JRETURN_RUBY(rb_str_new(bytes, (signed long)JS_GetStringLength(str)));
133
139
  }
134
140
 
135
141
  static VALUE convert_regexp_to_ruby(JohnsonRuntime* runtime, jsval regexp)
@@ -141,7 +147,7 @@ static VALUE convert_regexp_to_ruby(JohnsonRuntime* runtime, jsval regexp)
141
147
 
142
148
  JRETURN_RUBY(CALL_RUBY_WRAPPER(rb_funcall_2, rb_cRegexp, rb_intern("new"), 2,
143
149
  convert_js_string_to_ruby(runtime, re->source),
144
- INT2NUM(re->flags)));
150
+ INT2NUM((long)re->flags)));
145
151
  }
146
152
 
147
153
  static bool js_value_is_regexp(JohnsonRuntime* runtime, jsval maybe_regexp)
@@ -22,7 +22,7 @@ static VALUE line_number(VALUE UNUSED(self), VALUE context, VALUE script, VALUE
22
22
  Data_Get_Struct(script, JSScript, js_script);
23
23
  Data_Get_Struct(bytecode, jsbytecode, js_bytecode);
24
24
 
25
- return INT2NUM(JS_PCToLineNumber(js, js_script, js_bytecode));
25
+ return INT2NUM((long)JS_PCToLineNumber(js, js_script, js_bytecode));
26
26
  }
27
27
 
28
28
  static VALUE file_name(VALUE UNUSED(self), VALUE context, VALUE script)
@@ -64,7 +64,7 @@ static void new_script_hook(JSContext *UNUSED(js),
64
64
  {
65
65
  VALUE self = (VALUE)rb;
66
66
  VALUE rb_filename = rb_str_new2(filename);
67
- VALUE rb_linenum = UINT2NUM(lineno);
67
+ VALUE rb_linenum = UINT2NUM((unsigned long)lineno);
68
68
 
69
69
  /* FIXME: Pass the rest of this crap to the debugger? */
70
70
  rb_funcall(self, rb_intern("new_script_hook"), 2, rb_filename, rb_linenum);
@@ -103,8 +103,8 @@ static void source_handler(const char *filename, uintN lineno,
103
103
  {
104
104
  VALUE self = (VALUE)rb;
105
105
  VALUE rb_filename = rb_str_new2(filename);
106
- VALUE rb_lineno = UINT2NUM(lineno);
107
- VALUE rb_str = rb_str_new((char *)str, (signed)(length * sizeof(jschar)));
106
+ VALUE rb_lineno = ULONG2NUM((unsigned long)lineno);
107
+ VALUE rb_str = rb_str_new((char *)str, (signed long)(length * sizeof(jschar)));
108
108
 
109
109
  rb_funcall(self, rb_intern("source_handler"), 3, rb_filename, rb_lineno, rb_str);
110
110
  }
@@ -164,7 +164,7 @@ static JSBool debug_error_hook(JSContext *UNUSED(js), const char *message,
164
164
 
165
165
  static VALUE allocate(VALUE klass)
166
166
  {
167
- JSDebugHooks* debug = calloc(1, sizeof(JSDebugHooks));
167
+ JSDebugHooks* debug = calloc(1L, sizeof(JSDebugHooks));
168
168
  VALUE self = Data_Wrap_Struct(klass, 0, 0, debug);
169
169
 
170
170
  debug->interruptHandler = interrupt_handler;
@@ -17,12 +17,12 @@ static void deallocate(ImmutableNodeContext* context)
17
17
 
18
18
  static VALUE allocate(VALUE klass)
19
19
  {
20
- ImmutableNodeContext * context = calloc(1, sizeof(ImmutableNodeContext));
20
+ ImmutableNodeContext * context = calloc(1L, sizeof(ImmutableNodeContext));
21
21
 
22
22
  VALUE self = Data_Wrap_Struct(klass, 0, deallocate, context);
23
23
 
24
24
  assert(context->runtime = JS_NewRuntime(0x100000));
25
- assert(context->js = JS_NewContext(context->runtime, 8192));
25
+ assert(context->js = JS_NewContext(context->runtime, 8192L));
26
26
 
27
27
  return self;
28
28
  }
@@ -40,7 +40,7 @@ static VALUE parse_io(int argc, VALUE *argv, VALUE klass) {
40
40
  ImmutableNodeContext* context;
41
41
  Data_Get_Struct(self, ImmutableNodeContext, context);
42
42
 
43
- assert(context->pc = calloc(1, sizeof(JSParseContext)));
43
+ assert(context->pc = calloc(1L, sizeof(JSParseContext)));
44
44
 
45
45
  rb_scan_args( argc, argv, "12", &stream, &filename, &linenum );
46
46
 
@@ -80,7 +80,7 @@ static VALUE parse_io(int argc, VALUE *argv, VALUE klass) {
80
80
  Qnil :
81
81
  rb_str_new2(JS_GetStringBytes(JSVAL_TO_STRING(message))),
82
82
  rb_str_new2(JS_GetStringBytes(JSVAL_TO_STRING(file_name))),
83
- INT2NUM(JSVAL_TO_INT(line_number))
83
+ INT2NUM((long)JSVAL_TO_INT(line_number))
84
84
  );
85
85
 
86
86
  }
@@ -97,7 +97,7 @@ static VALUE line(VALUE self) {
97
97
  ImmutableNodeContext * ctx;
98
98
 
99
99
  Data_Get_Struct(self, ImmutableNodeContext, ctx);
100
- return INT2NUM(ctx->node->pn_pos.begin.lineno);
100
+ return INT2NUM((long)(ctx->node->pn_pos.begin.lineno));
101
101
  }
102
102
 
103
103
  /*
@@ -110,7 +110,7 @@ static VALUE begin_index(VALUE self) {
110
110
  ImmutableNodeContext * ctx;
111
111
 
112
112
  Data_Get_Struct(self, ImmutableNodeContext, ctx);
113
- return INT2NUM(ctx->node->pn_pos.begin.index);
113
+ return INT2NUM((long)(ctx->node->pn_pos.begin.index));
114
114
  }
115
115
 
116
116
  /*
@@ -157,7 +157,7 @@ static VALUE pn_type(VALUE self) {
157
157
  case <%= token %>: return ID2SYM(rb_intern("<%= token.downcase %>"));
158
158
  <% end %>
159
159
  }
160
- return INT2NUM(ctx->node->pn_type);
160
+ return INT2NUM((long)(ctx->node->pn_type));
161
161
  }
162
162
 
163
163
  /*
@@ -273,7 +273,7 @@ static VALUE data_pn_dval(VALUE self) {
273
273
  if(JSVAL_IS_NUMBER(ATOM_KEY(ctx->node->pn_atom))) {
274
274
  return rb_float_new(ctx->node->pn_dval);
275
275
  } else {
276
- return INT2NUM((int)(ctx->node->pn_dval));
276
+ return INT2NUM((long)(ctx->node->pn_dval));
277
277
  }
278
278
  }
279
279
 
@@ -322,7 +322,7 @@ static VALUE data_pn_extra(VALUE self) {
322
322
 
323
323
  Data_Get_Struct(self, ImmutableNodeContext, ctx);
324
324
 
325
- return UINT2NUM(ctx->node->pn_extra);
325
+ return UINT2NUM((unsigned long)(ctx->node->pn_extra));
326
326
  }
327
327
 
328
328
  /*
@@ -393,7 +393,7 @@ static VALUE function_args(VALUE self) {
393
393
  object = ctx->node->pn_funpob->object;
394
394
  f = (JSFunction *)JS_GetPrivate(ctx->js, ctx->node->pn_funpob->object);
395
395
 
396
- func_args = rb_ary_new2(f->nargs);
396
+ func_args = rb_ary_new2((long)f->nargs);
397
397
  if(f->nargs > 0) {
398
398
  names = js_GetLocalNameArray(ctx->js, f, &ctx->js->tempPool);
399
399
  for(i = 0; i < f->nargs; i++) {
@@ -484,7 +484,7 @@ VALUE jsop_to_symbol(JSUint32 jsop)
484
484
  case <%= jsop %>: return ID2SYM(rb_intern("<%= jsop.downcase %>"));
485
485
  <% end %>
486
486
  }
487
- return UINT2NUM(jsop);
487
+ return UINT2NUM((unsigned long)(jsop));
488
488
  }
489
489
 
490
490
  void init_Johnson_SpiderMonkey_Immutable_Node(VALUE spidermonkey)
@@ -1,8 +1,8 @@
1
1
  #ifndef JOHNSON_JROOT_H
2
2
  #define JOHNSON_JROOT_H
3
3
 
4
- #define _JROOT_NAMESIZE 200
5
- #define _JROOT_ERRSIZE 500
4
+ #define _JROOT_NAMESIZE 200L
5
+ #define _JROOT_ERRSIZE 500L
6
6
 
7
7
  #define _JROOT_ROOT (void*)(1)
8
8
 
@@ -176,10 +176,10 @@
176
176
  #define DEFINE_RUBY_WRAPPER(name, func, arglist) \
177
177
  VALUE name ## _invoke(VALUE magic) \
178
178
  { \
179
- name ## _args * _data = (name ## _args *)(FIX2INT(magic) << 2); \
179
+ name ## _args * _data = (name ## _args *)(FIX2LONG(magic) << 2); \
180
180
  return func(arglist); \
181
181
  }
182
- #define RUBY_WRAPPER_ARG(name, args...) ({ name ## _args _x = { args }; INT2FIX((int)(&_x) >> 2); })
182
+ #define RUBY_WRAPPER_ARG(name, args...) ({ name ## _args _x = { args }; LONG2FIX((long)(&_x) >> 2); })
183
183
  #define RUBY_WRAPPER(name) name ## _invoke
184
184
  #define CALL_RUBY_WRAPPER(name, args...) JPROTECT(RUBY_WRAPPER(name), RUBY_WRAPPER_ARG(name, args))
185
185
 
@@ -61,14 +61,14 @@ static VALUE call_ruby_from_js_invoke(VALUE args)
61
61
  JSBool call_ruby_from_js_va(JohnsonRuntime* runtime, VALUE* result, VALUE self, ID id, int argc, va_list va)
62
62
  {
63
63
  VALUE old_errinfo = ruby_errinfo;
64
- VALUE args = rb_ary_new2(argc + 2);
64
+ VALUE args = rb_ary_new2((long)argc + 2);
65
65
 
66
- int i;
66
+ long i;
67
67
  for(i = 0; i < argc; i++)
68
68
  rb_ary_store(args, i, va_arg(va, VALUE));
69
69
 
70
- rb_ary_store(args, argc, ID2SYM(id));
71
- rb_ary_store(args, argc + 1, self);
70
+ rb_ary_store(args, (long)argc, ID2SYM(id));
71
+ rb_ary_store(args, (long)argc + 1, self);
72
72
 
73
73
  int state;
74
74
  *result = rb_protect(call_ruby_from_js_invoke, args, &state);
@@ -181,8 +181,9 @@ static bool respond_to_p(JSContext* js_context, JSObject* obj, char* name)
181
181
 
182
182
  static jsval evaluate_js_property_expression(JohnsonRuntime * runtime, const char * property, jsval* retval) {
183
183
  JSContext * context = johnson_get_current_context(runtime);
184
+ assert(strlen(property) < INT_MAX);
184
185
  return JS_EvaluateScript(context, runtime->global,
185
- property, strlen(property), "johnson:evaluate_js_property_expression", 1,
186
+ property, (unsigned int)strlen(property), "johnson:evaluate_js_property_expression", 1,
186
187
  retval);
187
188
  }
188
189
 
@@ -550,10 +551,10 @@ static void finalize(JSContext* js_context, JSObject* obj)
550
551
 
551
552
  // remove the proxy OID from the id map
552
553
  JS_HashTableRemove(runtime->rbids, (void *)self);
553
-
554
+
554
555
  // free up the ruby value for GC
555
- call_ruby_from_js(runtime, NULL, ruby_runtime, rb_intern("remove_gcthing"), 1, self);
556
- }
556
+ rb_funcall(ruby_runtime, rb_intern("remove_gcthing"), 1, rb_obj_id(self));
557
+ }
557
558
  }
558
559
 
559
560
  JSBool make_js_land_proxy(JohnsonRuntime* runtime, VALUE value, jsval* retval)
@@ -65,7 +65,7 @@ get(VALUE self, VALUE name)
65
65
  switch(TYPE(name)) {
66
66
  case T_FIXNUM:
67
67
  JCHECK(JS_GetElement(context,
68
- JSVAL_TO_OBJECT(proxy_value), NUM2INT(name), &js_value));
68
+ JSVAL_TO_OBJECT(proxy_value), (jsint)(NUM2INT(name)), &js_value));
69
69
  break;
70
70
  default:
71
71
  Check_Type(name, T_STRING);
@@ -104,7 +104,7 @@ set(VALUE self, VALUE name, VALUE value)
104
104
  switch(TYPE(name)) {
105
105
  case T_FIXNUM:
106
106
  JCHECK(JS_SetElement(context,
107
- JSVAL_TO_OBJECT(proxy_value), NUM2INT(name), &js_value));
107
+ JSVAL_TO_OBJECT(proxy_value), (jsint)(NUM2INT(name)), &js_value));
108
108
  break;
109
109
  default:
110
110
  Check_Type(name, T_STRING);
@@ -150,7 +150,8 @@ respond_to_p(VALUE self, VALUE sym)
150
150
  JSContext * context = johnson_get_current_context(proxy->runtime);
151
151
  PREPARE_RUBY_JROOTS(context, 2);
152
152
 
153
- char* name = rb_id2name(SYM2ID(sym));
153
+ VALUE stringval = rb_funcall(sym, rb_intern("to_s"), 0);
154
+ char* name = StringValuePtr(stringval);
154
155
 
155
156
  // assignment is always okay
156
157
  if (name[strlen(name) - 1] == '=')
@@ -278,7 +279,7 @@ each(VALUE self)
278
279
  VALUE key = CONVERT_TO_RUBY(proxy->runtime, js_key);
279
280
  VALUE value = CONVERT_TO_RUBY(proxy->runtime, js_value);
280
281
 
281
- CALL_RUBY_WRAPPER(rb_yield, rb_ary_new3(2, key, value));
282
+ CALL_RUBY_WRAPPER(rb_yield, rb_ary_new3(2L, key, value));
282
283
 
283
284
  JUNROOT(js_value);
284
285
  JUNROOT(js_key);