mirror of
https://git.savannah.gnu.org/git/gperf.git
synced 2025-12-02 13:09:22 +00:00
Move the output routines to output.h and output.cc.
This commit is contained in:
11
ChangeLog
11
ChangeLog
@@ -1,3 +1,14 @@
|
|||||||
|
2002-10-04 Bruno Haible <bruno@clisp.org>
|
||||||
|
|
||||||
|
* src/output.h: New file, extracted from key-list.h.
|
||||||
|
* src/output.cc: New file, extracted from key-list.cc.
|
||||||
|
* src/key-list.h (Key_List): Make some fields protected. Move output
|
||||||
|
routines to src/output.h.
|
||||||
|
* src/key-list.cc: Move output routines to src/output.cc.
|
||||||
|
* src/gen-perf.cc (Gen_Perf::doit_all): Use class Output.
|
||||||
|
* src/Makefile.in (OBJECTS): Add output.o.
|
||||||
|
(output.o): New rule.
|
||||||
|
|
||||||
2002-10-03 Bruno Haible <bruno@clisp.org>
|
2002-10-03 Bruno Haible <bruno@clisp.org>
|
||||||
|
|
||||||
* src/iterator.h: Remove file.
|
* src/iterator.h: Remove file.
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ VPATH = $(srcdir)
|
|||||||
|
|
||||||
OBJECTS = options.o main.o gen-perf.o key-list.o \
|
OBJECTS = options.o main.o gen-perf.o key-list.o \
|
||||||
hash-table.o bool-array.o read-line.o vectors.o version.o \
|
hash-table.o bool-array.o read-line.o vectors.o version.o \
|
||||||
keyword.o keyword-list.o
|
keyword.o keyword-list.o output.o
|
||||||
LIBS = ../lib/libgp.a @GPERF_LIBM@
|
LIBS = ../lib/libgp.a @GPERF_LIBM@
|
||||||
CPPFLAGS = -I. -I$(srcdir)/../lib
|
CPPFLAGS = -I. -I$(srcdir)/../lib
|
||||||
|
|
||||||
@@ -114,6 +114,8 @@ keyword.o : keyword.cc keyword.h
|
|||||||
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(srcdir)/keyword.cc
|
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(srcdir)/keyword.cc
|
||||||
keyword-list.o : keyword-list.cc keyword-list.h
|
keyword-list.o : keyword-list.cc keyword-list.h
|
||||||
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(srcdir)/keyword-list.cc
|
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(srcdir)/keyword-list.cc
|
||||||
|
output.o : output.cc output.h
|
||||||
|
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(srcdir)/output.cc
|
||||||
|
|
||||||
install : all force
|
install : all force
|
||||||
$(MKINSTALLDIRS) $(DESTDIR)$(bindir)
|
$(MKINSTALLDIRS) $(DESTDIR)$(bindir)
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
|
|||||||
#include <time.h> /* declares time() */
|
#include <time.h> /* declares time() */
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "gen-perf.h"
|
#include "gen-perf.h"
|
||||||
|
#include "output.h"
|
||||||
|
|
||||||
/* Efficiently returns the least power of two greater than or equal to X! */
|
/* Efficiently returns the least power of two greater than or equal to X! */
|
||||||
#define POW(X) ((!X)?1:(X-=1,X|=X>>1,X|=X>>2,X|=X>>4,X|=X>>8,X|=X>>16,(++X)))
|
#define POW(X) ((!X)?1:(X-=1,X|=X>>1,X|=X>>2,X|=X>>4,X|=X>>8,X|=X>>16,(++X)))
|
||||||
@@ -331,7 +332,10 @@ Gen_Perf::doit_all (void)
|
|||||||
processing turned out O.K. */
|
processing turned out O.K. */
|
||||||
|
|
||||||
sort ();
|
sort ();
|
||||||
output ();
|
Output outputter (head, array_type, return_type, struct_tag, additional_code,
|
||||||
|
include_src, total_keys, total_duplicates, max_key_len,
|
||||||
|
min_key_len, this);
|
||||||
|
outputter.output ();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
1447
src/key-list.cc
1447
src/key-list.cc
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
/* Data and function member declarations for the keyword list class.
|
/* Data and function member declarations for the keyword list class.
|
||||||
|
|
||||||
Copyright (C) 1989-1998 Free Software Foundation, Inc.
|
Copyright (C) 1989-1998, 2002 Free Software Foundation, Inc.
|
||||||
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
||||||
|
|
||||||
This file is part of GNU GPERF.
|
This file is part of GNU GPERF.
|
||||||
@@ -33,26 +33,25 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
|
|||||||
#include "vectors.h"
|
#include "vectors.h"
|
||||||
#include "read-line.h"
|
#include "read-line.h"
|
||||||
|
|
||||||
/* OSF/1 cxx needs these forward declarations. */
|
|
||||||
struct Output_Constants;
|
|
||||||
struct Output_Compare;
|
|
||||||
|
|
||||||
class Key_List : private Read_Line, public Vectors
|
class Key_List : private Read_Line, public Vectors
|
||||||
{
|
{
|
||||||
private:
|
protected:
|
||||||
const char *array_type; /* Pointer to the type for word 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 *return_type; /* Pointer to return type for lookup function. */
|
||||||
const char *struct_tag; /* Shorthand for user-defined struct tag type. */
|
const char *struct_tag; /* Shorthand for user-defined struct tag type. */
|
||||||
const char *include_src; /* C source code to be included verbatim. */
|
const char *include_src; /* C source code to be included verbatim. */
|
||||||
int max_key_len; /* Maximum length of the longest keyword. */
|
int max_key_len; /* Maximum length of the longest keyword. */
|
||||||
int min_key_len; /* Minimum length of the shortest keyword. */
|
int min_key_len; /* Minimum length of the shortest keyword. */
|
||||||
int min_hash_value; /* Minimum hash value for all keywords. */
|
private:
|
||||||
int max_hash_value; /* Maximum hash value for all keywords. */
|
|
||||||
int occurrence_sort; /* True if sorting by occurrence. */
|
int occurrence_sort; /* True if sorting by occurrence. */
|
||||||
int hash_sort; /* True if sorting by hash value. */
|
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 total_keys; /* Total number of keys, counting duplicates. */
|
||||||
|
private:
|
||||||
static int determined[MAX_ALPHA_SIZE]; /* Used in function reorder, below. */
|
static int determined[MAX_ALPHA_SIZE]; /* Used in function reorder, below. */
|
||||||
static int get_occurrence (KeywordExt *ptr);
|
static int get_occurrence (KeywordExt *ptr);
|
||||||
#ifndef strcspn
|
#ifndef strcspn
|
||||||
@@ -60,16 +59,6 @@ private:
|
|||||||
#endif
|
#endif
|
||||||
static int already_determined (KeywordExt *ptr);
|
static int already_determined (KeywordExt *ptr);
|
||||||
static void set_determined (KeywordExt *ptr);
|
static void set_determined (KeywordExt *ptr);
|
||||||
void compute_min_max (void);
|
|
||||||
int num_hash_values (void);
|
|
||||||
void output_constants (struct Output_Constants&);
|
|
||||||
void output_hash_function (void);
|
|
||||||
void output_keylength_table (void);
|
|
||||||
void output_keyword_table (void);
|
|
||||||
void output_lookup_array (void);
|
|
||||||
void output_lookup_tables (void);
|
|
||||||
void output_lookup_function_body (const struct Output_Compare&);
|
|
||||||
void output_lookup_function (void);
|
|
||||||
void set_output_types (void);
|
void set_output_types (void);
|
||||||
void dump (void);
|
void dump (void);
|
||||||
const char *get_array_type (void);
|
const char *get_array_type (void);
|
||||||
@@ -90,7 +79,6 @@ public:
|
|||||||
void reorder (void);
|
void reorder (void);
|
||||||
void sort (void);
|
void sort (void);
|
||||||
void read_keys (void);
|
void read_keys (void);
|
||||||
void output (void);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
1483
src/output.cc
Normal file
1483
src/output.cc
Normal file
File diff suppressed because it is too large
Load Diff
79
src/output.h
Normal file
79
src/output.h
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
/* This may look like C code, but it is really -*- C++ -*- */
|
||||||
|
|
||||||
|
/* Output routines.
|
||||||
|
|
||||||
|
Copyright (C) 1989-1998, 2000, 2002 Free Software Foundation, Inc.
|
||||||
|
Written by Bruno Haible <bruno@clisp.org>.
|
||||||
|
|
||||||
|
This file is part of GNU GPERF.
|
||||||
|
|
||||||
|
GNU GPERF is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 1, or (at your option)
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
GNU GPERF is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with GNU GPERF; see the file COPYING. If not, write to the Free
|
||||||
|
Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
|
||||||
|
|
||||||
|
#ifndef output_h
|
||||||
|
#define output_h 1
|
||||||
|
|
||||||
|
#include "keyword-list.h"
|
||||||
|
#include "vectors.h"
|
||||||
|
|
||||||
|
/* OSF/1 cxx needs these forward declarations. */
|
||||||
|
struct Output_Constants;
|
||||||
|
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 (void);
|
||||||
|
private:
|
||||||
|
void compute_min_max (void);
|
||||||
|
int num_hash_values (void);
|
||||||
|
void output_constants (struct Output_Constants&);
|
||||||
|
void output_hash_function (void);
|
||||||
|
void output_keylength_table (void);
|
||||||
|
void output_keyword_table (void);
|
||||||
|
void output_lookup_array (void);
|
||||||
|
void output_lookup_tables (void);
|
||||||
|
void output_lookup_function_body (const struct Output_Compare&);
|
||||||
|
void output_lookup_function (void);
|
||||||
|
|
||||||
|
/* Linked list of keywords. */
|
||||||
|
KeywordExt_List *head;
|
||||||
|
|
||||||
|
/* Pointer to the type for word list. */
|
||||||
|
const char *array_type;
|
||||||
|
/* Pointer to return type for lookup function. */
|
||||||
|
const char *return_type;
|
||||||
|
/* Shorthand for user-defined struct tag type. */
|
||||||
|
const char *struct_tag;
|
||||||
|
/* True if any additional C code is included. */
|
||||||
|
int additional_code;
|
||||||
|
/* C source code to be included verbatim. */
|
||||||
|
const char *include_src;
|
||||||
|
/* Total number of keys, counting duplicates. */
|
||||||
|
int total_keys;
|
||||||
|
/* Total number of duplicate hash values. */
|
||||||
|
int total_duplicates;
|
||||||
|
/* Maximum length of the longest keyword. */
|
||||||
|
int max_key_len;
|
||||||
|
/* Minimum length of the shortest keyword. */
|
||||||
|
int min_key_len;
|
||||||
|
/* Minimum hash value for all keywords. */
|
||||||
|
int min_hash_value;
|
||||||
|
/* Maximum hash value for all keywords. */
|
||||||
|
int max_hash_value;
|
||||||
|
Vectors * v;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user