therubyracer 0.4.9-x86-linux

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

Potentially problematic release.


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

Files changed (637) hide show
  1. data/.gitignore +11 -0
  2. data/.gitmodules +3 -0
  3. data/Doxyfile +1514 -0
  4. data/History.txt +43 -0
  5. data/README.rdoc +157 -0
  6. data/Rakefile +51 -0
  7. data/docs/data_conversion.txt +18 -0
  8. data/ext/v8/callbacks.cpp +160 -0
  9. data/ext/v8/callbacks.h +14 -0
  10. data/ext/v8/convert_ruby.cpp +8 -0
  11. data/ext/v8/convert_ruby.h +99 -0
  12. data/ext/v8/convert_string.cpp +10 -0
  13. data/ext/v8/convert_string.h +73 -0
  14. data/ext/v8/convert_v8.cpp +9 -0
  15. data/ext/v8/convert_v8.h +121 -0
  16. data/ext/v8/converters.cpp +83 -0
  17. data/ext/v8/converters.h +23 -0
  18. data/ext/v8/extconf.rb +36 -0
  19. data/ext/v8/upstream/2.0.6/.gitignore +26 -0
  20. data/ext/v8/upstream/2.0.6/AUTHORS +23 -0
  21. data/ext/v8/upstream/2.0.6/ChangeLog +1479 -0
  22. data/ext/v8/upstream/2.0.6/LICENSE +55 -0
  23. data/ext/v8/upstream/2.0.6/SConstruct +1028 -0
  24. data/ext/v8/upstream/2.0.6/include/v8-debug.h +275 -0
  25. data/ext/v8/upstream/2.0.6/include/v8.h +3236 -0
  26. data/ext/v8/upstream/2.0.6/src/SConscript +283 -0
  27. data/ext/v8/upstream/2.0.6/src/accessors.cc +695 -0
  28. data/ext/v8/upstream/2.0.6/src/accessors.h +114 -0
  29. data/ext/v8/upstream/2.0.6/src/allocation.cc +198 -0
  30. data/ext/v8/upstream/2.0.6/src/allocation.h +169 -0
  31. data/ext/v8/upstream/2.0.6/src/api.cc +3831 -0
  32. data/ext/v8/upstream/2.0.6/src/api.h +479 -0
  33. data/ext/v8/upstream/2.0.6/src/apinatives.js +110 -0
  34. data/ext/v8/upstream/2.0.6/src/apiutils.h +69 -0
  35. data/ext/v8/upstream/2.0.6/src/arguments.h +97 -0
  36. data/ext/v8/upstream/2.0.6/src/arm/assembler-arm-inl.h +277 -0
  37. data/ext/v8/upstream/2.0.6/src/arm/assembler-arm.cc +1821 -0
  38. data/ext/v8/upstream/2.0.6/src/arm/assembler-arm.h +1027 -0
  39. data/ext/v8/upstream/2.0.6/src/arm/assembler-thumb2-inl.h +267 -0
  40. data/ext/v8/upstream/2.0.6/src/arm/assembler-thumb2.cc +1821 -0
  41. data/ext/v8/upstream/2.0.6/src/arm/assembler-thumb2.h +1027 -0
  42. data/ext/v8/upstream/2.0.6/src/arm/builtins-arm.cc +1271 -0
  43. data/ext/v8/upstream/2.0.6/src/arm/codegen-arm-inl.h +74 -0
  44. data/ext/v8/upstream/2.0.6/src/arm/codegen-arm.cc +6682 -0
  45. data/ext/v8/upstream/2.0.6/src/arm/codegen-arm.h +535 -0
  46. data/ext/v8/upstream/2.0.6/src/arm/constants-arm.cc +112 -0
  47. data/ext/v8/upstream/2.0.6/src/arm/constants-arm.h +347 -0
  48. data/ext/v8/upstream/2.0.6/src/arm/cpu-arm.cc +132 -0
  49. data/ext/v8/upstream/2.0.6/src/arm/debug-arm.cc +213 -0
  50. data/ext/v8/upstream/2.0.6/src/arm/disasm-arm.cc +1166 -0
  51. data/ext/v8/upstream/2.0.6/src/arm/fast-codegen-arm.cc +1698 -0
  52. data/ext/v8/upstream/2.0.6/src/arm/frames-arm.cc +123 -0
  53. data/ext/v8/upstream/2.0.6/src/arm/frames-arm.h +162 -0
  54. data/ext/v8/upstream/2.0.6/src/arm/ic-arm.cc +849 -0
  55. data/ext/v8/upstream/2.0.6/src/arm/jump-target-arm.cc +238 -0
  56. data/ext/v8/upstream/2.0.6/src/arm/macro-assembler-arm.cc +1259 -0
  57. data/ext/v8/upstream/2.0.6/src/arm/macro-assembler-arm.h +423 -0
  58. data/ext/v8/upstream/2.0.6/src/arm/regexp-macro-assembler-arm.cc +1266 -0
  59. data/ext/v8/upstream/2.0.6/src/arm/regexp-macro-assembler-arm.h +282 -0
  60. data/ext/v8/upstream/2.0.6/src/arm/register-allocator-arm-inl.h +103 -0
  61. data/ext/v8/upstream/2.0.6/src/arm/register-allocator-arm.cc +59 -0
  62. data/ext/v8/upstream/2.0.6/src/arm/register-allocator-arm.h +43 -0
  63. data/ext/v8/upstream/2.0.6/src/arm/simulator-arm.cc +2264 -0
  64. data/ext/v8/upstream/2.0.6/src/arm/simulator-arm.h +306 -0
  65. data/ext/v8/upstream/2.0.6/src/arm/stub-cache-arm.cc +1516 -0
  66. data/ext/v8/upstream/2.0.6/src/arm/virtual-frame-arm.cc +412 -0
  67. data/ext/v8/upstream/2.0.6/src/arm/virtual-frame-arm.h +532 -0
  68. data/ext/v8/upstream/2.0.6/src/array.js +1154 -0
  69. data/ext/v8/upstream/2.0.6/src/assembler.cc +772 -0
  70. data/ext/v8/upstream/2.0.6/src/assembler.h +525 -0
  71. data/ext/v8/upstream/2.0.6/src/ast.cc +512 -0
  72. data/ext/v8/upstream/2.0.6/src/ast.h +1820 -0
  73. data/ext/v8/upstream/2.0.6/src/bootstrapper.cc +1680 -0
  74. data/ext/v8/upstream/2.0.6/src/bootstrapper.h +103 -0
  75. data/ext/v8/upstream/2.0.6/src/builtins.cc +851 -0
  76. data/ext/v8/upstream/2.0.6/src/builtins.h +245 -0
  77. data/ext/v8/upstream/2.0.6/src/bytecodes-irregexp.h +104 -0
  78. data/ext/v8/upstream/2.0.6/src/char-predicates-inl.h +86 -0
  79. data/ext/v8/upstream/2.0.6/src/char-predicates.h +65 -0
  80. data/ext/v8/upstream/2.0.6/src/checks.cc +100 -0
  81. data/ext/v8/upstream/2.0.6/src/checks.h +284 -0
  82. data/ext/v8/upstream/2.0.6/src/code-stubs.cc +164 -0
  83. data/ext/v8/upstream/2.0.6/src/code-stubs.h +164 -0
  84. data/ext/v8/upstream/2.0.6/src/code.h +68 -0
  85. data/ext/v8/upstream/2.0.6/src/codegen-inl.h +88 -0
  86. data/ext/v8/upstream/2.0.6/src/codegen.cc +504 -0
  87. data/ext/v8/upstream/2.0.6/src/codegen.h +522 -0
  88. data/ext/v8/upstream/2.0.6/src/compilation-cache.cc +490 -0
  89. data/ext/v8/upstream/2.0.6/src/compilation-cache.h +98 -0
  90. data/ext/v8/upstream/2.0.6/src/compiler.cc +1132 -0
  91. data/ext/v8/upstream/2.0.6/src/compiler.h +107 -0
  92. data/ext/v8/upstream/2.0.6/src/contexts.cc +256 -0
  93. data/ext/v8/upstream/2.0.6/src/contexts.h +345 -0
  94. data/ext/v8/upstream/2.0.6/src/conversions-inl.h +95 -0
  95. data/ext/v8/upstream/2.0.6/src/conversions.cc +709 -0
  96. data/ext/v8/upstream/2.0.6/src/conversions.h +118 -0
  97. data/ext/v8/upstream/2.0.6/src/counters.cc +78 -0
  98. data/ext/v8/upstream/2.0.6/src/counters.h +239 -0
  99. data/ext/v8/upstream/2.0.6/src/cpu.h +65 -0
  100. data/ext/v8/upstream/2.0.6/src/d8-debug.cc +345 -0
  101. data/ext/v8/upstream/2.0.6/src/d8-debug.h +155 -0
  102. data/ext/v8/upstream/2.0.6/src/d8-posix.cc +675 -0
  103. data/ext/v8/upstream/2.0.6/src/d8-readline.cc +128 -0
  104. data/ext/v8/upstream/2.0.6/src/d8-windows.cc +42 -0
  105. data/ext/v8/upstream/2.0.6/src/d8.cc +776 -0
  106. data/ext/v8/upstream/2.0.6/src/d8.h +225 -0
  107. data/ext/v8/upstream/2.0.6/src/d8.js +1625 -0
  108. data/ext/v8/upstream/2.0.6/src/date-delay.js +1138 -0
  109. data/ext/v8/upstream/2.0.6/src/dateparser-inl.h +114 -0
  110. data/ext/v8/upstream/2.0.6/src/dateparser.cc +186 -0
  111. data/ext/v8/upstream/2.0.6/src/dateparser.h +240 -0
  112. data/ext/v8/upstream/2.0.6/src/debug-agent.cc +425 -0
  113. data/ext/v8/upstream/2.0.6/src/debug-agent.h +129 -0
  114. data/ext/v8/upstream/2.0.6/src/debug-delay.js +2073 -0
  115. data/ext/v8/upstream/2.0.6/src/debug.cc +2751 -0
  116. data/ext/v8/upstream/2.0.6/src/debug.h +866 -0
  117. data/ext/v8/upstream/2.0.6/src/disasm.h +77 -0
  118. data/ext/v8/upstream/2.0.6/src/disassembler.cc +318 -0
  119. data/ext/v8/upstream/2.0.6/src/disassembler.h +56 -0
  120. data/ext/v8/upstream/2.0.6/src/dtoa-config.c +91 -0
  121. data/ext/v8/upstream/2.0.6/src/execution.cc +701 -0
  122. data/ext/v8/upstream/2.0.6/src/execution.h +312 -0
  123. data/ext/v8/upstream/2.0.6/src/factory.cc +957 -0
  124. data/ext/v8/upstream/2.0.6/src/factory.h +393 -0
  125. data/ext/v8/upstream/2.0.6/src/fast-codegen.cc +725 -0
  126. data/ext/v8/upstream/2.0.6/src/fast-codegen.h +371 -0
  127. data/ext/v8/upstream/2.0.6/src/flag-definitions.h +426 -0
  128. data/ext/v8/upstream/2.0.6/src/flags.cc +555 -0
  129. data/ext/v8/upstream/2.0.6/src/flags.h +81 -0
  130. data/ext/v8/upstream/2.0.6/src/frame-element.cc +45 -0
  131. data/ext/v8/upstream/2.0.6/src/frame-element.h +235 -0
  132. data/ext/v8/upstream/2.0.6/src/frames-inl.h +215 -0
  133. data/ext/v8/upstream/2.0.6/src/frames.cc +749 -0
  134. data/ext/v8/upstream/2.0.6/src/frames.h +659 -0
  135. data/ext/v8/upstream/2.0.6/src/func-name-inferrer.cc +76 -0
  136. data/ext/v8/upstream/2.0.6/src/func-name-inferrer.h +135 -0
  137. data/ext/v8/upstream/2.0.6/src/global-handles.cc +516 -0
  138. data/ext/v8/upstream/2.0.6/src/global-handles.h +180 -0
  139. data/ext/v8/upstream/2.0.6/src/globals.h +608 -0
  140. data/ext/v8/upstream/2.0.6/src/handles-inl.h +76 -0
  141. data/ext/v8/upstream/2.0.6/src/handles.cc +811 -0
  142. data/ext/v8/upstream/2.0.6/src/handles.h +367 -0
  143. data/ext/v8/upstream/2.0.6/src/hashmap.cc +226 -0
  144. data/ext/v8/upstream/2.0.6/src/hashmap.h +120 -0
  145. data/ext/v8/upstream/2.0.6/src/heap-inl.h +407 -0
  146. data/ext/v8/upstream/2.0.6/src/heap-profiler.cc +695 -0
  147. data/ext/v8/upstream/2.0.6/src/heap-profiler.h +277 -0
  148. data/ext/v8/upstream/2.0.6/src/heap.cc +4204 -0
  149. data/ext/v8/upstream/2.0.6/src/heap.h +1704 -0
  150. data/ext/v8/upstream/2.0.6/src/ia32/assembler-ia32-inl.h +325 -0
  151. data/ext/v8/upstream/2.0.6/src/ia32/assembler-ia32.cc +2375 -0
  152. data/ext/v8/upstream/2.0.6/src/ia32/assembler-ia32.h +914 -0
  153. data/ext/v8/upstream/2.0.6/src/ia32/builtins-ia32.cc +1222 -0
  154. data/ext/v8/upstream/2.0.6/src/ia32/codegen-ia32-inl.h +46 -0
  155. data/ext/v8/upstream/2.0.6/src/ia32/codegen-ia32.cc +9770 -0
  156. data/ext/v8/upstream/2.0.6/src/ia32/codegen-ia32.h +834 -0
  157. data/ext/v8/upstream/2.0.6/src/ia32/cpu-ia32.cc +79 -0
  158. data/ext/v8/upstream/2.0.6/src/ia32/debug-ia32.cc +208 -0
  159. data/ext/v8/upstream/2.0.6/src/ia32/disasm-ia32.cc +1357 -0
  160. data/ext/v8/upstream/2.0.6/src/ia32/fast-codegen-ia32.cc +1813 -0
  161. data/ext/v8/upstream/2.0.6/src/ia32/frames-ia32.cc +111 -0
  162. data/ext/v8/upstream/2.0.6/src/ia32/frames-ia32.h +135 -0
  163. data/ext/v8/upstream/2.0.6/src/ia32/ic-ia32.cc +1490 -0
  164. data/ext/v8/upstream/2.0.6/src/ia32/jump-target-ia32.cc +432 -0
  165. data/ext/v8/upstream/2.0.6/src/ia32/macro-assembler-ia32.cc +1517 -0
  166. data/ext/v8/upstream/2.0.6/src/ia32/macro-assembler-ia32.h +528 -0
  167. data/ext/v8/upstream/2.0.6/src/ia32/regexp-macro-assembler-ia32.cc +1219 -0
  168. data/ext/v8/upstream/2.0.6/src/ia32/regexp-macro-assembler-ia32.h +230 -0
  169. data/ext/v8/upstream/2.0.6/src/ia32/register-allocator-ia32-inl.h +82 -0
  170. data/ext/v8/upstream/2.0.6/src/ia32/register-allocator-ia32.cc +99 -0
  171. data/ext/v8/upstream/2.0.6/src/ia32/register-allocator-ia32.h +43 -0
  172. data/ext/v8/upstream/2.0.6/src/ia32/simulator-ia32.cc +30 -0
  173. data/ext/v8/upstream/2.0.6/src/ia32/simulator-ia32.h +62 -0
  174. data/ext/v8/upstream/2.0.6/src/ia32/stub-cache-ia32.cc +1961 -0
  175. data/ext/v8/upstream/2.0.6/src/ia32/virtual-frame-ia32.cc +1105 -0
  176. data/ext/v8/upstream/2.0.6/src/ia32/virtual-frame-ia32.h +580 -0
  177. data/ext/v8/upstream/2.0.6/src/ic-inl.h +93 -0
  178. data/ext/v8/upstream/2.0.6/src/ic.cc +1426 -0
  179. data/ext/v8/upstream/2.0.6/src/ic.h +443 -0
  180. data/ext/v8/upstream/2.0.6/src/interpreter-irregexp.cc +646 -0
  181. data/ext/v8/upstream/2.0.6/src/interpreter-irregexp.h +48 -0
  182. data/ext/v8/upstream/2.0.6/src/json-delay.js +254 -0
  183. data/ext/v8/upstream/2.0.6/src/jsregexp.cc +5234 -0
  184. data/ext/v8/upstream/2.0.6/src/jsregexp.h +1439 -0
  185. data/ext/v8/upstream/2.0.6/src/jump-target-inl.h +49 -0
  186. data/ext/v8/upstream/2.0.6/src/jump-target.cc +383 -0
  187. data/ext/v8/upstream/2.0.6/src/jump-target.h +280 -0
  188. data/ext/v8/upstream/2.0.6/src/list-inl.h +166 -0
  189. data/ext/v8/upstream/2.0.6/src/list.h +158 -0
  190. data/ext/v8/upstream/2.0.6/src/log-inl.h +126 -0
  191. data/ext/v8/upstream/2.0.6/src/log-utils.cc +503 -0
  192. data/ext/v8/upstream/2.0.6/src/log-utils.h +292 -0
  193. data/ext/v8/upstream/2.0.6/src/log.cc +1457 -0
  194. data/ext/v8/upstream/2.0.6/src/log.h +371 -0
  195. data/ext/v8/upstream/2.0.6/src/macro-assembler.h +93 -0
  196. data/ext/v8/upstream/2.0.6/src/macros.py +137 -0
  197. data/ext/v8/upstream/2.0.6/src/mark-compact.cc +2007 -0
  198. data/ext/v8/upstream/2.0.6/src/mark-compact.h +442 -0
  199. data/ext/v8/upstream/2.0.6/src/math.js +263 -0
  200. data/ext/v8/upstream/2.0.6/src/memory.h +74 -0
  201. data/ext/v8/upstream/2.0.6/src/messages.cc +177 -0
  202. data/ext/v8/upstream/2.0.6/src/messages.h +112 -0
  203. data/ext/v8/upstream/2.0.6/src/messages.js +937 -0
  204. data/ext/v8/upstream/2.0.6/src/mirror-delay.js +2332 -0
  205. data/ext/v8/upstream/2.0.6/src/mksnapshot.cc +169 -0
  206. data/ext/v8/upstream/2.0.6/src/natives.h +63 -0
  207. data/ext/v8/upstream/2.0.6/src/objects-debug.cc +1317 -0
  208. data/ext/v8/upstream/2.0.6/src/objects-inl.h +3044 -0
  209. data/ext/v8/upstream/2.0.6/src/objects.cc +8306 -0
  210. data/ext/v8/upstream/2.0.6/src/objects.h +4960 -0
  211. data/ext/v8/upstream/2.0.6/src/oprofile-agent.cc +116 -0
  212. data/ext/v8/upstream/2.0.6/src/oprofile-agent.h +69 -0
  213. data/ext/v8/upstream/2.0.6/src/parser.cc +4810 -0
  214. data/ext/v8/upstream/2.0.6/src/parser.h +195 -0
  215. data/ext/v8/upstream/2.0.6/src/platform-freebsd.cc +645 -0
  216. data/ext/v8/upstream/2.0.6/src/platform-linux.cc +808 -0
  217. data/ext/v8/upstream/2.0.6/src/platform-macos.cc +643 -0
  218. data/ext/v8/upstream/2.0.6/src/platform-nullos.cc +454 -0
  219. data/ext/v8/upstream/2.0.6/src/platform-openbsd.cc +597 -0
  220. data/ext/v8/upstream/2.0.6/src/platform-posix.cc +380 -0
  221. data/ext/v8/upstream/2.0.6/src/platform-win32.cc +1908 -0
  222. data/ext/v8/upstream/2.0.6/src/platform.h +556 -0
  223. data/ext/v8/upstream/2.0.6/src/prettyprinter.cc +1511 -0
  224. data/ext/v8/upstream/2.0.6/src/prettyprinter.h +219 -0
  225. data/ext/v8/upstream/2.0.6/src/property.cc +96 -0
  226. data/ext/v8/upstream/2.0.6/src/property.h +327 -0
  227. data/ext/v8/upstream/2.0.6/src/regexp-delay.js +406 -0
  228. data/ext/v8/upstream/2.0.6/src/regexp-macro-assembler-irregexp-inl.h +78 -0
  229. data/ext/v8/upstream/2.0.6/src/regexp-macro-assembler-irregexp.cc +464 -0
  230. data/ext/v8/upstream/2.0.6/src/regexp-macro-assembler-irregexp.h +141 -0
  231. data/ext/v8/upstream/2.0.6/src/regexp-macro-assembler-tracer.cc +356 -0
  232. data/ext/v8/upstream/2.0.6/src/regexp-macro-assembler-tracer.h +103 -0
  233. data/ext/v8/upstream/2.0.6/src/regexp-macro-assembler.cc +240 -0
  234. data/ext/v8/upstream/2.0.6/src/regexp-macro-assembler.h +220 -0
  235. data/ext/v8/upstream/2.0.6/src/regexp-stack.cc +103 -0
  236. data/ext/v8/upstream/2.0.6/src/regexp-stack.h +123 -0
  237. data/ext/v8/upstream/2.0.6/src/register-allocator-inl.h +74 -0
  238. data/ext/v8/upstream/2.0.6/src/register-allocator.cc +100 -0
  239. data/ext/v8/upstream/2.0.6/src/register-allocator.h +295 -0
  240. data/ext/v8/upstream/2.0.6/src/rewriter.cc +855 -0
  241. data/ext/v8/upstream/2.0.6/src/rewriter.h +54 -0
  242. data/ext/v8/upstream/2.0.6/src/runtime.cc +8163 -0
  243. data/ext/v8/upstream/2.0.6/src/runtime.h +432 -0
  244. data/ext/v8/upstream/2.0.6/src/runtime.js +626 -0
  245. data/ext/v8/upstream/2.0.6/src/scanner.cc +1098 -0
  246. data/ext/v8/upstream/2.0.6/src/scanner.h +425 -0
  247. data/ext/v8/upstream/2.0.6/src/scopeinfo.cc +649 -0
  248. data/ext/v8/upstream/2.0.6/src/scopeinfo.h +236 -0
  249. data/ext/v8/upstream/2.0.6/src/scopes.cc +963 -0
  250. data/ext/v8/upstream/2.0.6/src/scopes.h +401 -0
  251. data/ext/v8/upstream/2.0.6/src/serialize.cc +1260 -0
  252. data/ext/v8/upstream/2.0.6/src/serialize.h +404 -0
  253. data/ext/v8/upstream/2.0.6/src/shell.h +55 -0
  254. data/ext/v8/upstream/2.0.6/src/simulator.h +41 -0
  255. data/ext/v8/upstream/2.0.6/src/smart-pointer.h +109 -0
  256. data/ext/v8/upstream/2.0.6/src/snapshot-common.cc +97 -0
  257. data/ext/v8/upstream/2.0.6/src/snapshot-empty.cc +40 -0
  258. data/ext/v8/upstream/2.0.6/src/snapshot.h +59 -0
  259. data/ext/v8/upstream/2.0.6/src/spaces-inl.h +372 -0
  260. data/ext/v8/upstream/2.0.6/src/spaces.cc +2864 -0
  261. data/ext/v8/upstream/2.0.6/src/spaces.h +2072 -0
  262. data/ext/v8/upstream/2.0.6/src/string-stream.cc +584 -0
  263. data/ext/v8/upstream/2.0.6/src/string-stream.h +189 -0
  264. data/ext/v8/upstream/2.0.6/src/string.js +901 -0
  265. data/ext/v8/upstream/2.0.6/src/stub-cache.cc +1108 -0
  266. data/ext/v8/upstream/2.0.6/src/stub-cache.h +578 -0
  267. data/ext/v8/upstream/2.0.6/src/third_party/dtoa/COPYING +15 -0
  268. data/ext/v8/upstream/2.0.6/src/third_party/dtoa/dtoa.c +3330 -0
  269. data/ext/v8/upstream/2.0.6/src/third_party/valgrind/valgrind.h +3925 -0
  270. data/ext/v8/upstream/2.0.6/src/token.cc +56 -0
  271. data/ext/v8/upstream/2.0.6/src/token.h +270 -0
  272. data/ext/v8/upstream/2.0.6/src/top.cc +991 -0
  273. data/ext/v8/upstream/2.0.6/src/top.h +459 -0
  274. data/ext/v8/upstream/2.0.6/src/unicode-inl.h +238 -0
  275. data/ext/v8/upstream/2.0.6/src/unicode.cc +749 -0
  276. data/ext/v8/upstream/2.0.6/src/unicode.h +279 -0
  277. data/ext/v8/upstream/2.0.6/src/uri.js +415 -0
  278. data/ext/v8/upstream/2.0.6/src/usage-analyzer.cc +426 -0
  279. data/ext/v8/upstream/2.0.6/src/usage-analyzer.h +40 -0
  280. data/ext/v8/upstream/2.0.6/src/utils.cc +322 -0
  281. data/ext/v8/upstream/2.0.6/src/utils.h +592 -0
  282. data/ext/v8/upstream/2.0.6/src/v8-counters.cc +55 -0
  283. data/ext/v8/upstream/2.0.6/src/v8-counters.h +198 -0
  284. data/ext/v8/upstream/2.0.6/src/v8.cc +193 -0
  285. data/ext/v8/upstream/2.0.6/src/v8.h +119 -0
  286. data/ext/v8/upstream/2.0.6/src/v8natives.js +846 -0
  287. data/ext/v8/upstream/2.0.6/src/v8threads.cc +450 -0
  288. data/ext/v8/upstream/2.0.6/src/v8threads.h +144 -0
  289. data/ext/v8/upstream/2.0.6/src/variables.cc +163 -0
  290. data/ext/v8/upstream/2.0.6/src/variables.h +235 -0
  291. data/ext/v8/upstream/2.0.6/src/version.cc +88 -0
  292. data/ext/v8/upstream/2.0.6/src/version.h +64 -0
  293. data/ext/v8/upstream/2.0.6/src/virtual-frame.cc +381 -0
  294. data/ext/v8/upstream/2.0.6/src/virtual-frame.h +44 -0
  295. data/ext/v8/upstream/2.0.6/src/x64/assembler-x64-inl.h +352 -0
  296. data/ext/v8/upstream/2.0.6/src/x64/assembler-x64.cc +2539 -0
  297. data/ext/v8/upstream/2.0.6/src/x64/assembler-x64.h +1399 -0
  298. data/ext/v8/upstream/2.0.6/src/x64/builtins-x64.cc +1255 -0
  299. data/ext/v8/upstream/2.0.6/src/x64/codegen-x64-inl.h +46 -0
  300. data/ext/v8/upstream/2.0.6/src/x64/codegen-x64.cc +8223 -0
  301. data/ext/v8/upstream/2.0.6/src/x64/codegen-x64.h +785 -0
  302. data/ext/v8/upstream/2.0.6/src/x64/cpu-x64.cc +79 -0
  303. data/ext/v8/upstream/2.0.6/src/x64/debug-x64.cc +202 -0
  304. data/ext/v8/upstream/2.0.6/src/x64/disasm-x64.cc +1596 -0
  305. data/ext/v8/upstream/2.0.6/src/x64/fast-codegen-x64.cc +1820 -0
  306. data/ext/v8/upstream/2.0.6/src/x64/frames-x64.cc +109 -0
  307. data/ext/v8/upstream/2.0.6/src/x64/frames-x64.h +121 -0
  308. data/ext/v8/upstream/2.0.6/src/x64/ic-x64.cc +1392 -0
  309. data/ext/v8/upstream/2.0.6/src/x64/jump-target-x64.cc +432 -0
  310. data/ext/v8/upstream/2.0.6/src/x64/macro-assembler-x64.cc +2409 -0
  311. data/ext/v8/upstream/2.0.6/src/x64/macro-assembler-x64.h +765 -0
  312. data/ext/v8/upstream/2.0.6/src/x64/regexp-macro-assembler-x64.cc +1337 -0
  313. data/ext/v8/upstream/2.0.6/src/x64/regexp-macro-assembler-x64.h +295 -0
  314. data/ext/v8/upstream/2.0.6/src/x64/register-allocator-x64-inl.h +86 -0
  315. data/ext/v8/upstream/2.0.6/src/x64/register-allocator-x64.cc +84 -0
  316. data/ext/v8/upstream/2.0.6/src/x64/register-allocator-x64.h +43 -0
  317. data/ext/v8/upstream/2.0.6/src/x64/simulator-x64.cc +27 -0
  318. data/ext/v8/upstream/2.0.6/src/x64/simulator-x64.h +63 -0
  319. data/ext/v8/upstream/2.0.6/src/x64/stub-cache-x64.cc +1884 -0
  320. data/ext/v8/upstream/2.0.6/src/x64/virtual-frame-x64.cc +1089 -0
  321. data/ext/v8/upstream/2.0.6/src/x64/virtual-frame-x64.h +560 -0
  322. data/ext/v8/upstream/2.0.6/src/zone-inl.h +297 -0
  323. data/ext/v8/upstream/2.0.6/src/zone.cc +193 -0
  324. data/ext/v8/upstream/2.0.6/src/zone.h +305 -0
  325. data/ext/v8/upstream/2.0.6/tools/codemap.js +258 -0
  326. data/ext/v8/upstream/2.0.6/tools/consarray.js +93 -0
  327. data/ext/v8/upstream/2.0.6/tools/csvparser.js +98 -0
  328. data/ext/v8/upstream/2.0.6/tools/gyp/v8.gyp +620 -0
  329. data/ext/v8/upstream/2.0.6/tools/js2c.py +376 -0
  330. data/ext/v8/upstream/2.0.6/tools/jsmin.py +280 -0
  331. data/ext/v8/upstream/2.0.6/tools/linux-tick-processor +24 -0
  332. data/ext/v8/upstream/2.0.6/tools/linux-tick-processor.py +78 -0
  333. data/ext/v8/upstream/2.0.6/tools/logreader.js +320 -0
  334. data/ext/v8/upstream/2.0.6/tools/mac-nm +18 -0
  335. data/ext/v8/upstream/2.0.6/tools/mac-tick-processor +6 -0
  336. data/ext/v8/upstream/2.0.6/tools/oprofile/annotate +7 -0
  337. data/ext/v8/upstream/2.0.6/tools/oprofile/common +19 -0
  338. data/ext/v8/upstream/2.0.6/tools/oprofile/dump +7 -0
  339. data/ext/v8/upstream/2.0.6/tools/oprofile/report +7 -0
  340. data/ext/v8/upstream/2.0.6/tools/oprofile/reset +7 -0
  341. data/ext/v8/upstream/2.0.6/tools/oprofile/run +14 -0
  342. data/ext/v8/upstream/2.0.6/tools/oprofile/shutdown +7 -0
  343. data/ext/v8/upstream/2.0.6/tools/oprofile/start +7 -0
  344. data/ext/v8/upstream/2.0.6/tools/presubmit.py +299 -0
  345. data/ext/v8/upstream/2.0.6/tools/process-heap-prof.py +120 -0
  346. data/ext/v8/upstream/2.0.6/tools/profile.js +621 -0
  347. data/ext/v8/upstream/2.0.6/tools/profile_view.js +224 -0
  348. data/ext/v8/upstream/2.0.6/tools/run-valgrind.py +77 -0
  349. data/ext/v8/upstream/2.0.6/tools/splaytree.js +322 -0
  350. data/ext/v8/upstream/2.0.6/tools/splaytree.py +226 -0
  351. data/ext/v8/upstream/2.0.6/tools/stats-viewer.py +456 -0
  352. data/ext/v8/upstream/2.0.6/tools/test.py +1370 -0
  353. data/ext/v8/upstream/2.0.6/tools/tickprocessor-driver.js +53 -0
  354. data/ext/v8/upstream/2.0.6/tools/tickprocessor.js +731 -0
  355. data/ext/v8/upstream/2.0.6/tools/tickprocessor.py +535 -0
  356. data/ext/v8/upstream/2.0.6/tools/utils.py +82 -0
  357. data/ext/v8/upstream/2.0.6/tools/visual_studio/README.txt +71 -0
  358. data/ext/v8/upstream/2.0.6/tools/visual_studio/arm.vsprops +14 -0
  359. data/ext/v8/upstream/2.0.6/tools/visual_studio/common.vsprops +35 -0
  360. data/ext/v8/upstream/2.0.6/tools/visual_studio/d8.vcproj +199 -0
  361. data/ext/v8/upstream/2.0.6/tools/visual_studio/d8_arm.vcproj +199 -0
  362. data/ext/v8/upstream/2.0.6/tools/visual_studio/d8_x64.vcproj +201 -0
  363. data/ext/v8/upstream/2.0.6/tools/visual_studio/d8js2c.cmd +6 -0
  364. data/ext/v8/upstream/2.0.6/tools/visual_studio/debug.vsprops +17 -0
  365. data/ext/v8/upstream/2.0.6/tools/visual_studio/ia32.vsprops +13 -0
  366. data/ext/v8/upstream/2.0.6/tools/visual_studio/js2c.cmd +6 -0
  367. data/ext/v8/upstream/2.0.6/tools/visual_studio/release.vsprops +24 -0
  368. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8.sln +101 -0
  369. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8.vcproj +223 -0
  370. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_arm.sln +74 -0
  371. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_arm.vcproj +223 -0
  372. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_base.vcproj +971 -0
  373. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_base_arm.vcproj +983 -0
  374. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_base_x64.vcproj +959 -0
  375. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_cctest.vcproj +255 -0
  376. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_cctest_arm.vcproj +243 -0
  377. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_cctest_x64.vcproj +257 -0
  378. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_mksnapshot.vcproj +151 -0
  379. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_mksnapshot_x64.vcproj +151 -0
  380. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_process_sample.vcproj +151 -0
  381. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_process_sample_arm.vcproj +151 -0
  382. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_process_sample_x64.vcproj +151 -0
  383. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_shell_sample.vcproj +151 -0
  384. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_shell_sample_arm.vcproj +151 -0
  385. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_shell_sample_x64.vcproj +153 -0
  386. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_snapshot.vcproj +142 -0
  387. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_snapshot_cc.vcproj +92 -0
  388. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_snapshot_cc_x64.vcproj +92 -0
  389. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_snapshot_x64.vcproj +142 -0
  390. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_x64.sln +101 -0
  391. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_x64.vcproj +223 -0
  392. data/ext/v8/upstream/2.0.6/tools/visual_studio/x64.vsprops +13 -0
  393. data/ext/v8/upstream/2.0.6/tools/windows-tick-processor.bat +5 -0
  394. data/ext/v8/upstream/2.0.6/tools/windows-tick-processor.py +137 -0
  395. data/ext/v8/upstream/Makefile +31 -0
  396. data/ext/v8/upstream/no-strict-aliasing.patch +13 -0
  397. data/ext/v8/upstream/scons/CHANGES.txt +5183 -0
  398. data/ext/v8/upstream/scons/LICENSE.txt +20 -0
  399. data/ext/v8/upstream/scons/MANIFEST +202 -0
  400. data/ext/v8/upstream/scons/PKG-INFO +13 -0
  401. data/ext/v8/upstream/scons/README.txt +273 -0
  402. data/ext/v8/upstream/scons/RELEASE.txt +1040 -0
  403. data/ext/v8/upstream/scons/engine/SCons/Action.py +1256 -0
  404. data/ext/v8/upstream/scons/engine/SCons/Builder.py +868 -0
  405. data/ext/v8/upstream/scons/engine/SCons/CacheDir.py +217 -0
  406. data/ext/v8/upstream/scons/engine/SCons/Conftest.py +794 -0
  407. data/ext/v8/upstream/scons/engine/SCons/Debug.py +237 -0
  408. data/ext/v8/upstream/scons/engine/SCons/Defaults.py +485 -0
  409. data/ext/v8/upstream/scons/engine/SCons/Environment.py +2327 -0
  410. data/ext/v8/upstream/scons/engine/SCons/Errors.py +207 -0
  411. data/ext/v8/upstream/scons/engine/SCons/Executor.py +636 -0
  412. data/ext/v8/upstream/scons/engine/SCons/Job.py +435 -0
  413. data/ext/v8/upstream/scons/engine/SCons/Memoize.py +292 -0
  414. data/ext/v8/upstream/scons/engine/SCons/Node/Alias.py +153 -0
  415. data/ext/v8/upstream/scons/engine/SCons/Node/FS.py +3220 -0
  416. data/ext/v8/upstream/scons/engine/SCons/Node/Python.py +128 -0
  417. data/ext/v8/upstream/scons/engine/SCons/Node/__init__.py +1341 -0
  418. data/ext/v8/upstream/scons/engine/SCons/Options/BoolOption.py +50 -0
  419. data/ext/v8/upstream/scons/engine/SCons/Options/EnumOption.py +50 -0
  420. data/ext/v8/upstream/scons/engine/SCons/Options/ListOption.py +50 -0
  421. data/ext/v8/upstream/scons/engine/SCons/Options/PackageOption.py +50 -0
  422. data/ext/v8/upstream/scons/engine/SCons/Options/PathOption.py +76 -0
  423. data/ext/v8/upstream/scons/engine/SCons/Options/__init__.py +74 -0
  424. data/ext/v8/upstream/scons/engine/SCons/PathList.py +232 -0
  425. data/ext/v8/upstream/scons/engine/SCons/Platform/__init__.py +236 -0
  426. data/ext/v8/upstream/scons/engine/SCons/Platform/aix.py +70 -0
  427. data/ext/v8/upstream/scons/engine/SCons/Platform/cygwin.py +55 -0
  428. data/ext/v8/upstream/scons/engine/SCons/Platform/darwin.py +46 -0
  429. data/ext/v8/upstream/scons/engine/SCons/Platform/hpux.py +46 -0
  430. data/ext/v8/upstream/scons/engine/SCons/Platform/irix.py +44 -0
  431. data/ext/v8/upstream/scons/engine/SCons/Platform/os2.py +58 -0
  432. data/ext/v8/upstream/scons/engine/SCons/Platform/posix.py +264 -0
  433. data/ext/v8/upstream/scons/engine/SCons/Platform/sunos.py +50 -0
  434. data/ext/v8/upstream/scons/engine/SCons/Platform/win32.py +386 -0
  435. data/ext/v8/upstream/scons/engine/SCons/SConf.py +1038 -0
  436. data/ext/v8/upstream/scons/engine/SCons/SConsign.py +381 -0
  437. data/ext/v8/upstream/scons/engine/SCons/Scanner/C.py +132 -0
  438. data/ext/v8/upstream/scons/engine/SCons/Scanner/D.py +74 -0
  439. data/ext/v8/upstream/scons/engine/SCons/Scanner/Dir.py +111 -0
  440. data/ext/v8/upstream/scons/engine/SCons/Scanner/Fortran.py +320 -0
  441. data/ext/v8/upstream/scons/engine/SCons/Scanner/IDL.py +48 -0
  442. data/ext/v8/upstream/scons/engine/SCons/Scanner/LaTeX.py +378 -0
  443. data/ext/v8/upstream/scons/engine/SCons/Scanner/Prog.py +103 -0
  444. data/ext/v8/upstream/scons/engine/SCons/Scanner/RC.py +55 -0
  445. data/ext/v8/upstream/scons/engine/SCons/Scanner/__init__.py +415 -0
  446. data/ext/v8/upstream/scons/engine/SCons/Script/Interactive.py +386 -0
  447. data/ext/v8/upstream/scons/engine/SCons/Script/Main.py +1360 -0
  448. data/ext/v8/upstream/scons/engine/SCons/Script/SConsOptions.py +944 -0
  449. data/ext/v8/upstream/scons/engine/SCons/Script/SConscript.py +642 -0
  450. data/ext/v8/upstream/scons/engine/SCons/Script/__init__.py +414 -0
  451. data/ext/v8/upstream/scons/engine/SCons/Sig.py +63 -0
  452. data/ext/v8/upstream/scons/engine/SCons/Subst.py +911 -0
  453. data/ext/v8/upstream/scons/engine/SCons/Taskmaster.py +1030 -0
  454. data/ext/v8/upstream/scons/engine/SCons/Tool/386asm.py +61 -0
  455. data/ext/v8/upstream/scons/engine/SCons/Tool/BitKeeper.py +65 -0
  456. data/ext/v8/upstream/scons/engine/SCons/Tool/CVS.py +73 -0
  457. data/ext/v8/upstream/scons/engine/SCons/Tool/FortranCommon.py +247 -0
  458. data/ext/v8/upstream/scons/engine/SCons/Tool/JavaCommon.py +324 -0
  459. data/ext/v8/upstream/scons/engine/SCons/Tool/MSCommon/__init__.py +56 -0
  460. data/ext/v8/upstream/scons/engine/SCons/Tool/MSCommon/arch.py +61 -0
  461. data/ext/v8/upstream/scons/engine/SCons/Tool/MSCommon/common.py +210 -0
  462. data/ext/v8/upstream/scons/engine/SCons/Tool/MSCommon/netframework.py +84 -0
  463. data/ext/v8/upstream/scons/engine/SCons/Tool/MSCommon/sdk.py +321 -0
  464. data/ext/v8/upstream/scons/engine/SCons/Tool/MSCommon/vc.py +367 -0
  465. data/ext/v8/upstream/scons/engine/SCons/Tool/MSCommon/vs.py +497 -0
  466. data/ext/v8/upstream/scons/engine/SCons/Tool/Perforce.py +104 -0
  467. data/ext/v8/upstream/scons/engine/SCons/Tool/PharLapCommon.py +138 -0
  468. data/ext/v8/upstream/scons/engine/SCons/Tool/RCS.py +64 -0
  469. data/ext/v8/upstream/scons/engine/SCons/Tool/SCCS.py +64 -0
  470. data/ext/v8/upstream/scons/engine/SCons/Tool/Subversion.py +71 -0
  471. data/ext/v8/upstream/scons/engine/SCons/Tool/__init__.py +675 -0
  472. data/ext/v8/upstream/scons/engine/SCons/Tool/aixc++.py +82 -0
  473. data/ext/v8/upstream/scons/engine/SCons/Tool/aixcc.py +74 -0
  474. data/ext/v8/upstream/scons/engine/SCons/Tool/aixf77.py +80 -0
  475. data/ext/v8/upstream/scons/engine/SCons/Tool/aixlink.py +76 -0
  476. data/ext/v8/upstream/scons/engine/SCons/Tool/applelink.py +71 -0
  477. data/ext/v8/upstream/scons/engine/SCons/Tool/ar.py +63 -0
  478. data/ext/v8/upstream/scons/engine/SCons/Tool/as.py +78 -0
  479. data/ext/v8/upstream/scons/engine/SCons/Tool/bcc32.py +82 -0
  480. data/ext/v8/upstream/scons/engine/SCons/Tool/c++.py +99 -0
  481. data/ext/v8/upstream/scons/engine/SCons/Tool/cc.py +114 -0
  482. data/ext/v8/upstream/scons/engine/SCons/Tool/cvf.py +58 -0
  483. data/ext/v8/upstream/scons/engine/SCons/Tool/default.py +50 -0
  484. data/ext/v8/upstream/scons/engine/SCons/Tool/dmd.py +224 -0
  485. data/ext/v8/upstream/scons/engine/SCons/Tool/dvi.py +64 -0
  486. data/ext/v8/upstream/scons/engine/SCons/Tool/dvipdf.py +125 -0
  487. data/ext/v8/upstream/scons/engine/SCons/Tool/dvips.py +94 -0
  488. data/ext/v8/upstream/scons/engine/SCons/Tool/f77.py +62 -0
  489. data/ext/v8/upstream/scons/engine/SCons/Tool/f90.py +62 -0
  490. data/ext/v8/upstream/scons/engine/SCons/Tool/f95.py +63 -0
  491. data/ext/v8/upstream/scons/engine/SCons/Tool/filesystem.py +98 -0
  492. data/ext/v8/upstream/scons/engine/SCons/Tool/fortran.py +63 -0
  493. data/ext/v8/upstream/scons/engine/SCons/Tool/g++.py +90 -0
  494. data/ext/v8/upstream/scons/engine/SCons/Tool/g77.py +73 -0
  495. data/ext/v8/upstream/scons/engine/SCons/Tool/gas.py +53 -0
  496. data/ext/v8/upstream/scons/engine/SCons/Tool/gcc.py +80 -0
  497. data/ext/v8/upstream/scons/engine/SCons/Tool/gfortran.py +64 -0
  498. data/ext/v8/upstream/scons/engine/SCons/Tool/gnulink.py +63 -0
  499. data/ext/v8/upstream/scons/engine/SCons/Tool/gs.py +81 -0
  500. data/ext/v8/upstream/scons/engine/SCons/Tool/hpc++.py +85 -0
  501. data/ext/v8/upstream/scons/engine/SCons/Tool/hpcc.py +53 -0
  502. data/ext/v8/upstream/scons/engine/SCons/Tool/hplink.py +77 -0
  503. data/ext/v8/upstream/scons/engine/SCons/Tool/icc.py +59 -0
  504. data/ext/v8/upstream/scons/engine/SCons/Tool/icl.py +52 -0
  505. data/ext/v8/upstream/scons/engine/SCons/Tool/ifl.py +72 -0
  506. data/ext/v8/upstream/scons/engine/SCons/Tool/ifort.py +90 -0
  507. data/ext/v8/upstream/scons/engine/SCons/Tool/ilink.py +59 -0
  508. data/ext/v8/upstream/scons/engine/SCons/Tool/ilink32.py +60 -0
  509. data/ext/v8/upstream/scons/engine/SCons/Tool/install.py +229 -0
  510. data/ext/v8/upstream/scons/engine/SCons/Tool/intelc.py +490 -0
  511. data/ext/v8/upstream/scons/engine/SCons/Tool/ipkg.py +71 -0
  512. data/ext/v8/upstream/scons/engine/SCons/Tool/jar.py +110 -0
  513. data/ext/v8/upstream/scons/engine/SCons/Tool/javac.py +234 -0
  514. data/ext/v8/upstream/scons/engine/SCons/Tool/javah.py +138 -0
  515. data/ext/v8/upstream/scons/engine/SCons/Tool/latex.py +79 -0
  516. data/ext/v8/upstream/scons/engine/SCons/Tool/lex.py +99 -0
  517. data/ext/v8/upstream/scons/engine/SCons/Tool/link.py +121 -0
  518. data/ext/v8/upstream/scons/engine/SCons/Tool/linkloc.py +112 -0
  519. data/ext/v8/upstream/scons/engine/SCons/Tool/m4.py +63 -0
  520. data/ext/v8/upstream/scons/engine/SCons/Tool/masm.py +77 -0
  521. data/ext/v8/upstream/scons/engine/SCons/Tool/midl.py +90 -0
  522. data/ext/v8/upstream/scons/engine/SCons/Tool/mingw.py +159 -0
  523. data/ext/v8/upstream/scons/engine/SCons/Tool/mslib.py +64 -0
  524. data/ext/v8/upstream/scons/engine/SCons/Tool/mslink.py +266 -0
  525. data/ext/v8/upstream/scons/engine/SCons/Tool/mssdk.py +50 -0
  526. data/ext/v8/upstream/scons/engine/SCons/Tool/msvc.py +269 -0
  527. data/ext/v8/upstream/scons/engine/SCons/Tool/msvs.py +1439 -0
  528. data/ext/v8/upstream/scons/engine/SCons/Tool/mwcc.py +208 -0
  529. data/ext/v8/upstream/scons/engine/SCons/Tool/mwld.py +107 -0
  530. data/ext/v8/upstream/scons/engine/SCons/Tool/nasm.py +72 -0
  531. data/ext/v8/upstream/scons/engine/SCons/Tool/packaging/__init__.py +314 -0
  532. data/ext/v8/upstream/scons/engine/SCons/Tool/packaging/ipk.py +185 -0
  533. data/ext/v8/upstream/scons/engine/SCons/Tool/packaging/msi.py +526 -0
  534. data/ext/v8/upstream/scons/engine/SCons/Tool/packaging/rpm.py +367 -0
  535. data/ext/v8/upstream/scons/engine/SCons/Tool/packaging/src_tarbz2.py +43 -0
  536. data/ext/v8/upstream/scons/engine/SCons/Tool/packaging/src_targz.py +43 -0
  537. data/ext/v8/upstream/scons/engine/SCons/Tool/packaging/src_zip.py +43 -0
  538. data/ext/v8/upstream/scons/engine/SCons/Tool/packaging/tarbz2.py +44 -0
  539. data/ext/v8/upstream/scons/engine/SCons/Tool/packaging/targz.py +44 -0
  540. data/ext/v8/upstream/scons/engine/SCons/Tool/packaging/zip.py +44 -0
  541. data/ext/v8/upstream/scons/engine/SCons/Tool/pdf.py +78 -0
  542. data/ext/v8/upstream/scons/engine/SCons/Tool/pdflatex.py +83 -0
  543. data/ext/v8/upstream/scons/engine/SCons/Tool/pdftex.py +108 -0
  544. data/ext/v8/upstream/scons/engine/SCons/Tool/qt.py +336 -0
  545. data/ext/v8/upstream/scons/engine/SCons/Tool/rmic.py +121 -0
  546. data/ext/v8/upstream/scons/engine/SCons/Tool/rpcgen.py +70 -0
  547. data/ext/v8/upstream/scons/engine/SCons/Tool/rpm.py +132 -0
  548. data/ext/v8/upstream/scons/engine/SCons/Tool/sgiar.py +68 -0
  549. data/ext/v8/upstream/scons/engine/SCons/Tool/sgic++.py +58 -0
  550. data/ext/v8/upstream/scons/engine/SCons/Tool/sgicc.py +53 -0
  551. data/ext/v8/upstream/scons/engine/SCons/Tool/sgilink.py +63 -0
  552. data/ext/v8/upstream/scons/engine/SCons/Tool/sunar.py +67 -0
  553. data/ext/v8/upstream/scons/engine/SCons/Tool/sunc++.py +142 -0
  554. data/ext/v8/upstream/scons/engine/SCons/Tool/suncc.py +58 -0
  555. data/ext/v8/upstream/scons/engine/SCons/Tool/sunf77.py +63 -0
  556. data/ext/v8/upstream/scons/engine/SCons/Tool/sunf90.py +64 -0
  557. data/ext/v8/upstream/scons/engine/SCons/Tool/sunf95.py +64 -0
  558. data/ext/v8/upstream/scons/engine/SCons/Tool/sunlink.py +77 -0
  559. data/ext/v8/upstream/scons/engine/SCons/Tool/swig.py +186 -0
  560. data/ext/v8/upstream/scons/engine/SCons/Tool/tar.py +73 -0
  561. data/ext/v8/upstream/scons/engine/SCons/Tool/tex.py +805 -0
  562. data/ext/v8/upstream/scons/engine/SCons/Tool/textfile.py +175 -0
  563. data/ext/v8/upstream/scons/engine/SCons/Tool/tlib.py +53 -0
  564. data/ext/v8/upstream/scons/engine/SCons/Tool/wix.py +100 -0
  565. data/ext/v8/upstream/scons/engine/SCons/Tool/yacc.py +131 -0
  566. data/ext/v8/upstream/scons/engine/SCons/Tool/zip.py +100 -0
  567. data/ext/v8/upstream/scons/engine/SCons/Util.py +1645 -0
  568. data/ext/v8/upstream/scons/engine/SCons/Variables/BoolVariable.py +91 -0
  569. data/ext/v8/upstream/scons/engine/SCons/Variables/EnumVariable.py +107 -0
  570. data/ext/v8/upstream/scons/engine/SCons/Variables/ListVariable.py +139 -0
  571. data/ext/v8/upstream/scons/engine/SCons/Variables/PackageVariable.py +109 -0
  572. data/ext/v8/upstream/scons/engine/SCons/Variables/PathVariable.py +147 -0
  573. data/ext/v8/upstream/scons/engine/SCons/Variables/__init__.py +317 -0
  574. data/ext/v8/upstream/scons/engine/SCons/Warnings.py +228 -0
  575. data/ext/v8/upstream/scons/engine/SCons/__init__.py +49 -0
  576. data/ext/v8/upstream/scons/engine/SCons/compat/__init__.py +302 -0
  577. data/ext/v8/upstream/scons/engine/SCons/compat/_scons_UserString.py +98 -0
  578. data/ext/v8/upstream/scons/engine/SCons/compat/_scons_hashlib.py +91 -0
  579. data/ext/v8/upstream/scons/engine/SCons/compat/_scons_itertools.py +124 -0
  580. data/ext/v8/upstream/scons/engine/SCons/compat/_scons_optparse.py +1725 -0
  581. data/ext/v8/upstream/scons/engine/SCons/compat/_scons_sets.py +583 -0
  582. data/ext/v8/upstream/scons/engine/SCons/compat/_scons_sets15.py +176 -0
  583. data/ext/v8/upstream/scons/engine/SCons/compat/_scons_shlex.py +325 -0
  584. data/ext/v8/upstream/scons/engine/SCons/compat/_scons_subprocess.py +1296 -0
  585. data/ext/v8/upstream/scons/engine/SCons/compat/_scons_textwrap.py +382 -0
  586. data/ext/v8/upstream/scons/engine/SCons/compat/builtins.py +187 -0
  587. data/ext/v8/upstream/scons/engine/SCons/cpp.py +598 -0
  588. data/ext/v8/upstream/scons/engine/SCons/dblite.py +248 -0
  589. data/ext/v8/upstream/scons/engine/SCons/exitfuncs.py +77 -0
  590. data/ext/v8/upstream/scons/os_spawnv_fix.diff +83 -0
  591. data/ext/v8/upstream/scons/scons-time.1 +1017 -0
  592. data/ext/v8/upstream/scons/scons.1 +15179 -0
  593. data/ext/v8/upstream/scons/sconsign.1 +208 -0
  594. data/ext/v8/upstream/scons/script/scons +184 -0
  595. data/ext/v8/upstream/scons/script/scons-time +1529 -0
  596. data/ext/v8/upstream/scons/script/scons.bat +31 -0
  597. data/ext/v8/upstream/scons/script/sconsign +508 -0
  598. data/ext/v8/upstream/scons/setup.cfg +6 -0
  599. data/ext/v8/upstream/scons/setup.py +427 -0
  600. data/ext/v8/v8.cpp +89 -0
  601. data/ext/v8/v8_cxt.cpp +92 -0
  602. data/ext/v8/v8_cxt.h +20 -0
  603. data/ext/v8/v8_func.cpp +10 -0
  604. data/ext/v8/v8_func.h +11 -0
  605. data/ext/v8/v8_msg.cpp +54 -0
  606. data/ext/v8/v8_msg.h +18 -0
  607. data/ext/v8/v8_obj.cpp +52 -0
  608. data/ext/v8/v8_obj.h +13 -0
  609. data/ext/v8/v8_ref.cpp +26 -0
  610. data/ext/v8/v8_ref.h +31 -0
  611. data/ext/v8/v8_script.cpp +20 -0
  612. data/ext/v8/v8_script.h +8 -0
  613. data/ext/v8/v8_standalone.cpp +69 -0
  614. data/ext/v8/v8_standalone.h +31 -0
  615. data/ext/v8/v8_str.cpp +17 -0
  616. data/ext/v8/v8_str.h +9 -0
  617. data/ext/v8/v8_template.cpp +53 -0
  618. data/ext/v8/v8_template.h +13 -0
  619. data/lib/v8.rb +10 -0
  620. data/lib/v8/context.rb +101 -0
  621. data/lib/v8/object.rb +38 -0
  622. data/lib/v8/to.rb +33 -0
  623. data/lib/v8/v8.so +0 -0
  624. data/script/console +10 -0
  625. data/script/destroy +14 -0
  626. data/script/generate +14 -0
  627. data/spec/ext/cxt_spec.rb +25 -0
  628. data/spec/ext/obj_spec.rb +13 -0
  629. data/spec/redjs/jsapi_spec.rb +405 -0
  630. data/spec/redjs/tap.rb +8 -0
  631. data/spec/redjs_helper.rb +3 -0
  632. data/spec/spec.opts +1 -0
  633. data/spec/spec_helper.rb +14 -0
  634. data/spec/v8/to_spec.rb +15 -0
  635. data/tasks/rspec.rake +21 -0
  636. data/therubyracer.gemspec +680 -0
  637. metadata +697 -0
@@ -0,0 +1,275 @@
1
+ // Copyright 2008 the V8 project authors. All rights reserved.
2
+ // Redistribution and use in source and binary forms, with or without
3
+ // modification, are permitted provided that the following conditions are
4
+ // met:
5
+ //
6
+ // * Redistributions of source code must retain the above copyright
7
+ // notice, this list of conditions and the following disclaimer.
8
+ // * Redistributions in binary form must reproduce the above
9
+ // copyright notice, this list of conditions and the following
10
+ // disclaimer in the documentation and/or other materials provided
11
+ // with the distribution.
12
+ // * Neither the name of Google Inc. nor the names of its
13
+ // contributors may be used to endorse or promote products derived
14
+ // from this software without specific prior written permission.
15
+ //
16
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+
28
+ #ifndef V8_V8_DEBUG_H_
29
+ #define V8_V8_DEBUG_H_
30
+
31
+ #include "v8.h"
32
+
33
+ #ifdef _WIN32
34
+ typedef int int32_t;
35
+ typedef unsigned int uint32_t;
36
+ typedef unsigned short uint16_t; // NOLINT
37
+ typedef long long int64_t; // NOLINT
38
+
39
+ // Setup for Windows DLL export/import. See v8.h in this directory for
40
+ // information on how to build/use V8 as a DLL.
41
+ #if defined(BUILDING_V8_SHARED) && defined(USING_V8_SHARED)
42
+ #error both BUILDING_V8_SHARED and USING_V8_SHARED are set - please check the\
43
+ build configuration to ensure that at most one of these is set
44
+ #endif
45
+
46
+ #ifdef BUILDING_V8_SHARED
47
+ #define EXPORT __declspec(dllexport)
48
+ #elif USING_V8_SHARED
49
+ #define EXPORT __declspec(dllimport)
50
+ #else
51
+ #define EXPORT
52
+ #endif
53
+
54
+ #else // _WIN32
55
+
56
+ // Setup for Linux shared library export. See v8.h in this directory for
57
+ // information on how to build/use V8 as shared library.
58
+ #if defined(__GNUC__) && (__GNUC__ >= 4) && defined(V8_SHARED)
59
+ #define EXPORT __attribute__ ((visibility("default")))
60
+ #else // defined(__GNUC__) && (__GNUC__ >= 4)
61
+ #define EXPORT
62
+ #endif // defined(__GNUC__) && (__GNUC__ >= 4)
63
+
64
+ #endif // _WIN32
65
+
66
+
67
+ /**
68
+ * Debugger support for the V8 JavaScript engine.
69
+ */
70
+ namespace v8 {
71
+
72
+ // Debug events which can occur in the V8 JavaScript engine.
73
+ enum DebugEvent {
74
+ Break = 1,
75
+ Exception = 2,
76
+ NewFunction = 3,
77
+ BeforeCompile = 4,
78
+ AfterCompile = 5,
79
+ ScriptCollected = 6
80
+ };
81
+
82
+
83
+ class EXPORT Debug {
84
+ public:
85
+ /**
86
+ * A client object passed to the v8 debugger whose ownership will be taken by
87
+ * it. v8 is always responsible for deleting the object.
88
+ */
89
+ class ClientData {
90
+ public:
91
+ virtual ~ClientData() {}
92
+ };
93
+
94
+
95
+ /**
96
+ * A message object passed to the debug message handler.
97
+ */
98
+ class Message {
99
+ public:
100
+ /**
101
+ * Check type of message.
102
+ */
103
+ virtual bool IsEvent() const = 0;
104
+ virtual bool IsResponse() const = 0;
105
+ virtual DebugEvent GetEvent() const = 0;
106
+
107
+ /**
108
+ * Indicate whether this is a response to a continue command which will
109
+ * start the VM running after this is processed.
110
+ */
111
+ virtual bool WillStartRunning() const = 0;
112
+
113
+ /**
114
+ * Access to execution state and event data. Don't store these cross
115
+ * callbacks as their content becomes invalid. These objects are from the
116
+ * debugger event that started the debug message loop.
117
+ */
118
+ virtual Handle<Object> GetExecutionState() const = 0;
119
+ virtual Handle<Object> GetEventData() const = 0;
120
+
121
+ /**
122
+ * Get the debugger protocol JSON.
123
+ */
124
+ virtual Handle<String> GetJSON() const = 0;
125
+
126
+ /**
127
+ * Get the context active when the debug event happened. Note this is not
128
+ * the current active context as the JavaScript part of the debugger is
129
+ * running in it's own context which is entered at this point.
130
+ */
131
+ virtual Handle<Context> GetEventContext() const = 0;
132
+
133
+ /**
134
+ * Client data passed with the corresponding request if any. This is the
135
+ * client_data data value passed into Debug::SendCommand along with the
136
+ * request that led to the message or NULL if the message is an event. The
137
+ * debugger takes ownership of the data and will delete it even if there is
138
+ * no message handler.
139
+ */
140
+ virtual ClientData* GetClientData() const = 0;
141
+
142
+ virtual ~Message() {}
143
+ };
144
+
145
+
146
+ /**
147
+ * Debug event callback function.
148
+ *
149
+ * \param event the type of the debug event that triggered the callback
150
+ * (enum DebugEvent)
151
+ * \param exec_state execution state (JavaScript object)
152
+ * \param event_data event specific data (JavaScript object)
153
+ * \param data value passed by the user to SetDebugEventListener
154
+ */
155
+ typedef void (*EventCallback)(DebugEvent event,
156
+ Handle<Object> exec_state,
157
+ Handle<Object> event_data,
158
+ Handle<Value> data);
159
+
160
+
161
+ /**
162
+ * Debug message callback function.
163
+ *
164
+ * \param message the debug message handler message object
165
+ * \param length length of the message
166
+ * \param client_data the data value passed when registering the message handler
167
+
168
+ * A MessageHandler does not take posession of the message string,
169
+ * and must not rely on the data persisting after the handler returns.
170
+ *
171
+ * This message handler is deprecated. Use MessageHandler2 instead.
172
+ */
173
+ typedef void (*MessageHandler)(const uint16_t* message, int length,
174
+ ClientData* client_data);
175
+
176
+ /**
177
+ * Debug message callback function.
178
+ *
179
+ * \param message the debug message handler message object
180
+
181
+ * A MessageHandler does not take posession of the message data,
182
+ * and must not rely on the data persisting after the handler returns.
183
+ */
184
+ typedef void (*MessageHandler2)(const Message& message);
185
+
186
+ /**
187
+ * Debug host dispatch callback function.
188
+ */
189
+ typedef void (*HostDispatchHandler)();
190
+
191
+ /**
192
+ * Callback function for the host to ensure debug messages are processed.
193
+ */
194
+ typedef void (*DebugMessageDispatchHandler)();
195
+
196
+ // Set a C debug event listener.
197
+ static bool SetDebugEventListener(EventCallback that,
198
+ Handle<Value> data = Handle<Value>());
199
+
200
+ // Set a JavaScript debug event listener.
201
+ static bool SetDebugEventListener(v8::Handle<v8::Object> that,
202
+ Handle<Value> data = Handle<Value>());
203
+
204
+ // Break execution of JavaScript.
205
+ static void DebugBreak();
206
+
207
+ // Message based interface. The message protocol is JSON. NOTE the message
208
+ // handler thread is not supported any more parameter must be false.
209
+ static void SetMessageHandler(MessageHandler handler,
210
+ bool message_handler_thread = false);
211
+ static void SetMessageHandler2(MessageHandler2 handler);
212
+ static void SendCommand(const uint16_t* command, int length,
213
+ ClientData* client_data = NULL);
214
+
215
+ // Dispatch interface.
216
+ static void SetHostDispatchHandler(HostDispatchHandler handler,
217
+ int period = 100);
218
+
219
+ /**
220
+ * Register a callback function to be called when a debug message has been
221
+ * received and is ready to be processed. For the debug messages to be
222
+ * processed V8 needs to be entered, and in certain embedding scenarios this
223
+ * callback can be used to make sure V8 is entered for the debug message to
224
+ * be processed. Note that debug messages will only be processed if there is
225
+ * a V8 break. This can happen automatically by using the option
226
+ * --debugger-auto-break.
227
+ */
228
+ static void SetDebugMessageDispatchHandler(
229
+ DebugMessageDispatchHandler handler);
230
+
231
+ /**
232
+ * Run a JavaScript function in the debugger.
233
+ * \param fun the function to call
234
+ * \param data passed as second argument to the function
235
+ * With this call the debugger is entered and the function specified is called
236
+ * with the execution state as the first argument. This makes it possible to
237
+ * get access to information otherwise not available during normal JavaScript
238
+ * execution e.g. details on stack frames. The following example show a
239
+ * JavaScript function which when passed to v8::Debug::Call will return the
240
+ * current line of JavaScript execution.
241
+ *
242
+ * \code
243
+ * function frame_source_line(exec_state) {
244
+ * return exec_state.frame(0).sourceLine();
245
+ * }
246
+ * \endcode
247
+ */
248
+ static Local<Value> Call(v8::Handle<v8::Function> fun,
249
+ Handle<Value> data = Handle<Value>());
250
+
251
+ /**
252
+ * Returns a mirror object for the given object.
253
+ */
254
+ static Local<Value> GetMirror(v8::Handle<v8::Value> obj);
255
+
256
+ /**
257
+ * Enable the V8 builtin debug agent. The debugger agent will listen on the
258
+ * supplied TCP/IP port for remote debugger connection.
259
+ * \param name the name of the embedding application
260
+ * \param port the TCP/IP port to listen on
261
+ * \param wait_for_connection whether V8 should pause on a first statement
262
+ * allowing remote debugger to connect before anything interesting happened
263
+ */
264
+ static bool EnableAgent(const char* name, int port,
265
+ bool wait_for_connection = false);
266
+ };
267
+
268
+
269
+ } // namespace v8
270
+
271
+
272
+ #undef EXPORT
273
+
274
+
275
+ #endif // V8_V8_DEBUG_H_
@@ -0,0 +1,3236 @@
1
+ // Copyright 2007-2009 the V8 project authors. All rights reserved.
2
+ // Redistribution and use in source and binary forms, with or without
3
+ // modification, are permitted provided that the following conditions are
4
+ // met:
5
+ //
6
+ // * Redistributions of source code must retain the above copyright
7
+ // notice, this list of conditions and the following disclaimer.
8
+ // * Redistributions in binary form must reproduce the above
9
+ // copyright notice, this list of conditions and the following
10
+ // disclaimer in the documentation and/or other materials provided
11
+ // with the distribution.
12
+ // * Neither the name of Google Inc. nor the names of its
13
+ // contributors may be used to endorse or promote products derived
14
+ // from this software without specific prior written permission.
15
+ //
16
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+
28
+ /** \mainpage V8 API Reference Guide
29
+ *
30
+ * V8 is Google's open source JavaScript engine.
31
+ *
32
+ * This set of documents provides reference material generated from the
33
+ * V8 header file, include/v8.h.
34
+ *
35
+ * For other documentation see http://code.google.com/apis/v8/
36
+ */
37
+
38
+ #ifndef V8_H_
39
+ #define V8_H_
40
+
41
+ #include <stdio.h>
42
+
43
+ #ifdef _WIN32
44
+ // When compiling on MinGW stdint.h is available.
45
+ #ifdef __MINGW32__
46
+ #include <stdint.h>
47
+ #else // __MINGW32__
48
+ typedef signed char int8_t;
49
+ typedef unsigned char uint8_t;
50
+ typedef short int16_t; // NOLINT
51
+ typedef unsigned short uint16_t; // NOLINT
52
+ typedef int int32_t;
53
+ typedef unsigned int uint32_t;
54
+ typedef __int64 int64_t;
55
+ typedef unsigned __int64 uint64_t;
56
+ // intptr_t and friends are defined in crtdefs.h through stdio.h.
57
+ #endif // __MINGW32__
58
+
59
+ // Setup for Windows DLL export/import. When building the V8 DLL the
60
+ // BUILDING_V8_SHARED needs to be defined. When building a program which uses
61
+ // the V8 DLL USING_V8_SHARED needs to be defined. When either building the V8
62
+ // static library or building a program which uses the V8 static library neither
63
+ // BUILDING_V8_SHARED nor USING_V8_SHARED should be defined.
64
+ // The reason for having both V8EXPORT and V8EXPORT_INLINE is that classes which
65
+ // have their code inside this header file need to have __declspec(dllexport)
66
+ // when building the DLL but cannot have __declspec(dllimport) when building
67
+ // a program which uses the DLL.
68
+ #if defined(BUILDING_V8_SHARED) && defined(USING_V8_SHARED)
69
+ #error both BUILDING_V8_SHARED and USING_V8_SHARED are set - please check the\
70
+ build configuration to ensure that at most one of these is set
71
+ #endif
72
+
73
+ #ifdef BUILDING_V8_SHARED
74
+ #define V8EXPORT __declspec(dllexport)
75
+ #define V8EXPORT_INLINE __declspec(dllexport)
76
+ #elif USING_V8_SHARED
77
+ #define V8EXPORT __declspec(dllimport)
78
+ #define V8EXPORT_INLINE
79
+ #else
80
+ #define V8EXPORT
81
+ #define V8EXPORT_INLINE
82
+ #endif // BUILDING_V8_SHARED
83
+
84
+ #else // _WIN32
85
+
86
+ #include <stdint.h>
87
+
88
+ // Setup for Linux shared library export. There is no need to distinguish
89
+ // between building or using the V8 shared library, but we should not
90
+ // export symbols when we are building a static library.
91
+ #if defined(__GNUC__) && (__GNUC__ >= 4) && defined(V8_SHARED)
92
+ #define V8EXPORT __attribute__ ((visibility("default")))
93
+ #define V8EXPORT_INLINE __attribute__ ((visibility("default")))
94
+ #else // defined(__GNUC__) && (__GNUC__ >= 4)
95
+ #define V8EXPORT
96
+ #define V8EXPORT_INLINE
97
+ #endif // defined(__GNUC__) && (__GNUC__ >= 4)
98
+
99
+ #endif // _WIN32
100
+
101
+ /**
102
+ * The v8 JavaScript engine.
103
+ */
104
+ namespace v8 {
105
+
106
+ class Context;
107
+ class String;
108
+ class Value;
109
+ class Utils;
110
+ class Number;
111
+ class Object;
112
+ class Array;
113
+ class Int32;
114
+ class Uint32;
115
+ class External;
116
+ class Primitive;
117
+ class Boolean;
118
+ class Integer;
119
+ class Function;
120
+ class Date;
121
+ class ImplementationUtilities;
122
+ class Signature;
123
+ template <class T> class Handle;
124
+ template <class T> class Local;
125
+ template <class T> class Persistent;
126
+ class FunctionTemplate;
127
+ class ObjectTemplate;
128
+ class Data;
129
+
130
+ namespace internal {
131
+
132
+ class Arguments;
133
+ class Object;
134
+ class Top;
135
+
136
+ }
137
+
138
+
139
+ // --- W e a k H a n d l e s
140
+
141
+
142
+ /**
143
+ * A weak reference callback function.
144
+ *
145
+ * \param object the weak global object to be reclaimed by the garbage collector
146
+ * \param parameter the value passed in when making the weak global object
147
+ */
148
+ typedef void (*WeakReferenceCallback)(Persistent<Value> object,
149
+ void* parameter);
150
+
151
+
152
+ // --- H a n d l e s ---
153
+
154
+ #define TYPE_CHECK(T, S) \
155
+ while (false) { \
156
+ *(static_cast<T**>(0)) = static_cast<S*>(0); \
157
+ }
158
+
159
+ /**
160
+ * An object reference managed by the v8 garbage collector.
161
+ *
162
+ * All objects returned from v8 have to be tracked by the garbage
163
+ * collector so that it knows that the objects are still alive. Also,
164
+ * because the garbage collector may move objects, it is unsafe to
165
+ * point directly to an object. Instead, all objects are stored in
166
+ * handles which are known by the garbage collector and updated
167
+ * whenever an object moves. Handles should always be passed by value
168
+ * (except in cases like out-parameters) and they should never be
169
+ * allocated on the heap.
170
+ *
171
+ * There are two types of handles: local and persistent handles.
172
+ * Local handles are light-weight and transient and typically used in
173
+ * local operations. They are managed by HandleScopes. Persistent
174
+ * handles can be used when storing objects across several independent
175
+ * operations and have to be explicitly deallocated when they're no
176
+ * longer used.
177
+ *
178
+ * It is safe to extract the object stored in the handle by
179
+ * dereferencing the handle (for instance, to extract the Object* from
180
+ * an Handle<Object>); the value will still be governed by a handle
181
+ * behind the scenes and the same rules apply to these values as to
182
+ * their handles.
183
+ */
184
+ template <class T> class V8EXPORT_INLINE Handle {
185
+ public:
186
+
187
+ /**
188
+ * Creates an empty handle.
189
+ */
190
+ inline Handle();
191
+
192
+ /**
193
+ * Creates a new handle for the specified value.
194
+ */
195
+ explicit Handle(T* val) : val_(val) { }
196
+
197
+ /**
198
+ * Creates a handle for the contents of the specified handle. This
199
+ * constructor allows you to pass handles as arguments by value and
200
+ * to assign between handles. However, if you try to assign between
201
+ * incompatible handles, for instance from a Handle<String> to a
202
+ * Handle<Number> it will cause a compiletime error. Assigning
203
+ * between compatible handles, for instance assigning a
204
+ * Handle<String> to a variable declared as Handle<Value>, is legal
205
+ * because String is a subclass of Value.
206
+ */
207
+ template <class S> inline Handle(Handle<S> that)
208
+ : val_(reinterpret_cast<T*>(*that)) {
209
+ /**
210
+ * This check fails when trying to convert between incompatible
211
+ * handles. For example, converting from a Handle<String> to a
212
+ * Handle<Number>.
213
+ */
214
+ TYPE_CHECK(T, S);
215
+ }
216
+
217
+ /**
218
+ * Returns true if the handle is empty.
219
+ */
220
+ bool IsEmpty() const { return val_ == 0; }
221
+
222
+ T* operator->() const { return val_; }
223
+
224
+ T* operator*() const { return val_; }
225
+
226
+ /**
227
+ * Sets the handle to be empty. IsEmpty() will then return true.
228
+ */
229
+ void Clear() { this->val_ = 0; }
230
+
231
+ /**
232
+ * Checks whether two handles are the same.
233
+ * Returns true if both are empty, or if the objects
234
+ * to which they refer are identical.
235
+ * The handles' references are not checked.
236
+ */
237
+ template <class S> bool operator==(Handle<S> that) const {
238
+ internal::Object** a = reinterpret_cast<internal::Object**>(**this);
239
+ internal::Object** b = reinterpret_cast<internal::Object**>(*that);
240
+ if (a == 0) return b == 0;
241
+ if (b == 0) return false;
242
+ return *a == *b;
243
+ }
244
+
245
+ /**
246
+ * Checks whether two handles are different.
247
+ * Returns true if only one of the handles is empty, or if
248
+ * the objects to which they refer are different.
249
+ * The handles' references are not checked.
250
+ */
251
+ template <class S> bool operator!=(Handle<S> that) const {
252
+ return !operator==(that);
253
+ }
254
+
255
+ template <class S> static inline Handle<T> Cast(Handle<S> that) {
256
+ #ifdef V8_ENABLE_CHECKS
257
+ // If we're going to perform the type check then we have to check
258
+ // that the handle isn't empty before doing the checked cast.
259
+ if (that.IsEmpty()) return Handle<T>();
260
+ #endif
261
+ return Handle<T>(T::Cast(*that));
262
+ }
263
+
264
+ private:
265
+ T* val_;
266
+ };
267
+
268
+
269
+ /**
270
+ * A light-weight stack-allocated object handle. All operations
271
+ * that return objects from within v8 return them in local handles. They
272
+ * are created within HandleScopes, and all local handles allocated within a
273
+ * handle scope are destroyed when the handle scope is destroyed. Hence it
274
+ * is not necessary to explicitly deallocate local handles.
275
+ */
276
+ template <class T> class V8EXPORT_INLINE Local : public Handle<T> {
277
+ public:
278
+ inline Local();
279
+ template <class S> inline Local(Local<S> that)
280
+ : Handle<T>(reinterpret_cast<T*>(*that)) {
281
+ /**
282
+ * This check fails when trying to convert between incompatible
283
+ * handles. For example, converting from a Handle<String> to a
284
+ * Handle<Number>.
285
+ */
286
+ TYPE_CHECK(T, S);
287
+ }
288
+ template <class S> inline Local(S* that) : Handle<T>(that) { }
289
+ template <class S> static inline Local<T> Cast(Local<S> that) {
290
+ #ifdef V8_ENABLE_CHECKS
291
+ // If we're going to perform the type check then we have to check
292
+ // that the handle isn't empty before doing the checked cast.
293
+ if (that.IsEmpty()) return Local<T>();
294
+ #endif
295
+ return Local<T>(T::Cast(*that));
296
+ }
297
+
298
+ /** Create a local handle for the content of another handle.
299
+ * The referee is kept alive by the local handle even when
300
+ * the original handle is destroyed/disposed.
301
+ */
302
+ inline static Local<T> New(Handle<T> that);
303
+ };
304
+
305
+
306
+ /**
307
+ * An object reference that is independent of any handle scope. Where
308
+ * a Local handle only lives as long as the HandleScope in which it was
309
+ * allocated, a Persistent handle remains valid until it is explicitly
310
+ * disposed.
311
+ *
312
+ * A persistent handle contains a reference to a storage cell within
313
+ * the v8 engine which holds an object value and which is updated by
314
+ * the garbage collector whenever the object is moved. A new storage
315
+ * cell can be created using Persistent::New and existing handles can
316
+ * be disposed using Persistent::Dispose. Since persistent handles
317
+ * are passed by value you may have many persistent handle objects
318
+ * that point to the same storage cell. For instance, if you pass a
319
+ * persistent handle as an argument to a function you will not get two
320
+ * different storage cells but rather two references to the same
321
+ * storage cell.
322
+ */
323
+ template <class T> class V8EXPORT_INLINE Persistent : public Handle<T> {
324
+ public:
325
+
326
+ /**
327
+ * Creates an empty persistent handle that doesn't point to any
328
+ * storage cell.
329
+ */
330
+ inline Persistent();
331
+
332
+ /**
333
+ * Creates a persistent handle for the same storage cell as the
334
+ * specified handle. This constructor allows you to pass persistent
335
+ * handles as arguments by value and to assign between persistent
336
+ * handles. However, attempting to assign between incompatible
337
+ * persistent handles, for instance from a Persistent<String> to a
338
+ * Persistent<Number> will cause a compiletime error. Assigning
339
+ * between compatible persistent handles, for instance assigning a
340
+ * Persistent<String> to a variable declared as Persistent<Value>,
341
+ * is allowed as String is a subclass of Value.
342
+ */
343
+ template <class S> inline Persistent(Persistent<S> that)
344
+ : Handle<T>(reinterpret_cast<T*>(*that)) {
345
+ /**
346
+ * This check fails when trying to convert between incompatible
347
+ * handles. For example, converting from a Handle<String> to a
348
+ * Handle<Number>.
349
+ */
350
+ TYPE_CHECK(T, S);
351
+ }
352
+
353
+ template <class S> inline Persistent(S* that) : Handle<T>(that) { }
354
+
355
+ /**
356
+ * "Casts" a plain handle which is known to be a persistent handle
357
+ * to a persistent handle.
358
+ */
359
+ template <class S> explicit inline Persistent(Handle<S> that)
360
+ : Handle<T>(*that) { }
361
+
362
+ template <class S> static inline Persistent<T> Cast(Persistent<S> that) {
363
+ #ifdef V8_ENABLE_CHECKS
364
+ // If we're going to perform the type check then we have to check
365
+ // that the handle isn't empty before doing the checked cast.
366
+ if (that.IsEmpty()) return Persistent<T>();
367
+ #endif
368
+ return Persistent<T>(T::Cast(*that));
369
+ }
370
+
371
+ /**
372
+ * Creates a new persistent handle for an existing local or
373
+ * persistent handle.
374
+ */
375
+ inline static Persistent<T> New(Handle<T> that);
376
+
377
+ /**
378
+ * Releases the storage cell referenced by this persistent handle.
379
+ * Does not remove the reference to the cell from any handles.
380
+ * This handle's reference, and any any other references to the storage
381
+ * cell remain and IsEmpty will still return false.
382
+ */
383
+ inline void Dispose();
384
+
385
+ /**
386
+ * Make the reference to this object weak. When only weak handles
387
+ * refer to the object, the garbage collector will perform a
388
+ * callback to the given V8::WeakReferenceCallback function, passing
389
+ * it the object reference and the given parameters.
390
+ */
391
+ inline void MakeWeak(void* parameters, WeakReferenceCallback callback);
392
+
393
+ /** Clears the weak reference to this object.*/
394
+ inline void ClearWeak();
395
+
396
+ /**
397
+ *Checks if the handle holds the only reference to an object.
398
+ */
399
+ inline bool IsNearDeath() const;
400
+
401
+ /**
402
+ * Returns true if the handle's reference is weak.
403
+ */
404
+ inline bool IsWeak() const;
405
+
406
+ private:
407
+ friend class ImplementationUtilities;
408
+ friend class ObjectTemplate;
409
+ };
410
+
411
+
412
+ /**
413
+ * A stack-allocated class that governs a number of local handles.
414
+ * After a handle scope has been created, all local handles will be
415
+ * allocated within that handle scope until either the handle scope is
416
+ * deleted or another handle scope is created. If there is already a
417
+ * handle scope and a new one is created, all allocations will take
418
+ * place in the new handle scope until it is deleted. After that,
419
+ * new handles will again be allocated in the original handle scope.
420
+ *
421
+ * After the handle scope of a local handle has been deleted the
422
+ * garbage collector will no longer track the object stored in the
423
+ * handle and may deallocate it. The behavior of accessing a handle
424
+ * for which the handle scope has been deleted is undefined.
425
+ */
426
+ class V8EXPORT HandleScope {
427
+ public:
428
+ HandleScope();
429
+
430
+ ~HandleScope();
431
+
432
+ /**
433
+ * Closes the handle scope and returns the value as a handle in the
434
+ * previous scope, which is the new current scope after the call.
435
+ */
436
+ template <class T> Local<T> Close(Handle<T> value);
437
+
438
+ /**
439
+ * Counts the number of allocated handles.
440
+ */
441
+ static int NumberOfHandles();
442
+
443
+ /**
444
+ * Creates a new handle with the given value.
445
+ */
446
+ static internal::Object** CreateHandle(internal::Object* value);
447
+
448
+ private:
449
+ // Make it impossible to create heap-allocated or illegal handle
450
+ // scopes by disallowing certain operations.
451
+ HandleScope(const HandleScope&);
452
+ void operator=(const HandleScope&);
453
+ void* operator new(size_t size);
454
+ void operator delete(void*, size_t);
455
+
456
+ // This Data class is accessible internally as HandleScopeData through a
457
+ // typedef in the ImplementationUtilities class.
458
+ class V8EXPORT Data {
459
+ public:
460
+ int extensions;
461
+ internal::Object** next;
462
+ internal::Object** limit;
463
+ inline void Initialize() {
464
+ extensions = -1;
465
+ next = limit = NULL;
466
+ }
467
+ };
468
+
469
+ Data previous_;
470
+
471
+ // Allow for the active closing of HandleScopes which allows to pass a handle
472
+ // from the HandleScope being closed to the next top most HandleScope.
473
+ bool is_closed_;
474
+ internal::Object** RawClose(internal::Object** value);
475
+
476
+ friend class ImplementationUtilities;
477
+ };
478
+
479
+
480
+ // --- S p e c i a l o b j e c t s ---
481
+
482
+
483
+ /**
484
+ * The superclass of values and API object templates.
485
+ */
486
+ class V8EXPORT Data {
487
+ private:
488
+ Data();
489
+ };
490
+
491
+
492
+ /**
493
+ * Pre-compilation data that can be associated with a script. This
494
+ * data can be calculated for a script in advance of actually
495
+ * compiling it, and can be stored between compilations. When script
496
+ * data is given to the compile method compilation will be faster.
497
+ */
498
+ class V8EXPORT ScriptData { // NOLINT
499
+ public:
500
+ virtual ~ScriptData() { }
501
+ static ScriptData* PreCompile(const char* input, int length);
502
+ static ScriptData* New(unsigned* data, int length);
503
+
504
+ virtual int Length() = 0;
505
+ virtual unsigned* Data() = 0;
506
+ virtual bool HasError() = 0;
507
+ };
508
+
509
+
510
+ /**
511
+ * The origin, within a file, of a script.
512
+ */
513
+ class V8EXPORT ScriptOrigin {
514
+ public:
515
+ ScriptOrigin(Handle<Value> resource_name,
516
+ Handle<Integer> resource_line_offset = Handle<Integer>(),
517
+ Handle<Integer> resource_column_offset = Handle<Integer>())
518
+ : resource_name_(resource_name),
519
+ resource_line_offset_(resource_line_offset),
520
+ resource_column_offset_(resource_column_offset) { }
521
+ inline Handle<Value> ResourceName() const;
522
+ inline Handle<Integer> ResourceLineOffset() const;
523
+ inline Handle<Integer> ResourceColumnOffset() const;
524
+ private:
525
+ Handle<Value> resource_name_;
526
+ Handle<Integer> resource_line_offset_;
527
+ Handle<Integer> resource_column_offset_;
528
+ };
529
+
530
+
531
+ /**
532
+ * A compiled JavaScript script.
533
+ */
534
+ class V8EXPORT Script {
535
+ public:
536
+
537
+ /**
538
+ * Compiles the specified script. The ScriptOrigin* and ScriptData*
539
+ * parameters are owned by the caller of Script::Compile. No
540
+ * references to these objects are kept after compilation finishes.
541
+ *
542
+ * The script object returned is context independent; when run it
543
+ * will use the currently entered context.
544
+ */
545
+ static Local<Script> New(Handle<String> source,
546
+ ScriptOrigin* origin = NULL,
547
+ ScriptData* pre_data = NULL);
548
+
549
+ /**
550
+ * Compiles the specified script using the specified file name
551
+ * object (typically a string) as the script's origin.
552
+ *
553
+ * The script object returned is context independent; when run it
554
+ * will use the currently entered context.
555
+ */
556
+ static Local<Script> New(Handle<String> source,
557
+ Handle<Value> file_name);
558
+
559
+ /**
560
+ * Compiles the specified script. The ScriptOrigin* and ScriptData*
561
+ * parameters are owned by the caller of Script::Compile. No
562
+ * references to these objects are kept after compilation finishes.
563
+ *
564
+ * The script object returned is bound to the context that was active
565
+ * when this function was called. When run it will always use this
566
+ * context.
567
+ */
568
+ static Local<Script> Compile(Handle<String> source,
569
+ ScriptOrigin* origin = NULL,
570
+ ScriptData* pre_data = NULL);
571
+
572
+ /**
573
+ * Compiles the specified script using the specified file name
574
+ * object (typically a string) as the script's origin.
575
+ *
576
+ * The script object returned is bound to the context that was active
577
+ * when this function was called. When run it will always use this
578
+ * context.
579
+ */
580
+ static Local<Script> Compile(Handle<String> source,
581
+ Handle<Value> file_name);
582
+
583
+ /**
584
+ * Runs the script returning the resulting value. If the script is
585
+ * context independent (created using ::New) it will be run in the
586
+ * currently entered context. If it is context specific (created
587
+ * using ::Compile) it will be run in the context in which it was
588
+ * compiled.
589
+ */
590
+ Local<Value> Run();
591
+
592
+ /**
593
+ * Returns the script id value.
594
+ */
595
+ Local<Value> Id();
596
+
597
+ /**
598
+ * Associate an additional data object with the script. This is mainly used
599
+ * with the debugger as this data object is only available through the
600
+ * debugger API.
601
+ */
602
+ void SetData(Handle<String> data);
603
+ };
604
+
605
+
606
+ /**
607
+ * An error message.
608
+ */
609
+ class V8EXPORT Message {
610
+ public:
611
+ Local<String> Get() const;
612
+ Local<String> GetSourceLine() const;
613
+
614
+ /**
615
+ * Returns the resource name for the script from where the function causing
616
+ * the error originates.
617
+ */
618
+ Handle<Value> GetScriptResourceName() const;
619
+
620
+ /**
621
+ * Returns the resource data for the script from where the function causing
622
+ * the error originates.
623
+ */
624
+ Handle<Value> GetScriptData() const;
625
+
626
+ /**
627
+ * Returns the number, 1-based, of the line where the error occurred.
628
+ */
629
+ int GetLineNumber() const;
630
+
631
+ /**
632
+ * Returns the index within the script of the first character where
633
+ * the error occurred.
634
+ */
635
+ int GetStartPosition() const;
636
+
637
+ /**
638
+ * Returns the index within the script of the last character where
639
+ * the error occurred.
640
+ */
641
+ int GetEndPosition() const;
642
+
643
+ /**
644
+ * Returns the index within the line of the first character where
645
+ * the error occurred.
646
+ */
647
+ int GetStartColumn() const;
648
+
649
+ /**
650
+ * Returns the index within the line of the last character where
651
+ * the error occurred.
652
+ */
653
+ int GetEndColumn() const;
654
+
655
+ // TODO(1245381): Print to a string instead of on a FILE.
656
+ static void PrintCurrentStackTrace(FILE* out);
657
+ };
658
+
659
+
660
+ // --- V a l u e ---
661
+
662
+
663
+ /**
664
+ * The superclass of all JavaScript values and objects.
665
+ */
666
+ class V8EXPORT Value : public Data {
667
+ public:
668
+
669
+ /**
670
+ * Returns true if this value is the undefined value. See ECMA-262
671
+ * 4.3.10.
672
+ */
673
+ bool IsUndefined() const;
674
+
675
+ /**
676
+ * Returns true if this value is the null value. See ECMA-262
677
+ * 4.3.11.
678
+ */
679
+ bool IsNull() const;
680
+
681
+ /**
682
+ * Returns true if this value is true.
683
+ */
684
+ bool IsTrue() const;
685
+
686
+ /**
687
+ * Returns true if this value is false.
688
+ */
689
+ bool IsFalse() const;
690
+
691
+ /**
692
+ * Returns true if this value is an instance of the String type.
693
+ * See ECMA-262 8.4.
694
+ */
695
+ inline bool IsString() const;
696
+
697
+ /**
698
+ * Returns true if this value is a function.
699
+ */
700
+ bool IsFunction() const;
701
+
702
+ /**
703
+ * Returns true if this value is an array.
704
+ */
705
+ bool IsArray() const;
706
+
707
+ /**
708
+ * Returns true if this value is an object.
709
+ */
710
+ bool IsObject() const;
711
+
712
+ /**
713
+ * Returns true if this value is boolean.
714
+ */
715
+ bool IsBoolean() const;
716
+
717
+ /**
718
+ * Returns true if this value is a number.
719
+ */
720
+ bool IsNumber() const;
721
+
722
+ /**
723
+ * Returns true if this value is external.
724
+ */
725
+ bool IsExternal() const;
726
+
727
+ /**
728
+ * Returns true if this value is a 32-bit signed integer.
729
+ */
730
+ bool IsInt32() const;
731
+
732
+ /**
733
+ * Returns true if this value is a Date.
734
+ */
735
+ bool IsDate() const;
736
+
737
+ Local<Boolean> ToBoolean() const;
738
+ Local<Number> ToNumber() const;
739
+ Local<String> ToString() const;
740
+ Local<String> ToDetailString() const;
741
+ Local<Object> ToObject() const;
742
+ Local<Integer> ToInteger() const;
743
+ Local<Uint32> ToUint32() const;
744
+ Local<Int32> ToInt32() const;
745
+
746
+ /**
747
+ * Attempts to convert a string to an array index.
748
+ * Returns an empty handle if the conversion fails.
749
+ */
750
+ Local<Uint32> ToArrayIndex() const;
751
+
752
+ bool BooleanValue() const;
753
+ double NumberValue() const;
754
+ int64_t IntegerValue() const;
755
+ uint32_t Uint32Value() const;
756
+ int32_t Int32Value() const;
757
+
758
+ /** JS == */
759
+ bool Equals(Handle<Value> that) const;
760
+ bool StrictEquals(Handle<Value> that) const;
761
+
762
+ private:
763
+ inline bool QuickIsString() const;
764
+ bool FullIsString() const;
765
+ };
766
+
767
+
768
+ /**
769
+ * The superclass of primitive values. See ECMA-262 4.3.2.
770
+ */
771
+ class V8EXPORT Primitive : public Value { };
772
+
773
+
774
+ /**
775
+ * A primitive boolean value (ECMA-262, 4.3.14). Either the true
776
+ * or false value.
777
+ */
778
+ class V8EXPORT Boolean : public Primitive {
779
+ public:
780
+ bool Value() const;
781
+ static inline Handle<Boolean> New(bool value);
782
+ };
783
+
784
+
785
+ /**
786
+ * A JavaScript string value (ECMA-262, 4.3.17).
787
+ */
788
+ class V8EXPORT String : public Primitive {
789
+ public:
790
+
791
+ /**
792
+ * Returns the number of characters in this string.
793
+ */
794
+ int Length() const;
795
+
796
+ /**
797
+ * Returns the number of bytes in the UTF-8 encoded
798
+ * representation of this string.
799
+ */
800
+ int Utf8Length() const;
801
+
802
+ /**
803
+ * Write the contents of the string to an external buffer.
804
+ * If no arguments are given, expects the buffer to be large
805
+ * enough to hold the entire string and NULL terminator. Copies
806
+ * the contents of the string and the NULL terminator into the
807
+ * buffer.
808
+ *
809
+ * Copies up to length characters into the output buffer.
810
+ * Only null-terminates if there is enough space in the buffer.
811
+ *
812
+ * \param buffer The buffer into which the string will be copied.
813
+ * \param start The starting position within the string at which
814
+ * copying begins.
815
+ * \param length The number of bytes to copy from the string.
816
+ * \return The number of characters copied to the buffer
817
+ * excluding the NULL terminator.
818
+ */
819
+ int Write(uint16_t* buffer, int start = 0, int length = -1) const; // UTF-16
820
+ int WriteAscii(char* buffer, int start = 0, int length = -1) const; // ASCII
821
+ int WriteUtf8(char* buffer, int length = -1) const; // UTF-8
822
+
823
+ /**
824
+ * A zero length string.
825
+ */
826
+ static v8::Local<v8::String> Empty();
827
+
828
+ /**
829
+ * Returns true if the string is external
830
+ */
831
+ bool IsExternal() const;
832
+
833
+ /**
834
+ * Returns true if the string is both external and ascii
835
+ */
836
+ bool IsExternalAscii() const;
837
+
838
+ class V8EXPORT ExternalStringResourceBase {
839
+ public:
840
+ virtual ~ExternalStringResourceBase() {}
841
+ protected:
842
+ ExternalStringResourceBase() {}
843
+ private:
844
+ // Disallow copying and assigning.
845
+ ExternalStringResourceBase(const ExternalStringResourceBase&);
846
+ void operator=(const ExternalStringResourceBase&);
847
+ };
848
+
849
+ /**
850
+ * An ExternalStringResource is a wrapper around a two-byte string
851
+ * buffer that resides outside V8's heap. Implement an
852
+ * ExternalStringResource to manage the life cycle of the underlying
853
+ * buffer. Note that the string data must be immutable.
854
+ */
855
+ class V8EXPORT ExternalStringResource
856
+ : public ExternalStringResourceBase {
857
+ public:
858
+ /**
859
+ * Override the destructor to manage the life cycle of the underlying
860
+ * buffer.
861
+ */
862
+ virtual ~ExternalStringResource() {}
863
+ /** The string data from the underlying buffer.*/
864
+ virtual const uint16_t* data() const = 0;
865
+ /** The length of the string. That is, the number of two-byte characters.*/
866
+ virtual size_t length() const = 0;
867
+ protected:
868
+ ExternalStringResource() {}
869
+ };
870
+
871
+ /**
872
+ * An ExternalAsciiStringResource is a wrapper around an ascii
873
+ * string buffer that resides outside V8's heap. Implement an
874
+ * ExternalAsciiStringResource to manage the life cycle of the
875
+ * underlying buffer. Note that the string data must be immutable
876
+ * and that the data must be strict 7-bit ASCII, not Latin1 or
877
+ * UTF-8, which would require special treatment internally in the
878
+ * engine and, in the case of UTF-8, do not allow efficient indexing.
879
+ * Use String::New or convert to 16 bit data for non-ASCII.
880
+ */
881
+
882
+ class V8EXPORT ExternalAsciiStringResource
883
+ : public ExternalStringResourceBase {
884
+ public:
885
+ /**
886
+ * Override the destructor to manage the life cycle of the underlying
887
+ * buffer.
888
+ */
889
+ virtual ~ExternalAsciiStringResource() {}
890
+ /** The string data from the underlying buffer.*/
891
+ virtual const char* data() const = 0;
892
+ /** The number of ascii characters in the string.*/
893
+ virtual size_t length() const = 0;
894
+ protected:
895
+ ExternalAsciiStringResource() {}
896
+ };
897
+
898
+ /**
899
+ * Get the ExternalStringResource for an external string. Returns
900
+ * NULL if IsExternal() doesn't return true.
901
+ */
902
+ inline ExternalStringResource* GetExternalStringResource() const;
903
+
904
+ /**
905
+ * Get the ExternalAsciiStringResource for an external ascii string.
906
+ * Returns NULL if IsExternalAscii() doesn't return true.
907
+ */
908
+ ExternalAsciiStringResource* GetExternalAsciiStringResource() const;
909
+
910
+ static inline String* Cast(v8::Value* obj);
911
+
912
+ /**
913
+ * Allocates a new string from either utf-8 encoded or ascii data.
914
+ * The second parameter 'length' gives the buffer length.
915
+ * If the data is utf-8 encoded, the caller must
916
+ * be careful to supply the length parameter.
917
+ * If it is not given, the function calls
918
+ * 'strlen' to determine the buffer length, it might be
919
+ * wrong if 'data' contains a null character.
920
+ */
921
+ static Local<String> New(const char* data, int length = -1);
922
+
923
+ /** Allocates a new string from utf16 data.*/
924
+ static Local<String> New(const uint16_t* data, int length = -1);
925
+
926
+ /** Creates a symbol. Returns one if it exists already.*/
927
+ static Local<String> NewSymbol(const char* data, int length = -1);
928
+
929
+ /**
930
+ * Creates a new string by concatenating the left and the right strings
931
+ * passed in as parameters.
932
+ */
933
+ static Local<String> Concat(Handle<String> left, Handle<String>right);
934
+
935
+ /**
936
+ * Creates a new external string using the data defined in the given
937
+ * resource. The resource is deleted when the external string is no
938
+ * longer live on V8's heap. The caller of this function should not
939
+ * delete or modify the resource. Neither should the underlying buffer be
940
+ * deallocated or modified except through the destructor of the
941
+ * external string resource.
942
+ */
943
+ static Local<String> NewExternal(ExternalStringResource* resource);
944
+
945
+ /**
946
+ * Associate an external string resource with this string by transforming it
947
+ * in place so that existing references to this string in the JavaScript heap
948
+ * will use the external string resource. The external string resource's
949
+ * character contents needs to be equivalent to this string.
950
+ * Returns true if the string has been changed to be an external string.
951
+ * The string is not modified if the operation fails.
952
+ */
953
+ bool MakeExternal(ExternalStringResource* resource);
954
+
955
+ /**
956
+ * Creates a new external string using the ascii data defined in the given
957
+ * resource. The resource is deleted when the external string is no
958
+ * longer live on V8's heap. The caller of this function should not
959
+ * delete or modify the resource. Neither should the underlying buffer be
960
+ * deallocated or modified except through the destructor of the
961
+ * external string resource.
962
+ */
963
+ static Local<String> NewExternal(ExternalAsciiStringResource* resource);
964
+
965
+ /**
966
+ * Associate an external string resource with this string by transforming it
967
+ * in place so that existing references to this string in the JavaScript heap
968
+ * will use the external string resource. The external string resource's
969
+ * character contents needs to be equivalent to this string.
970
+ * Returns true if the string has been changed to be an external string.
971
+ * The string is not modified if the operation fails.
972
+ */
973
+ bool MakeExternal(ExternalAsciiStringResource* resource);
974
+
975
+ /**
976
+ * Returns true if this string can be made external.
977
+ */
978
+ bool CanMakeExternal();
979
+
980
+ /** Creates an undetectable string from the supplied ascii or utf-8 data.*/
981
+ static Local<String> NewUndetectable(const char* data, int length = -1);
982
+
983
+ /** Creates an undetectable string from the supplied utf-16 data.*/
984
+ static Local<String> NewUndetectable(const uint16_t* data, int length = -1);
985
+
986
+ /**
987
+ * Converts an object to a utf8-encoded character array. Useful if
988
+ * you want to print the object. If conversion to a string fails
989
+ * (eg. due to an exception in the toString() method of the object)
990
+ * then the length() method returns 0 and the * operator returns
991
+ * NULL.
992
+ */
993
+ class V8EXPORT Utf8Value {
994
+ public:
995
+ explicit Utf8Value(Handle<v8::Value> obj);
996
+ ~Utf8Value();
997
+ char* operator*() { return str_; }
998
+ const char* operator*() const { return str_; }
999
+ int length() const { return length_; }
1000
+ private:
1001
+ char* str_;
1002
+ int length_;
1003
+
1004
+ // Disallow copying and assigning.
1005
+ Utf8Value(const Utf8Value&);
1006
+ void operator=(const Utf8Value&);
1007
+ };
1008
+
1009
+ /**
1010
+ * Converts an object to an ascii string.
1011
+ * Useful if you want to print the object.
1012
+ * If conversion to a string fails (eg. due to an exception in the toString()
1013
+ * method of the object) then the length() method returns 0 and the * operator
1014
+ * returns NULL.
1015
+ */
1016
+ class V8EXPORT AsciiValue {
1017
+ public:
1018
+ explicit AsciiValue(Handle<v8::Value> obj);
1019
+ ~AsciiValue();
1020
+ char* operator*() { return str_; }
1021
+ const char* operator*() const { return str_; }
1022
+ int length() const { return length_; }
1023
+ private:
1024
+ char* str_;
1025
+ int length_;
1026
+
1027
+ // Disallow copying and assigning.
1028
+ AsciiValue(const AsciiValue&);
1029
+ void operator=(const AsciiValue&);
1030
+ };
1031
+
1032
+ /**
1033
+ * Converts an object to a two-byte string.
1034
+ * If conversion to a string fails (eg. due to an exception in the toString()
1035
+ * method of the object) then the length() method returns 0 and the * operator
1036
+ * returns NULL.
1037
+ */
1038
+ class V8EXPORT Value {
1039
+ public:
1040
+ explicit Value(Handle<v8::Value> obj);
1041
+ ~Value();
1042
+ uint16_t* operator*() { return str_; }
1043
+ const uint16_t* operator*() const { return str_; }
1044
+ int length() const { return length_; }
1045
+ private:
1046
+ uint16_t* str_;
1047
+ int length_;
1048
+
1049
+ // Disallow copying and assigning.
1050
+ Value(const Value&);
1051
+ void operator=(const Value&);
1052
+ };
1053
+
1054
+ private:
1055
+ void VerifyExternalStringResource(ExternalStringResource* val) const;
1056
+ static void CheckCast(v8::Value* obj);
1057
+ };
1058
+
1059
+
1060
+ /**
1061
+ * A JavaScript number value (ECMA-262, 4.3.20)
1062
+ */
1063
+ class V8EXPORT Number : public Primitive {
1064
+ public:
1065
+ double Value() const;
1066
+ static Local<Number> New(double value);
1067
+ static inline Number* Cast(v8::Value* obj);
1068
+ private:
1069
+ Number();
1070
+ static void CheckCast(v8::Value* obj);
1071
+ };
1072
+
1073
+
1074
+ /**
1075
+ * A JavaScript value representing a signed integer.
1076
+ */
1077
+ class V8EXPORT Integer : public Number {
1078
+ public:
1079
+ static Local<Integer> New(int32_t value);
1080
+ static Local<Integer> NewFromUnsigned(uint32_t value);
1081
+ int64_t Value() const;
1082
+ static inline Integer* Cast(v8::Value* obj);
1083
+ private:
1084
+ Integer();
1085
+ static void CheckCast(v8::Value* obj);
1086
+ };
1087
+
1088
+
1089
+ /**
1090
+ * A JavaScript value representing a 32-bit signed integer.
1091
+ */
1092
+ class V8EXPORT Int32 : public Integer {
1093
+ public:
1094
+ int32_t Value() const;
1095
+ private:
1096
+ Int32();
1097
+ };
1098
+
1099
+
1100
+ /**
1101
+ * A JavaScript value representing a 32-bit unsigned integer.
1102
+ */
1103
+ class V8EXPORT Uint32 : public Integer {
1104
+ public:
1105
+ uint32_t Value() const;
1106
+ private:
1107
+ Uint32();
1108
+ };
1109
+
1110
+
1111
+ /**
1112
+ * An instance of the built-in Date constructor (ECMA-262, 15.9).
1113
+ */
1114
+ class V8EXPORT Date : public Value {
1115
+ public:
1116
+ static Local<Value> New(double time);
1117
+
1118
+ /**
1119
+ * A specialization of Value::NumberValue that is more efficient
1120
+ * because we know the structure of this object.
1121
+ */
1122
+ double NumberValue() const;
1123
+
1124
+ static inline Date* Cast(v8::Value* obj);
1125
+ private:
1126
+ static void CheckCast(v8::Value* obj);
1127
+ };
1128
+
1129
+
1130
+ enum PropertyAttribute {
1131
+ None = 0,
1132
+ ReadOnly = 1 << 0,
1133
+ DontEnum = 1 << 1,
1134
+ DontDelete = 1 << 2
1135
+ };
1136
+
1137
+ enum ExternalArrayType {
1138
+ kExternalByteArray = 1,
1139
+ kExternalUnsignedByteArray,
1140
+ kExternalShortArray,
1141
+ kExternalUnsignedShortArray,
1142
+ kExternalIntArray,
1143
+ kExternalUnsignedIntArray,
1144
+ kExternalFloatArray
1145
+ };
1146
+
1147
+ /**
1148
+ * A JavaScript object (ECMA-262, 4.3.3)
1149
+ */
1150
+ class V8EXPORT Object : public Value {
1151
+ public:
1152
+ bool Set(Handle<Value> key,
1153
+ Handle<Value> value,
1154
+ PropertyAttribute attribs = None);
1155
+
1156
+ // Sets a local property on this object bypassing interceptors and
1157
+ // overriding accessors or read-only properties.
1158
+ //
1159
+ // Note that if the object has an interceptor the property will be set
1160
+ // locally, but since the interceptor takes precedence the local property
1161
+ // will only be returned if the interceptor doesn't return a value.
1162
+ //
1163
+ // Note also that this only works for named properties.
1164
+ bool ForceSet(Handle<Value> key,
1165
+ Handle<Value> value,
1166
+ PropertyAttribute attribs = None);
1167
+
1168
+ Local<Value> Get(Handle<Value> key);
1169
+
1170
+ // TODO(1245389): Replace the type-specific versions of these
1171
+ // functions with generic ones that accept a Handle<Value> key.
1172
+ bool Has(Handle<String> key);
1173
+
1174
+ bool Delete(Handle<String> key);
1175
+
1176
+ // Delete a property on this object bypassing interceptors and
1177
+ // ignoring dont-delete attributes.
1178
+ bool ForceDelete(Handle<Value> key);
1179
+
1180
+ bool Has(uint32_t index);
1181
+
1182
+ bool Delete(uint32_t index);
1183
+
1184
+ /**
1185
+ * Returns an array containing the names of the enumerable properties
1186
+ * of this object, including properties from prototype objects. The
1187
+ * array returned by this method contains the same values as would
1188
+ * be enumerated by a for-in statement over this object.
1189
+ */
1190
+ Local<Array> GetPropertyNames();
1191
+
1192
+ /**
1193
+ * Get the prototype object. This does not skip objects marked to
1194
+ * be skipped by __proto__ and it does not consult the security
1195
+ * handler.
1196
+ */
1197
+ Local<Value> GetPrototype();
1198
+
1199
+ /**
1200
+ * Finds an instance of the given function template in the prototype
1201
+ * chain.
1202
+ */
1203
+ Local<Object> FindInstanceInPrototypeChain(Handle<FunctionTemplate> tmpl);
1204
+
1205
+ /**
1206
+ * Call builtin Object.prototype.toString on this object.
1207
+ * This is different from Value::ToString() that may call
1208
+ * user-defined toString function. This one does not.
1209
+ */
1210
+ Local<String> ObjectProtoToString();
1211
+
1212
+ /** Gets the number of internal fields for this Object. */
1213
+ int InternalFieldCount();
1214
+ /** Gets the value in an internal field. */
1215
+ inline Local<Value> GetInternalField(int index);
1216
+ /** Sets the value in an internal field. */
1217
+ void SetInternalField(int index, Handle<Value> value);
1218
+
1219
+ /** Gets a native pointer from an internal field. */
1220
+ inline void* GetPointerFromInternalField(int index);
1221
+
1222
+ /** Sets a native pointer in an internal field. */
1223
+ void SetPointerInInternalField(int index, void* value);
1224
+
1225
+ // Testers for local properties.
1226
+ bool HasRealNamedProperty(Handle<String> key);
1227
+ bool HasRealIndexedProperty(uint32_t index);
1228
+ bool HasRealNamedCallbackProperty(Handle<String> key);
1229
+
1230
+ /**
1231
+ * If result.IsEmpty() no real property was located in the prototype chain.
1232
+ * This means interceptors in the prototype chain are not called.
1233
+ */
1234
+ Local<Value> GetRealNamedPropertyInPrototypeChain(Handle<String> key);
1235
+
1236
+ /**
1237
+ * If result.IsEmpty() no real property was located on the object or
1238
+ * in the prototype chain.
1239
+ * This means interceptors in the prototype chain are not called.
1240
+ */
1241
+ Local<Value> GetRealNamedProperty(Handle<String> key);
1242
+
1243
+ /** Tests for a named lookup interceptor.*/
1244
+ bool HasNamedLookupInterceptor();
1245
+
1246
+ /** Tests for an index lookup interceptor.*/
1247
+ bool HasIndexedLookupInterceptor();
1248
+
1249
+ /**
1250
+ * Turns on access check on the object if the object is an instance of
1251
+ * a template that has access check callbacks. If an object has no
1252
+ * access check info, the object cannot be accessed by anyone.
1253
+ */
1254
+ void TurnOnAccessCheck();
1255
+
1256
+ /**
1257
+ * Returns the identity hash for this object. The current implemenation uses
1258
+ * a hidden property on the object to store the identity hash.
1259
+ *
1260
+ * The return value will never be 0. Also, it is not guaranteed to be
1261
+ * unique.
1262
+ */
1263
+ int GetIdentityHash();
1264
+
1265
+ /**
1266
+ * Access hidden properties on JavaScript objects. These properties are
1267
+ * hidden from the executing JavaScript and only accessible through the V8
1268
+ * C++ API. Hidden properties introduced by V8 internally (for example the
1269
+ * identity hash) are prefixed with "v8::".
1270
+ */
1271
+ bool SetHiddenValue(Handle<String> key, Handle<Value> value);
1272
+ Local<Value> GetHiddenValue(Handle<String> key);
1273
+ bool DeleteHiddenValue(Handle<String> key);
1274
+
1275
+ /**
1276
+ * Returns true if this is an instance of an api function (one
1277
+ * created from a function created from a function template) and has
1278
+ * been modified since it was created. Note that this method is
1279
+ * conservative and may return true for objects that haven't actually
1280
+ * been modified.
1281
+ */
1282
+ bool IsDirty();
1283
+
1284
+ /**
1285
+ * Clone this object with a fast but shallow copy. Values will point
1286
+ * to the same values as the original object.
1287
+ */
1288
+ Local<Object> Clone();
1289
+
1290
+ /**
1291
+ * Set the backing store of the indexed properties to be managed by the
1292
+ * embedding layer. Access to the indexed properties will follow the rules
1293
+ * spelled out in CanvasPixelArray.
1294
+ * Note: The embedding program still owns the data and needs to ensure that
1295
+ * the backing store is preserved while V8 has a reference.
1296
+ */
1297
+ void SetIndexedPropertiesToPixelData(uint8_t* data, int length);
1298
+
1299
+ /**
1300
+ * Set the backing store of the indexed properties to be managed by the
1301
+ * embedding layer. Access to the indexed properties will follow the rules
1302
+ * spelled out for the CanvasArray subtypes in the WebGL specification.
1303
+ * Note: The embedding program still owns the data and needs to ensure that
1304
+ * the backing store is preserved while V8 has a reference.
1305
+ */
1306
+ void SetIndexedPropertiesToExternalArrayData(void* data,
1307
+ ExternalArrayType array_type,
1308
+ int number_of_elements);
1309
+
1310
+ static Local<Object> New();
1311
+ static inline Object* Cast(Value* obj);
1312
+ private:
1313
+ Object();
1314
+ static void CheckCast(Value* obj);
1315
+ Local<Value> CheckedGetInternalField(int index);
1316
+ void* SlowGetPointerFromInternalField(int index);
1317
+
1318
+ /**
1319
+ * If quick access to the internal field is possible this method
1320
+ * returns the value. Otherwise an empty handle is returned.
1321
+ */
1322
+ inline Local<Value> UncheckedGetInternalField(int index);
1323
+ };
1324
+
1325
+
1326
+ /**
1327
+ * An instance of the built-in array constructor (ECMA-262, 15.4.2).
1328
+ */
1329
+ class V8EXPORT Array : public Object {
1330
+ public:
1331
+ uint32_t Length() const;
1332
+
1333
+ /**
1334
+ * Clones an element at index |index|. Returns an empty
1335
+ * handle if cloning fails (for any reason).
1336
+ */
1337
+ Local<Object> CloneElementAt(uint32_t index);
1338
+
1339
+ static Local<Array> New(int length = 0);
1340
+ static inline Array* Cast(Value* obj);
1341
+ private:
1342
+ Array();
1343
+ static void CheckCast(Value* obj);
1344
+ };
1345
+
1346
+
1347
+ /**
1348
+ * A JavaScript function object (ECMA-262, 15.3).
1349
+ */
1350
+ class V8EXPORT Function : public Object {
1351
+ public:
1352
+ Local<Object> NewInstance() const;
1353
+ Local<Object> NewInstance(int argc, Handle<Value> argv[]) const;
1354
+ Local<Value> Call(Handle<Object> recv, int argc, Handle<Value> argv[]);
1355
+ void SetName(Handle<String> name);
1356
+ Handle<Value> GetName() const;
1357
+ static inline Function* Cast(Value* obj);
1358
+ private:
1359
+ Function();
1360
+ static void CheckCast(Value* obj);
1361
+ };
1362
+
1363
+
1364
+ /**
1365
+ * A JavaScript value that wraps a C++ void*. This type of value is
1366
+ * mainly used to associate C++ data structures with JavaScript
1367
+ * objects.
1368
+ *
1369
+ * The Wrap function V8 will return the most optimal Value object wrapping the
1370
+ * C++ void*. The type of the value is not guaranteed to be an External object
1371
+ * and no assumptions about its type should be made. To access the wrapped
1372
+ * value Unwrap should be used, all other operations on that object will lead
1373
+ * to unpredictable results.
1374
+ */
1375
+ class V8EXPORT External : public Value {
1376
+ public:
1377
+ static Local<Value> Wrap(void* data);
1378
+ static inline void* Unwrap(Handle<Value> obj);
1379
+
1380
+ static Local<External> New(void* value);
1381
+ static inline External* Cast(Value* obj);
1382
+ void* Value() const;
1383
+ private:
1384
+ External();
1385
+ static void CheckCast(v8::Value* obj);
1386
+ static inline void* QuickUnwrap(Handle<v8::Value> obj);
1387
+ static void* FullUnwrap(Handle<v8::Value> obj);
1388
+ };
1389
+
1390
+
1391
+ // --- T e m p l a t e s ---
1392
+
1393
+
1394
+ /**
1395
+ * The superclass of object and function templates.
1396
+ */
1397
+ class V8EXPORT Template : public Data {
1398
+ public:
1399
+ /** Adds a property to each instance created by this template.*/
1400
+ void Set(Handle<String> name, Handle<Data> value,
1401
+ PropertyAttribute attributes = None);
1402
+ inline void Set(const char* name, Handle<Data> value);
1403
+ private:
1404
+ Template();
1405
+
1406
+ friend class ObjectTemplate;
1407
+ friend class FunctionTemplate;
1408
+ };
1409
+
1410
+
1411
+ /**
1412
+ * The argument information given to function call callbacks. This
1413
+ * class provides access to information about the context of the call,
1414
+ * including the receiver, the number and values of arguments, and
1415
+ * the holder of the function.
1416
+ */
1417
+ class V8EXPORT Arguments {
1418
+ public:
1419
+ inline int Length() const;
1420
+ inline Local<Value> operator[](int i) const;
1421
+ inline Local<Function> Callee() const;
1422
+ inline Local<Object> This() const;
1423
+ inline Local<Object> Holder() const;
1424
+ inline bool IsConstructCall() const;
1425
+ inline Local<Value> Data() const;
1426
+ private:
1427
+ Arguments();
1428
+ friend class ImplementationUtilities;
1429
+ inline Arguments(Local<Value> data,
1430
+ Local<Object> holder,
1431
+ Local<Function> callee,
1432
+ bool is_construct_call,
1433
+ void** values, int length);
1434
+ Local<Value> data_;
1435
+ Local<Object> holder_;
1436
+ Local<Function> callee_;
1437
+ bool is_construct_call_;
1438
+ void** values_;
1439
+ int length_;
1440
+ };
1441
+
1442
+
1443
+ /**
1444
+ * The information passed to an accessor callback about the context
1445
+ * of the property access.
1446
+ */
1447
+ class V8EXPORT AccessorInfo {
1448
+ public:
1449
+ inline AccessorInfo(internal::Object** args)
1450
+ : args_(args) { }
1451
+ inline Local<Value> Data() const;
1452
+ inline Local<Object> This() const;
1453
+ inline Local<Object> Holder() const;
1454
+ private:
1455
+ internal::Object** args_;
1456
+ };
1457
+
1458
+
1459
+ typedef Handle<Value> (*InvocationCallback)(const Arguments& args);
1460
+
1461
+ typedef int (*LookupCallback)(Local<Object> self, Local<String> name);
1462
+
1463
+ /**
1464
+ * Accessor[Getter|Setter] are used as callback functions when
1465
+ * setting|getting a particular property. See objectTemplate::SetAccessor.
1466
+ */
1467
+ typedef Handle<Value> (*AccessorGetter)(Local<String> property,
1468
+ const AccessorInfo& info);
1469
+
1470
+
1471
+ typedef void (*AccessorSetter)(Local<String> property,
1472
+ Local<Value> value,
1473
+ const AccessorInfo& info);
1474
+
1475
+
1476
+ /**
1477
+ * NamedProperty[Getter|Setter] are used as interceptors on object.
1478
+ * See ObjectTemplate::SetNamedPropertyHandler.
1479
+ */
1480
+ typedef Handle<Value> (*NamedPropertyGetter)(Local<String> property,
1481
+ const AccessorInfo& info);
1482
+
1483
+
1484
+ /**
1485
+ * Returns the value if the setter intercepts the request.
1486
+ * Otherwise, returns an empty handle.
1487
+ */
1488
+ typedef Handle<Value> (*NamedPropertySetter)(Local<String> property,
1489
+ Local<Value> value,
1490
+ const AccessorInfo& info);
1491
+
1492
+
1493
+ /**
1494
+ * Returns a non-empty handle if the interceptor intercepts the request.
1495
+ * The result is true if the property exists and false otherwise.
1496
+ */
1497
+ typedef Handle<Boolean> (*NamedPropertyQuery)(Local<String> property,
1498
+ const AccessorInfo& info);
1499
+
1500
+
1501
+ /**
1502
+ * Returns a non-empty handle if the deleter intercepts the request.
1503
+ * The return value is true if the property could be deleted and false
1504
+ * otherwise.
1505
+ */
1506
+ typedef Handle<Boolean> (*NamedPropertyDeleter)(Local<String> property,
1507
+ const AccessorInfo& info);
1508
+
1509
+ /**
1510
+ * Returns an array containing the names of the properties the named
1511
+ * property getter intercepts.
1512
+ */
1513
+ typedef Handle<Array> (*NamedPropertyEnumerator)(const AccessorInfo& info);
1514
+
1515
+
1516
+ /**
1517
+ * Returns the value of the property if the getter intercepts the
1518
+ * request. Otherwise, returns an empty handle.
1519
+ */
1520
+ typedef Handle<Value> (*IndexedPropertyGetter)(uint32_t index,
1521
+ const AccessorInfo& info);
1522
+
1523
+
1524
+ /**
1525
+ * Returns the value if the setter intercepts the request.
1526
+ * Otherwise, returns an empty handle.
1527
+ */
1528
+ typedef Handle<Value> (*IndexedPropertySetter)(uint32_t index,
1529
+ Local<Value> value,
1530
+ const AccessorInfo& info);
1531
+
1532
+
1533
+ /**
1534
+ * Returns a non-empty handle if the interceptor intercepts the request.
1535
+ * The result is true if the property exists and false otherwise.
1536
+ */
1537
+ typedef Handle<Boolean> (*IndexedPropertyQuery)(uint32_t index,
1538
+ const AccessorInfo& info);
1539
+
1540
+ /**
1541
+ * Returns a non-empty handle if the deleter intercepts the request.
1542
+ * The return value is true if the property could be deleted and false
1543
+ * otherwise.
1544
+ */
1545
+ typedef Handle<Boolean> (*IndexedPropertyDeleter)(uint32_t index,
1546
+ const AccessorInfo& info);
1547
+
1548
+ /**
1549
+ * Returns an array containing the indices of the properties the
1550
+ * indexed property getter intercepts.
1551
+ */
1552
+ typedef Handle<Array> (*IndexedPropertyEnumerator)(const AccessorInfo& info);
1553
+
1554
+
1555
+ /**
1556
+ * Access control specifications.
1557
+ *
1558
+ * Some accessors should be accessible across contexts. These
1559
+ * accessors have an explicit access control parameter which specifies
1560
+ * the kind of cross-context access that should be allowed.
1561
+ *
1562
+ * Additionally, for security, accessors can prohibit overwriting by
1563
+ * accessors defined in JavaScript. For objects that have such
1564
+ * accessors either locally or in their prototype chain it is not
1565
+ * possible to overwrite the accessor by using __defineGetter__ or
1566
+ * __defineSetter__ from JavaScript code.
1567
+ */
1568
+ enum AccessControl {
1569
+ DEFAULT = 0,
1570
+ ALL_CAN_READ = 1,
1571
+ ALL_CAN_WRITE = 1 << 1,
1572
+ PROHIBITS_OVERWRITING = 1 << 2
1573
+ };
1574
+
1575
+
1576
+ /**
1577
+ * Access type specification.
1578
+ */
1579
+ enum AccessType {
1580
+ ACCESS_GET,
1581
+ ACCESS_SET,
1582
+ ACCESS_HAS,
1583
+ ACCESS_DELETE,
1584
+ ACCESS_KEYS
1585
+ };
1586
+
1587
+
1588
+ /**
1589
+ * Returns true if cross-context access should be allowed to the named
1590
+ * property with the given key on the host object.
1591
+ */
1592
+ typedef bool (*NamedSecurityCallback)(Local<Object> host,
1593
+ Local<Value> key,
1594
+ AccessType type,
1595
+ Local<Value> data);
1596
+
1597
+
1598
+ /**
1599
+ * Returns true if cross-context access should be allowed to the indexed
1600
+ * property with the given index on the host object.
1601
+ */
1602
+ typedef bool (*IndexedSecurityCallback)(Local<Object> host,
1603
+ uint32_t index,
1604
+ AccessType type,
1605
+ Local<Value> data);
1606
+
1607
+
1608
+ /**
1609
+ * A FunctionTemplate is used to create functions at runtime. There
1610
+ * can only be one function created from a FunctionTemplate in a
1611
+ * context. The lifetime of the created function is equal to the
1612
+ * lifetime of the context. So in case the embedder needs to create
1613
+ * temporary functions that can be collected using Scripts is
1614
+ * preferred.
1615
+ *
1616
+ * A FunctionTemplate can have properties, these properties are added to the
1617
+ * function object when it is created.
1618
+ *
1619
+ * A FunctionTemplate has a corresponding instance template which is
1620
+ * used to create object instances when the function is used as a
1621
+ * constructor. Properties added to the instance template are added to
1622
+ * each object instance.
1623
+ *
1624
+ * A FunctionTemplate can have a prototype template. The prototype template
1625
+ * is used to create the prototype object of the function.
1626
+ *
1627
+ * The following example shows how to use a FunctionTemplate:
1628
+ *
1629
+ * \code
1630
+ * v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New();
1631
+ * t->Set("func_property", v8::Number::New(1));
1632
+ *
1633
+ * v8::Local<v8::Template> proto_t = t->PrototypeTemplate();
1634
+ * proto_t->Set("proto_method", v8::FunctionTemplate::New(InvokeCallback));
1635
+ * proto_t->Set("proto_const", v8::Number::New(2));
1636
+ *
1637
+ * v8::Local<v8::ObjectTemplate> instance_t = t->InstanceTemplate();
1638
+ * instance_t->SetAccessor("instance_accessor", InstanceAccessorCallback);
1639
+ * instance_t->SetNamedPropertyHandler(PropertyHandlerCallback, ...);
1640
+ * instance_t->Set("instance_property", Number::New(3));
1641
+ *
1642
+ * v8::Local<v8::Function> function = t->GetFunction();
1643
+ * v8::Local<v8::Object> instance = function->NewInstance();
1644
+ * \endcode
1645
+ *
1646
+ * Let's use "function" as the JS variable name of the function object
1647
+ * and "instance" for the instance object created above. The function
1648
+ * and the instance will have the following properties:
1649
+ *
1650
+ * \code
1651
+ * func_property in function == true;
1652
+ * function.func_property == 1;
1653
+ *
1654
+ * function.prototype.proto_method() invokes 'InvokeCallback'
1655
+ * function.prototype.proto_const == 2;
1656
+ *
1657
+ * instance instanceof function == true;
1658
+ * instance.instance_accessor calls 'InstanceAccessorCallback'
1659
+ * instance.instance_property == 3;
1660
+ * \endcode
1661
+ *
1662
+ * A FunctionTemplate can inherit from another one by calling the
1663
+ * FunctionTemplate::Inherit method. The following graph illustrates
1664
+ * the semantics of inheritance:
1665
+ *
1666
+ * \code
1667
+ * FunctionTemplate Parent -> Parent() . prototype -> { }
1668
+ * ^ ^
1669
+ * | Inherit(Parent) | .__proto__
1670
+ * | |
1671
+ * FunctionTemplate Child -> Child() . prototype -> { }
1672
+ * \endcode
1673
+ *
1674
+ * A FunctionTemplate 'Child' inherits from 'Parent', the prototype
1675
+ * object of the Child() function has __proto__ pointing to the
1676
+ * Parent() function's prototype object. An instance of the Child
1677
+ * function has all properties on Parent's instance templates.
1678
+ *
1679
+ * Let Parent be the FunctionTemplate initialized in the previous
1680
+ * section and create a Child FunctionTemplate by:
1681
+ *
1682
+ * \code
1683
+ * Local<FunctionTemplate> parent = t;
1684
+ * Local<FunctionTemplate> child = FunctionTemplate::New();
1685
+ * child->Inherit(parent);
1686
+ *
1687
+ * Local<Function> child_function = child->GetFunction();
1688
+ * Local<Object> child_instance = child_function->NewInstance();
1689
+ * \endcode
1690
+ *
1691
+ * The Child function and Child instance will have the following
1692
+ * properties:
1693
+ *
1694
+ * \code
1695
+ * child_func.prototype.__proto__ == function.prototype;
1696
+ * child_instance.instance_accessor calls 'InstanceAccessorCallback'
1697
+ * child_instance.instance_property == 3;
1698
+ * \endcode
1699
+ */
1700
+ class V8EXPORT FunctionTemplate : public Template {
1701
+ public:
1702
+ /** Creates a function template.*/
1703
+ static Local<FunctionTemplate> New(
1704
+ InvocationCallback callback = 0,
1705
+ Handle<Value> data = Handle<Value>(),
1706
+ Handle<Signature> signature = Handle<Signature>());
1707
+ /** Returns the unique function instance in the current execution context.*/
1708
+ Local<Function> GetFunction();
1709
+
1710
+ /**
1711
+ * Set the call-handler callback for a FunctionTemplate. This
1712
+ * callback is called whenever the function created from this
1713
+ * FunctionTemplate is called.
1714
+ */
1715
+ void SetCallHandler(InvocationCallback callback,
1716
+ Handle<Value> data = Handle<Value>());
1717
+
1718
+ /** Get the InstanceTemplate. */
1719
+ Local<ObjectTemplate> InstanceTemplate();
1720
+
1721
+ /** Causes the function template to inherit from a parent function template.*/
1722
+ void Inherit(Handle<FunctionTemplate> parent);
1723
+
1724
+ /**
1725
+ * A PrototypeTemplate is the template used to create the prototype object
1726
+ * of the function created by this template.
1727
+ */
1728
+ Local<ObjectTemplate> PrototypeTemplate();
1729
+
1730
+
1731
+ /**
1732
+ * Set the class name of the FunctionTemplate. This is used for
1733
+ * printing objects created with the function created from the
1734
+ * FunctionTemplate as its constructor.
1735
+ */
1736
+ void SetClassName(Handle<String> name);
1737
+
1738
+ /**
1739
+ * Determines whether the __proto__ accessor ignores instances of
1740
+ * the function template. If instances of the function template are
1741
+ * ignored, __proto__ skips all instances and instead returns the
1742
+ * next object in the prototype chain.
1743
+ *
1744
+ * Call with a value of true to make the __proto__ accessor ignore
1745
+ * instances of the function template. Call with a value of false
1746
+ * to make the __proto__ accessor not ignore instances of the
1747
+ * function template. By default, instances of a function template
1748
+ * are not ignored.
1749
+ */
1750
+ void SetHiddenPrototype(bool value);
1751
+
1752
+ /**
1753
+ * Returns true if the given object is an instance of this function
1754
+ * template.
1755
+ */
1756
+ bool HasInstance(Handle<Value> object);
1757
+
1758
+ private:
1759
+ FunctionTemplate();
1760
+ void AddInstancePropertyAccessor(Handle<String> name,
1761
+ AccessorGetter getter,
1762
+ AccessorSetter setter,
1763
+ Handle<Value> data,
1764
+ AccessControl settings,
1765
+ PropertyAttribute attributes);
1766
+ void SetNamedInstancePropertyHandler(NamedPropertyGetter getter,
1767
+ NamedPropertySetter setter,
1768
+ NamedPropertyQuery query,
1769
+ NamedPropertyDeleter remover,
1770
+ NamedPropertyEnumerator enumerator,
1771
+ Handle<Value> data);
1772
+ void SetIndexedInstancePropertyHandler(IndexedPropertyGetter getter,
1773
+ IndexedPropertySetter setter,
1774
+ IndexedPropertyQuery query,
1775
+ IndexedPropertyDeleter remover,
1776
+ IndexedPropertyEnumerator enumerator,
1777
+ Handle<Value> data);
1778
+ void SetInstanceCallAsFunctionHandler(InvocationCallback callback,
1779
+ Handle<Value> data);
1780
+
1781
+ friend class Context;
1782
+ friend class ObjectTemplate;
1783
+ };
1784
+
1785
+
1786
+ /**
1787
+ * An ObjectTemplate is used to create objects at runtime.
1788
+ *
1789
+ * Properties added to an ObjectTemplate are added to each object
1790
+ * created from the ObjectTemplate.
1791
+ */
1792
+ class V8EXPORT ObjectTemplate : public Template {
1793
+ public:
1794
+ /** Creates an ObjectTemplate. */
1795
+ static Local<ObjectTemplate> New();
1796
+
1797
+ /** Creates a new instance of this template.*/
1798
+ Local<Object> NewInstance();
1799
+
1800
+ /**
1801
+ * Sets an accessor on the object template.
1802
+ *
1803
+ * Whenever the property with the given name is accessed on objects
1804
+ * created from this ObjectTemplate the getter and setter callbacks
1805
+ * are called instead of getting and setting the property directly
1806
+ * on the JavaScript object.
1807
+ *
1808
+ * \param name The name of the property for which an accessor is added.
1809
+ * \param getter The callback to invoke when getting the property.
1810
+ * \param setter The callback to invoke when setting the property.
1811
+ * \param data A piece of data that will be passed to the getter and setter
1812
+ * callbacks whenever they are invoked.
1813
+ * \param settings Access control settings for the accessor. This is a bit
1814
+ * field consisting of one of more of
1815
+ * DEFAULT = 0, ALL_CAN_READ = 1, or ALL_CAN_WRITE = 2.
1816
+ * The default is to not allow cross-context access.
1817
+ * ALL_CAN_READ means that all cross-context reads are allowed.
1818
+ * ALL_CAN_WRITE means that all cross-context writes are allowed.
1819
+ * The combination ALL_CAN_READ | ALL_CAN_WRITE can be used to allow all
1820
+ * cross-context access.
1821
+ * \param attribute The attributes of the property for which an accessor
1822
+ * is added.
1823
+ */
1824
+ void SetAccessor(Handle<String> name,
1825
+ AccessorGetter getter,
1826
+ AccessorSetter setter = 0,
1827
+ Handle<Value> data = Handle<Value>(),
1828
+ AccessControl settings = DEFAULT,
1829
+ PropertyAttribute attribute = None);
1830
+
1831
+ /**
1832
+ * Sets a named property handler on the object template.
1833
+ *
1834
+ * Whenever a named property is accessed on objects created from
1835
+ * this object template, the provided callback is invoked instead of
1836
+ * accessing the property directly on the JavaScript object.
1837
+ *
1838
+ * \param getter The callback to invoke when getting a property.
1839
+ * \param setter The callback to invoke when setting a property.
1840
+ * \param query The callback to invoke to check is an object has a property.
1841
+ * \param deleter The callback to invoke when deleting a property.
1842
+ * \param enumerator The callback to invoke to enumerate all the named
1843
+ * properties of an object.
1844
+ * \param data A piece of data that will be passed to the callbacks
1845
+ * whenever they are invoked.
1846
+ */
1847
+ void SetNamedPropertyHandler(NamedPropertyGetter getter,
1848
+ NamedPropertySetter setter = 0,
1849
+ NamedPropertyQuery query = 0,
1850
+ NamedPropertyDeleter deleter = 0,
1851
+ NamedPropertyEnumerator enumerator = 0,
1852
+ Handle<Value> data = Handle<Value>());
1853
+
1854
+ /**
1855
+ * Sets an indexed property handler on the object template.
1856
+ *
1857
+ * Whenever an indexed property is accessed on objects created from
1858
+ * this object template, the provided callback is invoked instead of
1859
+ * accessing the property directly on the JavaScript object.
1860
+ *
1861
+ * \param getter The callback to invoke when getting a property.
1862
+ * \param setter The callback to invoke when setting a property.
1863
+ * \param query The callback to invoke to check is an object has a property.
1864
+ * \param deleter The callback to invoke when deleting a property.
1865
+ * \param enumerator The callback to invoke to enumerate all the indexed
1866
+ * properties of an object.
1867
+ * \param data A piece of data that will be passed to the callbacks
1868
+ * whenever they are invoked.
1869
+ */
1870
+ void SetIndexedPropertyHandler(IndexedPropertyGetter getter,
1871
+ IndexedPropertySetter setter = 0,
1872
+ IndexedPropertyQuery query = 0,
1873
+ IndexedPropertyDeleter deleter = 0,
1874
+ IndexedPropertyEnumerator enumerator = 0,
1875
+ Handle<Value> data = Handle<Value>());
1876
+ /**
1877
+ * Sets the callback to be used when calling instances created from
1878
+ * this template as a function. If no callback is set, instances
1879
+ * behave like normal JavaScript objects that cannot be called as a
1880
+ * function.
1881
+ */
1882
+ void SetCallAsFunctionHandler(InvocationCallback callback,
1883
+ Handle<Value> data = Handle<Value>());
1884
+
1885
+ /**
1886
+ * Mark object instances of the template as undetectable.
1887
+ *
1888
+ * In many ways, undetectable objects behave as though they are not
1889
+ * there. They behave like 'undefined' in conditionals and when
1890
+ * printed. However, properties can be accessed and called as on
1891
+ * normal objects.
1892
+ */
1893
+ void MarkAsUndetectable();
1894
+
1895
+ /**
1896
+ * Sets access check callbacks on the object template.
1897
+ *
1898
+ * When accessing properties on instances of this object template,
1899
+ * the access check callback will be called to determine whether or
1900
+ * not to allow cross-context access to the properties.
1901
+ * The last parameter specifies whether access checks are turned
1902
+ * on by default on instances. If access checks are off by default,
1903
+ * they can be turned on on individual instances by calling
1904
+ * Object::TurnOnAccessCheck().
1905
+ */
1906
+ void SetAccessCheckCallbacks(NamedSecurityCallback named_handler,
1907
+ IndexedSecurityCallback indexed_handler,
1908
+ Handle<Value> data = Handle<Value>(),
1909
+ bool turned_on_by_default = true);
1910
+
1911
+ /**
1912
+ * Gets the number of internal fields for objects generated from
1913
+ * this template.
1914
+ */
1915
+ int InternalFieldCount();
1916
+
1917
+ /**
1918
+ * Sets the number of internal fields for objects generated from
1919
+ * this template.
1920
+ */
1921
+ void SetInternalFieldCount(int value);
1922
+
1923
+ private:
1924
+ ObjectTemplate();
1925
+ static Local<ObjectTemplate> New(Handle<FunctionTemplate> constructor);
1926
+ friend class FunctionTemplate;
1927
+ };
1928
+
1929
+
1930
+ /**
1931
+ * A Signature specifies which receivers and arguments a function can
1932
+ * legally be called with.
1933
+ */
1934
+ class V8EXPORT Signature : public Data {
1935
+ public:
1936
+ static Local<Signature> New(Handle<FunctionTemplate> receiver =
1937
+ Handle<FunctionTemplate>(),
1938
+ int argc = 0,
1939
+ Handle<FunctionTemplate> argv[] = 0);
1940
+ private:
1941
+ Signature();
1942
+ };
1943
+
1944
+
1945
+ /**
1946
+ * A utility for determining the type of objects based on the template
1947
+ * they were constructed from.
1948
+ */
1949
+ class V8EXPORT TypeSwitch : public Data {
1950
+ public:
1951
+ static Local<TypeSwitch> New(Handle<FunctionTemplate> type);
1952
+ static Local<TypeSwitch> New(int argc, Handle<FunctionTemplate> types[]);
1953
+ int match(Handle<Value> value);
1954
+ private:
1955
+ TypeSwitch();
1956
+ };
1957
+
1958
+
1959
+ // --- E x t e n s i o n s ---
1960
+
1961
+
1962
+ /**
1963
+ * Ignore
1964
+ */
1965
+ class V8EXPORT Extension { // NOLINT
1966
+ public:
1967
+ Extension(const char* name,
1968
+ const char* source = 0,
1969
+ int dep_count = 0,
1970
+ const char** deps = 0);
1971
+ virtual ~Extension() { }
1972
+ virtual v8::Handle<v8::FunctionTemplate>
1973
+ GetNativeFunction(v8::Handle<v8::String> name) {
1974
+ return v8::Handle<v8::FunctionTemplate>();
1975
+ }
1976
+
1977
+ const char* name() { return name_; }
1978
+ const char* source() { return source_; }
1979
+ int dependency_count() { return dep_count_; }
1980
+ const char** dependencies() { return deps_; }
1981
+ void set_auto_enable(bool value) { auto_enable_ = value; }
1982
+ bool auto_enable() { return auto_enable_; }
1983
+
1984
+ private:
1985
+ const char* name_;
1986
+ const char* source_;
1987
+ int dep_count_;
1988
+ const char** deps_;
1989
+ bool auto_enable_;
1990
+
1991
+ // Disallow copying and assigning.
1992
+ Extension(const Extension&);
1993
+ void operator=(const Extension&);
1994
+ };
1995
+
1996
+
1997
+ void V8EXPORT RegisterExtension(Extension* extension);
1998
+
1999
+
2000
+ /**
2001
+ * Ignore
2002
+ */
2003
+ class V8EXPORT DeclareExtension {
2004
+ public:
2005
+ inline DeclareExtension(Extension* extension) {
2006
+ RegisterExtension(extension);
2007
+ }
2008
+ };
2009
+
2010
+
2011
+ // --- S t a t i c s ---
2012
+
2013
+
2014
+ Handle<Primitive> V8EXPORT Undefined();
2015
+ Handle<Primitive> V8EXPORT Null();
2016
+ Handle<Boolean> V8EXPORT True();
2017
+ Handle<Boolean> V8EXPORT False();
2018
+
2019
+
2020
+ /**
2021
+ * A set of constraints that specifies the limits of the runtime's memory use.
2022
+ * You must set the heap size before initializing the VM - the size cannot be
2023
+ * adjusted after the VM is initialized.
2024
+ *
2025
+ * If you are using threads then you should hold the V8::Locker lock while
2026
+ * setting the stack limit and you must set a non-default stack limit separately
2027
+ * for each thread.
2028
+ */
2029
+ class V8EXPORT ResourceConstraints {
2030
+ public:
2031
+ ResourceConstraints();
2032
+ int max_young_space_size() const { return max_young_space_size_; }
2033
+ void set_max_young_space_size(int value) { max_young_space_size_ = value; }
2034
+ int max_old_space_size() const { return max_old_space_size_; }
2035
+ void set_max_old_space_size(int value) { max_old_space_size_ = value; }
2036
+ uint32_t* stack_limit() const { return stack_limit_; }
2037
+ // Sets an address beyond which the VM's stack may not grow.
2038
+ void set_stack_limit(uint32_t* value) { stack_limit_ = value; }
2039
+ private:
2040
+ int max_young_space_size_;
2041
+ int max_old_space_size_;
2042
+ uint32_t* stack_limit_;
2043
+ };
2044
+
2045
+
2046
+ bool SetResourceConstraints(ResourceConstraints* constraints);
2047
+
2048
+
2049
+ // --- E x c e p t i o n s ---
2050
+
2051
+
2052
+ typedef void (*FatalErrorCallback)(const char* location, const char* message);
2053
+
2054
+
2055
+ typedef void (*MessageCallback)(Handle<Message> message, Handle<Value> data);
2056
+
2057
+
2058
+ /**
2059
+ * Schedules an exception to be thrown when returning to JavaScript. When an
2060
+ * exception has been scheduled it is illegal to invoke any JavaScript
2061
+ * operation; the caller must return immediately and only after the exception
2062
+ * has been handled does it become legal to invoke JavaScript operations.
2063
+ */
2064
+ Handle<Value> V8EXPORT ThrowException(Handle<Value> exception);
2065
+
2066
+ /**
2067
+ * Create new error objects by calling the corresponding error object
2068
+ * constructor with the message.
2069
+ */
2070
+ class V8EXPORT Exception {
2071
+ public:
2072
+ static Local<Value> RangeError(Handle<String> message);
2073
+ static Local<Value> ReferenceError(Handle<String> message);
2074
+ static Local<Value> SyntaxError(Handle<String> message);
2075
+ static Local<Value> TypeError(Handle<String> message);
2076
+ static Local<Value> Error(Handle<String> message);
2077
+ };
2078
+
2079
+
2080
+ // --- C o u n t e r s C a l l b a c k s ---
2081
+
2082
+ typedef int* (*CounterLookupCallback)(const char* name);
2083
+
2084
+ typedef void* (*CreateHistogramCallback)(const char* name,
2085
+ int min,
2086
+ int max,
2087
+ size_t buckets);
2088
+
2089
+ typedef void (*AddHistogramSampleCallback)(void* histogram, int sample);
2090
+
2091
+ // --- F a i l e d A c c e s s C h e c k C a l l b a c k ---
2092
+ typedef void (*FailedAccessCheckCallback)(Local<Object> target,
2093
+ AccessType type,
2094
+ Local<Value> data);
2095
+
2096
+ // --- G a r b a g e C o l l e c t i o n C a l l b a c k s
2097
+
2098
+ /**
2099
+ * Applications can register a callback function which is called
2100
+ * before and after a major garbage collection. Allocations are not
2101
+ * allowed in the callback function, you therefore cannot manipulate
2102
+ * objects (set or delete properties for example) since it is possible
2103
+ * such operations will result in the allocation of objects.
2104
+ */
2105
+ typedef void (*GCCallback)();
2106
+
2107
+
2108
+ // --- C o n t e x t G e n e r a t o r ---
2109
+
2110
+ /**
2111
+ * Applications must provide a callback function which is called to generate
2112
+ * a context if a context was not deserialized from the snapshot.
2113
+ */
2114
+ typedef Persistent<Context> (*ContextGenerator)();
2115
+
2116
+
2117
+ /**
2118
+ * Profiler modules.
2119
+ *
2120
+ * In V8, profiler consists of several modules: CPU profiler, and different
2121
+ * kinds of heap profiling. Each can be turned on / off independently.
2122
+ * When PROFILER_MODULE_HEAP_SNAPSHOT flag is passed to ResumeProfilerEx,
2123
+ * modules are enabled only temporarily for making a snapshot of the heap.
2124
+ */
2125
+ enum ProfilerModules {
2126
+ PROFILER_MODULE_NONE = 0,
2127
+ PROFILER_MODULE_CPU = 1,
2128
+ PROFILER_MODULE_HEAP_STATS = 1 << 1,
2129
+ PROFILER_MODULE_JS_CONSTRUCTORS = 1 << 2,
2130
+ PROFILER_MODULE_HEAP_SNAPSHOT = 1 << 16
2131
+ };
2132
+
2133
+
2134
+ /**
2135
+ * Collection of V8 heap information.
2136
+ *
2137
+ * Instances of this class can be passed to v8::V8::HeapStatistics to
2138
+ * get heap statistics from V8.
2139
+ */
2140
+ class V8EXPORT HeapStatistics {
2141
+ public:
2142
+ HeapStatistics();
2143
+ size_t total_heap_size() { return total_heap_size_; }
2144
+ size_t used_heap_size() { return used_heap_size_; }
2145
+
2146
+ private:
2147
+ void set_total_heap_size(size_t size) { total_heap_size_ = size; }
2148
+ void set_used_heap_size(size_t size) { used_heap_size_ = size; }
2149
+
2150
+ size_t total_heap_size_;
2151
+ size_t used_heap_size_;
2152
+
2153
+ friend class V8;
2154
+ };
2155
+
2156
+
2157
+ /**
2158
+ * Container class for static utility functions.
2159
+ */
2160
+ class V8EXPORT V8 {
2161
+ public:
2162
+ /** Set the callback to invoke in case of fatal errors. */
2163
+ static void SetFatalErrorHandler(FatalErrorCallback that);
2164
+
2165
+ /**
2166
+ * Ignore out-of-memory exceptions.
2167
+ *
2168
+ * V8 running out of memory is treated as a fatal error by default.
2169
+ * This means that the fatal error handler is called and that V8 is
2170
+ * terminated.
2171
+ *
2172
+ * IgnoreOutOfMemoryException can be used to not treat a
2173
+ * out-of-memory situation as a fatal error. This way, the contexts
2174
+ * that did not cause the out of memory problem might be able to
2175
+ * continue execution.
2176
+ */
2177
+ static void IgnoreOutOfMemoryException();
2178
+
2179
+ /**
2180
+ * Check if V8 is dead and therefore unusable. This is the case after
2181
+ * fatal errors such as out-of-memory situations.
2182
+ */
2183
+ static bool IsDead();
2184
+
2185
+ /**
2186
+ * Adds a message listener.
2187
+ *
2188
+ * The same message listener can be added more than once and it that
2189
+ * case it will be called more than once for each message.
2190
+ */
2191
+ static bool AddMessageListener(MessageCallback that,
2192
+ Handle<Value> data = Handle<Value>());
2193
+
2194
+ /**
2195
+ * Remove all message listeners from the specified callback function.
2196
+ */
2197
+ static void RemoveMessageListeners(MessageCallback that);
2198
+
2199
+ /**
2200
+ * Sets V8 flags from a string.
2201
+ */
2202
+ static void SetFlagsFromString(const char* str, int length);
2203
+
2204
+ /**
2205
+ * Sets V8 flags from the command line.
2206
+ */
2207
+ static void SetFlagsFromCommandLine(int* argc,
2208
+ char** argv,
2209
+ bool remove_flags);
2210
+
2211
+ /** Get the version string. */
2212
+ static const char* GetVersion();
2213
+
2214
+ /**
2215
+ * Enables the host application to provide a mechanism for recording
2216
+ * statistics counters.
2217
+ */
2218
+ static void SetCounterFunction(CounterLookupCallback);
2219
+
2220
+ /**
2221
+ * Enables the host application to provide a mechanism for recording
2222
+ * histograms. The CreateHistogram function returns a
2223
+ * histogram which will later be passed to the AddHistogramSample
2224
+ * function.
2225
+ */
2226
+ static void SetCreateHistogramFunction(CreateHistogramCallback);
2227
+ static void SetAddHistogramSampleFunction(AddHistogramSampleCallback);
2228
+
2229
+ /**
2230
+ * Enables the computation of a sliding window of states. The sliding
2231
+ * window information is recorded in statistics counters.
2232
+ */
2233
+ static void EnableSlidingStateWindow();
2234
+
2235
+ /** Callback function for reporting failed access checks.*/
2236
+ static void SetFailedAccessCheckCallbackFunction(FailedAccessCheckCallback);
2237
+
2238
+ /**
2239
+ * Enables the host application to receive a notification before a
2240
+ * major garbage colletion. Allocations are not allowed in the
2241
+ * callback function, you therefore cannot manipulate objects (set
2242
+ * or delete properties for example) since it is possible such
2243
+ * operations will result in the allocation of objects.
2244
+ */
2245
+ static void SetGlobalGCPrologueCallback(GCCallback);
2246
+
2247
+ /**
2248
+ * Enables the host application to receive a notification after a
2249
+ * major garbage collection. Allocations are not allowed in the
2250
+ * callback function, you therefore cannot manipulate objects (set
2251
+ * or delete properties for example) since it is possible such
2252
+ * operations will result in the allocation of objects.
2253
+ */
2254
+ static void SetGlobalGCEpilogueCallback(GCCallback);
2255
+
2256
+ /**
2257
+ * Allows the host application to group objects together. If one
2258
+ * object in the group is alive, all objects in the group are alive.
2259
+ * After each garbage collection, object groups are removed. It is
2260
+ * intended to be used in the before-garbage-collection callback
2261
+ * function, for instance to simulate DOM tree connections among JS
2262
+ * wrapper objects.
2263
+ */
2264
+ static void AddObjectGroup(Persistent<Value>* objects, size_t length);
2265
+
2266
+ /**
2267
+ * Initializes from snapshot if possible. Otherwise, attempts to
2268
+ * initialize from scratch. This function is called implicitly if
2269
+ * you use the API without calling it first.
2270
+ */
2271
+ static bool Initialize();
2272
+
2273
+ /**
2274
+ * Adjusts the amount of registered external memory. Used to give
2275
+ * V8 an indication of the amount of externally allocated memory
2276
+ * that is kept alive by JavaScript objects. V8 uses this to decide
2277
+ * when to perform global garbage collections. Registering
2278
+ * externally allocated memory will trigger global garbage
2279
+ * collections more often than otherwise in an attempt to garbage
2280
+ * collect the JavaScript objects keeping the externally allocated
2281
+ * memory alive.
2282
+ *
2283
+ * \param change_in_bytes the change in externally allocated memory
2284
+ * that is kept alive by JavaScript objects.
2285
+ * \returns the adjusted value.
2286
+ */
2287
+ static int AdjustAmountOfExternalAllocatedMemory(int change_in_bytes);
2288
+
2289
+ /**
2290
+ * Suspends recording of tick samples in the profiler.
2291
+ * When the V8 profiling mode is enabled (usually via command line
2292
+ * switches) this function suspends recording of tick samples.
2293
+ * Profiling ticks are discarded until ResumeProfiler() is called.
2294
+ *
2295
+ * See also the --prof and --prof_auto command line switches to
2296
+ * enable V8 profiling.
2297
+ */
2298
+ static void PauseProfiler();
2299
+
2300
+ /**
2301
+ * Resumes recording of tick samples in the profiler.
2302
+ * See also PauseProfiler().
2303
+ */
2304
+ static void ResumeProfiler();
2305
+
2306
+ /**
2307
+ * Return whether profiler is currently paused.
2308
+ */
2309
+ static bool IsProfilerPaused();
2310
+
2311
+ /**
2312
+ * Resumes specified profiler modules.
2313
+ * "ResumeProfiler" is equivalent to "ResumeProfilerEx(PROFILER_MODULE_CPU)".
2314
+ * See ProfilerModules enum.
2315
+ *
2316
+ * \param flags Flags specifying profiler modules.
2317
+ */
2318
+ static void ResumeProfilerEx(int flags);
2319
+
2320
+ /**
2321
+ * Pauses specified profiler modules.
2322
+ * "PauseProfiler" is equivalent to "PauseProfilerEx(PROFILER_MODULE_CPU)".
2323
+ * See ProfilerModules enum.
2324
+ *
2325
+ * \param flags Flags specifying profiler modules.
2326
+ */
2327
+ static void PauseProfilerEx(int flags);
2328
+
2329
+ /**
2330
+ * Returns active (resumed) profiler modules.
2331
+ * See ProfilerModules enum.
2332
+ *
2333
+ * \returns active profiler modules.
2334
+ */
2335
+ static int GetActiveProfilerModules();
2336
+
2337
+ /**
2338
+ * If logging is performed into a memory buffer (via --logfile=*), allows to
2339
+ * retrieve previously written messages. This can be used for retrieving
2340
+ * profiler log data in the application. This function is thread-safe.
2341
+ *
2342
+ * Caller provides a destination buffer that must exist during GetLogLines
2343
+ * call. Only whole log lines are copied into the buffer.
2344
+ *
2345
+ * \param from_pos specified a point in a buffer to read from, 0 is the
2346
+ * beginning of a buffer. It is assumed that caller updates its current
2347
+ * position using returned size value from the previous call.
2348
+ * \param dest_buf destination buffer for log data.
2349
+ * \param max_size size of the destination buffer.
2350
+ * \returns actual size of log data copied into buffer.
2351
+ */
2352
+ static int GetLogLines(int from_pos, char* dest_buf, int max_size);
2353
+
2354
+ /**
2355
+ * Retrieve the V8 thread id of the calling thread.
2356
+ *
2357
+ * The thread id for a thread should only be retrieved after the V8
2358
+ * lock has been acquired with a Locker object with that thread.
2359
+ */
2360
+ static int GetCurrentThreadId();
2361
+
2362
+ /**
2363
+ * Forcefully terminate execution of a JavaScript thread. This can
2364
+ * be used to terminate long-running scripts.
2365
+ *
2366
+ * TerminateExecution should only be called when then V8 lock has
2367
+ * been acquired with a Locker object. Therefore, in order to be
2368
+ * able to terminate long-running threads, preemption must be
2369
+ * enabled to allow the user of TerminateExecution to acquire the
2370
+ * lock.
2371
+ *
2372
+ * The termination is achieved by throwing an exception that is
2373
+ * uncatchable by JavaScript exception handlers. Termination
2374
+ * exceptions act as if they were caught by a C++ TryCatch exception
2375
+ * handlers. If forceful termination is used, any C++ TryCatch
2376
+ * exception handler that catches an exception should check if that
2377
+ * exception is a termination exception and immediately return if
2378
+ * that is the case. Returning immediately in that case will
2379
+ * continue the propagation of the termination exception if needed.
2380
+ *
2381
+ * The thread id passed to TerminateExecution must have been
2382
+ * obtained by calling GetCurrentThreadId on the thread in question.
2383
+ *
2384
+ * \param thread_id The thread id of the thread to terminate.
2385
+ */
2386
+ static void TerminateExecution(int thread_id);
2387
+
2388
+ /**
2389
+ * Forcefully terminate the current thread of JavaScript execution.
2390
+ *
2391
+ * This method can be used by any thread even if that thread has not
2392
+ * acquired the V8 lock with a Locker object.
2393
+ */
2394
+ static void TerminateExecution();
2395
+
2396
+ /**
2397
+ * Releases any resources used by v8 and stops any utility threads
2398
+ * that may be running. Note that disposing v8 is permanent, it
2399
+ * cannot be reinitialized.
2400
+ *
2401
+ * It should generally not be necessary to dispose v8 before exiting
2402
+ * a process, this should happen automatically. It is only necessary
2403
+ * to use if the process needs the resources taken up by v8.
2404
+ */
2405
+ static bool Dispose();
2406
+
2407
+ /**
2408
+ * Get statistics about the heap memory usage.
2409
+ */
2410
+ static void GetHeapStatistics(HeapStatistics* heap_statistics);
2411
+
2412
+ /**
2413
+ * Optional notification that the embedder is idle.
2414
+ * V8 uses the notification to reduce memory footprint.
2415
+ * This call can be used repeatedly if the embedder remains idle.
2416
+ * Returns true if the embedder should stop calling IdleNotification
2417
+ * until real work has been done. This indicates that V8 has done
2418
+ * as much cleanup as it will be able to do.
2419
+ */
2420
+ static bool IdleNotification();
2421
+
2422
+ /**
2423
+ * Optional notification that the system is running low on memory.
2424
+ * V8 uses these notifications to attempt to free memory.
2425
+ */
2426
+ static void LowMemoryNotification();
2427
+
2428
+ private:
2429
+ V8();
2430
+
2431
+ static internal::Object** GlobalizeReference(internal::Object** handle);
2432
+ static void DisposeGlobal(internal::Object** global_handle);
2433
+ static void MakeWeak(internal::Object** global_handle,
2434
+ void* data,
2435
+ WeakReferenceCallback);
2436
+ static void ClearWeak(internal::Object** global_handle);
2437
+ static bool IsGlobalNearDeath(internal::Object** global_handle);
2438
+ static bool IsGlobalWeak(internal::Object** global_handle);
2439
+
2440
+ template <class T> friend class Handle;
2441
+ template <class T> friend class Local;
2442
+ template <class T> friend class Persistent;
2443
+ friend class Context;
2444
+ };
2445
+
2446
+
2447
+ /**
2448
+ * An external exception handler.
2449
+ */
2450
+ class V8EXPORT TryCatch {
2451
+ public:
2452
+
2453
+ /**
2454
+ * Creates a new try/catch block and registers it with v8.
2455
+ */
2456
+ TryCatch();
2457
+
2458
+ /**
2459
+ * Unregisters and deletes this try/catch block.
2460
+ */
2461
+ ~TryCatch();
2462
+
2463
+ /**
2464
+ * Returns true if an exception has been caught by this try/catch block.
2465
+ */
2466
+ bool HasCaught() const;
2467
+
2468
+ /**
2469
+ * For certain types of exceptions, it makes no sense to continue
2470
+ * execution.
2471
+ *
2472
+ * Currently, the only type of exception that can be caught by a
2473
+ * TryCatch handler and for which it does not make sense to continue
2474
+ * is termination exception. Such exceptions are thrown when the
2475
+ * TerminateExecution methods are called to terminate a long-running
2476
+ * script.
2477
+ *
2478
+ * If CanContinue returns false, the correct action is to perform
2479
+ * any C++ cleanup needed and then return.
2480
+ */
2481
+ bool CanContinue() const;
2482
+
2483
+ /**
2484
+ * Throws the exception caught by this TryCatch in a way that avoids
2485
+ * it being caught again by this same TryCatch. As with ThrowException
2486
+ * it is illegal to execute any JavaScript operations after calling
2487
+ * ReThrow; the caller must return immediately to where the exception
2488
+ * is caught.
2489
+ */
2490
+ Handle<Value> ReThrow();
2491
+
2492
+ /**
2493
+ * Returns the exception caught by this try/catch block. If no exception has
2494
+ * been caught an empty handle is returned.
2495
+ *
2496
+ * The returned handle is valid until this TryCatch block has been destroyed.
2497
+ */
2498
+ Local<Value> Exception() const;
2499
+
2500
+ /**
2501
+ * Returns the .stack property of the thrown object. If no .stack
2502
+ * property is present an empty handle is returned.
2503
+ */
2504
+ Local<Value> StackTrace() const;
2505
+
2506
+ /**
2507
+ * Returns the message associated with this exception. If there is
2508
+ * no message associated an empty handle is returned.
2509
+ *
2510
+ * The returned handle is valid until this TryCatch block has been
2511
+ * destroyed.
2512
+ */
2513
+ Local<v8::Message> Message() const;
2514
+
2515
+ /**
2516
+ * Clears any exceptions that may have been caught by this try/catch block.
2517
+ * After this method has been called, HasCaught() will return false.
2518
+ *
2519
+ * It is not necessary to clear a try/catch block before using it again; if
2520
+ * another exception is thrown the previously caught exception will just be
2521
+ * overwritten. However, it is often a good idea since it makes it easier
2522
+ * to determine which operation threw a given exception.
2523
+ */
2524
+ void Reset();
2525
+
2526
+ /**
2527
+ * Set verbosity of the external exception handler.
2528
+ *
2529
+ * By default, exceptions that are caught by an external exception
2530
+ * handler are not reported. Call SetVerbose with true on an
2531
+ * external exception handler to have exceptions caught by the
2532
+ * handler reported as if they were not caught.
2533
+ */
2534
+ void SetVerbose(bool value);
2535
+
2536
+ /**
2537
+ * Set whether or not this TryCatch should capture a Message object
2538
+ * which holds source information about where the exception
2539
+ * occurred. True by default.
2540
+ */
2541
+ void SetCaptureMessage(bool value);
2542
+
2543
+ private:
2544
+ void* next_;
2545
+ void* exception_;
2546
+ void* message_;
2547
+ bool is_verbose_ : 1;
2548
+ bool can_continue_ : 1;
2549
+ bool capture_message_ : 1;
2550
+ bool rethrow_ : 1;
2551
+
2552
+ friend class v8::internal::Top;
2553
+ };
2554
+
2555
+
2556
+ // --- C o n t e x t ---
2557
+
2558
+
2559
+ /**
2560
+ * Ignore
2561
+ */
2562
+ class V8EXPORT ExtensionConfiguration {
2563
+ public:
2564
+ ExtensionConfiguration(int name_count, const char* names[])
2565
+ : name_count_(name_count), names_(names) { }
2566
+ private:
2567
+ friend class ImplementationUtilities;
2568
+ int name_count_;
2569
+ const char** names_;
2570
+ };
2571
+
2572
+
2573
+ /**
2574
+ * A sandboxed execution context with its own set of built-in objects
2575
+ * and functions.
2576
+ */
2577
+ class V8EXPORT Context {
2578
+ public:
2579
+ /** Returns the global object of the context. */
2580
+ Local<Object> Global();
2581
+
2582
+ /**
2583
+ * Detaches the global object from its context before
2584
+ * the global object can be reused to create a new context.
2585
+ */
2586
+ void DetachGlobal();
2587
+
2588
+ /** Creates a new context. */
2589
+ static Persistent<Context> New(
2590
+ ExtensionConfiguration* extensions = 0,
2591
+ Handle<ObjectTemplate> global_template = Handle<ObjectTemplate>(),
2592
+ Handle<Value> global_object = Handle<Value>());
2593
+
2594
+ /** Returns the last entered context. */
2595
+ static Local<Context> GetEntered();
2596
+
2597
+ /** Returns the context that is on the top of the stack. */
2598
+ static Local<Context> GetCurrent();
2599
+
2600
+ /**
2601
+ * Returns the context of the calling JavaScript code. That is the
2602
+ * context of the top-most JavaScript frame. If there are no
2603
+ * JavaScript frames an empty handle is returned.
2604
+ */
2605
+ static Local<Context> GetCalling();
2606
+
2607
+ /**
2608
+ * Sets the security token for the context. To access an object in
2609
+ * another context, the security tokens must match.
2610
+ */
2611
+ void SetSecurityToken(Handle<Value> token);
2612
+
2613
+ /** Restores the security token to the default value. */
2614
+ void UseDefaultSecurityToken();
2615
+
2616
+ /** Returns the security token of this context.*/
2617
+ Handle<Value> GetSecurityToken();
2618
+
2619
+ /**
2620
+ * Enter this context. After entering a context, all code compiled
2621
+ * and run is compiled and run in this context. If another context
2622
+ * is already entered, this old context is saved so it can be
2623
+ * restored when the new context is exited.
2624
+ */
2625
+ void Enter();
2626
+
2627
+ /**
2628
+ * Exit this context. Exiting the current context restores the
2629
+ * context that was in place when entering the current context.
2630
+ */
2631
+ void Exit();
2632
+
2633
+ /** Returns true if the context has experienced an out of memory situation. */
2634
+ bool HasOutOfMemoryException();
2635
+
2636
+ /** Returns true if V8 has a current context. */
2637
+ static bool InContext();
2638
+
2639
+ /**
2640
+ * Associate an additional data object with the context. This is mainly used
2641
+ * with the debugger to provide additional information on the context through
2642
+ * the debugger API.
2643
+ */
2644
+ void SetData(Handle<String> data);
2645
+ Local<Value> GetData();
2646
+
2647
+ /**
2648
+ * Stack-allocated class which sets the execution context for all
2649
+ * operations executed within a local scope.
2650
+ */
2651
+ class V8EXPORT Scope {
2652
+ public:
2653
+ inline Scope(Handle<Context> context) : context_(context) {
2654
+ context_->Enter();
2655
+ }
2656
+ inline ~Scope() { context_->Exit(); }
2657
+ private:
2658
+ Handle<Context> context_;
2659
+ };
2660
+
2661
+ private:
2662
+ friend class Value;
2663
+ friend class Script;
2664
+ friend class Object;
2665
+ friend class Function;
2666
+ };
2667
+
2668
+
2669
+ /**
2670
+ * Multiple threads in V8 are allowed, but only one thread at a time
2671
+ * is allowed to use V8. The definition of 'using V8' includes
2672
+ * accessing handles or holding onto object pointers obtained from V8
2673
+ * handles. It is up to the user of V8 to ensure (perhaps with
2674
+ * locking) that this constraint is not violated.
2675
+ *
2676
+ * If you wish to start using V8 in a thread you can do this by constructing
2677
+ * a v8::Locker object. After the code using V8 has completed for the
2678
+ * current thread you can call the destructor. This can be combined
2679
+ * with C++ scope-based construction as follows:
2680
+ *
2681
+ * \code
2682
+ * ...
2683
+ * {
2684
+ * v8::Locker locker;
2685
+ * ...
2686
+ * // Code using V8 goes here.
2687
+ * ...
2688
+ * } // Destructor called here
2689
+ * \endcode
2690
+ *
2691
+ * If you wish to stop using V8 in a thread A you can do this by either
2692
+ * by destroying the v8::Locker object as above or by constructing a
2693
+ * v8::Unlocker object:
2694
+ *
2695
+ * \code
2696
+ * {
2697
+ * v8::Unlocker unlocker;
2698
+ * ...
2699
+ * // Code not using V8 goes here while V8 can run in another thread.
2700
+ * ...
2701
+ * } // Destructor called here.
2702
+ * \endcode
2703
+ *
2704
+ * The Unlocker object is intended for use in a long-running callback
2705
+ * from V8, where you want to release the V8 lock for other threads to
2706
+ * use.
2707
+ *
2708
+ * The v8::Locker is a recursive lock. That is, you can lock more than
2709
+ * once in a given thread. This can be useful if you have code that can
2710
+ * be called either from code that holds the lock or from code that does
2711
+ * not. The Unlocker is not recursive so you can not have several
2712
+ * Unlockers on the stack at once, and you can not use an Unlocker in a
2713
+ * thread that is not inside a Locker's scope.
2714
+ *
2715
+ * An unlocker will unlock several lockers if it has to and reinstate
2716
+ * the correct depth of locking on its destruction. eg.:
2717
+ *
2718
+ * \code
2719
+ * // V8 not locked.
2720
+ * {
2721
+ * v8::Locker locker;
2722
+ * // V8 locked.
2723
+ * {
2724
+ * v8::Locker another_locker;
2725
+ * // V8 still locked (2 levels).
2726
+ * {
2727
+ * v8::Unlocker unlocker;
2728
+ * // V8 not locked.
2729
+ * }
2730
+ * // V8 locked again (2 levels).
2731
+ * }
2732
+ * // V8 still locked (1 level).
2733
+ * }
2734
+ * // V8 Now no longer locked.
2735
+ * \endcode
2736
+ */
2737
+ class V8EXPORT Unlocker {
2738
+ public:
2739
+ Unlocker();
2740
+ ~Unlocker();
2741
+ };
2742
+
2743
+
2744
+ class V8EXPORT Locker {
2745
+ public:
2746
+ Locker();
2747
+ ~Locker();
2748
+
2749
+ /**
2750
+ * Start preemption.
2751
+ *
2752
+ * When preemption is started, a timer is fired every n milli seconds
2753
+ * that will switch between multiple threads that are in contention
2754
+ * for the V8 lock.
2755
+ */
2756
+ static void StartPreemption(int every_n_ms);
2757
+
2758
+ /**
2759
+ * Stop preemption.
2760
+ */
2761
+ static void StopPreemption();
2762
+
2763
+ /**
2764
+ * Returns whether or not the locker is locked by the current thread.
2765
+ */
2766
+ static bool IsLocked();
2767
+
2768
+ /**
2769
+ * Returns whether v8::Locker is being used by this V8 instance.
2770
+ */
2771
+ static bool IsActive() { return active_; }
2772
+
2773
+ private:
2774
+ bool has_lock_;
2775
+ bool top_level_;
2776
+
2777
+ static bool active_;
2778
+
2779
+ // Disallow copying and assigning.
2780
+ Locker(const Locker&);
2781
+ void operator=(const Locker&);
2782
+ };
2783
+
2784
+
2785
+
2786
+ // --- I m p l e m e n t a t i o n ---
2787
+
2788
+
2789
+ namespace internal {
2790
+
2791
+
2792
+ // Tag information for HeapObject.
2793
+ const int kHeapObjectTag = 1;
2794
+ const int kHeapObjectTagSize = 2;
2795
+ const intptr_t kHeapObjectTagMask = (1 << kHeapObjectTagSize) - 1;
2796
+
2797
+ // Tag information for Smi.
2798
+ const int kSmiTag = 0;
2799
+ const int kSmiTagSize = 1;
2800
+ const intptr_t kSmiTagMask = (1 << kSmiTagSize) - 1;
2801
+
2802
+ template <size_t ptr_size> struct SmiConstants;
2803
+
2804
+ // Smi constants for 32-bit systems.
2805
+ template <> struct SmiConstants<4> {
2806
+ static const int kSmiShiftSize = 0;
2807
+ static const int kSmiValueSize = 31;
2808
+ static inline int SmiToInt(internal::Object* value) {
2809
+ int shift_bits = kSmiTagSize + kSmiShiftSize;
2810
+ // Throw away top 32 bits and shift down (requires >> to be sign extending).
2811
+ return static_cast<int>(reinterpret_cast<intptr_t>(value)) >> shift_bits;
2812
+ }
2813
+ };
2814
+
2815
+ // Smi constants for 64-bit systems.
2816
+ template <> struct SmiConstants<8> {
2817
+ static const int kSmiShiftSize = 31;
2818
+ static const int kSmiValueSize = 32;
2819
+ static inline int SmiToInt(internal::Object* value) {
2820
+ int shift_bits = kSmiTagSize + kSmiShiftSize;
2821
+ // Shift down and throw away top 32 bits.
2822
+ return static_cast<int>(reinterpret_cast<intptr_t>(value) >> shift_bits);
2823
+ }
2824
+ };
2825
+
2826
+ const int kSmiShiftSize = SmiConstants<sizeof(void*)>::kSmiShiftSize;
2827
+ const int kSmiValueSize = SmiConstants<sizeof(void*)>::kSmiValueSize;
2828
+
2829
+ template <size_t ptr_size> struct InternalConstants;
2830
+
2831
+ // Internal constants for 32-bit systems.
2832
+ template <> struct InternalConstants<4> {
2833
+ static const int kStringResourceOffset = 3 * sizeof(void*);
2834
+ };
2835
+
2836
+ // Internal constants for 64-bit systems.
2837
+ template <> struct InternalConstants<8> {
2838
+ static const int kStringResourceOffset = 2 * sizeof(void*);
2839
+ };
2840
+
2841
+ /**
2842
+ * This class exports constants and functionality from within v8 that
2843
+ * is necessary to implement inline functions in the v8 api. Don't
2844
+ * depend on functions and constants defined here.
2845
+ */
2846
+ class Internals {
2847
+ public:
2848
+
2849
+ // These values match non-compiler-dependent values defined within
2850
+ // the implementation of v8.
2851
+ static const int kHeapObjectMapOffset = 0;
2852
+ static const int kMapInstanceTypeOffset = sizeof(void*) + sizeof(int);
2853
+ static const int kStringResourceOffset =
2854
+ InternalConstants<sizeof(void*)>::kStringResourceOffset;
2855
+
2856
+ static const int kProxyProxyOffset = sizeof(void*);
2857
+ static const int kJSObjectHeaderSize = 3 * sizeof(void*);
2858
+ static const int kFullStringRepresentationMask = 0x07;
2859
+ static const int kExternalTwoByteRepresentationTag = 0x03;
2860
+
2861
+ // These constants are compiler dependent so their values must be
2862
+ // defined within the implementation.
2863
+ V8EXPORT static int kJSObjectType;
2864
+ V8EXPORT static int kFirstNonstringType;
2865
+ V8EXPORT static int kProxyType;
2866
+
2867
+ static inline bool HasHeapObjectTag(internal::Object* value) {
2868
+ return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) ==
2869
+ kHeapObjectTag);
2870
+ }
2871
+
2872
+ static inline bool HasSmiTag(internal::Object* value) {
2873
+ return ((reinterpret_cast<intptr_t>(value) & kSmiTagMask) == kSmiTag);
2874
+ }
2875
+
2876
+ static inline int SmiValue(internal::Object* value) {
2877
+ return SmiConstants<sizeof(void*)>::SmiToInt(value);
2878
+ }
2879
+
2880
+ static inline int GetInstanceType(internal::Object* obj) {
2881
+ typedef internal::Object O;
2882
+ O* map = ReadField<O*>(obj, kHeapObjectMapOffset);
2883
+ return ReadField<uint8_t>(map, kMapInstanceTypeOffset);
2884
+ }
2885
+
2886
+ static inline void* GetExternalPointer(internal::Object* obj) {
2887
+ if (HasSmiTag(obj)) {
2888
+ return obj;
2889
+ } else if (GetInstanceType(obj) == kProxyType) {
2890
+ return ReadField<void*>(obj, kProxyProxyOffset);
2891
+ } else {
2892
+ return NULL;
2893
+ }
2894
+ }
2895
+
2896
+ static inline bool IsExternalTwoByteString(int instance_type) {
2897
+ int representation = (instance_type & kFullStringRepresentationMask);
2898
+ return representation == kExternalTwoByteRepresentationTag;
2899
+ }
2900
+
2901
+ template <typename T>
2902
+ static inline T ReadField(Object* ptr, int offset) {
2903
+ uint8_t* addr = reinterpret_cast<uint8_t*>(ptr) + offset - kHeapObjectTag;
2904
+ return *reinterpret_cast<T*>(addr);
2905
+ }
2906
+
2907
+ };
2908
+
2909
+ }
2910
+
2911
+
2912
+ template <class T>
2913
+ Handle<T>::Handle() : val_(0) { }
2914
+
2915
+
2916
+ template <class T>
2917
+ Local<T>::Local() : Handle<T>() { }
2918
+
2919
+
2920
+ template <class T>
2921
+ Local<T> Local<T>::New(Handle<T> that) {
2922
+ if (that.IsEmpty()) return Local<T>();
2923
+ internal::Object** p = reinterpret_cast<internal::Object**>(*that);
2924
+ return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(*p)));
2925
+ }
2926
+
2927
+
2928
+ template <class T>
2929
+ Persistent<T> Persistent<T>::New(Handle<T> that) {
2930
+ if (that.IsEmpty()) return Persistent<T>();
2931
+ internal::Object** p = reinterpret_cast<internal::Object**>(*that);
2932
+ return Persistent<T>(reinterpret_cast<T*>(V8::GlobalizeReference(p)));
2933
+ }
2934
+
2935
+
2936
+ template <class T>
2937
+ bool Persistent<T>::IsNearDeath() const {
2938
+ if (this->IsEmpty()) return false;
2939
+ return V8::IsGlobalNearDeath(reinterpret_cast<internal::Object**>(**this));
2940
+ }
2941
+
2942
+
2943
+ template <class T>
2944
+ bool Persistent<T>::IsWeak() const {
2945
+ if (this->IsEmpty()) return false;
2946
+ return V8::IsGlobalWeak(reinterpret_cast<internal::Object**>(**this));
2947
+ }
2948
+
2949
+
2950
+ template <class T>
2951
+ void Persistent<T>::Dispose() {
2952
+ if (this->IsEmpty()) return;
2953
+ V8::DisposeGlobal(reinterpret_cast<internal::Object**>(**this));
2954
+ }
2955
+
2956
+
2957
+ template <class T>
2958
+ Persistent<T>::Persistent() : Handle<T>() { }
2959
+
2960
+ template <class T>
2961
+ void Persistent<T>::MakeWeak(void* parameters, WeakReferenceCallback callback) {
2962
+ V8::MakeWeak(reinterpret_cast<internal::Object**>(**this),
2963
+ parameters,
2964
+ callback);
2965
+ }
2966
+
2967
+ template <class T>
2968
+ void Persistent<T>::ClearWeak() {
2969
+ V8::ClearWeak(reinterpret_cast<internal::Object**>(**this));
2970
+ }
2971
+
2972
+ Local<Value> Arguments::operator[](int i) const {
2973
+ if (i < 0 || length_ <= i) return Local<Value>(*Undefined());
2974
+ return Local<Value>(reinterpret_cast<Value*>(values_ - i));
2975
+ }
2976
+
2977
+
2978
+ Local<Function> Arguments::Callee() const {
2979
+ return callee_;
2980
+ }
2981
+
2982
+
2983
+ Local<Object> Arguments::This() const {
2984
+ return Local<Object>(reinterpret_cast<Object*>(values_ + 1));
2985
+ }
2986
+
2987
+
2988
+ Local<Object> Arguments::Holder() const {
2989
+ return holder_;
2990
+ }
2991
+
2992
+
2993
+ Local<Value> Arguments::Data() const {
2994
+ return data_;
2995
+ }
2996
+
2997
+
2998
+ bool Arguments::IsConstructCall() const {
2999
+ return is_construct_call_;
3000
+ }
3001
+
3002
+
3003
+ int Arguments::Length() const {
3004
+ return length_;
3005
+ }
3006
+
3007
+
3008
+ template <class T>
3009
+ Local<T> HandleScope::Close(Handle<T> value) {
3010
+ internal::Object** before = reinterpret_cast<internal::Object**>(*value);
3011
+ internal::Object** after = RawClose(before);
3012
+ return Local<T>(reinterpret_cast<T*>(after));
3013
+ }
3014
+
3015
+ Handle<Value> ScriptOrigin::ResourceName() const {
3016
+ return resource_name_;
3017
+ }
3018
+
3019
+
3020
+ Handle<Integer> ScriptOrigin::ResourceLineOffset() const {
3021
+ return resource_line_offset_;
3022
+ }
3023
+
3024
+
3025
+ Handle<Integer> ScriptOrigin::ResourceColumnOffset() const {
3026
+ return resource_column_offset_;
3027
+ }
3028
+
3029
+
3030
+ Handle<Boolean> Boolean::New(bool value) {
3031
+ return value ? True() : False();
3032
+ }
3033
+
3034
+
3035
+ void Template::Set(const char* name, v8::Handle<Data> value) {
3036
+ Set(v8::String::New(name), value);
3037
+ }
3038
+
3039
+
3040
+ Local<Value> Object::GetInternalField(int index) {
3041
+ #ifndef V8_ENABLE_CHECKS
3042
+ Local<Value> quick_result = UncheckedGetInternalField(index);
3043
+ if (!quick_result.IsEmpty()) return quick_result;
3044
+ #endif
3045
+ return CheckedGetInternalField(index);
3046
+ }
3047
+
3048
+
3049
+ Local<Value> Object::UncheckedGetInternalField(int index) {
3050
+ typedef internal::Object O;
3051
+ typedef internal::Internals I;
3052
+ O* obj = *reinterpret_cast<O**>(this);
3053
+ if (I::GetInstanceType(obj) == I::kJSObjectType) {
3054
+ // If the object is a plain JSObject, which is the common case,
3055
+ // we know where to find the internal fields and can return the
3056
+ // value directly.
3057
+ int offset = I::kJSObjectHeaderSize + (sizeof(void*) * index);
3058
+ O* value = I::ReadField<O*>(obj, offset);
3059
+ O** result = HandleScope::CreateHandle(value);
3060
+ return Local<Value>(reinterpret_cast<Value*>(result));
3061
+ } else {
3062
+ return Local<Value>();
3063
+ }
3064
+ }
3065
+
3066
+
3067
+ void* External::Unwrap(Handle<v8::Value> obj) {
3068
+ #ifdef V8_ENABLE_CHECKS
3069
+ return FullUnwrap(obj);
3070
+ #else
3071
+ return QuickUnwrap(obj);
3072
+ #endif
3073
+ }
3074
+
3075
+
3076
+ void* External::QuickUnwrap(Handle<v8::Value> wrapper) {
3077
+ typedef internal::Object O;
3078
+ O* obj = *reinterpret_cast<O**>(const_cast<v8::Value*>(*wrapper));
3079
+ return internal::Internals::GetExternalPointer(obj);
3080
+ }
3081
+
3082
+
3083
+ void* Object::GetPointerFromInternalField(int index) {
3084
+ typedef internal::Object O;
3085
+ typedef internal::Internals I;
3086
+
3087
+ O* obj = *reinterpret_cast<O**>(this);
3088
+
3089
+ if (I::GetInstanceType(obj) == I::kJSObjectType) {
3090
+ // If the object is a plain JSObject, which is the common case,
3091
+ // we know where to find the internal fields and can return the
3092
+ // value directly.
3093
+ int offset = I::kJSObjectHeaderSize + (sizeof(void*) * index);
3094
+ O* value = I::ReadField<O*>(obj, offset);
3095
+ return I::GetExternalPointer(value);
3096
+ }
3097
+
3098
+ return SlowGetPointerFromInternalField(index);
3099
+ }
3100
+
3101
+
3102
+ String* String::Cast(v8::Value* value) {
3103
+ #ifdef V8_ENABLE_CHECKS
3104
+ CheckCast(value);
3105
+ #endif
3106
+ return static_cast<String*>(value);
3107
+ }
3108
+
3109
+
3110
+ String::ExternalStringResource* String::GetExternalStringResource() const {
3111
+ typedef internal::Object O;
3112
+ typedef internal::Internals I;
3113
+ O* obj = *reinterpret_cast<O**>(const_cast<String*>(this));
3114
+ String::ExternalStringResource* result;
3115
+ if (I::IsExternalTwoByteString(I::GetInstanceType(obj))) {
3116
+ void* value = I::ReadField<void*>(obj, I::kStringResourceOffset);
3117
+ result = reinterpret_cast<String::ExternalStringResource*>(value);
3118
+ } else {
3119
+ result = NULL;
3120
+ }
3121
+ #ifdef V8_ENABLE_CHECKS
3122
+ VerifyExternalStringResource(result);
3123
+ #endif
3124
+ return result;
3125
+ }
3126
+
3127
+
3128
+ bool Value::IsString() const {
3129
+ #ifdef V8_ENABLE_CHECKS
3130
+ return FullIsString();
3131
+ #else
3132
+ return QuickIsString();
3133
+ #endif
3134
+ }
3135
+
3136
+ bool Value::QuickIsString() const {
3137
+ typedef internal::Object O;
3138
+ typedef internal::Internals I;
3139
+ O* obj = *reinterpret_cast<O**>(const_cast<Value*>(this));
3140
+ if (!I::HasHeapObjectTag(obj)) return false;
3141
+ return (I::GetInstanceType(obj) < I::kFirstNonstringType);
3142
+ }
3143
+
3144
+
3145
+ Number* Number::Cast(v8::Value* value) {
3146
+ #ifdef V8_ENABLE_CHECKS
3147
+ CheckCast(value);
3148
+ #endif
3149
+ return static_cast<Number*>(value);
3150
+ }
3151
+
3152
+
3153
+ Integer* Integer::Cast(v8::Value* value) {
3154
+ #ifdef V8_ENABLE_CHECKS
3155
+ CheckCast(value);
3156
+ #endif
3157
+ return static_cast<Integer*>(value);
3158
+ }
3159
+
3160
+
3161
+ Date* Date::Cast(v8::Value* value) {
3162
+ #ifdef V8_ENABLE_CHECKS
3163
+ CheckCast(value);
3164
+ #endif
3165
+ return static_cast<Date*>(value);
3166
+ }
3167
+
3168
+
3169
+ Object* Object::Cast(v8::Value* value) {
3170
+ #ifdef V8_ENABLE_CHECKS
3171
+ CheckCast(value);
3172
+ #endif
3173
+ return static_cast<Object*>(value);
3174
+ }
3175
+
3176
+
3177
+ Array* Array::Cast(v8::Value* value) {
3178
+ #ifdef V8_ENABLE_CHECKS
3179
+ CheckCast(value);
3180
+ #endif
3181
+ return static_cast<Array*>(value);
3182
+ }
3183
+
3184
+
3185
+ Function* Function::Cast(v8::Value* value) {
3186
+ #ifdef V8_ENABLE_CHECKS
3187
+ CheckCast(value);
3188
+ #endif
3189
+ return static_cast<Function*>(value);
3190
+ }
3191
+
3192
+
3193
+ External* External::Cast(v8::Value* value) {
3194
+ #ifdef V8_ENABLE_CHECKS
3195
+ CheckCast(value);
3196
+ #endif
3197
+ return static_cast<External*>(value);
3198
+ }
3199
+
3200
+
3201
+ Local<Value> AccessorInfo::Data() const {
3202
+ return Local<Value>(reinterpret_cast<Value*>(&args_[-3]));
3203
+ }
3204
+
3205
+
3206
+ Local<Object> AccessorInfo::This() const {
3207
+ return Local<Object>(reinterpret_cast<Object*>(&args_[0]));
3208
+ }
3209
+
3210
+
3211
+ Local<Object> AccessorInfo::Holder() const {
3212
+ return Local<Object>(reinterpret_cast<Object*>(&args_[-1]));
3213
+ }
3214
+
3215
+
3216
+ /**
3217
+ * \example shell.cc
3218
+ * A simple shell that takes a list of expressions on the
3219
+ * command-line and executes them.
3220
+ */
3221
+
3222
+
3223
+ /**
3224
+ * \example process.cc
3225
+ */
3226
+
3227
+
3228
+ } // namespace v8
3229
+
3230
+
3231
+ #undef V8EXPORT
3232
+ #undef V8EXPORT_INLINE
3233
+ #undef TYPE_CHECK
3234
+
3235
+
3236
+ #endif // V8_H_