mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
Bug 933834 - Rename and handlify JS_ValueToString. r=terrence,bz
This commit is contained in:
parent
ab661fadf8
commit
bc757ef965
@ -112,10 +112,10 @@ IDToString(JSContext *cx, jsid id_)
|
||||
if (JSID_IS_STRING(id))
|
||||
return JS_GetInternedStringChars(JSID_TO_STRING(id));
|
||||
|
||||
JS::Value idval;
|
||||
if (!JS_IdToValue(cx, id, &idval))
|
||||
JS::Rooted<JS::Value> idval(cx);
|
||||
if (!JS_IdToValue(cx, id, idval.address()))
|
||||
return nullptr;
|
||||
JSString *str = JS_ValueToString(cx, idval);
|
||||
JSString *str = JS::ToString(cx, idval);
|
||||
if(!str)
|
||||
return nullptr;
|
||||
return JS_GetStringCharsZ(cx, str);
|
||||
|
@ -268,7 +268,7 @@ nsDOMMultipartFile::ParseBlobArrayArgument(JSContext* aCx, JS::Value& aValue,
|
||||
}
|
||||
|
||||
// coerce it to a string
|
||||
JSString* str = JS_ValueToString(aCx, element);
|
||||
JSString* str = JS::ToString(aCx, element);
|
||||
NS_ENSURE_TRUE(str, NS_ERROR_TYPE_ERR);
|
||||
blobSet.AppendString(str, aNativeEOL, aCx);
|
||||
}
|
||||
@ -342,7 +342,7 @@ nsDOMMultipartFile::InitChromeFile(JSContext* aCx,
|
||||
mIsFromNsiFile = true;
|
||||
} else {
|
||||
// It's a string
|
||||
JSString* str = JS_ValueToString(aCx, aArgv[0]);
|
||||
JSString* str = JS::ToString(aCx, JS::Handle<JS::Value>::fromMarkedLocation(&aArgv[0]));
|
||||
NS_ENSURE_TRUE(str, NS_ERROR_XPC_BAD_CONVERT_JS);
|
||||
|
||||
nsDependentJSString xpcomStr;
|
||||
@ -397,7 +397,7 @@ nsDOMMultipartFile::InitFile(JSContext* aCx,
|
||||
}
|
||||
|
||||
// File name
|
||||
JSString* str = JS_ValueToString(aCx, aArgv[1]);
|
||||
JSString* str = JS::ToString(aCx, JS::Handle<JS::Value>::fromMarkedLocation(&aArgv[1]));
|
||||
NS_ENSURE_TRUE(str, NS_ERROR_XPC_BAD_CONVERT_JS);
|
||||
|
||||
nsDependentJSString xpcomStr;
|
||||
|
@ -1444,8 +1444,8 @@ txVariable::Convert(nsIVariant *aValue, txAExprResult** aResult)
|
||||
JS::Rooted<JSObject*> jsobj(cx, holder->GetJSObject());
|
||||
NS_ENSURE_STATE(jsobj);
|
||||
|
||||
JS::Rooted<JSString*> str(cx,
|
||||
JS_ValueToString(cx, OBJECT_TO_JSVAL(jsobj)));
|
||||
JS::Rooted<JS::Value> v(cx, JS::ObjectValue(*jsobj));
|
||||
JS::Rooted<JSString*> str(cx, JS::ToString(cx, v));
|
||||
NS_ENSURE_TRUE(str, NS_ERROR_FAILURE);
|
||||
|
||||
nsDependentJSString value;
|
||||
|
@ -677,7 +677,7 @@ AudioChannelService::Observe(nsISupports* aSubject, const char* aTopic, const PR
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
JS::Rooted<JSString*> jsKey(cx, JS_ValueToString(cx, key));
|
||||
JS::Rooted<JSString*> jsKey(cx, JS::ToString(cx, key));
|
||||
if (!jsKey) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -616,10 +616,10 @@ IdToString(JSContext *cx, jsid id)
|
||||
{
|
||||
if (JSID_IS_STRING(id))
|
||||
return JSID_TO_STRING(id);
|
||||
jsval idval;
|
||||
if (!::JS_IdToValue(cx, id, &idval))
|
||||
JS::Rooted<JS::Value> idval(cx);
|
||||
if (!::JS_IdToValue(cx, id, idval.address()))
|
||||
return nullptr;
|
||||
return JS_ValueToString(cx, idval);
|
||||
return JS::ToString(cx, idval);
|
||||
}
|
||||
|
||||
static inline nsresult
|
||||
@ -3292,7 +3292,7 @@ LocationSetterGuts(JSContext *cx, JSObject *obj, JS::MutableHandle<JS::Value> vp
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Grab the value we're being set to before we stomp on |vp|
|
||||
JS::Rooted<JSString*> val(cx, ::JS_ValueToString(cx, vp));
|
||||
JS::Rooted<JSString*> val(cx, JS::ToString(cx, vp));
|
||||
NS_ENSURE_TRUE(val, NS_ERROR_UNEXPECTED);
|
||||
|
||||
// Make sure |val| stays alive below
|
||||
@ -4198,9 +4198,10 @@ nsHTMLDocumentSH::ReleaseDocument(JSFreeOp *fop, JSObject *obj)
|
||||
bool
|
||||
nsHTMLDocumentSH::CallToGetPropMapper(JSContext *cx, unsigned argc, jsval *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
// Handle document.all("foo") style access to document.all.
|
||||
|
||||
if (argc != 1) {
|
||||
if (args.length() != 1) {
|
||||
// XXX: Should throw NS_ERROR_XPC_NOT_ENOUGH_ARGS for argc < 1,
|
||||
// and create a new NS_ERROR_XPC_TOO_MANY_ARGS for argc > 1? IE
|
||||
// accepts nothing other than one arg.
|
||||
@ -4210,7 +4211,7 @@ nsHTMLDocumentSH::CallToGetPropMapper(JSContext *cx, unsigned argc, jsval *vp)
|
||||
}
|
||||
|
||||
// Convert all types to string.
|
||||
JS::Rooted<JSString*> str(cx, ::JS_ValueToString(cx, JS_ARGV(cx, vp)[0]));
|
||||
JS::Rooted<JSString*> str(cx, JS::ToString(cx, args[0]));
|
||||
if (!str) {
|
||||
return false;
|
||||
}
|
||||
@ -4218,10 +4219,9 @@ nsHTMLDocumentSH::CallToGetPropMapper(JSContext *cx, unsigned argc, jsval *vp)
|
||||
// If we are called via document.all(id) instead of document.all.item(i) or
|
||||
// another method, use the document.all callee object as self.
|
||||
JSObject *self;
|
||||
JS::Value callee = JS_CALLEE(cx, vp);
|
||||
if (callee.isObject() &&
|
||||
JS_GetClass(&callee.toObject()) == &sHTMLDocumentAllClass) {
|
||||
self = JSVAL_TO_OBJECT(JS_CALLEE(cx, vp));
|
||||
if (args.calleev().isObject() &&
|
||||
JS_GetClass(&args.calleev().toObject()) == &sHTMLDocumentAllClass) {
|
||||
self = &args.calleev().toObject();
|
||||
} else {
|
||||
self = JS_THIS_OBJECT(cx, vp);
|
||||
if (!self)
|
||||
@ -4235,13 +4235,7 @@ nsHTMLDocumentSH::CallToGetPropMapper(JSContext *cx, unsigned argc, jsval *vp)
|
||||
return false;
|
||||
}
|
||||
|
||||
JS::Rooted<JS::Value> value(cx);
|
||||
if (!::JS_GetUCProperty(cx, self, chars, length, &value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*vp = value;
|
||||
return true;
|
||||
return ::JS_GetUCProperty(cx, self, chars, length, args.rval());
|
||||
}
|
||||
|
||||
// StringArray helper
|
||||
@ -4436,7 +4430,8 @@ nsStorage2SH::SetProperty(nsIXPConnectWrappedNative *wrapper,
|
||||
nsDependentJSString keyStr;
|
||||
NS_ENSURE_TRUE(keyStr.init(cx, key), NS_ERROR_UNEXPECTED);
|
||||
|
||||
JSString *value = ::JS_ValueToString(cx, *vp);
|
||||
JS::Rooted<JS::Value> val(cx, *vp);
|
||||
JSString *value = JS::ToString(cx, val);
|
||||
NS_ENSURE_TRUE(value, NS_ERROR_UNEXPECTED);
|
||||
|
||||
nsDependentJSString valueStr;
|
||||
|
@ -1536,16 +1536,16 @@ TraceMallocEnable(JSContext *cx, unsigned argc, JS::Value *vp)
|
||||
static bool
|
||||
TraceMallocOpenLogFile(JSContext *cx, unsigned argc, JS::Value *vp)
|
||||
{
|
||||
int fd;
|
||||
JSString *str;
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
|
||||
if (!CheckUniversalXPConnectForTraceMalloc(cx))
|
||||
return false;
|
||||
|
||||
int fd;
|
||||
if (argc == 0) {
|
||||
fd = -1;
|
||||
} else {
|
||||
str = JS_ValueToString(cx, JS_ARGV(cx, vp)[0]);
|
||||
JSString *str = JS::ToString(cx, args[0]);
|
||||
if (!str)
|
||||
return false;
|
||||
JSAutoByteString filename(cx, str);
|
||||
@ -1557,7 +1557,7 @@ TraceMallocOpenLogFile(JSContext *cx, unsigned argc, JS::Value *vp)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
JS_SET_RVAL(cx, vp, INT_TO_JSVAL(fd));
|
||||
args.rva().setInt32(fd);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1608,27 +1608,29 @@ TraceMallocCloseLogFD(JSContext *cx, unsigned argc, JS::Value *vp)
|
||||
static bool
|
||||
TraceMallocLogTimestamp(JSContext *cx, unsigned argc, JS::Value *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
if (!CheckUniversalXPConnectForTraceMalloc(cx))
|
||||
return false;
|
||||
|
||||
JSString *str = JS_ValueToString(cx, argc ? JS_ARGV(cx, vp)[0] : JSVAL_VOID);
|
||||
JSString *str = JS::ToString(cx, args.get(0));
|
||||
if (!str)
|
||||
return false;
|
||||
JSAutoByteString caption(cx, str);
|
||||
if (!caption)
|
||||
return false;
|
||||
NS_TraceMallocLogTimestamp(caption.ptr());
|
||||
JS_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
TraceMallocDumpAllocations(JSContext *cx, unsigned argc, JS::Value *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
if (!CheckUniversalXPConnectForTraceMalloc(cx))
|
||||
return false;
|
||||
|
||||
JSString *str = JS_ValueToString(cx, argc ? JS_ARGV(cx, vp)[0] : JSVAL_VOID);
|
||||
JSString *str = JS::ToString(cx, args.get(0));
|
||||
if (!str)
|
||||
return false;
|
||||
JSAutoByteString pathname(cx, str);
|
||||
@ -1638,7 +1640,7 @@ TraceMallocDumpAllocations(JSContext *cx, unsigned argc, JS::Value *vp)
|
||||
JS_ReportError(cx, "can't dump to %s: %s", pathname.ptr(), strerror(errno));
|
||||
return false;
|
||||
}
|
||||
JS_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1668,7 +1670,8 @@ namespace dmd {
|
||||
static bool
|
||||
ReportAndDump(JSContext *cx, unsigned argc, JS::Value *vp)
|
||||
{
|
||||
JSString *str = JS_ValueToString(cx, argc ? JS_ARGV(cx, vp)[0] : JSVAL_VOID);
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
JSString *str = JS::ToString(cx, args.get(0));
|
||||
if (!str)
|
||||
return false;
|
||||
JSAutoByteString pathname(cx, str);
|
||||
@ -1690,7 +1693,7 @@ ReportAndDump(JSContext *cx, unsigned argc, JS::Value *vp)
|
||||
|
||||
fclose(fp);
|
||||
|
||||
JS_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -317,7 +317,8 @@ nsJSScriptTimeoutHandler::Init(nsGlobalWindow *aWindow, bool *aIsInterval,
|
||||
case JSTYPE_STRING:
|
||||
case JSTYPE_OBJECT:
|
||||
{
|
||||
JSString *str = ::JS_ValueToString(cx, argv[0]);
|
||||
JS::Rooted<JS::Value> arg(cx, argv[0]);
|
||||
JSString *str = JS::ToString(cx, arg);
|
||||
if (!str)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
@ -278,7 +278,8 @@ nsJSUtils::EvaluateString(JSContext* aCx,
|
||||
}
|
||||
|
||||
if (ok && aEvaluateOptions.coerceToString && !aRetValue->isUndefined()) {
|
||||
JSString* str = JS_ValueToString(aCx, *aRetValue);
|
||||
JS::Rooted<JS::Value> value(aCx, *aRetValue);
|
||||
JSString* str = JS::ToString(aCx, value);
|
||||
ok = !!str;
|
||||
*aRetValue = ok ? JS::StringValue(str) : JS::UndefinedValue();
|
||||
}
|
||||
|
@ -241,9 +241,11 @@ nsScreen::GetLockOrientationPermission() const
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScreen::MozLockOrientation(const JS::Value& aOrientation, JSContext* aCx,
|
||||
nsScreen::MozLockOrientation(const JS::Value& aOrientation_, JSContext* aCx,
|
||||
bool* aReturn)
|
||||
{
|
||||
JS::Rooted<JS::Value> aOrientation(aCx, aOrientation_);
|
||||
|
||||
if (aOrientation.isObject()) {
|
||||
JS::Rooted<JSObject*> seq(aCx, &aOrientation.toObject());
|
||||
if (IsArrayLike(aCx, seq)) {
|
||||
@ -264,7 +266,7 @@ nsScreen::MozLockOrientation(const JS::Value& aOrientation, JSContext* aCx,
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
JS::Rooted<JSString*> jsString(aCx, JS_ValueToString(aCx, temp));
|
||||
JS::Rooted<JSString*> jsString(aCx, JS::ToString(aCx, temp));
|
||||
if (!jsString) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -283,7 +285,7 @@ nsScreen::MozLockOrientation(const JS::Value& aOrientation, JSContext* aCx,
|
||||
}
|
||||
}
|
||||
|
||||
JS::Rooted<JSString*> jsString(aCx, JS_ValueToString(aCx, aOrientation));
|
||||
JS::Rooted<JSString*> jsString(aCx, JS::ToString(aCx, aOrientation));
|
||||
if (!jsString) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -2108,7 +2108,7 @@ ConvertJSValueToByteString(JSContext* cx, JS::Handle<JS::Value> v,
|
||||
return true;
|
||||
}
|
||||
|
||||
s = JS_ValueToString(cx, v);
|
||||
s = JS::ToString(cx, v);
|
||||
if (!s) {
|
||||
return false;
|
||||
}
|
||||
|
@ -900,11 +900,11 @@ EnumValueNotFound<true>(JSContext* cx, const jschar* chars, size_t length,
|
||||
|
||||
template<bool InvalidValueFatal>
|
||||
inline int
|
||||
FindEnumStringIndex(JSContext* cx, JS::Value v, const EnumEntry* values,
|
||||
FindEnumStringIndex(JSContext* cx, JS::Handle<JS::Value> v, const EnumEntry* values,
|
||||
const char* type, const char* sourceDescription, bool* ok)
|
||||
{
|
||||
// JS_StringEqualsAscii is slow as molasses, so don't use it here.
|
||||
JSString* str = JS_ValueToString(cx, v);
|
||||
JSString* str = JS::ToString(cx, v);
|
||||
if (!str) {
|
||||
*ok = false;
|
||||
return 0;
|
||||
@ -1550,7 +1550,7 @@ ConvertJSValueToString(JSContext* cx, JS::Handle<JS::Value> v,
|
||||
return true;
|
||||
}
|
||||
|
||||
s = JS_ValueToString(cx, v);
|
||||
s = JS::ToString(cx, v);
|
||||
if (!s) {
|
||||
return false;
|
||||
}
|
||||
|
@ -213,12 +213,12 @@ CreateGenericEvent(mozilla::dom::EventTarget* aEventOwner,
|
||||
}
|
||||
|
||||
inline nsresult
|
||||
GetInputStreamForJSVal(const JS::Value& aValue, JSContext* aCx,
|
||||
GetInputStreamForJSVal(JS::Handle<JS::Value> aValue, JSContext* aCx,
|
||||
nsIInputStream** aInputStream, uint64_t* aInputLength)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if (!JSVAL_IS_PRIMITIVE(aValue)) {
|
||||
if (aValue.isObject()) {
|
||||
JS::Rooted<JSObject*> obj(aCx, &aValue.toObject());
|
||||
if (JS_IsArrayBufferObject(obj)) {
|
||||
char* data = reinterpret_cast<char*>(JS_GetArrayBufferData(obj));
|
||||
@ -246,14 +246,8 @@ GetInputStreamForJSVal(const JS::Value& aValue, JSContext* aCx,
|
||||
}
|
||||
}
|
||||
|
||||
JSString* jsstr;
|
||||
if (JSVAL_IS_STRING(aValue)) {
|
||||
jsstr = JSVAL_TO_STRING(aValue);
|
||||
}
|
||||
else {
|
||||
jsstr = JS_ValueToString(aCx, aValue);
|
||||
JSString* jsstr = JS::ToString(aCx, aValue);
|
||||
NS_ENSURE_TRUE(jsstr, NS_ERROR_XPC_BAD_CONVERT_JS);
|
||||
}
|
||||
|
||||
nsDependentJSString str;
|
||||
if (!str.init(aCx, jsstr)) {
|
||||
@ -864,10 +858,11 @@ LockedFile::WriteOrAppend(const JS::Value& aValue,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
JS::Rooted<JS::Value> val(aCx, aValue);
|
||||
nsCOMPtr<nsIInputStream> inputStream;
|
||||
uint64_t inputLength;
|
||||
nsresult rv =
|
||||
GetInputStreamForJSVal(aValue, aCx, getter_AddRefs(inputStream),
|
||||
GetInputStreamForJSVal(val, aCx, getter_AddRefs(inputStream),
|
||||
&inputLength);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
@ -255,8 +255,9 @@ KeyPath::Parse(JSContext* aCx, const mozilla::dom::Sequence<nsString>& aStrings,
|
||||
|
||||
// static
|
||||
nsresult
|
||||
KeyPath::Parse(JSContext* aCx, const JS::Value& aValue, KeyPath* aKeyPath)
|
||||
KeyPath::Parse(JSContext* aCx, const JS::Value& aValue_, KeyPath* aKeyPath)
|
||||
{
|
||||
JS::Rooted<JS::Value> aValue(aCx, aValue_);
|
||||
KeyPath keyPath(0);
|
||||
|
||||
aKeyPath->SetType(NONEXISTENT);
|
||||
@ -283,7 +284,7 @@ KeyPath::Parse(JSContext* aCx, const JS::Value& aValue, KeyPath* aKeyPath)
|
||||
JSString* jsstr;
|
||||
nsDependentJSString str;
|
||||
if (!JS_GetElement(aCx, obj, index, &val) ||
|
||||
!(jsstr = JS_ValueToString(aCx, val)) ||
|
||||
!(jsstr = JS::ToString(aCx, val)) ||
|
||||
!str.init(aCx, jsstr)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -297,7 +298,7 @@ KeyPath::Parse(JSContext* aCx, const JS::Value& aValue, KeyPath* aKeyPath)
|
||||
else if (!JSVAL_IS_NULL(aValue) && !JSVAL_IS_VOID(aValue)) {
|
||||
JSString* jsstr;
|
||||
nsDependentJSString str;
|
||||
if (!(jsstr = JS_ValueToString(aCx, aValue)) ||
|
||||
if (!(jsstr = JS::ToString(aCx, aValue)) ||
|
||||
!str.init(aCx, jsstr)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ static nsresult CompareDictionaries(JSContext* aCx, JSObject *aA,
|
||||
bool success = JS_IdToValue(aCx, props[i], nameval.address());
|
||||
NS_ENSURE_TRUE(success, NS_ERROR_UNEXPECTED);
|
||||
|
||||
JS::Rooted<JSString*> namestr(aCx, JS_ValueToString(aCx, nameval));
|
||||
JS::Rooted<JSString*> namestr(aCx, JS::ToString(aCx, nameval));
|
||||
NS_ENSURE_TRUE(namestr, NS_ERROR_UNEXPECTED);
|
||||
aDifference->Assign(JS_GetStringCharsZ(aCx, namestr));
|
||||
return NS_OK;
|
||||
|
@ -286,7 +286,7 @@ nsresult nsJSThunk::EvaluateScript(nsIChannel *aChannel,
|
||||
sandboxObj = js::UncheckedUnwrap(sandboxObj);
|
||||
JSAutoCompartment ac(cx, sandboxObj);
|
||||
|
||||
// Push our JSContext on the context stack so the JS_ValueToString call (and
|
||||
// Push our JSContext on the context stack so the EvalInSandboxObject call (and
|
||||
// JS_ReportPendingException, if relevant) will use the principal of cx.
|
||||
nsCxPusher pusher;
|
||||
pusher.Push(cx);
|
||||
|
@ -243,7 +243,7 @@ AutoMounterSetting::Observe(nsISupports* aSubject,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
JSString *jsKey = JS_ValueToString(cx, key);
|
||||
JSString *jsKey = JS::ToString(cx, key);
|
||||
nsDependentJSString keyStr;
|
||||
if (!keyStr.init(cx, jsKey)) {
|
||||
return NS_OK;
|
||||
|
@ -1991,7 +1991,8 @@ XMLHttpRequest::Send(JSObject* aBody, ErrorResult& aRv)
|
||||
valToClone.setObject(*aBody);
|
||||
}
|
||||
else {
|
||||
JSString* bodyStr = JS_ValueToString(cx, OBJECT_TO_JSVAL(aBody));
|
||||
JS::Rooted<JS::Value> obj(cx, JS::ObjectValue(*aBody));
|
||||
JSString* bodyStr = JS::ToString(cx, obj);
|
||||
if (!bodyStr) {
|
||||
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
return;
|
||||
|
@ -85,16 +85,12 @@ Environment(Handle<JSObject*> global)
|
||||
}
|
||||
|
||||
static bool
|
||||
Print(JSContext *cx,
|
||||
unsigned argc,
|
||||
JS::Value *vp)
|
||||
Print(JSContext *cx, unsigned argc, JS::Value *vp)
|
||||
{
|
||||
unsigned i, n;
|
||||
JSString *str;
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
|
||||
JS::Value *argv = JS_ARGV(cx, vp);
|
||||
for (i = n = 0; i < argc; i++) {
|
||||
str = JS_ValueToString(cx, argv[i]);
|
||||
for (unsigned i = 0; i < args.length(); i++) {
|
||||
JSString *str = JS::ToString(cx, args[i]);
|
||||
if (!str)
|
||||
return false;
|
||||
JSAutoByteString bytes(cx, str);
|
||||
@ -103,10 +99,8 @@ Print(JSContext *cx,
|
||||
fprintf(stdout, "%s%s", i ? " " : "", bytes.ptr());
|
||||
fflush(stdout);
|
||||
}
|
||||
n++;
|
||||
if (n)
|
||||
fputc('\n', stdout);
|
||||
JS_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -125,17 +119,14 @@ GetLine(char *bufp,
|
||||
}
|
||||
|
||||
static bool
|
||||
Dump(JSContext *cx,
|
||||
unsigned argc,
|
||||
JS::Value *vp)
|
||||
Dump(JSContext *cx, unsigned argc, JS::Value *vp)
|
||||
{
|
||||
JS_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
|
||||
JSString *str;
|
||||
if (!argc)
|
||||
if (!args.length())
|
||||
return true;
|
||||
|
||||
str = JS_ValueToString(cx, JS_ARGV(cx, vp)[0]);
|
||||
JSString *str = JS::ToString(cx, args[0]);
|
||||
if (!str)
|
||||
return false;
|
||||
JSAutoByteString bytes(cx, str);
|
||||
@ -152,18 +143,16 @@ Load(JSContext *cx,
|
||||
unsigned argc,
|
||||
JS::Value *vp)
|
||||
{
|
||||
JS::Rooted<JS::Value> result(cx);
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
|
||||
JS::Rooted<JSObject*> obj(cx, JS_THIS_OBJECT(cx, vp));
|
||||
if (!obj)
|
||||
return false;
|
||||
|
||||
JS::Value *argv = JS_ARGV(cx, vp);
|
||||
for (unsigned i = 0; i < argc; i++) {
|
||||
JSString *str = JS_ValueToString(cx, argv[i]);
|
||||
for (unsigned i = 0; i < args.length(); i++) {
|
||||
JS::Rooted<JSString*> str(cx, JS::ToString(cx, args[i]));
|
||||
if (!str)
|
||||
return false;
|
||||
argv[i] = STRING_TO_JSVAL(str);
|
||||
JSAutoByteString filename(cx, str);
|
||||
if (!filename)
|
||||
return false;
|
||||
@ -183,11 +172,12 @@ Load(JSContext *cx,
|
||||
if (!script)
|
||||
return false;
|
||||
|
||||
JS::Rooted<JS::Value> result(cx);
|
||||
if (!JS_ExecuteScript(cx, obj, script, result.address())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
JS_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -391,9 +381,9 @@ XPCShellEnvironment::ProcessFile(JSContext *cx,
|
||||
|
||||
ok = JS_ExecuteScript(cx, obj, script, result.address());
|
||||
if (ok && result != JSVAL_VOID) {
|
||||
/* Suppress error reports from JS_ValueToString(). */
|
||||
/* Suppress error reports from JS::ToString(). */
|
||||
older = JS_SetErrorReporter(cx, nullptr);
|
||||
str = JS_ValueToString(cx, result);
|
||||
str = JS::ToString(cx, result);
|
||||
JSAutoByteString bytes;
|
||||
if (str)
|
||||
bytes.encodeLatin1(cx, str);
|
||||
@ -609,7 +599,7 @@ XPCShellEnvironment::EvaluateString(const nsString& aString,
|
||||
bool ok = JS_ExecuteScript(cx, global, script, result.address());
|
||||
if (ok && result != JSVAL_VOID) {
|
||||
JSErrorReporter old = JS_SetErrorReporter(cx, nullptr);
|
||||
JSString* str = JS_ValueToString(cx, result);
|
||||
JSString* str = JS::ToString(cx, result);
|
||||
nsDependentJSString depStr;
|
||||
if (str)
|
||||
depStr.init(cx, str);
|
||||
|
@ -129,7 +129,7 @@ JavaScriptShared::convertIdToGeckoString(JSContext *cx, JS::HandleId id, nsStrin
|
||||
if (!JS_IdToValue(cx, id, idval.address()))
|
||||
return false;
|
||||
|
||||
RootedString str(cx, JS_ValueToString(cx, idval));
|
||||
RootedString str(cx, ToString(cx, idval));
|
||||
if (!str)
|
||||
return false;
|
||||
|
||||
|
@ -486,7 +486,8 @@ jsd_ValToStringInStackFrame(JSDContext* jsdc,
|
||||
JS_ASSERT(cx);
|
||||
|
||||
exceptionState = JS_SaveExceptionState(cx);
|
||||
retval = JS_ValueToString(cx, val);
|
||||
JS::RootedValue v(cx, val);
|
||||
retval = JS::ToString(cx, v);
|
||||
JS_RestoreExceptionState(cx, exceptionState);
|
||||
|
||||
return retval;
|
||||
|
@ -189,7 +189,8 @@ jsd_GetValueString(JSDContext* jsdc, JSDValue* jsdval)
|
||||
{
|
||||
JSAutoCompartment ac(cx, scopeObj);
|
||||
AutoSaveExceptionState as(cx);
|
||||
string = JS_ValueToString(cx, jsdval->val);
|
||||
JS::RootedValue v(cx, jsdval->val);
|
||||
string = JS::ToString(cx, v);
|
||||
}
|
||||
|
||||
JSAutoCompartment ac2(cx, jsdc->glob);
|
||||
|
@ -273,7 +273,7 @@ GCParameter(JSContext *cx, unsigned argc, Value *vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
JSString *str = JS_ValueToString(cx, args.get(0));
|
||||
JSString *str = ToString(cx, args.get(0));
|
||||
if (!str)
|
||||
return false;
|
||||
|
||||
@ -350,12 +350,13 @@ IsProxy(JSContext *cx, unsigned argc, Value *vp)
|
||||
static bool
|
||||
InternalConst(JSContext *cx, unsigned argc, jsval *vp)
|
||||
{
|
||||
if (argc != 1) {
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
if (args.length() == 0) {
|
||||
JS_ReportError(cx, "the function takes exactly one argument");
|
||||
return false;
|
||||
}
|
||||
|
||||
JSString *str = JS_ValueToString(cx, vp[2]);
|
||||
JSString *str = ToString(cx, args[0]);
|
||||
if (!str)
|
||||
return false;
|
||||
JSFlatString *flat = JS_FlattenString(cx, str);
|
||||
@ -684,6 +685,8 @@ static const struct TraceKindPair {
|
||||
static bool
|
||||
CountHeap(JSContext *cx, unsigned argc, jsval *vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
jsval v;
|
||||
int32_t traceKind;
|
||||
JSString *str;
|
||||
@ -692,8 +695,8 @@ CountHeap(JSContext *cx, unsigned argc, jsval *vp)
|
||||
size_t counter;
|
||||
|
||||
RootedValue startValue(cx, UndefinedValue());
|
||||
if (argc > 0) {
|
||||
v = JS_ARGV(cx, vp)[0];
|
||||
if (args.length() > 0) {
|
||||
v = args[0];
|
||||
if (JSVAL_IS_TRACEABLE(v)) {
|
||||
startValue = v;
|
||||
} else if (!JSVAL_IS_NULL(v)) {
|
||||
@ -705,8 +708,8 @@ CountHeap(JSContext *cx, unsigned argc, jsval *vp)
|
||||
}
|
||||
|
||||
traceKind = -1;
|
||||
if (argc > 1) {
|
||||
str = JS_ValueToString(cx, JS_ARGV(cx, vp)[1]);
|
||||
if (args.length() > 1) {
|
||||
str = ToString(cx, args[0]);
|
||||
if (!str)
|
||||
return false;
|
||||
JSFlatString *flatStr = JS_FlattenString(cx, str);
|
||||
|
@ -517,8 +517,7 @@ ArrayTypeRepresentation::appendStringArray(JSContext *cx, StringBuffer &contents
|
||||
if (!contents.append(", "))
|
||||
return false;
|
||||
|
||||
Value len = NumberValue(length());
|
||||
if (!contents.append(JS_ValueToString(cx, len)))
|
||||
if (!NumberValueToStringBuffer(cx, NumberValue(length()), contents))
|
||||
return false;
|
||||
|
||||
if (!contents.append(")"))
|
||||
|
@ -6792,7 +6792,7 @@ CDataFinalizer::Methods::ToString(JSContext *cx, unsigned argc, jsval *vp)
|
||||
} else if (!CDataFinalizer::GetValue(cx, objThis, value.address())) {
|
||||
MOZ_ASSUME_UNREACHABLE("Could not convert an empty CDataFinalizer");
|
||||
} else {
|
||||
strMessage = JS_ValueToString(cx, value);
|
||||
strMessage = ToString(cx, value);
|
||||
if (!strMessage) {
|
||||
return false;
|
||||
}
|
||||
|
@ -8,7 +8,8 @@
|
||||
|
||||
BEGIN_TEST(testOOM)
|
||||
{
|
||||
JS::RootedString jsstr(cx, JS_ValueToString(cx, INT_TO_JSVAL(9)));
|
||||
JS::RootedValue v(cx, JS::Int32Value(9));
|
||||
JS::RootedString jsstr(cx, JS::ToString(cx, v));
|
||||
mozilla::DebugOnly<const jschar *> s = JS_GetStringCharsZ(cx, jsstr);
|
||||
JS_ASSERT(s[0] == '9' && s[1] == '\0');
|
||||
return true;
|
||||
|
@ -210,7 +210,7 @@ class JSAPITest
|
||||
JS::RootedValue v(cx);
|
||||
JS_GetPendingException(cx, &v);
|
||||
JS_ClearPendingException(cx);
|
||||
JSString *s = JS_ValueToString(cx, v);
|
||||
JSString *s = JS::ToString(cx, v);
|
||||
if (s) {
|
||||
JSAutoByteString bytes(cx, s);
|
||||
if (!!bytes)
|
||||
@ -237,9 +237,10 @@ class JSAPITest
|
||||
static bool
|
||||
print(JSContext *cx, unsigned argc, jsval *vp)
|
||||
{
|
||||
jsval *argv = JS_ARGV(cx, vp);
|
||||
for (unsigned i = 0; i < argc; i++) {
|
||||
JSString *str = JS_ValueToString(cx, argv[i]);
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
|
||||
for (unsigned i = 0; i < args.length(); i++) {
|
||||
JSString *str = JS::ToString(cx, args[i]);
|
||||
if (!str)
|
||||
return false;
|
||||
char *bytes = JS_EncodeString(cx, str);
|
||||
@ -251,7 +252,7 @@ class JSAPITest
|
||||
|
||||
putchar('\n');
|
||||
fflush(stdout);
|
||||
JS_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -406,16 +406,6 @@ JS_ValueToConstructor(JSContext *cx, HandleValue value)
|
||||
return ReportIfNotFunction(cx, value);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSString *)
|
||||
JS_ValueToString(JSContext *cx, jsval valueArg)
|
||||
{
|
||||
RootedValue value(cx, valueArg);
|
||||
AssertHeapIsIdle(cx);
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, value);
|
||||
return ToString<CanGC>(cx, value);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSString *)
|
||||
JS_ValueToSource(JSContext *cx, jsval valueArg)
|
||||
{
|
||||
|
@ -1042,9 +1042,6 @@ JS_ValueToFunction(JSContext *cx, JS::HandleValue v);
|
||||
extern JS_PUBLIC_API(JSFunction *)
|
||||
JS_ValueToConstructor(JSContext *cx, JS::HandleValue v);
|
||||
|
||||
extern JS_PUBLIC_API(JSString *)
|
||||
JS_ValueToString(JSContext *cx, jsval v);
|
||||
|
||||
extern JS_PUBLIC_API(JSString *)
|
||||
JS_ValueToSource(JSContext *cx, jsval v);
|
||||
|
||||
@ -1060,6 +1057,12 @@ ToNumberSlow(JSContext *cx, JS::Value v, double *dp);
|
||||
*/
|
||||
extern JS_PUBLIC_API(bool)
|
||||
ToBooleanSlow(JS::HandleValue v);
|
||||
|
||||
/*
|
||||
* DO NOT CALL THIS. Use JS::ToString
|
||||
*/
|
||||
extern JS_PUBLIC_API(JSString*)
|
||||
ToStringSlow(JSContext *cx, JS::HandleValue v);
|
||||
} /* namespace js */
|
||||
|
||||
namespace JS {
|
||||
@ -1099,6 +1102,14 @@ ToBoolean(HandleValue v)
|
||||
return js::ToBooleanSlow(v);
|
||||
}
|
||||
|
||||
JS_ALWAYS_INLINE JSString*
|
||||
ToString(JSContext *cx, HandleValue v)
|
||||
{
|
||||
if (v.isString())
|
||||
return v.toString();
|
||||
return js::ToStringSlow(cx, v);
|
||||
}
|
||||
|
||||
} /* namespace JS */
|
||||
|
||||
extern JS_PUBLIC_API(bool)
|
||||
|
@ -3989,6 +3989,12 @@ js::ToStringSlow<CanGC>(ExclusiveContext *cx, HandleValue arg);
|
||||
template JSString *
|
||||
js::ToStringSlow<NoGC>(ExclusiveContext *cx, Value arg);
|
||||
|
||||
JS_PUBLIC_API(JSString *)
|
||||
js::ToStringSlow(JSContext *cx, HandleValue v)
|
||||
{
|
||||
return ToStringSlow<CanGC>(cx, v);
|
||||
}
|
||||
|
||||
JSString *
|
||||
js::ValueToSource(JSContext *cx, HandleValue v)
|
||||
{
|
||||
|
@ -207,43 +207,6 @@ extern JS_EXPORT_API(void) add_history(char *line);
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
static void
|
||||
ReportException(JSContext *cx)
|
||||
{
|
||||
if (JS_IsExceptionPending(cx)) {
|
||||
if (!JS_ReportPendingException(cx))
|
||||
JS_ClearPendingException(cx);
|
||||
}
|
||||
}
|
||||
|
||||
class ToStringHelper
|
||||
{
|
||||
public:
|
||||
ToStringHelper(JSContext *aCx, HandleValue v, bool aThrow = false)
|
||||
: cx(aCx), mStr(cx, JS_ValueToString(cx, v))
|
||||
{
|
||||
if (!aThrow && !mStr)
|
||||
ReportException(cx);
|
||||
}
|
||||
ToStringHelper(JSContext *aCx, HandleId id, bool aThrow = false)
|
||||
: cx(aCx), mStr(cx, JS_ValueToString(cx, IdToValue(id)))
|
||||
{
|
||||
if (!aThrow && !mStr)
|
||||
ReportException(cx);
|
||||
}
|
||||
bool threw() { return !mStr; }
|
||||
jsval getJSVal() { return STRING_TO_JSVAL(mStr); }
|
||||
const char *getBytes() {
|
||||
if (mStr && (mBytes.ptr() || mBytes.encodeLatin1(cx, mStr)))
|
||||
return mBytes.ptr();
|
||||
return "(error converting value)";
|
||||
}
|
||||
private:
|
||||
JSContext *cx;
|
||||
RootedString mStr; // Objects of this class are always stack-allocated.
|
||||
JSAutoByteString mBytes;
|
||||
};
|
||||
|
||||
static char *
|
||||
GetLine(FILE *file, const char * prompt)
|
||||
{
|
||||
@ -693,7 +656,7 @@ Options(JSContext *cx, unsigned argc, jsval *vp)
|
||||
|
||||
JS::ContextOptions oldOptions = JS::ContextOptionsRef(cx);
|
||||
for (unsigned i = 0; i < args.length(); i++) {
|
||||
JSString *str = JS_ValueToString(cx, args[i]);
|
||||
JSString *str = JS::ToString(cx, args[i]);
|
||||
if (!str)
|
||||
return false;
|
||||
args[i].setString(str);
|
||||
@ -768,7 +731,7 @@ LoadScript(JSContext *cx, unsigned argc, jsval *vp, bool scriptRelative)
|
||||
|
||||
RootedString str(cx);
|
||||
for (unsigned i = 0; i < args.length(); i++) {
|
||||
str = JS_ValueToString(cx, args[i]);
|
||||
str = JS::ToString(cx, args[i]);
|
||||
if (!str) {
|
||||
JS_ReportErrorNumber(cx, my_GetErrorMessage, nullptr, JSSMSG_INVALID_ARGS, "load");
|
||||
return false;
|
||||
@ -934,7 +897,7 @@ Evaluate(JSContext *cx, unsigned argc, jsval *vp)
|
||||
if (v.isNull()) {
|
||||
fileName = nullptr;
|
||||
} else if (!v.isUndefined()) {
|
||||
JSString *s = JS_ValueToString(cx, v);
|
||||
JSString *s = ToString(cx, v);
|
||||
if (!s)
|
||||
return false;
|
||||
fileName = fileNameBytes.encodeLatin1(cx, s);
|
||||
@ -950,7 +913,7 @@ Evaluate(JSContext *cx, unsigned argc, jsval *vp)
|
||||
if (!JS_GetProperty(cx, opts, "sourceURL", &v))
|
||||
return false;
|
||||
if (!v.isUndefined()) {
|
||||
sourceURL = JS_ValueToString(cx, v);
|
||||
sourceURL = ToString(cx, v);
|
||||
if (!sourceURL)
|
||||
return false;
|
||||
}
|
||||
@ -958,7 +921,7 @@ Evaluate(JSContext *cx, unsigned argc, jsval *vp)
|
||||
if (!JS_GetProperty(cx, opts, "sourceMapURL", &v))
|
||||
return false;
|
||||
if (!v.isUndefined()) {
|
||||
sourceMapURL = JS_ValueToString(cx, v);
|
||||
sourceMapURL = ToString(cx, v);
|
||||
if (!sourceMapURL)
|
||||
return false;
|
||||
}
|
||||
@ -1000,7 +963,7 @@ Evaluate(JSContext *cx, unsigned argc, jsval *vp)
|
||||
if (!JS_GetProperty(cx, opts, "sourcePolicy", &v))
|
||||
return false;
|
||||
if (!v.isUndefined()) {
|
||||
JSString *s = JS_ValueToString(cx, v);
|
||||
JSString *s = ToString(cx, v);
|
||||
if (!s)
|
||||
return false;
|
||||
char *policy = JS_EncodeStringToUTF8(cx, s);
|
||||
@ -1185,7 +1148,7 @@ Run(JSContext *cx, unsigned argc, jsval *vp)
|
||||
if (!thisobj)
|
||||
return false;
|
||||
|
||||
JSString *str = JS_ValueToString(cx, args[0]);
|
||||
JSString *str = JS::ToString(cx, args[0]);
|
||||
if (!str)
|
||||
return false;
|
||||
args[0].setString(str);
|
||||
@ -1308,7 +1271,7 @@ PutStr(JSContext *cx, unsigned argc, jsval *vp)
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
if (args.length() != 0) {
|
||||
JSString *str = JS_ValueToString(cx, args[0]);
|
||||
JSString *str = JS::ToString(cx, args[0]);
|
||||
if (!str)
|
||||
return false;
|
||||
char *bytes = JSStringToUTF8(cx, str);
|
||||
@ -1336,7 +1299,7 @@ static bool
|
||||
PrintInternal(JSContext *cx, const CallArgs &args, FILE *file)
|
||||
{
|
||||
for (unsigned i = 0; i < args.length(); i++) {
|
||||
JSString *str = JS_ValueToString(cx, args[i]);
|
||||
JSString *str = JS::ToString(cx, args[i]);
|
||||
if (!str)
|
||||
return false;
|
||||
char *bytes = JSStringToUTF8(cx, str);
|
||||
@ -1565,7 +1528,7 @@ Trap(JSContext *cx, unsigned argc, jsval *vp)
|
||||
return false;
|
||||
}
|
||||
argc = args.length() - 1;
|
||||
RootedString str(cx, JS_ValueToString(cx, args[argc]));
|
||||
RootedString str(cx, JS::ToString(cx, args[argc]));
|
||||
if (!str)
|
||||
return false;
|
||||
args[argc].setString(str);
|
||||
@ -1610,7 +1573,7 @@ SetDebuggerHandler(JSContext *cx, unsigned argc, jsval *vp)
|
||||
return false;
|
||||
}
|
||||
|
||||
JSString *str = JS_ValueToString(cx, args[0]);
|
||||
JSString *str = JS::ToString(cx, args[0]);
|
||||
if (!str)
|
||||
return false;
|
||||
|
||||
@ -1630,7 +1593,7 @@ SetThrowHook(JSContext *cx, unsigned argc, jsval *vp)
|
||||
return false;
|
||||
}
|
||||
|
||||
str = JS_ValueToString(cx, args[0]);
|
||||
str = JS::ToString(cx, args[0]);
|
||||
if (!str)
|
||||
return false;
|
||||
|
||||
@ -2033,7 +1996,8 @@ DisassFile(JSContext *cx, unsigned argc, jsval *vp)
|
||||
if (!thisobj)
|
||||
return false;
|
||||
|
||||
JSString *str = JS_ValueToString(cx, p.argv[0]);
|
||||
// We should change DisassembleOptionParser to store CallArgs.
|
||||
JSString *str = JS::ToString(cx, HandleValue::fromMarkedLocation(&p.argv[0]));
|
||||
if (!str)
|
||||
return false;
|
||||
JSAutoByteString filename(cx, str);
|
||||
@ -2170,7 +2134,7 @@ DumpHeap(JSContext *cx, unsigned argc, jsval *vp)
|
||||
|
||||
JSAutoByteString fileName;
|
||||
if (args.hasDefined(0)) {
|
||||
RootedString str(cx, JS_ValueToString(cx, args[0]));
|
||||
RootedString str(cx, JS::ToString(cx, args[0]));
|
||||
if (!str)
|
||||
return false;
|
||||
|
||||
@ -2269,7 +2233,7 @@ static bool
|
||||
Intern(JSContext *cx, unsigned argc, jsval *vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
JSString *str = JS_ValueToString(cx, args.length() == 0 ? UndefinedValue() : args[0]);
|
||||
JSString *str = JS::ToString(cx, args.get(0));
|
||||
if (!str)
|
||||
return false;
|
||||
|
||||
@ -3413,7 +3377,7 @@ ReadFile(JSContext *cx, unsigned argc, jsval *vp, bool scriptRelative)
|
||||
return false;
|
||||
|
||||
if (args.length() > 1) {
|
||||
JSString *opt = JS_ValueToString(cx, args[1]);
|
||||
JSString *opt = JS::ToString(cx, args[1]);
|
||||
if (!opt)
|
||||
return false;
|
||||
bool match;
|
||||
@ -3495,24 +3459,24 @@ RedirectOutput(JSContext *cx, unsigned argc, jsval *vp)
|
||||
static bool
|
||||
System(JSContext *cx, unsigned argc, jsval *vp)
|
||||
{
|
||||
JSString *str;
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
if (argc != 1) {
|
||||
if (args.length() == 0) {
|
||||
JS_ReportErrorNumber(cx, my_GetErrorMessage, nullptr, JSSMSG_INVALID_ARGS,
|
||||
"system");
|
||||
return false;
|
||||
}
|
||||
|
||||
str = JS_ValueToString(cx, JS_ARGV(cx, vp)[0]);
|
||||
JSString *str = JS::ToString(cx, args[0]);
|
||||
if (!str)
|
||||
return false;
|
||||
|
||||
JSAutoByteString command(cx, str);
|
||||
if (!command)
|
||||
return false;
|
||||
|
||||
int result = system(command.ptr());
|
||||
|
||||
JS_SET_RVAL(cx, vp, Int32Value(result));
|
||||
args.rval().setInt32(result);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -3632,7 +3596,7 @@ NestedShell(JSContext *cx, unsigned argc, jsval *vp)
|
||||
// The arguments to nestedShell are stringified and append to argv.
|
||||
RootedString str(cx);
|
||||
for (unsigned i = 0; i < args.length(); i++) {
|
||||
str = JS_ValueToString(cx, args[i]);
|
||||
str = ToString(cx, args[i]);
|
||||
if (!str || !argv.append(JS_EncodeString(cx, str)))
|
||||
return false;
|
||||
|
||||
@ -3929,7 +3893,7 @@ class ShellSourceHook: public SourceHook {
|
||||
1, filenameValue.address(), &result))
|
||||
return false;
|
||||
|
||||
str = JS_ValueToString(cx, result);
|
||||
str = JS::ToString(cx, result);
|
||||
if (!str)
|
||||
return false;
|
||||
|
||||
@ -4500,6 +4464,8 @@ my_ErrorReporter(JSContext *cx, const char *message, JSErrorReport *report)
|
||||
static bool
|
||||
Exec(JSContext *cx, unsigned argc, jsval *vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
JSFunction *fun;
|
||||
const char *name, **nargv;
|
||||
unsigned i, nargc;
|
||||
@ -4527,7 +4493,7 @@ Exec(JSContext *cx, unsigned argc, jsval *vp)
|
||||
nargv[0] = name;
|
||||
jsval *argv = JS_ARGV(cx, vp);
|
||||
for (i = 0; i < nargc; i++) {
|
||||
str = (i == 0) ? fun->atom : JS_ValueToString(cx, argv[i-1]);
|
||||
str = (i == 0) ? fun->atom : JS::ToString(cx, args[i-1]);
|
||||
if (!str) {
|
||||
ok = false;
|
||||
goto done;
|
||||
@ -4654,15 +4620,21 @@ env_setProperty(JSContext *cx, HandleObject obj, HandleId id, bool strict, Mutab
|
||||
#if !defined XP_OS2 && !defined SOLARIS
|
||||
int rv;
|
||||
|
||||
ToStringHelper idstr(cx, id, true);
|
||||
if (idstr.threw())
|
||||
RootedValue idvalue(cx, IdToValue(id));
|
||||
JSAutoByteString idstr;
|
||||
if (!idstr.encodeLatin1(cx, idvalue.toString()))
|
||||
return false;
|
||||
ToStringHelper valstr(cx, vp, true);
|
||||
if (valstr.threw())
|
||||
|
||||
RootedString value(cx, ToString(cx, vp));
|
||||
if (!value)
|
||||
return false;
|
||||
JSAutoByteString valstr;
|
||||
if (!valstr.encodeLatin1(cx, value))
|
||||
return false;
|
||||
|
||||
#if defined XP_WIN || defined HPUX || defined OSF1
|
||||
{
|
||||
char *waste = JS_smprintf("%s=%s", idstr.getBytes(), valstr.getBytes());
|
||||
char *waste = JS_smprintf("%s=%s", idstr.ptr(), valstr.ptr());
|
||||
if (!waste) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
return false;
|
||||
@ -4680,13 +4652,13 @@ env_setProperty(JSContext *cx, HandleObject obj, HandleId id, bool strict, Mutab
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
rv = setenv(idstr.getBytes(), valstr.getBytes(), 1);
|
||||
rv = setenv(idstr.ptr(), valstr.ptr(), 1);
|
||||
#endif
|
||||
if (rv < 0) {
|
||||
JS_ReportError(cx, "can't set env variable %s to %s", idstr.getBytes(), valstr.getBytes());
|
||||
JS_ReportError(cx, "can't set env variable %s to %s", idstr.ptr(), valstr.ptr());
|
||||
return false;
|
||||
}
|
||||
vp.set(valstr.getJSVal());
|
||||
vp.set(StringValue(value));
|
||||
#endif /* !defined XP_OS2 && !defined SOLARIS */
|
||||
return true;
|
||||
}
|
||||
@ -4723,17 +4695,15 @@ static bool
|
||||
env_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
|
||||
MutableHandleObject objp)
|
||||
{
|
||||
JSString *valstr;
|
||||
const char *name, *value;
|
||||
|
||||
ToStringHelper idstr(cx, id, true);
|
||||
if (idstr.threw())
|
||||
RootedValue idvalue(cx, IdToValue(id));
|
||||
JSAutoByteString idstr;
|
||||
if (!idstr.encodeLatin1(cx, idvalue.toString()))
|
||||
return false;
|
||||
|
||||
name = idstr.getBytes();
|
||||
value = getenv(name);
|
||||
const char *name = idstr.ptr();
|
||||
const char *value = getenv(name);
|
||||
if (value) {
|
||||
valstr = JS_NewStringCopyZ(cx, value);
|
||||
RootedString valstr(cx, JS_NewStringCopyZ(cx, value));
|
||||
if (!valstr)
|
||||
return false;
|
||||
if (!JS_DefineProperty(cx, obj, name, STRING_TO_JSVAL(valstr),
|
||||
|
@ -4337,7 +4337,7 @@ DebuggerGenericEval(JSContext *cx, const char *fullMethodName, const Value &code
|
||||
if (!JS_GetProperty(cx, opts, "url", &v))
|
||||
return false;
|
||||
if (!v.isUndefined()) {
|
||||
RootedString url_str(cx, JS_ValueToString(cx, v));
|
||||
RootedString url_str(cx, ToString<CanGC>(cx, v));
|
||||
if (!url_str)
|
||||
return false;
|
||||
url = JS_EncodeString(cx, url_str);
|
||||
|
@ -106,13 +106,14 @@ static PRLogModuleInfo *gJSCLLog;
|
||||
#define ERROR_SETTING_SYMBOL "%s - Could not set symbol '%s' on target object."
|
||||
|
||||
static bool
|
||||
Dump(JSContext *cx, unsigned argc, jsval *vp)
|
||||
Dump(JSContext *cx, unsigned argc, Value *vp)
|
||||
{
|
||||
JSString *str;
|
||||
if (!argc)
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
if (args.length() == 0)
|
||||
return true;
|
||||
|
||||
str = JS_ValueToString(cx, JS_ARGV(cx, vp)[0]);
|
||||
JSString *str = JS::ToString(cx, args[0]);
|
||||
if (!str)
|
||||
return false;
|
||||
|
||||
|
@ -80,11 +80,12 @@ xpc::NewSandboxConstructor()
|
||||
static bool
|
||||
SandboxDump(JSContext *cx, unsigned argc, jsval *vp)
|
||||
{
|
||||
JSString *str;
|
||||
if (!argc)
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
if (args.length() == 0)
|
||||
return true;
|
||||
|
||||
str = JS_ValueToString(cx, JS_ARGV(cx, vp)[0]);
|
||||
RootedString str(cx, ToString(cx, args[0]));
|
||||
if (!str)
|
||||
return false;
|
||||
|
||||
@ -111,7 +112,7 @@ SandboxDump(JSContext *cx, unsigned argc, jsval *vp)
|
||||
fputs(cstr, stdout);
|
||||
fflush(stdout);
|
||||
NS_Free(cstr);
|
||||
JS_SET_RVAL(cx, vp, JSVAL_TRUE);
|
||||
args.rval().setBoolean(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -138,7 +139,7 @@ SandboxImport(JSContext *cx, unsigned argc, Value *vp)
|
||||
RootedString funname(cx);
|
||||
if (args.length() > 1) {
|
||||
// Use the second parameter as the function name.
|
||||
funname = JS_ValueToString(cx, args[1]);
|
||||
funname = ToString(cx, args[1]);
|
||||
if (!funname)
|
||||
return false;
|
||||
} else {
|
||||
@ -1640,7 +1641,7 @@ xpc::EvalInSandbox(JSContext *cx, HandleObject sandboxArg, const nsAString& sour
|
||||
PromiseFlatString(source).get(), source.Length(),
|
||||
v.address());
|
||||
if (ok && returnStringOnly && !v.isUndefined()) {
|
||||
JSString *str = JS_ValueToString(sandcx, v);
|
||||
JSString *str = ToString(sandcx, v);
|
||||
ok = !!str;
|
||||
v = ok ? JS::StringValue(str) : JS::UndefinedValue();
|
||||
}
|
||||
@ -1652,7 +1653,7 @@ xpc::EvalInSandbox(JSContext *cx, HandleObject sandboxArg, const nsAString& sour
|
||||
if (returnStringOnly) {
|
||||
// The caller asked for strings only, convert the
|
||||
// exception into a string.
|
||||
JSString *str = JS_ValueToString(sandcx, exn);
|
||||
JSString *str = ToString(sandcx, exn);
|
||||
exn = str ? JS::StringValue(str) : JS::UndefinedValue();
|
||||
}
|
||||
}
|
||||
|
@ -1576,7 +1576,7 @@ nsXPCComponents_ID::CallOrConstruct(nsIXPConnectWrappedNative *wrapper,
|
||||
JSAutoByteString bytes;
|
||||
nsID id;
|
||||
|
||||
if (!(jsstr = JS_ValueToString(cx, args[0])) ||
|
||||
if (!(jsstr = ToString(cx, args[0])) ||
|
||||
!bytes.encodeLatin1(cx, jsstr) ||
|
||||
!id.Parse(bytes.ptr())) {
|
||||
return ThrowAndFail(NS_ERROR_XPC_BAD_ID_STRING, cx, _retval);
|
||||
@ -1837,7 +1837,7 @@ struct MOZ_STACK_CLASS ExceptionArgParser
|
||||
*/
|
||||
|
||||
bool parseMessage(HandleValue v) {
|
||||
JSString *str = JS_ValueToString(cx, v);
|
||||
JSString *str = ToString(cx, v);
|
||||
if (!str)
|
||||
return false;
|
||||
eMsg = messageBytes.encodeLatin1(cx, str);
|
||||
@ -2450,7 +2450,7 @@ nsXPCComponents_Constructor::CallOrConstruct(nsIXPConnectWrappedNative *wrapper,
|
||||
|
||||
if (args.length() >= 3) {
|
||||
// args[2] is an initializer function or property name
|
||||
RootedString str(cx, JS_ValueToString(cx, args[2]));
|
||||
RootedString str(cx, ToString(cx, args[2]));
|
||||
if (!str || !(cInitializer = cInitializerBytes.encodeLatin1(cx, str)))
|
||||
return ThrowAndFail(NS_ERROR_XPC_BAD_CONVERT_JS, cx, _retval);
|
||||
}
|
||||
@ -2476,7 +2476,7 @@ nsXPCComponents_Constructor::CallOrConstruct(nsIXPConnectWrappedNative *wrapper,
|
||||
return ThrowAndFail(NS_ERROR_XPC_UNEXPECTED, cx, _retval);
|
||||
}
|
||||
|
||||
RootedString str(cx, JS_ValueToString(cx, args[1]));
|
||||
RootedString str(cx, ToString(cx, args[1]));
|
||||
RootedId id(cx);
|
||||
if (!str || !JS_ValueToId(cx, StringValue(str), id.address()))
|
||||
return ThrowAndFail(NS_ERROR_XPC_BAD_CONVERT_JS, cx, _retval);
|
||||
@ -2525,7 +2525,7 @@ nsXPCComponents_Constructor::CallOrConstruct(nsIXPConnectWrappedNative *wrapper,
|
||||
return ThrowAndFail(NS_ERROR_XPC_UNEXPECTED, cx, _retval);
|
||||
}
|
||||
|
||||
RootedString str(cx, JS_ValueToString(cx, args[0]));
|
||||
RootedString str(cx, ToString(cx, args[0]));
|
||||
RootedId id(cx);
|
||||
if (!str || !JS_ValueToId(cx, StringValue(str), id.address()))
|
||||
return ThrowAndFail(NS_ERROR_XPC_BAD_CONVERT_JS, cx, _retval);
|
||||
@ -2665,7 +2665,7 @@ nsXPCComponents_Utils::ReportError(const Value &errorArg, JSContext *cx)
|
||||
}
|
||||
|
||||
// It's not a JS Error object, so we synthesize as best we're able.
|
||||
RootedString msgstr(cx, JS_ValueToString(cx, error));
|
||||
RootedString msgstr(cx, ToString(cx, error));
|
||||
if (!msgstr)
|
||||
return NS_OK;
|
||||
|
||||
@ -2698,7 +2698,7 @@ nsXPCComponents_Utils::ReportError(const Value &errorArg, JSContext *cx)
|
||||
NS_IMETHODIMP
|
||||
nsXPCComponents_Utils::EvalInSandbox(const nsAString& source,
|
||||
const Value& sandboxValArg,
|
||||
const Value& version,
|
||||
const Value& versionArg,
|
||||
const Value& filenameVal,
|
||||
int32_t lineNumber,
|
||||
JSContext *cx,
|
||||
@ -2706,6 +2706,7 @@ nsXPCComponents_Utils::EvalInSandbox(const nsAString& source,
|
||||
Value *retval)
|
||||
{
|
||||
RootedValue sandboxVal(cx, sandboxValArg);
|
||||
RootedValue version(cx, versionArg);
|
||||
RootedObject sandbox(cx);
|
||||
if (!JS_ValueToObject(cx, sandboxVal, &sandbox) || !sandbox)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
@ -2713,7 +2714,7 @@ nsXPCComponents_Utils::EvalInSandbox(const nsAString& source,
|
||||
// Optional third argument: JS version, as a string.
|
||||
JSVersion jsVersion = JSVERSION_DEFAULT;
|
||||
if (optionalArgc >= 1) {
|
||||
JSString *jsVersionStr = JS_ValueToString(cx, version);
|
||||
JSString *jsVersionStr = ToString(cx, version);
|
||||
if (!jsVersionStr)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
@ -2737,7 +2738,8 @@ nsXPCComponents_Utils::EvalInSandbox(const nsAString& source,
|
||||
nsXPIDLCString filename;
|
||||
int32_t lineNo = (optionalArgc >= 3) ? lineNumber : 1;
|
||||
if (optionalArgc >= 2) {
|
||||
JSString *filenameStr = JS_ValueToString(cx, filenameVal);
|
||||
RootedValue value(cx, filenameVal);
|
||||
JSString *filenameStr = ToString(cx, value);
|
||||
if (!filenameStr)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
|
@ -410,7 +410,7 @@ XPCConvert::JSData2Native(void* d, HandleValue s,
|
||||
return ConvertToPrimitive(cx, s, static_cast<bool*>(d));
|
||||
case nsXPTType::T_CHAR :
|
||||
{
|
||||
JSString* str = JS_ValueToString(cx, s);
|
||||
JSString* str = ToString(cx, s);
|
||||
if (!str) {
|
||||
return false;
|
||||
}
|
||||
@ -429,7 +429,7 @@ XPCConvert::JSData2Native(void* d, HandleValue s,
|
||||
case nsXPTType::T_WCHAR :
|
||||
{
|
||||
JSString* str;
|
||||
if (!(str = JS_ValueToString(cx, s))) {
|
||||
if (!(str = ToString(cx, s))) {
|
||||
return false;
|
||||
}
|
||||
size_t length;
|
||||
@ -495,7 +495,7 @@ XPCConvert::JSData2Native(void* d, HandleValue s,
|
||||
length = 0;
|
||||
}
|
||||
} else if (!JSVAL_IS_NULL(s)) {
|
||||
str = JS_ValueToString(cx, s);
|
||||
str = ToString(cx, s);
|
||||
if (!str)
|
||||
return false;
|
||||
|
||||
@ -559,7 +559,7 @@ XPCConvert::JSData2Native(void* d, HandleValue s,
|
||||
return true;
|
||||
}
|
||||
|
||||
JSString* str = JS_ValueToString(cx, s);
|
||||
JSString* str = ToString(cx, s);
|
||||
if (!str) {
|
||||
return false;
|
||||
}
|
||||
@ -600,7 +600,7 @@ XPCConvert::JSData2Native(void* d, HandleValue s,
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(str = JS_ValueToString(cx, s))) {
|
||||
if (!(str = ToString(cx, s))) {
|
||||
return false;
|
||||
}
|
||||
if (!(chars = JS_GetStringCharsZ(cx, str))) {
|
||||
@ -643,7 +643,7 @@ XPCConvert::JSData2Native(void* d, HandleValue s,
|
||||
|
||||
// The JS val is neither null nor void...
|
||||
|
||||
if (!(str = JS_ValueToString(cx, s))||
|
||||
if (!(str = ToString(cx, s))||
|
||||
!(chars = JS_GetStringCharsZ(cx, str))) {
|
||||
return false;
|
||||
}
|
||||
@ -686,7 +686,7 @@ XPCConvert::JSData2Native(void* d, HandleValue s,
|
||||
}
|
||||
|
||||
// The JS val is neither null nor void...
|
||||
JSString* str = JS_ValueToString(cx, s);
|
||||
JSString* str = ToString(cx, s);
|
||||
if (!str) {
|
||||
return false;
|
||||
}
|
||||
@ -1164,7 +1164,7 @@ XPCConvert::JSValToXPCException(MutableHandleValue s,
|
||||
if (nullptr != (report = JS_ErrorFromException(cx, s))) {
|
||||
JSAutoByteString message;
|
||||
JSString* str;
|
||||
if (nullptr != (str = JS_ValueToString(cx, s)))
|
||||
if (nullptr != (str = ToString(cx, s)))
|
||||
message.encodeLatin1(cx, str);
|
||||
return JSErrorToXPCException(message.ptr(), ifaceName,
|
||||
methodName, report, exceptn);
|
||||
@ -1201,7 +1201,7 @@ XPCConvert::JSValToXPCException(MutableHandleValue s,
|
||||
|
||||
// otherwise we'll just try to convert it to a string
|
||||
|
||||
JSString* str = JS_ValueToString(cx, s);
|
||||
JSString* str = ToString(cx, s);
|
||||
if (!str)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
@ -1272,7 +1272,7 @@ XPCConvert::JSValToXPCException(MutableHandleValue s,
|
||||
// otherwise we'll just try to convert it to a string
|
||||
// Note: e.g., bools get converted to JSStrings by this code.
|
||||
|
||||
JSString* str = JS_ValueToString(cx, s);
|
||||
JSString* str = ToString(cx, s);
|
||||
if (str) {
|
||||
JSAutoByteString strBytes(cx, str);
|
||||
if (!!strBytes) {
|
||||
@ -1793,7 +1793,7 @@ XPCConvert::JSStringWithSize2Native(void* d, HandleValue s,
|
||||
return true;
|
||||
}
|
||||
|
||||
JSString* str = JS_ValueToString(cx, s);
|
||||
JSString* str = ToString(cx, s);
|
||||
if (!str) {
|
||||
return false;
|
||||
}
|
||||
@ -1848,7 +1848,7 @@ XPCConvert::JSStringWithSize2Native(void* d, HandleValue s,
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(str = JS_ValueToString(cx, s))) {
|
||||
if (!(str = ToString(cx, s))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ xpc_DumpEvalInJSStackFrame(JSContext* cx, uint32_t frameno, const char* text)
|
||||
JSString* str;
|
||||
JSAutoByteString bytes;
|
||||
if (frame.evaluateInStackFrame(cx, text, strlen(text), "eval", 1, &rval) &&
|
||||
nullptr != (str = JS_ValueToString(cx, rval)) &&
|
||||
nullptr != (str = ToString(cx, rval)) &&
|
||||
bytes.encodeLatin1(cx, str)) {
|
||||
DebugDump("%s\n", bytes.ptr());
|
||||
} else
|
||||
|
@ -748,46 +748,19 @@ xpc_qsUnwrapArgImpl(JSContext *cx,
|
||||
}
|
||||
|
||||
bool
|
||||
xpc_qsJsvalToCharStr(JSContext *cx, jsval v, JSAutoByteString *bytes)
|
||||
xpc_qsJsvalToCharStr(JSContext *cx, HandleValue v, JSAutoByteString *bytes)
|
||||
{
|
||||
JSString *str;
|
||||
|
||||
MOZ_ASSERT(!bytes->ptr());
|
||||
if (JSVAL_IS_STRING(v)) {
|
||||
str = JSVAL_TO_STRING(v);
|
||||
} else if (JSVAL_IS_VOID(v) || JSVAL_IS_NULL(v)) {
|
||||
|
||||
if (v.isNullOrUndefined())
|
||||
return true;
|
||||
} else {
|
||||
if (!(str = JS_ValueToString(cx, v)))
|
||||
|
||||
JSString *str = ToString(cx, v);
|
||||
if (!str)
|
||||
return false;
|
||||
}
|
||||
return !!bytes->encodeLatin1(cx, str);
|
||||
}
|
||||
|
||||
bool
|
||||
xpc_qsJsvalToWcharStr(JSContext *cx, jsval v, jsval *pval, const PRUnichar **pstr)
|
||||
{
|
||||
JSString *str;
|
||||
|
||||
if (JSVAL_IS_STRING(v)) {
|
||||
str = JSVAL_TO_STRING(v);
|
||||
} else if (JSVAL_IS_VOID(v) || JSVAL_IS_NULL(v)) {
|
||||
*pstr = nullptr;
|
||||
return true;
|
||||
} else {
|
||||
if (!(str = JS_ValueToString(cx, v)))
|
||||
return false;
|
||||
*pval = STRING_TO_JSVAL(str); // Root the new string.
|
||||
}
|
||||
|
||||
const jschar *chars = JS_GetStringCharsZ(cx, str);
|
||||
if (!chars)
|
||||
return false;
|
||||
|
||||
*pstr = static_cast<const PRUnichar *>(chars);
|
||||
return true;
|
||||
}
|
||||
|
||||
namespace xpc {
|
||||
|
||||
bool
|
||||
|
@ -227,7 +227,7 @@ protected:
|
||||
* when |v| is JSVAL_IS_NULL and JSVAL_IS_VOID respectively.
|
||||
*/
|
||||
template<class traits>
|
||||
JSString* InitOrStringify(JSContext* cx, jsval v,
|
||||
JSString* InitOrStringify(JSContext* cx, JS::HandleValue v,
|
||||
JS::MutableHandleValue pval,
|
||||
bool notpassed,
|
||||
StringificationBehavior nullBehavior,
|
||||
@ -255,7 +255,7 @@ protected:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
s = JS_ValueToString(cx, v);
|
||||
s = JS::ToString(cx, v);
|
||||
if (!s) {
|
||||
mValid = false;
|
||||
return nullptr;
|
||||
|
@ -211,18 +211,20 @@ GetLine(JSContext *cx, char *bufp, FILE *file, const char *prompt) {
|
||||
static bool
|
||||
ReadLine(JSContext *cx, unsigned argc, jsval *vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
// While 4096 might be quite arbitrary, this is something to be fixed in
|
||||
// bug 105707. It is also the same limit as in ProcessFile.
|
||||
char buf[4096];
|
||||
JSString *str;
|
||||
RootedString str(cx);
|
||||
|
||||
/* If a prompt was specified, construct the string */
|
||||
if (argc > 0) {
|
||||
str = JS_ValueToString(cx, JS_ARGV(cx, vp)[0]);
|
||||
if (args.length() > 0) {
|
||||
str = JS::ToString(cx, args[0]);
|
||||
if (!str)
|
||||
return false;
|
||||
} else {
|
||||
str = JSVAL_TO_STRING(JS_GetEmptyStringValue(cx));
|
||||
str = JS_GetEmptyString(JS_GetRuntime(cx));
|
||||
}
|
||||
|
||||
/* Get a line from the infile */
|
||||
@ -253,12 +255,11 @@ ReadLine(JSContext *cx, unsigned argc, jsval *vp)
|
||||
static bool
|
||||
Print(JSContext *cx, unsigned argc, jsval *vp)
|
||||
{
|
||||
unsigned i, n;
|
||||
JSString *str;
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
jsval *argv = JS_ARGV(cx, vp);
|
||||
for (i = n = 0; i < argc; i++) {
|
||||
str = JS_ValueToString(cx, argv[i]);
|
||||
RootedString str(cx);
|
||||
for (unsigned i = 0; i < args.length(); i++) {
|
||||
str = ToString(cx, args[i]);
|
||||
if (!str)
|
||||
return false;
|
||||
JSAutoByteString strBytes(cx, str);
|
||||
@ -267,23 +268,22 @@ Print(JSContext *cx, unsigned argc, jsval *vp)
|
||||
fprintf(gOutFile, "%s%s", i ? " " : "", strBytes.ptr());
|
||||
fflush(gOutFile);
|
||||
}
|
||||
n++;
|
||||
if (n)
|
||||
fputc('\n', gOutFile);
|
||||
JS_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
Dump(JSContext *cx, unsigned argc, jsval *vp)
|
||||
{
|
||||
JS_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
JSString *str;
|
||||
if (!argc)
|
||||
args.rval().setUndefined();
|
||||
|
||||
if (!args.length())
|
||||
return true;
|
||||
|
||||
str = JS_ValueToString(cx, JS_ARGV(cx, vp)[0]);
|
||||
RootedString str(cx, ToString(cx, args[0]));
|
||||
if (!str)
|
||||
return false;
|
||||
|
||||
@ -302,16 +302,17 @@ Dump(JSContext *cx, unsigned argc, jsval *vp)
|
||||
static bool
|
||||
Load(JSContext *cx, unsigned argc, jsval *vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
JS::Rooted<JSObject*> obj(cx, JS_THIS_OBJECT(cx, vp));
|
||||
if (!obj)
|
||||
return false;
|
||||
|
||||
jsval *argv = JS_ARGV(cx, vp);
|
||||
for (unsigned i = 0; i < argc; i++) {
|
||||
JSString *str = JS_ValueToString(cx, argv[i]);
|
||||
RootedString str(cx);
|
||||
for (unsigned i = 0; i < args.length(); i++) {
|
||||
str = ToString(cx, args[i]);
|
||||
if (!str)
|
||||
return false;
|
||||
argv[i] = STRING_TO_JSVAL(str);
|
||||
JSAutoByteString filename(cx, str);
|
||||
if (!filename)
|
||||
return false;
|
||||
@ -335,7 +336,7 @@ Load(JSContext *cx, unsigned argc, jsval *vp)
|
||||
if (!compileOnly && !JS_ExecuteScript(cx, obj, script, result.address()))
|
||||
return false;
|
||||
}
|
||||
JS_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -430,33 +431,32 @@ GCZeal(JSContext *cx, unsigned argc, jsval *vp)
|
||||
#endif
|
||||
|
||||
static bool
|
||||
SendCommand(JSContext* cx,
|
||||
unsigned argc,
|
||||
jsval* vp)
|
||||
SendCommand(JSContext *cx, unsigned argc, Value *vp)
|
||||
{
|
||||
if (argc == 0) {
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
if (args.length() == 0) {
|
||||
JS_ReportError(cx, "Function takes at least one argument!");
|
||||
return false;
|
||||
}
|
||||
|
||||
jsval *argv = JS_ARGV(cx, vp);
|
||||
JSString* str = JS_ValueToString(cx, argv[0]);
|
||||
JSString* str = ToString(cx, args[0]);
|
||||
if (!str) {
|
||||
JS_ReportError(cx, "Could not convert argument 1 to string!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (argc > 1 && JS_TypeOfValue(cx, argv[1]) != JSTYPE_FUNCTION) {
|
||||
if (args.length() > 1 && JS_TypeOfValue(cx, args[1]) != JSTYPE_FUNCTION) {
|
||||
JS_ReportError(cx, "Could not convert argument 2 to function!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!XRE_SendTestShellCommand(cx, str, argc > 1 ? &argv[1] : nullptr)) {
|
||||
if (!XRE_SendTestShellCommand(cx, str, args.length() > 1 ? args[1].address() : nullptr)) {
|
||||
JS_ReportError(cx, "Couldn't send command!");
|
||||
return false;
|
||||
}
|
||||
|
||||
JS_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -467,7 +467,7 @@ Options(JSContext *cx, unsigned argc, jsval *vp)
|
||||
ContextOptions oldOptions = ContextOptionsRef(cx);
|
||||
|
||||
for (unsigned i = 0; i < argc; ++i) {
|
||||
JSString *str = JS_ValueToString(cx, args[i]);
|
||||
JSString *str = ToString(cx, args[i]);
|
||||
if (!str)
|
||||
return false;
|
||||
|
||||
@ -731,12 +731,12 @@ env_setProperty(JSContext *cx, HandleObject obj, HandleId id, bool strict, Mutab
|
||||
JS::Rooted<JSString*> idstr(cx);
|
||||
int rv;
|
||||
|
||||
jsval idval;
|
||||
if (!JS_IdToValue(cx, id, &idval))
|
||||
RootedValue idval(cx);
|
||||
if (!JS_IdToValue(cx, id, idval.address()))
|
||||
return false;
|
||||
|
||||
idstr = JS_ValueToString(cx, idval);
|
||||
valstr = JS_ValueToString(cx, vp);
|
||||
idstr = ToString(cx, idval);
|
||||
valstr = ToString(cx, vp);
|
||||
if (!idstr || !valstr)
|
||||
return false;
|
||||
JSAutoByteString name(cx, idstr);
|
||||
@ -814,11 +814,11 @@ env_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
|
||||
{
|
||||
JSString *idstr, *valstr;
|
||||
|
||||
jsval idval;
|
||||
if (!JS_IdToValue(cx, id, &idval))
|
||||
RootedValue idval(cx);
|
||||
if (!JS_IdToValue(cx, id, idval.address()))
|
||||
return false;
|
||||
|
||||
idstr = JS_ValueToString(cx, idval);
|
||||
idstr = ToString(cx, idval);
|
||||
if (!idstr)
|
||||
return false;
|
||||
JSAutoByteString name(cx, idstr);
|
||||
@ -954,9 +954,9 @@ ProcessFile(JSContext *cx, JS::Handle<JSObject*> obj, const char *filename, FILE
|
||||
if (!compileOnly) {
|
||||
ok = JS_ExecuteScript(cx, obj, script, result.address());
|
||||
if (ok && result != JSVAL_VOID) {
|
||||
/* Suppress error reports from JS_ValueToString(). */
|
||||
/* Suppress error reports from JS::ToString(). */
|
||||
older = JS_SetErrorReporter(cx, nullptr);
|
||||
str = JS_ValueToString(cx, result);
|
||||
str = ToString(cx, result);
|
||||
JS_SetErrorReporter(cx, older);
|
||||
JSAutoByteString bytes;
|
||||
if (str && bytes.encodeLatin1(cx, str))
|
||||
|
@ -388,7 +388,7 @@ nsXPCWrappedJSClass::BuildPropertyEnumerator(XPCCallContext& ccx,
|
||||
if (!JS_IdToValue(cx, idName, jsvalName.address()))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
JSString* name = JS_ValueToString(cx, jsvalName);
|
||||
JSString* name = ToString(cx, jsvalName);
|
||||
if (!name)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -454,11 +454,6 @@ argumentUnboxingTemplates = {
|
||||
" return false;\n"
|
||||
" char *${name} = ${name}_bytes.ptr();\n",
|
||||
|
||||
'wstring':
|
||||
" const PRUnichar *${name};\n"
|
||||
" if (!xpc_qsJsvalToWcharStr(cx, ${argVal}, ${argPtr}, &${name}))\n"
|
||||
" return false;\n",
|
||||
|
||||
'[cstring]':
|
||||
" xpc_qsACString ${name}(cx, ${argVal}, ${argPtr}, ${notPassed});\n"
|
||||
" if (!${name}.IsValid())\n"
|
||||
|
@ -957,7 +957,8 @@ cryptojs_ReadArgsAndGenerateKey(JSContext *cx,
|
||||
}
|
||||
keySize = JSVAL_TO_INT(argv[0]);
|
||||
if (!JSVAL_IS_NULL(argv[1])) {
|
||||
jsString = JS_ValueToString(cx,argv[1]);
|
||||
JS::Rooted<JS::Value> v(cx, argv[1]);
|
||||
jsString = JS::ToString(cx, v);
|
||||
NS_ENSURE_TRUE(jsString, NS_ERROR_OUT_OF_MEMORY);
|
||||
argv[1] = STRING_TO_JSVAL(jsString);
|
||||
params.encodeLatin1(cx, jsString);
|
||||
@ -969,7 +970,8 @@ cryptojs_ReadArgsAndGenerateKey(JSContext *cx,
|
||||
"key generation type not specified");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
jsString = JS_ValueToString(cx, argv[2]);
|
||||
JS::Rooted<JS::Value> v(cx, argv[2]);
|
||||
jsString = JS::ToString(cx, v);
|
||||
NS_ENSURE_TRUE(jsString, NS_ERROR_OUT_OF_MEMORY);
|
||||
argv[2] = STRING_TO_JSVAL(jsString);
|
||||
nsDependentJSString dependentKeyGenAlg;
|
||||
|
Loading…
Reference in New Issue
Block a user