You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1854 lines
71 KiB

  1. diff --git a/.travis.yml b/.travis.yml
  2. index 32c6656dd2..6530d2cb5f 100644
  3. --- a/.travis.yml
  4. +++ b/.travis.yml
  5. @@ -89,27 +89,17 @@ matrix:
  6. dist: xenial
  7. - compiler: gcc
  8. os: linux
  9. - env: SWIGLANG=javascript ENGINE=node VER=0.10
  10. - sudo: required
  11. - dist: xenial
  12. - - compiler: gcc
  13. - os: linux
  14. - env: SWIGLANG=javascript ENGINE=node VER=4 CPP11=1
  15. - sudo: required
  16. - dist: xenial
  17. - - compiler: gcc
  18. - os: linux
  19. - env: SWIGLANG=javascript ENGINE=node VER=6 CPP11=1
  20. + env: SWIGLANG=javascript ENGINE=node VER=10 CPP11=1
  21. sudo: required
  22. dist: xenial
  23. - compiler: gcc
  24. os: linux
  25. - env: SWIGLANG=javascript ENGINE=node VER=8 CPP11=1
  26. + env: SWIGLANG=javascript ENGINE=node VER=12 CPP11=1
  27. sudo: required
  28. dist: xenial
  29. - compiler: gcc
  30. os: linux
  31. - env: SWIGLANG=javascript ENGINE=node VER=10 CPP11=1
  32. + env: SWIGLANG=javascript ENGINE=node VER=13 CPP11=1
  33. sudo: required
  34. dist: xenial
  35. - compiler: gcc
  36. @@ -117,11 +107,6 @@ matrix:
  37. env: SWIGLANG=javascript ENGINE=jsc
  38. sudo: required
  39. dist: xenial
  40. - - compiler: gcc
  41. - os: linux
  42. - env: SWIGLANG=javascript ENGINE=v8
  43. - sudo: required
  44. - dist: xenial
  45. - compiler: gcc
  46. os: linux
  47. env: SWIGLANG=lua
  48. diff --git a/Examples/Makefile.in b/Examples/Makefile.in
  49. index 6fbca29db5..dadb012bf9 100644
  50. --- a/Examples/Makefile.in
  51. +++ b/Examples/Makefile.in
  52. @@ -674,8 +674,8 @@ java_clean:
  53. # create a configuration for a new example.
  54. ROOT_DIR = @ROOT_DIR@
  55. -JSINCLUDES = @JSCOREINC@ @JSV8INC@
  56. -JSDYNAMICLINKING = @JSCOREDYNAMICLINKING@ @JSV8DYNAMICLINKING@
  57. +JSINCLUDES = @JSCOREINC@
  58. +JSDYNAMICLINKING = @JSCOREDYNAMICLINKING@
  59. NODEJS = @NODEJS@
  60. NODEGYP = @NODEGYP@
  61. @@ -710,7 +710,7 @@ javascript: $(SRCDIR_SRCS) javascript_custom_interpreter
  62. ifeq (jsc, $(ENGINE))
  63. $(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(ISRCS) $(SRCDIR_SRCS) $(INCLUDES) $(JSINCLUDES)
  64. $(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(JSDYNAMICLINKING) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
  65. -else # (v8 | node) # v8 and node must be compiled as c++
  66. +else # (node) # node must be compiled as c++
  67. $(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ISRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) $(JSINCLUDES)
  68. $(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(JSDYNAMICLINKING) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
  69. endif
  70. @@ -759,9 +759,6 @@ ifeq (jsc, $(ENGINE))
  71. echo "Unknown JavascriptCore version."; \
  72. fi
  73. endif
  74. -ifeq (v8, $(ENGINE))
  75. - echo "Unknown v8 version."
  76. -endif
  77. # -----------------------------------------------------------------
  78. # Cleaning the Javascript examples
  79. diff --git a/Examples/javascript/example.mk b/Examples/javascript/example.mk
  80. index 3ef012aa82..beafd6f3fb 100644
  81. --- a/Examples/javascript/example.mk
  82. +++ b/Examples/javascript/example.mk
  83. @@ -7,19 +7,13 @@ else
  84. JSENGINE=node
  85. endif
  86. -ifneq (, $(V8_VERSION))
  87. - JSV8_VERSION=$(V8_VERSION)
  88. -else
  89. - JSV8_VERSION=0x031110
  90. -endif
  91. -
  92. EXAMPLES_TOP = ../..
  93. SWIG_TOP = ../../..
  94. SWIGEXE = $(SWIG_TOP)/swig
  95. SWIG_LIB_DIR = $(SWIG_TOP)/$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
  96. TARGET = example
  97. INTERFACE = example.i
  98. -SWIGOPT = -$(JSENGINE) -DV8_VERSION=$(JSV8_VERSION)
  99. +SWIGOPT = -$(JSENGINE)
  100. check: build
  101. $(MAKE) -f $(EXAMPLES_TOP)/Makefile SRCDIR='$(SRCDIR)' JSENGINE='$(JSENGINE)' TARGET='$(TARGET)' javascript_run
  102. diff --git a/Examples/javascript/native/example.i b/Examples/javascript/native/example.i
  103. index 8c61600606..e94f18118b 100644
  104. --- a/Examples/javascript/native/example.i
  105. +++ b/Examples/javascript/native/example.i
  106. @@ -15,7 +15,7 @@ int placeholder() { return 0; }
  107. static SwigV8ReturnValue JavaScript_do_work(const SwigV8Arguments &args) {
  108. SWIGV8_HANDLESCOPE();
  109. const int MY_MAGIC_NUMBER = 5;
  110. - v8::Handle<v8::Value> jsresult =
  111. + v8::Local<v8::Value> jsresult =
  112. SWIG_From_int(static_cast< int >(MY_MAGIC_NUMBER));
  113. if (args.Length() != 0)
  114. SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments.");
  115. diff --git a/Examples/test-suite/javascript/Makefile.in b/Examples/test-suite/javascript/Makefile.in
  116. index 8127415f12..ce16f2ec0d 100644
  117. --- a/Examples/test-suite/javascript/Makefile.in
  118. +++ b/Examples/test-suite/javascript/Makefile.in
  119. @@ -22,16 +22,8 @@ else
  120. JSENGINE=node
  121. endif
  122. -ifneq (, $(V8_VERSION))
  123. - JSV8_VERSION=$(V8_VERSION)
  124. -else
  125. - JSV8_VERSION=0x031110
  126. -endif
  127. -
  128. include $(srcdir)/../common.mk
  129. -SWIGOPT += -DV8_VERSION=$(JSV8_VERSION)
  130. -
  131. _setup = \
  132. if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
  133. echo "$(ACTION)ing $(LANGUAGE) ($(JSENGINE)) testcase $* (with run test)" ; \
  134. diff --git a/Examples/test-suite/native_directive.i b/Examples/test-suite/native_directive.i
  135. index 9ae76e0b7f..99089af507 100644
  136. --- a/Examples/test-suite/native_directive.i
  137. +++ b/Examples/test-suite/native_directive.i
  138. @@ -53,7 +53,7 @@ extern "C" JNIEXPORT jint JNICALL Java_native_1directive_native_1directiveJNI_Co
  139. static SwigV8ReturnValue JavaScript_alpha_count(const SwigV8Arguments &args) {
  140. SWIGV8_HANDLESCOPE();
  141. - v8::Handle<v8::Value> jsresult;
  142. + v8::Local<v8::Value> jsresult;
  143. char *arg1 = (char *)0;
  144. int res1;
  145. char *buf1 = 0;
  146. diff --git a/Lib/javascript/v8/javascriptcode.swg b/Lib/javascript/v8/javascriptcode.swg
  147. index c4aaf3db0c..b470e2aeeb 100644
  148. --- a/Lib/javascript/v8/javascriptcode.swg
  149. +++ b/Lib/javascript/v8/javascriptcode.swg
  150. @@ -11,7 +11,7 @@
  151. static SwigV8ReturnValue $jswrapper(const SwigV8Arguments &args) {
  152. SWIGV8_HANDLESCOPE();
  153. - v8::Handle<v8::Object> self = args.Holder();
  154. + v8::Local<v8::Object> self = args.Holder();
  155. $jslocals
  156. if(args.Length() != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper.");
  157. $jscode
  158. @@ -53,7 +53,7 @@ static SwigV8ReturnValue $jswrapper(const SwigV8Arguments &args) {
  159. SWIGV8_HANDLESCOPE();
  160. OverloadErrorHandler errorHandler;
  161. - v8::Handle<v8::Value> self;
  162. + v8::Local<v8::Value> self;
  163. // switch all cases by means of series of if-returns.
  164. $jsdispatchcases
  165. @@ -78,7 +78,7 @@ fail:
  166. static SwigV8ReturnValue $jswrapper(const SwigV8Arguments &args, V8ErrorHandler &SWIGV8_ErrorHandler) {
  167. SWIGV8_HANDLESCOPE();
  168. - v8::Handle<v8::Object> self = args.Holder();
  169. + v8::Local<v8::Object> self = args.Holder();
  170. $jslocals
  171. if(args.Length() != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper.");
  172. $jscode
  173. @@ -103,17 +103,10 @@ fail:
  174. %{
  175. if(args.Length() == $jsargcount) {
  176. errorHandler.err.Clear();
  177. -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903)
  178. - self = $jswrapper(args, errorHandler);
  179. - if(errorHandler.err.IsEmpty()) {
  180. - SWIGV8_ESCAPE(self);
  181. - }
  182. -#else
  183. $jswrapper(args, errorHandler);
  184. if(errorHandler.err.IsEmpty()) {
  185. return;
  186. }
  187. -#endif
  188. }
  189. %}
  190. @@ -124,23 +117,8 @@ fail:
  191. * ----------------------------------------------------------------------------- */
  192. %fragment ("js_dtor", "templates")
  193. %{
  194. -
  195. -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
  196. -static void $jswrapper(v8::Persistent< v8::Value > object, void *parameter) {
  197. - SWIGV8_Proxy *proxy = static_cast<SWIGV8_Proxy *>(parameter);
  198. -#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900)
  199. -static void $jswrapper(v8::Isolate *isolate, v8::Persistent<v8::Value> object, void *parameter) {
  200. - SWIGV8_Proxy *proxy = static_cast<SWIGV8_Proxy *>(parameter);
  201. -#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
  202. -static void $jswrapper(v8::Isolate *isolate, v8::Persistent<v8::Object> *object, SWIGV8_Proxy *proxy) {
  203. -#elif (V8_MAJOR_VERSION-0) < 5
  204. -static void $jswrapper(const v8::WeakCallbackData<v8::Object, SWIGV8_Proxy> &data) {
  205. - v8::Local<v8::Object> object = data.GetValue();
  206. - SWIGV8_Proxy *proxy = data.GetParameter();
  207. -#else
  208. static void $jswrapper(const v8::WeakCallbackInfo<SWIGV8_Proxy> &data) {
  209. SWIGV8_Proxy *proxy = data.GetParameter();
  210. -#endif
  211. if(proxy->swigCMemOwn && proxy->swigCObject) {
  212. #ifdef SWIGRUNTIME_DEBUG
  213. @@ -149,20 +127,6 @@ static void $jswrapper(const v8::WeakCallbackData<v8::Object, SWIGV8_Proxy> &dat
  214. $jsfree proxy->swigCObject;
  215. }
  216. delete proxy;
  217. -
  218. -#if (V8_MAJOR_VERSION-0) < 5
  219. - object.Clear();
  220. -#endif
  221. -
  222. -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
  223. - object.Dispose();
  224. -#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900)
  225. - object.Dispose(isolate);
  226. -#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032100)
  227. - object->Dispose(isolate);
  228. -#elif (V8_MAJOR_VERSION-0) < 5
  229. - object->Dispose();
  230. -#endif
  231. }
  232. %}
  233. @@ -174,40 +138,14 @@ static void $jswrapper(const v8::WeakCallbackData<v8::Object, SWIGV8_Proxy> &dat
  234. * ----------------------------------------------------------------------------- */
  235. %fragment ("js_dtoroverride", "templates")
  236. %{
  237. -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
  238. -static void $jswrapper(v8::Persistent<v8::Value> object, void *parameter) {
  239. - SWIGV8_Proxy *proxy = static_cast<SWIGV8_Proxy *>(parameter);
  240. -#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900)
  241. -static void $jswrapper(v8::Isolate *isolate, v8::Persistent<v8::Value> object, void *parameter) {
  242. - SWIGV8_Proxy *proxy = static_cast<SWIGV8_Proxy *>(parameter);
  243. -#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
  244. -static void $jswrapper(v8::Isolate *isolate, v8::Persistent< v8::Object> *object, SWIGV8_Proxy *proxy) {
  245. -#elif (V8_MAJOR_VERSION-0) < 5
  246. -static void $jswrapper(const v8::WeakCallbackData<v8::Object, SWIGV8_Proxy> &data) {
  247. - v8::Local<v8::Object> object = data.GetValue();
  248. - SWIGV8_Proxy *proxy = data.GetParameter();
  249. -#else
  250. static void $jswrapper(const v8::WeakCallbackInfo<SWIGV8_Proxy> &data) {
  251. SWIGV8_Proxy *proxy = data.GetParameter();
  252. -#endif
  253. if(proxy->swigCMemOwn && proxy->swigCObject) {
  254. $jstype arg1 = ($jstype)proxy->swigCObject;
  255. ${destructor_action}
  256. }
  257. delete proxy;
  258. -
  259. -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
  260. - object.Dispose();
  261. -#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900)
  262. - object.Dispose(isolate);
  263. -#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032100)
  264. - object->Dispose(isolate);
  265. -#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
  266. - object->Dispose();
  267. -#elif (V8_MAJOR_VERSION-0) < 5
  268. - object.Clear();
  269. -#endif
  270. }
  271. %}
  272. @@ -219,14 +157,10 @@ static void $jswrapper(const v8::WeakCallbackInfo<SWIGV8_Proxy> &data) {
  273. * ----------------------------------------------------------------------------- */
  274. %fragment("js_getter", "templates")
  275. %{
  276. -#if (V8_MAJOR_VERSION-0) < 5
  277. -static SwigV8ReturnValue $jswrapper(v8::Local<v8::String> property, const SwigV8PropertyCallbackInfo &info) {
  278. -#else
  279. static SwigV8ReturnValue $jswrapper(v8::Local<v8::Name> property, const SwigV8PropertyCallbackInfo &info) {
  280. -#endif
  281. SWIGV8_HANDLESCOPE();
  282. - v8::Handle<v8::Value> jsresult;
  283. + v8::Local<v8::Value> jsresult;
  284. $jslocals
  285. $jscode
  286. SWIGV8_RETURN_INFO(jsresult, info);
  287. @@ -245,11 +179,7 @@ fail:
  288. * ----------------------------------------------------------------------------- */
  289. %fragment("js_setter", "templates")
  290. %{
  291. -#if (V8_MAJOR_VERSION-0) < 5
  292. -static void $jswrapper(v8::Local<v8::String> property, v8::Local<v8::Value> value, const SwigV8PropertyCallbackInfoVoid &info) {
  293. -#else
  294. static void $jswrapper(v8::Local<v8::Name> property, v8::Local<v8::Value> value, const SwigV8PropertyCallbackInfoVoid &info) {
  295. -#endif
  296. SWIGV8_HANDLESCOPE();
  297. $jslocals
  298. @@ -271,7 +201,7 @@ fail:
  299. static SwigV8ReturnValue $jswrapper(const SwigV8Arguments &args) {
  300. SWIGV8_HANDLESCOPE();
  301. - v8::Handle<v8::Value> jsresult;
  302. + v8::Local<v8::Value> jsresult;
  303. $jslocals
  304. if(args.Length() != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper.");
  305. @@ -296,7 +226,7 @@ fail:
  306. static SwigV8ReturnValue $jswrapper(const SwigV8Arguments &args) {
  307. SWIGV8_HANDLESCOPE();
  308. - v8::Handle<v8::Value> jsresult;
  309. + v8::Local<v8::Value> jsresult;
  310. OverloadErrorHandler errorHandler;
  311. $jscode
  312. @@ -320,7 +250,7 @@ static SwigV8ReturnValue $jswrapper(const SwigV8Arguments &args, V8ErrorHandler
  313. {
  314. SWIGV8_HANDLESCOPE();
  315. - v8::Handle<v8::Value> jsresult;
  316. + v8::Local<v8::Value> jsresult;
  317. $jslocals
  318. $jscode
  319. SWIGV8_RETURN(jsresult);
  320. @@ -342,17 +272,10 @@ fail:
  321. if(args.Length() == $jsargcount) {
  322. errorHandler.err.Clear();
  323. -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903)
  324. - jsresult = $jswrapper(args, errorHandler);
  325. - if(errorHandler.err.IsEmpty()) {
  326. - SWIGV8_ESCAPE(jsresult);
  327. - }
  328. -#else
  329. $jswrapper(args, errorHandler);
  330. if(errorHandler.err.IsEmpty()) {
  331. return;
  332. }
  333. -#endif
  334. }
  335. %}
  336. @@ -374,7 +297,7 @@ fail:
  337. %fragment("jsv8_define_class_template", "templates")
  338. %{
  339. /* Name: $jsmangledname, Type: $jsmangledtype, Dtor: $jsdtor */
  340. - v8::Handle<v8::FunctionTemplate> $jsmangledname_class = SWIGV8_CreateClassTemplate("$jsmangledname");
  341. + v8::Local<v8::FunctionTemplate> $jsmangledname_class = SWIGV8_CreateClassTemplate("$jsmangledname");
  342. SWIGV8_SET_CLASS_TEMPL($jsmangledname_clientData.class_templ, $jsmangledname_class);
  343. $jsmangledname_clientData.dtor = $jsdtor;
  344. if (SWIGTYPE_$jsmangledtype->clientdata == 0) {
  345. @@ -392,15 +315,11 @@ fail:
  346. %{
  347. if (SWIGTYPE_p$jsbaseclass->clientdata && !(static_cast<SWIGV8_ClientData *>(SWIGTYPE_p$jsbaseclass->clientdata)->class_templ.IsEmpty()))
  348. {
  349. -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903)
  350. - $jsmangledname_class->Inherit(static_cast<SWIGV8_ClientData *>(SWIGTYPE_p$jsbaseclass->clientdata)->class_templ);
  351. -#else
  352. $jsmangledname_class->Inherit(
  353. v8::Local<v8::FunctionTemplate>::New(
  354. v8::Isolate::GetCurrent(),
  355. static_cast<SWIGV8_ClientData *>(SWIGTYPE_p$jsbaseclass->clientdata)->class_templ)
  356. );
  357. -#endif
  358. #ifdef SWIGRUNTIME_DEBUG
  359. printf("Inheritance successful $jsmangledname $jsbaseclass\n");
  360. @@ -420,11 +339,10 @@ fail:
  361. %fragment("jsv8_create_class_instance", "templates")
  362. %{
  363. /* Class: $jsname ($jsmangledname) */
  364. - v8::Handle<v8::FunctionTemplate> $jsmangledname_class_0 = SWIGV8_CreateClassTemplate("$jsname");
  365. + v8::Local<v8::FunctionTemplate> $jsmangledname_class_0 = SWIGV8_CreateClassTemplate("$jsname");
  366. $jsmangledname_class_0->SetCallHandler($jsctor);
  367. $jsmangledname_class_0->Inherit($jsmangledname_class);
  368. - $jsmangledname_class_0->SetHiddenPrototype(true);
  369. - v8::Handle<v8::Object> $jsmangledname_obj = $jsmangledname_class_0->GetFunction();
  370. + v8::Local<v8::Object> $jsmangledname_obj = $jsmangledname_class_0->GetFunction(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked();
  371. %}
  372. /* -----------------------------------------------------------------------------
  373. @@ -435,7 +353,7 @@ fail:
  374. * ----------------------------------------------------------------------------- */
  375. %fragment("jsv8_register_class", "templates")
  376. %{
  377. - $jsparent_obj->Set(SWIGV8_SYMBOL_NEW("$jsname"), $jsmangledname_obj);
  378. + $jsparent_obj->Set(SWIGV8_CURRENT_CONTEXT(), SWIGV8_SYMBOL_NEW("$jsname"), $jsmangledname_obj);
  379. %}
  380. /* -----------------------------------------------------------------------------
  381. @@ -444,7 +362,7 @@ fail:
  382. * ----------------------------------------------------------------------------- */
  383. %fragment("jsv8_create_namespace", "templates")
  384. %{
  385. - v8::Handle<v8::Object> $jsmangledname_obj = SWIGV8_OBJECT_NEW();
  386. + v8::Local<v8::Object> $jsmangledname_obj = SWIGV8_OBJECT_NEW();
  387. %}
  388. /* -----------------------------------------------------------------------------
  389. @@ -455,7 +373,7 @@ fail:
  390. * ----------------------------------------------------------------------------- */
  391. %fragment("jsv8_register_namespace", "templates")
  392. %{
  393. - $jsparent_obj->Set(SWIGV8_SYMBOL_NEW("$jsname"), $jsmangledname_obj);
  394. + $jsparent_obj->Set(SWIGV8_CURRENT_CONTEXT(), SWIGV8_SYMBOL_NEW("$jsname"), $jsmangledname_obj);
  395. %}
  396. /* -----------------------------------------------------------------------------
  397. diff --git a/Lib/javascript/v8/javascriptcomplex.swg b/Lib/javascript/v8/javascriptcomplex.swg
  398. index d3b4aaffa6..533e548131 100644
  399. --- a/Lib/javascript/v8/javascriptcomplex.swg
  400. +++ b/Lib/javascript/v8/javascriptcomplex.swg
  401. @@ -12,7 +12,7 @@
  402. %fragment(SWIG_From_frag(Type),"header",
  403. fragment=SWIG_From_frag(double))
  404. {
  405. -SWIGINTERNINLINE v8::Handle<v8::Value>
  406. +SWIGINTERNINLINE v8::Local<v8::Value>
  407. SWIG_From_dec(Type)(%ifcplusplus(const Type&, Type) c)
  408. {
  409. SWIGV8_HANDLESCOPE_ESC();
  410. @@ -32,12 +32,12 @@ SWIG_From_dec(Type)(%ifcplusplus(const Type&, Type) c)
  411. fragment=SWIG_AsVal_frag(double))
  412. {
  413. SWIGINTERN int
  414. -SWIG_AsVal_dec(Type) (v8::Handle<v8::Value> o, Type* val)
  415. +SWIG_AsVal_dec(Type) (v8::Local<v8::Value> o, Type* val)
  416. {
  417. SWIGV8_HANDLESCOPE();
  418. if (o->IsArray()) {
  419. - v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(o);
  420. + v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(o);
  421. if(array->Length() != 2) SWIG_Error(SWIG_TypeError, "Illegal argument for complex: must be array[2].");
  422. double re, im;
  423. @@ -74,12 +74,12 @@ SWIG_AsVal_dec(Type) (v8::Handle<v8::Value> o, Type* val)
  424. %fragment(SWIG_AsVal_frag(Type),"header",
  425. fragment=SWIG_AsVal_frag(float)) {
  426. SWIGINTERN int
  427. -SWIG_AsVal_dec(Type) (v8::Handle<v8::Value> o, Type* val)
  428. +SWIG_AsVal_dec(Type) (v8::Local<v8::Value> o, Type* val)
  429. {
  430. SWIGV8_HANDLESCOPE();
  431. if (o->IsArray()) {
  432. - v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(o);
  433. + v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(o);
  434. if(array->Length() != 2) SWIG_Error(SWIG_TypeError, "Illegal argument for complex: must be array[2].");
  435. double re, im;
  436. diff --git a/Lib/javascript/v8/javascripthelpers.swg b/Lib/javascript/v8/javascripthelpers.swg
  437. index 80fbd7aa1a..d722581552 100644
  438. --- a/Lib/javascript/v8/javascripthelpers.swg
  439. +++ b/Lib/javascript/v8/javascripthelpers.swg
  440. @@ -1,39 +1,26 @@
  441. %insert(runtime) %{
  442. -// Note: since 3.19 there are new CallBack types, since 03.21.9 the old ones have been removed
  443. -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903)
  444. -typedef v8::InvocationCallback SwigV8FunctionCallback;
  445. -typedef v8::AccessorGetter SwigV8AccessorGetterCallback;
  446. -typedef v8::AccessorSetter SwigV8AccessorSetterCallback;
  447. -typedef v8::AccessorInfo SwigV8PropertyCallbackInfoVoid;
  448. -#elif (V8_MAJOR_VERSION-0) < 5
  449. -typedef v8::FunctionCallback SwigV8FunctionCallback;
  450. -typedef v8::AccessorGetterCallback SwigV8AccessorGetterCallback;
  451. -typedef v8::AccessorSetterCallback SwigV8AccessorSetterCallback;
  452. -typedef v8::PropertyCallbackInfo<void> SwigV8PropertyCallbackInfoVoid;
  453. -#else
  454. typedef v8::FunctionCallback SwigV8FunctionCallback;
  455. typedef v8::AccessorNameGetterCallback SwigV8AccessorGetterCallback;
  456. typedef v8::AccessorNameSetterCallback SwigV8AccessorSetterCallback;
  457. typedef v8::PropertyCallbackInfo<void> SwigV8PropertyCallbackInfoVoid;
  458. -#endif
  459. /**
  460. * Creates a class template for a class with specified initialization function.
  461. */
  462. -SWIGRUNTIME v8::Handle<v8::FunctionTemplate> SWIGV8_CreateClassTemplate(const char* symbol) {
  463. +SWIGRUNTIME v8::Local<v8::FunctionTemplate> SWIGV8_CreateClassTemplate(const char* symbol) {
  464. SWIGV8_HANDLESCOPE_ESC();
  465. v8::Local<v8::FunctionTemplate> class_templ = SWIGV8_FUNCTEMPLATE_NEW_VOID();
  466. class_templ->SetClassName(SWIGV8_SYMBOL_NEW(symbol));
  467. - v8::Handle<v8::ObjectTemplate> inst_templ = class_templ->InstanceTemplate();
  468. + v8::Local<v8::ObjectTemplate> inst_templ = class_templ->InstanceTemplate();
  469. inst_templ->SetInternalFieldCount(1);
  470. - v8::Handle<v8::ObjectTemplate> equals_templ = class_templ->PrototypeTemplate();
  471. + v8::Local<v8::ObjectTemplate> equals_templ = class_templ->PrototypeTemplate();
  472. equals_templ->Set(SWIGV8_SYMBOL_NEW("equals"), SWIGV8_FUNCTEMPLATE_NEW(_SWIGV8_wrap_equals));
  473. - v8::Handle<v8::ObjectTemplate> cptr_templ = class_templ->PrototypeTemplate();
  474. + v8::Local<v8::ObjectTemplate> cptr_templ = class_templ->PrototypeTemplate();
  475. cptr_templ->Set(SWIGV8_SYMBOL_NEW("getCPtr"), SWIGV8_FUNCTEMPLATE_NEW(_wrap_getCPtr));
  476. SWIGV8_ESCAPE(class_templ);
  477. @@ -42,55 +29,47 @@ SWIGRUNTIME v8::Handle<v8::FunctionTemplate> SWIGV8_CreateClassTemplate(const ch
  478. /**
  479. * Registers a class method with given name for a given class template.
  480. */
  481. -SWIGRUNTIME void SWIGV8_AddMemberFunction(v8::Handle<v8::FunctionTemplate> class_templ, const char* symbol,
  482. +SWIGRUNTIME void SWIGV8_AddMemberFunction(v8::Local<v8::FunctionTemplate> class_templ, const char* symbol,
  483. SwigV8FunctionCallback _func) {
  484. - v8::Handle<v8::ObjectTemplate> proto_templ = class_templ->PrototypeTemplate();
  485. + v8::Local<v8::ObjectTemplate> proto_templ = class_templ->PrototypeTemplate();
  486. proto_templ->Set(SWIGV8_SYMBOL_NEW(symbol), SWIGV8_FUNCTEMPLATE_NEW(_func));
  487. }
  488. /**
  489. * Registers a class property with given name for a given class template.
  490. */
  491. -SWIGRUNTIME void SWIGV8_AddMemberVariable(v8::Handle<v8::FunctionTemplate> class_templ, const char* symbol,
  492. +SWIGRUNTIME void SWIGV8_AddMemberVariable(v8::Local<v8::FunctionTemplate> class_templ, const char* symbol,
  493. SwigV8AccessorGetterCallback getter, SwigV8AccessorSetterCallback setter) {
  494. - v8::Handle<v8::ObjectTemplate> proto_templ = class_templ->InstanceTemplate();
  495. + v8::Local<v8::ObjectTemplate> proto_templ = class_templ->InstanceTemplate();
  496. proto_templ->SetAccessor(SWIGV8_SYMBOL_NEW(symbol), getter, setter);
  497. }
  498. /**
  499. * Registers a class method with given name for a given object.
  500. */
  501. -SWIGRUNTIME void SWIGV8_AddStaticFunction(v8::Handle<v8::Object> obj, const char* symbol,
  502. +SWIGRUNTIME void SWIGV8_AddStaticFunction(v8::Local<v8::Object> obj, const char* symbol,
  503. const SwigV8FunctionCallback& _func) {
  504. - obj->Set(SWIGV8_SYMBOL_NEW(symbol), SWIGV8_FUNCTEMPLATE_NEW(_func)->GetFunction());
  505. +#if (NODE_MODULE_VERSION < 72)
  506. + obj->Set(SWIGV8_SYMBOL_NEW(symbol), SWIGV8_FUNCTEMPLATE_NEW(_func)->GetFunction(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked());
  507. +#else
  508. + obj->Set(SWIGV8_CURRENT_CONTEXT(), SWIGV8_SYMBOL_NEW(symbol), SWIGV8_FUNCTEMPLATE_NEW(_func)->GetFunction(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked());
  509. +#endif
  510. }
  511. /**
  512. * Registers a class method with given name for a given object.
  513. */
  514. -SWIGRUNTIME void SWIGV8_AddStaticVariable(v8::Handle<v8::Object> obj, const char* symbol,
  515. +SWIGRUNTIME void SWIGV8_AddStaticVariable(v8::Local<v8::Object> obj, const char* symbol,
  516. SwigV8AccessorGetterCallback getter, SwigV8AccessorSetterCallback setter) {
  517. -#if (V8_MAJOR_VERSION-0) < 5
  518. - obj->SetAccessor(SWIGV8_SYMBOL_NEW(symbol), getter, setter);
  519. -#else
  520. obj->SetAccessor(SWIGV8_CURRENT_CONTEXT(), SWIGV8_SYMBOL_NEW(symbol), getter, setter);
  521. -#endif
  522. }
  523. -#if (V8_MAJOR_VERSION-0) < 5
  524. -SWIGRUNTIME void JS_veto_set_variable(v8::Local<v8::String> property, v8::Local<v8::Value> value, const SwigV8PropertyCallbackInfoVoid& info)
  525. -#else
  526. SWIGRUNTIME void JS_veto_set_variable(v8::Local<v8::Name> property, v8::Local<v8::Value> value, const SwigV8PropertyCallbackInfoVoid& info)
  527. -#endif
  528. {
  529. char buffer[256];
  530. char msg[512];
  531. int res;
  532. -#if (V8_MAJOR_VERSION-0) < 5
  533. - property->WriteUtf8(buffer, 256);
  534. - res = sprintf(msg, "Tried to write read-only variable: %s.", buffer);
  535. -#else
  536. v8::Local<v8::String> sproperty;
  537. if (property->ToString(SWIGV8_CURRENT_CONTEXT()).ToLocal(&sproperty)) {
  538. SWIGV8_WRITE_UTF8(sproperty, buffer, 256);
  539. @@ -99,7 +78,6 @@ SWIGRUNTIME void JS_veto_set_variable(v8::Local<v8::Name> property, v8::Local<v8
  540. else {
  541. res = -1;
  542. }
  543. -#endif
  544. if(res<0) {
  545. SWIG_exception(SWIG_ERROR, "Tried to write read-only variable.");
  546. diff --git a/Lib/javascript/v8/javascriptinit.swg b/Lib/javascript/v8/javascriptinit.swg
  547. index 8faf2dd8e1..5f6c219dcc 100644
  548. --- a/Lib/javascript/v8/javascriptinit.swg
  549. +++ b/Lib/javascript/v8/javascriptinit.swg
  550. @@ -68,16 +68,16 @@ SWIG_V8_GetModule(void *) {
  551. // TODO: is it ok to do that?
  552. extern "C"
  553. #if (NODE_MODULE_VERSION < 0x000C)
  554. -void SWIGV8_INIT (v8::Handle<v8::Object> exports)
  555. +void SWIGV8_INIT (v8::Local<v8::Object> exports)
  556. #else
  557. -void SWIGV8_INIT (v8::Handle<v8::Object> exports, v8::Handle<v8::Object> /*module*/)
  558. +void SWIGV8_INIT (v8::Local<v8::Object> exports, v8::Local<v8::Object> /*module*/)
  559. #endif
  560. {
  561. SWIG_InitializeModule(static_cast<void *>(&exports));
  562. SWIGV8_HANDLESCOPE();
  563. - v8::Handle<v8::Object> exports_obj = exports;
  564. + v8::Local<v8::Object> exports_obj = exports;
  565. %}
  566. diff --git a/Lib/javascript/v8/javascriptprimtypes.swg b/Lib/javascript/v8/javascriptprimtypes.swg
  567. index f76be983b1..41635e9d2d 100644
  568. --- a/Lib/javascript/v8/javascriptprimtypes.swg
  569. +++ b/Lib/javascript/v8/javascriptprimtypes.swg
  570. @@ -6,7 +6,7 @@
  571. %fragment(SWIG_From_frag(bool),"header") {
  572. SWIGINTERNINLINE
  573. -v8::Handle<v8::Value>
  574. +v8::Local<v8::Value>
  575. SWIG_From_dec(bool)(bool value)
  576. {
  577. return SWIGV8_BOOLEAN_NEW(value);
  578. @@ -16,7 +16,7 @@ SWIG_From_dec(bool)(bool value)
  579. %fragment(SWIG_AsVal_frag(bool),"header",
  580. fragment=SWIG_AsVal_frag(long)) {
  581. SWIGINTERN
  582. -int SWIG_AsVal_dec(bool)(v8::Handle<v8::Value> obj, bool *val)
  583. +int SWIG_AsVal_dec(bool)(v8::Local<v8::Value> obj, bool *val)
  584. {
  585. if(!obj->IsBoolean()) {
  586. return SWIG_ERROR;
  587. @@ -31,7 +31,7 @@ int SWIG_AsVal_dec(bool)(v8::Handle<v8::Value> obj, bool *val)
  588. %fragment(SWIG_From_frag(int),"header") {
  589. SWIGINTERNINLINE
  590. -v8::Handle<v8::Value> SWIG_From_dec(int)(int value)
  591. +v8::Local<v8::Value> SWIG_From_dec(int)(int value)
  592. {
  593. return SWIGV8_INT32_NEW(value);
  594. }
  595. @@ -39,7 +39,7 @@ v8::Handle<v8::Value> SWIG_From_dec(int)(int value)
  596. %fragment(SWIG_AsVal_frag(int),"header") {
  597. SWIGINTERN
  598. -int SWIG_AsVal_dec(int)(v8::Handle<v8::Value> valRef, int* val)
  599. +int SWIG_AsVal_dec(int)(v8::Local<v8::Value> valRef, int* val)
  600. {
  601. if (!valRef->IsNumber()) {
  602. return SWIG_TypeError;
  603. @@ -54,7 +54,7 @@ int SWIG_AsVal_dec(int)(v8::Handle<v8::Value> valRef, int* val)
  604. %fragment(SWIG_From_frag(long),"header") {
  605. SWIGINTERNINLINE
  606. -v8::Handle<v8::Value> SWIG_From_dec(long)(long value)
  607. +v8::Local<v8::Value> SWIG_From_dec(long)(long value)
  608. {
  609. return SWIGV8_NUMBER_NEW(value);
  610. }
  611. @@ -63,7 +63,7 @@ v8::Handle<v8::Value> SWIG_From_dec(long)(long value)
  612. %fragment(SWIG_AsVal_frag(long),"header",
  613. fragment="SWIG_CanCastAsInteger") {
  614. SWIGINTERN
  615. -int SWIG_AsVal_dec(long)(v8::Handle<v8::Value> obj, long* val)
  616. +int SWIG_AsVal_dec(long)(v8::Local<v8::Value> obj, long* val)
  617. {
  618. if (!obj->IsNumber()) {
  619. return SWIG_TypeError;
  620. @@ -79,7 +79,7 @@ int SWIG_AsVal_dec(long)(v8::Handle<v8::Value> obj, long* val)
  621. %fragment(SWIG_From_frag(unsigned long),"header",
  622. fragment=SWIG_From_frag(long)) {
  623. SWIGINTERNINLINE
  624. -v8::Handle<v8::Value> SWIG_From_dec(unsigned long)(unsigned long value)
  625. +v8::Local<v8::Value> SWIG_From_dec(unsigned long)(unsigned long value)
  626. {
  627. return (value > LONG_MAX) ?
  628. SWIGV8_INTEGER_NEW_UNS(value) : SWIGV8_INTEGER_NEW(%numeric_cast(value,long));
  629. @@ -89,7 +89,7 @@ v8::Handle<v8::Value> SWIG_From_dec(unsigned long)(unsigned long value)
  630. %fragment(SWIG_AsVal_frag(unsigned long),"header",
  631. fragment="SWIG_CanCastAsInteger") {
  632. SWIGINTERN
  633. -int SWIG_AsVal_dec(unsigned long)(v8::Handle<v8::Value> obj, unsigned long *val)
  634. +int SWIG_AsVal_dec(unsigned long)(v8::Local<v8::Value> obj, unsigned long *val)
  635. {
  636. if(!obj->IsNumber()) {
  637. return SWIG_TypeError;
  638. @@ -115,7 +115,7 @@ int SWIG_AsVal_dec(unsigned long)(v8::Handle<v8::Value> obj, unsigned long *val)
  639. fragment="SWIG_LongLongAvailable") {
  640. %#ifdef SWIG_LONG_LONG_AVAILABLE
  641. SWIGINTERNINLINE
  642. -v8::Handle<v8::Value> SWIG_From_dec(long long)(long long value)
  643. +v8::Local<v8::Value> SWIG_From_dec(long long)(long long value)
  644. {
  645. return SWIGV8_NUMBER_NEW(value);
  646. }
  647. @@ -128,7 +128,7 @@ v8::Handle<v8::Value> SWIG_From_dec(long long)(long long value)
  648. fragment="SWIG_LongLongAvailable") {
  649. %#ifdef SWIG_LONG_LONG_AVAILABLE
  650. SWIGINTERN
  651. -int SWIG_AsVal_dec(long long)(v8::Handle<v8::Value> obj, long long* val)
  652. +int SWIG_AsVal_dec(long long)(v8::Local<v8::Value> obj, long long* val)
  653. {
  654. if (!obj->IsNumber()) {
  655. return SWIG_TypeError;
  656. @@ -148,7 +148,7 @@ int SWIG_AsVal_dec(long long)(v8::Handle<v8::Value> obj, long long* val)
  657. fragment="SWIG_LongLongAvailable") {
  658. %#ifdef SWIG_LONG_LONG_AVAILABLE
  659. SWIGINTERNINLINE
  660. -v8::Handle<v8::Value> SWIG_From_dec(unsigned long long)(unsigned long long value)
  661. +v8::Local<v8::Value> SWIG_From_dec(unsigned long long)(unsigned long long value)
  662. {
  663. return (value > LONG_MAX) ?
  664. SWIGV8_INTEGER_NEW_UNS(value) : SWIGV8_INTEGER_NEW(%numeric_cast(value,long));
  665. @@ -162,7 +162,7 @@ v8::Handle<v8::Value> SWIG_From_dec(unsigned long long)(unsigned long long value
  666. fragment="SWIG_LongLongAvailable") {
  667. %#ifdef SWIG_LONG_LONG_AVAILABLE
  668. SWIGINTERN
  669. -int SWIG_AsVal_dec(unsigned long long)(v8::Handle<v8::Value> obj, unsigned long long *val)
  670. +int SWIG_AsVal_dec(unsigned long long)(v8::Local<v8::Value> obj, unsigned long long *val)
  671. {
  672. if(!obj->IsNumber()) {
  673. return SWIG_TypeError;
  674. @@ -185,7 +185,7 @@ int SWIG_AsVal_dec(unsigned long long)(v8::Handle<v8::Value> obj, unsigned long
  675. %fragment(SWIG_From_frag(double),"header") {
  676. SWIGINTERN
  677. -v8::Handle<v8::Value> SWIG_From_dec(double) (double val)
  678. +v8::Local<v8::Value> SWIG_From_dec(double) (double val)
  679. {
  680. return SWIGV8_NUMBER_NEW(val);
  681. }
  682. @@ -193,7 +193,7 @@ v8::Handle<v8::Value> SWIG_From_dec(double) (double val)
  683. %fragment(SWIG_AsVal_frag(double),"header") {
  684. SWIGINTERN
  685. -int SWIG_AsVal_dec(double)(v8::Handle<v8::Value> obj, double *val)
  686. +int SWIG_AsVal_dec(double)(v8::Local<v8::Value> obj, double *val)
  687. {
  688. if(!obj->IsNumber()) {
  689. return SWIG_TypeError;
  690. @@ -203,4 +203,3 @@ int SWIG_AsVal_dec(double)(v8::Handle<v8::Value> obj, double *val)
  691. return SWIG_OK;
  692. }
  693. }
  694. -
  695. diff --git a/Lib/javascript/v8/javascriptrun.swg b/Lib/javascript/v8/javascriptrun.swg
  696. index 2452f4040d..2023d023da 100644
  697. --- a/Lib/javascript/v8/javascriptrun.swg
  698. +++ b/Lib/javascript/v8/javascriptrun.swg
  699. @@ -5,70 +5,37 @@
  700. // First v8 version that uses "SetWeak" and not "MakeWeak"
  701. -#define SWIGV8_SETWEAK_VERSION 0x032224
  702. -
  703. -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031803)
  704. -#define SWIGV8_STRING_NEW2(cstr, len) v8::String::New(cstr, len)
  705. -#else
  706. +#if (NODE_MODULE_VERSION < 72)
  707. #define SWIGV8_STRING_NEW2(cstr, len) v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), cstr, v8::String::kNormalString, len)
  708. +#else
  709. +#define SWIGV8_STRING_NEW2(cstr, len) (v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), cstr, v8::NewStringType::kNormal, len)).ToLocalChecked()
  710. #endif
  711. -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903)
  712. -typedef v8::Handle<v8::Value> SwigV8ReturnValue;
  713. -typedef v8::Arguments SwigV8Arguments;
  714. -typedef v8::AccessorInfo SwigV8PropertyCallbackInfo;
  715. -#define SWIGV8_RETURN(val) return scope.Close(val)
  716. -#define SWIGV8_RETURN_INFO(val, info) return scope.Close(val)
  717. -#else
  718. typedef void SwigV8ReturnValue;
  719. typedef v8::FunctionCallbackInfo<v8::Value> SwigV8Arguments;
  720. typedef v8::PropertyCallbackInfo<v8::Value> SwigV8PropertyCallbackInfo;
  721. #define SWIGV8_RETURN(val) args.GetReturnValue().Set(val); return
  722. #define SWIGV8_RETURN_INFO(val, info) info.GetReturnValue().Set(val); return
  723. -#endif
  724. -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032117)
  725. -#define SWIGV8_HANDLESCOPE() v8::HandleScope scope
  726. -#define SWIGV8_HANDLESCOPE_ESC() v8::HandleScope scope
  727. -#define SWIGV8_ESCAPE(val) return scope.Close(val)
  728. -#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032224)
  729. -#define SWIGV8_HANDLESCOPE() v8::HandleScope scope(v8::Isolate::GetCurrent());
  730. -#define SWIGV8_HANDLESCOPE_ESC() v8::HandleScope scope(v8::Isolate::GetCurrent());
  731. -#define SWIGV8_ESCAPE(val) return scope.Close(val)
  732. -#else
  733. #define SWIGV8_HANDLESCOPE() v8::HandleScope scope(v8::Isolate::GetCurrent());
  734. #define SWIGV8_HANDLESCOPE_ESC() v8::EscapableHandleScope scope(v8::Isolate::GetCurrent());
  735. #define SWIGV8_ESCAPE(val) return scope.Escape(val)
  736. -#endif
  737. -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032224)
  738. -#define SWIGV8_ADJUST_MEMORY(size) v8::V8::AdjustAmountOfExternalAllocatedMemory(size)
  739. -#define SWIGV8_CURRENT_CONTEXT() v8::Context::GetCurrent()
  740. -#define SWIGV8_THROW_EXCEPTION(err) v8::ThrowException(err)
  741. -#define SWIGV8_STRING_NEW(str) v8::String::New(str)
  742. -#define SWIGV8_SYMBOL_NEW(sym) v8::String::NewSymbol(sym)
  743. +#if (NODE_MODULE_VERSION < 72)
  744. +#define SWIGV8_ADJUST_MEMORY(size) v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(size)
  745. +#define SWIGV8_CURRENT_CONTEXT() v8::Isolate::GetCurrent()->GetCurrentContext()
  746. +#define SWIGV8_THROW_EXCEPTION(err) v8::Isolate::GetCurrent()->ThrowException(err)
  747. +#define SWIGV8_STRING_NEW(str) v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), str, v8::String::kNormalString)
  748. +#define SWIGV8_SYMBOL_NEW(sym) v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), sym, v8::String::kNormalString)
  749. #else
  750. #define SWIGV8_ADJUST_MEMORY(size) v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(size)
  751. #define SWIGV8_CURRENT_CONTEXT() v8::Isolate::GetCurrent()->GetCurrentContext()
  752. #define SWIGV8_THROW_EXCEPTION(err) v8::Isolate::GetCurrent()->ThrowException(err)
  753. -#define SWIGV8_STRING_NEW(str) v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), str)
  754. -#define SWIGV8_SYMBOL_NEW(sym) v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), sym)
  755. +#define SWIGV8_STRING_NEW(str) (v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), str, v8::NewStringType::kNormal)).ToLocalChecked()
  756. +#define SWIGV8_SYMBOL_NEW(sym) (v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), sym, v8::NewStringType::kNormal)).ToLocalChecked()
  757. #endif
  758. -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032318)
  759. -#define SWIGV8_ARRAY_NEW() v8::Array::New()
  760. -#define SWIGV8_BOOLEAN_NEW(bool) v8::Boolean::New(bool)
  761. -#define SWIGV8_EXTERNAL_NEW(val) v8::External::New(val)
  762. -#define SWIGV8_FUNCTEMPLATE_NEW(func) v8::FunctionTemplate::New(func)
  763. -#define SWIGV8_FUNCTEMPLATE_NEW_VOID() v8::FunctionTemplate::New()
  764. -#define SWIGV8_INT32_NEW(num) v8::Int32::New(num)
  765. -#define SWIGV8_INTEGER_NEW(num) v8::Integer::New(num)
  766. -#define SWIGV8_INTEGER_NEW_UNS(num) v8::Integer::NewFromUnsigned(num)
  767. -#define SWIGV8_NUMBER_NEW(num) v8::Number::New(num)
  768. -#define SWIGV8_OBJECT_NEW() v8::Object::New()
  769. -#define SWIGV8_UNDEFINED() v8::Undefined()
  770. -#define SWIGV8_NULL() v8::Null()
  771. -#else
  772. +
  773. #define SWIGV8_ARRAY_NEW() v8::Array::New(v8::Isolate::GetCurrent())
  774. #define SWIGV8_BOOLEAN_NEW(bool) v8::Boolean::New(v8::Isolate::GetCurrent(), bool)
  775. #define SWIGV8_EXTERNAL_NEW(val) v8::External::New(v8::Isolate::GetCurrent(), val)
  776. @@ -81,15 +48,8 @@ typedef v8::PropertyCallbackInfo<v8::Value> SwigV8PropertyCallbackInfo;
  777. #define SWIGV8_OBJECT_NEW() v8::Object::New(v8::Isolate::GetCurrent())
  778. #define SWIGV8_UNDEFINED() v8::Undefined(v8::Isolate::GetCurrent())
  779. #define SWIGV8_NULL() v8::Null(v8::Isolate::GetCurrent())
  780. -#endif
  781. -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
  782. -#define SWIGV8_SET_CLASS_TEMPL(class_templ, class) class_templ = v8::Persistent<v8::FunctionTemplate>::New(class);
  783. -#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900)
  784. -#define SWIGV8_SET_CLASS_TEMPL(class_templ, class) class_templ = v8::Persistent<v8::FunctionTemplate>::New(v8::Isolate::GetCurrent(), class);
  785. -#else
  786. #define SWIGV8_SET_CLASS_TEMPL(class_templ, class) class_templ.Reset(v8::Isolate::GetCurrent(), class);
  787. -#endif
  788. #ifdef NODE_VERSION
  789. #if NODE_VERSION_AT_LEAST(10, 12, 0)
  790. @@ -98,23 +58,17 @@ typedef v8::PropertyCallbackInfo<v8::Value> SwigV8PropertyCallbackInfo;
  791. #endif
  792. //Necessary to check Node.js version because V8 API changes are backported in Node.js
  793. -#if (defined(NODE_VERSION) && !defined(SWIG_NODE_AT_LEAST_1012)) || \
  794. - (!defined(NODE_VERSION) && (V8_MAJOR_VERSION-0) < 7)
  795. -#define SWIGV8_TO_OBJECT(handle) (handle)->ToObject()
  796. -#define SWIGV8_TO_STRING(handle) (handle)->ToString()
  797. -#define SWIGV8_NUMBER_VALUE(handle) (handle)->NumberValue()
  798. -#define SWIGV8_INTEGER_VALUE(handle) (handle)->IntegerValue()
  799. -#define SWIGV8_BOOLEAN_VALUE(handle) (handle)->BooleanValue()
  800. -#define SWIGV8_WRITE_UTF8(handle, buffer, len) (handle)->WriteUtf8(buffer, len)
  801. -#define SWIGV8_UTF8_LENGTH(handle) (handle)->Utf8Length()
  802. -#else
  803. #define SWIGV8_TO_OBJECT(handle) (handle)->ToObject(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked()
  804. #define SWIGV8_TO_STRING(handle) (handle)->ToString(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked()
  805. #define SWIGV8_NUMBER_VALUE(handle) (handle)->NumberValue(SWIGV8_CURRENT_CONTEXT()).ToChecked()
  806. #define SWIGV8_INTEGER_VALUE(handle) (handle)->IntegerValue(SWIGV8_CURRENT_CONTEXT()).ToChecked()
  807. -#define SWIGV8_BOOLEAN_VALUE(handle) (handle)->BooleanValue(SWIGV8_CURRENT_CONTEXT()).ToChecked()
  808. #define SWIGV8_WRITE_UTF8(handle, buffer, len) (handle)->WriteUtf8(v8::Isolate::GetCurrent(), buffer, len)
  809. #define SWIGV8_UTF8_LENGTH(handle) (handle)->Utf8Length(v8::Isolate::GetCurrent())
  810. +
  811. +#if (NODE_MODULE_VERSION < 72)
  812. +#define SWIGV8_BOOLEAN_VALUE(handle) (handle)->BooleanValue(SWIGV8_CURRENT_CONTEXT()).ToChecked()
  813. +#else
  814. +#define SWIGV8_BOOLEAN_VALUE(handle) (handle)->BooleanValue(v8::Isolate::GetCurrent())
  815. #endif
  816. /* ---------------------------------------------------------------------------
  817. @@ -163,7 +117,7 @@ public:
  818. SWIGV8_THROW_EXCEPTION(err);
  819. }
  820. }
  821. - v8::Handle<v8::Value> err;
  822. + v8::Local<v8::Value> err;
  823. };
  824. /* ---------------------------------------------------------------------------
  825. @@ -182,23 +136,8 @@ public:
  826. };
  827. ~SWIGV8_Proxy() {
  828. -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
  829. - handle.ClearWeak();
  830. - handle.Dispose();
  831. -#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032100)
  832. - handle.ClearWeak(v8::Isolate::GetCurrent());
  833. - handle.Dispose(v8::Isolate::GetCurrent());
  834. -#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
  835. - handle.ClearWeak();
  836. - handle.Dispose();
  837. -#else
  838. handle.ClearWeak();
  839. handle.Reset();
  840. -#endif
  841. -
  842. -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
  843. - handle.Clear();
  844. -#endif
  845. SWIGV8_ADJUST_MEMORY(-SWIGV8_AVG_OBJ_SIZE);
  846. }
  847. @@ -213,32 +152,17 @@ class SWIGV8_ClientData {
  848. public:
  849. v8::Persistent<v8::FunctionTemplate> class_templ;
  850. -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
  851. - void (*dtor) (v8::Persistent< v8::Value> object, void *parameter);
  852. -#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900)
  853. - void (*dtor) (v8::Isolate *isolate, v8::Persistent< v8::Value> object, void *parameter);
  854. -#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
  855. - void (*dtor) (v8::Isolate *isolate, v8::Persistent< v8::Object > *object, SWIGV8_Proxy *proxy);
  856. -#elif (V8_MAJOR_VERSION-0) < 5
  857. - void (*dtor) (const v8::WeakCallbackData<v8::Object, SWIGV8_Proxy> &data);
  858. -#else
  859. void (*dtor) (const v8::WeakCallbackInfo<SWIGV8_Proxy> &data);
  860. -#endif
  861. };
  862. SWIGRUNTIME v8::Persistent<v8::FunctionTemplate> SWIGV8_SWIGTYPE_Proxy_class_templ;
  863. -SWIGRUNTIME int SWIG_V8_ConvertInstancePtr(v8::Handle<v8::Object> objRef, void **ptr, swig_type_info *info, int flags) {
  864. +SWIGRUNTIME int SWIG_V8_ConvertInstancePtr(v8::Local<v8::Object> objRef, void **ptr, swig_type_info *info, int flags) {
  865. SWIGV8_HANDLESCOPE();
  866. if(objRef->InternalFieldCount() < 1) return SWIG_ERROR;
  867. -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031511)
  868. - v8::Handle<v8::Value> cdataRef = objRef->GetInternalField(0);
  869. - SWIGV8_Proxy *cdata = static_cast<SWIGV8_Proxy *>(v8::External::Unwrap(cdataRef));
  870. -#else
  871. SWIGV8_Proxy *cdata = static_cast<SWIGV8_Proxy *>(objRef->GetAlignedPointerFromInternalField(0));
  872. -#endif
  873. if(cdata == NULL) {
  874. return SWIG_ERROR;
  875. @@ -261,39 +185,21 @@ SWIGRUNTIME int SWIG_V8_ConvertInstancePtr(v8::Handle<v8::Object> objRef, void *
  876. }
  877. -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
  878. -SWIGRUNTIME void SWIGV8_Proxy_DefaultDtor(v8::Persistent< v8::Value > object, void *parameter) {
  879. - SWIGV8_Proxy *proxy = static_cast<SWIGV8_Proxy *>(parameter);
  880. -#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900)
  881. -SWIGRUNTIME void SWIGV8_Proxy_DefaultDtor(v8::Isolate *, v8::Persistent< v8::Value > object, void *parameter) {
  882. - SWIGV8_Proxy *proxy = static_cast<SWIGV8_Proxy *>(parameter);
  883. -#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
  884. -SWIGRUNTIME void SWIGV8_Proxy_DefaultDtor(v8::Isolate *, v8::Persistent< v8::Object > *object, SWIGV8_Proxy *proxy) {
  885. -#elif (V8_MAJOR_VERSION-0) < 5
  886. -SWIGRUNTIME void SWIGV8_Proxy_DefaultDtor(const v8::WeakCallbackData<v8::Object, SWIGV8_Proxy> &data) {
  887. - SWIGV8_Proxy *proxy = data.GetParameter();
  888. -#else
  889. SWIGRUNTIME void SWIGV8_Proxy_DefaultDtor(const v8::WeakCallbackInfo<SWIGV8_Proxy> &data) {
  890. SWIGV8_Proxy *proxy = data.GetParameter();
  891. -#endif
  892. delete proxy;
  893. }
  894. -SWIGRUNTIME int SWIG_V8_GetInstancePtr(v8::Handle<v8::Value> valRef, void **ptr) {
  895. +SWIGRUNTIME int SWIG_V8_GetInstancePtr(v8::Local<v8::Value> valRef, void **ptr) {
  896. if(!valRef->IsObject()) {
  897. return SWIG_TypeError;
  898. }
  899. - v8::Handle<v8::Object> objRef = SWIGV8_TO_OBJECT(valRef);
  900. + v8::Local<v8::Object> objRef = SWIGV8_TO_OBJECT(valRef);
  901. if(objRef->InternalFieldCount() < 1) return SWIG_ERROR;
  902. -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031511)
  903. - v8::Handle<v8::Value> cdataRef = objRef->GetInternalField(0);
  904. - SWIGV8_Proxy *cdata = static_cast<SWIGV8_Proxy *>(v8::External::Unwrap(cdataRef));
  905. -#else
  906. SWIGV8_Proxy *cdata = static_cast<SWIGV8_Proxy *>(objRef->GetAlignedPointerFromInternalField(0));
  907. -#endif
  908. if(cdata == NULL) {
  909. return SWIG_ERROR;
  910. @@ -304,70 +210,31 @@ SWIGRUNTIME int SWIG_V8_GetInstancePtr(v8::Handle<v8::Value> valRef, void **ptr)
  911. return SWIG_OK;
  912. }
  913. -SWIGRUNTIME void SWIGV8_SetPrivateData(v8::Handle<v8::Object> obj, void *ptr, swig_type_info *info, int flags) {
  914. +SWIGRUNTIME void SWIGV8_SetPrivateData(v8::Local<v8::Object> obj, void *ptr, swig_type_info *info, int flags) {
  915. SWIGV8_Proxy *cdata = new SWIGV8_Proxy();
  916. cdata->swigCObject = ptr;
  917. cdata->swigCMemOwn = (flags & SWIG_POINTER_OWN) ? 1 : 0;
  918. cdata->info = info;
  919. -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031511)
  920. - obj->SetPointerInInternalField(0, cdata);
  921. -#else
  922. obj->SetAlignedPointerInInternalField(0, cdata);
  923. -#endif
  924. -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
  925. - cdata->handle = v8::Persistent<v8::Object>::New(obj);
  926. -#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900)
  927. - cdata->handle = v8::Persistent<v8::Object>::New(v8::Isolate::GetCurrent(), obj);
  928. -#else
  929. cdata->handle.Reset(v8::Isolate::GetCurrent(), obj);
  930. -#endif
  931. -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
  932. - // clientdata must be set for owned data as we need to register the dtor
  933. - if(cdata->swigCMemOwn && (SWIGV8_ClientData*)info->clientdata) {
  934. - cdata->handle.MakeWeak(cdata, ((SWIGV8_ClientData*)info->clientdata)->dtor);
  935. - } else {
  936. - cdata->handle.MakeWeak(cdata, SWIGV8_Proxy_DefaultDtor);
  937. - }
  938. -#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031918)
  939. - if(cdata->swigCMemOwn && (SWIGV8_ClientData*)info->clientdata) {
  940. - cdata->handle.MakeWeak(v8::Isolate::GetCurrent(), cdata, ((SWIGV8_ClientData*)info->clientdata)->dtor);
  941. - } else {
  942. - cdata->handle.MakeWeak(v8::Isolate::GetCurrent(), cdata, SWIGV8_Proxy_DefaultDtor);
  943. - }
  944. -#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
  945. - if(cdata->swigCMemOwn && (SWIGV8_ClientData*)info->clientdata) {
  946. - cdata->handle.MakeWeak(cdata, ((SWIGV8_ClientData*)info->clientdata)->dtor);
  947. - } else {
  948. - cdata->handle.MakeWeak(cdata, SWIGV8_Proxy_DefaultDtor);
  949. - }
  950. -#elif (V8_MAJOR_VERSION-0) < 5
  951. - if(cdata->swigCMemOwn && (SWIGV8_ClientData*)info->clientdata) {
  952. - cdata->handle.SetWeak(cdata, ((SWIGV8_ClientData*)info->clientdata)->dtor);
  953. - } else {
  954. - cdata->handle.SetWeak(cdata, SWIGV8_Proxy_DefaultDtor);
  955. - }
  956. -#else
  957. if(cdata->swigCMemOwn && (SWIGV8_ClientData*)info->clientdata) {
  958. cdata->handle.SetWeak(cdata, ((SWIGV8_ClientData*)info->clientdata)->dtor, v8::WeakCallbackType::kParameter);
  959. } else {
  960. cdata->handle.SetWeak(cdata, SWIGV8_Proxy_DefaultDtor, v8::WeakCallbackType::kParameter);
  961. }
  962. -#endif
  963. -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
  964. - cdata->handle.MarkIndependent();
  965. -#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032100)
  966. - cdata->handle.MarkIndependent(v8::Isolate::GetCurrent());
  967. -#else
  968. +#if (NODE_MODULE_VERSION < 72)
  969. cdata->handle.MarkIndependent();
  970. +// Looks like future versions do not require that anymore:
  971. +// https://monorail-prod.appspot.com/p/chromium/issues/detail?id=923361#c11
  972. #endif
  973. }
  974. -SWIGRUNTIME int SWIG_V8_ConvertPtr(v8::Handle<v8::Value> valRef, void **ptr, swig_type_info *info, int flags) {
  975. +SWIGRUNTIME int SWIG_V8_ConvertPtr(v8::Local<v8::Value> valRef, void **ptr, swig_type_info *info, int flags) {
  976. SWIGV8_HANDLESCOPE();
  977. /* special case: JavaScript null => C NULL pointer */
  978. @@ -378,31 +245,20 @@ SWIGRUNTIME int SWIG_V8_ConvertPtr(v8::Handle<v8::Value> valRef, void **ptr, swi
  979. if(!valRef->IsObject()) {
  980. return SWIG_TypeError;
  981. }
  982. - v8::Handle<v8::Object> objRef = SWIGV8_TO_OBJECT(valRef);
  983. + v8::Local<v8::Object> objRef = SWIGV8_TO_OBJECT(valRef);
  984. return SWIG_V8_ConvertInstancePtr(objRef, ptr, info, flags);
  985. }
  986. -SWIGRUNTIME v8::Handle<v8::Value> SWIG_V8_NewPointerObj(void *ptr, swig_type_info *info, int flags) {
  987. +SWIGRUNTIME v8::Local<v8::Value> SWIG_V8_NewPointerObj(void *ptr, swig_type_info *info, int flags) {
  988. SWIGV8_HANDLESCOPE_ESC();
  989. - v8::Handle<v8::FunctionTemplate> class_templ;
  990. + v8::Local<v8::FunctionTemplate> class_templ;
  991. if (ptr == NULL) {
  992. -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903)
  993. - SWIGV8_ESCAPE(SWIGV8_NULL());
  994. -#else
  995. v8::Local<v8::Primitive> result = SWIGV8_NULL();
  996. SWIGV8_ESCAPE(result);
  997. -#endif
  998. }
  999. -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903)
  1000. - if(info->clientdata != 0) {
  1001. - class_templ = ((SWIGV8_ClientData*) info->clientdata)->class_templ;
  1002. - } else {
  1003. - class_templ = SWIGV8_SWIGTYPE_Proxy_class_templ;
  1004. - }
  1005. -#else
  1006. v8::Isolate *isolate = v8::Isolate::GetCurrent();
  1007. if(info->clientdata != 0) {
  1008. @@ -410,10 +266,13 @@ SWIGRUNTIME v8::Handle<v8::Value> SWIG_V8_NewPointerObj(void *ptr, swig_type_inf
  1009. } else {
  1010. class_templ = v8::Local<v8::FunctionTemplate>::New(isolate, SWIGV8_SWIGTYPE_Proxy_class_templ);
  1011. }
  1012. -#endif
  1013. -// v8::Handle<v8::Object> result = class_templ->InstanceTemplate()->NewInstance();
  1014. +#if (NODE_MODULE_VERSION < 72)
  1015. v8::Local<v8::Object> result = class_templ->InstanceTemplate()->NewInstance();
  1016. +#else
  1017. + v8::Local<v8::Object> result = class_templ->InstanceTemplate()->NewInstance(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked();
  1018. +#endif
  1019. +
  1020. SWIGV8_SetPrivateData(result, ptr, info, flags);
  1021. SWIGV8_ESCAPE(result);
  1022. @@ -433,7 +292,7 @@ SWIGRUNTIME v8::Handle<v8::Value> SWIG_V8_NewPointerObj(void *ptr, swig_type_inf
  1023. SWIGRUNTIME SwigV8ReturnValue _SWIGV8_wrap_equals(const SwigV8Arguments &args) {
  1024. SWIGV8_HANDLESCOPE();
  1025. - v8::Handle<v8::Value> jsresult;
  1026. + v8::Local<v8::Value> jsresult;
  1027. void *arg1 = (void *) 0 ;
  1028. void *arg2 = (void *) 0 ;
  1029. bool result;
  1030. @@ -463,7 +322,7 @@ fail:
  1031. SWIGRUNTIME SwigV8ReturnValue _wrap_getCPtr(const SwigV8Arguments &args) {
  1032. SWIGV8_HANDLESCOPE();
  1033. - v8::Handle<v8::Value> jsresult;
  1034. + v8::Local<v8::Value> jsresult;
  1035. void *arg1 = (void *) 0 ;
  1036. long result;
  1037. int res1;
  1038. @@ -502,37 +361,29 @@ public:
  1039. };
  1040. SWIGRUNTIMEINLINE
  1041. -int SwigV8Packed_Check(v8::Handle<v8::Value> valRef) {
  1042. +int SwigV8Packed_Check(v8::Local<v8::Value> valRef) {
  1043. SWIGV8_HANDLESCOPE();
  1044. - v8::Handle<v8::Object> objRef = SWIGV8_TO_OBJECT(valRef);
  1045. + v8::Local<v8::Object> objRef = SWIGV8_TO_OBJECT(valRef);
  1046. if(objRef->InternalFieldCount() < 1) return false;
  1047. -#if (V8_MAJOR_VERSION-0) < 5
  1048. - v8::Handle<v8::Value> flag = objRef->GetHiddenValue(SWIGV8_STRING_NEW("__swig__packed_data__"));
  1049. -#else
  1050. v8::Local<v8::Private> privateKey = v8::Private::ForApi(v8::Isolate::GetCurrent(), SWIGV8_STRING_NEW("__swig__packed_data__"));
  1051. v8::Local<v8::Value> flag;
  1052. if (!objRef->GetPrivate(SWIGV8_CURRENT_CONTEXT(), privateKey).ToLocal(&flag))
  1053. return false;
  1054. -#endif
  1055. +
  1056. return (flag->IsBoolean() && SWIGV8_BOOLEAN_VALUE(flag));
  1057. }
  1058. SWIGRUNTIME
  1059. -swig_type_info *SwigV8Packed_UnpackData(v8::Handle<v8::Value> valRef, void *ptr, size_t size) {
  1060. +swig_type_info *SwigV8Packed_UnpackData(v8::Local<v8::Value> valRef, void *ptr, size_t size) {
  1061. if (SwigV8Packed_Check(valRef)) {
  1062. SWIGV8_HANDLESCOPE();
  1063. SwigV8PackedData *sobj;
  1064. - v8::Handle<v8::Object> objRef = SWIGV8_TO_OBJECT(valRef);
  1065. + v8::Local<v8::Object> objRef = SWIGV8_TO_OBJECT(valRef);
  1066. -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031511)
  1067. - v8::Handle<v8::Value> cdataRef = objRef->GetInternalField(0);
  1068. - sobj = static_cast<SwigV8PackedData*>(v8::External::Unwrap(cdataRef));
  1069. -#else
  1070. sobj = static_cast<SwigV8PackedData*>(objRef->GetAlignedPointerFromInternalField(0));
  1071. -#endif
  1072. if (sobj == NULL || sobj->size != size) return 0;
  1073. memcpy(ptr, sobj->data, size);
  1074. return sobj->type;
  1075. @@ -542,7 +393,7 @@ swig_type_info *SwigV8Packed_UnpackData(v8::Handle<v8::Value> valRef, void *ptr,
  1076. }
  1077. SWIGRUNTIME
  1078. -int SWIGV8_ConvertPacked(v8::Handle<v8::Value> valRef, void *ptr, size_t sz, swig_type_info *ty) {
  1079. +int SWIGV8_ConvertPacked(v8::Local<v8::Value> valRef, void *ptr, size_t sz, swig_type_info *ty) {
  1080. swig_type_info *to = SwigV8Packed_UnpackData(valRef, ptr, sz);
  1081. if (!to) return SWIG_ERROR;
  1082. if (ty) {
  1083. @@ -555,89 +406,32 @@ int SWIGV8_ConvertPacked(v8::Handle<v8::Value> valRef, void *ptr, size_t sz, swi
  1084. return SWIG_OK;
  1085. }
  1086. -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
  1087. -SWIGRUNTIME void _wrap_SwigV8PackedData_delete(v8::Persistent< v8::Value > object, void *parameter) {
  1088. - SwigV8PackedData *cdata = static_cast<SwigV8PackedData *>(parameter);
  1089. -#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900)
  1090. -SWIGRUNTIME void _wrap_SwigV8PackedData_delete(v8::Isolate *isolate, v8::Persistent<v8::Value> object, void *parameter) {
  1091. - SwigV8PackedData *cdata = static_cast<SwigV8PackedData *>(parameter);
  1092. -#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
  1093. -SWIGRUNTIME void _wrap_SwigV8PackedData_delete(v8::Isolate *isolate, v8::Persistent<v8::Object> *object, SwigV8PackedData *cdata) {
  1094. -#elif (V8_MAJOR_VERSION-0) < 5
  1095. -SWIGRUNTIME void _wrap_SwigV8PackedData_delete(const v8::WeakCallbackData<v8::Object, SwigV8PackedData> &data) {
  1096. - v8::Local<v8::Object> object = data.GetValue();
  1097. - SwigV8PackedData *cdata = data.GetParameter();
  1098. -#else
  1099. SWIGRUNTIME void _wrap_SwigV8PackedData_delete(const v8::WeakCallbackInfo<SwigV8PackedData> &data) {
  1100. SwigV8PackedData *cdata = data.GetParameter();
  1101. -#endif
  1102. delete cdata;
  1103. -
  1104. -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
  1105. - object.Clear();
  1106. - object.Dispose();
  1107. -#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900)
  1108. - object.Clear();
  1109. - object.Dispose(isolate);
  1110. -#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032100)
  1111. - object->Dispose(isolate);
  1112. -#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
  1113. - object->Dispose();
  1114. -#elif (V8_MAJOR_VERSION-0) < 5
  1115. - object.Clear();
  1116. -#endif
  1117. }
  1118. SWIGRUNTIME
  1119. -v8::Handle<v8::Value> SWIGV8_NewPackedObj(void *data, size_t size, swig_type_info *type) {
  1120. +v8::Local<v8::Value> SWIGV8_NewPackedObj(void *data, size_t size, swig_type_info *type) {
  1121. SWIGV8_HANDLESCOPE_ESC();
  1122. SwigV8PackedData *cdata = new SwigV8PackedData(data, size, type);
  1123. -// v8::Handle<v8::Object> obj = SWIGV8_OBJECT_NEW();
  1124. v8::Local<v8::Object> obj = SWIGV8_OBJECT_NEW();
  1125. -#if (V8_MAJOR_VERSION-0) < 5
  1126. - obj->SetHiddenValue(SWIGV8_STRING_NEW("__swig__packed_data__"), SWIGV8_BOOLEAN_NEW(true));
  1127. -#else
  1128. v8::Local<v8::Private> privateKey = v8::Private::ForApi(v8::Isolate::GetCurrent(), SWIGV8_STRING_NEW("__swig__packed_data__"));
  1129. obj->SetPrivate(SWIGV8_CURRENT_CONTEXT(), privateKey, SWIGV8_BOOLEAN_NEW(true));
  1130. -#endif
  1131. -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031511)
  1132. - obj->SetPointerInInternalField(0, cdata);
  1133. -#else
  1134. obj->SetAlignedPointerInInternalField(0, cdata);
  1135. -#endif
  1136. -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
  1137. - cdata->handle = v8::Persistent<v8::Object>::New(obj);
  1138. -#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900)
  1139. - cdata->handle = v8::Persistent<v8::Object>::New(v8::Isolate::GetCurrent(), obj);
  1140. -#else
  1141. cdata->handle.Reset(v8::Isolate::GetCurrent(), obj);
  1142. -#endif
  1143. -
  1144. -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
  1145. - cdata->handle.MakeWeak(cdata, _wrap_SwigV8PackedData_delete);
  1146. -#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031918)
  1147. - cdata->handle.MakeWeak(v8::Isolate::GetCurrent(), cdata, _wrap_SwigV8PackedData_delete);
  1148. -#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
  1149. - cdata->handle.MakeWeak(cdata, _wrap_SwigV8PackedData_delete);
  1150. -#elif (V8_MAJOR_VERSION-0) < 5
  1151. - cdata->handle.SetWeak(cdata, _wrap_SwigV8PackedData_delete);
  1152. -// v8::V8::SetWeak(&cdata->handle, cdata, _wrap_SwigV8PackedData_delete);
  1153. -#else
  1154. cdata->handle.SetWeak(cdata, _wrap_SwigV8PackedData_delete, v8::WeakCallbackType::kParameter);
  1155. -#endif
  1156. -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
  1157. - cdata->handle.MarkIndependent();
  1158. -#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032100)
  1159. - cdata->handle.MarkIndependent(v8::Isolate::GetCurrent());
  1160. -#else
  1161. +#if (NODE_MODULE_VERSION < 72)
  1162. cdata->handle.MarkIndependent();
  1163. +// Looks like future versions do not require that anymore:
  1164. +// https://monorail-prod.appspot.com/p/chromium/issues/detail?id=923361#c11
  1165. #endif
  1166. SWIGV8_ESCAPE(obj);
  1167. @@ -654,22 +448,18 @@ v8::Handle<v8::Value> SWIGV8_NewPackedObj(void *data, size_t size, swig_type_inf
  1168. SWIGRUNTIME
  1169. -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903)
  1170. -v8::Handle<v8::Value> SWIGV8_AppendOutput(v8::Handle<v8::Value> result, v8::Handle<v8::Value> obj) {
  1171. -#else
  1172. -v8::Handle<v8::Value> SWIGV8_AppendOutput(v8::Local<v8::Value> result, v8::Handle<v8::Value> obj) {
  1173. -#endif
  1174. +v8::Local<v8::Value> SWIGV8_AppendOutput(v8::Local<v8::Value> result, v8::Local<v8::Value> obj) {
  1175. SWIGV8_HANDLESCOPE_ESC();
  1176. if (result->IsUndefined()) {
  1177. result = SWIGV8_ARRAY_NEW();
  1178. }
  1179. -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903)
  1180. - v8::Handle<v8::Array> arr = v8::Handle<v8::Array>::Cast(result);
  1181. -#else
  1182. v8::Local<v8::Array> arr = v8::Local<v8::Array>::Cast(result);
  1183. -#endif
  1184. +#if (NODE_MODULE_VERSION < 72)
  1185. arr->Set(arr->Length(), obj);
  1186. +#else
  1187. + arr->Set(SWIGV8_CURRENT_CONTEXT(), arr->Length(), obj);
  1188. +#endif
  1189. SWIGV8_ESCAPE(arr);
  1190. }
  1191. diff --git a/Lib/javascript/v8/javascriptstrings.swg b/Lib/javascript/v8/javascriptstrings.swg
  1192. index e767a6d662..61a937fa52 100644
  1193. --- a/Lib/javascript/v8/javascriptstrings.swg
  1194. +++ b/Lib/javascript/v8/javascriptstrings.swg
  1195. @@ -4,10 +4,10 @@
  1196. * ------------------------------------------------------------ */
  1197. %fragment("SWIG_AsCharPtrAndSize", "header", fragment="SWIG_pchar_descriptor") {
  1198. SWIGINTERN int
  1199. -SWIG_AsCharPtrAndSize(v8::Handle<v8::Value> valRef, char** cptr, size_t* psize, int *alloc)
  1200. +SWIG_AsCharPtrAndSize(v8::Local<v8::Value> valRef, char** cptr, size_t* psize, int *alloc)
  1201. {
  1202. if(valRef->IsString()) {
  1203. - v8::Handle<v8::String> js_str = SWIGV8_TO_STRING(valRef);
  1204. + v8::Local<v8::String> js_str = SWIGV8_TO_STRING(valRef);
  1205. size_t len = SWIGV8_UTF8_LENGTH(js_str) + 1;
  1206. char* cstr = new char[len];
  1207. @@ -20,7 +20,7 @@ SWIG_AsCharPtrAndSize(v8::Handle<v8::Value> valRef, char** cptr, size_t* psize,
  1208. return SWIG_OK;
  1209. } else {
  1210. if(valRef->IsObject()) {
  1211. - v8::Handle<v8::Object> obj = SWIGV8_TO_OBJECT(valRef);
  1212. + v8::Local<v8::Object> obj = SWIGV8_TO_OBJECT(valRef);
  1213. // try if the object is a wrapped char[]
  1214. swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
  1215. if (pchar_descriptor) {
  1216. @@ -41,7 +41,7 @@ SWIG_AsCharPtrAndSize(v8::Handle<v8::Value> valRef, char** cptr, size_t* psize,
  1217. }
  1218. %fragment("SWIG_FromCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") {
  1219. -SWIGINTERNINLINE v8::Handle<v8::Value>
  1220. +SWIGINTERNINLINE v8::Local<v8::Value>
  1221. SWIG_FromCharPtrAndSize(const char* carray, size_t size)
  1222. {
  1223. if (carray) {
  1224. @@ -49,7 +49,7 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size)
  1225. // TODO: handle extra long strings
  1226. return SWIGV8_UNDEFINED();
  1227. } else {
  1228. - v8::Handle<v8::String> js_str = SWIGV8_STRING_NEW2(carray, size);
  1229. + v8::Local<v8::String> js_str = SWIGV8_STRING_NEW2(carray, size);
  1230. return js_str;
  1231. }
  1232. } else {
  1233. diff --git a/Lib/javascript/v8/javascripttypemaps.swg b/Lib/javascript/v8/javascripttypemaps.swg
  1234. index 4601698e03..fbe7849cd2 100644
  1235. --- a/Lib/javascript/v8/javascripttypemaps.swg
  1236. +++ b/Lib/javascript/v8/javascripttypemaps.swg
  1237. @@ -25,7 +25,7 @@
  1238. /* Javascript types */
  1239. -#define SWIG_Object v8::Handle<v8::Value>
  1240. +#define SWIG_Object v8::Local<v8::Value>
  1241. #define VOID_Object SWIGV8_UNDEFINED()
  1242. /* Overload of the output/constant/exception/dirout handling */
  1243. diff --git a/Tools/javascript/Makefile.in b/Tools/javascript/Makefile.in
  1244. index 5eeec07857..21088a8fad 100644
  1245. --- a/Tools/javascript/Makefile.in
  1246. +++ b/Tools/javascript/Makefile.in
  1247. @@ -3,12 +3,9 @@
  1248. # ----------------------------------------------------------------
  1249. #
  1250. # Note:
  1251. -# There is no common CLI Javascript interpreter.
  1252. -# V8 comes with one 'd8' which however does not provide a means
  1253. -# to load extensions. Therefore, by default we use nodejs as
  1254. -# environment.
  1255. -# For testing native v8 and jsc extensions we provide our own
  1256. -# interpreter (see 'Tools/javascript').
  1257. +# There is no common CLI Javascript interpreter. By default we
  1258. +# use nodejs as environment. For testing jsc extensions we
  1259. +# provide our own interpreter (see 'Tools/javascript').
  1260. #
  1261. # ----------------------------------------------------------------
  1262. all: javascript
  1263. @@ -24,37 +21,25 @@ LDFLAGS =
  1264. LINKFLAGS = @JSINTERPRETERLINKFLAGS@
  1265. ROOT_DIR = @ROOT_DIR@
  1266. -JSINCLUDES = @JSCOREINC@ @JSV8INC@
  1267. -JSDYNAMICLINKING = @JSCOREDYNAMICLINKING@ @JSV8DYNAMICLINKING@
  1268. -JSV8ENABLED = @JSV8ENABLED@
  1269. +JSINCLUDES = @JSCOREINC@
  1270. +JSDYNAMICLINKING = @JSCOREDYNAMICLINKING@
  1271. JSCENABLED = @JSCENABLED@
  1272. srcdir = @srcdir@
  1273. -
  1274. -ifneq (, $(V8_VERSION))
  1275. - JSV8_VERSION=$(V8_VERSION)
  1276. -else
  1277. - JSV8_VERSION=0x031110
  1278. -endif
  1279. -
  1280. # Regenerate Makefile if Makefile.in or config.status have changed.
  1281. Makefile: $(srcdir)/Makefile.in ../../config.status
  1282. cd ../.. && $(SHELL) ./config.status Tools/javascript/Makefile
  1283. # These settings are provided by 'configure' (see '/configure.in')
  1284. -ifeq (1, $(JSV8ENABLED))
  1285. -JS_INTERPRETER_SRC_V8 = v8_shell.cxx
  1286. -JS_INTERPRETER_ENABLE_V8 = -DENABLE_V8 -DSWIG_V8_VERSION=$(JSV8_VERSION) -DV8_DEPRECATION_WARNINGS
  1287. -endif
  1288. ifeq (1, $(JSCENABLED))
  1289. JS_INTERPRETER_SRC_JSC = jsc_shell.cxx
  1290. JS_INTERPRETER_ENABLE_JSC = -DENABLE_JSC
  1291. endif
  1292. -JS_INTERPRETER_DEFINES = $(JS_INTERPRETER_ENABLE_JSC) $(JS_INTERPRETER_ENABLE_V8)
  1293. -JS_INTERPRETER_SRC = javascript.cxx js_shell.cxx $(JS_INTERPRETER_SRC_JSC) $(JS_INTERPRETER_SRC_V8)
  1294. +JS_INTERPRETER_DEFINES = $(JS_INTERPRETER_ENABLE_JSC)
  1295. +JS_INTERPRETER_SRC = javascript.cxx js_shell.cxx $(JS_INTERPRETER_SRC_JSC)
  1296. JS_INTERPRETER_OBJS = $(JS_INTERPRETER_SRC:.cxx=.o)
  1297. diff --git a/Tools/javascript/v8_shell.cxx b/Tools/javascript/v8_shell.cxx
  1298. deleted file mode 100644
  1299. index 5001bc25a6..0000000000
  1300. --- a/Tools/javascript/v8_shell.cxx
  1301. +++ /dev/null
  1302. @@ -1,388 +0,0 @@
  1303. -#include <assert.h>
  1304. -#include <fcntl.h>
  1305. -#include <string.h>
  1306. -#include <stdio.h>
  1307. -#include <stdlib.h>
  1308. -
  1309. -#include <v8.h>
  1310. -#include <vector>
  1311. -
  1312. -#include "js_shell.h"
  1313. -
  1314. -typedef int (*V8ExtensionInitializer) (v8::Handle<v8::Object> module);
  1315. -
  1316. -// Note: these typedefs and defines are used to deal with v8 API changes since version 3.19.00
  1317. -
  1318. -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903)
  1319. -typedef v8::Handle<v8::Value> SwigV8ReturnValue;
  1320. -typedef v8::Arguments SwigV8Arguments;
  1321. -typedef v8::AccessorInfo SwigV8PropertyCallbackInfo;
  1322. -#define SWIGV8_RETURN(val) return scope.Close(val)
  1323. -#define SWIGV8_RETURN_INFO(val, info) return scope.Close(val)
  1324. -#else
  1325. -typedef void SwigV8ReturnValue;
  1326. -typedef v8::FunctionCallbackInfo<v8::Value> SwigV8Arguments;
  1327. -typedef v8::PropertyCallbackInfo<v8::Value> SwigV8PropertyCallbackInfo;
  1328. -#define SWIGV8_RETURN(val) args.GetReturnValue().Set(val); return
  1329. -#define SWIGV8_RETURN_INFO(val, info) info.GetReturnValue().Set(val); return
  1330. -#endif
  1331. -
  1332. -
  1333. -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032117)
  1334. -#define SWIGV8_HANDLESCOPE() v8::HandleScope scope
  1335. -#define SWIGV8_HANDLESCOPE_ESC() v8::HandleScope scope
  1336. -#define SWIGV8_ESCAPE(val) return scope.Close(val)
  1337. -#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032318)
  1338. -#define SWIGV8_HANDLESCOPE() v8::HandleScope scope(v8::Isolate::GetCurrent());
  1339. -#define SWIGV8_HANDLESCOPE_ESC() v8::HandleScope scope(v8::Isolate::GetCurrent());
  1340. -#define SWIGV8_ESCAPE(val) return scope.Close(val)
  1341. -#else
  1342. -#define SWIGV8_HANDLESCOPE() v8::HandleScope scope(v8::Isolate::GetCurrent());
  1343. -#define SWIGV8_HANDLESCOPE_ESC() v8::EscapableHandleScope scope(v8::Isolate::GetCurrent());
  1344. -#define SWIGV8_ESCAPE(val) return scope.Escape(val)
  1345. -#endif
  1346. -
  1347. -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032318)
  1348. -#define SWIGV8_CURRENT_CONTEXT() v8::Context::GetCurrent()
  1349. -#define SWIGV8_STRING_NEW(str) v8::String::New(str)
  1350. -#define SWIGV8_FUNCTEMPLATE_NEW(func) v8::FunctionTemplate::New(func)
  1351. -#define SWIGV8_OBJECT_NEW() v8::Object::New()
  1352. -#define SWIGV8_EXTERNAL_NEW(val) v8::External::New(val)
  1353. -#define SWIGV8_UNDEFINED() v8::Undefined()
  1354. -#else
  1355. -#define SWIGV8_CURRENT_CONTEXT() v8::Isolate::GetCurrent()->GetCurrentContext()
  1356. -#define SWIGV8_STRING_NEW(str) v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), str)
  1357. -#define SWIGV8_FUNCTEMPLATE_NEW(func) v8::FunctionTemplate::New(v8::Isolate::GetCurrent(), func)
  1358. -#define SWIGV8_OBJECT_NEW() v8::Object::New(v8::Isolate::GetCurrent())
  1359. -#define SWIGV8_EXTERNAL_NEW(val) v8::External::New(v8::Isolate::GetCurrent(), val)
  1360. -#define SWIGV8_UNDEFINED() v8::Undefined(v8::Isolate::GetCurrent())
  1361. -#endif
  1362. -
  1363. -
  1364. -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900)
  1365. -typedef v8::Persistent<v8::Context> SwigV8Context;
  1366. -#else
  1367. -typedef v8::Local<v8::Context> SwigV8Context;
  1368. -#endif
  1369. -
  1370. -class V8Shell: public JSShell {
  1371. -
  1372. -public:
  1373. - V8Shell();
  1374. -
  1375. - virtual ~V8Shell();
  1376. -
  1377. - virtual bool RunScript(const std::string &scriptPath);
  1378. -
  1379. - virtual bool RunShell();
  1380. -
  1381. -
  1382. -protected:
  1383. -
  1384. - virtual bool InitializeEngine();
  1385. -
  1386. - virtual bool ExecuteScript(const std::string &source, const std::string &scriptPath);
  1387. -
  1388. - virtual bool DisposeEngine();
  1389. -
  1390. -private:
  1391. -
  1392. - v8::Handle<v8::Value> Import(const std::string &moduleName);
  1393. -
  1394. - SwigV8Context CreateShellContext();
  1395. -
  1396. - void ReportException(v8::TryCatch *handler);
  1397. -
  1398. - static SwigV8ReturnValue Print(const SwigV8Arguments &args);
  1399. -
  1400. - static SwigV8ReturnValue Require(const SwigV8Arguments &args);
  1401. -
  1402. - static SwigV8ReturnValue Quit(const SwigV8Arguments &args);
  1403. -
  1404. - static SwigV8ReturnValue Version(const SwigV8Arguments &args);
  1405. -
  1406. - static const char* ToCString(const v8::String::Utf8Value &value);
  1407. -
  1408. -};
  1409. -
  1410. -#ifdef __GNUC__
  1411. -#include <dlfcn.h>
  1412. -#define LOAD_SYMBOL(handle, name) dlsym(handle, name)
  1413. -#else
  1414. -#error "implement dll loading"
  1415. -#endif
  1416. -
  1417. -V8Shell::V8Shell() {}
  1418. -
  1419. -V8Shell::~V8Shell() {}
  1420. -
  1421. -bool V8Shell::RunScript(const std::string &scriptPath) {
  1422. - std::string source = ReadFile(scriptPath);
  1423. -
  1424. - v8::Isolate *isolate = v8::Isolate::New();
  1425. - v8::Isolate::Scope isolate_scope(isolate);
  1426. -
  1427. - SWIGV8_HANDLESCOPE();
  1428. -
  1429. - SwigV8Context context = CreateShellContext();
  1430. -
  1431. - if (context.IsEmpty()) {
  1432. - printf("Could not create context.\n");
  1433. - return false;
  1434. - }
  1435. -
  1436. - context->Enter();
  1437. -
  1438. - // Store a pointer to this shell for later use
  1439. -
  1440. - v8::Handle<v8::Object> global = context->Global();
  1441. - v8::Local<v8::External> __shell__ = SWIGV8_EXTERNAL_NEW((void*) (long) this);
  1442. -
  1443. - global->SetHiddenValue(SWIGV8_STRING_NEW("__shell__"), __shell__);
  1444. -
  1445. - // Node.js compatibility: make `print` available as `console.log()`
  1446. - ExecuteScript("var console = {}; console.log = print;", "<console>");
  1447. -
  1448. - bool success = ExecuteScript(source, scriptPath);
  1449. -
  1450. - // Cleanup
  1451. -
  1452. - context->Exit();
  1453. -
  1454. -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
  1455. - context.Dispose();
  1456. -#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900)
  1457. - context.Dispose(v8::Isolate::GetCurrent());
  1458. -#else
  1459. -// context.Dispose();
  1460. -#endif
  1461. -
  1462. -// v8::V8::Dispose();
  1463. -
  1464. - return success;
  1465. -}
  1466. -
  1467. -bool V8Shell::RunShell() {
  1468. - SWIGV8_HANDLESCOPE();
  1469. -
  1470. - SwigV8Context context = CreateShellContext();
  1471. -
  1472. - if (context.IsEmpty()) {
  1473. - printf("Could not create context.\n");
  1474. - return false;
  1475. - }
  1476. -
  1477. - context->Enter();
  1478. -
  1479. - v8::Context::Scope context_scope(context);
  1480. -
  1481. - ExecuteScript("var console = {}; console.log = print;", "<console>");
  1482. -
  1483. - static const int kBufferSize = 1024;
  1484. - while (true) {
  1485. - char buffer[kBufferSize];
  1486. - printf("> ");
  1487. - char *str = fgets(buffer, kBufferSize, stdin);
  1488. - if (str == NULL) break;
  1489. - std::string source(str);
  1490. - ExecuteScript(source, "(shell)");
  1491. - }
  1492. - printf("\n");
  1493. -
  1494. - // Cleanup
  1495. -
  1496. - context->Exit();
  1497. -
  1498. -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
  1499. - context.Dispose();
  1500. -#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900)
  1501. - context.Dispose(v8::Isolate::GetCurrent());
  1502. -#else
  1503. -// context.Dispose();
  1504. -#endif
  1505. -
  1506. -// v8::V8::Dispose();
  1507. -
  1508. - return true;
  1509. -}
  1510. -
  1511. -
  1512. -bool V8Shell::InitializeEngine() {
  1513. - return true;
  1514. -}
  1515. -
  1516. -bool V8Shell::ExecuteScript(const std::string &source, const std::string &name) {
  1517. - SWIGV8_HANDLESCOPE();
  1518. -
  1519. - v8::TryCatch try_catch;
  1520. - v8::Handle<v8::Script> script = v8::Script::Compile(SWIGV8_STRING_NEW(source.c_str()), SWIGV8_STRING_NEW(name.c_str()));
  1521. -
  1522. - // Stop if script is empty
  1523. - if (script.IsEmpty()) {
  1524. - // Print errors that happened during compilation.
  1525. - ReportException(&try_catch);
  1526. - return false;
  1527. - }
  1528. -
  1529. - v8::Handle<v8::Value> result = script->Run();
  1530. -
  1531. - // Print errors that happened during execution.
  1532. - if (try_catch.HasCaught()) {
  1533. - ReportException(&try_catch);
  1534. - return false;
  1535. - } else {
  1536. - return true;
  1537. - }
  1538. -}
  1539. -
  1540. -bool V8Shell::DisposeEngine() {
  1541. - return true;
  1542. -}
  1543. -
  1544. -SwigV8Context V8Shell::CreateShellContext() {
  1545. - // Create a template for the global object.
  1546. - v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New();
  1547. -
  1548. - // Bind global functions
  1549. - global->Set(SWIGV8_STRING_NEW("print"), SWIGV8_FUNCTEMPLATE_NEW(V8Shell::Print));
  1550. - global->Set(SWIGV8_STRING_NEW("quit"), SWIGV8_FUNCTEMPLATE_NEW(V8Shell::Quit));
  1551. - global->Set(SWIGV8_STRING_NEW("require"), SWIGV8_FUNCTEMPLATE_NEW(V8Shell::Require));
  1552. - global->Set(SWIGV8_STRING_NEW("version"), SWIGV8_FUNCTEMPLATE_NEW(V8Shell::Version));
  1553. -
  1554. -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900)
  1555. - SwigV8Context context = v8::Context::New(NULL, global);
  1556. - return context;
  1557. -#else
  1558. - SwigV8Context context = v8::Context::New(v8::Isolate::GetCurrent(), NULL, global);
  1559. - return context;
  1560. -#endif
  1561. -}
  1562. -
  1563. -v8::Handle<v8::Value> V8Shell::Import(const std::string &module_path)
  1564. -{
  1565. - SWIGV8_HANDLESCOPE_ESC();
  1566. -
  1567. - HANDLE library;
  1568. - std::string module_name = LoadModule(module_path, &library);
  1569. -
  1570. - std::string symname = std::string(module_name).append("_initialize");
  1571. -
  1572. - V8ExtensionInitializer init_function = reinterpret_cast<V8ExtensionInitializer>((long) LOAD_SYMBOL(library, symname.c_str()));
  1573. -
  1574. - if(init_function == 0) {
  1575. - printf("Could not find initializer function.");
  1576. -
  1577. - return SWIGV8_UNDEFINED();
  1578. - }
  1579. -
  1580. - v8::Local<v8::Object> module = SWIGV8_OBJECT_NEW();
  1581. - init_function(module);
  1582. -
  1583. - SWIGV8_ESCAPE(module);
  1584. -}
  1585. -
  1586. -SwigV8ReturnValue V8Shell::Print(const SwigV8Arguments &args) {
  1587. - SWIGV8_HANDLESCOPE();
  1588. -
  1589. - bool first = true;
  1590. - for (int i = 0; i < args.Length(); i++) {
  1591. -
  1592. - if (first) {
  1593. - first = false;
  1594. - } else {
  1595. - printf(" ");
  1596. - }
  1597. - v8::String::Utf8Value str(args[i]);
  1598. - const char *cstr = V8Shell::ToCString(str);
  1599. - printf("%s", cstr);
  1600. - }
  1601. - printf("\n");
  1602. - fflush(stdout);
  1603. -
  1604. - SWIGV8_RETURN(SWIGV8_UNDEFINED());
  1605. -}
  1606. -
  1607. -SwigV8ReturnValue V8Shell::Require(const SwigV8Arguments &args) {
  1608. - SWIGV8_HANDLESCOPE();
  1609. -
  1610. - if (args.Length() != 1) {
  1611. - printf("Illegal arguments for `require`");
  1612. - };
  1613. -
  1614. - v8::String::Utf8Value str(args[0]);
  1615. - const char *cstr = V8Shell::ToCString(str);
  1616. - std::string moduleName(cstr);
  1617. -
  1618. - v8::Local<v8::Object> global = SWIGV8_CURRENT_CONTEXT()->Global();
  1619. -
  1620. - v8::Local<v8::Value> hidden = global->GetHiddenValue(SWIGV8_STRING_NEW("__shell__"));
  1621. - v8::Local<v8::External> __shell__ = v8::Local<v8::External>::Cast(hidden);
  1622. - V8Shell *_this = (V8Shell *) (long) __shell__->Value();
  1623. -
  1624. - v8::Handle<v8::Value> module = _this->Import(moduleName);
  1625. -
  1626. - SWIGV8_RETURN(module);
  1627. -}
  1628. -
  1629. -SwigV8ReturnValue V8Shell::Quit(const SwigV8Arguments &args) {
  1630. - SWIGV8_HANDLESCOPE();
  1631. -
  1632. - int exit_code = args[0]->Int32Value();
  1633. - fflush(stdout);
  1634. - fflush(stderr);
  1635. - exit(exit_code);
  1636. -
  1637. - SWIGV8_RETURN(SWIGV8_UNDEFINED());
  1638. -}
  1639. -
  1640. -SwigV8ReturnValue V8Shell::Version(const SwigV8Arguments &args) {
  1641. - SWIGV8_HANDLESCOPE();
  1642. - SWIGV8_RETURN(SWIGV8_STRING_NEW(v8::V8::GetVersion()));
  1643. -}
  1644. -
  1645. -void V8Shell::ReportException(v8::TryCatch *try_catch) {
  1646. - SWIGV8_HANDLESCOPE();
  1647. -
  1648. - v8::String::Utf8Value exception(try_catch->Exception());
  1649. - const char *exception_string = V8Shell::ToCString(exception);
  1650. - v8::Handle<v8::Message> message = try_catch->Message();
  1651. - if (message.IsEmpty()) {
  1652. - // V8 didn't provide any extra information about this error; just
  1653. - // print the exception.
  1654. - printf("%s\n", exception_string);
  1655. - } else {
  1656. - // Print (filename):(line number): (message).
  1657. - v8::String::Utf8Value filename(message->GetScriptResourceName());
  1658. - const char *filename_string = V8Shell::ToCString(filename);
  1659. - int linenum = message->GetLineNumber();
  1660. - printf("%s:%i: %s\n", filename_string, linenum, exception_string);
  1661. - // Print line of source code.
  1662. - v8::String::Utf8Value sourceline(message->GetSourceLine());
  1663. - const char *sourceline_string = V8Shell::ToCString(sourceline);
  1664. - printf("%s\n", sourceline_string);
  1665. - // Print wavy underline (GetUnderline is deprecated).
  1666. - int start = message->GetStartColumn();
  1667. - for (int i = 0; i < start; i++) {
  1668. - printf(" ");
  1669. - }
  1670. - int end = message->GetEndColumn();
  1671. - for (int i = start; i < end; i++) {
  1672. - printf("^");
  1673. - }
  1674. - printf("\n");
  1675. - v8::String::Utf8Value stack_trace(try_catch->StackTrace());
  1676. - if (stack_trace.length() > 0) {
  1677. - const char *stack_trace_string = V8Shell::ToCString(stack_trace);
  1678. - printf("%s\n", stack_trace_string);
  1679. - }
  1680. - }
  1681. -}
  1682. -
  1683. -// Extracts a C string from a V8 Utf8Value.
  1684. -const char *V8Shell::ToCString(const v8::String::Utf8Value &value) {
  1685. - return *value ? *value : "<string conversion failed>";
  1686. -}
  1687. -
  1688. -JSShell *V8Shell_Create() {
  1689. - return new V8Shell();
  1690. -}
  1691. diff --git a/Tools/travis-linux-install.sh b/Tools/travis-linux-install.sh
  1692. index c8347d27a4..2427d08230 100755
  1693. --- a/Tools/travis-linux-install.sh
  1694. +++ b/Tools/travis-linux-install.sh
  1695. @@ -39,22 +39,12 @@
  1696. [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
  1697. travis_retry nvm install ${VER}
  1698. nvm use ${VER}
  1699. - if [ "$VER" == "0.10" ] || [ "$VER" == "0.12" ] || [ "$VER" == "4" ] || [ "$VER" == "6" ] ; then
  1700. -# travis_retry sudo apt-get install -qq nodejs node-gyp
  1701. - travis_retry npm install -g node-gyp@$VER
  1702. - elif [ "$VER" == "8" ] ; then
  1703. - travis_retry npm install -g node-gyp@6
  1704. - else
  1705. - travis_retry npm install -g node-gyp
  1706. - fi
  1707. + travis_retry npm install -g node-gyp
  1708. ;;
  1709. "jsc")
  1710. travis_retry sudo apt-get install -qq libwebkitgtk-dev
  1711. ;;
  1712. - "v8")
  1713. - travis_retry sudo apt-get install -qq libv8-dev
  1714. - ;;
  1715. - esac
  1716. +
  1717. ;;
  1718. "guile")
  1719. travis_retry sudo apt-get -qq install guile-2.0-dev