... by setting up their reader or writer fields then, instead of
testing at each input or output operation whether the relevant field is null,
and filling it in if it is.
library/io.primitives_read.m:
library/io.primitives_write.m:
Delete the test-and-fill-if-needed code from the read and write operations.
library/io.stream_ops.m:
Initialize the reader and writer fields of each MR_MercuryFileStruct
as it is created an file open time.
Document when each field of the MR_MercuryFileStruct is meaningful.
Add an XXX about binary vs text files.
Add an XXX proposing a new arrangement of stream types.
library/io.m:
Add the predicates
read_named_file_as_string_wf
read_named_file_as_lines_wf
read_file_as_string_wf
read_file_as_string_and_num_code_units_wf
which extend their base predicates (without the _wf suffix) by checking
whether the string read from the file is well formed, and returning
an error if it is not.
library/io.stream_op.m:
Fix and expand a comment.
library/io.text_read.m:
Add a comment.
library/string.m:
Add check_well_formedness, a predicate that checks whether a string
is well formed, and (if relevant) specifies the offset of the first
non-well-formed character.
Make the documentation of index_next and index_next_repl more detailed.
runtime/mercury_string.[ch]:
Define MR_utf8_find_ill_formed_char, a version of MR_utf8_verify
that returns the offset of the first ill-formed UTF-8 char in the
given string, if there is one. This is used in the implementation of
check_well_formedness for C.
NEWS.md:
Announce the new library predicates.
Sort some lists of pred names.
... move the implementation of flush_*output to io.stream_ops.m.
In both cases, improve the predicate names a bit.
Add a distinguishing prefix to the names of the function symbols of a type,
to reduce the number of times the function symbol names ok, error and eof
are overloaded from ridiculous to slighly less ridiculous :-(
Move related predicate arguments next to each other.
library/io.text_read.m:
New submodule containing the code that implement the predicates
that read values of non-primitive types, all but one of which are text.
library/io.stream_ops.m:
Move the implementation of flushing output here from io.m.
library/io.m:
Delete the code moved to the above modules.
library/MODULES_UNDOC:
library/library.m:
List the new submodule as undocumented.
library/Mercury.options:
Allow io.text_read.m, instead of io.m, to define an inst for a type
that has a definition in a foreign language as well as Mercury.
This diff moves this inst definition to io.text_read.m.
Also, move foreign code pieces still in io.m that belong in
previously-carved-out modules to those modules.
library/io.m:
library/io.stream_ops.m:
As above. The new private submodule contains the implementations
(helper predicates) of the operations that
- open and close streams,
- get and set offsets in those streams,
- get and set line numbers on streams,
- return the standard streams, and
- set streams as the current streams.
library/io.m:
Make some previously private includes public, to allow modules outside
of io.m to refer to the C# and Java symbols they define. These includes
are in the second, undocumented interface section of io.m.
Delete the foreign code moved to io.primitives_{read,write}.m,
as well as the foreign code moved to io.stream_ops.m.
Change {get,set}_{line_number,output_line_number}/3, which used
to be implemented directly using foreign_procs, to implement them
in terms of their arity-4 counterparts which take an explicit stream
argument, which now are in io.stream_ops.m. This can yield a slowdown,
but it should be so small as to be unmeasurable on all non-microbenchmark
workloads.
Move related code together.
Update module qualifications in C# and Java code.
Delete the second #include of mercury_library_types.h.
Delete the MR_{initial,final}_io_state macros.
library/MODULES_UNDOC:
library/library.m:
List the new submodule as undocumented.
library/io.primitives_read.m:
library/io.primitives_write.m:
Move the C, C# and Java code related to reading and writing values
of primitive types here from io.m. Put them into one foreign_decl
and one foreign_code per language.
Update module qualifications in C# and Java code.
library/benchmarking.m:
library/bitmap.m:
library/io.call_system.m:
Update module qualifications in C# and Java code.
library/stm_builtin.m:
Replace uses of the MR_{initial,final}_io_state macros with their bodies.