Changeset 200fcb3 for examples/wrapper


Ignore:
Timestamp:
Dec 12, 2018, 9:16:12 AM (6 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
Children:
5ebb1368
Parents:
3d99498
Message:

add auto newline to sout, change endl to nl

Location:
examples/wrapper/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • examples/wrapper/src/main.c

    r3d99498 r200fcb3  
    11#include "pointer.h"
    22
    3 wrapper_t make_copy(wrapper_t copy)
    4 {
     3wrapper_t make_copy(wrapper_t copy) {
    54        return copy;
    65}
    76
    8 int main(int argc, char const *argv[])
    9 {
     7int main(int argc, char const *argv[]) {
    108        wrapper_t p = wrap(6);
    11 
    12         sout | endl | "test started" | endl;
    13 
     9        sout | nl | "test started";
    1410        wrapper_t p2 = p;
    15 
    1611        clear(&p);
    17 
    1812        p = p2;
    19 
    2013        wrapper_t p3 = make_copy(p2);
    21 
    22         sout | endl | "test ended" | endl;
    23 
     14        sout | nl | "test ended";
    2415        return 0;
    2516}
  • examples/wrapper/src/pointer.h

    r3d99498 r200fcb3  
    3434void ?{}(content_t* this)
    3535{
    36         sout | "Constructing content" | endl;
     36        sout | "Constructing content";
    3737        this->count = 0;
    3838}
     
    4040void ^?{}(content_t* this)
    4141{
    42         sout | "Destroying content" | endl;
     42        sout | "Destroying content";
    4343}
    4444
     
    5353void ?{}(wrapper_t* this)
    5454{
    55         sout | "Constructing empty ref pointer" | endl | endl;
     55        sout | "Constructing empty ref pointer" | nl;
    5656        this->ptr = NULL;
    5757}
     
    5959void ?{}(wrapper_t* this, wrapper_t rhs)
    6060{
    61         sout | "Constructing ref pointer from copy" | endl;
     61        sout | "Constructing ref pointer from copy";
    6262        this->ptr = rhs.ptr;
    6363        this->ptr->count++;
    64         sout | "Reference is " | this->ptr->count | endl | endl;
     64        sout | "Reference is " | this->ptr->count | nl;
    6565}
    6666
     
    6969        if(this->ptr)
    7070        {
    71                 sout | "Destroying ref pointer" | endl;
     71                sout | "Destroying ref pointer";
    7272                this->ptr->count--;
    73                 sout | "Reference is " | this->ptr->count | endl | endl;
     73                sout | "Reference is " | this->ptr->count | nl;
    7474                if(!this->ptr->count) delete(this->ptr);
    7575        }
    7676        else
    7777        {
    78                 sout | "Destroying empty ref pointer" | endl | endl;
     78                sout | "Destroying empty ref pointer" | nl;
    7979        }
    8080}
     
    8282wrapper_t ?=?(wrapper_t* this, wrapper_t rhs)
    8383{
    84         sout | "Setting ref pointer" | endl;
     84        sout | "Setting ref pointer";
    8585        if(this->ptr)
    8686        {
    8787                this->ptr->count--;
    88                 sout | "Reference is " | this->ptr->count | endl | endl;
     88                sout | "Reference is " | this->ptr->count | nl;
    8989                if(!this->ptr->count) delete(this->ptr);
    9090        }
    9191        this->ptr = rhs.ptr;
    9292        this->ptr->count++;
    93         sout | "Reference is " | this->ptr->count | endl | endl;
     93        sout | "Reference is " | this->ptr->count | nl;
    9494}
    9595
     
    9898        this->ptr = c;
    9999        this->ptr->count++;
    100         sout | "Setting ref pointer" | endl;
    101         sout | "Reference is " | this->ptr->count | endl | endl;
     100        sout | "Setting ref pointer";
     101        sout | "Reference is " | this->ptr->count | nl;
    102102}
    103103
    104104void clear(wrapper_t* this)
    105105{
    106         sout | "Clearing ref pointer" | endl;
     106        sout | "Clearing ref pointer";
    107107        this->ptr->count--;
    108         sout | "Reference is " | this->ptr->count | endl | endl;
     108        sout | "Reference is " | this->ptr->count | nl;
    109109        if(!this->ptr->count) delete(this->ptr);
    110110        this->ptr = NULL;
Note: See TracChangeset for help on using the changeset viewer.