added the process-only option

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52774 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Francesco Montorsi
2008-03-24 23:22:39 +00:00
parent d7ef641d4e
commit d5978709f3
3 changed files with 45 additions and 8 deletions

View File

@@ -22,6 +22,7 @@
#include "wx/cmdline.h" #include "wx/cmdline.h"
#include "wx/textfile.h" #include "wx/textfile.h"
#include "wx/filename.h"
#include "wx/stopwatch.h" // for wxGetLocalTime #include "wx/stopwatch.h" // for wxGetLocalTime
#include "xmlparser.h" #include "xmlparser.h"
@@ -37,17 +38,21 @@ bool g_verbose = false;
#define API_DUMP_FILE "dump.api.txt" #define API_DUMP_FILE "dump.api.txt"
#define INTERFACE_DUMP_FILE "dump.interface.txt" #define INTERFACE_DUMP_FILE "dump.interface.txt"
#define PROCESS_ONLY_SWITCH "p"
#define MODIFY_SWITCH "m" #define MODIFY_SWITCH "m"
#define DUMP_SWITCH "dump" #define DUMP_SWITCH "d"
#define HELP_SWITCH "h" #define HELP_SWITCH "h"
#define VERBOSE_SWITCH "v" #define VERBOSE_SWITCH "v"
static const wxCmdLineEntryDesc g_cmdLineDesc[] = static const wxCmdLineEntryDesc g_cmdLineDesc[] =
{ {
{ wxCMD_LINE_OPTION, PROCESS_ONLY_SWITCH, "process-only",
"processes only header files matching the given wildcard",
wxCMD_LINE_VAL_STRING, wxCMD_LINE_NEEDS_SEPARATOR },
{ wxCMD_LINE_SWITCH, MODIFY_SWITCH, "modify", { wxCMD_LINE_SWITCH, MODIFY_SWITCH, "modify",
"modify the interface headers to match the real ones" }, "modify the interface headers to match the real ones" },
{ wxCMD_LINE_SWITCH, "", DUMP_SWITCH, { wxCMD_LINE_SWITCH, DUMP_SWITCH, "dump",
"dump both interface and API to plain text" }, "dump both interface and API to plain text dump.*.txt files" },
{ wxCMD_LINE_SWITCH, HELP_SWITCH, "help", { wxCMD_LINE_SWITCH, HELP_SWITCH, "help",
"show help message", wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP }, "show help message", wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP },
{ wxCMD_LINE_SWITCH, VERBOSE_SWITCH, "verbose", { wxCMD_LINE_SWITCH, VERBOSE_SWITCH, "verbose",
@@ -73,12 +78,23 @@ public:
void ShowProgress(); void ShowProgress();
void PrintStatistics(long secs); void PrintStatistics(long secs);
bool IsToProcess(const wxString& headername) const
{
if (m_strToMatch.IsEmpty())
return true;
return wxMatchWild(m_strToMatch, headername, false);
}
protected: protected:
wxXmlGccInterface m_api; // "real" headers API wxXmlGccInterface m_api; // "real" headers API
wxXmlDoxygenInterface m_interface; // doxygen-commented headers API wxXmlDoxygenInterface m_interface; // doxygen-commented headers API
// was the MODIFY_SWITCH passed? // was the MODIFY_SWITCH passed?
bool m_modify; bool m_modify;
// if non-empty, then PROCESS_ONLY_SWITCH was passed and this is the
// wildcard expression to match
wxString m_strToMatch;
}; };
IMPLEMENT_APP_CONSOLE(IfaceCheckApp) IMPLEMENT_APP_CONSOLE(IfaceCheckApp)
@@ -117,6 +133,15 @@ int IfaceCheckApp::OnRun()
if (parser.Found(MODIFY_SWITCH)) if (parser.Found(MODIFY_SWITCH))
m_modify = true; m_modify = true;
if (parser.Found(PROCESS_ONLY_SWITCH, &m_strToMatch))
{
size_t len = m_strToMatch.Len();
if (m_strToMatch.StartsWith("\"") &&
m_strToMatch.EndsWith("\"") &&
len > 2)
m_strToMatch = m_strToMatch.Mid(1, len-2);
}
ok = Compare(); ok = Compare();
} }
@@ -143,8 +168,18 @@ bool IfaceCheckApp::Compare()
LogMessage("Comparing the interface API to the real API (%d classes to compare)...", LogMessage("Comparing the interface API to the real API (%d classes to compare)...",
interface.GetCount()); interface.GetCount());
if (!m_strToMatch.IsEmpty())
LogMessage("Processing only header files matching '%s' expression.", m_strToMatch);
for (unsigned int i=0; i<interface.GetCount(); i++) for (unsigned int i=0; i<interface.GetCount(); i++)
{ {
// shorten the name of the header so the log file is more readable
// and also for calling IsToProcess() against it
wxString header = wxFileName(interface[i].GetHeader()).GetFullName();
if (!IsToProcess(header))
continue; // skip this one
wxString cname = interface[i].GetName(); wxString cname = interface[i].GetName();
api.Empty(); api.Empty();
@@ -165,9 +200,6 @@ bool IfaceCheckApp::Compare()
} else { } else {
// shorten the name of the header so the log file is more readable
wxString header = interface[i].GetHeader().AfterLast('/');
LogMessage("%s: couldn't find the real interface for the '%s' class", LogMessage("%s: couldn't find the real interface for the '%s' class",
header, cname); header, cname);
ccount++; ccount++;
@@ -196,7 +228,7 @@ int IfaceCheckApp::CompareClasses(const wxClass* iface, const wxClassPtrArray& a
searchedclasses.Remove(0, 1); searchedclasses.Remove(0, 1);
// shorten the name of the header so the log file is more readable // shorten the name of the header so the log file is more readable
wxString header = iface->GetHeader().AfterLast('/'); wxString header = wxFileName(iface->GetHeader()).GetFullName();
for (unsigned int i=0; i<iface->GetMethodCount(); i++) for (unsigned int i=0; i<iface->GetMethodCount(); i++)
{ {

View File

@@ -170,6 +170,8 @@ bool wxMethod::IsOk() const
return false; return false;
} }
wxASSERT((m_bVirtual && m_bPureVirtual) || !m_bVirtual);
for (unsigned int i=0; i<m_args.GetCount(); i++) for (unsigned int i=0; i<m_args.GetCount(); i++)
if (!m_args[i].IsOk()) { if (!m_args[i].IsOk()) {
LogError("'%s' method has invalid %d-th argument type: %s", LogError("'%s' method has invalid %d-th argument type: %s",

View File

@@ -165,7 +165,10 @@ public: // setters
void SetVirtual(bool c = true) void SetVirtual(bool c = true)
{ m_bVirtual=c; } { m_bVirtual=c; }
void SetPureVirtual(bool c = true) void SetPureVirtual(bool c = true)
{ m_bPureVirtual=c; } {
m_bPureVirtual=c;
if (c) m_bVirtual=c; // pure virtual => virtual
}
void SetDeprecated(bool c = true) void SetDeprecated(bool c = true)
{ m_bDeprecated=c; } { m_bDeprecated=c; }
void SetLocation(int lineNumber) void SetLocation(int lineNumber)