johnson 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (371) hide show
  1. data/.autotest +14 -0
  2. data/CHANGELOG.rdoc +11 -0
  3. data/Manifest.txt +370 -0
  4. data/README.rdoc +60 -0
  5. data/Rakefile +42 -0
  6. data/bin/johnson +108 -0
  7. data/docs/MINGW32.mk +124 -0
  8. data/docs/cross-compile.txt +38 -0
  9. data/ext/spidermonkey/context.c +115 -0
  10. data/ext/spidermonkey/context.h +19 -0
  11. data/ext/spidermonkey/conversions.c +320 -0
  12. data/ext/spidermonkey/conversions.h +18 -0
  13. data/ext/spidermonkey/debugger.c +226 -0
  14. data/ext/spidermonkey/debugger.h +9 -0
  15. data/ext/spidermonkey/extconf.rb +30 -0
  16. data/ext/spidermonkey/extensions.c +37 -0
  17. data/ext/spidermonkey/extensions.h +12 -0
  18. data/ext/spidermonkey/global.c +40 -0
  19. data/ext/spidermonkey/global.h +11 -0
  20. data/ext/spidermonkey/idhash.c +16 -0
  21. data/ext/spidermonkey/idhash.h +8 -0
  22. data/ext/spidermonkey/immutable_node.c +1153 -0
  23. data/ext/spidermonkey/immutable_node.c.erb +523 -0
  24. data/ext/spidermonkey/immutable_node.h +22 -0
  25. data/ext/spidermonkey/jroot.h +187 -0
  26. data/ext/spidermonkey/js_land_proxy.c +610 -0
  27. data/ext/spidermonkey/js_land_proxy.h +20 -0
  28. data/ext/spidermonkey/ruby_land_proxy.c +543 -0
  29. data/ext/spidermonkey/ruby_land_proxy.h +17 -0
  30. data/ext/spidermonkey/runtime.c +330 -0
  31. data/ext/spidermonkey/runtime.h +25 -0
  32. data/ext/spidermonkey/spidermonkey.c +20 -0
  33. data/ext/spidermonkey/spidermonkey.h +29 -0
  34. data/johnson.gemspec +44 -0
  35. data/js/johnson/cli.js +30 -0
  36. data/js/johnson/prelude.js +80 -0
  37. data/lib/johnson.rb +55 -0
  38. data/lib/johnson/cli.rb +7 -0
  39. data/lib/johnson/cli/options.rb +67 -0
  40. data/lib/johnson/error.rb +4 -0
  41. data/lib/johnson/nodes.rb +7 -0
  42. data/lib/johnson/nodes/binary_node.rb +65 -0
  43. data/lib/johnson/nodes/for.rb +14 -0
  44. data/lib/johnson/nodes/for_in.rb +12 -0
  45. data/lib/johnson/nodes/function.rb +13 -0
  46. data/lib/johnson/nodes/list.rb +28 -0
  47. data/lib/johnson/nodes/node.rb +68 -0
  48. data/lib/johnson/nodes/ternary_node.rb +20 -0
  49. data/lib/johnson/parser.rb +21 -0
  50. data/lib/johnson/parser/syntax_error.rb +13 -0
  51. data/lib/johnson/runtime.rb +63 -0
  52. data/lib/johnson/spidermonkey/context.rb +10 -0
  53. data/lib/johnson/spidermonkey/debugger.rb +67 -0
  54. data/lib/johnson/spidermonkey/immutable_node.rb +282 -0
  55. data/lib/johnson/spidermonkey/js_land_proxy.rb +62 -0
  56. data/lib/johnson/spidermonkey/mutable_tree_visitor.rb +242 -0
  57. data/lib/johnson/spidermonkey/ruby_land_proxy.rb +54 -0
  58. data/lib/johnson/spidermonkey/runtime.rb +103 -0
  59. data/lib/johnson/version.rb +3 -0
  60. data/lib/johnson/visitable.rb +16 -0
  61. data/lib/johnson/visitors.rb +5 -0
  62. data/lib/johnson/visitors/dot_visitor.rb +169 -0
  63. data/lib/johnson/visitors/ecma_visitor.rb +323 -0
  64. data/lib/johnson/visitors/enumerating_visitor.rb +15 -0
  65. data/lib/johnson/visitors/sexp_visitor.rb +174 -0
  66. data/lib/johnson/visitors/visitor.rb +91 -0
  67. data/lib/rails/init.rb +37 -0
  68. data/lib/tasks/gem.rake +9 -0
  69. data/lib/tasks/parsing.rake +37 -0
  70. data/lib/tasks/testing.rake +36 -0
  71. data/lib/tasks/vendor.rake +20 -0
  72. data/test/helper.rb +55 -0
  73. data/test/johnson/browser_test.rb +43 -0
  74. data/test/johnson/conversions/array_test.rb +32 -0
  75. data/test/johnson/conversions/boolean_test.rb +17 -0
  76. data/test/johnson/conversions/callable_test.rb +34 -0
  77. data/test/johnson/conversions/file_test.rb +15 -0
  78. data/test/johnson/conversions/nil_test.rb +20 -0
  79. data/test/johnson/conversions/number_test.rb +34 -0
  80. data/test/johnson/conversions/regexp_test.rb +24 -0
  81. data/test/johnson/conversions/string_test.rb +26 -0
  82. data/test/johnson/conversions/struct_test.rb +15 -0
  83. data/test/johnson/conversions/symbol_test.rb +19 -0
  84. data/test/johnson/conversions/thread_test.rb +24 -0
  85. data/test/johnson/error_test.rb +9 -0
  86. data/test/johnson/extensions_test.rb +56 -0
  87. data/test/johnson/nodes/array_literal_test.rb +57 -0
  88. data/test/johnson/nodes/array_node_test.rb +26 -0
  89. data/test/johnson/nodes/binary_node_test.rb +61 -0
  90. data/test/johnson/nodes/bracket_access_test.rb +16 -0
  91. data/test/johnson/nodes/delete_test.rb +11 -0
  92. data/test/johnson/nodes/do_while_test.rb +12 -0
  93. data/test/johnson/nodes/dot_accessor_test.rb +15 -0
  94. data/test/johnson/nodes/export_test.rb +9 -0
  95. data/test/johnson/nodes/for_test.rb +54 -0
  96. data/test/johnson/nodes/function_test.rb +71 -0
  97. data/test/johnson/nodes/if_test.rb +41 -0
  98. data/test/johnson/nodes/import_test.rb +13 -0
  99. data/test/johnson/nodes/label_test.rb +19 -0
  100. data/test/johnson/nodes/let_test.rb +31 -0
  101. data/test/johnson/nodes/object_literal_test.rb +110 -0
  102. data/test/johnson/nodes/return_test.rb +16 -0
  103. data/test/johnson/nodes/semi_test.rb +8 -0
  104. data/test/johnson/nodes/switch_test.rb +55 -0
  105. data/test/johnson/nodes/ternary_test.rb +25 -0
  106. data/test/johnson/nodes/throw_test.rb +9 -0
  107. data/test/johnson/nodes/try_node_test.rb +59 -0
  108. data/test/johnson/nodes/typeof_test.rb +11 -0
  109. data/test/johnson/nodes/unary_node_test.rb +23 -0
  110. data/test/johnson/nodes/void_test.rb +11 -0
  111. data/test/johnson/nodes/while_test.rb +26 -0
  112. data/test/johnson/nodes/with_test.rb +10 -0
  113. data/test/johnson/prelude_test.rb +56 -0
  114. data/test/johnson/runtime_test.rb +64 -0
  115. data/test/johnson/spidermonkey/context_test.rb +21 -0
  116. data/test/johnson/spidermonkey/immutable_node_test.rb +34 -0
  117. data/test/johnson/spidermonkey/js_land_proxy_test.rb +236 -0
  118. data/test/johnson/spidermonkey/ruby_land_proxy_test.rb +240 -0
  119. data/test/johnson/spidermonkey/runtime_test.rb +17 -0
  120. data/test/johnson/version_test.rb +13 -0
  121. data/test/johnson/visitors/dot_visitor_test.rb +39 -0
  122. data/test/johnson/visitors/enumerating_visitor_test.rb +12 -0
  123. data/test/johnson_test.rb +16 -0
  124. data/test/parser_test.rb +276 -0
  125. data/vendor/spidermonkey/.cvsignore +9 -0
  126. data/vendor/spidermonkey/Makefile.in +449 -0
  127. data/vendor/spidermonkey/Makefile.ref +365 -0
  128. data/vendor/spidermonkey/README.html +820 -0
  129. data/vendor/spidermonkey/SpiderMonkey.rsp +12 -0
  130. data/vendor/spidermonkey/Y.js +19 -0
  131. data/vendor/spidermonkey/build.mk +43 -0
  132. data/vendor/spidermonkey/config.mk +192 -0
  133. data/vendor/spidermonkey/config/AIX4.1.mk +65 -0
  134. data/vendor/spidermonkey/config/AIX4.2.mk +64 -0
  135. data/vendor/spidermonkey/config/AIX4.3.mk +65 -0
  136. data/vendor/spidermonkey/config/Darwin.mk +83 -0
  137. data/vendor/spidermonkey/config/Darwin1.3.mk +81 -0
  138. data/vendor/spidermonkey/config/Darwin1.4.mk +41 -0
  139. data/vendor/spidermonkey/config/Darwin5.2.mk +81 -0
  140. data/vendor/spidermonkey/config/Darwin5.3.mk +81 -0
  141. data/vendor/spidermonkey/config/HP-UXB.10.10.mk +77 -0
  142. data/vendor/spidermonkey/config/HP-UXB.10.20.mk +77 -0
  143. data/vendor/spidermonkey/config/HP-UXB.11.00.mk +80 -0
  144. data/vendor/spidermonkey/config/IRIX.mk +87 -0
  145. data/vendor/spidermonkey/config/IRIX5.3.mk +44 -0
  146. data/vendor/spidermonkey/config/IRIX6.1.mk +44 -0
  147. data/vendor/spidermonkey/config/IRIX6.2.mk +44 -0
  148. data/vendor/spidermonkey/config/IRIX6.3.mk +44 -0
  149. data/vendor/spidermonkey/config/IRIX6.5.mk +44 -0
  150. data/vendor/spidermonkey/config/Linux_All.mk +103 -0
  151. data/vendor/spidermonkey/config/Mac_OS10.0.mk +82 -0
  152. data/vendor/spidermonkey/config/OSF1V4.0.mk +72 -0
  153. data/vendor/spidermonkey/config/OSF1V5.0.mk +69 -0
  154. data/vendor/spidermonkey/config/SunOS4.1.4.mk +101 -0
  155. data/vendor/spidermonkey/config/SunOS5.10.mk +50 -0
  156. data/vendor/spidermonkey/config/SunOS5.3.mk +91 -0
  157. data/vendor/spidermonkey/config/SunOS5.4.mk +92 -0
  158. data/vendor/spidermonkey/config/SunOS5.5.1.mk +44 -0
  159. data/vendor/spidermonkey/config/SunOS5.5.mk +87 -0
  160. data/vendor/spidermonkey/config/SunOS5.6.mk +89 -0
  161. data/vendor/spidermonkey/config/SunOS5.7.mk +44 -0
  162. data/vendor/spidermonkey/config/SunOS5.8.mk +44 -0
  163. data/vendor/spidermonkey/config/SunOS5.9.mk +44 -0
  164. data/vendor/spidermonkey/config/WINNT4.0.mk +117 -0
  165. data/vendor/spidermonkey/config/WINNT5.0.mk +117 -0
  166. data/vendor/spidermonkey/config/WINNT5.1.mk +117 -0
  167. data/vendor/spidermonkey/config/WINNT5.2.mk +117 -0
  168. data/vendor/spidermonkey/config/WINNT6.0.mk +117 -0
  169. data/vendor/spidermonkey/config/dgux.mk +64 -0
  170. data/vendor/spidermonkey/editline/Makefile.ref +144 -0
  171. data/vendor/spidermonkey/editline/README +83 -0
  172. data/vendor/spidermonkey/editline/editline.3 +175 -0
  173. data/vendor/spidermonkey/editline/editline.c +1369 -0
  174. data/vendor/spidermonkey/editline/editline.h +135 -0
  175. data/vendor/spidermonkey/editline/sysunix.c +182 -0
  176. data/vendor/spidermonkey/editline/unix.h +82 -0
  177. data/vendor/spidermonkey/fdlibm/.cvsignore +7 -0
  178. data/vendor/spidermonkey/fdlibm/Makefile.in +127 -0
  179. data/vendor/spidermonkey/fdlibm/Makefile.ref +192 -0
  180. data/vendor/spidermonkey/fdlibm/e_acos.c +147 -0
  181. data/vendor/spidermonkey/fdlibm/e_acosh.c +105 -0
  182. data/vendor/spidermonkey/fdlibm/e_asin.c +156 -0
  183. data/vendor/spidermonkey/fdlibm/e_atan2.c +165 -0
  184. data/vendor/spidermonkey/fdlibm/e_atanh.c +110 -0
  185. data/vendor/spidermonkey/fdlibm/e_cosh.c +133 -0
  186. data/vendor/spidermonkey/fdlibm/e_exp.c +202 -0
  187. data/vendor/spidermonkey/fdlibm/e_fmod.c +184 -0
  188. data/vendor/spidermonkey/fdlibm/e_gamma.c +71 -0
  189. data/vendor/spidermonkey/fdlibm/e_gamma_r.c +70 -0
  190. data/vendor/spidermonkey/fdlibm/e_hypot.c +173 -0
  191. data/vendor/spidermonkey/fdlibm/e_j0.c +524 -0
  192. data/vendor/spidermonkey/fdlibm/e_j1.c +523 -0
  193. data/vendor/spidermonkey/fdlibm/e_jn.c +315 -0
  194. data/vendor/spidermonkey/fdlibm/e_lgamma.c +71 -0
  195. data/vendor/spidermonkey/fdlibm/e_lgamma_r.c +347 -0
  196. data/vendor/spidermonkey/fdlibm/e_log.c +184 -0
  197. data/vendor/spidermonkey/fdlibm/e_log10.c +134 -0
  198. data/vendor/spidermonkey/fdlibm/e_pow.c +386 -0
  199. data/vendor/spidermonkey/fdlibm/e_rem_pio2.c +222 -0
  200. data/vendor/spidermonkey/fdlibm/e_remainder.c +120 -0
  201. data/vendor/spidermonkey/fdlibm/e_scalb.c +89 -0
  202. data/vendor/spidermonkey/fdlibm/e_sinh.c +122 -0
  203. data/vendor/spidermonkey/fdlibm/e_sqrt.c +497 -0
  204. data/vendor/spidermonkey/fdlibm/fdlibm.h +273 -0
  205. data/vendor/spidermonkey/fdlibm/fdlibm.mak +1453 -0
  206. data/vendor/spidermonkey/fdlibm/fdlibm.mdp +0 -0
  207. data/vendor/spidermonkey/fdlibm/k_cos.c +135 -0
  208. data/vendor/spidermonkey/fdlibm/k_rem_pio2.c +354 -0
  209. data/vendor/spidermonkey/fdlibm/k_sin.c +114 -0
  210. data/vendor/spidermonkey/fdlibm/k_standard.c +785 -0
  211. data/vendor/spidermonkey/fdlibm/k_tan.c +170 -0
  212. data/vendor/spidermonkey/fdlibm/s_asinh.c +101 -0
  213. data/vendor/spidermonkey/fdlibm/s_atan.c +175 -0
  214. data/vendor/spidermonkey/fdlibm/s_cbrt.c +133 -0
  215. data/vendor/spidermonkey/fdlibm/s_ceil.c +120 -0
  216. data/vendor/spidermonkey/fdlibm/s_copysign.c +72 -0
  217. data/vendor/spidermonkey/fdlibm/s_cos.c +118 -0
  218. data/vendor/spidermonkey/fdlibm/s_erf.c +356 -0
  219. data/vendor/spidermonkey/fdlibm/s_expm1.c +267 -0
  220. data/vendor/spidermonkey/fdlibm/s_fabs.c +70 -0
  221. data/vendor/spidermonkey/fdlibm/s_finite.c +71 -0
  222. data/vendor/spidermonkey/fdlibm/s_floor.c +121 -0
  223. data/vendor/spidermonkey/fdlibm/s_frexp.c +99 -0
  224. data/vendor/spidermonkey/fdlibm/s_ilogb.c +85 -0
  225. data/vendor/spidermonkey/fdlibm/s_isnan.c +74 -0
  226. data/vendor/spidermonkey/fdlibm/s_ldexp.c +66 -0
  227. data/vendor/spidermonkey/fdlibm/s_lib_version.c +73 -0
  228. data/vendor/spidermonkey/fdlibm/s_log1p.c +211 -0
  229. data/vendor/spidermonkey/fdlibm/s_logb.c +79 -0
  230. data/vendor/spidermonkey/fdlibm/s_matherr.c +64 -0
  231. data/vendor/spidermonkey/fdlibm/s_modf.c +132 -0
  232. data/vendor/spidermonkey/fdlibm/s_nextafter.c +124 -0
  233. data/vendor/spidermonkey/fdlibm/s_rint.c +131 -0
  234. data/vendor/spidermonkey/fdlibm/s_scalbn.c +107 -0
  235. data/vendor/spidermonkey/fdlibm/s_signgam.c +40 -0
  236. data/vendor/spidermonkey/fdlibm/s_significand.c +68 -0
  237. data/vendor/spidermonkey/fdlibm/s_sin.c +118 -0
  238. data/vendor/spidermonkey/fdlibm/s_tan.c +112 -0
  239. data/vendor/spidermonkey/fdlibm/s_tanh.c +122 -0
  240. data/vendor/spidermonkey/fdlibm/w_acos.c +78 -0
  241. data/vendor/spidermonkey/fdlibm/w_acosh.c +78 -0
  242. data/vendor/spidermonkey/fdlibm/w_asin.c +80 -0
  243. data/vendor/spidermonkey/fdlibm/w_atan2.c +79 -0
  244. data/vendor/spidermonkey/fdlibm/w_atanh.c +81 -0
  245. data/vendor/spidermonkey/fdlibm/w_cosh.c +77 -0
  246. data/vendor/spidermonkey/fdlibm/w_exp.c +88 -0
  247. data/vendor/spidermonkey/fdlibm/w_fmod.c +78 -0
  248. data/vendor/spidermonkey/fdlibm/w_gamma.c +85 -0
  249. data/vendor/spidermonkey/fdlibm/w_gamma_r.c +81 -0
  250. data/vendor/spidermonkey/fdlibm/w_hypot.c +78 -0
  251. data/vendor/spidermonkey/fdlibm/w_j0.c +105 -0
  252. data/vendor/spidermonkey/fdlibm/w_j1.c +106 -0
  253. data/vendor/spidermonkey/fdlibm/w_jn.c +128 -0
  254. data/vendor/spidermonkey/fdlibm/w_lgamma.c +85 -0
  255. data/vendor/spidermonkey/fdlibm/w_lgamma_r.c +81 -0
  256. data/vendor/spidermonkey/fdlibm/w_log.c +78 -0
  257. data/vendor/spidermonkey/fdlibm/w_log10.c +81 -0
  258. data/vendor/spidermonkey/fdlibm/w_pow.c +99 -0
  259. data/vendor/spidermonkey/fdlibm/w_remainder.c +77 -0
  260. data/vendor/spidermonkey/fdlibm/w_scalb.c +95 -0
  261. data/vendor/spidermonkey/fdlibm/w_sinh.c +77 -0
  262. data/vendor/spidermonkey/fdlibm/w_sqrt.c +77 -0
  263. data/vendor/spidermonkey/javascript-trace.d +73 -0
  264. data/vendor/spidermonkey/js.c +3951 -0
  265. data/vendor/spidermonkey/js.mdp +0 -0
  266. data/vendor/spidermonkey/js.msg +308 -0
  267. data/vendor/spidermonkey/js3240.rc +79 -0
  268. data/vendor/spidermonkey/jsOS240.def +654 -0
  269. data/vendor/spidermonkey/jsapi.c +5836 -0
  270. data/vendor/spidermonkey/jsapi.h +2624 -0
  271. data/vendor/spidermonkey/jsarena.c +450 -0
  272. data/vendor/spidermonkey/jsarena.h +318 -0
  273. data/vendor/spidermonkey/jsarray.c +2996 -0
  274. data/vendor/spidermonkey/jsarray.h +127 -0
  275. data/vendor/spidermonkey/jsatom.c +1045 -0
  276. data/vendor/spidermonkey/jsatom.h +442 -0
  277. data/vendor/spidermonkey/jsbit.h +253 -0
  278. data/vendor/spidermonkey/jsbool.c +176 -0
  279. data/vendor/spidermonkey/jsbool.h +73 -0
  280. data/vendor/spidermonkey/jsclist.h +139 -0
  281. data/vendor/spidermonkey/jscntxt.c +1348 -0
  282. data/vendor/spidermonkey/jscntxt.h +1120 -0
  283. data/vendor/spidermonkey/jscompat.h +57 -0
  284. data/vendor/spidermonkey/jsconfig.h +248 -0
  285. data/vendor/spidermonkey/jsconfig.mk +181 -0
  286. data/vendor/spidermonkey/jscpucfg.c +396 -0
  287. data/vendor/spidermonkey/jscpucfg.h +212 -0
  288. data/vendor/spidermonkey/jsdate.c +2390 -0
  289. data/vendor/spidermonkey/jsdate.h +124 -0
  290. data/vendor/spidermonkey/jsdbgapi.c +1802 -0
  291. data/vendor/spidermonkey/jsdbgapi.h +464 -0
  292. data/vendor/spidermonkey/jsdhash.c +868 -0
  293. data/vendor/spidermonkey/jsdhash.h +592 -0
  294. data/vendor/spidermonkey/jsdtoa.c +3167 -0
  295. data/vendor/spidermonkey/jsdtoa.h +130 -0
  296. data/vendor/spidermonkey/jsdtracef.c +317 -0
  297. data/vendor/spidermonkey/jsdtracef.h +77 -0
  298. data/vendor/spidermonkey/jsemit.c +6909 -0
  299. data/vendor/spidermonkey/jsemit.h +741 -0
  300. data/vendor/spidermonkey/jsexn.c +1371 -0
  301. data/vendor/spidermonkey/jsexn.h +96 -0
  302. data/vendor/spidermonkey/jsfile.c +2736 -0
  303. data/vendor/spidermonkey/jsfile.h +56 -0
  304. data/vendor/spidermonkey/jsfile.msg +90 -0
  305. data/vendor/spidermonkey/jsfun.c +2634 -0
  306. data/vendor/spidermonkey/jsfun.h +254 -0
  307. data/vendor/spidermonkey/jsgc.c +3562 -0
  308. data/vendor/spidermonkey/jsgc.h +403 -0
  309. data/vendor/spidermonkey/jshash.c +476 -0
  310. data/vendor/spidermonkey/jshash.h +151 -0
  311. data/vendor/spidermonkey/jsify.pl +485 -0
  312. data/vendor/spidermonkey/jsinterp.c +7007 -0
  313. data/vendor/spidermonkey/jsinterp.h +525 -0
  314. data/vendor/spidermonkey/jsinvoke.c +43 -0
  315. data/vendor/spidermonkey/jsiter.c +1067 -0
  316. data/vendor/spidermonkey/jsiter.h +122 -0
  317. data/vendor/spidermonkey/jskeyword.tbl +124 -0
  318. data/vendor/spidermonkey/jskwgen.c +460 -0
  319. data/vendor/spidermonkey/jslibmath.h +266 -0
  320. data/vendor/spidermonkey/jslock.c +1309 -0
  321. data/vendor/spidermonkey/jslock.h +313 -0
  322. data/vendor/spidermonkey/jslocko.asm +60 -0
  323. data/vendor/spidermonkey/jslog2.c +94 -0
  324. data/vendor/spidermonkey/jslong.c +264 -0
  325. data/vendor/spidermonkey/jslong.h +412 -0
  326. data/vendor/spidermonkey/jsmath.c +567 -0
  327. data/vendor/spidermonkey/jsmath.h +57 -0
  328. data/vendor/spidermonkey/jsnum.c +1239 -0
  329. data/vendor/spidermonkey/jsnum.h +283 -0
  330. data/vendor/spidermonkey/jsobj.c +5282 -0
  331. data/vendor/spidermonkey/jsobj.h +709 -0
  332. data/vendor/spidermonkey/jsopcode.c +5245 -0
  333. data/vendor/spidermonkey/jsopcode.h +394 -0
  334. data/vendor/spidermonkey/jsopcode.tbl +523 -0
  335. data/vendor/spidermonkey/jsotypes.h +202 -0
  336. data/vendor/spidermonkey/jsparse.c +6704 -0
  337. data/vendor/spidermonkey/jsparse.h +511 -0
  338. data/vendor/spidermonkey/jsprf.c +1262 -0
  339. data/vendor/spidermonkey/jsprf.h +150 -0
  340. data/vendor/spidermonkey/jsproto.tbl +128 -0
  341. data/vendor/spidermonkey/jsprvtd.h +267 -0
  342. data/vendor/spidermonkey/jspubtd.h +744 -0
  343. data/vendor/spidermonkey/jsregexp.c +4364 -0
  344. data/vendor/spidermonkey/jsregexp.h +183 -0
  345. data/vendor/spidermonkey/jsreops.tbl +145 -0
  346. data/vendor/spidermonkey/jsscan.c +2012 -0
  347. data/vendor/spidermonkey/jsscan.h +387 -0
  348. data/vendor/spidermonkey/jsscope.c +1957 -0
  349. data/vendor/spidermonkey/jsscope.h +418 -0
  350. data/vendor/spidermonkey/jsscript.c +1832 -0
  351. data/vendor/spidermonkey/jsscript.h +287 -0
  352. data/vendor/spidermonkey/jsshell.msg +50 -0
  353. data/vendor/spidermonkey/jsstddef.h +83 -0
  354. data/vendor/spidermonkey/jsstr.c +5005 -0
  355. data/vendor/spidermonkey/jsstr.h +641 -0
  356. data/vendor/spidermonkey/jstypes.h +475 -0
  357. data/vendor/spidermonkey/jsutil.c +345 -0
  358. data/vendor/spidermonkey/jsutil.h +157 -0
  359. data/vendor/spidermonkey/jsxdrapi.c +800 -0
  360. data/vendor/spidermonkey/jsxdrapi.h +218 -0
  361. data/vendor/spidermonkey/jsxml.c +8476 -0
  362. data/vendor/spidermonkey/jsxml.h +349 -0
  363. data/vendor/spidermonkey/lock_SunOS.s +119 -0
  364. data/vendor/spidermonkey/perfect.js +39 -0
  365. data/vendor/spidermonkey/plify_jsdhash.sed +36 -0
  366. data/vendor/spidermonkey/prmjtime.c +846 -0
  367. data/vendor/spidermonkey/prmjtime.h +103 -0
  368. data/vendor/spidermonkey/resource.h +15 -0
  369. data/vendor/spidermonkey/rules.mk +197 -0
  370. data/vendor/spidermonkey/win32.order +384 -0
  371. metadata +513 -0
@@ -0,0 +1,709 @@
1
+ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2
+ * vim: set ts=8 sw=4 et tw=78:
3
+ *
4
+ * ***** BEGIN LICENSE BLOCK *****
5
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6
+ *
7
+ * The contents of this file are subject to the Mozilla Public License Version
8
+ * 1.1 (the "License"); you may not use this file except in compliance with
9
+ * the License. You may obtain a copy of the License at
10
+ * http://www.mozilla.org/MPL/
11
+ *
12
+ * Software distributed under the License is distributed on an "AS IS" basis,
13
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14
+ * for the specific language governing rights and limitations under the
15
+ * License.
16
+ *
17
+ * The Original Code is Mozilla Communicator client code, released
18
+ * March 31, 1998.
19
+ *
20
+ * The Initial Developer of the Original Code is
21
+ * Netscape Communications Corporation.
22
+ * Portions created by the Initial Developer are Copyright (C) 1998
23
+ * the Initial Developer. All Rights Reserved.
24
+ *
25
+ * Contributor(s):
26
+ *
27
+ * Alternatively, the contents of this file may be used under the terms of
28
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
29
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30
+ * in which case the provisions of the GPL or the LGPL are applicable instead
31
+ * of those above. If you wish to allow use of your version of this file only
32
+ * under the terms of either the GPL or the LGPL, and not to allow others to
33
+ * use your version of this file under the terms of the MPL, indicate your
34
+ * decision by deleting the provisions above and replace them with the notice
35
+ * and other provisions required by the GPL or the LGPL. If you do not delete
36
+ * the provisions above, a recipient may use your version of this file under
37
+ * the terms of any one of the MPL, the GPL or the LGPL.
38
+ *
39
+ * ***** END LICENSE BLOCK ***** */
40
+
41
+ #ifndef jsobj_h___
42
+ #define jsobj_h___
43
+ /*
44
+ * JS object definitions.
45
+ *
46
+ * A JS object consists of a possibly-shared object descriptor containing
47
+ * ordered property names, called the map; and a dense vector of property
48
+ * values, called slots. The map/slot pointer pair is GC'ed, while the map
49
+ * is reference counted and the slot vector is malloc'ed.
50
+ */
51
+ #include "jshash.h" /* Added by JSIFY */
52
+ #include "jsprvtd.h"
53
+ #include "jspubtd.h"
54
+
55
+ JS_BEGIN_EXTERN_C
56
+
57
+ struct JSObjectMap {
58
+ jsrefcount nrefs; /* count of all referencing objects */
59
+ JSObjectOps *ops; /* high level object operation vtable */
60
+ uint32 freeslot; /* index of next free slot in object */
61
+ };
62
+
63
+ /* Shorthand macros for frequently-made calls. */
64
+ #define OBJ_LOOKUP_PROPERTY(cx,obj,id,objp,propp) \
65
+ (obj)->map->ops->lookupProperty(cx,obj,id,objp,propp)
66
+ #define OBJ_DEFINE_PROPERTY(cx,obj,id,value,getter,setter,attrs,propp) \
67
+ (obj)->map->ops->defineProperty(cx,obj,id,value,getter,setter,attrs,propp)
68
+ #define OBJ_GET_PROPERTY(cx,obj,id,vp) \
69
+ (obj)->map->ops->getProperty(cx,obj,id,vp)
70
+ #define OBJ_SET_PROPERTY(cx,obj,id,vp) \
71
+ (obj)->map->ops->setProperty(cx,obj,id,vp)
72
+ #define OBJ_GET_ATTRIBUTES(cx,obj,id,prop,attrsp) \
73
+ (obj)->map->ops->getAttributes(cx,obj,id,prop,attrsp)
74
+ #define OBJ_SET_ATTRIBUTES(cx,obj,id,prop,attrsp) \
75
+ (obj)->map->ops->setAttributes(cx,obj,id,prop,attrsp)
76
+ #define OBJ_DELETE_PROPERTY(cx,obj,id,rval) \
77
+ (obj)->map->ops->deleteProperty(cx,obj,id,rval)
78
+ #define OBJ_DEFAULT_VALUE(cx,obj,hint,vp) \
79
+ (obj)->map->ops->defaultValue(cx,obj,hint,vp)
80
+ #define OBJ_ENUMERATE(cx,obj,enum_op,statep,idp) \
81
+ (obj)->map->ops->enumerate(cx,obj,enum_op,statep,idp)
82
+ #define OBJ_CHECK_ACCESS(cx,obj,id,mode,vp,attrsp) \
83
+ (obj)->map->ops->checkAccess(cx,obj,id,mode,vp,attrsp)
84
+
85
+ /* These four are time-optimized to avoid stub calls. */
86
+ #define OBJ_THIS_OBJECT(cx,obj) \
87
+ ((obj)->map->ops->thisObject \
88
+ ? (obj)->map->ops->thisObject(cx,obj) \
89
+ : (obj))
90
+ #define OBJ_DROP_PROPERTY(cx,obj,prop) \
91
+ ((obj)->map->ops->dropProperty \
92
+ ? (obj)->map->ops->dropProperty(cx,obj,prop) \
93
+ : (void)0)
94
+ #define OBJ_GET_REQUIRED_SLOT(cx,obj,slot) \
95
+ ((obj)->map->ops->getRequiredSlot \
96
+ ? (obj)->map->ops->getRequiredSlot(cx, obj, slot) \
97
+ : JSVAL_VOID)
98
+ #define OBJ_SET_REQUIRED_SLOT(cx,obj,slot,v) \
99
+ ((obj)->map->ops->setRequiredSlot \
100
+ ? (obj)->map->ops->setRequiredSlot(cx, obj, slot, v) \
101
+ : JS_TRUE)
102
+
103
+ #define OBJ_TO_INNER_OBJECT(cx,obj) \
104
+ JS_BEGIN_MACRO \
105
+ JSClass *clasp_ = OBJ_GET_CLASS(cx, obj); \
106
+ if (clasp_->flags & JSCLASS_IS_EXTENDED) { \
107
+ JSExtendedClass *xclasp_ = (JSExtendedClass*)clasp_; \
108
+ if (xclasp_->innerObject) \
109
+ obj = xclasp_->innerObject(cx, obj); \
110
+ } \
111
+ JS_END_MACRO
112
+
113
+ #define OBJ_TO_OUTER_OBJECT(cx,obj) \
114
+ JS_BEGIN_MACRO \
115
+ JSClass *clasp_ = OBJ_GET_CLASS(cx, obj); \
116
+ if (clasp_->flags & JSCLASS_IS_EXTENDED) { \
117
+ JSExtendedClass *xclasp_ = (JSExtendedClass*)clasp_; \
118
+ if (xclasp_->outerObject) \
119
+ obj = xclasp_->outerObject(cx, obj); \
120
+ } \
121
+ JS_END_MACRO
122
+
123
+ #define JS_INITIAL_NSLOTS 6
124
+
125
+ /*
126
+ * When JSObject.dslots is not null, JSObject.dslots[-1] records the number of
127
+ * available slots.
128
+ */
129
+ struct JSObject {
130
+ JSObjectMap *map;
131
+ jsval fslots[JS_INITIAL_NSLOTS];
132
+ jsval *dslots; /* dynamically allocated slots */
133
+ };
134
+
135
+ #define JSSLOT_PROTO 0
136
+ #define JSSLOT_PARENT 1
137
+ #define JSSLOT_CLASS 2
138
+ #define JSSLOT_PRIVATE 3
139
+ #define JSSLOT_START(clasp) (((clasp)->flags & JSCLASS_HAS_PRIVATE) \
140
+ ? JSSLOT_PRIVATE + 1 \
141
+ : JSSLOT_CLASS + 1)
142
+
143
+ #define JSSLOT_FREE(clasp) (JSSLOT_START(clasp) \
144
+ + JSCLASS_RESERVED_SLOTS(clasp))
145
+
146
+ /*
147
+ * STOBJ prefix means Single Threaded Object. Use the following fast macros to
148
+ * directly manipulate slots in obj when only one thread can access obj and
149
+ * when obj->map->freeslot can be inconsistent with slots.
150
+ */
151
+
152
+ #define STOBJ_NSLOTS(obj) \
153
+ ((obj)->dslots ? (uint32)(obj)->dslots[-1] : (uint32)JS_INITIAL_NSLOTS)
154
+
155
+ #define STOBJ_GET_SLOT(obj,slot) \
156
+ ((slot) < JS_INITIAL_NSLOTS \
157
+ ? (obj)->fslots[(slot)] \
158
+ : (JS_ASSERT((slot) < (uint32)(obj)->dslots[-1]), \
159
+ (obj)->dslots[(slot) - JS_INITIAL_NSLOTS]))
160
+
161
+ #define STOBJ_SET_SLOT(obj,slot,value) \
162
+ ((slot) < JS_INITIAL_NSLOTS \
163
+ ? (obj)->fslots[(slot)] = (value) \
164
+ : (JS_ASSERT((slot) < (uint32)(obj)->dslots[-1]), \
165
+ (obj)->dslots[(slot) - JS_INITIAL_NSLOTS] = (value)))
166
+
167
+ #define STOBJ_GET_PROTO(obj) \
168
+ JSVAL_TO_OBJECT((obj)->fslots[JSSLOT_PROTO])
169
+ #define STOBJ_SET_PROTO(obj,proto) \
170
+ ((obj)->fslots[JSSLOT_PROTO] = OBJECT_TO_JSVAL(proto))
171
+
172
+ #define STOBJ_GET_PARENT(obj) \
173
+ JSVAL_TO_OBJECT((obj)->fslots[JSSLOT_PARENT])
174
+ #define STOBJ_SET_PARENT(obj,parent) \
175
+ ((obj)->fslots[JSSLOT_PARENT] = OBJECT_TO_JSVAL(parent))
176
+
177
+ /*
178
+ * We use JSSLOT_CLASS to store both JSClass* and the system flag as an int-
179
+ * tagged value (see jsapi.h for details) with the system flag stored in the
180
+ * second lowest bit.
181
+ */
182
+ #define STOBJ_GET_CLASS(obj) ((JSClass *)((obj)->fslots[JSSLOT_CLASS] & ~3))
183
+ #define STOBJ_IS_SYSTEM(obj) (((obj)->fslots[JSSLOT_CLASS] & 2) != 0)
184
+
185
+ #define STOBJ_SET_SYSTEM(obj) ((void)((obj)->fslots[JSSLOT_CLASS] |= 2))
186
+
187
+ #define STOBJ_GET_PRIVATE(obj) \
188
+ (JS_ASSERT(JSVAL_IS_INT(STOBJ_GET_SLOT(obj, JSSLOT_PRIVATE))), \
189
+ JSVAL_TO_PRIVATE(STOBJ_GET_SLOT(obj, JSSLOT_PRIVATE)))
190
+
191
+ #define OBJ_CHECK_SLOT(obj,slot) \
192
+ JS_ASSERT(slot < (obj)->map->freeslot)
193
+
194
+ #define LOCKED_OBJ_GET_SLOT(obj,slot) \
195
+ (OBJ_CHECK_SLOT(obj, slot), STOBJ_GET_SLOT(obj, slot))
196
+ #define LOCKED_OBJ_SET_SLOT(obj,slot,value) \
197
+ (OBJ_CHECK_SLOT(obj, slot), STOBJ_SET_SLOT(obj, slot, value))
198
+
199
+ /*
200
+ * NB: Don't call LOCKED_OBJ_SET_SLOT or STOBJ_SET_SLOT for a write to a slot
201
+ * that may contain a function reference already, or where the new value is a
202
+ * function ref, and the object's scope may be branded with a property cache
203
+ * structural type capability that distinguishes versions of the object with
204
+ * and without the function property. Instead use LOCKED_OBJ_WRITE_BARRIER or
205
+ * a fast inline equivalent (JSOP_SETNAME/JSOP_SETPROP cases in jsinterp.c).
206
+ */
207
+ #define LOCKED_OBJ_WRITE_BARRIER(cx,obj,slot,newval) \
208
+ JS_BEGIN_MACRO \
209
+ JSScope *scope_ = OBJ_SCOPE(obj); \
210
+ JS_ASSERT(scope_->object == (obj)); \
211
+ GC_WRITE_BARRIER(cx, scope_, LOCKED_OBJ_GET_SLOT(obj, slot), newval); \
212
+ LOCKED_OBJ_SET_SLOT(obj, slot, newval); \
213
+ JS_END_MACRO
214
+
215
+ #define LOCKED_OBJ_GET_PROTO(obj) \
216
+ (OBJ_CHECK_SLOT(obj, JSSLOT_PROTO), STOBJ_GET_PROTO(obj))
217
+ #define LOCKED_OBJ_SET_PROTO(obj,proto) \
218
+ (OBJ_CHECK_SLOT(obj, JSSLOT_PROTO), STOBJ_SET_PROTO(obj, proto))
219
+
220
+ #define LOCKED_OBJ_GET_PARENT(obj) \
221
+ (OBJ_CHECK_SLOT(obj, JSSLOT_PARENT), STOBJ_GET_PARENT(obj))
222
+ #define LOCKED_OBJ_SET_PARENT(obj,parent) \
223
+ (OBJ_CHECK_SLOT(obj, JSSLOT_PARENT), STOBJ_SET_PARENT(obj, parent))
224
+
225
+ #define LOCKED_OBJ_GET_CLASS(obj) \
226
+ (OBJ_CHECK_SLOT(obj, JSSLOT_CLASS), STOBJ_GET_CLASS(obj))
227
+
228
+ #define LOCKED_OBJ_GET_PRIVATE(obj) \
229
+ (OBJ_CHECK_SLOT(obj, JSSLOT_PRIVATE), STOBJ_GET_PRIVATE(obj))
230
+
231
+ #ifdef JS_THREADSAFE
232
+
233
+ /* Thread-safe functions and wrapper macros for accessing slots in obj. */
234
+ #define OBJ_GET_SLOT(cx,obj,slot) \
235
+ (OBJ_CHECK_SLOT(obj, slot), \
236
+ (OBJ_IS_NATIVE(obj) && OBJ_SCOPE(obj)->title.ownercx == cx) \
237
+ ? LOCKED_OBJ_GET_SLOT(obj, slot) \
238
+ : js_GetSlotThreadSafe(cx, obj, slot))
239
+
240
+ #define OBJ_SET_SLOT(cx,obj,slot,value) \
241
+ JS_BEGIN_MACRO \
242
+ OBJ_CHECK_SLOT(obj, slot); \
243
+ if (OBJ_IS_NATIVE(obj) && OBJ_SCOPE(obj)->title.ownercx == cx) \
244
+ LOCKED_OBJ_WRITE_BARRIER(cx, obj, slot, value); \
245
+ else \
246
+ js_SetSlotThreadSafe(cx, obj, slot, value); \
247
+ JS_END_MACRO
248
+
249
+ /*
250
+ * If thread-safe, define an OBJ_GET_SLOT wrapper that bypasses, for a native
251
+ * object, the lock-free "fast path" test of (OBJ_SCOPE(obj)->ownercx == cx),
252
+ * to avoid needlessly switching from lock-free to lock-full scope when doing
253
+ * GC on a different context from the last one to own the scope. The caller
254
+ * in this case is probably a JSClass.mark function, e.g., fun_mark, or maybe
255
+ * a finalizer.
256
+ *
257
+ * The GC runs only when all threads except the one on which the GC is active
258
+ * are suspended at GC-safe points, so calling STOBJ_GET_SLOT from the GC's
259
+ * thread is safe when rt->gcRunning is set. See jsgc.c for details.
260
+ */
261
+ #define THREAD_IS_RUNNING_GC(rt, thread) \
262
+ ((rt)->gcRunning && (rt)->gcThread == (thread))
263
+
264
+ #define CX_THREAD_IS_RUNNING_GC(cx) \
265
+ THREAD_IS_RUNNING_GC((cx)->runtime, (cx)->thread)
266
+
267
+ #else /* !JS_THREADSAFE */
268
+
269
+ #define OBJ_GET_SLOT(cx,obj,slot) LOCKED_OBJ_GET_SLOT(obj,slot)
270
+ #define OBJ_SET_SLOT(cx,obj,slot,value) LOCKED_OBJ_WRITE_BARRIER(cx,obj,slot, \
271
+ value)
272
+
273
+ #endif /* !JS_THREADSAFE */
274
+
275
+ /* Thread-safe proto, parent, and class access macros. */
276
+ #define OBJ_GET_PROTO(cx,obj) \
277
+ STOBJ_GET_PROTO(obj)
278
+ #define OBJ_SET_PROTO(cx,obj,proto) \
279
+ STOBJ_SET_SLOT(obj, JSSLOT_PROTO, OBJECT_TO_JSVAL(proto))
280
+
281
+ #define OBJ_GET_PARENT(cx,obj) \
282
+ STOBJ_GET_PARENT(obj)
283
+ #define OBJ_SET_PARENT(cx,obj,parent) \
284
+ STOBJ_SET_SLOT(obj, JSSLOT_PARENT, OBJECT_TO_JSVAL(parent))
285
+
286
+ /*
287
+ * Class is invariant and comes from the fixed JSSLOT_CLASS. Thus no locking
288
+ * is necessary to read it. Same for the private slot.
289
+ */
290
+ #define OBJ_GET_CLASS(cx,obj) STOBJ_GET_CLASS(obj)
291
+ #define OBJ_GET_PRIVATE(cx,obj) STOBJ_GET_PRIVATE(obj)
292
+
293
+ /* Test whether a map or object is native. */
294
+ #define MAP_IS_NATIVE(map) \
295
+ JS_LIKELY((map)->ops == &js_ObjectOps || \
296
+ (map)->ops->newObjectMap == js_ObjectOps.newObjectMap)
297
+
298
+ #define OBJ_IS_NATIVE(obj) MAP_IS_NATIVE((obj)->map)
299
+
300
+ extern JS_FRIEND_DATA(JSObjectOps) js_ObjectOps;
301
+ extern JS_FRIEND_DATA(JSObjectOps) js_WithObjectOps;
302
+ extern JSClass js_ObjectClass;
303
+ extern JSClass js_WithClass;
304
+ extern JSClass js_BlockClass;
305
+
306
+ /*
307
+ * Block scope object macros. The slots reserved by js_BlockClass are:
308
+ *
309
+ * JSSLOT_PRIVATE JSStackFrame * active frame pointer or null
310
+ * JSSLOT_BLOCK_DEPTH int depth of block slots in frame
311
+ *
312
+ * After JSSLOT_BLOCK_DEPTH come one or more slots for the block locals.
313
+ *
314
+ * A With object is like a Block object, in that both have one reserved slot
315
+ * telling the stack depth of the relevant slots (the slot whose value is the
316
+ * object named in the with statement, the slots containing the block's local
317
+ * variables); and both have a private slot referring to the JSStackFrame in
318
+ * whose activation they were created (or null if the with or block object
319
+ * outlives the frame).
320
+ */
321
+ #define JSSLOT_BLOCK_DEPTH (JSSLOT_PRIVATE + 1)
322
+
323
+ #define OBJ_IS_CLONED_BLOCK(obj) \
324
+ (OBJ_SCOPE(obj)->object != (obj))
325
+ #define OBJ_BLOCK_COUNT(cx,obj) \
326
+ (OBJ_SCOPE(obj)->entryCount)
327
+ #define OBJ_BLOCK_DEPTH(cx,obj) \
328
+ JSVAL_TO_INT(STOBJ_GET_SLOT(obj, JSSLOT_BLOCK_DEPTH))
329
+ #define OBJ_SET_BLOCK_DEPTH(cx,obj,depth) \
330
+ STOBJ_SET_SLOT(obj, JSSLOT_BLOCK_DEPTH, INT_TO_JSVAL(depth))
331
+
332
+ /*
333
+ * To make sure this slot is well-defined, always call js_NewWithObject to
334
+ * create a With object, don't call js_NewObject directly. When creating a
335
+ * With object that does not correspond to a stack slot, pass -1 for depth.
336
+ *
337
+ * When popping the stack across this object's "with" statement, client code
338
+ * must call JS_SetPrivate(cx, withobj, NULL).
339
+ */
340
+ extern JSObject *
341
+ js_NewWithObject(JSContext *cx, JSObject *proto, JSObject *parent, jsint depth);
342
+
343
+ /*
344
+ * Create a new block scope object not linked to any proto or parent object.
345
+ * Blocks are created by the compiler to reify let blocks and comprehensions.
346
+ * Only when dynamic scope is captured do they need to be cloned and spliced
347
+ * into an active scope chain.
348
+ */
349
+ extern JSObject *
350
+ js_NewBlockObject(JSContext *cx);
351
+
352
+ extern JSObject *
353
+ js_CloneBlockObject(JSContext *cx, JSObject *proto, JSObject *parent,
354
+ JSStackFrame *fp);
355
+
356
+ extern JSBool
357
+ js_PutBlockObject(JSContext *cx, JSBool normalUnwind);
358
+
359
+ struct JSSharpObjectMap {
360
+ jsrefcount depth;
361
+ jsatomid sharpgen;
362
+ JSHashTable *table;
363
+ };
364
+
365
+ #define SHARP_BIT ((jsatomid) 1)
366
+ #define BUSY_BIT ((jsatomid) 2)
367
+ #define SHARP_ID_SHIFT 2
368
+ #define IS_SHARP(he) (JS_PTR_TO_UINT32((he)->value) & SHARP_BIT)
369
+ #define MAKE_SHARP(he) ((he)->value = JS_UINT32_TO_PTR(JS_PTR_TO_UINT32((he)->value)|SHARP_BIT))
370
+ #define IS_BUSY(he) (JS_PTR_TO_UINT32((he)->value) & BUSY_BIT)
371
+ #define MAKE_BUSY(he) ((he)->value = JS_UINT32_TO_PTR(JS_PTR_TO_UINT32((he)->value)|BUSY_BIT))
372
+ #define CLEAR_BUSY(he) ((he)->value = JS_UINT32_TO_PTR(JS_PTR_TO_UINT32((he)->value)&~BUSY_BIT))
373
+
374
+ extern JSHashEntry *
375
+ js_EnterSharpObject(JSContext *cx, JSObject *obj, JSIdArray **idap,
376
+ jschar **sp);
377
+
378
+ extern void
379
+ js_LeaveSharpObject(JSContext *cx, JSIdArray **idap);
380
+
381
+ /*
382
+ * Mark objects stored in map if GC happens between js_EnterSharpObject
383
+ * and js_LeaveSharpObject. GC calls this when map->depth > 0.
384
+ */
385
+ extern void
386
+ js_TraceSharpMap(JSTracer *trc, JSSharpObjectMap *map);
387
+
388
+ extern JSBool
389
+ js_HasOwnPropertyHelper(JSContext *cx, JSLookupPropOp lookup, jsval *vp);
390
+
391
+ extern JSObject *
392
+ js_InitBlockClass(JSContext *cx, JSObject* obj);
393
+
394
+ extern JSObject *
395
+ js_InitEval(JSContext *cx, JSObject *obj);
396
+
397
+ extern JSObject *
398
+ js_InitObjectClass(JSContext *cx, JSObject *obj);
399
+
400
+ /* Select Object.prototype method names shared between jsapi.c and jsobj.c. */
401
+ extern const char js_watch_str[];
402
+ extern const char js_unwatch_str[];
403
+ extern const char js_hasOwnProperty_str[];
404
+ extern const char js_isPrototypeOf_str[];
405
+ extern const char js_propertyIsEnumerable_str[];
406
+ extern const char js_defineGetter_str[];
407
+ extern const char js_defineSetter_str[];
408
+ extern const char js_lookupGetter_str[];
409
+ extern const char js_lookupSetter_str[];
410
+
411
+ extern void
412
+ js_InitObjectMap(JSObjectMap *map, jsrefcount nrefs, JSObjectOps *ops,
413
+ JSClass *clasp);
414
+
415
+ extern JSObjectMap *
416
+ js_NewObjectMap(JSContext *cx, jsrefcount nrefs, JSObjectOps *ops,
417
+ JSClass *clasp, JSObject *obj);
418
+
419
+ extern void
420
+ js_DestroyObjectMap(JSContext *cx, JSObjectMap *map);
421
+
422
+ extern JSObjectMap *
423
+ js_HoldObjectMap(JSContext *cx, JSObjectMap *map);
424
+
425
+ extern JSObjectMap *
426
+ js_DropObjectMap(JSContext *cx, JSObjectMap *map, JSObject *obj);
427
+
428
+ extern JSBool
429
+ js_GetClassId(JSContext *cx, JSClass *clasp, jsid *idp);
430
+
431
+ extern JSObject *
432
+ js_NewObject(JSContext *cx, JSClass *clasp, JSObject *proto, JSObject *parent,
433
+ uintN objectSize);
434
+
435
+ /*
436
+ * See jsapi.h, JS_NewObjectWithGivenProto.
437
+ *
438
+ * objectSize is either the explicit size for the allocated object or 0
439
+ * indicating to use the default size based on object's class.
440
+ */
441
+ extern JSObject *
442
+ js_NewObjectWithGivenProto(JSContext *cx, JSClass *clasp, JSObject *proto,
443
+ JSObject *parent, uintN objectSize);
444
+
445
+ /*
446
+ * Fast access to immutable standard objects (constructors and prototypes).
447
+ */
448
+ extern JSBool
449
+ js_GetClassObject(JSContext *cx, JSObject *obj, JSProtoKey key,
450
+ JSObject **objp);
451
+
452
+ extern JSBool
453
+ js_SetClassObject(JSContext *cx, JSObject *obj, JSProtoKey key, JSObject *cobj);
454
+
455
+ extern JSBool
456
+ js_FindClassObject(JSContext *cx, JSObject *start, jsid id, jsval *vp);
457
+
458
+ extern JSObject *
459
+ js_ConstructObject(JSContext *cx, JSClass *clasp, JSObject *proto,
460
+ JSObject *parent, uintN argc, jsval *argv);
461
+
462
+ extern void
463
+ js_FinalizeObject(JSContext *cx, JSObject *obj);
464
+
465
+ extern JSBool
466
+ js_AllocSlot(JSContext *cx, JSObject *obj, uint32 *slotp);
467
+
468
+ extern void
469
+ js_FreeSlot(JSContext *cx, JSObject *obj, uint32 slot);
470
+
471
+ /* JSVAL_INT_MAX as a string */
472
+ #define JSVAL_INT_MAX_STRING "1073741823"
473
+
474
+ #define CHECK_FOR_STRING_INDEX(id) \
475
+ JS_BEGIN_MACRO \
476
+ if (JSID_IS_ATOM(id)) { \
477
+ JSAtom *atom_ = JSID_TO_ATOM(id); \
478
+ JSString *str_ = ATOM_TO_STRING(atom_); \
479
+ const jschar *s_ = JSFLATSTR_CHARS(str_); \
480
+ JSBool negative_ = (*s_ == '-'); \
481
+ if (negative_) s_++; \
482
+ if (JS7_ISDEC(*s_)) { \
483
+ size_t n_ = JSFLATSTR_LENGTH(str_) - negative_; \
484
+ if (n_ <= sizeof(JSVAL_INT_MAX_STRING) - 1) \
485
+ id = js_CheckForStringIndex(id, s_, s_ + n_, negative_); \
486
+ } \
487
+ } \
488
+ JS_END_MACRO
489
+
490
+ extern jsid
491
+ js_CheckForStringIndex(jsid id, const jschar *cp, const jschar *end,
492
+ JSBool negative);
493
+
494
+ /*
495
+ * Find or create a property named by id in obj's scope, with the given getter
496
+ * and setter, slot, attributes, and other members.
497
+ */
498
+ extern JSScopeProperty *
499
+ js_AddNativeProperty(JSContext *cx, JSObject *obj, jsid id,
500
+ JSPropertyOp getter, JSPropertyOp setter, uint32 slot,
501
+ uintN attrs, uintN flags, intN shortid);
502
+
503
+ /*
504
+ * Change sprop to have the given attrs, getter, and setter in scope, morphing
505
+ * it into a potentially new JSScopeProperty. Return a pointer to the changed
506
+ * or identical property.
507
+ */
508
+ extern JSScopeProperty *
509
+ js_ChangeNativePropertyAttrs(JSContext *cx, JSObject *obj,
510
+ JSScopeProperty *sprop, uintN attrs, uintN mask,
511
+ JSPropertyOp getter, JSPropertyOp setter);
512
+
513
+ /*
514
+ * On error, return false. On success, if propp is non-null, return true with
515
+ * obj locked and with a held property in *propp; if propp is null, return true
516
+ * but release obj's lock first. Therefore all callers who pass non-null propp
517
+ * result parameters must later call OBJ_DROP_PROPERTY(cx, obj, *propp) both to
518
+ * drop the held property, and to release the lock on obj.
519
+ */
520
+ extern JSBool
521
+ js_DefineProperty(JSContext *cx, JSObject *obj, jsid id, jsval value,
522
+ JSPropertyOp getter, JSPropertyOp setter, uintN attrs,
523
+ JSProperty **propp);
524
+
525
+ extern JSBool
526
+ js_DefineNativeProperty(JSContext *cx, JSObject *obj, jsid id, jsval value,
527
+ JSPropertyOp getter, JSPropertyOp setter, uintN attrs,
528
+ uintN flags, intN shortid, JSProperty **propp);
529
+
530
+ /*
531
+ * Unlike js_DefineProperty, propp must be non-null. On success, and if id was
532
+ * found, return true with *objp non-null and locked, and with a held property
533
+ * stored in *propp. If successful but id was not found, return true with both
534
+ * *objp and *propp null. Therefore all callers who receive a non-null *propp
535
+ * must later call OBJ_DROP_PROPERTY(cx, *objp, *propp).
536
+ */
537
+ extern JS_FRIEND_API(JSBool)
538
+ js_LookupProperty(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
539
+ JSProperty **propp);
540
+
541
+ /*
542
+ * Specialized subroutine that allows caller to preset JSRESOLVE_* flags and
543
+ * returns the index along the prototype chain in which *propp was found, or
544
+ * the last index if not found, or -1 on error.
545
+ */
546
+ extern int
547
+ js_LookupPropertyWithFlags(JSContext *cx, JSObject *obj, jsid id, uintN flags,
548
+ JSObject **objp, JSProperty **propp);
549
+
550
+ extern int
551
+ js_FindPropertyHelper(JSContext *cx, jsid id, JSObject **objp,
552
+ JSObject **pobjp, JSProperty **propp,
553
+ JSPropCacheEntry **entryp);
554
+
555
+ /*
556
+ * Return the index along the scope chain in which id was found, or the last
557
+ * index if not found, or -1 on error.
558
+ */
559
+ extern JS_FRIEND_API(JSBool)
560
+ js_FindProperty(JSContext *cx, jsid id, JSObject **objp, JSObject **pobjp,
561
+ JSProperty **propp);
562
+
563
+ extern JSObject *
564
+ js_FindIdentifierBase(JSContext *cx, jsid id, JSPropCacheEntry *entry);
565
+
566
+ extern JSObject *
567
+ js_FindVariableScope(JSContext *cx, JSFunction **funp);
568
+
569
+ /*
570
+ * NB: js_NativeGet and js_NativeSet are called with the scope containing sprop
571
+ * (pobj's scope for Get, obj's for Set) locked, and on successful return, that
572
+ * scope is again locked. But on failure, both functions return false with the
573
+ * scope containing sprop unlocked.
574
+ */
575
+ extern JSBool
576
+ js_NativeGet(JSContext *cx, JSObject *obj, JSObject *pobj,
577
+ JSScopeProperty *sprop, jsval *vp);
578
+
579
+ extern JSBool
580
+ js_NativeSet(JSContext *cx, JSObject *obj, JSScopeProperty *sprop, jsval *vp);
581
+
582
+ extern JSBool
583
+ js_GetPropertyHelper(JSContext *cx, JSObject *obj, jsid id, jsval *vp,
584
+ JSPropCacheEntry **entryp);
585
+
586
+ extern JSBool
587
+ js_GetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
588
+
589
+ extern JSBool
590
+ js_SetPropertyHelper(JSContext *cx, JSObject *obj, jsid id, jsval *vp,
591
+ JSPropCacheEntry **entryp);
592
+
593
+ extern JSBool
594
+ js_SetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
595
+
596
+ extern JSBool
597
+ js_GetAttributes(JSContext *cx, JSObject *obj, jsid id, JSProperty *prop,
598
+ uintN *attrsp);
599
+
600
+ extern JSBool
601
+ js_SetAttributes(JSContext *cx, JSObject *obj, jsid id, JSProperty *prop,
602
+ uintN *attrsp);
603
+
604
+ extern JSBool
605
+ js_DeleteProperty(JSContext *cx, JSObject *obj, jsid id, jsval *rval);
606
+
607
+ extern JSBool
608
+ js_DefaultValue(JSContext *cx, JSObject *obj, JSType hint, jsval *vp);
609
+
610
+ extern JSIdArray *
611
+ js_NewIdArray(JSContext *cx, jsint length);
612
+
613
+ /*
614
+ * Unlike realloc(3), this function frees ida on failure.
615
+ */
616
+ extern JSIdArray *
617
+ js_SetIdArrayLength(JSContext *cx, JSIdArray *ida, jsint length);
618
+
619
+ extern JSBool
620
+ js_Enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
621
+ jsval *statep, jsid *idp);
622
+
623
+ extern void
624
+ js_TraceNativeIteratorStates(JSTracer *trc);
625
+
626
+ extern JSBool
627
+ js_CheckAccess(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode,
628
+ jsval *vp, uintN *attrsp);
629
+
630
+ extern JSBool
631
+ js_Call(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
632
+
633
+ extern JSBool
634
+ js_Construct(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
635
+ jsval *rval);
636
+
637
+ extern JSBool
638
+ js_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp);
639
+
640
+ extern JSBool
641
+ js_SetProtoOrParent(JSContext *cx, JSObject *obj, uint32 slot, JSObject *pobj);
642
+
643
+ extern JSBool
644
+ js_IsDelegate(JSContext *cx, JSObject *obj, jsval v, JSBool *bp);
645
+
646
+ extern JSBool
647
+ js_GetClassPrototype(JSContext *cx, JSObject *scope, jsid id,
648
+ JSObject **protop);
649
+
650
+ extern JSBool
651
+ js_SetClassPrototype(JSContext *cx, JSObject *ctor, JSObject *proto,
652
+ uintN attrs);
653
+
654
+ /*
655
+ * Wrap boolean, number or string as Boolean, Number or String object.
656
+ * *vp must not be an object, null or undefined.
657
+ */
658
+ extern JSBool
659
+ js_PrimitiveToObject(JSContext *cx, jsval *vp);
660
+
661
+ extern JSBool
662
+ js_ValueToObject(JSContext *cx, jsval v, JSObject **objp);
663
+
664
+ extern JSObject *
665
+ js_ValueToNonNullObject(JSContext *cx, jsval v);
666
+
667
+ extern JSBool
668
+ js_TryValueOf(JSContext *cx, JSObject *obj, JSType type, jsval *rval);
669
+
670
+ extern JSBool
671
+ js_TryMethod(JSContext *cx, JSObject *obj, JSAtom *atom,
672
+ uintN argc, jsval *argv, jsval *rval);
673
+
674
+ extern JSBool
675
+ js_XDRObject(JSXDRState *xdr, JSObject **objp);
676
+
677
+ extern void
678
+ js_TraceObject(JSTracer *trc, JSObject *obj);
679
+
680
+ extern void
681
+ js_PrintObjectSlotName(JSTracer *trc, char *buf, size_t bufsize);
682
+
683
+ extern void
684
+ js_Clear(JSContext *cx, JSObject *obj);
685
+
686
+ extern jsval
687
+ js_GetRequiredSlot(JSContext *cx, JSObject *obj, uint32 slot);
688
+
689
+ extern JSBool
690
+ js_SetRequiredSlot(JSContext *cx, JSObject *obj, uint32 slot, jsval v);
691
+
692
+ extern JSObject *
693
+ js_CheckScopeChainValidity(JSContext *cx, JSObject *scopeobj, const char *caller);
694
+
695
+ extern JSBool
696
+ js_CheckPrincipalsAccess(JSContext *cx, JSObject *scopeobj,
697
+ JSPrincipals *principals, JSAtom *caller);
698
+
699
+ /* Infallible -- returns its argument if there is no wrapped object. */
700
+ extern JSObject *
701
+ js_GetWrappedObject(JSContext *cx, JSObject *obj);
702
+
703
+ /* NB: Infallible. */
704
+ extern const char *
705
+ js_ComputeFilename(JSContext *cx, JSStackFrame *caller,
706
+ JSPrincipals *principals, uintN *linenop);
707
+ JS_END_EXTERN_C
708
+
709
+ #endif /* jsobj_h___ */