+
+// ----------------------------------------------------------------------------
+// wxArgumentType
+// ----------------------------------------------------------------------------
+
+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);
+
+
+ // clean the default argument strings
+ // ----------------------------------
+
+ // 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
+
+ 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:
+ p->Replace("\\011", "\\t");
+ p->Replace("e+0", "");
+ p->Replace("2147483647", "__INT_MAX__");
+
+ // ADHOC-FIX: for wxConv* default values
+ p->Replace("wxConvAuto(wxFONTENCODING_DEFAULT)", "wxConvAuto()");
+ p->Replace("wxGet_wxConvUTF8()", "wxConvUTF8");
+ p->Replace("wxGet_wxConvLocal()", "wxConvLocal");
+ }
+
+
+ // clean ONLY the default argument string specific for comparison
+ // --------------------------------------------------------------
+
+ if (m_strDefaultValueForCmp.StartsWith("wxT(") &&
+ m_strDefaultValueForCmp.EndsWith(")"))
+ {
+ // get rid of the wxT() part
+ unsigned int len = m_strDefaultValueForCmp.Len();
+ m_strDefaultValueForCmp = m_strDefaultValueForCmp.Mid(4,len-5);
+ }
+
+ // 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("* GetColour(COLOUR_BLACK)", "*wxBLACK");
+
+ // ADHOC-FIX:
+ if (m_strDefaultValueForCmp.Contains("wxGetTranslation"))
+ m_strDefaultValueForCmp = "_(TOFIX)"; // TODO: wxGetTranslation gives problems to gccxml
+}
+
+bool wxArgumentType::operator==(const wxArgumentType& m) const
+{
+ if ((const wxType&)(*this) != (const wxType&)m)
+ return false;
+
+ // check if the default values match
+ // ---------------------------------
+
+
+ // ADHOC-FIX:
+ // default values for style attributes of wxWindow-derived classes in gccxml appear as raw
+ // numbers; avoid false positives in this case!
+ if (m_strArgName == m.m_strArgName && m_strArgName == "style" &&
+ (m_strDefaultValueForCmp.IsNumber() || m.m_strDefaultValueForCmp.IsNumber()))
+ return true;
+
+ // fix for default values which were replaced by gcc-xml with their numeric values
+ // (at this point we know that m_strTypeClean == m.m_strTypeClean):
+ if (m_strTypeClean == "long" || m_strTypeClean == "int")
+ {
+ if ((m_strDefaultValueForCmp.IsNumber() && m.m_strDefaultValueForCmp.StartsWith("wx")) ||
+ (m.m_strDefaultValueForCmp.IsNumber() && m_strDefaultValueForCmp.StartsWith("wx")))
+ {
+ if (g_verbose)
+ wxLogMessage("Supposing '%s' default value to be the same of '%s'...",
+ m_strDefaultValueForCmp, m.m_strDefaultValueForCmp);
+
+ return true;
+ }
+ }
+ else if (m_strTypeClean == "float" || m_strTypeClean == "double")
+ // gccXML translates the default floating values in a hardly usable
+ // format; e.g. 25.2 => 2.51999999999999992894572642398998141288757324219e+1
+ // we avoid check on these...
+ return true;
+
+ if (m_strDefaultValueForCmp != m.m_strDefaultValueForCmp)
+ {
+ // maybe the default values are numbers.
+ // in this case gccXML gives as default values things like '-0x0000001' instead of just '-1'.
+ // To handle these cases, we try to convert the default value strings to numbers:
+ long def1val, def2val;
+ if (m_strDefaultValueForCmp.ToLong(&def1val, 0 /* auto-detect */) &&
+ m.m_strDefaultValueForCmp.ToLong(&def2val, 0 /* auto-detect */))
+ {
+ if (def1val == def2val)
+ return true; // the default values match
+ }
+
+ if (g_verbose)
+ wxLogMessage("Argument type '%s = %s' has different default value from '%s = %s'",
+ m_strType, m_strDefaultValueForCmp, m.m_strType, m.m_strDefaultValueForCmp);
+ return false;
+ }
+
+ // we deliberately avoid checks on the argument name
+
+ return true;
+}
+
+