johnson 1.2.0 → 2.0.0.pre0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (782) hide show
  1. data/CHANGELOG.rdoc +8 -0
  2. data/Manifest.txt +762 -48
  3. data/README.rdoc +2 -1
  4. data/Rakefile +90 -18
  5. data/ext/spidermonkey/conversions.c +9 -2
  6. data/ext/spidermonkey/ruby_land_proxy.c +1 -1
  7. data/ext/spidermonkey/runtime.h +1 -1
  8. data/ext/tracemonkey/context.cc +125 -0
  9. data/ext/tracemonkey/context.h +19 -0
  10. data/ext/tracemonkey/conversions.cc +365 -0
  11. data/ext/tracemonkey/conversions.h +32 -0
  12. data/ext/tracemonkey/debugger.cc +234 -0
  13. data/ext/tracemonkey/debugger.h +10 -0
  14. data/ext/tracemonkey/extconf.rb +37 -0
  15. data/ext/tracemonkey/extensions.cc +37 -0
  16. data/ext/tracemonkey/extensions.h +12 -0
  17. data/ext/tracemonkey/global.cc +40 -0
  18. data/ext/tracemonkey/global.h +11 -0
  19. data/ext/tracemonkey/idhash.cc +16 -0
  20. data/ext/tracemonkey/idhash.h +8 -0
  21. data/ext/tracemonkey/immutable_node.cc +1199 -0
  22. data/ext/tracemonkey/immutable_node.cc.erb +559 -0
  23. data/ext/tracemonkey/immutable_node.h +22 -0
  24. data/ext/tracemonkey/jroot.h +215 -0
  25. data/ext/tracemonkey/js_land_proxy.cc +620 -0
  26. data/ext/tracemonkey/js_land_proxy.h +20 -0
  27. data/ext/tracemonkey/ruby_land_proxy.cc +618 -0
  28. data/ext/tracemonkey/ruby_land_proxy.h +38 -0
  29. data/ext/tracemonkey/runtime.cc +454 -0
  30. data/ext/tracemonkey/runtime.h +27 -0
  31. data/ext/tracemonkey/split_global.cc +392 -0
  32. data/ext/tracemonkey/split_global.h +11 -0
  33. data/ext/tracemonkey/tracemonkey.cc +23 -0
  34. data/ext/tracemonkey/tracemonkey.h +32 -0
  35. data/lib/johnson.rb +12 -4
  36. data/lib/johnson/error.rb +5 -0
  37. data/lib/johnson/js/prelude.js +16 -1
  38. data/lib/johnson/parser.rb +2 -1
  39. data/lib/johnson/runtime.rb +87 -26
  40. data/lib/johnson/spidermonkey/runtime.rb +7 -16
  41. data/lib/johnson/tracemonkey.rb +13 -0
  42. data/lib/johnson/tracemonkey/context.rb +10 -0
  43. data/lib/johnson/tracemonkey/debugger.rb +67 -0
  44. data/lib/johnson/tracemonkey/immutable_node.rb +282 -0
  45. data/lib/johnson/tracemonkey/js_land_proxy.rb +64 -0
  46. data/lib/johnson/tracemonkey/mutable_tree_visitor.rb +242 -0
  47. data/lib/johnson/tracemonkey/ruby_land_proxy.rb +17 -0
  48. data/lib/johnson/tracemonkey/runtime.rb +80 -0
  49. data/test/{johnson_test.rb → generic/johnson_test.rb} +1 -1
  50. data/test/{parser_test.rb → generic/parser_test.rb} +1 -1
  51. data/test/helper.rb +23 -4
  52. data/test/johnson/{browser_test.rb → generic/browser_test.rb} +1 -1
  53. data/test/johnson/{conversions → generic/conversions}/array_test.rb +1 -1
  54. data/test/johnson/{conversions → generic/conversions}/boolean_test.rb +1 -1
  55. data/test/johnson/{conversions → generic/conversions}/callable_test.rb +1 -1
  56. data/test/johnson/{conversions → generic/conversions}/file_test.rb +1 -1
  57. data/test/johnson/generic/conversions/helper.rb +1 -0
  58. data/test/johnson/{conversions → generic/conversions}/nil_test.rb +1 -1
  59. data/test/johnson/{conversions → generic/conversions}/number_test.rb +1 -1
  60. data/test/johnson/{conversions → generic/conversions}/regexp_test.rb +1 -1
  61. data/test/johnson/{conversions → generic/conversions}/string_test.rb +1 -1
  62. data/test/johnson/{conversions → generic/conversions}/struct_test.rb +1 -1
  63. data/test/johnson/{conversions → generic/conversions}/symbol_test.rb +1 -1
  64. data/test/johnson/{conversions → generic/conversions}/thread_test.rb +1 -1
  65. data/test/johnson/{custom_conversions_test.rb → generic/custom_conversions_test.rb} +1 -1
  66. data/test/johnson/generic/default_test.rb +12 -0
  67. data/test/johnson/{error_test.rb → generic/error_test.rb} +1 -1
  68. data/test/johnson/{extensions_test.rb → generic/extensions_test.rb} +1 -1
  69. data/test/johnson/generic/helper.rb +1 -0
  70. data/test/johnson/{nodes → generic/nodes}/array_literal_test.rb +1 -1
  71. data/test/johnson/{nodes → generic/nodes}/array_node_test.rb +1 -1
  72. data/test/johnson/{nodes → generic/nodes}/binary_node_test.rb +1 -1
  73. data/test/johnson/{nodes → generic/nodes}/bracket_access_test.rb +1 -1
  74. data/test/johnson/{nodes → generic/nodes}/delete_test.rb +1 -1
  75. data/test/johnson/{nodes → generic/nodes}/do_while_test.rb +1 -1
  76. data/test/johnson/{nodes → generic/nodes}/dot_accessor_test.rb +1 -1
  77. data/test/johnson/generic/nodes/export_test.rb +11 -0
  78. data/test/johnson/{nodes → generic/nodes}/for_test.rb +1 -1
  79. data/test/johnson/{nodes → generic/nodes}/function_test.rb +1 -1
  80. data/test/johnson/generic/nodes/helper.rb +1 -0
  81. data/test/johnson/{nodes → generic/nodes}/if_test.rb +16 -6
  82. data/test/johnson/generic/nodes/import_test.rb +15 -0
  83. data/test/johnson/{nodes → generic/nodes}/label_test.rb +1 -1
  84. data/test/johnson/{nodes → generic/nodes}/let_test.rb +1 -1
  85. data/test/johnson/{nodes → generic/nodes}/object_literal_test.rb +1 -1
  86. data/test/johnson/{nodes → generic/nodes}/return_test.rb +1 -1
  87. data/test/johnson/{nodes → generic/nodes}/semi_test.rb +1 -1
  88. data/test/johnson/{nodes → generic/nodes}/switch_test.rb +1 -1
  89. data/test/johnson/{nodes → generic/nodes}/ternary_test.rb +1 -1
  90. data/test/johnson/{nodes → generic/nodes}/throw_test.rb +1 -1
  91. data/test/johnson/{nodes → generic/nodes}/try_node_test.rb +36 -6
  92. data/test/johnson/{nodes → generic/nodes}/typeof_test.rb +1 -1
  93. data/test/johnson/{nodes → generic/nodes}/unary_node_test.rb +1 -1
  94. data/test/johnson/{nodes → generic/nodes}/void_test.rb +1 -1
  95. data/test/johnson/{nodes → generic/nodes}/while_test.rb +1 -1
  96. data/test/johnson/{nodes → generic/nodes}/with_test.rb +1 -1
  97. data/test/johnson/{prelude_test.rb → generic/prelude_test.rb} +1 -1
  98. data/test/johnson/{runtime_test.rb → generic/runtime_test.rb} +3 -6
  99. data/test/johnson/generic/version_test.rb +13 -0
  100. data/test/johnson/{visitors → generic/visitors}/dot_visitor_test.rb +1 -1
  101. data/test/johnson/{visitors → generic/visitors}/enumerating_visitor_test.rb +1 -1
  102. data/test/johnson/generic/visitors/helper.rb +1 -0
  103. data/test/johnson/spidermonkey/js_land_proxy_test.rb +1 -5
  104. data/test/johnson/spidermonkey/ruby_land_proxy_test.rb +11 -7
  105. data/test/johnson/tracemonkey/context_test.rb +21 -0
  106. data/test/johnson/tracemonkey/immutable_node_test.rb +34 -0
  107. data/test/johnson/tracemonkey/js_land_proxy_test.rb +273 -0
  108. data/test/johnson/tracemonkey/ruby_land_proxy_test.rb +274 -0
  109. data/test/johnson/tracemonkey/runtime_test.rb +41 -0
  110. data/test/johnson/tracemonkey/split_global_test.rb +32 -0
  111. data/vendor/spidermonkey/js.pkg +2 -0
  112. data/vendor/tracemonkey/Makefile.in +668 -0
  113. data/vendor/tracemonkey/Makefile.ref +483 -0
  114. data/vendor/tracemonkey/README.html +54 -0
  115. data/vendor/tracemonkey/SpiderMonkey.rsp +11 -0
  116. data/vendor/tracemonkey/Y.js +19 -0
  117. data/vendor/tracemonkey/aclocal.m4 +9 -0
  118. data/vendor/tracemonkey/bench.sh +5 -0
  119. data/vendor/tracemonkey/build/autoconf/acoutput-fast.pl +202 -0
  120. data/vendor/tracemonkey/build/autoconf/altoptions.m4 +154 -0
  121. data/vendor/tracemonkey/build/autoconf/config.guess +1537 -0
  122. data/vendor/tracemonkey/build/autoconf/config.sub +1595 -0
  123. data/vendor/tracemonkey/build/autoconf/install-sh +119 -0
  124. data/vendor/tracemonkey/build/autoconf/make-makefile +315 -0
  125. data/vendor/tracemonkey/build/autoconf/match-dir.sh +101 -0
  126. data/vendor/tracemonkey/build/autoconf/moznbytetype.m4 +136 -0
  127. data/vendor/tracemonkey/build/autoconf/nspr.m4 +82 -0
  128. data/vendor/tracemonkey/build/autoconf/pkg.m4 +59 -0
  129. data/vendor/tracemonkey/build/autoconf/update-makefile.sh +118 -0
  130. data/vendor/tracemonkey/build/cygwin-wrapper +75 -0
  131. data/vendor/tracemonkey/build/hcc +111 -0
  132. data/vendor/tracemonkey/build/hcpp +155 -0
  133. data/vendor/tracemonkey/build/unix/mddepend.pl +165 -0
  134. data/vendor/tracemonkey/build/unix/uniq.pl +63 -0
  135. data/vendor/tracemonkey/build/win32/pgomerge.py +40 -0
  136. data/vendor/tracemonkey/builtins.tbl +91 -0
  137. data/vendor/tracemonkey/call.js +13 -0
  138. data/vendor/tracemonkey/config.mk +206 -0
  139. data/vendor/tracemonkey/config/Makefile.in +106 -0
  140. data/vendor/tracemonkey/config/Moz/Milestone.pm +232 -0
  141. data/vendor/tracemonkey/config/autoconf.mk.in +362 -0
  142. data/vendor/tracemonkey/config/check-sync-dirs.py +103 -0
  143. data/vendor/tracemonkey/config/check-sync-exceptions +7 -0
  144. data/vendor/tracemonkey/config/config.mk +881 -0
  145. data/vendor/tracemonkey/config/fastcwd.pl +66 -0
  146. data/vendor/tracemonkey/config/gcc_hidden.h +2 -0
  147. data/vendor/tracemonkey/config/insure.mk +53 -0
  148. data/vendor/tracemonkey/config/make-system-wrappers.pl +59 -0
  149. data/vendor/tracemonkey/config/milestone.pl +112 -0
  150. data/vendor/tracemonkey/config/milestone.txt +13 -0
  151. data/vendor/tracemonkey/config/mkdepend/Makefile.in +84 -0
  152. data/vendor/tracemonkey/config/mkdepend/cppsetup.c +233 -0
  153. data/vendor/tracemonkey/config/mkdepend/def.h +184 -0
  154. data/vendor/tracemonkey/config/mkdepend/ifparser.c +551 -0
  155. data/vendor/tracemonkey/config/mkdepend/ifparser.h +83 -0
  156. data/vendor/tracemonkey/config/mkdepend/imakemdep.h +733 -0
  157. data/vendor/tracemonkey/config/mkdepend/include.c +337 -0
  158. data/vendor/tracemonkey/config/mkdepend/main.c +860 -0
  159. data/vendor/tracemonkey/config/mkdepend/mkdepend.man +382 -0
  160. data/vendor/tracemonkey/config/mkdepend/parse.c +686 -0
  161. data/vendor/tracemonkey/config/mkdepend/pr.c +124 -0
  162. data/vendor/tracemonkey/config/nfspwd.pl +50 -0
  163. data/vendor/tracemonkey/config/nsinstall.c +481 -0
  164. data/vendor/tracemonkey/config/nsinstall.py +155 -0
  165. data/vendor/tracemonkey/config/pathsub.c +247 -0
  166. data/vendor/tracemonkey/config/pathsub.h +74 -0
  167. data/vendor/tracemonkey/config/preprocessor.pl +671 -0
  168. data/vendor/tracemonkey/config/revdepth-nt.pl +48 -0
  169. data/vendor/tracemonkey/config/revdepth.pl +51 -0
  170. data/vendor/tracemonkey/config/rules.mk +2310 -0
  171. data/vendor/tracemonkey/config/static-checking-config.mk +21 -0
  172. data/vendor/tracemonkey/config/static-checking.js +92 -0
  173. data/vendor/tracemonkey/config/string-format.js +61 -0
  174. data/vendor/tracemonkey/config/system-headers +1035 -0
  175. data/vendor/tracemonkey/config/version.mk +85 -0
  176. data/vendor/tracemonkey/config/version_win.pl +442 -0
  177. data/vendor/tracemonkey/configure +14183 -0
  178. data/vendor/tracemonkey/configure.in +5363 -0
  179. data/vendor/tracemonkey/correct.sh +23 -0
  180. data/vendor/tracemonkey/correct/check-3d-morph.js +55 -0
  181. data/vendor/tracemonkey/correct/check-3d-raytrace.js +445 -0
  182. data/vendor/tracemonkey/correct/check-access-binary-trees.js +52 -0
  183. data/vendor/tracemonkey/correct/check-access-fannkuch.js +66 -0
  184. data/vendor/tracemonkey/correct/check-access-nbody.js +171 -0
  185. data/vendor/tracemonkey/correct/check-access-nsieve.js +40 -0
  186. data/vendor/tracemonkey/correct/check-bitops-3bit-bits-in-byte.js +35 -0
  187. data/vendor/tracemonkey/correct/check-bitops-bits-in-byte.js +24 -0
  188. data/vendor/tracemonkey/correct/check-bitops-bitwise-and.js +29 -0
  189. data/vendor/tracemonkey/correct/check-bitops-nsieve-bits.js +40 -0
  190. data/vendor/tracemonkey/correct/check-controlflow-recursive.js +27 -0
  191. data/vendor/tracemonkey/correct/check-date-format-tofte.js +302 -0
  192. data/vendor/tracemonkey/correct/check-date-format-xparb.js +421 -0
  193. data/vendor/tracemonkey/correct/check-mont.js +119 -0
  194. data/vendor/tracemonkey/dtoa.c +3335 -0
  195. data/vendor/tracemonkey/editline/Makefile.in +55 -0
  196. data/vendor/tracemonkey/editline/Makefile.ref +143 -0
  197. data/vendor/tracemonkey/editline/README +83 -0
  198. data/vendor/tracemonkey/editline/editline.3 +175 -0
  199. data/vendor/tracemonkey/editline/editline.c +1371 -0
  200. data/vendor/tracemonkey/editline/editline.h +135 -0
  201. data/vendor/tracemonkey/editline/sysunix.c +182 -0
  202. data/vendor/tracemonkey/editline/unix.h +82 -0
  203. data/vendor/tracemonkey/if.js +13 -0
  204. data/vendor/tracemonkey/imacro_asm.js.in +396 -0
  205. data/vendor/tracemonkey/imacros.c.out +1034 -0
  206. data/vendor/tracemonkey/imacros.jsasm +770 -0
  207. data/vendor/tracemonkey/javascript-trace.d +73 -0
  208. data/vendor/tracemonkey/jitstats.tbl +55 -0
  209. data/vendor/tracemonkey/js-config.h.in +82 -0
  210. data/vendor/tracemonkey/js-config.in +111 -0
  211. data/vendor/tracemonkey/js.mdp +0 -0
  212. data/vendor/tracemonkey/js.msg +312 -0
  213. data/vendor/tracemonkey/js3240.rc +79 -0
  214. data/vendor/tracemonkey/jsOS240.def +654 -0
  215. data/vendor/tracemonkey/jsapi.cpp +6005 -0
  216. data/vendor/tracemonkey/jsapi.h +2727 -0
  217. data/vendor/tracemonkey/jsarena.cpp +450 -0
  218. data/vendor/tracemonkey/jsarena.h +318 -0
  219. data/vendor/tracemonkey/jsarray.cpp +3664 -0
  220. data/vendor/tracemonkey/jsarray.h +238 -0
  221. data/vendor/tracemonkey/jsatom.cpp +1244 -0
  222. data/vendor/tracemonkey/jsatom.h +493 -0
  223. data/vendor/tracemonkey/jsbit.h +249 -0
  224. data/vendor/tracemonkey/jsbool.cpp +184 -0
  225. data/vendor/tracemonkey/jsbool.h +88 -0
  226. data/vendor/tracemonkey/jsbuiltins.cpp +415 -0
  227. data/vendor/tracemonkey/jsbuiltins.h +456 -0
  228. data/vendor/tracemonkey/jsclist.h +139 -0
  229. data/vendor/tracemonkey/jscntxt.cpp +1816 -0
  230. data/vendor/tracemonkey/jscntxt.h +1541 -0
  231. data/vendor/tracemonkey/jscompat.h +57 -0
  232. data/vendor/tracemonkey/jsconfig.mk +181 -0
  233. data/vendor/tracemonkey/jscpucfg.cpp +194 -0
  234. data/vendor/tracemonkey/jscpucfg.h +91 -0
  235. data/vendor/tracemonkey/jsdate.cpp +2465 -0
  236. data/vendor/tracemonkey/jsdate.h +129 -0
  237. data/vendor/tracemonkey/jsdbgapi.cpp +2017 -0
  238. data/vendor/tracemonkey/jsdbgapi.h +500 -0
  239. data/vendor/tracemonkey/jsdhash.cpp +876 -0
  240. data/vendor/tracemonkey/jsdhash.h +588 -0
  241. data/vendor/tracemonkey/jsdtoa.cpp +572 -0
  242. data/vendor/tracemonkey/jsdtoa.h +131 -0
  243. data/vendor/tracemonkey/jsdtracef.c +318 -0
  244. data/vendor/tracemonkey/jsdtracef.h +81 -0
  245. data/vendor/tracemonkey/jsemit.cpp +7292 -0
  246. data/vendor/tracemonkey/jsemit.h +802 -0
  247. data/vendor/tracemonkey/jsexn.cpp +1337 -0
  248. data/vendor/tracemonkey/jsexn.h +96 -0
  249. data/vendor/tracemonkey/jsfile.cpp +2747 -0
  250. data/vendor/tracemonkey/jsfile.h +56 -0
  251. data/vendor/tracemonkey/jsfile.msg +90 -0
  252. data/vendor/tracemonkey/jsfun.cpp +3089 -0
  253. data/vendor/tracemonkey/jsfun.h +366 -0
  254. data/vendor/tracemonkey/jsgc.cpp +3816 -0
  255. data/vendor/tracemonkey/jsgc.h +429 -0
  256. data/vendor/tracemonkey/jshash.cpp +477 -0
  257. data/vendor/tracemonkey/jshash.h +151 -0
  258. data/vendor/tracemonkey/jsify.pl +483 -0
  259. data/vendor/tracemonkey/jsinterp.cpp +7441 -0
  260. data/vendor/tracemonkey/jsinterp.h +666 -0
  261. data/vendor/tracemonkey/jsinvoke.cpp +42 -0
  262. data/vendor/tracemonkey/jsiter.cpp +1040 -0
  263. data/vendor/tracemonkey/jsiter.h +140 -0
  264. data/vendor/tracemonkey/jskeyword.tbl +124 -0
  265. data/vendor/tracemonkey/jskwgen.cpp +460 -0
  266. data/vendor/tracemonkey/jslibmath.h +69 -0
  267. data/vendor/tracemonkey/jslock.cpp +1512 -0
  268. data/vendor/tracemonkey/jslock.h +325 -0
  269. data/vendor/tracemonkey/jslocko.asm +60 -0
  270. data/vendor/tracemonkey/jslog2.cpp +111 -0
  271. data/vendor/tracemonkey/jslong.h +167 -0
  272. data/vendor/tracemonkey/jsmath.cpp +806 -0
  273. data/vendor/tracemonkey/jsmath.h +63 -0
  274. data/vendor/tracemonkey/jsnum.cpp +1374 -0
  275. data/vendor/tracemonkey/jsnum.h +280 -0
  276. data/vendor/tracemonkey/jsobj.cpp +6165 -0
  277. data/vendor/tracemonkey/jsobj.h +870 -0
  278. data/vendor/tracemonkey/json.cpp +1338 -0
  279. data/vendor/tracemonkey/json.h +108 -0
  280. data/vendor/tracemonkey/jsopcode.cpp +5484 -0
  281. data/vendor/tracemonkey/jsopcode.h +434 -0
  282. data/vendor/tracemonkey/jsopcode.tbl +591 -0
  283. data/vendor/tracemonkey/jsoplengen.cpp +121 -0
  284. data/vendor/tracemonkey/jsotypes.h +202 -0
  285. data/vendor/tracemonkey/jsparse.cpp +9257 -0
  286. data/vendor/tracemonkey/jsparse.h +900 -0
  287. data/vendor/tracemonkey/jsprf.cpp +1262 -0
  288. data/vendor/tracemonkey/jsprf.h +150 -0
  289. data/vendor/tracemonkey/jsproto.tbl +117 -0
  290. data/vendor/tracemonkey/jsprvtd.h +366 -0
  291. data/vendor/tracemonkey/jspubtd.h +585 -0
  292. data/vendor/tracemonkey/jsregexp.cpp +5051 -0
  293. data/vendor/tracemonkey/jsregexp.h +199 -0
  294. data/vendor/tracemonkey/jsreops.tbl +145 -0
  295. data/vendor/tracemonkey/jsscan.cpp +2040 -0
  296. data/vendor/tracemonkey/jsscan.h +467 -0
  297. data/vendor/tracemonkey/jsscope.cpp +1966 -0
  298. data/vendor/tracemonkey/jsscope.h +487 -0
  299. data/vendor/tracemonkey/jsscript.cpp +1932 -0
  300. data/vendor/tracemonkey/jsscript.h +345 -0
  301. data/vendor/tracemonkey/jsshell.msg +54 -0
  302. data/vendor/tracemonkey/jsstack.js +167 -0
  303. data/vendor/tracemonkey/jsstaticcheck.h +69 -0
  304. data/vendor/tracemonkey/jsstddef.h +87 -0
  305. data/vendor/tracemonkey/jsstdint.h +96 -0
  306. data/vendor/tracemonkey/jsstr.cpp +5277 -0
  307. data/vendor/tracemonkey/jsstr.h +702 -0
  308. data/vendor/tracemonkey/jstracer.cpp +10991 -0
  309. data/vendor/tracemonkey/jstracer.h +794 -0
  310. data/vendor/tracemonkey/jstypes.h +481 -0
  311. data/vendor/tracemonkey/jsutil.cpp +361 -0
  312. data/vendor/tracemonkey/jsutil.h +178 -0
  313. data/vendor/tracemonkey/jsversion.h +243 -0
  314. data/vendor/tracemonkey/jswince.asm +44 -0
  315. data/vendor/tracemonkey/jsxdrapi.cpp +800 -0
  316. data/vendor/tracemonkey/jsxdrapi.h +220 -0
  317. data/vendor/tracemonkey/jsxml.cpp +8327 -0
  318. data/vendor/tracemonkey/jsxml.h +305 -0
  319. data/vendor/tracemonkey/liveconnect/LiveConnect.dsp +157 -0
  320. data/vendor/tracemonkey/liveconnect/LiveConnectShell.dsp +120 -0
  321. data/vendor/tracemonkey/liveconnect/LiveConnectShell.dsw +44 -0
  322. data/vendor/tracemonkey/liveconnect/Makefile.in +105 -0
  323. data/vendor/tracemonkey/liveconnect/Makefile.ref +169 -0
  324. data/vendor/tracemonkey/liveconnect/README.html +712 -0
  325. data/vendor/tracemonkey/liveconnect/_jni/netscape_javascript_JSException.h +14 -0
  326. data/vendor/tracemonkey/liveconnect/_jni/netscape_javascript_JSObject.h +155 -0
  327. data/vendor/tracemonkey/liveconnect/classes/Makefile.in +89 -0
  328. data/vendor/tracemonkey/liveconnect/classes/Makefile.ref +57 -0
  329. data/vendor/tracemonkey/liveconnect/classes/netscape/Makefile.ref +47 -0
  330. data/vendor/tracemonkey/liveconnect/classes/netscape/javascript/JSException.java +140 -0
  331. data/vendor/tracemonkey/liveconnect/classes/netscape/javascript/JSObject.java +183 -0
  332. data/vendor/tracemonkey/liveconnect/classes/netscape/javascript/JSProxy.java +58 -0
  333. data/vendor/tracemonkey/liveconnect/classes/netscape/javascript/JSRunnable.java +70 -0
  334. data/vendor/tracemonkey/liveconnect/classes/netscape/javascript/JSUtil.java +59 -0
  335. data/vendor/tracemonkey/liveconnect/classes/netscape/javascript/Makefile.ref +53 -0
  336. data/vendor/tracemonkey/liveconnect/config/AIX4.1.mk +45 -0
  337. data/vendor/tracemonkey/liveconnect/config/AIX4.2.mk +45 -0
  338. data/vendor/tracemonkey/liveconnect/config/AIX4.3.mk +50 -0
  339. data/vendor/tracemonkey/liveconnect/config/HP-UXB.10.10.mk +43 -0
  340. data/vendor/tracemonkey/liveconnect/config/HP-UXB.10.20.mk +43 -0
  341. data/vendor/tracemonkey/liveconnect/config/HP-UXB.11.00.mk +43 -0
  342. data/vendor/tracemonkey/liveconnect/config/IRIX6.2.mk +43 -0
  343. data/vendor/tracemonkey/liveconnect/config/IRIX6.3.mk +43 -0
  344. data/vendor/tracemonkey/liveconnect/config/IRIX6.5.mk +43 -0
  345. data/vendor/tracemonkey/liveconnect/config/Linux_All.mk +73 -0
  346. data/vendor/tracemonkey/liveconnect/config/OSF1V4.0.mk +65 -0
  347. data/vendor/tracemonkey/liveconnect/config/OSF1V5.0.mk +62 -0
  348. data/vendor/tracemonkey/liveconnect/config/SunOS5.5.1.mk +55 -0
  349. data/vendor/tracemonkey/liveconnect/config/SunOS5.6.mk +39 -0
  350. data/vendor/tracemonkey/liveconnect/config/SunOS5.7.mk +39 -0
  351. data/vendor/tracemonkey/liveconnect/config/SunOS5.8.mk +39 -0
  352. data/vendor/tracemonkey/liveconnect/config/WINNT4.0.mk +53 -0
  353. data/vendor/tracemonkey/liveconnect/jsj.c +886 -0
  354. data/vendor/tracemonkey/liveconnect/jsj.msg +98 -0
  355. data/vendor/tracemonkey/liveconnect/jsj_JSObject.c +1377 -0
  356. data/vendor/tracemonkey/liveconnect/jsj_JavaArray.c +474 -0
  357. data/vendor/tracemonkey/liveconnect/jsj_JavaClass.c +737 -0
  358. data/vendor/tracemonkey/liveconnect/jsj_JavaMember.c +191 -0
  359. data/vendor/tracemonkey/liveconnect/jsj_JavaObject.c +1079 -0
  360. data/vendor/tracemonkey/liveconnect/jsj_JavaPackage.c +569 -0
  361. data/vendor/tracemonkey/liveconnect/jsj_array.c +207 -0
  362. data/vendor/tracemonkey/liveconnect/jsj_class.c +770 -0
  363. data/vendor/tracemonkey/liveconnect/jsj_convert.c +902 -0
  364. data/vendor/tracemonkey/liveconnect/jsj_field.c +421 -0
  365. data/vendor/tracemonkey/liveconnect/jsj_hash.c +488 -0
  366. data/vendor/tracemonkey/liveconnect/jsj_hash.h +161 -0
  367. data/vendor/tracemonkey/liveconnect/jsj_method.c +1825 -0
  368. data/vendor/tracemonkey/liveconnect/jsj_nodl.c +1 -0
  369. data/vendor/tracemonkey/liveconnect/jsj_private.h +677 -0
  370. data/vendor/tracemonkey/liveconnect/jsj_simpleapi.c +219 -0
  371. data/vendor/tracemonkey/liveconnect/jsj_utils.c +513 -0
  372. data/vendor/tracemonkey/liveconnect/jsjava.h +316 -0
  373. data/vendor/tracemonkey/liveconnect/netscape_javascript_JSObject.h +155 -0
  374. data/vendor/tracemonkey/liveconnect/nsCLiveconnect.cpp +785 -0
  375. data/vendor/tracemonkey/liveconnect/nsCLiveconnect.h +197 -0
  376. data/vendor/tracemonkey/liveconnect/nsCLiveconnectFactory.cpp +118 -0
  377. data/vendor/tracemonkey/liveconnect/nsCLiveconnectFactory.h +76 -0
  378. data/vendor/tracemonkey/liveconnect/nsILiveconnect.h +197 -0
  379. data/vendor/tracemonkey/liveconnect/nsISecureLiveconnect.h +94 -0
  380. data/vendor/tracemonkey/liveconnect/nsISecurityContext.h +136 -0
  381. data/vendor/tracemonkey/lock_SunOS.s +119 -0
  382. data/vendor/tracemonkey/mandelbrot-results.js +3 -0
  383. data/vendor/tracemonkey/math-partial-sums.js +32 -0
  384. data/vendor/tracemonkey/math-trace-tests.js +507 -0
  385. data/vendor/tracemonkey/md5.js +289 -0
  386. data/vendor/tracemonkey/nanojit/Assembler.cpp +1984 -0
  387. data/vendor/tracemonkey/nanojit/Assembler.h +375 -0
  388. data/vendor/tracemonkey/nanojit/Fragmento.cpp +651 -0
  389. data/vendor/tracemonkey/nanojit/Fragmento.h +237 -0
  390. data/vendor/tracemonkey/nanojit/LIR.cpp +2314 -0
  391. data/vendor/tracemonkey/nanojit/LIR.h +879 -0
  392. data/vendor/tracemonkey/nanojit/LIRopcode.tbl +252 -0
  393. data/vendor/tracemonkey/nanojit/Native.h +127 -0
  394. data/vendor/tracemonkey/nanojit/NativeARM.cpp +1742 -0
  395. data/vendor/tracemonkey/nanojit/NativeARM.h +844 -0
  396. data/vendor/tracemonkey/nanojit/NativeSparc.cpp +1130 -0
  397. data/vendor/tracemonkey/nanojit/NativeSparc.h +948 -0
  398. data/vendor/tracemonkey/nanojit/NativeThumb.cpp +1322 -0
  399. data/vendor/tracemonkey/nanojit/NativeThumb.h +525 -0
  400. data/vendor/tracemonkey/nanojit/Nativei386.cpp +1748 -0
  401. data/vendor/tracemonkey/nanojit/Nativei386.h +857 -0
  402. data/vendor/tracemonkey/nanojit/RegAlloc.cpp +183 -0
  403. data/vendor/tracemonkey/nanojit/RegAlloc.h +95 -0
  404. data/vendor/tracemonkey/nanojit/TraceTreeDrawer.cpp +306 -0
  405. data/vendor/tracemonkey/nanojit/TraceTreeDrawer.h +88 -0
  406. data/vendor/tracemonkey/nanojit/avmplus.cpp +56 -0
  407. data/vendor/tracemonkey/nanojit/avmplus.h +1016 -0
  408. data/vendor/tracemonkey/nanojit/nanojit.h +253 -0
  409. data/vendor/tracemonkey/perfect.js +39 -0
  410. data/vendor/tracemonkey/plify_jsdhash.sed +35 -0
  411. data/vendor/tracemonkey/prmjtime.cpp +869 -0
  412. data/vendor/tracemonkey/prmjtime.h +103 -0
  413. data/vendor/tracemonkey/ref-config/AIX4.1.mk +65 -0
  414. data/vendor/tracemonkey/ref-config/AIX4.2.mk +64 -0
  415. data/vendor/tracemonkey/ref-config/AIX4.3.mk +65 -0
  416. data/vendor/tracemonkey/ref-config/Darwin.mk +85 -0
  417. data/vendor/tracemonkey/ref-config/Darwin1.3.mk +81 -0
  418. data/vendor/tracemonkey/ref-config/Darwin1.4.mk +41 -0
  419. data/vendor/tracemonkey/ref-config/Darwin5.2.mk +81 -0
  420. data/vendor/tracemonkey/ref-config/Darwin5.3.mk +81 -0
  421. data/vendor/tracemonkey/ref-config/Darwin64.mk +72 -0
  422. data/vendor/tracemonkey/ref-config/HP-UXB.10.10.mk +77 -0
  423. data/vendor/tracemonkey/ref-config/HP-UXB.10.20.mk +77 -0
  424. data/vendor/tracemonkey/ref-config/HP-UXB.11.00.mk +80 -0
  425. data/vendor/tracemonkey/ref-config/IRIX.mk +87 -0
  426. data/vendor/tracemonkey/ref-config/IRIX5.3.mk +44 -0
  427. data/vendor/tracemonkey/ref-config/IRIX6.1.mk +44 -0
  428. data/vendor/tracemonkey/ref-config/IRIX6.2.mk +44 -0
  429. data/vendor/tracemonkey/ref-config/IRIX6.3.mk +44 -0
  430. data/vendor/tracemonkey/ref-config/IRIX6.5.mk +44 -0
  431. data/vendor/tracemonkey/ref-config/Linux_All.mk +105 -0
  432. data/vendor/tracemonkey/ref-config/Mac_OS10.0.mk +82 -0
  433. data/vendor/tracemonkey/ref-config/OSF1V4.0.mk +72 -0
  434. data/vendor/tracemonkey/ref-config/OSF1V5.0.mk +69 -0
  435. data/vendor/tracemonkey/ref-config/SunOS4.1.4.mk +101 -0
  436. data/vendor/tracemonkey/ref-config/SunOS5.10.mk +50 -0
  437. data/vendor/tracemonkey/ref-config/SunOS5.3.mk +91 -0
  438. data/vendor/tracemonkey/ref-config/SunOS5.4.mk +92 -0
  439. data/vendor/tracemonkey/ref-config/SunOS5.5.1.mk +44 -0
  440. data/vendor/tracemonkey/ref-config/SunOS5.5.mk +87 -0
  441. data/vendor/tracemonkey/ref-config/SunOS5.6.mk +89 -0
  442. data/vendor/tracemonkey/ref-config/SunOS5.7.mk +44 -0
  443. data/vendor/tracemonkey/ref-config/SunOS5.8.mk +44 -0
  444. data/vendor/tracemonkey/ref-config/SunOS5.9.mk +44 -0
  445. data/vendor/tracemonkey/ref-config/WINNT4.0.mk +118 -0
  446. data/vendor/tracemonkey/ref-config/WINNT5.0.mk +118 -0
  447. data/vendor/tracemonkey/ref-config/WINNT5.1.mk +118 -0
  448. data/vendor/tracemonkey/ref-config/WINNT5.2.mk +118 -0
  449. data/vendor/tracemonkey/ref-config/WINNT6.0.mk +118 -0
  450. data/vendor/tracemonkey/ref-config/dgux.mk +64 -0
  451. data/vendor/tracemonkey/resource.h +15 -0
  452. data/vendor/tracemonkey/rules.mk +206 -0
  453. data/vendor/tracemonkey/shell/Makefile.in +72 -0
  454. data/vendor/tracemonkey/shell/js.cpp +4719 -0
  455. data/vendor/tracemonkey/t/3d-cube.js +337 -0
  456. data/vendor/tracemonkey/t/3d-morph.js +54 -0
  457. data/vendor/tracemonkey/t/3d-raytrace.js +441 -0
  458. data/vendor/tracemonkey/t/access-binary-trees.js +50 -0
  459. data/vendor/tracemonkey/t/access-fannkuch.js +66 -0
  460. data/vendor/tracemonkey/t/access-nbody.js +169 -0
  461. data/vendor/tracemonkey/t/access-nsieve.js +38 -0
  462. data/vendor/tracemonkey/t/bitops-3bit-bits-in-byte.js +32 -0
  463. data/vendor/tracemonkey/t/bitops-bits-in-byte.js +21 -0
  464. data/vendor/tracemonkey/t/bitops-bitwise-and.js +28 -0
  465. data/vendor/tracemonkey/t/bitops-nsieve-bits.js +32 -0
  466. data/vendor/tracemonkey/t/controlflow-recursive.js +25 -0
  467. data/vendor/tracemonkey/t/crypto-aes.js +422 -0
  468. data/vendor/tracemonkey/t/crypto-md5.js +286 -0
  469. data/vendor/tracemonkey/t/crypto-sha1.js +224 -0
  470. data/vendor/tracemonkey/t/date-format-tofte.js +299 -0
  471. data/vendor/tracemonkey/t/date-format-xparb.js +417 -0
  472. data/vendor/tracemonkey/t/math-cordic.js +95 -0
  473. data/vendor/tracemonkey/t/math-partial-sums.js +33 -0
  474. data/vendor/tracemonkey/t/math-spectral-norm.js +51 -0
  475. data/vendor/tracemonkey/t/regexp-dna.js +1712 -0
  476. data/vendor/tracemonkey/t/string-base64.js +135 -0
  477. data/vendor/tracemonkey/t/string-fasta.js +85 -0
  478. data/vendor/tracemonkey/t/string-tagcloud.js +265 -0
  479. data/vendor/tracemonkey/t/string-unpack-code.js +68 -0
  480. data/vendor/tracemonkey/t/string-validate-input.js +89 -0
  481. data/vendor/tracemonkey/time.sh +13 -0
  482. data/vendor/tracemonkey/trace-test.js +5564 -0
  483. data/vendor/tracemonkey/v8/base.js +187 -0
  484. data/vendor/tracemonkey/v8/crypto.js +1689 -0
  485. data/vendor/tracemonkey/v8/deltablue.js +880 -0
  486. data/vendor/tracemonkey/v8/earley-boyer.js +4682 -0
  487. data/vendor/tracemonkey/v8/raytrace.js +3418 -0
  488. data/vendor/tracemonkey/v8/richards.js +539 -0
  489. data/vendor/tracemonkey/v8/run-crypto.js +44 -0
  490. data/vendor/tracemonkey/v8/run-deltablue.js +44 -0
  491. data/vendor/tracemonkey/v8/run-earley-boyer.js +44 -0
  492. data/vendor/tracemonkey/v8/run-raytrace.js +44 -0
  493. data/vendor/tracemonkey/v8/run-richards.js +44 -0
  494. data/vendor/tracemonkey/v8/run.js +49 -0
  495. data/vendor/tracemonkey/vprof/readme.txt +93 -0
  496. data/vendor/tracemonkey/vprof/vprof.cpp +360 -0
  497. data/vendor/tracemonkey/vprof/vprof.h +245 -0
  498. data/vendor/tracemonkey/xpconnect/Makefile.in +67 -0
  499. data/vendor/tracemonkey/xpconnect/crashtests/117307-1.html +20 -0
  500. data/vendor/tracemonkey/xpconnect/crashtests/193710.html +11 -0
  501. data/vendor/tracemonkey/xpconnect/crashtests/290162-1.html +5 -0
  502. data/vendor/tracemonkey/xpconnect/crashtests/326615-1.html +16 -0
  503. data/vendor/tracemonkey/xpconnect/crashtests/328553-1.html +13 -0
  504. data/vendor/tracemonkey/xpconnect/crashtests/346258-1.html +12 -0
  505. data/vendor/tracemonkey/xpconnect/crashtests/346512-1-frame1.xhtml +16 -0
  506. data/vendor/tracemonkey/xpconnect/crashtests/346512-1-frame2.xhtml +15 -0
  507. data/vendor/tracemonkey/xpconnect/crashtests/346512-1.xhtml +30 -0
  508. data/vendor/tracemonkey/xpconnect/crashtests/382133-1.html +3 -0
  509. data/vendor/tracemonkey/xpconnect/crashtests/386680-1.html +22 -0
  510. data/vendor/tracemonkey/xpconnect/crashtests/394810-1.html +4 -0
  511. data/vendor/tracemonkey/xpconnect/crashtests/400349-1.html +20 -0
  512. data/vendor/tracemonkey/xpconnect/crashtests/403356-1.html +13 -0
  513. data/vendor/tracemonkey/xpconnect/crashtests/418139-1.svg +22 -0
  514. data/vendor/tracemonkey/xpconnect/crashtests/420513-1.html +11 -0
  515. data/vendor/tracemonkey/xpconnect/crashtests/453935-1.html +37 -0
  516. data/vendor/tracemonkey/xpconnect/crashtests/462926.html +12 -0
  517. data/vendor/tracemonkey/xpconnect/crashtests/468552-1.html +18 -0
  518. data/vendor/tracemonkey/xpconnect/crashtests/471366-1.html +12 -0
  519. data/vendor/tracemonkey/xpconnect/crashtests/475185-1.html +13 -0
  520. data/vendor/tracemonkey/xpconnect/crashtests/475291-1.html +14 -0
  521. data/vendor/tracemonkey/xpconnect/crashtests/503286-1.html +23 -0
  522. data/vendor/tracemonkey/xpconnect/crashtests/crashtests.list +21 -0
  523. data/vendor/tracemonkey/xpconnect/idl/Makefile.in +78 -0
  524. data/vendor/tracemonkey/xpconnect/idl/XPCIDispatch.idl +51 -0
  525. data/vendor/tracemonkey/xpconnect/idl/mozIJSSubScriptLoader.idl +64 -0
  526. data/vendor/tracemonkey/xpconnect/idl/nsIActiveXSecurityPolicy.idl +67 -0
  527. data/vendor/tracemonkey/xpconnect/idl/nsIDispatchSupport.idl +119 -0
  528. data/vendor/tracemonkey/xpconnect/idl/nsIJSContextStack.idl +85 -0
  529. data/vendor/tracemonkey/xpconnect/idl/nsIJSRuntimeService.idl +51 -0
  530. data/vendor/tracemonkey/xpconnect/idl/nsIScriptError.idl +102 -0
  531. data/vendor/tracemonkey/xpconnect/idl/nsIScriptableInterfaces.idl +67 -0
  532. data/vendor/tracemonkey/xpconnect/idl/nsIXPCScriptNotify.idl +66 -0
  533. data/vendor/tracemonkey/xpconnect/idl/nsIXPCScriptable.idl +183 -0
  534. data/vendor/tracemonkey/xpconnect/idl/nsIXPCSecurityManager.idl +114 -0
  535. data/vendor/tracemonkey/xpconnect/idl/nsIXPConnect.idl +819 -0
  536. data/vendor/tracemonkey/xpconnect/idl/xpcIJSModuleLoader.idl +95 -0
  537. data/vendor/tracemonkey/xpconnect/idl/xpcIJSWeakReference.idl +49 -0
  538. data/vendor/tracemonkey/xpconnect/idl/xpccomponents.idl +254 -0
  539. data/vendor/tracemonkey/xpconnect/idl/xpcexception.idl +66 -0
  540. data/vendor/tracemonkey/xpconnect/idl/xpcjsid.idl +83 -0
  541. data/vendor/tracemonkey/xpconnect/loader/ISO8601DateUtils.jsm +176 -0
  542. data/vendor/tracemonkey/xpconnect/loader/Makefile.in +63 -0
  543. data/vendor/tracemonkey/xpconnect/loader/XPCOMUtils.jsm +267 -0
  544. data/vendor/tracemonkey/xpconnect/loader/mozJSComponentLoader.cpp +1717 -0
  545. data/vendor/tracemonkey/xpconnect/loader/mozJSComponentLoader.h +172 -0
  546. data/vendor/tracemonkey/xpconnect/loader/mozJSLoaderConstructors.h +101 -0
  547. data/vendor/tracemonkey/xpconnect/loader/mozJSSubScriptLoader.cpp +360 -0
  548. data/vendor/tracemonkey/xpconnect/loader/mozJSSubScriptLoader.h +66 -0
  549. data/vendor/tracemonkey/xpconnect/public/Makefile.in +54 -0
  550. data/vendor/tracemonkey/xpconnect/public/nsAXPCNativeCallContext.h +89 -0
  551. data/vendor/tracemonkey/xpconnect/public/nsAutoJSValHolder.h +168 -0
  552. data/vendor/tracemonkey/xpconnect/public/xpc_map_end.h +327 -0
  553. data/vendor/tracemonkey/xpconnect/sample/Makefile.in +71 -0
  554. data/vendor/tracemonkey/xpconnect/sample/README +39 -0
  555. data/vendor/tracemonkey/xpconnect/sample/xpcsample1.cpp +337 -0
  556. data/vendor/tracemonkey/xpconnect/sample/xpcsample1.idl +82 -0
  557. data/vendor/tracemonkey/xpconnect/sample/xpcsample1.js +21 -0
  558. data/vendor/tracemonkey/xpconnect/shell/Makefile.in +106 -0
  559. data/vendor/tracemonkey/xpconnect/shell/jsshell.msg +50 -0
  560. data/vendor/tracemonkey/xpconnect/shell/xpcshell.cpp +1817 -0
  561. data/vendor/tracemonkey/xpconnect/shell/xpcshellMacUtils.h +43 -0
  562. data/vendor/tracemonkey/xpconnect/shell/xpcshellMacUtils.mm +54 -0
  563. data/vendor/tracemonkey/xpconnect/src/Makefile.in +228 -0
  564. data/vendor/tracemonkey/xpconnect/src/README +3 -0
  565. data/vendor/tracemonkey/xpconnect/src/XPCCrossOriginWrapper.cpp +1186 -0
  566. data/vendor/tracemonkey/xpconnect/src/XPCDispConvert.cpp +593 -0
  567. data/vendor/tracemonkey/xpconnect/src/XPCDispInlines.h +667 -0
  568. data/vendor/tracemonkey/xpconnect/src/XPCDispInterface.cpp +383 -0
  569. data/vendor/tracemonkey/xpconnect/src/XPCDispObject.cpp +516 -0
  570. data/vendor/tracemonkey/xpconnect/src/XPCDispParamPropJSClass.cpp +223 -0
  571. data/vendor/tracemonkey/xpconnect/src/XPCDispParams.cpp +103 -0
  572. data/vendor/tracemonkey/xpconnect/src/XPCDispPrivate.h +1401 -0
  573. data/vendor/tracemonkey/xpconnect/src/XPCDispTearOff.cpp +547 -0
  574. data/vendor/tracemonkey/xpconnect/src/XPCDispTypeInfo.cpp +471 -0
  575. data/vendor/tracemonkey/xpconnect/src/XPCIDispatchClassInfo.cpp +139 -0
  576. data/vendor/tracemonkey/xpconnect/src/XPCIDispatchExtension.cpp +362 -0
  577. data/vendor/tracemonkey/xpconnect/src/XPCNativeWrapper.cpp +1350 -0
  578. data/vendor/tracemonkey/xpconnect/src/XPCNativeWrapper.h +88 -0
  579. data/vendor/tracemonkey/xpconnect/src/XPCSafeJSObjectWrapper.cpp +1148 -0
  580. data/vendor/tracemonkey/xpconnect/src/XPCSystemOnlyWrapper.cpp +718 -0
  581. data/vendor/tracemonkey/xpconnect/src/XPCWrapper.cpp +850 -0
  582. data/vendor/tracemonkey/xpconnect/src/XPCWrapper.h +394 -0
  583. data/vendor/tracemonkey/xpconnect/src/dom_quickstubs.qsconf +568 -0
  584. data/vendor/tracemonkey/xpconnect/src/nsDispatchSupport.cpp +348 -0
  585. data/vendor/tracemonkey/xpconnect/src/nsScriptError.cpp +201 -0
  586. data/vendor/tracemonkey/xpconnect/src/nsXPConnect.cpp +2609 -0
  587. data/vendor/tracemonkey/xpconnect/src/qsgen.py +1487 -0
  588. data/vendor/tracemonkey/xpconnect/src/xpc.msg +217 -0
  589. data/vendor/tracemonkey/xpconnect/src/xpcJSWeakReference.cpp +148 -0
  590. data/vendor/tracemonkey/xpconnect/src/xpcJSWeakReference.h +56 -0
  591. data/vendor/tracemonkey/xpconnect/src/xpccallcontext.cpp +579 -0
  592. data/vendor/tracemonkey/xpconnect/src/xpccomponents.cpp +4144 -0
  593. data/vendor/tracemonkey/xpconnect/src/xpccontext.cpp +115 -0
  594. data/vendor/tracemonkey/xpconnect/src/xpcconvert.cpp +2298 -0
  595. data/vendor/tracemonkey/xpconnect/src/xpcdebug.cpp +481 -0
  596. data/vendor/tracemonkey/xpconnect/src/xpcexception.cpp +502 -0
  597. data/vendor/tracemonkey/xpconnect/src/xpcforwards.h +114 -0
  598. data/vendor/tracemonkey/xpconnect/src/xpcinlines.h +772 -0
  599. data/vendor/tracemonkey/xpconnect/src/xpcjsid.cpp +1025 -0
  600. data/vendor/tracemonkey/xpconnect/src/xpcjsruntime.cpp +1342 -0
  601. data/vendor/tracemonkey/xpconnect/src/xpclog.cpp +128 -0
  602. data/vendor/tracemonkey/xpconnect/src/xpclog.h +101 -0
  603. data/vendor/tracemonkey/xpconnect/src/xpcmaps.cpp +761 -0
  604. data/vendor/tracemonkey/xpconnect/src/xpcmaps.h +713 -0
  605. data/vendor/tracemonkey/xpconnect/src/xpcmodule.cpp +136 -0
  606. data/vendor/tracemonkey/xpconnect/src/xpcprivate.h +4138 -0
  607. data/vendor/tracemonkey/xpconnect/src/xpcquickstubs.cpp +1128 -0
  608. data/vendor/tracemonkey/xpconnect/src/xpcquickstubs.h +480 -0
  609. data/vendor/tracemonkey/xpconnect/src/xpcruntimesvc.cpp +179 -0
  610. data/vendor/tracemonkey/xpconnect/src/xpcstack.cpp +342 -0
  611. data/vendor/tracemonkey/xpconnect/src/xpcstring.cpp +139 -0
  612. data/vendor/tracemonkey/xpconnect/src/xpcthreadcontext.cpp +599 -0
  613. data/vendor/tracemonkey/xpconnect/src/xpcthrower.cpp +399 -0
  614. data/vendor/tracemonkey/xpconnect/src/xpcvariant.cpp +850 -0
  615. data/vendor/tracemonkey/xpconnect/src/xpcwrappedjs.cpp +670 -0
  616. data/vendor/tracemonkey/xpconnect/src/xpcwrappedjsclass.cpp +2015 -0
  617. data/vendor/tracemonkey/xpconnect/src/xpcwrappednative.cpp +3482 -0
  618. data/vendor/tracemonkey/xpconnect/src/xpcwrappednativeinfo.cpp +945 -0
  619. data/vendor/tracemonkey/xpconnect/src/xpcwrappednativejsops.cpp +2003 -0
  620. data/vendor/tracemonkey/xpconnect/src/xpcwrappednativeproto.cpp +302 -0
  621. data/vendor/tracemonkey/xpconnect/src/xpcwrappednativescope.cpp +991 -0
  622. data/vendor/tracemonkey/xpconnect/tests/Makefile.in +75 -0
  623. data/vendor/tracemonkey/xpconnect/tests/TestXPC.cpp +785 -0
  624. data/vendor/tracemonkey/xpconnect/tests/chrome/Makefile.in +51 -0
  625. data/vendor/tracemonkey/xpconnect/tests/chrome/test_bug500931.xul +43 -0
  626. data/vendor/tracemonkey/xpconnect/tests/components/Makefile.in +85 -0
  627. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_array.cpp +388 -0
  628. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_attributes.cpp +305 -0
  629. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_calljs.cpp +135 -0
  630. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_child.cpp +225 -0
  631. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_const.cpp +76 -0
  632. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_domstring.cpp +118 -0
  633. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_echo.cpp +616 -0
  634. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_in.cpp +204 -0
  635. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_inout.cpp +171 -0
  636. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_module.cpp +77 -0
  637. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_multiple.cpp +554 -0
  638. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_noisy.cpp +154 -0
  639. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_out.cpp +335 -0
  640. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_overloaded.cpp +250 -0
  641. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_private.h +192 -0
  642. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_string.cpp +185 -0
  643. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_variant.cpp +355 -0
  644. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/StdAfx.cpp +12 -0
  645. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/StdAfx.h +28 -0
  646. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/XPCDispUtilities.h +28 -0
  647. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/XPCIDispatchTest.cpp +86 -0
  648. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/XPCIDispatchTest.def +9 -0
  649. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/XPCIDispatchTest.dsp +318 -0
  650. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/XPCIDispatchTest.dsw +29 -0
  651. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/XPCIDispatchTest.idl +454 -0
  652. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/XPCIDispatchTest.rc +145 -0
  653. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispSimple.cpp +44 -0
  654. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispSimple.h +56 -0
  655. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispSimple.rgs +23 -0
  656. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestArrays.cpp +221 -0
  657. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestArrays.h +53 -0
  658. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestArrays.rgs +23 -0
  659. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestMethods.cpp +699 -0
  660. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestMethods.h +138 -0
  661. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestMethods.rgs +23 -0
  662. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestNoIDispatch.cpp +23 -0
  663. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestNoIDispatch.h +41 -0
  664. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestNoIDispatch.rgs +23 -0
  665. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestProperties.cpp +256 -0
  666. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestProperties.h +88 -0
  667. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestProperties.rgs +23 -0
  668. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestScriptOff.cpp +23 -0
  669. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestScriptOff.h +43 -0
  670. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestScriptOff.rgs +23 -0
  671. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestScriptOn.cpp +29 -0
  672. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestScriptOn.h +45 -0
  673. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestScriptOn.rgs +23 -0
  674. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestWrappedJS.cpp +177 -0
  675. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestWrappedJS.h +50 -0
  676. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestWrappedJS.rgs +23 -0
  677. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/resource.h +36 -0
  678. data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/WrappedCOM/Arrays/XPCIDispatchArrayTests.js +54 -0
  679. data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/WrappedCOM/Attributes/XPCIDispatchAttributeTests.js +150 -0
  680. data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/WrappedCOM/General/XPCIDispatchInstantiations.js +122 -0
  681. data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/WrappedCOM/General/XPCStress.js +58 -0
  682. data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/WrappedCOM/Methods/XPCIDispatchMethodTests.js +376 -0
  683. data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/WrappedCOM/shell.js +377 -0
  684. data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/WrappedJS/General/XPCIDispatchTestWrappedJS.js +76 -0
  685. data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/WrappedJS/shell.js +377 -0
  686. data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/exectests.cmd +1 -0
  687. data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/jsDriver.pl +1288 -0
  688. data/vendor/tracemonkey/xpconnect/tests/idl/Makefile.in +61 -0
  689. data/vendor/tracemonkey/xpconnect/tests/idl/xpctest.idl +312 -0
  690. data/vendor/tracemonkey/xpconnect/tests/idl/xpctest2.idl +51 -0
  691. data/vendor/tracemonkey/xpconnect/tests/idl/xpctest_attributes.idl +67 -0
  692. data/vendor/tracemonkey/xpconnect/tests/idl/xpctest_calljs.idl +59 -0
  693. data/vendor/tracemonkey/xpconnect/tests/idl/xpctest_const.idl +61 -0
  694. data/vendor/tracemonkey/xpconnect/tests/idl/xpctest_domstring.idl +59 -0
  695. data/vendor/tracemonkey/xpconnect/tests/idl/xpctest_in.idl +88 -0
  696. data/vendor/tracemonkey/xpconnect/tests/idl/xpctest_inout.idl +86 -0
  697. data/vendor/tracemonkey/xpconnect/tests/idl/xpctest_multiple.idl +77 -0
  698. data/vendor/tracemonkey/xpconnect/tests/idl/xpctest_out.idl +142 -0
  699. data/vendor/tracemonkey/xpconnect/tests/js/checkid.js +82 -0
  700. data/vendor/tracemonkey/xpconnect/tests/js/evaluate.js +311 -0
  701. data/vendor/tracemonkey/xpconnect/tests/js/exceptions-2.js +153 -0
  702. data/vendor/tracemonkey/xpconnect/tests/js/exceptions-3.js +194 -0
  703. data/vendor/tracemonkey/xpconnect/tests/js/exceptions-4.js +297 -0
  704. data/vendor/tracemonkey/xpconnect/tests/js/exceptions-5.js +343 -0
  705. data/vendor/tracemonkey/xpconnect/tests/js/exceptions.js +230 -0
  706. data/vendor/tracemonkey/xpconnect/tests/js/javascript.js +96 -0
  707. data/vendor/tracemonkey/xpconnect/tests/js/multiple-2.js +151 -0
  708. data/vendor/tracemonkey/xpconnect/tests/js/multiple-3.js +148 -0
  709. data/vendor/tracemonkey/xpconnect/tests/js/multiple-4.js +152 -0
  710. data/vendor/tracemonkey/xpconnect/tests/js/multiple.js +137 -0
  711. data/vendor/tracemonkey/xpconnect/tests/js/notscriptable.js +104 -0
  712. data/vendor/tracemonkey/xpconnect/tests/js/old/simpletest.js +36 -0
  713. data/vendor/tracemonkey/xpconnect/tests/js/old/speed.js +60 -0
  714. data/vendor/tracemonkey/xpconnect/tests/js/old/testxpc.js +464 -0
  715. data/vendor/tracemonkey/xpconnect/tests/js/old/threads.js +74 -0
  716. data/vendor/tracemonkey/xpconnect/tests/js/old/try.js +27 -0
  717. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_array.js +308 -0
  718. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_callcontext.js +68 -0
  719. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_echo.js +636 -0
  720. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_enum_and_sort.js +28 -0
  721. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_enum_constants.js +15 -0
  722. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_enum_create.js +200 -0
  723. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_exceptions.js +167 -0
  724. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_ids.js +135 -0
  725. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_observer.js +36 -0
  726. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_overloaded.js +14 -0
  727. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_primitives.js +141 -0
  728. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_propertybag.js +36 -0
  729. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_variant.js +339 -0
  730. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_variant_array.js +30 -0
  731. data/vendor/tracemonkey/xpconnect/tests/js/readonlyattributes.js +74 -0
  732. data/vendor/tracemonkey/xpconnect/tests/js/readwriteattributes.js +101 -0
  733. data/vendor/tracemonkey/xpconnect/tests/js/scriptable.js +120 -0
  734. data/vendor/tracemonkey/xpconnect/tests/js/testin.js +203 -0
  735. data/vendor/tracemonkey/xpconnect/tests/js/xpcfun.js +234 -0
  736. data/vendor/tracemonkey/xpconnect/tests/js/xpctest_primitives.js +200 -0
  737. data/vendor/tracemonkey/xpconnect/tests/mochitest/Makefile.in +66 -0
  738. data/vendor/tracemonkey/xpconnect/tests/mochitest/bug500931_helper.html +7 -0
  739. data/vendor/tracemonkey/xpconnect/tests/mochitest/inner.html +7 -0
  740. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug361111.xul +29 -0
  741. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug384632.html +32 -0
  742. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug390488.html +65 -0
  743. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug393269.html +46 -0
  744. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug396851.html +43 -0
  745. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug428021.html +41 -0
  746. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug446584.html +49 -0
  747. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug448587.html +31 -0
  748. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug462428.html +42 -0
  749. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug478438.html +66 -0
  750. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug484107.html +100 -0
  751. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug484459.html +36 -0
  752. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug500691.html +28 -0
  753. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_wrappers.html +116 -0
  754. data/vendor/tracemonkey/xpconnect/tests/unit/bogus_element_type.jsm +1 -0
  755. data/vendor/tracemonkey/xpconnect/tests/unit/bogus_exports_type.jsm +1 -0
  756. data/vendor/tracemonkey/xpconnect/tests/unit/bug451678_subscript.js +2 -0
  757. data/vendor/tracemonkey/xpconnect/tests/unit/component_import.js +144 -0
  758. data/vendor/tracemonkey/xpconnect/tests/unit/recursive_importA.jsm +44 -0
  759. data/vendor/tracemonkey/xpconnect/tests/unit/recursive_importB.jsm +45 -0
  760. data/vendor/tracemonkey/xpconnect/tests/unit/syntax_error.jsm +1 -0
  761. data/vendor/tracemonkey/xpconnect/tests/unit/test_bogus_files.js +88 -0
  762. data/vendor/tracemonkey/xpconnect/tests/unit/test_bug408412.js +51 -0
  763. data/vendor/tracemonkey/xpconnect/tests/unit/test_bug451678.js +52 -0
  764. data/vendor/tracemonkey/xpconnect/tests/unit/test_bug_442086.js +68 -0
  765. data/vendor/tracemonkey/xpconnect/tests/unit/test_import.js +127 -0
  766. data/vendor/tracemonkey/xpconnect/tests/unit/test_js_weak_references.js +63 -0
  767. data/vendor/tracemonkey/xpconnect/tests/unit/test_recursive_import.js +62 -0
  768. data/vendor/tracemonkey/xpconnect/tools/Makefile.in +49 -0
  769. data/vendor/tracemonkey/xpconnect/tools/idl/Makefile.in +53 -0
  770. data/vendor/tracemonkey/xpconnect/tools/idl/nsIXPCToolsCompiler.idl +60 -0
  771. data/vendor/tracemonkey/xpconnect/tools/idl/nsIXPCToolsProfiler.idl +57 -0
  772. data/vendor/tracemonkey/xpconnect/tools/js/CompileJSFiles.js +28 -0
  773. data/vendor/tracemonkey/xpconnect/tools/js/ListJSFiles.js +18 -0
  774. data/vendor/tracemonkey/xpconnect/tools/src/Makefile.in +76 -0
  775. data/vendor/tracemonkey/xpconnect/tools/src/nsXPCToolsCompiler.cpp +161 -0
  776. data/vendor/tracemonkey/xpconnect/tools/src/nsXPCToolsModule.cpp +65 -0
  777. data/vendor/tracemonkey/xpconnect/tools/src/nsXPCToolsProfiler.cpp +370 -0
  778. data/vendor/tracemonkey/xpconnect/tools/src/xpctools_private.h +236 -0
  779. metadata +782 -107
  780. data/test/johnson/nodes/export_test.rb +0 -9
  781. data/test/johnson/nodes/import_test.rb +0 -13
  782. data/test/johnson/version_test.rb +0 -13
@@ -0,0 +1,2727 @@
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 jsapi_h___
42
+ #define jsapi_h___
43
+ /*
44
+ * JavaScript API.
45
+ */
46
+ #include <stddef.h>
47
+ #include <stdio.h>
48
+ #include "js-config.h"
49
+ #include "jspubtd.h"
50
+ #include "jsutil.h"
51
+
52
+ JS_BEGIN_EXTERN_C
53
+
54
+ /*
55
+ * Type tags stored in the low bits of a jsval.
56
+ */
57
+ #define JSVAL_OBJECT 0x0 /* untagged reference to object */
58
+ #define JSVAL_INT 0x1 /* tagged 31-bit integer value */
59
+ #define JSVAL_DOUBLE 0x2 /* tagged reference to double */
60
+ #define JSVAL_STRING 0x4 /* tagged reference to string */
61
+ #define JSVAL_BOOLEAN 0x6 /* tagged boolean value */
62
+
63
+ /* Type tag bitfield length and derived macros. */
64
+ #define JSVAL_TAGBITS 3
65
+ #define JSVAL_TAGMASK JS_BITMASK(JSVAL_TAGBITS)
66
+ #define JSVAL_TAG(v) ((v) & JSVAL_TAGMASK)
67
+ #define JSVAL_SETTAG(v,t) ((v) | (t))
68
+ #define JSVAL_CLRTAG(v) ((v) & ~(jsval)JSVAL_TAGMASK)
69
+ #define JSVAL_ALIGN JS_BIT(JSVAL_TAGBITS)
70
+
71
+ /* Predicates for type testing. */
72
+ #define JSVAL_IS_OBJECT(v) (JSVAL_TAG(v) == JSVAL_OBJECT)
73
+ #define JSVAL_IS_NUMBER(v) (JSVAL_IS_INT(v) || JSVAL_IS_DOUBLE(v))
74
+ #define JSVAL_IS_INT(v) ((v) & JSVAL_INT)
75
+ #define JSVAL_IS_DOUBLE(v) (JSVAL_TAG(v) == JSVAL_DOUBLE)
76
+ #define JSVAL_IS_STRING(v) (JSVAL_TAG(v) == JSVAL_STRING)
77
+ #define JSVAL_IS_BOOLEAN(v) (((v) & ~((jsval)1 << JSVAL_TAGBITS)) == \
78
+ JSVAL_BOOLEAN)
79
+ #define JSVAL_IS_NULL(v) ((v) == JSVAL_NULL)
80
+ #define JSVAL_IS_VOID(v) ((v) == JSVAL_VOID)
81
+ #define JSVAL_IS_PRIMITIVE(v) (!JSVAL_IS_OBJECT(v) || JSVAL_IS_NULL(v))
82
+
83
+ /* Objects, strings, and doubles are GC'ed. */
84
+ #define JSVAL_IS_GCTHING(v) (!((v) & JSVAL_INT) && \
85
+ JSVAL_TAG(v) != JSVAL_BOOLEAN)
86
+
87
+ static JS_ALWAYS_INLINE void *
88
+ JSVAL_TO_GCTHING(jsval v)
89
+ {
90
+ JS_ASSERT(JSVAL_IS_GCTHING(v));
91
+ return (void *) JSVAL_CLRTAG(v);
92
+ }
93
+
94
+ static JS_ALWAYS_INLINE JSObject *
95
+ JSVAL_TO_OBJECT(jsval v)
96
+ {
97
+ JS_ASSERT(JSVAL_IS_OBJECT(v));
98
+ return (JSObject *) JSVAL_TO_GCTHING(v);
99
+ }
100
+
101
+ static JS_ALWAYS_INLINE jsdouble *
102
+ JSVAL_TO_DOUBLE(jsval v)
103
+ {
104
+ JS_ASSERT(JSVAL_IS_DOUBLE(v));
105
+ return (jsdouble *) JSVAL_TO_GCTHING(v);
106
+ }
107
+
108
+ static JS_ALWAYS_INLINE JSString *
109
+ JSVAL_TO_STRING(jsval v)
110
+ {
111
+ JS_ASSERT(JSVAL_IS_STRING(v));
112
+ return (JSString *) JSVAL_TO_GCTHING(v);
113
+ }
114
+
115
+ static JS_ALWAYS_INLINE jsval
116
+ OBJECT_TO_JSVAL(JSObject *obj)
117
+ {
118
+ JS_ASSERT(((jsval) obj & JSVAL_TAGMASK) == JSVAL_OBJECT);
119
+ return (jsval) obj;
120
+ }
121
+
122
+ static JS_ALWAYS_INLINE jsval
123
+ DOUBLE_TO_JSVAL(jsdouble *dp)
124
+ {
125
+ JS_ASSERT(((jsword) dp & JSVAL_TAGMASK) == 0);
126
+ return JSVAL_SETTAG((jsval) dp, JSVAL_DOUBLE);
127
+ }
128
+
129
+ static JS_ALWAYS_INLINE jsval
130
+ STRING_TO_JSVAL(JSString *str)
131
+ {
132
+ return JSVAL_SETTAG((jsval) str, JSVAL_STRING);
133
+ }
134
+
135
+ /* Lock and unlock the GC thing held by a jsval. */
136
+ #define JSVAL_LOCK(cx,v) (JSVAL_IS_GCTHING(v) \
137
+ ? JS_LockGCThing(cx, JSVAL_TO_GCTHING(v)) \
138
+ : JS_TRUE)
139
+ #define JSVAL_UNLOCK(cx,v) (JSVAL_IS_GCTHING(v) \
140
+ ? JS_UnlockGCThing(cx, JSVAL_TO_GCTHING(v)) \
141
+ : JS_TRUE)
142
+
143
+ /* Domain limits for the jsval int type. */
144
+ #define JSVAL_INT_BITS 31
145
+ #define JSVAL_INT_POW2(n) ((jsval)1 << (n))
146
+ #define JSVAL_INT_MIN (-JSVAL_INT_POW2(30))
147
+ #define JSVAL_INT_MAX (JSVAL_INT_POW2(30) - 1)
148
+ #define INT_FITS_IN_JSVAL(i) ((jsuint)(i) - (jsuint)JSVAL_INT_MIN <= \
149
+ (jsuint)(JSVAL_INT_MAX - JSVAL_INT_MIN))
150
+ #define JSVAL_TO_INT(v) ((jsint)(v) >> 1)
151
+ #define INT_TO_JSVAL(i) (((jsval)(i) << 1) | JSVAL_INT)
152
+
153
+ /*
154
+ * A pseudo-boolean is a 29-bit (for 32-bit jsval) or 61-bit (for 64-bit jsval)
155
+ * value other than 0 or 1 encoded as a jsval whose tag is JSVAL_BOOLEAN.
156
+ *
157
+ * JSVAL_VOID happens to be defined as a jsval encoding a pseudo-boolean, but
158
+ * embedders MUST NOT rely on this. All other possible pseudo-boolean values
159
+ * are implementation-reserved and MUST NOT be constructed by any embedding of
160
+ * SpiderMonkey.
161
+ */
162
+ #define JSVAL_TO_PSEUDO_BOOLEAN(v) ((JSBool) ((v) >> JSVAL_TAGBITS))
163
+ #define PSEUDO_BOOLEAN_TO_JSVAL(b) \
164
+ JSVAL_SETTAG((jsval) (b) << JSVAL_TAGBITS, JSVAL_BOOLEAN)
165
+
166
+ /*
167
+ * Well-known JS values. The extern'd variables are initialized when the
168
+ * first JSContext is created by JS_NewContext (see below).
169
+ */
170
+ #define JSVAL_NULL ((jsval) 0)
171
+ #define JSVAL_ZERO INT_TO_JSVAL(0)
172
+ #define JSVAL_ONE INT_TO_JSVAL(1)
173
+ #define JSVAL_FALSE PSEUDO_BOOLEAN_TO_JSVAL(JS_FALSE)
174
+ #define JSVAL_TRUE PSEUDO_BOOLEAN_TO_JSVAL(JS_TRUE)
175
+ #define JSVAL_VOID PSEUDO_BOOLEAN_TO_JSVAL(2)
176
+
177
+
178
+ /* Convert between boolean and jsval, asserting that inputs are valid. */
179
+ static JS_ALWAYS_INLINE JSBool
180
+ JSVAL_TO_BOOLEAN(jsval v)
181
+ {
182
+ JS_ASSERT(v == JSVAL_TRUE || v == JSVAL_FALSE);
183
+ return JSVAL_TO_PSEUDO_BOOLEAN(v);
184
+ }
185
+
186
+ static JS_ALWAYS_INLINE jsval
187
+ BOOLEAN_TO_JSVAL(JSBool b)
188
+ {
189
+ JS_ASSERT(b == JS_TRUE || b == JS_FALSE);
190
+ return PSEUDO_BOOLEAN_TO_JSVAL(b);
191
+ }
192
+
193
+ /* A private data pointer (2-byte-aligned) can be stored as an int jsval. */
194
+ #define JSVAL_TO_PRIVATE(v) ((void *)((v) & ~JSVAL_INT))
195
+ #define PRIVATE_TO_JSVAL(p) ((jsval)(p) | JSVAL_INT)
196
+
197
+ /* Property attributes, set in JSPropertySpec and passed to API functions. */
198
+ #define JSPROP_ENUMERATE 0x01 /* property is visible to for/in loop */
199
+ #define JSPROP_READONLY 0x02 /* not settable: assignment is no-op */
200
+ #define JSPROP_PERMANENT 0x04 /* property cannot be deleted */
201
+ #define JSPROP_GETTER 0x10 /* property holds getter function */
202
+ #define JSPROP_SETTER 0x20 /* property holds setter function */
203
+ #define JSPROP_SHARED 0x40 /* don't allocate a value slot for this
204
+ property; don't copy the property on
205
+ set of the same-named property in an
206
+ object that delegates to a prototype
207
+ containing this property */
208
+ #define JSPROP_INDEX 0x80 /* name is actually (jsint) index */
209
+
210
+ /* Function flags, set in JSFunctionSpec and passed to JS_NewFunction etc. */
211
+ #define JSFUN_LAMBDA 0x08 /* expressed, not declared, function */
212
+ #define JSFUN_GETTER JSPROP_GETTER
213
+ #define JSFUN_SETTER JSPROP_SETTER
214
+ #define JSFUN_BOUND_METHOD 0x40 /* bind this to fun->object's parent */
215
+ #define JSFUN_HEAVYWEIGHT 0x80 /* activation requires a Call object */
216
+
217
+ #define JSFUN_DISJOINT_FLAGS(f) ((f) & 0x0f)
218
+ #define JSFUN_GSFLAGS(f) ((f) & (JSFUN_GETTER | JSFUN_SETTER))
219
+
220
+ #define JSFUN_GETTER_TEST(f) ((f) & JSFUN_GETTER)
221
+ #define JSFUN_SETTER_TEST(f) ((f) & JSFUN_SETTER)
222
+ #define JSFUN_BOUND_METHOD_TEST(f) ((f) & JSFUN_BOUND_METHOD)
223
+ #define JSFUN_HEAVYWEIGHT_TEST(f) ((f) & JSFUN_HEAVYWEIGHT)
224
+
225
+ #define JSFUN_GSFLAG2ATTR(f) JSFUN_GSFLAGS(f)
226
+
227
+ #define JSFUN_THISP_FLAGS(f) (f)
228
+ #define JSFUN_THISP_TEST(f,t) ((f) & t)
229
+
230
+ #define JSFUN_THISP_STRING 0x0100 /* |this| may be a primitive string */
231
+ #define JSFUN_THISP_NUMBER 0x0200 /* |this| may be a primitive number */
232
+ #define JSFUN_THISP_BOOLEAN 0x0400 /* |this| may be a primitive boolean */
233
+ #define JSFUN_THISP_PRIMITIVE 0x0700 /* |this| may be any primitive value */
234
+
235
+ #define JSFUN_FAST_NATIVE 0x0800 /* JSFastNative needs no JSStackFrame */
236
+
237
+ #define JSFUN_FLAGS_MASK 0x0ff8 /* overlay JSFUN_* attributes --
238
+ bits 12-15 are used internally to
239
+ flag interpreted functions */
240
+
241
+ #define JSFUN_STUB_GSOPS 0x1000 /* use JS_PropertyStub getter/setter
242
+ instead of defaulting to class gsops
243
+ for property holding function */
244
+
245
+ /*
246
+ * Re-use JSFUN_LAMBDA, which applies only to scripted functions, for use in
247
+ * JSFunctionSpec arrays that specify generic native prototype methods, i.e.,
248
+ * methods of a class prototype that are exposed as static methods taking an
249
+ * extra leading argument: the generic |this| parameter.
250
+ *
251
+ * If you set this flag in a JSFunctionSpec struct's flags initializer, then
252
+ * that struct must live at least as long as the native static method object
253
+ * created due to this flag by JS_DefineFunctions or JS_InitClass. Typically
254
+ * JSFunctionSpec structs are allocated in static arrays.
255
+ */
256
+ #define JSFUN_GENERIC_NATIVE JSFUN_LAMBDA
257
+
258
+ /*
259
+ * Microseconds since the epoch, midnight, January 1, 1970 UTC. See the
260
+ * comment in jstypes.h regarding safe int64 usage.
261
+ */
262
+ extern JS_PUBLIC_API(int64)
263
+ JS_Now(void);
264
+
265
+ /* Don't want to export data, so provide accessors for non-inline jsvals. */
266
+ extern JS_PUBLIC_API(jsval)
267
+ JS_GetNaNValue(JSContext *cx);
268
+
269
+ extern JS_PUBLIC_API(jsval)
270
+ JS_GetNegativeInfinityValue(JSContext *cx);
271
+
272
+ extern JS_PUBLIC_API(jsval)
273
+ JS_GetPositiveInfinityValue(JSContext *cx);
274
+
275
+ extern JS_PUBLIC_API(jsval)
276
+ JS_GetEmptyStringValue(JSContext *cx);
277
+
278
+ /*
279
+ * Format is a string of the following characters (spaces are insignificant),
280
+ * specifying the tabulated type conversions:
281
+ *
282
+ * b JSBool Boolean
283
+ * c uint16/jschar ECMA uint16, Unicode char
284
+ * i int32 ECMA int32
285
+ * u uint32 ECMA uint32
286
+ * j int32 Rounded int32 (coordinate)
287
+ * d jsdouble IEEE double
288
+ * I jsdouble Integral IEEE double
289
+ * s char * C string
290
+ * S JSString * Unicode string, accessed by a JSString pointer
291
+ * W jschar * Unicode character vector, 0-terminated (W for wide)
292
+ * o JSObject * Object reference
293
+ * f JSFunction * Function private
294
+ * v jsval Argument value (no conversion)
295
+ * * N/A Skip this argument (no vararg)
296
+ * / N/A End of required arguments
297
+ *
298
+ * The variable argument list after format must consist of &b, &c, &s, e.g.,
299
+ * where those variables have the types given above. For the pointer types
300
+ * char *, JSString *, and JSObject *, the pointed-at memory returned belongs
301
+ * to the JS runtime, not to the calling native code. The runtime promises
302
+ * to keep this memory valid so long as argv refers to allocated stack space
303
+ * (so long as the native function is active).
304
+ *
305
+ * Fewer arguments than format specifies may be passed only if there is a /
306
+ * in format after the last required argument specifier and argc is at least
307
+ * the number of required arguments. More arguments than format specifies
308
+ * may be passed without error; it is up to the caller to deal with trailing
309
+ * unconverted arguments.
310
+ */
311
+ extern JS_PUBLIC_API(JSBool)
312
+ JS_ConvertArguments(JSContext *cx, uintN argc, jsval *argv, const char *format,
313
+ ...);
314
+
315
+ #ifdef va_start
316
+ extern JS_PUBLIC_API(JSBool)
317
+ JS_ConvertArgumentsVA(JSContext *cx, uintN argc, jsval *argv,
318
+ const char *format, va_list ap);
319
+ #endif
320
+
321
+ /*
322
+ * Inverse of JS_ConvertArguments: scan format and convert trailing arguments
323
+ * into jsvals, GC-rooted if necessary by the JS stack. Return null on error,
324
+ * and a pointer to the new argument vector on success. Also return a stack
325
+ * mark on success via *markp, in which case the caller must eventually clean
326
+ * up by calling JS_PopArguments.
327
+ *
328
+ * Note that the number of actual arguments supplied is specified exclusively
329
+ * by format, so there is no argc parameter.
330
+ */
331
+ extern JS_PUBLIC_API(jsval *)
332
+ JS_PushArguments(JSContext *cx, void **markp, const char *format, ...);
333
+
334
+ #ifdef va_start
335
+ extern JS_PUBLIC_API(jsval *)
336
+ JS_PushArgumentsVA(JSContext *cx, void **markp, const char *format, va_list ap);
337
+ #endif
338
+
339
+ extern JS_PUBLIC_API(void)
340
+ JS_PopArguments(JSContext *cx, void *mark);
341
+
342
+ #ifdef JS_ARGUMENT_FORMATTER_DEFINED
343
+
344
+ /*
345
+ * Add and remove a format string handler for JS_{Convert,Push}Arguments{,VA}.
346
+ * The handler function has this signature (see jspubtd.h):
347
+ *
348
+ * JSBool MyArgumentFormatter(JSContext *cx, const char *format,
349
+ * JSBool fromJS, jsval **vpp, va_list *app);
350
+ *
351
+ * It should return true on success, and return false after reporting an error
352
+ * or detecting an already-reported error.
353
+ *
354
+ * For a given format string, for example "AA", the formatter is called from
355
+ * JS_ConvertArgumentsVA like so:
356
+ *
357
+ * formatter(cx, "AA...", JS_TRUE, &sp, &ap);
358
+ *
359
+ * sp points into the arguments array on the JS stack, while ap points into
360
+ * the stdarg.h va_list on the C stack. The JS_TRUE passed for fromJS tells
361
+ * the formatter to convert zero or more jsvals at sp to zero or more C values
362
+ * accessed via pointers-to-values at ap, updating both sp (via *vpp) and ap
363
+ * (via *app) to point past the converted arguments and their result pointers
364
+ * on the C stack.
365
+ *
366
+ * When called from JS_PushArgumentsVA, the formatter is invoked thus:
367
+ *
368
+ * formatter(cx, "AA...", JS_FALSE, &sp, &ap);
369
+ *
370
+ * where JS_FALSE for fromJS means to wrap the C values at ap according to the
371
+ * format specifier and store them at sp, updating ap and sp appropriately.
372
+ *
373
+ * The "..." after "AA" is the rest of the format string that was passed into
374
+ * JS_{Convert,Push}Arguments{,VA}. The actual format trailing substring used
375
+ * in each Convert or PushArguments call is passed to the formatter, so that
376
+ * one such function may implement several formats, in order to share code.
377
+ *
378
+ * Remove just forgets about any handler associated with format. Add does not
379
+ * copy format, it points at the string storage allocated by the caller, which
380
+ * is typically a string constant. If format is in dynamic storage, it is up
381
+ * to the caller to keep the string alive until Remove is called.
382
+ */
383
+ extern JS_PUBLIC_API(JSBool)
384
+ JS_AddArgumentFormatter(JSContext *cx, const char *format,
385
+ JSArgumentFormatter formatter);
386
+
387
+ extern JS_PUBLIC_API(void)
388
+ JS_RemoveArgumentFormatter(JSContext *cx, const char *format);
389
+
390
+ #endif /* JS_ARGUMENT_FORMATTER_DEFINED */
391
+
392
+ extern JS_PUBLIC_API(JSBool)
393
+ JS_ConvertValue(JSContext *cx, jsval v, JSType type, jsval *vp);
394
+
395
+ extern JS_PUBLIC_API(JSBool)
396
+ JS_ValueToObject(JSContext *cx, jsval v, JSObject **objp);
397
+
398
+ extern JS_PUBLIC_API(JSFunction *)
399
+ JS_ValueToFunction(JSContext *cx, jsval v);
400
+
401
+ extern JS_PUBLIC_API(JSFunction *)
402
+ JS_ValueToConstructor(JSContext *cx, jsval v);
403
+
404
+ extern JS_PUBLIC_API(JSString *)
405
+ JS_ValueToString(JSContext *cx, jsval v);
406
+
407
+ extern JS_PUBLIC_API(JSString *)
408
+ JS_ValueToSource(JSContext *cx, jsval v);
409
+
410
+ extern JS_PUBLIC_API(JSBool)
411
+ JS_ValueToNumber(JSContext *cx, jsval v, jsdouble *dp);
412
+
413
+ /*
414
+ * Convert a value to a number, then to an int32, according to the ECMA rules
415
+ * for ToInt32.
416
+ */
417
+ extern JS_PUBLIC_API(JSBool)
418
+ JS_ValueToECMAInt32(JSContext *cx, jsval v, int32 *ip);
419
+
420
+ /*
421
+ * Convert a value to a number, then to a uint32, according to the ECMA rules
422
+ * for ToUint32.
423
+ */
424
+ extern JS_PUBLIC_API(JSBool)
425
+ JS_ValueToECMAUint32(JSContext *cx, jsval v, uint32 *ip);
426
+
427
+ /*
428
+ * Convert a value to a number, then to an int32 if it fits by rounding to
429
+ * nearest; but failing with an error report if the double is out of range
430
+ * or unordered.
431
+ */
432
+ extern JS_PUBLIC_API(JSBool)
433
+ JS_ValueToInt32(JSContext *cx, jsval v, int32 *ip);
434
+
435
+ /*
436
+ * ECMA ToUint16, for mapping a jsval to a Unicode point.
437
+ */
438
+ extern JS_PUBLIC_API(JSBool)
439
+ JS_ValueToUint16(JSContext *cx, jsval v, uint16 *ip);
440
+
441
+ extern JS_PUBLIC_API(JSBool)
442
+ JS_ValueToBoolean(JSContext *cx, jsval v, JSBool *bp);
443
+
444
+ extern JS_PUBLIC_API(JSType)
445
+ JS_TypeOfValue(JSContext *cx, jsval v);
446
+
447
+ extern JS_PUBLIC_API(const char *)
448
+ JS_GetTypeName(JSContext *cx, JSType type);
449
+
450
+ /************************************************************************/
451
+
452
+ /*
453
+ * Initialization, locking, contexts, and memory allocation.
454
+ *
455
+ * It is important that the first runtime and first context be created in a
456
+ * single-threaded fashion, otherwise the behavior of the library is undefined.
457
+ * See: http://developer.mozilla.org/en/docs/Category:JSAPI_Reference
458
+ */
459
+ #define JS_NewRuntime JS_Init
460
+ #define JS_DestroyRuntime JS_Finish
461
+ #define JS_LockRuntime JS_Lock
462
+ #define JS_UnlockRuntime JS_Unlock
463
+
464
+ extern JS_PUBLIC_API(JSRuntime *)
465
+ JS_NewRuntime(uint32 maxbytes);
466
+
467
+ extern JS_PUBLIC_API(void)
468
+ JS_DestroyRuntime(JSRuntime *rt);
469
+
470
+ extern JS_PUBLIC_API(void)
471
+ JS_ShutDown(void);
472
+
473
+ JS_PUBLIC_API(void *)
474
+ JS_GetRuntimePrivate(JSRuntime *rt);
475
+
476
+ JS_PUBLIC_API(void)
477
+ JS_SetRuntimePrivate(JSRuntime *rt, void *data);
478
+
479
+ extern JS_PUBLIC_API(void)
480
+ JS_BeginRequest(JSContext *cx);
481
+
482
+ extern JS_PUBLIC_API(void)
483
+ JS_EndRequest(JSContext *cx);
484
+
485
+ /* Yield to pending GC operations, regardless of request depth */
486
+ extern JS_PUBLIC_API(void)
487
+ JS_YieldRequest(JSContext *cx);
488
+
489
+ extern JS_PUBLIC_API(jsrefcount)
490
+ JS_SuspendRequest(JSContext *cx);
491
+
492
+ extern JS_PUBLIC_API(void)
493
+ JS_ResumeRequest(JSContext *cx, jsrefcount saveDepth);
494
+
495
+ #ifdef __cplusplus
496
+ JS_END_EXTERN_C
497
+
498
+ class JSAutoRequest {
499
+ public:
500
+ JSAutoRequest(JSContext *cx) : mContext(cx), mSaveDepth(0) {
501
+ JS_BeginRequest(mContext);
502
+ }
503
+ ~JSAutoRequest() {
504
+ JS_EndRequest(mContext);
505
+ }
506
+
507
+ void suspend() {
508
+ mSaveDepth = JS_SuspendRequest(mContext);
509
+ }
510
+ void resume() {
511
+ JS_ResumeRequest(mContext, mSaveDepth);
512
+ }
513
+
514
+ protected:
515
+ JSContext *mContext;
516
+ jsrefcount mSaveDepth;
517
+
518
+ #if 0
519
+ private:
520
+ static void *operator new(size_t) CPP_THROW_NEW { return 0; };
521
+ static void operator delete(void *, size_t) { };
522
+ #endif
523
+ };
524
+
525
+ class JSAutoSuspendRequest {
526
+ public:
527
+ JSAutoSuspendRequest(JSContext *cx) : mContext(cx), mSaveDepth(0) {
528
+ if (mContext) {
529
+ mSaveDepth = JS_SuspendRequest(mContext);
530
+ }
531
+ }
532
+ ~JSAutoSuspendRequest() {
533
+ resume();
534
+ }
535
+
536
+ void resume() {
537
+ if (mContext) {
538
+ JS_ResumeRequest(mContext, mSaveDepth);
539
+ mContext = 0;
540
+ }
541
+ }
542
+
543
+ protected:
544
+ JSContext *mContext;
545
+ jsrefcount mSaveDepth;
546
+
547
+ #if 0
548
+ private:
549
+ static void *operator new(size_t) CPP_THROW_NEW { return 0; };
550
+ static void operator delete(void *, size_t) { };
551
+ #endif
552
+ };
553
+
554
+ JS_BEGIN_EXTERN_C
555
+ #endif
556
+
557
+ extern JS_PUBLIC_API(void)
558
+ JS_Lock(JSRuntime *rt);
559
+
560
+ extern JS_PUBLIC_API(void)
561
+ JS_Unlock(JSRuntime *rt);
562
+
563
+ extern JS_PUBLIC_API(JSContextCallback)
564
+ JS_SetContextCallback(JSRuntime *rt, JSContextCallback cxCallback);
565
+
566
+ extern JS_PUBLIC_API(JSContext *)
567
+ JS_NewContext(JSRuntime *rt, size_t stackChunkSize);
568
+
569
+ extern JS_PUBLIC_API(void)
570
+ JS_DestroyContext(JSContext *cx);
571
+
572
+ extern JS_PUBLIC_API(void)
573
+ JS_DestroyContextNoGC(JSContext *cx);
574
+
575
+ extern JS_PUBLIC_API(void)
576
+ JS_DestroyContextMaybeGC(JSContext *cx);
577
+
578
+ extern JS_PUBLIC_API(void *)
579
+ JS_GetContextPrivate(JSContext *cx);
580
+
581
+ extern JS_PUBLIC_API(void)
582
+ JS_SetContextPrivate(JSContext *cx, void *data);
583
+
584
+ extern JS_PUBLIC_API(JSRuntime *)
585
+ JS_GetRuntime(JSContext *cx);
586
+
587
+ extern JS_PUBLIC_API(JSContext *)
588
+ JS_ContextIterator(JSRuntime *rt, JSContext **iterp);
589
+
590
+ extern JS_PUBLIC_API(JSVersion)
591
+ JS_GetVersion(JSContext *cx);
592
+
593
+ extern JS_PUBLIC_API(JSVersion)
594
+ JS_SetVersion(JSContext *cx, JSVersion version);
595
+
596
+ extern JS_PUBLIC_API(const char *)
597
+ JS_VersionToString(JSVersion version);
598
+
599
+ extern JS_PUBLIC_API(JSVersion)
600
+ JS_StringToVersion(const char *string);
601
+
602
+ /*
603
+ * JS options are orthogonal to version, and may be freely composed with one
604
+ * another as well as with version.
605
+ *
606
+ * JSOPTION_VAROBJFIX is recommended -- see the comments associated with the
607
+ * prototypes for JS_ExecuteScript, JS_EvaluateScript, etc.
608
+ */
609
+ #define JSOPTION_STRICT JS_BIT(0) /* warn on dubious practice */
610
+ #define JSOPTION_WERROR JS_BIT(1) /* convert warning to error */
611
+ #define JSOPTION_VAROBJFIX JS_BIT(2) /* make JS_EvaluateScript use
612
+ the last object on its 'obj'
613
+ param's scope chain as the
614
+ ECMA 'variables object' */
615
+ #define JSOPTION_PRIVATE_IS_NSISUPPORTS \
616
+ JS_BIT(3) /* context private data points
617
+ to an nsISupports subclass */
618
+ #define JSOPTION_COMPILE_N_GO JS_BIT(4) /* caller of JS_Compile*Script
619
+ promises to execute compiled
620
+ script once only; enables
621
+ compile-time scope chain
622
+ resolution of consts. */
623
+ #define JSOPTION_ATLINE JS_BIT(5) /* //@line number ["filename"]
624
+ option supported for the
625
+ XUL preprocessor and kindred
626
+ beasts. */
627
+ #define JSOPTION_XML JS_BIT(6) /* EMCAScript for XML support:
628
+ parse <!-- --> as a token,
629
+ not backward compatible with
630
+ the comment-hiding hack used
631
+ in HTML script tags. */
632
+ #define JSOPTION_DONT_REPORT_UNCAUGHT \
633
+ JS_BIT(8) /* When returning from the
634
+ outermost API call, prevent
635
+ uncaught exceptions from
636
+ being converted to error
637
+ reports */
638
+
639
+ #define JSOPTION_RELIMIT JS_BIT(9) /* Throw exception on any
640
+ regular expression which
641
+ backtracks more than n^3
642
+ times, where n is length
643
+ of the input string */
644
+ #define JSOPTION_ANONFUNFIX JS_BIT(10) /* Disallow function () {} in
645
+ statement context per
646
+ ECMA-262 Edition 3. */
647
+
648
+ #define JSOPTION_JIT JS_BIT(11) /* Enable JIT compilation. */
649
+
650
+ #define JSOPTION_NO_SCRIPT_RVAL JS_BIT(12) /* A promise to the compiler
651
+ that a null rval out-param
652
+ will be passed to each call
653
+ to JS_ExecuteScript. */
654
+ #define JSOPTION_UNROOTED_GLOBAL JS_BIT(13) /* The GC will not root the
655
+ contexts' global objects
656
+ (see JS_GetGlobalObject),
657
+ leaving that up to the
658
+ embedding. */
659
+
660
+ extern JS_PUBLIC_API(uint32)
661
+ JS_GetOptions(JSContext *cx);
662
+
663
+ extern JS_PUBLIC_API(uint32)
664
+ JS_SetOptions(JSContext *cx, uint32 options);
665
+
666
+ extern JS_PUBLIC_API(uint32)
667
+ JS_ToggleOptions(JSContext *cx, uint32 options);
668
+
669
+ extern JS_PUBLIC_API(const char *)
670
+ JS_GetImplementationVersion(void);
671
+
672
+ extern JS_PUBLIC_API(JSObject *)
673
+ JS_GetGlobalObject(JSContext *cx);
674
+
675
+ extern JS_PUBLIC_API(void)
676
+ JS_SetGlobalObject(JSContext *cx, JSObject *obj);
677
+
678
+ /*
679
+ * Initialize standard JS class constructors, prototypes, and any top-level
680
+ * functions and constants associated with the standard classes (e.g. isNaN
681
+ * for Number).
682
+ *
683
+ * NB: This sets cx's global object to obj if it was null.
684
+ */
685
+ extern JS_PUBLIC_API(JSBool)
686
+ JS_InitStandardClasses(JSContext *cx, JSObject *obj);
687
+
688
+ /*
689
+ * Resolve id, which must contain either a string or an int, to a standard
690
+ * class name in obj if possible, defining the class's constructor and/or
691
+ * prototype and storing true in *resolved. If id does not name a standard
692
+ * class or a top-level property induced by initializing a standard class,
693
+ * store false in *resolved and just return true. Return false on error,
694
+ * as usual for JSBool result-typed API entry points.
695
+ *
696
+ * This API can be called directly from a global object class's resolve op,
697
+ * to define standard classes lazily. The class's enumerate op should call
698
+ * JS_EnumerateStandardClasses(cx, obj), to define eagerly during for..in
699
+ * loops any classes not yet resolved lazily.
700
+ */
701
+ extern JS_PUBLIC_API(JSBool)
702
+ JS_ResolveStandardClass(JSContext *cx, JSObject *obj, jsval id,
703
+ JSBool *resolved);
704
+
705
+ extern JS_PUBLIC_API(JSBool)
706
+ JS_EnumerateStandardClasses(JSContext *cx, JSObject *obj);
707
+
708
+ /*
709
+ * Enumerate any already-resolved standard class ids into ida, or into a new
710
+ * JSIdArray if ida is null. Return the augmented array on success, null on
711
+ * failure with ida (if it was non-null on entry) destroyed.
712
+ */
713
+ extern JS_PUBLIC_API(JSIdArray *)
714
+ JS_EnumerateResolvedStandardClasses(JSContext *cx, JSObject *obj,
715
+ JSIdArray *ida);
716
+
717
+ extern JS_PUBLIC_API(JSBool)
718
+ JS_GetClassObject(JSContext *cx, JSObject *obj, JSProtoKey key,
719
+ JSObject **objp);
720
+
721
+ extern JS_PUBLIC_API(JSObject *)
722
+ JS_GetScopeChain(JSContext *cx);
723
+
724
+ extern JS_PUBLIC_API(JSObject *)
725
+ JS_GetGlobalForObject(JSContext *cx, JSObject *obj);
726
+
727
+ /*
728
+ * Macros to hide interpreter stack layout details from a JSFastNative using
729
+ * its jsval *vp parameter. The stack layout underlying invocation can't change
730
+ * without breaking source and binary compatibility (argv[-2] is well-known to
731
+ * be the callee jsval, and argv[-1] is as well known to be |this|).
732
+ *
733
+ * Note well: However, argv[-1] may be JSVAL_NULL where with slow natives it
734
+ * is the global object, so embeddings implementing fast natives *must* call
735
+ * JS_THIS or JS_THIS_OBJECT and test for failure indicated by a null return,
736
+ * which should propagate as a false return from native functions and hooks.
737
+ *
738
+ * To reduce boilerplace checks, JS_InstanceOf and JS_GetInstancePrivate now
739
+ * handle a null obj parameter by returning false (throwing a TypeError if
740
+ * given non-null argv), so most native functions that type-check their |this|
741
+ * parameter need not add null checking.
742
+ *
743
+ * NB: there is an anti-dependency between JS_CALLEE and JS_SET_RVAL: native
744
+ * methods that may inspect their callee must defer setting their return value
745
+ * until after any such possible inspection. Otherwise the return value will be
746
+ * inspected instead of the callee function object.
747
+ *
748
+ * WARNING: These are not (yet) mandatory macros, but new code outside of the
749
+ * engine should use them. In the Mozilla 2.0 milestone their definitions may
750
+ * change incompatibly.
751
+ */
752
+ #define JS_CALLEE(cx,vp) ((vp)[0])
753
+ #define JS_ARGV_CALLEE(argv) ((argv)[-2])
754
+ #define JS_THIS(cx,vp) JS_ComputeThis(cx, vp)
755
+ #define JS_THIS_OBJECT(cx,vp) ((JSObject *) JS_THIS(cx,vp))
756
+ #define JS_ARGV(cx,vp) ((vp) + 2)
757
+ #define JS_RVAL(cx,vp) (*(vp))
758
+ #define JS_SET_RVAL(cx,vp,v) (*(vp) = (v))
759
+
760
+ extern JS_PUBLIC_API(jsval)
761
+ JS_ComputeThis(JSContext *cx, jsval *vp);
762
+
763
+ extern JS_PUBLIC_API(void *)
764
+ JS_malloc(JSContext *cx, size_t nbytes);
765
+
766
+ extern JS_PUBLIC_API(void *)
767
+ JS_realloc(JSContext *cx, void *p, size_t nbytes);
768
+
769
+ extern JS_PUBLIC_API(void)
770
+ JS_free(JSContext *cx, void *p);
771
+
772
+ extern JS_PUBLIC_API(char *)
773
+ JS_strdup(JSContext *cx, const char *s);
774
+
775
+ extern JS_PUBLIC_API(jsdouble *)
776
+ JS_NewDouble(JSContext *cx, jsdouble d);
777
+
778
+ extern JS_PUBLIC_API(JSBool)
779
+ JS_NewDoubleValue(JSContext *cx, jsdouble d, jsval *rval);
780
+
781
+ extern JS_PUBLIC_API(JSBool)
782
+ JS_NewNumberValue(JSContext *cx, jsdouble d, jsval *rval);
783
+
784
+ /*
785
+ * A JS GC root is a pointer to a JSObject *, JSString *, or jsdouble * that
786
+ * itself points into the GC heap (more recently, we support this extension:
787
+ * a root may be a pointer to a jsval v for which JSVAL_IS_GCTHING(v) is true).
788
+ *
789
+ * Therefore, you never pass JSObject *obj to JS_AddRoot(cx, obj). You always
790
+ * call JS_AddRoot(cx, &obj), passing obj by reference. And later, before obj
791
+ * or the structure it is embedded within goes out of scope or is freed, you
792
+ * must call JS_RemoveRoot(cx, &obj).
793
+ *
794
+ * Also, use JS_AddNamedRoot(cx, &structPtr->memberObj, "structPtr->memberObj")
795
+ * in preference to JS_AddRoot(cx, &structPtr->memberObj), in order to identify
796
+ * roots by their source callsites. This way, you can find the callsite while
797
+ * debugging if you should fail to do JS_RemoveRoot(cx, &structPtr->memberObj)
798
+ * before freeing structPtr's memory.
799
+ */
800
+ extern JS_PUBLIC_API(JSBool)
801
+ JS_AddRoot(JSContext *cx, void *rp);
802
+
803
+ #ifdef NAME_ALL_GC_ROOTS
804
+ #define JS_DEFINE_TO_TOKEN(def) #def
805
+ #define JS_DEFINE_TO_STRING(def) JS_DEFINE_TO_TOKEN(def)
806
+ #define JS_AddRoot(cx,rp) JS_AddNamedRoot((cx), (rp), (__FILE__ ":" JS_TOKEN_TO_STRING(__LINE__))
807
+ #endif
808
+
809
+ extern JS_PUBLIC_API(JSBool)
810
+ JS_AddNamedRoot(JSContext *cx, void *rp, const char *name);
811
+
812
+ extern JS_PUBLIC_API(JSBool)
813
+ JS_AddNamedRootRT(JSRuntime *rt, void *rp, const char *name);
814
+
815
+ extern JS_PUBLIC_API(JSBool)
816
+ JS_RemoveRoot(JSContext *cx, void *rp);
817
+
818
+ extern JS_PUBLIC_API(JSBool)
819
+ JS_RemoveRootRT(JSRuntime *rt, void *rp);
820
+
821
+ /*
822
+ * The last GC thing of each type (object, string, double, external string
823
+ * types) created on a given context is kept alive until another thing of the
824
+ * same type is created, using a newborn root in the context. These newborn
825
+ * roots help native code protect newly-created GC-things from GC invocations
826
+ * activated before those things can be rooted using local or global roots.
827
+ *
828
+ * However, the newborn roots can also entrain great gobs of garbage, so the
829
+ * JS_GC entry point clears them for the context on which GC is being forced.
830
+ * Embeddings may need to do likewise for all contexts.
831
+ *
832
+ * See the scoped local root API immediately below for a better way to manage
833
+ * newborns in cases where native hooks (functions, getters, setters, etc.)
834
+ * create many GC-things, potentially without connecting them to predefined
835
+ * local roots such as *rval or argv[i] in an active native function. Using
836
+ * JS_EnterLocalRootScope disables updating of the context's per-gc-thing-type
837
+ * newborn roots, until control flow unwinds and leaves the outermost nesting
838
+ * local root scope.
839
+ */
840
+ extern JS_PUBLIC_API(void)
841
+ JS_ClearNewbornRoots(JSContext *cx);
842
+
843
+ /*
844
+ * Scoped local root management allows native functions, getter/setters, etc.
845
+ * to avoid worrying about the newborn root pigeon-holes, overloading local
846
+ * roots allocated in argv and *rval, or ending up having to call JS_Add*Root
847
+ * and JS_RemoveRoot to manage global roots temporarily.
848
+ *
849
+ * Instead, calling JS_EnterLocalRootScope and JS_LeaveLocalRootScope around
850
+ * the body of the native hook causes the engine to allocate a local root for
851
+ * each newborn created in between the two API calls, using a local root stack
852
+ * associated with cx. For example:
853
+ *
854
+ * JSBool
855
+ * my_GetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
856
+ * {
857
+ * JSBool ok;
858
+ *
859
+ * if (!JS_EnterLocalRootScope(cx))
860
+ * return JS_FALSE;
861
+ * ok = my_GetPropertyBody(cx, obj, id, vp);
862
+ * JS_LeaveLocalRootScope(cx);
863
+ * return ok;
864
+ * }
865
+ *
866
+ * NB: JS_LeaveLocalRootScope must be called once for every prior successful
867
+ * call to JS_EnterLocalRootScope. If JS_EnterLocalRootScope fails, you must
868
+ * not make the matching JS_LeaveLocalRootScope call.
869
+ *
870
+ * JS_LeaveLocalRootScopeWithResult(cx, rval) is an alternative way to leave
871
+ * a local root scope that protects a result or return value, by effectively
872
+ * pushing it in the caller's local root scope.
873
+ *
874
+ * In case a native hook allocates many objects or other GC-things, but the
875
+ * native protects some of those GC-things by storing them as property values
876
+ * in an object that is itself protected, the hook can call JS_ForgetLocalRoot
877
+ * to free the local root automatically pushed for the now-protected GC-thing.
878
+ *
879
+ * JS_ForgetLocalRoot works on any GC-thing allocated in the current local
880
+ * root scope, but it's more time-efficient when called on references to more
881
+ * recently created GC-things. Calling it successively on other than the most
882
+ * recently allocated GC-thing will tend to average the time inefficiency, and
883
+ * may risk O(n^2) growth rate, but in any event, you shouldn't allocate too
884
+ * many local roots if you can root as you go (build a tree of objects from
885
+ * the top down, forgetting each latest-allocated GC-thing immediately upon
886
+ * linking it to its parent).
887
+ */
888
+ extern JS_PUBLIC_API(JSBool)
889
+ JS_EnterLocalRootScope(JSContext *cx);
890
+
891
+ extern JS_PUBLIC_API(void)
892
+ JS_LeaveLocalRootScope(JSContext *cx);
893
+
894
+ extern JS_PUBLIC_API(void)
895
+ JS_LeaveLocalRootScopeWithResult(JSContext *cx, jsval rval);
896
+
897
+ extern JS_PUBLIC_API(void)
898
+ JS_ForgetLocalRoot(JSContext *cx, void *thing);
899
+
900
+ #ifdef __cplusplus
901
+ JS_END_EXTERN_C
902
+
903
+ class JSAutoLocalRootScope {
904
+ public:
905
+ JSAutoLocalRootScope(JSContext *cx) : mContext(cx) {
906
+ JS_EnterLocalRootScope(mContext);
907
+ }
908
+ ~JSAutoLocalRootScope() {
909
+ JS_LeaveLocalRootScope(mContext);
910
+ }
911
+
912
+ void forget(void *thing) {
913
+ JS_ForgetLocalRoot(mContext, thing);
914
+ }
915
+
916
+ protected:
917
+ JSContext *mContext;
918
+
919
+ #if 0
920
+ private:
921
+ static void *operator new(size_t) CPP_THROW_NEW { return 0; };
922
+ static void operator delete(void *, size_t) { };
923
+ #endif
924
+ };
925
+
926
+ JS_BEGIN_EXTERN_C
927
+ #endif
928
+
929
+ #ifdef DEBUG
930
+ extern JS_PUBLIC_API(void)
931
+ JS_DumpNamedRoots(JSRuntime *rt,
932
+ void (*dump)(const char *name, void *rp, void *data),
933
+ void *data);
934
+ #endif
935
+
936
+ /*
937
+ * Call JS_MapGCRoots to map the GC's roots table using map(rp, name, data).
938
+ * The root is pointed at by rp; if the root is unnamed, name is null; data is
939
+ * supplied from the third parameter to JS_MapGCRoots.
940
+ *
941
+ * The map function should return JS_MAP_GCROOT_REMOVE to cause the currently
942
+ * enumerated root to be removed. To stop enumeration, set JS_MAP_GCROOT_STOP
943
+ * in the return value. To keep on mapping, return JS_MAP_GCROOT_NEXT. These
944
+ * constants are flags; you can OR them together.
945
+ *
946
+ * This function acquires and releases rt's GC lock around the mapping of the
947
+ * roots table, so the map function should run to completion in as few cycles
948
+ * as possible. Of course, map cannot call JS_GC, JS_MaybeGC, JS_BeginRequest,
949
+ * or any JS API entry point that acquires locks, without double-tripping or
950
+ * deadlocking on the GC lock.
951
+ *
952
+ * JS_MapGCRoots returns the count of roots that were successfully mapped.
953
+ */
954
+ #define JS_MAP_GCROOT_NEXT 0 /* continue mapping entries */
955
+ #define JS_MAP_GCROOT_STOP 1 /* stop mapping entries */
956
+ #define JS_MAP_GCROOT_REMOVE 2 /* remove and free the current entry */
957
+
958
+ typedef intN
959
+ (* JSGCRootMapFun)(void *rp, const char *name, void *data);
960
+
961
+ extern JS_PUBLIC_API(uint32)
962
+ JS_MapGCRoots(JSRuntime *rt, JSGCRootMapFun map, void *data);
963
+
964
+ extern JS_PUBLIC_API(JSBool)
965
+ JS_LockGCThing(JSContext *cx, void *thing);
966
+
967
+ extern JS_PUBLIC_API(JSBool)
968
+ JS_LockGCThingRT(JSRuntime *rt, void *thing);
969
+
970
+ extern JS_PUBLIC_API(JSBool)
971
+ JS_UnlockGCThing(JSContext *cx, void *thing);
972
+
973
+ extern JS_PUBLIC_API(JSBool)
974
+ JS_UnlockGCThingRT(JSRuntime *rt, void *thing);
975
+
976
+ /*
977
+ * Register externally maintained GC roots.
978
+ *
979
+ * traceOp: the trace operation. For each root the implementation should call
980
+ * JS_CallTracer whenever the root contains a traceable thing.
981
+ * data: the data argument to pass to each invocation of traceOp.
982
+ */
983
+ extern JS_PUBLIC_API(void)
984
+ JS_SetExtraGCRoots(JSRuntime *rt, JSTraceDataOp traceOp, void *data);
985
+
986
+ /*
987
+ * For implementors of JSMarkOp. All new code should implement JSTraceOp
988
+ * instead.
989
+ */
990
+ extern JS_PUBLIC_API(void)
991
+ JS_MarkGCThing(JSContext *cx, void *thing, const char *name, void *arg);
992
+
993
+ /*
994
+ * JS_CallTracer API and related macros for implementors of JSTraceOp, to
995
+ * enumerate all references to traceable things reachable via a property or
996
+ * other strong ref identified for debugging purposes by name or index or
997
+ * a naming callback.
998
+ *
999
+ * By definition references to traceable things include non-null pointers
1000
+ * to JSObject, JSString and jsdouble and corresponding jsvals.
1001
+ *
1002
+ * See the JSTraceOp typedef in jspubtd.h.
1003
+ */
1004
+
1005
+ /* Trace kinds to pass to JS_Tracing. */
1006
+ #define JSTRACE_OBJECT 0
1007
+ #define JSTRACE_DOUBLE 1
1008
+ #define JSTRACE_STRING 2
1009
+
1010
+ /*
1011
+ * Use the following macros to check if a particular jsval is a traceable
1012
+ * thing and to extract the thing and its kind to pass to JS_CallTracer.
1013
+ */
1014
+ #define JSVAL_IS_TRACEABLE(v) (JSVAL_IS_GCTHING(v) && !JSVAL_IS_NULL(v))
1015
+ #define JSVAL_TO_TRACEABLE(v) (JSVAL_TO_GCTHING(v))
1016
+ #define JSVAL_TRACE_KIND(v) (JSVAL_TAG(v) >> 1)
1017
+
1018
+ struct JSTracer {
1019
+ JSContext *context;
1020
+ JSTraceCallback callback;
1021
+ #ifdef DEBUG
1022
+ JSTraceNamePrinter debugPrinter;
1023
+ const void *debugPrintArg;
1024
+ size_t debugPrintIndex;
1025
+ #endif
1026
+ };
1027
+
1028
+ /*
1029
+ * The method to call on each reference to a traceable thing stored in a
1030
+ * particular JSObject or other runtime structure. With DEBUG defined the
1031
+ * caller before calling JS_CallTracer must initialize JSTracer fields
1032
+ * describing the reference using the macros below.
1033
+ */
1034
+ extern JS_PUBLIC_API(void)
1035
+ JS_CallTracer(JSTracer *trc, void *thing, uint32 kind);
1036
+
1037
+ /*
1038
+ * Set debugging information about a reference to a traceable thing to prepare
1039
+ * for the following call to JS_CallTracer.
1040
+ *
1041
+ * When printer is null, arg must be const char * or char * C string naming
1042
+ * the reference and index must be either (size_t)-1 indicating that the name
1043
+ * alone describes the reference or it must be an index into some array vector
1044
+ * that stores the reference.
1045
+ *
1046
+ * When printer callback is not null, the arg and index arguments are
1047
+ * available to the callback as debugPrinterArg and debugPrintIndex fields
1048
+ * of JSTracer.
1049
+ *
1050
+ * The storage for name or callback's arguments needs to live only until
1051
+ * the following call to JS_CallTracer returns.
1052
+ */
1053
+ #ifdef DEBUG
1054
+ # define JS_SET_TRACING_DETAILS(trc, printer, arg, index) \
1055
+ JS_BEGIN_MACRO \
1056
+ (trc)->debugPrinter = (printer); \
1057
+ (trc)->debugPrintArg = (arg); \
1058
+ (trc)->debugPrintIndex = (index); \
1059
+ JS_END_MACRO
1060
+ #else
1061
+ # define JS_SET_TRACING_DETAILS(trc, printer, arg, index) \
1062
+ JS_BEGIN_MACRO \
1063
+ JS_END_MACRO
1064
+ #endif
1065
+
1066
+ /*
1067
+ * Convenience macro to describe the argument of JS_CallTracer using C string
1068
+ * and index.
1069
+ */
1070
+ # define JS_SET_TRACING_INDEX(trc, name, index) \
1071
+ JS_SET_TRACING_DETAILS(trc, NULL, name, index)
1072
+
1073
+ /*
1074
+ * Convenience macro to describe the argument of JS_CallTracer using C string.
1075
+ */
1076
+ # define JS_SET_TRACING_NAME(trc, name) \
1077
+ JS_SET_TRACING_DETAILS(trc, NULL, name, (size_t)-1)
1078
+
1079
+ /*
1080
+ * Convenience macro to invoke JS_CallTracer using C string as the name for
1081
+ * the reference to a traceable thing.
1082
+ */
1083
+ # define JS_CALL_TRACER(trc, thing, kind, name) \
1084
+ JS_BEGIN_MACRO \
1085
+ JS_SET_TRACING_NAME(trc, name); \
1086
+ JS_CallTracer((trc), (thing), (kind)); \
1087
+ JS_END_MACRO
1088
+
1089
+ /*
1090
+ * Convenience macros to invoke JS_CallTracer when jsval represents a
1091
+ * reference to a traceable thing.
1092
+ */
1093
+ #define JS_CALL_VALUE_TRACER(trc, val, name) \
1094
+ JS_BEGIN_MACRO \
1095
+ if (JSVAL_IS_TRACEABLE(val)) { \
1096
+ JS_CALL_TRACER((trc), JSVAL_TO_GCTHING(val), \
1097
+ JSVAL_TRACE_KIND(val), name); \
1098
+ } \
1099
+ JS_END_MACRO
1100
+
1101
+ #define JS_CALL_OBJECT_TRACER(trc, object, name) \
1102
+ JS_BEGIN_MACRO \
1103
+ JSObject *obj_ = (object); \
1104
+ JS_ASSERT(obj_); \
1105
+ JS_CALL_TRACER((trc), obj_, JSTRACE_OBJECT, name); \
1106
+ JS_END_MACRO
1107
+
1108
+ #define JS_CALL_STRING_TRACER(trc, string, name) \
1109
+ JS_BEGIN_MACRO \
1110
+ JSString *str_ = (string); \
1111
+ JS_ASSERT(str_); \
1112
+ JS_CALL_TRACER((trc), str_, JSTRACE_STRING, name); \
1113
+ JS_END_MACRO
1114
+
1115
+ #define JS_CALL_DOUBLE_TRACER(trc, number, name) \
1116
+ JS_BEGIN_MACRO \
1117
+ jsdouble *num_ = (number); \
1118
+ JS_ASSERT(num_); \
1119
+ JS_CALL_TRACER((trc), num_, JSTRACE_DOUBLE, name); \
1120
+ JS_END_MACRO
1121
+
1122
+ /*
1123
+ * API for JSTraceCallback implementations.
1124
+ */
1125
+ # define JS_TRACER_INIT(trc, cx_, callback_) \
1126
+ JS_BEGIN_MACRO \
1127
+ (trc)->context = (cx_); \
1128
+ (trc)->callback = (callback_); \
1129
+ JS_SET_TRACING_DETAILS(trc, NULL, NULL, (size_t)-1); \
1130
+ JS_END_MACRO
1131
+
1132
+ extern JS_PUBLIC_API(void)
1133
+ JS_TraceChildren(JSTracer *trc, void *thing, uint32 kind);
1134
+
1135
+ extern JS_PUBLIC_API(void)
1136
+ JS_TraceRuntime(JSTracer *trc);
1137
+
1138
+ #ifdef DEBUG
1139
+
1140
+ extern JS_PUBLIC_API(void)
1141
+ JS_PrintTraceThingInfo(char *buf, size_t bufsize, JSTracer *trc,
1142
+ void *thing, uint32 kind, JSBool includeDetails);
1143
+
1144
+ /*
1145
+ * DEBUG-only method to dump the object graph of heap-allocated things.
1146
+ *
1147
+ * fp: file for the dump output.
1148
+ * start: when non-null, dump only things reachable from start
1149
+ * thing. Otherwise dump all things reachable from the
1150
+ * runtime roots.
1151
+ * startKind: trace kind of start if start is not null. Must be 0 when
1152
+ * start is null.
1153
+ * thingToFind: dump only paths in the object graph leading to thingToFind
1154
+ * when non-null.
1155
+ * maxDepth: the upper bound on the number of edges to descend from the
1156
+ * graph roots.
1157
+ * thingToIgnore: thing to ignore during the graph traversal when non-null.
1158
+ */
1159
+ extern JS_PUBLIC_API(JSBool)
1160
+ JS_DumpHeap(JSContext *cx, FILE *fp, void* startThing, uint32 startKind,
1161
+ void *thingToFind, size_t maxDepth, void *thingToIgnore);
1162
+
1163
+ #endif
1164
+
1165
+ /*
1166
+ * Garbage collector API.
1167
+ */
1168
+ extern JS_PUBLIC_API(void)
1169
+ JS_GC(JSContext *cx);
1170
+
1171
+ extern JS_PUBLIC_API(void)
1172
+ JS_MaybeGC(JSContext *cx);
1173
+
1174
+ extern JS_PUBLIC_API(JSGCCallback)
1175
+ JS_SetGCCallback(JSContext *cx, JSGCCallback cb);
1176
+
1177
+ extern JS_PUBLIC_API(JSGCCallback)
1178
+ JS_SetGCCallbackRT(JSRuntime *rt, JSGCCallback cb);
1179
+
1180
+ extern JS_PUBLIC_API(JSBool)
1181
+ JS_IsGCMarkingTracer(JSTracer *trc);
1182
+
1183
+ extern JS_PUBLIC_API(JSBool)
1184
+ JS_IsAboutToBeFinalized(JSContext *cx, void *thing);
1185
+
1186
+ typedef enum JSGCParamKey {
1187
+ /* Maximum nominal heap before last ditch GC. */
1188
+ JSGC_MAX_BYTES = 0,
1189
+
1190
+ /* Number of JS_malloc bytes before last ditch GC. */
1191
+ JSGC_MAX_MALLOC_BYTES = 1,
1192
+
1193
+ /* Hoard stackPools for this long, in ms, default is 30 seconds. */
1194
+ JSGC_STACKPOOL_LIFESPAN = 2,
1195
+
1196
+ /*
1197
+ * The factor that defines when the GC is invoked. The factor is a
1198
+ * percent of the memory allocated by the GC after the last run of
1199
+ * the GC. When the current memory allocated by the GC is more than
1200
+ * this percent then the GC is invoked. The factor cannot be less
1201
+ * than 100 since the current memory allocated by the GC cannot be less
1202
+ * than the memory allocated after the last run of the GC.
1203
+ */
1204
+ JSGC_TRIGGER_FACTOR = 3,
1205
+
1206
+ /* Amount of bytes allocated by the GC. */
1207
+ JSGC_BYTES = 4,
1208
+
1209
+ /* Number of times when GC was invoked. */
1210
+ JSGC_NUMBER = 5,
1211
+
1212
+ /* Max size of the code cache in bytes. */
1213
+ JSGC_MAX_CODE_CACHE_BYTES = 6
1214
+ } JSGCParamKey;
1215
+
1216
+ extern JS_PUBLIC_API(void)
1217
+ JS_SetGCParameter(JSRuntime *rt, JSGCParamKey key, uint32 value);
1218
+
1219
+ extern JS_PUBLIC_API(uint32)
1220
+ JS_GetGCParameter(JSRuntime *rt, JSGCParamKey key);
1221
+
1222
+ extern JS_PUBLIC_API(void)
1223
+ JS_SetGCParameterForThread(JSContext *cx, JSGCParamKey key, uint32 value);
1224
+
1225
+ extern JS_PUBLIC_API(uint32)
1226
+ JS_GetGCParameterForThread(JSContext *cx, JSGCParamKey key);
1227
+
1228
+ /*
1229
+ * Add a finalizer for external strings created by JS_NewExternalString (see
1230
+ * below) using a type-code returned from this function, and that understands
1231
+ * how to free or release the memory pointed at by JS_GetStringChars(str).
1232
+ *
1233
+ * Return a nonnegative type index if there is room for finalizer in the
1234
+ * global GC finalizers table, else return -1. If the engine is compiled
1235
+ * JS_THREADSAFE and used in a multi-threaded environment, this function must
1236
+ * be invoked on the primordial thread only, at startup -- or else the entire
1237
+ * program must single-thread itself while loading a module that calls this
1238
+ * function.
1239
+ */
1240
+ extern JS_PUBLIC_API(intN)
1241
+ JS_AddExternalStringFinalizer(JSStringFinalizeOp finalizer);
1242
+
1243
+ /*
1244
+ * Remove finalizer from the global GC finalizers table, returning its type
1245
+ * code if found, -1 if not found.
1246
+ *
1247
+ * As with JS_AddExternalStringFinalizer, there is a threading restriction
1248
+ * if you compile the engine JS_THREADSAFE: this function may be called for a
1249
+ * given finalizer pointer on only one thread; different threads may call to
1250
+ * remove distinct finalizers safely.
1251
+ *
1252
+ * You must ensure that all strings with finalizer's type have been collected
1253
+ * before calling this function. Otherwise, string data will be leaked by the
1254
+ * GC, for want of a finalizer to call.
1255
+ */
1256
+ extern JS_PUBLIC_API(intN)
1257
+ JS_RemoveExternalStringFinalizer(JSStringFinalizeOp finalizer);
1258
+
1259
+ /*
1260
+ * Create a new JSString whose chars member refers to external memory, i.e.,
1261
+ * memory requiring special, type-specific finalization. The type code must
1262
+ * be a nonnegative return value from JS_AddExternalStringFinalizer.
1263
+ */
1264
+ extern JS_PUBLIC_API(JSString *)
1265
+ JS_NewExternalString(JSContext *cx, jschar *chars, size_t length, intN type);
1266
+
1267
+ /*
1268
+ * Returns the external-string finalizer index for this string, or -1 if it is
1269
+ * an "internal" (native to JS engine) string.
1270
+ */
1271
+ extern JS_PUBLIC_API(intN)
1272
+ JS_GetExternalStringGCType(JSRuntime *rt, JSString *str);
1273
+
1274
+ /*
1275
+ * Sets maximum (if stack grows upward) or minimum (downward) legal stack byte
1276
+ * address in limitAddr for the thread or process stack used by cx. To disable
1277
+ * stack size checking, pass 0 for limitAddr.
1278
+ */
1279
+ extern JS_PUBLIC_API(void)
1280
+ JS_SetThreadStackLimit(JSContext *cx, jsuword limitAddr);
1281
+
1282
+ /*
1283
+ * Set the quota on the number of bytes that stack-like data structures can
1284
+ * use when the runtime compiles and executes scripts. These structures
1285
+ * consume heap space, so JS_SetThreadStackLimit does not bound their size.
1286
+ * The default quota is 32MB which is quite generous.
1287
+ *
1288
+ * The function must be called before any script compilation or execution API
1289
+ * calls, i.e. either immediately after JS_NewContext or from JSCONTEXT_NEW
1290
+ * context callback.
1291
+ */
1292
+ extern JS_PUBLIC_API(void)
1293
+ JS_SetScriptStackQuota(JSContext *cx, size_t quota);
1294
+
1295
+ #define JS_DEFAULT_SCRIPT_STACK_QUOTA ((size_t) 0x2000000)
1296
+
1297
+ /************************************************************************/
1298
+
1299
+ /*
1300
+ * Classes, objects, and properties.
1301
+ */
1302
+
1303
+ /* For detailed comments on the function pointer types, see jspubtd.h. */
1304
+ struct JSClass {
1305
+ const char *name;
1306
+ uint32 flags;
1307
+
1308
+ /* Mandatory non-null function pointer members. */
1309
+ JSPropertyOp addProperty;
1310
+ JSPropertyOp delProperty;
1311
+ JSPropertyOp getProperty;
1312
+ JSPropertyOp setProperty;
1313
+ JSEnumerateOp enumerate;
1314
+ JSResolveOp resolve;
1315
+ JSConvertOp convert;
1316
+ JSFinalizeOp finalize;
1317
+
1318
+ /* Optionally non-null members start here. */
1319
+ JSGetObjectOps getObjectOps;
1320
+ JSCheckAccessOp checkAccess;
1321
+ JSNative call;
1322
+ JSNative construct;
1323
+ JSXDRObjectOp xdrObject;
1324
+ JSHasInstanceOp hasInstance;
1325
+ JSMarkOp mark;
1326
+ JSReserveSlotsOp reserveSlots;
1327
+ };
1328
+
1329
+ struct JSExtendedClass {
1330
+ JSClass base;
1331
+ JSEqualityOp equality;
1332
+ JSObjectOp outerObject;
1333
+ JSObjectOp innerObject;
1334
+ JSIteratorOp iteratorObject;
1335
+ JSObjectOp wrappedObject; /* NB: infallible, null
1336
+ returns are treated as
1337
+ the original object */
1338
+ void (*reserved0)(void);
1339
+ void (*reserved1)(void);
1340
+ void (*reserved2)(void);
1341
+ };
1342
+
1343
+ #define JSCLASS_HAS_PRIVATE (1<<0) /* objects have private slot */
1344
+ #define JSCLASS_NEW_ENUMERATE (1<<1) /* has JSNewEnumerateOp hook */
1345
+ #define JSCLASS_NEW_RESOLVE (1<<2) /* has JSNewResolveOp hook */
1346
+ #define JSCLASS_PRIVATE_IS_NSISUPPORTS (1<<3) /* private is (nsISupports *) */
1347
+ #define JSCLASS_SHARE_ALL_PROPERTIES (1<<4) /* all properties are SHARED */
1348
+ #define JSCLASS_NEW_RESOLVE_GETS_START (1<<5) /* JSNewResolveOp gets starting
1349
+ object in prototype chain
1350
+ passed in via *objp in/out
1351
+ parameter */
1352
+ #define JSCLASS_CONSTRUCT_PROTOTYPE (1<<6) /* call constructor on class
1353
+ prototype */
1354
+ #define JSCLASS_DOCUMENT_OBSERVER (1<<7) /* DOM document observer */
1355
+
1356
+ /*
1357
+ * To reserve slots fetched and stored via JS_Get/SetReservedSlot, bitwise-or
1358
+ * JSCLASS_HAS_RESERVED_SLOTS(n) into the initializer for JSClass.flags, where
1359
+ * n is a constant in [1, 255]. Reserved slots are indexed from 0 to n-1.
1360
+ */
1361
+ #define JSCLASS_RESERVED_SLOTS_SHIFT 8 /* room for 8 flags below */
1362
+ #define JSCLASS_RESERVED_SLOTS_WIDTH 8 /* and 16 above this field */
1363
+ #define JSCLASS_RESERVED_SLOTS_MASK JS_BITMASK(JSCLASS_RESERVED_SLOTS_WIDTH)
1364
+ #define JSCLASS_HAS_RESERVED_SLOTS(n) (((n) & JSCLASS_RESERVED_SLOTS_MASK) \
1365
+ << JSCLASS_RESERVED_SLOTS_SHIFT)
1366
+ #define JSCLASS_RESERVED_SLOTS(clasp) (((clasp)->flags \
1367
+ >> JSCLASS_RESERVED_SLOTS_SHIFT) \
1368
+ & JSCLASS_RESERVED_SLOTS_MASK)
1369
+
1370
+ #define JSCLASS_HIGH_FLAGS_SHIFT (JSCLASS_RESERVED_SLOTS_SHIFT + \
1371
+ JSCLASS_RESERVED_SLOTS_WIDTH)
1372
+
1373
+ /* True if JSClass is really a JSExtendedClass. */
1374
+ #define JSCLASS_IS_EXTENDED (1<<(JSCLASS_HIGH_FLAGS_SHIFT+0))
1375
+ #define JSCLASS_IS_ANONYMOUS (1<<(JSCLASS_HIGH_FLAGS_SHIFT+1))
1376
+ #define JSCLASS_IS_GLOBAL (1<<(JSCLASS_HIGH_FLAGS_SHIFT+2))
1377
+
1378
+ /* Indicates that JSClass.mark is a tracer with JSTraceOp type. */
1379
+ #define JSCLASS_MARK_IS_TRACE (1<<(JSCLASS_HIGH_FLAGS_SHIFT+3))
1380
+
1381
+ /*
1382
+ * ECMA-262 requires that most constructors used internally create objects
1383
+ * with "the original Foo.prototype value" as their [[Prototype]] (__proto__)
1384
+ * member initial value. The "original ... value" verbiage is there because
1385
+ * in ECMA-262, global properties naming class objects are read/write and
1386
+ * deleteable, for the most part.
1387
+ *
1388
+ * Implementing this efficiently requires that global objects have classes
1389
+ * with the following flags. Failure to use JSCLASS_GLOBAL_FLAGS won't break
1390
+ * anything except the ECMA-262 "original prototype value" behavior, which was
1391
+ * broken for years in SpiderMonkey. In other words, without these flags you
1392
+ * get backward compatibility.
1393
+ */
1394
+ #define JSCLASS_GLOBAL_FLAGS \
1395
+ (JSCLASS_IS_GLOBAL | JSCLASS_HAS_RESERVED_SLOTS(JSProto_LIMIT))
1396
+
1397
+ /* Fast access to the original value of each standard class's prototype. */
1398
+ #define JSCLASS_CACHED_PROTO_SHIFT (JSCLASS_HIGH_FLAGS_SHIFT + 8)
1399
+ #define JSCLASS_CACHED_PROTO_WIDTH 8
1400
+ #define JSCLASS_CACHED_PROTO_MASK JS_BITMASK(JSCLASS_CACHED_PROTO_WIDTH)
1401
+ #define JSCLASS_HAS_CACHED_PROTO(key) ((key) << JSCLASS_CACHED_PROTO_SHIFT)
1402
+ #define JSCLASS_CACHED_PROTO_KEY(clasp) ((JSProtoKey) \
1403
+ (((clasp)->flags \
1404
+ >> JSCLASS_CACHED_PROTO_SHIFT) \
1405
+ & JSCLASS_CACHED_PROTO_MASK))
1406
+
1407
+ /* Initializer for unused members of statically initialized JSClass structs. */
1408
+ #define JSCLASS_NO_OPTIONAL_MEMBERS 0,0,0,0,0,0,0,0
1409
+ #define JSCLASS_NO_RESERVED_MEMBERS 0,0,0
1410
+
1411
+ struct JSIdArray {
1412
+ jsint length;
1413
+ jsid vector[1]; /* actually, length jsid words */
1414
+ };
1415
+
1416
+ extern JS_PUBLIC_API(void)
1417
+ JS_DestroyIdArray(JSContext *cx, JSIdArray *ida);
1418
+
1419
+ extern JS_PUBLIC_API(JSBool)
1420
+ JS_ValueToId(JSContext *cx, jsval v, jsid *idp);
1421
+
1422
+ extern JS_PUBLIC_API(JSBool)
1423
+ JS_IdToValue(JSContext *cx, jsid id, jsval *vp);
1424
+
1425
+ /*
1426
+ * The magic XML namespace id is int-tagged, but not a valid integer jsval.
1427
+ * Global object classes in embeddings that enable JS_HAS_XML_SUPPORT (E4X)
1428
+ * should handle this id specially before converting id via JSVAL_TO_INT.
1429
+ */
1430
+ #define JS_DEFAULT_XML_NAMESPACE_ID ((jsid) JSVAL_VOID)
1431
+
1432
+ /*
1433
+ * JSNewResolveOp flag bits.
1434
+ */
1435
+ #define JSRESOLVE_QUALIFIED 0x01 /* resolve a qualified property id */
1436
+ #define JSRESOLVE_ASSIGNING 0x02 /* resolve on the left of assignment */
1437
+ #define JSRESOLVE_DETECTING 0x04 /* 'if (o.p)...' or '(o.p) ?...:...' */
1438
+ #define JSRESOLVE_DECLARING 0x08 /* var, const, or function prolog op */
1439
+ #define JSRESOLVE_CLASSNAME 0x10 /* class name used when constructing */
1440
+ #define JSRESOLVE_WITH 0x20 /* resolve inside a with statement */
1441
+
1442
+ extern JS_PUBLIC_API(JSBool)
1443
+ JS_PropertyStub(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
1444
+
1445
+ extern JS_PUBLIC_API(JSBool)
1446
+ JS_EnumerateStub(JSContext *cx, JSObject *obj);
1447
+
1448
+ extern JS_PUBLIC_API(JSBool)
1449
+ JS_ResolveStub(JSContext *cx, JSObject *obj, jsval id);
1450
+
1451
+ extern JS_PUBLIC_API(JSBool)
1452
+ JS_ConvertStub(JSContext *cx, JSObject *obj, JSType type, jsval *vp);
1453
+
1454
+ extern JS_PUBLIC_API(void)
1455
+ JS_FinalizeStub(JSContext *cx, JSObject *obj);
1456
+
1457
+ struct JSConstDoubleSpec {
1458
+ jsdouble dval;
1459
+ const char *name;
1460
+ uint8 flags;
1461
+ uint8 spare[3];
1462
+ };
1463
+
1464
+ /*
1465
+ * To define an array element rather than a named property member, cast the
1466
+ * element's index to (const char *) and initialize name with it, and set the
1467
+ * JSPROP_INDEX bit in flags.
1468
+ */
1469
+ struct JSPropertySpec {
1470
+ const char *name;
1471
+ int8 tinyid;
1472
+ uint8 flags;
1473
+ JSPropertyOp getter;
1474
+ JSPropertyOp setter;
1475
+ };
1476
+
1477
+ struct JSFunctionSpec {
1478
+ const char *name;
1479
+ JSNative call;
1480
+ uint16 nargs;
1481
+ uint16 flags;
1482
+
1483
+ /*
1484
+ * extra & 0xFFFF: Number of extra argument slots for local GC roots.
1485
+ * If fast native, must be zero.
1486
+ * extra >> 16: Reserved for future use (must be 0).
1487
+ */
1488
+ uint32 extra;
1489
+ };
1490
+
1491
+ /*
1492
+ * Terminating sentinel initializer to put at the end of a JSFunctionSpec array
1493
+ * that's passed to JS_DefineFunctions or JS_InitClass.
1494
+ */
1495
+ #define JS_FS_END JS_FS(NULL,NULL,0,0,0)
1496
+
1497
+ /*
1498
+ * Initializer macro for a JSFunctionSpec array element. This is the original
1499
+ * kind of native function specifier initializer. Use JS_FN ("fast native", see
1500
+ * JSFastNative in jspubtd.h) for all functions that do not need a stack frame
1501
+ * when activated.
1502
+ */
1503
+ #define JS_FS(name,call,nargs,flags,extra) \
1504
+ {name, call, nargs, flags, extra}
1505
+
1506
+ /*
1507
+ * "Fast native" initializer macro for a JSFunctionSpec array element. Use this
1508
+ * in preference to JS_FS if the native in question does not need its own stack
1509
+ * frame when activated.
1510
+ */
1511
+ #define JS_FN(name,fastcall,nargs,flags) \
1512
+ JS_FS(name, (JSNative)(fastcall), nargs, \
1513
+ (flags) | JSFUN_FAST_NATIVE | JSFUN_STUB_GSOPS, 0)
1514
+
1515
+ extern JS_PUBLIC_API(JSObject *)
1516
+ JS_InitClass(JSContext *cx, JSObject *obj, JSObject *parent_proto,
1517
+ JSClass *clasp, JSNative constructor, uintN nargs,
1518
+ JSPropertySpec *ps, JSFunctionSpec *fs,
1519
+ JSPropertySpec *static_ps, JSFunctionSpec *static_fs);
1520
+
1521
+ #ifdef JS_THREADSAFE
1522
+ extern JS_PUBLIC_API(JSClass *)
1523
+ JS_GetClass(JSContext *cx, JSObject *obj);
1524
+
1525
+ #define JS_GET_CLASS(cx,obj) JS_GetClass(cx, obj)
1526
+ #else
1527
+ extern JS_PUBLIC_API(JSClass *)
1528
+ JS_GetClass(JSObject *obj);
1529
+
1530
+ #define JS_GET_CLASS(cx,obj) JS_GetClass(obj)
1531
+ #endif
1532
+
1533
+ extern JS_PUBLIC_API(JSBool)
1534
+ JS_InstanceOf(JSContext *cx, JSObject *obj, JSClass *clasp, jsval *argv);
1535
+
1536
+ extern JS_PUBLIC_API(JSBool)
1537
+ JS_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp);
1538
+
1539
+ extern JS_PUBLIC_API(void *)
1540
+ JS_GetPrivate(JSContext *cx, JSObject *obj);
1541
+
1542
+ extern JS_PUBLIC_API(JSBool)
1543
+ JS_SetPrivate(JSContext *cx, JSObject *obj, void *data);
1544
+
1545
+ extern JS_PUBLIC_API(void *)
1546
+ JS_GetInstancePrivate(JSContext *cx, JSObject *obj, JSClass *clasp,
1547
+ jsval *argv);
1548
+
1549
+ extern JS_PUBLIC_API(JSObject *)
1550
+ JS_GetPrototype(JSContext *cx, JSObject *obj);
1551
+
1552
+ extern JS_PUBLIC_API(JSBool)
1553
+ JS_SetPrototype(JSContext *cx, JSObject *obj, JSObject *proto);
1554
+
1555
+ extern JS_PUBLIC_API(JSObject *)
1556
+ JS_GetParent(JSContext *cx, JSObject *obj);
1557
+
1558
+ extern JS_PUBLIC_API(JSBool)
1559
+ JS_SetParent(JSContext *cx, JSObject *obj, JSObject *parent);
1560
+
1561
+ extern JS_PUBLIC_API(JSObject *)
1562
+ JS_GetConstructor(JSContext *cx, JSObject *proto);
1563
+
1564
+ /*
1565
+ * Get a unique identifier for obj, good for the lifetime of obj (even if it
1566
+ * is moved by a copying GC). Return false on failure (likely out of memory),
1567
+ * and true with *idp containing the unique id on success.
1568
+ */
1569
+ extern JS_PUBLIC_API(JSBool)
1570
+ JS_GetObjectId(JSContext *cx, JSObject *obj, jsid *idp);
1571
+
1572
+ extern JS_PUBLIC_API(JSObject *)
1573
+ JS_NewObject(JSContext *cx, JSClass *clasp, JSObject *proto, JSObject *parent);
1574
+
1575
+ /*
1576
+ * Unlike JS_NewObject, JS_NewObjectWithGivenProto does not compute a default
1577
+ * proto if proto's actual parameter value is null.
1578
+ */
1579
+ extern JS_PUBLIC_API(JSObject *)
1580
+ JS_NewObjectWithGivenProto(JSContext *cx, JSClass *clasp, JSObject *proto,
1581
+ JSObject *parent);
1582
+
1583
+ extern JS_PUBLIC_API(JSBool)
1584
+ JS_SealObject(JSContext *cx, JSObject *obj, JSBool deep);
1585
+
1586
+ extern JS_PUBLIC_API(JSObject *)
1587
+ JS_ConstructObject(JSContext *cx, JSClass *clasp, JSObject *proto,
1588
+ JSObject *parent);
1589
+
1590
+ extern JS_PUBLIC_API(JSObject *)
1591
+ JS_ConstructObjectWithArguments(JSContext *cx, JSClass *clasp, JSObject *proto,
1592
+ JSObject *parent, uintN argc, jsval *argv);
1593
+
1594
+ extern JS_PUBLIC_API(JSObject *)
1595
+ JS_DefineObject(JSContext *cx, JSObject *obj, const char *name, JSClass *clasp,
1596
+ JSObject *proto, uintN attrs);
1597
+
1598
+ extern JS_PUBLIC_API(JSBool)
1599
+ JS_DefineConstDoubles(JSContext *cx, JSObject *obj, JSConstDoubleSpec *cds);
1600
+
1601
+ extern JS_PUBLIC_API(JSBool)
1602
+ JS_DefineProperties(JSContext *cx, JSObject *obj, JSPropertySpec *ps);
1603
+
1604
+ extern JS_PUBLIC_API(JSBool)
1605
+ JS_DefineProperty(JSContext *cx, JSObject *obj, const char *name, jsval value,
1606
+ JSPropertyOp getter, JSPropertyOp setter, uintN attrs);
1607
+
1608
+ extern JS_PUBLIC_API(JSBool)
1609
+ JS_DefinePropertyById(JSContext *cx, JSObject *obj, jsid id, jsval value,
1610
+ JSPropertyOp getter, JSPropertyOp setter, uintN attrs);
1611
+
1612
+ /*
1613
+ * Determine the attributes (JSPROP_* flags) of a property on a given object.
1614
+ *
1615
+ * If the object does not have a property by that name, *foundp will be
1616
+ * JS_FALSE and the value of *attrsp is undefined.
1617
+ */
1618
+ extern JS_PUBLIC_API(JSBool)
1619
+ JS_GetPropertyAttributes(JSContext *cx, JSObject *obj, const char *name,
1620
+ uintN *attrsp, JSBool *foundp);
1621
+
1622
+ /*
1623
+ * The same, but if the property is native, return its getter and setter via
1624
+ * *getterp and *setterp, respectively (and only if the out parameter pointer
1625
+ * is not null).
1626
+ */
1627
+ extern JS_PUBLIC_API(JSBool)
1628
+ JS_GetPropertyAttrsGetterAndSetter(JSContext *cx, JSObject *obj,
1629
+ const char *name,
1630
+ uintN *attrsp, JSBool *foundp,
1631
+ JSPropertyOp *getterp,
1632
+ JSPropertyOp *setterp);
1633
+
1634
+ extern JS_PUBLIC_API(JSBool)
1635
+ JS_GetPropertyAttrsGetterAndSetterById(JSContext *cx, JSObject *obj,
1636
+ jsid id,
1637
+ uintN *attrsp, JSBool *foundp,
1638
+ JSPropertyOp *getterp,
1639
+ JSPropertyOp *setterp);
1640
+
1641
+ /*
1642
+ * Set the attributes of a property on a given object.
1643
+ *
1644
+ * If the object does not have a property by that name, *foundp will be
1645
+ * JS_FALSE and nothing will be altered.
1646
+ */
1647
+ extern JS_PUBLIC_API(JSBool)
1648
+ JS_SetPropertyAttributes(JSContext *cx, JSObject *obj, const char *name,
1649
+ uintN attrs, JSBool *foundp);
1650
+
1651
+ extern JS_PUBLIC_API(JSBool)
1652
+ JS_DefinePropertyWithTinyId(JSContext *cx, JSObject *obj, const char *name,
1653
+ int8 tinyid, jsval value,
1654
+ JSPropertyOp getter, JSPropertyOp setter,
1655
+ uintN attrs);
1656
+
1657
+ extern JS_PUBLIC_API(JSBool)
1658
+ JS_AliasProperty(JSContext *cx, JSObject *obj, const char *name,
1659
+ const char *alias);
1660
+
1661
+ extern JS_PUBLIC_API(JSBool)
1662
+ JS_AlreadyHasOwnProperty(JSContext *cx, JSObject *obj, const char *name,
1663
+ JSBool *foundp);
1664
+
1665
+ extern JS_PUBLIC_API(JSBool)
1666
+ JS_AlreadyHasOwnPropertyById(JSContext *cx, JSObject *obj, jsid id,
1667
+ JSBool *foundp);
1668
+
1669
+ extern JS_PUBLIC_API(JSBool)
1670
+ JS_HasProperty(JSContext *cx, JSObject *obj, const char *name, JSBool *foundp);
1671
+
1672
+ extern JS_PUBLIC_API(JSBool)
1673
+ JS_HasPropertyById(JSContext *cx, JSObject *obj, jsid id, JSBool *foundp);
1674
+
1675
+ extern JS_PUBLIC_API(JSBool)
1676
+ JS_LookupProperty(JSContext *cx, JSObject *obj, const char *name, jsval *vp);
1677
+
1678
+ extern JS_PUBLIC_API(JSBool)
1679
+ JS_LookupPropertyById(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
1680
+
1681
+ extern JS_PUBLIC_API(JSBool)
1682
+ JS_LookupPropertyWithFlags(JSContext *cx, JSObject *obj, const char *name,
1683
+ uintN flags, jsval *vp);
1684
+
1685
+ extern JS_PUBLIC_API(JSBool)
1686
+ JS_LookupPropertyWithFlagsById(JSContext *cx, JSObject *obj, jsid id,
1687
+ uintN flags, JSObject **objp, jsval *vp);
1688
+
1689
+ struct JSPropertyDescriptor {
1690
+ JSObject *obj;
1691
+ uintN attrs;
1692
+ JSPropertyOp getter;
1693
+ JSPropertyOp setter;
1694
+ jsval value;
1695
+ };
1696
+
1697
+ /*
1698
+ * Like JS_GetPropertyAttrsGetterAndSetterById but will return a property on
1699
+ * an object on the prototype chain (returned in objp). If data->obj is null,
1700
+ * then this property was not found on the prototype chain.
1701
+ */
1702
+ extern JS_PUBLIC_API(JSBool)
1703
+ JS_GetPropertyDescriptorById(JSContext *cx, JSObject *obj, jsid id, uintN flags,
1704
+ JSPropertyDescriptor *desc);
1705
+
1706
+ extern JS_PUBLIC_API(JSBool)
1707
+ JS_GetProperty(JSContext *cx, JSObject *obj, const char *name, jsval *vp);
1708
+
1709
+ extern JS_PUBLIC_API(JSBool)
1710
+ JS_GetPropertyById(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
1711
+
1712
+ extern JS_PUBLIC_API(JSBool)
1713
+ JS_GetMethodById(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
1714
+ jsval *vp);
1715
+
1716
+ extern JS_PUBLIC_API(JSBool)
1717
+ JS_GetMethod(JSContext *cx, JSObject *obj, const char *name, JSObject **objp,
1718
+ jsval *vp);
1719
+
1720
+ extern JS_PUBLIC_API(JSBool)
1721
+ JS_SetProperty(JSContext *cx, JSObject *obj, const char *name, jsval *vp);
1722
+
1723
+ extern JS_PUBLIC_API(JSBool)
1724
+ JS_SetPropertyById(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
1725
+
1726
+ extern JS_PUBLIC_API(JSBool)
1727
+ JS_DeleteProperty(JSContext *cx, JSObject *obj, const char *name);
1728
+
1729
+ extern JS_PUBLIC_API(JSBool)
1730
+ JS_DeleteProperty2(JSContext *cx, JSObject *obj, const char *name,
1731
+ jsval *rval);
1732
+
1733
+ extern JS_PUBLIC_API(JSBool)
1734
+ JS_DeletePropertyById(JSContext *cx, JSObject *obj, jsid id);
1735
+
1736
+ extern JS_PUBLIC_API(JSBool)
1737
+ JS_DeletePropertyById2(JSContext *cx, JSObject *obj, jsid id, jsval *rval);
1738
+
1739
+ extern JS_PUBLIC_API(JSBool)
1740
+ JS_DefineUCProperty(JSContext *cx, JSObject *obj,
1741
+ const jschar *name, size_t namelen, jsval value,
1742
+ JSPropertyOp getter, JSPropertyOp setter,
1743
+ uintN attrs);
1744
+
1745
+ /*
1746
+ * Determine the attributes (JSPROP_* flags) of a property on a given object.
1747
+ *
1748
+ * If the object does not have a property by that name, *foundp will be
1749
+ * JS_FALSE and the value of *attrsp is undefined.
1750
+ */
1751
+ extern JS_PUBLIC_API(JSBool)
1752
+ JS_GetUCPropertyAttributes(JSContext *cx, JSObject *obj,
1753
+ const jschar *name, size_t namelen,
1754
+ uintN *attrsp, JSBool *foundp);
1755
+
1756
+ /*
1757
+ * The same, but if the property is native, return its getter and setter via
1758
+ * *getterp and *setterp, respectively (and only if the out parameter pointer
1759
+ * is not null).
1760
+ */
1761
+ extern JS_PUBLIC_API(JSBool)
1762
+ JS_GetUCPropertyAttrsGetterAndSetter(JSContext *cx, JSObject *obj,
1763
+ const jschar *name, size_t namelen,
1764
+ uintN *attrsp, JSBool *foundp,
1765
+ JSPropertyOp *getterp,
1766
+ JSPropertyOp *setterp);
1767
+
1768
+ /*
1769
+ * Set the attributes of a property on a given object.
1770
+ *
1771
+ * If the object does not have a property by that name, *foundp will be
1772
+ * JS_FALSE and nothing will be altered.
1773
+ */
1774
+ extern JS_PUBLIC_API(JSBool)
1775
+ JS_SetUCPropertyAttributes(JSContext *cx, JSObject *obj,
1776
+ const jschar *name, size_t namelen,
1777
+ uintN attrs, JSBool *foundp);
1778
+
1779
+
1780
+ extern JS_PUBLIC_API(JSBool)
1781
+ JS_DefineUCPropertyWithTinyId(JSContext *cx, JSObject *obj,
1782
+ const jschar *name, size_t namelen,
1783
+ int8 tinyid, jsval value,
1784
+ JSPropertyOp getter, JSPropertyOp setter,
1785
+ uintN attrs);
1786
+
1787
+ extern JS_PUBLIC_API(JSBool)
1788
+ JS_AlreadyHasOwnUCProperty(JSContext *cx, JSObject *obj, const jschar *name,
1789
+ size_t namelen, JSBool *foundp);
1790
+
1791
+ extern JS_PUBLIC_API(JSBool)
1792
+ JS_HasUCProperty(JSContext *cx, JSObject *obj,
1793
+ const jschar *name, size_t namelen,
1794
+ JSBool *vp);
1795
+
1796
+ extern JS_PUBLIC_API(JSBool)
1797
+ JS_LookupUCProperty(JSContext *cx, JSObject *obj,
1798
+ const jschar *name, size_t namelen,
1799
+ jsval *vp);
1800
+
1801
+ extern JS_PUBLIC_API(JSBool)
1802
+ JS_GetUCProperty(JSContext *cx, JSObject *obj,
1803
+ const jschar *name, size_t namelen,
1804
+ jsval *vp);
1805
+
1806
+ extern JS_PUBLIC_API(JSBool)
1807
+ JS_SetUCProperty(JSContext *cx, JSObject *obj,
1808
+ const jschar *name, size_t namelen,
1809
+ jsval *vp);
1810
+
1811
+ extern JS_PUBLIC_API(JSBool)
1812
+ JS_DeleteUCProperty2(JSContext *cx, JSObject *obj,
1813
+ const jschar *name, size_t namelen,
1814
+ jsval *rval);
1815
+
1816
+ extern JS_PUBLIC_API(JSObject *)
1817
+ JS_NewArrayObject(JSContext *cx, jsint length, jsval *vector);
1818
+
1819
+ extern JS_PUBLIC_API(JSBool)
1820
+ JS_IsArrayObject(JSContext *cx, JSObject *obj);
1821
+
1822
+ extern JS_PUBLIC_API(JSBool)
1823
+ JS_GetArrayLength(JSContext *cx, JSObject *obj, jsuint *lengthp);
1824
+
1825
+ extern JS_PUBLIC_API(JSBool)
1826
+ JS_SetArrayLength(JSContext *cx, JSObject *obj, jsuint length);
1827
+
1828
+ extern JS_PUBLIC_API(JSBool)
1829
+ JS_HasArrayLength(JSContext *cx, JSObject *obj, jsuint *lengthp);
1830
+
1831
+ extern JS_PUBLIC_API(JSBool)
1832
+ JS_DefineElement(JSContext *cx, JSObject *obj, jsint index, jsval value,
1833
+ JSPropertyOp getter, JSPropertyOp setter, uintN attrs);
1834
+
1835
+ extern JS_PUBLIC_API(JSBool)
1836
+ JS_AliasElement(JSContext *cx, JSObject *obj, const char *name, jsint alias);
1837
+
1838
+ extern JS_PUBLIC_API(JSBool)
1839
+ JS_AlreadyHasOwnElement(JSContext *cx, JSObject *obj, jsint index,
1840
+ JSBool *foundp);
1841
+
1842
+ extern JS_PUBLIC_API(JSBool)
1843
+ JS_HasElement(JSContext *cx, JSObject *obj, jsint index, JSBool *foundp);
1844
+
1845
+ extern JS_PUBLIC_API(JSBool)
1846
+ JS_LookupElement(JSContext *cx, JSObject *obj, jsint index, jsval *vp);
1847
+
1848
+ extern JS_PUBLIC_API(JSBool)
1849
+ JS_GetElement(JSContext *cx, JSObject *obj, jsint index, jsval *vp);
1850
+
1851
+ extern JS_PUBLIC_API(JSBool)
1852
+ JS_SetElement(JSContext *cx, JSObject *obj, jsint index, jsval *vp);
1853
+
1854
+ extern JS_PUBLIC_API(JSBool)
1855
+ JS_DeleteElement(JSContext *cx, JSObject *obj, jsint index);
1856
+
1857
+ extern JS_PUBLIC_API(JSBool)
1858
+ JS_DeleteElement2(JSContext *cx, JSObject *obj, jsint index, jsval *rval);
1859
+
1860
+ extern JS_PUBLIC_API(void)
1861
+ JS_ClearScope(JSContext *cx, JSObject *obj);
1862
+
1863
+ extern JS_PUBLIC_API(JSIdArray *)
1864
+ JS_Enumerate(JSContext *cx, JSObject *obj);
1865
+
1866
+ /*
1867
+ * Create an object to iterate over enumerable properties of obj, in arbitrary
1868
+ * property definition order. NB: This differs from longstanding for..in loop
1869
+ * order, which uses order of property definition in obj.
1870
+ */
1871
+ extern JS_PUBLIC_API(JSObject *)
1872
+ JS_NewPropertyIterator(JSContext *cx, JSObject *obj);
1873
+
1874
+ /*
1875
+ * Return true on success with *idp containing the id of the next enumerable
1876
+ * property to visit using iterobj, or JSVAL_VOID if there is no such property
1877
+ * left to visit. Return false on error.
1878
+ */
1879
+ extern JS_PUBLIC_API(JSBool)
1880
+ JS_NextProperty(JSContext *cx, JSObject *iterobj, jsid *idp);
1881
+
1882
+ extern JS_PUBLIC_API(JSBool)
1883
+ JS_CheckAccess(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode,
1884
+ jsval *vp, uintN *attrsp);
1885
+
1886
+ extern JS_PUBLIC_API(JSBool)
1887
+ JS_GetReservedSlot(JSContext *cx, JSObject *obj, uint32 index, jsval *vp);
1888
+
1889
+ extern JS_PUBLIC_API(JSBool)
1890
+ JS_SetReservedSlot(JSContext *cx, JSObject *obj, uint32 index, jsval v);
1891
+
1892
+ /************************************************************************/
1893
+
1894
+ /*
1895
+ * Security protocol.
1896
+ */
1897
+ struct JSPrincipals {
1898
+ char *codebase;
1899
+
1900
+ /* XXX unspecified and unused by Mozilla code -- can we remove these? */
1901
+ void * (* getPrincipalArray)(JSContext *cx, JSPrincipals *);
1902
+ JSBool (* globalPrivilegesEnabled)(JSContext *cx, JSPrincipals *);
1903
+
1904
+ /* Don't call "destroy"; use reference counting macros below. */
1905
+ jsrefcount refcount;
1906
+
1907
+ void (* destroy)(JSContext *cx, JSPrincipals *);
1908
+ JSBool (* subsume)(JSPrincipals *, JSPrincipals *);
1909
+ };
1910
+
1911
+ #ifdef JS_THREADSAFE
1912
+ #define JSPRINCIPALS_HOLD(cx, principals) JS_HoldPrincipals(cx,principals)
1913
+ #define JSPRINCIPALS_DROP(cx, principals) JS_DropPrincipals(cx,principals)
1914
+
1915
+ extern JS_PUBLIC_API(jsrefcount)
1916
+ JS_HoldPrincipals(JSContext *cx, JSPrincipals *principals);
1917
+
1918
+ extern JS_PUBLIC_API(jsrefcount)
1919
+ JS_DropPrincipals(JSContext *cx, JSPrincipals *principals);
1920
+
1921
+ #else
1922
+ #define JSPRINCIPALS_HOLD(cx, principals) (++(principals)->refcount)
1923
+ #define JSPRINCIPALS_DROP(cx, principals) \
1924
+ ((--(principals)->refcount == 0) \
1925
+ ? ((*(principals)->destroy)((cx), (principals)), 0) \
1926
+ : (principals)->refcount)
1927
+ #endif
1928
+
1929
+
1930
+ struct JSSecurityCallbacks {
1931
+ JSCheckAccessOp checkObjectAccess;
1932
+ JSPrincipalsTranscoder principalsTranscoder;
1933
+ JSObjectPrincipalsFinder findObjectPrincipals;
1934
+ };
1935
+
1936
+ extern JS_PUBLIC_API(JSSecurityCallbacks *)
1937
+ JS_SetRuntimeSecurityCallbacks(JSRuntime *rt, JSSecurityCallbacks *callbacks);
1938
+
1939
+ extern JS_PUBLIC_API(JSSecurityCallbacks *)
1940
+ JS_GetRuntimeSecurityCallbacks(JSRuntime *rt);
1941
+
1942
+ extern JS_PUBLIC_API(JSSecurityCallbacks *)
1943
+ JS_SetContextSecurityCallbacks(JSContext *cx, JSSecurityCallbacks *callbacks);
1944
+
1945
+ extern JS_PUBLIC_API(JSSecurityCallbacks *)
1946
+ JS_GetSecurityCallbacks(JSContext *cx);
1947
+
1948
+ /************************************************************************/
1949
+
1950
+ /*
1951
+ * Functions and scripts.
1952
+ */
1953
+ extern JS_PUBLIC_API(JSFunction *)
1954
+ JS_NewFunction(JSContext *cx, JSNative call, uintN nargs, uintN flags,
1955
+ JSObject *parent, const char *name);
1956
+
1957
+ extern JS_PUBLIC_API(JSObject *)
1958
+ JS_GetFunctionObject(JSFunction *fun);
1959
+
1960
+ /*
1961
+ * Deprecated, useful only for diagnostics. Use JS_GetFunctionId instead for
1962
+ * anonymous vs. "anonymous" disambiguation and Unicode fidelity.
1963
+ */
1964
+ extern JS_PUBLIC_API(const char *)
1965
+ JS_GetFunctionName(JSFunction *fun);
1966
+
1967
+ /*
1968
+ * Return the function's identifier as a JSString, or null if fun is unnamed.
1969
+ * The returned string lives as long as fun, so you don't need to root a saved
1970
+ * reference to it if fun is well-connected or rooted, and provided you bound
1971
+ * the use of the saved reference by fun's lifetime.
1972
+ *
1973
+ * Prefer JS_GetFunctionId over JS_GetFunctionName because it returns null for
1974
+ * truly anonymous functions, and because it doesn't chop to ISO-Latin-1 chars
1975
+ * from UTF-16-ish jschars.
1976
+ */
1977
+ extern JS_PUBLIC_API(JSString *)
1978
+ JS_GetFunctionId(JSFunction *fun);
1979
+
1980
+ /*
1981
+ * Return JSFUN_* flags for fun.
1982
+ */
1983
+ extern JS_PUBLIC_API(uintN)
1984
+ JS_GetFunctionFlags(JSFunction *fun);
1985
+
1986
+ /*
1987
+ * Return the arity (length) of fun.
1988
+ */
1989
+ extern JS_PUBLIC_API(uint16)
1990
+ JS_GetFunctionArity(JSFunction *fun);
1991
+
1992
+ /*
1993
+ * Infallible predicate to test whether obj is a function object (faster than
1994
+ * comparing obj's class name to "Function", but equivalent unless someone has
1995
+ * overwritten the "Function" identifier with a different constructor and then
1996
+ * created instances using that constructor that might be passed in as obj).
1997
+ */
1998
+ extern JS_PUBLIC_API(JSBool)
1999
+ JS_ObjectIsFunction(JSContext *cx, JSObject *obj);
2000
+
2001
+ extern JS_PUBLIC_API(JSBool)
2002
+ JS_DefineFunctions(JSContext *cx, JSObject *obj, JSFunctionSpec *fs);
2003
+
2004
+ extern JS_PUBLIC_API(JSFunction *)
2005
+ JS_DefineFunction(JSContext *cx, JSObject *obj, const char *name, JSNative call,
2006
+ uintN nargs, uintN attrs);
2007
+
2008
+ extern JS_PUBLIC_API(JSFunction *)
2009
+ JS_DefineUCFunction(JSContext *cx, JSObject *obj,
2010
+ const jschar *name, size_t namelen, JSNative call,
2011
+ uintN nargs, uintN attrs);
2012
+
2013
+ extern JS_PUBLIC_API(JSObject *)
2014
+ JS_CloneFunctionObject(JSContext *cx, JSObject *funobj, JSObject *parent);
2015
+
2016
+ /*
2017
+ * Given a buffer, return JS_FALSE if the buffer might become a valid
2018
+ * javascript statement with the addition of more lines. Otherwise return
2019
+ * JS_TRUE. The intent is to support interactive compilation - accumulate
2020
+ * lines in a buffer until JS_BufferIsCompilableUnit is true, then pass it to
2021
+ * the compiler.
2022
+ */
2023
+ extern JS_PUBLIC_API(JSBool)
2024
+ JS_BufferIsCompilableUnit(JSContext *cx, JSObject *obj,
2025
+ const char *bytes, size_t length);
2026
+
2027
+ /*
2028
+ * The JSScript objects returned by the following functions refer to string and
2029
+ * other kinds of literals, including doubles and RegExp objects. These
2030
+ * literals are vulnerable to garbage collection; to root script objects and
2031
+ * prevent literals from being collected, create a rootable object using
2032
+ * JS_NewScriptObject, and root the resulting object using JS_Add[Named]Root.
2033
+ */
2034
+ extern JS_PUBLIC_API(JSScript *)
2035
+ JS_CompileScript(JSContext *cx, JSObject *obj,
2036
+ const char *bytes, size_t length,
2037
+ const char *filename, uintN lineno);
2038
+
2039
+ extern JS_PUBLIC_API(JSScript *)
2040
+ JS_CompileScriptForPrincipals(JSContext *cx, JSObject *obj,
2041
+ JSPrincipals *principals,
2042
+ const char *bytes, size_t length,
2043
+ const char *filename, uintN lineno);
2044
+
2045
+ extern JS_PUBLIC_API(JSScript *)
2046
+ JS_CompileUCScript(JSContext *cx, JSObject *obj,
2047
+ const jschar *chars, size_t length,
2048
+ const char *filename, uintN lineno);
2049
+
2050
+ extern JS_PUBLIC_API(JSScript *)
2051
+ JS_CompileUCScriptForPrincipals(JSContext *cx, JSObject *obj,
2052
+ JSPrincipals *principals,
2053
+ const jschar *chars, size_t length,
2054
+ const char *filename, uintN lineno);
2055
+
2056
+ extern JS_PUBLIC_API(JSScript *)
2057
+ JS_CompileFile(JSContext *cx, JSObject *obj, const char *filename);
2058
+
2059
+ extern JS_PUBLIC_API(JSScript *)
2060
+ JS_CompileFileHandle(JSContext *cx, JSObject *obj, const char *filename,
2061
+ FILE *fh);
2062
+
2063
+ extern JS_PUBLIC_API(JSScript *)
2064
+ JS_CompileFileHandleForPrincipals(JSContext *cx, JSObject *obj,
2065
+ const char *filename, FILE *fh,
2066
+ JSPrincipals *principals);
2067
+
2068
+ /*
2069
+ * NB: you must use JS_NewScriptObject and root a pointer to its return value
2070
+ * in order to keep a JSScript and its atoms safe from garbage collection after
2071
+ * creating the script via JS_Compile* and before a JS_ExecuteScript* call.
2072
+ * E.g., and without error checks:
2073
+ *
2074
+ * JSScript *script = JS_CompileFile(cx, global, filename);
2075
+ * JSObject *scrobj = JS_NewScriptObject(cx, script);
2076
+ * JS_AddNamedRoot(cx, &scrobj, "scrobj");
2077
+ * do {
2078
+ * jsval result;
2079
+ * JS_ExecuteScript(cx, global, script, &result);
2080
+ * JS_GC();
2081
+ * } while (!JSVAL_IS_BOOLEAN(result) || JSVAL_TO_BOOLEAN(result));
2082
+ * JS_RemoveRoot(cx, &scrobj);
2083
+ */
2084
+ extern JS_PUBLIC_API(JSObject *)
2085
+ JS_NewScriptObject(JSContext *cx, JSScript *script);
2086
+
2087
+ /*
2088
+ * Infallible getter for a script's object. If JS_NewScriptObject has not been
2089
+ * called on script yet, the return value will be null.
2090
+ */
2091
+ extern JS_PUBLIC_API(JSObject *)
2092
+ JS_GetScriptObject(JSScript *script);
2093
+
2094
+ extern JS_PUBLIC_API(void)
2095
+ JS_DestroyScript(JSContext *cx, JSScript *script);
2096
+
2097
+ extern JS_PUBLIC_API(JSFunction *)
2098
+ JS_CompileFunction(JSContext *cx, JSObject *obj, const char *name,
2099
+ uintN nargs, const char **argnames,
2100
+ const char *bytes, size_t length,
2101
+ const char *filename, uintN lineno);
2102
+
2103
+ extern JS_PUBLIC_API(JSFunction *)
2104
+ JS_CompileFunctionForPrincipals(JSContext *cx, JSObject *obj,
2105
+ JSPrincipals *principals, const char *name,
2106
+ uintN nargs, const char **argnames,
2107
+ const char *bytes, size_t length,
2108
+ const char *filename, uintN lineno);
2109
+
2110
+ extern JS_PUBLIC_API(JSFunction *)
2111
+ JS_CompileUCFunction(JSContext *cx, JSObject *obj, const char *name,
2112
+ uintN nargs, const char **argnames,
2113
+ const jschar *chars, size_t length,
2114
+ const char *filename, uintN lineno);
2115
+
2116
+ extern JS_PUBLIC_API(JSFunction *)
2117
+ JS_CompileUCFunctionForPrincipals(JSContext *cx, JSObject *obj,
2118
+ JSPrincipals *principals, const char *name,
2119
+ uintN nargs, const char **argnames,
2120
+ const jschar *chars, size_t length,
2121
+ const char *filename, uintN lineno);
2122
+
2123
+ extern JS_PUBLIC_API(JSString *)
2124
+ JS_DecompileScript(JSContext *cx, JSScript *script, const char *name,
2125
+ uintN indent);
2126
+
2127
+ /*
2128
+ * API extension: OR this into indent to avoid pretty-printing the decompiled
2129
+ * source resulting from JS_DecompileFunction{,Body}.
2130
+ */
2131
+ #define JS_DONT_PRETTY_PRINT ((uintN)0x8000)
2132
+
2133
+ extern JS_PUBLIC_API(JSString *)
2134
+ JS_DecompileFunction(JSContext *cx, JSFunction *fun, uintN indent);
2135
+
2136
+ extern JS_PUBLIC_API(JSString *)
2137
+ JS_DecompileFunctionBody(JSContext *cx, JSFunction *fun, uintN indent);
2138
+
2139
+ /*
2140
+ * NB: JS_ExecuteScript, JS_ExecuteScriptPart, and the JS_Evaluate*Script*
2141
+ * quadruplets all use the obj parameter as the initial scope chain header,
2142
+ * the 'this' keyword value, and the variables object (ECMA parlance for where
2143
+ * 'var' and 'function' bind names) of the execution context for script.
2144
+ *
2145
+ * Using obj as the variables object is problematic if obj's parent (which is
2146
+ * the scope chain link; see JS_SetParent and JS_NewObject) is not null: in
2147
+ * this case, variables created by 'var x = 0', e.g., go in obj, but variables
2148
+ * created by assignment to an unbound id, 'x = 0', go in the last object on
2149
+ * the scope chain linked by parent.
2150
+ *
2151
+ * ECMA calls that last scoping object the "global object", but note that many
2152
+ * embeddings have several such objects. ECMA requires that "global code" be
2153
+ * executed with the variables object equal to this global object. But these
2154
+ * JS API entry points provide freedom to execute code against a "sub-global",
2155
+ * i.e., a parented or scoped object, in which case the variables object will
2156
+ * differ from the last object on the scope chain, resulting in confusing and
2157
+ * non-ECMA explicit vs. implicit variable creation.
2158
+ *
2159
+ * Caveat embedders: unless you already depend on this buggy variables object
2160
+ * binding behavior, you should call JS_SetOptions(cx, JSOPTION_VAROBJFIX) or
2161
+ * JS_SetOptions(cx, JS_GetOptions(cx) | JSOPTION_VAROBJFIX) -- the latter if
2162
+ * someone may have set other options on cx already -- for each context in the
2163
+ * application, if you pass parented objects as the obj parameter, or may ever
2164
+ * pass such objects in the future.
2165
+ *
2166
+ * Why a runtime option? The alternative is to add six or so new API entry
2167
+ * points with signatures matching the following six, and that doesn't seem
2168
+ * worth the code bloat cost. Such new entry points would probably have less
2169
+ * obvious names, too, so would not tend to be used. The JS_SetOption call,
2170
+ * OTOH, can be more easily hacked into existing code that does not depend on
2171
+ * the bug; such code can continue to use the familiar JS_EvaluateScript,
2172
+ * etc., entry points.
2173
+ */
2174
+ extern JS_PUBLIC_API(JSBool)
2175
+ JS_ExecuteScript(JSContext *cx, JSObject *obj, JSScript *script, jsval *rval);
2176
+
2177
+ /*
2178
+ * Execute either the function-defining prolog of a script, or the script's
2179
+ * main body, but not both.
2180
+ */
2181
+ typedef enum JSExecPart { JSEXEC_PROLOG, JSEXEC_MAIN } JSExecPart;
2182
+
2183
+ extern JS_PUBLIC_API(JSBool)
2184
+ JS_ExecuteScriptPart(JSContext *cx, JSObject *obj, JSScript *script,
2185
+ JSExecPart part, jsval *rval);
2186
+
2187
+ extern JS_PUBLIC_API(JSBool)
2188
+ JS_EvaluateScript(JSContext *cx, JSObject *obj,
2189
+ const char *bytes, uintN length,
2190
+ const char *filename, uintN lineno,
2191
+ jsval *rval);
2192
+
2193
+ extern JS_PUBLIC_API(JSBool)
2194
+ JS_EvaluateScriptForPrincipals(JSContext *cx, JSObject *obj,
2195
+ JSPrincipals *principals,
2196
+ const char *bytes, uintN length,
2197
+ const char *filename, uintN lineno,
2198
+ jsval *rval);
2199
+
2200
+ extern JS_PUBLIC_API(JSBool)
2201
+ JS_EvaluateUCScript(JSContext *cx, JSObject *obj,
2202
+ const jschar *chars, uintN length,
2203
+ const char *filename, uintN lineno,
2204
+ jsval *rval);
2205
+
2206
+ extern JS_PUBLIC_API(JSBool)
2207
+ JS_EvaluateUCScriptForPrincipals(JSContext *cx, JSObject *obj,
2208
+ JSPrincipals *principals,
2209
+ const jschar *chars, uintN length,
2210
+ const char *filename, uintN lineno,
2211
+ jsval *rval);
2212
+
2213
+ extern JS_PUBLIC_API(JSBool)
2214
+ JS_CallFunction(JSContext *cx, JSObject *obj, JSFunction *fun, uintN argc,
2215
+ jsval *argv, jsval *rval);
2216
+
2217
+ extern JS_PUBLIC_API(JSBool)
2218
+ JS_CallFunctionName(JSContext *cx, JSObject *obj, const char *name, uintN argc,
2219
+ jsval *argv, jsval *rval);
2220
+
2221
+ extern JS_PUBLIC_API(JSBool)
2222
+ JS_CallFunctionValue(JSContext *cx, JSObject *obj, jsval fval, uintN argc,
2223
+ jsval *argv, jsval *rval);
2224
+
2225
+ /*
2226
+ * These functions allow setting an operation callback that will be called
2227
+ * from the thread the context is associated with some time after any thread
2228
+ * triggered the callback using JS_TriggerOperationCallback(cx).
2229
+ *
2230
+ * In a threadsafe build the engine internally triggers operation callbacks
2231
+ * under certain circumstances (i.e. GC and title transfer) to force the
2232
+ * context to yield its current request, which the engine always
2233
+ * automatically does immediately prior to calling the callback function.
2234
+ * The embedding should thus not rely on callbacks being triggered through
2235
+ * the external API only.
2236
+ *
2237
+ * Important note: Additional callbacks can occur inside the callback handler
2238
+ * if it re-enters the JS engine. The embedding must ensure that the callback
2239
+ * is disconnected before attempting such re-entry.
2240
+ */
2241
+
2242
+ extern JS_PUBLIC_API(JSOperationCallback)
2243
+ JS_SetOperationCallback(JSContext *cx, JSOperationCallback callback);
2244
+
2245
+ extern JS_PUBLIC_API(JSOperationCallback)
2246
+ JS_GetOperationCallback(JSContext *cx);
2247
+
2248
+ extern JS_PUBLIC_API(void)
2249
+ JS_TriggerOperationCallback(JSContext *cx);
2250
+
2251
+ extern JS_PUBLIC_API(void)
2252
+ JS_TriggerAllOperationCallbacks(JSRuntime *rt);
2253
+
2254
+ extern JS_PUBLIC_API(JSBool)
2255
+ JS_IsRunning(JSContext *cx);
2256
+
2257
+ extern JS_PUBLIC_API(JSBool)
2258
+ JS_IsConstructing(JSContext *cx);
2259
+
2260
+ /*
2261
+ * Returns true if a script is executing and its current bytecode is a set
2262
+ * (assignment) operation, even if there are native (no script) stack frames
2263
+ * between the script and the caller to JS_IsAssigning.
2264
+ */
2265
+ extern JS_FRIEND_API(JSBool)
2266
+ JS_IsAssigning(JSContext *cx);
2267
+
2268
+ /*
2269
+ * Set the second return value, which should be a string or int jsval that
2270
+ * identifies a property in the returned object, to form an ECMA reference
2271
+ * type value (obj, id). Only native methods can return reference types,
2272
+ * and if the returned value is used on the left-hand side of an assignment
2273
+ * op, the identified property will be set. If the return value is in an
2274
+ * r-value, the interpreter just gets obj[id]'s value.
2275
+ */
2276
+ extern JS_PUBLIC_API(void)
2277
+ JS_SetCallReturnValue2(JSContext *cx, jsval v);
2278
+
2279
+ /*
2280
+ * Saving and restoring frame chains.
2281
+ *
2282
+ * These two functions are used to set aside cx's call stack while that stack
2283
+ * is inactive. After a call to JS_SaveFrameChain, it looks as if there is no
2284
+ * code running on cx. Before calling JS_RestoreFrameChain, cx's call stack
2285
+ * must be balanced and all nested calls to JS_SaveFrameChain must have had
2286
+ * matching JS_RestoreFrameChain calls.
2287
+ *
2288
+ * JS_SaveFrameChain deals with cx not having any code running on it. A null
2289
+ * return does not signify an error, and JS_RestoreFrameChain handles a null
2290
+ * frame pointer argument safely.
2291
+ */
2292
+ extern JS_PUBLIC_API(JSStackFrame *)
2293
+ JS_SaveFrameChain(JSContext *cx);
2294
+
2295
+ extern JS_PUBLIC_API(void)
2296
+ JS_RestoreFrameChain(JSContext *cx, JSStackFrame *fp);
2297
+
2298
+ /************************************************************************/
2299
+
2300
+ /*
2301
+ * Strings.
2302
+ *
2303
+ * NB: JS_NewString takes ownership of bytes on success, avoiding a copy; but
2304
+ * on error (signified by null return), it leaves bytes owned by the caller.
2305
+ * So the caller must free bytes in the error case, if it has no use for them.
2306
+ * In contrast, all the JS_New*StringCopy* functions do not take ownership of
2307
+ * the character memory passed to them -- they copy it.
2308
+ */
2309
+ extern JS_PUBLIC_API(JSString *)
2310
+ JS_NewString(JSContext *cx, char *bytes, size_t length);
2311
+
2312
+ extern JS_PUBLIC_API(JSString *)
2313
+ JS_NewStringCopyN(JSContext *cx, const char *s, size_t n);
2314
+
2315
+ extern JS_PUBLIC_API(JSString *)
2316
+ JS_NewStringCopyZ(JSContext *cx, const char *s);
2317
+
2318
+ extern JS_PUBLIC_API(JSString *)
2319
+ JS_InternString(JSContext *cx, const char *s);
2320
+
2321
+ extern JS_PUBLIC_API(JSString *)
2322
+ JS_NewUCString(JSContext *cx, jschar *chars, size_t length);
2323
+
2324
+ extern JS_PUBLIC_API(JSString *)
2325
+ JS_NewUCStringCopyN(JSContext *cx, const jschar *s, size_t n);
2326
+
2327
+ extern JS_PUBLIC_API(JSString *)
2328
+ JS_NewUCStringCopyZ(JSContext *cx, const jschar *s);
2329
+
2330
+ extern JS_PUBLIC_API(JSString *)
2331
+ JS_InternUCStringN(JSContext *cx, const jschar *s, size_t length);
2332
+
2333
+ extern JS_PUBLIC_API(JSString *)
2334
+ JS_InternUCString(JSContext *cx, const jschar *s);
2335
+
2336
+ extern JS_PUBLIC_API(char *)
2337
+ JS_GetStringBytes(JSString *str);
2338
+
2339
+ extern JS_PUBLIC_API(jschar *)
2340
+ JS_GetStringChars(JSString *str);
2341
+
2342
+ extern JS_PUBLIC_API(size_t)
2343
+ JS_GetStringLength(JSString *str);
2344
+
2345
+ extern JS_PUBLIC_API(intN)
2346
+ JS_CompareStrings(JSString *str1, JSString *str2);
2347
+
2348
+ /*
2349
+ * Mutable string support. A string's characters are never mutable in this JS
2350
+ * implementation, but a growable string has a buffer that can be reallocated,
2351
+ * and a dependent string is a substring of another (growable, dependent, or
2352
+ * immutable) string. The direct data members of the (opaque to API clients)
2353
+ * JSString struct may be changed in a single-threaded way for growable and
2354
+ * dependent strings.
2355
+ *
2356
+ * Therefore mutable strings cannot be used by more than one thread at a time.
2357
+ * You may call JS_MakeStringImmutable to convert the string from a mutable
2358
+ * (growable or dependent) string to an immutable (and therefore thread-safe)
2359
+ * string. The engine takes care of converting growable and dependent strings
2360
+ * to immutable for you if you store strings in multi-threaded objects using
2361
+ * JS_SetProperty or kindred API entry points.
2362
+ *
2363
+ * If you store a JSString pointer in a native data structure that is (safely)
2364
+ * accessible to multiple threads, you must call JS_MakeStringImmutable before
2365
+ * retiring the store.
2366
+ */
2367
+ extern JS_PUBLIC_API(JSString *)
2368
+ JS_NewGrowableString(JSContext *cx, jschar *chars, size_t length);
2369
+
2370
+ /*
2371
+ * Create a dependent string, i.e., a string that owns no character storage,
2372
+ * but that refers to a slice of another string's chars. Dependent strings
2373
+ * are mutable by definition, so the thread safety comments above apply.
2374
+ */
2375
+ extern JS_PUBLIC_API(JSString *)
2376
+ JS_NewDependentString(JSContext *cx, JSString *str, size_t start,
2377
+ size_t length);
2378
+
2379
+ /*
2380
+ * Concatenate two strings, resulting in a new growable string. If you create
2381
+ * the left string and pass it to JS_ConcatStrings on a single thread, try to
2382
+ * use JS_NewGrowableString to create the left string -- doing so helps Concat
2383
+ * avoid allocating a new buffer for the result and copying left's chars into
2384
+ * the new buffer. See above for thread safety comments.
2385
+ */
2386
+ extern JS_PUBLIC_API(JSString *)
2387
+ JS_ConcatStrings(JSContext *cx, JSString *left, JSString *right);
2388
+
2389
+ /*
2390
+ * Convert a dependent string into an independent one. This function does not
2391
+ * change the string's mutability, so the thread safety comments above apply.
2392
+ */
2393
+ extern JS_PUBLIC_API(const jschar *)
2394
+ JS_UndependString(JSContext *cx, JSString *str);
2395
+
2396
+ /*
2397
+ * Convert a mutable string (either growable or dependent) into an immutable,
2398
+ * thread-safe one.
2399
+ */
2400
+ extern JS_PUBLIC_API(JSBool)
2401
+ JS_MakeStringImmutable(JSContext *cx, JSString *str);
2402
+
2403
+ /*
2404
+ * Return JS_TRUE if C (char []) strings passed via the API and internally
2405
+ * are UTF-8.
2406
+ */
2407
+ JS_PUBLIC_API(JSBool)
2408
+ JS_CStringsAreUTF8(void);
2409
+
2410
+ /*
2411
+ * Update the value to be returned by JS_CStringsAreUTF8(). Once set, it
2412
+ * can never be changed. This API must be called before the first call to
2413
+ * JS_NewRuntime.
2414
+ */
2415
+ JS_PUBLIC_API(void)
2416
+ JS_SetCStringsAreUTF8(void);
2417
+
2418
+ /*
2419
+ * Character encoding support.
2420
+ *
2421
+ * For both JS_EncodeCharacters and JS_DecodeBytes, set *dstlenp to the size
2422
+ * of the destination buffer before the call; on return, *dstlenp contains the
2423
+ * number of bytes (JS_EncodeCharacters) or jschars (JS_DecodeBytes) actually
2424
+ * stored. To determine the necessary destination buffer size, make a sizing
2425
+ * call that passes NULL for dst.
2426
+ *
2427
+ * On errors, the functions report the error. In that case, *dstlenp contains
2428
+ * the number of characters or bytes transferred so far. If cx is NULL, no
2429
+ * error is reported on failure, and the functions simply return JS_FALSE.
2430
+ *
2431
+ * NB: Neither function stores an additional zero byte or jschar after the
2432
+ * transcoded string.
2433
+ *
2434
+ * If JS_CStringsAreUTF8() is true then JS_EncodeCharacters encodes to
2435
+ * UTF-8, and JS_DecodeBytes decodes from UTF-8, which may create additional
2436
+ * errors if the character sequence is malformed. If UTF-8 support is
2437
+ * disabled, the functions deflate and inflate, respectively.
2438
+ */
2439
+ JS_PUBLIC_API(JSBool)
2440
+ JS_EncodeCharacters(JSContext *cx, const jschar *src, size_t srclen, char *dst,
2441
+ size_t *dstlenp);
2442
+
2443
+ JS_PUBLIC_API(JSBool)
2444
+ JS_DecodeBytes(JSContext *cx, const char *src, size_t srclen, jschar *dst,
2445
+ size_t *dstlenp);
2446
+
2447
+ /*
2448
+ * A variation on JS_EncodeCharacters where a null terminated string is
2449
+ * returned that you are expected to call JS_free on when done.
2450
+ */
2451
+ JS_PUBLIC_API(char *)
2452
+ JS_EncodeString(JSContext *cx, JSString *str);
2453
+
2454
+ /************************************************************************/
2455
+ /*
2456
+ * JSON functions
2457
+ */
2458
+ typedef JSBool (* JSONWriteCallback)(const jschar *buf, uint32 len, void *data);
2459
+
2460
+ /*
2461
+ * JSON.stringify as specified by ES3.1 (draft)
2462
+ */
2463
+ JS_PUBLIC_API(JSBool)
2464
+ JS_Stringify(JSContext *cx, jsval *vp, JSObject *replacer, jsval space,
2465
+ JSONWriteCallback callback, void *data);
2466
+
2467
+ /*
2468
+ * Retrieve a toJSON function. If found, set vp to its result.
2469
+ */
2470
+ JS_PUBLIC_API(JSBool)
2471
+ JS_TryJSON(JSContext *cx, jsval *vp);
2472
+
2473
+ /*
2474
+ * JSON.parse as specified by ES3.1 (draft)
2475
+ */
2476
+ JS_PUBLIC_API(JSONParser *)
2477
+ JS_BeginJSONParse(JSContext *cx, jsval *vp);
2478
+
2479
+ JS_PUBLIC_API(JSBool)
2480
+ JS_ConsumeJSONText(JSContext *cx, JSONParser *jp, const jschar *data, uint32 len);
2481
+
2482
+ JS_PUBLIC_API(JSBool)
2483
+ JS_FinishJSONParse(JSContext *cx, JSONParser *jp, jsval reviver);
2484
+
2485
+ /************************************************************************/
2486
+
2487
+ /*
2488
+ * Locale specific string conversion and error message callbacks.
2489
+ */
2490
+ struct JSLocaleCallbacks {
2491
+ JSLocaleToUpperCase localeToUpperCase;
2492
+ JSLocaleToLowerCase localeToLowerCase;
2493
+ JSLocaleCompare localeCompare;
2494
+ JSLocaleToUnicode localeToUnicode;
2495
+ JSErrorCallback localeGetErrorMessage;
2496
+ };
2497
+
2498
+ /*
2499
+ * Establish locale callbacks. The pointer must persist as long as the
2500
+ * JSContext. Passing NULL restores the default behaviour.
2501
+ */
2502
+ extern JS_PUBLIC_API(void)
2503
+ JS_SetLocaleCallbacks(JSContext *cx, JSLocaleCallbacks *callbacks);
2504
+
2505
+ /*
2506
+ * Return the address of the current locale callbacks struct, which may
2507
+ * be NULL.
2508
+ */
2509
+ extern JS_PUBLIC_API(JSLocaleCallbacks *)
2510
+ JS_GetLocaleCallbacks(JSContext *cx);
2511
+
2512
+ /************************************************************************/
2513
+
2514
+ /*
2515
+ * Error reporting.
2516
+ */
2517
+
2518
+ /*
2519
+ * Report an exception represented by the sprintf-like conversion of format
2520
+ * and its arguments. This exception message string is passed to a pre-set
2521
+ * JSErrorReporter function (set by JS_SetErrorReporter; see jspubtd.h for
2522
+ * the JSErrorReporter typedef).
2523
+ */
2524
+ extern JS_PUBLIC_API(void)
2525
+ JS_ReportError(JSContext *cx, const char *format, ...);
2526
+
2527
+ /*
2528
+ * Use an errorNumber to retrieve the format string, args are char *
2529
+ */
2530
+ extern JS_PUBLIC_API(void)
2531
+ JS_ReportErrorNumber(JSContext *cx, JSErrorCallback errorCallback,
2532
+ void *userRef, const uintN errorNumber, ...);
2533
+
2534
+ /*
2535
+ * Use an errorNumber to retrieve the format string, args are jschar *
2536
+ */
2537
+ extern JS_PUBLIC_API(void)
2538
+ JS_ReportErrorNumberUC(JSContext *cx, JSErrorCallback errorCallback,
2539
+ void *userRef, const uintN errorNumber, ...);
2540
+
2541
+ /*
2542
+ * As above, but report a warning instead (JSREPORT_IS_WARNING(report.flags)).
2543
+ * Return true if there was no error trying to issue the warning, and if the
2544
+ * warning was not converted into an error due to the JSOPTION_WERROR option
2545
+ * being set, false otherwise.
2546
+ */
2547
+ extern JS_PUBLIC_API(JSBool)
2548
+ JS_ReportWarning(JSContext *cx, const char *format, ...);
2549
+
2550
+ extern JS_PUBLIC_API(JSBool)
2551
+ JS_ReportErrorFlagsAndNumber(JSContext *cx, uintN flags,
2552
+ JSErrorCallback errorCallback, void *userRef,
2553
+ const uintN errorNumber, ...);
2554
+
2555
+ extern JS_PUBLIC_API(JSBool)
2556
+ JS_ReportErrorFlagsAndNumberUC(JSContext *cx, uintN flags,
2557
+ JSErrorCallback errorCallback, void *userRef,
2558
+ const uintN errorNumber, ...);
2559
+
2560
+ /*
2561
+ * Complain when out of memory.
2562
+ */
2563
+ extern JS_PUBLIC_API(void)
2564
+ JS_ReportOutOfMemory(JSContext *cx);
2565
+
2566
+ /*
2567
+ * Complain when an allocation size overflows the maximum supported limit.
2568
+ */
2569
+ extern JS_PUBLIC_API(void)
2570
+ JS_ReportAllocationOverflow(JSContext *cx);
2571
+
2572
+ struct JSErrorReport {
2573
+ const char *filename; /* source file name, URL, etc., or null */
2574
+ uintN lineno; /* source line number */
2575
+ const char *linebuf; /* offending source line without final \n */
2576
+ const char *tokenptr; /* pointer to error token in linebuf */
2577
+ const jschar *uclinebuf; /* unicode (original) line buffer */
2578
+ const jschar *uctokenptr; /* unicode (original) token pointer */
2579
+ uintN flags; /* error/warning, etc. */
2580
+ uintN errorNumber; /* the error number, e.g. see js.msg */
2581
+ const jschar *ucmessage; /* the (default) error message */
2582
+ const jschar **messageArgs; /* arguments for the error message */
2583
+ };
2584
+
2585
+ /*
2586
+ * JSErrorReport flag values. These may be freely composed.
2587
+ */
2588
+ #define JSREPORT_ERROR 0x0 /* pseudo-flag for default case */
2589
+ #define JSREPORT_WARNING 0x1 /* reported via JS_ReportWarning */
2590
+ #define JSREPORT_EXCEPTION 0x2 /* exception was thrown */
2591
+ #define JSREPORT_STRICT 0x4 /* error or warning due to strict option */
2592
+
2593
+ /*
2594
+ * If JSREPORT_EXCEPTION is set, then a JavaScript-catchable exception
2595
+ * has been thrown for this runtime error, and the host should ignore it.
2596
+ * Exception-aware hosts should also check for JS_IsExceptionPending if
2597
+ * JS_ExecuteScript returns failure, and signal or propagate the exception, as
2598
+ * appropriate.
2599
+ */
2600
+ #define JSREPORT_IS_WARNING(flags) (((flags) & JSREPORT_WARNING) != 0)
2601
+ #define JSREPORT_IS_EXCEPTION(flags) (((flags) & JSREPORT_EXCEPTION) != 0)
2602
+ #define JSREPORT_IS_STRICT(flags) (((flags) & JSREPORT_STRICT) != 0)
2603
+
2604
+ extern JS_PUBLIC_API(JSErrorReporter)
2605
+ JS_SetErrorReporter(JSContext *cx, JSErrorReporter er);
2606
+
2607
+ /************************************************************************/
2608
+
2609
+ /*
2610
+ * Regular Expressions.
2611
+ */
2612
+ #define JSREG_FOLD 0x01 /* fold uppercase to lowercase */
2613
+ #define JSREG_GLOB 0x02 /* global exec, creates array of matches */
2614
+ #define JSREG_MULTILINE 0x04 /* treat ^ and $ as begin and end of line */
2615
+ #define JSREG_STICKY 0x08 /* only match starting at lastIndex */
2616
+ #define JSREG_FLAT 0x10 /* parse as a flat regexp */
2617
+
2618
+ extern JS_PUBLIC_API(JSObject *)
2619
+ JS_NewRegExpObject(JSContext *cx, char *bytes, size_t length, uintN flags);
2620
+
2621
+ extern JS_PUBLIC_API(JSObject *)
2622
+ JS_NewUCRegExpObject(JSContext *cx, jschar *chars, size_t length, uintN flags);
2623
+
2624
+ extern JS_PUBLIC_API(void)
2625
+ JS_SetRegExpInput(JSContext *cx, JSString *input, JSBool multiline);
2626
+
2627
+ extern JS_PUBLIC_API(void)
2628
+ JS_ClearRegExpStatics(JSContext *cx);
2629
+
2630
+ extern JS_PUBLIC_API(void)
2631
+ JS_ClearRegExpRoots(JSContext *cx);
2632
+
2633
+ /* TODO: compile, exec, get/set other statics... */
2634
+
2635
+ /************************************************************************/
2636
+
2637
+ extern JS_PUBLIC_API(JSBool)
2638
+ JS_IsExceptionPending(JSContext *cx);
2639
+
2640
+ extern JS_PUBLIC_API(JSBool)
2641
+ JS_GetPendingException(JSContext *cx, jsval *vp);
2642
+
2643
+ extern JS_PUBLIC_API(void)
2644
+ JS_SetPendingException(JSContext *cx, jsval v);
2645
+
2646
+ extern JS_PUBLIC_API(void)
2647
+ JS_ClearPendingException(JSContext *cx);
2648
+
2649
+ extern JS_PUBLIC_API(JSBool)
2650
+ JS_ReportPendingException(JSContext *cx);
2651
+
2652
+ /*
2653
+ * Save the current exception state. This takes a snapshot of cx's current
2654
+ * exception state without making any change to that state.
2655
+ *
2656
+ * The returned state pointer MUST be passed later to JS_RestoreExceptionState
2657
+ * (to restore that saved state, overriding any more recent state) or else to
2658
+ * JS_DropExceptionState (to free the state struct in case it is not correct
2659
+ * or desirable to restore it). Both Restore and Drop free the state struct,
2660
+ * so callers must stop using the pointer returned from Save after calling the
2661
+ * Release or Drop API.
2662
+ */
2663
+ extern JS_PUBLIC_API(JSExceptionState *)
2664
+ JS_SaveExceptionState(JSContext *cx);
2665
+
2666
+ extern JS_PUBLIC_API(void)
2667
+ JS_RestoreExceptionState(JSContext *cx, JSExceptionState *state);
2668
+
2669
+ extern JS_PUBLIC_API(void)
2670
+ JS_DropExceptionState(JSContext *cx, JSExceptionState *state);
2671
+
2672
+ /*
2673
+ * If the given value is an exception object that originated from an error,
2674
+ * the exception will contain an error report struct, and this API will return
2675
+ * the address of that struct. Otherwise, it returns NULL. The lifetime of
2676
+ * the error report struct that might be returned is the same as the lifetime
2677
+ * of the exception object.
2678
+ */
2679
+ extern JS_PUBLIC_API(JSErrorReport *)
2680
+ JS_ErrorFromException(JSContext *cx, jsval v);
2681
+
2682
+ /*
2683
+ * Given a reported error's message and JSErrorReport struct pointer, throw
2684
+ * the corresponding exception on cx.
2685
+ */
2686
+ extern JS_PUBLIC_API(JSBool)
2687
+ JS_ThrowReportedError(JSContext *cx, const char *message,
2688
+ JSErrorReport *reportp);
2689
+
2690
+ /*
2691
+ * Throws a StopIteration exception on cx.
2692
+ */
2693
+ extern JS_PUBLIC_API(JSBool)
2694
+ JS_ThrowStopIteration(JSContext *cx);
2695
+
2696
+ /*
2697
+ * Associate the current thread with the given context. This is done
2698
+ * implicitly by JS_NewContext.
2699
+ *
2700
+ * Returns the old thread id for this context, which should be treated as
2701
+ * an opaque value. This value is provided for comparison to 0, which
2702
+ * indicates that ClearContextThread has been called on this context
2703
+ * since the last SetContextThread, or non-0, which indicates the opposite.
2704
+ */
2705
+ extern JS_PUBLIC_API(jsword)
2706
+ JS_GetContextThread(JSContext *cx);
2707
+
2708
+ extern JS_PUBLIC_API(jsword)
2709
+ JS_SetContextThread(JSContext *cx);
2710
+
2711
+ extern JS_PUBLIC_API(jsword)
2712
+ JS_ClearContextThread(JSContext *cx);
2713
+
2714
+ /************************************************************************/
2715
+
2716
+ #ifdef DEBUG
2717
+ #define JS_GC_ZEAL 1
2718
+ #endif
2719
+
2720
+ #ifdef JS_GC_ZEAL
2721
+ extern JS_PUBLIC_API(void)
2722
+ JS_SetGCZeal(JSContext *cx, uint8 zeal);
2723
+ #endif
2724
+
2725
+ JS_END_EXTERN_C
2726
+
2727
+ #endif /* jsapi_h___ */