]> git.saurik.com Git - wxWidgets.git/blobdiff - utils/ifacecheck/src/xmlparser.h
Doc and comment cleanup, fixes, tweaks
[wxWidgets.git] / utils / ifacecheck / src / xmlparser.h
index f160c79b3f45804459e16b7aefc8ab7524b12230..b103cb2c39db5cf47c6e0aa27c24e11ea1501076 100644 (file)
 #include <wx/xml/xml.h>
 #include <wx/platinfo.h>
 
+
+/*
+    IMPORTANT
+    =========
+
+    Any fix aimed to reduce "false positives" which involves
+    references to a specific wxWidgets class is marked in
+    ifacecheck sources with the string:
+
+    // ADHOC-FIX:
+
+*/
+
+
+
 // helper macros
-#define LogMessage(fmt, ...)   { wxPrintf(fmt "\n", __VA_ARGS__); fflush(stdout); }
-#define LogWarning(fmt, ...)   { wxPrintf(fmt "\n", __VA_ARGS__); fflush(stdout); }
-#define LogError(fmt, ...)     { wxPrintf("ERROR: " fmt "\n", __VA_ARGS__); fflush(stdout); }
+#define LogMessage(fmt, ...)   { if (g_bLogEnabled) { wxPrintf(fmt "\n", __VA_ARGS__); fflush(stdout); }}
+#define LogWarning(fmt, ...)   { if (g_bLogEnabled) { wxPrintf(fmt "\n", __VA_ARGS__); fflush(stdout); }}
+#define LogError(fmt, ...)     { if (g_bLogEnabled) { wxPrintf("ERROR: " fmt "\n", __VA_ARGS__); fflush(stdout); }}
 #define wxPrint(str)           { wxPrintf(str); fflush(stdout); }
 
+// enable/disable logging
+extern bool g_bLogEnabled;
+
+class LogNull
+{
+public:
+    LogNull() { g_bLogEnabled = false; }
+    ~LogNull() { g_bLogEnabled = true; }
+};
+
+
 
 // ----------------------------------------------------------------------------
 // Represents a type with or without const/static/ qualifier
@@ -39,6 +65,12 @@ public:
     wxString GetAsString() const
         { return m_strType; }
 
+    // returns this type _without_ any decoration,
+    // including the & (which indicates this is a reference),
+    // the * (which indicates this is a pointer), etc.
+    wxString GetAsCleanString() const
+        { return m_strTypeClean; }
+
     bool IsConst() const
         { return m_strType.Contains("const"); }
     bool IsStatic() const
@@ -80,10 +112,15 @@ public:
     wxString GetArgumentName() const
         { return m_strArgName; }
 
-    void SetDefaultValue(const wxString& defval, const wxString& defvalForCmp = wxEmptyString);
+    void SetDefaultValue(const wxString& defval,
+                         const wxString& defvalForCmp = wxEmptyString);
     wxString GetDefaultValue() const
         { return m_strDefaultValue; }
 
+    // returns the default value used for comparisons
+    wxString GetDefaultCleanValue() const
+        { return m_strDefaultValueForCmp; }
+
     bool HasDefaultValue() const
         { return !m_strDefaultValue.IsEmpty(); }
 
@@ -95,18 +132,25 @@ protected:
     wxString m_strDefaultValue;
 
     // this string may differ from m_strDefaultValue if there were
-    // preprocessor substitutions; can be wxEmptyString.
+    // preprocessor substitutions or other "replacements" done to
+    // avoid false errors.
     wxString m_strDefaultValueForCmp;
 
-    wxString m_strArgName;      // this one only makes sense when this wxType is
-                                // used as argument type (and not as return type)
-                                // and can be empty.
+    // the argument name
+    wxString m_strArgName;
 };
 
 extern wxArgumentType wxEmptyArgumentType;
 WX_DECLARE_OBJARRAY(wxArgumentType, wxArgumentTypeArray);
 
 
+enum wxMethodAccessSpecifier
+{
+    wxMAS_PUBLIC,
+    wxMAS_PROTECTED,
+    wxMAS_PRIVATE
+};
+
 // ----------------------------------------------------------------------------
 // Represents a single prototype of a class' member.
 // ----------------------------------------------------------------------------
@@ -115,7 +159,7 @@ class wxMethod
 public:
     wxMethod()
         { m_bConst=m_bVirtual=m_bPureVirtual=m_bStatic=m_bDeprecated=false;
-          m_nLine=-1; m_nAvailability=wxPORT_UNKNOWN; }
+          m_nLine=-1; m_nAvailability=wxPORT_UNKNOWN; m_access=wxMAS_PUBLIC; }
 
     wxMethod(const wxType& rettype, const wxString& name,
              const wxArgumentTypeArray& arguments,
@@ -127,7 +171,16 @@ public:
 
 public:     // getters
 
-    wxString GetAsString(bool bWithArgumentNames = true) const;
+    // bWithArgumentNames = output argument names?
+    // bCleanDefaultValues = output clean argument default values?
+    // bDeprecated = output [deprecated] next to deprecated methods?
+    // bAccessSpec = output [public], [protected] or [private] next to method?
+    //
+    // TODO: convert to readable flags this set of bools
+    wxString GetAsString(bool bWithArgumentNames = true,
+                         bool bCleanDefaultValues = false,
+                         bool bDeprecated = false,
+                         bool bAccessSpec = false) const;
 
     // parser of the prototype:
     // all these functions return strings with spaces stripped
@@ -141,6 +194,8 @@ public:     // getters
         { return m_nLine; }
     int GetAvailability() const
         { return m_nAvailability; }
+    wxMethodAccessSpecifier GetAccessSpecifier() const
+        { return m_access; }
 
     bool IsConst() const
         { return m_bConst; }
@@ -186,6 +241,8 @@ public:     // setters
         { m_nLine=lineNumber; }
     void SetAvailability(int nAvail)
         { m_nAvailability=nAvail; }
+    void SetAccessSpecifier(wxMethodAccessSpecifier spec)
+        { m_access=spec; }
 
 public:     // misc
 
@@ -193,6 +250,13 @@ public:     // misc
     bool operator!=(const wxMethod& m) const
         { return !(*this == m); }
 
+    // this function works like operator== but tests everything:
+    // - method name
+    // - return type
+    // - argument types
+    // except for the method attributes (const,static,virtual,pureVirtual,deprecated)
+    bool MatchesExceptForAttributes(const wxMethod& m) const;
+
     void Dump(wxTextOutputStream& stream) const;
 
 protected:
@@ -215,6 +279,9 @@ protected:
     // NOTE: this is not used for comparing wxMethod objects
     //       (gccXML never gives this kind of info).
     int m_nAvailability;
+
+    // the access specifier for this method
+    wxMethodAccessSpecifier m_access;
 };
 
 WX_DECLARE_OBJARRAY(wxMethod, wxMethodArray);
@@ -277,7 +344,7 @@ public:     // misc
 
     // returns an array of pointers to the overloaded methods with the
     // same given name
-    wxMethodPtrArray FindMethodNamed(const wxString& m) const;
+    wxMethodPtrArray FindMethodsNamed(const wxString& m) const;
 
     // dumps all methods to the given output stream
     void Dump(wxTextOutputStream& stream) const;