Changeset 58ebd78 for libcfa


Ignore:
Timestamp:
Aug 31, 2021, 1:49:09 AM (3 years ago)
Author:
Jacob Prud'homme <jafprudhomme@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, pthread-emulation, qualifiedEnum
Children:
8f01cb04
Parents:
7582458
git-author:
Jacob Prud'homme <jafprudhomme@…> (07/16/21 15:06:54)
git-committer:
Jacob Prud'homme <jafprudhomme@…> (08/31/21 01:49:09)
Message:

Made some small changes

Comments, spacing, etc.

Location:
libcfa/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/parseconfig.cfa

    r7582458 r58ebd78  
    77        * [ char *, char * ] data;
    88};
    9 void ?{}( VLA & vla ) with ( vla ) {    // default constructor
     9void ?{}( KVPairs & kvp ) with ( kvp ) {        // default constructor
    1010        size = 0; max_size = 0; data = 0p;
    1111}
    12 void ?{}( VLA & vla, int size, char fill = ['\0', '\0'] ) { // initialization
    13         vla.[ size, max_size, data ] = [ 0, max_size, alloc( size, fill ) ];
     12void ?{}( KVPairs & kvp, int size ) {           // initialization
     13        kvp.[ size, max_size ] = [ 0, size ];
     14        kvp.data = alloc( size );
    1415}
    15 void ?{}( VLA & vla, VLA val ) with( val ) { // copy, deep
    16         vla.[ size, max_size, data ] = [ size, max_size, alloc( size, data ) ];
    17 }
    18 void ^?{}( VLA & vla ) with ( vla ) {   // destructor
     16void ^?{}( KVPairs & kvp ) with ( kvp ) {       // destructor
    1917        free( data );
    2018        size = 0; max_size = 0; data = 0p;
    2119}
    2220
    23 void add_kv_pair( KVPairs kv_pairs, char * k, char * v ) with( kv_pairs ) {
     21void add_kv_pair( KVPairs kv_pairs, char * k, char * v ) with ( kv_pairs ) {
    2422        if ( size == max_size ) {
    25                 max_size = max_size * 2;
     23                max_size *= 2;
    2624                data = resize( data, max_size );
    2725        }
     
    4240
    4341// Parse configuration from a file formatted in shell style
    44 KVPairs & parse_shell_config_format( const char * config_file ) {
    45         KVPairs kv_pairs{ num_entries };
     42KVPairs & parse_shell_config_format( const char * config_file, size_t num_entries ) {
     43        KVPairs kv_pairs = { num_entries };
    4644
    4745        ifstream in;
     
    6967}
    7068
    71 // Process the configuration file to set the simulation parameters.
     69// Parse configuration values from intermediate format
    7270void parse_config( const char * config_file, config_entry entries[], size_t num_entries ) {
    73         KVPairs kv_pairs = parse_shell_config_format( config_file );
     71        KVPairs kv_pairs = parse_shell_config_format( config_file, num_entries );
    7472
    75         // *** WE MUST ALLOW SOME SORT OF VALIDATION FUNCTIONALITY TOO!!! ***
    7673        int entries_so_far = 0;
    7774        for ( i; kv_pairs.size ) {
     
    8885                        }
    8986
    90                         serr | "Value " | src_value | " for key " | dest_key | " could not be parsed";
     87                        serr | "Value '" | src_value | "' for key '" | src_key | "' could not be parsed";
    9188                }
    9289        }
  • libcfa/src/parseconfig.hfa

    r7582458 r58ebd78  
    44        const char * key;
    55        void * variable;
    6         bool (*parse)(const char *, void *);
     6        bool (*parse)( const char *, void * );
    77};
    88
    99static inline void ?{}( config_entry & this ) {}
    1010
    11 forall(T & | { bool parse(const char *, T & ); })
     11forall(T & | { bool parse( const char *, T & ); })
    1212static inline void ?{}( config_entry & this, const char * key, T & variable ) {
    1313        this.key      = key;
Note: See TracChangeset for help on using the changeset viewer.