Changeset 09687aa for src/libcfa
- Timestamp:
- Dec 7, 2017, 1:10:51 PM (6 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 5e1adb5
- Parents:
- 92494fd
- Location:
- src/libcfa
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/fstream
r92494fd r09687aa 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jul 7 08:32:38201713 // Update Count : 1 1712 // Last Modified On : Thu Dec 7 08:06:11 2017 13 // Update Count : 129 14 14 // 15 15 … … 30 30 31 31 // private 32 _Bool sepPrt( ofstream *);33 void sepReset( ofstream *);34 void sepReset( ofstream *, _Bool );35 const char * sepGetCur( ofstream *);36 void sepSetCur( ofstream *, const char * );37 _Bool getNL( ofstream *);38 void setNL( ofstream *, _Bool );32 _Bool sepPrt( ofstream & ); 33 void sepReset( ofstream & ); 34 void sepReset( ofstream &, _Bool ); 35 const char * sepGetCur( ofstream & ); 36 void sepSetCur( ofstream &, const char * ); 37 _Bool getNL( ofstream & ); 38 void setNL( ofstream &, _Bool ); 39 39 40 40 // public 41 void sepOn( ofstream *);42 void sepOff( ofstream *);43 _Bool sepDisable( ofstream *);44 _Bool sepEnable( ofstream *);41 void sepOn( ofstream & ); 42 void sepOff( ofstream & ); 43 _Bool sepDisable( ofstream & ); 44 _Bool sepEnable( ofstream & ); 45 45 46 const char * sepGet( ofstream *);47 void sepSet( ofstream *, const char * );48 const char * sepGetTuple( ofstream *);49 void sepSetTuple( ofstream *, const char * );46 const char * sepGet( ofstream & ); 47 void sepSet( ofstream &, const char * ); 48 const char * sepGetTuple( ofstream & ); 49 void sepSetTuple( ofstream &, const char * ); 50 50 51 int fail( ofstream *);52 int flush( ofstream *);53 void open( ofstream *, const char * name, const char * mode );54 void close( ofstream *);55 ofstream * write( ofstream *, const char * data, unsigned long int size );56 int fmt( ofstream *, const char fmt[], ... );51 int fail( ofstream & ); 52 int flush( ofstream & ); 53 void open( ofstream &, const char * name, const char * mode ); 54 void close( ofstream & ); 55 ofstream & write( ofstream &, const char * data, unsigned long int size ); 56 int fmt( ofstream &, const char fmt[], ... ); 57 57 58 void ?{}( ofstream & ); 58 void ?{}( ofstream & os ); 59 void ?{}( ofstream & os, const char * name, const char * mode ); 59 60 60 extern ofstream * sout, *serr;61 extern ofstream & sout, & serr; 61 62 62 // implement context istream 63 63 64 struct ifstream { 64 65 void * file; 65 66 }; // ifstream 66 67 67 int fail( ifstream * is ); 68 int eof( ifstream * is ); 69 void open( ifstream * is, const char * name, const char * mode ); 70 void close( ifstream * is ); 71 ifstream * read( ifstream * is, char * data, unsigned long int size ); 72 ifstream * ungetc( ifstream * is, char c ); 73 int fmt( ifstream *, const char fmt[], ... ); 68 // public 69 int fail( ifstream & is ); 70 int eof( ifstream & is ); 71 void open( ifstream & is, const char * name ); 72 void close( ifstream & is ); 73 ifstream & read( ifstream & is, char * data, unsigned long int size ); 74 ifstream & ungetc( ifstream & is, char c ); 75 int fmt( ifstream &, const char fmt[], ... ); 74 76 75 extern ifstream * sin; 77 void ?{}( ifstream & is ); 78 void ?{}( ifstream & is, const char * name ); 79 80 extern ifstream & sin; 76 81 77 82 // Local Variables: // -
src/libcfa/fstream.c
r92494fd r09687aa 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 20 15:20:49201713 // Update Count : 2 5212 // Last Modified On : Thu Dec 7 08:35:01 2017 13 // Update Count : 270 14 14 // 15 15 … … 27 27 #define IO_MSG "I/O error: " 28 28 29 void ?{}( ofstream & this, void * file, _Bool sepDefault, _Bool sepOnOff, const char * separator, const char * tupleSeparator ) {30 this.file = file;31 this.sepDefault = sepDefault;32 this.sepOnOff = sepOnOff;33 sepSet( &this, separator );34 sepSetCur( &this, sepGet( &this ) );35 sepSetTuple( &this, tupleSeparator );29 void ?{}( ofstream & os, void * file, _Bool sepDefault, _Bool sepOnOff, const char * separator, const char * tupleSeparator ) { 30 os.file = file; 31 os.sepDefault = sepDefault; 32 os.sepOnOff = sepOnOff; 33 sepSet( os, separator ); 34 sepSetCur( os, sepGet( os ) ); 35 sepSetTuple( os, tupleSeparator ); 36 36 } 37 37 38 38 // private 39 _Bool sepPrt( ofstream * os ) { setNL( os, false ); return os->sepOnOff; }40 void sepReset( ofstream * os ) { os->sepOnOff = os->sepDefault; }41 void sepReset( ofstream * os, _Bool reset ) { os->sepDefault = reset; os->sepOnOff = os->sepDefault; }42 const char * sepGetCur( ofstream * os ) { return os->sepCur; }43 void sepSetCur( ofstream * os, const char * sepCur ) { os->sepCur = sepCur; }44 _Bool getNL( ofstream * os ) { return os->sawNL; }45 void setNL( ofstream * os, _Bool state ) { os->sawNL = state; }39 _Bool sepPrt( ofstream & os ) { setNL( os, false ); return os.sepOnOff; } 40 void sepReset( ofstream & os ) { os.sepOnOff = os.sepDefault; } 41 void sepReset( ofstream & os, _Bool reset ) { os.sepDefault = reset; os.sepOnOff = os.sepDefault; } 42 const char * sepGetCur( ofstream & os ) { return os.sepCur; } 43 void sepSetCur( ofstream & os, const char * sepCur ) { os.sepCur = sepCur; } 44 _Bool getNL( ofstream & os ) { return os.sawNL; } 45 void setNL( ofstream & os, _Bool state ) { os.sawNL = state; } 46 46 47 47 // public 48 void sepOn( ofstream * os ) { os->sepOnOff = ! getNL( os ); } 49 void sepOff( ofstream * os ) { os->sepOnOff = false; } 50 51 _Bool sepDisable( ofstream *os ) { 52 _Bool temp = os->sepDefault; 53 os->sepDefault = false; 48 void ?{}( ofstream & os ) {} 49 50 void ?{}( ofstream & os, const char * name, const char * mode ) { 51 open( os, name, mode ); 52 } 53 54 void sepOn( ofstream & os ) { os.sepOnOff = ! getNL( os ); } 55 void sepOff( ofstream & os ) { os.sepOnOff = false; } 56 57 _Bool sepDisable( ofstream & os ) { 58 _Bool temp = os.sepDefault; 59 os.sepDefault = false; 54 60 sepReset( os ); 55 61 return temp; 56 62 } // sepDisable 57 63 58 _Bool sepEnable( ofstream *os ) {59 _Bool temp = os ->sepDefault;60 os ->sepDefault = true;61 if ( os ->sepOnOff ) sepReset( os ); // start of line ?64 _Bool sepEnable( ofstream & os ) { 65 _Bool temp = os.sepDefault; 66 os.sepDefault = true; 67 if ( os.sepOnOff ) sepReset( os ); // start of line ? 62 68 return temp; 63 69 } // sepEnable 64 70 65 const char * sepGet( ofstream * os ) { return os->separator; }66 void sepSet( ofstream *os, const char * s ) {71 const char * sepGet( ofstream & os ) { return os.separator; } 72 void sepSet( ofstream & os, const char * s ) { 67 73 assert( s ); 68 strncpy( os ->separator, s, sepSize - 1 );69 os ->separator[sepSize - 1] = '\0';74 strncpy( os.separator, s, sepSize - 1 ); 75 os.separator[sepSize - 1] = '\0'; 70 76 } // sepSet 71 77 72 const char * sepGetTuple( ofstream * os ) { return os->tupleSeparator; }73 void sepSetTuple( ofstream *os, const char * s ) {78 const char * sepGetTuple( ofstream & os ) { return os.tupleSeparator; } 79 void sepSetTuple( ofstream & os, const char * s ) { 74 80 assert( s ); 75 strncpy( os ->tupleSeparator, s, sepSize - 1 );76 os ->tupleSeparator[sepSize - 1] = '\0';81 strncpy( os.tupleSeparator, s, sepSize - 1 ); 82 os.tupleSeparator[sepSize - 1] = '\0'; 77 83 } // sepSet 78 84 79 int fail( ofstream *os ) {80 return ferror( (FILE *)(os ->file) );85 int fail( ofstream & os ) { 86 return ferror( (FILE *)(os.file) ); 81 87 } // fail 82 88 83 int flush( ofstream *os ) {84 return fflush( (FILE *)(os ->file) );89 int flush( ofstream & os ) { 90 return fflush( (FILE *)(os.file) ); 85 91 } // flush 86 92 87 void open( ofstream *os, const char * name, const char * mode ) {93 void open( ofstream & os, const char * name, const char * mode ) { 88 94 FILE *file = fopen( name, mode ); 89 95 if ( file == 0 ) { // do not change unless successful … … 92 98 exit( EXIT_FAILURE ); 93 99 } // if 94 ?{}( *os, file, true, false, " ", ", " );100 (os){ file, true, false, " ", ", " }; 95 101 } // open 96 102 97 void close( ofstream *os ) {98 if ( (FILE *)(os ->file) == stdout || (FILE *)(os->file) == stderr ) return;99 100 if ( fclose( (FILE *)(os ->file) ) == EOF ) {103 void close( ofstream & os ) { 104 if ( (FILE *)(os.file) == stdout || (FILE *)(os.file) == stderr ) return; 105 106 if ( fclose( (FILE *)(os.file) ) == EOF ) { 101 107 perror( IO_MSG "close output" ); 102 108 } // if 103 109 } // close 104 110 105 ofstream * write( ofstream *os, const char * data, unsigned long int size ) {111 ofstream & write( ofstream & os, const char * data, unsigned long int size ) { 106 112 if ( fail( os ) ) { 107 113 fprintf( stderr, "attempt write I/O on failed stream\n" ); … … 109 115 } // if 110 116 111 if ( fwrite( data, 1, size, (FILE *)(os ->file) ) != size ) {117 if ( fwrite( data, 1, size, (FILE *)(os.file) ) != size ) { 112 118 perror( IO_MSG "write" ); 113 119 exit( EXIT_FAILURE ); … … 116 122 } // write 117 123 118 int fmt( ofstream *os, const char format[], ... ) {124 int fmt( ofstream & os, const char format[], ... ) { 119 125 va_list args; 120 126 va_start( args, format ); 121 int len = vfprintf( (FILE *)(os ->file), format, args );127 int len = vfprintf( (FILE *)(os.file), format, args ); 122 128 if ( len == EOF ) { 123 if ( ferror( (FILE *)(os ->file) ) ) {129 if ( ferror( (FILE *)(os.file) ) ) { 124 130 fprintf( stderr, "invalid write\n" ); 125 131 exit( EXIT_FAILURE ); … … 133 139 134 140 static ofstream soutFile = { (FILE *)(&_IO_2_1_stdout_), true, false, " ", ", " }; 135 ofstream *sout = &soutFile;141 ofstream & sout = soutFile; 136 142 static ofstream serrFile = { (FILE *)(&_IO_2_1_stderr_), true, false, " ", ", " }; 137 ofstream *serr = &serrFile;143 ofstream & serr = serrFile; 138 144 139 145 140 146 //--------------------------------------- 141 147 142 143 int fail( ifstream * is ) { 144 return ferror( (FILE *)(is->file) ); 148 // private 149 void ?{}( ifstream & is, void * file ) { 150 is.file = file; 151 } 152 153 // public 154 void ?{}( ifstream & is ) {} 155 156 void ?{}( ifstream & is, const char * name ) { 157 open( is, name ); 158 } 159 160 int fail( ifstream & is ) { 161 return ferror( (FILE *)(is.file) ); 145 162 } // fail 146 163 147 int eof( ifstream *is ) {148 return feof( (FILE *)(is ->file) );164 int eof( ifstream & is ) { 165 return feof( (FILE *)(is.file) ); 149 166 } // eof 150 167 151 void open( ifstream * is, const char * name, const char * mode ) {152 FILE *file = fopen( name, mode);168 void open( ifstream & is, const char * name ) { 169 FILE *file = fopen( name, "r" ); 153 170 if ( file == 0 ) { // do not change unless successful 154 171 fprintf( stderr, IO_MSG "open input file \"%s\", ", name ); … … 156 173 exit( EXIT_FAILURE ); 157 174 } // if 158 is ->file = file;175 is.file = file; 159 176 } // open 160 177 161 void close( ifstream *is ) {162 if ( (FILE *)(is ->file) == stdin ) return;163 164 if ( fclose( (FILE *)(is ->file) ) == EOF ) {178 void close( ifstream & is ) { 179 if ( (FILE *)(is.file) == stdin ) return; 180 181 if ( fclose( (FILE *)(is.file) ) == EOF ) { 165 182 perror( IO_MSG "close input" ); 166 183 } // if 167 184 } // close 168 185 169 ifstream * read( ifstream *is, char * data, unsigned long int size ) {186 ifstream & read( ifstream & is, char * data, unsigned long int size ) { 170 187 if ( fail( is ) ) { 171 188 fprintf( stderr, "attempt read I/O on failed stream\n" ); … … 173 190 } // if 174 191 175 if ( fread( data, size, 1, (FILE *)(is ->file) ) == 0 ) {192 if ( fread( data, size, 1, (FILE *)(is.file) ) == 0 ) { 176 193 perror( IO_MSG "read" ); 177 194 exit( EXIT_FAILURE ); … … 180 197 } // read 181 198 182 ifstream *ungetc( ifstream *is, char c ) {199 ifstream &ungetc( ifstream & is, char c ) { 183 200 if ( fail( is ) ) { 184 201 fprintf( stderr, "attempt ungetc I/O on failed stream\n" ); … … 186 203 } // if 187 204 188 if ( ungetc( c, (FILE *)(is ->file) ) == EOF ) {205 if ( ungetc( c, (FILE *)(is.file) ) == EOF ) { 189 206 perror( IO_MSG "ungetc" ); 190 207 exit( EXIT_FAILURE ); … … 193 210 } // ungetc 194 211 195 int fmt( ifstream *is, const char format[], ... ) {212 int fmt( ifstream & is, const char format[], ... ) { 196 213 va_list args; 197 214 198 215 va_start( args, format ); 199 int len = vfscanf( (FILE *)(is ->file), format, args );216 int len = vfscanf( (FILE *)(is.file), format, args ); 200 217 if ( len == EOF ) { 201 if ( ferror( (FILE *)(is ->file) ) ) {218 if ( ferror( (FILE *)(is.file) ) ) { 202 219 fprintf( stderr, "invalid read\n" ); 203 220 exit( EXIT_FAILURE ); … … 210 227 211 228 static ifstream sinFile = { (FILE *)(&_IO_2_1_stdin_) }; 212 ifstream *sin = &sinFile;229 ifstream & sin = sinFile; 213 230 214 231 // Local Variables: // -
src/libcfa/gmp
r92494fd r09687aa 10 10 // Created On : Tue Apr 19 08:43:43 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Sep 4 09:54:33201713 // Update Count : 2 012 // Last Modified On : Thu Dec 7 09:10:41 2017 13 // Update Count : 21 14 14 // 15 15 … … 257 257 // I/O 258 258 static inline forall( dtype istype | istream( istype ) ) 259 istype * ?|?( istype *is, Int & mp ) {259 istype & ?|?( istype & is, Int & mp ) { 260 260 gmp_scanf( "%Zd", &mp ); 261 261 return is; … … 263 263 264 264 static inline forall( dtype ostype | ostream( ostype ) ) 265 ostype * ?|?( ostype *os, Int mp ) {265 ostype & ?|?( ostype & os, Int mp ) { 266 266 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 267 267 gmp_printf( "%Zd", mp.mpz ); -
src/libcfa/iostream
r92494fd r09687aa 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Oct 10 14:51:10 201713 // Update Count : 14 012 // Last Modified On : Wed Dec 6 23:03:30 2017 13 // Update Count : 144 14 14 // 15 15 … … 20 20 trait ostream( dtype ostype ) { 21 21 // private 22 _Bool sepPrt( ostype *); // return separator state (on/off)23 void sepReset( ostype *); // set separator state to default state24 void sepReset( ostype *, _Bool ); // set separator and default state25 const char * sepGetCur( ostype *); // get current separator string26 void sepSetCur( ostype *, const char * ); // set current separator string27 _Bool getNL( ostype *); // check newline28 void setNL( ostype *, _Bool ); // saw newline22 _Bool sepPrt( ostype & ); // return separator state (on/off) 23 void sepReset( ostype & ); // set separator state to default state 24 void sepReset( ostype &, _Bool ); // set separator and default state 25 const char * sepGetCur( ostype & ); // get current separator string 26 void sepSetCur( ostype &, const char * ); // set current separator string 27 _Bool getNL( ostype & ); // check newline 28 void setNL( ostype &, _Bool ); // saw newline 29 29 // public 30 void sepOn( ostype *); // turn separator state on31 void sepOff( ostype *); // turn separator state off32 _Bool sepDisable( ostype *); // set default state to off, and return previous state33 _Bool sepEnable( ostype *); // set default state to on, and return previous state30 void sepOn( ostype & ); // turn separator state on 31 void sepOff( ostype & ); // turn separator state off 32 _Bool sepDisable( ostype & ); // set default state to off, and return previous state 33 _Bool sepEnable( ostype & ); // set default state to on, and return previous state 34 34 35 const char * sepGet( ostype *); // get separator string36 void sepSet( ostype *, const char * ); // set separator to string (15 character maximum)37 const char * sepGetTuple( ostype *); // get tuple separator string38 void sepSetTuple( ostype *, const char * ); // set tuple separator to string (15 character maximum)35 const char * sepGet( ostype & ); // get separator string 36 void sepSet( ostype &, const char * ); // set separator to string (15 character maximum) 37 const char * sepGetTuple( ostype & ); // get tuple separator string 38 void sepSetTuple( ostype &, const char * ); // set tuple separator to string (15 character maximum) 39 39 40 int fail( ostype *);41 int flush( ostype *);42 void open( ostype *os, const char * name, const char * mode );43 void close( ostype *os );44 ostype * write( ostype *, const char *, unsigned long int );45 int fmt( ostype *, const char fmt[], ... );40 int fail( ostype & ); 41 int flush( ostype & ); 42 void open( ostype & os, const char * name, const char * mode ); 43 void close( ostype & os ); 44 ostype & write( ostype &, const char *, unsigned long int ); 45 int fmt( ostype &, const char fmt[], ... ); 46 46 }; // ostream 47 47 48 48 // trait writeable( otype T ) { 49 // forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, T );49 // forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, T ); 50 50 // }; // writeable 51 51 52 52 trait writeable( otype T, dtype ostype | ostream( ostype ) ) { 53 ostype * ?|?( ostype *, T );53 ostype & ?|?( ostype &, T ); 54 54 }; // writeable 55 55 56 56 // implement writable for intrinsic types 57 57 58 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, char );59 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, signed char );60 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, unsigned char );58 forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, char ); 59 forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, signed char ); 60 forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, unsigned char ); 61 61 62 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, short int );63 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, unsigned short int );64 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, int );65 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, unsigned int );66 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, long int );67 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, long long int );68 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, unsigned long int );69 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, unsigned long long int );62 forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, short int ); 63 forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, unsigned short int ); 64 forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, int ); 65 forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, unsigned int ); 66 forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, long int ); 67 forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, long long int ); 68 forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, unsigned long int ); 69 forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, unsigned long long int ); 70 70 71 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, float ); // FIX ME: should not be required72 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, double );73 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, long double );71 forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, float ); // FIX ME: should not be required 72 forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, double ); 73 forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, long double ); 74 74 75 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, float _Complex );76 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, double _Complex );77 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, long double _Complex );75 forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, float _Complex ); 76 forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, double _Complex ); 77 forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, long double _Complex ); 78 78 79 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, const char * );80 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, const char16_t * );79 forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, const char * ); 80 forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, const char16_t * ); 81 81 #if ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 ) // char32_t == wchar_t => ambiguous 82 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, const char32_t * );82 forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, const char32_t * ); 83 83 #endif // ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 ) 84 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, const wchar_t * );85 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, const void * );84 forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, const wchar_t * ); 85 forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, const void * ); 86 86 87 87 // tuples 88 forall( dtype ostype, otype T, ttype Params | writeable( T, ostype ) | { ostype * ?|?( ostype *, Params ); } )89 ostype * ?|?( ostype *os, T arg, Params rest );88 forall( dtype ostype, otype T, ttype Params | writeable( T, ostype ) | { ostype & ?|?( ostype &, Params ); } ) 89 ostype & ?|?( ostype & os, T arg, Params rest ); 90 90 91 91 // manipulators 92 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, ostype * (*)( ostype *) );93 forall( dtype ostype | ostream( ostype ) ) ostype * endl( ostype *);94 forall( dtype ostype | ostream( ostype ) ) ostype * sep( ostype *);95 forall( dtype ostype | ostream( ostype ) ) ostype * sepTuple( ostype *);96 forall( dtype ostype | ostream( ostype ) ) ostype * sepOn( ostype *);97 forall( dtype ostype | ostream( ostype ) ) ostype * sepOff( ostype *);98 forall( dtype ostype | ostream( ostype ) ) ostype * sepDisable( ostype *);99 forall( dtype ostype | ostream( ostype ) ) ostype * sepEnable( ostype *);92 forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, ostype & (*)( ostype & ) ); 93 forall( dtype ostype | ostream( ostype ) ) ostype & endl( ostype & ); 94 forall( dtype ostype | ostream( ostype ) ) ostype & sep( ostype & ); 95 forall( dtype ostype | ostream( ostype ) ) ostype & sepTuple( ostype & ); 96 forall( dtype ostype | ostream( ostype ) ) ostype & sepOn( ostype & ); 97 forall( dtype ostype | ostream( ostype ) ) ostype & sepOff( ostype & ); 98 forall( dtype ostype | ostream( ostype ) ) ostype & sepDisable( ostype & ); 99 forall( dtype ostype | ostream( ostype ) ) ostype & sepEnable( ostype & ); 100 100 101 101 // writes the range [begin, end) to the given stream 102 102 forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) ) 103 void write( iterator_type begin, iterator_type end, ostype *os );103 void write( iterator_type begin, iterator_type end, ostype & os ); 104 104 105 105 forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) ) 106 void write_reverse( iterator_type begin, iterator_type end, ostype *os );106 void write_reverse( iterator_type begin, iterator_type end, ostype & os ); 107 107 108 108 //--------------------------------------- 109 109 110 110 trait istream( dtype istype ) { 111 int fail( istype *);112 int eof( istype *);113 void open( istype * is, const char * name, const char * mode );114 void close( istype *is );115 istype * read( istype *, char *, unsigned long int );116 istype * ungetc( istype *, char );117 int fmt( istype *, const char fmt[], ... );111 int fail( istype & ); 112 int eof( istype & ); 113 void open( istype & is, const char * name ); 114 void close( istype & is ); 115 istype & read( istype &, char *, unsigned long int ); 116 istype & ungetc( istype &, char ); 117 int fmt( istype &, const char fmt[], ... ); 118 118 }; // istream 119 119 120 120 trait readable( otype T ) { 121 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, T );121 forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, T ); 122 122 }; // readable 123 123 124 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, char & );125 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, signed char & );126 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, unsigned char & );124 forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, char & ); 125 forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, signed char & ); 126 forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, unsigned char & ); 127 127 128 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, short int & );129 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, unsigned short int & );130 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, int & );131 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, unsigned int & );132 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, long int & );133 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, long long int & );134 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, unsigned long int & );135 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, unsigned long long int & );128 forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, short int & ); 129 forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, unsigned short int & ); 130 forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, int & ); 131 forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, unsigned int & ); 132 forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, long int & ); 133 forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, long long int & ); 134 forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, unsigned long int & ); 135 forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, unsigned long long int & ); 136 136 137 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, float & );138 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, double & );139 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, long double & );137 forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, float & ); 138 forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, double & ); 139 forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, long double & ); 140 140 141 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, float _Complex & );142 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, double _Complex & );143 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, long double _Complex & );141 forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, float _Complex & ); 142 forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, double _Complex & ); 143 forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, long double _Complex & ); 144 144 145 145 struct _Istream_cstrUC { char * s; }; 146 146 _Istream_cstrUC cstr( char * ); 147 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, _Istream_cstrUC );147 forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, _Istream_cstrUC ); 148 148 149 149 struct _Istream_cstrC { char * s; int size; }; 150 150 _Istream_cstrC cstr( char *, int size ); 151 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, _Istream_cstrC );151 forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, _Istream_cstrC ); 152 152 153 153 // Local Variables: // -
src/libcfa/iostream.c
r92494fd r09687aa 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Oct 10 14:51:09201713 // Update Count : 42 412 // Last Modified On : Wed Dec 6 23:03:43 2017 13 // Update Count : 426 14 14 // 15 15 … … 25 25 26 26 forall( dtype ostype | ostream( ostype ) ) 27 ostype * ?|?( ostype *os, char ch ) {27 ostype & ?|?( ostype & os, char ch ) { 28 28 fmt( os, "%c", ch ); 29 29 if ( ch == '\n' ) setNL( os, true ); … … 33 33 34 34 forall( dtype ostype | ostream( ostype ) ) 35 ostype * ?|?( ostype *os, signed char c ) {35 ostype & ?|?( ostype & os, signed char c ) { 36 36 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 37 37 fmt( os, "%hhd", c ); … … 40 40 41 41 forall( dtype ostype | ostream( ostype ) ) 42 ostype * ?|?( ostype *os, unsigned char c ) {42 ostype & ?|?( ostype & os, unsigned char c ) { 43 43 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 44 44 fmt( os, "%hhu", c ); … … 47 47 48 48 forall( dtype ostype | ostream( ostype ) ) 49 ostype * ?|?( ostype *os, short int si ) {49 ostype & ?|?( ostype & os, short int si ) { 50 50 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 51 51 fmt( os, "%hd", si ); … … 54 54 55 55 forall( dtype ostype | ostream( ostype ) ) 56 ostype * ?|?( ostype *os, unsigned short int usi ) {56 ostype & ?|?( ostype & os, unsigned short int usi ) { 57 57 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 58 58 fmt( os, "%hu", usi ); … … 61 61 62 62 forall( dtype ostype | ostream( ostype ) ) 63 ostype * ?|?( ostype *os, int i ) {63 ostype & ?|?( ostype & os, int i ) { 64 64 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 65 65 fmt( os, "%d", i ); … … 68 68 69 69 forall( dtype ostype | ostream( ostype ) ) 70 ostype * ?|?( ostype *os, unsigned int ui ) {70 ostype & ?|?( ostype & os, unsigned int ui ) { 71 71 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 72 72 fmt( os, "%u", ui ); … … 75 75 76 76 forall( dtype ostype | ostream( ostype ) ) 77 ostype * ?|?( ostype *os, long int li ) {77 ostype & ?|?( ostype & os, long int li ) { 78 78 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 79 79 fmt( os, "%ld", li ); … … 82 82 83 83 forall( dtype ostype | ostream( ostype ) ) 84 ostype * ?|?( ostype *os, unsigned long int uli ) {84 ostype & ?|?( ostype & os, unsigned long int uli ) { 85 85 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 86 86 fmt( os, "%lu", uli ); … … 89 89 90 90 forall( dtype ostype | ostream( ostype ) ) 91 ostype * ?|?( ostype *os, long long int lli ) {91 ostype & ?|?( ostype & os, long long int lli ) { 92 92 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 93 93 fmt( os, "%lld", lli ); … … 96 96 97 97 forall( dtype ostype | ostream( ostype ) ) 98 ostype * ?|?( ostype *os, unsigned long long int ulli ) {98 ostype & ?|?( ostype & os, unsigned long long int ulli ) { 99 99 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 100 100 fmt( os, "%llu", ulli ); … … 103 103 104 104 forall( dtype ostype | ostream( ostype ) ) 105 ostype * ?|?( ostype *os, float f ) {105 ostype & ?|?( ostype & os, float f ) { 106 106 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 107 107 fmt( os, "%g", f ); … … 110 110 111 111 forall( dtype ostype | ostream( ostype ) ) 112 ostype * ?|?( ostype *os, double d ) {112 ostype & ?|?( ostype & os, double d ) { 113 113 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 114 114 fmt( os, "%.*lg", DBL_DIG, d ); … … 117 117 118 118 forall( dtype ostype | ostream( ostype ) ) 119 ostype * ?|?( ostype *os, long double ld ) {119 ostype & ?|?( ostype & os, long double ld ) { 120 120 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 121 121 fmt( os, "%.*Lg", LDBL_DIG, ld ); … … 124 124 125 125 forall( dtype ostype | ostream( ostype ) ) 126 ostype * ?|?( ostype *os, float _Complex fc ) {126 ostype & ?|?( ostype & os, float _Complex fc ) { 127 127 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 128 128 fmt( os, "%g%+gi", crealf( fc ), cimagf( fc ) ); … … 131 131 132 132 forall( dtype ostype | ostream( ostype ) ) 133 ostype * ?|?( ostype *os, double _Complex dc ) {133 ostype & ?|?( ostype & os, double _Complex dc ) { 134 134 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 135 135 fmt( os, "%.*lg%+.*lgi", DBL_DIG, creal( dc ), DBL_DIG, cimag( dc ) ); … … 138 138 139 139 forall( dtype ostype | ostream( ostype ) ) 140 ostype * ?|?( ostype *os, long double _Complex ldc ) {140 ostype & ?|?( ostype & os, long double _Complex ldc ) { 141 141 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 142 142 fmt( os, "%.*Lg%+.*Lgi", LDBL_DIG, creall( ldc ), LDBL_DIG, cimagl( ldc ) ); … … 145 145 146 146 forall( dtype ostype | ostream( ostype ) ) 147 ostype * ?|?( ostype *os, const char * str ) {147 ostype & ?|?( ostype & os, const char * str ) { 148 148 enum { Open = 1, Close, OpenClose }; 149 149 static const unsigned char mask[256] @= { … … 185 185 186 186 forall( dtype ostype | ostream( ostype ) ) 187 ostype * ?|?( ostype *os, const char16_t * str ) {187 ostype & ?|?( ostype & os, const char16_t * str ) { 188 188 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 189 189 fmt( os, "%ls", str ); … … 193 193 #if ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 ) // char32_t == wchar_t => ambiguous 194 194 forall( dtype ostype | ostream( ostype ) ) 195 ostype * ?|?( ostype *os, const char32_t * str ) {195 ostype & ?|?( ostype & os, const char32_t * str ) { 196 196 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 197 197 fmt( os, "%ls", str ); … … 201 201 202 202 forall( dtype ostype | ostream( ostype ) ) 203 ostype * ?|?( ostype *os, const wchar_t * str ) {203 ostype & ?|?( ostype & os, const wchar_t * str ) { 204 204 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 205 205 fmt( os, "%ls", str ); … … 208 208 209 209 forall( dtype ostype | ostream( ostype ) ) 210 ostype * ?|?( ostype *os, const void * p ) {210 ostype & ?|?( ostype & os, const void * p ) { 211 211 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 212 212 fmt( os, "%p", p ); … … 216 216 217 217 // tuples 218 forall( dtype ostype, otype T, ttype Params | writeable( T, ostype ) | { ostype * ?|?( ostype *, Params ); } )219 ostype * ?|?( ostype *os, T arg, Params rest ) {218 forall( dtype ostype, otype T, ttype Params | writeable( T, ostype ) | { ostype & ?|?( ostype &, Params ); } ) 219 ostype & ?|?( ostype & os, T arg, Params rest ) { 220 220 os | arg; // print first argument 221 221 sepSetCur( os, sepGetTuple( os ) ); // switch to tuple separator … … 228 228 // manipulators 229 229 forall( dtype ostype | ostream( ostype ) ) 230 ostype * ?|?( ostype * os, ostype * (* manip)( ostype *) ) {230 ostype & ?|?( ostype & os, ostype & (* manip)( ostype & ) ) { 231 231 return manip( os ); 232 232 } // ?|? 233 233 234 234 forall( dtype ostype | ostream( ostype ) ) 235 ostype * sep( ostype *os ) {235 ostype & sep( ostype & os ) { 236 236 os | sepGet( os ); 237 237 return os; … … 239 239 240 240 forall( dtype ostype | ostream( ostype ) ) 241 ostype * sepTuple( ostype *os ) {241 ostype & sepTuple( ostype & os ) { 242 242 os | sepGetTuple( os ); 243 243 return os; … … 245 245 246 246 forall( dtype ostype | ostream( ostype ) ) 247 ostype * endl( ostype *os ) {247 ostype & endl( ostype & os ) { 248 248 os | '\n'; 249 249 setNL( os, true ); … … 254 254 255 255 forall( dtype ostype | ostream( ostype ) ) 256 ostype * sepOn( ostype *os ) {256 ostype & sepOn( ostype & os ) { 257 257 sepOn( os ); 258 258 return os; … … 260 260 261 261 forall( dtype ostype | ostream( ostype ) ) 262 ostype * sepOff( ostype *os ) {262 ostype & sepOff( ostype & os ) { 263 263 sepOff( os ); 264 264 return os; … … 266 266 267 267 forall( dtype ostype | ostream( ostype ) ) 268 ostype * sepEnable( ostype *os ) {268 ostype & sepEnable( ostype & os ) { 269 269 sepEnable( os ); 270 270 return os; … … 272 272 273 273 forall( dtype ostype | ostream( ostype ) ) 274 ostype * sepDisable( ostype *os ) {274 ostype & sepDisable( ostype & os ) { 275 275 sepDisable( os ); 276 276 return os; … … 280 280 281 281 forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) ) 282 void write( iterator_type begin, iterator_type end, ostype *os ) {282 void write( iterator_type begin, iterator_type end, ostype & os ) { 283 283 void print( elt_type i ) { os | i; } 284 284 for_each( begin, end, print ); … … 286 286 287 287 forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) ) 288 void write_reverse( iterator_type begin, iterator_type end, ostype *os ) {288 void write_reverse( iterator_type begin, iterator_type end, ostype & os ) { 289 289 void print( elt_type i ) { os | i; } 290 290 for_each_reverse( begin, end, print ); … … 294 294 295 295 forall( dtype istype | istream( istype ) ) 296 istype * ?|?( istype *is, char & c ) {296 istype & ?|?( istype & is, char & c ) { 297 297 fmt( is, "%c", &c ); // must pass pointer through varg to fmt 298 298 return is; … … 300 300 301 301 forall( dtype istype | istream( istype ) ) 302 istype * ?|?( istype *is, signed char & sc ) {302 istype & ?|?( istype & is, signed char & sc ) { 303 303 fmt( is, "%hhd", &sc ); 304 304 return is; … … 306 306 307 307 forall( dtype istype | istream( istype ) ) 308 istype * ?|?( istype *is, unsigned char & usc ) {308 istype & ?|?( istype & is, unsigned char & usc ) { 309 309 fmt( is, "%hhu", &usc ); 310 310 return is; … … 312 312 313 313 forall( dtype istype | istream( istype ) ) 314 istype * ?|?( istype *is, short int & si ) {314 istype & ?|?( istype & is, short int & si ) { 315 315 fmt( is, "%hd", &si ); 316 316 return is; … … 318 318 319 319 forall( dtype istype | istream( istype ) ) 320 istype * ?|?( istype *is, unsigned short int & usi ) {320 istype & ?|?( istype & is, unsigned short int & usi ) { 321 321 fmt( is, "%hu", &usi ); 322 322 return is; … … 324 324 325 325 forall( dtype istype | istream( istype ) ) 326 istype * ?|?( istype *is, int & i ) {326 istype & ?|?( istype & is, int & i ) { 327 327 fmt( is, "%d", &i ); 328 328 return is; … … 330 330 331 331 forall( dtype istype | istream( istype ) ) 332 istype * ?|?( istype *is, unsigned int & ui ) {332 istype & ?|?( istype & is, unsigned int & ui ) { 333 333 fmt( is, "%u", &ui ); 334 334 return is; … … 336 336 337 337 forall( dtype istype | istream( istype ) ) 338 istype * ?|?( istype *is, long int & li ) {338 istype & ?|?( istype & is, long int & li ) { 339 339 fmt( is, "%ld", &li ); 340 340 return is; … … 342 342 343 343 forall( dtype istype | istream( istype ) ) 344 istype * ?|?( istype *is, unsigned long int & ulli ) {344 istype & ?|?( istype & is, unsigned long int & ulli ) { 345 345 fmt( is, "%lu", &ulli ); 346 346 return is; … … 348 348 349 349 forall( dtype istype | istream( istype ) ) 350 istype * ?|?( istype *is, long long int & lli ) {350 istype & ?|?( istype & is, long long int & lli ) { 351 351 fmt( is, "%lld", &lli ); 352 352 return is; … … 354 354 355 355 forall( dtype istype | istream( istype ) ) 356 istype * ?|?( istype *is, unsigned long long int & ulli ) {356 istype & ?|?( istype & is, unsigned long long int & ulli ) { 357 357 fmt( is, "%llu", &ulli ); 358 358 return is; … … 361 361 362 362 forall( dtype istype | istream( istype ) ) 363 istype * ?|?( istype *is, float & f ) {363 istype & ?|?( istype & is, float & f ) { 364 364 fmt( is, "%f", &f ); 365 365 return is; … … 367 367 368 368 forall( dtype istype | istream( istype ) ) 369 istype * ?|?( istype *is, double & d ) {369 istype & ?|?( istype & is, double & d ) { 370 370 fmt( is, "%lf", &d ); 371 371 return is; … … 373 373 374 374 forall( dtype istype | istream( istype ) ) 375 istype * ?|?( istype *is, long double & ld ) {375 istype & ?|?( istype & is, long double & ld ) { 376 376 fmt( is, "%Lf", &ld ); 377 377 return is; … … 380 380 381 381 forall( dtype istype | istream( istype ) ) 382 istype * ?|?( istype *is, float _Complex & fc ) {382 istype & ?|?( istype & is, float _Complex & fc ) { 383 383 float re, im; 384 384 fmt( is, "%g%gi", &re, &im ); … … 388 388 389 389 forall( dtype istype | istream( istype ) ) 390 istype * ?|?( istype *is, double _Complex & dc ) {390 istype & ?|?( istype & is, double _Complex & dc ) { 391 391 double re, im; 392 392 fmt( is, "%lf%lfi", &re, &im ); … … 396 396 397 397 forall( dtype istype | istream( istype ) ) 398 istype * ?|?( istype *is, long double _Complex & ldc ) {398 istype & ?|?( istype & is, long double _Complex & ldc ) { 399 399 long double re, im; 400 400 fmt( is, "%Lf%Lfi", &re, &im ); … … 405 405 _Istream_cstrUC cstr( char * str ) { return (_Istream_cstrUC){ str }; } 406 406 forall( dtype istype | istream( istype ) ) 407 istype * ?|?( istype *is, _Istream_cstrUC cstr ) {407 istype & ?|?( istype & is, _Istream_cstrUC cstr ) { 408 408 fmt( is, "%s", cstr.s ); 409 409 return is; … … 412 412 _Istream_cstrC cstr( char * str, int size ) { return (_Istream_cstrC){ str, size }; } 413 413 forall( dtype istype | istream( istype ) ) 414 istype * ?|?( istype *is, _Istream_cstrC cstr ) {414 istype & ?|?( istype & is, _Istream_cstrC cstr ) { 415 415 char buf[16]; 416 416 sprintf( buf, "%%%ds", cstr.size ); -
src/libcfa/rational
r92494fd r09687aa 12 12 // Created On : Wed Apr 6 17:56:25 2016 13 13 // Last Modified By : Peter A. Buhr 14 // Last Modified On : Wed Aug 23 22:35:09201715 // Update Count : 9 514 // Last Modified On : Wed Dec 6 23:12:53 2017 15 // Update Count : 97 16 16 // 17 17 … … 135 135 // I/O 136 136 forall( otype RationalImpl | arithmetic( RationalImpl ) ) 137 forall( dtype istype | istream( istype ) | { istype * ?|?( istype *, RationalImpl & ); } )138 istype * ?|?( istype *, Rational(RationalImpl) & );137 forall( dtype istype | istream( istype ) | { istype & ?|?( istype &, RationalImpl & ); } ) 138 istype & ?|?( istype &, Rational(RationalImpl) & ); 139 139 140 140 forall( otype RationalImpl | arithmetic( RationalImpl ) ) 141 forall( dtype ostype | ostream( ostype ) | { ostype * ?|?( ostype *, RationalImpl ); } )142 ostype * ?|?( ostype *, Rational(RationalImpl ) );141 forall( dtype ostype | ostream( ostype ) | { ostype & ?|?( ostype &, RationalImpl ); } ) 142 ostype & ?|?( ostype &, Rational(RationalImpl ) ); 143 143 144 144 // Local Variables: // -
src/libcfa/rational.c
r92494fd r09687aa 10 10 // Created On : Wed Apr 6 17:54:28 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Aug 23 22:38:48 201713 // Update Count : 15 412 // Last Modified On : Wed Dec 6 23:13:58 2017 13 // Update Count : 156 14 14 // 15 15 … … 228 228 229 229 forall( otype RationalImpl | arithmetic( RationalImpl ) ) 230 forall( dtype istype | istream( istype ) | { istype * ?|?( istype *, RationalImpl & ); } )231 istype * ?|?( istype *is, Rational(RationalImpl) & r ) {230 forall( dtype istype | istream( istype ) | { istype & ?|?( istype &, RationalImpl & ); } ) 231 istype & ?|?( istype & is, Rational(RationalImpl) & r ) { 232 232 RationalImpl t; 233 233 is | r.numerator | r.denominator; … … 239 239 240 240 forall( otype RationalImpl | arithmetic( RationalImpl ) ) 241 forall( dtype ostype | ostream( ostype ) | { ostype * ?|?( ostype *, RationalImpl ); } )242 ostype * ?|?( ostype *os, Rational(RationalImpl ) r ) {241 forall( dtype ostype | ostream( ostype ) | { ostype & ?|?( ostype &, RationalImpl ); } ) 242 ostype & ?|?( ostype & os, Rational(RationalImpl ) r ) { 243 243 return os | r.numerator | '/' | r.denominator; 244 244 } // ?|?
Note: See TracChangeset
for help on using the changeset viewer.