Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

FindProjectFromFile refactoring

(1/1)

oBFusCATed:
@devs:
What do you think about this patch: http://cmpt.benbmp.org/codeblocks/patches/dbg/find_project_from_file_01.patch ?

The idea of it is to remove some code duplication and to make life of plugin writers easier. I plan to use this method in the gdb/mi plugin.
I'm not sure I like the signature of the method. I'd rather make it return a std::pair, so the users of the method have a in-code documentation that the method returns two values - a cbProject and a ProjectFile.

Any comments are welcome. If there are no objections in the next week or so, I'll commit it. :-P

ollydbg:

--- Code: ---+cbProject* ProjectManager::FindProjectForFile(const wxString& file, ProjectFile **resultFile,
+                                              bool isRelative, bool isUnixFilename)
+{
+    for (size_t i = 0; i < m_pProjects->GetCount(); ++i)
+    {
+        cbProject* prj = m_pProjects->Item(i);
+        ProjectFile *temp = prj->GetFileByFilename(file, isRelative, isUnixFilename);
+        if (temp)
+        {
+            if (resultFile)
+                *resultFile = temp;
+            return prj;
+        }
+    }
+    if (resultFile)
+        *resultFile = nullptr;
+    return nullptr;
+}

--- End code ---

So, the first matching project is returned. Right? (The original code does the same thing)

Ok about other part. :)

MortenMacFly:

--- Quote from: oBFusCATed on April 17, 2012, 11:47:28 pm ---Any comments are welcome. If there are no objections in the next week or so, I'll commit it. :-P

--- End quote ---
Fine with me.

Navigation

[0] Message Index

Go to full version