From 1a151781eab7d2bc8bbc59bab2b882641a0c966f Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Sat, 23 Jun 2018 21:12:08 +0200 Subject: [PATCH 1/2] Clean some include statements The changes are based on an analysis done with include-what-you-use. Replace also some standard header files by the corresponding standard C++ header files. Signed-off-by: Stefan Weil --- src/arch/dotproductavx.cpp | 1 - src/arch/dotproductsse.cpp | 1 - src/arch/dotproductsse.h | 2 -- src/arch/intsimdmatrix.cpp | 8 +++++--- src/arch/intsimdmatrix.h | 5 +++-- src/arch/simddetect.cpp | 1 - src/ccmain/ltrresultiterator.h | 8 +++++--- src/ccstruct/blamer.cpp | 13 +++++++++---- src/ccstruct/blobbox.cpp | 19 ++++++++++++------- src/ccstruct/coutln.cpp | 20 +++++++++++++------- src/ccstruct/coutln.h | 23 +++++++++++++++-------- src/ccstruct/dppoint.h | 2 +- src/ccstruct/fontinfo.h | 5 ++--- src/ccstruct/imagedata.cpp | 13 ++++++++----- src/ccstruct/imagedata.h | 16 +++++++++------- src/ccstruct/ipoints.h | 11 ++++++----- src/ccstruct/pageres.cpp | 23 +++++++++++++++++++---- src/ccstruct/polyaprx.cpp | 17 +++++++++++++---- src/ccutil/memry.h | 7 +++---- src/ccutil/strngs.cpp | 14 ++++++-------- src/ccutil/strngs.h | 14 +++++++------- src/cutil/callcpp.cpp | 16 +++++----------- 22 files changed, 141 insertions(+), 98 deletions(-) diff --git a/src/arch/dotproductavx.cpp b/src/arch/dotproductavx.cpp index 81c17073e..297e0270e 100644 --- a/src/arch/dotproductavx.cpp +++ b/src/arch/dotproductavx.cpp @@ -35,7 +35,6 @@ double DotProductAVX(const double* u, const double* v, int n) { #include #include #include "dotproductavx.h" -#include "host.h" namespace tesseract { diff --git a/src/arch/dotproductsse.cpp b/src/arch/dotproductsse.cpp index d1fc47a9b..149dc1964 100644 --- a/src/arch/dotproductsse.cpp +++ b/src/arch/dotproductsse.cpp @@ -41,7 +41,6 @@ int32_t IntDotProductSSE(const int8_t* u, const int8_t* v, int n) { #include #include #include "dotproductsse.h" -#include "host.h" namespace tesseract { diff --git a/src/arch/dotproductsse.h b/src/arch/dotproductsse.h index a65466939..941c958fd 100644 --- a/src/arch/dotproductsse.h +++ b/src/arch/dotproductsse.h @@ -19,8 +19,6 @@ #ifndef TESSERACT_ARCH_DOTPRODUCTSSE_H_ #define TESSERACT_ARCH_DOTPRODUCTSSE_H_ -#include "host.h" - namespace tesseract { // Computes and returns the dot product of the n-vectors u and v. diff --git a/src/arch/intsimdmatrix.cpp b/src/arch/intsimdmatrix.cpp index d5c7b08df..f08480b96 100644 --- a/src/arch/intsimdmatrix.cpp +++ b/src/arch/intsimdmatrix.cpp @@ -17,9 +17,11 @@ /////////////////////////////////////////////////////////////////////// #include "intsimdmatrix.h" -#include "intsimdmatrixavx2.h" -#include "intsimdmatrixsse.h" -#include "simddetect.h" +#include "genericvector.h" // for GenericVector +#include "intsimdmatrixavx2.h" // for IntSimdMatrixAVX2 +#include "intsimdmatrixsse.h" // for IntSimdMatrixSSE +#include "matrix.h" // for GENERIC_2D_ARRAY +#include "simddetect.h" // for SIMDDetect namespace tesseract { diff --git a/src/arch/intsimdmatrix.h b/src/arch/intsimdmatrix.h index e7b55f622..5185eac86 100644 --- a/src/arch/intsimdmatrix.h +++ b/src/arch/intsimdmatrix.h @@ -21,8 +21,9 @@ #include #include -#include "genericvector.h" -#include "matrix.h" + +template class GENERIC_2D_ARRAY; +template class GenericVector; namespace tesseract { diff --git a/src/arch/simddetect.cpp b/src/arch/simddetect.cpp index 697100bbf..3a3990a5b 100644 --- a/src/arch/simddetect.cpp +++ b/src/arch/simddetect.cpp @@ -16,7 +16,6 @@ /////////////////////////////////////////////////////////////////////// #include "simddetect.h" -#include "tprintf.h" #undef X86_BUILD #if defined(__x86_64__) || defined(__i386__) || defined(_WIN32) diff --git a/src/ccmain/ltrresultiterator.h b/src/ccmain/ltrresultiterator.h index 09e1230ac..2d3103505 100644 --- a/src/ccmain/ltrresultiterator.h +++ b/src/ccmain/ltrresultiterator.h @@ -21,11 +21,13 @@ #ifndef TESSERACT_CCMAIN_LTR_RESULT_ITERATOR_H_ #define TESSERACT_CCMAIN_LTR_RESULT_ITERATOR_H_ -#include "platform.h" -#include "pageiterator.h" -#include "unichar.h" +#include "pageiterator.h" // for PageIterator +#include "platform.h" // for TESS_API +#include "publictypes.h" // for PageIteratorLevel +#include "unichar.h" // for StrongScriptDirection class BLOB_CHOICE_IT; +class PAGE_RES; class WERD_RES; namespace tesseract { diff --git a/src/ccstruct/blamer.cpp b/src/ccstruct/blamer.cpp index a84e87f20..f0361e02e 100644 --- a/src/ccstruct/blamer.cpp +++ b/src/ccstruct/blamer.cpp @@ -19,10 +19,15 @@ /////////////////////////////////////////////////////////////////////// #include "blamer.h" -#include "blobs.h" -#include "matrix.h" -#include "normalis.h" -#include "pageres.h" +#include // for abs +#include // for abs +#include "blobs.h" // for TPOINT, TWERD, TBLOB +#include "errcode.h" // for ASSERT_HOST +#include "matrix.h" // for MATRIX +#include "normalis.h" // for DENORM +#include "pageres.h" // for WERD_RES +#include "tesscallback.h" // for TessResultCallback2 +#include "unicharset.h" // for UNICHARSET // Names for each value of IncorrectResultReason enum. Keep in sync. const char kBlameCorrect[] = "corr"; diff --git a/src/ccstruct/blobbox.cpp b/src/ccstruct/blobbox.cpp index 9d89d7444..5228262b3 100644 --- a/src/ccstruct/blobbox.cpp +++ b/src/ccstruct/blobbox.cpp @@ -1,8 +1,8 @@ /********************************************************************** * File: blobbox.cpp (Formerly blobnbox.c) * Description: Code for the textord blob class. - * Author: Ray Smith - * Created: Thu Jul 30 09:08:51 BST 1992 + * Author: Ray Smith + * Created: Thu Jul 30 09:08:51 BST 1992 * * (C) Copyright 1992, Hewlett-Packard Ltd. ** Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,12 +23,17 @@ #endif #include "blobbox.h" -#include "allheaders.h" -#include "blobs.h" -#include "helpers.h" -#include "normalis.h" +#include // for INT32_MAX, INT16_MAX +#include // for max, min +#include "allheaders.h" // for pixGetHeight, pixGetPixel +#include "blobs.h" // for TPOINT +#include "coutln.h" // for C_OUTLINE_IT, C_OUTLINE, C_OUTLINE_LIST +#include "environ.h" // for l_uint32 +#include "helpers.h" // for UpdateRange, IntCastRounded +#include "host.h" // for NearlyEqual, TRUE +#include "ipoints.h" // for operator+=, ICOORD::rotate -#include +struct Pix; #define PROJECTION_MARGIN 10 //arbitrary #define EXTERN diff --git a/src/ccstruct/coutln.cpp b/src/ccstruct/coutln.cpp index b829e0a50..0de696fa8 100644 --- a/src/ccstruct/coutln.cpp +++ b/src/ccstruct/coutln.cpp @@ -17,14 +17,20 @@ * **********************************************************************/ -#include -#include - #include "coutln.h" - -#include "allheaders.h" -#include "blobs.h" -#include "normalis.h" +#include // for max, min +#include // for abs +#include // for abs +#include // for memset, memcpy, memmove +#include "allheaders.h" // for pixSetPixel, pixGetData, pixRasterop, pixGe... +#include "arrayaccess.h" // for GET_DATA_BYTE +#include "blobs.h" // for TPOINT +#include "crakedge.h" // for CRACKEDGE +#include "environ.h" // for l_uint32 +#include "errcode.h" // for ASSERT_HOST +#include "helpers.h" // for ClipToRange, IntCastRounded, Modulo +#include "normalis.h" // for DENORM +#include "pix.h" // for Pix (ptr only), PIX_DST, PIX_NOT // Include automatically generated configuration file if running autoconf. #ifdef HAVE_CONFIG_H diff --git a/src/ccstruct/coutln.h b/src/ccstruct/coutln.h index 00faa6199..5032e514b 100644 --- a/src/ccstruct/coutln.h +++ b/src/ccstruct/coutln.h @@ -17,17 +17,24 @@ * **********************************************************************/ -#ifndef COUTLN_H -#define COUTLN_H +#ifndef COUTLN_H +#define COUTLN_H -#include "crakedge.h" -#include "mod128.h" -#include "bits16.h" -#include "rect.h" -#include "blckerr.h" -#include "scrollview.h" +#include // for int16_t, int32_t +#include "bits16.h" // for BITS16 +#include "elst.h" // for ELIST_ITERATOR, ELISTIZEH, ELIST_LINK +#include "ipoints.h" // for operator+= +#include "memry.h" // for free_mem +#include "mod128.h" // for DIR128, DIRBITS +#include "platform.h" // for DLLSYM +#include "points.h" // for ICOORD, FCOORD +#include "rect.h" // for TBOX +#include "scrollview.h" // for ScrollView, ScrollView::Color +class CRACKEDGE; +class C_OUTLINE; class DENORM; +struct Pix; #define INTERSECTING INT16_MAX//no winding number diff --git a/src/ccstruct/dppoint.h b/src/ccstruct/dppoint.h index 6008c09cc..4694ef9db 100644 --- a/src/ccstruct/dppoint.h +++ b/src/ccstruct/dppoint.h @@ -20,7 +20,7 @@ #ifndef TESSERACT_CCSTRUCT_DPPOINT_H_ #define TESSERACT_CCSTRUCT_DPPOINT_H_ -#include "host.h" +#include namespace tesseract { diff --git a/src/ccstruct/fontinfo.h b/src/ccstruct/fontinfo.h index 3b1c94b5d..fd641a4fa 100644 --- a/src/ccstruct/fontinfo.h +++ b/src/ccstruct/fontinfo.h @@ -21,17 +21,16 @@ #ifndef TESSERACT_CCSTRUCT_FONTINFO_H_ #define TESSERACT_CCSTRUCT_FONTINFO_H_ +#include // for uint16_t, uint32_t +#include // for FILE #include "errcode.h" #include "genericvector.h" -#include "host.h" #include "unichar.h" template class UnicityTable; namespace tesseract { -class BitVector; - // Simple struct to hold a font and a score. The scores come from the low-level // integer matcher, so they are in the uint16_t range. Fonts are an index to // fontinfo_table. diff --git a/src/ccstruct/imagedata.cpp b/src/ccstruct/imagedata.cpp index 8bc7b73ef..6a2bae436 100644 --- a/src/ccstruct/imagedata.cpp +++ b/src/ccstruct/imagedata.cpp @@ -30,11 +30,14 @@ #include #endif -#include "allheaders.h" -#include "boxread.h" -#include "callcpp.h" -#include "helpers.h" -#include "tprintf.h" +#include "allheaders.h" // for pixDestroy, pixGetHeight, pixGetWidth, lept_... +#include "boxread.h" // for ReadMemBoxes +#include "callcpp.h" // for window_wait +#include "helpers.h" // for IntCastRounded, TRand, ClipToRange, Modulo +#include "rect.h" // for TBOX +#include "scrollview.h" // for ScrollView, ScrollView::CYAN, ScrollView::NONE +#include "serialis.h" // for TFile +#include "tprintf.h" // for tprintf // Number of documents to read ahead while training. Doesn't need to be very // large. diff --git a/src/ccstruct/imagedata.h b/src/ccstruct/imagedata.h index ad8d2b961..6679db4cb 100644 --- a/src/ccstruct/imagedata.h +++ b/src/ccstruct/imagedata.h @@ -20,17 +20,19 @@ #ifndef TESSERACT_IMAGE_IMAGEDATA_H_ #define TESSERACT_IMAGE_IMAGEDATA_H_ +#include "genericvector.h" // for GenericVector, PointerVector, FileReader +#include "points.h" // for FCOORD +#include "strngs.h" // for STRING +#include "svutil.h" // for SVAutoLock, SVMutex -#include "genericvector.h" -#include "normalis.h" -#include "rect.h" -#include "strngs.h" -#include "svutil.h" - +class ScrollView; +class TBOX; struct Pix; namespace tesseract { +class TFile; + // Amount of padding to apply in output pixels in feature mode. const int kFeaturePadding = 2; // Number of pixels to pad around text boxes. @@ -118,7 +120,7 @@ class ImageData { // Reads from the given file. Returns false in case of error. bool DeSerialize(TFile* fp); // As DeSerialize, but only seeks past the data - hence a static method. - static bool SkipDeSerialize(tesseract::TFile* fp); + static bool SkipDeSerialize(TFile* fp); // Other accessors. const STRING& imagefilename() const { diff --git a/src/ccstruct/ipoints.h b/src/ccstruct/ipoints.h index 099982ccd..d5fbd3028 100644 --- a/src/ccstruct/ipoints.h +++ b/src/ccstruct/ipoints.h @@ -1,8 +1,8 @@ /********************************************************************** * File: ipoints.h (Formerly icoords.h) * Description: Inline functions for coords.h. - * Author: Ray Smith - * Created: Fri Jun 21 15:14:21 BST 1991 + * Author: Ray Smith + * Created: Fri Jun 21 15:14:21 BST 1991 * * (C) Copyright 1991, Hewlett-Packard Ltd. ** Licensed under the Apache License, Version 2.0 (the "License"); @@ -17,10 +17,11 @@ * **********************************************************************/ -#ifndef IPOINTS_H -#define IPOINTS_H +#ifndef IPOINTS_H +#define IPOINTS_H -#include +#include +#include "points.h" // ICOORD /********************************************************************** * operator! diff --git a/src/ccstruct/pageres.cpp b/src/ccstruct/pageres.cpp index 2cbaf5806..923ad30aa 100644 --- a/src/ccstruct/pageres.cpp +++ b/src/ccstruct/pageres.cpp @@ -22,11 +22,26 @@ * **********************************************************************/ -#include -#include -#include "blamer.h" #include "pageres.h" -#include "blobs.h" +#include // for assert +#include // for INT32_MAX +#include // for strlen +#include "blamer.h" // for BlamerBundle +#include "blobs.h" // for TWERD, TBLOB +#include "boxword.h" // for BoxWord +#include "errcode.h" // for ASSERT_HOST +#include "host.h" // for TRUE, FALSE +#include "ocrblock.h" // for BLOCK_IT, BLOCK, BLOCK_LIST (ptr only) +#include "ocrrow.h" // for ROW, ROW_IT +#include "pdblock.h" // for PDBLK +#include "polyblk.h" // for POLY_BLOCK +#include "publictypes.h" // for OcrEngineMode, OEM_LSTM_ONLY +#include "seam.h" // for SEAM, start_seam_list +#include "stepblob.h" // for C_BLOB_IT, C_BLOB, C_BLOB_LIST +#include "tesscallback.h" // for NewPermanentTessCallback, TessResultCallback2 +#include "tprintf.h" // for tprintf + +struct Pix; ELISTIZE (BLOCK_RES) CLISTIZE (BLOCK_RES) ELISTIZE (ROW_RES) ELISTIZE (WERD_RES) diff --git a/src/ccstruct/polyaprx.cpp b/src/ccstruct/polyaprx.cpp index d8df93418..62b198b14 100644 --- a/src/ccstruct/polyaprx.cpp +++ b/src/ccstruct/polyaprx.cpp @@ -17,13 +17,22 @@ * **********************************************************************/ -#include -#define FASTEDGELENGTH 256 #include "polyaprx.h" -#include "params.h" -#include "tprintf.h" +#include // for INT16_MAX, int8_t +#include "blobs.h" // for EDGEPT, TPOINT, VECTOR, TESSLINE +#include "coutln.h" // for C_OUTLINE +#include "errcode.h" // for ASSERT_HOST +#include "host.h" // for FALSE, TRUE +#include "ipoints.h" // for operator+=, operator*= +#include "mod128.h" // for DIR128 +#include "params.h" // for BoolParam, BOOL_VAR +#include "points.h" // for ICOORD +#include "rect.h" // for TBOX +#include "tprintf.h" // for tprintf +#include "vecfuncs.h" // for LENGTH, point_diff, CROSS #define EXTERN +#define FASTEDGELENGTH 256 EXTERN BOOL_VAR(poly_debug, FALSE, "Debug old poly"); EXTERN BOOL_VAR(poly_wide_objects_better, TRUE, diff --git a/src/ccutil/memry.h b/src/ccutil/memry.h index d917c8757..34e01dc0b 100644 --- a/src/ccutil/memry.h +++ b/src/ccutil/memry.h @@ -17,11 +17,10 @@ * **********************************************************************/ -#ifndef MEMRY_H -#define MEMRY_H +#ifndef MEMRY_H +#define MEMRY_H -#include -#include "host.h" +#include // allocate string extern char *alloc_string(int32_t count); diff --git a/src/ccutil/strngs.cpp b/src/ccutil/strngs.cpp index 471628db6..cba79f1f8 100644 --- a/src/ccutil/strngs.cpp +++ b/src/ccutil/strngs.cpp @@ -18,14 +18,12 @@ **********************************************************************/ #include "strngs.h" - -#include - -#include "errcode.h" -#include "genericvector.h" -#include "helpers.h" -#include "serialis.h" -#include "tprintf.h" +#include // for assert +#include "errcode.h" // for ASSERT_HOST +#include "genericvector.h" // for GenericVector +#include "helpers.h" // for ReverseN +#include "memry.h" // for alloc_string, free_string +#include "serialis.h" // for TFile using tesseract::TFile; diff --git a/src/ccutil/strngs.h b/src/ccutil/strngs.h index aa3a72c27..d6e4b04d9 100644 --- a/src/ccutil/strngs.h +++ b/src/ccutil/strngs.h @@ -17,14 +17,14 @@ * **********************************************************************/ -#ifndef STRNGS_H -#define STRNGS_H +#ifndef STRNGS_H +#define STRNGS_H -#include -#include -#include -#include "memry.h" -#include "platform.h" +#include // for assert +#include // for uint32_t +#include // for FILE +#include // for strncpy +#include "platform.h" // for TESS_API namespace tesseract { class TFile; diff --git a/src/cutil/callcpp.cpp b/src/cutil/callcpp.cpp index 5fb68647f..7528f0fcc 100644 --- a/src/cutil/callcpp.cpp +++ b/src/cutil/callcpp.cpp @@ -22,18 +22,12 @@ #include "config_auto.h" #endif -#include "errcode.h" -#include -#include -#include "memry.h" -#include "scrollview.h" -#include "params.h" #include "callcpp.h" -#include "tprintf.h" -#include "host.h" -#include "unichar.h" - -#include +#include // for va_end, va_list, va_start +#include // for vsprintf +#include // for unique_ptr +#include "scrollview.h" // for ScrollView, SVEvent, SVET_ANY, SVET_INPUT +#include "tprintf.h" // for tprintf void cprintf ( //Trace printf From 91522dfba5b2df96a235af32ce71da026cd3e890 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Sat, 23 Jun 2018 21:15:51 +0200 Subject: [PATCH 2/2] Remove memry.h from public API It is no longer needed by genericvector.h. Signed-off-by: Stefan Weil --- CMakeLists.txt | 1 - src/ccutil/Makefile.am | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 35f586c1f..606f22010 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -358,7 +358,6 @@ install(FILES src/ccutil/genericvector.h src/ccutil/helpers.h src/ccutil/host.h - src/ccutil/memry.h src/ccutil/params.h src/ccutil/ocrclass.h src/ccutil/platform.h diff --git a/src/ccutil/Makefile.am b/src/ccutil/Makefile.am index 2624d9ae7..976d11b4c 100644 --- a/src/ccutil/Makefile.am +++ b/src/ccutil/Makefile.am @@ -12,14 +12,14 @@ AM_CPPFLAGS += -DTESS_EXPORTS endif pkginclude_HEADERS = \ - genericvector.h helpers.h host.h memry.h \ + genericvector.h helpers.h host.h \ ocrclass.h platform.h serialis.h strngs.h \ tesscallback.h unichar.h noinst_HEADERS = \ ambigs.h basedir.h bits16.h bitvector.h ccutil.h clst.h doubleptr.h elst2.h \ elst.h errcode.h fileerr.h genericheap.h globaloc.h \ - indexmapbidi.h kdpair.h lsterr.h \ + indexmapbidi.h kdpair.h lsterr.h memry.h \ nwmain.h object_cache.h params.h qrsequence.h sorthelper.h stderr.h \ scanutils.h tessdatamanager.h tprintf.h \ unicharcompress.h unicharmap.h unicharset.h unicity_table.h unicodes.h \