From: Francesco Montorsi Date: Tue, 14 Oct 2008 19:49:48 +0000 (+0000) Subject: further additions to avoid false warnings (ActsAsDefaultCtor, better wxArgumentType... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/f3998820a3a8770d705828e542f1b774703f4fc1 further additions to avoid false warnings (ActsAsDefaultCtor, better wxArgumentType::SetDefaultValue) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56314 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/utils/ifacecheck/src/ifacecheck.cpp b/utils/ifacecheck/src/ifacecheck.cpp index 7c89afc015..0d9b49b1b7 100644 --- a/utils/ifacecheck/src/ifacecheck.cpp +++ b/utils/ifacecheck/src/ifacecheck.cpp @@ -301,17 +301,26 @@ int IfaceCheckApp::CompareClasses(const wxClass* iface, const wxClass* api) // search in the methods of the api classes provided real = api->RecursiveUpwardFindMethod(m, &m_gccInterface); + // + if (!real && m.ActsAsDefaultCtor()) + { + // build an artifical default ctor for this class: + wxMethod temp(m); + temp.GetArgumentTypes().Clear(); + + real = api->RecursiveUpwardFindMethod(temp, &m_gccInterface); + } + if (!real) { wxMethodPtrArray overloads = api->RecursiveUpwardFindMethodsNamed(m.GetName(), &m_gccInterface); -#define HACK_TO_AUTO_CORRECT_ONLY_METHOD_ATTRIBUTES 0 +#define HACK_TO_AUTO_CORRECT_ONLY_METHOD_ATTRIBUTES 1 #if HACK_TO_AUTO_CORRECT_ONLY_METHOD_ATTRIBUTES bool exit = false; for (unsigned int k=0; kMatchesExceptForAttributes(m) && - overloads[k]->IsPureVirtual() == m.IsPureVirtual()) + if (overloads[k]->MatchesExceptForAttributes(m)) { // fix default values of results[k]: wxMethod tmp(*overloads[k]); @@ -368,7 +377,7 @@ int IfaceCheckApp::CompareClasses(const wxClass* iface, const wxClass* api) { wxASSERT(overloads.GetCount() == 1); - if (m_modify) + if (m_modify || m.IsCtor()) { wxPrint("\tfixing it...\n"); @@ -601,6 +610,9 @@ bool IfaceCheckApp::ParsePreprocessorOutput(const wxString& filename) void IfaceCheckApp::PrintStatistics(long secs) { + // these stats, for what regards the gcc XML, are all referred to the wxWidgets + // classes only! + LogMessage("wx real headers contains declaration of %d classes (%d methods)", m_gccInterface.GetClassesCount(), m_gccInterface.GetMethodCount()); LogMessage("wx interface headers contains declaration of %d classes (%d methods)", diff --git a/utils/ifacecheck/src/xmlparser.cpp b/utils/ifacecheck/src/xmlparser.cpp index 4c73ca43fe..849a36a8a9 100644 --- a/utils/ifacecheck/src/xmlparser.cpp +++ b/utils/ifacecheck/src/xmlparser.cpp @@ -59,11 +59,15 @@ void wxType::SetTypeFromString(const wxString& t) which works at char-level and does everything in a single pass */ + // clean the type string + // --------------------- + m_strType = t; // [] is the same as * for gccxml m_strType.Replace("[]", "*"); m_strType.Replace("long int", "long"); // in wx typically we never write "long int", just "long" + m_strType.Replace("long unsigned int", "unsigned long"); // make sure the * and & operator always use the same spacing rules // (to make sure GetAsString() output is always consistent) @@ -79,8 +83,12 @@ void wxType::SetTypeFromString(const wxString& t) m_strType = m_strType.Strip(wxString::both); - // now set the clean version - m_strTypeClean = m_strType; + + + // clean the type string (this time for the comparison) + // ---------------------------------------------------- + + m_strTypeClean = m_strType; // begin with the already-cleaned string m_strTypeClean.Replace("const", ""); m_strTypeClean.Replace("static", ""); m_strTypeClean.Replace("*", ""); @@ -141,25 +149,36 @@ bool wxType::operator==(const wxType& m) const void wxArgumentType::SetDefaultValue(const wxString& defval, const wxString& defvalForCmp) { m_strDefaultValue = defval.Strip(wxString::both); - m_strDefaultValueForCmp = defvalForCmp.IsEmpty() ? m_strDefaultValue : defvalForCmp.Strip(wxString::both); + m_strDefaultValueForCmp = defvalForCmp.IsEmpty() ? + m_strDefaultValue : defvalForCmp.Strip(wxString::both); + + + // clean the default argument strings + // ---------------------------------- - // adjust aesthetic form of DefaultValue for the modify mode of ifacecheck: - // we may need to write it out in an interface header - if (m_strDefaultValue == "0u") - m_strDefaultValue = "0"; + // Note: we adjust the aesthetic form of the m_strDefaultValue string for the "modify mode" + // of ifacecheck: we may need to write it out in an interface header - // in order to make valid&simple comparison on argument defaults, - // we reduce some of the multiple forms in which the same things may appear - // to a single form: - if (m_strDefaultValueForCmp == "0u") - m_strDefaultValueForCmp = "0"; + wxString *p; + for (int i=0; i<2; i++) // to avoid copying&pasting the code! + { + if (i == 0) p = &m_strDefaultValue; + if (i == 1) p = &m_strDefaultValueForCmp; + + if (*p == "0u") *p = "0"; + + p->Replace("0x000000001", "1"); + p->Replace("\\000\\000\\000", ""); // fix for unicode strings: + + // ADHOC-FIX: for wxConv* default values + p->Replace("wxConvAuto(wxFONTENCODING_DEFAULT)", "wxConvAuto()"); + p->Replace("wxGet_wxConvUTF8()", "wxConvUTF8"); + p->Replace("wxGet_wxConvLocal()", "wxConvLocal"); + } - m_strDefaultValue.Replace("0x000000001", "1"); - m_strDefaultValueForCmp.Replace("0x000000001", "1"); - // fix for unicode strings: - m_strDefaultValue.Replace("\\000\\000\\000", ""); - m_strDefaultValueForCmp.Replace("\\000\\000\\000", ""); + // clean ONLY the default argument string specific for comparison + // -------------------------------------------------------------- if (m_strDefaultValueForCmp.StartsWith("wxT(") && m_strDefaultValueForCmp.EndsWith(")")) @@ -169,21 +188,12 @@ void wxArgumentType::SetDefaultValue(const wxString& defval, const wxString& def m_strDefaultValueForCmp = m_strDefaultValueForCmp.Mid(4,len-5); } -/* - if (IsPointer()) - m_strDefaultValueForCmp.Replace("0", "NULL"); - else - m_strDefaultValueForCmp.Replace("NULL", "0"); -*/ // ADHOC-FIX: // doxygen likes to put wxDateTime:: in front of all wxDateTime enums; // fix this to avoid false positives m_strDefaultValueForCmp.Replace("wxDateTime::", ""); m_strDefaultValueForCmp.Replace("wxStockGDI::", ""); // same story for some other classes m_strDefaultValueForCmp.Replace("wxHelpEvent::", ""); // same story for some other classes - - m_strDefaultValueForCmp.Replace("wxGet_wxConvLocal()", "wxConvLocal"); - m_strDefaultValueForCmp.Replace("* GetColour(COLOUR_BLACK)", "*wxBLACK"); // ADHOC-FIX: @@ -321,6 +331,18 @@ bool wxMethod::MatchesExceptForAttributes(const wxMethod& m) const return true; } +bool wxMethod::ActsAsDefaultCtor() const +{ + if (!IsCtor()) + return false; + + for (unsigned int i=0; i