Skip to content

Commit

Permalink
Changed ArgumentList to be an STL container
Browse files Browse the repository at this point in the history
  • Loading branch information
doxygen committed Oct 27, 2019
1 parent 560bd4f commit c38a6fe
Show file tree
Hide file tree
Showing 35 changed files with 1,459 additions and 2,271 deletions.
60 changes: 25 additions & 35 deletions addon/doxyparse/doxyparse.cpp
Expand Up @@ -183,28 +183,25 @@ std::string sanitizeString(std::string data) {
return !new_data.isEmpty() ? new_data.data() : "";
}

std::string argumentData(Argument *argument) {
std::string argumentData(const Argument &argument) {
std::string data = "";
if (argument->type != NULL && argument->type.size() > 1)
data = sanitizeString(argument->type.data());
else if (argument->name != NULL)
data = sanitizeString(argument->name.data());
if (argument.type.size() > 1)
data = sanitizeString(argument.type.data());
else if (!argument.name.isEmpty())
data = sanitizeString(argument.name.data());
return data;
}

std::string functionSignature(MemberDef* md) {
std::string signature = sanitizeString(md->name().data());
if(md->isFunction()){
ArgumentList *argList = md->argumentList();
const ArgumentList &argList = md->argumentList();
signature += "(";
if (argList) {
ArgumentListIterator iterator(*argList);
Argument * argument = iterator.toFirst();
if(argument != NULL) {
signature += argumentData(argument);
for(++iterator; (argument = iterator.current()); ++iterator) {
signature += std::string(",") + argumentData(argument);
}
auto it = argList.begin();
if(it!=argList.end()) {
signature += argumentData(*it);
for(++it; it!=argList.end(); ++it) {
signature += std::string(",") + argumentData(*it);
}
}
signature += ")";
Expand Down Expand Up @@ -255,19 +252,14 @@ void cModule(ClassDef* cd) {
}
}

static bool checkOverrideArg(ArgumentList *argList, MemberDef *md) {
ArgumentListIterator iterator(*argList);
Argument * argument = iterator.toFirst();

if(!md->isFunction() || argList->count() == 0){
return false;
static bool checkOverrideArg(const ArgumentList &argList, MemberDef *md) {
if(!md->isFunction() || argList.empty()){
return false;
}

if(argument != NULL) {
for(; (argument = iterator.current()); ++iterator){
if(md->name() == argument->name) {
return true;
}
for (const Argument &argument : argList) {
if(md->name() == argument.name) {
return true;
}
}

Expand All @@ -278,17 +270,15 @@ void functionInformation(MemberDef* md) {
std::string temp = "";
int size = md->getEndBodyLine() - md->getStartBodyLine() + 1;
printNumberOfLines(size);
ArgumentList *argList = md->argumentList();
if (argList) {
ArgumentListIterator iterator(*argList);
Argument * argument = iterator.toFirst();
if(argument != NULL) {
temp = argumentData(argument);
const ArgumentList &argList = md->argumentList();
if (!argList.empty())
{
temp = argumentData(argList.front());
// TODO: This is a workaround; better not include "void" in argList, in the first place.
if(temp != "void") {
printNumberOfArguments(argList->count());
}
}
if (temp!="void")
{
printNumberOfArguments(argList.size());
}
}

printNumberOfConditionalPaths(md);
Expand Down
48 changes: 17 additions & 31 deletions src/arguments.cpp
@@ -1,39 +1,25 @@
/*****************************************************************************
* Copyright (C) 1997-2019 by Dimitri van Heesch.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation under the terms of the GNU General Public License is hereby
* granted. No representations are made about the suitability of this software
* for any purpose. It is provided "as is" without express or implied warranty.
* See the GNU General Public License for more details.
*
* Documents produced by Doxygen are derivative works derived from the
* input used in their production; they are not affected by this license.
*/

#include <algorithm>

#include "arguments.h"
#include <assert.h>

/*! the argument list is documented if one of its
* arguments is documented
* arguments is documented
*/
bool ArgumentList::hasDocumentation() const
{
bool hasDocs=FALSE;
ArgumentListIterator ali(*this);
Argument *a;
for (ali.toFirst();!hasDocs && (a=ali.current());++ali)
{
hasDocs = a->hasDocumentation();
}
return hasDocs;
}

ArgumentList *ArgumentList::deepCopy() const
{
ArgumentList *argList = new ArgumentList;
argList->setAutoDelete(TRUE);

QListIterator<Argument> ali(*this);
Argument *a;
for (;(a=ali.current());++ali)
{
argList->append(new Argument(*a));
}
argList->constSpecifier = constSpecifier;
argList->volatileSpecifier = volatileSpecifier;
argList->pureSpecifier = pureSpecifier;
argList->trailingReturnType = trailingReturnType;
argList->isDeleted = isDeleted;
argList->refQualifier = refQualifier;

return argList;
return std::any_of(begin(),end(),[](const Argument &a){ return a.hasDocumentation(); });
}

81 changes: 29 additions & 52 deletions src/arguments.h
Expand Up @@ -16,7 +16,7 @@
#ifndef ARGUMENTS_H
#define ARGUMENTS_H

#include <qlist.h>
#include <vector>
#include <qcstring.h>

class StorageIntf;
Expand All @@ -27,34 +27,6 @@ class StorageIntf;
*/
struct Argument
{
/*! Construct a new argument. */
Argument() {}
/*! Copy an argument (does a deep copy of all strings). */
Argument(const Argument &a)
{
attrib=a.attrib;
type=a.type;
name=a.name;
array=a.array;
defval=a.defval;
docs=a.docs;
typeConstraint=a.typeConstraint;
}
/*! Assignment of an argument (does a deep copy of all strings). */
Argument &operator=(const Argument &a)
{
if (this!=&a)
{
attrib=a.attrib;
type=a.type;
name=a.name;
array=a.array;
defval=a.defval;
docs=a.docs;
typeConstraint=a.typeConstraint;
}
return *this;
}
/*! return TRUE if this argument is documentation and the argument has a
* non empty name.
*/
Expand Down Expand Up @@ -86,37 +58,42 @@ enum RefQualifierType
* put after the argument list, such as whether the member is const,
* volatile or pure virtual.
*/
class ArgumentList : public QList<Argument>
class ArgumentList : public std::vector<Argument>
{
public:
/*! Creates an empty argument list */
ArgumentList() : QList<Argument>(),
constSpecifier(FALSE),
volatileSpecifier(FALSE),
pureSpecifier(FALSE),
isDeleted(FALSE),
refQualifier(RefQualifierNone)
{ setAutoDelete(TRUE); }
/*! Destroys the argument list */
~ArgumentList() {}
/*! Makes a deep copy of this object */
ArgumentList *deepCopy() const;
/*! Does any argument of this list have documentation? */
bool hasDocumentation() const;
/*! Does the member modify the state of the class? default: FALSE. */
bool constSpecifier;
/*! Is the member volatile? default: FALSE. */
bool volatileSpecifier;
/*! Is this a pure virtual member? default: FALSE */
bool pureSpecifier;
/*! Does this list have zero or more parameters */
bool hasParameters() const
{
return !empty() || noParameters;
}
void reset()
{
clear();
constSpecifier = FALSE;
volatileSpecifier = FALSE;
pureSpecifier = FALSE;
trailingReturnType.resize(0);
isDeleted = FALSE;
refQualifier = RefQualifierNone;
noParameters = FALSE;
}

/*! Does the member modify the state of the class? */
bool constSpecifier = FALSE;
/*! Is the member volatile? */
bool volatileSpecifier = FALSE;
/*! Is this a pure virtual member? */
bool pureSpecifier = FALSE;
/*! C++11 style Trailing return type? */
QCString trailingReturnType;
/*! method with =delete */
bool isDeleted;
bool isDeleted = FALSE;
/*! C++11 ref qualifier */
RefQualifierType refQualifier;
RefQualifierType refQualifier = RefQualifierNone;
/*! is it an explicit empty list */
bool noParameters = FALSE;
};

typedef QListIterator<Argument> ArgumentListIterator;

#endif

0 comments on commit c38a6fe

Please sign in to comment.