xfail scan-tree-dump-not throw in g++.dg/pr99966.C on hppa*64*-*-*
[official-gcc.git] / gcc / m2 / gm2-libs-iso / RTgenif.mod
blob034a3e901c7a48241538402f5f1689f4504de165
1 (* RTgenif.mod implement a generic device interface mechanism used by RTgen.
3 Copyright (C) 2008-2024 Free Software Foundation, Inc.
4 Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
6 This file is part of GNU Modula-2.
8 GNU Modula-2 is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
11 any later version.
13 GNU Modula-2 is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 Under Section 7 of GPL version 3, you are granted additional
19 permissions described in the GCC Runtime Library Exception, version
20 3.1, as published by the Free Software Foundation.
22 You should have received a copy of the GNU General Public License and
23 a copy of the GCC Runtime Library Exception along with this program;
24 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25 <http://www.gnu.org/licenses/>. *)
27 IMPLEMENTATION MODULE RTgenif ;
29 FROM Storage IMPORT ALLOCATE, DEALLOCATE ;
31 TYPE
32 GenDevIF = POINTER TO RECORD
33 did : DeviceId ;
34 dorc : readchar ;
35 dourc : unreadchar ;
36 dogeterrno: geterrno ;
37 dorbytes : readbytes ;
38 dowbytes : writebytes ;
39 dowrln : writeln;
40 doeof : iseof ;
41 doeoln : iseoln ;
42 doerror : iserror ;
43 END ;
47 InitGenDev - initializes a generic device.
50 PROCEDURE InitGenDevIF (d : DeviceId;
51 rc : readchar;
52 urc : unreadchar;
53 geterr: geterrno;
54 rbytes: readbytes;
55 wbytes: writebytes;
56 wl : writeln;
57 eof : iseof;
58 eoln : iseoln;
59 iserr : iserror) : GenDevIF ;
60 VAR
61 g: GenDevIF ;
62 BEGIN
63 NEW(g) ;
64 WITH g^ DO
65 did := d ;
66 dorc := rc ;
67 dourc := urc ;
68 dogeterrno := geterr ;
69 dorbytes := rbytes ;
70 dowbytes := wbytes ;
71 dowrln := wl ;
72 doeof := eof ;
73 doeoln := eoln ;
74 doerror := iserr
75 END ;
76 RETURN( g )
77 END InitGenDevIF ;
81 getDID - returns the device id belonging to this generic interface.
84 PROCEDURE getDID (g: GenDevIF) : DeviceId ;
85 BEGIN
86 RETURN( g^.did )
87 END getDID ;
91 doReadChar - returns the next character from the generic device.
94 PROCEDURE doReadChar (g: GenDevIF; d: DeviceTablePtr) : CHAR ;
95 BEGIN
96 RETURN( g^.dorc(g, d) )
97 END doReadChar ;
101 doUnReadChar - pushes back a character to the generic device.
104 PROCEDURE doUnReadChar (g: GenDevIF; d: DeviceTablePtr; ch: CHAR) : CHAR ;
105 BEGIN
106 RETURN( g^.dourc(g, d, ch) )
107 END doUnReadChar ;
111 doGetErrno - returns the errno relating to the generic device.
114 PROCEDURE doGetErrno (g: GenDevIF; d: DeviceTablePtr) : INTEGER ;
115 BEGIN
116 RETURN( g^.dogeterrno(g, d) )
117 END doGetErrno ;
121 doRBytes - attempts to read, n, bytes from the generic device.
122 It set the actual amount read and returns a boolean
123 to determine whether an error occurred.
126 PROCEDURE doRBytes (g: GenDevIF; d: DeviceTablePtr;
127 to: ADDRESS; max: CARDINAL;
128 VAR actual: CARDINAL) : BOOLEAN ;
129 BEGIN
130 RETURN( g^.dorbytes(g, d, to, max, actual) )
131 END doRBytes ;
135 doWBytes - attempts to write, n, bytes to the generic device.
136 It sets the actual amount written and returns a
137 boolean to determine whether an error occurred.
140 PROCEDURE doWBytes (g: GenDevIF; d: DeviceTablePtr;
141 from: ADDRESS; max: CARDINAL;
142 VAR actual: CARDINAL) : BOOLEAN ;
143 BEGIN
144 RETURN( g^.dowbytes(g, d, from, max, actual) )
145 END doWBytes ;
149 doWrLn - writes an end of line marker and returns
150 TRUE if successful.
153 PROCEDURE doWrLn (g: GenDevIF; d: DeviceTablePtr) : BOOLEAN ;
154 BEGIN
155 RETURN( g^.dowrln(g, d) )
156 END doWrLn ;
160 isEOF - returns true if the end of file was reached.
163 PROCEDURE isEOF (g: GenDevIF; d: DeviceTablePtr) : BOOLEAN ;
164 BEGIN
165 RETURN( g^.doeof(g, d) )
166 END isEOF ;
170 isEOLN - returns true if the end of line was reached.
173 PROCEDURE isEOLN (g: GenDevIF; d: DeviceTablePtr) : BOOLEAN ;
174 BEGIN
175 RETURN( g^.doeoln(g, d) )
176 END isEOLN ;
180 isError - returns true if an error was seen in the device.
183 PROCEDURE isError (g: GenDevIF; d: DeviceTablePtr) : BOOLEAN ;
184 BEGIN
185 RETURN( g^.doerror(g, d) )
186 END isError ;
190 KillGenDevIF - deallocates a generic device.
193 PROCEDURE KillGenDevIF (g: GenDevIF) : GenDevIF ;
194 BEGIN
195 DISPOSE(g) ;
196 RETURN( NIL )
197 END KillGenDevIF ;
200 END RTgenif.