Changeset 76acb60 for libcfa


Ignore:
Timestamp:
Aug 5, 2023, 1:08:10 PM (10 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
6d5790d
Parents:
419985c
Message:

remove static from Exception macro

Location:
libcfa/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/common.hfa

    r419985c r76acb60  
    1010// Created On       : Wed Jul 11 17:54:36 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Aug  5 11:52:08 2023
    13 // Update Count     : 26
     12// Last Modified On : Sat Aug  5 13:05:27 2023
     13// Update Count     : 32
    1414//
    1515
     
    1717
    1818// TEMPORARY
    19 #define Exception( name ) exception name{}; static vtable( name ) name ## _vt
     19#define Exception( name ) exception name{}; vtable( name ) name ## _vt
    2020#define Throw( name ) throw (name){ &name ## _vt }
    2121
  • libcfa/src/stdlib.cfa

    r419985c r76acb60  
    1010// Created On       : Thu Jan 28 17:10:29 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 16 16:31:34 2023
    13 // Update Count     : 633
     12// Last Modified On : Sat Aug  5 11:53:43 2023
     13// Update Count     : 637
    1414//
    1515
     
    6565//---------------------------------------
    6666
    67 float _Complex strto( const char sptr[], char ** eptr ) {
     67static vtable(out_of_range) out_of_range_vt;
     68static vtable(invalid_argument) invalid_argument_vt;
     69
     70forall( T | { T strto( const char sptr[], char * eptr[], int ); } )
     71T convert( const char sptr[] ) {
     72        char * eptr;
     73        errno = 0;                                                                                      // reset
     74        T val = strto( sptr, &eptr, 10 );                                       // attempt conversion
     75        if ( errno == ERANGE ) Throw( out_of_range );
     76        if ( eptr == sptr ||                                                            // conversion failed, no characters generated
     77                 *eptr != '\0' ) Throw( invalid_argument );             // not at end of str ?
     78        return val;
     79} // convert
     80
     81float _Complex strto( const char sptr[], char * eptr[] ) {
    6882        float re, im;
    6983        char * eeptr;
     
    7690} // strto
    7791
    78 double _Complex strto( const char sptr[], char ** eptr ) {
     92double _Complex strto( const char sptr[], char * eptr[] ) {
    7993        double re, im;
    8094        char * eeptr;
     
    87101} // strto
    88102
    89 long double _Complex strto( const char sptr[], char ** eptr ) {
     103long double _Complex strto( const char sptr[], char * eptr[] ) {
    90104        long double re, im;
    91105        char * eeptr;
  • libcfa/src/stdlib.hfa

    r419985c r76acb60  
    1010// Created On       : Thu Jan 28 17:12:35 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb  2 11:30:04 2023
    13 // Update Count     : 766
     12// Last Modified On : Sat Aug  5 11:53:42 2023
     13// Update Count     : 774
    1414//
    1515
     
    2222#include <stdlib.h>                                                                             // *alloc, strto*, ato*
    2323#include <heap.hfa>
    24 
     24#include <errno.h>
    2525
    2626// Reduce includes by explicitly defining these routines.
     
    294294
    295295static inline {
    296         int strto( const char sptr[], char ** eptr, int base ) { return (int)strtol( sptr, eptr, base ); }
    297         unsigned int strto( const char sptr[], char ** eptr, int base ) { return (unsigned int)strtoul( sptr, eptr, base ); }
    298         long int strto( const char sptr[], char ** eptr, int base ) { return strtol( sptr, eptr, base ); }
    299         unsigned long int strto( const char sptr[], char ** eptr, int base ) { return strtoul( sptr, eptr, base ); }
    300         long long int strto( const char sptr[], char ** eptr, int base ) { return strtoll( sptr, eptr, base ); }
    301         unsigned long long int strto( const char sptr[], char ** eptr, int base ) { return strtoull( sptr, eptr, base ); }
    302 
    303         float strto( const char sptr[], char ** eptr ) { return strtof( sptr, eptr ); }
    304         double strto( const char sptr[], char ** eptr ) { return strtod( sptr, eptr ); }
    305         long double strto( const char sptr[], char ** eptr ) { return strtold( sptr, eptr ); }
    306 } // distribution
    307 
    308 float _Complex strto( const char sptr[], char ** eptr );
    309 double _Complex strto( const char sptr[], char ** eptr );
    310 long double _Complex strto( const char sptr[], char ** eptr );
     296        int strto( const char sptr[], char * eptr[], int base ) { return (int)strtol( sptr, eptr, base ); }
     297        unsigned int strto( const char sptr[], char * eptr[], int base ) { return (unsigned int)strtoul( sptr, eptr, base ); }
     298        long int strto( const char sptr[], char * eptr[], int base ) { return strtol( sptr, eptr, base ); }
     299        unsigned long int strto( const char sptr[], char * eptr[], int base ) { return strtoul( sptr, eptr, base ); }
     300        long long int strto( const char sptr[], char * eptr[], int base ) { return strtoll( sptr, eptr, base ); }
     301        unsigned long long int strto( const char sptr[], char * eptr[], int base ) { return strtoull( sptr, eptr, base ); }
     302
     303        float strto( const char sptr[], char * eptr[] ) { return strtof( sptr, eptr ); }
     304        double strto( const char sptr[], char * eptr[] ) { return strtod( sptr, eptr ); }
     305        long double strto( const char sptr[], char * eptr[] ) { return strtold( sptr, eptr ); }
     306} // distribution
     307
     308float _Complex strto( const char sptr[], char * eptr[] );
     309double _Complex strto( const char sptr[], char * eptr[] );
     310long double _Complex strto( const char sptr[], char * eptr[] );
     311
     312exception out_of_range {};
     313exception invalid_argument {};
     314
     315forall( T | { T strto( const char sptr[], char * eptr[], int ); } )
     316T convert( const char sptr[] );
    311317
    312318static inline {
Note: See TracChangeset for help on using the changeset viewer.