Ignore:
Timestamp:
Apr 28, 2021, 1:06:13 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:
b7fd2db6
Parents:
e9c0b4c (diff), c7015e6b (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

    re9c0b4c radaee12  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Apr 24 09:28:56 2021
    13 // Update Count     : 393
     12// Last Modified On : Tue Apr 27 17:59:21 2021
     13// Update Count     : 398
    1414//
    1515
     
    4949        void ends( ostype & );                                                          // end of output statement
    5050        int fmt( ostype &, const char format[], ... ) __attribute__(( format(printf, 2, 3) ));
    51         int flush( ostype & );
    5251}; // basic_ostream
    5352       
    5453trait ostream( ostype & | basic_ostream( ostype ) ) {
     54        int flush( ostype & );
    5555        bool fail( ostype & );                                                          // operation failed?
    5656        void open( ostype &, const char name[], const char mode[] );
     
    9797        ostype & ?|?( ostype &, unsigned long long int );
    9898        void ?|?( ostype &, unsigned long long int );
    99 #if defined( __SIZEOF_INT128__ )
     99        #if defined( __SIZEOF_INT128__ )
    100100        ostype & ?|?( ostype &, int128 );
    101101        void ?|?( ostype &, int128 );
    102102        ostype & ?|?( ostype &, unsigned int128 );
    103103        void ?|?( ostype &, unsigned int128 );
    104 #endif // __SIZEOF_INT128__
     104        #endif // __SIZEOF_INT128__
    105105
    106106        ostype & ?|?( ostype &, float );
     
    121121        void ?|?( ostype &, const char [] );
    122122        // ostype & ?|?( ostype &, const char16_t * );
    123 #if ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 ) // char32_t == wchar_t => ambiguous
     123        #if ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 ) // char32_t == wchar_t => ambiguous
    124124        // ostype & ?|?( ostype &, const char32_t * );
    125 #endif // ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 )
     125        #endif // ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 )
    126126        // ostype & ?|?( ostype &, const wchar_t * );
    127127        ostype & ?|?( ostype &, const void * );
     
    164164struct _Ostream_Manip {
    165165        T val;                                                                                          // polymorphic base-type
    166         int wd, pc;                                                                                     // width, precision
     166        int wd, pc;                                                                                     // width, precision: signed for computations
    167167        char base;                                                                                      // numeric base / floating-point style
    168168        union {
     
    192192        _Ostream_Manip(T) hex( T val ) { return (_Ostream_Manip(T))@{ val, 1, 0, 'x', { .all : 0 } }; } \
    193193        _Ostream_Manip(T) wd( unsigned int w, T val ) { return (_Ostream_Manip(T))@{ val, w, 0, CODE, { .all : 0 } }; } \
    194         _Ostream_Manip(T) wd( unsigned int w, unsigned char pc, T val ) { return (_Ostream_Manip(T))@{ val, w, pc, CODE, { .flags.pc : true } }; } \
     194        _Ostream_Manip(T) wd( unsigned int w, unsigned int pc, T val ) { return (_Ostream_Manip(T))@{ val, w, pc, CODE, { .flags.pc : true } }; } \
    195195        _Ostream_Manip(T) & wd( unsigned int w, _Ostream_Manip(T) & fmt ) { fmt.wd = w; return fmt; } \
    196         _Ostream_Manip(T) & wd( unsigned int w, unsigned char pc, _Ostream_Manip(T) & fmt ) { fmt.wd = w; fmt.pc = pc; fmt.flags.pc = true; return fmt; } \
     196        _Ostream_Manip(T) & wd( unsigned int w, unsigned int pc, _Ostream_Manip(T) & fmt ) { fmt.wd = w; fmt.pc = pc; fmt.flags.pc = true; return fmt; } \
    197197        _Ostream_Manip(T) & left( _Ostream_Manip(T) & fmt ) { fmt.flags.left = true; return fmt; } \
    198198        _Ostream_Manip(T) & upcase( _Ostream_Manip(T) & fmt ) { if ( fmt.base == 'x' || fmt.base == 'b' ) fmt.base -= 32; /* upper case */ return fmt; } \
     
    231231        _Ostream_Manip(T) eng( T val ) { return (_Ostream_Manip(T))@{ val, 1, 0, 'g', { .flags.eng : true } }; } \
    232232        _Ostream_Manip(T) wd( unsigned int w, T val ) { return (_Ostream_Manip(T))@{ val, w, 0, 'g', { .all : 0 } }; } \
    233         _Ostream_Manip(T) wd( unsigned int w, unsigned char pc, T val ) { return (_Ostream_Manip(T))@{ val, w, pc, 'f', { .flags.pc : true } }; } \
    234         _Ostream_Manip(T) ws( unsigned int w, unsigned char pc, T val ) { return (_Ostream_Manip(T))@{ val, w, pc, 'g', { .flags.pc : true } }; } \
     233        _Ostream_Manip(T) wd( unsigned int w, unsigned int pc, T val ) { return (_Ostream_Manip(T))@{ val, w, pc, 'f', { .flags.pc : true } }; } \
     234        _Ostream_Manip(T) ws( unsigned int w, unsigned int pc, T val ) { return (_Ostream_Manip(T))@{ val, w, pc, 'g', { .flags.pc : true } }; } \
    235235        _Ostream_Manip(T) & wd( unsigned int w, _Ostream_Manip(T) & fmt ) { if ( fmt.flags.eng ) fmt.base = 'f'; fmt.wd = w; return fmt; } \
    236         _Ostream_Manip(T) & wd( unsigned int w, unsigned char pc, _Ostream_Manip(T) & fmt ) { if ( fmt.flags.eng ) fmt.base = 'f'; fmt.wd = w; fmt.pc = pc; fmt.flags.pc = true; return fmt; } \
    237         _Ostream_Manip(T) & ws( unsigned int w, unsigned char pc, _Ostream_Manip(T) & fmt ) { fmt.wd = w; fmt.pc = pc; fmt.flags.pc = true; return fmt; } \
     236        _Ostream_Manip(T) & wd( unsigned int w, unsigned int pc, _Ostream_Manip(T) & fmt ) { if ( fmt.flags.eng ) fmt.base = 'f'; fmt.wd = w; fmt.pc = pc; fmt.flags.pc = true; return fmt; } \
     237        _Ostream_Manip(T) & ws( unsigned int w, unsigned int pc, _Ostream_Manip(T) & fmt ) { fmt.wd = w; fmt.pc = pc; fmt.flags.pc = true; return fmt; } \
    238238        _Ostream_Manip(T) & left( _Ostream_Manip(T) & fmt ) { fmt.flags.left = true; return fmt; } \
    239239        _Ostream_Manip(T) upcase( T val ) { return (_Ostream_Manip(T))@{ val, 1, 0, 'G', { .all : 0 } }; } \
     
    279279        _Ostream_Manip(const char *) hex( const char s[] ) { return (_Ostream_Manip(const char *))@{ s, 1, 0, 'x', { .all : 0 } }; }
    280280        _Ostream_Manip(const char *) wd( unsigned int w, const char s[] ) { return (_Ostream_Manip(const char *))@{ s, w, 0, 's', { .all : 0 } }; }
    281         _Ostream_Manip(const char *) wd( unsigned int w, unsigned char pc, const char s[] ) { return (_Ostream_Manip(const char *))@{ s, w, pc, 's', { .flags.pc : true } }; }
     281        _Ostream_Manip(const char *) wd( unsigned int w, unsigned int pc, const char s[] ) { return (_Ostream_Manip(const char *))@{ s, w, pc, 's', { .flags.pc : true } }; }
    282282        _Ostream_Manip(const char *) & wd( unsigned int w, _Ostream_Manip(const char *) & fmt ) { fmt.wd = w; return fmt; }
    283         _Ostream_Manip(const char *) & wd( unsigned int w, unsigned char pc, _Ostream_Manip(const char *) & fmt ) { fmt.wd = w; fmt.pc = pc; fmt.flags.pc = true; return fmt; }
     283        _Ostream_Manip(const char *) & wd( unsigned int w, unsigned int pc, _Ostream_Manip(const char *) & fmt ) { fmt.wd = w; fmt.pc = pc; fmt.flags.pc = true; return fmt; }
    284284        _Ostream_Manip(const char *) & left( _Ostream_Manip(const char *) & fmt ) { fmt.flags.left = true; return fmt; }
    285285        _Ostream_Manip(const char *) & nobase( _Ostream_Manip(const char *) & fmt ) { fmt.flags.nobsdp = true; return fmt; }
     
    294294
    295295
    296 trait istream( istype & ) {
     296trait basic_istream( istype & ) {
     297        bool getANL( istype & );                                                        // get scan newline (on/off)
    297298        void nlOn( istype & );                                                          // read newline
    298299        void nlOff( istype & );                                                         // scan newline
    299         bool getANL( istype & );                                                        // get scan newline (on/off)
    300300
    301301        void ends( istype & os );                                                       // end of output statement
     302        int fmt( istype &, const char format[], ... ) __attribute__(( format(scanf, 2, 3) ));
     303        istype & ungetc( istype &, char );
     304        int eof( istype & );
     305}; // basic_istream
     306
     307trait istream( istype & | basic_istream( istype ) ) {
    302308        bool fail( istype & );
    303         int eof( istype & );
    304309        void open( istype & is, const char name[] );
    305310        void close( istype & is );
    306311        istype & read( istype &, char *, size_t );
    307         istype & ungetc( istype &, char );
    308         int fmt( istype &, const char format[], ... ) __attribute__(( format(scanf, 2, 3) ));
    309         void acquire( istype & );
     312        void acquire( istype & );                                                       // concurrent access
    310313}; // istream
    311314
     
    314317}; // readable
    315318
    316 forall( istype & | istream( istype ) ) {
     319forall( istype & | basic_istream( istype ) ) {
    317320        istype & ?|?( istype &, bool & );
    318321        void ?|?( istype &, bool & );
     
    341344        istype & ?|?( istype &, unsigned long long int & );
    342345        void ?|?( istype &, unsigned long long int & );
    343 #if defined( __SIZEOF_INT128__ )
     346        #if defined( __SIZEOF_INT128__ )
    344347        istype & ?|?( istype &, int128 & );
    345348        void ?|?( istype &, int128 & );
    346349        istype & ?|?( istype &, unsigned int128 & );
    347350        void ?|?( istype &, unsigned int128 & );
    348 #endif // __SIZEOF_INT128__
     351        #endif // __SIZEOF_INT128__
    349352
    350353        istype & ?|?( istype &, float & );
     
    372375        istype & nlOn( istype & );
    373376        istype & nlOff( istype & );
     377} // distribution
     378
     379forall( istype & | istream( istype ) ) {
    374380        istype & acquire( istype & );
    375381} // distribution
     
    391397
    392398static inline {
     399        _Istream_Cstr skip( const char scanset[] ) { return (_Istream_Cstr){ 0p, scanset, -1, { .all : 0 } }; }
    393400        _Istream_Cstr skip( unsigned int n ) { return (_Istream_Cstr){ 0p, 0p, n, { .all : 0 } }; }
    394         _Istream_Cstr skip( const char scanset[] ) { return (_Istream_Cstr){ 0p, scanset, -1, { .all : 0 } }; }
    395401        _Istream_Cstr incl( const char scanset[], char * s ) { return (_Istream_Cstr){ s, scanset, -1, { .flags.inex : false } }; }
    396402        _Istream_Cstr & incl( const char scanset[], _Istream_Cstr & fmt ) { fmt.scanset = scanset; fmt.flags.inex = false; return fmt; }
     
    402408        _Istream_Cstr & wdi( unsigned int w, _Istream_Cstr & fmt ) { fmt.wd = w; return fmt; }
    403409} // distribution
    404 forall( istype & | istream( istype ) ) {
     410forall( istype & | basic_istream( istype ) ) {
    405411        istype & ?|?( istype & is, _Istream_Cstr f );
    406412        void ?|?( istype & is, _Istream_Cstr f );
     
    415421        _Istream_Char & ignore( _Istream_Char & fmt ) { fmt.ignore = true; return fmt; }
    416422} // distribution
    417 forall( istype & | istream( istype ) ) {
     423forall( istype & | basic_istream( istype ) ) {
    418424        istype & ?|?( istype & is, _Istream_Char f );
    419425        void ?|?( istype & is, _Istream_Char f );
     
    434440        _Istream_Manip(T) & wdi( unsigned int w, _Istream_Manip(T) & fmt ) { fmt.wd = w; return fmt; } \
    435441} /* distribution */ \
    436 forall( istype & | istream( istype ) ) { \
     442forall( istype & | basic_istream( istype ) ) { \
    437443        istype & ?|?( istype & is, _Istream_Manip(T) f ); \
    438444        void ?|?( istype & is, _Istream_Manip(T) f ); \
Note: See TracChangeset for help on using the changeset viewer.