From 103b2d845a96451055d6795eaede7e4070977731 Mon Sep 17 00:00:00 2001 From: dos-reis Date: Wed, 22 Oct 2008 14:05:05 +0000 Subject: * algebra/net.spad.pamphlet (InputOutputBinaryFile): New. (position$InputBinaryFile): New. (position!$InputBinaryFile): Likewise. * algebra/exposed.lsp.pamphlet: Expose InputOutputBinaryFile. * algebra/Makefile.pamphlet (axiom_algebra_layer_user): Add IOBFILE. --- src/algebra/Makefile.in | 6 +++++- src/algebra/Makefile.pamphlet | 6 +++++- src/algebra/exposed.lsp.pamphlet | 1 + src/algebra/net.spad.pamphlet | 43 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 54 insertions(+), 2 deletions(-) (limited to 'src/algebra') diff --git a/src/algebra/Makefile.in b/src/algebra/Makefile.in index f3521c0a..2bf2dc80 100644 --- a/src/algebra/Makefile.in +++ b/src/algebra/Makefile.in @@ -826,7 +826,8 @@ axiom_algebra_layer_user = \ LETAST SUCHAST RDUCEAST COLONAST ADDAST CAPSLAST \ CASEAST HASAST ISAST CATAST WHEREAST COMMAAST \ QQUTAST DEFAST MACROAST SPADXPT SPADAST \ - INBFILE OUTBFILE RGBCMDL RGBCSPC CTORKIND CTOR + INBFILE OUTBFILE IOBFILE RGBCMDL RGBCSPC CTORKIND \ + CTOR axiom_algebra_layer_user_nrlibs = \ $(addsuffix .NRLIB/code.$(FASLEXT),$(axiom_algebra_layer_user)) @@ -881,10 +882,13 @@ 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) +IOBFILE.NRLIB/code.$(FASLEXT): $(OUT)/INBFILE.$(FASLEXT) \ + $(OUT)/OUTBFILE.$(FASLEXT) CTOR.NRLIB/code.$(FASLEXT): $(OUT)/CTORKIND.$(FASLEXT) \ $(OUT)/IDENT.$(FASLEXT) diff --git a/src/algebra/Makefile.pamphlet b/src/algebra/Makefile.pamphlet index 609786e6..16cb9d93 100644 --- a/src/algebra/Makefile.pamphlet +++ b/src/algebra/Makefile.pamphlet @@ -1253,7 +1253,8 @@ axiom_algebra_layer_user = \ LETAST SUCHAST RDUCEAST COLONAST ADDAST CAPSLAST \ CASEAST HASAST ISAST CATAST WHEREAST COMMAAST \ QQUTAST DEFAST MACROAST SPADXPT SPADAST \ - INBFILE OUTBFILE RGBCMDL RGBCSPC CTORKIND CTOR + INBFILE OUTBFILE IOBFILE RGBCMDL RGBCSPC CTORKIND \ + CTOR axiom_algebra_layer_user_nrlibs = \ $(addsuffix .NRLIB/code.$(FASLEXT),$(axiom_algebra_layer_user)) @@ -1308,10 +1309,13 @@ 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) +IOBFILE.NRLIB/code.$(FASLEXT): $(OUT)/INBFILE.$(FASLEXT) \ + $(OUT)/OUTBFILE.$(FASLEXT) CTOR.NRLIB/code.$(FASLEXT): $(OUT)/CTORKIND.$(FASLEXT) \ $(OUT)/IDENT.$(FASLEXT) diff --git a/src/algebra/exposed.lsp.pamphlet b/src/algebra/exposed.lsp.pamphlet index 18e6384f..9d54ae9c 100644 --- a/src/algebra/exposed.lsp.pamphlet +++ b/src/algebra/exposed.lsp.pamphlet @@ -201,6 +201,7 @@ (|InfiniteTupleFunctions3| . ITFUN3) (|Infinity| . INFINITY) (|InputBinaryFile| . INBFILE) + (|InputOutputBinaryFile| . IOBFILE) (|Integer| . INT) (|IntegerCombinatoricFunctions| . COMBINAT) (|IntegerLinearDependence| . ZLINDEP) diff --git a/src/algebra/net.spad.pamphlet b/src/algebra/net.spad.pamphlet index c44130e2..ba8bfdc7 100644 --- a/src/algebra/net.spad.pamphlet +++ b/src/algebra/net.spad.pamphlet @@ -130,6 +130,10 @@ InputBinaryFile(): Public == Private where ++ eof?(ifile) holds when the last read reached end of file. isOpen?: % -> Boolean ++ open?(ifile) holds if `ifile' is in open state. + position: % -> SingleInteger + ++ position(f) returns the current byte-position in the file `f'. + position!: (%,SingleInteger) -> SingleInteger + ++ position(f,p) sets the current byte-position to `i'. Private == add Rep == Record(stream: SExpression, filename: FileName, eof: Boolean) inputBinaryFile(f: FileName) == @@ -153,6 +157,15 @@ InputBinaryFile(): Public == Private where rep(ifile).stream := closeFile(rep(ifile).stream)$Lisp rep(ifile).eof := true ifile + position ifile == + isOpen? ifile => + FILE_-POSITION(rep(ifile).stream)$Lisp + error "file is not open" + position!(ifile,p) == + isOpen? ifile => + FILE_-POSITION(rep(ifile).stream,p)$Lisp + p + error "file is not open" coerce(ifile: %): OutputForm == rep(ifile).filename::OutputForm @ @@ -197,6 +210,35 @@ OutputBinaryFile(): Public == Private where rep(ifile).filename::OutputForm @ +\subsection{The InputOutputBinaryFile domain} + +<>= +)abbrev domain IOBFILE InputOutputBinaryFile +++ Author: Gabriel Dos Reis +++ Date Created: October 21, 2008 +++ Date Last Modified: October 21, 2008 +++ Description: +++ This domain provides representation for binary files open +++ for input and output operations. +++ See Also: InputBinaryFile, OutputBinaryFile +InputOutputBinaryFile(): Public == Private where + Public == Join(InputOutputByteConduit, CoercibleTo OutputForm) with + inputOutputBinaryFile: FileName -> % + ++ inputOutputBinaryFile(f) returns an input/output conduit obtained + ++ by opening the file designated by `f' as a binary file. + inputOutputBinaryFile: String -> % + ++ inputOutputBinaryFile(f) returns an input/output conduit obtained + ++ by opening the file named by `f' as a binary file. + isOpen?: % -> Boolean + ++ isOpen?(f) holds if `f' is in open state. + Private == (InputBinaryFile, OutputBinaryFile) add + Rep == Record(stream: SExpression, filename: FileName) + inputOutputBinaryFile(f: FileName) == + per [openBinaryFile(f::String,bothWays$IOMode)$Lisp,f] + inputOutputBinaryFile(f: String) == + per [openBinaryFile(f,bothWays$IOMode)$Lisp,f::FileName] +@ + \section{The Hostname domain} @@ -289,6 +331,7 @@ PortNumber(): Public == Private where <> <> +<> <> <> -- cgit v1.2.3