From: Francesco Montorsi Date: Sat, 22 Mar 2008 19:18:25 +0000 (+0000) Subject: add Id keyword; remove old code (was commented out) which tried to implement alternat... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/5ceba28d35c9eea1065da7d4a0af56c471fb7c61 add Id keyword; remove old code (was commented out) which tried to implement alternative parsing strategies; basically those involved doing 4-5 passes on the gcc XML before actually passing it storing the list of the type IDs related in some way to wxWidgets, and then do the true parsing pass, skipping anything non-wx related. This approach (and its variations) showed however to be slower than building the full type table. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52710 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/utils/ifacecheck/src/ifacecheck.bkl b/utils/ifacecheck/src/ifacecheck.bkl index 59ef48cd07..a3b3038b9c 100644 --- a/utils/ifacecheck/src/ifacecheck.bkl +++ b/utils/ifacecheck/src/ifacecheck.bkl @@ -1,4 +1,6 @@ + + diff --git a/utils/ifacecheck/src/ifacecheck.cpp b/utils/ifacecheck/src/ifacecheck.cpp index 94b168b4d6..2f1656b971 100644 --- a/utils/ifacecheck/src/ifacecheck.cpp +++ b/utils/ifacecheck/src/ifacecheck.cpp @@ -314,16 +314,3 @@ void IfaceCheckApp::PrintStatistics(long secs) LogMessage("total processing took %d seconds.", secs); } - -/* - HACK -*/ - -#include "wx/process.h" -#include "wx/unix/execute.h" - -int wxAddProcessCallback(wxEndProcessData *, int ) -{ - return 0; -} - diff --git a/utils/ifacecheck/src/xmlparser.cpp b/utils/ifacecheck/src/xmlparser.cpp index b768a519ec..f74f53e230 100644 --- a/utils/ifacecheck/src/xmlparser.cpp +++ b/utils/ifacecheck/src/xmlparser.cpp @@ -142,84 +142,6 @@ void wxMethod::SetArgumentTypes(const wxTypeArray& arr, const wxArrayString& def } } - -/* -void wxMethod::SetFromString(const wxString& proto) -{ - m_strProto=proto.Strip(wxString::both); - - // make sure there is a space separing each token - m_strProto.Replace("&", "& "); - m_strProto.Replace("*", "* "); - m_strProto.Replace(",", ", "); - - wxASSERT(m_strProto.Contains("::")); - wxASSERT(m_strProto.Contains("(") && m_strProto.Contains(")")); -} - -wxType wxMethod::GetReturnType() const -{ - wxString leftpart = m_strProto.Left(m_strProto.Find("::")).Strip(wxString::both); - if (!leftpart.Contains(" ")) - // this is a dtor or a ctor then... - return wxEmptyType; - - // see SetFromString: all tokens are separed by a space! - wxType ret(leftpart.BeforeFirst(' ').Strip(wxString::both)); - wxASSERT(ret.IsOk()); - - return ret; -} - -wxString wxMethod::GetName() const -{ - int nstart = m_strProto.Find("::")+2, - nend = m_strProto.Find("("); - wxASSERT(nstart!=wxNOT_FOUND && nend!=wxNOT_FOUND); - - return m_strProto.Mid(nstart, nend-nstart).Strip(wxString::both); -} - -bool wxMethod::IsConst() const -{ - return m_strProto.EndsWith("const"); -} - -bool wxMethod::IsStatic() const -{ - return m_strProto.StartsWith("static"); -} - -wxTypeArray wxMethod::GetArgumentTypes() const -{ - int nstart = m_strProto.Find('(', false * start from beginning *)+1, - nend = m_strProto.Find(')', true * start from end *); - wxASSERT(nstart!=wxNOT_FOUND && nend!=wxNOT_FOUND); - - wxString argstr = m_strProto.Mid(nstart, nend-nstart).Strip(wxString::both); - wxArrayString args = wxSplit(argstr, ','); - - wxTypeArray ret; - for (unsigned int i=0; i1 && - !temp.Last().Contains("&") && - !temp.Last().Contains("*") && - g_) - arg.Replace(temp.Last(), ""); // looks like an argument name - remove it - - ret.Add(wxType(arg)); - } - - return ret; -} -*/ bool wxMethod::operator==(const wxMethod& m) const { if (GetReturnType() != m.GetReturnType() || @@ -431,9 +353,12 @@ public: int attribs; }; -//WX_DECLARE_STRING_HASH_MAP( toResolveTypeItem, wxToResolveTypeHashMap ); +#if 1 +WX_DECLARE_STRING_HASH_MAP( toResolveTypeItem, wxToResolveTypeHashMap ); +#else #include typedef std::map wxToResolveTypeHashMap; +#endif bool wxXmlGccInterface::Parse(const wxString& filename) { @@ -463,97 +388,6 @@ bool wxXmlGccInterface::Parse(const wxString& filename) m_classes.Alloc(ESTIMATED_NUM_CLASSES); arrMemberIds.Alloc(ESTIMATED_NUM_TYPES); -#if 0 - // do a quick parsing of the nodes; we take advantage of the fact that - // gccxml puts all of them in a contiguos block at the end of the file it produces. - child = doc.GetRoot()->GetChildren(); - while (child && child->GetName() != "File") - child = child->GetNext(); // skip everything until first node - - // here starts the node block - while (child) - { - wxString id = child->GetAttribute("id", ""); - if (!id.StartsWith("f")) { - LogError("Unexpected file ID: %s", id); - return false; - } - - fileIds.Add(id); - fileNames.Add(child->GetAttribute("name", "")); - - child = child->GetNext(); - } -#endif - -#if 0 - wxString allWxClassesIds, allWxMethodsIds, allWxReferencesIds; - allWxClassesIds.Alloc(240000); - allWxMethodsIds.Alloc(240000); - allWxReferencesIds.Alloc(240000); - child = doc.GetRoot()->GetChildren(); - while (child) - { - if (child->GetName() == "Class") - if (child->GetAttribute("name", wxEmptyString).StartsWith("wx")) - allWxClassesIds += " " + child->GetAttribute("members", wxEmptyString); - child = child->GetNext(); - } - - child = doc.GetRoot()->GetChildren(); - while (child) - { - wxString n = child->GetName(); - if ((n == "Method" || n == "Constructor" || n == "Destructor" || n == "OperatorMethod") && - child->GetAttribute("access", wxEmptyString) == "public") - { - if (allWxClassesIds.Contains(child->GetAttribute("id", wxEmptyString))) - { - allWxMethodsIds += " " + child->GetAttribute("returns", wxEmptyString); - - wxXmlNode *arg = child->GetChildren(); - while (arg) - { - if (arg->GetName() == "Argument") - allWxMethodsIds += " " + arg->GetAttribute("type", wxEmptyString); - - arg = arg->GetNext(); - } - } - } - - child = child->GetNext(); - } - - child = doc.GetRoot()->GetChildren(); - while (child) - { - if (allWxMethodsIds.Contains(child->GetAttribute("id", wxEmptyString))) - { - const wxString& type = child->GetAttribute("type", wxEmptyString); - allWxReferencesIds += " " + type; - } - - child = child->GetNext(); - } - - child = doc.GetRoot()->GetChildren(); - while (child) - { - if (allWxReferencesIds.Contains(child->GetAttribute("id", wxEmptyString))) - { - const wxString& type = child->GetAttribute("type", wxEmptyString); - allWxReferencesIds += " " + type; - } - - child = child->GetNext(); - } - - LogMessage("adfafdasfdas %d-%d-%d", allWxClassesIds.Len(), - allWxMethodsIds.Len(), allWxReferencesIds.Len()); -#endif - - // build a list of wx classes and in general of all existent types child = doc.GetRoot()->GetChildren(); while (child) @@ -561,34 +395,6 @@ bool wxXmlGccInterface::Parse(const wxString& filename) const wxString& n = child->GetName(); const wxString& id = child->GetAttribute("id", wxEmptyString); -#if 0 - if (!allWxClassesIds.Contains(id) && !allWxMethodsIds.Contains(id) && !allWxReferencesIds.Contains(id)) - ; // ignore this node - else -#endif -#if 0 - wxString fid = child->GetAttribute("file", ""); - int fileidx = wxNOT_FOUND; - - if (!fid.IsEmpty()) { - fileidx = fileIds.Index(fid); - if (fileidx == wxNOT_FOUND) { - LogError("couldn't find the file ID '%s'", fid); - return false; - } - } - - if (fileidx!=wxNOT_FOUND && !fileNames[fileidx].Contains("wx")) - { - // skip this node: not wx related! - } else -#endif - - /*if (child->GetAttribute("artificial", "") == "1") - { - // discard this immediately - we're not interested - } - else*/ if (n == "Class") { wxString cname = child->GetAttribute("name", wxEmptyString); @@ -606,8 +412,6 @@ bool wxXmlGccInterface::Parse(const wxString& filename) } // register this class also as possible return/argument type: - //typeIds.Add(child->GetAttribute("id", wxEmptyString)); - //typeNames.Add(cname); types[id] = cname; } else if (n == "PointerType" || n == "ReferenceType" || @@ -630,9 +434,6 @@ bool wxXmlGccInterface::Parse(const wxString& filename) attr = ATTRIB_ARRAY; // these nodes make reference to other types... we'll resolve them later - //toResolveTypeIds.Add(id); - //toResolveRefType.Add(type); - //toResolveAttrib.Add(attr); toResolveTypes[id] = toResolveTypeItem(type, attr); } else if (n == "FunctionType" || n == "MethodType") @@ -662,10 +463,6 @@ bool wxXmlGccInterface::Parse(const wxString& filename) { // we register everything else as a possible return/argument type: const wxString& name = child->GetAttribute("name", wxEmptyString); - /*if (id.IsEmpty() || name.IsEmpty()) { - LogError("Invalid empty name/id for '%s' node", n); - return false; - }*/ if (!name.IsEmpty()) { @@ -682,8 +479,6 @@ bool wxXmlGccInterface::Parse(const wxString& filename) if (g_verbose) LogWarning("Type '%s' with ID '%s' does not have name attribute", n, id); - //typeIds.Add(id); - //typeNames.Add("TOFIX"); types[id] = "TOFIX"; } } @@ -766,52 +561,6 @@ bool wxXmlGccInterface::Parse(const wxString& filename) } } } -/* - // now get the return types of all wx methods parsed above - child = doc.GetRoot()->GetChildren(); - int idx; - while (child) { - - wxString n = child->GetName(); - - if (n == "PointerType" || n == "ReferenceType" || n == "CvQualifiedType") { - wxString id = child->GetAttribute("id", wxEmptyString); - wxString type = child->GetAttribute("type", wxEmptyString); - - // are we interested to this id? - while ((idx = retTypeIds.Index(id)) != wxNOT_FOUND) - { - // substitute this ID with the ID referenced by this node - retTypeIds[idx] = type; - // leave "incompleteMethods" array untouched - } - } else { - wxString id = child->GetAttribute("id", wxEmptyString); - wxString name = child->GetAttribute("name", wxEmptyString); - if (!name.IsEmpty()) - { - // are we interested to this id? - while ((idx = retTypeIds.Index(id)) != wxNOT_FOUND) - { - wxMethod *p = (wxMethod*)incompleteMethods[idx]; - p->SetFromString(name + " " + p->GetAsString()); - - //LogMessage("rettype node is named %s and is '%s'", n, - // child->GetAttribute("name", "")); - - // prototype is now complete; remove it from the list of protos - // waiting for completion - retTypeIds.RemoveAt(idx); - incompleteMethods.RemoveAt(idx); - } - } - } - - child = child->GetNext(); - - // give feedback to the user about the progress... - if ((++nodes%PROGRESS_RATE)==0) ShowProgress(); - }*/ } // resolve header names