Commit Graph

6 Commits

Author SHA1 Message Date
Zoltan Somogyi
91782bd972 Put io.primitives_write.m into a logical order. 2023-04-27 17:34:03 +10:00
Zoltan Somogyi
79b65ff650 Fully initialize C# MR_MercuryFileStructs at open ...
... 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.
2023-04-24 11:43:50 +10:00
Julien Fischer
0a7365dd95 Add write_binary_utf8_string.
Add predicates for writing the UTF-8 encoding of strings to binary output
streams.

library/io.m:
library/io.primitives_write.m:
    Add the new predicates.

NEWS:
    Announce the additions.

tests/hard_coded/Mmakefile:
tests/hard_coded/write_binary_utf8.{m,exp}:
    Add a test of the new predicates.
2022-04-07 12:29:46 +10:00
Julien Fischer
6e9ce5e02f Address XXXs.
library/io.primitives_read.m:
library/io.primitives_write.m:
library/io.stream_ops.m:
     Delete unnecessary C# foreign_decl pragmas.
2022-04-03 17:36:27 +10:00
Zoltan Somogyi
05fd615471 Carve io.stream_ops.m out of io.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.
2022-03-14 15:20:22 +11:00
Zoltan Somogyi
f3d7165a3a Carve io.primitives_{read,write}.m out of io.m.
library/io.m:
library/io.primitives_read.m:
library/io.primitives_write.m:
    As above. The two new private submodules contain the implementations
    (helper predicates) of the operations that respectively read and write
    values of primitive types.

library/MODULES_UNDOC:
library/library.m:
    List the new submodules as undocumented.
2022-03-12 15:00:41 +11:00