From: <br...@us...> - 2010-09-20 03:09:21
|
Revision: 4201 http://openvrml.svn.sourceforge.net/openvrml/?rev=4201&view=rev Author: braden Date: 2010-09-20 03:09:12 +0000 (Mon, 20 Sep 2010) Log Message: ----------- SpiderMonkey included in the forthcoming XULRunner 1.9.3 removes JS_AddRoot and JS_RemoveRoot and replaces them with type-specific functions. Test for this and adjust our usage accordingly. Modified Paths: -------------- trunk/ChangeLog trunk/configure.ac trunk/src/script/javascript.cpp Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-09-18 20:36:20 UTC (rev 4200) +++ trunk/ChangeLog 2010-09-20 03:09:12 UTC (rev 4201) @@ -1,3 +1,12 @@ +2010-09-19 Braden McDaniel <br...@en...> + + SpiderMonkey included in the forthcoming XULRunner 1.9.3 removes + JS_AddRoot and JS_RemoveRoot and replaces them with type-specific + functions. Test for this and adjust our usage accordingly. + + * configure.ac + * src/script/javascript.cpp + 2010-09-18 Braden McDaniel <br...@en...> * src/Makefile.am (EXTRA_DIST): Fixed directory for openvrml-gl.rc Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2010-09-18 20:36:20 UTC (rev 4200) +++ trunk/configure.ac 2010-09-20 03:09:12 UTC (rev 4201) @@ -179,6 +179,27 @@ [Whether JSPropertyOp function signatures use jsid]) # +# XULRunner 1.9.3 replaced JS_{Add,Remove}Root with type-specific +# functions. +# +AC_CACHE_CHECK([whether SpiderMonkey uses type-specific root functions], +[ov_cv_js_uses_typed_root_functions], +[ov_cv_js_uses_typed_root_functions=no +ov_save_CPPFLAGS=$CPPFLAGS +CPPFLAGS="$JS_CFLAGS $CPPFLAGS" +AC_LANG_PUSH([C]) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM( +[[#include <jsapi.h>]], +[[JS_AddNamedRoot(0, 0);]])], +[ov_cv_js_uses_typed_root_functions=yes]) +AC_LANG_POP([C]) +CPPFLAGS=$ov_save_CPPFLAGS +]) +AS_IF([test X$ov_cv_js_uses_typed_root_functions = Xyes], + [AC_DEFINE([OPENVRML_JS_HAS_TYPED_ROOT_FUNCTIONS], [1], + [Defined if SpiderMonkey uses type-specific add/remove root functions])]) + +# # openvrml-xembed and openvrml-player both use GOption, which was # introduced in GLib 2.6. # Modified: trunk/src/script/javascript.cpp =================================================================== --- trunk/src/script/javascript.cpp 2010-09-18 20:36:20 UTC (rev 4200) +++ trunk/src/script/javascript.cpp 2010-09-20 03:09:12 UTC (rev 4201) @@ -62,6 +62,26 @@ # endif } + OPENVRML_LOCAL JSBool add_value_root(JSContext * const cx, + jsval * const vp) + { +# ifdef OPENVRML_JS_HAS_TYPED_ROOT_FUNCTIONS + return JS_AddValueRoot(cx, vp); +# else + return JS_AddRoot(cx, vp); +# endif + } + + OPENVRML_LOCAL JSBool remove_value_root(JSContext * const cx, + jsval * const vp) + { +# ifdef OPENVRML_JS_HAS_TYPED_ROOT_FUNCTIONS + return JS_RemoveValueRoot(cx, vp); +# else + return JS_RemoveRoot(cx, vp); +# endif + } + class SFNode; class MFNode; @@ -1266,7 +1286,7 @@ assert(argv[i]); jsargv[i] = vrmlFieldToJSVal(*argv[i]); if (JSVAL_IS_GCTHING(jsargv[i])) { - if (!JS_AddRoot(this->cx, &jsargv[i])) { + if (!add_value_root(this->cx, &jsargv[i])) { throw std::bad_alloc(); } } @@ -1284,7 +1304,7 @@ for (i = 0; i < argc; ++i) { assert(jsargv[i] != JSVAL_NULL); if (JSVAL_IS_GCTHING(jsargv[i])) { - ok = JS_RemoveRoot(cx, &jsargv[i]); + ok = remove_value_root(cx, &jsargv[i]); assert(ok); } } @@ -2000,7 +2020,7 @@ if (!JS_NewNumberValue(cx, floats[i], &jsvec[i])) { return JS_FALSE; } - if (!JS_AddRoot(cx, &jsvec[i])) { return JS_FALSE; } + if (!add_value_root(cx, &jsvec[i])) { return JS_FALSE; } } JSObject * arr = 0; @@ -2009,7 +2029,7 @@ if (arr) { *rval = OBJECT_TO_JSVAL(arr); } } - for (size_t j = 0; j < i; ++j) { JS_RemoveRoot(cx, &jsvec[j]); } + for (size_t j = 0; j < i; ++j) { remove_value_root(cx, &jsvec[j]); } if (!arr) { return JS_FALSE; } @@ -5346,11 +5366,11 @@ size_t i; try { for (i = 0; i < jsvalArray.size(); ++i) { - if (!JS_AddRoot(cx, &jsvalArray[i])) { throw bad_alloc(); } + if (!add_value_root(cx, &jsvalArray[i])) { throw bad_alloc(); } } } catch (bad_alloc &) { for (size_t j = 0; j < i - 1; ++j) { - JS_RemoveRoot(cx, &jsvalArray[j]); + remove_value_root(cx, &jsvalArray[j]); } throw; } @@ -5360,7 +5380,7 @@ OPENVRML_NOTHROW { for (size_t i = 0; i < jsvalArray.size(); ++i) { - const JSBool ok = JS_RemoveRoot(cx, &jsvalArray[i]); + const JSBool ok = remove_value_root(cx, &jsvalArray[i]); assert(ok); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |