Ignore:
Timestamp:
Dec 2, 2015, 11:58:59 AM (10 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
9cb8e88d
Parents:
9ed3237 (diff), f2b2029 (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' into ctor

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/examples/iostream.c

    r9ed3237 r0ddb713  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed May 27 18:18:13 2015
    13 // Update Count     : 2
     12// Last Modified On : Fri Nov 20 13:19:19 2015
     13// Update Count     : 9
    1414//
    1515
     
    1717extern "C" {
    1818#include <stdio.h>
    19 //#include <string.h>
    20 //#include <ctype.h>
    21         typedef long unsigned int size_t;
    22         size_t strlen(const char *s);
     19#include <string.h>                                                                             // strlen
    2320}
    2421
     
    2623ostype * ?<<?( ostype *os, char c ) {
    2724        return write( os, &c, 1 );
    28 }
     25} // ?<<?
    2926
    3027forall( dtype ostype | ostream( ostype ) )
    3128ostype * ?<<?( ostype *os, int i ) {
    32         char buffer[20];      // larger than the largest integer
     29        char buffer[32];                                                                        // larger than the largest integer
    3330        sprintf( buffer, "%d", i );
    3431        return write( os, buffer, strlen( buffer ) );
    35 }
     32} // ?<<?
    3633
    3734forall( dtype ostype | ostream( ostype ) )
    3835ostype * ?<<?( ostype *os, double d ) {
    39         char buffer[32];      // larger than the largest double
     36        char buffer[32];                                                                        // larger than the largest double
    4037        sprintf( buffer, "%g", d );
    4138        return write( os, buffer, strlen( buffer ) );
    42 }
     39} // ?<<?
    4340
    4441forall( dtype ostype | ostream( ostype ) )
    4542ostype * ?<<?( ostype *os, const char *cp ) {
    4643        return write( os, cp, strlen( cp ) );
    47 }
     44} // ?<<?
     45
     46forall( dtype ostype | ostream( ostype ) )
     47ostype * ?<<?( ostype *os, const void *p ) {
     48        char buffer[32];                                                                        // larger than the largest pointer
     49        sprintf( buffer, "%p", p );
     50        return write( os, buffer, strlen( buffer ) );
     51} // ?<<?
     52
     53forall( type elt_type | writeable( elt_type ),
     54                type iterator_type | iterator( iterator_type, elt_type ),
     55                dtype os_type | ostream( os_type ) )
     56void write( iterator_type begin, iterator_type end, os_type *os ) {
     57        void print( elt_type i ) {
     58                os << i << ' ';
     59        }
     60        for_each( begin, end, print );
     61} // ?<<?
     62
     63forall( type elt_type | writeable( elt_type ),
     64                type iterator_type | iterator( iterator_type, elt_type ),
     65                dtype os_type | ostream( os_type ) )
     66void write_reverse( iterator_type begin, iterator_type end, os_type *os ) {
     67        void print( elt_type i ) {
     68                os << i << ' ';
     69        }
     70        for_each_reverse( begin, end, print );
     71} // ?<<?
     72
    4873
    4974forall( dtype istype | istream( istype ) )
    5075istype * ?>>?( istype *is, char *cp ) {
    5176        return read( is, cp, 1 );
    52 }
     77} // ?>>?
    5378
    5479forall( dtype istype | istream( istype ) )
     
    7297        unread( is, cur );
    7398        return is;
    74 }
     99} // ?>>?
    75100
    76101// Local Variables: //
Note: See TracChangeset for help on using the changeset viewer.