1
0
mirror of https://git.savannah.gnu.org/git/gperf.git synced 2025-12-02 13:09:22 +00:00

Align all member declarations.

This commit is contained in:
Bruno Haible
2002-11-18 12:52:33 +00:00
parent ef7645289d
commit 4cda19576b
13 changed files with 189 additions and 185 deletions

View File

@@ -1,3 +1,7 @@
2002-10-16 Bruno Haible <bruno@clisp.org>
* src/*.h: Align all member names at column 24.
2002-10-15 Bruno Haible <bruno@clisp.org>
* src/input.h: New file.

View File

@@ -38,28 +38,28 @@ class Bool_Array
public:
/* Initializes the bit array with room for SIZE bits, numbered from
0 to SIZE-1. */
Bool_Array (unsigned int size);
Bool_Array (unsigned int size);
/* Frees this object. */
~Bool_Array ();
~Bool_Array ();
/* Resets all bits to zero. */
void clear ();
void clear ();
/* Sets the specified bit to one. Returns its previous value (0 or 1). */
int set_bit (unsigned int index);
int set_bit (unsigned int index);
private:
/* Size of array. */
unsigned int const _size;
unsigned int const _size;
/* Current iteration number. Always nonzero. Starts out as 1, and is
incremented each time clear() is called. */
unsigned int _iteration_number;
unsigned int _iteration_number;
/* For each index, we store in storage_array[index] the iteration_number at
the time set_bit(index) was last called. */
unsigned int * const _storage_array;
unsigned int * const _storage_array;
};
#ifdef __OPTIMIZE__ /* efficiency hack! */

View File

@@ -31,21 +31,21 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
class Gen_Perf : private Key_List
{
private:
int _max_hash_value; /* Maximum possible hash value. */
int _fewest_collisions; /* Records fewest # of collisions for asso value. */
int _num_done; /* Number of keywords processed without a collision. */
Bool_Array *_collision_detector;
int _max_hash_value; /* Maximum possible hash value. */
int _fewest_collisions; /* Records fewest # of collisions for asso value. */
int _num_done; /* Number of keywords processed without a collision. */
Bool_Array * _collision_detector;
void change (KeywordExt *prior, KeywordExt *curr);
int affects_prev (char c, KeywordExt *curr);
static int hash (KeywordExt *key_node);
static int compute_disjoint_union (const char *set_1, int size_1, const char *set_2, int size_2, char *set_3);
static void sort_set (char *union_set, int len);
void change (KeywordExt *prior, KeywordExt *curr);
int affects_prev (char c, KeywordExt *curr);
static int hash (KeywordExt *key_node);
static int compute_disjoint_union (const char *set_1, int size_1, const char *set_2, int size_2, char *set_3);
static void sort_set (char *union_set, int len);
public:
Gen_Perf ();
~Gen_Perf ();
int doit_all ();
Gen_Perf ();
~Gen_Perf ();
int doit_all ();
};
#endif

View File

@@ -29,15 +29,15 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
class Hash_Table
{
private:
KeywordExt **_table; /* Vector of pointers to linked lists of keywords. */
int _size; /* Size of the vector. */
int _collisions; /* Find out how well our double hashing is working! */
int _ignore_length;
KeywordExt ** _table; /* Vector of pointers to linked lists of keywords. */
int _size; /* Size of the vector. */
int _collisions; /* Find out how well our double hashing is working! */
int _ignore_length;
public:
Hash_Table (KeywordExt **t, int s, int ignore_len);
~Hash_Table ();
KeywordExt *insert (KeywordExt *item);
Hash_Table (KeywordExt **t, int s, int ignore_len);
~Hash_Table ();
KeywordExt * insert (KeywordExt *item);
};
#endif

View File

@@ -31,22 +31,22 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
class Input : private Read_Line
{
public:
void read_keys ();
void read_keys ();
private:
#ifndef strcspn
static int strcspn (const char *s, const char *reject);
static int strcspn (const char *s, const char *reject);
#endif
void set_output_types ();
const char *get_array_type ();
const char *save_include_src ();
const char *get_special_input (char delimiter);
void set_output_types ();
const char * get_array_type ();
const char * save_include_src ();
const char * get_special_input (char delimiter);
public:
const char *_array_type; /* Pointer to the type for word list. */
const char *_return_type; /* Pointer to return type for lookup function. */
const char *_struct_tag; /* Shorthand for user-defined struct tag type. */
const char *_include_src; /* C source code to be included verbatim. */
int _additional_code; /* True if any additional C code is included. */
KeywordExt_List *_head; /* Points to the head of the linked list. */
const char * _array_type; /* Pointer to the type for word list. */
const char * _return_type; /* Pointer to return type for lookup function. */
const char * _struct_tag; /* Shorthand for user-defined struct tag type. */
const char * _include_src; /* C source code to be included verbatim. */
int _additional_code; /* True if any additional C code is included. */
KeywordExt_List * _head; /* Points to the head of the linked list. */
};
#endif

View File

@@ -36,46 +36,46 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
class Key_List : public Vectors
{
protected:
const char *_array_type; /* Pointer to the type for word list. */
const char *_return_type; /* Pointer to return type for lookup function. */
const char *_struct_tag; /* Shorthand for user-defined struct tag type. */
const char *_include_src; /* C source code to be included verbatim. */
int _max_key_len; /* Maximum length of the longest keyword. */
int _min_key_len; /* Minimum length of the shortest keyword. */
const char * _array_type; /* Pointer to the type for word list. */
const char * _return_type; /* Pointer to return type for lookup function. */
const char * _struct_tag; /* Shorthand for user-defined struct tag type. */
const char * _include_src; /* C source code to be included verbatim. */
int _max_key_len; /* Maximum length of the longest keyword. */
int _min_key_len; /* Minimum length of the shortest keyword. */
private:
int _occurrence_sort; /* True if sorting by occurrence. */
int _hash_sort; /* True if sorting by hash value. */
int _occurrence_sort; /* True if sorting by occurrence. */
int _hash_sort; /* True if sorting by hash value. */
protected:
int _additional_code; /* True if any additional C code is included. */
int _additional_code; /* True if any additional C code is included. */
private:
int _list_len; /* Length of head's Key_List, not counting duplicates. */
int _list_len; /* Length of head's Key_List, not counting duplicates. */
protected:
int _total_keys; /* Total number of keys, counting duplicates. */
int _size; /* Range of the hash table. */
int _total_keys; /* Total number of keys, counting duplicates. */
int _size; /* Range of the hash table. */
private:
static int _determined[MAX_ALPHA_SIZE]; /* Used in function reorder, below. */
static int get_occurrence (KeywordExt *ptr);
static int already_determined (KeywordExt *ptr);
static void set_determined (KeywordExt *ptr);
void dump ();
KeywordExt_List *merge (KeywordExt_List *list1, KeywordExt_List *list2);
KeywordExt_List *merge_sort (KeywordExt_List *head);
static int _determined[MAX_ALPHA_SIZE]; /* Used in function reorder, below. */
static int get_occurrence (KeywordExt *ptr);
static int already_determined (KeywordExt *ptr);
static void set_determined (KeywordExt *ptr);
void dump ();
KeywordExt_List * merge (KeywordExt_List *list1, KeywordExt_List *list2);
KeywordExt_List * merge_sort (KeywordExt_List *head);
protected:
KeywordExt_List *_head; /* Points to the head of the linked list. */
int _total_duplicates; /* Total number of duplicate hash values. */
KeywordExt_List * _head; /* Points to the head of the linked list. */
int _total_duplicates; /* Total number of duplicate hash values. */
public:
Key_List ();
~Key_List ();
int keyword_list_length ();
int max_key_length ();
void reorder ();
void sort ();
void read_keys ();
int get_max_keysig_size ();
void set_asso_max (int r) { _size = r; }
int get_asso_max () { return _size; }
Key_List ();
~Key_List ();
int keyword_list_length ();
int max_key_length ();
void reorder ();
void sort ();
void read_keys ();
int get_max_keysig_size ();
void set_asso_max (int r) { _size = r; }
int get_asso_max () { return _size; }
};
#endif

View File

@@ -30,15 +30,15 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
class KeywordExt_List : private KeywordExt {
public:
/* Constructor. */
KeywordExt_List (const char *allchars, int allchars_length, const char *rest);
KeywordExt_List (const char *allchars, int allchars_length, const char *rest);
/* Access to first element of list. */
KeywordExt* first () { return this; }
KeywordExt * first () { return this; }
/* Access to next element of list. */
KeywordExt_List *& rest () { return _cdr; }
KeywordExt_List *& rest () { return _cdr; }
private:
KeywordExt_List * _cdr;
KeywordExt_List * _cdr;
};
#endif

View File

@@ -30,51 +30,51 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
struct Keyword
{
/* Constructor. */
Keyword (const char *allchars, int allchars_length, const char *rest);
Keyword (const char *allchars, int allchars_length, const char *rest);
/* Data members defined immediately by the input file. */
/* The keyword as a string, possibly containing NUL bytes. */
const char *const _allchars;
const int _allchars_length;
const char *const _allchars;
const int _allchars_length;
/* Additional stuff seen on the same line of the input file. */
const char *const _rest;
const char *const _rest;
};
/* A keyword, in the context of a given keyposition list. */
struct KeywordExt : public Keyword
{
/* Constructor. */
KeywordExt (const char *allchars, int allchars_length, const char *rest);
KeywordExt (const char *allchars, int allchars_length, const char *rest);
/* Data members depending on the keyposition list. */
/* The selected characters that participate for the hash function,
reordered according to the keyposition list. */
const char * _selchars;
int _selchars_length;
const char * _selchars;
int _selchars_length;
/* Chained list of keywords having the same selchars. */
KeywordExt * _duplicate_link;
KeywordExt * _duplicate_link;
/* Methods depending on the keyposition list. */
/* Initialize selchars and selchars_length, and update v->occurrences. */
void init_selchars (Vectors *v);
void init_selchars (Vectors *v);
/* Data members used by the algorithm. */
int _occurrence; /* A metric for frequency of key set occurrences. */
int _hash_value; /* Hash value for the key. */
int _occurrence; /* A metric for frequency of key set occurrences. */
int _hash_value; /* Hash value for the key. */
/* Data members used by the output routines. */
int _final_index;
int _final_index;
};
/* A factory for creating Keyword instances. */
class Keyword_Factory
{
public:
Keyword_Factory ();
virtual ~Keyword_Factory ();
Keyword_Factory ();
virtual ~Keyword_Factory ();
/* Creates a new Keyword. */
virtual Keyword * create_keyword (const char *allchars, int allchars_length,
const char *rest) = 0;
virtual Keyword * create_keyword (const char *allchars, int allchars_length,
const char *rest) = 0;
};
#endif

View File

@@ -295,24 +295,24 @@ Options::print_options () const
class PositionStringParser
{
public:
PositionStringParser (const char *str, int low_bound, int high_bound, int end_word_marker, int error_value, int end_marker);
int nextPosition ();
PositionStringParser (const char *str, int low_bound, int high_bound, int end_word_marker, int error_value, int end_marker);
int nextPosition ();
private:
/* A pointer to the string provided by the user. */
const char * _str;
const char * _str;
/* Smallest possible value, inclusive. */
int const _low_bound;
int const _low_bound;
/* Greatest possible value, inclusive. */
int const _high_bound;
int const _high_bound;
/* A value marking the abstract "end of word" ( usually '$'). */
int const _end_word_marker;
int const _end_word_marker;
/* Error value returned when input is syntactically erroneous. */
int const _error_value;
int const _error_value;
/* Value returned after last key is processed. */
int const _end_marker;
int _size;
int _curr_value;
int _upper_bound;
int const _end_marker;
int _size;
int _curr_value;
int _upper_bound;
};
PositionStringParser::PositionStringParser (const char *str, int low_bound, int high_bound, int end_word_marker, int error_value, int end_marker)

View File

@@ -108,34 +108,34 @@ class Positions
friend class PositionIterator;
public:
/* Denotes the last char of a keyword, depending on the keyword's length. */
static const int LASTCHAR = 0;
static const int LASTCHAR = 0;
/* Maximum size of the set. */
static const int MAX_KEY_POS = 127;
static const int MAX_KEY_POS = 127;
/* Constructors. */
Positions ();
Positions (int key1);
Positions (int key1, int key2);
Positions ();
Positions (int key1);
Positions (int key1, int key2);
/* Accessors. */
int operator[] (unsigned int index) const;
unsigned int get_size () const;
int operator[] (unsigned int index) const;
unsigned int get_size () const;
/* Write access. */
unsigned char * pointer ();
void set_size (unsigned int size);
unsigned char * pointer ();
void set_size (unsigned int size);
/* Sorts the array in reverse order.
Returns 1 if there are no duplicates, 0 otherwise. */
int sort ();
int sort ();
private:
/* Number of positions, excluding the terminating PositionIterator::EOS. */
unsigned int _size;
unsigned int _size;
/* Array of positions. 1 for the first char, 2 for the second char etc.,
LASTCHAR for the last char. PositionIterator::EOS past the end. */
unsigned char _positions[MAX_KEY_POS];
unsigned char _positions[MAX_KEY_POS];
};
/* This class denotes an iterator through a set of key positions. */
@@ -144,17 +144,17 @@ class PositionIterator
{
public:
/* Initializes an iterator through POSITIONS. */
PositionIterator (Positions const& positions);
PositionIterator (Positions const& positions);
/* End of iteration marker. */
static const int EOS = Positions::MAX_KEY_POS;
static const int EOS = Positions::MAX_KEY_POS;
/* Retrieves the next position, or EOS past the end. */
int next ();
int next ();
private:
const Positions& _set;
int _index;
const Positions& _set;
int _index;
};
/* Class manager for gperf program Options. */
@@ -163,118 +163,118 @@ class Options
{
public:
/* Constructor. */
Options ();
Options ();
/* Destructor. */
~Options ();
~Options ();
/* Parses the options given in the command-line arguments. */
void parse_options (int argc, char *argv[]);
void parse_options (int argc, char *argv[]);
/* Prints the given options. */
void print_options () const;
void print_options () const;
/* Accessors. */
/* Tests a given boolean option. Returns 1 if set, 0 otherwise. */
int operator[] (Option_Type option) const;
int operator[] (Option_Type option) const;
/* Returns the iterations value. */
int get_iterations () const;
int get_iterations () const;
/* Returns the jump value. */
int get_jump () const;
int get_jump () const;
/* Returns the initial associated character value. */
int get_initial_asso_value () const;
int get_initial_asso_value () const;
/* Returns the total number of switch statements to generate. */
int get_total_switches () const;
int get_total_switches () const;
/* Returns the factor by which to multiply the generated table's size. */
int get_size_multiple () const;
int get_size_multiple () const;
/* Returns the generated function name. */
const char * get_function_name () const;
const char * get_function_name () const;
/* Returns the keyword key name. */
const char * get_key_name () const;
const char * get_key_name () const;
/* Returns the struct initializer suffix. */
const char * get_initializer_suffix () const;
const char * get_initializer_suffix () const;
/* Returns the generated class name. */
const char * get_class_name () const;
const char * get_class_name () const;
/* Returns the hash function name. */
const char * get_hash_name () const;
const char * get_hash_name () const;
/* Returns the hash table array name. */
const char * get_wordlist_name () const;
const char * get_wordlist_name () const;
/* Returns the string used to delimit keywords from other attributes. */
const char * get_delimiter () const;
const char * get_delimiter () const;
/* Returns key positions. */
const Positions& get_key_positions () const;
const Positions& get_key_positions () const;
/* Returns total distinct key positions. */
int get_max_keysig_size () const;
int get_max_keysig_size () const;
private:
/* Prints program usage to given stream. */
void short_usage (FILE * stream) const;
void short_usage (FILE * stream) const;
/* Prints program usage to given stream. */
void long_usage (FILE * stream) const;
void long_usage (FILE * stream) const;
/* Records count of command-line arguments. */
int _argument_count;
int _argument_count;
/* Stores a pointer to command-line argument vector. */
char **_argument_vector;
char ** _argument_vector;
/* Holds the boolean options. */
int _option_word;
int _option_word;
/* Amount to iterate when a collision occurs. */
int _iterations;
int _iterations;
/* Jump length when trying alternative values. */
int _jump;
int _jump;
/* Initial value for asso_values table. */
int _initial_asso_value;
int _initial_asso_value;
/* Number of switch statements to generate. */
int _total_switches;
int _total_switches;
/* Factor by which to multiply the generated table's size. */
int _size_multiple;
int _size_multiple;
/* Names used for generated lookup function. */
const char *_function_name;
const char * _function_name;
/* Name used for keyword key. */
const char *_key_name;
const char * _key_name;
/* Suffix for empty struct initializers. */
const char *_initializer_suffix;
const char * _initializer_suffix;
/* Name used for generated C++ class. */
const char *_class_name;
const char * _class_name;
/* Name used for generated hash function. */
const char *_hash_name;
const char * _hash_name;
/* Name used for hash table array. */
const char *_wordlist_name;
const char * _wordlist_name;
/* Separates keywords from other attributes. */
const char *_delimiters;
const char * _delimiters;
/* Contains user-specified key choices. */
Positions _key_positions;
Positions _key_positions;
};
/* Global option coordinator for the entire program. */

View File

@@ -34,46 +34,46 @@ struct Output_Compare;
class Output
{
public:
Output (KeywordExt_List *head, const char *array_type, const char *return_type, const char *struct_tag, int additional_code, const char *include_src, int total_keys, int total_duplicates, int max_key_len, int min_key_len, Vectors *v);
void output ();
Output (KeywordExt_List *head, const char *array_type, const char *return_type, const char *struct_tag, int additional_code, const char *include_src, int total_keys, int total_duplicates, int max_key_len, int min_key_len, Vectors *v);
void output ();
private:
void compute_min_max ();
int num_hash_values ();
void output_constants (struct Output_Constants&);
void output_hash_function ();
void output_keylength_table ();
void output_keyword_table ();
void output_lookup_array ();
void output_lookup_tables ();
void output_lookup_function_body (const struct Output_Compare&);
void output_lookup_function ();
void compute_min_max ();
int num_hash_values ();
void output_constants (struct Output_Constants&);
void output_hash_function ();
void output_keylength_table ();
void output_keyword_table ();
void output_lookup_array ();
void output_lookup_tables ();
void output_lookup_function_body (const struct Output_Compare&);
void output_lookup_function ();
/* Linked list of keywords. */
KeywordExt_List *_head;
KeywordExt_List * _head;
/* Pointer to the type for word list. */
const char *_array_type;
const char * _array_type;
/* Pointer to return type for lookup function. */
const char *_return_type;
const char * _return_type;
/* Shorthand for user-defined struct tag type. */
const char *_struct_tag;
const char * _struct_tag;
/* True if any additional C code is included. */
int _additional_code;
int _additional_code;
/* C source code to be included verbatim. */
const char *_include_src;
const char * _include_src;
/* Total number of keys, counting duplicates. */
int _total_keys;
int _total_keys;
/* Total number of duplicate hash values. */
int _total_duplicates;
int _total_duplicates;
/* Maximum length of the longest keyword. */
int _max_key_len;
int _max_key_len;
/* Minimum length of the shortest keyword. */
int _min_key_len;
int _min_key_len;
/* Minimum hash value for all keywords. */
int _min_hash_value;
int _min_hash_value;
/* Maximum hash value for all keywords. */
int _max_hash_value;
Vectors * _v;
int _max_hash_value;
Vectors * _v;
};
#endif

View File

@@ -35,16 +35,16 @@ class Read_Line
public:
/* Initializes the instance with a given input stream. */
Read_Line (FILE *stream = stdin) : _fp (stream) {}
Read_Line (FILE *stream = stdin) : _fp (stream) {}
/* Reads the next line and returns it, excluding the terminating newline,
and ignoring lines starting with '#'. Returns NULL on error or EOF.
The storage for the string is dynamically allocated and must be freed
through delete[]. */
char *read_next_line ();
char * read_next_line ();
private:
FILE * const _fp; /* FILE pointer to the input stream. */
FILE * const _fp; /* FILE pointer to the input stream. */
};
#ifdef __OPTIMIZE__

View File

@@ -29,9 +29,9 @@ static const int MAX_ALPHA_SIZE = 256;
struct Vectors
{
static int ALPHA_SIZE; /* Size of alphabet. */
static int _occurrences[MAX_ALPHA_SIZE]; /* Counts occurrences of each key set character. */
static int _asso_values[MAX_ALPHA_SIZE]; /* Value associated with each character. */
static int ALPHA_SIZE; /* Size of alphabet. */
static int _occurrences[MAX_ALPHA_SIZE]; /* Counts occurrences of each key set character. */
static int _asso_values[MAX_ALPHA_SIZE]; /* Value associated with each character. */
};
#endif