Bug 832141 - Rename js_ValueToSource to ValueToSource and make it internal. r=luke

This commit is contained in:
Benjamin Peterson 2013-01-18 14:30:32 -05:00
parent b8e8e1bc08
commit 8b0731376b
7 changed files with 21 additions and 22 deletions

View File

@ -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);

View File

@ -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)

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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);

View File

@ -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