diff --git a/scripting/javascript/bindings/ScriptingCore.cpp b/scripting/javascript/bindings/ScriptingCore.cpp index d69e293603..864c0b63c4 100644 --- a/scripting/javascript/bindings/ScriptingCore.cpp +++ b/scripting/javascript/bindings/ScriptingCore.cpp @@ -459,7 +459,9 @@ JSBool ScriptingCore::runScript(const char *path, JSObject* global, JSContext* c js::RootedObject obj(cx, global); JS::CompileOptions options(cx); - options.setUTF8(true).setFileAndLine(rpath.c_str(), 1); + options.setFileAndLine(rpath.c_str(), 1); + // Don't setUTF8 since it will cause messy string output by cc.log . +// options.setUTF8(true).setFileAndLine(rpath.c_str(), 1); // this will always compile the script, we can actually check if the script // was compiled before, because it can be in the global map @@ -1622,13 +1624,7 @@ JSBool JSBDebug_BufferWrite(JSContext* cx, unsigned argc, jsval* vp) { if (argc == 1) { jsval* argv = JS_ARGV(cx, vp); - const char* str; - - JSString* jsstr = JS_ValueToString(cx, argv[0]); - // Not supported in SpiderMonkey v19 - //str = JS_EncodeString(cx, jsstr); - JSStringWrapper strWrapper(jsstr); - + JSStringWrapper strWrapper(argv[0]); // this is safe because we're already inside a lock (from clearBuffers) outData.append(strWrapper.get()); } diff --git a/scripting/javascript/bindings/ScriptingCore.h b/scripting/javascript/bindings/ScriptingCore.h index a18e145dd6..2ce1d9e237 100644 --- a/scripting/javascript/bindings/ScriptingCore.h +++ b/scripting/javascript/bindings/ScriptingCore.h @@ -267,8 +267,7 @@ public: } ~JSStringWrapper() { if (buffer) { -// JS_free(ScriptingCore::getInstance()->getGlobalContext(), (void*)buffer); - CC_SAFE_DELETE_ARRAY(buffer); + JS_free(ScriptingCore::getInstance()->getGlobalContext(), (void*)buffer); } } void set(jsval val, JSContext* cx) { @@ -283,14 +282,7 @@ public: if (!cx) { cx = ScriptingCore::getInstance()->getGlobalContext(); } - // Not suppored in SpiderMonkey v19 - //buffer = JS_EncodeString(cx, string); - - const jschar *chars = JS_GetStringCharsZ(cx, string); - size_t l = JS_GetStringLength(string); - char* pUTF8Str = cc_utf16_to_utf8((const unsigned short*)chars, l, NULL, NULL); - buffer = pUTF8Str; - + buffer = JS_EncodeString(cx, string); } std::string get() { return buffer; diff --git a/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id b/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id index 86822eed37..7d2c874a13 100644 --- a/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id +++ b/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id @@ -1 +1 @@ -e4b7d86461a17a555283bbc28cba2ab48cab21cd \ No newline at end of file +c12cdcc2ffa853b5b702ed1347279ff7fa076974 \ No newline at end of file diff --git a/scripting/javascript/bindings/js_bindings_core.cpp b/scripting/javascript/bindings/js_bindings_core.cpp index d3b7971c34..8297f7b011 100644 --- a/scripting/javascript/bindings/js_bindings_core.cpp +++ b/scripting/javascript/bindings/js_bindings_core.cpp @@ -80,12 +80,8 @@ JSBool JSBCore_log(JSContext *cx, uint32_t argc, jsval *vp) JSString *string = NULL; JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "S", &string); if (string) { - // Not supported in SpiderMonkey v19 - //char *cstr = JS_EncodeString(cx, string); - const jschar *chars = JS_GetStringCharsZ(cx, string); - size_t l = JS_GetStringLength(string); - char* pUTF8Str = cc_utf16_to_utf8((const unsigned short*)chars, l, NULL, NULL); - CCLOG(pUTF8Str); + JSAutoByteString log_str(cx, string); + CCLOG(log_str.ptr()); } return JS_TRUE; diff --git a/scripting/javascript/bindings/js_manual_conversions.cpp b/scripting/javascript/bindings/js_manual_conversions.cpp index 7bf9db68c8..bc2b42f650 100644 --- a/scripting/javascript/bindings/js_manual_conversions.cpp +++ b/scripting/javascript/bindings/js_manual_conversions.cpp @@ -199,8 +199,6 @@ JSBool jsval_to_charptr( JSContext *cx, jsval vp, const char **ret ) // root it vp = STRING_TO_JSVAL(jsstr); - // Not supported in SpiderMonkey v19 - //char *ptr = JS_EncodeString(cx, jsstr); JSStringWrapper strWrapper(jsstr); // XXX: It is converted to CCString and then back to char* to autorelease the created object.