X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f270e1ddda1b89edfe4db9aa29ef26cac9ff4d0f..fe1a36a70c2f5ed8a6f9ea0b82005ebb987e5860:/utils/ifacecheck/src/xmlparser.h diff --git a/utils/ifacecheck/src/xmlparser.h b/utils/ifacecheck/src/xmlparser.h index 4baa76de1c..f160c79b3f 100644 --- a/utils/ifacecheck/src/xmlparser.h +++ b/utils/ifacecheck/src/xmlparser.h @@ -15,6 +15,7 @@ #include #include #include +#include // helper macros #define LogMessage(fmt, ...) { wxPrintf(fmt "\n", __VA_ARGS__); fflush(stdout); } @@ -54,10 +55,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; @@ -80,16 +80,24 @@ public: wxString GetArgumentName() const { return m_strArgName; } - void SetDefaultValue(const wxString& defval); + void SetDefaultValue(const wxString& defval, const wxString& defvalForCmp = wxEmptyString); wxString GetDefaultValue() const { return m_strDefaultValue; } + bool HasDefaultValue() const + { return !m_strDefaultValue.IsEmpty(); } + bool operator==(const wxArgumentType& m) const; bool operator!=(const wxArgumentType& m) const { return !(*this == m); } protected: wxString m_strDefaultValue; + + // this string may differ from m_strDefaultValue if there were + // preprocessor substitutions; can be wxEmptyString. + 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. @@ -106,7 +114,8 @@ class wxMethod { public: wxMethod() - { m_bConst=m_bVirtual=m_bPureVirtual=m_bStatic=m_bDeprecated=false; m_nLine=-1; } + { m_bConst=m_bVirtual=m_bPureVirtual=m_bStatic=m_bDeprecated=false; + m_nLine=-1; m_nAvailability=wxPORT_UNKNOWN; } wxMethod(const wxType& rettype, const wxString& name, const wxArgumentTypeArray& arguments, @@ -130,6 +139,8 @@ public: // getters { return m_args; } int GetLocation() const { return m_nLine; } + int GetAvailability() const + { return m_nAvailability; } bool IsConst() const { return m_bConst; } @@ -165,11 +176,16 @@ public: // setters void SetVirtual(bool c = true) { m_bVirtual=c; } void SetPureVirtual(bool c = true) - { m_bPureVirtual=c; } + { + m_bPureVirtual=c; + if (c) m_bVirtual=c; // pure virtual => virtual + } void SetDeprecated(bool c = true) { m_bDeprecated=c; } void SetLocation(int lineNumber) { m_nLine=lineNumber; } + void SetAvailability(int nAvail) + { m_nAvailability=nAvail; } public: // misc @@ -183,12 +199,22 @@ protected: wxType m_retType; wxString m_strName; wxArgumentTypeArray m_args; + + // misc attributes: bool m_bConst; bool m_bStatic; bool m_bVirtual; bool m_bPureVirtual; bool m_bDeprecated; + + // m_nLine can be -1 if no location infos are available int m_nLine; + + // this is a combination of wxPORT_* flags (see wxPortId) or wxPORT_UNKNOWN + // if this method should be available for all wxWidgets ports. + // NOTE: this is not used for comparing wxMethod objects + // (gccXML never gives this kind of info). + int m_nAvailability; }; WX_DECLARE_OBJARRAY(wxMethod, wxMethodArray); @@ -205,18 +231,18 @@ public: wxClass(const wxString& name, const wxString& headername) : m_strName(name), m_strHeader(headername) {} - void AddMethod(const wxMethod& func) - { m_methods.Add(func); } + +public: // setters void SetHeader(const wxString& header) { m_strHeader=header; } void SetName(const wxString& name) { m_strName=name; } - wxString GetName() const - { return m_strName; } - wxString GetHeader() const - { return m_strHeader; } - wxString GetNameWithoutTemplate() const; + void SetAvailability(int nAvail) + { m_nAvailability=nAvail; } + + +public: // getters bool IsOk() const { return !m_strName.IsEmpty() && !m_methods.IsEmpty(); } @@ -224,6 +250,12 @@ public: bool IsValidCtorForThisClass(const wxMethod& m) const; bool IsValidDtorForThisClass(const wxMethod& m) const; + wxString GetName() const + { return m_strName; } + wxString GetHeader() const + { return m_strHeader; } + wxString GetNameWithoutTemplate() const; + unsigned int GetMethodCount() const { return m_methods.GetCount(); } wxMethod& GetMethod(unsigned int n) const @@ -231,6 +263,14 @@ public: wxMethod& GetLastMethod() const { return m_methods.Last(); } + int GetAvailability() const + { return m_nAvailability; } + +public: // misc + + void AddMethod(const wxMethod& func) + { m_methods.Add(func); } + // returns a single result (the first, which is also the only // one if CheckConsistency() return true) const wxMethod* FindMethod(const wxMethod& m) const; @@ -249,6 +289,9 @@ protected: wxString m_strName; wxString m_strHeader; wxMethodArray m_methods; + + // see the wxMethod::m_nAvailability field for more info + int m_nAvailability; }; WX_DECLARE_OBJARRAY(wxClass, wxClassArray); @@ -288,6 +331,9 @@ public: return methods; } + // pass a full-path header filename: + wxClassPtrArray FindClassesDefinedIn(const wxString& headerfile) const; + void ShowProgress() { /*wxPrint(".");*/ } @@ -303,6 +349,8 @@ protected: WX_DECLARE_HASH_MAP( unsigned long, wxString, wxIntegerHash, wxIntegerEqual, wxTypeIdHashMap ); + +WX_DECLARE_STRING_HASH_MAP( wxString, wxStringHashMap ); #else #include typedef std::basic_string stlString; @@ -317,20 +365,27 @@ typedef std::map wxTypeIdHashMap; class wxXmlGccInterface : public wxXmlInterface { public: - wxXmlGccInterface() {} - - // !!SPEEDUP-TODO!! - // Using wxXmlDocument::Load as is, all the types contained in the - // the entire gccXML file are stored in memory while parsing; - // however we are only interested to wx's own structs/classes/funcs/etc - // so that we could use the file IDs to avoid loading stuff which does - // not belong to wx. See the very end of the gccXML file: it contains - // a set of nodes referenced by all nodes above. + wxXmlGccInterface() + { + // FIXME: we should retrieve this from the XML file! + // here we suppose the XML was created for the currently-running port + m_portId = wxPlatformInfo::Get().GetPortId(); + } bool Parse(const wxString& filename); bool ParseMethod(const wxXmlNode *p, const wxTypeIdHashMap& types, wxMethod& m); + + wxPortId GetInterfacePort() const + { return m_portId; } + + wxString GetInterfacePortName() const + { return wxPlatformInfo::GetPortIdName(m_portId, false); } + +protected: + // the port for which the gcc XML was generated + wxPortId m_portId; }; @@ -354,6 +409,14 @@ public: bool Parse(const wxString& filename); bool ParseCompoundDefinition(const wxString& filename); bool ParseMethod(const wxXmlNode*, wxMethod&, wxString& header); + + // this class can take advantage of the preprocessor output to give + // a minor number of false positive warnings in the final comparison + void AddPreprocessorValue(const wxString& name, const wxString& val) + { m_preproc[name]=val; } + +protected: + wxStringHashMap m_preproc; };