[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdevelop/lib/interfaces
From: Jonas Jacobi <jonas.jacobi () web ! de>
Date: 2004-06-17 15:17:48
Message-ID: 20040617151748.218EE935B () office ! kde ! org
[Download RAW message or body]
CVS commit by jacobi:
Addition to the codemodel utils:
+Added function to compare a function definition and a declaration(check if name and \
signature is equal) +Added a predicate class to use with findFunctionDefintion, which \
searches for a matching functiondefinition to a declaration
M +17 -0 codemodel_utils.cpp 1.3
M +26 -0 codemodel_utils.h 1.7
--- kdevelop/lib/interfaces/codemodel_utils.cpp #1.2:1.3
@@ -294,4 +294,21 @@ AllFunctionDefinitions allFunctionDefini
}
+bool compareDeclarationToDefinition( const FunctionDom & dec, const \
FunctionDefinitionDom & def ) +{
+ if (dec->scope() == def->scope() && dec->name() == def->name() && \
dec->resultType() == def->resultType() && dec->isConstant() == def->isConstant()) + \
{ + const ArgumentList defList = def->argumentList(), decList = \
dec->argumentList(); + if (defList.size() != decList.size())
+ return false;
+
+ size_t n = defList.size();
+ for(size_t i = 0; i < n; ++i)
+ if (defList[i]->type() != decList[i]->type())
+ return false;
+
+ return true;
+ }
+ return false;
}
+}//end of namespace CodeModeUtils
--- kdevelop/lib/interfaces/codemodel_utils.h #1.6:1.7
@@ -86,4 +86,5 @@ void findFunctionDefinitions( Pred pred,
lst << fun;
}
+;
#if 0
@@ -187,4 +188,29 @@ void processNamespaces(FunctionDefinitio
}
+/**
+ * Compare a declaration and a defintion of a function.
+ * @param dec declaration
+ * @param def definition
+ * @return true, if dec is the declaration of the functiondefinition def, false \
otherwise + * @author Jonas Jacobi <j.jacobi@gmx.de>
+ */
+bool compareDeclarationToDefinition(const FunctionDom& dec, const \
FunctionDefinitionDom& def); +
+/**
+ * Predicate for use with findFunctionDefintions. Searches for a defintion matching \
a declaration. + * @author Jonas Jacobi
+ */
+class PredDefinitionMatchesDeclaration{
+public:
+ PredDefinitionMatchesDeclaration(const FunctionDom& func) : \
m_declaration(func){}; + bool operator() (const FunctionDefinitionDom& def) \
const + {
+ return compareDeclarationToDefinition(m_declaration, def);
+ }
+
+private:
+ const FunctionDom m_declaration;
+};
+
FunctionList allFunctions(const FileDom &dom);
AllFunctions allFunctionsDetailed(const FileDom &dom);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic