/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifdef HAVE_IO_H # include <io.h> /* for isatty() */ #endif #ifdef HAVE_UNISTD_H # include <unistd.h> /* for isatty() */ #endif
JS::RootedObject thisObject(cx); if (!args.computeThis(cx, &thisObject)) returnfalse; if (!JS_IsGlobalObject(thisObject)) {
JS_ReportErrorASCII(cx, "Trying to load() into a non-global object"); returnfalse;
}
for (unsigned i = 0; i < args.length(); i++) {
JS::Rooted<JSString*> str(cx, JS::ToString(cx, args[i])); if (!str) { returnfalse;
}
JS::UniqueChars filename = JS_EncodeStringToUTF8(cx, str); if (!filename) { returnfalse;
}
#ifdef ANDROID staticbool ChangeTestShellDir(JSContext* cx, unsigned argc, Value* vp) { // This method should only be used by testing/xpcshell/head.js to change to // the correct directory on Android Remote XPCShell tests. // // TODO: Bug 1801725 - Find a more ergonomic way to do this than exposing // identical methods in XPCShellEnvironment and XPCShellImpl to chdir on // android for Remote XPCShell tests on Android.
CallArgs args = CallArgsFromVp(argc, vp);
if (args.length() != 1) {
JS_ReportErrorASCII(cx, "changeTestShellDir() takes one argument"); returnfalse;
}
nsAutoJSCString path; if (!path.init(cx, args[0])) {
JS_ReportErrorASCII(
cx, "changeTestShellDir(): could not convert argument 1 to string"); returnfalse;
}
if (chdir(path.get())) {
JS_ReportErrorASCII(cx, "changeTestShellDir(): could not change directory"); returnfalse;
}
if (forceTTY) {
file = stdin;
} elseif (!isatty(fileno(file))) { /* * It's not interactive - just execute it. * * Support the UNIX #! shell hack; gobble the first line if it starts * with '#'.
*/ int ch = fgetc(file); if (ch == '#') { while ((ch = fgetc(file)) != EOF) { if (ch == '\n' || ch == '\r') break;
}
}
ungetc(ch, file);
/* It's an interactive filehandle; drop into read-eval-print loop. */
lineno = 1;
hitEOF = false; do {
bufp = buffer;
*bufp = '\0';
/* * Accumulate lines until we get a 'compilable unit' - one that either * generates an error (before running out of source) or that compiles * cleanly. This should be whenever we get a complete statement that * coincides with the end of a line.
*/
startline = lineno; do { if (!GetLine(bufp, file, startline == lineno ? "js> " : "")) {
hitEOF = true; break;
}
bufp += strlen(bufp);
lineno++;
} while (
!JS_Utf8BufferIsCompilableUnit(cx, global, buffer, strlen(buffer)));
/* Clear any pending exception from previous failed compiles. */
JS_ClearPendingException(cx);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.