aboutsummaryrefslogtreecommitdiff
path: root/src/algebra
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2008-10-01 09:50:16 +0000
committerdos-reis <gdr@axiomatics.org>2008-10-01 09:50:16 +0000
commit41c41ca859e093f8029bc5c6e9df996df8998530 (patch)
treefc6328409bbd3dec92bf4af92f9a0552fe791e59 /src/algebra
parent7390fa59b4e4411c142ecdb13070c5f0ac91d51d (diff)
downloadopen-axiom-41c41ca859e093f8029bc5c6e9df996df8998530.tar.gz
* algebra/files.spad.pamphlet (IOMode): New domain.
* algebra/net.spad.pamphlet (InputBinaryFile): Likewise. (OutputBinaryFile): Likewise. * interp/sys-utility.boot (openBinaryFile): New. (readByteFromFile): Likewise. (writeByteToFile): Likewise. (closeFile): Likewise.
Diffstat (limited to 'src/algebra')
-rw-r--r--src/algebra/Makefile.in9
-rw-r--r--src/algebra/Makefile.pamphlet9
-rw-r--r--src/algebra/data.spad.pamphlet7
-rw-r--r--src/algebra/exposed.lsp.pamphlet2
-rw-r--r--src/algebra/files.spad.pamphlet44
-rw-r--r--src/algebra/net.spad.pamphlet91
6 files changed, 153 insertions, 9 deletions
diff --git a/src/algebra/Makefile.in b/src/algebra/Makefile.in
index 0e82462f..6e09aa79 100644
--- a/src/algebra/Makefile.in
+++ b/src/algebra/Makefile.in
@@ -363,7 +363,7 @@ axiom_algebra_layer_0 = \
ABELSG- ORDSET ORDSET- FNCAT FILECAT SEXCAT \
MKBCFUNC MKRECORD MKUCFUNC DROPT1 PLOT1 ITFUN2 \
ITFUN3 STREAM1 STREAM2 STREAM3 ANY1 SEGBIND2 \
- COMBOPC EQ2 NONE1 CONDUIT
+ COMBOPC EQ2 NONE1 CONDUIT IOMODE
axiom_algebra_layer_0_nrlibs = \
$(addsuffix .NRLIB/code.$(FASLEXT),$(axiom_algebra_layer_0))
@@ -825,7 +825,8 @@ axiom_algebra_layer_user = \
LSTAST EXITAST RETAST SEGAST PRTDAST CRCAST \
LETAST SUCHAST RDUCEAST COLONAST ADDAST CAPSLAST \
CASEAST HASAST ISAST CATAST WHEREAST COMMAAST \
- QQUTAST DEFAST MACROAST SPADXPT SPADAST
+ QQUTAST DEFAST MACROAST SPADXPT SPADAST \
+ INBFILE OUTBFILE
axiom_algebra_layer_user_nrlibs = \
$(addsuffix .NRLIB/code.$(FASLEXT),$(axiom_algebra_layer_user))
@@ -880,6 +881,10 @@ SPADAST.NRLIB/code.$(FASLEXT): \
CLLCTAST LSTAST EXITAST RETAST CRCEAST PRTDAST RSTRCAST \
SEGAST SEQAST LETAST SUCHTAST COLONAST CASEAST HASAST \
ISAST))
+INBFILE.NRLIB/code.$(FASLEXT): $(OUT)/FNAME.$(FASLEXT) \
+ $(OUT)/INBCON.$(FASLEXT) $(OUT)/STRING.$(FASLEXT)
+OUTBFILE.NRLIB/code.$(FASLEXT): $(OUT)/FNAME.$(FASLEXT) \
+ $(OUT)/OUTBCON.$(FASLEXT) $(OUT)/STRING.$(FASLEXT)
.PHONY: all all-algebra mkdir-output-directory
all: all-ax
diff --git a/src/algebra/Makefile.pamphlet b/src/algebra/Makefile.pamphlet
index 11bc702a..10eef219 100644
--- a/src/algebra/Makefile.pamphlet
+++ b/src/algebra/Makefile.pamphlet
@@ -192,7 +192,7 @@ axiom_algebra_layer_0 = \
ABELSG- ORDSET ORDSET- FNCAT FILECAT SEXCAT \
MKBCFUNC MKRECORD MKUCFUNC DROPT1 PLOT1 ITFUN2 \
ITFUN3 STREAM1 STREAM2 STREAM3 ANY1 SEGBIND2 \
- COMBOPC EQ2 NONE1 CONDUIT
+ COMBOPC EQ2 NONE1 CONDUIT IOMODE
axiom_algebra_layer_0_nrlibs = \
$(addsuffix .NRLIB/code.$(FASLEXT),$(axiom_algebra_layer_0))
@@ -1252,7 +1252,8 @@ axiom_algebra_layer_user = \
LSTAST EXITAST RETAST SEGAST PRTDAST CRCAST \
LETAST SUCHAST RDUCEAST COLONAST ADDAST CAPSLAST \
CASEAST HASAST ISAST CATAST WHEREAST COMMAAST \
- QQUTAST DEFAST MACROAST SPADXPT SPADAST
+ QQUTAST DEFAST MACROAST SPADXPT SPADAST \
+ INBFILE OUTBFILE
axiom_algebra_layer_user_nrlibs = \
$(addsuffix .NRLIB/code.$(FASLEXT),$(axiom_algebra_layer_user))
@@ -1307,6 +1308,10 @@ SPADAST.NRLIB/code.$(FASLEXT): \
CLLCTAST LSTAST EXITAST RETAST CRCEAST PRTDAST RSTRCAST \
SEGAST SEQAST LETAST SUCHTAST COLONAST CASEAST HASAST \
ISAST))
+INBFILE.NRLIB/code.$(FASLEXT): $(OUT)/FNAME.$(FASLEXT) \
+ $(OUT)/INBCON.$(FASLEXT) $(OUT)/STRING.$(FASLEXT)
+OUTBFILE.NRLIB/code.$(FASLEXT): $(OUT)/FNAME.$(FASLEXT) \
+ $(OUT)/OUTBCON.$(FASLEXT) $(OUT)/STRING.$(FASLEXT)
@
\section{Broken Files}
diff --git a/src/algebra/data.spad.pamphlet b/src/algebra/data.spad.pamphlet
index e3262ef5..fff04339 100644
--- a/src/algebra/data.spad.pamphlet
+++ b/src/algebra/data.spad.pamphlet
@@ -23,7 +23,7 @@ import OutputForm
++ Description:
++ Byte is the datatype of 8-bit sized unsigned integer values.
Byte(): Public == Private where
- Public ==> Join(OrderedSet, CoercibleTo NonNegativeInteger) with
+ Public == Join(OrderedSet, CoercibleTo NonNegativeInteger) with
byte: NonNegativeInteger -> %
++ byte(x) injects the unsigned integer value `v' into
++ the Byte algebra. `v' must be non-negative and less than 256.
@@ -34,12 +34,15 @@ Byte(): Public == Private where
bitior: (%,%) -> %
++ bitor(x,y) returns the bitwise `inclusive or' of `x' and `y'.
- Private ==> add
+ Private == add
byte(x: NonNegativeInteger): % ==
not (x < 256$Lisp) =>
userError "integer value cannot be represented by a byte"
x : %
+ hash x ==
+ SXHASH(x)$Lisp
+
coerce(x: NonNegativeInteger): % ==
byte x
diff --git a/src/algebra/exposed.lsp.pamphlet b/src/algebra/exposed.lsp.pamphlet
index 8f50526d..e19ec96c 100644
--- a/src/algebra/exposed.lsp.pamphlet
+++ b/src/algebra/exposed.lsp.pamphlet
@@ -200,6 +200,7 @@
(|InfiniteTupleFunctions2| . ITFUN2)
(|InfiniteTupleFunctions3| . ITFUN3)
(|Infinity| . INFINITY)
+ (|InputBinaryFile| . INBFILE)
(|Integer| . INT)
(|IntegerCombinatoricFunctions| . COMBINAT)
(|IntegerLinearDependence| . ZLINDEP)
@@ -291,6 +292,7 @@
(|OrdinaryDifferentialRing| . ODR)
(|OrdSetInts| . OSI)
(|OrthogonalPolynomialFunctions| . ORTHPOL)
+ (|OutputBinaryFile| . OUTBFILE)
(|OutputPackage| . OUT)
(|PadeApproximantPackage| . PADEPAC)
(|Pair| . PAIR)
diff --git a/src/algebra/files.spad.pamphlet b/src/algebra/files.spad.pamphlet
index f331e958..34cd7937 100644
--- a/src/algebra/files.spad.pamphlet
+++ b/src/algebra/files.spad.pamphlet
@@ -1,15 +1,51 @@
\documentclass{article}
\usepackage{axiom}
\begin{document}
-\title{\$SPAD/src/algebra files.spad}
-\author{Stephen M. Watt, Victor Miller, Barry Trager}
+
+\title{src/algebra files.spad}
+\author{Stephen M. Watt, Victor Miller, Barry Trager, Gabriel Dos~Reis}
+
\maketitle
\begin{abstract}
\end{abstract}
-\eject
\tableofcontents
\eject
+
+
+\section{A domain for IO mode}
+
+<<domain IOMODE IOMode>>=
+)abbrev domain IOMODE IOMode
+++ Author: Gabriel Dos Reis
+++ Date Created: September 30, 2008
+++ Date Last Updated: September 30, 2008
+++ Basic Operations: inputIOMode, outputIoMode, bothWayIOMode
+++ Description:
+++ This domain provides constants to describe directions of
+++ IO conduits (file, etc) mode of operations.
+IOMode(): Public == Private where
+ Public == SetCategory with
+ input: %
+ ++ `input' indicates that an IO conduit is for input.
+ output: %
+ ++ `output' indicates that an IO conduit is for output
+ bothWays: %
+ ++ `bothWays' indicates that an IO conduit is for both input and output.
+ Private == add
+ input == _$InputIOMode$Lisp
+ output == _$OutputIOMode$Lisp
+ bothWays == _$BothWaysIOode$Lisp
+ x = y == EQ(x,y)$Lisp
+ coerce m ==
+ m = input => outputForm 'input
+ m = output => outputForm 'output
+ outputForm 'bothWays
+
+@
+
+
\section{category FILECAT FileCategory}
+
<<category FILECAT FileCategory>>=
)abbrev category FILECAT FileCategory
++ Author: Stephen M. Watt, Victor Miller
@@ -548,6 +584,8 @@ Library(): TableAggregate(String, Any) with
<<*>>=
<<license>>
+<<domain IOMODE IOMode>>
+
<<category FILECAT FileCategory>>
<<domain FILE File>>
<<domain TEXTFILE TextFile>>
diff --git a/src/algebra/net.spad.pamphlet b/src/algebra/net.spad.pamphlet
index 4a8d4961..ef5f7cec 100644
--- a/src/algebra/net.spad.pamphlet
+++ b/src/algebra/net.spad.pamphlet
@@ -106,6 +106,94 @@ InputOutputByteConduit(): Category ==
@
+
+\subsection{The InputBinaryFile domain}
+
+<<domain INBFILE InputBinaryFile>>=
+)abbrev domain INBFILE InputBinaryFile
+++ Author: Gabriel Dos Reis
+++ Date Created: September 30, 2008
+++ Date Last Modified: September 30, 2008
+++ Description:
+++ This domain provides representation for binary files open
+++ for input operations. `Binary' here means that the conduits
+++ do not interpret their contents.
+InputBinaryFile(): Public == Private where
+ Public == Join(InputByteConduit, CoercibleTo OutputForm) with
+ inputBinaryFile: FileName -> %
+ ++ inputBinaryFile(f) returns an input conduit obtained by
+ ++ opening the file named by `f' as a binary file.
+ inputBinaryFile: String -> %
+ ++ inputBinaryFile(f) returns an input conduit obtained by
+ ++ opening the file named by `f' as a binary file.
+ eof?: % -> Boolean
+ ++ eof?(ifile) holds when end-of-file has been reached
+ ++ for the conduit file `ifile'.
+ isOpen?: % -> Boolean
+ ++ open?(ifile) holds if `ifile' is in open state.
+ Private == add
+ Rep == Record(stream: SExpression, filename: FileName)
+ inputBinaryFile(f: FileName) ==
+ per [openBinaryFile(f::String,input$IOMode)$Lisp,f]
+ inputBinaryFile(f: String) ==
+ per [openBinaryFile(f,input$IOMode)$Lisp,f::FileName]
+ isOpen? ifile ==
+ not null? rep(ifile).stream
+ readByteIfCan! ifile ==
+ isOpen? ifile => readByteFromFile(rep(ifile).stream)$Lisp
+ error "file is not open"
+ eof? ifile ==
+ isOpen? ifile => readByteIfCan! ifile < 0@SingleInteger
+ error "file is not open"
+ close! ifile ==
+ if isOpen? ifile then
+ rep(ifile).stream := closeFile(rep(ifile).stream)$Lisp
+ ifile
+ coerce(ifile: %): OutputForm ==
+ rep(ifile).filename::OutputForm
+@
+
+\subsection{The OutputBinaryFile domain}
+
+<<domain OUTBFILE OutputBinaryFile>>=
+)abbrev domain OUTBFILE OutputBinaryFile
+++ Author: Gabriel Dos Reis
+++ Date Created: September 30, 2008
+++ Date Last Modified: September 30, 2008
+++ Description:
+++ This domain provides representation for binary files open
+++ for output operations. `Binary' here means that the conduits
+++ do not interpret their contents.
+OutputBinaryFile(): Public == Private where
+ Public == Join(OutputByteConduit, CoercibleTo OutputForm) with
+ outputBinaryFile: FileName -> %
+ ++ outputBinaryFile(f) returns an output conduit obtained by
+ ++ opening the file named by `f' as a binary file.
+ outputBinaryFile: String -> %
+ ++ outputBinaryFile(f) returns an output conduit obtained by
+ ++ opening the file named by `f' as a binary file.
+ isOpen?: % -> Boolean
+ ++ open?(ifile) holds if `ifile' is in open state.
+ Private == add
+ Rep == Record(stream: SExpression, filename: FileName)
+ outputBinaryFile(f: FileName) ==
+ per [openBinaryFile(f::String,output$IOMode)$Lisp,f]
+ outputBinaryFile(f: String) ==
+ per [openBinaryFile(f,output$IOMode)$Lisp,f::FileName]
+ isOpen? ifile ==
+ not null? rep(ifile).stream
+ writeByteIfCan!(ifile,b) ==
+ isOpen? ifile => writeByteToFile(rep(ifile).stream,b)$Lisp
+ error "file is not open"
+ close! ifile ==
+ if isOpen? ifile then
+ rep(ifile).stream := closeFile(rep(ifile).stream)$Lisp
+ ifile
+ coerce(ifile: %): OutputForm ==
+ rep(ifile).filename::OutputForm
+@
+
+
\section{The Hostname domain}
<<domain HOSTNAME Hostname>>=
@@ -195,6 +283,9 @@ PortNumber(): Public == Private where
<<category OUTBCON OutputByteConduit>>
<<category IOBCON InputOutputByteConduit>>
+<<domain INBFILE InputBinaryFile>>
+<<domain OUTBFILE OutputBinaryFile>>
+
<<domain HOSTNAME Hostname>>
<<domain PORTNUM PortNumber>>