X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d2367a0f7899c3d39cf0e95d0ecf70b94688a9e3..b640fa17f3359e2766232e5dae3922de28236bde:/utils/ifacecheck/src/xmlparser.h diff --git a/utils/ifacecheck/src/xmlparser.h b/utils/ifacecheck/src/xmlparser.h index acf2ca7d72..f491bf0b08 100644 --- a/utils/ifacecheck/src/xmlparser.h +++ b/utils/ifacecheck/src/xmlparser.h @@ -16,12 +16,23 @@ #include #include #include +#include -// 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 wxPrint(str) { wxPrintf(str); fflush(stdout); } + +/* + 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: + // ...fix description... +*/ + +// NOTE: all messages in this way are printed on the stderr +//#define wxLogWarning wxLogMessage // ---------------------------------------------------------------------------- @@ -39,6 +50,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 @@ -55,10 +72,9 @@ public: bool IsOk() const; protected: - wxString m_strType; - - // utility for doing comparisons - wxString GetClean() const; + wxString m_strType, + m_strTypeClean; // m_strType "cleaned" of its attributes + // (only for internal use) }; extern wxType wxEmptyType; @@ -81,10 +97,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(); } @@ -96,18 +117,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. // ---------------------------------------------------------------------------- @@ -116,7 +144,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, @@ -128,7 +156,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 @@ -136,12 +173,16 @@ public: // getters { return m_retType; } wxString GetName() const { return m_strName; } - wxArgumentTypeArray GetArgumentTypes() const + const wxArgumentTypeArray& GetArgumentTypes() const + { return m_args; } + wxArgumentTypeArray& GetArgumentTypes() { return m_args; } int GetLocation() const { return m_nLine; } int GetAvailability() const { return m_nAvailability; } + wxMethodAccessSpecifier GetAccessSpecifier() const + { return m_access; } bool IsConst() const { return m_bConst; } @@ -157,11 +198,14 @@ public: // getters { return m_retType==wxEmptyType && !m_strName.StartsWith("~"); } bool IsDtor() const { return m_retType==wxEmptyType && m_strName.StartsWith("~"); } + bool IsOperator() const + { return m_strName.StartsWith("operator"); } bool IsDeprecated() const { return m_bDeprecated; } + public: // setters void SetReturnType(const wxType& t) @@ -187,6 +231,8 @@ public: // setters { m_nLine=lineNumber; } void SetAvailability(int nAvail) { m_nAvailability=nAvail; } + void SetAccessSpecifier(wxMethodAccessSpecifier spec) + { m_access=spec; } public: // misc @@ -194,6 +240,18 @@ 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; + + // returns true if this is a ctor which has default values for all its + // argument, thus is able to act also as default ctor + bool ActsAsDefaultCtor() const; + + // dumps the contents of this class in the given stream void Dump(wxTextOutputStream& stream) const; protected: @@ -216,12 +274,23 @@ 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); WX_DEFINE_ARRAY(const wxMethod*, wxMethodPtrArray); +// we need wxClassPtrArray to be defined _before_ wxClass itself, +// since wxClass uses wxClassPtrArray. +class wxClass; +WX_DEFINE_ARRAY(const wxClass*, wxClassPtrArray); + +class wxXmlInterface; + + // ---------------------------------------------------------------------------- // Represents a class of the wx API/interface. // ---------------------------------------------------------------------------- @@ -241,7 +310,8 @@ public: // setters { m_strName=name; } void SetAvailability(int nAvail) { m_nAvailability=nAvail; } - + void SetParent(unsigned int k, const wxString& name) + { m_parents[k]=name; } public: // getters @@ -267,18 +337,37 @@ public: // getters int GetAvailability() const { return m_nAvailability; } + //const wxClass *GetParent(unsigned int i) const + const wxString& GetParent(unsigned int i) const + { return m_parents[i]; } + unsigned int GetParentCount() const + { return m_parents.GetCount(); } + public: // misc void AddMethod(const wxMethod& func) { m_methods.Add(func); } + void AddParent(const wxString& parent)//wxClass* parent) + { m_parents.Add(parent); } + // returns a single result (the first, which is also the only // one if CheckConsistency() return true) const wxMethod* FindMethod(const wxMethod& m) const; + // like FindMethod() but this one searches also recursively in + // the parents of this class. + const wxMethod* RecursiveUpwardFindMethod(const wxMethod& m, + const wxXmlInterface* allclasses) const; + // returns an array of pointers to the overloaded methods with the // same given name - wxMethodPtrArray FindMethodNamed(const wxString& m) const; + wxMethodPtrArray FindMethodsNamed(const wxString& name) const; + + // like FindMethodsNamed() but this one searches also recursively in + // the parents of this class. + wxMethodPtrArray RecursiveUpwardFindMethodsNamed(const wxString& name, + const wxXmlInterface* allclasses) const; // dumps all methods to the given output stream void Dump(wxTextOutputStream& stream) const; @@ -291,12 +380,17 @@ protected: wxString m_strHeader; wxMethodArray m_methods; + // name of the base classes: we store the names and not the pointers + // because this makes _much_ easier the parsing process! + // (basically because when parsing class X which derives from Y, + // we may have not parsed yet class Y!) + wxArrayString m_parents; + // see the wxMethod::m_nAvailability field for more info int m_nAvailability; }; WX_DECLARE_OBJARRAY(wxClass, wxClassArray); -WX_DEFINE_ARRAY(const wxClass*, wxClassPtrArray); @@ -336,9 +430,10 @@ public: wxClassPtrArray FindClassesDefinedIn(const wxString& headerfile) const; void ShowProgress() - { /*wxPrint(".");*/ } + { /*wxFprintf(stderr, ".");*/ } - bool CheckParseResults() const; + // is this interface coherent? + bool CheckConsistency() const; protected: wxClassArray m_classes;