-/////////////////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////////////
// Name: xmlparser.cpp
// Purpose: Parser of the API/interface XML files
// Author: Francesco Montorsi
// for all others, include the necessary headers
#ifndef WX_PRECOMP
+ #include "wx/crt.h"
#endif
#include "wx/xml/xml.h"
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)
m_strType.Replace(" ,", ",");
+ // ADHOC-FIX
+ m_strType.Replace("_wxArraywxArrayStringBase", "const wxString&");
+
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("*", "");
m_strTypeClean.Replace("wxDateTime::", "");
m_strTypeClean.Replace("wxStockGDI::", ""); // same story for some other classes
m_strTypeClean.Replace("wxHelpEvent::", "");
+ m_strTypeClean.Replace("wxWindowID", "int");
}
bool wxType::IsOk() const
return true;
if (g_verbose)
+ {
LogMessage("Type '%s' does not match type '%s'", m_strType, m.m_strType);
+ LogMessage(" => TypeClean %s / %s; IsConst %d / %d; IsStatic %d / %d; IsPointer %d / %d; IsReference %d / %d",
+ m_strTypeClean, m.m_strTypeClean, IsConst(), m.IsConst(),
+ IsStatic(), m.IsStatic(), IsPointer(), m.IsPointer(),
+ IsReference(), m.IsReference());
+ }
return false;
}
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);
+
- // 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";
+ // clean the default argument strings
+ // ----------------------------------
- // 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";
+ // 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
- m_strDefaultValue.Replace("0x000000001", "1");
- m_strDefaultValueForCmp.Replace("0x000000001", "1");
+ 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");
+ }
- // 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(")"))
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:
{
if (GetReturnType() != m.GetReturnType() ||
GetName() != m.GetName())
+ {
+ if (g_verbose)
+ LogMessage("The method '%s' does not match method '%s'; different names/rettype", GetName(), m.GetName());
return false;
+ }
if (m_args.GetCount()!=m.m_args.GetCount()) {
if (g_verbose)
return true;
}
+bool wxMethod::ActsAsDefaultCtor() const
+{
+ if (!IsCtor())
+ return false;
+
+ for (unsigned int i=0; i<m_args.GetCount(); i++)
+ if (!m_args[i].HasDefaultValue())
+ return false;
+
+ return true;
+}
+
bool wxMethod::operator==(const wxMethod& m) const
{
// check attributes
IsPureVirtual() != m.IsPureVirtual() ||
IsDeprecated() != m.IsDeprecated() ||
GetAccessSpecifier() != m.GetAccessSpecifier())
+ {
+ if (g_verbose)
+ LogMessage("The method '%s' does not match method '%s'; different attributes", GetName(), m.GetName());
+
return false;
+ }
// check everything else
return MatchesExceptForAttributes(m);
LogError("class %s has two methods with the same prototype: '%s'",
m_strName, m_methods[i].GetAsString());
return false;
- ((wxClass*)this)->m_methods.RemoveAt(j);
- j--;
+
+ // fix the problem?
+ //((wxClass*)this)->m_methods.RemoveAt(j);
+ //j--;
}
return true;
// utility to parse gccXML ID values;
// this function is equivalent to wxString(str).Mid(1).ToULong(&id, GCCXML_BASE)
// but is a little bit faster
-bool getID(unsigned long *id, const wxStringCharType* str)
+bool getID(unsigned long *id, const wxString& str)
{
+ const wxStringCharType * const start = str.wx_str()+1;
wxStringCharType *end;
#if wxUSE_UNICODE_WCHAR
- unsigned long val = wcstoul(str+1, &end, GCCXML_BASE);
+ unsigned long val = wcstoul(start, &end, GCCXML_BASE);
#else
- unsigned long val = strtoul(str+1, &end, GCCXML_BASE);
+ unsigned long val = strtoul(start, &end, GCCXML_BASE);
#endif
// return true only if scan was stopped by the terminating NUL and
// if the string was not empty to start with and no under/overflow
// occurred:
- if ( *end != '\0' || end == str+1 || errno == ERANGE || errno == EINVAL )
+ if ( *end != '\0' || end == start || errno == ERANGE || errno == EINVAL )
return false;
*id = val;
// utility specialized to parse efficiently the gccXML list of IDs which occur
// in nodes like <Class> ones... i.e. numeric values separed by " _" token
-bool getMemberIDs(wxClassMemberIdHashMap* map, wxClass* p, const wxStringCharType* str)
+bool getMemberIDs(wxClassMemberIdHashMap* map, wxClass* p, const wxString& str)
{
+ const wxStringCharType * const start = str.wx_str();
#if wxUSE_UNICODE_WCHAR
- size_t len = wcslen(str);
+ size_t len = wcslen(start);
#else
- size_t len = strlen(str);
+ size_t len = strlen(start);
#endif
- if (len == 0 || str[0] != '_')
+ if (len == 0 || start[0] != '_')
return false;
- const wxStringCharType *curpos = str,
- *end = str + len;
+ const wxStringCharType *curpos = start,
+ *end = start + len;
wxStringCharType *nexttoken;
while (curpos < end)