From: <br...@us...> - 2011-01-23 22:31:13
|
Revision: 4210 http://openvrml.svn.sourceforge.net/openvrml/?rev=4210&view=rev Author: braden Date: 2011-01-23 22:31:07 +0000 (Sun, 23 Jan 2011) Log Message: ----------- Use JS_EncodeString instead of the obsolete JS_GetStringBytes. Modified Paths: -------------- trunk/configure.ac trunk/src/script/javascript.cpp Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2011-01-23 08:32:32 UTC (rev 4209) +++ trunk/configure.ac 2011-01-23 22:31:07 UTC (rev 4210) @@ -132,8 +132,11 @@ PKG_CHECK_MODULES([FONTCONFIG], [fontconfig >= 2.3.0], , [have_fontconfig=no]) PKG_CHECK_MODULES([FREETYPE], [freetype2 >= 2.2], , [have_freetype=no]) +# +# Require at least XULRunner 1.9 for JS_EncodeString. +# have_libmozjs=yes -PKG_CHECK_MODULES([JS], [mozilla-js >= 1.8.1.8], , [have_libmozjs=no]) +PKG_CHECK_MODULES([JS], [mozilla-js >= 1.9], , [have_libmozjs=no]) # # JS_BeginRequest should be there only if SpiderMonkey was built with # -DJS_THREADSAFE. Modified: trunk/src/script/javascript.cpp =================================================================== --- trunk/src/script/javascript.cpp 2011-01-23 08:32:32 UTC (rev 4209) +++ trunk/src/script/javascript.cpp 2011-01-23 22:31:07 UTC (rev 4210) @@ -1686,7 +1686,7 @@ JSString * const str = JS_ValueToString(cx, id); if (!str) { return JS_FALSE; } - const char * const eventId = JS_GetStringBytes(str); + const char * const eventId = JS_EncodeString(cx, str); // // The script object pointer is stored as private data in the @@ -1741,7 +1741,7 @@ JSString * const str = JS_ValueToString(cx, id); if (!str) { return JS_FALSE; } - const char * const fieldId = JS_GetStringBytes(str); + const char * const fieldId = JS_EncodeString(cx, str); // // The script object pointer is stored as private data in the @@ -2126,7 +2126,7 @@ // return auto_ptr<field_value> (new sfstring(jsstring - ? JS_GetStringBytes(jsstring) + ? JS_EncodeString(cx, jsstring) : "")); } @@ -2242,7 +2242,7 @@ JSString * const str = JS_ValueToString(cx, argv[i]); if (!str) { return JS_FALSE; } s->script_node().scene()->browser() - .out(JS_GetStringBytes(str)); + .out(JS_EncodeString(cx, str)); } return JS_TRUE; } @@ -2435,7 +2435,7 @@ if (!str) { return JS_FALSE; } try { - std::istringstream in(JS_GetStringBytes(str)); + std::istringstream in(JS_EncodeString(cx, str)); assert(s.script_node().scene()); openvrml::browser & browser = s.script_node().scene()->browser(); @@ -2494,7 +2494,7 @@ return JS_FALSE; } - const char * const event = JS_GetStringBytes(event_str); + const char * const event = JS_EncodeString(cx, event_str); try { s.script_node().scene() @@ -2549,7 +2549,7 @@ // JSString * arg1_str = JS_ValueToString(cx, argv[1]); if (!arg1_str) { return JS_FALSE; } - const char * const fromEventOut = JS_GetStringBytes(arg1_str); + const char * const fromEventOut = JS_EncodeString(cx, arg1_str); // // Make sure our third argument (toNode) is a SFNode. @@ -2574,7 +2574,7 @@ // JSString * arg3_str = JS_ValueToString(cx, argv[3]); if (!arg3_str) { return JS_FALSE; } - const char * const toEventIn = JS_GetStringBytes(arg3_str); + const char * const toEventIn = JS_EncodeString(cx, arg3_str); try { add_route(*fromNode->value(), @@ -2619,7 +2619,7 @@ // JSString * arg1_str = JS_ValueToString(cx, argv[1]); if (!arg1_str) { return JS_FALSE; } - const char * const fromEventOut = JS_GetStringBytes(arg1_str); + const char * const fromEventOut = JS_EncodeString(cx, arg1_str); // // Make sure our third argument (toNode) is a SFNode. @@ -2637,7 +2637,7 @@ // JSString * arg3_str = JS_ValueToString(cx, argv[3]); if (!arg3_str) { return JS_FALSE; } - const char * const toEventIn = JS_GetStringBytes(arg3_str); + const char * const toEventIn = JS_EncodeString(cx, arg3_str); delete_route(*fromNode->value(), fromEventOut, @@ -2660,7 +2660,7 @@ assert(JS_GetContextPrivate(cx)); script & s = *static_cast<script *>(JS_GetContextPrivate(cx)); openvrml::browser & browser = s.script_node().scene()->browser(); - browser.description(JS_GetStringBytes(str)); + browser.description(JS_EncodeString(cx, str)); *rval = JSVAL_VOID; return JS_TRUE; } @@ -3397,7 +3397,7 @@ assert(JS_GetContextPrivate(cx)); script & s = *static_cast<script *>(JS_GetContextPrivate(cx)); - istringstream in(JS_GetStringBytes(vrmlstring)); + istringstream in(JS_EncodeString(cx, vrmlstring)); assert(s.script_node().scene()); openvrml::browser & browser = s.script_node().scene()->browser(); @@ -3455,7 +3455,7 @@ script & s = *static_cast<script *>(JS_GetContextPrivate(cx)); try { - const char * eventOut = JS_GetStringBytes(JSVAL_TO_STRING(id)); + const char * eventOut = JS_EncodeString(cx, JSVAL_TO_STRING(id)); openvrml::event_emitter & emitter = thisNode.value()->event_emitter(eventOut); *vp = s.vrmlFieldToJSVal(emitter.value()); @@ -3487,7 +3487,8 @@ boost::intrusive_ptr<openvrml::node> nodePtr = thisNode.value(); - const char * const eventInId = JS_GetStringBytes(JSVAL_TO_STRING(id)); + const char * const eventInId = + JS_EncodeString(cx, JSVAL_TO_STRING(id)); try { using boost::shared_ptr; @@ -7044,7 +7045,7 @@ for (MField::JsvalArray::size_type i = 0; i < mfdata->array.size(); ++i) { assert(JSVAL_IS_STRING(mfdata->array[i])); const char * const str = - JS_GetStringBytes(JSVAL_TO_STRING(mfdata->array[i])); + JS_EncodeString(cx, JSVAL_TO_STRING(mfdata->array[i])); temp[i] = str; } mfstring->value(temp); @@ -7208,7 +7209,7 @@ for (JsvalArray::size_type i = 0; i < mfdata->array.size(); ++i) { assert(JSVAL_IS_STRING(mfdata->array[i])); out << '\"' - << JS_GetStringBytes(JSVAL_TO_STRING(mfdata->array[i])) + << JS_EncodeString(cx, JSVAL_TO_STRING(mfdata->array[i])) << '\"'; if ((i + 1) < mfdata->array.size()) { out << ", "; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |