[m-rev.] diff: add binary stream reader instances for int8 and uint8

Julien Fischer jfischer at opturion.com
Wed Oct 3 11:19:54 AEST 2018


Add binary stream reader instances for int8 and uint8.

library/io.m:
     As above.

Julien.

diff --git a/library/io.m b/library/io.m
index c85fb3d..20af25a 100644
--- a/library/io.m
+++ b/library/io.m
@@ -1748,6 +1748,8 @@
  :- instance stream.stream(binary_input_stream,  io).
  :- instance stream.input(binary_input_stream, io).
  :- instance stream.reader(binary_input_stream, int, io, io.error).
+:- instance stream.reader(binary_input_stream, int8, io, io.error).
+:- instance stream.reader(binary_input_stream, uint8, io, io.error).
  :- instance stream.bulk_reader(binary_input_stream, int,
          bitmap, io, io.error).
  :- instance stream.putback(binary_input_stream, int, io, io.error).
@@ -12599,6 +12601,24 @@ result_to_stream_result(error(Error)) = error(Error).
      )
  ].

+:- instance stream.reader(binary_input_stream, int8, io, io.error)
+    where
+[
+    ( get(Stream, Result, !IO) :-
+        read_binary_int8(Stream, Result0, !IO),
+        Result = result_to_stream_result(Result0)
+    )
+].
+
+:- instance stream.reader(binary_input_stream, uint8, io, io.error)
+    where
+[
+    ( get(Stream, Result, !IO) :-
+        read_binary_uint8(Stream, Result0, !IO),
+        Result = result_to_stream_result(Result0)
+    )
+].
+
  :- instance stream.bulk_reader(binary_input_stream, int,
          bitmap, io, io.error)
      where


More information about the reviews mailing list