Changeset a493682 for src/libcfa


Ignore:
Timestamp:
Jul 17, 2017, 1:55:22 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
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:
b46e3bd
Parents:
bf30ab3
Message:

Update several library files to use references

Location:
src/libcfa
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/fstream

    rbf30ab3 ra493682  
    5656int fmt( ofstream *, const char fmt[], ... );
    5757
    58 void ?{}( ofstream * );
     58void ?{}( ofstream & );
    5959
    6060extern ofstream * sout, * serr;
  • src/libcfa/fstream.c

    rbf30ab3 ra493682  
    2929#define IO_MSG "I/O error: "
    3030
    31 void ?{}( ofstream * this, void * file, _Bool sepDefault, _Bool sepOnOff, const char * separator, const char * tupleSeparator ) {
    32         this->file = file;
    33         this->sepDefault = sepDefault;
    34         this->sepOnOff = sepOnOff;
    35         sepSet( this, separator );
    36         sepSetCur( this, sepGet( this ) );
    37         sepSetTuple( this, tupleSeparator );
     31void ?{}( ofstream & this, void * file, _Bool sepDefault, _Bool sepOnOff, const char * separator, const char * tupleSeparator ) {
     32        this.file = file;
     33        this.sepDefault = sepDefault;
     34        this.sepOnOff = sepOnOff;
     35        sepSet( &this, separator );
     36        sepSetCur( &this, sepGet( &this ) );
     37        sepSetTuple( &this, tupleSeparator );
    3838}
    3939
     
    9494                exit( EXIT_FAILURE );
    9595        } // if
    96         ?{}( os, file, true, false, " ", ", " );
     96        ?{}( *os, file, true, false, " ", ", " );
    9797} // open
    9898
  • src/libcfa/iterator

    rbf30ab3 ra493682  
    1919trait iterator( otype iterator_type, otype elt_type ) {
    2020        // point to the next element
    21 //      iterator_type ?++( iterator_type * );
    22         iterator_type ++?( iterator_type * );
    23         iterator_type --?( iterator_type * );
     21//      iterator_type ?++( iterator_type & );
     22        iterator_type ++?( iterator_type & );
     23        iterator_type --?( iterator_type & );
    2424
    2525        // can be tested for equality with other iterators
  • src/libcfa/rational

    rbf30ab3 ra493682  
    3131        int ?>?( T, T );
    3232        int ?>=?( T, T );
    33         void ?{}( T *, zero_t );
    34         void ?{}( T *, one_t );
     33        void ?{}( T &, zero_t );
     34        void ?{}( T &, one_t );
    3535        T +?( T );
    3636        T -?( T );
     
    5454
    5555forall( otype RationalImpl | arithmetic( RationalImpl ) )
    56 void ?{}( Rational(RationalImpl) * r );
     56void ?{}( Rational(RationalImpl) & r );
    5757
    5858forall( otype RationalImpl | arithmetic( RationalImpl ) )
    59 void ?{}( Rational(RationalImpl) * r, RationalImpl n );
     59void ?{}( Rational(RationalImpl) & r, RationalImpl n );
    6060
    6161forall( otype RationalImpl | arithmetic( RationalImpl ) )
    62 void ?{}( Rational(RationalImpl) * r, RationalImpl n, RationalImpl d );
     62void ?{}( Rational(RationalImpl) & r, RationalImpl n, RationalImpl d );
    6363
    6464forall( otype RationalImpl | arithmetic( RationalImpl ) )
    65 void ?{}( Rational(RationalImpl) * r, zero_t );
     65void ?{}( Rational(RationalImpl) & r, zero_t );
    6666
    6767forall( otype RationalImpl | arithmetic( RationalImpl ) )
    68 void ?{}( Rational(RationalImpl) * r, one_t );
     68void ?{}( Rational(RationalImpl) & r, one_t );
    6969
    7070// numerator/denominator getter
     
    7777
    7878forall( otype RationalImpl | arithmetic( RationalImpl ) )
    79 [ RationalImpl, RationalImpl ] ?=?( * [ RationalImpl, RationalImpl ] dest, Rational(RationalImpl) src );
     79[ RationalImpl, RationalImpl ] ?=?( & [ RationalImpl, RationalImpl ] dest, Rational(RationalImpl) src );
    8080
    8181// numerator/denominator setter
  • src/libcfa/rational.c

    rbf30ab3 ra493682  
    1 // 
     1//
    22// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
    33//
    44// The contents of this file are covered under the licence agreement in the
    55// file "LICENCE" distributed with Cforall.
    6 // 
    7 // rational.c -- 
    8 // 
     6//
     7// rational.c --
     8//
    99// Author           : Peter A. Buhr
    1010// Created On       : Wed Apr  6 17:54:28 2016
     
    1212// Last Modified On : Tue May 16 18:35:36 2017
    1313// Update Count     : 150
    14 // 
     14//
    1515
    1616#include "rational"
     
    4747
    4848forall( otype RationalImpl | arithmetic( RationalImpl ) )
    49 void ?{}( Rational(RationalImpl) * r ) {
     49void ?{}( Rational(RationalImpl) & r ) {
    5050        r{ (RationalImpl){0}, (RationalImpl){1} };
    5151} // rational
    5252
    5353forall( otype RationalImpl | arithmetic( RationalImpl ) )
    54 void ?{}( Rational(RationalImpl) * r, RationalImpl n ) {
     54void ?{}( Rational(RationalImpl) & r, RationalImpl n ) {
    5555        r{ n, (RationalImpl){1} };
    5656} // rational
    5757
    5858forall( otype RationalImpl | arithmetic( RationalImpl ) )
    59 void ?{}( Rational(RationalImpl) * r, RationalImpl n, RationalImpl d ) {
     59void ?{}( Rational(RationalImpl) & r, RationalImpl n, RationalImpl d ) {
    6060        RationalImpl t = simplify( &n, &d );                            // simplify
    6161        r->numerator = n / t;
     
    7777
    7878forall( otype RationalImpl | arithmetic( RationalImpl ) )
    79 [ RationalImpl, RationalImpl ] ?=?( * [ RationalImpl, RationalImpl ] dest, Rational(RationalImpl) src ) {
     79[ RationalImpl, RationalImpl ] ?=?( & [ RationalImpl, RationalImpl ] dest, Rational(RationalImpl) src ) {
    8080        return *dest = src.[ numerator, denominator ];
    8181}
  • src/libcfa/stdlib.c

    rbf30ab3 ra493682  
    4141forall( dtype T | sized(T), ttype Params | { void ?{}( T &, Params ); } )
    4242T * new( Params p ) {
    43         return (malloc()){ p };                                                         // run constructor
     43        return &(*malloc()){ p };                                                               // run constructor
    4444} // new
    4545
     
    6767        T *arr = alloc( dim );
    6868        for ( unsigned int i = 0; i < dim; i += 1 ) {
    69                 (&arr[i]){ p };                                                                 // run constructor
     69                (arr[i]){ p };                                                                  // run constructor
    7070        } // for
    7171        return arr;
     
    7676        if ( arr ) {                                                                            // ignore null
    7777                for ( int i = dim - 1; i >= 0; i -= 1 ) {               // reverse allocation order, must be unsigned
    78                         ^(&arr[i]){};                                                           // run destructor
     78                        ^(arr[i]){};                                                            // run destructor
    7979                } // for
    8080                free( arr );
     
    8686        if ( arr ) {                                                                            // ignore null
    8787                for ( int i = dim - 1; i >= 0; i -= 1 ) {               // reverse allocation order, must be unsigned
    88                         ^(&arr[i]){};                                                           // run destructor
     88                        ^(arr[i]){};                                                            // run destructor
    8989                } // for
    9090                free( arr );
Note: See TracChangeset for help on using the changeset viewer.