зеркало из https://github.com/mozilla/pluotsorbet.git
move console.print to separate NativeConsoleOutputStream
This commit is contained in:
Родитель
52975779ce
Коммит
dcb39a8f4f
|
@ -170,29 +170,12 @@
|
|||
}
|
||||
|
||||
WebConsole.prototype = {
|
||||
flush: function() {
|
||||
if (this.buffer.length) {
|
||||
var temp = this.buffer;
|
||||
this.buffer = "";
|
||||
console.info(temp);
|
||||
}
|
||||
},
|
||||
|
||||
push: function(item) {
|
||||
if (item.matchesCurrentFilters()) {
|
||||
this.flush(); // Preserve order w/r/t console.print().
|
||||
NativeConsoleOutputStream.flush(); // Preserve order w/r/t NativeConsoleOutputStream.print().
|
||||
windowConsole[item.levelName].apply(windowConsole, [item.message]);
|
||||
}
|
||||
},
|
||||
|
||||
/** Print one character to the output (buffered). */
|
||||
print: function(ch) {
|
||||
if (ch === 10) {
|
||||
this.flush();
|
||||
} else {
|
||||
this.buffer += String.fromCharCode(ch);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -299,12 +282,9 @@
|
|||
terminal: typeof Terminal === "undefined" ? new WebConsole() : new TerminalConsole("#consoleContainer")
|
||||
};
|
||||
|
||||
var print = CONSOLES.web.print.bind(CONSOLES.web);
|
||||
|
||||
// If we're only printing to the web console, then use the original console
|
||||
// object, so that file/line number references show up correctly in it.
|
||||
if (ENABLED_CONSOLE_TYPES.length === 1 && ENABLED_CONSOLE_TYPES[0] === "web") {
|
||||
windowConsole.print = print;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -351,7 +331,6 @@
|
|||
info: logAtLevel.bind(null, "info"),
|
||||
warn: logAtLevel.bind(null, "warn"),
|
||||
error: logAtLevel.bind(null, "error"),
|
||||
print: print,
|
||||
profile: typeof console !== "undefined" && console.profile ? console.profile.bind(console) : null,
|
||||
profileEnd: typeof console !== "undefined" && console.profileEnd ? console.profileEnd.bind(console) : null,
|
||||
};
|
||||
|
|
23
native.js
23
native.js
|
@ -538,8 +538,29 @@ Native["java/lang/Thread.activeCount.()I"] = function() {
|
|||
return $.ctx.runtime.threadCount;
|
||||
};
|
||||
|
||||
var NativeConsoleOutputStream = {
|
||||
buffer: "",
|
||||
|
||||
flush: function() {
|
||||
if (this.buffer.length) {
|
||||
var temp = this.buffer;
|
||||
this.buffer = "";
|
||||
console.info(temp);
|
||||
}
|
||||
},
|
||||
|
||||
/** Print one character to the output (buffered). */
|
||||
print: function(ch) {
|
||||
if (ch === 10) {
|
||||
this.flush();
|
||||
} else {
|
||||
this.buffer += String.fromCharCode(ch);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Native["com/sun/cldchi/io/ConsoleOutputStream.write.(I)V"] = function(ch) {
|
||||
console.print(ch);
|
||||
NativeConsoleOutputStream.print(ch);
|
||||
};
|
||||
|
||||
Native["com/sun/cldc/io/ResourceInputStream.open.(Ljava/lang/String;)Ljava/lang/Object;"] = function(name) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче