add deprecation tags/attributes parsing
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52750 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
fc37712510
commit
0403e5dcc6
@ -21,23 +21,22 @@
|
|||||||
|
|
||||||
#include "wx/xml/xml.h"
|
#include "wx/xml/xml.h"
|
||||||
#include "wx/wfstream.h"
|
#include "wx/wfstream.h"
|
||||||
#include "wx/arrimpl.cpp"
|
|
||||||
#include "wx/hashmap.h"
|
#include "wx/hashmap.h"
|
||||||
#include "wx/filename.h"
|
#include "wx/filename.h"
|
||||||
|
#include "xmlparser.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include "xmlparser.h"
|
#include <wx/arrimpl.cpp>
|
||||||
|
|
||||||
#define PROGRESS_RATE 1000 // each PROGRESS_RATE nodes processed print a dot
|
|
||||||
#define ESTIMATED_NUM_CLASSES 600 // used by both wxXmlInterface-derived classes to prealloc mem
|
|
||||||
|
|
||||||
WX_DEFINE_OBJARRAY(wxTypeArray)
|
WX_DEFINE_OBJARRAY(wxTypeArray)
|
||||||
WX_DEFINE_OBJARRAY(wxMethodArray)
|
WX_DEFINE_OBJARRAY(wxMethodArray)
|
||||||
WX_DEFINE_OBJARRAY(wxClassArray)
|
WX_DEFINE_OBJARRAY(wxClassArray)
|
||||||
|
|
||||||
|
|
||||||
// declared in ifacecheck.cpp
|
#define PROGRESS_RATE 1000 // each PROGRESS_RATE nodes processed print a dot
|
||||||
|
#define ESTIMATED_NUM_CLASSES 600 // used by both wxXmlInterface-derived classes to prealloc mem
|
||||||
|
|
||||||
|
|
||||||
|
// defined in ifacecheck.cpp
|
||||||
extern bool g_verbose;
|
extern bool g_verbose;
|
||||||
|
|
||||||
|
|
||||||
@ -149,7 +148,8 @@ bool wxMethod::operator==(const wxMethod& m) const
|
|||||||
GetName() != m.GetName() ||
|
GetName() != m.GetName() ||
|
||||||
IsConst() != m.IsConst() ||
|
IsConst() != m.IsConst() ||
|
||||||
IsStatic() != m.IsStatic() ||
|
IsStatic() != m.IsStatic() ||
|
||||||
IsVirtual() != m.IsVirtual())
|
IsVirtual() != m.IsVirtual() ||
|
||||||
|
IsDeprecated() != m.IsDeprecated())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (m_args.GetCount()!=m.m_args.GetCount())
|
if (m_args.GetCount()!=m.m_args.GetCount())
|
||||||
@ -192,6 +192,9 @@ wxString wxMethod::GetAsString() const
|
|||||||
if (m_bVirtual)
|
if (m_bVirtual)
|
||||||
ret = "virtual " + ret;
|
ret = "virtual " + ret;
|
||||||
|
|
||||||
|
if (m_bDeprecated)
|
||||||
|
ret = "wxDEPRECATED( " + ret + " )";
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,6 +212,8 @@ void wxMethod::Dump(wxTextOutputStream& stream) const
|
|||||||
stream << " STATIC";
|
stream << " STATIC";
|
||||||
if (IsVirtual())
|
if (IsVirtual())
|
||||||
stream << " VIRTUAL";
|
stream << " VIRTUAL";
|
||||||
|
if (IsDeprecated())
|
||||||
|
stream << " DEPRECATED";
|
||||||
|
|
||||||
// no final newline
|
// no final newline
|
||||||
}
|
}
|
||||||
@ -543,16 +548,26 @@ bool wxXmlGccInterface::Parse(const wxString& filename)
|
|||||||
}
|
}
|
||||||
else if (n == "FunctionType" || n == "MethodType")
|
else if (n == "FunctionType" || n == "MethodType")
|
||||||
{
|
{
|
||||||
/* TODO: incomplete */
|
/*
|
||||||
|
TODO: parsing FunctionType and MethodType nodes is not as easy
|
||||||
|
as for other "simple" types.
|
||||||
|
*/
|
||||||
|
|
||||||
unsigned long ret = 0;
|
wxString argstr;
|
||||||
if (!getID(&ret, child->GetAttribute("returns")) || ret == 0) {
|
wxXmlNode *arg = child->GetChildren();
|
||||||
LogError("Invalid empty returns value for '%s' node", n);
|
while (arg)
|
||||||
return false;
|
{
|
||||||
|
if (arg->GetName() == "Argument")
|
||||||
|
argstr += arg->GetAttribute("type") + ", ";
|
||||||
|
arg = arg->GetNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (argstr.Len() > 0)
|
||||||
|
argstr = argstr.Left(argstr.Len()-2);
|
||||||
|
|
||||||
// these nodes make reference to other types... we'll resolve them later
|
// these nodes make reference to other types... we'll resolve them later
|
||||||
toResolveTypes[id] = toResolveTypeItem(ret, 0);
|
//toResolveTypes[id] = toResolveTypeItem(ret, 0);
|
||||||
|
types[id] = child->GetAttribute("returns") + "(" + argstr + ")";
|
||||||
}
|
}
|
||||||
else if (n == "File")
|
else if (n == "File")
|
||||||
{
|
{
|
||||||
@ -650,19 +665,8 @@ bool wxXmlGccInterface::Parse(const wxString& filename)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if 1
|
|
||||||
LogError("Cannot solve '%s' reference type!", referenced);
|
LogError("Cannot solve '%s' reference type!", referenced);
|
||||||
return false;
|
return false;
|
||||||
#else
|
|
||||||
typeIds.Add(toResolveTypeIds[i]);
|
|
||||||
typeNames.Add("TOFIX");
|
|
||||||
|
|
||||||
// this one has been resolved!
|
|
||||||
toResolveTypeIds.RemoveAt(i);
|
|
||||||
toResolveRefType.RemoveAt(i);
|
|
||||||
toResolveAttrib.RemoveAt(i);
|
|
||||||
n--;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -819,6 +823,7 @@ bool wxXmlGccInterface::ParseMethod(const wxXmlNode *p,
|
|||||||
m.SetConst(p->GetAttribute("const") == "1");
|
m.SetConst(p->GetAttribute("const") == "1");
|
||||||
m.SetStatic(p->GetAttribute("static") == "1");
|
m.SetStatic(p->GetAttribute("static") == "1");
|
||||||
m.SetVirtual(p->GetAttribute("virtual") == "1");
|
m.SetVirtual(p->GetAttribute("virtual") == "1");
|
||||||
|
m.SetDeprecated(p->GetAttribute("attributes") == "deprecated");
|
||||||
|
|
||||||
if (!m.IsOk()) {
|
if (!m.IsOk()) {
|
||||||
LogError("The prototype '%s' is not valid!", m.GetAsString());
|
LogError("The prototype '%s' is not valid!", m.GetAsString());
|
||||||
@ -1012,6 +1017,35 @@ static wxString GetTextFromChildren(const wxXmlNode *n)
|
|||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool HasTextNodeContaining(const wxXmlNode *parent, const wxString& name)
|
||||||
|
{
|
||||||
|
wxXmlNode *p = parent->GetChildren();
|
||||||
|
while (p)
|
||||||
|
{
|
||||||
|
switch (p->GetType())
|
||||||
|
{
|
||||||
|
case wxXML_TEXT_NODE:
|
||||||
|
if (p->GetContent() == name)
|
||||||
|
return true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case wxXML_ELEMENT_NODE:
|
||||||
|
// recurse into this node...
|
||||||
|
if (HasTextNodeContaining(p, name))
|
||||||
|
return true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// skip it
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
p = p->GetNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool wxXmlDoxygenInterface::ParseMethod(const wxXmlNode* p, wxMethod& m, wxString& header)
|
bool wxXmlDoxygenInterface::ParseMethod(const wxXmlNode* p, wxMethod& m, wxString& header)
|
||||||
{
|
{
|
||||||
wxTypeArray args;
|
wxTypeArray args;
|
||||||
@ -1058,6 +1092,13 @@ bool wxXmlDoxygenInterface::ParseMethod(const wxXmlNode* p, wxMethod& m, wxStrin
|
|||||||
m.SetLocation((int)line);
|
m.SetLocation((int)line);
|
||||||
header = child->GetAttribute("file");
|
header = child->GetAttribute("file");
|
||||||
}
|
}
|
||||||
|
else if (child->GetName() == "detaileddescription")
|
||||||
|
{
|
||||||
|
// when a method has a @deprecated tag inside its description,
|
||||||
|
// Doxygen outputs somewhere nested inside <detaileddescription>
|
||||||
|
// a <xreftitle>Deprecated</xreftitle> tag.
|
||||||
|
m.SetDeprecated(HasTextNodeContaining(child, "Deprecated"));
|
||||||
|
}
|
||||||
|
|
||||||
child = child->GetNext();
|
child = child->GetNext();
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,9 @@ WX_DECLARE_OBJARRAY(wxType, wxTypeArray);
|
|||||||
class wxMethod
|
class wxMethod
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxMethod() { m_bConst=m_bVirtual=m_bStatic=false; m_nLine=-1; }
|
wxMethod()
|
||||||
|
{ m_bConst=m_bVirtual=m_bStatic=m_bDeprecated=false; m_nLine=-1; }
|
||||||
|
|
||||||
wxMethod(const wxType& rettype, const wxString& name,
|
wxMethod(const wxType& rettype, const wxString& name,
|
||||||
const wxTypeArray& arguments, const wxArrayString& defaults,
|
const wxTypeArray& arguments, const wxArrayString& defaults,
|
||||||
bool isConst, bool isStatic, bool isVirtual)
|
bool isConst, bool isStatic, bool isVirtual)
|
||||||
@ -110,6 +112,9 @@ public: // getters
|
|||||||
bool IsDtor() const
|
bool IsDtor() const
|
||||||
{ return m_retType==wxEmptyType && m_strName.StartsWith("~"); }
|
{ return m_retType==wxEmptyType && m_strName.StartsWith("~"); }
|
||||||
|
|
||||||
|
bool IsDeprecated() const
|
||||||
|
{ return m_bDeprecated; }
|
||||||
|
|
||||||
|
|
||||||
public: // setters
|
public: // setters
|
||||||
|
|
||||||
@ -124,6 +129,8 @@ public: // setters
|
|||||||
{ m_bStatic=c; }
|
{ m_bStatic=c; }
|
||||||
void SetVirtual(bool c = true)
|
void SetVirtual(bool c = true)
|
||||||
{ m_bVirtual=c; }
|
{ m_bVirtual=c; }
|
||||||
|
void SetDeprecated(bool c = true)
|
||||||
|
{ m_bDeprecated=c; }
|
||||||
void SetLocation(int lineNumber)
|
void SetLocation(int lineNumber)
|
||||||
{ m_nLine=lineNumber; }
|
{ m_nLine=lineNumber; }
|
||||||
|
|
||||||
@ -143,6 +150,7 @@ protected:
|
|||||||
bool m_bConst;
|
bool m_bConst;
|
||||||
bool m_bStatic;
|
bool m_bStatic;
|
||||||
bool m_bVirtual;
|
bool m_bVirtual;
|
||||||
|
bool m_bDeprecated;
|
||||||
int m_nLine;
|
int m_nLine;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user