Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / ACE / apps / gperf / src / Key_List.h
blob62a104868126eb98bc370eb7a9379c2f0d5f82b2
1 // -*- C++ -*-
3 /**
4 * Copyright (C) 1989 Free Software Foundation, Inc.
5 * written by Douglas C. Schmidt (d.schmidt@vanderbilt.edu)
7 * This file is part of GNU GPERF.
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #ifndef KEY_LIST_H
25 #define KEY_LIST_H
27 #include "Options.h"
29 #include "List_Node.h"
30 #include "Vectors.h"
31 #include "ace/Copy_Disabled.h"
33 /**
34 * Describes a duplicate entry.
36 * This is used for generating code by the <Key_List>.
38 class Duplicate_Entry : private ACE_Copy_Disabled
40 public:
41 /// Hash value for this particular duplicate set.
42 int hash_value;
44 /// Slot into the main keyword storage array.
45 int slot;
47 /// Number of consecutive duplicates at this slot.
48 int count;
51 /**
52 * Data and function member declarations for the keyword list class.
54 * The key word list is a useful abstraction that keeps track of
55 * various pieces of information that enable that fast generation of
56 * the Gen_Perf.hash function. A Key_List is a singly-linked list
57 * of List_Nodes.
59 class Key_List : private ACE_Copy_Disabled
61 public:
62 Key_List ();
63 ~Key_List ();
64 int keyword_list_length ();
65 int max_key_length ();
66 void reorder ();
67 void sort ();
68 void string_sort ();
69 int read_keys ();
70 int output ();
72 /// Points to the head of the linked list.
73 List_Node *head;
75 /// Total number of duplicate hash values.
76 int total_duplicates;
78 private:
79 // = Make hash table 10 times larger than # of keyword entries.
80 enum
82 TABLE_MULTIPLE = 10
85 static int occurrence (List_Node *ptr);
86 static int already_determined (List_Node *ptr);
87 static void determined (List_Node *ptr);
89 // @@ All of the following methods should be factored out and
90 // replaced by the use of the Strategy/Bridge pattern so that we can
91 // easily add new languages.
92 void output_min_max ();
93 void output_switch (int use_keyword_table = 0);
94 void output_keyword_table ();
95 void output_keylength_table ();
96 void output_hash_function ();
97 void output_lookup_function ();
98 int output_binary_search_function();
99 int output_linear_search_function ();
100 int output_lookup_array ();
101 void output_strcasecmp ();
102 int output_types ();
103 void dump ();
104 char *array_type ();
105 char *save_include_src ();
106 char *special_input (char delimiter);
107 List_Node *merge (List_Node *list1, List_Node *list2);
108 List_Node *merge_sort (List_Node *head);
109 int count_duplicates (List_Node *link, const char *type);
110 void update_lookup_array (int lookup_array[],
111 int i1,
112 int i2,
113 Duplicate_Entry *dup_ptr,
114 int value);
115 /// Pointer to the type for word list.
116 char *array_type_;
118 // Pointer to return type for lookup function.
119 char *return_type;
121 /// Shorthand for user-defined struct tag type.
122 char *struct_tag;
124 /// C source code to be included verbatim.
125 char *include_src;
127 /// Maximum length of the longest keyword.
128 int max_key_len;
130 /// Minimum length of the shortest keyword.
131 int min_key_len;
133 /// Minimum hash value for all keywords.
134 int min_hash_value;
136 /// Maximum hash value for all keywords.
137 int max_hash_value;
139 /// True if sorting by occurrence.
140 int occurrence_sort;
142 /// True if sorting by hash value.
143 int hash_sort;
145 /// True if sorting by key value.
146 int key_sort;
148 /// True if any additional C code is included.
149 int additional_code;
151 /// Length of head's Key_List, not counting duplicates.
152 int list_len;
154 /// Total number of keys, counting duplicates.
155 int total_keys;
157 /// Default type for generated code.
158 static const char *const default_array_type;
160 /// in_word_set return type, by default.
161 static const char *const default_return_type;
163 /// How wide the printed field width must be to contain the maximum
164 /// hash value.
165 static int field_width;
167 /// Sets the slot location for all keysig characters that are now
168 /// determined.
169 static int determined_[ACE_STANDARD_CHARACTER_SET_SIZE];
172 #endif /* KEY_LIST_H */