зеркало из https://github.com/mozilla/pjs.git
bug 610198 - Replacing JS_GetStringBytes usage with JS_EncodeString. r=gal
This commit is contained in:
Родитель
c46dc735b0
Коммит
7ebf7dfa52
|
@ -68,7 +68,7 @@ nsSecurityNameSet::~nsSecurityNameSet()
|
|||
|
||||
NS_IMPL_ISUPPORTS1(nsSecurityNameSet, nsIScriptExternalNameSet)
|
||||
|
||||
static char *
|
||||
static JSString *
|
||||
getStringArgument(JSContext *cx, JSObject *obj, PRUint16 argNum, uintN argc, jsval *argv)
|
||||
{
|
||||
if (argc <= argNum || !JSVAL_IS_STRING(argv[argNum])) {
|
||||
|
@ -80,11 +80,15 @@ getStringArgument(JSContext *cx, JSObject *obj, PRUint16 argNum, uintN argc, jsv
|
|||
* We don't want to use JS_ValueToString because we want to be able
|
||||
* to have an object to represent a target in subsequent versions.
|
||||
*/
|
||||
JSString *str = JSVAL_TO_STRING(argv[argNum]);
|
||||
if (!str)
|
||||
return nsnull;
|
||||
return JSVAL_TO_STRING(argv[argNum]);
|
||||
}
|
||||
|
||||
return JS_GetStringBytes(str);
|
||||
static bool
|
||||
getBytesArgument(JSContext *cx, JSObject *obj, PRUint16 argNum, uintN argc, jsval *argv,
|
||||
JSAutoByteString *bytes)
|
||||
{
|
||||
JSString *str = getStringArgument(cx, obj, argNum, argc, argv);
|
||||
return str && bytes->encode(cx, str);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -119,15 +123,18 @@ netscape_security_isPrivilegeEnabled(JSContext *cx, uintN argc, jsval *vp)
|
|||
return JS_FALSE;
|
||||
|
||||
JSBool result = JS_FALSE;
|
||||
char *cap = getStringArgument(cx, obj, 0, argc, JS_ARGV(cx, vp));
|
||||
if (cap) {
|
||||
if (JSString *str = getStringArgument(cx, obj, 0, argc, JS_ARGV(cx, vp))) {
|
||||
JSAutoByteString cap(cx, str);
|
||||
if (!cap)
|
||||
return JS_FALSE;
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIScriptSecurityManager> securityManager =
|
||||
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// NS_ASSERTION(cx == GetCurrentContext(), "unexpected context");
|
||||
|
||||
rv = securityManager->IsCapabilityEnabled(cap, &result);
|
||||
rv = securityManager->IsCapabilityEnabled(cap.ptr(), &result);
|
||||
if (NS_FAILED(rv))
|
||||
result = JS_FALSE;
|
||||
}
|
||||
|
@ -144,8 +151,8 @@ netscape_security_enablePrivilege(JSContext *cx, uintN argc, jsval *vp)
|
|||
if (!obj)
|
||||
return JS_FALSE;
|
||||
|
||||
char *cap = getStringArgument(cx, obj, 0, argc, JS_ARGV(cx, vp));
|
||||
if (!cap)
|
||||
JSAutoByteString cap;
|
||||
if (!getBytesArgument(cx, obj, 0, argc, JS_ARGV(cx, vp), &cap))
|
||||
return JS_FALSE;
|
||||
|
||||
nsresult rv;
|
||||
|
@ -156,7 +163,7 @@ netscape_security_enablePrivilege(JSContext *cx, uintN argc, jsval *vp)
|
|||
|
||||
// NS_ASSERTION(cx == GetCurrentContext(), "unexpected context");
|
||||
|
||||
rv = securityManager->EnableCapability(cap);
|
||||
rv = securityManager->EnableCapability(cap.ptr());
|
||||
if (NS_FAILED(rv))
|
||||
return JS_FALSE;
|
||||
JS_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
|
@ -170,8 +177,8 @@ netscape_security_disablePrivilege(JSContext *cx, uintN argc, jsval *vp)
|
|||
if (!obj)
|
||||
return JS_FALSE;
|
||||
|
||||
char *cap = getStringArgument(cx, obj, 0, argc, JS_ARGV(cx, vp));
|
||||
if (!cap)
|
||||
JSAutoByteString cap;
|
||||
if (!getBytesArgument(cx, obj, 0, argc, JS_ARGV(cx, vp), &cap))
|
||||
return JS_FALSE;
|
||||
|
||||
nsresult rv;
|
||||
|
@ -182,7 +189,7 @@ netscape_security_disablePrivilege(JSContext *cx, uintN argc, jsval *vp)
|
|||
|
||||
// NS_ASSERTION(cx == GetCurrentContext(), "unexpected context");
|
||||
|
||||
rv = securityManager->DisableCapability(cap);
|
||||
rv = securityManager->DisableCapability(cap.ptr());
|
||||
if (NS_FAILED(rv))
|
||||
return JS_FALSE;
|
||||
JS_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
|
@ -196,8 +203,8 @@ netscape_security_revertPrivilege(JSContext *cx, uintN argc, jsval *vp)
|
|||
if (!obj)
|
||||
return JS_FALSE;
|
||||
|
||||
char *cap = getStringArgument(cx, obj, 0, argc, JS_ARGV(cx, vp));
|
||||
if (!cap)
|
||||
JSAutoByteString cap;
|
||||
if (!getBytesArgument(cx, obj, 0, argc, JS_ARGV(cx, vp), &cap))
|
||||
return JS_FALSE;
|
||||
|
||||
nsresult rv;
|
||||
|
@ -208,7 +215,7 @@ netscape_security_revertPrivilege(JSContext *cx, uintN argc, jsval *vp)
|
|||
|
||||
// NS_ASSERTION(cx == GetCurrentContext(), "unexpected context");
|
||||
|
||||
rv = securityManager->RevertCapability(cap);
|
||||
rv = securityManager->RevertCapability(cap.ptr());
|
||||
if (NS_FAILED(rv))
|
||||
return JS_FALSE;
|
||||
JS_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
|
@ -225,7 +232,8 @@ netscape_security_setCanEnablePrivilege(JSContext *cx, uintN argc, jsval *vp)
|
|||
if (argc < 2) return JS_FALSE;
|
||||
nsCAutoString principalFingerprint;
|
||||
getUTF8StringArgument(cx, obj, 0, argc, JS_ARGV(cx, vp), principalFingerprint);
|
||||
char *cap = getStringArgument(cx, obj, 1, argc, JS_ARGV(cx, vp));
|
||||
JSAutoByteString cap;
|
||||
getBytesArgument(cx, obj, 1, argc, JS_ARGV(cx, vp), &cap);
|
||||
if (principalFingerprint.IsEmpty() || !cap)
|
||||
return JS_FALSE;
|
||||
|
||||
|
@ -237,7 +245,8 @@ netscape_security_setCanEnablePrivilege(JSContext *cx, uintN argc, jsval *vp)
|
|||
|
||||
// NS_ASSERTION(cx == GetCurrentContext(), "unexpected context");
|
||||
|
||||
rv = securityManager->SetCanEnableCapability(principalFingerprint, cap,
|
||||
rv = securityManager->SetCanEnableCapability(principalFingerprint,
|
||||
cap.ptr(),
|
||||
nsIPrincipal::ENABLE_GRANTED);
|
||||
if (NS_FAILED(rv))
|
||||
return JS_FALSE;
|
||||
|
|
|
@ -3136,7 +3136,6 @@ TraceMallocOpenLogFile(JSContext *cx, uintN argc, jsval *vp)
|
|||
{
|
||||
int fd;
|
||||
JSString *str;
|
||||
char *filename;
|
||||
|
||||
if (!CheckUniversalXPConnectForTraceMalloc(cx))
|
||||
return JS_FALSE;
|
||||
|
@ -3147,10 +3146,12 @@ TraceMallocOpenLogFile(JSContext *cx, uintN argc, jsval *vp)
|
|||
str = JS_ValueToString(cx, JS_ARGV(cx, vp)[0]);
|
||||
if (!str)
|
||||
return JS_FALSE;
|
||||
filename = JS_GetStringBytes(str);
|
||||
fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC, 0644);
|
||||
JSAutoByteString filename(cx, str);
|
||||
if (!filename)
|
||||
return JS_FALSE;
|
||||
fd = open(filename.ptr(), O_CREAT | O_WRONLY | O_TRUNC, 0644);
|
||||
if (fd < 0) {
|
||||
JS_ReportError(cx, "can't open %s: %s", filename, strerror(errno));
|
||||
JS_ReportError(cx, "can't open %s: %s", filename.ptr(), strerror(errno));
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -3201,17 +3202,16 @@ TraceMallocCloseLogFD(JSContext *cx, uintN argc, jsval *vp)
|
|||
static JSBool
|
||||
TraceMallocLogTimestamp(JSContext *cx, uintN argc, jsval *vp)
|
||||
{
|
||||
JSString *str;
|
||||
const char *caption;
|
||||
|
||||
if (!CheckUniversalXPConnectForTraceMalloc(cx))
|
||||
return JS_FALSE;
|
||||
|
||||
str = JS_ValueToString(cx, argc ? JS_ARGV(cx, vp)[0] : JSVAL_VOID);
|
||||
JSString *str = JS_ValueToString(cx, argc ? JS_ARGV(cx, vp)[0] : JSVAL_VOID);
|
||||
if (!str)
|
||||
return JS_FALSE;
|
||||
caption = JS_GetStringBytes(str);
|
||||
NS_TraceMallocLogTimestamp(caption);
|
||||
JSAutoByteString caption(cx, str);
|
||||
if (!caption)
|
||||
return JS_FALSE;
|
||||
NS_TraceMallocLogTimestamp(caption.ptr());
|
||||
JS_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
@ -3219,18 +3219,17 @@ TraceMallocLogTimestamp(JSContext *cx, uintN argc, jsval *vp)
|
|||
static JSBool
|
||||
TraceMallocDumpAllocations(JSContext *cx, uintN argc, jsval *vp)
|
||||
{
|
||||
JSString *str;
|
||||
const char *pathname;
|
||||
|
||||
if (!CheckUniversalXPConnectForTraceMalloc(cx))
|
||||
return JS_FALSE;
|
||||
|
||||
str = JS_ValueToString(cx, argc ? JS_ARGV(cx, vp)[0] : JSVAL_VOID);
|
||||
JSString *str = JS_ValueToString(cx, argc ? JS_ARGV(cx, vp)[0] : JSVAL_VOID);
|
||||
if (!str)
|
||||
return JS_FALSE;
|
||||
pathname = JS_GetStringBytes(str);
|
||||
if (NS_TraceMallocDumpAllocations(pathname) < 0) {
|
||||
JS_ReportError(cx, "can't dump to %s: %s", pathname, strerror(errno));
|
||||
JSAutoByteString pathname(cx, str);
|
||||
if (!pathname)
|
||||
return JS_FALSE;
|
||||
if (NS_TraceMallocDumpAllocations(pathname.ptr()) < 0) {
|
||||
JS_ReportError(cx, "can't dump to %s: %s", pathname.ptr(), strerror(errno));
|
||||
return JS_FALSE;
|
||||
}
|
||||
JS_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
|
|
|
@ -151,18 +151,20 @@ Print(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
for (unsigned int i=0; i<argc; ++i) {
|
||||
JSString *str = JS_ValueToString(cx, argv[i]);
|
||||
if (!str) return JS_FALSE;
|
||||
JSAutoByteString bytes(cx, str);
|
||||
if (!bytes) return JS_FALSE;
|
||||
if (shell->mOutput) {
|
||||
if (shell->mEmitHeader) {
|
||||
char buf[80];
|
||||
sprintf(buf, "[%d]", JS_GetStringLength(str));
|
||||
shell->mOutput->Write(buf, strlen(buf), &bytesWritten);
|
||||
}
|
||||
shell->mOutput->Write(JS_GetStringBytes(str), JS_GetStringLength(str), &bytesWritten);
|
||||
shell->mOutput->Write(bytes.ptr(), strlen(bytes), &bytesWritten);
|
||||
}
|
||||
else
|
||||
printf("%s", JS_GetStringBytes(str)); // use cout if no output stream given.
|
||||
printf("%s", bytes.ptr()); // use cout if no output stream given.
|
||||
#ifdef DEBUG
|
||||
// printf("%s", JS_GetStringBytes(str));
|
||||
// printf("%s", bytes.ptr());
|
||||
#endif
|
||||
}
|
||||
return JS_TRUE;
|
||||
|
@ -196,7 +198,8 @@ Load(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
JSString *str = JS_ValueToString(cx, argv[i]);
|
||||
if (!str) return JS_FALSE;
|
||||
//argv[i] = STRING_TO_JSVAL(str);
|
||||
const char *url = JS_GetStringBytes(str);
|
||||
JSAutoByteString url(cx, str);
|
||||
if (!url) return JS_FALSE;
|
||||
if (!shell->LoadURL(url, rval))
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
|
|
@ -254,7 +254,10 @@ Print(JSContext *cx,
|
|||
str = JS_ValueToString(cx, argv[i]);
|
||||
if (!str)
|
||||
return JS_FALSE;
|
||||
fprintf(stdout, "%s%s", i ? " " : "", JS_GetStringBytes(str));
|
||||
JSAutoByteString bytes(cx, str);
|
||||
if (!bytes)
|
||||
return JS_FALSE;
|
||||
fprintf(stdout, "%s%s", i ? " " : "", bytes.ptr());
|
||||
fflush(stdout);
|
||||
}
|
||||
n++;
|
||||
|
@ -304,7 +307,6 @@ Load(JSContext *cx,
|
|||
{
|
||||
uintN i;
|
||||
JSString *str;
|
||||
const char *filename;
|
||||
JSScript *script;
|
||||
JSBool ok;
|
||||
jsval result;
|
||||
|
@ -320,13 +322,15 @@ Load(JSContext *cx,
|
|||
if (!str)
|
||||
return JS_FALSE;
|
||||
argv[i] = STRING_TO_JSVAL(str);
|
||||
filename = JS_GetStringBytes(str);
|
||||
file = fopen(filename, "r");
|
||||
JSAutoByteString filename(cx, str);
|
||||
if (!filename)
|
||||
return JS_FALSE;
|
||||
file = fopen(filename.ptr(), "r");
|
||||
if (!file) {
|
||||
JS_ReportError(cx, "cannot open file '%s' for reading", filename);
|
||||
JS_ReportError(cx, "cannot open file '%s' for reading", filename.ptr());
|
||||
return JS_FALSE;
|
||||
}
|
||||
script = JS_CompileFileHandleForPrincipals(cx, obj, filename, file,
|
||||
script = JS_CompileFileHandleForPrincipals(cx, obj, filename.ptr(), file,
|
||||
Environment(cx)->GetPrincipal());
|
||||
fclose(file);
|
||||
if (!script)
|
||||
|
@ -430,7 +434,7 @@ DumpHeap(JSContext *cx,
|
|||
uintN argc,
|
||||
jsval *vp)
|
||||
{
|
||||
char *fileName = NULL;
|
||||
JSAutoByteString fileName;
|
||||
void* startThing = NULL;
|
||||
uint32 startTraceKind = 0;
|
||||
void *thingToFind = NULL;
|
||||
|
@ -450,7 +454,8 @@ DumpHeap(JSContext *cx,
|
|||
if (!str)
|
||||
return JS_FALSE;
|
||||
*vp = STRING_TO_JSVAL(str);
|
||||
fileName = JS_GetStringBytes(str);
|
||||
if (!fileName.encode(cx, str))
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
vp = argv + 1;
|
||||
|
@ -487,10 +492,10 @@ DumpHeap(JSContext *cx,
|
|||
if (!fileName) {
|
||||
dumpFile = stdout;
|
||||
} else {
|
||||
dumpFile = fopen(fileName, "w");
|
||||
dumpFile = fopen(fileName.ptr(), "w");
|
||||
if (!dumpFile) {
|
||||
fprintf(stderr, "dumpHeap: can't open %s: %s\n",
|
||||
fileName, strerror(errno));
|
||||
fileName.ptr(), strerror(errno));
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -671,10 +676,13 @@ ProcessFile(JSContext *cx,
|
|||
/* Suppress error reports from JS_ValueToString(). */
|
||||
older = JS_SetErrorReporter(cx, NULL);
|
||||
str = JS_ValueToString(cx, result);
|
||||
JSAutoByteString bytes;
|
||||
if (str)
|
||||
bytes.encode(cx, str);
|
||||
JS_SetErrorReporter(cx, older);
|
||||
|
||||
if (str)
|
||||
fprintf(stdout, "%s\n", JS_GetStringBytes(str));
|
||||
if (!!bytes)
|
||||
fprintf(stdout, "%s\n", bytes.ptr());
|
||||
else
|
||||
ok = JS_FALSE;
|
||||
}
|
||||
|
|
|
@ -513,18 +513,17 @@ JSBool
|
|||
TypeError(JSContext* cx, const char* expected, jsval actual)
|
||||
{
|
||||
JSString* str = JS_ValueToSource(cx, actual);
|
||||
js::AutoStringRooter root(cx, str);
|
||||
|
||||
JSAutoByteString bytes;
|
||||
|
||||
const char* src;
|
||||
if (str) {
|
||||
src = JS_GetStringBytesZ(cx, str);
|
||||
src = bytes.encode(cx, str);
|
||||
if (!src)
|
||||
return false;
|
||||
} else {
|
||||
JS_ClearPendingException(cx);
|
||||
src = "<<error converting value to string>>";
|
||||
}
|
||||
|
||||
JS_ReportErrorNumber(cx, GetErrorMessage, NULL,
|
||||
CTYPESMSG_TYPE_ERROR, expected, src);
|
||||
return false;
|
||||
|
@ -4331,11 +4330,11 @@ StructType::LookupField(JSContext* cx, JSObject* obj, JSString *name)
|
|||
if (ptr)
|
||||
return &ptr->value;
|
||||
|
||||
const char* bytes = JS_GetStringBytesZ(cx, name);
|
||||
JSAutoByteString bytes(cx, name);
|
||||
if (!bytes)
|
||||
return NULL;
|
||||
|
||||
JS_ReportError(cx, "%s does not name a field", bytes);
|
||||
JS_ReportError(cx, "%s does not name a field", bytes.ptr());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -174,8 +174,11 @@ class JSAPITest
|
|||
|
||||
JSAPITestString toSource(jsval v) {
|
||||
JSString *str = JS_ValueToSource(cx, v);
|
||||
if (str)
|
||||
return JSAPITestString(JS_GetStringBytes(str));
|
||||
if (str) {
|
||||
JSAutoByteString bytes(cx, str);
|
||||
if (!!bytes)
|
||||
return JSAPITestString(bytes.ptr());
|
||||
}
|
||||
JS_ClearPendingException(cx);
|
||||
return JSAPITestString("<<error converting value to string>>");
|
||||
}
|
||||
|
@ -207,8 +210,11 @@ class JSAPITest
|
|||
JS_GetPendingException(cx, v.addr());
|
||||
JS_ClearPendingException(cx);
|
||||
JSString *s = JS_ValueToString(cx, v);
|
||||
if (s)
|
||||
msg += JS_GetStringBytes(s);
|
||||
if (s) {
|
||||
JSAutoByteString bytes(cx, s);
|
||||
if (!!bytes)
|
||||
msg += bytes.ptr();
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "%s:%d:%.*s\n", filename, lineno, (int) msg.length(), msg.begin());
|
||||
msgs += msg;
|
||||
|
|
|
@ -253,10 +253,11 @@ JS_ConvertArgumentsVA(JSContext *cx, uintN argc, jsval *argv, const char *format
|
|||
if (fun) {
|
||||
char numBuf[12];
|
||||
JS_snprintf(numBuf, sizeof numBuf, "%u", argc);
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
||||
JSMSG_MORE_ARGS_NEEDED,
|
||||
JS_GetFunctionName(fun), numBuf,
|
||||
(argc == 1) ? "" : "s");
|
||||
JSAutoByteString funNameBytes;
|
||||
if (const char *name = GetFunctionNameBytes(cx, fun, &funNameBytes)) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_MORE_ARGS_NEEDED,
|
||||
name, numBuf, (argc == 1) ? "" : "s");
|
||||
}
|
||||
}
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
@ -5017,8 +5018,11 @@ JS_New(JSContext *cx, JSObject *ctor, uintN argc, jsval *argv)
|
|||
* Although constructors may return primitives (via proxies), this
|
||||
* API is asking for an object, so we report an error.
|
||||
*/
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_BAD_NEW_RESULT,
|
||||
js_ValueToPrintableString(cx, args.rval()));
|
||||
JSAutoByteString bytes;
|
||||
if (js_ValueToPrintable(cx, args.rval(), &bytes)) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_BAD_NEW_RESULT,
|
||||
bytes.ptr());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2918,6 +2918,56 @@ JS_DecodeBytes(JSContext *cx, const char *src, size_t srclen, jschar *dst,
|
|||
JS_PUBLIC_API(char *)
|
||||
JS_EncodeString(JSContext *cx, JSString *str);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
class JSAutoByteString {
|
||||
public:
|
||||
JSAutoByteString(JSContext *cx, JSString *str JS_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: mBytes(JS_EncodeString(cx, str)) {
|
||||
JS_ASSERT(cx);
|
||||
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
}
|
||||
|
||||
JSAutoByteString(JS_GUARD_OBJECT_NOTIFIER_PARAM0)
|
||||
: mBytes(NULL) {
|
||||
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
}
|
||||
|
||||
~JSAutoByteString() {
|
||||
js_free(mBytes);
|
||||
}
|
||||
|
||||
char *encode(JSContext *cx, JSString *str) {
|
||||
JS_ASSERT(!mBytes);
|
||||
JS_ASSERT(cx);
|
||||
mBytes = JS_EncodeString(cx, str);
|
||||
return mBytes;
|
||||
}
|
||||
|
||||
void clear() {
|
||||
js_free(mBytes);
|
||||
mBytes = NULL;
|
||||
}
|
||||
|
||||
char *ptr() const {
|
||||
return mBytes;
|
||||
}
|
||||
|
||||
bool operator!() const {
|
||||
return !mBytes;
|
||||
}
|
||||
|
||||
private:
|
||||
char *mBytes;
|
||||
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
|
||||
/* Copy and assignment are not supported. */
|
||||
JSAutoByteString(const JSAutoByteString &another);
|
||||
JSAutoByteString &operator=(const JSAutoByteString &another);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/************************************************************************/
|
||||
/*
|
||||
* JSON functions
|
||||
|
|
|
@ -90,9 +90,9 @@ JS_STATIC_ASSERT((1 + 2) * sizeof(JSAtom *) ==
|
|||
offsetof(JSAtomState, typeAtoms) - ATOM_OFFSET_START);
|
||||
|
||||
const char *
|
||||
js_AtomToPrintableString(JSContext *cx, JSAtom *atom)
|
||||
js_AtomToPrintableString(JSContext *cx, JSAtom *atom, JSAutoByteString *bytes)
|
||||
{
|
||||
return js_ValueToPrintableString(cx, StringValue(ATOM_TO_STRING(atom)));
|
||||
return js_ValueToPrintable(cx, StringValue(ATOM_TO_STRING(atom)), bytes);
|
||||
}
|
||||
|
||||
#define JS_PROTO(name,code,init) const char js_##name##_str[] = #name;
|
||||
|
|
|
@ -133,11 +133,10 @@ IdToJsval(jsid id)
|
|||
|
||||
/*
|
||||
* Return a printable, lossless char[] representation of a string-type atom.
|
||||
* The lifetime of the result extends at least until the next GC activation,
|
||||
* longer if cx's string newborn root is not overwritten.
|
||||
* The lifetime of the result matches the lifetime of bytes.
|
||||
*/
|
||||
extern const char *
|
||||
js_AtomToPrintableString(JSContext *cx, JSAtom *atom);
|
||||
js_AtomToPrintableString(JSContext *cx, JSAtom *atom, JSAutoByteString *bytes);
|
||||
|
||||
struct JSAtomListElement {
|
||||
JSHashEntry entry;
|
||||
|
|
|
@ -2299,21 +2299,18 @@ date_toLocaleTimeString(JSContext *cx, uintN argc, Value *vp)
|
|||
static JSBool
|
||||
date_toLocaleFormat(JSContext *cx, uintN argc, Value *vp)
|
||||
{
|
||||
JSString *fmt;
|
||||
const char *fmtbytes;
|
||||
|
||||
if (argc == 0)
|
||||
return date_toLocaleString(cx, argc, vp);
|
||||
|
||||
fmt = js_ValueToString(cx, vp[2]);
|
||||
JSString *fmt = js_ValueToString(cx, vp[2]);
|
||||
if (!fmt)
|
||||
return JS_FALSE;
|
||||
vp[2].setString(fmt);
|
||||
fmtbytes = js_GetStringBytes(cx, fmt);
|
||||
JSAutoByteString fmtbytes(cx, fmt);
|
||||
if (!fmtbytes)
|
||||
return JS_FALSE;
|
||||
|
||||
return date_toLocaleHelper(cx, fmtbytes, vp);
|
||||
return date_toLocaleHelper(cx, fmtbytes.ptr(), vp);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
|
|
|
@ -698,12 +698,6 @@ FilenameToString(JSContext *cx, const char *filename)
|
|||
return JS_NewStringCopyZ(cx, filename);
|
||||
}
|
||||
|
||||
static const char *
|
||||
StringToFilename(JSContext *cx, JSString *str)
|
||||
{
|
||||
return js_GetStringBytes(cx, str);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
Exception(JSContext *cx, uintN argc, Value *vp)
|
||||
{
|
||||
|
@ -1247,44 +1241,42 @@ js_ReportUncaughtException(JSContext *cx)
|
|||
|
||||
/* XXX L10N angels cry once again (see also jsemit.c, /L10N gaffes/) */
|
||||
str = js_ValueToString(cx, Valueify(exn));
|
||||
JSAutoByteString bytesStorage;
|
||||
if (!str) {
|
||||
bytes = "unknown (can't convert to string)";
|
||||
} else {
|
||||
roots[1] = STRING_TO_JSVAL(str);
|
||||
bytes = js_GetStringBytes(cx, str);
|
||||
if (!bytes)
|
||||
if (!bytesStorage.encode(cx, str))
|
||||
return false;
|
||||
bytes = bytesStorage.ptr();
|
||||
}
|
||||
|
||||
JSAutoByteString filename;
|
||||
if (!reportp && exnObject && exnObject->getClass() == &js_ErrorClass) {
|
||||
const char *filename;
|
||||
|
||||
if (!JS_GetProperty(cx, exnObject, js_message_str, &roots[2]))
|
||||
return false;
|
||||
if (JSVAL_IS_STRING(roots[2])) {
|
||||
bytes = js_GetStringBytes(cx, JSVAL_TO_STRING(roots[2]));
|
||||
if (!bytes)
|
||||
bytesStorage.clear();
|
||||
if (!bytesStorage.encode(cx, str))
|
||||
return false;
|
||||
bytes = bytesStorage.ptr();
|
||||
}
|
||||
|
||||
if (!JS_GetProperty(cx, exnObject, js_fileName_str, &roots[3]))
|
||||
return false;
|
||||
str = js_ValueToString(cx, Valueify(roots[3]));
|
||||
if (!str)
|
||||
return false;
|
||||
filename = StringToFilename(cx, str);
|
||||
if (!filename)
|
||||
if (!str || !filename.encode(cx, str))
|
||||
return false;
|
||||
|
||||
if (!JS_GetProperty(cx, exnObject, js_lineNumber_str, &roots[4]))
|
||||
return false;
|
||||
uint32_t lineno;
|
||||
if (!ValueToECMAUint32 (cx, Valueify(roots[4]), &lineno))
|
||||
if (!ValueToECMAUint32(cx, Valueify(roots[4]), &lineno))
|
||||
return false;
|
||||
|
||||
reportp = &report;
|
||||
PodZero(&report);
|
||||
report.filename = filename;
|
||||
report.filename = filename.ptr();
|
||||
report.lineno = (uintN) lineno;
|
||||
if (JSVAL_IS_STRING(roots[2])) {
|
||||
report.ucmessage = js_GetStringChars(cx, JSVAL_TO_STRING(roots[2]));
|
||||
|
|
|
@ -1806,15 +1806,17 @@ js_XDRFunctionObject(JSXDRState *xdr, JSObject **objp)
|
|||
if (xdr->mode == JSXDR_ENCODE) {
|
||||
fun = GET_FUNCTION_PRIVATE(cx, *objp);
|
||||
if (!FUN_INTERPRETED(fun)) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
||||
JSMSG_NOT_SCRIPTED_FUNCTION,
|
||||
JS_GetFunctionName(fun));
|
||||
JSAutoByteString funNameBytes;
|
||||
if (const char *name = GetFunctionNameBytes(cx, fun, &funNameBytes)) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_NOT_SCRIPTED_FUNCTION,
|
||||
name);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (fun->u.i.wrapper) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
||||
JSMSG_XDR_CLOSURE_WRAPPER,
|
||||
JS_GetFunctionName(fun));
|
||||
JSAutoByteString funNameBytes;
|
||||
if (const char *name = GetFunctionNameBytes(cx, fun, &funNameBytes))
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_XDR_CLOSURE_WRAPPER, name);
|
||||
return false;
|
||||
}
|
||||
JS_ASSERT((fun->u.i.wrapper & ~1U) == 0);
|
||||
|
@ -2188,13 +2190,12 @@ js_fun_call(JSContext *cx, uintN argc, Value *vp)
|
|||
if (!js_IsCallable(fval)) {
|
||||
JSString *str = js_ValueToString(cx, fval);
|
||||
if (str) {
|
||||
const char *bytes = js_GetStringBytes(cx, str);
|
||||
|
||||
if (bytes) {
|
||||
JSAutoByteString bytes(cx, str);
|
||||
if (!!bytes) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
||||
JSMSG_INCOMPATIBLE_PROTO,
|
||||
js_Function_str, js_call_str,
|
||||
bytes);
|
||||
bytes.ptr());
|
||||
}
|
||||
}
|
||||
return JS_FALSE;
|
||||
|
@ -2238,11 +2239,12 @@ js_fun_apply(JSContext *cx, uintN argc, Value *vp)
|
|||
Value fval = vp[1];
|
||||
if (!js_IsCallable(fval)) {
|
||||
if (JSString *str = js_ValueToString(cx, fval)) {
|
||||
if (const char *bytes = js_GetStringBytes(cx, str)) {
|
||||
JSAutoByteString bytes(cx, str);
|
||||
if (!!bytes) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
||||
JSMSG_INCOMPATIBLE_PROTO,
|
||||
js_Function_str, js_apply_str,
|
||||
bytes);
|
||||
bytes.ptr());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -2414,10 +2416,11 @@ fun_bind(JSContext *cx, uintN argc, Value *vp)
|
|||
/* Step 2. */
|
||||
if (!target->isCallable()) {
|
||||
if (JSString *str = js_ValueToString(cx, vp[1])) {
|
||||
if (const char *bytes = js_GetStringBytes(cx, str)) {
|
||||
JSAutoByteString bytes(cx, str);
|
||||
if (!!bytes) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
||||
JSMSG_INCOMPATIBLE_PROTO,
|
||||
js_Function_str, "bind", bytes);
|
||||
js_Function_str, "bind", bytes.ptr());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -2636,12 +2639,14 @@ Function(JSContext *cx, uintN argc, Value *vp)
|
|||
|
||||
/* Check for a duplicate parameter name. */
|
||||
if (fun->lookupLocal(cx, atom, NULL) != JSLOCAL_NONE) {
|
||||
const char *name;
|
||||
|
||||
name = js_AtomToPrintableString(cx, atom);
|
||||
if (!name && ReportCompileErrorNumber(cx, &ts, NULL,
|
||||
JSREPORT_WARNING | JSREPORT_STRICT,
|
||||
JSMSG_DUPLICATE_FORMAL, name)) {
|
||||
JSAutoByteString name;
|
||||
if (!js_AtomToPrintableString(cx, atom, &name)) {
|
||||
state = BAD;
|
||||
goto after_args;
|
||||
}
|
||||
if (!ReportCompileErrorNumber(cx, &ts, NULL,
|
||||
JSREPORT_WARNING | JSREPORT_STRICT,
|
||||
JSMSG_DUPLICATE_FORMAL, name.ptr())) {
|
||||
goto after_args;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -489,6 +489,14 @@ IsConstructing_PossiblyWithGivenThisObject(const Value *vp, JSObject **ctorThis)
|
|||
return isCtor;
|
||||
}
|
||||
|
||||
inline const char *
|
||||
GetFunctionNameBytes(JSContext *cx, JSFunction *fun, JSAutoByteString *bytes)
|
||||
{
|
||||
if (fun->atom)
|
||||
return bytes->encode(cx, ATOM_TO_STRING(fun->atom));
|
||||
return js_anonymous_str;
|
||||
}
|
||||
|
||||
} /* namespace js */
|
||||
|
||||
extern JSString *
|
||||
|
|
|
@ -499,10 +499,11 @@ ReportIncompatibleMethod(JSContext *cx, Value *vp, Class *clasp)
|
|||
: thisv.isUndefined()
|
||||
? js_undefined_str
|
||||
: "value";
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
||||
JSMSG_INCOMPATIBLE_PROTO,
|
||||
clasp->name, JS_GetFunctionName(fun),
|
||||
name);
|
||||
JSAutoByteString funNameBytes;
|
||||
if (const char *funName = GetFunctionNameBytes(cx, fun, &funNameBytes)) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_INCOMPATIBLE_PROTO,
|
||||
clasp->name, funName, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1113,7 +1114,8 @@ CheckRedeclaration(JSContext *cx, JSObject *obj, jsid id, uintN attrs,
|
|||
: isFunction
|
||||
? js_function_str
|
||||
: js_var_str;
|
||||
name = js_ValueToPrintableString(cx, IdToValue(id));
|
||||
JSAutoByteString bytes;
|
||||
name = js_ValueToPrintable(cx, IdToValue(id), &bytes);
|
||||
if (!name)
|
||||
return JS_FALSE;
|
||||
return !!JS_ReportErrorFlagsAndNumber(cx, report,
|
||||
|
@ -1218,12 +1220,12 @@ InstanceOfSlow(JSContext *cx, JSObject *obj, Class *clasp, Value *argv)
|
|||
if (argv) {
|
||||
JSFunction *fun = js_ValueToFunction(cx, &argv[-2], 0);
|
||||
if (fun) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
||||
JSMSG_INCOMPATIBLE_PROTO,
|
||||
clasp->name, JS_GetFunctionName(fun),
|
||||
obj
|
||||
? obj->getClass()->name
|
||||
: js_null_str);
|
||||
JSAutoByteString funNameBytes;
|
||||
if (const char *funName = GetFunctionNameBytes(cx, fun, &funNameBytes)) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_INCOMPATIBLE_PROTO,
|
||||
clasp->name, funName,
|
||||
obj ? obj->getClass()->name : js_null_str);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -1269,10 +1271,12 @@ InvokeConstructor(JSContext *cx, const CallArgs &argsRef)
|
|||
if (args.rval().isPrimitive()) {
|
||||
if (clasp != &js_FunctionClass) {
|
||||
/* native [[Construct]] returning primitive is error */
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
||||
JSMSG_BAD_NEW_RESULT,
|
||||
js_ValueToPrintableString(cx, args.rval()));
|
||||
return false;
|
||||
JSAutoByteString bytes;
|
||||
if (js_ValueToPrintable(cx, args.rval(), &bytes)) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
||||
JSMSG_BAD_NEW_RESULT, bytes.ptr());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* The interpreter fixes rval for us. */
|
||||
|
@ -6967,13 +6971,11 @@ END_CASE(JSOP_ARRAYPUSH)
|
|||
|
||||
atom_not_defined:
|
||||
{
|
||||
const char *printable;
|
||||
|
||||
printable = js_AtomToPrintableString(cx, atomNotDefined);
|
||||
if (printable)
|
||||
js_ReportIsNotDefined(cx, printable);
|
||||
goto error;
|
||||
JSAutoByteString printable;
|
||||
if (js_AtomToPrintableString(cx, atomNotDefined, &printable))
|
||||
js_ReportIsNotDefined(cx, printable.ptr());
|
||||
}
|
||||
goto error;
|
||||
|
||||
/*
|
||||
* This path is used when it's guaranteed the method can be finished
|
||||
|
|
|
@ -417,9 +417,11 @@ GetCustomIterator(JSContext *cx, JSObject *obj, uintN flags, Value *vp)
|
|||
* We are always coming from js_ValueToIterator, and we are no longer on
|
||||
* trace, so the object we are iterating over is on top of the stack (-1).
|
||||
*/
|
||||
JSAutoByteString bytes;
|
||||
if (!js_AtomToPrintableString(cx, atom, &bytes))
|
||||
return false;
|
||||
js_ReportValueError2(cx, JSMSG_BAD_TRAP_RETURN_VALUE,
|
||||
-1, ObjectValue(*obj), NULL,
|
||||
js_AtomToPrintableString(cx, atom));
|
||||
-1, ObjectValue(*obj), NULL, bytes.ptr());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -731,7 +731,10 @@ num_toLocaleString(JSContext *cx, uintN argc, Value *vp)
|
|||
if (!num_toString(cx, 0, vp))
|
||||
return JS_FALSE;
|
||||
JS_ASSERT(vp->isString());
|
||||
num = js_GetStringBytes(cx, vp->toString());
|
||||
JSAutoByteString numBytes(cx, vp->toString());
|
||||
if (!numBytes)
|
||||
return JS_FALSE;
|
||||
num = numBytes.ptr();
|
||||
if (!num)
|
||||
return JS_FALSE;
|
||||
|
||||
|
|
|
@ -913,18 +913,17 @@ js_CheckPrincipalsAccess(JSContext *cx, JSObject *scopeobj,
|
|||
{
|
||||
JSSecurityCallbacks *callbacks;
|
||||
JSPrincipals *scopePrincipals;
|
||||
const char *callerstr;
|
||||
|
||||
callbacks = JS_GetSecurityCallbacks(cx);
|
||||
if (callbacks && callbacks->findObjectPrincipals) {
|
||||
scopePrincipals = callbacks->findObjectPrincipals(cx, scopeobj);
|
||||
if (!principals || !scopePrincipals ||
|
||||
!principals->subsume(principals, scopePrincipals)) {
|
||||
callerstr = js_AtomToPrintableString(cx, caller);
|
||||
if (!callerstr)
|
||||
JSAutoByteString callerstr;
|
||||
if (!js_AtomToPrintableString(cx, caller, &callerstr))
|
||||
return JS_FALSE;
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
||||
JSMSG_BAD_INDIRECT_CALL, callerstr);
|
||||
JSMSG_BAD_INDIRECT_CALL, callerstr.ptr());
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -1949,8 +1948,10 @@ Reject(JSContext *cx, uintN errorNumber, bool throwError, jsid id, bool *rval)
|
|||
jsid idstr;
|
||||
if (!js_ValueToStringId(cx, IdToValue(id), &idstr))
|
||||
return JS_FALSE;
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, errorNumber,
|
||||
JS_GetStringBytes(JSID_TO_STRING(idstr)));
|
||||
JSAutoByteString bytes(cx, JSID_TO_STRING(idstr));
|
||||
if (!bytes)
|
||||
return JS_FALSE;
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, errorNumber, bytes.ptr());
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -5150,13 +5151,13 @@ js_CheckUndeclaredVarAssignment(JSContext *cx, JSString *propname)
|
|||
return true;
|
||||
}
|
||||
|
||||
const char *bytes = js_GetStringBytes(cx, propname);
|
||||
return bytes &&
|
||||
JSAutoByteString bytes(cx, propname);
|
||||
return !!bytes &&
|
||||
JS_ReportErrorFlagsAndNumber(cx,
|
||||
(JSREPORT_WARNING | JSREPORT_STRICT
|
||||
| JSREPORT_STRICT_MODE_ERROR),
|
||||
js_GetErrorMessage, NULL,
|
||||
JSMSG_UNDECLARED_VAR, bytes);
|
||||
JSMSG_UNDECLARED_VAR, bytes.ptr());
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -289,8 +289,8 @@ js_DumpScript(JSContext *cx, JSScript *script)
|
|||
return js_Disassemble(cx, script, true, stdout);
|
||||
}
|
||||
|
||||
const char *
|
||||
ToDisassemblySource(JSContext *cx, jsval v)
|
||||
static bool
|
||||
ToDisassemblySource(JSContext *cx, jsval v, JSAutoByteString *bytes)
|
||||
{
|
||||
if (!JSVAL_IS_PRIMITIVE(v)) {
|
||||
JSObject *obj = JSVAL_TO_OBJECT(v);
|
||||
|
@ -302,13 +302,13 @@ ToDisassemblySource(JSContext *cx, jsval v)
|
|||
Shape::Range r = obj->lastProperty()->all();
|
||||
while (!r.empty()) {
|
||||
const Shape &shape = r.front();
|
||||
const char *bytes = js_AtomToPrintableString(cx, JSID_TO_ATOM(shape.id));
|
||||
if (!bytes)
|
||||
JSAutoByteString bytes;
|
||||
if (!js_AtomToPrintableString(cx, JSID_TO_ATOM(shape.id), &bytes))
|
||||
return NULL;
|
||||
|
||||
r.popFront();
|
||||
source = JS_sprintf_append(source, "%s: %d%s",
|
||||
bytes, shape.shortid,
|
||||
bytes.ptr(), shape.shortid,
|
||||
!r.empty() ? ", " : "");
|
||||
}
|
||||
|
||||
|
@ -319,7 +319,7 @@ ToDisassemblySource(JSContext *cx, jsval v)
|
|||
JSString *str = JS_NewString(cx, source, strlen(source));
|
||||
if (!str)
|
||||
return NULL;
|
||||
return js_GetStringBytes(cx, str);
|
||||
return bytes->encode(cx, str);
|
||||
}
|
||||
|
||||
if (clasp == &js_FunctionClass) {
|
||||
|
@ -327,18 +327,18 @@ ToDisassemblySource(JSContext *cx, jsval v)
|
|||
JSString *str = JS_DecompileFunction(cx, fun, JS_DONT_PRETTY_PRINT);
|
||||
if (!str)
|
||||
return NULL;
|
||||
return js_GetStringBytes(cx, str);
|
||||
return bytes->encode(cx, str);
|
||||
}
|
||||
|
||||
if (clasp == &js_RegExpClass) {
|
||||
AutoValueRooter tvr(cx);
|
||||
if (!js_regexp_toString(cx, obj, tvr.addr()))
|
||||
return NULL;
|
||||
return js_GetStringBytes(cx, JSVAL_TO_STRING(Jsvalify(tvr.value())));
|
||||
return bytes->encode(cx, JSVAL_TO_STRING(Jsvalify(tvr.value())));
|
||||
}
|
||||
}
|
||||
|
||||
return js_ValueToPrintableSource(cx, Valueify(v));
|
||||
return !!js_ValueToPrintable(cx, Valueify(v), bytes, true);
|
||||
}
|
||||
|
||||
JS_FRIEND_API(uintN)
|
||||
|
@ -353,7 +353,6 @@ js_Disassemble1(JSContext *cx, JSScript *script, jsbytecode *pc,
|
|||
uintN index;
|
||||
JSObject *obj;
|
||||
jsval v;
|
||||
const char *bytes;
|
||||
jsint i;
|
||||
|
||||
op = (JSOp)*pc;
|
||||
|
@ -404,19 +403,23 @@ js_Disassemble1(JSContext *cx, JSScript *script, jsbytecode *pc,
|
|||
obj = script->getRegExp(index);
|
||||
v = OBJECT_TO_JSVAL(obj);
|
||||
}
|
||||
bytes = ToDisassemblySource(cx, v);
|
||||
if (!bytes)
|
||||
return 0;
|
||||
fprintf(fp, " %s", bytes);
|
||||
{
|
||||
JSAutoByteString bytes;
|
||||
if (!ToDisassemblySource(cx, v, &bytes))
|
||||
return 0;
|
||||
fprintf(fp, " %s", bytes.ptr());
|
||||
}
|
||||
break;
|
||||
|
||||
case JOF_GLOBAL:
|
||||
atom = script->getGlobalAtom(GET_SLOTNO(pc));
|
||||
v = ATOM_TO_JSVAL(atom);
|
||||
bytes = ToDisassemblySource(cx, v);
|
||||
if (!bytes)
|
||||
return 0;
|
||||
fprintf(fp, " %s", bytes);
|
||||
{
|
||||
JSAutoByteString bytes;
|
||||
if (!ToDisassemblySource(cx, v, &bytes))
|
||||
return 0;
|
||||
fprintf(fp, " %s", bytes.ptr());
|
||||
}
|
||||
break;
|
||||
|
||||
case JOF_UINT16PAIR:
|
||||
|
@ -474,10 +477,10 @@ js_Disassemble1(JSContext *cx, JSScript *script, jsbytecode *pc,
|
|||
off = GetJumpOffset(pc, pc2);
|
||||
pc2 += jmplen;
|
||||
|
||||
bytes = ToDisassemblySource(cx, Jsvalify(script->getConst(constIndex)));
|
||||
if (!bytes)
|
||||
JSAutoByteString bytes;
|
||||
if (!ToDisassemblySource(cx, Jsvalify(script->getConst(constIndex)), &bytes))
|
||||
return 0;
|
||||
fprintf(fp, "\n\t%s: %d", bytes, (intN) off);
|
||||
fprintf(fp, "\n\t%s: %d", bytes.ptr(), (intN) off);
|
||||
npairs--;
|
||||
}
|
||||
len = 1 + pc2 - pc;
|
||||
|
@ -493,7 +496,7 @@ js_Disassemble1(JSContext *cx, JSScript *script, jsbytecode *pc,
|
|||
break;
|
||||
|
||||
case JOF_SLOTATOM:
|
||||
case JOF_SLOTOBJECT:
|
||||
case JOF_SLOTOBJECT: {
|
||||
fprintf(fp, " %u", GET_SLOTNO(pc));
|
||||
index = js_GetIndexFromBytecode(cx, script, pc, SLOTNO_LEN);
|
||||
if (type == JOF_SLOTATOM) {
|
||||
|
@ -503,11 +506,13 @@ js_Disassemble1(JSContext *cx, JSScript *script, jsbytecode *pc,
|
|||
obj = script->getObject(index);
|
||||
v = OBJECT_TO_JSVAL(obj);
|
||||
}
|
||||
bytes = ToDisassemblySource(cx, v);
|
||||
if (!bytes)
|
||||
|
||||
JSAutoByteString bytes;
|
||||
if (!ToDisassemblySource(cx, v, &bytes))
|
||||
return 0;
|
||||
fprintf(fp, " %s", bytes);
|
||||
fprintf(fp, " %s", bytes.ptr());
|
||||
break;
|
||||
}
|
||||
|
||||
case JOF_UINT24:
|
||||
JS_ASSERT(op == JSOP_UINT24 || op == JSOP_NEWARRAY);
|
||||
|
@ -1461,10 +1466,13 @@ DecompileDestructuringLHS(SprintStack *ss, jsbytecode *pc, jsbytecode *endpc,
|
|||
} else {
|
||||
lval = GetLocal(ss, i);
|
||||
}
|
||||
if (atom)
|
||||
lval = js_AtomToPrintableString(cx, atom);
|
||||
LOCAL_ASSERT(lval);
|
||||
todo = SprintCString(&ss->sprinter, lval);
|
||||
{
|
||||
JSAutoByteString bytes;
|
||||
if (atom)
|
||||
lval = js_AtomToPrintableString(cx, atom, &bytes);
|
||||
LOCAL_ASSERT(lval);
|
||||
todo = SprintCString(&ss->sprinter, lval);
|
||||
}
|
||||
if (op != JSOP_SETLOCALPOP) {
|
||||
pc += oplen;
|
||||
if (pc == endpc)
|
||||
|
|
|
@ -1232,16 +1232,16 @@ static JSBool
|
|||
ReportBadReturn(JSContext *cx, JSTreeContext *tc, uintN flags, uintN errnum,
|
||||
uintN anonerrnum)
|
||||
{
|
||||
const char *name;
|
||||
JSAutoByteString name;
|
||||
|
||||
JS_ASSERT(tc->inFunction());
|
||||
if (tc->fun->atom) {
|
||||
name = js_AtomToPrintableString(cx, tc->fun->atom);
|
||||
if (!js_AtomToPrintableString(cx, tc->fun->atom, &name))
|
||||
return false;
|
||||
} else {
|
||||
errnum = anonerrnum;
|
||||
name = NULL;
|
||||
}
|
||||
return ReportCompileErrorNumber(cx, TS(tc->parser), NULL, flags, errnum, name);
|
||||
return ReportCompileErrorNumber(cx, TS(tc->parser), NULL, flags, errnum, name.ptr());
|
||||
}
|
||||
|
||||
static JSBool
|
||||
|
@ -1264,10 +1264,10 @@ CheckStrictAssignment(JSContext *cx, JSTreeContext *tc, JSParseNode *lhs)
|
|||
JSAtom *atom = lhs->pn_atom;
|
||||
JSAtomState *atomState = &cx->runtime->atomState;
|
||||
if (atom == atomState->evalAtom || atom == atomState->argumentsAtom) {
|
||||
const char *name = js_AtomToPrintableString(cx, atom);
|
||||
if (!name ||
|
||||
JSAutoByteString name;
|
||||
if (!js_AtomToPrintableString(cx, atom, &name) ||
|
||||
!ReportStrictModeError(cx, TS(tc->parser), tc, lhs, JSMSG_DEPRECATED_ASSIGN,
|
||||
name)) {
|
||||
name.ptr())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1289,10 +1289,10 @@ CheckStrictBinding(JSContext *cx, JSTreeContext *tc, JSAtom *atom, JSParseNode *
|
|||
|
||||
JSAtomState *atomState = &cx->runtime->atomState;
|
||||
if (atom == atomState->evalAtom || atom == atomState->argumentsAtom) {
|
||||
const char *name = js_AtomToPrintableString(cx, atom);
|
||||
if (!name)
|
||||
JSAutoByteString name;
|
||||
if (!js_AtomToPrintableString(cx, atom, &name))
|
||||
return false;
|
||||
return ReportStrictModeError(cx, TS(tc->parser), tc, pn, JSMSG_BAD_BINDING, name);
|
||||
return ReportStrictModeError(cx, TS(tc->parser), tc, pn, JSMSG_BAD_BINDING, name.ptr());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1329,9 +1329,10 @@ CheckStrictFormals(JSContext *cx, JSTreeContext *tc, JSFunction *fun,
|
|||
JSDefinition *dn = ALE_DEFN(tc->decls.lookup(atom));
|
||||
if (dn->pn_op == JSOP_GETARG)
|
||||
pn = dn;
|
||||
const char *name = js_AtomToPrintableString(cx, atom);
|
||||
if (!name ||
|
||||
!ReportStrictModeError(cx, TS(tc->parser), tc, pn, JSMSG_DUPLICATE_FORMAL, name)) {
|
||||
JSAutoByteString name;
|
||||
if (!js_AtomToPrintableString(cx, atom, &name) ||
|
||||
!ReportStrictModeError(cx, TS(tc->parser), tc, pn, JSMSG_DUPLICATE_FORMAL,
|
||||
name.ptr())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1343,9 +1344,9 @@ CheckStrictFormals(JSContext *cx, JSTreeContext *tc, JSFunction *fun,
|
|||
/* The definition's source position will be more precise. */
|
||||
JSDefinition *dn = ALE_DEFN(tc->decls.lookup(atom));
|
||||
JS_ASSERT(dn->pn_atom == atom);
|
||||
const char *name = js_AtomToPrintableString(cx, atom);
|
||||
if (!name ||
|
||||
!ReportStrictModeError(cx, TS(tc->parser), tc, dn, JSMSG_BAD_BINDING, name)) {
|
||||
JSAutoByteString name;
|
||||
if (!js_AtomToPrintableString(cx, atom, &name) ||
|
||||
!ReportStrictModeError(cx, TS(tc->parser), tc, dn, JSMSG_BAD_BINDING, name.ptr())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -2888,15 +2889,15 @@ Parser::functionDef(JSAtom *funAtom, FunctionType type, uintN lambda)
|
|||
JS_ASSERT(dn->pn_defn);
|
||||
|
||||
if (JS_HAS_STRICT_OPTION(context) || dn_kind == JSDefinition::CONST) {
|
||||
const char *name = js_AtomToPrintableString(context, funAtom);
|
||||
if (!name ||
|
||||
JSAutoByteString name;
|
||||
if (!js_AtomToPrintableString(context, funAtom, &name) ||
|
||||
!reportErrorNumber(NULL,
|
||||
(dn_kind != JSDefinition::CONST)
|
||||
? JSREPORT_WARNING | JSREPORT_STRICT
|
||||
: JSREPORT_ERROR,
|
||||
JSMSG_REDECLARED_VAR,
|
||||
JSDefinition::kindString(dn_kind),
|
||||
name)) {
|
||||
name.ptr())) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -3378,14 +3379,14 @@ BindLet(JSContext *cx, BindData *data, JSAtom *atom, JSTreeContext *tc)
|
|||
blockObj = tc->blockChain();
|
||||
ale = tc->decls.lookup(atom);
|
||||
if (ale && ALE_DEFN(ale)->pn_blockid == tc->blockid()) {
|
||||
const char *name = js_AtomToPrintableString(cx, atom);
|
||||
if (name) {
|
||||
JSAutoByteString name;
|
||||
if (js_AtomToPrintableString(cx, atom, &name)) {
|
||||
ReportCompileErrorNumber(cx, TS(tc->parser), pn,
|
||||
JSREPORT_ERROR, JSMSG_REDECLARED_VAR,
|
||||
(ale && ALE_DEFN(ale)->isConst())
|
||||
? js_const_str
|
||||
: js_variable_str,
|
||||
name);
|
||||
name.ptr());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -3620,22 +3621,21 @@ BindVarOrConst(JSContext *cx, BindData *data, JSAtom *atom, JSTreeContext *tc)
|
|||
if (stmt || ale) {
|
||||
JSDefinition *dn = ale ? ALE_DEFN(ale) : NULL;
|
||||
JSDefinition::Kind dn_kind = dn ? dn->kind() : JSDefinition::VAR;
|
||||
const char *name;
|
||||
|
||||
if (dn_kind == JSDefinition::ARG) {
|
||||
name = js_AtomToPrintableString(cx, atom);
|
||||
if (!name)
|
||||
JSAutoByteString name;
|
||||
if (!js_AtomToPrintableString(cx, atom, &name))
|
||||
return JS_FALSE;
|
||||
|
||||
if (op == JSOP_DEFCONST) {
|
||||
ReportCompileErrorNumber(cx, TS(tc->parser), pn,
|
||||
JSREPORT_ERROR, JSMSG_REDECLARED_PARAM,
|
||||
name);
|
||||
name.ptr());
|
||||
return JS_FALSE;
|
||||
}
|
||||
if (!ReportCompileErrorNumber(cx, TS(tc->parser), pn,
|
||||
JSREPORT_WARNING | JSREPORT_STRICT,
|
||||
JSMSG_VAR_HIDES_ARG, name)) {
|
||||
JSMSG_VAR_HIDES_ARG, name.ptr())) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
} else {
|
||||
|
@ -3647,15 +3647,15 @@ BindVarOrConst(JSContext *cx, BindData *data, JSAtom *atom, JSTreeContext *tc)
|
|||
if (JS_HAS_STRICT_OPTION(cx)
|
||||
? op != JSOP_DEFVAR || dn_kind != JSDefinition::VAR
|
||||
: error) {
|
||||
name = js_AtomToPrintableString(cx, atom);
|
||||
if (!name ||
|
||||
JSAutoByteString name;
|
||||
if (!js_AtomToPrintableString(cx, atom, &name) ||
|
||||
!ReportCompileErrorNumber(cx, TS(tc->parser), pn,
|
||||
!error
|
||||
? JSREPORT_WARNING | JSREPORT_STRICT
|
||||
: JSREPORT_ERROR,
|
||||
JSMSG_REDECLARED_VAR,
|
||||
JSDefinition::kindString(dn_kind),
|
||||
name)) {
|
||||
name.ptr())) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -8429,10 +8429,10 @@ Parser::primaryExpr(TokenKind tt, JSBool afterDot)
|
|||
JSAtomListElement *ale = seen.lookup(atom);
|
||||
if (ale) {
|
||||
if (ALE_INDEX(ale) & attributesMask) {
|
||||
const char *name = js_AtomToPrintableString(context, atom);
|
||||
if (!name ||
|
||||
JSAutoByteString name;
|
||||
if (!js_AtomToPrintableString(context, atom, &name) ||
|
||||
!ReportStrictModeError(context, &tokenStream, tc, NULL,
|
||||
JSMSG_DUPLICATE_PROPERTY, name)) {
|
||||
JSMSG_DUPLICATE_PROPERTY, name.ptr())) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ jsprobes_jsvaltovoid(JSContext *cx, const js::Value &argval)
|
|||
#endif
|
||||
|
||||
const char *
|
||||
Probes::FunctionName(JSContext *cx, const JSFunction *fun)
|
||||
Probes::FunctionName(JSContext *cx, const JSFunction *fun, JSAutoByteString *bytes)
|
||||
{
|
||||
if (!fun)
|
||||
return nullName;
|
||||
|
@ -139,8 +139,7 @@ Probes::FunctionName(JSContext *cx, const JSFunction *fun)
|
|||
return nullName;
|
||||
}
|
||||
|
||||
char *name = (char *)js_GetStringBytes(cx, ATOM_TO_STRING(atom));
|
||||
return name ? name : nullName;
|
||||
return bytes->encode(cx, ATOM_TO_STRING(atom)) ? bytes->ptr() : nullName;
|
||||
}
|
||||
|
||||
#ifdef INCLUDE_MOZILLA_DTRACE
|
||||
|
|
|
@ -50,7 +50,7 @@ class Probes {
|
|||
static const char *FunctionClassname(const JSFunction *fun);
|
||||
static const char *ScriptFilename(JSScript *script);
|
||||
static int FunctionLineNumber(JSContext *cx, const JSFunction *fun);
|
||||
static const char *FunctionName(JSContext *cx, const JSFunction *fun);
|
||||
static const char *FunctionName(JSContext *cx, const JSFunction *fun, JSAutoByteString *bytes);
|
||||
|
||||
static void enterJSFunImpl(JSContext *cx, JSFunction *fun, JSScript *script);
|
||||
static void handleFunctionReturn(JSContext *cx, JSFunction *fun, JSScript *script);
|
||||
|
|
|
@ -179,12 +179,14 @@ PropertyCache::fill(JSContext *cx, JSObject *obj, uintN scopeIndex, uintN protoI
|
|||
if (!pobj->branded()) {
|
||||
PCMETER(brandfills++);
|
||||
#ifdef DEBUG_notme
|
||||
fprintf(stderr,
|
||||
"branding %p (%s) for funobj %p (%s), shape %lu\n",
|
||||
pobj, pobj->getClass()->name,
|
||||
JSVAL_TO_OBJECT(v),
|
||||
JS_GetFunctionName(GET_FUNCTION_PRIVATE(cx, JSVAL_TO_OBJECT(v))),
|
||||
obj->shape());
|
||||
JSFunction *fun = GET_FUNCTION_PRIVATE(cx, JSVAL_TO_OBJECT(v));
|
||||
JSAutoByteString funNameBytes;
|
||||
if (const char *funName = GetFunctionNameBytes(cx, fun, &funNameBytes)) {
|
||||
fprintf(stderr,
|
||||
"branding %p (%s) for funobj %p (%s), shape %lu\n",
|
||||
pobj, pobj->getClass()->name, JSVAL_TO_OBJECT(v), funName,
|
||||
obj->shape());
|
||||
}
|
||||
#endif
|
||||
if (!pobj->brand(cx))
|
||||
return JS_NO_PROP_CACHE_FILL;
|
||||
|
@ -340,10 +342,11 @@ PropertyCache::fullTest(JSContext *cx, jsbytecode *pc, JSObject **objp, JSObject
|
|||
JSAtom *atom = GetAtomFromBytecode(cx, pc, op, cs);
|
||||
#ifdef DEBUG_notme
|
||||
JSScript *script = cx->fp()->getScript();
|
||||
JSAutoByteString printable;
|
||||
fprintf(stderr,
|
||||
"id miss for %s from %s:%u"
|
||||
" (pc %u, kpc %u, kshape %u, shape %u)\n",
|
||||
js_AtomToPrintableString(cx, atom),
|
||||
js_AtomToPrintableString(cx, atom, &printable),
|
||||
script->filename,
|
||||
js_PCToLineNumber(cx, script, pc),
|
||||
pc - script->code,
|
||||
|
|
|
@ -310,8 +310,9 @@ GetFundamentalTrap(JSContext *cx, JSObject *handler, JSAtom *atom, Value *fvalp)
|
|||
return false;
|
||||
|
||||
if (!js_IsCallable(*fvalp)) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_NOT_FUNCTION,
|
||||
js_AtomToPrintableString(cx, atom));
|
||||
JSAutoByteString bytes;
|
||||
if (js_AtomToPrintableString(cx, atom, &bytes))
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_NOT_FUNCTION, bytes.ptr());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -472,9 +473,11 @@ static bool
|
|||
ReturnedValueMustNotBePrimitive(JSContext *cx, JSObject *proxy, JSAtom *atom, const Value &v)
|
||||
{
|
||||
if (v.isPrimitive()) {
|
||||
js_ReportValueError2(cx, JSMSG_BAD_TRAP_RETURN_VALUE,
|
||||
JSDVG_SEARCH_STACK, ObjectOrNullValue(proxy), NULL,
|
||||
js_AtomToPrintableString(cx, atom));
|
||||
JSAutoByteString bytes;
|
||||
if (js_AtomToPrintableString(cx, atom, &bytes)) {
|
||||
js_ReportValueError2(cx, JSMSG_BAD_TRAP_RETURN_VALUE,
|
||||
JSDVG_SEARCH_STACK, ObjectOrNullValue(proxy), NULL, bytes.ptr());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -785,9 +785,10 @@ regexp_exec_sub(JSContext *cx, JSObject *obj, uintN argc, Value *argv, JSBool te
|
|||
/* Need to grab input from statics. */
|
||||
str = res->getPendingInput();
|
||||
if (!str) {
|
||||
const char *sourceBytes = js_GetStringBytes(cx, re->getSource());
|
||||
if (sourceBytes) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_NO_INPUT, sourceBytes,
|
||||
JSAutoByteString sourceBytes(cx, re->getSource());
|
||||
if (!!sourceBytes) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_NO_INPUT,
|
||||
sourceBytes.ptr(),
|
||||
re->global() ? "g" : "",
|
||||
re->ignoreCase() ? "i" : "",
|
||||
re->multiline() ? "m" : "",
|
||||
|
|
|
@ -3697,18 +3697,18 @@ js_NewStringCopyZ(JSContext *cx, const char *s)
|
|||
return js_NewStringCopyN(cx, s, strlen(s));
|
||||
}
|
||||
|
||||
JS_FRIEND_API(const char *)
|
||||
js_ValueToPrintable(JSContext *cx, const Value &v, JSValueToStringFun v2sfun)
|
||||
const char *
|
||||
js_ValueToPrintable(JSContext *cx, const Value &v, JSAutoByteString *bytes, bool asSource)
|
||||
{
|
||||
JSString *str;
|
||||
|
||||
str = v2sfun(cx, v);
|
||||
str = (asSource ? js_ValueToSource : js_ValueToString)(cx, v);
|
||||
if (!str)
|
||||
return NULL;
|
||||
str = js_QuoteString(cx, str, 0);
|
||||
if (!str)
|
||||
return NULL;
|
||||
return js_GetStringBytes(cx, str);
|
||||
return bytes->encode(cx, str);
|
||||
}
|
||||
|
||||
JSString *
|
||||
|
|
|
@ -944,16 +944,9 @@ js_NewStringCopyZ(JSContext *cx, const char *s);
|
|||
/*
|
||||
* Convert a value to a printable C string.
|
||||
*/
|
||||
typedef JSString *(*JSValueToStringFun)(JSContext *cx, const js::Value &v);
|
||||
|
||||
extern JS_FRIEND_API(const char *)
|
||||
js_ValueToPrintable(JSContext *cx, const js::Value &, JSValueToStringFun v2sfun);
|
||||
|
||||
#define js_ValueToPrintableString(cx,v) \
|
||||
js_ValueToPrintable(cx, v, js_ValueToString)
|
||||
|
||||
#define js_ValueToPrintableSource(cx,v) \
|
||||
js_ValueToPrintable(cx, v, js_ValueToSource)
|
||||
extern const char *
|
||||
js_ValueToPrintable(JSContext *cx, const js::Value &,
|
||||
JSAutoByteString *bytes, bool asSource = false);
|
||||
|
||||
/*
|
||||
* Convert a value to a string, returning null after reporting an error,
|
||||
|
|
|
@ -3441,24 +3441,29 @@ TraceRecorder::importImpl(Address addr, const void* p, JSValueType t,
|
|||
void* mark = NULL;
|
||||
jsuword* localNames = NULL;
|
||||
const char* funName = NULL;
|
||||
JSAutoByteString funNameBytes;
|
||||
if (*prefix == 'a' || *prefix == 'v') {
|
||||
mark = JS_ARENA_MARK(&cx->tempPool);
|
||||
if (fp->fun()->hasLocalNames())
|
||||
localNames = fp->fun()->getLocalNameArray(cx, &cx->tempPool);
|
||||
funName = fp->fun()->atom
|
||||
? js_AtomToPrintableString(cx, fp->fun()->atom)
|
||||
? js_AtomToPrintableString(cx, fp->fun()->atom, &funNameBytes)
|
||||
: "<anonymous>";
|
||||
}
|
||||
if (!strcmp(prefix, "argv")) {
|
||||
if (index < fp->numFormalArgs()) {
|
||||
JSAtom *atom = JS_LOCAL_NAME_TO_ATOM(localNames[index]);
|
||||
JS_snprintf(name, sizeof name, "$%s.%s", funName, js_AtomToPrintableString(cx, atom));
|
||||
JSAutoByteString atomBytes;
|
||||
JS_snprintf(name, sizeof name, "$%s.%s", funName,
|
||||
js_AtomToPrintableString(cx, atom, &atomBytes));
|
||||
} else {
|
||||
JS_snprintf(name, sizeof name, "$%s.<arg%d>", funName, index);
|
||||
}
|
||||
} else if (!strcmp(prefix, "vars")) {
|
||||
JSAtom *atom = JS_LOCAL_NAME_TO_ATOM(localNames[fp->numFormalArgs() + index]);
|
||||
JS_snprintf(name, sizeof name, "$%s.%s", funName, js_AtomToPrintableString(cx, atom));
|
||||
JSAutoByteString atomBytes;
|
||||
JS_snprintf(name, sizeof name, "$%s.%s", funName,
|
||||
js_AtomToPrintableString(cx, atom, &atomBytes));
|
||||
} else {
|
||||
JS_snprintf(name, sizeof name, "$%s%d", prefix, index);
|
||||
}
|
||||
|
@ -10099,8 +10104,9 @@ TraceRecorder::record_EnterFrame()
|
|||
if (++callDepth >= MAX_CALLDEPTH)
|
||||
RETURN_STOP_A("exceeded maximum call depth");
|
||||
|
||||
debug_only_stmt(JSAutoByteString funBytes);
|
||||
debug_only_printf(LC_TMTracer, "EnterFrame %s, callDepth=%d\n",
|
||||
js_AtomToPrintableString(cx, cx->fp()->fun()->atom),
|
||||
js_AtomToPrintableString(cx, cx->fp()->fun()->atom, &funBytes),
|
||||
callDepth);
|
||||
debug_only_stmt(
|
||||
if (LogController.lcbits & LC_TMRecorder) {
|
||||
|
@ -10301,9 +10307,10 @@ TraceRecorder::record_JSOP_RETURN()
|
|||
} else {
|
||||
rval_ins = get(&rval);
|
||||
}
|
||||
debug_only_stmt(JSAutoByteString funBytes);
|
||||
debug_only_printf(LC_TMTracer,
|
||||
"returning from %s\n",
|
||||
js_AtomToPrintableString(cx, fp->fun()->atom));
|
||||
js_AtomToPrintableString(cx, fp->fun()->atom, &funBytes));
|
||||
clearCurrentFrameSlotsFromTracker(nativeFrameTracker);
|
||||
|
||||
return ARECORD_CONTINUE;
|
||||
|
@ -11357,7 +11364,16 @@ TraceRecorder::callNative(uintN argc, JSOp mode)
|
|||
ci->_abi = ABI_CDECL;
|
||||
ci->_typesig = typesig;
|
||||
#ifdef DEBUG
|
||||
ci->_name = JS_GetFunctionName(fun);
|
||||
ci->_name = js_anonymous_str;
|
||||
if (fun->atom) {
|
||||
JSAutoByteString bytes(cx, ATOM_TO_STRING(fun->atom));
|
||||
if (!!bytes) {
|
||||
size_t n = strlen(bytes.ptr()) + 1;
|
||||
char *buffer = new (traceAlloc()) char[n];
|
||||
memcpy(buffer, bytes.ptr(), n);
|
||||
ci->_name = buffer;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Generate a JSSpecializedNative structure on the fly.
|
||||
|
|
|
@ -300,6 +300,8 @@ public:
|
|||
JSGuardObjectNotificationReceiver _mCheckNotUsedAsTemporary;
|
||||
#define JS_GUARD_OBJECT_NOTIFIER_PARAM \
|
||||
, const JSGuardObjectNotifier& _notifier = JSGuardObjectNotifier()
|
||||
#define JS_GUARD_OBJECT_NOTIFIER_PARAM0 \
|
||||
const JSGuardObjectNotifier& _notifier = JSGuardObjectNotifier()
|
||||
#define JS_GUARD_OBJECT_NOTIFIER_INIT \
|
||||
JS_BEGIN_MACRO _mCheckNotUsedAsTemporary.Init(_notifier); JS_END_MACRO
|
||||
|
||||
|
@ -307,6 +309,7 @@ public:
|
|||
|
||||
#define JS_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
#define JS_GUARD_OBJECT_NOTIFIER_PARAM
|
||||
#define JS_GUARD_OBJECT_NOTIFIER_PARAM0
|
||||
#define JS_GUARD_OBJECT_NOTIFIER_INIT JS_BEGIN_MACRO JS_END_MACRO
|
||||
|
||||
#endif /* !defined(DEBUG) */
|
||||
|
|
|
@ -689,9 +689,11 @@ NamespaceHelper(JSContext *cx, JSObject *obj, intN argc, jsval *argv,
|
|||
return JS_FALSE;
|
||||
if (!prefix->empty()) {
|
||||
Value v = StringValue(prefix);
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
||||
JSMSG_BAD_XML_NAMESPACE,
|
||||
js_ValueToPrintableString(cx, v));
|
||||
JSAutoByteString bytes;
|
||||
if (js_ValueToPrintable(cx, v, &bytes)) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
||||
JSMSG_BAD_XML_NAMESPACE, bytes.ptr());
|
||||
}
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -1227,9 +1229,11 @@ ParseNodeToQName(Parser *parser, JSParseNode *pn,
|
|||
|
||||
if (!uri) {
|
||||
Value v = StringValue(prefix);
|
||||
ReportCompileErrorNumber(parser->context, &parser->tokenStream, pn,
|
||||
JSREPORT_ERROR, JSMSG_BAD_XML_NAMESPACE,
|
||||
js_ValueToPrintableString(parser->context, v));
|
||||
JSAutoByteString bytes;
|
||||
if (js_ValueToPrintable(parser->context, v, &bytes)) {
|
||||
ReportCompileErrorNumber(parser->context, &parser->tokenStream, pn,
|
||||
JSREPORT_ERROR, JSMSG_BAD_XML_NAMESPACE, bytes.ptr());
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1446,9 +1450,12 @@ ParseNodeToXML(Parser *parser, JSParseNode *pn,
|
|||
for (pn3 = head; pn3 != pn2; pn3 = pn3->pn_next->pn_next) {
|
||||
if (pn3->pn_atom == pn2->pn_atom) {
|
||||
Value v = StringValue(ATOM_TO_STRING(pn2->pn_atom));
|
||||
ReportCompileErrorNumber(cx, &parser->tokenStream, pn2,
|
||||
JSREPORT_ERROR, JSMSG_DUPLICATE_XML_ATTR,
|
||||
js_ValueToPrintableString(cx, v));
|
||||
JSAutoByteString bytes;
|
||||
if (js_ValueToPrintable(cx, v, &bytes)) {
|
||||
ReportCompileErrorNumber(cx, &parser->tokenStream, pn2,
|
||||
JSREPORT_ERROR, JSMSG_DUPLICATE_XML_ATTR,
|
||||
bytes.ptr());
|
||||
}
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
@ -1540,9 +1547,12 @@ ParseNodeToXML(Parser *parser, JSParseNode *pn,
|
|||
if (js_EqualStrings(GetURI(attrjqn), GetURI(qn)) &&
|
||||
js_EqualStrings(GetLocalName(attrjqn), GetLocalName(qn))) {
|
||||
Value v = StringValue(ATOM_TO_STRING(pn2->pn_atom));
|
||||
ReportCompileErrorNumber(cx, &parser->tokenStream, pn2,
|
||||
JSREPORT_ERROR, JSMSG_DUPLICATE_XML_ATTR,
|
||||
js_ValueToPrintableString(cx, v));
|
||||
JSAutoByteString bytes;
|
||||
if (js_ValueToPrintable(cx, v, &bytes)) {
|
||||
ReportCompileErrorNumber(cx, &parser->tokenStream, pn2,
|
||||
JSREPORT_ERROR, JSMSG_DUPLICATE_XML_ATTR,
|
||||
bytes.ptr());
|
||||
}
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
@ -1580,9 +1590,11 @@ ParseNodeToXML(Parser *parser, JSParseNode *pn,
|
|||
} else if (pn->pn_type == TOK_XMLPI) {
|
||||
if (IS_XML(str)) {
|
||||
Value v = StringValue(str);
|
||||
ReportCompileErrorNumber(cx, &parser->tokenStream, pn,
|
||||
JSREPORT_ERROR, JSMSG_RESERVED_ID,
|
||||
js_ValueToPrintableString(cx, v));
|
||||
JSAutoByteString bytes;
|
||||
if (js_ValueToPrintable(cx, v, &bytes)) {
|
||||
ReportCompileErrorNumber(cx, &parser->tokenStream, pn,
|
||||
JSREPORT_ERROR, JSMSG_RESERVED_ID, bytes.ptr());
|
||||
}
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -2164,12 +2176,12 @@ GetNamespace(JSContext *cx, JSObject *qn, const JSXMLArray *inScopeNSes)
|
|||
prefix = GetPrefix(qn);
|
||||
JS_ASSERT(uri);
|
||||
if (!uri) {
|
||||
Value v = StringValue(prefix);
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
||||
JSMSG_BAD_XML_NAMESPACE,
|
||||
prefix
|
||||
? js_ValueToPrintableString(cx, v)
|
||||
: js_undefined_str);
|
||||
JSAutoByteString bytes;
|
||||
const char *s = !prefix ?
|
||||
js_undefined_str
|
||||
: js_ValueToPrintable(cx, StringValue(prefix), &bytes);
|
||||
if (s)
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_BAD_XML_NAMESPACE, s);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -2905,9 +2917,9 @@ out:
|
|||
return obj;
|
||||
|
||||
bad:
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
||||
JSMSG_BAD_XML_NAME,
|
||||
js_ValueToPrintableString(cx, StringValue(name)));
|
||||
JSAutoByteString bytes;
|
||||
if (js_ValueToPrintable(cx, StringValue(name), &bytes))
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_BAD_XML_NAME, bytes.ptr());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -4460,9 +4472,11 @@ out:
|
|||
return ok;
|
||||
|
||||
type_error:
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
||||
JSMSG_BAD_XMLLIST_PUT,
|
||||
js_ValueToPrintableString(cx, IdToValue(id)));
|
||||
{
|
||||
JSAutoByteString bytes;
|
||||
if (js_ValueToPrintable(cx, IdToValue(id), &bytes))
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_BAD_XMLLIST_PUT, bytes.ptr());
|
||||
}
|
||||
bad:
|
||||
ok = JS_FALSE;
|
||||
goto out;
|
||||
|
@ -5162,9 +5176,11 @@ StartNonListXMLMethod(JSContext *cx, jsval *vp, JSObject **objp)
|
|||
|
||||
fun = GET_FUNCTION_PRIVATE(cx, JSVAL_TO_OBJECT(*vp));
|
||||
JS_snprintf(numBuf, sizeof numBuf, "%u", xml->xml_kids.length);
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
||||
JSMSG_NON_LIST_XML_METHOD,
|
||||
JS_GetFunctionName(fun), numBuf);
|
||||
JSAutoByteString funNameBytes;
|
||||
if (const char *funName = GetFunctionNameBytes(cx, fun, &funNameBytes)) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_NON_LIST_XML_METHOD,
|
||||
funName, numBuf);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -7371,7 +7387,6 @@ js_FindXMLProperty(JSContext *cx, const Value &nameval, JSObject **objp, jsid *i
|
|||
JSXML *xml;
|
||||
JSBool found;
|
||||
JSProperty *prop;
|
||||
const char *printable;
|
||||
|
||||
JS_ASSERT(nameval.isObject());
|
||||
nameobj = &nameval.toObject();
|
||||
|
@ -7425,11 +7440,10 @@ js_FindXMLProperty(JSContext *cx, const Value &nameval, JSObject **objp, jsid *i
|
|||
}
|
||||
} while ((obj = obj->getParent()) != NULL);
|
||||
|
||||
printable = js_ValueToPrintableString(cx, ObjectValue(*nameobj));
|
||||
if (printable) {
|
||||
JS_ReportErrorFlagsAndNumber(cx, JSREPORT_ERROR,
|
||||
js_GetErrorMessage, NULL,
|
||||
JSMSG_UNDEFINED_XML_NAME, printable);
|
||||
JSAutoByteString printable;
|
||||
if (js_ValueToPrintable(cx, ObjectValue(*nameobj), &printable)) {
|
||||
JS_ReportErrorFlagsAndNumber(cx, JSREPORT_ERROR, js_GetErrorMessage, NULL,
|
||||
JSMSG_UNDEFINED_XML_NAME, printable.ptr());
|
||||
}
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
|
|
@ -65,9 +65,9 @@ ValueToObject(JSContext *cx, Value *vp)
|
|||
static inline void
|
||||
ReportAtomNotDefined(JSContext *cx, JSAtom *atom)
|
||||
{
|
||||
const char *printable = js_AtomToPrintableString(cx, atom);
|
||||
if (printable)
|
||||
js_ReportIsNotDefined(cx, printable);
|
||||
JSAutoByteString printable;
|
||||
if (js_AtomToPrintableString(cx, atom, &printable))
|
||||
js_ReportIsNotDefined(cx, printable.ptr());
|
||||
}
|
||||
|
||||
#define NATIVE_SET(cx,obj,shape,entry,vp) \
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* vim: set ts=8 sw=4 et tw=99:
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
|
@ -240,10 +240,9 @@ ReportException(JSContext *cx)
|
|||
}
|
||||
|
||||
class ToString {
|
||||
public:
|
||||
public:
|
||||
ToString(JSContext *aCx, jsval v, JSBool aThrow = JS_FALSE)
|
||||
: cx(aCx)
|
||||
, mThrow(aThrow)
|
||||
: cx(aCx), mThrow(aThrow)
|
||||
{
|
||||
mStr = JS_ValueToString(cx, v);
|
||||
if (!aThrow && !mStr)
|
||||
|
@ -256,12 +255,15 @@ public:
|
|||
JSBool threw() { return !mStr; }
|
||||
jsval getJSVal() { return STRING_TO_JSVAL(mStr); }
|
||||
const char *getBytes() {
|
||||
return mStr ? JS_GetStringBytes(mStr) : "(error converting value)";
|
||||
if (mStr && (mBytes.ptr() || mBytes.encode(cx, mStr)))
|
||||
return mBytes.ptr();
|
||||
return "(error converting value)";
|
||||
}
|
||||
private:
|
||||
private:
|
||||
JSContext *cx;
|
||||
JSString *mStr;
|
||||
JSBool mThrow;
|
||||
JSAutoByteString mBytes;
|
||||
};
|
||||
|
||||
class IdToString : public ToString {
|
||||
|
@ -548,10 +550,13 @@ Process(JSContext *cx, JSObject *obj, char *filename, JSBool forceTTY)
|
|||
ok = JS_ExecuteScript(cx, obj, script, &result);
|
||||
if (ok && !JSVAL_IS_VOID(result)) {
|
||||
str = JS_ValueToSource(cx, result);
|
||||
if (str)
|
||||
fprintf(gOutFile, "%s\n", JS_GetStringBytes(str));
|
||||
else
|
||||
ok = JS_FALSE;
|
||||
ok = !!str;
|
||||
if (ok) {
|
||||
JSAutoByteString bytes(cx, str);
|
||||
ok = !!bytes;
|
||||
if (ok)
|
||||
fprintf(gOutFile, "%s\n", bytes.ptr());
|
||||
}
|
||||
}
|
||||
}
|
||||
JS_DestroyScript(cx, script);
|
||||
|
@ -972,7 +977,6 @@ Options(JSContext *cx, uintN argc, jsval *vp)
|
|||
{
|
||||
uint32 optset, flag;
|
||||
JSString *str;
|
||||
const char *opt;
|
||||
char *names;
|
||||
JSBool found;
|
||||
|
||||
|
@ -983,10 +987,10 @@ Options(JSContext *cx, uintN argc, jsval *vp)
|
|||
if (!str)
|
||||
return JS_FALSE;
|
||||
argv[i] = STRING_TO_JSVAL(str);
|
||||
opt = JS_GetStringBytes(str);
|
||||
JSAutoByteString opt(cx, str);
|
||||
if (!opt)
|
||||
return JS_FALSE;
|
||||
flag = MapContextOptionNameToFlag(cx, opt);
|
||||
flag = MapContextOptionNameToFlag(cx, opt.ptr());
|
||||
if (!flag)
|
||||
return JS_FALSE;
|
||||
optset |= flag;
|
||||
|
@ -1024,7 +1028,6 @@ Load(JSContext *cx, uintN argc, jsval *vp)
|
|||
{
|
||||
uintN i;
|
||||
JSString *str;
|
||||
const char *filename;
|
||||
JSScript *script;
|
||||
JSBool ok;
|
||||
uint32 oldopts;
|
||||
|
@ -1039,11 +1042,13 @@ Load(JSContext *cx, uintN argc, jsval *vp)
|
|||
if (!str)
|
||||
return JS_FALSE;
|
||||
argv[i] = STRING_TO_JSVAL(str);
|
||||
filename = JS_GetStringBytes(str);
|
||||
JSAutoByteString filename(cx, str);
|
||||
if (!filename)
|
||||
return JS_FALSE;
|
||||
errno = 0;
|
||||
oldopts = JS_GetOptions(cx);
|
||||
JS_SetOptions(cx, oldopts | JSOPTION_COMPILE_N_GO | JSOPTION_NO_SCRIPT_RVAL);
|
||||
script = JS_CompileFile(cx, thisobj, filename);
|
||||
script = JS_CompileFile(cx, thisobj, filename.ptr());
|
||||
JS_SetOptions(cx, oldopts);
|
||||
if (!script) {
|
||||
ok = JS_FALSE;
|
||||
|
@ -1218,12 +1223,13 @@ Quit(JSContext *cx, uintN argc, jsval *vp)
|
|||
}
|
||||
|
||||
static const char *
|
||||
ToSource(JSContext *cx, jsval *vp)
|
||||
ToSource(JSContext *cx, jsval *vp, JSAutoByteString *bytes)
|
||||
{
|
||||
JSString *str = JS_ValueToSource(cx, *vp);
|
||||
if (str) {
|
||||
*vp = STRING_TO_JSVAL(str);
|
||||
return JS_GetStringBytes(str);
|
||||
if (bytes->encode(cx, str))
|
||||
return bytes->ptr();
|
||||
}
|
||||
JS_ClearPendingException(cx);
|
||||
return "<<error converting value to string>>";
|
||||
|
@ -1245,14 +1251,18 @@ AssertEq(JSContext *cx, uintN argc, jsval *vp)
|
|||
|
||||
jsval *argv = JS_ARGV(cx, vp);
|
||||
if (!JS_SameValue(cx, argv[0], argv[1])) {
|
||||
const char *actual = ToSource(cx, &argv[0]);
|
||||
const char *expected = ToSource(cx, &argv[1]);
|
||||
JSAutoByteString bytes0, bytes1;
|
||||
const char *actual = ToSource(cx, &argv[0], &bytes0);
|
||||
const char *expected = ToSource(cx, &argv[1], &bytes1);
|
||||
if (argc == 2) {
|
||||
JS_ReportErrorNumber(cx, my_GetErrorMessage, NULL, JSSMSG_ASSERT_EQ_FAILED,
|
||||
actual, expected);
|
||||
} else {
|
||||
JSAutoByteString bytes2(cx, JSVAL_TO_STRING(argv[2]));
|
||||
if (!bytes2)
|
||||
return JS_FALSE;
|
||||
JS_ReportErrorNumber(cx, my_GetErrorMessage, NULL, JSSMSG_ASSERT_EQ_FAILED_MSG,
|
||||
actual, expected, JS_GetStringBytes(JSVAL_TO_STRING(argv[2])));
|
||||
actual, expected, bytes2.ptr());
|
||||
}
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
@ -1493,7 +1503,9 @@ CountHeap(JSContext *cx, uintN argc, jsval *vp)
|
|||
break;
|
||||
}
|
||||
if (++i == JS_ARRAY_LENGTH(traceKindNames)) {
|
||||
JS_ReportError(cx, "trace kind name '%s' is unknown", JS_GetStringBytes(str));
|
||||
JSAutoByteString bytes(cx, str);
|
||||
if (!!bytes)
|
||||
JS_ReportError(cx, "trace kind name '%s' is unknown", bytes.ptr());
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -1904,21 +1916,14 @@ SrcNotes(JSContext *cx, JSScript *script)
|
|||
putc(')', gOutFile);
|
||||
break;
|
||||
case SRC_FUNCDEF: {
|
||||
const char *bytes;
|
||||
JSObject *obj;
|
||||
JSFunction *fun;
|
||||
|
||||
index = js_GetSrcNoteOffset(sn, 0);
|
||||
obj = script->getObject(index);
|
||||
fun = (JSFunction *) JS_GetPrivate(cx, obj);
|
||||
JSObject *obj = script->getObject(index);
|
||||
JSFunction *fun = (JSFunction *) JS_GetPrivate(cx, obj);
|
||||
str = JS_DecompileFunction(cx, fun, JS_DONT_PRETTY_PRINT);
|
||||
if (str) {
|
||||
bytes = JS_GetStringBytes(str);
|
||||
} else {
|
||||
ReportException(cx);
|
||||
bytes = "N/A";
|
||||
}
|
||||
fprintf(gOutFile, " function %u (%s)", index, bytes);
|
||||
JSAutoByteString bytes;
|
||||
if (!str || !bytes.encode(cx, str))
|
||||
ReportException(cx);
|
||||
fprintf(gOutFile, " function %u (%s)", index, !!bytes ? bytes.ptr() : "N/A");
|
||||
break;
|
||||
}
|
||||
case SRC_SWITCH:
|
||||
|
@ -2031,9 +2036,11 @@ DisassembleValue(JSContext *cx, jsval v, bool lines, bool recursive)
|
|||
for (uint32 i = 0, n = uva->length; i < n; i++) {
|
||||
JSAtom *atom = JS_LOCAL_NAME_TO_ATOM(localNames[upvar_base + i]);
|
||||
UpvarCookie cookie = uva->vector[i];
|
||||
|
||||
printf(" %s: {skip:%u, slot:%u},\n",
|
||||
js_AtomToPrintableString(cx, atom), cookie.level(), cookie.slot());
|
||||
JSAutoByteString printable;
|
||||
if (js_AtomToPrintableString(cx, atom, &printable)) {
|
||||
printf(" %s: {skip:%u, slot:%u},\n",
|
||||
printable.ptr(), cookie.level(), cookie.slot());
|
||||
}
|
||||
}
|
||||
|
||||
JS_ARENA_RELEASE(&cx->tempPool, mark);
|
||||
|
@ -2091,11 +2098,6 @@ Disassemble(JSContext *cx, uintN argc, jsval *vp)
|
|||
static JSBool
|
||||
DisassFile(JSContext *cx, uintN argc, jsval *vp)
|
||||
{
|
||||
JSString *str;
|
||||
const char *filename;
|
||||
JSScript *script;
|
||||
JSBool ok;
|
||||
uint32 oldopts;
|
||||
jsval *argv = JS_ARGV(cx, vp);
|
||||
|
||||
if (!argc) {
|
||||
|
@ -2107,14 +2109,16 @@ DisassFile(JSContext *cx, uintN argc, jsval *vp)
|
|||
if (!thisobj)
|
||||
return JS_FALSE;
|
||||
|
||||
str = JS_ValueToString(cx, argv[0]);
|
||||
JSString *str = JS_ValueToString(cx, argv[0]);
|
||||
if (!str)
|
||||
return JS_FALSE;
|
||||
JSAutoByteString filename(cx, str);
|
||||
if (!filename)
|
||||
return JS_FALSE;
|
||||
|
||||
filename = JS_GetStringBytes(str);
|
||||
oldopts = JS_GetOptions(cx);
|
||||
uint32 oldopts = JS_GetOptions(cx);
|
||||
JS_SetOptions(cx, oldopts | JSOPTION_COMPILE_N_GO | JSOPTION_NO_SCRIPT_RVAL);
|
||||
script = JS_CompileFile(cx, thisobj, filename);
|
||||
JSScript *script = JS_CompileFile(cx, thisobj, filename.ptr());
|
||||
JS_SetOptions(cx, oldopts);
|
||||
if (!script)
|
||||
return JS_FALSE;
|
||||
|
@ -2129,7 +2133,7 @@ DisassFile(JSContext *cx, uintN argc, jsval *vp)
|
|||
return JS_FALSE;
|
||||
|
||||
argv[0] = OBJECT_TO_JSVAL(obj); /* I like to root it, root it. */
|
||||
ok = Disassemble(cx, 1, vp); /* gross, but works! */
|
||||
JSBool ok = Disassemble(cx, 1, vp); /* gross, but works! */
|
||||
JS_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
return ok;
|
||||
}
|
||||
|
@ -2246,11 +2250,13 @@ Tracing(JSContext *cx, uintN argc, jsval *vp)
|
|||
break;
|
||||
}
|
||||
case JSTYPE_STRING: {
|
||||
char *name = JS_GetStringBytes(JSVAL_TO_STRING(argv[0]));
|
||||
file = fopen(name, "w");
|
||||
JSAutoByteString name(cx, JSVAL_TO_STRING(argv[0]));
|
||||
if (!name)
|
||||
return JS_FALSE;
|
||||
file = fopen(name.ptr(), "w");
|
||||
if (!file) {
|
||||
JS_ReportError(cx, "tracing: couldn't open output file %s: %s",
|
||||
name, strerror(errno));
|
||||
name.ptr(), strerror(errno));
|
||||
return JS_FALSE;
|
||||
}
|
||||
break;
|
||||
|
@ -2269,8 +2275,10 @@ Tracing(JSContext *cx, uintN argc, jsval *vp)
|
|||
JSString *str = JS_ValueToString(cx, argv[0]);
|
||||
if (!str)
|
||||
return JS_FALSE;
|
||||
JS_ReportError(cx, "tracing: illegal argument %s",
|
||||
JS_GetStringBytes(str));
|
||||
JSAutoByteString bytes(cx, str);
|
||||
if (!bytes)
|
||||
return JS_FALSE;
|
||||
JS_ReportError(cx, "tracing: illegal argument %s", bytes.ptr());
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -2336,7 +2344,6 @@ DumpStats(JSContext *cx, uintN argc, jsval *vp)
|
|||
static JSBool
|
||||
DumpHeap(JSContext *cx, uintN argc, jsval *vp)
|
||||
{
|
||||
char *fileName;
|
||||
jsval v;
|
||||
void* startThing;
|
||||
uint32 startTraceKind;
|
||||
|
@ -2347,7 +2354,8 @@ DumpHeap(JSContext *cx, uintN argc, jsval *vp)
|
|||
FILE *dumpFile;
|
||||
JSBool ok;
|
||||
|
||||
fileName = NULL;
|
||||
const char *fileName = NULL;
|
||||
JSAutoByteString fileNameBytes;
|
||||
if (argc > 0) {
|
||||
v = JS_ARGV(cx, vp)[0];
|
||||
if (!JSVAL_IS_NULL(v)) {
|
||||
|
@ -2357,7 +2365,9 @@ DumpHeap(JSContext *cx, uintN argc, jsval *vp)
|
|||
if (!str)
|
||||
return JS_FALSE;
|
||||
JS_ARGV(cx, vp)[0] = STRING_TO_JSVAL(str);
|
||||
fileName = JS_GetStringBytes(str);
|
||||
if (!fileNameBytes.encode(cx, str))
|
||||
return JS_FALSE;
|
||||
fileName = fileNameBytes.ptr();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2531,7 +2541,6 @@ ConvertArgs(JSContext *cx, uintN argc, jsval *vp)
|
|||
int32 i = 0, j = 0;
|
||||
uint32 u = 0;
|
||||
jsdouble d = 0, I = 0, re = 0, im = 0;
|
||||
char *s = NULL;
|
||||
JSString *str = NULL;
|
||||
jschar *w = NULL;
|
||||
JSObject *obj2 = NULL;
|
||||
|
@ -2541,8 +2550,8 @@ ConvertArgs(JSContext *cx, uintN argc, jsval *vp)
|
|||
|
||||
if (!JS_AddArgumentFormatter(cx, "ZZ", ZZ_formatter))
|
||||
return JS_FALSE;
|
||||
ok = JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "b/ciujdIsSWofvZZ*",
|
||||
&b, &c, &i, &u, &j, &d, &I, &s, &str, &w, &obj2,
|
||||
ok = JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "b/ciujdISWofvZZ*",
|
||||
&b, &c, &i, &u, &j, &d, &I, &str, &w, &obj2,
|
||||
&fun, &v, &re, &im);
|
||||
JS_RemoveArgumentFormatter(cx, "ZZ");
|
||||
if (!ok)
|
||||
|
@ -2552,20 +2561,19 @@ ConvertArgs(JSContext *cx, uintN argc, jsval *vp)
|
|||
b, c, (char)c, i, u, j);
|
||||
ToString obj2string(cx, obj2);
|
||||
ToString valueString(cx, v);
|
||||
JSAutoByteString strBytes;
|
||||
if (str)
|
||||
strBytes.encode(cx, str);
|
||||
JSString *tmpstr = JS_DecompileFunction(cx, fun, 4);
|
||||
const char *func;
|
||||
if (tmpstr) {
|
||||
func = JS_GetStringBytes(tmpstr);
|
||||
} else {
|
||||
JSAutoByteString func;
|
||||
if (!tmpstr || !func.encode(cx, tmpstr));
|
||||
ReportException(cx);
|
||||
func = "error decompiling fun";
|
||||
}
|
||||
fprintf(gOutFile,
|
||||
"d %g, I %g, s %s, S %s, W %s, obj %s, fun %s\n"
|
||||
"d %g, I %g, S %s, W %s, obj %s, fun %s\n"
|
||||
"v %s, re %g, im %g\n",
|
||||
d, I, s, str ? JS_GetStringBytes(str) : "", EscapeWideString(w),
|
||||
d, I, !!strBytes ? strBytes.ptr() : "", EscapeWideString(w),
|
||||
obj2string.getBytes(),
|
||||
fun ? func : "",
|
||||
fun ? (!!func ? func.ptr() : "error decompiling fun") : "",
|
||||
valueString.getBytes(), re, im);
|
||||
JS_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
return JS_TRUE;
|
||||
|
@ -4054,7 +4062,6 @@ static JSBool
|
|||
Snarf(JSContext *cx, uintN argc, jsval *vp)
|
||||
{
|
||||
JSString *str;
|
||||
const char *filename;
|
||||
const char *pathname;
|
||||
JSStackFrame *fp;
|
||||
JSBool ok;
|
||||
|
@ -4068,17 +4075,19 @@ Snarf(JSContext *cx, uintN argc, jsval *vp)
|
|||
str = JS_ValueToString(cx, JS_ARGV(cx, vp)[0]);
|
||||
if (!str)
|
||||
return JS_FALSE;
|
||||
filename = JS_GetStringBytes(str);
|
||||
JSAutoByteString filename(cx, str);
|
||||
if (!filename)
|
||||
return JS_FALSE;
|
||||
|
||||
/* Get the currently executing script's name. */
|
||||
fp = JS_GetScriptedCaller(cx, NULL);
|
||||
JS_ASSERT(fp && fp->script()->filename);
|
||||
#ifdef XP_UNIX
|
||||
pathname = MakeAbsolutePathname(cx, fp->script()->filename, filename);
|
||||
pathname = MakeAbsolutePathname(cx, fp->script()->filename, filename.ptr());
|
||||
if (!pathname)
|
||||
return JS_FALSE;
|
||||
#else
|
||||
pathname = filename;
|
||||
pathname = filename.ptr();
|
||||
#endif
|
||||
|
||||
ok = JS_FALSE;
|
||||
|
@ -4595,26 +4604,36 @@ static JSPropertySpec its_props[] = {
|
|||
static JSBool
|
||||
its_bindMethod(JSContext *cx, uintN argc, jsval *vp)
|
||||
{
|
||||
char *name;
|
||||
JSString *name;
|
||||
JSObject *method;
|
||||
|
||||
JSObject *thisobj = JS_THIS_OBJECT(cx, vp);
|
||||
|
||||
if (!JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "so", &name, &method))
|
||||
if (!JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "So", &name, &method))
|
||||
return JS_FALSE;
|
||||
|
||||
*vp = OBJECT_TO_JSVAL(method);
|
||||
|
||||
if (JS_TypeOfValue(cx, *vp) != JSTYPE_FUNCTION) {
|
||||
JSString *valstr = JS_ValueToString(cx, *vp);
|
||||
if (valstr) {
|
||||
JS_ReportError(cx, "can't bind method %s to non-callable object %s",
|
||||
name, JS_GetStringBytes(valstr));
|
||||
JSAutoByteString nameBytes(cx, name);
|
||||
if (!!nameBytes) {
|
||||
JSString *valstr = JS_ValueToString(cx, *vp);
|
||||
if (valstr) {
|
||||
JSAutoByteString valBytes(cx, valstr);
|
||||
if (!!valBytes) {
|
||||
JS_ReportError(cx, "can't bind method %s to non-callable object %s",
|
||||
nameBytes.ptr(), valBytes.ptr());
|
||||
}
|
||||
}
|
||||
}
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (!JS_DefineProperty(cx, thisobj, name, *vp, NULL, NULL, JSPROP_ENUMERATE))
|
||||
jsid id;
|
||||
if (!JS_ValueToId(cx, STRING_TO_JSVAL(name), &id))
|
||||
return JS_FALSE;
|
||||
|
||||
if (!JS_DefinePropertyById(cx, thisobj, id, *vp, NULL, NULL, JSPROP_ENUMERATE))
|
||||
return JS_FALSE;
|
||||
|
||||
return JS_SetParent(cx, method, thisobj);
|
||||
|
@ -4921,6 +4940,7 @@ Exec(JSContext *cx, uintN argc, jsval *vp)
|
|||
const char *name, **nargv;
|
||||
uintN i, nargc;
|
||||
JSString *str;
|
||||
bool ok;
|
||||
pid_t pid;
|
||||
int status;
|
||||
|
||||
|
@ -4931,22 +4951,28 @@ Exec(JSContext *cx, uintN argc, jsval *vp)
|
|||
return JS_FALSE;
|
||||
if (!fun->atom)
|
||||
return JS_TRUE;
|
||||
name = JS_GetStringBytes(ATOM_TO_STRING(fun->atom));
|
||||
|
||||
nargc = 1 + argc;
|
||||
nargv = JS_malloc(cx, (nargc + 1) * sizeof(char *));
|
||||
|
||||
/* nargc + 1 accounts for the terminating NULL. */
|
||||
nargv = new (char *)[nargc + 1];
|
||||
if (!nargv)
|
||||
return JS_FALSE;
|
||||
memset(nargv, 0, sizeof(nargv[0]) * (nargc + 1));
|
||||
nargv[0] = name;
|
||||
jsval *argv = JS_ARGV(cx, vp);
|
||||
for (i = 1; i < nargc; i++) {
|
||||
str = JS_ValueToString(cx, argv[i-1]);
|
||||
for (i = 0; i < nargc; i++) {
|
||||
str = (i == 0) ? ATOM_TO_STRING(fun->atom) : JS_ValueToString(cx, argv[i-1]);
|
||||
if (!str) {
|
||||
JS_free(cx, nargv);
|
||||
return JS_FALSE;
|
||||
ok = false;
|
||||
goto done;
|
||||
}
|
||||
nargv[i] = JS_EncodeString(cx, str);
|
||||
if (!nargv[i]) {
|
||||
ok = false;
|
||||
goto done;
|
||||
}
|
||||
nargv[i] = JS_GetStringBytes(str);
|
||||
}
|
||||
nargv[nargc] = 0;
|
||||
pid = fork();
|
||||
switch (pid) {
|
||||
case -1:
|
||||
|
@ -4961,8 +4987,13 @@ Exec(JSContext *cx, uintN argc, jsval *vp)
|
|||
continue;
|
||||
break;
|
||||
}
|
||||
JS_free(cx, nargv);
|
||||
return JS_TRUE;
|
||||
ok = true;
|
||||
|
||||
done:
|
||||
for (i = 0; i < nargc; i++)
|
||||
JS_free(cx, nargv[i]);
|
||||
delete[] nargv;
|
||||
return ok;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -5010,11 +5041,13 @@ global_resolve(JSContext *cx, JSObject *obj, jsid id, uintN flags,
|
|||
path = JS_strdup(cx, path);
|
||||
if (!path)
|
||||
return JS_FALSE;
|
||||
name = JS_GetStringBytes(JSVAL_TO_STRING(id));
|
||||
JSAutoByteString name(cx, JSVAL_TO_STRING(id));
|
||||
if (!name)
|
||||
return JS_FALSE;
|
||||
ok = JS_TRUE;
|
||||
for (comp = strtok(path, ":"); comp; comp = strtok(NULL, ":")) {
|
||||
if (*comp != '\0') {
|
||||
full = JS_smprintf("%s/%s", comp, name);
|
||||
full = JS_smprintf("%s/%s", comp, name.ptr());
|
||||
if (!full) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
ok = JS_FALSE;
|
||||
|
|
|
@ -398,11 +398,11 @@ class MainQueue : public EventQueue, public WorkerParent
|
|||
if (result == Event::forwardToParent) {
|
||||
// FIXME - pointlessly truncates the string to 8 bits
|
||||
jsval data;
|
||||
const char *s;
|
||||
JSAutoByteString bytes;
|
||||
if (event->deserializeData(cx, &data) &&
|
||||
JSVAL_IS_STRING(data) &&
|
||||
(s = JS_GetStringBytesZ(cx, JSVAL_TO_STRING(data)))) {
|
||||
JS_ReportError(cx, "%s", s);
|
||||
bytes.encode(cx, JSVAL_TO_STRING(data))) {
|
||||
JS_ReportError(cx, "%s", bytes.ptr());
|
||||
} else {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
}
|
||||
|
@ -890,11 +890,11 @@ class InitEvent : public Event
|
|||
if (!deserializeData(cx, &s))
|
||||
return fail;
|
||||
JS_ASSERT(JSVAL_IS_STRING(s));
|
||||
const char *filename = JS_GetStringBytesZ(cx, JSVAL_TO_STRING(s));
|
||||
JSAutoByteString filename(cx, JSVAL_TO_STRING(s));
|
||||
if (!filename)
|
||||
return fail;
|
||||
|
||||
JSScript *script = JS_CompileFile(cx, child->getGlobal(), filename);
|
||||
JSScript *script = JS_CompileFile(cx, child->getGlobal(), filename.ptr());
|
||||
if (!script)
|
||||
return fail;
|
||||
|
||||
|
|
|
@ -226,8 +226,11 @@ Atob(JSContext *cx, uintN argc, jsval *vp)
|
|||
if (!str)
|
||||
return JS_FALSE;
|
||||
|
||||
JSAutoByteString base64Bytes(cx, str);
|
||||
if (!base64Bytes)
|
||||
return JS_FALSE;
|
||||
const char *base64Str = base64Bytes.ptr();
|
||||
size_t base64StrLength = JS_GetStringLength(str);
|
||||
char *base64Str = JS_GetStringBytes(str);
|
||||
|
||||
PRUint32 bin_dataLength = (PRUint32)base64StrLength;
|
||||
if (base64StrLength >= 1 && base64Str[base64StrLength - 1] == '=') {
|
||||
|
@ -262,7 +265,10 @@ Btoa(JSContext *cx, uintN argc, jsval *vp)
|
|||
if (!str)
|
||||
return JS_FALSE;
|
||||
|
||||
char *bin_data = JS_GetStringBytes(str);
|
||||
JSAutoByteString bin_dataBytes(cx, str);
|
||||
if (!bin_dataBytes)
|
||||
return JS_FALSE;
|
||||
const char *bin_data = bin_dataBytes.ptr();
|
||||
size_t bin_dataLength = JS_GetStringLength(str);
|
||||
|
||||
char *base64 = PL_Base64Encode(bin_data, bin_dataLength, nsnull);
|
||||
|
@ -1533,9 +1539,12 @@ mozJSComponentLoader::ImportInto(const nsACString & aLocation,
|
|||
}
|
||||
|
||||
if (!JS_GetPropertyById(mContext, mod->global, symbolId, &val)) {
|
||||
JSAutoByteString bytes(mContext, JSID_TO_STRING(symbolId));
|
||||
if (!bytes)
|
||||
return NS_ERROR_FAILURE;
|
||||
return ReportOnCaller(cxhelper, ERROR_GETTING_SYMBOL,
|
||||
PromiseFlatCString(aLocation).get(),
|
||||
JS_GetStringBytes(JSID_TO_STRING(symbolId)));
|
||||
bytes.ptr());
|
||||
}
|
||||
|
||||
JSAutoEnterCompartment target_ac;
|
||||
|
@ -1543,15 +1552,20 @@ mozJSComponentLoader::ImportInto(const nsACString & aLocation,
|
|||
if (!target_ac.enter(mContext, targetObj) ||
|
||||
!JS_WrapValue(mContext, &val) ||
|
||||
!JS_SetPropertyById(mContext, targetObj, symbolId, &val)) {
|
||||
JSAutoByteString bytes(mContext, JSID_TO_STRING(symbolId));
|
||||
if (!bytes)
|
||||
return NS_ERROR_FAILURE;
|
||||
return ReportOnCaller(cxhelper, ERROR_SETTING_SYMBOL,
|
||||
PromiseFlatCString(aLocation).get(),
|
||||
JS_GetStringBytes(JSID_TO_STRING(symbolId)));
|
||||
bytes.ptr());
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if (i == 0) {
|
||||
logBuffer.AssignLiteral("Installing symbols [ ");
|
||||
}
|
||||
logBuffer.Append(JS_GetStringBytes(JSID_TO_STRING(symbolId)));
|
||||
JSAutoByteString bytes(mContext, JSID_TO_STRING(symbolId));
|
||||
if (!!bytes)
|
||||
logBuffer.Append(bytes.ptr());
|
||||
logBuffer.AppendLiteral(" ");
|
||||
if (i == symbolCount - 1) {
|
||||
LOG(("%s] from %s\n", PromiseFlatCString(logBuffer).get(),
|
||||
|
|
|
@ -161,16 +161,22 @@ mozJSSubScriptLoader::LoadSubScript (const PRUnichar * aURL
|
|||
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
char *url;
|
||||
JSString *url;
|
||||
JSObject *target_obj = nsnull;
|
||||
jschar *charset = nsnull;
|
||||
ok = JS_ConvertArguments (cx, argc, argv, "s / o W", &url, &target_obj, &charset);
|
||||
ok = JS_ConvertArguments (cx, argc, argv, "S / o W", &url, &target_obj, &charset);
|
||||
if (!ok)
|
||||
{
|
||||
/* let the exception raised by JS_ConvertArguments show through */
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
JSAutoByteString urlbytes(cx, url);
|
||||
if (!urlbytes)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!target_obj)
|
||||
{
|
||||
/* if the user didn't provide an object to eval onto, find the global
|
||||
|
@ -277,7 +283,7 @@ mozJSSubScriptLoader::LoadSubScript (const PRUnichar * aURL
|
|||
|
||||
// Make sure to explicitly create the URI, since we'll need the
|
||||
// canonicalized spec.
|
||||
rv = NS_NewURI(getter_AddRefs(uri), url, nsnull, serv);
|
||||
rv = NS_NewURI(getter_AddRefs(uri), urlbytes.ptr(), nsnull, serv);
|
||||
if (NS_FAILED(rv)) {
|
||||
errmsg = JS_NewStringCopyZ (cx, LOAD_ERROR_NOURI);
|
||||
goto return_exception;
|
||||
|
|
|
@ -388,7 +388,8 @@ ReadLine(JSContext *cx, uintN argc, jsval *vp)
|
|||
}
|
||||
|
||||
/* Get a line from the infile */
|
||||
if (!GetLine(cx, buf, gInFile, JS_GetStringBytes(str)))
|
||||
JSAutoByteString strBytes(cx, str);
|
||||
if (!strBytes || !GetLine(cx, buf, gInFile, strBytes.ptr()))
|
||||
return JS_FALSE;
|
||||
|
||||
/* Strip newline character added by GetLine() */
|
||||
|
@ -422,7 +423,10 @@ Print(JSContext *cx, uintN argc, jsval *vp)
|
|||
str = JS_ValueToString(cx, argv[i]);
|
||||
if (!str)
|
||||
return JS_FALSE;
|
||||
fprintf(gOutFile, "%s%s", i ? " " : "", JS_GetStringBytes(str));
|
||||
JSAutoByteString strBytes(cx, str);
|
||||
if (!strBytes)
|
||||
return JS_FALSE;
|
||||
fprintf(gOutFile, "%s%s", i ? " " : "", strBytes.ptr());
|
||||
fflush(gOutFile);
|
||||
}
|
||||
n++;
|
||||
|
@ -455,7 +459,6 @@ Load(JSContext *cx, uintN argc, jsval *vp)
|
|||
{
|
||||
uintN i;
|
||||
JSString *str;
|
||||
const char *filename;
|
||||
JSScript *script;
|
||||
JSBool ok;
|
||||
jsval result;
|
||||
|
@ -471,14 +474,17 @@ Load(JSContext *cx, uintN argc, jsval *vp)
|
|||
if (!str)
|
||||
return JS_FALSE;
|
||||
argv[i] = STRING_TO_JSVAL(str);
|
||||
filename = JS_GetStringBytes(str);
|
||||
file = fopen(filename, "r");
|
||||
JSAutoByteString filename(cx, str);
|
||||
if (!filename)
|
||||
return JS_FALSE;
|
||||
file = fopen(filename.ptr(), "r");
|
||||
if (!file) {
|
||||
JS_ReportError(cx, "cannot open file '%s' for reading", filename);
|
||||
JS_ReportError(cx, "cannot open file '%s' for reading",
|
||||
filename.ptr());
|
||||
return JS_FALSE;
|
||||
}
|
||||
script = JS_CompileFileHandleForPrincipals(cx, obj, filename, file,
|
||||
gJSPrincipals);
|
||||
script = JS_CompileFileHandleForPrincipals(cx, obj, filename.ptr(),
|
||||
file, gJSPrincipals);
|
||||
fclose(file);
|
||||
if (!script)
|
||||
return JS_FALSE;
|
||||
|
@ -583,7 +589,6 @@ GCZeal(JSContext *cx, uintN argc, jsval *vp)
|
|||
static JSBool
|
||||
DumpHeap(JSContext *cx, uintN argc, jsval *vp)
|
||||
{
|
||||
char *fileName = NULL;
|
||||
void* startThing = NULL;
|
||||
uint32 startTraceKind = 0;
|
||||
void *thingToFind = NULL;
|
||||
|
@ -596,6 +601,7 @@ DumpHeap(JSContext *cx, uintN argc, jsval *vp)
|
|||
JS_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
|
||||
vp = argv + 0;
|
||||
JSAutoByteString fileName;
|
||||
if (argc > 0 && *vp != JSVAL_NULL && *vp != JSVAL_VOID) {
|
||||
JSString *str;
|
||||
|
||||
|
@ -603,7 +609,8 @@ DumpHeap(JSContext *cx, uintN argc, jsval *vp)
|
|||
if (!str)
|
||||
return JS_FALSE;
|
||||
*vp = STRING_TO_JSVAL(str);
|
||||
fileName = JS_GetStringBytes(str);
|
||||
if (!fileName.encode(cx, str))
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
vp = argv + 1;
|
||||
|
@ -640,10 +647,10 @@ DumpHeap(JSContext *cx, uintN argc, jsval *vp)
|
|||
if (!fileName) {
|
||||
dumpFile = gOutFile;
|
||||
} else {
|
||||
dumpFile = fopen(fileName, "w");
|
||||
dumpFile = fopen(fileName.ptr(), "w");
|
||||
if (!dumpFile) {
|
||||
fprintf(gErrFile, "dumpHeap: can't open %s: %s\n",
|
||||
fileName, strerror(errno));
|
||||
fileName.ptr(), strerror(errno));
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -776,7 +783,6 @@ Options(JSContext *cx, uintN argc, jsval *vp)
|
|||
{
|
||||
uint32 optset, flag;
|
||||
JSString *str;
|
||||
const char *opt;
|
||||
char *names;
|
||||
JSBool found;
|
||||
|
||||
|
@ -787,10 +793,10 @@ Options(JSContext *cx, uintN argc, jsval *vp)
|
|||
if (!str)
|
||||
return JS_FALSE;
|
||||
argv[i] = STRING_TO_JSVAL(str);
|
||||
opt = JS_GetStringBytes(str);
|
||||
JSAutoByteString opt(cx, str);
|
||||
if (!opt)
|
||||
return JS_FALSE;
|
||||
flag = MapContextOptionNameToFlag(cx, opt);
|
||||
flag = MapContextOptionNameToFlag(cx, opt.ptr());
|
||||
if (!flag)
|
||||
return JS_FALSE;
|
||||
optset |= flag;
|
||||
|
@ -890,7 +896,6 @@ env_setProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
|||
/* XXX porting may be easy, but these don't seem to supply setenv by default */
|
||||
#if !defined XP_BEOS && !defined XP_OS2 && !defined SOLARIS
|
||||
JSString *idstr, *valstr;
|
||||
const char *name, *value;
|
||||
int rv;
|
||||
|
||||
jsval idval;
|
||||
|
@ -901,12 +906,16 @@ env_setProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
|||
valstr = JS_ValueToString(cx, *vp);
|
||||
if (!idstr || !valstr)
|
||||
return JS_FALSE;
|
||||
name = JS_GetStringBytes(idstr);
|
||||
value = JS_GetStringBytes(valstr);
|
||||
JSAutoByteString name(cx, idstr);
|
||||
if (!name)
|
||||
return JS_FALSE;
|
||||
JSAutoByteString value(cx, valstr);
|
||||
if (!value)
|
||||
return JS_FALSE;
|
||||
#if defined XP_WIN || defined HPUX || defined OSF1 || defined IRIX \
|
||||
|| defined SCO
|
||||
{
|
||||
char *waste = JS_smprintf("%s=%s", name, value);
|
||||
char *waste = JS_smprintf("%s=%s", name.ptr(), value.ptr());
|
||||
if (!waste) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
return JS_FALSE;
|
||||
|
@ -924,10 +933,10 @@ env_setProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
|||
#endif
|
||||
}
|
||||
#else
|
||||
rv = setenv(name, value, 1);
|
||||
rv = setenv(name.ptr(), value.ptr(), 1);
|
||||
#endif
|
||||
if (rv < 0) {
|
||||
JS_ReportError(cx, "can't set envariable %s to %s", name, value);
|
||||
JS_ReportError(cx, "can't set envariable %s to %s", name.ptr(), value.ptr());
|
||||
return JS_FALSE;
|
||||
}
|
||||
*vp = STRING_TO_JSVAL(valstr);
|
||||
|
@ -972,7 +981,6 @@ env_resolve(JSContext *cx, JSObject *obj, jsid id, uintN flags,
|
|||
JSObject **objp)
|
||||
{
|
||||
JSString *idstr, *valstr;
|
||||
const char *name, *value;
|
||||
|
||||
if (flags & JSRESOLVE_ASSIGNING)
|
||||
return JS_TRUE;
|
||||
|
@ -984,14 +992,16 @@ env_resolve(JSContext *cx, JSObject *obj, jsid id, uintN flags,
|
|||
idstr = JS_ValueToString(cx, idval);
|
||||
if (!idstr)
|
||||
return JS_FALSE;
|
||||
name = JS_GetStringBytes(idstr);
|
||||
value = getenv(name);
|
||||
JSAutoByteString name(cx, idstr);
|
||||
if (!name)
|
||||
return JS_FALSE;
|
||||
const char *value = getenv(name.ptr());
|
||||
if (value) {
|
||||
valstr = JS_NewStringCopyZ(cx, value);
|
||||
if (!valstr)
|
||||
return JS_FALSE;
|
||||
if (!JS_DefineProperty(cx, obj, name, STRING_TO_JSVAL(valstr),
|
||||
NULL, NULL, JSPROP_ENUMERATE)) {
|
||||
if (!JS_DefinePropertyById(cx, obj, id, STRING_TO_JSVAL(valstr),
|
||||
NULL, NULL, JSPROP_ENUMERATE)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
*objp = obj;
|
||||
|
@ -1122,9 +1132,9 @@ ProcessFile(JSContext *cx, JSObject *obj, const char *filename, FILE *file,
|
|||
older = JS_SetErrorReporter(cx, NULL);
|
||||
str = JS_ValueToString(cx, result);
|
||||
JS_SetErrorReporter(cx, older);
|
||||
|
||||
if (str)
|
||||
fprintf(gOutFile, "%s\n", JS_GetStringBytes(str));
|
||||
JSAutoByteString bytes;
|
||||
if (str && bytes.encode(cx, str))
|
||||
fprintf(gOutFile, "%s\n", bytes.ptr());
|
||||
else
|
||||
ok = JS_FALSE;
|
||||
}
|
||||
|
|
|
@ -481,9 +481,10 @@ argumentUnboxingTemplates = {
|
|||
" return JS_FALSE;\n",
|
||||
|
||||
'string':
|
||||
" char *${name};\n"
|
||||
" if (!xpc_qsJsvalToCharStr(cx, ${argVal}, ${argPtr}, &${name}))\n"
|
||||
" return JS_FALSE;\n",
|
||||
" JSAutoByteString ${name}_bytes;\n"
|
||||
" if (!xpc_qsJsvalToCharStr(cx, ${argVal}, &${name}_bytes))\n"
|
||||
" return JS_FALSE;\n"
|
||||
" char *${name} = ${name}_bytes.ptr();\n",
|
||||
|
||||
'wstring':
|
||||
" PRUnichar *${name};\n"
|
||||
|
|
|
@ -337,15 +337,14 @@ nsXPCComponents_Interfaces::NewResolve(nsIXPConnectWrappedNative *wrapper,
|
|||
jsid id, PRUint32 flags,
|
||||
JSObject * *objp, PRBool *_retval)
|
||||
{
|
||||
const char* name = nsnull;
|
||||
|
||||
JSAutoByteString name;
|
||||
if(mManager &&
|
||||
JSID_IS_STRING(id) &&
|
||||
nsnull != (name = JS_GetStringBytes(JSID_TO_STRING(id))) &&
|
||||
name[0] != '{') // we only allow interfaces by name here
|
||||
name.encode(cx, JSID_TO_STRING(id)) &&
|
||||
name.ptr()[0] != '{') // we only allow interfaces by name here
|
||||
{
|
||||
nsCOMPtr<nsIInterfaceInfo> info;
|
||||
mManager->GetInfoForName(name, getter_AddRefs(info));
|
||||
mManager->GetInfoForName(name.ptr(), getter_AddRefs(info));
|
||||
if(!info)
|
||||
return NS_OK;
|
||||
|
||||
|
@ -974,14 +973,14 @@ nsXPCComponents_Classes::NewResolve(nsIXPConnectWrappedNative *wrapper,
|
|||
JSObject * *objp, PRBool *_retval)
|
||||
|
||||
{
|
||||
const char* name = nsnull;
|
||||
JSAutoByteString name;
|
||||
|
||||
if(JSID_IS_STRING(id) &&
|
||||
nsnull != (name = JS_GetStringBytes(JSID_TO_STRING(id))) &&
|
||||
name[0] != '{') // we only allow contractids here
|
||||
name.encode(cx, JSID_TO_STRING(id)) &&
|
||||
name.ptr()[0] != '{') // we only allow contractids here
|
||||
{
|
||||
nsCOMPtr<nsIJSCID> nsid =
|
||||
dont_AddRef(static_cast<nsIJSCID*>(nsJSCID::NewID(name)));
|
||||
dont_AddRef(static_cast<nsIJSCID*>(nsJSCID::NewID(name.ptr())));
|
||||
if(nsid)
|
||||
{
|
||||
nsCOMPtr<nsIXPConnect> xpc;
|
||||
|
@ -1242,15 +1241,15 @@ nsXPCComponents_ClassesByID::NewResolve(nsIXPConnectWrappedNative *wrapper,
|
|||
jsid id, PRUint32 flags,
|
||||
JSObject * *objp, PRBool *_retval)
|
||||
{
|
||||
const char* name = nsnull;
|
||||
JSAutoByteString name;
|
||||
|
||||
if(JSID_IS_STRING(id) &&
|
||||
nsnull != (name = JS_GetStringBytes(JSID_TO_STRING(id))) &&
|
||||
name[0] == '{' &&
|
||||
IsRegisteredCLSID(name)) // we only allow canonical CLSIDs here
|
||||
name.encode(cx, JSID_TO_STRING(id)) &&
|
||||
name.ptr()[0] == '{' &&
|
||||
IsRegisteredCLSID(name.ptr())) // we only allow canonical CLSIDs here
|
||||
{
|
||||
nsCOMPtr<nsIJSCID> nsid =
|
||||
dont_AddRef(static_cast<nsIJSCID*>(nsJSCID::NewID(name)));
|
||||
dont_AddRef(static_cast<nsIJSCID*>(nsJSCID::NewID(name.ptr())));
|
||||
if(nsid)
|
||||
{
|
||||
nsCOMPtr<nsIXPConnect> xpc;
|
||||
|
@ -1477,17 +1476,16 @@ nsXPCComponents_Results::NewResolve(nsIXPConnectWrappedNative *wrapper,
|
|||
jsid id, PRUint32 flags,
|
||||
JSObject * *objp, PRBool *_retval)
|
||||
{
|
||||
const char* name = nsnull;
|
||||
JSAutoByteString name;
|
||||
|
||||
if(JSID_IS_STRING(id) &&
|
||||
nsnull != (name = JS_GetStringBytes(JSID_TO_STRING(id))))
|
||||
if(JSID_IS_STRING(id) && name.encode(cx, JSID_TO_STRING(id)))
|
||||
{
|
||||
const char* rv_name;
|
||||
void* iter = nsnull;
|
||||
nsresult rv;
|
||||
while(nsXPCException::IterateNSResults(&rv, &rv_name, nsnull, &iter))
|
||||
{
|
||||
if(!strcmp(name, rv_name))
|
||||
if(!strcmp(name.ptr(), rv_name))
|
||||
{
|
||||
jsval val;
|
||||
|
||||
|
@ -1704,12 +1702,12 @@ nsXPCComponents_ID::CallOrConstruct(nsIXPConnectWrappedNative *wrapper,
|
|||
// convert the first argument into a string and see if it looks like an id
|
||||
|
||||
JSString* jsstr;
|
||||
const char* str;
|
||||
JSAutoByteString bytes;
|
||||
nsID id;
|
||||
|
||||
if(!(jsstr = JS_ValueToString(cx, argv[0])) ||
|
||||
!(str = JS_GetStringBytes(jsstr)) ||
|
||||
! id.Parse(str))
|
||||
!bytes.encode(cx, jsstr) ||
|
||||
!id.Parse(bytes.ptr()))
|
||||
{
|
||||
return ThrowAndFail(NS_ERROR_XPC_BAD_ID_STRING, cx, _retval);
|
||||
}
|
||||
|
@ -1927,6 +1925,7 @@ nsXPCComponents_Exception::CallOrConstruct(nsIXPConnectWrappedNative *wrapper,
|
|||
|
||||
// initialization params for the exception object we will create
|
||||
const char* eMsg = "exception";
|
||||
JSAutoByteString eMsgBytes;
|
||||
nsresult eResult = NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsIStackFrame> eStack;
|
||||
nsCOMPtr<nsISupports> eData;
|
||||
|
@ -1971,7 +1970,7 @@ nsXPCComponents_Exception::CallOrConstruct(nsIXPConnectWrappedNative *wrapper,
|
|||
case 1: // argv[0] is string for eMsg
|
||||
{
|
||||
JSString* str = JS_ValueToString(cx, argv[0]);
|
||||
if(!str || !(eMsg = JS_GetStringBytes(str)))
|
||||
if(!str || !(eMsg = eMsgBytes.encode(cx, str)))
|
||||
return ThrowAndFail(NS_ERROR_XPC_BAD_CONVERT_JS, cx, _retval);
|
||||
}
|
||||
// ...fall through...
|
||||
|
@ -2501,12 +2500,13 @@ nsXPCComponents_Constructor::CallOrConstruct(nsIXPConnectWrappedNative *wrapper,
|
|||
nsCOMPtr<nsIJSCID> cClassID;
|
||||
nsCOMPtr<nsIJSIID> cInterfaceID;
|
||||
const char* cInitializer = nsnull;
|
||||
|
||||
JSAutoByteString cInitializerBytes;
|
||||
|
||||
if(argc >= 3)
|
||||
{
|
||||
// argv[2] is an initializer function or property name
|
||||
JSString* str = JS_ValueToString(cx, argv[2]);
|
||||
if(!str || !(cInitializer = JS_GetStringBytes(str)))
|
||||
if(!str || !(cInitializer = cInitializerBytes.encode(cx, str)))
|
||||
return ThrowAndFail(NS_ERROR_XPC_BAD_CONVERT_JS, cx, _retval);
|
||||
}
|
||||
|
||||
|
@ -3533,11 +3533,11 @@ nsXPCComponents_Utils::EvalInSandbox(const nsAString &source)
|
|||
return rv;
|
||||
|
||||
JSObject *sandbox;
|
||||
char *jsVersionStr = NULL;
|
||||
char *filenameStr = NULL;
|
||||
JSString *jsVersionStr = NULL;
|
||||
JSString *filenameStr = NULL;
|
||||
PRInt32 lineNo = 0;
|
||||
|
||||
JSBool ok = JS_ConvertArguments(cx, argc, argv, "*o/ssi",
|
||||
JSBool ok = JS_ConvertArguments(cx, argc, argv, "*o/SSi",
|
||||
&sandbox, &jsVersionStr,
|
||||
&filenameStr, &lineNo);
|
||||
|
||||
|
@ -3548,16 +3548,23 @@ nsXPCComponents_Utils::EvalInSandbox(const nsAString &source)
|
|||
|
||||
// Optional third argument: JS version, as a string.
|
||||
if (jsVersionStr) {
|
||||
jsVersion = JS_StringToVersion(jsVersionStr);
|
||||
JSAutoByteString bytes(cx, jsVersionStr);
|
||||
if (!bytes)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
jsVersion = JS_StringToVersion(bytes.ptr());
|
||||
if (jsVersion == JSVERSION_UNKNOWN)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
JSAutoByteString filenameBytes;
|
||||
nsXPIDLCString filename;
|
||||
|
||||
|
||||
// Optional fourth and fifth arguments: filename and line number.
|
||||
if (filenameStr) {
|
||||
filename = filenameStr;
|
||||
if (!filenameBytes.encode(cx, filenameStr))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
filename = filenameBytes.ptr();
|
||||
} else {
|
||||
// Get the current source info from xpc.
|
||||
nsCOMPtr<nsIStackFrame> frame;
|
||||
|
|
|
@ -1653,11 +1653,11 @@ XPCConvert::JSValToXPCException(XPCCallContext& ccx,
|
|||
const JSErrorReport* report;
|
||||
if(nsnull != (report = JS_ErrorFromException(cx, s)))
|
||||
{
|
||||
const char* message = nsnull;
|
||||
JSAutoByteString message;
|
||||
JSString* str;
|
||||
if(nsnull != (str = JS_ValueToString(cx, s)))
|
||||
message = JS_GetStringBytes(str);
|
||||
return JSErrorToXPCException(ccx, message, ifaceName,
|
||||
message.encode(cx, str);
|
||||
return JSErrorToXPCException(ccx, message.ptr(), ifaceName,
|
||||
methodName, report, exceptn);
|
||||
}
|
||||
|
||||
|
@ -1696,10 +1696,13 @@ XPCConvert::JSValToXPCException(XPCCallContext& ccx,
|
|||
if(!str)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
JSAutoByteString strBytes(cx, str);
|
||||
if (!strBytes)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return ConstructException(NS_ERROR_XPC_JS_THREW_JS_OBJECT,
|
||||
JS_GetStringBytes(str),
|
||||
ifaceName, methodName, nsnull,
|
||||
exceptn, cx, &s);
|
||||
strBytes.ptr(), ifaceName, methodName,
|
||||
nsnull, exceptn, cx, &s);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1767,10 +1770,15 @@ XPCConvert::JSValToXPCException(XPCCallContext& ccx,
|
|||
|
||||
JSString* str = JS_ValueToString(cx, s);
|
||||
if(str)
|
||||
return ConstructException(NS_ERROR_XPC_JS_THREW_STRING,
|
||||
JS_GetStringBytes(str),
|
||||
ifaceName, methodName, nsnull,
|
||||
exceptn, cx, &s);
|
||||
{
|
||||
JSAutoByteString strBytes(cx, str);
|
||||
if(!!strBytes)
|
||||
{
|
||||
return ConstructException(NS_ERROR_XPC_JS_THREW_STRING,
|
||||
strBytes.ptr(), ifaceName, methodName,
|
||||
nsnull, exceptn, cx, &s);
|
||||
}
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,13 +45,14 @@
|
|||
#endif
|
||||
#define TAB " "
|
||||
|
||||
static const char* JSVAL2String(JSContext* cx, jsval val, JSBool* isString)
|
||||
static const char* JSVAL2String(JSContext* cx, jsval val, JSBool* isString,
|
||||
JSAutoByteString *bytes)
|
||||
{
|
||||
JSAutoRequest ar(cx);
|
||||
const char* value = nsnull;
|
||||
JSString* value_str = JS_ValueToString(cx, val);
|
||||
if(value_str)
|
||||
value = JS_GetStringBytes(value_str);
|
||||
value = bytes->encode(cx, value_str);
|
||||
if(value)
|
||||
{
|
||||
const char* found = strstr(value, "function ");
|
||||
|
@ -79,8 +80,6 @@ static char* FormatJSFrame(JSContext* cx, JSStackFrame* fp,
|
|||
JSFunction* fun = nsnull;
|
||||
uint32 namedArgCount = 0;
|
||||
jsval val;
|
||||
const char* name;
|
||||
const char* value;
|
||||
JSBool isString;
|
||||
|
||||
// get the info for this stack frame
|
||||
|
@ -139,11 +138,13 @@ static char* FormatJSFrame(JSContext* cx, JSStackFrame* fp,
|
|||
JSPropertyDesc* desc = &callProps.array[i];
|
||||
if(desc->flags & JSPD_ARGUMENT)
|
||||
{
|
||||
name = JSVAL2String(cx, desc->id, &isString);
|
||||
JSAutoByteString nameBytes;
|
||||
const char* name = JSVAL2String(cx, desc->id, &isString, &nameBytes);
|
||||
if(!isString)
|
||||
name = nsnull;
|
||||
value = JSVAL2String(cx, desc->value, &isString);
|
||||
|
||||
JSAutoByteString valueBytes;
|
||||
const char* value = JSVAL2String(cx, desc->value, &isString, &valueBytes);
|
||||
|
||||
buf = JS_sprintf_append(buf, "%s%s%s%s%s%s",
|
||||
namedArgCount ? ", " : "",
|
||||
name ? name :"",
|
||||
|
@ -174,7 +175,8 @@ static char* FormatJSFrame(JSContext* cx, JSStackFrame* fp,
|
|||
|
||||
if(JS_GetProperty(cx, argsObj, number, &val))
|
||||
{
|
||||
value = JSVAL2String(cx, val, &isString);
|
||||
JSAutoByteString valueBytes;
|
||||
const char *value = JSVAL2String(cx, val, &isString, &valueBytes);
|
||||
buf = JS_sprintf_append(buf, "%s%s%s%s",
|
||||
k ? ", " : "",
|
||||
isString ? "\"" : "",
|
||||
|
@ -204,8 +206,10 @@ static char* FormatJSFrame(JSContext* cx, JSStackFrame* fp,
|
|||
JSPropertyDesc* desc = &callProps.array[i];
|
||||
if(desc->flags & JSPD_VARIABLE)
|
||||
{
|
||||
name = JSVAL2String(cx, desc->id, nsnull);
|
||||
value = JSVAL2String(cx, desc->value, &isString);
|
||||
JSAutoByteString nameBytes;
|
||||
JSAutoByteString valueBytes;
|
||||
const char *name = JSVAL2String(cx, desc->id, nsnull, &nameBytes);
|
||||
const char *value = JSVAL2String(cx, desc->value, &isString, &valueBytes);
|
||||
|
||||
if(name && value)
|
||||
{
|
||||
|
@ -227,12 +231,12 @@ static char* FormatJSFrame(JSContext* cx, JSStackFrame* fp,
|
|||
if(gotThisVal)
|
||||
{
|
||||
JSString* thisValStr;
|
||||
char* thisValChars;
|
||||
JSAutoByteString thisValBytes;
|
||||
|
||||
if(nsnull != (thisValStr = JS_ValueToString(cx, thisVal)) &&
|
||||
nsnull != (thisValChars = JS_GetStringBytes(thisValStr)))
|
||||
thisValBytes.encode(cx, thisValStr))
|
||||
{
|
||||
buf = JS_sprintf_append(buf, TAB "this = %s\n", thisValChars);
|
||||
buf = JS_sprintf_append(buf, TAB "this = %s\n", thisValBytes.ptr());
|
||||
if(!buf) goto out;
|
||||
}
|
||||
}
|
||||
|
@ -250,9 +254,10 @@ static char* FormatJSFrame(JSContext* cx, JSStackFrame* fp,
|
|||
JSPropertyDesc* desc = &thisProps.array[i];
|
||||
if(desc->flags & JSPD_ENUMERATE)
|
||||
{
|
||||
|
||||
name = JSVAL2String(cx, desc->id, nsnull);
|
||||
value = JSVAL2String(cx, desc->value, &isString);
|
||||
JSAutoByteString nameBytes;
|
||||
JSAutoByteString valueBytes;
|
||||
const char *name = JSVAL2String(cx, desc->id, nsnull, &nameBytes);
|
||||
const char *value = JSVAL2String(cx, desc->value, &isString, &valueBytes);
|
||||
if(name && value)
|
||||
{
|
||||
buf = JS_sprintf_append(buf, TAB "this.%s = %s%s%s\n",
|
||||
|
@ -368,12 +373,12 @@ xpc_DumpEvalInJSStackFrame(JSContext* cx, JSUint32 frameno, const char* text)
|
|||
|
||||
jsval rval;
|
||||
JSString* str;
|
||||
const char* chars;
|
||||
JSAutoByteString bytes;
|
||||
if(JS_EvaluateInStackFrame(cx, fp, text, strlen(text), "eval", 1, &rval) &&
|
||||
nsnull != (str = JS_ValueToString(cx, rval)) &&
|
||||
nsnull != (chars = JS_GetStringBytes(str)))
|
||||
bytes.encode(cx, str))
|
||||
{
|
||||
printf("%s\n", chars);
|
||||
printf("%s\n", bytes.ptr());
|
||||
}
|
||||
else
|
||||
puts("eval failed!");
|
||||
|
|
|
@ -561,9 +561,10 @@ ThrowCallFailed(JSContext *cx, nsresult rv,
|
|||
format = "";
|
||||
}
|
||||
|
||||
JSAutoByteString memberNameBytes;
|
||||
if (!memberName) {
|
||||
memberName = JSID_IS_STRING(memberId)
|
||||
? JS_GetStringBytes(JSID_TO_STRING(memberId))
|
||||
? memberNameBytes.encode(cx, JSID_TO_STRING(memberId))
|
||||
: "unknown";
|
||||
}
|
||||
if(nsXPCException::NameAndFormatForNSResult(rv, &name, nsnull)
|
||||
|
@ -633,9 +634,10 @@ ThrowBadArg(JSContext *cx, nsresult rv, const char *ifaceName,
|
|||
if(!nsXPCException::NameAndFormatForNSResult(rv, nsnull, &format))
|
||||
format = "";
|
||||
|
||||
JSAutoByteString memberNameBytes;
|
||||
if (!memberName) {
|
||||
memberName = JSID_IS_STRING(memberId)
|
||||
? JS_GetStringBytes(JSID_TO_STRING(memberId))
|
||||
? memberNameBytes.encode(cx, JSID_TO_STRING(memberId))
|
||||
: "unknown";
|
||||
}
|
||||
sz = JS_smprintf("%s arg %u [%s.%s]",
|
||||
|
@ -770,9 +772,14 @@ xpc_qsACString::xpc_qsACString(JSContext *cx, jsval v, jsval *pval)
|
|||
*pval = STRING_TO_JSVAL(s); // Root the new string.
|
||||
}
|
||||
|
||||
const char *bytes = JS_GetStringBytes(s);
|
||||
size_t len = s->length();
|
||||
new(mBuf) implementation_type(bytes, len);
|
||||
JSAutoByteString bytes(cx, s);
|
||||
if(!bytes)
|
||||
{
|
||||
mValid = JS_FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
new(mBuf) implementation_type(bytes.ptr(), strlen(bytes.ptr()));
|
||||
mValid = JS_TRUE;
|
||||
}
|
||||
|
||||
|
@ -1013,28 +1020,25 @@ xpc_qsUnwrapArgImpl(JSContext *cx,
|
|||
}
|
||||
|
||||
JSBool
|
||||
xpc_qsJsvalToCharStr(JSContext *cx, jsval v, jsval *pval, char **pstr)
|
||||
xpc_qsJsvalToCharStr(JSContext *cx, jsval v, JSAutoByteString *bytes)
|
||||
{
|
||||
JSString *str;
|
||||
|
||||
JS_ASSERT(!bytes->ptr());
|
||||
if(JSVAL_IS_STRING(v))
|
||||
{
|
||||
str = JSVAL_TO_STRING(v);
|
||||
}
|
||||
else if(JSVAL_IS_VOID(v) || JSVAL_IS_NULL(v))
|
||||
{
|
||||
*pstr = NULL;
|
||||
return JS_TRUE;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!(str = JS_ValueToString(cx, v)))
|
||||
return JS_FALSE;
|
||||
*pval = STRING_TO_JSVAL(str); // Root the new string.
|
||||
return false;
|
||||
}
|
||||
|
||||
*pstr = JS_GetStringBytes(str);
|
||||
return JS_TRUE;
|
||||
return !!bytes->encode(cx, str);
|
||||
}
|
||||
|
||||
JSBool
|
||||
|
|
|
@ -412,16 +412,15 @@ struct xpc_qsArgValArray
|
|||
* Convert a jsval to char*, returning JS_TRUE on success.
|
||||
*
|
||||
* @param cx
|
||||
* A context.
|
||||
* @param pval
|
||||
* In/out. *pval is the jsval to convert; the function may write to *pval,
|
||||
* using it as a GC root (like xpc_qsDOMString's constructor).
|
||||
* @param pstr
|
||||
* Out. On success *pstr receives the converted string or NULL if *pval is
|
||||
* null or undefined. Unicode data is garbled as with JS_GetStringBytes.
|
||||
* A context.
|
||||
* @param v
|
||||
* A value to convert.
|
||||
* @param bytes
|
||||
* Out. On success it receives the converted string unless v is null or
|
||||
* undefinedin which case bytes->ptr() remains null.
|
||||
*/
|
||||
JSBool
|
||||
xpc_qsJsvalToCharStr(JSContext *cx, jsval v, jsval *pval, char **pstr);
|
||||
xpc_qsJsvalToCharStr(JSContext *cx, jsval v, JSAutoByteString *bytes);
|
||||
|
||||
JSBool
|
||||
xpc_qsJsvalToWcharStr(JSContext *cx, jsval v, jsval *pval, PRUnichar **pstr);
|
||||
|
|
|
@ -199,11 +199,13 @@ XPCThrower::Verbosify(XPCCallContext& ccx,
|
|||
{
|
||||
id = ccx.GetMember()->GetName();
|
||||
}
|
||||
const char *name = JSID_IS_VOID(id) ? "Unknown" : JS_GetStringBytes(JSID_TO_STRING(id));
|
||||
sz = JS_smprintf("%s [%s.%s]",
|
||||
*psz,
|
||||
iface->GetNameString(),
|
||||
name);
|
||||
JSAutoByteString bytes;
|
||||
const char *name = JSID_IS_VOID(id) ? "Unknown" : bytes.encode(ccx, JSID_TO_STRING(id));
|
||||
if(!name)
|
||||
{
|
||||
name = "";
|
||||
}
|
||||
sz = JS_smprintf("%s [%s.%s]", *psz, iface->GetNameString(), name);
|
||||
}
|
||||
|
||||
if(sz)
|
||||
|
|
|
@ -350,13 +350,14 @@ DefinePropertyIfFound(XPCCallContext& ccx,
|
|||
|
||||
if(wrapperToReflectInterfaceNames)
|
||||
{
|
||||
JSAutoByteString name;
|
||||
AutoMarkingNativeInterfacePtr iface2(ccx);
|
||||
XPCWrappedNativeTearOff* to;
|
||||
JSObject* jso;
|
||||
|
||||
if(JSID_IS_STRING(id) &&
|
||||
nsnull != (name = JS_GetStringBytes(JSID_TO_STRING(id))) &&
|
||||
(iface2 = XPCNativeInterface::GetNewOrUsed(ccx, name), iface2) &&
|
||||
name.encode(ccx, JSID_TO_STRING(id)) &&
|
||||
(iface2 = XPCNativeInterface::GetNewOrUsed(ccx, name.ptr()), iface2) &&
|
||||
nsnull != (to = wrapperToReflectInterfaceNames->
|
||||
FindTearOff(ccx, iface2, JS_TRUE)) &&
|
||||
nsnull != (jso = to->GetJSObject()))
|
||||
|
|
|
@ -81,14 +81,17 @@ Print(JSContext *cx, uintN argc, jsval *vp)
|
|||
for (i = n = 0; i < argc; i++) {
|
||||
str = JS_ValueToString(cx, argv[i]);
|
||||
if (!str)
|
||||
return JS_FALSE;
|
||||
fprintf(gOutFile, "%s%s", i ? " " : "", JS_GetStringBytes(str));
|
||||
return false;
|
||||
JSAutoByteString bytes(cx, str);
|
||||
if (!bytes)
|
||||
return false;
|
||||
fprintf(gOutFile, "%s%s", i ? " " : "", bytes.ptr());
|
||||
}
|
||||
n++;
|
||||
if (n)
|
||||
fputc('\n', gOutFile);
|
||||
JS_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
return JS_TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
static JSBool
|
||||
|
@ -96,7 +99,6 @@ Load(JSContext *cx, uintN argc, jsval *vp)
|
|||
{
|
||||
uintN i;
|
||||
JSString *str;
|
||||
const char *filename;
|
||||
JSScript *script;
|
||||
JSBool ok;
|
||||
jsval result;
|
||||
|
@ -111,8 +113,10 @@ Load(JSContext *cx, uintN argc, jsval *vp)
|
|||
if (!str)
|
||||
return JS_FALSE;
|
||||
argv[i] = STRING_TO_JSVAL(str);
|
||||
filename = JS_GetStringBytes(str);
|
||||
script = JS_CompileFile(cx, obj, filename);
|
||||
JSAutoByteString filename(cx, str);
|
||||
if (!filename)
|
||||
return false;
|
||||
script = JS_CompileFile(cx, obj, filename.ptr());
|
||||
if (!script)
|
||||
ok = JS_FALSE;
|
||||
else {
|
||||
|
|
|
@ -179,7 +179,7 @@ WrapperFactory::PrepareForWrapping(JSContext *cx, JSObject *scope, JSObject *obj
|
|||
{
|
||||
XPCNativeInterface *iface = newwn->GetSet()->GetInterfaceAt(0);
|
||||
JSString *name = JSID_TO_STRING(iface->GetName());
|
||||
NS_ASSERTION(!strcmp("nsISupports", JS_GetStringBytes(name)), "weird interface");
|
||||
NS_ASSERTION(JS_MatchStringAndAscii(name, "nsISupports"), "weird interface");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -870,8 +870,7 @@ cryptojs_ReadArgsAndGenerateKey(JSContext *cx,
|
|||
PK11SlotInfo **slot, PRBool willEscrow)
|
||||
{
|
||||
JSString *jsString;
|
||||
char *params, *keyGenAlg; //Never free these strings cause
|
||||
//they are owned by the JS layer.
|
||||
JSAutoByteString params, keyGenAlg;
|
||||
int keySize;
|
||||
nsresult rv;
|
||||
|
||||
|
@ -881,13 +880,12 @@ cryptojs_ReadArgsAndGenerateKey(JSContext *cx,
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
keySize = JSVAL_TO_INT(argv[0]);
|
||||
if (JSVAL_IS_NULL(argv[1])) {
|
||||
params = nsnull;
|
||||
} else {
|
||||
if (!JSVAL_IS_NULL(argv[1])) {
|
||||
jsString = JS_ValueToString(cx,argv[1]);
|
||||
NS_ENSURE_TRUE(jsString, NS_ERROR_OUT_OF_MEMORY);
|
||||
argv[1] = STRING_TO_JSVAL(jsString);
|
||||
params = JS_GetStringBytes(jsString);
|
||||
params.encode(cx, jsString);
|
||||
NS_ENSURE_TRUE(!!params, NS_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
if (JSVAL_IS_NULL(argv[2])) {
|
||||
|
@ -898,12 +896,13 @@ cryptojs_ReadArgsAndGenerateKey(JSContext *cx,
|
|||
jsString = JS_ValueToString(cx, argv[2]);
|
||||
NS_ENSURE_TRUE(jsString, NS_ERROR_OUT_OF_MEMORY);
|
||||
argv[2] = STRING_TO_JSVAL(jsString);
|
||||
keyGenAlg = JS_GetStringBytes(jsString);
|
||||
keyGenType->keyGenType = cryptojs_interpret_key_gen_type(keyGenAlg);
|
||||
keyGenAlg.encode(cx, jsString);
|
||||
NS_ENSURE_TRUE(!!keyGenAlg, NS_ERROR_OUT_OF_MEMORY);
|
||||
keyGenType->keyGenType = cryptojs_interpret_key_gen_type(keyGenAlg.ptr());
|
||||
if (keyGenType->keyGenType == invalidKeyGen) {
|
||||
JS_ReportError(cx, "%s%s%s", JS_ERROR,
|
||||
"invalid key generation argument:",
|
||||
keyGenAlg);
|
||||
keyGenAlg.ptr());
|
||||
goto loser;
|
||||
}
|
||||
if (*slot == nsnull) {
|
||||
|
@ -912,13 +911,13 @@ cryptojs_ReadArgsAndGenerateKey(JSContext *cx,
|
|||
goto loser;
|
||||
}
|
||||
|
||||
rv = cryptojs_generateOneKeyPair(cx,keyGenType,keySize,params,uiCxt,*slot,
|
||||
willEscrow);
|
||||
rv = cryptojs_generateOneKeyPair(cx,keyGenType,keySize,params.ptr(),uiCxt,
|
||||
*slot,willEscrow);
|
||||
|
||||
if (rv != NS_OK) {
|
||||
JS_ReportError(cx,"%s%s%s", JS_ERROR,
|
||||
"could not generate the key for algorithm ",
|
||||
keyGenAlg);
|
||||
keyGenAlg.ptr());
|
||||
goto loser;
|
||||
}
|
||||
return NS_OK;
|
||||
|
@ -1849,37 +1848,32 @@ nsCrypto::GenerateCRMFRequest(nsIDOMCRMFObject** aReturn)
|
|||
JSString *jsString = JS_ValueToString(cx,argv[0]);
|
||||
NS_ENSURE_TRUE(jsString, NS_ERROR_OUT_OF_MEMORY);
|
||||
argv[0] = STRING_TO_JSVAL(jsString);
|
||||
|
||||
char * reqDN = JS_GetStringBytes(jsString);
|
||||
char *regToken;
|
||||
if (JSVAL_IS_NULL(argv[1])) {
|
||||
regToken = nsnull;
|
||||
} else {
|
||||
JSAutoByteString reqDN(cx,jsString);
|
||||
NS_ENSURE_TRUE(!!reqDN, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
JSAutoByteString regToken;
|
||||
if (!JSVAL_IS_NULL(argv[1])) {
|
||||
jsString = JS_ValueToString(cx, argv[1]);
|
||||
NS_ENSURE_TRUE(jsString, NS_ERROR_OUT_OF_MEMORY);
|
||||
argv[1] = STRING_TO_JSVAL(jsString);
|
||||
|
||||
regToken = JS_GetStringBytes(jsString);
|
||||
regToken.encode(cx, jsString);
|
||||
NS_ENSURE_TRUE(!!regToken, NS_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
char *authenticator;
|
||||
if (JSVAL_IS_NULL(argv[2])) {
|
||||
authenticator = nsnull;
|
||||
} else {
|
||||
JSAutoByteString authenticator;
|
||||
if (!JSVAL_IS_NULL(argv[2])) {
|
||||
jsString = JS_ValueToString(cx, argv[2]);
|
||||
NS_ENSURE_TRUE(jsString, NS_ERROR_OUT_OF_MEMORY);
|
||||
argv[2] = STRING_TO_JSVAL(jsString);
|
||||
|
||||
authenticator = JS_GetStringBytes(jsString);
|
||||
authenticator.encode(cx, jsString);
|
||||
NS_ENSURE_TRUE(!!authenticator, NS_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
char *eaCert;
|
||||
if (JSVAL_IS_NULL(argv[3])) {
|
||||
eaCert = nsnull;
|
||||
} else {
|
||||
JSAutoByteString eaCert;
|
||||
if (!JSVAL_IS_NULL(argv[3])) {
|
||||
jsString = JS_ValueToString(cx, argv[3]);
|
||||
NS_ENSURE_TRUE(jsString, NS_ERROR_OUT_OF_MEMORY);
|
||||
argv[3] = STRING_TO_JSVAL(jsString);
|
||||
|
||||
eaCert = JS_GetStringBytes(jsString);
|
||||
eaCert.encode(cx, jsString);
|
||||
NS_ENSURE_TRUE(!!eaCert, NS_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
if (JSVAL_IS_NULL(argv[4])) {
|
||||
JS_ReportError(cx, "%s%s\n", JS_ERROR, "no completion "
|
||||
|
@ -1889,6 +1883,8 @@ nsCrypto::GenerateCRMFRequest(nsIDOMCRMFObject** aReturn)
|
|||
jsString = JS_ValueToString(cx, argv[4]);
|
||||
NS_ENSURE_TRUE(jsString, NS_ERROR_OUT_OF_MEMORY);
|
||||
argv[4] = STRING_TO_JSVAL(jsString);
|
||||
JSAutoByteString jsCallback(cx, jsString);
|
||||
NS_ENSURE_TRUE(!!jsCallback, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nrv = xpc->WrapNative(cx, ::JS_GetGlobalObject(cx),
|
||||
static_cast<nsIDOMCrypto *>(this),
|
||||
|
@ -1905,9 +1901,9 @@ nsCrypto::GenerateCRMFRequest(nsIDOMCRMFObject** aReturn)
|
|||
nsNSSCertificate *escrowCert = nsnull;
|
||||
nsCOMPtr<nsIX509Cert> nssCert;
|
||||
PRBool willEscrow = PR_FALSE;
|
||||
if (eaCert) {
|
||||
if (!!eaCert) {
|
||||
SECItem certDer = {siBuffer, nsnull, 0};
|
||||
SECStatus srv = ATOB_ConvertAsciiToItem(&certDer, eaCert);
|
||||
SECStatus srv = ATOB_ConvertAsciiToItem(&certDer, eaCert.ptr());
|
||||
if (srv != SECSuccess) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -1972,9 +1968,10 @@ nsCrypto::GenerateCRMFRequest(nsIDOMCRMFObject** aReturn)
|
|||
if (slot)
|
||||
PK11_FreeSlot(slot);
|
||||
|
||||
char *encodedRequest = nsCreateReqFromKeyPairs(keyids, numRequests,
|
||||
reqDN, regToken,
|
||||
authenticator,escrowCert);
|
||||
char *encodedRequest = nsCreateReqFromKeyPairs(keyids,numRequests,
|
||||
reqDN.ptr(),regToken.ptr(),
|
||||
authenticator.ptr(),
|
||||
escrowCert);
|
||||
#ifdef DEBUG_javi
|
||||
printf ("Created the folloing CRMF request:\n%s\n", encodedRequest);
|
||||
#endif
|
||||
|
@ -2023,8 +2020,7 @@ nsCrypto::GenerateCRMFRequest(nsIDOMCRMFObject** aReturn)
|
|||
args->m_kungFuDeathGrip = GetISupportsFromContext(cx);
|
||||
args->m_scope = JS_GetParent(cx, script_obj);
|
||||
|
||||
char *jsCallback = JS_GetStringBytes(jsString);
|
||||
args->m_jsCallback.Adopt(jsCallback ? nsCRT::strdup(jsCallback) : 0);
|
||||
args->m_jsCallback.Adopt(!!jsCallback ? nsCRT::strdup(jsCallback.ptr()) : 0);
|
||||
args->m_principals = principals;
|
||||
|
||||
nsCryptoRunnable *cryptoRunnable = new nsCryptoRunnable(args);
|
||||
|
@ -2550,16 +2546,15 @@ nsCrypto::SignText(const nsAString& aStringToSign, const nsAString& aCaOption,
|
|||
|
||||
PRUint32 numCAs = argc - 2;
|
||||
if (numCAs > 0) {
|
||||
nsAutoArrayPtr<char*> caNames(new char*[numCAs]);
|
||||
if (!caNames) {
|
||||
aResult.Append(internalError);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
jsval *argv = nsnull;
|
||||
ncc->GetArgvPtr(&argv);
|
||||
|
||||
nsAutoArrayPtr<JSAutoByteString> caNameBytes(new JSAutoByteString[numCAs]);
|
||||
if (!caNameBytes) {
|
||||
aResult.Append(internalError);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
PRUint32 i;
|
||||
|
@ -2567,15 +2562,19 @@ nsCrypto::SignText(const nsAString& aStringToSign, const nsAString& aCaOption,
|
|||
JSString *caName = JS_ValueToString(cx, argv[i]);
|
||||
NS_ENSURE_TRUE(caName, NS_ERROR_OUT_OF_MEMORY);
|
||||
argv[i] = STRING_TO_JSVAL(caName);
|
||||
|
||||
if (!caName) {
|
||||
aResult.Append(internalError);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
caNames[i - 2] = JS_GetStringBytes(caName);
|
||||
caNameBytes[i - 2].encode(cx, caName);
|
||||
NS_ENSURE_TRUE(!!caNameBytes[i - 2], NS_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
nsAutoArrayPtr<char*> caNames(new char*[numCAs]);
|
||||
if (!caNames) {
|
||||
aResult.Append(internalError);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
for (i = 0; i < numCAs; ++i)
|
||||
caNames[i] = caNameBytes[i].ptr();
|
||||
|
||||
if (certList &&
|
||||
CERT_FilterCertListByCANames(certList, numCAs, caNames,
|
||||
certUsageEmailSigner) != SECSuccess) {
|
||||
|
|
|
@ -85,7 +85,9 @@ StatementRow::GetProperty(nsIXPConnectWrappedNative *aWrapper,
|
|||
NS_ENSURE_TRUE(mStatement, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
if (JSID_IS_STRING(aId)) {
|
||||
nsDependentCString jsid(::JS_GetStringBytes(JSID_TO_STRING(aId)));
|
||||
::JSAutoByteString idBytes(aCtx, JSID_TO_STRING(aId));
|
||||
NS_ENSURE_TRUE(!!idBytes, NS_ERROR_OUT_OF_MEMORY);
|
||||
nsDependentCString jsid(idBytes.ptr());
|
||||
|
||||
PRUint32 idx;
|
||||
nsresult rv = mStatement->GetColumnIndex(jsid, &idx);
|
||||
|
@ -162,8 +164,9 @@ StatementRow::NewResolve(nsIXPConnectWrappedNative *aWrapper,
|
|||
// prototype chain to be checked for the property.
|
||||
|
||||
if (JSID_IS_STRING(aId)) {
|
||||
JSString *str = JSID_TO_STRING(aId);
|
||||
nsDependentCString name(::JS_GetStringBytes(str));
|
||||
::JSAutoByteString idBytes(aCtx, JSID_TO_STRING(aId));
|
||||
NS_ENSURE_TRUE(!!idBytes, NS_ERROR_OUT_OF_MEMORY);
|
||||
nsDependentCString name(idBytes.ptr());
|
||||
|
||||
PRUint32 idx;
|
||||
nsresult rv = mStatement->GetColumnIndex(name, &idx);
|
||||
|
@ -175,9 +178,7 @@ StatementRow::NewResolve(nsIXPConnectWrappedNative *aWrapper,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
*_retval = ::JS_DefineUCProperty(aCtx, aScopeObj, ::JS_GetStringChars(str),
|
||||
::JS_GetStringLength(str),
|
||||
JSVAL_VOID,
|
||||
*_retval = ::JS_DefinePropertyById(aCtx, aScopeObj, aId, JSVAL_VOID,
|
||||
nsnull, nsnull, 0);
|
||||
*_objp = aScopeObj;
|
||||
return NS_OK;
|
||||
|
|
|
@ -294,7 +294,6 @@ InstallTriggerGlobalInstall(JSContext *cx, JSObject *obj, uintN argc, jsval *arg
|
|||
jsval v;
|
||||
const PRUnichar *name, *URL;
|
||||
const PRUnichar *iconURL = nsnull;
|
||||
const char *hash;
|
||||
|
||||
for (int i = 0; i < ida->length && !abortLoad; i++ )
|
||||
{
|
||||
|
@ -309,7 +308,7 @@ InstallTriggerGlobalInstall(JSContext *cx, JSObject *obj, uintN argc, jsval *arg
|
|||
name = reinterpret_cast<const PRUnichar*>(JS_GetStringChars( str ));
|
||||
|
||||
URL = iconURL = nsnull;
|
||||
hash = nsnull;
|
||||
JSAutoByteString hash;
|
||||
JS_GetUCProperty( cx, JSVAL_TO_OBJECT(argv[0]), reinterpret_cast<const jschar*>(name), nsCRT::strlen(name), &v );
|
||||
if ( JSVAL_IS_OBJECT(v) && JSVAL_TO_OBJECT(v) )
|
||||
{
|
||||
|
@ -334,11 +333,10 @@ InstallTriggerGlobalInstall(JSContext *cx, JSObject *obj, uintN argc, jsval *arg
|
|||
|
||||
if (JS_GetProperty( cx, JSVAL_TO_OBJECT(v), "Hash", &v2) && !JSVAL_IS_VOID(v2)) {
|
||||
JSString *str = JS_ValueToString(cx, v2);
|
||||
if (!str) {
|
||||
if (!str || !hash.encode(cx, str)) {
|
||||
abortLoad = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
hash = reinterpret_cast<const char*>(JS_GetStringBytes(str));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
Загрузка…
Ссылка в новой задаче