From 8b0731376bf609ef78e43c68b8a87b287c40ecf1 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Fri, 18 Jan 2013 14:30:32 -0500 Subject: [PATCH] Bug 832141 - Rename js_ValueToSource to ValueToSource and make it internal. r=luke --- js/src/builtin/Object.cpp | 2 +- js/src/jsapi.cpp | 2 +- js/src/jsarray.cpp | 2 +- js/src/jsexn.cpp | 4 ++-- js/src/jsopcode.cpp | 18 +++++++++--------- js/src/jsstr.cpp | 8 ++++---- js/src/jsstr.h | 7 +++---- 7 files changed, 21 insertions(+), 22 deletions(-) diff --git a/js/src/builtin/Object.cpp b/js/src/builtin/Object.cpp index efe577a5026..77ea53c2695 100644 --- a/js/src/builtin/Object.cpp +++ b/js/src/builtin/Object.cpp @@ -212,7 +212,7 @@ obj_toSource(JSContext *cx, unsigned argc, Value *vp) continue; /* Convert val[j] to its canonical source form. */ - RootedString valstr(cx, js_ValueToSource(cx, val[j])); + RootedString valstr(cx, ValueToSource(cx, val[j])); if (!valstr) return false; const jschar *vchars = valstr->getChars(cx); diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index 46c86aae0e5..5f902d59ea1 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -491,7 +491,7 @@ JS_ValueToSource(JSContext *cx, jsval valueArg) AssertHeapIsIdle(cx); CHECK_REQUEST(cx); assertSameCompartment(cx, value); - return js_ValueToSource(cx, value); + return ValueToSource(cx, value); } JS_PUBLIC_API(JSBool) diff --git a/js/src/jsarray.cpp b/js/src/jsarray.cpp index f69861fbc36..6c53dccf4df 100644 --- a/js/src/jsarray.cpp +++ b/js/src/jsarray.cpp @@ -652,7 +652,7 @@ array_toSource_impl(JSContext *cx, CallArgs args) if (hole) { str = cx->runtime->emptyString; } else { - str = js_ValueToSource(cx, elt); + str = ValueToSource(cx, elt); if (!str) return false; } diff --git a/js/src/jsexn.cpp b/js/src/jsexn.cpp index a1eb707ff34..f7ba6569d27 100644 --- a/js/src/jsexn.cpp +++ b/js/src/jsexn.cpp @@ -708,7 +708,7 @@ exn_toSource(JSContext *cx, unsigned argc, Value *vp) RootedValue messageVal(cx); RootedString message(cx); if (!JSObject::getProperty(cx, obj, obj, cx->names().message, &messageVal) || - !(message = js_ValueToSource(cx, messageVal))) + !(message = ValueToSource(cx, messageVal))) { return false; } @@ -716,7 +716,7 @@ exn_toSource(JSContext *cx, unsigned argc, Value *vp) RootedValue filenameVal(cx); RootedString filename(cx); if (!JSObject::getProperty(cx, obj, obj, cx->names().fileName, &filenameVal) || - !(filename = js_ValueToSource(cx, filenameVal))) + !(filename = ValueToSource(cx, filenameVal))) { return false; } diff --git a/js/src/jsopcode.cpp b/js/src/jsopcode.cpp index 51cd6f8862a..f0435b8bb17 100644 --- a/js/src/jsopcode.cpp +++ b/js/src/jsopcode.cpp @@ -4938,7 +4938,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, int nb) case JSOP_OBJECT: obj = jp->script->getObject(GET_UINT32_INDEX(pc)); - str = js_ValueToSource(cx, ObjectValue(*obj)); + str = ValueToSource(cx, ObjectValue(*obj)); if (!str) return NULL; goto sprint_string; @@ -6053,7 +6053,7 @@ ExpressionDecompiler::decompilePC(jsbytecode *pc) JSObject *obj = (op == JSOP_REGEXP) ? script->getRegExp(GET_UINT32_INDEX(pc)) : script->getObject(GET_UINT32_INDEX(pc)); - JSString *str = js_ValueToSource(cx, ObjectValue(*obj)); + JSString *str = ValueToSource(cx, ObjectValue(*obj)); if (!str) return false; return write(str); @@ -6286,7 +6286,7 @@ js::DecompileValueGenerator(JSContext *cx, int spindex, HandleValue v, if (!fallback) { if (v.isUndefined()) return JS_strdup(cx, js_undefined_str); // Prevent users from seeing "(void 0)" - fallback = js_ValueToSource(cx, v); + fallback = ValueToSource(cx, v); if (!fallback) return NULL; } @@ -6378,7 +6378,7 @@ js::DecompileArgument(JSContext *cx, int formalIndex, HandleValue v) } if (v.isUndefined()) return JS_strdup(cx, js_undefined_str); // Prevent users from seeing "(void 0)" - RootedString fallback(cx, js_ValueToSource(cx, v)); + RootedString fallback(cx, ValueToSource(cx, v)); if (!fallback) return NULL; @@ -6928,7 +6928,7 @@ js::GetPCCountScriptSummary(JSContext *cx, size_t index) AppendJSONProperty(buf, "file", NO_COMMA); JSString *str = JS_NewStringCopyZ(cx, script->filename); - if (!str || !(str = JS_ValueToSource(cx, StringValue(str)))) + if (!str || !(str = ValueToSource(cx, StringValue(str)))) return NULL; buf.append(str); @@ -6939,7 +6939,7 @@ js::GetPCCountScriptSummary(JSContext *cx, size_t index) JSAtom *atom = script->function()->displayAtom(); if (atom) { AppendJSONProperty(buf, "name"); - if (!(str = JS_ValueToSource(cx, StringValue(atom)))) + if (!(str = ValueToSource(cx, StringValue(atom)))) return NULL; buf.append(str); } @@ -7055,7 +7055,7 @@ GetPCCountJSON(JSContext *cx, const ScriptAndCounts &sac, StringBuffer &buf) return false; } JSString *str = js_GetPrinterOutput(jp); - if (!str || !(str = JS_ValueToSource(cx, StringValue(str)))) + if (!str || !(str = ValueToSource(cx, StringValue(str)))) return false; buf.append(str); @@ -7118,7 +7118,7 @@ GetPCCountJSON(JSContext *cx, const ScriptAndCounts &sac, StringBuffer &buf) if (text && *text != 0) { AppendJSONProperty(buf, "text"); JSString *str = JS_NewStringCopyZ(cx, text); - if (!str || !(str = JS_ValueToSource(cx, StringValue(str)))) + if (!str || !(str = ValueToSource(cx, StringValue(str)))) return false; buf.append(str); } @@ -7179,7 +7179,7 @@ GetPCCountJSON(JSContext *cx, const ScriptAndCounts &sac, StringBuffer &buf) AppendJSONProperty(buf, "code"); JSString *str = JS_NewStringCopyZ(cx, block.code()); - if (!str || !(str = JS_ValueToSource(cx, StringValue(str)))) + if (!str || !(str = ValueToSource(cx, StringValue(str)))) return false; buf.append(str); diff --git a/js/src/jsstr.cpp b/js/src/jsstr.cpp index 8fd1c8421a5..30064e2b337 100644 --- a/js/src/jsstr.cpp +++ b/js/src/jsstr.cpp @@ -339,7 +339,7 @@ static JSBool str_uneval(JSContext *cx, unsigned argc, Value *vp) { CallArgs args = CallArgsFromVp(argc, vp); - JSString *str = js_ValueToSource(cx, args.length() != 0 ? args[0] : UndefinedValue()); + JSString *str = ValueToSource(cx, args.length() != 0 ? args[0] : UndefinedValue()); if (!str) return false; @@ -3566,7 +3566,7 @@ js_ValueToPrintable(JSContext *cx, const Value &v, JSAutoByteString *bytes, bool { JSString *str; - str = (asSource ? js_ValueToSource : ToString)(cx, v); + str = (asSource ? ValueToSource : ToString)(cx, v); if (!str) return NULL; str = js_QuoteString(cx, str, 0); @@ -3602,8 +3602,8 @@ js::ToStringSlow(JSContext *cx, const Value &arg) return str; } -JS_FRIEND_API(JSString *) -js_ValueToSource(JSContext *cx, const Value &v) +JSString * +js::ValueToSource(JSContext *cx, const Value &v) { JS_CHECK_RECURSION(cx, return NULL); diff --git a/js/src/jsstr.h b/js/src/jsstr.h index 7d63bbd0e48..533968f9db9 100644 --- a/js/src/jsstr.h +++ b/js/src/jsstr.h @@ -149,14 +149,13 @@ ValueToStringBuffer(JSContext *cx, const Value &v, StringBuffer &sb); } /* namespace js */ +namespace js { /* * Convert a value to its source expression, returning null after reporting * an error, otherwise returning a new string reference. */ -extern JS_FRIEND_API(JSString *) -js_ValueToSource(JSContext *cx, const js::Value &v); - -namespace js { +extern JSString * +ValueToSource(JSContext *cx, const js::Value &v); /* * Test if strings are equal. The caller can call the function even if str1