Ignore:
Timestamp:
Mar 4, 2021, 7:40:25 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
77d601f
Parents:
342af53 (diff), a5040fe (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/iostream.hfa

    r342af53 r8e4aa05  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Aug 11 22:16:14 2020
    13 // Update Count     : 350
     12// Last Modified On : Tue Mar  2 14:05:08 2021
     13// Update Count     : 369
    1414//
    1515
     
    2222
    2323
    24 trait ostream( dtype ostype ) {
     24trait ostream( ostype & ) {
    2525        // private
    2626        bool $sepPrt( ostype & );                                                       // get separator state (on/off)
     
    5454        ostype & write( ostype &, const char [], size_t );
    5555        int fmt( ostype &, const char format[], ... ) __attribute__(( format(printf, 2, 3) ));
     56        void acquire( ostype & );
    5657}; // ostream
    5758
    58 // trait writeable( otype T ) {
    59 //      forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, T );
     59// trait writeable( T ) {
     60//      forall( ostype & | ostream( ostype ) ) ostype & ?|?( ostype &, T );
    6061// }; // writeable
    6162
    62 trait writeable( otype T, dtype ostype | ostream( ostype ) ) {
     63trait writeable( T, ostype & | ostream( ostype ) ) {
    6364        ostype & ?|?( ostype &, T );
    6465}; // writeable
     
    6667// implement writable for intrinsic types
    6768
    68 forall( dtype ostype | ostream( ostype ) ) {
     69forall( ostype & | ostream( ostype ) ) {
    6970        ostype & ?|?( ostype &, bool );
    7071        void ?|?( ostype &, bool );
     
    137138        ostype & nlOn( ostype & );
    138139        ostype & nlOff( ostype & );
     140        ostype & acquire( ostype & );
    139141} // distribution
    140142
    141143// tuples
    142 forall( dtype ostype, otype T, ttype Params | writeable( T, ostype ) | { ostype & ?|?( ostype &, Params ); } ) {
     144forall( ostype &, T, Params... | writeable( T, ostype ) | { ostype & ?|?( ostype &, Params ); } ) {
    143145        ostype & ?|?( ostype & os, T arg, Params rest );
    144146        void ?|?( ostype & os, T arg, Params rest );
     
    146148
    147149// writes the range [begin, end) to the given stream
    148 forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) ) {
     150forall( ostype &, elt_type | writeable( elt_type, ostype ), iterator_type | iterator( iterator_type, elt_type ) ) {
    149151        void write( iterator_type begin, iterator_type end, ostype & os );
    150152        void write_reverse( iterator_type begin, iterator_type end, ostype & os );
     
    153155// *********************************** manipulators ***********************************
    154156
    155 forall( otype T )
     157forall( T )
    156158struct _Ostream_Manip {
    157159        T val;                                                                                          // polymorphic base-type
     
    193195        _Ostream_Manip(T) & sign( _Ostream_Manip(T) & fmt ) { fmt.flags.sign = true; return fmt; } \
    194196} /* distribution */ \
    195 forall( dtype ostype | ostream( ostype ) ) { \
     197forall( ostype & | ostream( ostype ) ) { \
    196198        ostype & ?|?( ostype & os, _Ostream_Manip(T) f ); \
    197199        void ?|?( ostype & os, _Ostream_Manip(T) f ); \
     
    234236        _Ostream_Manip(T) & nodp( _Ostream_Manip(T) & fmt ) { fmt.flags.nobsdp = true; return fmt; } \
    235237} /* distribution */ \
    236 forall( dtype ostype | ostream( ostype ) ) { \
     238forall( ostype & | ostream( ostype ) ) { \
    237239        ostype & ?|?( ostype & os, _Ostream_Manip(T) f ); \
    238240        void ?|?( ostype & os, _Ostream_Manip(T) f ); \
     
    254256        _Ostream_Manip(char) & nobase( _Ostream_Manip(char) & fmt ) { fmt.flags.nobsdp = true; return fmt; }
    255257} // distribution
    256 forall( dtype ostype | ostream( ostype ) ) {
     258forall( ostype & | ostream( ostype ) ) {
    257259        ostype & ?|?( ostype & os, _Ostream_Manip(char) f );
    258260        void ?|?( ostype & os, _Ostream_Manip(char) f );
     
    272274        _Ostream_Manip(const char *) & nobase( _Ostream_Manip(const char *) & fmt ) { fmt.flags.nobsdp = true; return fmt; }
    273275} // distribution
    274 forall( dtype ostype | ostream( ostype ) ) {
     276forall( ostype & | ostream( ostype ) ) {
    275277        ostype & ?|?( ostype & os, _Ostream_Manip(const char *) f );
    276278        void ?|?( ostype & os, _Ostream_Manip(const char *) f );
     
    281283
    282284
    283 trait istream( dtype istype ) {
     285trait istream( istype & ) {
    284286        void nlOn( istype & );                                                          // read newline
    285287        void nlOff( istype & );                                                         // scan newline
    286288        bool getANL( istype & );                                                        // get scan newline (on/off)
     289
     290        void ends( istype & os );                                                       // end of output statement
    287291        int fail( istype & );
    288292        int eof( istype & );
     
    292296        istype & ungetc( istype &, char );
    293297        int fmt( istype &, const char format[], ... ) __attribute__(( format(scanf, 2, 3) ));
     298        void acquire( istype & );
    294299}; // istream
    295300
    296 trait readable( otype T ) {
    297         forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, T );
     301trait readable( T ) {
     302        forall( istype & | istream( istype ) ) istype & ?|?( istype &, T );
    298303}; // readable
    299304
    300 forall( dtype istype | istream( istype ) ) {
     305forall( istype & | istream( istype ) ) {
    301306        istype & ?|?( istype &, bool & );
     307        void ?|?( istype &, bool & );
    302308
    303309        istype & ?|?( istype &, char & );
     310        void ?|?( istype &, char & );
    304311        istype & ?|?( istype &, signed char & );
     312        void ?|?( istype &, signed char & );
    305313        istype & ?|?( istype &, unsigned char & );
     314        void ?|?( istype &, unsigned char & );
    306315
    307316        istype & ?|?( istype &, short int & );
     317        void ?|?( istype &, short int & );
    308318        istype & ?|?( istype &, unsigned short int & );
     319        void ?|?( istype &, unsigned short int & );
    309320        istype & ?|?( istype &, int & );
     321        void ?|?( istype &, int & );
    310322        istype & ?|?( istype &, unsigned int & );
     323        void ?|?( istype &, unsigned int & );
    311324        istype & ?|?( istype &, long int & );
     325        void ?|?( istype &, long int & );
    312326        istype & ?|?( istype &, unsigned long int & );
     327        void ?|?( istype &, unsigned long int & );
    313328        istype & ?|?( istype &, long long int & );
     329        void ?|?( istype &, long long int & );
    314330        istype & ?|?( istype &, unsigned long long int & );
     331        void ?|?( istype &, unsigned long long int & );
    315332#if defined( __SIZEOF_INT128__ )
    316333        istype & ?|?( istype &, int128 & );
     334        void ?|?( istype &, int128 & );
    317335        istype & ?|?( istype &, unsigned int128 & );
     336        void ?|?( istype &, unsigned int128 & );
    318337#endif // __SIZEOF_INT128__
    319338
    320339        istype & ?|?( istype &, float & );
     340        void ?|?( istype &, float & );
    321341        istype & ?|?( istype &, double & );
     342        void ?|?( istype &, double & );
    322343        istype & ?|?( istype &, long double & );
     344        void ?|?( istype &, long double & );
    323345
    324346        istype & ?|?( istype &, float _Complex & );
     347        void ?|?( istype &, float _Complex & );
    325348        istype & ?|?( istype &, double _Complex & );
     349        void ?|?( istype &, double _Complex & );
    326350        istype & ?|?( istype &, long double _Complex & );
     351        void ?|?( istype &, long double _Complex & );
    327352
    328353//      istype & ?|?( istype &, const char [] );
    329         istype & ?|?( istype &, char * );
     354        istype & ?|?( istype &, char [] );
     355        void ?|?( istype &, char [] );
    330356
    331357        // manipulators
    332358        istype & ?|?( istype &, istype & (*)( istype & ) );
     359        void ?|?( istype &, istype & (*)( istype & ) );
    333360        istype & nl( istype & is );
    334361        istype & nlOn( istype & );
    335362        istype & nlOff( istype & );
     363        istype & acquire( istype & );
    336364} // distribution
    337365
     
    363391        _Istream_Cstr & wdi( unsigned int w, _Istream_Cstr & fmt ) { fmt.wd = w; return fmt; }
    364392} // distribution
    365 forall( dtype istype | istream( istype ) ) istype & ?|?( istype & is, _Istream_Cstr f );
     393forall( istype & | istream( istype ) ) {
     394        istype & ?|?( istype & is, _Istream_Cstr f );
     395        void ?|?( istype & is, _Istream_Cstr f );
     396}
    366397
    367398struct _Istream_Char {
     
    373404        _Istream_Char & ignore( _Istream_Char & fmt ) { fmt.ignore = true; return fmt; }
    374405} // distribution
    375 forall( dtype istype | istream( istype ) ) istype & ?|?( istype & is, _Istream_Char f );
    376 
    377 forall( dtype T | sized( T ) )
     406forall( istype & | istream( istype ) ) {
     407        istype & ?|?( istype & is, _Istream_Char f );
     408        void ?|?( istype & is, _Istream_Char f );
     409}
     410
     411forall( T & | sized( T ) )
    378412struct _Istream_Manip {
    379413        T & val;                                                                                        // polymorphic base-type
     
    389423        _Istream_Manip(T) & wdi( unsigned int w, _Istream_Manip(T) & fmt ) { fmt.wd = w; return fmt; } \
    390424} /* distribution */ \
    391 forall( dtype istype | istream( istype ) ) { \
     425forall( istype & | istream( istype ) ) { \
    392426        istype & ?|?( istype & is, _Istream_Manip(T) f ); \
     427        void ?|?( istype & is, _Istream_Manip(T) f ); \
    393428} // ?|?
    394429
     
    418453#include <time_t.hfa>                                                                   // Duration (constructors) / Time (constructors)
    419454
    420 forall( dtype ostype | ostream( ostype ) ) {
     455forall( ostype & | ostream( ostype ) ) {
    421456        ostype & ?|?( ostype & os, Duration dur );
    422457        void ?|?( ostype & os, Duration dur );
Note: See TracChangeset for help on using the changeset viewer.