summaryrefslogtreecommitdiffstats
path: root/native_client_sdk/src/gonacl_appengine
diff options
context:
space:
mode:
authorsbc@chromium.org <sbc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-10 23:09:27 +0000
committersbc@chromium.org <sbc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-10 23:09:27 +0000
commite18bcf6e962df358b102c2c4e7c6b9aee483416c (patch)
tree4048d8bd7be0d3c81abffbadbdc3cb74e1eb4011 /native_client_sdk/src/gonacl_appengine
parent35e98edbe2ad34995d809a1f021321c5ef3163f8 (diff)
downloadchromium_src-e18bcf6e962df358b102c2c4e7c6b9aee483416c.zip
chromium_src-e18bcf6e962df358b102c2c4e7c6b9aee483416c.tar.gz
chromium_src-e18bcf6e962df358b102c2c4e7c6b9aee483416c.tar.bz2
[NaCl SDK] AppEngine: update lua page and executable.
This new .pexe inludes fixes to nacl_io that fix issues with readline. The version of naclterm has also been updated to the latest one in naclports. R=binji@chromium.org Review URL: https://codereview.chromium.org/67643002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@234186 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'native_client_sdk/src/gonacl_appengine')
-rwxr-xr-xnative_client_sdk/src/gonacl_appengine/src/lua/build.sh2
-rw-r--r--native_client_sdk/src/gonacl_appengine/static/lua/index.html12
-rw-r--r--native_client_sdk/src/gonacl_appengine/static/lua/naclterm.js151
3 files changed, 94 insertions, 71 deletions
diff --git a/native_client_sdk/src/gonacl_appengine/src/lua/build.sh b/native_client_sdk/src/gonacl_appengine/src/lua/build.sh
index db02c7a..40b97dc 100755
--- a/native_client_sdk/src/gonacl_appengine/src/lua/build.sh
+++ b/native_client_sdk/src/gonacl_appengine/src/lua/build.sh
@@ -12,7 +12,7 @@ cd ${SCRIPT_DIR}
OUT_DIR=out
NACLPORTS_URL=http://naclports.googlecode.com/svn/trunk/src
-NACLPORTS_REV=970
+NACLPORTS_REV=974
NACLPORTS_DIR=${OUT_DIR}/naclports
if [ -z "${NACL_SDK_ROOT:-}" ]; then
diff --git a/native_client_sdk/src/gonacl_appengine/static/lua/index.html b/native_client_sdk/src/gonacl_appengine/static/lua/index.html
index cb78bf9..43c6e65 100644
--- a/native_client_sdk/src/gonacl_appengine/static/lua/index.html
+++ b/native_client_sdk/src/gonacl_appengine/static/lua/index.html
@@ -8,7 +8,7 @@
<head>
<meta charset="UTF-8">
- <title>LUA Terminal</title>
+ <title>Lua Interpreter</title>
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:300,700">
<link href="/static/styles/style.css" rel="stylesheet">
@@ -22,20 +22,22 @@
<body class="demo">
<header>
- <h1>LUA Terminal</h1>
+ <h1>Lua Interpreter</h1>
</header>
<section>
<div class="intro">
<p>
- This demo provides a client-side playground of the <a
- href="http://www.lua.org/" target="_blank">LUA</a> programming
+ This demo provides a client-side interactive shell for the <a
+ href="http://www.lua.org/" target="_blank">Lua</a> programming
language.
</p>
<p class="note">
Note: the C++ source code of this demo is available in <a
href="https://code.google.com/p/naclports/source/browse/trunk/src/examples/tools/lua_ppapi/README.nacl"
- target="_blank">naclports</a>.
+ target="_blank">naclports</a>. The terminal interface is
+ rendered in HTML/CSS using the
+ <a href="https://github.com/libapps-mirror/libapps" target="_blank">hterm</a> library.
</p>
</div>
diff --git a/native_client_sdk/src/gonacl_appengine/static/lua/naclterm.js b/native_client_sdk/src/gonacl_appengine/static/lua/naclterm.js
index 85cf0ce..e49bc93 100644
--- a/native_client_sdk/src/gonacl_appengine/static/lua/naclterm.js
+++ b/native_client_sdk/src/gonacl_appengine/static/lua/naclterm.js
@@ -9,11 +9,6 @@
lib.rtdep('lib.f',
'hterm');
-function updateStatus(message) {
- document.getElementById('statusField').textContent = message;
- term_.io.print(message + '\n');
-}
-
// CSP means that we can't kick off the initialization from the html file,
// so we do it like this instead.
window.onload = function() {
@@ -30,8 +25,7 @@ window.onload = function() {
* @param {Object} argv The argument object passed in from the Terminal.
*/
function NaClTerm(argv) {
- this.argv_ = argv;
- this.io = null;
+ this.io = argv.io.push();
};
var embed;
@@ -59,22 +53,29 @@ NaClTerm.init = function() {
terminal.setCursorPosition(0, 0);
terminal.setCursorVisible(true);
terminal.runCommandClass(NaClTerm, document.location.hash.substr(1));
-
return true;
};
+NaClTerm.prototype.updateStatus = function(message) {
+ document.getElementById('statusField').textContent = message;
+ this.io.print(message + '\n');
+}
+
/**
* Handle messages sent to us from NaCl.
*
* @private
*/
NaClTerm.prototype.handleMessage_ = function(e) {
- if (e.data.indexOf(NaClTerm.prefix) != 0) return;
+ if (e.data.indexOf(NaClTerm.prefix) != 0) {
+ console.log('Got unhandled message: ' + e.data)
+ return;
+ }
var msg = e.data.substring(NaClTerm.prefix.length);
if (!this.loaded) {
this.bufferedOutput += msg;
} else {
- term_.io.print(msg);
+ this.io.print(msg);
}
}
@@ -82,45 +83,45 @@ NaClTerm.prototype.handleMessage_ = function(e) {
* Handle load error event from NaCl.
*/
NaClTerm.prototype.handleLoadAbort_ = function(e) {
- updateStatus('Load aborted.');
+ this.updateStatus('Load aborted.');
}
/**
* Handle load abort event from NaCl.
*/
NaClTerm.prototype.handleLoadError_ = function(e) {
- term_.io.print(embed.lastError + '\n');
+ this.updateStatus(embed.lastError);
}
NaClTerm.prototype.doneLoadingUrl = function() {
- var width = term_.io.terminal_.screenSize.width;
- term_.io.print('\r' + Array(width+1).join(' '));
+ var width = this.io.terminal_.screenSize.width;
+ this.io.print('\r' + Array(width+1).join(' '));
var message = '\rLoaded ' + this.lastUrl;
if (this.lastTotal) {
var kbsize = Math.round(this.lastTotal/1024)
message += ' ['+ kbsize + ' KiB]';
}
- term_.io.print(message.slice(0, width) + '\n')
+ this.io.print(message.slice(0, width) + '\n')
}
/**
* Handle load end event from NaCl.
*/
NaClTerm.prototype.handleLoad_ = function(e) {
- if (this.lastUrl) {
+ if (this.lastUrl)
this.doneLoadingUrl();
- } else {
- term_.io.print('Loaded.\n');
- }
+ else
+ this.io.print('Loaded.\n');
+
document.getElementById('loading-cover').style.display = 'none';
- term_.io.print(ansiReset);
+ this.io.print(ansiReset);
// Now that have completed loading and displaying
// loading messages we output any messages from the
// NaCl module that were buffered up unto this point
this.loaded = true;
- term_.io.print(this.bufferedOutput);
+ this.io.print(this.bufferedOutput);
this.bufferedOutput = ''
}
@@ -129,6 +130,7 @@ NaClTerm.prototype.handleLoad_ = function(e) {
*/
NaClTerm.prototype.handleProgress_ = function(e) {
var url = e.url.substring(e.url.lastIndexOf('/') + 1);
+
if (this.lastUrl && this.lastUrl != url)
this.doneLoadingUrl()
@@ -138,7 +140,7 @@ NaClTerm.prototype.handleProgress_ = function(e) {
var percent = 10;
var message = 'Loading ' + url;
- if (event.lengthComputable && event.total > 0) {
+ if (e.lengthComputable && e.total > 0) {
percent = Math.round(e.loaded * 100 / e.total);
var kbloaded = Math.round(e.loaded / 1024);
var kbtotal = Math.round(e.total / 1024);
@@ -147,8 +149,8 @@ NaClTerm.prototype.handleProgress_ = function(e) {
document.getElementById('progress-bar').style.width = percent + "%";
- var width = term_.io.terminal_.screenSize.width;
- term_.io.print('\r' + message.slice(-width));
+ var width = this.io.terminal_.screenSize.width;
+ this.io.print('\r' + message.slice(-width));
this.lastUrl = url;
this.lastTotal = e.total;
}
@@ -157,42 +159,26 @@ NaClTerm.prototype.handleProgress_ = function(e) {
* Handle crash event from NaCl.
*/
NaClTerm.prototype.handleCrash_ = function(e) {
- term_.io.print(ansiCyan)
+ this.io.print(ansiCyan)
if (embed.exitStatus == -1) {
- updateStatus('Program crashed (exit status -1)')
+ this.updateStatus('Program crashed (exit status -1)')
} else {
- updateStatus('Program exited (status=' + embed.exitStatus + ')');
+ this.updateStatus('Program exited (status=' + embed.exitStatus + ')');
}
}
-
-NaClTerm.prototype.onTerminalResize_ = function() {
- var width = term_.io.terminal_.screenSize.width;
- var height = term_.io.terminal_.screenSize.height;
- embed.postMessage({'tty_resize': [ width, height ]});
-}
-
-NaClTerm.prototype.onVTKeystroke_ = function(str) {
- var message = {};
- message[NaClTerm.prefix] = str;
- embed.postMessage(message);
-}
-
-/*
- * This is invoked by the terminal as a result of terminal.runCommandClass().
+/**
+ * Create the NaCl embed element.
+ * We delay this until the first terminal resize event so that we start
+ * with the correct size.
*/
-NaClTerm.prototype.run = function() {
- this.io = this.argv_.io.push();
- this.bufferedOutput = '';
- this.loaded = false;
- this.io.print(ansiCyan);
-
+NaClTerm.prototype.createEmbed = function(width, height) {
var mimetype = 'application/x-pnacl';
if (navigator.mimeTypes[mimetype] === undefined) {
if (mimetype.indexOf('pnacl') != -1)
- updateStatus('Browser does not support PNaCl or PNaCl is disabled');
+ this.updateStatus('Browser does not support PNaCl or PNaCl is disabled');
else
- updateStatus('Browser does not support NaCl or NaCl is disabled');
+ this.updateStatus('Browser does not support NaCl or NaCl is disabled');
return;
}
@@ -215,28 +201,63 @@ NaClTerm.prototype.run = function() {
embed.appendChild(param);
}
- addParam('ps_tty_prefix', NaClTerm.prefix);
- addParam('ps_tty_resize', 'tty_resize');
- addParam('ps_stdin', '/dev/tty');
- addParam('ps_stdout', '/dev/tty');
- addParam('ps_stderr', '/dev/tty');
- addParam('ps_verbosity', '2');
+ addParam('PS_TTY_PREFIX', NaClTerm.prefix);
+ addParam('PS_TTY_RESIZE', 'tty_resize');
+ addParam('PS_TTY_COLS', width);
+ addParam('PS_TTY_ROWS', height);
+ addParam('PS_STDIN', '/dev/tty');
+ addParam('PS_STDOUT', '/dev/tty');
+ addParam('PS_STDERR', '/dev/tty');
+ addParam('PS_VERBOSITY', '2');
+ addParam('PS_EXIT_MESSAGE', 'exited');
addParam('TERM', 'xterm-256color');
+ addParam('ARG2', 'all.lua');
+ addParam('ARG1', '-e_U=true');
+ addParam('LUA_DATA_URL', 'http://commondatastorage.googleapis.com/gonacl/demos/publish/test/lua');
+ // Add ARGV arguments from query parameters.
var args = lib.f.parseQuery(document.location.search);
- var argn = 1;
- while (true) {
- var argname = 'arg' + argn;
- var arg = args[argname];
- if (typeof(arg) === 'undefined')
- break;
- addParam(argname, arg);
- argn = argn + 1;
+ for (var argname in args) {
+ addParam(argname, args[argname]);
+ }
+
+ // If the application has set NaClTerm.argv and there were
+ // no arguments set in the query parameters then add the default
+ // NaClTerm.argv arguments.
+ if (typeof(args['arg1']) === 'undefined' && NaClTerm.argv) {
+ var argn = 1
+ NaClTerm.argv.forEach(function(arg) {
+ var argname = 'arg' + argn;
+ addParam(argname, arg);
+ argn = argn + 1
+ })
}
- updateStatus('Loading...');
+ this.updateStatus('Loading...');
this.io.print('Loading NaCl module.\n')
document.getElementById("listener").appendChild(embed);
+}
+
+NaClTerm.prototype.onTerminalResize_ = function(width, height) {
+ if (typeof(embed) === 'undefined')
+ this.createEmbed(width, height);
+ else
+ embed.postMessage({'tty_resize': [ width, height ]});
+}
+
+NaClTerm.prototype.onVTKeystroke_ = function(str) {
+ var message = {};
+ message[NaClTerm.prefix] = str;
+ embed.postMessage(message);
+}
+
+/*
+ * This is invoked by the terminal as a result of terminal.runCommandClass().
+ */
+NaClTerm.prototype.run = function() {
+ this.bufferedOutput = '';
+ this.loaded = false;
+ this.io.print(ansiCyan);
this.io.onVTKeystroke = this.onVTKeystroke_.bind(this);
this.io.onTerminalResize = this.onTerminalResize_.bind(this);