Example #1
0
ClassDef *GenericsSDict::find(const QCString &key)
{
  int i=key.find('<');
  if (i==-1)
  {
    GenericsCollection *collection = m_dict.find(key);
    if (collection && collection->count()==1)
    {
      QIntDictIterator<ClassDef> it(*collection);
      return it.current();
    }
  }
  else
  {
    GenericsCollection *collection = m_dict.find(key.left(i));
    if (collection)
    {
      ArgumentList argList;
      stringToArgumentList(key.mid(i),&argList);
      int c = argList.count();
      return collection->find(c);
    }
  }
  return 0;
}
Example #2
0
QString makeFunction(FunctionModelItem function, const QString preFix = QString()) {
    QString fullName;
    fullName += function->type().toString();
    fullName += " ";
    fullName += preFix;
    fullName += function->name();
    ArgumentList arguments = function->arguments();
    QStringList args;
    for (int i = 0; i < arguments.count(); ++i) {
        QString arg = arguments[i]->name();
        if (arg.isEmpty())
            arg = QString("arg%1").arg(i);
        QString theargs = arguments[i]->type().toString() + " " + arg;
        if (arguments[i]->defaultValue())
            theargs += " = " + arguments[i]->defaultValueExpression();
        args += theargs;
    }
    fullName += "(" + args.join(", ") + ")";
    if (function->isConstant())
        fullName +=  " const";

    if (function->isStatic())
        fullName =  "static " + fullName;

    return fullName;
}
Example #3
0
QSharedPointer<ClassDef> GenericsSDict::find(const QString &key)
{
   int i = key.indexOf('<');

   if (i == -1) {
       QSharedPointer<QHash<long, QSharedPointer<ClassDef>>> collection = m_dict.find(key);

      if (collection && collection->count() == 1) {        
         return collection->begin().value();
      }

   } else {
      QSharedPointer<QHash<long, QSharedPointer<ClassDef>>> collection = m_dict.find(key.left(i));

      if (collection) {
         ArgumentList argList;
         stringToArgumentList(key.mid(i), &argList);

         int c = argList.count();
         return collection->value(c);
      }
   }

   return QSharedPointer<ClassDef>();
}
Example #4
0
void GenericsSDict::insert(const QString &key, QSharedPointer<ClassDef> cd)
{
   int i = key.indexOf('<');

   if (i == -1) {
      return;
   }

   ArgumentList argList;
   stringToArgumentList(key.mid(i), &argList);

   int c = argList.count();

   if (c == 0) {
      return;
   }

   QSharedPointer<QHash<long, QSharedPointer<ClassDef>>> collection = m_dict.find(key.left(i));

   if (collection == 0) {
      // new hash
      collection = QMakeShared<QHash<long, QSharedPointer<ClassDef>>>();       

      // add new hash to m_dict
      m_dict.insert(key.left(i), collection);
   }

   if (! collection->contains(c)) {
      // add the collection
      collection->insert(c, cd);
   }
}
Example #5
0
void GenericsSDict::insert(const QCString &key,ClassDef *cd)
{
  int i=key.find('<');
  if (i==-1) return;
  ArgumentList argList;
  stringToArgumentList(key.mid(i),&argList);
  int c = argList.count();
  if (c==0) return;
  GenericsCollection *collection = m_dict.find(key.left(i));
  if (collection==0) // new name
  {
    collection = new GenericsCollection;
    m_dict.append(key.left(i),collection);
  }
  if (collection->find(c)==0) // should always be 0!
  {
    collection->insert(c,cd);
  }
}
Example #6
0
void generateDEFForMember(MemberDef *md,
    FTextStream &t,
    Definition *def,
    const char* Prefix)
{
  QCString memPrefix;

  // + declaration
  // - reimplements
  // - reimplementedBy
  // - exceptions
  // - const/volatile specifiers
  // - examples
  // + source definition
  // - source references
  // - source referenced by
  // - include code 

  if (md->memberType()==MemberDef::EnumValue) return;

  QCString scopeName;
  if (md->getClassDef()) 
    scopeName=md->getClassDef()->name();
  else if (md->getNamespaceDef()) 
    scopeName=md->getNamespaceDef()->name();

  t << "    " << Prefix << "-member = {" << endl;
  memPrefix = "      ";
  memPrefix.append( Prefix );
  memPrefix.append( "-mem-" );

  QCString memType;
  bool isFunc=FALSE;
  switch (md->memberType())
  {
    case MemberDef::Define:      memType="define";    break;
    case MemberDef::EnumValue:   ASSERT(0);           break;
    case MemberDef::Property:    memType="property";  break;
    case MemberDef::Event:       memType="event";     break;
    case MemberDef::Variable:    memType="variable";  break;
    case MemberDef::Typedef:     memType="typedef";   break;
    case MemberDef::Enumeration: memType="enum";      break;
    case MemberDef::Function:    memType="function";  isFunc=TRUE; break;
    case MemberDef::Signal:      memType="signal";    isFunc=TRUE; break;
    case MemberDef::Friend:      memType="friend";    isFunc=TRUE; break;
    case MemberDef::DCOP:        memType="dcop";      isFunc=TRUE; break;
    case MemberDef::Slot:        memType="slot";      isFunc=TRUE; break;
  }

  t << memPrefix << "kind = '" << memType << "';" << endl;
  t << memPrefix << "id   = '"
    << md->getOutputFileBase() << "_1" << md->anchor()
    << "';" << endl;

  t << memPrefix << "virt = ";
  switch (md->virtualness())
  {
    case Normal:  t << "normal;"       << endl; break;
    case Virtual: t << "virtual;"      << endl; break;
    case Pure:    t << "pure-virtual;" << endl; break;
    default: ASSERT(0);
  }

  t << memPrefix << "prot = ";
  switch(md->protection())
  {
    case Public:    t << "public;"    << endl; break;
    case Protected: t << "protected;" << endl; break;
    case Private:   t << "private;"   << endl; break;
    case Package:   t << "package;"   << endl; break;
  }

  if (md->memberType()!=MemberDef::Define &&
      md->memberType()!=MemberDef::Enumeration
     )
  {
    QCString typeStr = replaceAnonymousScopes(md->typeString());
    t << memPrefix << "type = <<_EnD_oF_dEf_TeXt_" << endl << typeStr << endl
      << "_EnD_oF_dEf_TeXt_;" << endl;
  }

  t << memPrefix << "name = '" << md->name() << "';" << endl;

  if (isFunc) //function
  {
    ArgumentList *declAl = new ArgumentList;
    LockingPtr<ArgumentList> defAl = md->argumentList();
    stringToArgumentList(md->argsString(),declAl);
    QCString fcnPrefix = "  " + memPrefix + "param-";

    if (declAl->count()>0)
    {
      ArgumentListIterator declAli(*declAl);
      ArgumentListIterator defAli(*defAl);
      Argument *a;
      for (declAli.toFirst();(a=declAli.current());++declAli)
      {
        Argument *defArg = defAli.current();
        t << memPrefix << "param = {" << endl;
        if (!a->attrib.isEmpty())
        {
          t << fcnPrefix << "attributes = ";
          writeDEFString(t,a->attrib);
          t << ';' << endl;
        }
        if (!a->type.isEmpty())
        {
          t << fcnPrefix << "type = <<_EnD_oF_dEf_TeXt_" << endl
            << a->type << endl << "_EnD_oF_dEf_TeXt_;" << endl;
        }
        if (!a->name.isEmpty())
        {
          t << fcnPrefix << "declname = ";
          writeDEFString(t,a->name);
          t << ';' << endl;
        }
        if (defArg && !defArg->name.isEmpty() && defArg->name!=a->name)
        {
          t << fcnPrefix << "defname = ";
          writeDEFString(t,defArg->name);
          t << ';' << endl;
        }
        if (!a->array.isEmpty())
        {
          t << fcnPrefix << "array = ";
          writeDEFString(t,a->array); 
          t << ';' << endl;
        }
        if (!a->defval.isEmpty())
        {
          t << fcnPrefix << "defval = <<_EnD_oF_dEf_TeXt_" << endl
            << a->defval << endl << "_EnD_oF_dEf_TeXt_;" << endl;
        }
        if (defArg) ++defAli;
        t << "      }; /*" << fcnPrefix << "-param */" << endl;
      }
    }
    delete declAl;
  }
  else if (  md->memberType()==MemberDef::Define
      && md->argsString()!=0)
  {
    ArgumentListIterator ali(*md->argumentList());
    Argument *a;
    QCString defPrefix = "  " + memPrefix + "def-";

    for (ali.toFirst();(a=ali.current());++ali)
    {
      t << memPrefix << "param  = {" << endl;
      t << defPrefix << "name = '" << a->type << "';" << endl;
      t << "      }; /*" << defPrefix << "-param */" << endl;
    }
  }

  if (!md->initializer().isEmpty())
  {
    t << memPrefix << "initializer = <<_EnD_oF_dEf_TeXt_" << endl
      << md->initializer() << endl << "_EnD_oF_dEf_TeXt_;" << endl;
  }
  // TODO: exceptions, const volatile
  if (md->memberType()==MemberDef::Enumeration) // enum
  {
    LockingPtr<MemberList> enumList = md->enumFieldList();
    if (enumList!=0)
    {
      MemberListIterator emli(*enumList);
      MemberDef *emd;
      for (emli.toFirst();(emd=emli.current());++emli)
      {
        t << memPrefix << "enum = { enum-name = " << emd->name() << ';';
        if (!emd->initializer().isEmpty())
        {
          t << " enum-value = ";
          writeDEFString(t,emd->initializer());
          t << ';';
        }
        t << " };" << endl;
      }
    }
  }

  t << memPrefix << "desc-file = '" << md->getDefFileName() << "';" << endl;
  t << memPrefix << "desc-line = '" << md->getDefLine()     << "';" << endl;
  t << memPrefix << "briefdesc =    <<_EnD_oF_dEf_TeXt_"    << endl
    << md->briefDescription() << endl << "_EnD_oF_dEf_TeXt_;" << endl;
  t << memPrefix << "documentation = <<_EnD_oF_dEf_TeXt_"   << endl
    << md->documentation() << endl << "_EnD_oF_dEf_TeXt_;" << endl;

  //printf("md->getReferencesMembers()=%p\n",md->getReferencesMembers());

  LockingPtr<MemberSDict> mdict = md->getReferencesMembers();
  if (!mdict.isNull())
  {
    MemberSDict::Iterator mdi(*mdict);
    MemberDef *rmd;
    QCString refPrefix = "  " + memPrefix + "ref-";

    for (mdi.toFirst();(rmd=mdi.current());++mdi)
    {
      if (rmd->getStartBodyLine()!=-1 && rmd->getBodyDef())
      {
        t << memPrefix << "referenceto = {" << endl;
        t << refPrefix << "id = '"
          << rmd->getBodyDef()->getOutputFileBase()
          << "_1"   // encoded `:' character (see util.cpp:convertNameToFile)
          << rmd->anchor() << "';" << endl;

        t << refPrefix << "line = '"
          << rmd->getStartBodyLine() << "';" << endl;

        QCString scope = rmd->getScopeString();
        QCString name = rmd->name();
        if (!scope.isEmpty() && scope!=def->name())
        {
          name.prepend(scope+"::");
        }

        t << refPrefix << "name = ";
        writeDEFString(t,name);
        t << ';' << endl << "    };" << endl;
      }
    } /* for (mdi.toFirst...) */
  }
  mdict = md->getReferencedByMembers();
  if (!mdict.isNull())
  {
    MemberSDict::Iterator mdi(*mdict);
    MemberDef *rmd;
    QCString refPrefix = "  " + memPrefix + "ref-";

    for (mdi.toFirst();(rmd=mdi.current());++mdi)
    {
      if (rmd->getStartBodyLine()!=-1 && rmd->getBodyDef())
      {
        t << memPrefix << "referenceby = {" << endl;
        t << refPrefix << "id = '"
          << rmd->getBodyDef()->getOutputFileBase()
          << "_1"   // encoded `:' character (see util.cpp:convertNameToFile)
          << rmd->anchor() << "';" << endl;

        t << refPrefix << "line = '"
          << rmd->getStartBodyLine() << "';" << endl;

        QCString scope = rmd->getScopeString();
        QCString name = rmd->name();
        if (!scope.isEmpty() && scope!=def->name())
        {
          name.prepend(scope+"::");
        }

        t << refPrefix << "name = ";
        writeDEFString(t,name);
        t << ';' << endl << "    };" << endl;
      }
    } /* for (mdi.toFirst...) */
  }

  t << "    }; /* " << Prefix << "-member */" << endl;
}
Example #7
0
    foreach (FunctionModelItem fun, functions) {
        if (done.contains(fun->name()))
            continue;

        // data function
        out << endl;

        QStringList fetchMeType;
        QStringList fetchMeName;

        ArgumentList arguments = fun->arguments();
        for (int i = 0; i < arguments.count(); ++i) {
            QString type = arguments[i]->type().toString();
            type = type.mid(0, type.indexOf(' '));
            QString name = arguments[i]->name();
            if (arguments[i]->type().indirections()) {
                type = "int";
                name = name + "Count";
            }
            fetchMeType << type;
            fetchMeName << name;
        }
        if (fun->type().toString() != "void") {
            QString returnType = fun->type().toString();
            fetchMeType << returnType;
            fetchMeName << fun->name();
        }
        if (fetchMeType.isEmpty()) {
            fetchMeType << "int";
            fetchMeName << "foo";
        }

        QStringList knownTypes;
        knownTypes << "int" << "qreal" << "bool" << "QString" << "QRectF" << "QPointF" << "QPixmap" << "QFont" << "QUrl" << "uint" << "QImage" << "QStringList";
        bool knowAllTypes = true;
        for (int i = 0; i < fetchMeType.count(); ++i) {
            if (!knownTypes.contains(fetchMeType[i])) {
                if (!declared.contains(fetchMeType[i])) {
                    out << "Q_DECLARE_METATYPE(" << fetchMeType[i] << ")" << endl;
                    declared.append(fetchMeType[i]);
                }
                knowAllTypes = false;
            }
        }


        out << QString("void %1::%2_data()\n{").arg(tstClassName).arg(fun->name()) << endl;

        if (!knowAllTypes)
            out << "#if 0" << endl;
        for (int i = 0; i < fetchMeType.count(); ++i)
            out << indent << QString("QTest::addColumn<%1>(\"%2\");").arg(fetchMeType[i]).arg(fetchMeName[i]) << endl;

        bool stubbed = false;
        // fill out the most common cases
        if (fetchMeType.count() == 1
            && fetchMeType[0] == "bool") {
            out << indent << "QTest::newRow(\"true\") << true;" << endl;
            out << indent << "QTest::newRow(\"false\") << false;" << endl;
            stubbed = true;
        }
        if (fetchMeType.count() == 1
            && fetchMeType[0] == "QString") {
            out << indent << "QTest::newRow(\"null\") << QString();" << endl;
            out << indent << "QTest::newRow(\"foo\") << QString(\"foo\");" << endl;
            stubbed = true;
        }
        if (fetchMeType.count() == 1
            && fetchMeType[0] == "int") {
            out << indent << "QTest::newRow(\"0\") << 0;" << endl;
            out << indent << "QTest::newRow(\"-1\") << -1;" << endl;
            stubbed = true;
        }

        if (!stubbed) {
            out << indent << "QTest::newRow(\"null\")";
            for (int i = 0; i < fetchMeType.count(); ++i) {
                out << " << ";
                if (fetchMeType[i] == "int")
                    out << "0";
                else if (fetchMeType[i] == "qreal")
                    out << "0.0";
                else if (fetchMeType[i] == "bool")
                    out << "false";
                else if (fetchMeType[i] == "QString")
                    out << "QString()";
                else
                    out << fetchMeType[i] << "()";
            }
            out << ";" << endl;
        }

        if (!knowAllTypes)
            out << "#endif" << endl;
        out << "}" << endl;

        out << endl;
        out << "// " << convertAccessPolicy(fun->accessPolicy()) << " " << makeFunction(fun) << endl;
        out << QString("void %1::%2()").arg(tstClassName).arg(fun->name()) << endl;
        out << "{" << endl;
        {
            out << "#if 0" << endl;
            for (int i = 0; i < fetchMeType.count(); ++i)
                out << indent << QString("QFETCH(%1, %2);").arg(fetchMeType[i]).arg(fetchMeName[i]) << endl;
            out << endl;
            out << indent << "Sub" << className << " " << shortName << ";" << endl;


            // any possible spies that the class emits
            // ### check spy args
            // ### properties
            out << endl;
            int spies = 0;
            for(int i = 0; i < functions.count(); ++i) {
                FunctionModelItem funt = functions[i];
                if (funt->functionType() == CodeModel::Signal) {
                    ArgumentList arguments = funt->arguments();
                    QStringList args;
                    for (int i = 0; i < arguments.count(); ++i) {
                        args += arguments[i]->type().toString();
                    }

                    out << indent << QString("QSignalSpy spy%1(&%2, SIGNAL(%3(%4)));").arg(spies++).arg(shortName).arg(funt->name()).arg(args.join(", ")) << endl;
                }
            }
            if (spies > 0)
                out << endl;

            bool returnsSomething = (fun->type().toString() != "void");
            out << indent;
            if (returnsSomething)
                out << "QCOMPARE(";
            out << shortName << ".";
            if (fun->accessPolicy() == CodeModel::Protected)
                out << "call_";
            out << fun->name();
            out << "(";
            QStringList args;
            for (int i = 0; i < arguments.count(); ++i)
                args.append(arguments[i]->name());
            out << args.join(", ");
            out << ")";
            if (returnsSomething) {
                out << ", " << fun->name() << ")";
            }
            out << ";" << endl;

            if (spies > 0)
                out << endl;

            spies = 0;
            for(int i = 0; i < functions.count(); ++i) {
                FunctionModelItem funt = functions[i];
                if (funt->functionType() == CodeModel::Signal) {
                    out << indent << QString("QCOMPARE(spy\%1.count(), 0);").arg(spies++) << endl;
                }
            }

            /*
            // any classes that can be used to check
            if (!fun->isConstant()) {
                out << endl;
                out << indent << "// This function isn't const so you should be able to do comparisons on all the const functions." << endl;
                for(int i = 0; i < functions.count(); ++i) {
                    FunctionModelItem funt = functions[i];
                    if (funt->type().toString() != "void")
                        out << indent << "// QCOMPARE(foo." << funt->name() << "(), something);" << endl;
                }
            }
            */
            out << "#endif" << endl;
            out << indent << "QSKIP(\"Test is not implemented.\", SkipAll);" << endl;
        }
        out << "}" << endl;
        done.append(fun->name());
    }
Example #8
0
void outputFile(ClassModelItem clazz, FunctionList functions,
                QList<QPair<QString,QString> > extraFunctions)
{
    // setup
    QString className = clazz->name();
    QString shortName = className.mid(className.lastIndexOf(QRegExp("[A-Z][a-z]*"))).toLower();
    QString tstClassName = "tst_" + className;
    QString indent = "    ";
    QTextStream out(stdout);

    // Includes
    out << endl;
    out << "#include <QtTest/QtTest>" << endl;
    QString classFileName = clazz->fileName().mid(clazz->fileName().indexOf('/'));
    if (classFileName[0] == '/')
        classFileName = classFileName.mid(1);
    out << "#include <" << classFileName << ">" << endl;

    // Generate class definition
    out << endl;
    out << QString("class %1 : public QObject").arg(tstClassName) << endl;
    out << "{" << endl;
    {
        out << indent << "Q_OBJECT" << endl;

        out << endl;
        out << "public slots:" << endl;
        for(int i = 0; i < extraFunctions.count(); ++i) {
            out << indent << QString("void %1();").arg(extraFunctions.at(i).first) << endl;

        }

        out << endl;
        out << "private slots:" << endl;
        out << indent << QString("void %1_data();").arg(className.toLower()) << endl;
        out << indent << QString("void %1();").arg(className.toLower()) << endl;
        out << endl;
        QStringList done;
        foreach (FunctionModelItem fun, functions) {
            if (done.contains(fun->name()))
                continue;
            out << indent << QString("void %1_data();").arg(fun->name()) << endl;
            out << indent << QString("void %1();").arg(fun->name()) << endl;
            done.append(fun->name());
        }
    }
    out << "};" << endl;


    // Generate subclass
    out << endl;
    out << "// Subclass that exposes the protected functions." << endl;
    out << "class Sub" + className + " : public " << className << endl;
    out << "{" << endl;
    {
        out << "public:" << endl;
        foreach (FunctionModelItem fun, functions) {
            // implement protected or virtual functions
            if (fun->accessPolicy() != CodeModel::Protected && !fun->isAbstract())
                continue;

            if (fun->isAbstract())
                out << indent << QString("// %1::%2 is a pure virtual function.").arg(className).arg(fun->name()) << endl;
            out << indent << makeFunction(fun, fun->isAbstract() ? "" : "call_") << endl;

            out << indent << indent << "{ ";
            {
                ArgumentList arguments = fun->arguments();
                if (!fun->isAbstract()) {
                    QStringList args;
                    for (int j = 0; j < arguments.count(); ++j) {
                        QString arg = arguments[j]->name();
                        if (arg.isEmpty())
                            arg = QString("arg%1").arg(j);
                        args += arg;
                    }
                    out << QString("return Sub%1::%2(%3);").arg(className).arg(fun->name()).arg(args.join(", "));
                }
            }
            out << " }" << endl;
            out << endl;
        }
    }
    out << "};" << endl;


    // Generate extra functions
    for(int i = 0; i < extraFunctions.count(); ++i) {
        out << endl;
        out << QString("// %1").arg(extraFunctions.at(i).second) << endl;
        out << QString("void %1::%2()\n{\n}").arg(tstClassName).arg(extraFunctions.at(i).first) << endl;
    }

    QStringList declared;

    // Make the test that calls every function
    out << endl;
    out << QString("void %1::%2_data()\n{\n}\n").arg(tstClassName).arg(className.toLower()) << endl;
    out << QString("void %1::%2()").arg(tstClassName).arg(className.toLower()) << endl;
    out << "{" << endl;
    {
        out << indent << QString("Sub%1 %2;").arg(className).arg(shortName) << endl;
        out << "#if 0" << endl;
        foreach (FunctionModelItem fun, functions) {
            QStringList args;
            for (int i = 0; i < fun->arguments().count(); ++i) {
                QString type= fun->arguments()[i]->type().toString();
                args += makeArg(type);
            }
            QString returnType = makeArg(fun->type().toString());
            out << indent;
            if (returnType != "void")
                out << "QCOMPARE(";
            out << shortName << ".";
            if (fun->accessPolicy() == CodeModel::Protected)
                out << "call_";
            out << fun->name() << "(";
            QString functionArgs = args.join(", ");
            if (functionArgs.endsWith("*"))
                out << "(" << functionArgs << ")0";
            else if (functionArgs == "int")
                out << "0";
            else if (functionArgs == "QString const&")
                out << "QString()";
            else
                out << functionArgs;
            out << ")";
            if (returnType != "void") {
                out << ", ";
                if (returnType == "int")
                    out << "0";
                else if (returnType == "int")
                    out << "0";
                else
                    out << returnType;
                out << ")";
            }
            out << ";" << endl;
        }
        out << "#endif" << endl;
        out << indent << "QSKIP(\"Test is not implemented.\", SkipAll);" << endl;
    }
Example #9
0
bool GroupDef::insertMember(MemberDef *md,bool docOnly)
{
  if (md->isHidden()) return FALSE;
  updateLanguage(md);
  //printf("GroupDef(%s)::insertMember(%s)\n", title.data(), md->name().data());
  MemberNameInfo *mni=0;
  if ((mni=(*allMemberNameInfoSDict)[md->name()]))
  { // member with this name already found
    MemberNameInfoIterator srcMnii(*mni); 
    MemberInfo *srcMi;
    for ( ; (srcMi=srcMnii.current()) ; ++srcMnii )
    {
      MemberDef *srcMd = srcMi->memberDef;
      if (srcMd==md) return FALSE; // already added before!

      bool sameScope = srcMd->getOuterScope()==md->getOuterScope() || // same class or namespace
          // both inside a file => definition and declaration do not have to be in the same file
           (srcMd->getOuterScope()->definitionType()==Definition::TypeFile &&
               md->getOuterScope()->definitionType()==Definition::TypeFile); 

      ArgumentList *srcMdAl  = srcMd->argumentList();
      ArgumentList *mdAl     = md->argumentList();
      ArgumentList *tSrcMdAl = srcMd->templateArguments();
      ArgumentList *tMdAl    = md->templateArguments();
      
      if (srcMd->isFunction() && md->isFunction() && // both are a function
          ((tSrcMdAl==0 && tMdAl==0) || 
           (tSrcMdAl!=0 && tMdAl!=0 && tSrcMdAl->count()==tMdAl->count())
          ) &&       // same number of template arguments
          matchArguments2(srcMd->getOuterScope(),srcMd->getFileDef(),srcMdAl,
                          md->getOuterScope(),md->getFileDef(),mdAl,
                          TRUE
                         ) && // matching parameters
          sameScope // both are found in the same scope
         )
      {
        if (srcMd->getGroupAlias()==0) 
        {
          md->setGroupAlias(srcMd); 
        }
        else if (md!=srcMd->getGroupAlias())
        {
          md->setGroupAlias(srcMd->getGroupAlias()); 
        }
        return FALSE; // member is the same as one that is already added
      }
    }
    mni->append(new MemberInfo(md,md->protection(),md->virtualness(),FALSE));
  }
  else
  {
    mni = new MemberNameInfo(md->name());
    mni->append(new MemberInfo(md,md->protection(),md->virtualness(),FALSE));
    allMemberNameInfoSDict->append(mni->memberName(),mni);
  }
  //printf("Added member!\n");
  allMemberList->append(md); 
  switch(md->memberType())
  {
    case MemberType_Variable:     
      if (!docOnly)
      {
        addMemberToList(MemberListType_decVarMembers,md);
      }
      addMemberToList(MemberListType_docVarMembers,md);
      break;
    case MemberType_Function: 
      if (!docOnly)
      {
        addMemberToList(MemberListType_decFuncMembers,md);
      }
      addMemberToList(MemberListType_docFuncMembers,md);
      break;
    case MemberType_Typedef:      
      if (!docOnly)
      {
        addMemberToList(MemberListType_decTypedefMembers,md);
      }
      addMemberToList(MemberListType_docTypedefMembers,md);
      break;
    case MemberType_Enumeration:  
      if (!docOnly)
      {
        addMemberToList(MemberListType_decEnumMembers,md);
      }
      addMemberToList(MemberListType_docEnumMembers,md);
      break;
    case MemberType_EnumValue:    
      if (!docOnly)
      {
        addMemberToList(MemberListType_decEnumValMembers,md);
      }
      addMemberToList(MemberListType_docEnumValMembers,md);
      break;
    case MemberType_Define:       
      if (!docOnly)
      {
        addMemberToList(MemberListType_decDefineMembers,md);
      }
      addMemberToList(MemberListType_docDefineMembers,md);
      break;
    case MemberType_Signal:       
      if (!docOnly)
      {
        addMemberToList(MemberListType_decSignalMembers,md);
      }
      addMemberToList(MemberListType_docSignalMembers,md);
      break;
    case MemberType_Slot:       
      if (md->protection()==Public)
      {
        if (!docOnly)
        {
          addMemberToList(MemberListType_decPubSlotMembers,md);
        }
        addMemberToList(MemberListType_docPubSlotMembers,md);
      }
      else if (md->protection()==Protected)
      {
        if (!docOnly)
        {
          addMemberToList(MemberListType_decProSlotMembers,md);
        }
        addMemberToList(MemberListType_docProSlotMembers,md);
      }
      else
      {
        if (!docOnly)
        {
          addMemberToList(MemberListType_decPriSlotMembers,md);
        }
        addMemberToList(MemberListType_docPriSlotMembers,md);
      }
      break;
    case MemberType_Event:       
      if (!docOnly)
      {
        addMemberToList(MemberListType_decEventMembers,md);
      }
      addMemberToList(MemberListType_docEventMembers,md);
      break;
    case MemberType_Property:       
      if (!docOnly)
      {
        addMemberToList(MemberListType_decPropMembers,md);
      }
      addMemberToList(MemberListType_docPropMembers,md);
      break;
    case MemberType_Friend:       
      if (!docOnly)
      {
        addMemberToList(MemberListType_decFriendMembers,md);
      }
      addMemberToList(MemberListType_docFriendMembers,md);
      break;
    default:
      err("GroupDef::insertMembers(): "
           "member `%s' (typeid=%d) with scope `%s' inserted in group scope `%s'!\n",
           md->name().data(),md->memberType(),
           md->getClassDef() ? md->getClassDef()->name().data() : "",
           name().data());
  }
  return TRUE;
}
Example #10
0
static void generateSqlite3ForMember(sqlite3*db,MemberDef *md,Definition *def)
{
  // + declaration/definition arg lists
  // + reimplements
  // + reimplementedBy
  // + exceptions
  // + const/volatile specifiers
  // - examples
  // + source definition
  // + source references
  // + source referenced by
  // - body code
  // + template arguments
  //     (templateArguments(), definitionTemplateParameterLists())
  // - call graph

  // enum values are written as part of the enum
  if (md->memberType()==MemberType_EnumValue) return;
  if (md->isHidden()) return;
  //if (md->name().at(0)=='@') return; // anonymous member

  // group members are only visible in their group
  //if (def->definitionType()!=Definition::TypeGroup && md->getGroupDef()) return;
  QCString memType;
  // memberdef
  bindTextParameter(i_s_memberdef,":refid",md->anchor().data(),FALSE);
  bindIntParameter(i_s_memberdef,":kind",md->memberType());
  bindIntParameter(i_s_memberdef,":prot",md->protection());
  bindIntParameter(i_s_memberdef,":static",md->isStatic());

  bool isFunc=FALSE;
  switch (md->memberType())
  {
    case MemberType_Function: // fall through
    case MemberType_Signal:   // fall through
    case MemberType_Friend:   // fall through
    case MemberType_DCOP:     // fall through
    case MemberType_Slot:
      isFunc=TRUE;
      break;
    default:
      break;
  }
  if (isFunc)
  {
    ArgumentList *al = md->argumentList();
    if (al!=0 && al->constSpecifier)
    {
      bindIntParameter(i_s_memberdef,":const",al->constSpecifier);
    }

    bindIntParameter(i_s_memberdef,":explicit",md->isExplicit());
    bindIntParameter(i_s_memberdef,":inline",md->isInline());
    bindIntParameter(i_s_memberdef,":final",md->isFinal());
    bindIntParameter(i_s_memberdef,":sealed",md->isSealed());
    bindIntParameter(i_s_memberdef,":new",md->isNew());
    bindIntParameter(i_s_memberdef,":optional",md->isOptional());
    bindIntParameter(i_s_memberdef,":required",md->isRequired());
    bindIntParameter(i_s_memberdef,":virt",md->virtualness());
  }
  // place in the arguments and linkify the arguments

  if (md->memberType() == MemberType_Variable)
  {
    bindIntParameter(i_s_memberdef,":mutable",md->isMutable());
    bindIntParameter(i_s_memberdef,":initonly",md->isInitonly());
  }
  else if (md->memberType() == MemberType_Property)
  {
    bindIntParameter(i_s_memberdef,":readable",md->isReadable());
    bindIntParameter(i_s_memberdef,":writable",md->isWritable());
    bindIntParameter(i_s_memberdef,":gettable",md->isGettable());
    bindIntParameter(i_s_memberdef,":settable",md->isSettable());

    if (md->isAssign() || md->isCopy() || md->isRetain())
    {
      int accessor = md->isAssign() ? md->isAssign() :
          (md->isCopy() ? md->isCopy() : md->isRetain()) ;

      bindIntParameter(i_s_memberdef,":accessor",accessor);
    }
  }
  else if (md->memberType() == MemberType_Event)
  {
    bindIntParameter(i_s_memberdef,":addable",md->isAddable());
    bindIntParameter(i_s_memberdef,":removable",md->isRemovable());
    bindIntParameter(i_s_memberdef,":raisable",md->isRaisable());
  }

  // + declaration/definition arg lists
  if (md->memberType()!=MemberType_Define &&
      md->memberType()!=MemberType_Enumeration
     )
  {
    QCString typeStr = md->typeString();
    stripQualifiers(typeStr);
    StringList l;
    linkifyText(TextGeneratorSqlite3Impl(l),def,md->getBodyDef(),md,typeStr);
    if (typeStr.data())
    {
      bindTextParameter(i_s_memberdef,":type",typeStr.data(),FALSE);
    }

    if (md->definition())
    {
      bindTextParameter(i_s_memberdef,":definition",md->definition());
    }

    if (md->argsString())
    {
      bindTextParameter(i_s_memberdef,":argsstring",md->argsString());
    }
  }

  bindTextParameter(i_s_memberdef,":name",md->name());

  if (md->memberType() == MemberType_Property)
  {
    if (md->isReadable())
    {
      DBG_CTX(("<read>\n"));
    }
    if (md->isWritable())
    {
      DBG_CTX(("<write>\n"));
    }
  }
  if (isFunc) //function
  {
    ArgumentList *declAl = md->declArgumentList();
    ArgumentList *defAl = md->argumentList();
    if (declAl!=0 && declAl->count()>0)
    {
      ArgumentListIterator declAli(*declAl);
      ArgumentListIterator defAli(*defAl);
      Argument *a;
      for (declAli.toFirst();(a=declAli.current());++declAli)
      {
        Argument *defArg = defAli.current();
        DBG_CTX(("<param>\n"));
        if (!a->attrib.isEmpty())
        {
          DBG_CTX(("<attributes>:%s\n",a->attrib.data()));
        }
        if (!a->type.isEmpty())
        {
          StringList l;
          linkifyText(TextGeneratorSqlite3Impl(l),def,md->getBodyDef(),md,a->type);

          StringListIterator li(l);
          QCString *s;
          while ((s=li.current()))
          {
            insertMemberReference(db,md->anchor().data(),s->data(),def->getDefFileName().data(),md->getDefLine(),1);
            ++li;
          }
        }
        if (!a->name.isEmpty())
        {
          DBG_CTX(("<declname>%s\n",a->name.data()));
        }
        if (defArg && !defArg->name.isEmpty() && defArg->name!=a->name)
        {
          DBG_CTX(("<defname>%s\n",defArg->name.data()));
        }
        if (!a->array.isEmpty())
        {
          DBG_CTX(("<array>%s",a->array.data()));
        }
        if (!a->defval.isEmpty())
        {
          StringList l;
          linkifyText(TextGeneratorSqlite3Impl(l),def,md->getBodyDef(),md,a->defval);
        }
        if (defArg) ++defAli;
      }
    }
  }
  else if (md->memberType()==MemberType_Define &&
          md->argsString()) // define
  {
    if (md->argumentList()->count()==0) // special case for "foo()" to
                                        // disguish it from "foo".
    {
      DBG_CTX(("no params\n"));
    }
    else
    {
      ArgumentListIterator ali(*md->argumentList());
      Argument *a;
      for (ali.toFirst();(a=ali.current());++ali)
      {
        DBG_CTX(("<param><defname>%s\n",a->type.data()));
      }
    }
  }


  // Extract references from initializer
  // avoid that extremely large tables are written to the output.
  // todo: it's better to adhere to MAX_INITIALIZER_LINES.
  // drm_mod_register_buffer,
  if (!md->initializer().isEmpty() && md->initializer().length()<2000)
  {
    bindTextParameter(i_s_memberdef,":initializer",md->initializer().data());

    StringList l;
    linkifyText(TextGeneratorSqlite3Impl(l),def,md->getBodyDef(),md,md->initializer());
    StringListIterator li(l);
    QCString *s;
    while ((s=li.current()))
    {
      if (md->getBodyDef())
      {
        DBG_CTX(("initializer:%s %s %s %d\n",
              md->anchor().data(),
              s->data(),
              md->getBodyDef()->getDefFileName().data(),
              md->getStartBodyLine()));
        insertMemberReference(db,md->anchor().data(),s->data(),md->getBodyDef()->getDefFileName().data(),md->getStartBodyLine(),1);
      }
      ++li;
    }
  }

  if ( md->getScopeString() )
  {
    bindTextParameter(i_s_memberdef,":scope",md->getScopeString().data(),FALSE);
  }

  // File location
  if (md->getDefLine() != -1)
  {
    int id_file = insertFile(db,md->getDefFileName());
    if (id_file!=-1)
    {
      bindIntParameter(i_s_memberdef,":id_file",id_file);
      bindIntParameter(i_s_memberdef,":line",md->getDefLine());
      bindIntParameter(i_s_memberdef,":column",md->getDefColumn());

      if (md->getStartBodyLine()!=-1)
      {
        int id_bfile = insertFile(db,md->getBodyDef()->absFilePath());
        if (id_bfile == -1)
        {
            sqlite3_clear_bindings(i_s_memberdef);
            return;
        }

        bindIntParameter(i_s_memberdef,":id_ibfile",id_bfile);
        bindIntParameter(i_s_memberdef,":bline",md->getStartBodyLine());

        // XXX implement getStartBodyColumn
        bindIntParameter(i_s_memberdef,":bcolumn",1);
      }
    }
  }

  if (-1==step(db,i_s_memberdef))
  {
      sqlite3_clear_bindings(i_s_memberdef);
  }
  /*int id_src =*/ sqlite3_last_insert_rowid(db);

  // + source references
  // The cross-references in initializers only work when both the src and dst
  // are defined.
  MemberSDict *mdict = md->getReferencesMembers();
  if (mdict!=0)
  {
    MemberSDict::IteratorDict mdi(*mdict);
    MemberDef *rmd;
    for (mdi.toFirst();(rmd=mdi.current());++mdi)
    {
      insertMemberReference(db,md,rmd,mdi.currentKey());
    }
  }

  // + source referenced by
  mdict = md->getReferencedByMembers();
  if (mdict!=0)
  {
    MemberSDict::IteratorDict mdi(*mdict);
    MemberDef *rmd;
    for (mdi.toFirst();(rmd=mdi.current());++mdi)
    {
      insertMemberReference(db,rmd,md,mdi.currentKey());
    }
  }
}