picolisp

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/picolisp.git/
Log | Files | Refs | README | LICENSE

commit 42ef8c60c3fee90c17b75ffea8af230717e03ac4
parent 3cb17b08d08117a48c41d976ced3a5d4900db066
Author: Commit-Bot <unknown>
Date:   Fri, 12 Nov 2010 11:34:06 +0000

Automatic commit from picoLisp.tgz, From: Fri, 12 Nov 2010 11:34:06 GMT
Diffstat:
Mersatz/PicoLisp.java | 36++++++++++++++++++++++++++----------
Mersatz/README | 4++--
Mersatz/fun.src | 21++++++++++++++++-----
Mersatz/picolisp.jar | 0
Mersatz/sys.src | 2+-
Msrc64/version.l | 4++--
6 files changed, 47 insertions(+), 20 deletions(-)

diff --git a/ersatz/PicoLisp.java b/ersatz/PicoLisp.java @@ -17,7 +17,7 @@ public class PicoLisp { final static HashMap<String,Symbol> Intern = new HashMap<String,Symbol>(); final static HashMap<String,Symbol> Transient = new HashMap<String,Symbol>(); final static byte MonLen[] = new byte[] {31,31,28,31,30,31,30,31,31,30,31,30,31}; - final static byte Version[] = new byte[] {3,0,4,5}; + final static byte Version[] = new byte[] {3,0,4,6}; final static Number Zero = new Number(0); final static Number One = new Number(1); @@ -375,8 +375,9 @@ public class PicoLisp { mkSymbol(new Number("308"), "flush", Intern); mkSymbol(new Number("309"), "port", Intern); mkSymbol(new Number("310"), "accept", Intern); - mkSymbol(new Number("311"), "connect", Intern); - MaxFun = 311; + mkSymbol(new Number("311"), "listen", Intern); + mkSymbol(new Number("312"), "connect", Intern); + MaxFun = 312; init(); for (boolean first = true; ; first = false) { try { @@ -1579,7 +1580,7 @@ public class PicoLisp { final boolean ready(Selector sel) throws IOException { if (Key == null) - return Rd.ready() || Stream != null && Stream.available() > 0; + return Rd != null && Rd.ready() || Stream != null && Stream.available() > 0; boolean rdy = (Key.readyOps() & Ops) != 0; Key.cancel(); Key = null; @@ -2715,8 +2716,10 @@ public class PicoLisp { return do309(ex); case 310: // accept return do310(ex); - case 311: // connect + case 311: // listen return do311(ex); + case 312: // connect + return do312(ex); default: return undefined(this, ex); } @@ -6537,13 +6540,12 @@ public class PicoLisp { } final static Any do309(Any ex) { // port - ex = ex.Cdr; // ... try { ServerSocketChannel chan = ServerSocketChannel.open();; - chan.socket().bind(new InetSocketAddress(evInt(ex))); + chan.socket().bind(new InetSocketAddress(evInt(ex.Cdr))); return new Number(new PicoLispReader(null, allocFd(), chan, SelectionKey.OP_ACCEPT).Fd); } - catch (IOException e) {} + catch (IOException e) {err(ex, null, e.toString());} return Nil; } @@ -6553,11 +6555,25 @@ public class PicoLisp { if ((i = xInt(x = ex.Cdr.Car.eval())) < 0 || i >= InFiles.length || InFiles[i] == null || InFiles[i].Chan == null) err(ex, x, "Bad socket"); try {return mkSocket(((ServerSocketChannel)InFiles[i].Chan).accept());} - catch (IOException e) {} + catch (IOException e) {err(ex, null, e.toString());} return Nil; } - final static Any do311(Any ex) { // connect + final static Any do311(Any ex) { // listen + int i, j; + Any x, y; + if ((i = xInt(y = (x = ex.Cdr).Car.eval())) < 0 || i >= InFiles.length || InFiles[i] == null || InFiles[i].Chan == null) + err(ex, y, "Bad socket"); + j = (y = x.Cdr.Car.eval()) == Nil? -1 : xInt(y); + for (;;) { + if (waitFd(ex, i, j) == 0) + return Nil; + try {return mkSocket(((ServerSocketChannel)InFiles[i].Chan).accept());} + catch (IOException e) {err(ex, null, e.toString());} + } + } + + final static Any do312(Any ex) { // connect int i; try { SocketChannel chan = SocketChannel.open(); diff --git a/ersatz/README b/ersatz/README @@ -1,4 +1,4 @@ -11nov10abu +12nov10abu (c) Software Lab. Alexander Burger @@ -21,7 +21,7 @@ There is no support for - raw console inpt ('key') and line editing - child processes ('fork') -- interprocess communication ('tell', 'hear', 'ipc' etc.) +- interprocess communication ('tell', 'hear', 'ipc', 'udp' etc.) - databases (external symbols) - signal handling diff --git a/ersatz/fun.src b/ersatz/fun.src @@ -3470,15 +3470,14 @@ flush () return OutFile.Wr.checkError()? Nil : T; ############ net ############ -# (port ['T] 'cnt|(cnt . cnt) ['var]) -> cnt +# (port 'cnt) -> cnt port () - ex = ex.Cdr; // ... try { ServerSocketChannel chan = ServerSocketChannel.open();; - chan.socket().bind(new InetSocketAddress(evInt(ex))); + chan.socket().bind(new InetSocketAddress(evInt(ex.Cdr))); return new Number(new PicoLispReader(null, allocFd(), chan, SelectionKey.OP_ACCEPT).Fd); } - catch (IOException e) {} + catch (IOException e) {err(ex, null, e.toString());} return Nil; # (accept 'cnt) -> cnt | NIL @@ -3486,9 +3485,21 @@ accept (i x) if ((i = xInt(x = ex.Cdr.Car.eval())) < 0 || i >= InFiles.length || InFiles[i] == null || InFiles[i].Chan == null) err(ex, x, "Bad socket"); try {return mkSocket(((ServerSocketChannel)InFiles[i].Chan).accept());} - catch (IOException e) {} + catch (IOException e) {err(ex, null, e.toString());} return Nil; +# (listen 'cnt1 ['cnt2]) -> cnt | NIL +listen (i j x y) + if ((i = xInt(y = (x = ex.Cdr).Car.eval())) < 0 || i >= InFiles.length || InFiles[i] == null || InFiles[i].Chan == null) + err(ex, y, "Bad socket"); + j = (y = x.Cdr.Car.eval()) == Nil? -1 : xInt(y); + for (;;) { + if (waitFd(ex, i, j) == 0) + return Nil; + try {return mkSocket(((ServerSocketChannel)InFiles[i].Chan).accept());} + catch (IOException e) {err(ex, null, e.toString());} + } + # (connect 'any 'cnt) -> cnt | NIL connect (i) try { diff --git a/ersatz/picolisp.jar b/ersatz/picolisp.jar Binary files differ. diff --git a/ersatz/sys.src b/ersatz/sys.src @@ -1269,7 +1269,7 @@ public class PicoLisp { final boolean ready(Selector sel) throws IOException { if (Key == null) - return Rd.ready() || Stream != null && Stream.available() > 0; + return Rd != null && Rd.ready() || Stream != null && Stream.available() > 0; boolean rdy = (Key.readyOps() & Ops) != 0; Key.cancel(); Key = null; diff --git a/src64/version.l b/src64/version.l @@ -1,6 +1,6 @@ -# 10nov10abu +# 12nov10abu # (c) Software Lab. Alexander Burger -(de *Version 3 0 4 5) +(de *Version 3 0 4 6) # vi:et:ts=3:sw=3