Skip to content

Commit

Permalink
start on devices, partial tcl support
Browse files Browse the repository at this point in the history
  • Loading branch information
psema4 committed Nov 16, 2011
1 parent 1617ef4 commit 6c59629
Show file tree
Hide file tree
Showing 19 changed files with 4,882 additions and 4 deletions.
1,594 changes: 1,594 additions & 0 deletions prototype/scripts/atomos.js

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions prototype/scripts/atomos.min.js

Large diffs are not rendered by default.

1,590 changes: 1,590 additions & 0 deletions prototype/scripts/atomos.t.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions prototype/scripts/bin/build
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ cat "cat.js" \
"pwd.js" \
"rm.js" \
"rmdir.js" \
"tcl.js" \
"touch.js" \
"wallpaper.js" \
> "atomos-bin.js"
Expand Down
68 changes: 68 additions & 0 deletions prototype/scripts/bin/tcl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/* tcl.js
*
* Atomic OS WASH command
*
* Run a tcl command
*
* @author Scott Elcomb <psema4@gmail.com (http://www.psema4.com)
* @version 2.0.0
*/

window.system = window.system || {};
system.bin = system.bin || {};

/* Dummy constructor
*
* Access programmatically via system.bin.tcl.!!methodName!!
* @constructor
*/
system.bin.tcl = {
/* @method help
* @returns {string} Returns a simple string synopsis for this command
*
* Simple synopsis on this command, used by the <a href="help.html">help command</a>
*/
help: function() {
return "Run a tcl command and print the result \n\n Usage: tcl [string]";
},

/* @method exec
* @param {Array} args A list of arguments the command was called with
* Executes command with args. The calling HxProcess is available as **this** and it's first 3 file descriptors are stdin, stdout, and stderr respectively.
* For example, to tcl text to stdout: **this.fd[1].write('foobar');**
*/
exec: function(args) {
var debug = false;
// 'this' is the calling process

var stdin = (this.fd && this.fd.length > 0) ? this.fd[0] : false;
var stdout = (this.fd && this.fd.length > 1) ? this.fd[1] : false;
var stderr = (this.fd && this.fd.length > 2) ? this.fd[2] : false;

try {
var message = (args instanceof Array) ? message = args.join(' ') : args;
var filename = '', result;

if (message.match(/^< /)) {
filename = message.replace(/^< /, '');
var buf = system.fs.readFile(filename);
result = tcl(buf);

} else {
result = tcl(message);
}

if (result && result.content) stdout.write(result.content);

} catch(e) {
if (stderr) {
stderr.write('command exception: ' + e);

} else {
console.log('command exception:');
console.dir(e);
}
}

}
};
6 changes: 6 additions & 0 deletions prototype/scripts/buildall
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ echo ""
echo "building kernel"
cd ./hx; ./build

echo ""
echo "building device files"
cd ../dev; ./build

echo ""
echo "building shell commands"
cd ../bin; ./build
Expand All @@ -23,8 +27,10 @@ echo "building system"
cat "vendor/zepto.min.js" \
"zepto.eof.txt" \
"vendor/ejohn-class.js" \
"vendor/tcl.04.aos.js" \
"bin/atomos-bin.js" \
"hx/atomos-hx.js" \
"dev/atomos-dev.js" \
"system.js" \
"libsys.js" \
> "atomos.t.js"
Expand Down
6 changes: 5 additions & 1 deletion prototype/scripts/buildall.bat
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@
@call build.bat
@cd ..

@cd dev
@call build.bat
@cd ..

@echo - merging dependencies and wash commands into system
@type vendor\zepto.min.js zepto.eof.txt vendor\ejohn-class.js bin\atomos-bin.js hx\atomos-hx.js system.js libsys.js > atomos.t.js 2>NUL
@type vendor\zepto.min.js zepto.eof.txt vendor\ejohn-class.js bin\atomos-bin.js hx\atomos-hx.js dev\atomos-dev.js system.js libsys.js > atomos.t.js 2>NUL

@echo - adding main
@type atomos.t.js main.js > atomos.js 2>NUL
Expand Down
60 changes: 60 additions & 0 deletions prototype/scripts/dev/atomos-dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/* dev/net.js
*
* ++[black[Atomic OS Class: Network Device]++
*
* Requires socket.io server
*
* @author Scott Elcomb <psema4@gmail.com (http://www.psema4.com)
* @version 2.0.0
*/

if (! window.io) {
console.warn('socket.io loading failed. faking support for network device')

window.io = {
connect: function() {}
};
}

var HxNETDevice = HxDevice.extend({
/* @constructor
* @method init
* Extends <a href="../classes/device.html">HxDevice</a>
*
* Represents a basic network device in Atomic OS
* @param {Object} opts Options dictionary
*/

init: function(opts) {
this.url = opts.url || '';
this.buffer = '';
this._super(opts);
// this.socket = io.connect('http://localhost:3734');
// this.socket.on('notify', this.write);
}//,

// send: function(method, data) {
// socket.emit(method, { data: data });
// }
});
/* dev/netfs.js
*
* ++[black[Atomic OS Class: Network Filesystem Device]++
*
* @author Scott Elcomb <psema4@gmail.com (http://www.psema4.com)
* @version 2.0.0
*/

var HxNETFSDevice = HxNETDevice.extend({
/* @constructor
* @method init
* Extends <a href="net.html">HxNETFSDevice</a>
*
* Represents a network device for access to a hosted filesystem in Atomic OS
* @param {Object} opts Options dictionary
*/

init: function(opts) {
this._super(opts);
}
});
23 changes: 23 additions & 0 deletions prototype/scripts/dev/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

echo "- merging device files"
cat "net.js" \
"netfs.js" \
> "atomos-dev.js"

#docs
DOCNGN=`which jsdog`

if [ -n "$DOCS" ] && [ -n "$DOCNGN" ]
then
echo " - building documentation and unit tests"

DOCDIR="../docs/device-files"
DOCTMPL="-m ../docs/jsdog.jade"

$DOCNGN $DOCTMPL -s net.js -t t/net.js > $DOCDIR/net.html
$DOCNGN $DOCTMPL -s netfs.js -t t/netfs.js > $DOCDIR/netfs.html

else
echo " - skipping documentation and unit tests"
fi
3 changes: 3 additions & 0 deletions prototype/scripts/dev/build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo - merging device files
@type net.js netfs.js > atomos-dev.js 2>NUL
@echo - skipping documentation and unit tests
39 changes: 39 additions & 0 deletions prototype/scripts/dev/net.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/* dev/net.js
*
* ++[black[Atomic OS Class: Network Device]++
*
* Requires socket.io server
*
* @author Scott Elcomb <psema4@gmail.com (http://www.psema4.com)
* @version 2.0.0
*/

if (! window.io) {
console.warn('socket.io loading failed. faking support for network device')

window.io = {
connect: function() {}
};
}

var HxNETDevice = HxDevice.extend({
/* @constructor
* @method init
* Extends <a href="../classes/device.html">HxDevice</a>
*
* Represents a basic network device in Atomic OS
* @param {Object} opts Options dictionary
*/

init: function(opts) {
this.url = opts.url || '';
this.buffer = '';
this._super(opts);
// this.socket = io.connect('http://localhost:3734');
// this.socket.on('notify', this.write);
}//,

// send: function(method, data) {
// socket.emit(method, { data: data });
// }
});
21 changes: 21 additions & 0 deletions prototype/scripts/dev/netfs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* dev/netfs.js
*
* ++[black[Atomic OS Class: Network Filesystem Device]++
*
* @author Scott Elcomb <psema4@gmail.com (http://www.psema4.com)
* @version 2.0.0
*/

var HxNETFSDevice = HxNETDevice.extend({
/* @constructor
* @method init
* Extends <a href="net.html">HxNETFSDevice</a>
*
* Represents a network device for access to a hosted filesystem in Atomic OS
* @param {Object} opts Options dictionary
*/

init: function(opts) {
this._super(opts);
}
});
2 changes: 2 additions & 0 deletions prototype/scripts/hx/build
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ cat "class.js" \
"bus.js" \
"stream.js" \
"file.js" \
"device.js" \
"jsfs.js" \
"procfs.js" \
"domfs.js" \
"process.js" \
"wash.js" \
"tcl.js" \
"panel.js" \
"window.js" \
"commandwindow.js" \
Expand Down
2 changes: 1 addition & 1 deletion prototype/scripts/hx/build.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
@echo - creating core system
@type class.js guid.js bus.js stream.js file.js jsfs.js procfs.js domfs.js process.js wash.js panel.js window.js commandWindow.js editWindow.js docWindow.js > atomos-hx.js 2>NUL
@type class.js guid.js bus.js stream.js file.js device.js jsfs.js procfs.js domfs.js process.js wash.js panel.js window.js commandWindow.js editWindow.js docWindow.js > atomos-hx.js 2>NUL
@echo - skipping documentation and unit tests
21 changes: 21 additions & 0 deletions prototype/scripts/hx/device.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* device.js
*
* ++[black[Atomic OS Class: HxDevice]++
*
* @author Scott Elcomb <psema4@gmail.com (http://www.psema4.com)
* @version 2.0.0
*/

var HxDevice = HxStream.extend({
/* @constructor
* @method init
* Extends <a href="stream.html">HxStream</a>
*
* Represents an input and/or output device in an Atomic OS system
* @param {Object} opts Options dictionary
*/

init: function(opts) {
this._super(opts);
}
});
Loading

0 comments on commit 6c59629

Please sign in to comment.