summaryrefslogtreecommitdiff
path: root/utils/classcheck/codeprocessor.h
blob: d50b8d2e066a386f7e46dbd871b84f1a51034e57 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//=============================================================================//
#if !defined( CODEPROCESSOR_H )
#define CODEPROCESSOR_H
#ifdef _WIN32
#pragma once
#endif

#include "class.h"
#include "icodeprocessor.h"

#include "utldict.h"

class CCodeProcessor : public ICodeProcessor
{
public:
				CCodeProcessor( void );
				~CCodeProcessor( void );

	void		Process( const char *baseentityclass, const char *gamespecific, const char *sourcetreebase, const char *subdir );
	void		Process( const char *baseentityclass, const char *gamespecific, const char *sourcetreebase, const char *subdir, const char *pFileName );
	CClass		*AddClass( const char *classname );

	void		SetQuiet( bool quiet );
	bool		GetQuiet( void ) const;

	void		SetPrintHierarchy( bool print );
	bool		GetPrintHierarchy( void ) const;

	void		SetPrintMembers( bool print );
	bool		GetPrintMembers( void ) const;

	void		SetPrintTDs( bool print );
	bool		GetPrintTDs( void ) const;

	void		SetPrintPredTDs( bool print );
	bool		GetPrintPredTDs( void ) const;

	void		SetPrintCreateMissingTDs( bool print );
	bool		GetPrintCreateMissingTDs( void ) const;

	void		SetPrintCreateMissingPredTDs( bool print );
	bool		GetPrintCreateMissingPredTDs( void ) const;

	void		SetLogFile( bool log );
	bool		GetLogFile( void ) const;

	void		SetCheckHungarian( bool check );
	bool		GetCheckHungarian() const;

	CClass		*FindClass( const char *name ) const;
	
	void		ResolveBaseClasses( const char *baseentityclass );
	void		Clear( void );
	void		PrintClassList( void ) const;
	void		PrintMissingTDFields( void ) const;
	void		ReportHungarianNotationErrors();
	
	int			Count( void ) const;
	
	void		SortClassList( void );

private:
	char		*ParseTypeDescription( char *current, bool fIsMacroized );
	char		*ParsePredictionTypeDescription( char *current );
	char		*ParseReceiveTable( char *current );

	void		ProcessModule( bool forcequiet, int depth, int& maxdepth, int& numheaders, int& skippedfiles, 
		const char *srcroot, const char *baseroot, const char *root, const char *module );
	void		ProcessModules( const char *srcroot, const char *root, const char *rootmodule );
	void		PrintResults( const char *baseentityclass );
	void		ConstructModuleList_R( int level, const char *baseentityclass, const char *gamespecific, const char *root, char const *srcroot );
	
	void		AddHeader( int depth, const char *filename, const char *rootmodule );

	bool		CheckShouldSkip( bool forcequiet, int depth, char const *filename, int& numheaders, int& skippedfiles);
	bool		LoadFile( char **buffer, char *filename, char const *module, bool forcequiet, 
					int depth, int& filelength, int& numheaders, int& skippedfiles,
					char const *srcroot, char const *root, char const *baseroot );

	// include file path
	void		CleanupIncludePath();
	void		AddIncludePath( const char *pPath );
	void		SetupIncludePath( const char *sourcetreebase, const char *subdir, const char *gamespecific );

	CClass		*m_pClassList;

	typedef struct
	{
		bool	skipped;
	} CODE_MODULE;

	CUtlDict< CODE_MODULE, int >	m_Modules;
	CUtlDict< CODE_MODULE, int >	m_Headers;

	CUtlVector< char * >	m_IncludePath;

	bool		m_bQuiet;
	bool		m_bPrintHierarchy;
	bool		m_bPrintMembers;
	bool		m_bPrintTypedescriptionErrors;
	bool		m_bPrintPredictionDescErrors;
	bool		m_bCreateMissingTDs;
	bool		m_bCreateMissingPredTDs;
	bool		m_bLogToFile;
	bool		m_bCheckHungarian;

	int			m_nFilesProcessed;
	int			m_nHeadersProcessed;
	int			m_nClassesParsed;
	int			m_nOffset;
	int			m_nBytesProcessed;
	int			m_nLinesOfCode;

	double		m_flStart;
	double		m_flEnd;

	char		m_szCurrentCPP[ 128 ];
	char		m_szBaseEntityClass[ 256 ];

};

extern ICodeProcessor *processor;

#endif // CODEPROCESSOR_H